devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: IIO <linux-iio@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	DEVICE TREE <devicetree@vger.kernel.org>,
	Carlo Caione <carlo@caione.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Aaron Lu <aaron.lu@intel.com>, Alan Cox <alan@linux.intel.com>,
	Jean Delvare <khali@linux-fr.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Fugang Duan <B38611@freescale.com>, Arnd Bergmann <arnd@arndb.de>,
	Zubair Lutfullah <zubair.lutfullah@gmail.com>,
	Sebastian Reichel <sre@debian.org>,
	Johannes Thumshirn <johannes.thumshirn@men.de>,
	Philippe Reynes <tremyfr@yahoo.fr>,
	Angelo Compagnucci <angelo.compagnu>
Subject: Re: [PATCH v4 1/3] mfd/axp20x: extend axp20x to support axp288 pmic
Date: Wed, 24 Sep 2014 12:02:12 +0100	[thread overview]
Message-ID: <20140924110212.GH19999@lee--X1> (raw)
In-Reply-To: <20140918053252.34829684@ultegra>

On Thu, 18 Sep 2014, Jacob Pan wrote:
> Lee Jones <lee.jones@linaro.org> wrote:
> > On Tue, 16 Sep 2014, Jacob Pan wrote:
> > 
> > > X-Powers AXP288 is a customized PMIC for Intel Baytrail-CR
> > > platforms. Similar to AXP202/209, AXP288 comes with USB charger,
> > > more LDO and BUCK channels, and AD converters. It also provides
> > > extended status and interrupt reporting capabilities than the
> > > devices currently supported in axp20x.c.
> > > 
> > > In addition to feature extension, this patch also adds ACPI binding
> > > for enumeration.
> > > 
> > > This consolidated driver should support more X-Powers' PMICs in
> > > both device tree and ACPI enumerated platforms.
> > > 
> > > Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > > ---
> > >  drivers/mfd/Kconfig        |   3 +-
> > >  drivers/mfd/axp20x.c       | 353
> > > +++++++++++++++++++++++++++++++++++++--------
> > > include/linux/mfd/axp20x.h |  58 ++++++++ 3 files changed, 354
> > > insertions(+), 60 deletions(-)

[...]

> > > -static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
> > > +static struct acpi_device_id axp20x_acpi_match[] = {
> > > +	{
> > > +		.id = "INT33F4",
> > > +		.driver_data = (kernel_ulong_t)AXP288_ID,
> > 
> > Why do you need to cast this?
> > 
> to make sure match driver_data which is different in acpi_device_id than
> of_device_id.

You don't need the cast.

[...]

> > > +static int axp20x_match_device(struct axp20x_dev *axp20x, struct
> > > device *dev) +{
> > > +	const struct acpi_device_id *acpi_id;
> > > +	const struct of_device_id *of_id;
> > > +
> > > +	of_id = of_match_device(axp20x_of_match, dev);
> > > +	if (of_id)
> > > +		axp20x->variant = (long) of_id->data;
> > > +	else {
> > > +		acpi_id =
> > > acpi_match_device(dev->driver->acpi_match_table, dev);
> > > +		if (!acpi_id || !acpi_id->driver_data) {
> > > +			dev_err(dev, "Unable to determine ID\n");
> > > +			return -ENODEV;
> > > +		}
> > > +		axp20x->variant = (long) acpi_id->driver_data;
> > > +	}
> > 
> > We can do better error handling here and give the user a better sense
> > of what happened if anything were to go wrong.  Do:
> > 
> > if (dev->of_node)
> >   of_id = of_match_device()
> >   if (!of_id)
> >     error()
> this will give false error on ACPI based platforms, right? in reality

Why would it?  dev->of_node should be NULL if running ACPI?

[...]

> > > +	switch (axp20x->variant) {
> > > +	case AXP202_ID:
> > > +	case AXP209_ID:
> > > +		axp20x->nr_cells = ARRAY_SIZE(axp20x_cells);
> > > +		axp20x->cells = axp20x_cells;
> > > +		axp20x->regmap_cfg = &axp20x_regmap_config;
> > > +		axp20x_regmap_irq_chip.num_regs	= 5;
> > > +		axp20x_regmap_irq_chip.irqs = axp20x_regmap_irqs;
> > > +		axp20x_regmap_irq_chip.num_irqs	=
> > > +			ARRAY_SIZE(axp20x_regmap_irqs);
> > > +		break;
> > > +	case AXP288_ID:
> > > +		axp20x->cells = axp288_cells;
> > > +		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> > > +		axp20x->regmap_cfg = &axp288_regmap_config;
> > > +		axp20x_regmap_irq_chip.irqs = axp288_regmap_irqs;
> > > +		axp20x_regmap_irq_chip.num_irqs	=
> > > +			ARRAY_SIZE(axp288_regmap_irqs);
> > > +		axp20x_regmap_irq_chip.num_regs	= 6;
> > > +		break;
> > > +	default:
> > > +		dev_err(dev, "unsupported AXP20X ID %lu\n",
> > > axp20x->variant);
> > > +		return -ENODEV;
> > 
> > -EINVAL might be better here.
> I was considering the return value gets propagated to probe function
> which is used to query the existence of a device per driver model. But
> I have no strong preference.

I think -EINVAL would be better as the argument passed in
axp20x->variant is invalid.

define EINVAL          22      /* Invalid argument */

> > > +	}
> > > +	dev_info(dev, "AXP20x variant %s found\n",
> > > +		axp20x_model_names[axp20x->variant]);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > >  static int axp20x_i2c_probe(struct i2c_client *i2c,
> > > -			 const struct i2c_device_id *id)
> > > +			const struct i2c_device_id *id)
> > 
> > Sneaky. ;)
> I should not fix the extra white spaces here, unrelated to this patch.
> will remove.

It's okay.  I don't mind little things like this occasionally.  I find
them more amusing than harmful.

[...]

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-09-24 11:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17  0:11 [PATCH v4 0/3] Initial support for XPowers AXP288 PMIC Jacob Pan
2014-09-17  0:11 ` [PATCH v4 1/3] mfd/axp20x: extend axp20x to support axp288 pmic Jacob Pan
     [not found]   ` <1410912715-25903-2-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-09-18  5:39     ` Lee Jones
2014-09-18 12:32       ` Jacob Pan
2014-09-24 11:02         ` Lee Jones [this message]
2014-09-24 13:46           ` Jacob Pan
2014-09-21 13:01     ` Jonathan Cameron
     [not found] ` <1410912715-25903-1-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-09-17  0:11   ` [PATCH v4 2/3] iio/adc: add support for axp288 adc Jacob Pan
     [not found]     ` <1410912715-25903-3-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-09-17 22:20       ` Hartmut Knaack
     [not found]         ` <541A0910.90806-Mmb7MZpHnFY@public.gmane.org>
2014-09-17 22:30           ` Hartmut Knaack
2014-09-17 23:13           ` Jacob Pan
2014-09-18 21:52             ` Hartmut Knaack
     [not found]               ` <541B5401.1010707-Mmb7MZpHnFY@public.gmane.org>
2014-09-18 22:35                 ` Jacob Pan
2014-09-21 13:14       ` Jonathan Cameron
     [not found]         ` <541ECF29.8060006-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-09-22 17:46           ` Jacob Pan
2014-09-22 19:17             ` Jonathan Cameron
2014-09-17  0:11 ` [PATCH v4 3/3] iio: add documentation for current attribute Jacob Pan
     [not found]   ` <1410912715-25903-4-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-09-21 13:03     ` Jonathan Cameron

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=20140924110212.GH19999@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=B38611@freescale.com \
    --cc=aaron.lu@intel.com \
    --cc=alan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=carlo@caione.org \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=johannes.thumshirn@men.de \
    --cc=khali@linux-fr.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=sre@debian.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tremyfr@yahoo.fr \
    --cc=zubair.lutfullah@gmail.com \
    /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).