All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
	ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH 1/1] iio: ak8975: Add Ak8975 magnetometer sensor
Date: Fri, 3 Sep 2010 16:16:23 -0700	[thread overview]
Message-ID: <20100903161623.26ab9c76.akpm@linux-foundation.org> (raw)
In-Reply-To: <1283470837-18210-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

On Thu,  2 Sep 2010 16:40:37 -0700
achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org wrote:

> This is for the Asahi Kasei AK8975 3-axis magnetometer.  It resides within
> the magnetometer section of the IIO subsystem, and implements the raw
> magn_x,y,z attributes, as well as x,y,z factory calibration attributes.
> 
> Signed-off-by: Andrew Chew <achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/staging/iio/magnetometer/Kconfig  |   11 +
>  drivers/staging/iio/magnetometer/Makefile |    1 +
>  drivers/staging/iio/magnetometer/ak8975.c |  521 +++++++++++++++++++++++++++++
>  3 files changed, 533 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/staging/iio/magnetometer/ak8975.c

This is version 2, yes?

It would be nice to provide some accounting of how it differs from
version 1, for those who already reviewed version 1.  The v1->v2 diff
is below.

--- a/drivers/staging/iio/magnetometer/ak8975.c~a
+++ a/drivers/staging/iio/magnetometer/ak8975.c
@@ -192,14 +192,14 @@ static int ak8975_setup(struct i2c_clien
 				   AK8975_REG_CNTL_MODE_SHIFT);
 	if (!status) {
 		dev_err(&client->dev, "Error in setting fuse access mode\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Get asa data and store in the device data. */
 	status = ak8975_read_data(client, AK8975_REG_ASAX, 3, buffer);
 	if (!status) {
 		dev_err(&client->dev, "Not able to read asa data\n");
-		return -ENODEV;
+		return -EINVAL;
 	}
 
 	data->asa[0] = buffer[0] & 0xFF;
@@ -236,10 +236,10 @@ static ssize_t store_mode(struct device 
 
 	/* Convert mode string and do some basic sanity checking on it.
 	   only 0 or 1 are valid. */
-	if (strict_strtol(buf, 10, &oval))
+	if (strict_strtoul(buf, 10, &oval))
 		return -EINVAL;
 
-	if ((oval < 0) || (oval > 1)) {
+	if (oval > 1) {
 		dev_err(dev, "mode value is not supported\n");
 		return -EINVAL;
 	}
@@ -320,7 +320,7 @@ static ssize_t show_raw(struct device *d
 				   AK8975_REG_CNTL_MODE_SHIFT);
 	if (!status) {
 		dev_err(&client->dev, "Error in setting operating mode\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Wait for the conversion to complete. */
@@ -333,13 +333,13 @@ static ssize_t show_raw(struct device *d
 	}
 	if (!timeout_ms) {
 		dev_err(&client->dev, "Conversion timeout happend\n");
-		return false;
+		return -EINVAL;
 	}
 
 	status = ak8975_read_data(client, AK8975_REG_ST1, 1, &read_status);
 	if (!status) {
 		dev_err(&client->dev, "Error in reading ST1\n");
-		return false;
+		return -EINVAL;
 	}
 
 	if (read_status & AK8975_REG_ST1_DRDY_MASK) {
@@ -347,13 +347,13 @@ static ssize_t show_raw(struct device *d
 					  1, &read_status);
 		if (!status) {
 			dev_err(&client->dev, "Error in reading ST2\n");
-			return false;
+			return -EINVAL;
 		}
 		if (read_status & (AK8975_REG_ST2_DERR_MASK |
 				   AK8975_REG_ST2_HOFL_MASK)) {
 			dev_err(&client->dev, "ST2 status error 0x%x\n",
 				read_status);
-			return false;
+			return -EINVAL;
 		}
 	}
 
@@ -363,7 +363,7 @@ static ssize_t show_raw(struct device *d
 				  (u8 *)&meas_reg);
 	if (!status) {
 		dev_err(&client->dev, "Read axis data fails\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Endian conversion of the measured values */
@@ -418,6 +418,11 @@ static int ak8975_probe(struct i2c_clien
 	data->eoc_irq = client->irq;
 	data->eoc_gpio = irq_to_gpio(client->irq);
 
+	if (!data->eoc_gpio) {
+		dev_err(&client->dev, "failed, no valid GPIO\n");
+		goto exit_free;
+	}
+
 	err = gpio_request(data->eoc_gpio, "ak_8975");
 	if (err < 0) {
 		dev_err(&client->dev, "failed to request GPIO %d, error %d\n",
@@ -429,7 +434,6 @@ static int ak8975_probe(struct i2c_clien
 	if (err < 0) {
 		dev_err(&client->dev, "Failed to configure input direction for"
 			" GPIO %d, error %d\n", data->eoc_gpio, err);
-		gpio_free(data->eoc_gpio);
 		goto exit_gpio;
 	}
 
_

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: achew@nvidia.com
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-i2c@vger.kernel.org, khali@linux-fr.org,
	ldewangan@nvidia.com
Subject: Re: [PATCH 1/1] iio: ak8975: Add Ak8975 magnetometer sensor
Date: Fri, 3 Sep 2010 16:16:23 -0700	[thread overview]
Message-ID: <20100903161623.26ab9c76.akpm@linux-foundation.org> (raw)
In-Reply-To: <1283470837-18210-1-git-send-email-achew@nvidia.com>

On Thu,  2 Sep 2010 16:40:37 -0700
achew@nvidia.com wrote:

> This is for the Asahi Kasei AK8975 3-axis magnetometer.  It resides within
> the magnetometer section of the IIO subsystem, and implements the raw
> magn_x,y,z attributes, as well as x,y,z factory calibration attributes.
> 
> Signed-off-by: Andrew Chew <achew@nvidia.com>
> ---
>  drivers/staging/iio/magnetometer/Kconfig  |   11 +
>  drivers/staging/iio/magnetometer/Makefile |    1 +
>  drivers/staging/iio/magnetometer/ak8975.c |  521 +++++++++++++++++++++++++++++
>  3 files changed, 533 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/staging/iio/magnetometer/ak8975.c

This is version 2, yes?

It would be nice to provide some accounting of how it differs from
version 1, for those who already reviewed version 1.  The v1->v2 diff
is below.

--- a/drivers/staging/iio/magnetometer/ak8975.c~a
+++ a/drivers/staging/iio/magnetometer/ak8975.c
@@ -192,14 +192,14 @@ static int ak8975_setup(struct i2c_clien
 				   AK8975_REG_CNTL_MODE_SHIFT);
 	if (!status) {
 		dev_err(&client->dev, "Error in setting fuse access mode\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Get asa data and store in the device data. */
 	status = ak8975_read_data(client, AK8975_REG_ASAX, 3, buffer);
 	if (!status) {
 		dev_err(&client->dev, "Not able to read asa data\n");
-		return -ENODEV;
+		return -EINVAL;
 	}
 
 	data->asa[0] = buffer[0] & 0xFF;
@@ -236,10 +236,10 @@ static ssize_t store_mode(struct device 
 
 	/* Convert mode string and do some basic sanity checking on it.
 	   only 0 or 1 are valid. */
-	if (strict_strtol(buf, 10, &oval))
+	if (strict_strtoul(buf, 10, &oval))
 		return -EINVAL;
 
-	if ((oval < 0) || (oval > 1)) {
+	if (oval > 1) {
 		dev_err(dev, "mode value is not supported\n");
 		return -EINVAL;
 	}
@@ -320,7 +320,7 @@ static ssize_t show_raw(struct device *d
 				   AK8975_REG_CNTL_MODE_SHIFT);
 	if (!status) {
 		dev_err(&client->dev, "Error in setting operating mode\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Wait for the conversion to complete. */
@@ -333,13 +333,13 @@ static ssize_t show_raw(struct device *d
 	}
 	if (!timeout_ms) {
 		dev_err(&client->dev, "Conversion timeout happend\n");
-		return false;
+		return -EINVAL;
 	}
 
 	status = ak8975_read_data(client, AK8975_REG_ST1, 1, &read_status);
 	if (!status) {
 		dev_err(&client->dev, "Error in reading ST1\n");
-		return false;
+		return -EINVAL;
 	}
 
 	if (read_status & AK8975_REG_ST1_DRDY_MASK) {
@@ -347,13 +347,13 @@ static ssize_t show_raw(struct device *d
 					  1, &read_status);
 		if (!status) {
 			dev_err(&client->dev, "Error in reading ST2\n");
-			return false;
+			return -EINVAL;
 		}
 		if (read_status & (AK8975_REG_ST2_DERR_MASK |
 				   AK8975_REG_ST2_HOFL_MASK)) {
 			dev_err(&client->dev, "ST2 status error 0x%x\n",
 				read_status);
-			return false;
+			return -EINVAL;
 		}
 	}
 
@@ -363,7 +363,7 @@ static ssize_t show_raw(struct device *d
 				  (u8 *)&meas_reg);
 	if (!status) {
 		dev_err(&client->dev, "Read axis data fails\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* Endian conversion of the measured values */
@@ -418,6 +418,11 @@ static int ak8975_probe(struct i2c_clien
 	data->eoc_irq = client->irq;
 	data->eoc_gpio = irq_to_gpio(client->irq);
 
+	if (!data->eoc_gpio) {
+		dev_err(&client->dev, "failed, no valid GPIO\n");
+		goto exit_free;
+	}
+
 	err = gpio_request(data->eoc_gpio, "ak_8975");
 	if (err < 0) {
 		dev_err(&client->dev, "failed to request GPIO %d, error %d\n",
@@ -429,7 +434,6 @@ static int ak8975_probe(struct i2c_clien
 	if (err < 0) {
 		dev_err(&client->dev, "Failed to configure input direction for"
 			" GPIO %d, error %d\n", data->eoc_gpio, err);
-		gpio_free(data->eoc_gpio);
 		goto exit_gpio;
 	}
 
_


  parent reply	other threads:[~2010-09-03 23:16 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-02 23:40 [PATCH 1/1] iio: ak8975: Add Ak8975 magnetometer sensor achew-DDmLM1+adcrQT0dZR+AlfA
2010-09-02 23:40 ` achew
     [not found] ` <1283470837-18210-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2010-09-03 23:16   ` Andrew Morton [this message]
2010-09-03 23:16     ` Andrew Morton
2010-09-04 16:38   ` Jonathan Cameron
2010-09-04 16:38     ` Jonathan Cameron
2010-09-06  8:17   ` Datta, Shubhrajyoti
2010-09-06  8:17     ` Datta, Shubhrajyoti
     [not found]     ` <0680EC522D0CC943BC586913CF3768C003C2018464-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-09-07 23:07       ` Andrew Chew
2010-09-07 23:07         ` Andrew Chew
     [not found]         ` <643E69AA4436674C8F39DCC2C05F763816B85AD0A9-lR+7xdUAJVNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2010-09-08 10:05           ` Datta, Shubhrajyoti
2010-09-08 10:05             ` Datta, Shubhrajyoti
     [not found]             ` <0680EC522D0CC943BC586913CF3768C003C2018BD4-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-09-08 15:34               ` Murphy, Dan
2010-09-08 15:34                 ` Murphy, Dan
  -- strict thread matches above, loose matches on Subject: below --
2010-09-02 21:35 achew-DDmLM1+adcrQT0dZR+AlfA
2010-09-02 21:35 ` achew
     [not found] ` <1283463351-15816-1-git-send-email-achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2010-09-02 22:19   ` Alan Cox
2010-09-02 22:19     ` Alan Cox
     [not found]     ` <20100902231942.21375cc0-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-09-02 22:16       ` Andrew Chew
2010-09-02 22:16         ` Andrew Chew
2010-09-02 22:41         ` Alan Cox
2010-09-02 23:15           ` Jonathan Cameron
2010-09-02 23:57             ` Andrew Chew
2010-09-03  7:19               ` Jonathan Cameron
2010-09-03 20:03                 ` Andrew Chew
2010-09-04 16:07                   ` Jonathan Cameron
2010-09-03  5:18       ` samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w
2010-09-03  5:18         ` samu.p.onkalo
     [not found]         ` <62697B07E9803846BC582181BD6FB6B82B9C057FFC-xJW1crHCIS+8kqYwC468Frtp2NbXvJi8gfoxzgwHRXE@public.gmane.org>
2010-09-03  7:23           ` Jonathan Cameron
2010-09-03  7:23             ` Jonathan Cameron
     [not found]             ` <4C80A26F.6020408-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2010-09-03  7:20               ` samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w
2010-09-03  7:20                 ` samu.p.onkalo
2010-09-03  7:20                 ` samu.p.onkalo

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=20100903161623.26ab9c76.akpm@linux-foundation.org \
    --to=akpm-de/tnxtf+jlsfhdxvbkv3wd2fqjk+8+b@public.gmane.org \
    --cc=achew-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.