diff mbox series

[01/10] backlight: Add backlight_device_get_by_name()

Message ID 20200429124830.27475-2-noralf@tronnes.org (mailing list archive)
State New, archived
Headers show
Series Generic USB Display driver | expand

Commit Message

Noralf Trønnes April 29, 2020, 12:48 p.m. UTC
Add a way to lookup a backlight device based on its name.
Will be used by a USB display gadget getting the name from configfs.

Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
 include/linux/backlight.h           |  1 +
 2 files changed, 22 insertions(+)

Comments

Lee Jones April 30, 2020, 8:32 a.m. UTC | #1
On Wed, 29 Apr 2020, Noralf Trønnes wrote:

> Add a way to lookup a backlight device based on its name.
> Will be used by a USB display gadget getting the name from configfs.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: Jingoo Han <jingoohan1@gmail.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
>  include/linux/backlight.h           |  1 +
>  2 files changed, 22 insertions(+)

Once reviewed, can this patch be applied on its own?

My guess is that it can't, as the other patches in this set depend on
it, right?  If this assumption is true, you need to send me the rest
of the set.

FYI: It's normally better to send the whole set to everyone, as it
provides visibility on current review (or lack there of) status of the
other patches and allows each of the maintainers to discuss possible
merge strategies.

> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index cac3e35d7630..92d80aa0c0ef 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -432,6 +432,27 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
>  }
>  EXPORT_SYMBOL(backlight_device_get_by_type);
>  
> +/**
> + * backlight_device_get_by_name - Get backlight device by name
> + * @name: Device name
> + *
> + * This function looks up a backlight device by its name. It obtains a reference
> + * on the backlight device and it is the caller's responsibility to drop the
> + * reference by calling backlight_put().
> + *
> + * Returns:
> + * A pointer to the backlight device if found, otherwise NULL.
> + */
> +struct backlight_device *backlight_device_get_by_name(const char *name)
> +{
> +	struct device *dev;
> +
> +	dev = class_find_device_by_name(backlight_class, name);
> +
> +	return dev ? to_backlight_device(dev) : NULL;
> +}
> +EXPORT_SYMBOL(backlight_device_get_by_name);
> +
>  /**
>   * backlight_device_unregister - unregisters a backlight device object.
>   * @bd: the backlight device object to be unregistered and freed.
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index c7d6b2e8c3b5..56e4580d4f55 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -190,6 +190,7 @@ extern void backlight_force_update(struct backlight_device *bd,
>  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);
> +struct backlight_device *backlight_device_get_by_name(const char *name);
>  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)
Noralf Trønnes April 30, 2020, 9:20 a.m. UTC | #2
Den 30.04.2020 10.32, skrev Lee Jones:
> On Wed, 29 Apr 2020, Noralf Trønnes wrote:
> 
>> Add a way to lookup a backlight device based on its name.
>> Will be used by a USB display gadget getting the name from configfs.
>>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Cc: Daniel Thompson <daniel.thompson@linaro.org>
>> Cc: Jingoo Han <jingoohan1@gmail.com>
>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
>> ---
>>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
>>  include/linux/backlight.h           |  1 +
>>  2 files changed, 22 insertions(+)
> 
> Once reviewed, can this patch be applied on its own?
> 

If you can apply it for 5.8, then we're good. DRM has cutoff at -rc5 and
the driver won't be ready for that. This patch has this dependency
chain: usb -> drm -> backlight. So if you can apply it for 5.8, things
gets easier.

> My guess is that it can't, as the other patches in this set depend on
> it, right?  If this assumption is true, you need to send me the rest
> of the set.
> 
> FYI: It's normally better to send the whole set to everyone, as it
> provides visibility on current review (or lack there of) status of the
> other patches and allows each of the maintainers to discuss possible
> merge strategies.

dri-devel is the ML for backlight so I assumed you got the full set.
I have had trouble in the past with my email provider dropping parts of
a series when I had to many recipients.

Noralf.

> 
>> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
>> index cac3e35d7630..92d80aa0c0ef 100644
>> --- a/drivers/video/backlight/backlight.c
>> +++ b/drivers/video/backlight/backlight.c
>> @@ -432,6 +432,27 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
>>  }
>>  EXPORT_SYMBOL(backlight_device_get_by_type);
>>  
>> +/**
>> + * backlight_device_get_by_name - Get backlight device by name
>> + * @name: Device name
>> + *
>> + * This function looks up a backlight device by its name. It obtains a reference
>> + * on the backlight device and it is the caller's responsibility to drop the
>> + * reference by calling backlight_put().
>> + *
>> + * Returns:
>> + * A pointer to the backlight device if found, otherwise NULL.
>> + */
>> +struct backlight_device *backlight_device_get_by_name(const char *name)
>> +{
>> +	struct device *dev;
>> +
>> +	dev = class_find_device_by_name(backlight_class, name);
>> +
>> +	return dev ? to_backlight_device(dev) : NULL;
>> +}
>> +EXPORT_SYMBOL(backlight_device_get_by_name);
>> +
>>  /**
>>   * backlight_device_unregister - unregisters a backlight device object.
>>   * @bd: the backlight device object to be unregistered and freed.
>> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
>> index c7d6b2e8c3b5..56e4580d4f55 100644
>> --- a/include/linux/backlight.h
>> +++ b/include/linux/backlight.h
>> @@ -190,6 +190,7 @@ extern void backlight_force_update(struct backlight_device *bd,
>>  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);
>> +struct backlight_device *backlight_device_get_by_name(const char *name);
>>  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)
>
Lee Jones April 30, 2020, 10:15 a.m. UTC | #3
On Thu, 30 Apr 2020, Noralf Trønnes wrote:

> 
> 
> Den 30.04.2020 10.32, skrev Lee Jones:
> > On Wed, 29 Apr 2020, Noralf Trønnes wrote:
> > 
> >> Add a way to lookup a backlight device based on its name.
> >> Will be used by a USB display gadget getting the name from configfs.
> >>
> >> Cc: Lee Jones <lee.jones@linaro.org>
> >> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> >> Cc: Jingoo Han <jingoohan1@gmail.com>
> >> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> >> ---
> >>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
> >>  include/linux/backlight.h           |  1 +
> >>  2 files changed, 22 insertions(+)
> > 
> > Once reviewed, can this patch be applied on its own?
> > 
> 
> If you can apply it for 5.8, then we're good. DRM has cutoff at -rc5 and
> the driver won't be ready for that. This patch has this dependency
> chain: usb -> drm -> backlight. So if you can apply it for 5.8, things
> gets easier.
> 
> > My guess is that it can't, as the other patches in this set depend on
> > it, right?  If this assumption is true, you need to send me the rest
> > of the set.
> > 
> > FYI: It's normally better to send the whole set to everyone, as it
> > provides visibility on current review (or lack there of) status of the
> > other patches and allows each of the maintainers to discuss possible
> > merge strategies.
> 
> dri-devel is the ML for backlight so I assumed you got the full set.

dri-devel isn't the ML for Backlight.  It's an interested party.

I certainly have no intention of subscribing to it.

> I have had trouble in the past with my email provider dropping parts of
> a series when I had to many recipients.

Without visibility into the other patches in the set, things become
more difficult.  Maybe use a different/better email provider.
Noralf Trønnes April 30, 2020, 10:42 a.m. UTC | #4
Den 30.04.2020 12.15, skrev Lee Jones:
> On Thu, 30 Apr 2020, Noralf Trønnes wrote:
> 
>>
>>
>> Den 30.04.2020 10.32, skrev Lee Jones:
>>> On Wed, 29 Apr 2020, Noralf Trønnes wrote:
>>>
>>>> Add a way to lookup a backlight device based on its name.
>>>> Will be used by a USB display gadget getting the name from configfs.
>>>>
>>>> Cc: Lee Jones <lee.jones@linaro.org>
>>>> Cc: Daniel Thompson <daniel.thompson@linaro.org>
>>>> Cc: Jingoo Han <jingoohan1@gmail.com>
>>>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
>>>> ---
>>>>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
>>>>  include/linux/backlight.h           |  1 +
>>>>  2 files changed, 22 insertions(+)
>>>
>>> Once reviewed, can this patch be applied on its own?
>>>
>>
>> If you can apply it for 5.8, then we're good. DRM has cutoff at -rc5 and
>> the driver won't be ready for that. This patch has this dependency
>> chain: usb -> drm -> backlight. So if you can apply it for 5.8, things
>> gets easier.
>>
>>> My guess is that it can't, as the other patches in this set depend on
>>> it, right?  If this assumption is true, you need to send me the rest
>>> of the set.
>>>
>>> FYI: It's normally better to send the whole set to everyone, as it
>>> provides visibility on current review (or lack there of) status of the
>>> other patches and allows each of the maintainers to discuss possible
>>> merge strategies.
>>
>> dri-devel is the ML for backlight so I assumed you got the full set.
> 
> dri-devel isn't the ML for Backlight.  It's an interested party.

Oh, I thought it was strange, but kernel development has all kinds of
things that seems strange to me, so I just went with it.

> 
> I certainly have no intention of subscribing to it.
> 
>> I have had trouble in the past with my email provider dropping parts of
>> a series when I had to many recipients.
> 
> Without visibility into the other patches in the set, things become
> more difficult.  Maybe use a different/better email provider.
> 

Yeah, you need to have context, I have resent the series to you, Daniel
and Jingoo.

Noralf.
Daniel Vetter April 30, 2020, 2:02 p.m. UTC | #5
On Thu, Apr 30, 2020 at 11:15:29AM +0100, Lee Jones wrote:
> On Thu, 30 Apr 2020, Noralf Trønnes wrote:
> 
> > 
> > 
> > Den 30.04.2020 10.32, skrev Lee Jones:
> > > On Wed, 29 Apr 2020, Noralf Trønnes wrote:
> > > 
> > >> Add a way to lookup a backlight device based on its name.
> > >> Will be used by a USB display gadget getting the name from configfs.
> > >>
> > >> Cc: Lee Jones <lee.jones@linaro.org>
> > >> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> > >> Cc: Jingoo Han <jingoohan1@gmail.com>
> > >> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> > >> ---
> > >>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
> > >>  include/linux/backlight.h           |  1 +
> > >>  2 files changed, 22 insertions(+)
> > > 
> > > Once reviewed, can this patch be applied on its own?
> > > 
> > 
> > If you can apply it for 5.8, then we're good. DRM has cutoff at -rc5 and
> > the driver won't be ready for that. This patch has this dependency
> > chain: usb -> drm -> backlight. So if you can apply it for 5.8, things
> > gets easier.
> > 
> > > My guess is that it can't, as the other patches in this set depend on
> > > it, right?  If this assumption is true, you need to send me the rest
> > > of the set.
> > > 
> > > FYI: It's normally better to send the whole set to everyone, as it
> > > provides visibility on current review (or lack there of) status of the
> > > other patches and allows each of the maintainers to discuss possible
> > > merge strategies.

Unfortunately this doesn't hold universally, since once you cc too many
people smtp servers start throwing your mails away. Generally only happens
for bigger refactorings, so pretty much anyone working cross-tree doesn't
do this because it doesn't work.

> > dri-devel is the ML for backlight so I assumed you got the full set.
> 
> dri-devel isn't the ML for Backlight.  It's an interested party.
> 
> I certainly have no intention of subscribing to it.

dri-devel is on lore so that you can grab missing patches. No need to
subscribe. I've only manged to get this sorted recently (last autumn or
so), but it's finally done.
-Daniel

> > I have had trouble in the past with my email provider dropping parts of
> > a series when I had to many recipients.
> 
> Without visibility into the other patches in the set, things become
> more difficult.  Maybe use a different/better email provider.
> 
> -- 
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sam Ravnborg May 3, 2020, 7:13 a.m. UTC | #6
Hi Noralf.

On Wed, Apr 29, 2020 at 02:48:21PM +0200, Noralf Trønnes wrote:
> Add a way to lookup a backlight device based on its name.
> Will be used by a USB display gadget getting the name from configfs.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: Jingoo Han <jingoohan1@gmail.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Simple and well-documented.
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
>  include/linux/backlight.h           |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index cac3e35d7630..92d80aa0c0ef 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -432,6 +432,27 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
>  }
>  EXPORT_SYMBOL(backlight_device_get_by_type);
>  
> +/**
> + * backlight_device_get_by_name - Get backlight device by name
> + * @name: Device name
> + *
> + * This function looks up a backlight device by its name. It obtains a reference
> + * on the backlight device and it is the caller's responsibility to drop the
> + * reference by calling backlight_put().
> + *
> + * Returns:
> + * A pointer to the backlight device if found, otherwise NULL.
> + */
> +struct backlight_device *backlight_device_get_by_name(const char *name)
> +{
> +	struct device *dev;
> +
> +	dev = class_find_device_by_name(backlight_class, name);
> +
> +	return dev ? to_backlight_device(dev) : NULL;
> +}
> +EXPORT_SYMBOL(backlight_device_get_by_name);
> +
>  /**
>   * backlight_device_unregister - unregisters a backlight device object.
>   * @bd: the backlight device object to be unregistered and freed.
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index c7d6b2e8c3b5..56e4580d4f55 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -190,6 +190,7 @@ extern void backlight_force_update(struct backlight_device *bd,
>  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);
> +struct backlight_device *backlight_device_get_by_name(const char *name);
>  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.23.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Lee Jones May 4, 2020, 7:10 a.m. UTC | #7
On Thu, 30 Apr 2020, Daniel Vetter wrote:

> On Thu, Apr 30, 2020 at 11:15:29AM +0100, Lee Jones wrote:
> > On Thu, 30 Apr 2020, Noralf Trønnes wrote:
> > 
> > > 
> > > 
> > > Den 30.04.2020 10.32, skrev Lee Jones:
> > > > On Wed, 29 Apr 2020, Noralf Trønnes wrote:
> > > > 
> > > >> Add a way to lookup a backlight device based on its name.
> > > >> Will be used by a USB display gadget getting the name from configfs.
> > > >>
> > > >> Cc: Lee Jones <lee.jones@linaro.org>
> > > >> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> > > >> Cc: Jingoo Han <jingoohan1@gmail.com>
> > > >> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> > > >> ---
> > > >>  drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
> > > >>  include/linux/backlight.h           |  1 +
> > > >>  2 files changed, 22 insertions(+)
> > > > 
> > > > Once reviewed, can this patch be applied on its own?
> > > > 
> > > 
> > > If you can apply it for 5.8, then we're good. DRM has cutoff at -rc5 and
> > > the driver won't be ready for that. This patch has this dependency
> > > chain: usb -> drm -> backlight. So if you can apply it for 5.8, things
> > > gets easier.
> > > 
> > > > My guess is that it can't, as the other patches in this set depend on
> > > > it, right?  If this assumption is true, you need to send me the rest
> > > > of the set.
> > > > 
> > > > FYI: It's normally better to send the whole set to everyone, as it
> > > > provides visibility on current review (or lack there of) status of the
> > > > other patches and allows each of the maintainers to discuss possible
> > > > merge strategies.
> 
> Unfortunately this doesn't hold universally, since once you cc too many
> people smtp servers start throwing your mails away. Generally only happens
> for bigger refactorings, so pretty much anyone working cross-tree doesn't
> do this because it doesn't work.

I haven't experienced issues with SMTP servers.  Although I am aware
of a few mailing lists that are configured to require moderator
intervention if the recipient list reaches a given length.

> > > dri-devel is the ML for backlight so I assumed you got the full set.
> > 
> > dri-devel isn't the ML for Backlight.  It's an interested party.
> > 
> > I certainly have no intention of subscribing to it.
> 
> dri-devel is on lore so that you can grab missing patches. No need to
> subscribe. I've only manged to get this sorted recently (last autumn or
> so), but it's finally done.

This is helpful.  Thanks for doing the work required to make this
happen.  It's still infinitely more convenient to have the full set
in my inbox available for review.  As someone who works cross-
subsystem a lot, I can tell you that it works well in the vast
majority of cases.

Maybe just add the listed (in 'MAINTAINERS') maintainers and possibly
the reviewers.  Obviously all of the secondary interested parties that
get_maintainer.pl recommends should be omitted.

> > > I have had trouble in the past with my email provider dropping parts of
> > > a series when I had to many recipients.
> > 
> > Without visibility into the other patches in the set, things become
> > more difficult.  Maybe use a different/better email provider.
diff mbox series

Patch

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index cac3e35d7630..92d80aa0c0ef 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -432,6 +432,27 @@  struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
 }
 EXPORT_SYMBOL(backlight_device_get_by_type);
 
+/**
+ * backlight_device_get_by_name - Get backlight device by name
+ * @name: Device name
+ *
+ * This function looks up a backlight device by its name. It obtains a reference
+ * on the backlight device and it is the caller's responsibility to drop the
+ * reference by calling backlight_put().
+ *
+ * Returns:
+ * A pointer to the backlight device if found, otherwise NULL.
+ */
+struct backlight_device *backlight_device_get_by_name(const char *name)
+{
+	struct device *dev;
+
+	dev = class_find_device_by_name(backlight_class, name);
+
+	return dev ? to_backlight_device(dev) : NULL;
+}
+EXPORT_SYMBOL(backlight_device_get_by_name);
+
 /**
  * backlight_device_unregister - unregisters a backlight device object.
  * @bd: the backlight device object to be unregistered and freed.
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index c7d6b2e8c3b5..56e4580d4f55 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -190,6 +190,7 @@  extern void backlight_force_update(struct backlight_device *bd,
 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);
+struct backlight_device *backlight_device_get_by_name(const char *name);
 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)