public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Lee Jones" <lee@kernel.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Rob Herring" <robh@kernel.org>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Haibo Chen" <haibo.chen@nxp.com>
Subject: Re: [PATCH v2 2/4] mfd: adp5585: Add Analog Devices ADP5585 core support
Date: Wed, 29 May 2024 12:35:41 +0300	[thread overview]
Message-ID: <20240529093541.GL1436@pendragon.ideasonboard.com> (raw)
In-Reply-To: <CAHp75VeHA8qH_S=KJjAMv24vGP=hmeN9wSt1_NPsRhBZfEYXXw@mail.gmail.com>

Hi Andy,

On Wed, May 29, 2024 at 08:44:26AM +0300, Andy Shevchenko wrote:
> On Tue, May 28, 2024 at 11:13 PM Laurent Pinchart wrote:
> > On Tue, May 28, 2024 at 10:27:34PM +0300, Andy Shevchenko wrote:
> > > Tue, May 28, 2024 at 10:03:12PM +0300, Laurent Pinchart kirjoitti:
> 
> ...
> 
> > > > +   depends on I2C && OF
> > >
> > > Why OF?
> >
> > Because the driver works on OF systems only.
> >
> > > No COMPILE_TEST?
> >
> > The driver won't compile without CONFIG_I2C, so I can use
> >
> >         depends on I2C
> >         depends on OF || COMPILE_TEST
> >
> > Do you think that's better ?
> 
> I think that dropping OF completely is the best.
> OF || COMPILE_TEST would work as well, but I still don't know why we need this.

For the same reason that many drivers depend on specific CONFIG_$ARCH.
They can't run on other platforms, the dependency hides the symbol for
users who can't use the driver. This driver works on OF platforms only.

> ...
> 
> > > + array_size.h
> > > + device.h // e.g., devm_kzalloc()
> > >
> > > > +#include <linux/module.h>
> > > > +#include <linux/moduleparam.h>
> > > > +#include <linux/init.h>
> > > > +#include <linux/slab.h>
> >
> > I'll drop those 3 headers, there's not needed anymore.
> >
> > > > +#include <linux/i2c.h>
> > >
> > > > +#include <linux/of.h>
> > > > +#include <linux/of_device.h>
> > >
> > > You don't need them, instead of proxying...
> >
> > of.h for of_device_get_match_data() and of_match_ptr(). I'll drop the
> > former, but I need the latter, so I'll keep of.h
> 
> Why do you need of_match_ptr()? What for?

That's actually not needed, I'll drop it.

> > of_device.h for historical reasons probably, I'll drop it.
> >
> > > > +#include <linux/mfd/core.h>
> > > > +#include <linux/mfd/adp5585.h>
> > >
> > > m is earlier than 'o', but with above drop no more issue :-)
> > >
> > > ...just include mod_devicetable.h.
> > >
> > > > +#include <linux/regmap.h>
> > >
> > > + types.h // e.g., u8
> 
> I assume that all marked with + in my previous reply you agree on?

If I don't reply to a particular comment it means I agree with it and
will address it, yes.

> ...
> 
> > > > +#define            ADP5585_MAN_ID(v)               (((v) & 0xf0) >> 4)
> > >
> > > GENMASK()
> >
> > This is not a mask. Or do you mean
> >
> >         (((v) & GENMASK(7, 4)) >> 4)
> >
> > ?
> 
> Yes.
> 
> > I think that's overkill.
> 
> Why? You have a mask, use it for less error prone code.

I'll change this to

diff --git a/drivers/mfd/adp5585.c b/drivers/mfd/adp5585.c
index fa4092a5c97f..924758b8a3cd 100644
--- a/drivers/mfd/adp5585.c
+++ b/drivers/mfd/adp5585.c
@@ -125,7 +125,7 @@ static int adp5585_i2c_probe(struct i2c_client *i2c)
 		return dev_err_probe(&i2c->dev, ret,
 				     "Failed to read device ID\n");
 
-	if (ADP5585_MAN_ID(id) != ADP5585_MAN_ID_VALUE)
+	if (id & ADP5585_MAN_ID_MASK != ADP5585_MAN_ID_VALUE)
 		return dev_err_probe(&i2c->dev, -ENODEV,
 				     "Invalid device ID 0x%02x\n", id);
 
diff --git a/include/linux/mfd/adp5585.h b/include/linux/mfd/adp5585.h
index f06a574afedf..f5776ee844dc 100644
--- a/include/linux/mfd/adp5585.h
+++ b/include/linux/mfd/adp5585.h
@@ -12,8 +12,8 @@
 #include <linux/bits.h>
 
 #define ADP5585_ID			0x00
-#define		ADP5585_MAN_ID(v)		(((v) & 0xf0) >> 4)
-#define		ADP5585_MAN_ID_VALUE		0x02
+#define		ADP5585_MAN_ID_VALUE		0x20
+#define		ADP5585_MAN_ID_MASK		GENMASK(7, 4)
 #define ADP5585_INT_STATUS		0x01
 #define ADP5585_STATUS			0x02
 #define ADP5585_FIFO_1			0x03

> ...
> 
> > > > +#define            ADP5585_Rx_PULL_CFG_MASK        (3)
> > >
> > > GENMASK()
> >
> > Not here, as this value is meant to be passed to ADP5585_Rx_PULL_CFG().
> 
> Why is it marked as a mask? Rename it to _ALL or alike.

It's a mask, but used as

	ADP5585_Rx_PULL_CFG(ADP5585_Rx_PULL_CFG_MASK)

We're reaching a level of bike-shedding that even I find impressive :-)
As with a few other of your review comments that I think are related to
personal taste more than anything else, I'll defer to the subsystem
maintainer and follow their preference on this one.

> ...
> 
> > > > +#define            ADP5585_C4_EXTEND_CFG_MASK      (1U << 6)
> > >
> > > > +#define            ADP5585_R4_EXTEND_CFG_MASK      (1U << 5)
> > >
> > > > +#define            ADP5585_R3_EXTEND_CFG_MASK      (3U << 2)
> > >
> > > > +#define            ADP5585_R0_EXTEND_CFG_MASK      (1U << 0)
> > >
> > > > +#define            ADP5585_OSC_FREQ_MASK           (3U << 5)
> > >
> > > BIT() / GENMASK()
> >
> > I'll use GENMASK for the masks.
> 
> For a single bit the BIT() is okay, and TBH I don't remember if
> GENMASK() supports h == l cases.

I've tested it and it works.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-05-29  9:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 19:03 [PATCH v2 0/4] ADP5585 GPIO expander, PWM and keypad controller support Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 1/4] dt-bindings: Add bindings for the Analog Devices ADP5585 Laurent Pinchart
2024-05-28 20:41   ` Rob Herring (Arm)
2024-05-28 20:49     ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 2/4] mfd: adp5585: Add Analog Devices ADP5585 core support Laurent Pinchart
2024-05-28 19:27   ` Andy Shevchenko
2024-05-28 20:13     ` Laurent Pinchart
2024-05-29  5:44       ` Andy Shevchenko
2024-05-29  9:35         ` Laurent Pinchart [this message]
2024-05-29 13:38           ` Andy Shevchenko
2024-05-28 19:03 ` [PATCH v2 3/4] gpio: adp5585: Add Analog Devices ADP5585 support Laurent Pinchart
2024-05-28 19:36   ` Andy Shevchenko
2024-05-28 20:20     ` Laurent Pinchart
2024-05-28 20:22       ` Laurent Pinchart
2024-05-28 20:23         ` Laurent Pinchart
2024-05-29  6:16       ` Andy Shevchenko
2024-05-29  9:47         ` Laurent Pinchart
2024-05-29 14:24           ` Andy Shevchenko
2024-05-29 14:35             ` Laurent Pinchart
2024-05-29 15:00               ` Andy Shevchenko
2024-05-29 15:17                 ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 4/4] pwm: " Laurent Pinchart
2024-05-28 19:41   ` Andy Shevchenko
2024-05-28 20:27     ` Laurent Pinchart
2024-05-29  6:22       ` Andy Shevchenko

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=20240529093541.GL1436@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=haibo.chen@nxp.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=ukleinek@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