aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorIvo van Doorn <IvDoorn@gmail.com>2008-06-03 14:30:01 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-14 12:17:55 -0400
commit475433be3d8f4d840e2930eef96671b7f8d11053 (patch)
tree0eab68260c952e08ef5767cadafaba4c1189efff /drivers/net
parent2b08da3fb595432f87b5206c1c77dcb72300cacf (diff)
rt2x00: Move led initialization into function
Reduce code duplication by moving led structure initialization into a per-driver function. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c41
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c41
5 files changed, 77 insertions, 101 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index cfb720f35b2c..94226b47d1d9 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -277,6 +277,17 @@ static int rt2400pci_blink_set(struct led_classdev *led_cdev,
277 277
278 return 0; 278 return 0;
279} 279}
280
281static void rt2400pci_init_led(struct rt2x00_dev *rt2x00dev,
282 struct rt2x00_led *led,
283 enum led_type type)
284{
285 led->rt2x00dev = rt2x00dev;
286 led->type = type;
287 led->led_dev.brightness_set = rt2400pci_brightness_set;
288 led->led_dev.blink_set = rt2400pci_blink_set;
289 led->flags = LED_INITIALIZED;
290}
280#endif /* CONFIG_RT2400PCI_LEDS */ 291#endif /* CONFIG_RT2400PCI_LEDS */
281 292
282/* 293/*
@@ -1298,23 +1309,10 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1298#ifdef CONFIG_RT2400PCI_LEDS 1309#ifdef CONFIG_RT2400PCI_LEDS
1299 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1310 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1300 1311
1301 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1312 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1302 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1313 if (value == LED_MODE_TXRX_ACTIVITY)
1303 rt2x00dev->led_radio.led_dev.brightness_set = 1314 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
1304 rt2400pci_brightness_set; 1315 LED_TYPE_ACTIVITY);
1305 rt2x00dev->led_radio.led_dev.blink_set =
1306 rt2400pci_blink_set;
1307 rt2x00dev->led_radio.flags = LED_INITIALIZED;
1308
1309 if (value == LED_MODE_TXRX_ACTIVITY) {
1310 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
1311 rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
1312 rt2x00dev->led_qual.led_dev.brightness_set =
1313 rt2400pci_brightness_set;
1314 rt2x00dev->led_qual.led_dev.blink_set =
1315 rt2400pci_blink_set;
1316 rt2x00dev->led_qual.flags = LED_INITIALIZED;
1317 }
1318#endif /* CONFIG_RT2400PCI_LEDS */ 1316#endif /* CONFIG_RT2400PCI_LEDS */
1319 1317
1320 /* 1318 /*
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index b08932d7bf20..c8cf8c1d095f 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -277,6 +277,17 @@ static int rt2500pci_blink_set(struct led_classdev *led_cdev,
277 277
278 return 0; 278 return 0;
279} 279}
280
281static void rt2500pci_init_led(struct rt2x00_dev *rt2x00dev,
282 struct rt2x00_led *led,
283 enum led_type type)
284{
285 led->rt2x00dev = rt2x00dev;
286 led->type = type;
287 led->led_dev.brightness_set = rt2500pci_brightness_set;
288 led->led_dev.blink_set = rt2500pci_blink_set;
289 led->flags = LED_INITIALIZED;
290}
280#endif /* CONFIG_RT2500PCI_LEDS */ 291#endif /* CONFIG_RT2500PCI_LEDS */
281 292
282/* 293/*
@@ -1476,23 +1487,10 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1476#ifdef CONFIG_RT2500PCI_LEDS 1487#ifdef CONFIG_RT2500PCI_LEDS
1477 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1488 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1478 1489
1479 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1490 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1480 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1491 if (value == LED_MODE_TXRX_ACTIVITY)
1481 rt2x00dev->led_radio.led_dev.brightness_set = 1492 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
1482 rt2500pci_brightness_set; 1493 LED_TYPE_ACTIVITY);
1483 rt2x00dev->led_radio.led_dev.blink_set =
1484 rt2500pci_blink_set;
1485 rt2x00dev->led_radio.flags = LED_INITIALIZED;
1486
1487 if (value == LED_MODE_TXRX_ACTIVITY) {
1488 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
1489 rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
1490 rt2x00dev->led_qual.led_dev.brightness_set =
1491 rt2500pci_brightness_set;
1492 rt2x00dev->led_qual.led_dev.blink_set =
1493 rt2500pci_blink_set;
1494 rt2x00dev->led_qual.flags = LED_INITIALIZED;
1495 }
1496#endif /* CONFIG_RT2500PCI_LEDS */ 1494#endif /* CONFIG_RT2500PCI_LEDS */
1497 1495
1498 /* 1496 /*
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index a46e4a6eba96..0d51b748c5b7 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -316,6 +316,17 @@ static int rt2500usb_blink_set(struct led_classdev *led_cdev,
316 316
317 return 0; 317 return 0;
318} 318}
319
320static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev,
321 struct rt2x00_led *led,
322 enum led_type type)
323{
324 led->rt2x00dev = rt2x00dev;
325 led->type = type;
326 led->led_dev.brightness_set = rt2500usb_brightness_set;
327 led->led_dev.blink_set = rt2500usb_blink_set;
328 led->flags = LED_INITIALIZED;
329}
319#endif /* CONFIG_RT2500USB_LEDS */ 330#endif /* CONFIG_RT2500USB_LEDS */
320 331
321/* 332/*
@@ -1385,23 +1396,10 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1385#ifdef CONFIG_RT2500USB_LEDS 1396#ifdef CONFIG_RT2500USB_LEDS
1386 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1397 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1387 1398
1388 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1399 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1389 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1400 if (value == LED_MODE_TXRX_ACTIVITY)
1390 rt2x00dev->led_radio.led_dev.brightness_set = 1401 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1391 rt2500usb_brightness_set; 1402 LED_TYPE_ACTIVITY);
1392 rt2x00dev->led_radio.led_dev.blink_set =
1393 rt2500usb_blink_set;
1394 rt2x00dev->led_radio.flags = LED_INITIALIZED;
1395
1396 if (value == LED_MODE_TXRX_ACTIVITY) {
1397 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
1398 rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
1399 rt2x00dev->led_qual.led_dev.brightness_set =
1400 rt2500usb_brightness_set;
1401 rt2x00dev->led_qual.led_dev.blink_set =
1402 rt2500usb_blink_set;
1403 rt2x00dev->led_qual.flags = LED_INITIALIZED;
1404 }
1405#endif /* CONFIG_RT2500USB_LEDS */ 1403#endif /* CONFIG_RT2500USB_LEDS */
1406 1404
1407 /* 1405 /*
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 4658dbd7ef63..aa9ef66921b8 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -330,6 +330,17 @@ static int rt61pci_blink_set(struct led_classdev *led_cdev,
330 330
331 return 0; 331 return 0;
332} 332}
333
334static void rt61pci_init_led(struct rt2x00_dev *rt2x00dev,
335 struct rt2x00_led *led,
336 enum led_type type)
337{
338 led->rt2x00dev = rt2x00dev;
339 led->type = type;
340 led->led_dev.brightness_set = rt61pci_brightness_set;
341 led->led_dev.blink_set = rt61pci_blink_set;
342 led->flags = LED_INITIALIZED;
343}
333#endif /* CONFIG_RT61PCI_LEDS */ 344#endif /* CONFIG_RT61PCI_LEDS */
334 345
335/* 346/*
@@ -2064,31 +2075,11 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2064 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 2075 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
2065 value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE); 2076 value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE);
2066 2077
2067 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 2078 rt61pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
2068 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 2079 rt61pci_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
2069 rt2x00dev->led_radio.led_dev.brightness_set = 2080 if (value == LED_MODE_SIGNAL_STRENGTH)
2070 rt61pci_brightness_set; 2081 rt61pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
2071 rt2x00dev->led_radio.led_dev.blink_set = 2082 LED_TYPE_QUALITY);
2072 rt61pci_blink_set;
2073 rt2x00dev->led_radio.flags = LED_INITIALIZED;
2074
2075 rt2x00dev->led_assoc.rt2x00dev = rt2x00dev;
2076 rt2x00dev->led_assoc.type = LED_TYPE_ASSOC;
2077 rt2x00dev->led_assoc.led_dev.brightness_set =
2078 rt61pci_brightness_set;
2079 rt2x00dev->led_assoc.led_dev.blink_set =
2080 rt61pci_blink_set;
2081 rt2x00dev->led_assoc.flags = LED_INITIALIZED;
2082
2083 if (value == LED_MODE_SIGNAL_STRENGTH) {
2084 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
2085 rt2x00dev->led_qual.type = LED_TYPE_QUALITY;
2086 rt2x00dev->led_qual.led_dev.brightness_set =
2087 rt61pci_brightness_set;
2088 rt2x00dev->led_qual.led_dev.blink_set =
2089 rt61pci_blink_set;
2090 rt2x00dev->led_qual.flags = LED_INITIALIZED;
2091 }
2092 2083
2093 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); 2084 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
2094 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, 2085 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index aabdc67c8555..db1fc136cda4 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -335,6 +335,17 @@ static int rt73usb_blink_set(struct led_classdev *led_cdev,
335 335
336 return 0; 336 return 0;
337} 337}
338
339static void rt73usb_init_led(struct rt2x00_dev *rt2x00dev,
340 struct rt2x00_led *led,
341 enum led_type type)
342{
343 led->rt2x00dev = rt2x00dev;
344 led->type = type;
345 led->led_dev.brightness_set = rt73usb_brightness_set;
346 led->led_dev.blink_set = rt73usb_blink_set;
347 led->flags = LED_INITIALIZED;
348}
338#endif /* CONFIG_RT73USB_LEDS */ 349#endif /* CONFIG_RT73USB_LEDS */
339 350
340/* 351/*
@@ -1627,31 +1638,11 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1627#ifdef CONFIG_RT73USB_LEDS 1638#ifdef CONFIG_RT73USB_LEDS
1628 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 1639 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
1629 1640
1630 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1641 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1631 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1642 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
1632 rt2x00dev->led_radio.led_dev.brightness_set = 1643 if (value == LED_MODE_SIGNAL_STRENGTH)
1633 rt73usb_brightness_set; 1644 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1634 rt2x00dev->led_radio.led_dev.blink_set = 1645 LED_TYPE_QUALITY);
1635 rt73usb_blink_set;
1636 rt2x00dev->led_radio.flags = LED_INITIALIZED;
1637
1638 rt2x00dev->led_assoc.rt2x00dev = rt2x00dev;
1639 rt2x00dev->led_assoc.type = LED_TYPE_ASSOC;
1640 rt2x00dev->led_assoc.led_dev.brightness_set =
1641 rt73usb_brightness_set;
1642 rt2x00dev->led_assoc.led_dev.blink_set =
1643 rt73usb_blink_set;
1644 rt2x00dev->led_assoc.flags = LED_INITIALIZED;
1645
1646 if (value == LED_MODE_SIGNAL_STRENGTH) {
1647 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
1648 rt2x00dev->led_qual.type = LED_TYPE_QUALITY;
1649 rt2x00dev->led_qual.led_dev.brightness_set =
1650 rt73usb_brightness_set;
1651 rt2x00dev->led_qual.led_dev.blink_set =
1652 rt73usb_blink_set;
1653 rt2x00dev->led_qual.flags = LED_INITIALIZED;
1654 }
1655 1646
1656 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); 1647 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
1657 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, 1648 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,