Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964983AbbHKJjS (ORCPT ); Tue, 11 Aug 2015 05:39:18 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:48172 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964909AbbHKJjJ (ORCPT ); Tue, 11 Aug 2015 05:39:09 -0400 X-AuditID: cbfee61b-f79706d000001b96-2f-55c9c2bb8508 From: Jacek Anaszewski To: linux-leds@vger.kernel.org Cc: linux-kernel@vger.kernel.org, cooloney@gmail.com, rpurdie@rpsys.net, stsp@users.sourceforge.net, Andrew Lunn , Jan-Simon Moeller , Jacek Anaszewski Subject: [PATCH/RFC v5 16/57] leds: blinkm: Remove work queue Date: Tue, 11 Aug 2015 11:37:29 +0200 Message-id: <1439285890-27329-17-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1439285890-27329-1-git-send-email-j.anaszewski@samsung.com> References: <1439285890-27329-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t9jQd3dh06GGux5Lmhx/u4hZoujOycy WUz5PYfVovfqc0aLy7vmsFlsfbOO0WL3rqesFp1901gcODx2zrrL7vHhY5zHzh2fmTz2zP/B 6tG3ZRWjR9OpdlaPz5vkAtijuGxSUnMyy1KL9O0SuDLaVi1nLHinU3H7dCNzA+Nt5S5GTg4J AROJaT+WsEHYYhIX7q0Hsrk4hARmMUqs6TrNDOH8ZJR4tWkpE0gVm4ChxM8Xr4FsDg4RATmJ nWcqQWqYBa4wSmw5vI0ZpEZYwFai8eNyNpAaFgFVid0zhUBMXgFPiUmPOUFMCQEFiTmTbECK OYGi158vYgSxhQQ8JI7PbmKbwMi7gJFhFaNEakFyQXFSeq5RXmq5XnFibnFpXrpecn7uJkZw yD2T3sF4eJf7IUYBDkYlHqD5J0OFWBPLiitzDzFKcDArifAWTgUK8aYkVlalFuXHF5XmpBYf YpTmYFES59U32RQqJJCeWJKanZpakFoEk2Xi4JRqYOwRbjGpbGYvUDv24koJ85X7YlVt9p6z 3N+dKHFM4VkRl9K6IXr6KgW28uynzyr7pz6wW1rQytIlpxnH9nLLamMPzmenIvantX+5EePA G6Ky9k5xpEp5NvuJDDb/drWjD14wn7A9bxz5JU9t6sv2J+oWE+TM5mVklIm8jn1X9z3jZa/0 YYW9SizFGYmGWsxFxYkAe3owHzUCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5814 Lines: 178 From: Andrew Lunn Now the core implements the work queue, remove it from the driver. Signed-off-by: Andrew Lunn Cc: Jan-Simon Moeller Signed-off-by: Jacek Anaszewski --- drivers/leds/leds-blinkm.c | 69 +++++--------------------------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index d0452b0..f1c8668 100644 --- a/drivers/leds/leds-blinkm.c +++ b/drivers/leds/leds-blinkm.c @@ -39,16 +39,9 @@ struct blinkm_led { struct i2c_client *i2c_client; struct led_classdev led_cdev; int id; - atomic_t active; -}; - -struct blinkm_work { - struct blinkm_led *blinkm_led; - struct work_struct work; }; #define cdev_to_blmled(c) container_of(c, struct blinkm_led, led_cdev) -#define work_to_blmwork(c) container_of(c, struct blinkm_work, work) struct blinkm_data { struct i2c_client *i2c_client; @@ -439,65 +432,30 @@ static int blinkm_transfer_hw(struct i2c_client *client, int cmd) return 0; } -static void led_work(struct work_struct *work) -{ - int ret; - struct blinkm_led *led; - struct blinkm_data *data; - struct blinkm_work *blm_work = work_to_blmwork(work); - - led = blm_work->blinkm_led; - data = i2c_get_clientdata(led->i2c_client); - ret = blinkm_transfer_hw(led->i2c_client, BLM_GO_RGB); - atomic_dec(&led->active); - dev_dbg(&led->i2c_client->dev, - "# DONE # next_red = %d, next_green = %d," - " next_blue = %d, active = %d\n", - data->next_red, data->next_green, - data->next_blue, atomic_read(&led->active)); - kfree(blm_work); -} - static int blinkm_led_common_set(struct led_classdev *led_cdev, enum led_brightness value, int color) { /* led_brightness is 0, 127 or 255 - we just use it here as-is */ struct blinkm_led *led = cdev_to_blmled(led_cdev); struct blinkm_data *data = i2c_get_clientdata(led->i2c_client); - struct blinkm_work *bl_work; switch (color) { case RED: /* bail out if there's no change */ if (data->next_red == (u8) value) return 0; - /* we assume a quite fast sequence here ([off]->on->off) - * think of network led trigger - we cannot blink that fast, so - * in case we already have a off->on->off transition queued up, - * we refuse to queue up more. - * Revisit: fast-changing brightness. */ - if (atomic_read(&led->active) > 1) - return 0; data->next_red = (u8) value; break; case GREEN: /* bail out if there's no change */ if (data->next_green == (u8) value) return 0; - /* we assume a quite fast sequence here ([off]->on->off) - * Revisit: fast-changing brightness. */ - if (atomic_read(&led->active) > 1) - return 0; data->next_green = (u8) value; break; case BLUE: /* bail out if there's no change */ if (data->next_blue == (u8) value) return 0; - /* we assume a quite fast sequence here ([off]->on->off) - * Revisit: fast-changing brightness. */ - if (atomic_read(&led->active) > 1) - return 0; data->next_blue = (u8) value; break; @@ -506,23 +464,12 @@ static int blinkm_led_common_set(struct led_classdev *led_cdev, return -EINVAL; } - bl_work = kzalloc(sizeof(*bl_work), GFP_ATOMIC); - if (!bl_work) - return -ENOMEM; - - atomic_inc(&led->active); + blinkm_transfer_hw(led->i2c_client, BLM_GO_RGB); dev_dbg(&led->i2c_client->dev, - "#TO_SCHED# next_red = %d, next_green = %d," - " next_blue = %d, active = %d\n", + "# DONE # next_red = %d, next_green = %d," + " next_blue = %d\n", data->next_red, data->next_green, - data->next_blue, atomic_read(&led->active)); - - /* a fresh work _item_ for each change */ - bl_work->blinkm_led = led; - INIT_WORK(&bl_work->work, led_work); - /* queue work in own queue for easy sync on exit*/ - schedule_work(&bl_work->work); - + data->next_blue); return 0; } @@ -669,7 +616,6 @@ static int blinkm_probe(struct i2c_client *client, led[i]->id = i; led[i]->led_cdev.max_brightness = 255; led[i]->led_cdev.flags = LED_CORE_SUSPENDRESUME; - atomic_set(&led[i]->active, 0); switch (i) { case RED: snprintf(blinkm_led_name, sizeof(blinkm_led_name), @@ -678,6 +624,7 @@ static int blinkm_probe(struct i2c_client *client, client->addr); led[i]->led_cdev.name = blinkm_led_name; led[i]->led_cdev.brightness_set = blinkm_led_red_set; + led[i]->led_cdev.flags |= LED_BRIGHTNESS_BLOCKING; err = led_classdev_register(&client->dev, &led[i]->led_cdev); if (err < 0) { @@ -694,6 +641,7 @@ static int blinkm_probe(struct i2c_client *client, client->addr); led[i]->led_cdev.name = blinkm_led_name; led[i]->led_cdev.brightness_set = blinkm_led_green_set; + led[i]->led_cdev.flags |= LED_BRIGHTNESS_BLOCKING; err = led_classdev_register(&client->dev, &led[i]->led_cdev); if (err < 0) { @@ -710,6 +658,7 @@ static int blinkm_probe(struct i2c_client *client, client->addr); led[i]->led_cdev.name = blinkm_led_name; led[i]->led_cdev.brightness_set = blinkm_led_blue_set; + led[i]->led_cdev.flags |= LED_BRIGHTNESS_BLOCKING; err = led_classdev_register(&client->dev, &led[i]->led_cdev); if (err < 0) { @@ -746,10 +695,8 @@ static int blinkm_remove(struct i2c_client *client) int i; /* make sure no workqueue entries are pending */ - for (i = 0; i < 3; i++) { - flush_scheduled_work(); + for (i = 0; i < 3; i++) led_classdev_unregister(&data->blinkm_leds[i].led_cdev); - } /* reset rgb */ data->next_red = 0x00; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/