devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Simon Shields <simon@lineageos.org>
Cc: linux-leds@vger.kernel.org, Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH 2/2] leds: add Panasonic AN30259A support
Date: Wed, 21 Feb 2018 13:22:26 +0100	[thread overview]
Message-ID: <20180221071455.GA25848@amd> (raw)
In-Reply-To: <20180220005446.8577-3-simon@lineageos.org>

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

Hi!

> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 3e763d2a0cb3..80bed557cc6b 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -57,6 +57,16 @@ config LEDS_AAT1290
>  	depends on PINCTRL
>  	help
>  	 This option enables support for the LEDs on the AAT1290.
> +
> +config LEDS_AN30259A
> +    tristate "LED support for Panasonic AN30259A"
> +    depends on OF
> +    depends on I2C
> +    depends on LEDS_CLASS
> +    help
> +     This option enables support for the AN30259A 3-channel
> +     LED driver.

Something funny goes on with the indentation here. And normally we'd
do depends on A && B && ... and have note how the module will be
called.


> +++ b/drivers/leds/leds-an30259a.c
> @@ -0,0 +1,338 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/i2c.h>

This would be suitable place for author name, and very short hw
description. http link for datasheet would be preffered here over the
dts binding.

> +		duty_max = an30259a_get_duty_max(brightness & 0xff);
> +		ret = regmap_write(led->chip->regmap,
> +				REG_LEDCNT1(led->num),
> +				LED_DUTYMAX(duty_max) | LED_DUTYMID(duty_max));
> +		if (ret)
> +			return ret;
> +		break;
> +	}
> +	ret = regmap_write(led->chip->regmap, REG_LEDON,
> +				ledon);

You can fit this on one line.

> +		chip->leds[i].cdev.brightness_set_blocking = an30259a_led_set;
> +		chip->leds[i].cdev.blink_set = an30259a_blink_set;
> +
> +		err = led_classdev_register(&client->dev, &chip->leds[i].cdev);
> +		if (err < 0)
> +			goto exit;
> +	}

Do ve have devm version of led class register?

> +static int an30259a_remove(struct i2c_client *client)
> +{
> +	struct an30259a *chip = i2c_get_clientdata(client);
> +	int i;
> +
> +	for (i = 0; i < MAX_LEDS; i++)
> +		led_classdev_unregister(&chip->leds[i].cdev);

You always unregister 3 leds; what if only 1 is described in the
device tree?

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

      parent reply	other threads:[~2018-02-21 12:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  0:54 [PATCH 0/2] Panasonic AN30259A support Simon Shields
2018-02-20  0:54 ` [PATCH 1/2] dt-bindings: leds: document Panasonic AN30259A bindings Simon Shields
2018-02-20 21:28   ` Jacek Anaszewski
2018-02-21 19:35     ` Jacek Anaszewski
2018-02-21 12:25   ` Pavel Machek
2018-02-20  0:54 ` [PATCH 2/2] leds: add Panasonic AN30259A support Simon Shields
2018-02-20 21:51   ` Jacek Anaszewski
2018-02-21 14:18     ` Simon Shields
2018-02-21 19:55       ` Jacek Anaszewski
2018-02-21 12:22   ` Pavel Machek [this message]

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=20180221071455.GA25848@amd \
    --to=pavel@ucw.cz \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rpurdie@rpsys.net \
    --cc=simon@lineageos.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;
as well as URLs for NNTP newsgroup(s).