public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
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>,
	Lee Jones <lee.jones@linaro.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.compagnucci@gmail.com>,
	Doug Anderson <dianders@chromium.org>
Subject: Re: [PATCH 2/4] mfd/axp2xx: extend axp20x to support axp288 pmic
Date: Tue, 9 Sep 2014 15:37:04 +0200	[thread overview]
Message-ID: <20140909133704.GO3804@lukather> (raw)
In-Reply-To: <20140909054517.5bd4e8b6@ultegra>

[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]

On Tue, Sep 09, 2014 at 05:45:17AM -0700, Jacob Pan wrote:
> > > -static int axp20x_i2c_probe(struct i2c_client *i2c,
> > > -			 const struct i2c_device_id *id)
> > > +static int axp2xx_match_device(struct axp2xx_dev *axp2xx, struct
> > > device *dev) {
> > > -	struct axp20x_dev *axp20x;
> > > +	const struct acpi_device_id *acpi_id;
> > >  	const struct of_device_id *of_id;
> > > -	int ret;
> > >  
> > > -	axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x),
> > > GFP_KERNEL);
> > > -	if (!axp20x)
> > > -		return -ENOMEM;
> > > +	of_id = of_match_device(axp2xx_of_match, dev);
> > > +	if (of_id) {
> > > +		axp2xx->variant = (long) of_id->data;
> > > +		goto found_match;
> > > +	}
> > >  
> > > -	of_id = of_match_device(axp20x_of_match, &i2c->dev);
> > > -	if (!of_id) {
> > > -		dev_err(&i2c->dev, "Unable to setup AXP20X
> > > data\n");
> > > +	acpi_id = acpi_match_device(dev->driver->acpi_match_table,
> > > dev);
> > > +	if (!acpi_id || !acpi_id->driver_data) {
> > > +		dev_err(dev, "Unable to setup AXP2XX ACPI data\n");
> > >  		return -ENODEV;
> > >  	}
> > > -	axp20x->variant = (long) of_id->data;
> > > +	axp2xx->variant = (long) acpi_id->driver_data;
> > 
> > Shouldn't that be in the if statement above? I guess acpi_id will be
> > null on a DT-based system.
> > 
> I am not sure what you mean. if acpi_id == NULL, then it will return
> -ENODEV since of_match_device() already found no match. If acpi_id !=
> NULL, then id must contain variant info.

Hmm, never mind. I read it backward and thought you were still in this
code path. I guess I need more coffee.

That goto isn't very intuitive though.

Maybe something like

if (of_id) {
   /* DT case */
} else if (acpi_id) {
  /* ACPI case */
} else {
  return;
}

would be better?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-09-09 13:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-08 22:24 [PATCH 0/4] Initial support for XPowers AXP288 PMIC Jacob Pan
2014-09-08 22:24 ` [PATCH 1/4] mfd/axp20x: rename files to support more devices Jacob Pan
2014-09-09  8:11   ` Lee Jones
2014-09-08 22:24 ` [PATCH 2/4] mfd/axp2xx: extend axp20x to support axp288 pmic Jacob Pan
2014-09-09  7:37   ` Maxime Ripard
2014-09-09 12:45     ` Jacob Pan
2014-09-09 13:37       ` Maxime Ripard [this message]
2014-09-11 22:23         ` Jacob Pan
2014-09-08 22:24 ` [PATCH 3/4] regulator/axp20x: use axp2xx consolidated header Jacob Pan
2014-09-09 11:25   ` Mark Brown
2014-09-11 22:26     ` Jacob Pan
2014-09-12  7:39       ` Mark Brown
2014-09-08 22:24 ` [PATCH 4/4] iio/adc/axp288: add support for axp288 gpadc Jacob Pan
2014-09-10  4:19   ` Pallala, Ramakrishna

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=20140909133704.GO3804@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=B38611@freescale.com \
    --cc=aaron.lu@intel.com \
    --cc=alan@linux.intel.com \
    --cc=angelo.compagnucci@gmail.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.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=lee.jones@linaro.org \
    --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