From patchwork Wed Apr 6 05:17:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 8758211 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B87E29FD89 for ; Wed, 6 Apr 2016 05:17:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB199201BC for ; Wed, 6 Apr 2016 05:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52597200BE for ; Wed, 6 Apr 2016 05:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760863AbcDFFRf (ORCPT ); Wed, 6 Apr 2016 01:17:35 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36213 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754234AbcDFFRc (ORCPT ); Wed, 6 Apr 2016 01:17:32 -0400 Received: by mail-pf0-f193.google.com with SMTP id q129so3199545pfb.3; Tue, 05 Apr 2016 22:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CK3lXekg+f5t4tOwhYkf3nyKKr8BEKaqVhbAaioRtUs=; b=IXyVHvLgWWkbyvQIGTPzSRUxIOMvMDieDK5HL3ROUwyC7O0TcYkG58rqmBYBZ0iNOY Xh5ea5UZdOlxX/qmK3qUQ4nmdkuX6VJdFkduMcedj+MjgATfUceussI83rNJnzQhTcri DWF0FawzWIA9yQCZPfmWm+FH/w8qqVNlgrRPfhJ+AX0yf9YhpHsIzvofOA4/7iciVXfT YUUZx2FRbkqY90D2HHhiFRbPcrUh/orVGlk5HGiW2FUVA8Vls8FPSknzwwn7UyyTzdZ0 Q8jY+EHShQl4hT8jx7e/rORgln9zQnMsGSGE1tUkX8fEGhKuoAhyygNe6qnqAntnrukJ V/3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CK3lXekg+f5t4tOwhYkf3nyKKr8BEKaqVhbAaioRtUs=; b=mRBkSljaYn1k3p0+YC9Ar3JtN5Z3R2ZxzjzHz6rwW/FF40bBp+uyla3+SMEmzw6SpC /Th2U0p1ihF3fLbW830r38rrp3geWKkCv02s9WkeIqIRHi31zn+yAVN2ZpP+dXjqmXXa kd/+oR392oZAIRxI5DYYAHORDBZJ+3+nwor2q6//eTRs6a+NtEL3IZU702mp7FpSJjtB tJC+THUgHe2cDej+NIMbbSj8gvr2CSkxgXfFhocrRfL6WrbtRINgSatBVgtZa5CzqlA4 h5Uvyjb7slWfM5zLsyeZhJxsC8p5jFDGw79CwRwPJ13wYSNRvs1HerQwdeouvglIEdM4 kiGQ== X-Gm-Message-State: AD7BkJI43ToBoqlrunimw7RpeOJgeHEDN0lGSIMg7CK9JM8KzzdFsJIA0OQMDHy0UzReTg== X-Received: by 10.98.73.142 with SMTP id r14mr35715360pfi.140.1459919851403; Tue, 05 Apr 2016 22:17:31 -0700 (PDT) Received: from d830 (or-67-232-74-92.dhcp.embarqhsd.net. [67.232.74.92]) by smtp.gmail.com with ESMTPSA id xa4sm1344447pab.26.2016.04.05.22.17.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Apr 2016 22:17:30 -0700 (PDT) Date: Tue, 5 Apr 2016 22:17:30 -0700 From: Alison Schofield 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 3/9] iio: adc: qcom-spmi-vadc: use regmap to retrieve struct device Message-ID: <13e62b042435dba9edc127a29691bd3519c8e2c0.1459918214.git.amsfield22@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);