提交 475433be 编写于 作者: I Ivo van Doorn 提交者: John W. Linville

rt2x00: Move led initialization into function

Reduce code duplication by moving led structure initialization
into a per-driver function.
Signed-off-by: NIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 2b08da3f
...@@ -277,6 +277,17 @@ static int rt2400pci_blink_set(struct led_classdev *led_cdev, ...@@ -277,6 +277,17 @@ static int rt2400pci_blink_set(struct led_classdev *led_cdev,
return 0; return 0;
} }
static void rt2400pci_init_led(struct rt2x00_dev *rt2x00dev,
struct rt2x00_led *led,
enum led_type type)
{
led->rt2x00dev = rt2x00dev;
led->type = type;
led->led_dev.brightness_set = rt2400pci_brightness_set;
led->led_dev.blink_set = rt2400pci_blink_set;
led->flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2400PCI_LEDS */ #endif /* CONFIG_RT2400PCI_LEDS */
/* /*
...@@ -1298,23 +1309,10 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -1298,23 +1309,10 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
#ifdef CONFIG_RT2400PCI_LEDS #ifdef CONFIG_RT2400PCI_LEDS
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
rt2x00dev->led_radio.rt2x00dev = rt2x00dev; rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
rt2x00dev->led_radio.type = LED_TYPE_RADIO; if (value == LED_MODE_TXRX_ACTIVITY)
rt2x00dev->led_radio.led_dev.brightness_set = rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
rt2400pci_brightness_set; LED_TYPE_ACTIVITY);
rt2x00dev->led_radio.led_dev.blink_set =
rt2400pci_blink_set;
rt2x00dev->led_radio.flags = LED_INITIALIZED;
if (value == LED_MODE_TXRX_ACTIVITY) {
rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
rt2x00dev->led_qual.led_dev.brightness_set =
rt2400pci_brightness_set;
rt2x00dev->led_qual.led_dev.blink_set =
rt2400pci_blink_set;
rt2x00dev->led_qual.flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2400PCI_LEDS */ #endif /* CONFIG_RT2400PCI_LEDS */
/* /*
......
...@@ -277,6 +277,17 @@ static int rt2500pci_blink_set(struct led_classdev *led_cdev, ...@@ -277,6 +277,17 @@ static int rt2500pci_blink_set(struct led_classdev *led_cdev,
return 0; return 0;
} }
static void rt2500pci_init_led(struct rt2x00_dev *rt2x00dev,
struct rt2x00_led *led,
enum led_type type)
{
led->rt2x00dev = rt2x00dev;
led->type = type;
led->led_dev.brightness_set = rt2500pci_brightness_set;
led->led_dev.blink_set = rt2500pci_blink_set;
led->flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2500PCI_LEDS */ #endif /* CONFIG_RT2500PCI_LEDS */
/* /*
...@@ -1476,23 +1487,10 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -1476,23 +1487,10 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
#ifdef CONFIG_RT2500PCI_LEDS #ifdef CONFIG_RT2500PCI_LEDS
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
rt2x00dev->led_radio.rt2x00dev = rt2x00dev; rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
rt2x00dev->led_radio.type = LED_TYPE_RADIO; if (value == LED_MODE_TXRX_ACTIVITY)
rt2x00dev->led_radio.led_dev.brightness_set = rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
rt2500pci_brightness_set; LED_TYPE_ACTIVITY);
rt2x00dev->led_radio.led_dev.blink_set =
rt2500pci_blink_set;
rt2x00dev->led_radio.flags = LED_INITIALIZED;
if (value == LED_MODE_TXRX_ACTIVITY) {
rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
rt2x00dev->led_qual.led_dev.brightness_set =
rt2500pci_brightness_set;
rt2x00dev->led_qual.led_dev.blink_set =
rt2500pci_blink_set;
rt2x00dev->led_qual.flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2500PCI_LEDS */ #endif /* CONFIG_RT2500PCI_LEDS */
/* /*
......
...@@ -316,6 +316,17 @@ static int rt2500usb_blink_set(struct led_classdev *led_cdev, ...@@ -316,6 +316,17 @@ static int rt2500usb_blink_set(struct led_classdev *led_cdev,
return 0; return 0;
} }
static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev,
struct rt2x00_led *led,
enum led_type type)
{
led->rt2x00dev = rt2x00dev;
led->type = type;
led->led_dev.brightness_set = rt2500usb_brightness_set;
led->led_dev.blink_set = rt2500usb_blink_set;
led->flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2500USB_LEDS */ #endif /* CONFIG_RT2500USB_LEDS */
/* /*
...@@ -1385,23 +1396,10 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -1385,23 +1396,10 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
#ifdef CONFIG_RT2500USB_LEDS #ifdef CONFIG_RT2500USB_LEDS
value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
rt2x00dev->led_radio.rt2x00dev = rt2x00dev; rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
rt2x00dev->led_radio.type = LED_TYPE_RADIO; if (value == LED_MODE_TXRX_ACTIVITY)
rt2x00dev->led_radio.led_dev.brightness_set = rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
rt2500usb_brightness_set; LED_TYPE_ACTIVITY);
rt2x00dev->led_radio.led_dev.blink_set =
rt2500usb_blink_set;
rt2x00dev->led_radio.flags = LED_INITIALIZED;
if (value == LED_MODE_TXRX_ACTIVITY) {
rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
rt2x00dev->led_qual.led_dev.brightness_set =
rt2500usb_brightness_set;
rt2x00dev->led_qual.led_dev.blink_set =
rt2500usb_blink_set;
rt2x00dev->led_qual.flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT2500USB_LEDS */ #endif /* CONFIG_RT2500USB_LEDS */
/* /*
......
...@@ -330,6 +330,17 @@ static int rt61pci_blink_set(struct led_classdev *led_cdev, ...@@ -330,6 +330,17 @@ static int rt61pci_blink_set(struct led_classdev *led_cdev,
return 0; return 0;
} }
static void rt61pci_init_led(struct rt2x00_dev *rt2x00dev,
struct rt2x00_led *led,
enum led_type type)
{
led->rt2x00dev = rt2x00dev;
led->type = type;
led->led_dev.brightness_set = rt61pci_brightness_set;
led->led_dev.blink_set = rt61pci_blink_set;
led->flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT61PCI_LEDS */ #endif /* CONFIG_RT61PCI_LEDS */
/* /*
...@@ -2064,31 +2075,11 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -2064,31 +2075,11 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE); value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE);
rt2x00dev->led_radio.rt2x00dev = rt2x00dev; rt61pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
rt2x00dev->led_radio.type = LED_TYPE_RADIO; rt61pci_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
rt2x00dev->led_radio.led_dev.brightness_set = if (value == LED_MODE_SIGNAL_STRENGTH)
rt61pci_brightness_set; rt61pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
rt2x00dev->led_radio.led_dev.blink_set = LED_TYPE_QUALITY);
rt61pci_blink_set;
rt2x00dev->led_radio.flags = LED_INITIALIZED;
rt2x00dev->led_assoc.rt2x00dev = rt2x00dev;
rt2x00dev->led_assoc.type = LED_TYPE_ASSOC;
rt2x00dev->led_assoc.led_dev.brightness_set =
rt61pci_brightness_set;
rt2x00dev->led_assoc.led_dev.blink_set =
rt61pci_blink_set;
rt2x00dev->led_assoc.flags = LED_INITIALIZED;
if (value == LED_MODE_SIGNAL_STRENGTH) {
rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
rt2x00dev->led_qual.type = LED_TYPE_QUALITY;
rt2x00dev->led_qual.led_dev.brightness_set =
rt61pci_brightness_set;
rt2x00dev->led_qual.led_dev.blink_set =
rt61pci_blink_set;
rt2x00dev->led_qual.flags = LED_INITIALIZED;
}
rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,
......
...@@ -335,6 +335,17 @@ static int rt73usb_blink_set(struct led_classdev *led_cdev, ...@@ -335,6 +335,17 @@ static int rt73usb_blink_set(struct led_classdev *led_cdev,
return 0; return 0;
} }
static void rt73usb_init_led(struct rt2x00_dev *rt2x00dev,
struct rt2x00_led *led,
enum led_type type)
{
led->rt2x00dev = rt2x00dev;
led->type = type;
led->led_dev.brightness_set = rt73usb_brightness_set;
led->led_dev.blink_set = rt73usb_blink_set;
led->flags = LED_INITIALIZED;
}
#endif /* CONFIG_RT73USB_LEDS */ #endif /* CONFIG_RT73USB_LEDS */
/* /*
...@@ -1627,31 +1638,11 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev) ...@@ -1627,31 +1638,11 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
#ifdef CONFIG_RT73USB_LEDS #ifdef CONFIG_RT73USB_LEDS
rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
rt2x00dev->led_radio.rt2x00dev = rt2x00dev; rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
rt2x00dev->led_radio.type = LED_TYPE_RADIO; rt73usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
rt2x00dev->led_radio.led_dev.brightness_set = if (value == LED_MODE_SIGNAL_STRENGTH)
rt73usb_brightness_set; rt73usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
rt2x00dev->led_radio.led_dev.blink_set = LED_TYPE_QUALITY);
rt73usb_blink_set;
rt2x00dev->led_radio.flags = LED_INITIALIZED;
rt2x00dev->led_assoc.rt2x00dev = rt2x00dev;
rt2x00dev->led_assoc.type = LED_TYPE_ASSOC;
rt2x00dev->led_assoc.led_dev.brightness_set =
rt73usb_brightness_set;
rt2x00dev->led_assoc.led_dev.blink_set =
rt73usb_blink_set;
rt2x00dev->led_assoc.flags = LED_INITIALIZED;
if (value == LED_MODE_SIGNAL_STRENGTH) {
rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
rt2x00dev->led_qual.type = LED_TYPE_QUALITY;
rt2x00dev->led_qual.led_dev.brightness_set =
rt73usb_brightness_set;
rt2x00dev->led_qual.led_dev.blink_set =
rt73usb_blink_set;
rt2x00dev->led_qual.flags = LED_INITIALIZED;
}
rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value); rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0, rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册