mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 1/2] leds: Add Intel Cherry Trail Whiskey Cove PMIC LEDs
Date: Tue, 12 Feb 2019 22:50:26 +0300	[thread overview]
Message-ID: <20190212195026.GB5213@jeknote.loshitsa1.net> (raw)
In-Reply-To: <9319c977-b8d4-98cc-d719-b21df5ef5a88@gmail.com>

On Mon, Feb 11, 2019 at 10:36:30PM +0100, Jacek Anaszewski wrote:
> Hi Yauhen,
> 
> Thank you for the patch.
> 
> Please find few comments in the code.
> 
> On 2/9/19 11:12 PM, Yauhen Kharuzhy wrote:
> > diff --git a/drivers/leds/leds-cht-wcove.c b/drivers/leds/leds-cht-wcove.c
> > new file mode 100644
> > index 000000000000..82ed0845bf72
> > --- /dev/null
> > +++ b/drivers/leds/leds-cht-wcove.c
> > @@ -0,0 +1,278 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Driver for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC
> > + *
> > + * Copyright 2019 Yauhen Kharuzhy <jekhor@gmail.com>
> > + *
> > + * Based on Lenovo Yoga Book Android kernel sources
> > + */
> 
> Please use uniform "//" comment style above.

OK.

> > +
> > +static int cht_wc_leds_brightness_set(struct led_classdev *cdev,
> > +				      enum led_brightness value)
> > +{
> > +	struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev);
> > +	int ret;
> 
> You need mutex protection here. Think of the cases where brightness
> is set from sysfs and the call from trigger jumps in the middle.

Agree.

> > +enum led_brightness cht_wc_leds_brightness_get(struct led_classdev *cdev)
> > +{
> > +	struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev);
> > +	int ret;
> > +	unsigned int val;
> 
> Ditto.

OK

> > +static int cht_wc_leds_blink_set(struct led_classdev *cdev,
> > +				 unsigned long *delay_on,
> > +				 unsigned long *delay_off)
> > +{
> > +	struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev);
> > +	unsigned int ctrl;
> > +	int ret;
> 
> mutex needed as well.

OK

> 
> > +	if (!*delay_on && !*delay_off) {
> > +		/* Return current settings */
> > +		ret = regmap_read(led->pmic->regmap, led->ctrl_reg, &ctrl);
> 
> Why read? This op sets blinking. Please refer to the blink_set semantics
> description from include/linux/leds.h:
> 
> /*
>  * Activate hardware accelerated blink, delays are in milliseconds
>  * and if both are zero then a sensible default should be chosen.
>  * The call should adjust the timings in that case and if it can't
>  * match the values specified exactly.
>  * Deactivate blinking again when the brightness is set to LED_OFF
>  * via the brightness_set() callback.
>  */
> int             (*blink_set)(struct led_classdev *led_cdev,
>                              unsigned long *delay_on,
>                              unsigned long *delay_off);
> 
> Please compare how other LED class drivers do that.

Hmm... This was attempt to set 'reasonable default' to current blink
settings from hardware. But if this is too unpredictable behaviour for
LED class, I will change it to constant values.

> > +MODULE_DESCRIPTION("Intel Cherrytrail Whiskey Cove PMIC LEDs driver");
> > +MODULE_AUTHOR("Yauhen Kharuzhy <jekhor@gmail.com>");
> > +MODULE_LICENSE("GPL");
> 
> s/GPL/GPL v2/

OK.

-- 
Yauhen Kharuzhy

  reply	other threads:[~2019-02-12 19:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09 22:12 [PATCH 0/2] Intel Cherry Trail Whiskey Cove LEDs support Yauhen Kharuzhy
2019-02-09 22:12 ` [PATCH 1/2] leds: Add Intel Cherry Trail Whiskey Cove PMIC LEDs Yauhen Kharuzhy
2019-02-11 13:17   ` Pavel Machek
2019-02-12 20:25     ` Yauhen Kharuzhy
2019-02-11 21:36   ` Jacek Anaszewski
2019-02-12 19:50     ` Yauhen Kharuzhy [this message]
2019-02-09 22:12 ` [PATCH 2/2] mfd: Add leds MFD cell for intel_soc_pmic_chtwc Yauhen Kharuzhy
2019-02-12  8:14   ` Lee Jones
2019-02-12 19:52     ` Yauhen Kharuzhy
2019-02-11 11:59 ` [PATCH 0/2] Intel Cherry Trail Whiskey Cove LEDs support Andy Shevchenko
2019-02-11 13:05   ` Pavel Machek
2019-02-11 21:20     ` Jacek Anaszewski

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=20190212195026.GB5213@jeknote.loshitsa1.net \
    --to=jekhor@gmail.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.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

all inboxes | Powered by JetHome®