From: Gwendal Grignou <gwendal@chromium.org>
To: srinivas.pandruvada@linux.intel.com, jic23@kernel.org, knaack.h@gmx.de
Cc: linux-iio@vger.kernel.org, Gwendal Grignou <gwendal@chromium.org>
Subject: [PATCH v2 1/3] iio: ak8975: minor fixes
Date: Mon, 17 Nov 2014 12:13:41 -0800 [thread overview]
Message-ID: <1416255221-18528-1-git-send-email-gwendal@chromium.org> (raw)
In-Reply-To: <1415225452-21957-2-git-send-email-gwendal@chromium.org>
Fixes code duplication, return of function.
Check client->irq properly when setting up optional irq handler.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
Fix client->irq checking, Srinivas found it was not correct on ACPI based
machine.
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,
--
2.1.0.rc2.206.gedb03e5
next prev parent reply other threads:[~2014-11-17 20:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 22:01 [PATCH 0/1] iio: ak8975: Add AKM0991x support Gwendal Grignou
2014-10-29 22:01 ` [PATCH] " Gwendal Grignou
2014-11-03 22:22 ` Hartmut Knaack
2014-11-04 19:41 ` [PATCHv2] " Gwendal Grignou
2014-11-05 14:31 ` Jonathan Cameron
2014-11-05 21:19 ` Gwendal Grignou
2014-11-05 22:10 ` [PATCH 0/3] Support all AKM compass in a single driver Gwendal Grignou
2014-11-05 22:10 ` [PATCH 1/3] iio: ak8975: minor fixes Gwendal Grignou
2014-11-06 15:00 ` Srinivas Pandruvada
2014-11-17 20:13 ` Gwendal Grignou [this message]
2014-11-19 11:16 ` [PATCH v2 " Hartmut Knaack
2014-11-05 22:10 ` [PATCH 2/3] iio: ak8975: add definition structure per compass type Gwendal Grignou
2014-11-06 15:02 ` Srinivas Pandruvada
2014-11-06 21:16 ` Gwendal Grignou
2014-11-19 11:25 ` Hartmut Knaack
2014-11-05 22:10 ` [PATCH 3/3] iio: ak8975: add ak09911 and ak09912 support Gwendal Grignou
2014-11-06 15:05 ` Srinivas Pandruvada
2014-11-06 21:25 ` Gwendal Grignou
2014-11-17 18:02 ` Srinivas Pandruvada
2014-11-17 20:15 ` Gwendal Grignou
2014-11-17 20:36 ` Srinivas Pandruvada
2014-11-19 11:39 ` Hartmut Knaack
2014-11-08 12:16 ` Jonathan Cameron
2014-11-14 9:01 ` Gwendal Grignou
2014-11-06 14:32 ` [PATCHv2] iio: ak8975: Add AKM0991x support Srinivas Pandruvada
2014-11-08 12:17 ` Jonathan Cameron
2014-10-31 15:21 ` [PATCH 0/1] " Srinivas Pandruvada
2014-11-01 21:03 ` Gwendal Grignou
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=1416255221-18528-1-git-send-email-gwendal@chromium.org \
--to=gwendal@chromium.org \
--cc=jic23@kernel.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 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.