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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 063DAC27C4F for ; Sat, 29 Jun 2024 19:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc: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=gW9flH2bnYax6s6Vn1XtoRecs+tVN9hWALjvIntzvY0=; b=VG2RcnXHj7iSncDsBU73H85BSX s9A++Q879GCCOjvRLqwHugp4YJjK0c4XeBJnDSKdIdp11I772rlKDXAR4WkqUhk+WBZytTCfeM3qh theouul468+xiROpNn2hGsmyKPhYFAEykpG6UlAaS3OwIB7PAmWghKAF+4eSjFRlqAGdt2hu79Y61 c0G6q/NP5+HTVQQVY8tONgG7WfN6Oyr3b9W1JiC/BS+y8sA2q8JHjA0uAx5k8Z34+aKFXpjlCyUt7 L/jNhIRAzMv9F5op1OSHOWQYRb9GMpJBc0ltB/L7EIhuO2RJQM9Ru/jKNO+N3lGduuBTsDAUJlYda oVGB+pJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNdMk-0000000GpKB-0eOt; Sat, 29 Jun 2024 19:04:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNdMa-0000000GpIB-1IBC for linux-arm-kernel@lists.infradead.org; Sat, 29 Jun 2024 19:03:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3AD7E60B54; Sat, 29 Jun 2024 19:03:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8FCC2BBFC; Sat, 29 Jun 2024 19:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719687833; bh=VhwYj9wYMKcVVnuUSektec5JaiNKACPQOUGlOLJi5/M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qmie8DnLr6Vjc/blzQEer4aMbo82Jb7MiaMVnje2nVNSePWdJDfRKc3BY/ZkBzHzT C/L2Jsqxmx8OrJVy9UPoHDhip063TJY6v836mwM7GF6an5ZruBHdW+dnpY6GjSL1cw Hjowd9V4K4PZIYvTYPCzE+9wR9FxRlN0tP8QdTagFy+cYCJpAWyiYTNBrNE2/bNJgQ +4X0LFhE6OZABjFhUy/mc5a2M9aeAff2PWSD2nXyqC4Pc4N15CGihDSs56J0PzzjA5 W0wkuGH4zJ1XgRoxzJ1NSSOBLEhjZE8iz/cVgu9z5I/5SgVLCYvm1+CTPcYyAR9tVB pVigWgq+T1Ceg== Date: Sat, 29 Jun 2024 20:03:47 +0100 From: Jonathan Cameron To: Olivier Moysan Cc: , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , , , , Subject: Re: [PATCH v2 6/8] iio: adc: stm32-dfsdm: adopt generic channels bindings Message-ID: <20240629200347.4e282f21@jic23-huawei> In-Reply-To: <20240625150717.1038212-7-olivier.moysan@foss.st.com> References: <20240625150717.1038212-1-olivier.moysan@foss.st.com> <20240625150717.1038212-7-olivier.moysan@foss.st.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240629_120356_519384_47A433A6 X-CRM114-Status: GOOD ( 27.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 25 Jun 2024 17:07:14 +0200 Olivier Moysan wrote: > Move to generic channels binding to ease new backend framework adoption > and prepare the convergence with MDF IP support on STM32MP2 SoC family. > > Legacy binding: > DFSDM is an IIO channel consumer. > SD modulator is an IIO channels provider. > The channel phandles are provided in DT through io-channels property > and channel indexes through st,adc-channels property. > > New binding: > DFSDM is an IIO channel provider. > The channel indexes are given by reg property in channel child node. > > This new binding is intended to be used with SD modulator IIO backends. > It does not support SD modulator legacy IIO devices. > The st,adc-channels property presence is used to discriminate > between legacy and backend bindings. > > The support of the DFSDM legacy channels and SD modulator IIO devices > is kept for backward compatibility. > > Signed-off-by: Olivier Moysan Hi Olivier Some minor comments inline. thanks, Jonathan > @@ -1362,15 +1422,20 @@ static int stm32_dfsdm_dma_request(struct device *dev, > return 0; > } > > -static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, > - struct iio_chan_spec *ch) > +static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, struct iio_chan_spec *ch, > + struct fwnode_handle *child) > { > struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); > int ret; > > - ret = stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, ch); > - if (ret < 0) > + if (child) > + ret = stm32_dfsdm_generic_channel_parse_of(adc->dfsdm, indio_dev, ch, child); > + else /* Legacy binding */ > + ret = stm32_dfsdm_channel_parse_of(adc->dfsdm, indio_dev, ch); > + if (ret < 0) { > + dev_err(&indio_dev->dev, "Failed to parse channel\n"); > return ret; return dev_err_probe() assuming only called from probe() which I think is the case but haven't actually checked. > + } > > ch->type = IIO_VOLTAGE; > ch->indexed = 1; > @@ -1385,6 +1450,7 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, > > if (adc->dev_data->type == DFSDM_AUDIO) { > ch->ext_info = dfsdm_adc_audio_ext_info; > + ch->scan_index = 0; > } else { > ch->scan_type.shift = 8; > } > @@ -1392,8 +1458,51 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, > ch->scan_type.realbits = 24; > ch->scan_type.storagebits = 32; > > - return stm32_dfsdm_chan_configure(adc->dfsdm, > - &adc->dfsdm->ch_list[ch->channel]); > + return stm32_dfsdm_chan_configure(adc->dfsdm, &adc->dfsdm->ch_list[ch->channel]); Is there a change here? If it's just a line wrap don't do that in same patch making real changes. > +} > + > +static int stm32_dfsdm_chan_init(struct iio_dev *indio_dev, struct iio_chan_spec *channels) > +{ > + int num_ch = indio_dev->num_channels; > + int chan_idx = 0, ret = 0; int ret; > + > + for (chan_idx = 0; chan_idx < num_ch; chan_idx++) { > + channels[chan_idx].scan_index = chan_idx; > + ret = stm32_dfsdm_adc_chan_init_one(indio_dev, &channels[chan_idx], NULL); > + if (ret < 0) { > + dev_err(&indio_dev->dev, "Channels init failed\n"); > + return ret; return dev_err_probe() (I think this is only called from probe?) > + } > + } > + > + return ret; return 0; at least I assume it can't be positive? > +} > + > +static int stm32_dfsdm_generic_chan_init(struct iio_dev *indio_dev, struct iio_chan_spec *channels) > +{ > + struct fwnode_handle *child; > + int chan_idx = 0, ret; > + > + device_for_each_child_node(&indio_dev->dev, child) { device_for_each_child_node_scoped() as then you can do direct returns. > + /* Skip DAI node in DFSDM audio nodes */ > + if (fwnode_property_present(child, "compatible")) > + continue; > + > + channels[chan_idx].scan_index = chan_idx; > + ret = stm32_dfsdm_adc_chan_init_one(indio_dev, &channels[chan_idx], child); > + if (ret < 0) { > + dev_err(&indio_dev->dev, "Channels init failed\n"); > + goto err; return dev_err_probe() once using scoped above. > + } > + > + chan_idx++; > + } > + return chan_idx; > + > +err: > + fwnode_handle_put(child); > + > + return ret; > } > > > @@ -1430,43 +1547,60 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev) > - ch = devm_kcalloc(&indio_dev->dev, num_ch, sizeof(*ch), > - GFP_KERNEL); > - if (!ch) > - return -ENOMEM; > + if (legacy) { > + /* Bind to SD modulator IIO device. */ > + adc->hwc = devm_iio_hw_consumer_alloc(&indio_dev->dev); > + if (IS_ERR(adc->hwc)) > + return -EPROBE_DEFER; Obviously in the legacy path, but worth a dev_err_probe() because if we defer, debug info gets stashed away so it is easy to see why a driver is continuing to defer. > + } else { > + /* Generic binding. SD modulator IIO device not used. Use SD modulator backend. */ > + adc->hwc = NULL;