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 237B2C282DE for ; Thu, 13 Mar 2025 12:36:50 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zLgTuknikC69Lqazt76mXizlIm5DLdJF7bpJiI++25Y=; b=2QPRtRDKy+m+VAMLD6AdGtG6W8 i9VDpsRxpgl1hThEw2ZfyFpq8J0+LnLipw7Mj2d+nW/TFes1K3ItKpu2qLHUmBFQLVywEjUZjZHPX ve0/hLUSgPlNQajbw4iQqXlMmCmMCMROurwFmOpFxQz1j/Q3ZKeAXN1mbmRyTyLzpEGmMknB3Yznp k4irOGuLRNtPXiBopxi8YbM3D0pRGpzrfGguzzeilpiJK7mZ2ZC/iPricf5jGsjxJjUOjouH5AWsl I77wsaHSrd6FDUu2sQoTg1qvcBbzFwV9t7fzMYVmo9RJIc8BVdEpMu3bnqMC9i3DxXesAPCh/eH2l Pb/9Tddg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshnj-0000000BG5f-2nwW; Thu, 13 Mar 2025 12:36:39 +0000 Received: from mgamail.intel.com ([192.198.163.9]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tshlh-0000000BFpX-1JOx for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 12:34:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741869273; x=1773405273; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=143J5LtMmgVhQahwflzcYxzA/PDJtG6Xbkjg/ZRiK1A=; b=iyFE2HiUsycdzMyhJEHKP97pvOhdPxPcN4SkrIu883PuFB8b/V+1LwpQ EE0wdtpApSF3+0nMhLVW82WPnAUl49RxQQfWkSPIO2brDQRbATZp4JUZ8 /lB8tpWzU8IpkmY1MhOEWx4o/GnNiHhrBmuFeNw23Wjc43YUCIBXsmXz9 LOnclKOdHEkcknzjg8MkOnOvPAkfiX4Hb/0dRexz91Km5feWIsRbikXGK YR1GmQ7IXavLr8InptVUCnGW+73ESVJnizEWOah07DQARTuauGyWLQrL5 /YA2xBNwBBkimOBE4XA78kH4qyFLXqWDy3sjh9DOWRY6tB55E6KTFeObc w==; X-CSE-ConnectionGUID: M+Sldrp6TxqwXaLqf9uIng== X-CSE-MsgGUID: 3re3hgTLRv6DujQna2gkNA== X-IronPort-AV: E=McAfee;i="6700,10204,11372"; a="53619362" X-IronPort-AV: E=Sophos;i="6.14,244,1736841600"; d="scan'208";a="53619362" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2025 05:34:32 -0700 X-CSE-ConnectionGUID: vtTlx5mcQCaxsKLpv0N+WA== X-CSE-MsgGUID: zXqPsfRgRTC8lqLrj9YpFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,244,1736841600"; d="scan'208";a="120933374" Received: from smile.fi.intel.com ([10.237.72.58]) by orviesa006.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2025 05:34:28 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1tshlY-00000002AeF-412s; Thu, 13 Mar 2025 14:34:24 +0200 Date: Thu, 13 Mar 2025 14:34:24 +0200 From: Andy Shevchenko To: Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Nuno Sa , David Lechner , Javier Carrasco , Olivier Moysan , Guillaume Stols , Dumitru Ceclan , Trevor Gamblin , Matteo Martelli , Alisa-Dariana Roman , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v7 05/10] iio: adc: sun20i-gpadc: Use adc-helpers Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_053433_365389_BCA8A9DE X-CRM114-Status: GOOD ( 16.31 ) 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 Thu, Mar 13, 2025 at 09:18:49AM +0200, Matti Vaittinen wrote: > The new devm_iio_adc_device_alloc_chaninfo_se() -helper is intended to > help drivers avoid open-coding the for_each_node -loop for getting the > channel IDs. The helper provides standard way to detect the ADC channel > nodes (by the node name), and a standard way to convert the "reg" > -properties to channel identification numbers, used in the struct > iio_chan_spec. Furthermore, the helper can optionally check the found > channel IDs are smaller than given maximum. This is useful for callers > which later use the IDs for example for indexing a channel data array. > > The original driver treated all found child nodes as channel nodes. The > new helper requires channel nodes to be named channel[@N]. This should > help avoid problems with devices which may contain also other but ADC > child nodes. Quick grep from arch/* with the sun20i-gpadc's compatible > string didn't reveal any in-tree .dts with channel nodes named > otherwise. Also, same grep shows all the in-tree .dts seem to have > channel IDs between 0..num of channels. > > Use the new helper. ... > + num_channels = devm_iio_adc_device_alloc_chaninfo_se(dev, > + &sun20i_gpadc_chan_template, -1, &channels); > + if (num_channels < 0) > + return num_channels; > + > if (num_channels == 0) > return dev_err_probe(dev, -ENODEV, "no channel children\n"); Note, this what I would expected in your helper to see, i.e. separated cases for < 0 (error code) and == 0, no channels. Also, are all users going to have this check? Usually in other similar APIs we return -ENOENT. And user won't need to have an additional check in case of 0 being considered as an error case too. -- With Best Regards, Andy Shevchenko