From: Alison Schofield <amsfield22@gmail.com>
To: jic23@kernel.org
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
kgene@kernel.org, k.kozlowski@samsung.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Subject: [PATCH 2/9] iio: adc: qcom-spmi-iadc: use regmap to retrieve struct device
Date: Tue, 5 Apr 2016 22:16:31 -0700 [thread overview]
Message-ID: <aaffb79b464a361556e098d42081406813c511c4.1459918214.git.amsfield22@gmail.com> (raw)
In-Reply-To: <cover.1459918214.git.amsfield22@gmail.com>
Driver includes struct regmap and struct device in its global data.
Remove the struct device and use regmap API to retrieve device info.
Patch created using Coccinelle plus manual edits.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
---
drivers/iio/adc/qcom-spmi-iadc.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c
index fabd24e..f69a057 100644
--- a/drivers/iio/adc/qcom-spmi-iadc.c
+++ b/drivers/iio/adc/qcom-spmi-iadc.c
@@ -102,7 +102,6 @@
/**
* struct iadc_chip - IADC Current ADC device structure.
* @regmap: regmap for register read/write.
- * @dev: This device pointer.
* @base: base offset for the ADC peripheral.
* @rsense: Values of the internal and external sense resister in micro Ohms.
* @poll_eoc: Poll for end of conversion instead of waiting for IRQ.
@@ -113,7 +112,6 @@
*/
struct iadc_chip {
struct regmap *regmap;
- struct device *dev;
u16 base;
bool poll_eoc;
u32 rsense[2];
@@ -170,6 +168,7 @@ static int iadc_set_state(struct iadc_chip *iadc, bool state)
static void iadc_status_show(struct iadc_chip *iadc)
{
+ struct device *dev = regmap_get_device(iadc->regmap);
u8 mode, sta1, chan, dig, en, req;
int ret;
@@ -197,7 +196,7 @@ static void iadc_status_show(struct iadc_chip *iadc)
if (ret < 0)
return;
- dev_err(iadc->dev,
+ dev_err(dev,
"mode:%02x en:%02x chan:%02x dig:%02x req:%02x sta1:%02x\n",
mode, en, chan, dig, req, sta1);
}
@@ -284,6 +283,7 @@ static int iadc_read_result(struct iadc_chip *iadc, u16 *data)
static int iadc_do_conversion(struct iadc_chip *iadc, int chan, u16 *data)
{
+ struct device *dev = regmap_get_device(iadc->regmap);
unsigned int wait;
int ret;
@@ -310,7 +310,7 @@ static int iadc_do_conversion(struct iadc_chip *iadc, int chan, u16 *data)
exit:
iadc_set_state(iadc, false);
if (ret < 0)
- dev_err(iadc->dev, "conversion failed\n");
+ dev_err(dev, "conversion failed\n");
return ret;
}
@@ -320,6 +320,7 @@ static int iadc_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
{
struct iadc_chip *iadc = iio_priv(indio_dev);
+ struct device *dev = regmap_get_device(iadc->regmap);
s32 isense_ua, vsense_uv;
u16 adc_raw, vsense_raw;
int ret;
@@ -339,7 +340,7 @@ static int iadc_read_raw(struct iio_dev *indio_dev,
isense_ua = vsense_uv / iadc->rsense[chan->channel];
- dev_dbg(iadc->dev, "off %d gain %d adc %d %duV I %duA\n",
+ dev_dbg(dev, "off %d gain %d adc %d %duV I %duA\n",
iadc->offset[chan->channel], iadc->gain,
adc_raw, vsense_uv, isense_ua);
@@ -370,6 +371,7 @@ static irqreturn_t iadc_isr(int irq, void *dev_id)
static int iadc_update_offset(struct iadc_chip *iadc)
{
+ struct device *dev = regmap_get_device(iadc->regmap);
int ret;
ret = iadc_do_conversion(iadc, IADC_GAIN_17P857MV, &iadc->gain);
@@ -382,7 +384,7 @@ static int iadc_update_offset(struct iadc_chip *iadc)
return ret;
if (iadc->gain == iadc->offset[IADC_INT_RSENSE]) {
- dev_err(iadc->dev, "error: internal offset == gain %d\n",
+ dev_err(dev, "error: internal offset == gain %d\n",
iadc->gain);
return -EINVAL;
}
@@ -393,8 +395,7 @@ static int iadc_update_offset(struct iadc_chip *iadc)
return ret;
if (iadc->gain == iadc->offset[IADC_EXT_RSENSE]) {
- dev_err(iadc->dev, "error: external offset == gain %d\n",
- iadc->gain);
+ dev_err(dev, "error: external offset == gain %d\n", iadc->gain);
return -EINVAL;
}
@@ -403,6 +404,7 @@ static int iadc_update_offset(struct iadc_chip *iadc)
static int iadc_version_check(struct iadc_chip *iadc)
{
+ struct device *dev = regmap_get_device(iadc->regmap);
u8 val;
int ret;
@@ -411,7 +413,7 @@ static int iadc_version_check(struct iadc_chip *iadc)
return ret;
if (val < IADC_PERPH_TYPE_ADC) {
- dev_err(iadc->dev, "%d is not ADC\n", val);
+ dev_err(dev, "%d is not ADC\n", val);
return -EINVAL;
}
@@ -420,7 +422,7 @@ static int iadc_version_check(struct iadc_chip *iadc)
return ret;
if (val < IADC_PERPH_SUBTYPE_IADC) {
- dev_err(iadc->dev, "%d is not IADC\n", val);
+ dev_err(dev, "%d is not IADC\n", val);
return -EINVAL;
}
@@ -429,7 +431,7 @@ static int iadc_version_check(struct iadc_chip *iadc)
return ret;
if (val < IADC_REVISION2_SUPPORTED_IADC) {
- dev_err(iadc->dev, "revision %d not supported\n", val);
+ dev_err(dev, "revision %d not supported\n", val);
return -EINVAL;
}
@@ -438,6 +440,7 @@ static int iadc_version_check(struct iadc_chip *iadc)
static int iadc_rsense_read(struct iadc_chip *iadc, struct device_node *node)
{
+ struct device *dev = regmap_get_device(iadc->regmap);
int ret, sign, int_sense;
u8 deviation;
@@ -447,7 +450,7 @@ static int iadc_rsense_read(struct iadc_chip *iadc, struct device_node *node)
iadc->rsense[IADC_EXT_RSENSE] = IADC_INT_RSENSE_IDEAL_VALUE;
if (!iadc->rsense[IADC_EXT_RSENSE]) {
- dev_err(iadc->dev, "external resistor can't be zero Ohms");
+ dev_err(dev, "external resistor can't be zero Ohms");
return -EINVAL;
}
@@ -505,7 +508,6 @@ static int iadc_probe(struct platform_device *pdev)
return -ENOMEM;
iadc = iio_priv(indio_dev);
- iadc->dev = dev;
iadc->regmap = dev_get_regmap(dev->parent, NULL);
if (!iadc->regmap)
@@ -528,7 +530,7 @@ static int iadc_probe(struct platform_device *pdev)
if (ret < 0)
return -ENODEV;
- dev_dbg(iadc->dev, "sense resistors %d and %d micro Ohm\n",
+ dev_dbg(&pdev->dev, "sense resistors %d and %d micro Ohm\n",
iadc->rsense[IADC_INT_RSENSE],
iadc->rsense[IADC_EXT_RSENSE]);
@@ -553,7 +555,7 @@ static int iadc_probe(struct platform_device *pdev)
else
return ret;
} else {
- device_init_wakeup(iadc->dev, 1);
+ device_init_wakeup(&pdev->dev, 1);
}
ret = iadc_update_offset(iadc);
--
2.1.4
next prev parent reply other threads:[~2016-04-06 5:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 5:15 [PATCH 0/9] iio: " Alison Schofield
2016-04-06 5:15 ` [PATCH 1/9] iio: adc: exynos_adc: " Alison Schofield
2016-04-06 7:03 ` Marek Szyprowski
2016-04-06 20:33 ` Alison Schofield
2016-04-07 5:33 ` Marek Szyprowski
2016-04-10 13:45 ` Jonathan Cameron
2016-04-06 5:16 ` Alison Schofield [this message]
2016-04-10 13:54 ` [PATCH 2/9] iio: adc: qcom-spmi-iadc: " Jonathan Cameron
2016-04-06 5:17 ` [PATCH 3/9] iio: adc: qcom-spmi-vadc: " Alison Schofield
2016-04-10 13:55 ` Jonathan Cameron
2016-04-06 5:18 ` [PATCH 4/9] iio: accel: bmc150: " Alison Schofield
2016-04-06 5:18 ` [PATCH 5/9] iio: accel: mma7455: " Alison Schofield
2016-04-06 7:35 ` Joachim Eastwood
2016-04-10 13:51 ` Jonathan Cameron
2016-04-06 5:19 ` [PATCH 6/9] iio: accel: mxc4005: " Alison Schofield
2016-04-06 5:20 ` [PATCH 7/9] iio: health: afe4403: " Alison Schofield
2016-04-06 5:20 ` [PATCH 8/9] iio: health: afe4404: " Alison Schofield
2016-04-06 5:21 ` [PATCH 9/9] iio: gyro: bmg160_core: " Alison Schofield
2016-04-10 19:03 ` [PATCH v2 0/5] iio: " Alison Schofield
2016-04-10 19:05 ` [PATCH v2 1/5] iio: accel: bmc150: " Alison Schofield
2016-04-16 19:20 ` Jonathan Cameron
2016-04-18 12:18 ` Tirdea, Irina
2016-04-18 14:59 ` Srinivas Pandruvada
2016-04-18 19:16 ` Jonathan Cameron
2016-04-10 19:06 ` [PATCH v2 2/5] iio: accel: mxc4005: " Alison Schofield
2016-04-16 19:21 ` Jonathan Cameron
2016-04-10 19:07 ` [PATCH v2 3/5] iio: health: afe4403: " Alison Schofield
2016-04-16 19:22 ` Jonathan Cameron
2016-04-10 19:07 ` [PATCH v2 4/5] iio: health: afe4404: " Alison Schofield
2016-04-16 19:22 ` Jonathan Cameron
2016-04-17 18:07 ` Andrew F. Davis
2016-04-18 4:56 ` Alison Schofield
2016-04-18 15:53 ` Andrew F. Davis
2016-04-18 19:25 ` Jonathan Cameron
2016-04-10 19:08 ` [PATCH v2 5/5] iio: gyro: bmg160: " Alison Schofield
2016-04-16 19:24 ` Jonathan Cameron
2016-04-18 15:03 ` Srinivas Pandruvada
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=aaffb79b464a361556e098d42081406813c511c4.1459918214.git.amsfield22@gmail.com \
--to=amsfield22@gmail.com \
--cc=jic23@kernel.org \
--cc=k.kozlowski@samsung.com \
--cc=kgene@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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
all inboxes | Powered by JetHome®