linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jic23@kernel.org (Jonathan Cameron)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/5] iio: health: afe4404: use regmap to retrieve struct device
Date: Sat, 16 Apr 2016 20:22:41 +0100	[thread overview]
Message-ID: <57129101.7000503@kernel.org> (raw)
In-Reply-To: <2dd23e55fa7c2d16c577146eefd4a84046d2b838.1460314070.git.amsfield22@gmail.com>

On 10/04/16 20:07, 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>
Cc'd Andrew
> ---
>  drivers/iio/health/afe4404.c | 38 +++++++++++++++++++-------------------
>  1 file changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
> index 5096a46..9cd8590 100644
> --- a/drivers/iio/health/afe4404.c
> +++ b/drivers/iio/health/afe4404.c
> @@ -107,14 +107,12 @@
>  
>  /**
>   * struct afe4404_data
> - * @dev - Device structure
>   * @regmap - Register map of the device
>   * @regulator - Pointer to the regulator for the IC
>   * @trig - IIO trigger for this device
>   * @irq - ADC_RDY line interrupt number
>   */
>  struct afe4404_data {
> -	struct device *dev;
>  	struct regmap *regmap;
>  	struct regulator *regulator;
>  	struct iio_trigger *trig;
> @@ -534,54 +532,54 @@ static int afe4404_probe(struct i2c_client *client,
>  	afe = iio_priv(indio_dev);
>  	i2c_set_clientdata(client, indio_dev);
>  
> -	afe->dev = &client->dev;
>  	afe->irq = client->irq;
>  
>  	afe->regmap = devm_regmap_init_i2c(client, &afe4404_regmap_config);
>  	if (IS_ERR(afe->regmap)) {
> -		dev_err(afe->dev, "Unable to allocate register map\n");
> +		dev_err(&client->dev, "Unable to allocate register map\n");
>  		return PTR_ERR(afe->regmap);
>  	}
>  
> -	afe->regulator = devm_regulator_get(afe->dev, "tx_sup");
> +	afe->regulator = devm_regulator_get(&client->dev, "tx_sup");
>  	if (IS_ERR(afe->regulator)) {
> -		dev_err(afe->dev, "Unable to get regulator\n");
> +		dev_err(&client->dev, "Unable to get regulator\n");
>  		return PTR_ERR(afe->regulator);
>  	}
>  	ret = regulator_enable(afe->regulator);
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to enable regulator\n");
> +		dev_err(&client->dev, "Unable to enable regulator\n");
>  		return ret;
>  	}
>  
>  	ret = regmap_write(afe->regmap, AFE440X_CONTROL0,
>  			   AFE440X_CONTROL0_SW_RESET);
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to reset device\n");
> +		dev_err(&client->dev, "Unable to reset device\n");
>  		goto disable_reg;
>  	}
>  
>  	ret = regmap_multi_reg_write(afe->regmap, afe4404_reg_sequences,
>  				     ARRAY_SIZE(afe4404_reg_sequences));
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to set register defaults\n");
> +		dev_err(&client->dev, "Unable to set register defaults\n");
>  		goto disable_reg;
>  	}
>  
>  	indio_dev->modes = INDIO_DIRECT_MODE;
> -	indio_dev->dev.parent = afe->dev;
> +	indio_dev->dev.parent = &client->dev;
>  	indio_dev->channels = afe4404_channels;
>  	indio_dev->num_channels = ARRAY_SIZE(afe4404_channels);
>  	indio_dev->name = AFE4404_DRIVER_NAME;
>  	indio_dev->info = &afe4404_iio_info;
>  
>  	if (afe->irq > 0) {
> -		afe->trig = devm_iio_trigger_alloc(afe->dev,
> +		afe->trig = devm_iio_trigger_alloc(&client->dev,
>  						   "%s-dev%d",
>  						   indio_dev->name,
>  						   indio_dev->id);
>  		if (!afe->trig) {
> -			dev_err(afe->dev, "Unable to allocate IIO trigger\n");
> +			dev_err(&client->dev,
> +				"Unable to allocate IIO trigger\n");
>  			ret = -ENOMEM;
>  			goto disable_reg;
>  		}
> @@ -589,21 +587,22 @@ static int afe4404_probe(struct i2c_client *client,
>  		iio_trigger_set_drvdata(afe->trig, indio_dev);
>  
>  		afe->trig->ops = &afe4404_trigger_ops;
> -		afe->trig->dev.parent = afe->dev;
> +		afe->trig->dev.parent = &client->dev;
>  
>  		ret = iio_trigger_register(afe->trig);
>  		if (ret) {
> -			dev_err(afe->dev, "Unable to register IIO trigger\n");
> +			dev_err(&client->dev,
> +				"Unable to register IIO trigger\n");
>  			goto disable_reg;
>  		}
>  
> -		ret = devm_request_threaded_irq(afe->dev, afe->irq,
> +		ret = devm_request_threaded_irq(&client->dev, afe->irq,
>  						iio_trigger_generic_data_rdy_poll,
>  						NULL, IRQF_ONESHOT,
>  						AFE4404_DRIVER_NAME,
>  						afe->trig);
>  		if (ret) {
> -			dev_err(afe->dev, "Unable to request IRQ\n");
> +			dev_err(&client->dev, "Unable to request IRQ\n");
>  			goto disable_reg;
>  		}
>  	}
> @@ -611,13 +610,13 @@ static int afe4404_probe(struct i2c_client *client,
>  	ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
>  					 afe4404_trigger_handler, NULL);
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to setup buffer\n");
> +		dev_err(&client->dev, "Unable to setup buffer\n");
>  		goto unregister_trigger;
>  	}
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to register IIO device\n");
> +		dev_err(&client->dev, "Unable to register IIO device\n");
>  		goto unregister_triggered_buffer;
>  	}
>  
> @@ -638,6 +637,7 @@ static int afe4404_remove(struct i2c_client *client)
>  {
>  	struct iio_dev *indio_dev = i2c_get_clientdata(client);
>  	struct afe4404_data *afe = iio_priv(indio_dev);
> +	struct device *dev = regmap_get_device(afe->regmap);
>  	int ret;
>  
>  	iio_device_unregister(indio_dev);
> @@ -649,7 +649,7 @@ static int afe4404_remove(struct i2c_client *client)
>  
>  	ret = regulator_disable(afe->regulator);
>  	if (ret) {
> -		dev_err(afe->dev, "Unable to disable regulator\n");
> +		dev_err(dev, "Unable to disable regulator\n");
>  		return ret;
>  	}
>  
> 

  reply	other threads:[~2016-04-16 19:22 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
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 [this message]
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=57129101.7000503@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).