提交 40e32ee6 编写于 作者: J Jiri Kosina

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: NJiri Kosina <jkosina@suse.cz>
上级 f04d5140
......@@ -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
......
......@@ -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,13 +374,6 @@ 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;
for (n = 0; n < 4; n++) {
......@@ -406,17 +399,10 @@ static int buzz_init(struct hid_device *hdev)
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;
......@@ -425,29 +411,24 @@ static int buzz_init(struct hid_device *hdev)
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;
......@@ -456,8 +437,6 @@ static void buzz_remove(struct hid_device *hdev)
led_classdev_unregister(led);
kfree(led);
}
}
#endif
kfree(drv_data->extra);
drv_data->extra = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册