Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp264771ybr; Fri, 22 May 2020 06:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbHGaisy/1V/YCDKuPBv6Gz0YQclhWJEGxRAYG+Pn8zU90KKtjq4QVO90GGiEPrXgqn9ww X-Received: by 2002:a17:906:7684:: with SMTP id o4mr8483057ejm.449.1590153123251; Fri, 22 May 2020 06:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590153123; cv=none; d=google.com; s=arc-20160816; b=rms9NQuNd6kdYCuxZcFcEFsGrPgXHBeW/EVYIDF7GphaXXlvKzHeauDl87UK9WtmX5 5gyHg5Z8io4ASU4c/oBr3jysmp8gsYTm63HYFgiLCXcwbUjAM4GQSFHFnIuLfcxTJvRR ti6WzLghUva8ALgj/SwLeb0iFULSCPbLojaFPMxPacBNeW1eGy29MhaK7aLocCeHsAWq 4vIWgp6zDV8z0hASbWom2JZJ6AoioaSdQA0ESdQrix8Ps9MC5m0du/WhGM9TtkM3ihfe JtyDRsD6h0F2Kw+hQx1pljlND5k29qAZ6yNVGetXdagO4cWjpMzZuXy+/D6K8APZf9nv 31oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1Q7gCeuJ581kpnucroF7DlgMsogEG0xwbuZzWwJcGxc=; b=P34eRMVgFZGLmTz3PcvGEbQxUiiC3VBpyjqNEIPBL0MFc494OjzW79TfK3iW2mT1sy L9NhFczWuHs7WLSvM13RQHAy9cJ7UhGf9qQ24VcC6E+mvMaSXG9d+vW6Q+T2aZ00LIjT pOHYaOvMTDUZFW3sefGcBEn8HeyY4wqns/Ctyf+j1YnkTXaYYyM8k7oB8sebPEY7PkSS irUuvG+JNGMGVTI2HASLBISqe7pVBAlQGVzZXJ+iVM4DW3K5zwQAheOB/TCNnAdID5Zm Z4A2+shPZCrh3URzyeDDlfhewm8mXg+49NDVEWGWnqX/dAGZ6IP1OGLfnYL1viq76aG7 +O2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si4819406ejb.85.2020.05.22.06.11.40; Fri, 22 May 2020 06:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729847AbgEVNIX (ORCPT + 99 others); Fri, 22 May 2020 09:08:23 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:22204 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729377AbgEVNIQ (ORCPT ); Fri, 22 May 2020 09:08:16 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04MD77X3027265; Fri, 22 May 2020 09:08:08 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 312d365vak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 May 2020 09:08:07 -0400 Received: from SCSQMBX11.ad.analog.com (scsqmbx11.ad.analog.com [10.77.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 04MD859n028639 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Fri, 22 May 2020 09:08:05 -0400 Received: from SCSQMBX11.ad.analog.com (10.77.17.10) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Fri, 22 May 2020 06:08:03 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Fri, 22 May 2020 06:08:03 -0700 Received: from saturn.ad.analog.com ([10.48.65.112]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 04MD81UG012565; Fri, 22 May 2020 09:08:01 -0400 From: Alexandru Ardelean To: , , , CC: , , , Alexandru Ardelean Subject: [PATCH] iio: stm32-dfsdm-adc: keep a reference to the iio device on the state struct Date: Fri, 22 May 2020 16:08:04 +0300 Message-ID: <20200522130804.631508-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-22_05:2020-05-22,2020-05-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 cotscore=-2147483648 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 clxscore=1015 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005220107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We may want to get rid of the iio_priv_to_dev() helper. The reason is that we will hide some of the members of the iio_dev structure (to prevent drivers from accessing them directly), and that will also mean hiding the implementation of the iio_priv_to_dev() helper inside the IIO core. Hiding the implementation of iio_priv_to_dev() implies that some fast-paths may not be fast anymore, so a general idea is to try to get rid of the iio_priv_to_dev() altogether. The iio_priv() helper won't be affected by the rework. For this driver, not using iio_priv_to_dev(), means keeping a reference to the IIO device on the state struct. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/stm32-dfsdm-adc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 76a60d93fe23..ff7a6afa4558 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -69,6 +69,7 @@ struct stm32_dfsdm_dev_data { struct stm32_dfsdm_adc { struct stm32_dfsdm *dfsdm; + struct iio_dev *indio_dev; const struct stm32_dfsdm_dev_data *dev_data; unsigned int fl_id; unsigned int nconv; @@ -332,7 +333,7 @@ static int stm32_dfsdm_compute_all_osrs(struct iio_dev *indio_dev, static int stm32_dfsdm_start_channel(struct stm32_dfsdm_adc *adc) { - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; const struct iio_chan_spec *chan; unsigned int bit; @@ -352,7 +353,7 @@ static int stm32_dfsdm_start_channel(struct stm32_dfsdm_adc *adc) static void stm32_dfsdm_stop_channel(struct stm32_dfsdm_adc *adc) { - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; const struct iio_chan_spec *chan; unsigned int bit; @@ -422,7 +423,7 @@ static int stm32_dfsdm_filter_set_trig(struct stm32_dfsdm_adc *adc, unsigned int fl_id, struct iio_trigger *trig) { - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; u32 jextsel = 0, jexten = STM32_DFSDM_JEXTEN_DISABLED; int ret; @@ -451,7 +452,7 @@ static int stm32_dfsdm_channels_configure(struct stm32_dfsdm_adc *adc, unsigned int fl_id, struct iio_trigger *trig) { - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; struct stm32_dfsdm_filter_osr *flo = &fl->flo[0]; @@ -495,7 +496,7 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, unsigned int fl_id, struct iio_trigger *trig) { - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast]; @@ -1314,7 +1315,7 @@ static const struct iio_info stm32_dfsdm_info_adc = { static irqreturn_t stm32_dfsdm_irq(int irq, void *arg) { struct stm32_dfsdm_adc *adc = arg; - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; struct regmap *regmap = adc->dfsdm->regmap; unsigned int status, int_en; @@ -1569,6 +1570,7 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) adc = iio_priv(iio); adc->dfsdm = dev_get_drvdata(dev->parent); + adc->indio_dev = iio; iio->dev.parent = dev; iio->dev.of_node = np; @@ -1651,7 +1653,7 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) static int stm32_dfsdm_adc_remove(struct platform_device *pdev) { struct stm32_dfsdm_adc *adc = platform_get_drvdata(pdev); - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; if (adc->dev_data->type == DFSDM_AUDIO) of_platform_depopulate(&pdev->dev); @@ -1664,7 +1666,7 @@ static int stm32_dfsdm_adc_remove(struct platform_device *pdev) static int __maybe_unused stm32_dfsdm_adc_suspend(struct device *dev) { struct stm32_dfsdm_adc *adc = dev_get_drvdata(dev); - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; if (iio_buffer_enabled(indio_dev)) __stm32_dfsdm_predisable(indio_dev); @@ -1675,7 +1677,7 @@ static int __maybe_unused stm32_dfsdm_adc_suspend(struct device *dev) static int __maybe_unused stm32_dfsdm_adc_resume(struct device *dev) { struct stm32_dfsdm_adc *adc = dev_get_drvdata(dev); - struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct iio_dev *indio_dev = adc->indio_dev; const struct iio_chan_spec *chan; struct stm32_dfsdm_channel *ch; int i, ret; -- 2.25.1