summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2013-05-28 11:22:09 +0200
committerJiri Kosina <jkosina@suse.cz>2013-05-28 11:22:09 +0200
commit40e32ee6e475852f532c847ed1804b87f6531a67 (patch)
treec82f929072fbd08bac483df64b3207882d61536f
parentf04d51404f51947d3feabf2518495ba5aa3bb2c4 (diff)
downloadtalos-obmc-linux-40e32ee6e475852f532c847ed1804b87f6531a67.tar.gz
talos-obmc-linux-40e32ee6e475852f532c847ed1804b87f6531a67.zip
HID: sony: fix leds dependency
The newly added support for Buzz controller - introduced Kconfig selection of LEDS_CLASS - introduced conditional preprocessor checking for CONFIG_LEDS_CLASS This has multiple problems -- namely select doesn't work transitively, so it shouldn't be used. On the other hand the code assumed that LEDS_CLASS is enabled in some places, but not everywhere. Put LEDS_CLASS as a Kconfig dependency for hid-sony and remove all the CONFIG_LEDS_CLASS conditionals from hid-sony. Reported-by: fengguang.wu@intel.com Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/Kconfig4
-rw-r--r--drivers/hid/hid-sony.c105
2 files changed, 44 insertions, 65 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 53caf0b115cb..5bad26ef227a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -596,8 +596,8 @@ config HID_SAMSUNG
config HID_SONY
tristate "Sony PS2/3 accessories"
depends on USB_HID
- select NEW_LEDS
- select LEDS_CLASS
+ depends on NEW_LEDS
+ depends on LEDS_CLASS
---help---
Support for
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 41e829c8bc48..f1c906176615 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/usb.h>
+#include <linux/leds.h>
#include "hid-ids.h"
@@ -103,10 +104,8 @@ struct sony_sc {
};
struct buzz_extra {
-#ifdef CONFIG_LEDS_CLASS
int led_state;
struct led_classdev *leds[4];
-#endif
};
/* Sony Vaio VGX has wrongly mouse pointer declared as constant */
@@ -274,7 +273,6 @@ static int sixaxis_set_operational_bt(struct hid_device *hdev)
return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
}
-#ifdef CONFIG_LEDS_CLASS
static void buzz_set_leds(struct hid_device *hdev, int leds)
{
struct list_head *report_list =
@@ -351,13 +349,15 @@ static enum led_brightness buzz_led_get_brightness(struct led_classdev *led)
return on ? LED_FULL : LED_OFF;
}
-#endif
static int buzz_init(struct hid_device *hdev)
{
struct sony_sc *drv_data;
struct buzz_extra *buzz;
- int ret = 0;
+ int n, ret = 0;
+ struct led_classdev *led;
+ size_t name_sz;
+ char *name;
drv_data = hid_get_drvdata(hdev);
BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
@@ -374,90 +374,69 @@ static int buzz_init(struct hid_device *hdev)
* LEDs to on */
buzz_set_leds(hdev, 0x00);
-#ifdef CONFIG_LEDS_CLASS
- {
- int n;
- struct led_classdev *led;
- size_t name_sz;
- char *name;
+ name_sz = strlen(dev_name(&hdev->dev)) + strlen("::buzz#") + 1;
- name_sz = strlen(dev_name(&hdev->dev)) + strlen("::buzz#") + 1;
-
- for (n = 0; n < 4; n++) {
- led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
- if (!led) {
- hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
- goto error_leds;
- }
+ for (n = 0; n < 4; n++) {
+ led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
+ if (!led) {
+ hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
+ goto error_leds;
+ }
- name = (void *)(&led[1]);
- snprintf(name, name_sz, "%s::buzz%d", dev_name(&hdev->dev), n + 1);
- led->name = name;
- led->brightness = 0;
- led->max_brightness = 1;
- led->brightness_get = buzz_led_get_brightness;
- led->brightness_set = buzz_led_set_brightness;
-
- if (led_classdev_register(&hdev->dev, led)) {
- hid_err(hdev, "Failed to register LED %d\n", n);
- kfree(led);
- goto error_leds;
- }
+ name = (void *)(&led[1]);
+ snprintf(name, name_sz, "%s::buzz%d", dev_name(&hdev->dev), n + 1);
+ led->name = name;
+ led->brightness = 0;
+ led->max_brightness = 1;
+ led->brightness_get = buzz_led_get_brightness;
+ led->brightness_set = buzz_led_set_brightness;
- buzz->leds[n] = led;
+ if (led_classdev_register(&hdev->dev, led)) {
+ hid_err(hdev, "Failed to register LED %d\n", n);
+ kfree(led);
+ goto error_leds;
}
+
+ buzz->leds[n] = led;
}
-#endif
return ret;
-#ifdef CONFIG_LEDS_CLASS
error_leds:
- {
- int n;
- struct led_classdev *led;
-
- for (n = 0; n < 4; n++) {
- led = buzz->leds[n];
- buzz->leds[n] = NULL;
- if (!led)
- continue;
- led_classdev_unregister(led);
- kfree(led);
- }
+ for (n = 0; n < 4; n++) {
+ led = buzz->leds[n];
+ buzz->leds[n] = NULL;
+ if (!led)
+ continue;
+ led_classdev_unregister(led);
+ kfree(led);
}
kfree(drv_data->extra);
drv_data->extra = NULL;
return ret;
-#endif
}
static void buzz_remove(struct hid_device *hdev)
{
struct sony_sc *drv_data;
struct buzz_extra *buzz;
+ struct led_classdev *led;
+ int n;
drv_data = hid_get_drvdata(hdev);
BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
buzz = drv_data->extra;
-
-#ifdef CONFIG_LEDS_CLASS
- {
- int n;
- struct led_classdev *led;
-
- for (n = 0; n < 4; n++) {
- led = buzz->leds[n];
- buzz->leds[n] = NULL;
- if (!led)
- continue;
- led_classdev_unregister(led);
- kfree(led);
- }
+
+ for (n = 0; n < 4; n++) {
+ led = buzz->leds[n];
+ buzz->leds[n] = NULL;
+ if (!led)
+ continue;
+ led_classdev_unregister(led);
+ kfree(led);
}
-#endif
kfree(drv_data->extra);
drv_data->extra = NULL;
OpenPOWER on IntegriCloud