devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: cy_huang <u0084500@gmail.com>
Cc: dmurphy@ti.com, robh+dt@kernel.org, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, cy_huang@richtek.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v1 1/2] leds: rt4505: Add support for Richtek RT4505 flash led controller
Date: Tue, 27 Oct 2020 09:29:00 +0100	[thread overview]
Message-ID: <20201027082900.GA21354@amd> (raw)
In-Reply-To: <1603784069-24114-1-git-send-email-u0084500@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2619 bytes --]

Hi!

> From: ChiYuan Huang <cy_huang@richtek.com>
> 
> Add support for RT4505 flash led controller. It can support up to 1.5A
> flash current with hardware timeout and low input voltage
> protection.

Please use upper-case "LED" everywhere.

This should be 2nd in the series, after DT changes.

> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> ---
>  drivers/leds/Kconfig       |  11 ++
>  drivers/leds/Makefile      |   1 +
>  drivers/leds/leds-rt4505.c | 397 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 409 insertions(+)
>  create mode 100644 drivers/leds/leds-rt4505.c

Lets put this into drivers/leds/flash/. (Yes, you'll have to create
it).


> +	help
> +	  This option enables support for the RT4505 flash led controller.

Information where it is used would be welcome here.

> +	  It can support up to 1.5A flash strobe current with hardware timeout
> +	  and low input voltage protection.

This does not / should not be here.
> +
> +static int rt4505_torch_brightness_set(struct led_classdev *lcdev, enum led_brightness level)
> +{

80 columns, where easy.

> +	struct rt4505_priv *priv = container_of(lcdev, struct rt4505_priv, flash.led_cdev);
> +	u32 val = 0;
> +	int ret;
> +
> +	mutex_lock(&priv->lock);
> +
> +	if (level != LED_OFF) {
> +		ret = regmap_update_bits(priv->regmap, RT4505_REG_ILED, RT4505_ITORCH_MASK,
> +					 (level - 1) << RT4505_ITORCH_SHIFT);
> +		if (ret)
> +			goto unlock;
> +
> +		val = RT4505_TORCH_SET;
> +	}
> +
> +	ret = regmap_update_bits(priv->regmap, RT4505_REG_ENABLE, RT4505_ENABLE_MASK, val);
> +
> +unlock:
> +	mutex_unlock(&priv->lock);
> +	return ret;
> +}

Why is the locking needed? What will the /sys/class/leds interface
look like on system with your flash?

> +static int rt4505_flash_strobe_get(struct led_classdev_flash *fled_cdev, bool *state)
> +{
> +	struct rt4505_priv *priv = container_of(fled_cdev, struct rt4505_priv, flash);
> +	u32 val;
> +	int ret;
> +
> +	mutex_lock(&priv->lock);
> +
> +	ret = regmap_read(priv->regmap, RT4505_REG_ENABLE, &val);
> +	if (ret)
> +		goto unlock;
> +
> +	*state = ((val & RT4505_FLASH_GET) == RT4505_FLASH_GET) ? true : false;

No need for ? ... part.

> +static bool rt4505_is_accessible_reg(struct device *dev, unsigned int reg)
> +{
> +	if (reg == RT4505_REG_RESET || (reg >= RT4505_REG_CONFIG  && reg <= RT4505_REG_FLAGS))
> +		return true;

Make this two stagements.

Otherwise... looks like easy simple driver, thanks.

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2020-10-27  8:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27  7:34 [PATCH v1 1/2] leds: rt4505: Add support for Richtek RT4505 flash led controller cy_huang
2020-10-27  7:34 ` [PATCH v1 2/2] leds: rt4505: Add DT binding document for Richtek RT4505 cy_huang
2020-10-30 18:59   ` Rob Herring
2020-10-27  8:29 ` Pavel Machek [this message]
2020-10-27  9:27   ` [PATCH v1 1/2] leds: rt4505: Add support for Richtek RT4505 flash led controller ChiYuan Huang
2020-10-27 10:06     ` ChiYuan Huang
2020-10-27 10:11       ` Pavel Machek
2020-10-27 10:15     ` Pavel Machek
2020-10-27 10:46       ` ChiYuan Huang
2020-10-27 14:55         ` ChiYuan Huang
2020-10-27 16:40   ` Jacek Anaszewski
2020-10-28  4:57     ` ChiYuan Huang
2020-10-28 11:07       ` Jacek Anaszewski
2020-10-28 11:14         ` ChiYuan Huang

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=20201027082900.GA21354@amd \
    --to=pavel@ucw.cz \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=u0084500@gmail.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;
as well as URLs for NNTP newsgroup(s).