From: jic23@kernel.org (Jonathan Cameron)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/5] iio: accel: mxc4005: use regmap to retrieve struct device
Date: Sat, 16 Apr 2016 20:21:16 +0100 [thread overview]
Message-ID: <571290AC.4080908@kernel.org> (raw)
In-Reply-To: <d537eefe0ed83b8fc4b33e94f3a1dab2cfe94708.1460314070.git.amsfield22@gmail.com>
On 10/04/16 20:06, Alison Schofield wrote:
> 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>
Again, I'm happy with this, but have cc'd Teodora whose driver this is
for info and comment.
Jonathan
> ---
> drivers/iio/accel/mxc4005.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
> index c23f47a..013d511 100644
> --- a/drivers/iio/accel/mxc4005.c
> +++ b/drivers/iio/accel/mxc4005.c
> @@ -60,7 +60,6 @@ enum mxc4005_range {
> };
>
> struct mxc4005_data {
> - struct device *dev;
> struct mutex mutex;
> struct regmap *regmap;
> struct iio_trigger *dready_trig;
> @@ -140,12 +139,13 @@ static const struct regmap_config mxc4005_regmap_config = {
>
> static int mxc4005_read_xyz(struct mxc4005_data *data)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> int ret;
>
> ret = regmap_bulk_read(data->regmap, MXC4005_REG_XOUT_UPPER,
> (u8 *) data->buffer, sizeof(data->buffer));
> if (ret < 0) {
> - dev_err(data->dev, "failed to read axes\n");
> + dev_err(dev, "failed to read axes\n");
> return ret;
> }
>
> @@ -155,12 +155,13 @@ static int mxc4005_read_xyz(struct mxc4005_data *data)
> static int mxc4005_read_axis(struct mxc4005_data *data,
> unsigned int addr)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> __be16 reg;
> int ret;
>
> ret = regmap_bulk_read(data->regmap, addr, (u8 *) ®, sizeof(reg));
> if (ret < 0) {
> - dev_err(data->dev, "failed to read reg %02x\n", addr);
> + dev_err(dev, "failed to read reg %02x\n", addr);
> return ret;
> }
>
> @@ -169,13 +170,14 @@ static int mxc4005_read_axis(struct mxc4005_data *data,
>
> static int mxc4005_read_scale(struct mxc4005_data *data)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> unsigned int reg;
> int ret;
> int i;
>
> ret = regmap_read(data->regmap, MXC4005_REG_CONTROL, ®);
> if (ret < 0) {
> - dev_err(data->dev, "failed to read reg_control\n");
> + dev_err(dev, "failed to read reg_control\n");
> return ret;
> }
>
> @@ -189,6 +191,7 @@ static int mxc4005_read_scale(struct mxc4005_data *data)
>
> static int mxc4005_set_scale(struct mxc4005_data *data, int val)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> unsigned int reg;
> int i;
> int ret;
> @@ -201,8 +204,7 @@ static int mxc4005_set_scale(struct mxc4005_data *data, int val)
> MXC4005_REG_CONTROL_MASK_FSR,
> reg);
> if (ret < 0)
> - dev_err(data->dev,
> - "failed to write reg_control\n");
> + dev_err(dev, "failed to write reg_control\n");
> return ret;
> }
> }
> @@ -321,13 +323,14 @@ err:
>
> static int mxc4005_clr_intr(struct mxc4005_data *data)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> int ret;
>
> /* clear interrupt */
> ret = regmap_write(data->regmap, MXC4005_REG_INT_CLR1,
> MXC4005_REG_INT_CLR1_BIT_DRDYC);
> if (ret < 0) {
> - dev_err(data->dev, "failed to write to reg_int_clr1\n");
> + dev_err(dev, "failed to write to reg_int_clr1\n");
> return ret;
> }
>
> @@ -339,6 +342,7 @@ static int mxc4005_set_trigger_state(struct iio_trigger *trig,
> {
> struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> struct mxc4005_data *data = iio_priv(indio_dev);
> + struct device *dev = regmap_get_device(data->regmap);
> int ret;
>
> mutex_lock(&data->mutex);
> @@ -352,7 +356,7 @@ static int mxc4005_set_trigger_state(struct iio_trigger *trig,
>
> if (ret < 0) {
> mutex_unlock(&data->mutex);
> - dev_err(data->dev, "failed to update reg_int_mask1");
> + dev_err(dev, "failed to update reg_int_mask1");
> return ret;
> }
>
> @@ -381,16 +385,17 @@ static const struct iio_trigger_ops mxc4005_trigger_ops = {
>
> static int mxc4005_chip_init(struct mxc4005_data *data)
> {
> + struct device *dev = regmap_get_device(data->regmap);
> int ret;
> unsigned int reg;
>
> ret = regmap_read(data->regmap, MXC4005_REG_DEVICE_ID, ®);
> if (ret < 0) {
> - dev_err(data->dev, "failed to read chip id\n");
> + dev_err(dev, "failed to read chip id\n");
> return ret;
> }
>
> - dev_dbg(data->dev, "MXC4005 chip id %02x\n", reg);
> + dev_dbg(dev, "MXC4005 chip id %02x\n", reg);
>
> return 0;
> }
> @@ -415,7 +420,6 @@ static int mxc4005_probe(struct i2c_client *client,
>
> data = iio_priv(indio_dev);
> i2c_set_clientdata(client, indio_dev);
> - data->dev = &client->dev;
> data->regmap = regmap;
>
> ret = mxc4005_chip_init(data);
>
next prev parent reply other threads:[~2016-04-16 19:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 5:15 [PATCH 0/9] iio: use regmap to retrieve struct device 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 ` [PATCH 2/9] iio: adc: qcom-spmi-iadc: " Alison Schofield
2016-04-10 13:54 ` 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 [this message]
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-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=571290AC.4080908@kernel.org \
--to=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.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 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).