提交 3de68ce9 编写于 作者: H Heiner Kallweit 提交者: Jiri Kosina

HID: thingm: remove workqueue

Defining workqueues in LED drivers isn't needed any longer as the LED core
was extended with a generic workqueue recently.
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 c2848f2e
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/workqueue.h>
#include "hid-ids.h" #include "hid-ids.h"
...@@ -56,7 +55,6 @@ struct thingm_rgb { ...@@ -56,7 +55,6 @@ struct thingm_rgb {
struct thingm_led red; struct thingm_led red;
struct thingm_led green; struct thingm_led green;
struct thingm_led blue; struct thingm_led blue;
struct work_struct work;
u8 num; u8 num;
}; };
...@@ -131,25 +129,21 @@ static int thingm_write_color(struct thingm_rgb *rgb) ...@@ -131,25 +129,21 @@ static int thingm_write_color(struct thingm_rgb *rgb)
return thingm_send(rgb->tdev, buf); return thingm_send(rgb->tdev, buf);
} }
static void thingm_work(struct work_struct *work) static int thingm_led_set(struct led_classdev *ldev,
enum led_brightness brightness)
{ {
struct thingm_rgb *rgb = container_of(work, struct thingm_rgb, work); struct thingm_led *led = container_of(ldev, struct thingm_led, ldev);
int ret;
mutex_lock(&rgb->tdev->lock);
if (thingm_write_color(rgb)) mutex_lock(&led->rgb->tdev->lock);
hid_err(rgb->tdev->hdev, "failed to write color\n");
mutex_unlock(&rgb->tdev->lock); ret = thingm_write_color(led->rgb);
} if (ret)
hid_err(led->rgb->tdev->hdev, "failed to write color\n");
static void thingm_led_set(struct led_classdev *ldev, mutex_unlock(&led->rgb->tdev->lock);
enum led_brightness brightness)
{
struct thingm_led *led = container_of(ldev, struct thingm_led, ldev);
/* the ledclass has already stored the brightness value */ return ret;
schedule_work(&led->rgb->work);
} }
static int thingm_init_rgb(struct thingm_rgb *rgb) static int thingm_init_rgb(struct thingm_rgb *rgb)
...@@ -162,7 +156,7 @@ static int thingm_init_rgb(struct thingm_rgb *rgb) ...@@ -162,7 +156,7 @@ static int thingm_init_rgb(struct thingm_rgb *rgb)
"thingm%d:red:led%d", minor, rgb->num); "thingm%d:red:led%d", minor, rgb->num);
rgb->red.ldev.name = rgb->red.name; rgb->red.ldev.name = rgb->red.name;
rgb->red.ldev.max_brightness = 255; rgb->red.ldev.max_brightness = 255;
rgb->red.ldev.brightness_set = thingm_led_set; rgb->red.ldev.brightness_set_blocking = thingm_led_set;
rgb->red.rgb = rgb; rgb->red.rgb = rgb;
err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->red.ldev); err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->red.ldev);
...@@ -174,7 +168,7 @@ static int thingm_init_rgb(struct thingm_rgb *rgb) ...@@ -174,7 +168,7 @@ static int thingm_init_rgb(struct thingm_rgb *rgb)
"thingm%d:green:led%d", minor, rgb->num); "thingm%d:green:led%d", minor, rgb->num);
rgb->green.ldev.name = rgb->green.name; rgb->green.ldev.name = rgb->green.name;
rgb->green.ldev.max_brightness = 255; rgb->green.ldev.max_brightness = 255;
rgb->green.ldev.brightness_set = thingm_led_set; rgb->green.ldev.brightness_set_blocking = thingm_led_set;
rgb->green.rgb = rgb; rgb->green.rgb = rgb;
err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->green.ldev); err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->green.ldev);
...@@ -186,15 +180,13 @@ static int thingm_init_rgb(struct thingm_rgb *rgb) ...@@ -186,15 +180,13 @@ static int thingm_init_rgb(struct thingm_rgb *rgb)
"thingm%d:blue:led%d", minor, rgb->num); "thingm%d:blue:led%d", minor, rgb->num);
rgb->blue.ldev.name = rgb->blue.name; rgb->blue.ldev.name = rgb->blue.name;
rgb->blue.ldev.max_brightness = 255; rgb->blue.ldev.max_brightness = 255;
rgb->blue.ldev.brightness_set = thingm_led_set; rgb->blue.ldev.brightness_set_blocking = thingm_led_set;
rgb->blue.rgb = rgb; rgb->blue.rgb = rgb;
err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->blue.ldev); err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->blue.ldev);
if (err) if (err)
goto unregister_green; goto unregister_green;
INIT_WORK(&rgb->work, thingm_work);
return 0; return 0;
unregister_green: unregister_green:
...@@ -211,7 +203,6 @@ static void thingm_remove_rgb(struct thingm_rgb *rgb) ...@@ -211,7 +203,6 @@ static void thingm_remove_rgb(struct thingm_rgb *rgb)
led_classdev_unregister(&rgb->red.ldev); led_classdev_unregister(&rgb->red.ldev);
led_classdev_unregister(&rgb->green.ldev); led_classdev_unregister(&rgb->green.ldev);
led_classdev_unregister(&rgb->blue.ldev); led_classdev_unregister(&rgb->blue.ldev);
flush_work(&rgb->work);
} }
static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id) static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册