lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dafab4dc-34ef-4abd-9f3f-1dee675a1a56@kernel.org>
Date: Thu, 20 Jun 2024 22:14:59 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Dzmitry Sankouski <dsankouski@...il.com>,
 Sebastian Reichel <sre@...nel.org>, Bjorn Andersson <andersson@...nel.org>,
 Michael Turquette <mturquette@...libre.com>, Stephen Boyd
 <sboyd@...nel.org>, Neil Armstrong <neil.armstrong@...aro.org>,
 Jessica Zhang <quic_jesszhan@...cinc.com>, Sam Ravnborg <sam@...nborg.org>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
 Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>, Lee Jones <lee@...nel.org>,
 Dmitry Torokhov <dmitry.torokhov@...il.com>, Pavel Machek <pavel@....cz>,
 Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
 Uwe Kleine-König <ukleinek@...nel.org>,
 Konrad Dybcio <konrad.dybcio@...aro.org>,
 Chanwoo Choi <cw00.choi@...sung.com>, phone-devel@...r.kernel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-arm-msm@...r.kernel.org, linux-clk@...r.kernel.org,
 dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org,
 linux-input@...r.kernel.org, linux-leds@...r.kernel.org,
 linux-pwm@...r.kernel.org, linux-samsung-soc@...r.kernel.org
Subject: Re: [PATCH v3 16/23] leds: max77705: Add LEDs support

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> This adds basic support for LEDs for the max77705 PMIC.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@...il.com>
> ---
>  MAINTAINERS                  |   1 +
>  drivers/leds/Kconfig         |   6 ++
>  drivers/leds/Makefile        |   1 +
>  drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 174 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f66f08825db9..f3c245d432d9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13691,6 +13691,7 @@ F:	drivers/*/max14577*.c
>  F:	drivers/*/max77686*.c
>  F:	drivers/*/max77693*.c
>  F:	drivers/*/max77705*.c
> +F:	drivers/leds/leds-max77705.c
>  F:	drivers/clk/clk-max77686.c
>  F:	drivers/extcon/extcon-max14577.c
>  F:	drivers/extcon/extcon-max77693.c
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 05e6af88b88c..14d483011308 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -728,6 +728,12 @@ config LEDS_MAX77650
>  	help
>  	  LEDs driver for MAX77650 family of PMICs from Maxim Integrated.
>  
> +config LEDS_MAX77705
> +	tristate "LED support for Maxim MAX77705 RGB"
> +	depends on MFD_MAX77705 && LEDS_CLASS && I2C
> +	help
> +	  LED driver for MAX77705 MFD chip from Maxim Integrated.
> +
>  config LEDS_MAX8997
>  	tristate "LED support for MAX8997 PMIC"
>  	depends on LEDS_CLASS && MFD_MAX8997
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index effdfc6f1e95..be064e3d678e 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_LP8860)		+= leds-lp8860.o
>  obj-$(CONFIG_LEDS_LT3593)		+= leds-lt3593.o
>  obj-$(CONFIG_LEDS_MAX5970)		+= leds-max5970.o
>  obj-$(CONFIG_LEDS_MAX77650)		+= leds-max77650.o
> +obj-$(CONFIG_LEDS_MAX77705)		+= leds-max77705.o
>  obj-$(CONFIG_LEDS_MAX8997)		+= leds-max8997.o
>  obj-$(CONFIG_LEDS_MC13783)		+= leds-mc13783.o
>  obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
> diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
> new file mode 100644
> index 000000000000..f91c0e41056c
> --- /dev/null
> +++ b/drivers/leds/leds-max77705.c
> @@ -0,0 +1,166 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Based on leds-max77650 driver:
> + *		Copyright (C) 2018 BayLibre SAS
> + *		Author: Bartosz Golaszewski <bgolaszewski@...libre.com>
> + *
> + * LED driver for MAXIM 77705 MFD.
> + * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@...il.org>
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/leds.h>
> +#include <linux/mfd/max77705.h>
> +#include <linux/mfd/max77705-private.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#define MAX77705_LED_NUM_LEDS		4
> +#define MAX77705_LED_EN_MASK		GENMASK(1, 0)
> +#define MAX77705_LED_MAX_BRIGHTNESS	0xff
> +
> +#define LEDBLNK_ON(time)	((time < 100) ? 0 :			\
> +				(time < 500) ? time/100-1 :		\
> +				(time < 3250) ? (time-500)/250+4 : 15)
> +
> +#define LEDBLNK_OFF(time)	((time < 1) ? 0x00 :			\
> +				(time < 500) ? 0x01 :			\
> +				(time < 5000) ? time/500 :		\
> +				(time < 8000) ? (time-5000)/1000+10 :	 \
> +				(time < 12000) ? (time-8000)/2000+13 : 15)

Make both static functions, if really needed, but these appear only in
one place, so maybe just code it directly.


> +
> +struct max77705_led {
> +	struct led_classdev cdev;
> +	struct regmap *regmap;
> +	unsigned int en_shift;
> +	unsigned int reg_brightness;
> +	unsigned int regB;

noCamelCase.

> +};
> +
> +static struct max77705_led *max77705_to_led(struct led_classdev *cdev)
> +{
> +	return container_of(cdev, struct max77705_led, cdev);
> +}
> +


> +		led = &leds[reg];
> +		led->regmap = map;
> +		led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg;
> +		led->en_shift = 2 * reg;
> +		led->cdev.brightness_set_blocking = max77705_led_brightness_set;
> +		led->cdev.blink_set = max77705_rgb_blink;
> +		led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS;
> +
> +		init_data.fwnode = child;
> +		init_data.devicename = "max77705";
> +		/* for backwards compatibility if `label` is not present */
> +		init_data.default_label = ":";

There is no backwards compatibility - it's fresh driver.

> +
> +		rv = devm_led_classdev_register_ext(dev, &led->cdev,
> +							&init_data);
> +		if (rv)
> +			goto err_node_put;
> +
> +		rv = max77705_led_brightness_set(&led->cdev, LED_OFF);
> +		if (rv)
> +			goto err_node_put;
> +	}
> +
> +	return 0;
> +err_node_put:
> +	fwnode_handle_put(child);
> +	return rv;
> +}
> +
> +static const struct of_device_id max77705_led_of_match[] = {
> +	{ .compatible = "maxim,max77705-led" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, max77705_led_of_match);
> +
> +static struct platform_driver max77705_led_driver = {
> +	.driver = {
> +		.name = "max77705-led",
> +		.of_match_table = max77705_led_of_match,
> +	},
> +	.probe = max77705_led_probe,
> +};
> +module_platform_driver(max77705_led_driver);
> +
> +MODULE_DESCRIPTION("MAXIM 77705 LED driver");
> +MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@...libre.com>");
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@...il.com>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:max77705-led");

You should not need MODULE_ALIAS() in normal cases. If you need it,
usually it means your device ID table is wrong (e.g. misses either
entries or MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute
for incomplete ID table.


Best regards,
Krzysztof


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ