[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBw7r12Yq0YMik78@duo.ucw.cz>
Date: Thu, 23 Mar 2023 12:44:47 +0100
From: Pavel Machek <pavel@....cz>
To: Naresh Solanki <naresh.solanki@...ements.com>
Cc: Lee Jones <lee@...nel.org>,
Patrick Rudolph <patrick.rudolph@...ements.com>,
linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org
Subject: Re: [PATCH 2/2] leds: max597x: Add support for max597x
On Wed 2023-03-22 13:43:16, Naresh Solanki wrote:
> From: Patrick Rudolph <patrick.rudolph@...ements.com>
>
> max597x is hot swap controller with indication led support.
"indicator LED"?
> This driver uses DT property to configure led during boot time &
> also provide the led control in sysfs.
LED.
> +++ b/drivers/leds/Kconfig
> @@ -590,6 +590,17 @@ config LEDS_ADP5520
> To compile this driver as a module, choose M here: the module will
> be called leds-adp5520.
>
> +config LEDS_MAX597X
> + tristate "LED Support for Maxim 597x"
> + depends on LEDS_CLASS
> + depends on MFD_MAX597X
> + help
> + This option enables support for the Maxim 597x smart switch indication LEDs
> + via the I2C bus.
Strange whitespace.
> --- /dev/null
> +++ b/drivers/leds/leds-max597x.c
> @@ -0,0 +1,132 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Device driver for regulators in MAX5970 and MAX5978 IC
Regulators go elsewhere.
> +static int max597x_led_set_brightness(struct led_classdev *cdev,
> + enum led_brightness brightness)
> +{
> + struct max597x_led *led = ldev_to_maxled(cdev);
> + int ret;
> +
> + if (!led || !led->regmap)
> + return -ENODEV;
> +
> + ret = regmap_update_bits(led->regmap, MAX5970_REG_LED_FLASH,
> + 1 << led->index, ~brightness << led->index);
~brightness << led->index is quite confusing. Can we get something
else?
> + led = devm_kzalloc(dev, sizeof(struct max597x_led),
> + GFP_KERNEL);
> + if (!led)
> + return -ENOMEM;
> +
> + if (of_property_read_string(nc, "label", &led->led.name))
> + led->led.name = nc->name;
> +
> + led->led.max_brightness = 1;
> + led->led.brightness_set_blocking = max597x_led_set_brightness;
> + led->led.default_trigger = "none";
> + led->index = reg;
> + led->regmap = regmap;
> + ret = led_classdev_register(dev, &led->led);
> + if (ret) {
> + dev_err(dev, "Error in initializing led %s", led->led.name);
> + devm_kfree(dev, led);
> + return ret;
> + }
You don't need to do the kfree.
> + if (!of_property_read_string(nc, "default-state", &state)) {
> + if (!strcmp(state, "on")) {
> + led->led.brightness = 1;
> + led_set_brightness(&led->led, led->led.brightness);
> + }
> + }
Lets get rid of this unless you really need it.
BR,
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists