From: Aaron Lu <aaron.lu@intel.com> To: "Rafael J. Wysocki" <rjw@rjwysocki.net>, Zhang Rui <rui.zhang@intel.com>, Jingoo Han <jingoohan1@gmail.com> Cc: linux-fbdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, Srinivas Pandruvada <srinivas.pandruvada@intel.com> Subject: [PATCH v3 1/4] video / backlight: add two APIs for drivers to use Date: Wed, 27 Apr 2016 20:45:02 +0800 [thread overview] Message-ID: <1461761105-5961-2-git-send-email-aaron.lu@intel.com> (raw) In-Reply-To: <1461761105-5961-1-git-send-email-aaron.lu@intel.com> It is useful to get the backlight device's pointer and use it to set backlight in some cases(the following patch will make use of it) so add the two APIs and export them. Signed-off-by: Aaron Lu <aaron.lu@intel.com> Acked-by: Jingoo Han <jg1.han@samsung.com> --- drivers/video/backlight/backlight.c | 43 +++++++++++++++++++++++++------------ include/linux/backlight.h | 2 ++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index bddc8b17a4d8..18901b9b1eb4 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -164,18 +164,10 @@ static ssize_t brightness_show(struct device *dev, return sprintf(buf, "%d\n", bd->props.brightness); } -static ssize_t brightness_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +int backlight_device_set_brightness(struct backlight_device *bd, + unsigned long brightness) { - int rc; - struct backlight_device *bd = to_backlight_device(dev); - unsigned long brightness; - - rc = kstrtoul(buf, 0, &brightness); - if (rc) - return rc; - - rc = -ENXIO; + int rc = -ENXIO; mutex_lock(&bd->ops_lock); if (bd->ops) { @@ -185,7 +177,7 @@ static ssize_t brightness_store(struct device *dev, pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; backlight_update_status(bd); - rc = count; + rc = 0; } } mutex_unlock(&bd->ops_lock); @@ -194,6 +186,23 @@ static ssize_t brightness_store(struct device *dev, return rc; } +EXPORT_SYMBOL(backlight_device_set_brightness); + +static ssize_t brightness_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int rc; + struct backlight_device *bd = to_backlight_device(dev); + unsigned long brightness; + + rc = kstrtoul(buf, 0, &brightness); + if (rc) + return rc; + + rc = backlight_device_set_brightness(bd, brightness); + + return rc ? rc : count; +} static DEVICE_ATTR_RW(brightness); static ssize_t type_show(struct device *dev, struct device_attribute *attr, @@ -380,7 +389,7 @@ struct backlight_device *backlight_device_register(const char *name, } EXPORT_SYMBOL(backlight_device_register); -bool backlight_device_registered(enum backlight_type type) +struct backlight_device *backlight_device_get_by_type(enum backlight_type type) { bool found = false; struct backlight_device *bd; @@ -394,7 +403,13 @@ bool backlight_device_registered(enum backlight_type type) } mutex_unlock(&backlight_dev_list_mutex); - return found; + return found ? bd : NULL; +} +EXPORT_SYMBOL(backlight_device_get_by_type); + +bool backlight_device_registered(enum backlight_type type) +{ + return backlight_device_get_by_type(type) ? true : false; } EXPORT_SYMBOL(backlight_device_registered); diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 1e7a69adbe6f..f46b88fa4a09 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -144,6 +144,8 @@ extern void backlight_force_update(struct backlight_device *bd, extern bool backlight_device_registered(enum backlight_type type); extern int backlight_register_notifier(struct notifier_block *nb); extern int backlight_unregister_notifier(struct notifier_block *nb); +extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); +extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness); #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) -- 2.5.5
WARNING: multiple messages have this Message-ID (diff)
From: Aaron Lu <aaron.lu@intel.com> To: "Rafael J. Wysocki" <rjw@rjwysocki.net>, Zhang Rui <rui.zhang@intel.com>, Jingoo Han <jingoohan1@gmail.com> Cc: linux-fbdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, Srinivas Pandruvada <srinivas.pandruvada@intel.com> Subject: [PATCH v3 1/4] video / backlight: add two APIs for drivers to use Date: Wed, 27 Apr 2016 12:45:02 +0000 [thread overview] Message-ID: <1461761105-5961-2-git-send-email-aaron.lu@intel.com> (raw) In-Reply-To: <1461761105-5961-1-git-send-email-aaron.lu@intel.com> It is useful to get the backlight device's pointer and use it to set backlight in some cases(the following patch will make use of it) so add the two APIs and export them. Signed-off-by: Aaron Lu <aaron.lu@intel.com> Acked-by: Jingoo Han <jg1.han@samsung.com> --- drivers/video/backlight/backlight.c | 43 +++++++++++++++++++++++++------------ include/linux/backlight.h | 2 ++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index bddc8b17a4d8..18901b9b1eb4 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -164,18 +164,10 @@ static ssize_t brightness_show(struct device *dev, return sprintf(buf, "%d\n", bd->props.brightness); } -static ssize_t brightness_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +int backlight_device_set_brightness(struct backlight_device *bd, + unsigned long brightness) { - int rc; - struct backlight_device *bd = to_backlight_device(dev); - unsigned long brightness; - - rc = kstrtoul(buf, 0, &brightness); - if (rc) - return rc; - - rc = -ENXIO; + int rc = -ENXIO; mutex_lock(&bd->ops_lock); if (bd->ops) { @@ -185,7 +177,7 @@ static ssize_t brightness_store(struct device *dev, pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; backlight_update_status(bd); - rc = count; + rc = 0; } } mutex_unlock(&bd->ops_lock); @@ -194,6 +186,23 @@ static ssize_t brightness_store(struct device *dev, return rc; } +EXPORT_SYMBOL(backlight_device_set_brightness); + +static ssize_t brightness_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int rc; + struct backlight_device *bd = to_backlight_device(dev); + unsigned long brightness; + + rc = kstrtoul(buf, 0, &brightness); + if (rc) + return rc; + + rc = backlight_device_set_brightness(bd, brightness); + + return rc ? rc : count; +} static DEVICE_ATTR_RW(brightness); static ssize_t type_show(struct device *dev, struct device_attribute *attr, @@ -380,7 +389,7 @@ struct backlight_device *backlight_device_register(const char *name, } EXPORT_SYMBOL(backlight_device_register); -bool backlight_device_registered(enum backlight_type type) +struct backlight_device *backlight_device_get_by_type(enum backlight_type type) { bool found = false; struct backlight_device *bd; @@ -394,7 +403,13 @@ bool backlight_device_registered(enum backlight_type type) } mutex_unlock(&backlight_dev_list_mutex); - return found; + return found ? bd : NULL; +} +EXPORT_SYMBOL(backlight_device_get_by_type); + +bool backlight_device_registered(enum backlight_type type) +{ + return backlight_device_get_by_type(type) ? true : false; } EXPORT_SYMBOL(backlight_device_registered); diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 1e7a69adbe6f..f46b88fa4a09 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -144,6 +144,8 @@ extern void backlight_force_update(struct backlight_device *bd, extern bool backlight_device_registered(enum backlight_type type); extern int backlight_register_notifier(struct notifier_block *nb); extern int backlight_unregister_notifier(struct notifier_block *nb); +extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); +extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness); #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) -- 2.5.5
next prev parent reply other threads:[~2016-04-27 12:45 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-04-27 12:45 [PATCH v3 0/4] Support INT3406 Display thermal device Aaron Lu 2016-04-27 12:45 ` Aaron Lu 2016-04-27 12:45 ` Aaron Lu [this message] 2016-04-27 12:45 ` [PATCH v3 1/4] video / backlight: add two APIs for drivers to use Aaron Lu 2016-04-27 12:45 ` [PATCH v3 2/4] video / backlight: remove the backlight_device_registered API Aaron Lu 2016-04-27 12:45 ` Aaron Lu 2016-04-27 12:45 ` [PATCH v3 3/4] ACPI/video: export acpi_video_get_levels Aaron Lu 2016-04-27 12:45 ` Aaron Lu 2016-04-27 12:45 ` [PATCH v3 4/4] Thermal: add INT3406 thermal driver Aaron Lu 2016-04-27 12:45 ` Aaron Lu 2016-05-09 7:47 ` Zhang, Rui 2016-05-09 7:47 ` Zhang, Rui 2016-05-09 7:54 ` [PATCH v3 update " Aaron Lu 2016-05-09 7:54 ` Aaron Lu 2016-05-10 8:08 ` Zhang, Rui 2016-05-10 8:08 ` Zhang, Rui 2016-05-13 22:05 ` Rafael J. Wysocki 2016-05-13 22:05 ` Rafael J. Wysocki 2016-04-27 19:38 ` [PATCH v3 0/4] Support INT3406 Display thermal device Rafael J. Wysocki 2016-04-27 19:38 ` Rafael J. Wysocki 2016-04-28 1:48 ` Aaron Lu 2016-04-28 1:48 ` Aaron Lu 2016-05-04 21:47 ` Rafael J. Wysocki 2016-05-04 21:47 ` Rafael J. Wysocki 2016-05-06 6:45 ` Aaron Lu 2016-05-06 6:45 ` Aaron Lu 2016-05-09 7:49 ` Zhang, Rui 2016-05-09 7:49 ` Zhang, Rui 2016-05-09 12:23 ` Rafael J. Wysocki 2016-05-09 12:23 ` Rafael J. Wysocki
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1461761105-5961-2-git-send-email-aaron.lu@intel.com \ --to=aaron.lu@intel.com \ --cc=jingoohan1@gmail.com \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=rjw@rjwysocki.net \ --cc=rui.zhang@intel.com \ --cc=srinivas.pandruvada@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.