summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/light.c
diff options
context:
space:
mode:
authorRui Miguel Silva <rui.silva@linaro.org>2016-01-12 14:35:49 +0000
committerGreg Kroah-Hartman <gregkh@google.com>2016-01-13 15:27:20 -0800
commit9c06c6a2b9ec4cfa78a4cf5ab123bfca0285e083 (patch)
treed31605b0e0478b72294c3cae3380ae874e7bbab5 /drivers/staging/greybus/light.c
parentb827e1137ca9b495f10f3215ed6dd6ff738f0c81 (diff)
greybus: lights: remove sync operation and work queue
In kernel v4.5 there is a change in LED api, which remove the need for individual work queue and rename the set_sync operation to set_blocking. This patch add the handling of this case and avoid compilation failure for this kernel versions. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/light.c')
-rw-r--r--drivers/staging/greybus/light.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 153c4f5479f0..3488bbd58198 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -30,7 +30,9 @@ struct gb_channel {
struct attribute **attrs;
struct attribute_group *attr_group;
const struct attribute_group **attr_groups;
+#ifndef LED_HAVE_SET_BLOCKING
struct work_struct work_brightness_set;
+#endif
struct led_classdev *led;
#ifdef LED_HAVE_FLASH
struct led_classdev_flash fled;
@@ -381,6 +383,7 @@ static int __gb_lights_brightness_set(struct gb_channel *channel)
return ret;
}
+#ifndef LED_HAVE_SET_BLOCKING
static void gb_brightness_set_work(struct work_struct *work)
{
struct gb_channel *channel = container_of(work, struct gb_channel,
@@ -412,6 +415,17 @@ static void gb_brightness_set(struct led_classdev *cdev,
cdev->brightness = value;
schedule_work(&channel->work_brightness_set);
}
+#else /* LED_HAVE_SET_BLOCKING */
+static int gb_brightness_set(struct led_classdev *cdev,
+ enum led_brightness value)
+{
+ struct gb_channel *channel = get_channel_from_cdev(cdev);
+
+ channel->led->brightness = value;
+
+ return __gb_lights_brightness_set(channel);
+}
+#endif
static enum led_brightness gb_brightness_get(struct led_classdev *cdev)
@@ -443,12 +457,17 @@ static int gb_blink_set(struct led_classdev *cdev, unsigned long *delay_on,
static void gb_lights_led_operations_set(struct gb_channel *channel,
struct led_classdev *cdev)
{
- cdev->brightness_set = gb_brightness_set;
cdev->brightness_get = gb_brightness_get;
#ifdef LED_HAVE_SET_SYNC
cdev->brightness_set_sync = gb_brightness_set_sync;
#endif
+#ifdef LED_HAVE_SET_BLOCKING
+ cdev->brightness_set_blocking = gb_brightness_set;
+#endif
+#ifndef LED_HAVE_SET_BLOCKING
+ cdev->brightness_set = gb_brightness_set;
INIT_WORK(&channel->work_brightness_set, gb_brightness_set_work);
+#endif
if (channel->flags & GB_LIGHT_CHANNEL_BLINK)
cdev->blink_set = gb_blink_set;
@@ -986,8 +1005,10 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
static void gb_lights_channel_free(struct gb_channel *channel)
{
+#ifndef LED_HAVE_SET_BLOCKING
if (&channel->work_brightness_set)
flush_work(&channel->work_brightness_set);
+#endif
kfree(channel->attrs);
kfree(channel->attr_group);
kfree(channel->attr_groups);