Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alison Schofield <amsfield22@gmail.com>
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: Re: [PATCH 3/9] iio: adc: qcom-spmi-vadc: use regmap to retrieve struct device
Date: Sun, 10 Apr 2016 14:55:39 +0100	[thread overview]
Message-ID: <570A5B5B.5050801@kernel.org> (raw)
In-Reply-To: <13e62b042435dba9edc127a29691bd3519c8e2c0.1459918214.git.amsfield22@gmail.com>

On 06/04/16 06:17, 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>
Another one where the regmap belongs to the wrong device... (parent)
> ---
>  drivers/iio/adc/qcom-spmi-vadc.c | 37 ++++++++++++++++++++-----------------
>  1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
> index c2babe5..9e7aeca 100644
> --- a/drivers/iio/adc/qcom-spmi-vadc.c
> +++ b/drivers/iio/adc/qcom-spmi-vadc.c
> @@ -161,7 +161,6 @@ struct vadc_channel_prop {
>  /**
>   * struct vadc_priv - VADC private structure.
>   * @regmap: pointer to struct regmap.
> - * @dev: pointer to struct device.
>   * @base: base address for the ADC peripheral.
>   * @nchannels: number of VADC channels.
>   * @chan_props: array of VADC channel properties.
> @@ -174,7 +173,6 @@ struct vadc_channel_prop {
>   */
>  struct vadc_priv {
>  	struct regmap		 *regmap;
> -	struct device		 *dev;
>  	u16			 base;
>  	unsigned int		 nchannels;
>  	struct vadc_channel_prop *chan_props;
> @@ -236,6 +234,7 @@ static int vadc_set_state(struct vadc_priv *vadc, bool state)
>  
>  static void vadc_show_status(struct vadc_priv *vadc)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	u8 mode, sta1, chan, dig, en, req;
>  	int ret;
>  
> @@ -263,7 +262,7 @@ static void vadc_show_status(struct vadc_priv *vadc)
>  	if (ret)
>  		return;
>  
> -	dev_err(vadc->dev,
> +	dev_err(dev,
>  		"mode:%02x en:%02x chan:%02x dig:%02x req:%02x sta1:%02x\n",
>  		mode, en, chan, dig, req, sta1);
>  }
> @@ -350,13 +349,14 @@ static int vadc_read_result(struct vadc_priv *vadc, u16 *data)
>  static struct vadc_channel_prop *vadc_get_channel(struct vadc_priv *vadc,
>  						  unsigned int num)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	unsigned int i;
>  
>  	for (i = 0; i < vadc->nchannels; i++)
>  		if (vadc->chan_props[i].channel == num)
>  			return &vadc->chan_props[i];
>  
> -	dev_dbg(vadc->dev, "no such channel %02x\n", num);
> +	dev_dbg(dev, "no such channel %02x\n", num);
>  
>  	return NULL;
>  }
> @@ -364,6 +364,7 @@ static struct vadc_channel_prop *vadc_get_channel(struct vadc_priv *vadc,
>  static int vadc_do_conversion(struct vadc_priv *vadc,
>  			      struct vadc_channel_prop *prop, u16 *data)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	unsigned int timeout;
>  	int ret;
>  
> @@ -406,7 +407,7 @@ static int vadc_do_conversion(struct vadc_priv *vadc,
>  err_disable:
>  	vadc_set_state(vadc, false);
>  	if (ret)
> -		dev_err(vadc->dev, "conversion failed\n");
> +		dev_err(dev, "conversion failed\n");
>  unlock:
>  	mutex_unlock(&vadc->lock);
>  	return ret;
> @@ -414,6 +415,7 @@ unlock:
>  
>  static int vadc_measure_ref_points(struct vadc_priv *vadc)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	struct vadc_channel_prop *prop;
>  	u16 read_1, read_2;
>  	int ret;
> @@ -463,7 +465,7 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
>  	vadc->graph[VADC_CALIB_RATIOMETRIC].gnd = read_2;
>  err:
>  	if (ret)
> -		dev_err(vadc->dev, "measure reference points failed\n");
> +		dev_err(dev, "measure reference points failed\n");
>  
>  	return ret;
>  }
> @@ -814,6 +816,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
>  
>  static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	const struct vadc_channels *vadc_chan;
>  	struct iio_chan_spec *iio_chan;
>  	struct vadc_channel_prop prop;
> @@ -825,12 +828,12 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
>  	if (!vadc->nchannels)
>  		return -EINVAL;
>  
> -	vadc->iio_chans = devm_kcalloc(vadc->dev, vadc->nchannels,
> +	vadc->iio_chans = devm_kcalloc(dev, vadc->nchannels,
>  				       sizeof(*vadc->iio_chans), GFP_KERNEL);
>  	if (!vadc->iio_chans)
>  		return -ENOMEM;
>  
> -	vadc->chan_props = devm_kcalloc(vadc->dev, vadc->nchannels,
> +	vadc->chan_props = devm_kcalloc(dev, vadc->nchannels,
>  					sizeof(*vadc->chan_props), GFP_KERNEL);
>  	if (!vadc->chan_props)
>  		return -ENOMEM;
> @@ -838,7 +841,7 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
>  	iio_chan = vadc->iio_chans;
>  
>  	for_each_available_child_of_node(node, child) {
> -		ret = vadc_get_dt_channel_data(vadc->dev, &prop, child);
> +		ret = vadc_get_dt_channel_data(dev, &prop, child);
>  		if (ret) {
>  			of_node_put(child);
>  			return ret;
> @@ -860,22 +863,22 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
>  
>  	/* These channels are mandatory, they are used as reference points */
>  	if (!vadc_get_channel(vadc, VADC_REF_1250MV)) {
> -		dev_err(vadc->dev, "Please define 1.25V channel\n");
> +		dev_err(dev, "Please define 1.25V channel\n");
>  		return -ENODEV;
>  	}
>  
>  	if (!vadc_get_channel(vadc, VADC_REF_625MV)) {
> -		dev_err(vadc->dev, "Please define 0.625V channel\n");
> +		dev_err(dev, "Please define 0.625V channel\n");
>  		return -ENODEV;
>  	}
>  
>  	if (!vadc_get_channel(vadc, VADC_VDD_VADC)) {
> -		dev_err(vadc->dev, "Please define VDD channel\n");
> +		dev_err(dev, "Please define VDD channel\n");
>  		return -ENODEV;
>  	}
>  
>  	if (!vadc_get_channel(vadc, VADC_GND_REF)) {
> -		dev_err(vadc->dev, "Please define GND channel\n");
> +		dev_err(dev, "Please define GND channel\n");
>  		return -ENODEV;
>  	}
>  
> @@ -893,6 +896,7 @@ static irqreturn_t vadc_isr(int irq, void *dev_id)
>  
>  static int vadc_check_revision(struct vadc_priv *vadc)
>  {
> +	struct device *dev = regmap_get_device(vadc->regmap);
>  	u8 val;
>  	int ret;
>  
> @@ -901,7 +905,7 @@ static int vadc_check_revision(struct vadc_priv *vadc)
>  		return ret;
>  
>  	if (val < VADC_PERPH_TYPE_ADC) {
> -		dev_err(vadc->dev, "%d is not ADC\n", val);
> +		dev_err(dev, "%d is not ADC\n", val);
>  		return -ENODEV;
>  	}
>  
> @@ -910,7 +914,7 @@ static int vadc_check_revision(struct vadc_priv *vadc)
>  		return ret;
>  
>  	if (val < VADC_PERPH_SUBTYPE_VADC) {
> -		dev_err(vadc->dev, "%d is not VADC\n", val);
> +		dev_err(dev, "%d is not VADC\n", val);
>  		return -ENODEV;
>  	}
>  
> @@ -919,7 +923,7 @@ static int vadc_check_revision(struct vadc_priv *vadc)
>  		return ret;
>  
>  	if (val < VADC_REVISION2_SUPPORTED_VADC) {
> -		dev_err(vadc->dev, "revision %d not supported\n", val);
> +		dev_err(dev, "revision %d not supported\n", val);
>  		return -ENODEV;
>  	}
>  
> @@ -950,7 +954,6 @@ static int vadc_probe(struct platform_device *pdev)
>  
>  	vadc = iio_priv(indio_dev);
>  	vadc->regmap = regmap;
> -	vadc->dev = dev;
>  	vadc->base = reg;
>  	vadc->are_ref_measured = false;
>  	init_completion(&vadc->complete);
> 

  reply	other threads:[~2016-04-10 13:55 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
     [not found]     ` <5704B4A4.1070704-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-04-06 20:33       ` Alison Schofield
     [not found]         ` <20160406203308.GA3462-WHVijhI79TDuUkLf1qLn2g@public.gmane.org>
2016-04-07  5:33           ` Marek Szyprowski
     [not found]             ` <5705F131.4090201-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-04-10 13:45               ` Jonathan Cameron
2016-04-06  5:17 ` [PATCH 3/9] iio: adc: qcom-spmi-vadc: " Alison Schofield
2016-04-10 13:55   ` Jonathan Cameron [this message]
2016-04-06  5:18 ` [PATCH 4/9] iio: accel: bmc150: " Alison Schofield
     [not found] ` <cover.1459918214.git.amsfield22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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: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:21   ` [PATCH 9/9] iio: gyro: bmg160_core: " Alison Schofield
2016-04-06  5:20 ` [PATCH 8/9] iio: health: afe4404: " Alison Schofield
2016-04-10 19:03 ` [PATCH v2 0/5] iio: " Alison Schofield
2016-04-10 19:06   ` [PATCH v2 2/5] iio: accel: mxc4005: " Alison Schofield
2016-04-16 19:21     ` Jonathan Cameron
     [not found]   ` <cover.1460314070.git.amsfield22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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
     [not found]         ` <57129064.9050508-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-04-18 14:59           ` Srinivas Pandruvada
     [not found]             ` <1460991578.8946.10.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-18 19:16               ` 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
     [not found]         ` <57129101.7000503-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
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
     [not found]       ` <57129157.3080603-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
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=570A5B5B.5050801@kernel.org \
    --to=jic23@kernel.org \
    --cc=amsfield22@gmail.com \
    --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