public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Pavel Machek" <pavel@ucw.cz>, "Lee Jones" <lee@kernel.org>,
	"Kate Hsuan" <hpa@redhat.com>,
	"Sebastian Reichel" <sre@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	"André Apitzsch" <git@apitzsch.eu>,
	linux-leds@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/3] power: supply: power-supply-leds: Add power_supply_[un]register_led_trigger()
Date: Fri, 10 May 2024 23:04:30 +0300	[thread overview]
Message-ID: <Zj59zito2FILn9qD@smile.fi.intel.com> (raw)
In-Reply-To: <20240510194012.138192-2-hdegoede@redhat.com>

On Fri, May 10, 2024 at 09:40:10PM +0200, Hans de Goede wrote:
> Add power_supply_[un]register_led_trigger() helper functions.
> 
> The primary goal of this is as a preparation patch for adding an activate
> callback to the power-supply LED triggers to ensure that power-supply
> LEDs get the correct initial value when the LED gets registered after
> the power_supply has been registered (this will use the psy back pointer).
> 
> There also is quite a lot of code duplication in the existing LED trigger
> registration in the form of the kasprintf() for the name-template for each
> trigger + related error handling. This duplication is removed by these
> new helpers.

...

> +	err = led_trigger_register(&psy_trig->trig);
> +	if (err)
> +		goto err_free_name;


> +err_free_name:
> +	kfree(psy_trig->trig.name);
> +err_free_trigger:
> +	kfree(psy_trig);
> +	return -ENOMEM;

Why not ret?

...

> +static int power_supply_create_bat_triggers(struct power_supply *psy)
> +{
> +	int err = 0;
> +
> +	err |= power_supply_register_led_trigger(psy, "%s-charging-or-full",
> +						 &psy->charging_full_trig);
> +	err |= power_supply_register_led_trigger(psy, "%s-charging",
> +						 &psy->charging_trig);
> +	err |= power_supply_register_led_trigger(psy, "%s-full",
> +						 &psy->full_trig);
> +	err |= power_supply_register_led_trigger(psy, "%s-charging-blink-full-solid",
> +						 &psy->charging_blink_full_solid_trig);
> +	err |= power_supply_register_led_trigger(psy, "%s-charging-orange-full-green",
> +						 &psy->charging_orange_full_green_trig);

Why not using the similar approach as you have done in v4l2 CCI?

> +	if (err) {
> +		power_supply_remove_bat_triggers(psy);
> +		/*
> +		 * led_trigger_register() may also return -EEXIST but that should
> +		 * never happen with the dynamically generated psy trigger names.
> +		 */

Maybe this comment should be above and here just return err; (but see above remark).

> +		return -ENOMEM;
> +	}
> +
> +	return 0;
>  }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-05-10 20:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 19:40 [PATCH 0/3] power: supply: power-supply-leds: Add activate() callback to triggers Hans de Goede
2024-05-10 19:40 ` [PATCH 1/3] power: supply: power-supply-leds: Add power_supply_[un]register_led_trigger() Hans de Goede
2024-05-10 20:04   ` Andy Shevchenko [this message]
2024-05-31 12:25     ` Hans de Goede
2024-05-10 19:40 ` [PATCH 2/3] power: supply: power-supply-leds: Share trig pointer for online and charging_full Hans de Goede
2024-05-10 19:40 ` [PATCH 3/3] power: supply: power-supply-leds: Add activate() callback to triggers Hans de Goede
2024-05-10 20:07   ` Andy Shevchenko
2024-05-31 13:21     ` Hans de Goede
2024-05-27 21:37 ` [PATCH 0/3] " Sebastian Reichel

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=Zj59zito2FILn9qD@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=git@apitzsch.eu \
    --cc=hdegoede@redhat.com \
    --cc=hpa@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sre@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox