summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2004-10-27 21:16:46 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2004-10-27 21:16:46 +0000
commit2d7e55def81bd27b8cec81f265d2716dad163699 (patch)
treeed44ee9bf7f411e29ef86cc403cb5f91e7a734d3 /sys/dev
parent11a82d3003638a5920ad63bc8b514c2fbf9af84e (diff)
Import ipw_get_table() and ipw_get_radio() functions from iwi.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_ipw.c34
-rw-r--r--sys/dev/pci/if_ipwreg.h3
2 files changed, 8 insertions, 29 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c
index b392ffdea04..495c0fa7fab 100644
--- a/sys/dev/pci/if_ipw.c
+++ b/sys/dev/pci/if_ipw.c
@@ -1,4 +1,4 @@
-/* $Id: if_ipw.c,v 1.6 2004/10/27 21:15:17 damien Exp $ */
+/* $Id: if_ipw.c,v 1.7 2004/10/27 21:16:45 damien Exp $ */
/*-
* Copyright (c) 2004
@@ -874,7 +874,7 @@ ipw_watchdog(struct ifnet *ifp)
int
ipw_get_table1(struct ipw_softc *sc, u_int32_t *tbl)
{
- u_int32_t addr, data, size, i;
+ u_int32_t i, size, buf[256];
if (!(sc->flags & IPW_FLAG_FW_INITED))
return ENOTTY;
@@ -882,42 +882,22 @@ ipw_get_table1(struct ipw_softc *sc, u_int32_t *tbl)
CSR_WRITE_4(sc, IPW_CSR_AUTOINC_ADDR, sc->table1_base);
size = CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA);
- if (copyout(&size, tbl, sizeof size) != 0)
- return EFAULT;
+ for (i = 1; i < size; i++)
+ buf[i] = MEM_READ_4(sc, CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA));
- for (i = 1, ++tbl; i < size; i++, tbl++) {
- addr = CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA);
- data = MEM_READ_4(sc, addr);
- if (copyout(&data, tbl, sizeof data) != 0)
- return EFAULT;
- }
- return 0;
+ return copyout(buf, tbl, size * sizeof (u_int32_t));
}
int
ipw_get_radio(struct ipw_softc *sc, int *ret)
{
- u_int32_t addr;
int val;
if (!(sc->flags & IPW_FLAG_FW_INITED))
return ENOTTY;
- addr = ipw_read_table1(sc, IPW_INFO_EEPROM_ADDRESS);
- if ((MEM_READ_4(sc, addr + 32) >> 24) & 1) {
- val = -1;
- copyout(&val, ret, sizeof val);
- return 0;
- }
-
- if (CSR_READ_4(sc, IPW_CSR_IO) & IPW_IO_RADIO_DISABLED)
- val = 0;
- else
- val = 1;
-
- copyout(&val, ret, sizeof val);
-
- return 0;
+ val = (CSR_READ_4(sc, IPW_CSR_IO) & IPW_IO_RADIO_DISABLED) ? 0 : 1;
+ return copyout(&val, ret, sizeof val);
}
int
diff --git a/sys/dev/pci/if_ipwreg.h b/sys/dev/pci/if_ipwreg.h
index 8f08f0fb337..e1aff17964c 100644
--- a/sys/dev/pci/if_ipwreg.h
+++ b/sys/dev/pci/if_ipwreg.h
@@ -1,4 +1,4 @@
-/* $Id: if_ipwreg.h,v 1.2 2004/10/27 21:10:22 damien Exp $ */
+/* $Id: if_ipwreg.h,v 1.3 2004/10/27 21:16:45 damien Exp $ */
/*-
* Copyright (c) 2004
@@ -100,7 +100,6 @@
#define IPW_INFO_CARD_DISABLED 628
#define IPW_INFO_CURRENT_CHANNEL 756
#define IPW_INFO_CURRENT_TX_RATE 768
-#define IPW_INFO_EEPROM_ADDRESS 816
/* table2 offsets */
#define IPW_INFO_ADAPTER_MAC 8