Re: [PATCH v3 3/7] mfd: Add MFD driver for ATC260x PMICs
From: Lee Jones
Date: Fri Dec 18 2020 - 08:22:26 EST
On Fri, 18 Dec 2020, Cristian Ciocaltea wrote:
> Hi Lee,
>
> Thank you for the detailed review!
>
> I will prepare a new revision, but there are still a couple of open
> points..
Could you please snip your replies, leaving only the open points.
Scrolling through lots of empty quotes or "done" comments is quite
time consuming. Thanks.
[...]
> > > + /*
> > > + * Using regmap within an atomic context (e.g. accessing a PMIC when
> > > + * powering system down) is normally allowed only if the regmap type
> > > + * is MMIO and the regcache type is either REGCACHE_NONE or
> > > + * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is
> > > + * internally protected by a mutex which is acquired non-atomically.
> > > + *
> > > + * Let's improve this by using a customized locking scheme inspired
> > > + * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a
> > > + * starting point.
> > > + */
> > > + if (system_state > SYSTEM_RUNNING && irqs_disabled())
> >
> > Were does system_state come from?
>
> It is declared in 'include/linux/kernel.h':
>
> extern enum system_states {
> SYSTEM_BOOTING,
> SYSTEM_SCHEDULING,
> SYSTEM_RUNNING,
> SYSTEM_HALT,
> SYSTEM_POWER_OFF,
> SYSTEM_RESTART,
> SYSTEM_SUSPEND,
> } system_state;
>
> The definition is in 'init/main.c':
>
> enum system_states system_state __read_mostly;
> EXPORT_SYMBOL(system_state);
Ah, it's a system wide thing. No problem.
[...]
> > > + ret = regmap_read(atc260x->regmap, atc260x->rev_reg, &chip_rev);
> > > + if (ret) {
> > > + dev_err(dev, "Failed to get chip revision\n");
> > > + return ret;
> > > + }
> > > +
> > > + if (chip_rev < 0 || chip_rev > 31) {
> > > + dev_err(dev, "Unknown chip revision: %d\n", ret);
> > > + return -EINVAL;
> > > + }
> >
> > This still seems limiting.
>
> This is based on the vendor implementation. Unfortunately I don't have
> access to a data sheet or any other source of information about the
> management of the chip revisions.
So which versions does this driver work with? All 32?
[...]
> > > +const struct of_device_id atc260x_i2c_of_match[] = {
> > > + { .compatible = "actions,atc2603c", .data = (void *)ATC2603C },
> > > + { .compatible = "actions,atc2609a", .data = (void *)ATC2609A },
> > > + { /* sentinel */ }
> >
> > I think you can drop the (void *) casts.
>
> Without the cast, I get the following compiler warning:
>
> drivers/mfd/atc260x-i2c.c:46:46: warning: initialization of ‘const void *’
> from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
> { .compatible = "actions,atc2603c", .data = ATC2603C },
Perhaps I'm getting confused with addresses of things. Never mind.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog