Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934359AbbHKJvW (ORCPT ); Tue, 11 Aug 2015 05:51:22 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:38820 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964936AbbHKJjM (ORCPT ); Tue, 11 Aug 2015 05:39:12 -0400 X-AuditID: cbfee61b-f79706d000001b96-fb-55c9c2a1d26f 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, Jacek Anaszewski , Ingi Kim , Andrew Lunn , Sakari Ailus , Pavel Machek Subject: [PATCH/RFC v5 07/57] leds: Drivers shouldn't enforce SYNC/ASYNC brightness setting Date: Tue, 11 Aug 2015 11:37:20 +0200 Message-id: <1439285890-27329-8-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+NgFtrMLMWRmVeSWpSXmKPExsVy+t9jQd2Fh06GGjxcIG9x/u4hZoujOycy Wey4+YXNovfqc0aLy7vmsFlsfbOO0eLuqaNsFrt3PWW1+LTlG5NFZ980Fgcuj52z7rJ7zDsZ 6LFzx2cmjz3zf7B69G1ZxeixYvV3do+mU+2sHp83yQVwRHHZpKTmZJalFunbJXBlvN67gKng rXvFyg1LWBoY99p0MXJySAiYSGz88p8FwhaTuHBvPVsXIxeHkMAsRomu41OZIJyfjBKrZ21k BaliEzCU+PniNVCCg0NEQE5i55lKkBpmgQVMEgd/7mYCqREWiJXoX/6NHcRmEVCV6DzdDLaB V8BD4smX06wgvRICChJzJoEdwSngKXH9+SJGEFsIqOT47Ca2CYy8CxgZVjFKpBYkFxQnpeca 5aWW6xUn5haX5qXrJefnbmIEB+Uz6R2Mh3e5H2IU4GBU4uEV8DwZKsSaWFZcmXuIUYKDWUmE t3AqUIg3JbGyKrUoP76oNCe1+BCjNAeLkjivvsmmUCGB9MSS1OzU1ILUIpgsEwenVANjwAUG 3pl2AvsdVY5y1WXkiyn+XuijveTAlPu/F0xhvMCqHRc3T/fTeqZzXNYcTyaVzFi1I0i83DJA XypXXIlV8320P98OB60PvZ48txU+TtztkDfJ+Yl3VkHvahPrzAUbspLN+W8Wxj/7xyhnutvg 3695eVxpHUdnTv+VJ5arlzdz5/Tf5y8rsRRnJBpqMRcVJwIAwpZceUYCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9198 Lines: 249 This patch removes brightness_set_sync op as well as SET_BRIGHTNESS_ASYNC and SET_BRIGHTNESS sync flags. led_set_brightness now calls led_set_brightness_nosleep rather then choosing between sync and async op basing on the flags defined by the driver. Now if a user wants to make sure that brightness will be set synchronously it has to use led_set_brightness_sync API. Signed-off-by: Jacek Anaszewski Cc: Ingi Kim Cc: Bryan Wu Cc: Andrew Lunn Cc: Sakari Ailus Cc: Pavel Machek Cc: Stas Sergeev --- drivers/leds/led-class-flash.c | 7 ------- drivers/leds/led-class.c | 2 -- drivers/leds/led-core.c | 22 +++------------------- drivers/leds/leds-aat1290.c | 12 ------------ drivers/leds/leds-ktd2692.c | 12 ------------ drivers/leds/leds-max77693.c | 12 ------------ include/linux/leds.h | 16 ++++------------ 7 files changed, 7 insertions(+), 76 deletions(-) diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c index 3b25734..68c3f36 100644 --- a/drivers/leds/led-class-flash.c +++ b/drivers/leds/led-class-flash.c @@ -298,9 +298,6 @@ int led_classdev_flash_register(struct device *parent, led_cdev = &fled_cdev->led_cdev; if (led_cdev->flags & LED_DEV_CAP_FLASH) { - if (!led_cdev->brightness_set_sync) - return -EINVAL; - ops = fled_cdev->ops; if (!ops || !ops->strobe_set) return -EINVAL; @@ -316,10 +313,6 @@ int led_classdev_flash_register(struct device *parent, if (ret < 0) return ret; - /* Setting a torch brightness needs to have immediate effect */ - led_cdev->flags &= ~SET_BRIGHTNESS_ASYNC; - led_cdev->flags |= SET_BRIGHTNESS_SYNC; - return 0; } EXPORT_SYMBOL_GPL(led_classdev_flash_register); diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index bd32919..5932c4c 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -285,8 +285,6 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) WARN_ON((led_cdev->flags & LED_BRIGHTNESS_BLOCKING) && !led_cdev->brightness_set); - led_cdev->flags |= SET_BRIGHTNESS_ASYNC; - led_update_brightness(led_cdev); INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed); diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 14377ea..b36f50e 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -118,8 +118,6 @@ EXPORT_SYMBOL_GPL(led_stop_software_blink); void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness) { - int ret = 0; - /* * In case blinking is on delay brightness setting * until the next timer tick. @@ -137,20 +135,9 @@ void led_set_brightness(struct led_classdev *led_cdev, */ led_cdev->flags |= LED_BLINK_DISABLE; led_set_brightness_async(led_cdev, brightness); - return; + } else { + led_set_brightness_nosleep(led_cdev, brightness); } - - if (led_cdev->flags & SET_BRIGHTNESS_ASYNC) { - led_set_brightness_async(led_cdev, brightness); - return; - } else if (led_cdev->flags & SET_BRIGHTNESS_SYNC) - ret = led_set_brightness_sync(led_cdev, brightness); - else - ret = -EINVAL; - - if (ret < 0) - dev_dbg(led_cdev->dev, "Setting LED brightness failed (%d)\n", - ret); } EXPORT_SYMBOL(led_set_brightness); @@ -164,10 +151,7 @@ int led_set_brightness_sync(struct led_classdev *led_cdev, if (led_cdev->flags & LED_SUSPENDED) return 0; - if (led_cdev->brightness_set_sync) - ret = led_cdev->brightness_set_sync(led_cdev, - led_cdev->brightness); - else if (led_cdev->brightness_set_nonblocking) + if (led_cdev->brightness_set_nonblocking) led_cdev->brightness_set_nonblocking(led_cdev, led_cdev->brightness); else if (led_cdev->brightness_set) diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c index fd7c25f..0ecaf76 100644 --- a/drivers/leds/leds-aat1290.c +++ b/drivers/leds/leds-aat1290.c @@ -180,17 +180,6 @@ static void aat1290_led_brightness_set(struct led_classdev *led_cdev, schedule_work(&led->work_brightness_set); } -static int aat1290_led_brightness_set_sync(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); - struct aat1290_led *led = fled_cdev_to_led(fled_cdev); - - aat1290_brightness_set(led, brightness); - - return 0; -} - static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool state) @@ -510,7 +499,6 @@ static int aat1290_led_probe(struct platform_device *pdev) /* Initialize LED Flash class device */ led_cdev->brightness_set = aat1290_led_brightness_set; - led_cdev->brightness_set_sync = aat1290_led_brightness_set_sync; led_cdev->max_brightness = led_cfg.max_brightness; led_cdev->flags |= LED_DEV_CAP_FLASH; INIT_WORK(&led->work_brightness_set, aat1290_brightness_set_work); diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c index 2ae8c4d..7f6758d 100644 --- a/drivers/leds/leds-ktd2692.c +++ b/drivers/leds/leds-ktd2692.c @@ -194,17 +194,6 @@ static void ktd2692_led_brightness_set(struct led_classdev *led_cdev, schedule_work(&led->work_brightness_set); } -static int ktd2692_led_brightness_set_sync(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); - struct ktd2692_context *led = fled_cdev_to_led(fled_cdev); - - ktd2692_brightness_set(led, brightness); - - return 0; -} - static int ktd2692_led_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool state) { @@ -382,7 +371,6 @@ static int ktd2692_probe(struct platform_device *pdev) led_cdev->max_brightness = led_cfg.max_brightness; led_cdev->brightness_set = ktd2692_led_brightness_set; - led_cdev->brightness_set_sync = ktd2692_led_brightness_set_sync; led_cdev->flags |= LED_CORE_SUSPENDRESUME | LED_DEV_CAP_FLASH; mutex_init(&led->lock); diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c index df348a0..856d929 100644 --- a/drivers/leds/leds-max77693.c +++ b/drivers/leds/leds-max77693.c @@ -511,17 +511,6 @@ static void max77693_led_brightness_set_work( /* LED subsystem callbacks */ -static int max77693_led_brightness_set_sync( - struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); - struct max77693_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); - struct max77693_led_device *led = sub_led_to_led(sub_led); - - return __max77693_led_brightness_set(led, sub_led->fled_id, value); -} - static void max77693_led_brightness_set( struct led_classdev *led_cdev, enum led_brightness value) @@ -932,7 +921,6 @@ static void max77693_init_fled_cdev(struct max77693_sub_led *sub_led, led_cdev->name = led_cfg->label[fled_id]; led_cdev->brightness_set = max77693_led_brightness_set; - led_cdev->brightness_set_sync = max77693_led_brightness_set_sync; led_cdev->max_brightness = (led->iout_joint ? led_cfg->iout_torch_max[FLED1] + led_cfg->iout_torch_max[FLED2] : diff --git a/include/linux/leds.h b/include/linux/leds.h index 9603a73..45cb93d 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -45,11 +45,9 @@ struct led_classdev { #define LED_BLINK_ONESHOT_STOP (1 << 18) #define LED_BLINK_INVERT (1 << 19) #define LED_SYSFS_DISABLE (1 << 20) -#define SET_BRIGHTNESS_ASYNC (1 << 21) -#define SET_BRIGHTNESS_SYNC (1 << 22) -#define LED_DEV_CAP_FLASH (1 << 23) -#define LED_BRIGHTNESS_BLOCKING (1 << 24) -#define LED_BLINK_DISABLE (1 << 25) +#define LED_DEV_CAP_FLASH (1 << 21) +#define LED_BRIGHTNESS_BLOCKING (1 << 22) +#define LED_BLINK_DISABLE (1 << 23) /* Set LED brightness level */ /* Intended for drivers that may set brightness in a blocking way. */ @@ -58,12 +56,6 @@ struct led_classdev { /* Intended for drivers that set brightness in a non-blocking way */ void (*brightness_set_nonblocking)(struct led_classdev *led_cdev, enum led_brightness brightness); - /* - * Set LED brightness level immediately - it can block the caller for - * the time required for accessing a LED device register. - */ - int (*brightness_set_sync)(struct led_classdev *led_cdev, - enum led_brightness brightness); /* Get LED brightness level */ enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); @@ -162,7 +154,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, * * Set an LED's brightness, and, if necessary, cancel the * software blink timer that implements blinking when the - * hardware doesn't. + * hardware doesn't. This function is guaranteed not to sleep. */ extern void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness); -- 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/