linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Gwendal Grignou <gwendal@chromium.org>,
	srinivas.pandruvada@linux.intel.com, knaack.h@gmx.de
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v4 1/3] iio: ak8975: minor fixes
Date: Sat, 22 Nov 2014 11:28:00 +0000	[thread overview]
Message-ID: <54707340.6000806@kernel.org> (raw)
In-Reply-To: <1416595549-18717-2-git-send-email-gwendal@chromium.org>

On 21/11/14 18:45, Gwendal Grignou wrote:
> Fixes code duplication, return of function.
> Check client->irq properly when setting up optional irq handler.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de>
Applied to the togreg branch of iio.git - pushed out as testing for the
autobuilder to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/magnetometer/ak8975.c | 35 ++++++++++++++---------------------
>  1 file changed, 14 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index bf5ef07..4e69480 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -64,10 +64,10 @@
>  #define AK8975_REG_CNTL			0x0A
>  #define AK8975_REG_CNTL_MODE_SHIFT	0
>  #define AK8975_REG_CNTL_MODE_MASK	(0xF << AK8975_REG_CNTL_MODE_SHIFT)
> -#define AK8975_REG_CNTL_MODE_POWER_DOWN	0
> -#define AK8975_REG_CNTL_MODE_ONCE	1
> -#define AK8975_REG_CNTL_MODE_SELF_TEST	8
> -#define AK8975_REG_CNTL_MODE_FUSE_ROM	0xF
> +#define AK8975_REG_CNTL_MODE_POWER_DOWN	0x00
> +#define AK8975_REG_CNTL_MODE_ONCE	0x01
> +#define AK8975_REG_CNTL_MODE_SELF_TEST	0x08
> +#define AK8975_REG_CNTL_MODE_FUSE_ROM	0x0F
>  
>  #define AK8975_REG_RSVC			0x0B
>  #define AK8975_REG_ASTC			0x0C
> @@ -166,8 +166,8 @@ static int ak8975_setup_irq(struct ak8975_data *data)
>  		irq = gpio_to_irq(data->eoc_gpio);
>  
>  	rc = devm_request_irq(&client->dev, irq, ak8975_irq_handler,
> -			 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> -			 dev_name(&client->dev), data);
> +			      IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> +			      dev_name(&client->dev), data);
>  	if (rc < 0) {
>  		dev_err(&client->dev,
>  			"irq %d request failed, (gpio %d): %d\n",
> @@ -231,8 +231,12 @@ static int ak8975_setup(struct i2c_client *client)
>  				AK8975_REG_CNTL_MODE_POWER_DOWN,
>  				AK8975_REG_CNTL_MODE_MASK,
>  				AK8975_REG_CNTL_MODE_SHIFT);
> +	if (ret < 0) {
> +		dev_err(&client->dev, "Error in setting power-down mode\n");
> +		return ret;
> +	}
>  
> -	if (data->eoc_gpio > 0 || client->irq) {
> +	if (data->eoc_gpio > 0 || client->irq > 0) {
>  		ret = ak8975_setup_irq(data);
>  		if (ret < 0) {
>  			dev_err(&client->dev,
> @@ -241,11 +245,6 @@ static int ak8975_setup(struct i2c_client *client)
>  		}
>  	}
>  
> -	if (ret < 0) {
> -		dev_err(&client->dev, "Error in setting power-down mode\n");
> -		return ret;
> -	}
> -
>  /*
>   * Precalculate scale factor (in Gauss units) for each axis and
>   * store in the device data.
> @@ -550,24 +549,18 @@ static int ak8975_probe(struct i2c_client *client,
>  	/* Perform some basic start-of-day setup of the device. */
>  	err = ak8975_setup(client);
>  	if (err < 0) {
> -		dev_err(&client->dev, "AK8975 initialization fails\n");
> +		dev_err(&client->dev, "%s initialization fails\n", name);
>  		return err;
>  	}
>  
> -	data->client = client;
>  	mutex_init(&data->lock);
> -	data->eoc_gpio = eoc_gpio;
>  	indio_dev->dev.parent = &client->dev;
>  	indio_dev->channels = ak8975_channels;
>  	indio_dev->num_channels = ARRAY_SIZE(ak8975_channels);
>  	indio_dev->info = &ak8975_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  	indio_dev->name = name;
> -	err = devm_iio_device_register(&client->dev, indio_dev);
> -	if (err < 0)
> -		return err;
> -
> -	return 0;
> +	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
>  static const struct i2c_device_id ak8975_id[] = {
> @@ -588,7 +581,7 @@ MODULE_DEVICE_TABLE(of, ak8975_of_match);
>  static struct i2c_driver ak8975_driver = {
>  	.driver = {
>  		.name	= "ak8975",
> -		.of_match_table = ak8975_of_match,
> +		.of_match_table = of_match_ptr(ak8975_of_match),
>  		.acpi_match_table = ACPI_PTR(ak_acpi_match),
>  	},
>  	.probe		= ak8975_probe,
> 


  reply	other threads:[~2014-11-22 11:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 18:45 [PATCH v4 0/3] Support all AKM compass in a single driver Gwendal Grignou
2014-11-21 18:45 ` [PATCH v4 1/3] iio: ak8975: minor fixes Gwendal Grignou
2014-11-22 11:28   ` Jonathan Cameron [this message]
2014-11-21 18:45 ` [PATCH v4 2/3] iio: ak8975: add definition structure per compass type Gwendal Grignou
2014-11-24  8:43   ` Gwendal Grignou
2014-12-04 22:20     ` Hartmut Knaack
2014-11-21 18:45 ` [PATCH v4 3/3] iio: ak8975: add ak09911 and ak09912 support Gwendal Grignou
2014-11-22 11:37   ` Jonathan Cameron
2014-11-24  8:44     ` Gwendal Grignou
2014-12-04 22:21       ` Hartmut Knaack
2014-12-12 12:23   ` 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=54707340.6000806@kernel.org \
    --to=jic23@kernel.org \
    --cc=gwendal@chromium.org \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.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).