diff mbox

[resend,2/4] backlight: Add backlight device (un)registration notification

Message ID 1400679596-19663-3-git-send-email-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans de Goede May 21, 2014, 1:39 p.m. UTC
Some firmware drivers, ie acpi-video want to get themselves out of the
way (in some cases) when their also is a raw backlight device available.

Due to module loading ordering being unknown, acpi-video cannot be certain
that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
the final verdict wrt there being a BACKLIGHT_RAW device.

By adding notification acpi-video can listen for backlight devices showing
up after it has loaded, and unregister its backlight device if desired.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/video/backlight/backlight.c | 40 +++++++++++++++++++++++++++++++++++++
 include/linux/backlight.h           |  7 +++++++
 2 files changed, 47 insertions(+)

Comments

Rafael J. Wysocki May 21, 2014, 11:31 p.m. UTC | #1
On Wednesday, May 21, 2014 03:39:54 PM Hans de Goede wrote:
> Some firmware drivers, ie acpi-video want to get themselves out of the
> way (in some cases) when their also is a raw backlight device available.
> 
> Due to module loading ordering being unknown, acpi-video cannot be certain
> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> the final verdict wrt there being a BACKLIGHT_RAW device.
> 
> By adding notification acpi-video can listen for backlight devices showing
> up after it has loaded, and unregister its backlight device if desired.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Backlight maintainer's ACK is requisite here.

> ---
>  drivers/video/backlight/backlight.c | 40 +++++++++++++++++++++++++++++++++++++
>  include/linux/backlight.h           |  7 +++++++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index bd2172c..4280890 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -23,6 +23,7 @@
>  
>  static struct list_head backlight_dev_list;
>  static struct mutex backlight_dev_list_mutex;
> +static struct blocking_notifier_head backlight_notifier;
>  
>  static const char *const backlight_types[] = {
>  	[BACKLIGHT_RAW] = "raw",
> @@ -370,6 +371,9 @@ struct backlight_device *backlight_device_register(const char *name,
>  	list_add(&new_bd->entry, &backlight_dev_list);
>  	mutex_unlock(&backlight_dev_list_mutex);
>  
> +	blocking_notifier_call_chain(&backlight_notifier,
> +				     BACKLIGHT_REGISTERED, new_bd);
> +
>  	return new_bd;
>  }
>  EXPORT_SYMBOL(backlight_device_register);
> @@ -413,6 +417,10 @@ void backlight_device_unregister(struct backlight_device *bd)
>  		pmac_backlight = NULL;
>  	mutex_unlock(&pmac_backlight_mutex);
>  #endif
> +
> +	blocking_notifier_call_chain(&backlight_notifier,
> +				     BACKLIGHT_UNREGISTERED, bd);
> +
>  	mutex_lock(&bd->ops_lock);
>  	bd->ops = NULL;
>  	mutex_unlock(&bd->ops_lock);
> @@ -438,6 +446,36 @@ static int devm_backlight_device_match(struct device *dev, void *res,
>  }
>  
>  /**
> + * backlight_register_notifier - get notified of backlight (un)registration
> + * @nb: notifier block with the notifier to call on backlight (un)registration
> + *
> + * @return 0 on success, otherwise a negative error code
> + *
> + * Register a notifier to get notified when backlight devices get registered
> + * or unregistered.
> + */
> +int backlight_register_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_register(&backlight_notifier, nb);
> +}
> +EXPORT_SYMBOL(backlight_register_notifier);
> +
> +/**
> + * backlight_unregister_notifier - unregister a backlight notifier
> + * @nb: notifier block to unregister
> + *
> + * @return 0 on success, otherwise a negative error code
> + *
> + * Register a notifier to get notified when backlight devices get registered
> + * or unregistered.
> + */
> +int backlight_unregister_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
> +}
> +EXPORT_SYMBOL(backlight_unregister_notifier);
> +
> +/**
>   * devm_backlight_device_register - resource managed backlight_device_register()
>   * @dev: the device to register
>   * @name: the name of the device
> @@ -544,6 +582,8 @@ static int __init backlight_class_init(void)
>  	backlight_class->pm = &backlight_class_dev_pm_ops;
>  	INIT_LIST_HEAD(&backlight_dev_list);
>  	mutex_init(&backlight_dev_list_mutex);
> +	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
> +
>  	return 0;
>  }
>  
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 7264742..adb14a8 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -40,6 +40,11 @@ enum backlight_type {
>  	BACKLIGHT_TYPE_MAX,
>  };
>  
> +enum backlight_notification {
> +	BACKLIGHT_REGISTERED,
> +	BACKLIGHT_UNREGISTERED,
> +};
> +
>  struct backlight_device;
>  struct fb_info;
>  
> @@ -133,6 +138,8 @@ extern void devm_backlight_device_unregister(struct device *dev,
>  extern void backlight_force_update(struct backlight_device *bd,
>  				   enum backlight_update_reason reason);
>  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);
>  
>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
>  
>
Hans de Goede May 22, 2014, 8:44 a.m. UTC | #2
Hi,

On 05/22/2014 01:31 AM, Rafael J. Wysocki wrote:
> On Wednesday, May 21, 2014 03:39:54 PM Hans de Goede wrote:
>> Some firmware drivers, ie acpi-video want to get themselves out of the
>> way (in some cases) when their also is a raw backlight device available.
>>
>> Due to module loading ordering being unknown, acpi-video cannot be certain
>> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
>> the final verdict wrt there being a BACKLIGHT_RAW device.
>>
>> By adding notification acpi-video can listen for backlight devices showing
>> up after it has loaded, and unregister its backlight device if desired.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Backlight maintainer's ACK is requisite here.

Agreed, which is why I send this set to all 3 the backlight maintainers
directly on both postings.

What may be helpful for them is to hear from you if you're ok with the
acpi-video bits which are actually going to use this, since those will
be the only user of the new backlight api (for now).

Thanks & Regardsm

Hans




> 
>> ---
>>  drivers/video/backlight/backlight.c | 40 +++++++++++++++++++++++++++++++++++++
>>  include/linux/backlight.h           |  7 +++++++
>>  2 files changed, 47 insertions(+)
>>
>> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
>> index bd2172c..4280890 100644
>> --- a/drivers/video/backlight/backlight.c
>> +++ b/drivers/video/backlight/backlight.c
>> @@ -23,6 +23,7 @@
>>  
>>  static struct list_head backlight_dev_list;
>>  static struct mutex backlight_dev_list_mutex;
>> +static struct blocking_notifier_head backlight_notifier;
>>  
>>  static const char *const backlight_types[] = {
>>  	[BACKLIGHT_RAW] = "raw",
>> @@ -370,6 +371,9 @@ struct backlight_device *backlight_device_register(const char *name,
>>  	list_add(&new_bd->entry, &backlight_dev_list);
>>  	mutex_unlock(&backlight_dev_list_mutex);
>>  
>> +	blocking_notifier_call_chain(&backlight_notifier,
>> +				     BACKLIGHT_REGISTERED, new_bd);
>> +
>>  	return new_bd;
>>  }
>>  EXPORT_SYMBOL(backlight_device_register);
>> @@ -413,6 +417,10 @@ void backlight_device_unregister(struct backlight_device *bd)
>>  		pmac_backlight = NULL;
>>  	mutex_unlock(&pmac_backlight_mutex);
>>  #endif
>> +
>> +	blocking_notifier_call_chain(&backlight_notifier,
>> +				     BACKLIGHT_UNREGISTERED, bd);
>> +
>>  	mutex_lock(&bd->ops_lock);
>>  	bd->ops = NULL;
>>  	mutex_unlock(&bd->ops_lock);
>> @@ -438,6 +446,36 @@ static int devm_backlight_device_match(struct device *dev, void *res,
>>  }
>>  
>>  /**
>> + * backlight_register_notifier - get notified of backlight (un)registration
>> + * @nb: notifier block with the notifier to call on backlight (un)registration
>> + *
>> + * @return 0 on success, otherwise a negative error code
>> + *
>> + * Register a notifier to get notified when backlight devices get registered
>> + * or unregistered.
>> + */
>> +int backlight_register_notifier(struct notifier_block *nb)
>> +{
>> +	return blocking_notifier_chain_register(&backlight_notifier, nb);
>> +}
>> +EXPORT_SYMBOL(backlight_register_notifier);
>> +
>> +/**
>> + * backlight_unregister_notifier - unregister a backlight notifier
>> + * @nb: notifier block to unregister
>> + *
>> + * @return 0 on success, otherwise a negative error code
>> + *
>> + * Register a notifier to get notified when backlight devices get registered
>> + * or unregistered.
>> + */
>> +int backlight_unregister_notifier(struct notifier_block *nb)
>> +{
>> +	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
>> +}
>> +EXPORT_SYMBOL(backlight_unregister_notifier);
>> +
>> +/**
>>   * devm_backlight_device_register - resource managed backlight_device_register()
>>   * @dev: the device to register
>>   * @name: the name of the device
>> @@ -544,6 +582,8 @@ static int __init backlight_class_init(void)
>>  	backlight_class->pm = &backlight_class_dev_pm_ops;
>>  	INIT_LIST_HEAD(&backlight_dev_list);
>>  	mutex_init(&backlight_dev_list_mutex);
>> +	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
>> +
>>  	return 0;
>>  }
>>  
>> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
>> index 7264742..adb14a8 100644
>> --- a/include/linux/backlight.h
>> +++ b/include/linux/backlight.h
>> @@ -40,6 +40,11 @@ enum backlight_type {
>>  	BACKLIGHT_TYPE_MAX,
>>  };
>>  
>> +enum backlight_notification {
>> +	BACKLIGHT_REGISTERED,
>> +	BACKLIGHT_UNREGISTERED,
>> +};
>> +
>>  struct backlight_device;
>>  struct fb_info;
>>  
>> @@ -133,6 +138,8 @@ extern void devm_backlight_device_unregister(struct device *dev,
>>  extern void backlight_force_update(struct backlight_device *bd,
>>  				   enum backlight_update_reason reason);
>>  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);
>>  
>>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
>>  
>>
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lee Jones May 22, 2014, 9:02 a.m. UTC | #3
> >> Some firmware drivers, ie acpi-video want to get themselves out of the
> >> way (in some cases) when their also is a raw backlight device available.
> >>
> >> Due to module loading ordering being unknown, acpi-video cannot be certain
> >> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> >> the final verdict wrt there being a BACKLIGHT_RAW device.
> >>
> >> By adding notification acpi-video can listen for backlight devices showing
> >> up after it has loaded, and unregister its backlight device if desired.
> >>
> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > 
> > Backlight maintainer's ACK is requisite here.
> 
> Agreed, which is why I send this set to all 3 the backlight maintainers
> directly on both postings.
> 
> What may be helpful for them is to hear from you if you're ok with the
> acpi-video bits which are actually going to use this, since those will
> be the only user of the new backlight api (for now).

I'm happy to apply any Backlight patches which have either Bryan or
Jingoo's Ack, as they are the reviewers for the BL subsystem.

> >> ---
> >>  drivers/video/backlight/backlight.c | 40 +++++++++++++++++++++++++++++++++++++
> >>  include/linux/backlight.h           |  7 +++++++
> >>  2 files changed, 47 insertions(+)
> >>
> >> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> >> index bd2172c..4280890 100644
> >> --- a/drivers/video/backlight/backlight.c
> >> +++ b/drivers/video/backlight/backlight.c
> >> @@ -23,6 +23,7 @@
> >>  
> >>  static struct list_head backlight_dev_list;
> >>  static struct mutex backlight_dev_list_mutex;
> >> +static struct blocking_notifier_head backlight_notifier;
> >>  
> >>  static const char *const backlight_types[] = {
> >>  	[BACKLIGHT_RAW] = "raw",
> >> @@ -370,6 +371,9 @@ struct backlight_device *backlight_device_register(const char *name,
> >>  	list_add(&new_bd->entry, &backlight_dev_list);
> >>  	mutex_unlock(&backlight_dev_list_mutex);
> >>  
> >> +	blocking_notifier_call_chain(&backlight_notifier,
> >> +				     BACKLIGHT_REGISTERED, new_bd);
> >> +
> >>  	return new_bd;
> >>  }
> >>  EXPORT_SYMBOL(backlight_device_register);
> >> @@ -413,6 +417,10 @@ void backlight_device_unregister(struct backlight_device *bd)
> >>  		pmac_backlight = NULL;
> >>  	mutex_unlock(&pmac_backlight_mutex);
> >>  #endif
> >> +
> >> +	blocking_notifier_call_chain(&backlight_notifier,
> >> +				     BACKLIGHT_UNREGISTERED, bd);
> >> +
> >>  	mutex_lock(&bd->ops_lock);
> >>  	bd->ops = NULL;
> >>  	mutex_unlock(&bd->ops_lock);
> >> @@ -438,6 +446,36 @@ static int devm_backlight_device_match(struct device *dev, void *res,
> >>  }
> >>  
> >>  /**
> >> + * backlight_register_notifier - get notified of backlight (un)registration
> >> + * @nb: notifier block with the notifier to call on backlight (un)registration
> >> + *
> >> + * @return 0 on success, otherwise a negative error code
> >> + *
> >> + * Register a notifier to get notified when backlight devices get registered
> >> + * or unregistered.
> >> + */
> >> +int backlight_register_notifier(struct notifier_block *nb)
> >> +{
> >> +	return blocking_notifier_chain_register(&backlight_notifier, nb);
> >> +}
> >> +EXPORT_SYMBOL(backlight_register_notifier);
> >> +
> >> +/**
> >> + * backlight_unregister_notifier - unregister a backlight notifier
> >> + * @nb: notifier block to unregister
> >> + *
> >> + * @return 0 on success, otherwise a negative error code
> >> + *
> >> + * Register a notifier to get notified when backlight devices get registered
> >> + * or unregistered.
> >> + */
> >> +int backlight_unregister_notifier(struct notifier_block *nb)
> >> +{
> >> +	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
> >> +}
> >> +EXPORT_SYMBOL(backlight_unregister_notifier);
> >> +
> >> +/**
> >>   * devm_backlight_device_register - resource managed backlight_device_register()
> >>   * @dev: the device to register
> >>   * @name: the name of the device
> >> @@ -544,6 +582,8 @@ static int __init backlight_class_init(void)
> >>  	backlight_class->pm = &backlight_class_dev_pm_ops;
> >>  	INIT_LIST_HEAD(&backlight_dev_list);
> >>  	mutex_init(&backlight_dev_list_mutex);
> >> +	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
> >> +
> >>  	return 0;
> >>  }
> >>  
> >> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> >> index 7264742..adb14a8 100644
> >> --- a/include/linux/backlight.h
> >> +++ b/include/linux/backlight.h
> >> @@ -40,6 +40,11 @@ enum backlight_type {
> >>  	BACKLIGHT_TYPE_MAX,
> >>  };
> >>  
> >> +enum backlight_notification {
> >> +	BACKLIGHT_REGISTERED,
> >> +	BACKLIGHT_UNREGISTERED,
> >> +};
> >> +
> >>  struct backlight_device;
> >>  struct fb_info;
> >>  
> >> @@ -133,6 +138,8 @@ extern void devm_backlight_device_unregister(struct device *dev,
> >>  extern void backlight_force_update(struct backlight_device *bd,
> >>  				   enum backlight_update_reason reason);
> >>  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);
> >>  
> >>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
> >>  
> >>
> >
Jingoo Han May 26, 2014, 3:03 a.m. UTC | #4
On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
> On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
> > On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
> > > On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
> > >> Some firmware drivers, ie acpi-video want to get themselves out of the
> > >> way (in some cases) when their also is a raw backlight device available.
> > >>
> > >> Due to module loading ordering being unknown, acpi-video cannot be certain
> > >> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> > >> the final verdict wrt there being a BACKLIGHT_RAW device.
> > >>
> > >> By adding notification acpi-video can listen for backlight devices showing
> > >> up after it has loaded, and unregister its backlight device if desired.
> > >>
> > >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > >
> > > Backlight maintainer's ACK is requisite here.
> >
> > Agreed, which is why I send this set to all 3 the backlight maintainers
> > directly on both postings.
> >
> > What may be helpful for them is to hear from you if you're ok with the
> > acpi-video bits which are actually going to use this, since those will
> > be the only user of the new backlight api (for now).
> 
> I'm happy to apply any Backlight patches which have either Bryan or
> Jingoo's Ack, as they are the reviewers for the BL subsystem.

Acked-by: Jingoo Han <jg1.han@samsung.com>

Lee Jones,
Would you merge this patch into your backlight git tree?
Thank you.

Best regards,
Jingoo Han

> 
> > >> ---
> > >>  drivers/video/backlight/backlight.c | 40 +++++++++++++++++++++++++++++++++++++
> > >>  include/linux/backlight.h           |  7 +++++++
> > >>  2 files changed, 47 insertions(+)
> > >>
> > >> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> > >> index bd2172c..4280890 100644
> > >> --- a/drivers/video/backlight/backlight.c
> > >> +++ b/drivers/video/backlight/backlight.c
> > >> @@ -23,6 +23,7 @@
> > >>
> > >>  static struct list_head backlight_dev_list;
> > >>  static struct mutex backlight_dev_list_mutex;
> > >> +static struct blocking_notifier_head backlight_notifier;
> > >>
> > >>  static const char *const backlight_types[] = {
> > >>  	[BACKLIGHT_RAW] = "raw",
> > >> @@ -370,6 +371,9 @@ struct backlight_device *backlight_device_register(const char *name,
> > >>  	list_add(&new_bd->entry, &backlight_dev_list);
> > >>  	mutex_unlock(&backlight_dev_list_mutex);
> > >>
> > >> +	blocking_notifier_call_chain(&backlight_notifier,
> > >> +				     BACKLIGHT_REGISTERED, new_bd);
> > >> +
> > >>  	return new_bd;
> > >>  }
> > >>  EXPORT_SYMBOL(backlight_device_register);
> > >> @@ -413,6 +417,10 @@ void backlight_device_unregister(struct backlight_device *bd)
> > >>  		pmac_backlight = NULL;
> > >>  	mutex_unlock(&pmac_backlight_mutex);
> > >>  #endif
> > >> +
> > >> +	blocking_notifier_call_chain(&backlight_notifier,
> > >> +				     BACKLIGHT_UNREGISTERED, bd);
> > >> +
> > >>  	mutex_lock(&bd->ops_lock);
> > >>  	bd->ops = NULL;
> > >>  	mutex_unlock(&bd->ops_lock);
> > >> @@ -438,6 +446,36 @@ static int devm_backlight_device_match(struct device *dev, void *res,
> > >>  }
> > >>
> > >>  /**
> > >> + * backlight_register_notifier - get notified of backlight (un)registration
> > >> + * @nb: notifier block with the notifier to call on backlight (un)registration
> > >> + *
> > >> + * @return 0 on success, otherwise a negative error code
> > >> + *
> > >> + * Register a notifier to get notified when backlight devices get registered
> > >> + * or unregistered.
> > >> + */
> > >> +int backlight_register_notifier(struct notifier_block *nb)
> > >> +{
> > >> +	return blocking_notifier_chain_register(&backlight_notifier, nb);
> > >> +}
> > >> +EXPORT_SYMBOL(backlight_register_notifier);
> > >> +
> > >> +/**
> > >> + * backlight_unregister_notifier - unregister a backlight notifier
> > >> + * @nb: notifier block to unregister
> > >> + *
> > >> + * @return 0 on success, otherwise a negative error code
> > >> + *
> > >> + * Register a notifier to get notified when backlight devices get registered
> > >> + * or unregistered.
> > >> + */
> > >> +int backlight_unregister_notifier(struct notifier_block *nb)
> > >> +{
> > >> +	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
> > >> +}
> > >> +EXPORT_SYMBOL(backlight_unregister_notifier);
> > >> +
> > >> +/**
> > >>   * devm_backlight_device_register - resource managed backlight_device_register()
> > >>   * @dev: the device to register
> > >>   * @name: the name of the device
> > >> @@ -544,6 +582,8 @@ static int __init backlight_class_init(void)
> > >>  	backlight_class->pm = &backlight_class_dev_pm_ops;
> > >>  	INIT_LIST_HEAD(&backlight_dev_list);
> > >>  	mutex_init(&backlight_dev_list_mutex);
> > >> +	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
> > >> +
> > >>  	return 0;
> > >>  }
> > >>
> > >> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> > >> index 7264742..adb14a8 100644
> > >> --- a/include/linux/backlight.h
> > >> +++ b/include/linux/backlight.h
> > >> @@ -40,6 +40,11 @@ enum backlight_type {
> > >>  	BACKLIGHT_TYPE_MAX,
> > >>  };
> > >>
> > >> +enum backlight_notification {
> > >> +	BACKLIGHT_REGISTERED,
> > >> +	BACKLIGHT_UNREGISTERED,
> > >> +};
> > >> +
> > >>  struct backlight_device;
> > >>  struct fb_info;
> > >>
> > >> @@ -133,6 +138,8 @@ extern void devm_backlight_device_unregister(struct device *dev,
> > >>  extern void backlight_force_update(struct backlight_device *bd,
> > >>  				   enum backlight_update_reason reason);
> > >>  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);
> > >>
> > >>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki May 26, 2014, 11:03 a.m. UTC | #5
On Monday, May 26, 2014 12:03:43 PM Jingoo Han wrote:
> On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
> > On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
> > > On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
> > > > On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
> > > >> Some firmware drivers, ie acpi-video want to get themselves out of the
> > > >> way (in some cases) when their also is a raw backlight device available.
> > > >>
> > > >> Due to module loading ordering being unknown, acpi-video cannot be certain
> > > >> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> > > >> the final verdict wrt there being a BACKLIGHT_RAW device.
> > > >>
> > > >> By adding notification acpi-video can listen for backlight devices showing
> > > >> up after it has loaded, and unregister its backlight device if desired.
> > > >>
> > > >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > > >
> > > > Backlight maintainer's ACK is requisite here.
> > >
> > > Agreed, which is why I send this set to all 3 the backlight maintainers
> > > directly on both postings.
> > >
> > > What may be helpful for them is to hear from you if you're ok with the
> > > acpi-video bits which are actually going to use this, since those will
> > > be the only user of the new backlight api (for now).
> > 
> > I'm happy to apply any Backlight patches which have either Bryan or
> > Jingoo's Ack, as they are the reviewers for the BL subsystem.
> 
> Acked-by: Jingoo Han <jg1.han@samsung.com>
> 
> Lee Jones,
> Would you merge this patch into your backlight git tree?

Hans, does this series depend on things that I've applied already?  If so,
I'd very much prefer to take this series too as a whole.

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede May 26, 2014, 11:21 a.m. UTC | #6
Hi,

On 05/26/2014 01:03 PM, Rafael J. Wysocki wrote:
> On Monday, May 26, 2014 12:03:43 PM Jingoo Han wrote:
>> On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
>>> On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
>>>> On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
>>>>> On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
>>>>>> Some firmware drivers, ie acpi-video want to get themselves out of the
>>>>>> way (in some cases) when their also is a raw backlight device available.
>>>>>>
>>>>>> Due to module loading ordering being unknown, acpi-video cannot be certain
>>>>>> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
>>>>>> the final verdict wrt there being a BACKLIGHT_RAW device.
>>>>>>
>>>>>> By adding notification acpi-video can listen for backlight devices showing
>>>>>> up after it has loaded, and unregister its backlight device if desired.
>>>>>>
>>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>>>
>>>>> Backlight maintainer's ACK is requisite here.
>>>>
>>>> Agreed, which is why I send this set to all 3 the backlight maintainers
>>>> directly on both postings.
>>>>
>>>> What may be helpful for them is to hear from you if you're ok with the
>>>> acpi-video bits which are actually going to use this, since those will
>>>> be the only user of the new backlight api (for now).
>>>
>>> I'm happy to apply any Backlight patches which have either Bryan or
>>> Jingoo's Ack, as they are the reviewers for the BL subsystem.
>>
>> Acked-by: Jingoo Han <jg1.han@samsung.com>
>>
>> Lee Jones,
>> Would you merge this patch into your backlight git tree?
> 
> Hans, does this series depend on things that I've applied already?  If so,
> I'd very much prefer to take this series too as a whole.

The 3th patch in this series:
" acpi-video: Unregister the backlight device if a raw one shows up later"
depends on my "acpi-video: Add an acpi_video_unregister_backlight function"
patch, which you've applied to your linux-next branch already.

As well as on the 2nd patch in this series:
"backlight: Add backlight device (un)registration notification"

So I agree that it is a good idea to take the whole series through your tree.

Thanks & Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lee Jones May 27, 2014, 9:20 a.m. UTC | #7
> On 05/26/2014 01:03 PM, Rafael J. Wysocki wrote:
> > On Monday, May 26, 2014 12:03:43 PM Jingoo Han wrote:
> >> On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
> >>> On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
> >>>> On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
> >>>>> On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
> >>>>>> Some firmware drivers, ie acpi-video want to get themselves out of the
> >>>>>> way (in some cases) when their also is a raw backlight device available.
> >>>>>>
> >>>>>> Due to module loading ordering being unknown, acpi-video cannot be certain
> >>>>>> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> >>>>>> the final verdict wrt there being a BACKLIGHT_RAW device.
> >>>>>>
> >>>>>> By adding notification acpi-video can listen for backlight devices showing
> >>>>>> up after it has loaded, and unregister its backlight device if desired.
> >>>>>>
> >>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >>>>>
> >>>>> Backlight maintainer's ACK is requisite here.
> >>>>
> >>>> Agreed, which is why I send this set to all 3 the backlight maintainers
> >>>> directly on both postings.
> >>>>
> >>>> What may be helpful for them is to hear from you if you're ok with the
> >>>> acpi-video bits which are actually going to use this, since those will
> >>>> be the only user of the new backlight api (for now).
> >>>
> >>> I'm happy to apply any Backlight patches which have either Bryan or
> >>> Jingoo's Ack, as they are the reviewers for the BL subsystem.
> >>
> >> Acked-by: Jingoo Han <jg1.han@samsung.com>
> >>
> >> Lee Jones,
> >> Would you merge this patch into your backlight git tree?
> > 
> > Hans, does this series depend on things that I've applied already?  If so,
> > I'd very much prefer to take this series too as a whole.
> 
> The 3th patch in this series:
> " acpi-video: Unregister the backlight device if a raw one shows up later"
> depends on my "acpi-video: Add an acpi_video_unregister_backlight function"
> patch, which you've applied to your linux-next branch already.
> 
> As well as on the 2nd patch in this series:
> "backlight: Add backlight device (un)registration notification"
> 
> So I agree that it is a good idea to take the whole series through your tree.

I'm fine with that.

Rafael, could you apply the set onto an immutable branch and send me a
signed pull-request please?
Rafael J. Wysocki May 31, 2014, 10:46 p.m. UTC | #8
On Tuesday, May 27, 2014 10:20:33 AM Lee Jones wrote:
> > On 05/26/2014 01:03 PM, Rafael J. Wysocki wrote:
> > > On Monday, May 26, 2014 12:03:43 PM Jingoo Han wrote:
> > >> On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
> > >>> On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
> > >>>> On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
> > >>>>> On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
> > >>>>>> Some firmware drivers, ie acpi-video want to get themselves out of the
> > >>>>>> way (in some cases) when their also is a raw backlight device available.
> > >>>>>>
> > >>>>>> Due to module loading ordering being unknown, acpi-video cannot be certain
> > >>>>>> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> > >>>>>> the final verdict wrt there being a BACKLIGHT_RAW device.
> > >>>>>>
> > >>>>>> By adding notification acpi-video can listen for backlight devices showing
> > >>>>>> up after it has loaded, and unregister its backlight device if desired.
> > >>>>>>
> > >>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > >>>>>
> > >>>>> Backlight maintainer's ACK is requisite here.
> > >>>>
> > >>>> Agreed, which is why I send this set to all 3 the backlight maintainers
> > >>>> directly on both postings.
> > >>>>
> > >>>> What may be helpful for them is to hear from you if you're ok with the
> > >>>> acpi-video bits which are actually going to use this, since those will
> > >>>> be the only user of the new backlight api (for now).
> > >>>
> > >>> I'm happy to apply any Backlight patches which have either Bryan or
> > >>> Jingoo's Ack, as they are the reviewers for the BL subsystem.
> > >>
> > >> Acked-by: Jingoo Han <jg1.han@samsung.com>
> > >>
> > >> Lee Jones,
> > >> Would you merge this patch into your backlight git tree?
> > > 
> > > Hans, does this series depend on things that I've applied already?  If so,
> > > I'd very much prefer to take this series too as a whole.
> > 
> > The 3th patch in this series:
> > " acpi-video: Unregister the backlight device if a raw one shows up later"
> > depends on my "acpi-video: Add an acpi_video_unregister_backlight function"
> > patch, which you've applied to your linux-next branch already.
> > 
> > As well as on the 2nd patch in this series:
> > "backlight: Add backlight device (un)registration notification"
> > 
> > So I agree that it is a good idea to take the whole series through your tree.
> 
> I'm fine with that.
> 
> Rafael, could you apply the set onto an immutable branch and send me a
> signed pull-request please?

You can find this patch on the branch at

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-video

The top-most commit is 0dc6b96ac20c (ACPI / video: Add 4 new models to the
use_native_backlight DMI list).

Please feel free to pull from there if necessary, it is not going to be rebased.

Thanks!
Lee Jones June 2, 2014, 7:33 a.m. UTC | #9
On Sun, 01 Jun 2014, Rafael J. Wysocki wrote:
> On Tuesday, May 27, 2014 10:20:33 AM Lee Jones wrote:
> > > On 05/26/2014 01:03 PM, Rafael J. Wysocki wrote:
> > > > On Monday, May 26, 2014 12:03:43 PM Jingoo Han wrote:
> > > >> On Thursday, May 22, 2014 6:02 PM, Lee Jones wrote:
> > > >>> On Thursday, May 22, 2014 5:45 PM, Hans de Goede wrote:
> > > >>>> On Thursday, May 22, 2014 8:31 AM, Rafael J. Wysocki wrote:
> > > >>>>> On Wednesday, May 21, 2014 10:40 PM, Hans de Goede wrote:
> > > >>>>>> Some firmware drivers, ie acpi-video want to get themselves out of the
> > > >>>>>> way (in some cases) when their also is a raw backlight device available.
> > > >>>>>>
> > > >>>>>> Due to module loading ordering being unknown, acpi-video cannot be certain
> > > >>>>>> that the backlight_device_registered(BACKLIGHT_RAW) it does for this is
> > > >>>>>> the final verdict wrt there being a BACKLIGHT_RAW device.
> > > >>>>>>
> > > >>>>>> By adding notification acpi-video can listen for backlight devices showing
> > > >>>>>> up after it has loaded, and unregister its backlight device if desired.
> > > >>>>>>
> > > >>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > > >>>>>
> > > >>>>> Backlight maintainer's ACK is requisite here.
> > > >>>>
> > > >>>> Agreed, which is why I send this set to all 3 the backlight maintainers
> > > >>>> directly on both postings.
> > > >>>>
> > > >>>> What may be helpful for them is to hear from you if you're ok with the
> > > >>>> acpi-video bits which are actually going to use this, since those will
> > > >>>> be the only user of the new backlight api (for now).
> > > >>>
> > > >>> I'm happy to apply any Backlight patches which have either Bryan or
> > > >>> Jingoo's Ack, as they are the reviewers for the BL subsystem.
> > > >>
> > > >> Acked-by: Jingoo Han <jg1.han@samsung.com>
> > > >>
> > > >> Lee Jones,
> > > >> Would you merge this patch into your backlight git tree?
> > > > 
> > > > Hans, does this series depend on things that I've applied already?  If so,
> > > > I'd very much prefer to take this series too as a whole.
> > > 
> > > The 3th patch in this series:
> > > " acpi-video: Unregister the backlight device if a raw one shows up later"
> > > depends on my "acpi-video: Add an acpi_video_unregister_backlight function"
> > > patch, which you've applied to your linux-next branch already.
> > > 
> > > As well as on the 2nd patch in this series:
> > > "backlight: Add backlight device (un)registration notification"
> > > 
> > > So I agree that it is a good idea to take the whole series through your tree.
> > 
> > I'm fine with that.
> > 
> > Rafael, could you apply the set onto an immutable branch and send me a
> > signed pull-request please?
> 
> You can find this patch on the branch at
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-video
> 
> The top-most commit is 0dc6b96ac20c (ACPI / video: Add 4 new models to the
> use_native_backlight DMI list).
> 
> Please feel free to pull from there if necessary, it is not going to be rebased.

acpi-video contains 14 patches!  If we share patches in the future,
the branches really need to contain as few patches as possible.  I'm
happy to set-up a special 'mfd-pm' immutable branch for future
releases to save either one of use pulling in more patches into our
respective trees than is necessary.

Rather than pull all those patches in to the MFD tree, I'll simply run
the risk of a merge conflict this time.
diff mbox

Patch

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index bd2172c..4280890 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -23,6 +23,7 @@ 
 
 static struct list_head backlight_dev_list;
 static struct mutex backlight_dev_list_mutex;
+static struct blocking_notifier_head backlight_notifier;
 
 static const char *const backlight_types[] = {
 	[BACKLIGHT_RAW] = "raw",
@@ -370,6 +371,9 @@  struct backlight_device *backlight_device_register(const char *name,
 	list_add(&new_bd->entry, &backlight_dev_list);
 	mutex_unlock(&backlight_dev_list_mutex);
 
+	blocking_notifier_call_chain(&backlight_notifier,
+				     BACKLIGHT_REGISTERED, new_bd);
+
 	return new_bd;
 }
 EXPORT_SYMBOL(backlight_device_register);
@@ -413,6 +417,10 @@  void backlight_device_unregister(struct backlight_device *bd)
 		pmac_backlight = NULL;
 	mutex_unlock(&pmac_backlight_mutex);
 #endif
+
+	blocking_notifier_call_chain(&backlight_notifier,
+				     BACKLIGHT_UNREGISTERED, bd);
+
 	mutex_lock(&bd->ops_lock);
 	bd->ops = NULL;
 	mutex_unlock(&bd->ops_lock);
@@ -438,6 +446,36 @@  static int devm_backlight_device_match(struct device *dev, void *res,
 }
 
 /**
+ * backlight_register_notifier - get notified of backlight (un)registration
+ * @nb: notifier block with the notifier to call on backlight (un)registration
+ *
+ * @return 0 on success, otherwise a negative error code
+ *
+ * Register a notifier to get notified when backlight devices get registered
+ * or unregistered.
+ */
+int backlight_register_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&backlight_notifier, nb);
+}
+EXPORT_SYMBOL(backlight_register_notifier);
+
+/**
+ * backlight_unregister_notifier - unregister a backlight notifier
+ * @nb: notifier block to unregister
+ *
+ * @return 0 on success, otherwise a negative error code
+ *
+ * Register a notifier to get notified when backlight devices get registered
+ * or unregistered.
+ */
+int backlight_unregister_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
+}
+EXPORT_SYMBOL(backlight_unregister_notifier);
+
+/**
  * devm_backlight_device_register - resource managed backlight_device_register()
  * @dev: the device to register
  * @name: the name of the device
@@ -544,6 +582,8 @@  static int __init backlight_class_init(void)
 	backlight_class->pm = &backlight_class_dev_pm_ops;
 	INIT_LIST_HEAD(&backlight_dev_list);
 	mutex_init(&backlight_dev_list_mutex);
+	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
+
 	return 0;
 }
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 7264742..adb14a8 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -40,6 +40,11 @@  enum backlight_type {
 	BACKLIGHT_TYPE_MAX,
 };
 
+enum backlight_notification {
+	BACKLIGHT_REGISTERED,
+	BACKLIGHT_UNREGISTERED,
+};
+
 struct backlight_device;
 struct fb_info;
 
@@ -133,6 +138,8 @@  extern void devm_backlight_device_unregister(struct device *dev,
 extern void backlight_force_update(struct backlight_device *bd,
 				   enum backlight_update_reason reason);
 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);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)