mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Meghana Madhyastha <meghana.madhyastha@gmail.com>
Cc: "Lee Jones" <lee.jones@linaro.org>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Tomi Valkeinen" <tomi.valkeinen@ti.com>,
	"Daniel Vetter" <daniel.vetter@intel.com>,
	"Sean Paul" <seanpaul@chromium.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v17 03/10] video: backlight: Add of_find_backlight helper in backlight.c
Date: Fri, 19 Jan 2018 11:05:56 +0000	[thread overview]
Message-ID: <20180119110556.q2z47isvdcnly2e2@oak.lan> (raw)
In-Reply-To: <116d160ba78be2e6dcbdcb6855622bce67da9472.1516358037.git.meghana.madhyastha@gmail.com>

On Fri, Jan 19, 2018 at 10:42:15AM +0000, Meghana Madhyastha wrote:
> Add of_find_backlight, a helper function which is a generic version
> of tinydrm_of_find_backlight that can be used by other drivers to avoid
> repetition of code and simplify things.
> 
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>

Didn't I already ack this one?


> ---
> changes in v17:
> -rebase with drm-misc-next
> -convert st7735r callers from tinydrm specific helpers
>  to new generic backlight helpers
> -remove select BACKLIGHT_LCD_SUPPORT
>  and select BACKLIGHT_CLASS_DEVICE from
>  tinydrm/Kconfig
> 
>  drivers/video/backlight/backlight.c | 43 +++++++++++++++++++++++++++++++++++++
>  include/linux/backlight.h           | 19 ++++++++++++++++
>  2 files changed, 62 insertions(+)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 8049e7656..553bf5c48 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -580,6 +580,49 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
>  EXPORT_SYMBOL(of_find_backlight_by_node);
>  #endif
>  
> +/**
> + * of_find_backlight - Get backlight device
> + * @dev: Device
> + *
> + * This function looks for a property named 'backlight' on the DT node
> + * connected to @dev and looks up the backlight device.
> + *
> + * Call backlight_put() to drop the reference on the backlight device.
> + *
> + * Returns:
> + * A pointer to the backlight device if found.
> + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
> + * device is found.
> + * NULL if there's no backlight property.
> + */
> +struct backlight_device *of_find_backlight(struct device *dev)
> +{
> +	struct backlight_device *bd = NULL;
> +	struct device_node *np;
> +
> +	if (!dev)
> +		return NULL;
> +
> +	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> +		np = of_parse_phandle(dev->of_node, "backlight", 0);
> +		if (np) {
> +			bd = of_find_backlight_by_node(np);
> +			of_node_put(np);
> +			if (!bd)
> +				return ERR_PTR(-EPROBE_DEFER);
> +			/*
> +			 * Note: gpio_backlight uses brightness as
> +			 * power state during probe
> +			 */
> +			if (!bd->props.brightness)
> +				bd->props.brightness = bd->props.max_brightness;
> +		}
> +	}
> +
> +	return bd;
> +}
> +EXPORT_SYMBOL(of_find_backlight);
> +
>  static void __exit backlight_class_exit(void)
>  {
>  	class_destroy(backlight_class);
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index ace825e2c..ddc9bade4 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -162,6 +162,16 @@ static inline int backlight_disable(struct backlight_device *bd)
>  	return backlight_update_status(bd);
>  }
>  
> +/**
> + * backlight_put - Drop backlight reference
> + * @bd: the backlight device to put
> + */
> +static inline void backlight_put(struct backlight_device *bd)
> +{
> +	if (bd)
> +		put_device(&bd->dev);
> +}
> +
>  extern struct backlight_device *backlight_device_register(const char *name,
>  	struct device *dev, void *devdata, const struct backlight_ops *ops,
>  	const struct backlight_properties *props);
> @@ -205,4 +215,13 @@ of_find_backlight_by_node(struct device_node *node)
>  }
>  #endif
>  
> +#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
> +struct backlight_device *of_find_backlight(struct device *dev);
> +#else
> +static inline struct backlight_device *of_find_backlight(struct device *dev)
> +{
> +	return NULL;
> +}
> +#endif
> +
>  #endif
> -- 
> 2.11.0
> 

  reply	other threads:[~2018-01-19 11:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 10:37 [PATCH v17 00/10] Add backlight helper functions Meghana Madhyastha
2018-01-19 10:39 ` [PATCH v17 01/10] video: backlight: Add helpers to enable and disable backlight Meghana Madhyastha
2018-01-19 11:04   ` Daniel Thompson
2018-01-19 14:26     ` Lee Jones
2018-01-19 10:40 ` [PATCH v17 02/10] drm/tinydrm: Convert tinydrm_enable/disable_backlight to backlight_enable/disable Meghana Madhyastha
2018-01-19 10:42 ` [PATCH v17 03/10] video: backlight: Add of_find_backlight helper in backlight.c Meghana Madhyastha
2018-01-19 11:05   ` Daniel Thompson [this message]
2018-01-21 18:35     ` Noralf Trønnes
2018-01-21 18:44   ` Noralf Trønnes
2018-01-19 10:43 ` [PATCH v17 04/10] drm/tinydrm: Replace tinydrm_of_find_backlight with of_find_backlight Meghana Madhyastha
2018-01-19 10:44 ` [PATCH v17 05/10] video: backlight: Add devres versions of of_find_backlight Meghana Madhyastha
2018-01-19 11:06   ` Daniel Thompson
2018-01-19 10:46 ` [PATCH v17 06/10] drm/tinydrm: Call devres version " Meghana Madhyastha
2018-01-21 18:42   ` Noralf Trønnes
2018-01-19 10:46 ` [PATCH v17 07/10] drm/panel: Use backlight_enable/disable helpers Meghana Madhyastha
2018-01-19 10:47 ` [PATCH v17 08/10] drm/omapdrm: " Meghana Madhyastha
2018-01-19 10:47 ` [PATCH v17 09/10] drm/panel: Use of_find_backlight helper Meghana Madhyastha
2018-01-21 18:39   ` Noralf Trønnes
2018-01-19 10:48 ` [PATCH v17 10/10] drm/omapdrm: " Meghana Madhyastha
2018-01-19 11:18 ` [PATCH v17 00/10] Add backlight helper functions Daniel Thompson

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=20180119110556.q2z47isvdcnly2e2@oak.lan \
    --to=daniel.thompson@linaro.org \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meghana.madhyastha@gmail.com \
    --cc=noralf@tronnes.org \
    --cc=seanpaul@chromium.org \
    --cc=thierry.reding@gmail.com \
    --cc=tomi.valkeinen@ti.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®