tech-net archive

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

[PATCH 2/2] Additions to zyd(4)



Hi.

In addition to the changes mentioned in the previous mail, this will replace
the repeated use of

#define N(a)   (sizeof (a) / sizeof ((a)[0]))

with __arraycount from <sys/cdefs.h>.

Regards,

Jukka.


Index: src/sys/dev/usb/if_zyd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_zyd.c,v
retrieving revision 1.14
diff -u -p -r1.14 if_zyd.c
--- src/sys/dev/usb/if_zyd.c    21 Sep 2008 09:38:27 -0000      1.14
+++ src/sys/dev/usb/if_zyd.c    18 Aug 2009 10:54:05 -0000
@@ -127,6 +127,7 @@ static const struct zyd_type {
        ZYD_ZD1211B_DEV(BELKIN,         F5D7050C),
        ZYD_ZD1211B_DEV(BELKIN,         ZD1211B),
        ZYD_ZD1211B_DEV(CISCOLINKSYS,   WUSBF54G),
+       ZYD_ZD1211B_DEV(CYBERTAN,       ZD1211B),
        ZYD_ZD1211B_DEV(FIBERLINE,      WL430U),
        ZYD_ZD1211B_DEV(MELCO,          KG54L),
        ZYD_ZD1211B_DEV(PHILIPS,        SNU5600),
@@ -939,26 +940,24 @@ zyd_unlock_phy(struct zyd_softc *sc)
 Static int
 zyd_rfmd_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_RFMD_PHY;
        static const uint32_t rfini[] = ZYD_RFMD_RF;
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
        }
 
        /* init RFMD radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
        return 0;
-#undef N
 }
 
 Static int
@@ -992,51 +991,55 @@ zyd_rfmd_set_channel(struct zyd_rf *rf, 
 Static int
 zyd_al2230_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY;
+       static const struct zyd_phy_pair phy2230s[] = ZYD_AL2230S_PHY_INIT;
        static const uint32_t rfini[] = ZYD_AL2230_RF;
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
        }
-
+       if (sc->rf_rev == ZYD_RF_AL2230S) {
+               for (i = 0; i < __arraycount(phy2230s); i++) {
+                       error = zyd_write16(sc, phy2230s[i].reg,
+                           phy2230s[i].val);
+                       if (error != 0)
+                               return error;
+               }
+       }
        /* init AL2230 radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
        return 0;
-#undef N
 }
 
 Static int
 zyd_al2230_init_b(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY_B;
        static const uint32_t rfini[] = ZYD_AL2230_RF_B;
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
        }
 
        /* init AL2230 radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
        return 0;
-#undef N
 }
 
 Static int
@@ -1075,7 +1078,6 @@ zyd_al2230_set_channel(struct zyd_rf *rf
 Static int
 zyd_al7230B_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini_1[] = ZYD_AL7230B_PHY_1;
        static const struct zyd_phy_pair phyini_2[] = ZYD_AL7230B_PHY_2;
@@ -1087,36 +1089,35 @@ zyd_al7230B_init(struct zyd_rf *rf)
        /* for AL7230B, PHY and RF need to be initialized in "phases" */
 
        /* init RF-dependent PHY registers, part one */
-       for (i = 0; i < N(phyini_1); i++) {
+       for (i = 0; i < __arraycount(phyini_1); i++) {
                error = zyd_write16(sc, phyini_1[i].reg, phyini_1[i].val);
                if (error != 0)
                        return error;
        }
        /* init AL7230B radio, part one */
-       for (i = 0; i < N(rfini_1); i++) {
+       for (i = 0; i < __arraycount(rfini_1); i++) {
                if ((error = zyd_rfwrite(sc, rfini_1[i])) != 0)
                        return error;
        }
        /* init RF-dependent PHY registers, part two */
-       for (i = 0; i < N(phyini_2); i++) {
+       for (i = 0; i < __arraycount(phyini_2); i++) {
                error = zyd_write16(sc, phyini_2[i].reg, phyini_2[i].val);
                if (error != 0)
                        return error;
        }
        /* init AL7230B radio, part two */
-       for (i = 0; i < N(rfini_2); i++) {
+       for (i = 0; i < __arraycount(rfini_2); i++) {
                if ((error = zyd_rfwrite(sc, rfini_2[i])) != 0)
                        return error;
        }
        /* init RF-dependent PHY registers, part three */
-       for (i = 0; i < N(phyini_3); i++) {
+       for (i = 0; i < __arraycount(phyini_3); i++) {
                error = zyd_write16(sc, phyini_3[i].reg, phyini_3[i].val);
                if (error != 0)
                        return error;
        }
 
        return 0;
-#undef N
 }
 
 Static int
@@ -1133,7 +1134,6 @@ zyd_al7230B_switch_radio(struct zyd_rf *
 Static int
 zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct {
                uint32_t        r1, r2;
@@ -1144,7 +1144,7 @@ zyd_al7230B_set_channel(struct zyd_rf *r
        (void)zyd_write16(sc, ZYD_CR240, 0x57);
        (void)zyd_write16(sc, ZYD_CR251, 0x2f);
 
-       for (i = 0; i < N(rfsc); i++) {
+       for (i = 0; i < __arraycount(rfsc); i++) {
                if ((error = zyd_rfwrite(sc, rfsc[i])) != 0)
                        return error;
        }
@@ -1164,7 +1164,6 @@ zyd_al7230B_set_channel(struct zyd_rf *r
        (void)zyd_write16(sc, ZYD_CR240, 0x08);
 
        return 0;
-#undef N
 }
 
 /*
@@ -1173,7 +1172,6 @@ zyd_al7230B_set_channel(struct zyd_rf *r
 Static int
 zyd_al2210_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_AL2210_PHY;
        static const uint32_t rfini[] = ZYD_AL2210_RF;
@@ -1183,13 +1181,13 @@ zyd_al2210_init(struct zyd_rf *rf)
        (void)zyd_write32(sc, ZYD_CR18, 2);
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
        }
        /* init AL2210 radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
@@ -1203,7 +1201,6 @@ zyd_al2210_init(struct zyd_rf *rf)
        (void)zyd_write32(sc, ZYD_CR18, 3);
 
        return 0;
-#undef N
 }
 
 Static int
@@ -1245,25 +1242,23 @@ zyd_al2210_set_channel(struct zyd_rf *rf
 Static int
 zyd_gct_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_GCT_PHY;
        static const uint32_t rfini[] = ZYD_GCT_RF;
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
        }
        /* init cgt radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
        return 0;
-#undef N
 }
 
 Static int
@@ -1293,7 +1288,6 @@ zyd_gct_set_channel(struct zyd_rf *rf, u
 Static int
 zyd_maxim_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_MAXIM_PHY;
        static const uint32_t rfini[] = ZYD_MAXIM_RF;
@@ -1301,7 +1295,7 @@ zyd_maxim_init(struct zyd_rf *rf)
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
@@ -1310,7 +1304,7 @@ zyd_maxim_init(struct zyd_rf *rf)
        (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4));
 
        /* init maxim radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
@@ -1318,7 +1312,6 @@ zyd_maxim_init(struct zyd_rf *rf)
        (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4));
 
        return 0;
-#undef N
 }
 
 Static int
@@ -1332,7 +1325,6 @@ zyd_maxim_switch_radio(struct zyd_rf *rf
 Static int
 zyd_maxim_set_channel(struct zyd_rf *rf, uint8_t chan)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_MAXIM_PHY;
        static const uint32_t rfini[] = ZYD_MAXIM_RF;
@@ -1348,7 +1340,7 @@ zyd_maxim_set_channel(struct zyd_rf *rf,
         */
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
@@ -1361,7 +1353,7 @@ zyd_maxim_set_channel(struct zyd_rf *rf,
        (void)zyd_rfwrite(sc, rfprog[chan - 1].r2);
 
        /* init maxim radio - skipping the two first values */
-       for (i = 2; i < N(rfini); i++) {
+       for (i = 2; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
@@ -1369,7 +1361,6 @@ zyd_maxim_set_channel(struct zyd_rf *rf,
        (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4));
 
        return 0;
-#undef N
 }
 
 /*
@@ -1378,7 +1369,6 @@ zyd_maxim_set_channel(struct zyd_rf *rf,
 Static int
 zyd_maxim2_init(struct zyd_rf *rf)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY;
        static const uint32_t rfini[] = ZYD_MAXIM2_RF;
@@ -1386,7 +1376,7 @@ zyd_maxim2_init(struct zyd_rf *rf)
        int i, error;
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
@@ -1395,7 +1385,7 @@ zyd_maxim2_init(struct zyd_rf *rf)
        (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4));
 
        /* init maxim2 radio */
-       for (i = 0; i < N(rfini); i++) {
+       for (i = 0; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
@@ -1403,7 +1393,6 @@ zyd_maxim2_init(struct zyd_rf *rf)
        (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4));
 
        return 0;
-#undef N
 }
 
 Static int
@@ -1417,7 +1406,6 @@ zyd_maxim2_switch_radio(struct zyd_rf *r
 Static int
 zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan)
 {
-#define N(a)   (sizeof (a) / sizeof ((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY;
        static const uint32_t rfini[] = ZYD_MAXIM2_RF;
@@ -1433,7 +1421,7 @@ zyd_maxim2_set_channel(struct zyd_rf *rf
         */
 
        /* init RF-dependent PHY registers */
-       for (i = 0; i < N(phyini); i++) {
+       for (i = 0; i < __arraycount(phyini); i++) {
                error = zyd_write16(sc, phyini[i].reg, phyini[i].val);
                if (error != 0)
                        return error;
@@ -1446,7 +1434,7 @@ zyd_maxim2_set_channel(struct zyd_rf *rf
        (void)zyd_rfwrite(sc, rfprog[chan - 1].r2);
 
        /* init maxim2 radio - skipping the two first values */
-       for (i = 2; i < N(rfini); i++) {
+       for (i = 2; i < __arraycount(rfini); i++) {
                if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
                        return error;
        }
@@ -1454,7 +1442,6 @@ zyd_maxim2_set_channel(struct zyd_rf *rf
        (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4));
 
        return 0;
-#undef N
 }
 
 Static int
@@ -1472,6 +1459,7 @@ zyd_rf_attach(struct zyd_softc *sc, uint
                rf->width        = 24;  /* 24-bit RF values */
                break;
        case ZYD_RF_AL2230:
+       case ZYD_RF_AL2230S:
                if (sc->mac_rev == ZYD_ZD1211B)
                        rf->init = zyd_al2230_init_b;
                else
@@ -1524,7 +1512,7 @@ zyd_rf_name(uint8_t type)
        static const char * const zyd_rfs[] = {
                "unknown", "unknown", "UW2451",   "UCHIP",     "AL2230",
                "AL7230B", "THETA",   "AL2210",   "MAXIM_NEW", "GCT",
-               "PV2000",  "RALINK",  "INTERSIL", "RFMD",      "MAXIM_NEW2",
+               "AL2230S",  "RALINK",  "INTERSIL", "RFMD",      "MAXIM_NEW2",
                "PHILIPS"
        };
 
Index: src/sys/dev/usb/if_zydreg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_zydreg.h,v
retrieving revision 1.2
diff -u -p -r1.2 if_zydreg.h
--- src/sys/dev/usb/if_zydreg.h 16 Jun 2007 11:18:45 -0000      1.2
+++ src/sys/dev/usb/if_zydreg.h 18 Aug 2009 10:54:05 -0000
@@ -160,7 +160,7 @@
 #define ZYD_RF_AL2210          0x7
 #define ZYD_RF_MAXIM_NEW       0x8
 #define ZYD_RF_GCT             0x9
-#define ZYD_RF_PV2000          0xa     /* not supported yet */
+#define ZYD_RF_AL2230S          0xa
 #define ZYD_RF_RALINK          0xb     /* not supported yet */
 #define ZYD_RF_INTERSIL                0xc     /* not supported yet */
 #define ZYD_RF_RFMD            0xd
@@ -638,6 +638,14 @@
        { ZYD_CR252, 0x00 }, { ZYD_CR253, 0x00 }                        \
 }
 
+#define        ZYD_AL2230S_PHY_INIT                                            
\
+{                                                                      \
+       { ZYD_CR47,  0x1e }, { ZYD_CR106, 0x22 }, { ZYD_CR107, 0x2a },  \
+       { ZYD_CR109, 0x13 }, { ZYD_CR118, 0xf8 }, { ZYD_CR119, 0x12 },  \
+       { ZYD_CR122, 0xe0 }, { ZYD_CR128, 0x10 }, { ZYD_CR129, 0x0e },  \
+       { ZYD_CR130, 0x10 }                                             \
+}
+
 #define ZYD_AL2230_RF                                                  \
 {                                                                      \
        0x03f790, 0x033331, 0x00000d, 0x0b3331, 0x03b812, 0x00fff3,     \
Index: src/sys/dev/usb/usbdevs
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usbdevs,v
retrieving revision 1.519.4.1
diff -u -p -r1.519.4.1 usbdevs
--- src/sys/dev/usb/usbdevs     22 Nov 2008 05:10:07 -0000      1.519.4.1
+++ src/sys/dev/usb/usbdevs     18 Aug 2009 10:54:05 -0000
@@ -895,6 +895,7 @@ product CTX EX1300          0x9999  Ex1300 hub
 
 /* CyberTAN Technology products */
 product CYBERTAN TG54USB       0x1666  TG54USB
+product CYBERTAN ZD1211B        0x1667  ZD1211B
 
 /* Cypress Semiconductor products */
 product CYPRESS MOUSE          0x0001  mouse


Home | Main Index | Thread Index | Old Index