mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Naresh Solanki <naresh.solanki@9elements.com>
Cc: Pavel Machek <pavel@ucw.cz>,
	Patrick Rudolph <patrick.rudolph@9elements.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [RESEND PATCH v3] leds: max5970: Add support for max5970
Date: Fri, 17 Nov 2023 12:15:31 +0000	[thread overview]
Message-ID: <20231117121531.GC137434@google.com> (raw)
In-Reply-To: <CABqG17h8hxgmMA=G5hitzgjNSX_BZ2utFsMZni9evn0Nogu0GA@mail.gmail.com>

On Thu, 09 Nov 2023, Naresh Solanki wrote:

> Hey Lee,
> 
> Is there anything specific you'd suggest changing in the current
> patchset, or are we good to proceed?

What do you mean by proceed?

You are good to make changes and submit a subsequent version.

Not entirely sure what you're asking.

> On Mon, 30 Oct 2023 at 14:22, Naresh Solanki
> <naresh.solanki@9elements.com> wrote:
> >
> > Hi,
> >
> > On Thu, 21 Sept 2023 at 16:02, Lee Jones <lee@kernel.org> wrote:
> > >
> > > On Thu, 21 Sep 2023, Naresh Solanki wrote:
> > >
> > > > Hi
> > > >
> > > >
> > > > On Wed, 20 Sept 2023 at 18:35, Lee Jones <lee@kernel.org> wrote:
> > > > >
> > > > > On Thu, 14 Sep 2023, Naresh Solanki wrote:
> > > > >
> > > > > > From: Patrick Rudolph <patrick.rudolph@9elements.com>
> > > > > >
> > > > > > The MAX5970 is hot swap controller and has 4 indication LED.
> > > > > >
> > > > > > Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> > > > > > Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> > > > > > ---
> > > > > > Changes in V3:
> > > > > > - Drop array for ddata variable.
> > > > > > Changes in V2:
> > > > > > - Add of_node_put before return.
> > > > > > - Code cleanup
> > > > > > - Refactor code & remove max5970_setup_led function.
> > > > > > ---
> > > > > >  drivers/leds/Kconfig        |  11 ++++
> > > > > >  drivers/leds/Makefile       |   1 +
> > > > > >  drivers/leds/leds-max5970.c | 110 ++++++++++++++++++++++++++++++++++++
> > > > > >  3 files changed, 122 insertions(+)
> > > > > >  create mode 100644 drivers/leds/leds-max5970.c
> > > > >
> > > > > Couple of nits and you're good to go.
> > > > >
> > > > > Once fixed please resubmit with my:
> > > > >
> > > > >   Reviewed-by: Lee Jones <lee@kernel.org>
> > > > >
> > > > > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> > > > > > index b92208eccdea..03ef527cc545 100644
> > > > > > --- a/drivers/leds/Kconfig
> > > > > > +++ b/drivers/leds/Kconfig
> > > > > > @@ -637,6 +637,17 @@ config LEDS_ADP5520
> > > > > >         To compile this driver as a module, choose M here: the module will
> > > > > >         be called leds-adp5520.
> > > > > >
> > > > > > +config LEDS_MAX5970
> > > > > > +     tristate "LED Support for Maxim 5970"
> > > > > > +     depends on LEDS_CLASS
> > > > > > +     depends on MFD_MAX5970
> > > > > > +     help
> > > > > > +       This option enables support for the Maxim MAX5970 & MAX5978 smart
> > > > > > +       switch indication LEDs via the I2C bus.
> > > > > > +
> > > > > > +       To compile this driver as a module, choose M here: the module will
> > > > > > +       be called leds-max5970.
> > > > > > +
> > > > > >  config LEDS_MC13783
> > > > > >       tristate "LED Support for MC13XXX PMIC"
> > > > > >       depends on LEDS_CLASS
> > > > > > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> > > > > > index d7348e8bc019..6eaee0a753c6 100644
> > > > > > --- a/drivers/leds/Makefile
> > > > > > +++ b/drivers/leds/Makefile
> > > > > > @@ -56,6 +56,7 @@ obj-$(CONFIG_LEDS_LP8501)           += leds-lp8501.o
> > > > > >  obj-$(CONFIG_LEDS_LP8788)            += leds-lp8788.o
> > > > > >  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_MAX8997)           += leds-max8997.o
> > > > > >  obj-$(CONFIG_LEDS_MC13783)           += leds-mc13783.o
> > > > > > diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c
> > > > > > new file mode 100644
> > > > > > index 000000000000..c9685990e26e
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/leds/leds-max5970.c
> > > > > > @@ -0,0 +1,110 @@
> > > > > > +// SPDX-License-Identifier: GPL-2.0
> > > > > > +/*
> > > > > > + * Device driver for leds in MAX5970 and MAX5978 IC
> > > > > > + *
> > > > > > + * Copyright (c) 2022 9elements GmbH
> > > > > > + *
> > > > > > + * Author: Patrick Rudolph <patrick.rudolph@9elements.com>
> > > > > > + */
> > > > > > +
> > > > > > +#include <linux/leds.h>
> > > > > > +#include <linux/mfd/max5970.h>
> > > > > > +#include <linux/of.h>
> > > > > > +#include <linux/platform_device.h>
> > > > > > +#include <linux/regmap.h>
> > > > > > +
> > > > > > +#define ldev_to_maxled(c)       container_of(c, struct max5970_led, cdev)
> > > > > > +
> > > > > > +struct max5970_led {
> > > > > > +     struct device *dev;
> > > > > > +     struct regmap *regmap;
> > > > > > +     struct led_classdev cdev;
> > > > > > +     unsigned int index;
> > > > > > +};
> > > > > > +
> > > > > > +static int max5970_led_set_brightness(struct led_classdev *cdev,
> > > > > > +                                   enum led_brightness brightness)
> > > > > > +{
> > > > > > +     struct max5970_led *ddata = ldev_to_maxled(cdev);
> > > > > > +     int ret, val;
> > > > > > +
> > > > > > +     /* Set/clear corresponding bit for given led index */
> > > > > > +     val = !brightness ? BIT(ddata->index) : 0;
> > > > > > +
> > > > > > +     ret = regmap_update_bits(ddata->regmap, MAX5970_REG_LED_FLASH, BIT(ddata->index), val);
> > > > > > +     if (ret < 0)
> > > > > > +             dev_err(cdev->dev, "failed to set brightness %d", ret);
> > > > > > +
> > > > > > +     return ret;
> > > > > > +}
> > > > > > +
> > > > > > +static int max5970_led_probe(struct platform_device *pdev)
> > > > > > +{
> > > > > > +     struct device *dev = &pdev->dev;
> > > > > > +     struct device_node *np = dev_of_node(dev->parent);
> > > > > > +     struct regmap *regmap;
> > > > > > +     struct device_node *led_node;
> > > > > > +     struct device_node *child;
> > > > >
> > > > > Nit: You can place these on the same line.
> > > > Ack
> > > > >
> > > > > > +     struct max5970_led *ddata;
> > > > > > +     int ret = -ENODEV, num_leds = 0;
> > > > > > +
> > > > > > +     regmap = dev_get_regmap(pdev->dev.parent, NULL);
> > > > > > +     if (!regmap)
> > > > > > +             return -EPROBE_DEFER;
> > > > >
> > > > > Why are you deferring here?
> > > > This is a Leaf driver. Making sure the parent driver has initialized regmap.
> > >
> > > How can this driver initialise before the parent driver?
> > The parent driver in this case is simple_i2c_mfd.
> > Based on reference from other similar implementations, the regmap
> > check was adapted.
> > As you mentioned, your right that leaf driver will not start before parent
> > driver is loaded successfully so probably the DEFER might not be needed
> > here.
> >
> > Thanks,
> > Naresh
> > >
> > > --
> > > Lee Jones [李琼斯]

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2023-11-17 12:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 11:45 Naresh Solanki
2023-09-20 13:05 ` Lee Jones
2023-09-21  9:07   ` Naresh Solanki
2023-09-21 10:31     ` Lee Jones
2023-10-30  8:52       ` Naresh Solanki
2023-11-09  9:50         ` Naresh Solanki
2023-11-17 12:15           ` Lee Jones [this message]
2023-11-20 10:10             ` Naresh Solanki
2023-11-21 15:33               ` Lee Jones
2023-11-21 16:01                 ` Naresh Solanki
2023-11-22 11:49                   ` Lee Jones
2023-11-23 13:14                     ` Naresh Solanki
  -- strict thread matches above, loose matches on Subject: below --
2023-08-31 10:22 Naresh Solanki

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=20231117121531.GC137434@google.com \
    --to=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=naresh.solanki@9elements.com \
    --cc=patrick.rudolph@9elements.com \
    --cc=pavel@ucw.cz \
    /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

Powered by JetHome