From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94514C433E0 for ; Sat, 16 May 2020 17:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B7CA206D8 for ; Sat, 16 May 2020 17:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589649184; bh=6IJY4KxDuWPHH1o658HGioayIj3kO/S0obPuk7kZ6mU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=DyxVN++ucJ5C5gxZWXCbnCuiMr4KABI1wGVWlWTe/rEjRqE6llTfv7xxKTN6pIpSj rqV/BuI1l0BjAz+QbZ0uIIsiYBIxn8W8SEb9oDl3iWivEVU/k0I+F4KYkU78m2r5me N53fa8JjuOyZ4xXB9lS6NQA2I+9vaBPrP3qH0ueg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726388AbgEPRMv (ORCPT ); Sat, 16 May 2020 13:12:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgEPRMu (ORCPT ); Sat, 16 May 2020 13:12:50 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D9E8206D8; Sat, 16 May 2020 17:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589649169; bh=6IJY4KxDuWPHH1o658HGioayIj3kO/S0obPuk7kZ6mU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=STLdi0QoDx5qKD4mjTSUI0w8gqa09q+XkcRAlqIajis1bhP/yjdMgL5GfnID13mXG BBjJ6101DlofeKYd3TIyMzLQ01BPWN7aQMhu+bjpzro1KL4aeQkp2r2kKlv2GmQ4/V 0OnH77GGibp4wG/Bpvc9DiX+lQeesvHCgsq6wqxU= Date: Sat, 16 May 2020 18:12:44 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: , , , , , , , , , , Subject: Re: [PATCH v2 1/8] iio: proximity: ping: pass reference to IIO device via call-stack Message-ID: <20200516181244.4d22c60b@archlinux> In-Reply-To: <20200514131710.84201-2-alexandru.ardelean@analog.com> References: <20200514131710.84201-1-alexandru.ardelean@analog.com> <20200514131710.84201-2-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 May 2020 16:17:03 +0300 Alexandru Ardelean wrote: > Since there will be some changes to how iio_priv_to_dev() is implemented, > it could be that the helper becomes a bit slower, as it will be hidden away > in the IIO core. > > For this driver, the IIO device can be passed directly as a parameter to > the ping_read() function, thus making it immune to the change of > iio_priv_to_dev(). > > Signed-off-by: Alexandru Ardelean Patch makes sense and I should have spotted this one during original review :( Going backwards and forwards is never a good idea even without the rework you have. But... (you knew that was coming :), there is no need to pass data to the the read function. It is the structure returned by iio_priv() and not used anywhere else in the read_raw callback. So might as well just pass the iio_dev and get the data structure with in the read function via iio_priv(indio_dev) Thanks, J > --- > drivers/iio/proximity/ping.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/proximity/ping.c b/drivers/iio/proximity/ping.c > index 12b893c5b0ee..ddc43a5a2ef8 100644 > --- a/drivers/iio/proximity/ping.c > +++ b/drivers/iio/proximity/ping.c > @@ -89,14 +89,13 @@ static irqreturn_t ping_handle_irq(int irq, void *dev_id) > return IRQ_HANDLED; > } > > -static int ping_read(struct ping_data *data) > +static int ping_read(struct iio_dev *indio_dev, struct ping_data *data) > { > int ret; > ktime_t ktime_dt; > s64 dt_ns; > u32 time_ns, distance_mm; > struct platform_device *pdev = to_platform_device(data->dev); > - struct iio_dev *indio_dev = iio_priv_to_dev(data); > > /* > * just one read-echo-cycle can take place at a time > @@ -236,7 +235,7 @@ static int ping_read_raw(struct iio_dev *indio_dev, > > switch (info) { > case IIO_CHAN_INFO_RAW: > - ret = ping_read(data); > + ret = ping_read(indio_dev, data); > if (ret < 0) > return ret; > *val = ret; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AEB5C433DF for ; Sat, 16 May 2020 17:12:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F19B206D8 for ; Sat, 16 May 2020 17:12:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="J0b0UK1j"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="STLdi0Qo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F19B206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fjB4zYgcMOrIAwG7TvSk2qi10eJgDlRkzTmRlVqXGQM=; b=J0b0UK1ji1Ga6q 2ZXzpNL4Fb0xfFxffMemMQpZY2FEOrHzaJ/hsohj1K87IZd4j96opwIhAKqg0fY7w7L7iEmwyBlzK +zN6e7VzYH3CL52J0w7evA5u0Bip5TDu7uARPGxsTPkjEF+5XT4mRVdcl9Q2f/hlHg/FiBDhjIwBQ +P/PZbabZT6NSLvehsN1lnKjTpukbbXbsmpVuRQdNLxi3EjPO3gPGSp0Mqt3IsepbjpuC96ecM/B8 1Fl3kGC2UpBiRkjQR9JOlQjM0oDr4jstakb9StDPJ82b/PvqH4uGj1yMcWOHQahh5Ta/6Yy8SqggB ipNTxbcZn1F+ci+ehLYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ja0Mm-0000kv-V7; Sat, 16 May 2020 17:12:52 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ja0Mj-0000kX-UV for linux-arm-kernel@lists.infradead.org; Sat, 16 May 2020 17:12:51 +0000 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D9E8206D8; Sat, 16 May 2020 17:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589649169; bh=6IJY4KxDuWPHH1o658HGioayIj3kO/S0obPuk7kZ6mU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=STLdi0QoDx5qKD4mjTSUI0w8gqa09q+XkcRAlqIajis1bhP/yjdMgL5GfnID13mXG BBjJ6101DlofeKYd3TIyMzLQ01BPWN7aQMhu+bjpzro1KL4aeQkp2r2kKlv2GmQ4/V 0OnH77GGibp4wG/Bpvc9DiX+lQeesvHCgsq6wqxU= Date: Sat, 16 May 2020 18:12:44 +0100 From: Jonathan Cameron To: Alexandru Ardelean Subject: Re: [PATCH v2 1/8] iio: proximity: ping: pass reference to IIO device via call-stack Message-ID: <20200516181244.4d22c60b@archlinux> In-Reply-To: <20200514131710.84201-2-alexandru.ardelean@analog.com> References: <20200514131710.84201-1-alexandru.ardelean@analog.com> <20200514131710.84201-2-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200516_101250_002815_7F297CE6 X-CRM114-Status: GOOD ( 19.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, alexandre.torgue@st.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, ak@it-klinger.de, mcoquelin.stm32@gmail.com, eugen.hristev@microchip.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 14 May 2020 16:17:03 +0300 Alexandru Ardelean wrote: > Since there will be some changes to how iio_priv_to_dev() is implemented, > it could be that the helper becomes a bit slower, as it will be hidden away > in the IIO core. > > For this driver, the IIO device can be passed directly as a parameter to > the ping_read() function, thus making it immune to the change of > iio_priv_to_dev(). > > Signed-off-by: Alexandru Ardelean Patch makes sense and I should have spotted this one during original review :( Going backwards and forwards is never a good idea even without the rework you have. But... (you knew that was coming :), there is no need to pass data to the the read function. It is the structure returned by iio_priv() and not used anywhere else in the read_raw callback. So might as well just pass the iio_dev and get the data structure with in the read function via iio_priv(indio_dev) Thanks, J > --- > drivers/iio/proximity/ping.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/proximity/ping.c b/drivers/iio/proximity/ping.c > index 12b893c5b0ee..ddc43a5a2ef8 100644 > --- a/drivers/iio/proximity/ping.c > +++ b/drivers/iio/proximity/ping.c > @@ -89,14 +89,13 @@ static irqreturn_t ping_handle_irq(int irq, void *dev_id) > return IRQ_HANDLED; > } > > -static int ping_read(struct ping_data *data) > +static int ping_read(struct iio_dev *indio_dev, struct ping_data *data) > { > int ret; > ktime_t ktime_dt; > s64 dt_ns; > u32 time_ns, distance_mm; > struct platform_device *pdev = to_platform_device(data->dev); > - struct iio_dev *indio_dev = iio_priv_to_dev(data); > > /* > * just one read-echo-cycle can take place at a time > @@ -236,7 +235,7 @@ static int ping_read_raw(struct iio_dev *indio_dev, > > switch (info) { > case IIO_CHAN_INFO_RAW: > - ret = ping_read(data); > + ret = ping_read(indio_dev, data); > if (ret < 0) > return ret; > *val = ret; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel