Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci use copyout instead of suword.



details:   https://anonhg.NetBSD.org/src/rev/d2e98d8bf846
branches:  trunk
changeset: 341734:d2e98d8bf846
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Nov 20 14:56:56 2015 +0000

description:
use copyout instead of suword.

diffstat:

 sys/dev/pci/if_ipw.c |  35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)

diffs (79 lines):

diff -r 4510357e479a -r d2e98d8bf846 sys/dev/pci/if_ipw.c
--- a/sys/dev/pci/if_ipw.c      Fri Nov 20 11:58:00 2015 +0000
+++ b/sys/dev/pci/if_ipw.c      Fri Nov 20 14:56:56 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ipw.c,v 1.58 2015/01/07 07:05:48 ozaki-r Exp $      */
+/*     $NetBSD: if_ipw.c,v 1.59 2015/11/20 14:56:56 christos Exp $     */
 /*     FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp         */
 
 /*-
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.58 2015/01/07 07:05:48 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.59 2015/11/20 14:56:56 christos Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -1541,7 +1541,8 @@
 static int
 ipw_get_table1(struct ipw_softc *sc, uint32_t *tbl)
 {
-       uint32_t addr, size, i;
+       uint32_t addr, size, data, i;
+       int error;
 
        if (!(sc->flags & IPW_FLAG_FW_INITED))
                return ENOTTY;
@@ -1549,13 +1550,14 @@
        CSR_WRITE_4(sc, IPW_CSR_AUTOINC_ADDR, sc->table1_base);
 
        size = CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA);
-       if (suword(tbl, size) != 0)
-               return EFAULT;
+       if ((error = copyout(&size, tbl, sizeof(size))) != 0)
+               return error;
 
        for (i = 1, ++tbl; i < size; i++, tbl++) {
                addr = CSR_READ_4(sc, IPW_CSR_AUTOINC_DATA);
-               if (suword(tbl, MEM_READ_4(sc, addr)) != 0)
-                       return EFAULT;
+               data = MEM_READ_4(sc, addr);
+               if ((error = copyout(&data, tbl, sizeof(data))) != 0)
+                       return error;
        }
        return 0;
 }
@@ -1563,23 +1565,20 @@
 static int
 ipw_get_radio(struct ipw_softc *sc, int *ret)
 {
-       uint32_t addr;
+       uint32_t addr, data;
 
        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) {
-               suword(ret, -1);
-               return 0;
-       }
+       if ((MEM_READ_4(sc, addr + 32) >> 24) & 1)
+               data = -1;
+       else if (CSR_READ_4(sc, IPW_CSR_IO) & IPW_IO_RADIO_DISABLED)
+               data = 0;
+       else
+               data = 1;
 
-       if (CSR_READ_4(sc, IPW_CSR_IO) & IPW_IO_RADIO_DISABLED)
-               suword(ret, 0);
-       else
-               suword(ret, 1);
-
-       return 0;
+       return copyout(&data, ret, sizeof(data));
 }
 
 static int



Home | Main Index | Thread Index | Old Index