All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 04/20] leds: leds-lp55xx: generalize probe/remove functions
Date: Thu, 20 Jun 2024 16:38:46 +0100	[thread overview]
Message-ID: <20240620153846.GN3029315@google.com> (raw)
In-Reply-To: <20240616215226.2112-5-ansuelsmth@gmail.com>

On Sun, 16 Jun 2024, Christian Marangi wrote:

> Now that stop_all_engine is generalized, probe and remove function are
> the same across every lp55xx based LED driver and can be generalized.
> 
> To permit to use a common probe, make use of the OF match_data and i2c
> driver_data value to store the device_config struct specific for the
> LED.
> 
> Also drop the now unused exported symbol in lp55xx-common and make them
> static.
> 
> Update any lp55xx based LED driver to use the new generic probe/remove.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
>  drivers/leds/leds-lp5521.c        |  81 +-------------------
>  drivers/leds/leds-lp5523.c        |  85 ++-------------------
>  drivers/leds/leds-lp5562.c        |  80 +------------------
>  drivers/leds/leds-lp55xx-common.c | 123 +++++++++++++++++++++++-------
>  drivers/leds/leds-lp55xx-common.h |  21 +----
>  drivers/leds/leds-lp8501.c        |  81 +-------------------
>  6 files changed, 119 insertions(+), 352 deletions(-)

[...]

> diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
> index 2cbc5b302fd4..7e623e4e565c 100644
> --- a/drivers/leds/leds-lp55xx-common.c
> +++ b/drivers/leds/leds-lp55xx-common.c
> @@ -32,6 +32,8 @@
>  /* External clock rate */
>  #define LP55XX_CLK_32K			32768
>  
> +static void lp55xx_deinit_device(struct lp55xx_chip *chip);

No forward declarations please.  Move the function.
> +
>  static struct lp55xx_led *cdev_to_lp55xx_led(struct led_classdev *cdev)
>  {
>  	return container_of(cdev, struct lp55xx_led, cdev);
> @@ -49,7 +51,7 @@ static struct lp55xx_led *mcled_cdev_to_led(struct led_classdev_mc *mc_cdev)
>  
>  static void lp55xx_wait_opmode_done(struct lp55xx_chip *chip)
>  {
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  	int __always_unused ret;
>  	u8 val;
>  
> @@ -69,7 +71,7 @@ static void lp55xx_wait_opmode_done(struct lp55xx_chip *chip)
>  
>  void lp55xx_stop_all_engine(struct lp55xx_chip *chip)
>  {
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  
>  	lp55xx_write(chip, cfg->reg_op_mode.addr, LP55xx_MODE_DISABLE_ALL_ENG);
>  	lp55xx_wait_opmode_done(chip);
> @@ -78,7 +80,7 @@ EXPORT_SYMBOL_GPL(lp55xx_stop_all_engine);
>  
>  static void lp55xx_reset_device(struct lp55xx_chip *chip)
>  {
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  	u8 addr = cfg->reset.addr;
>  	u8 val  = cfg->reset.val;
>  
> @@ -88,7 +90,7 @@ static void lp55xx_reset_device(struct lp55xx_chip *chip)
>  
>  static int lp55xx_detect_device(struct lp55xx_chip *chip)
>  {
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  	u8 addr = cfg->enable.addr;
>  	u8 val  = cfg->enable.val;
>  	int ret;
> @@ -111,7 +113,7 @@ static int lp55xx_detect_device(struct lp55xx_chip *chip)
>  
>  static int lp55xx_post_init_device(struct lp55xx_chip *chip)
>  {
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  
>  	if (!cfg->post_init_device)
>  		return 0;
> @@ -176,7 +178,7 @@ static int lp55xx_set_mc_brightness(struct led_classdev *cdev,
>  {
>  	struct led_classdev_mc *mc_dev = lcdev_to_mccdev(cdev);
>  	struct lp55xx_led *led = mcled_cdev_to_led(mc_dev);
> -	struct lp55xx_device_config *cfg = led->chip->cfg;
> +	const struct lp55xx_device_config *cfg = led->chip->cfg;
>  
>  	led_mc_calc_color_components(&led->mc_cdev, brightness);
>  	return cfg->multicolor_brightness_fn(led);
> @@ -187,7 +189,7 @@ static int lp55xx_set_brightness(struct led_classdev *cdev,
>  			     enum led_brightness brightness)
>  {
>  	struct lp55xx_led *led = cdev_to_lp55xx_led(cdev);
> -	struct lp55xx_device_config *cfg = led->chip->cfg;
> +	const struct lp55xx_device_config *cfg = led->chip->cfg;
>  
>  	led->brightness = (u8)brightness;
>  	return cfg->brightness_fn(led);
> @@ -197,7 +199,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
>  			struct lp55xx_chip *chip, int chan)
>  {
>  	struct lp55xx_platform_data *pdata = chip->pdata;
> -	struct lp55xx_device_config *cfg = chip->cfg;
> +	const struct lp55xx_device_config *cfg = chip->cfg;
>  	struct device *dev = &chip->cl->dev;
>  	int max_channel = cfg->max_channel;
>  	struct mc_subled *mc_led_info;
> @@ -459,10 +461,10 @@ bool lp55xx_is_extclk_used(struct lp55xx_chip *chip)
>  }
>  EXPORT_SYMBOL_GPL(lp55xx_is_extclk_used);
>  
> -int lp55xx_init_device(struct lp55xx_chip *chip)
> +static int lp55xx_init_device(struct lp55xx_chip *chip)
>  {
>  	struct lp55xx_platform_data *pdata;
> -	struct lp55xx_device_config *cfg;
> +	const struct lp55xx_device_config *cfg;
>  	struct device *dev = &chip->cl->dev;
>  	int ret = 0;
>  
> @@ -512,9 +514,8 @@ int lp55xx_init_device(struct lp55xx_chip *chip)
>  err:
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(lp55xx_init_device);
>  
> -void lp55xx_deinit_device(struct lp55xx_chip *chip)
> +static void lp55xx_deinit_device(struct lp55xx_chip *chip)
>  {
>  	struct lp55xx_platform_data *pdata = chip->pdata;
>  
> @@ -524,12 +525,11 @@ void lp55xx_deinit_device(struct lp55xx_chip *chip)
>  	if (pdata->enable_gpiod)
>  		gpiod_set_value(pdata->enable_gpiod, 0);
>  }
> -EXPORT_SYMBOL_GPL(lp55xx_deinit_device);

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2024-06-20 15:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16 21:51 [PATCH v6 00/20] leds: leds-lp55xx: overhaul driver Christian Marangi
2024-06-16 21:52 ` [PATCH v6 01/20] dt-bindings: leds-lp55xx: limit pwr-sel property to ti,lp8501 Christian Marangi
2024-06-16 21:52 ` [PATCH v6 02/20] dt-bindings: leds-lp55xx: Add new ti,lp5569 compatible Christian Marangi
2024-06-16 21:52 ` [PATCH v6 03/20] leds: leds-lp55xx: generalize stop_all_engine OP Christian Marangi
2024-06-16 21:52 ` [PATCH v6 04/20] leds: leds-lp55xx: generalize probe/remove functions Christian Marangi
2024-06-20 15:38   ` Lee Jones [this message]
2024-06-16 21:52 ` [PATCH v6 05/20] leds: leds-lp55xx: generalize load_engine function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 06/20] leds: leds-lp55xx: generalize load_engine_and_select_page function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 07/20] leds: leds-lp55xx: generalize run_engine function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 08/20] leds: leds-lp55xx: generalize update_program_memory function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 09/20] leds: leds-lp55xx: generalize firmware_loaded function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 10/20] leds: leds-lp55xx: generalize led_brightness function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 11/20] leds: leds-lp55xx: generalize multicolor_brightness function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 12/20] leds: leds-lp55xx: generalize set_led_current function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 13/20] leds: leds-lp55xx: generalize turn_off_channels function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 14/20] leds: leds-lp55xx: generalize stop_engine function Christian Marangi
2024-06-16 21:52 ` [PATCH v6 15/20] leds: leds-lp55xx: generalize sysfs engine_load and engine_mode Christian Marangi
2024-06-16 21:52 ` [PATCH v6 16/20] leds: leds-lp55xx: generalize sysfs engine_leds Christian Marangi
2024-06-16 21:52 ` [PATCH v6 17/20] leds: leds-lp55xx: generalize sysfs master_fader Christian Marangi
2024-06-16 21:52 ` [PATCH v6 18/20] leds: leds-lp55xx: support ENGINE program up to 128 bytes Christian Marangi
2024-06-16 21:52 ` [PATCH v6 19/20] leds: leds-lp55xx: drop deprecated defines Christian Marangi
2024-06-16 21:52 ` [PATCH v6 20/20] leds: leds-lp5569: Add support for Texas Instruments LP5569 Christian Marangi
2024-06-20 16:03   ` Lee Jones
2024-06-20 16:09 ` [PATCH v6 00/20] leds: leds-lp55xx: overhaul driver Lee Jones
2024-06-20 15:15   ` Christian Marangi
2024-06-20 16:57     ` Lee Jones
2024-06-20 16:49 ` Lee Jones
2024-06-20 15:57   ` Christian Marangi
2024-06-20 17:30     ` Lee Jones

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=20240620153846.GN3029315@google.com \
    --to=lee@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh@kernel.org \
    /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 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.