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=-12.7 required=3.0 tests=BAYES_00,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=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 E531EC2D0A8 for ; Sat, 26 Sep 2020 15:57:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 89D1E21527 for ; Sat, 26 Sep 2020 15:57:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="psylHqRG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="gYfxmpkS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89D1E21527 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+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=merlin.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=ReorZYlSQj1QHgrvHd9z2jlQlIfT4ytWDy2020mSlqY=; b=psylHqRGThwHFFRPtVlu2IUQJ OmF48sLx5xTrEmHF2WSdFuZxmdjo+wWi9IPJj0QDe2S6+FYBTLjF1E5JnfY5hPQ76uIJkwE2UzoEu 7AUua8dZ9nQ13dBOTDdBG55j9cBXb3gSZY5MCIVWIx2xhlDuK0Ih9LRXZ2GyXRmoKXQLPD0vUW8+Z I22OQhuP+mTt1ZmzWoINzOCxL8Ht/mzNERCumEKgWClU9le6rDtMVM+NKMjkopxTvtYWaqohBA4rk x3fFV1/q2/EF7jH5ilmQm1iSgRbVUP0VjlQsv0mlCvUDt5xIvZ10HqI52fBUsV7e4EtbKkJoyIn/Y qM5j2WHYw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMCYI-0006UK-0R; Sat, 26 Sep 2020 15:55:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMCYF-0006TQ-7G for linux-arm-kernel@lists.infradead.org; Sat, 26 Sep 2020 15:55:56 +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 5D5D6207D8; Sat, 26 Sep 2020 15:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601135754; bh=LeOuaawcgaWdaoGVCQeecPE0zOwmA8UVkFZ/3GJAbjU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gYfxmpkShgaW0niKHFRUuccauDW3BKWVWuvDeWLwU2mYWU4sV27mSCWVU7joJK+u2 N2PAutRzoYLcbjRSo+I2GxThxApQ6PIywFf+benV/N0GMeT4uihquDH56uFDANjslI naSQkbSz4cA1GRcMapiprPlTprCefZbBvwgLtvBE= Date: Sat, 26 Sep 2020 16:55:49 +0100 From: Jonathan Cameron To: Alexandru Ardelean Subject: Re: [PATCH] iio: adc: at91-sama5d2_adc: merge buffer & trigger init into a function Message-ID: <20200926165549.23dc420b@archlinux> In-Reply-To: <20200924102902.136169-1-alexandru.ardelean@analog.com> References: <20200924102902.136169-1-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.6 (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-20200926_115555_378122_874EC9AB X-CRM114-Status: GOOD ( 30.53 ) 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, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, eugen.hristev@microchip.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+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 24 Sep 2020 13:29:02 +0300 Alexandru Ardelean wrote: > This change is mostly cosmetic, but it's also a pre-cursor to the > the change for 'iio_buffer_set_attrs()', where the helper gets updated to > better support multiple IIO buffers for 1 IIO device. > > The only functional change is that the error message for the trigger alloc > failure is bound to the parent device vs the IIO device object. > > Also, the new at91_adc_buffer_and_trigger_init() function was moved after > the definition of the 'at91_adc_fifo_attributes'. > > Signed-off-by: Alexandru Ardelean Looks fine to me, but will let this sit on the list for a while so others have time to comment. Thanks, Jonathan > --- > drivers/iio/adc/at91-sama5d2_adc.c | 78 ++++++++++++++---------------- > 1 file changed, 36 insertions(+), 42 deletions(-) > > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c > index ad7d9819f83c..b9c3cc6d5913 100644 > --- a/drivers/iio/adc/at91-sama5d2_adc.c > +++ b/drivers/iio/adc/at91-sama5d2_adc.c > @@ -1014,21 +1014,6 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *indio, > > return trig; > } > - > -static int at91_adc_trigger_init(struct iio_dev *indio) > -{ > - struct at91_adc_state *st = iio_priv(indio); > - > - st->trig = at91_adc_allocate_trigger(indio, st->selected_trig->name); > - if (IS_ERR(st->trig)) { > - dev_err(&indio->dev, > - "could not allocate trigger\n"); > - return PTR_ERR(st->trig); > - } > - > - return 0; > -} > - > static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev, > struct iio_poll_func *pf) > { > @@ -1156,13 +1141,6 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) > return IRQ_HANDLED; > } > > -static int at91_adc_buffer_init(struct iio_dev *indio) > -{ > - return devm_iio_triggered_buffer_setup(&indio->dev, indio, > - &iio_pollfunc_store_time, > - &at91_adc_trigger_handler, &at91_buffer_setup_ops); > -} > - > static unsigned at91_adc_startup_time(unsigned startup_time_min, > unsigned adc_clk_khz) > { > @@ -1683,6 +1661,40 @@ static const struct iio_info at91_adc_info = { > .hwfifo_set_watermark = &at91_adc_set_watermark, > }; > > +static int at91_adc_buffer_and_trigger_init(struct device *dev, > + struct iio_dev *indio) > +{ > + struct at91_adc_state *st = iio_priv(indio); > + int ret; > + > + ret = devm_iio_triggered_buffer_setup(&indio->dev, indio, > + &iio_pollfunc_store_time, > + &at91_adc_trigger_handler, &at91_buffer_setup_ops); > + if (ret < 0) { > + dev_err(dev, "couldn't initialize the buffer.\n"); > + return ret; > + } > + > + if (!st->selected_trig->hw_trig) > + return 0; > + > + iio_buffer_set_attrs(indio->buffer, at91_adc_fifo_attributes); > + > + st->trig = at91_adc_allocate_trigger(indio, st->selected_trig->name); > + if (IS_ERR(st->trig)) { > + dev_err(dev, "could not allocate trigger\n"); > + return PTR_ERR(st->trig); > + } > + > + /* > + * Initially the iio buffer has a length of 2 and > + * a watermark of 1 > + */ > + st->dma_st.watermark = 1; > + > + return 0; > +} > + > static int at91_adc_probe(struct platform_device *pdev) > { > struct iio_dev *indio_dev; > @@ -1818,27 +1830,9 @@ static int at91_adc_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, indio_dev); > > - ret = at91_adc_buffer_init(indio_dev); > - if (ret < 0) { > - dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); > + ret = at91_adc_buffer_and_trigger_init(&pdev->dev, indio_dev); > + if (ret < 0) > goto per_clk_disable_unprepare; > - } > - > - if (st->selected_trig->hw_trig) { > - ret = at91_adc_trigger_init(indio_dev); > - if (ret < 0) { > - dev_err(&pdev->dev, "couldn't setup the triggers.\n"); > - goto per_clk_disable_unprepare; > - } > - /* > - * Initially the iio buffer has a length of 2 and > - * a watermark of 1 > - */ > - st->dma_st.watermark = 1; > - > - iio_buffer_set_attrs(indio_dev->buffer, > - at91_adc_fifo_attributes); > - } > > if (dma_coerce_mask_and_coherent(&indio_dev->dev, DMA_BIT_MASK(32))) > dev_info(&pdev->dev, "cannot set DMA mask to 32-bit\n"); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel