ugl(4): self->dv_unit fix (Re: cdce(4): sc->cdce_unit)

2013-12-05 Thread SASANO Takayoshi
Hello,

if_ugl.c has similar issue, and I think this should be fixed.
ok to commit?


SASANO Takayoshi 

Index: if_ugl.c
===
RCS file: /cvs/src/sys/dev/usb/if_ugl.c,v
retrieving revision 1.2
diff -u -p -r1.2 if_ugl.c
--- if_ugl.c3 Dec 2013 21:06:59 -   1.2
+++ if_ugl.c5 Dec 2013 20:06:50 -
@@ -152,7 +152,6 @@ struct ugl_softc {
 
uByte   sc_ibuf[UGL_INTR_PKTLEN];
 
-   int sc_unit;
u_int   sc_rx_errs;
struct timeval  sc_rx_notice;
u_int   sc_intr_errs;
@@ -246,7 +245,6 @@ ugl_attach(struct device *parent, struct
return;
}
 
-   sc->sc_unit = self->dv_unit;
sc->sc_udev = dev;
sc->sc_product = uaa->product;
sc->sc_vendor = uaa->vendor;
@@ -292,7 +290,7 @@ ugl_attach(struct device *parent, struct
macaddr_hi = htons(0x2acb);
bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
-   sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_unit);
+   sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.dv_unit);
 
printf("%s: address %s\n",
sc->sc_dev.dv_xname, ether_sprintf(sc->sc_arpcom.ac_enaddr));



Re: cdce(4): sc->cdce_unit

2013-12-03 Thread Theo de Raadt
> I read sys/dev/usb/if_cdce.c and found sc->cdce_unit is refered but
> none initializes. Maybe the fix is required like this :-
> 
[...]
> + sc->cdce_unit = self->dv_unit;

I really dislike variables that serve no purpose.  The same thing is
available straight out of struct device.  I've also fixed if_cdcef
(and checked that it compiles on the zaurus where it is used).

Index: if_cdce.c
===
RCS file: /cvs/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.57
diff -u -p -u -r1.57 if_cdce.c
--- if_cdce.c   15 Nov 2013 10:17:39 -  1.57
+++ if_cdce.c   3 Dec 2013 21:08:23 -
@@ -324,7 +324,7 @@ found:
getmicrotime(&now);
macaddr_lo = htonl(now.tv_usec << 8);
bcopy(&macaddr_lo, &sc->cdce_arpcom.ac_enaddr[2], 
sizeof(u_int32_t));
-   sc->cdce_arpcom.ac_enaddr[5] = (u_int8_t)(sc->cdce_unit);
+   sc->cdce_arpcom.ac_enaddr[5] = (u_int8_t)(sc->cdce_dev.dv_unit);
} else {
for (i = 0; i < ETHER_ADDR_LEN * 2; i++) {
int c = UGETW(eaddr_str.bString[i]);
Index: if_cdcef.c
===
RCS file: /cvs/src/sys/dev/usb/if_cdcef.c,v
retrieving revision 1.31
diff -u -p -u -r1.31 if_cdcef.c
--- if_cdcef.c  11 Nov 2013 10:09:40 -  1.31
+++ if_cdcef.c  3 Dec 2013 21:13:54 -
@@ -79,7 +79,6 @@ struct cdcef_softc {
 #define GET_IFP(sc) (&(sc)->sc_arpcom.ac_if)
 
int sc_rxeof_errors;
-   int sc_unit;
int sc_listening;
 };
 
@@ -243,7 +242,7 @@ cdcef_attach(struct device *parent, stru
macaddr_hi = htons(0x2acb);
bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
-   sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_unit);
+   sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.bdev.dv_unit);
 
printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
 
Index: if_cdcereg.h
===
RCS file: /cvs/src/sys/dev/usb/if_cdcereg.h,v
retrieving revision 1.5
diff -u -p -u -r1.5 if_cdcereg.h
--- if_cdcereg.h11 Nov 2013 12:38:16 -  1.5
+++ if_cdcereg.h3 Dec 2013 21:06:22 -
@@ -80,7 +80,6 @@ struct cdce_softc {
struct usbd_pipe*cdce_bulkin_pipe;
int  cdce_bulkout_no;
struct usbd_pipe*cdce_bulkout_pipe;
-   int  cdce_unit;
struct cdce_cdatacdce_cdata;
int  cdce_rxeof_errors;
u_int16_tcdce_flags;



cdce(4): sc->cdce_unit

2013-12-03 Thread SASANO Takayoshi
Hello,

I read sys/dev/usb/if_cdce.c and found sc->cdce_unit is refered but
none initializes. Maybe the fix is required like this :-

Index: if_cdce.c
===
RCS file: /cvs/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.57
diff -u -p -r1.57 if_cdce.c
--- if_cdce.c   15 Nov 2013 10:17:39 -  1.57
+++ if_cdce.c   3 Dec 2013 20:36:44 -
@@ -177,6 +177,7 @@ cdce_attach(struct device *parent, struc
int  ctl_ifcno = -1;
int  data_ifcno = -1;
 
+   sc->cdce_unit = self->dv_unit;
sc->cdce_udev = uaa->device;
sc->cdce_ctl_iface = uaa->iface;
id = usbd_get_interface_descriptor(sc->cdce_ctl_iface);

And, sc->sc_unit of sys/dev/usb/if_cdcef.c seems to have save problem.

Regards,
-- 
SASANO Takayoshi