From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 646E426772C for ; Thu, 13 Mar 2025 13:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741872589; cv=none; b=b9C+N2q5JEwU1kobNbpYitPVkNe8NbIu84EHKnM/FDb5xfDzYVt/72rLqbEvGj3ndi8v3i8k4P/gPR7ipvCWKXN7PdILOyATZ3CgOuGXCBtYYgWI7qP1Jv0q+3m5VcqmKE6lFyljuKT3h725qQxrIaH0WczU1WD18lAM6ORzcR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741872589; c=relaxed/simple; bh=3R5NqPG75eCifry1xE8jCo+Ba/RPNsND3Th6ewF0DW8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pjr0XwrO2Le61guHJtLLN0eB4E8eQg8DYikuUVZ83wmTbiHC55y3GiabxTCohbFd+1Yovt8aIp4sr1BNh6Jh53bDb5WF/xc/sTvO/XzzdFcZ+010yc1c7/OmdXXHKWVeGGn31sc+RZXB4AymJc72qyX2WFIG14RQiZgd5UaqOmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LUOQWDVp; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LUOQWDVp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741872588; x=1773408588; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=3R5NqPG75eCifry1xE8jCo+Ba/RPNsND3Th6ewF0DW8=; b=LUOQWDVpcOi8PI2qbyByY+2qScKBOOZtthpREA7utobv+e4OSJ9vhNSy pYTVOP2t+jxFIuYYwDYJ8rF7EujzPCkqTyjUwbwv1AALqiB5O5vO5InMp Sr1Ij9n8iQoe1rHbCS7orbAiFaCcnpPdld8YplDbk/ZSiYbedVwldkH13 4K756Ohf1jMeQ+rx7Zu9U+QMd9Tw+jcy0O8o/W5u58Nsn/Y0W7RoN7/aB Mlvpqqtr9Isa/ebhOt5eQ5EddubBZhhN6WQhY1KNoEdz4MOca5RO4sax0 BNvSwae4hDe49XBZEqxYoHT9vpTgpuCvIMZop4JjI8IpDZrT82sPKe0PZ Q==; X-CSE-ConnectionGUID: aYUgHIZNSDWqc2pC++buLQ== X-CSE-MsgGUID: 0n7zhYQdTEW2GBfsiRlmBw== X-IronPort-AV: E=McAfee;i="6700,10204,11372"; a="43119150" X-IronPort-AV: E=Sophos;i="6.14,244,1736841600"; d="scan'208";a="43119150" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2025 06:29:47 -0700 X-CSE-ConnectionGUID: 04qS8wQPRn6wZVe4oTPTzg== X-CSE-MsgGUID: 4xEfR6NSTcGJ84TSNnC6hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,244,1736841600"; d="scan'208";a="120669500" Received: from smile.fi.intel.com ([10.237.72.58]) by orviesa009.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2025 06:29:42 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1tsid0-00000002BNc-0muS; Thu, 13 Mar 2025 15:29:38 +0200 Date: Thu, 13 Mar 2025 15:29:37 +0200 From: Andy Shevchenko To: Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Lad Prabhakar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hugo Villeneuve , Nuno Sa , David Lechner , Javier Carrasco , Guillaume Stols , Dumitru Ceclan , Trevor Gamblin , Matteo Martelli , Alisa-Dariana Roman , Ramona Alexandra Nechita , AngeloGioacchino Del Regno , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v7 03/10] iio: adc: add helpers for parsing ADC nodes Message-ID: References: Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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 On Thu, Mar 13, 2025 at 03:17:27PM +0200, Matti Vaittinen wrote: > On 13/03/2025 14:31, Andy Shevchenko wrote: > > On Thu, Mar 13, 2025 at 09:18:18AM +0200, Matti Vaittinen wrote: ... > > > + num_chan = iio_adc_device_num_channels(dev); > > > + if (num_chan < 1) > > > + return num_chan; > > > > This is really interesting code. So, if the above returns negative error code, > > we return it, if it returns 0, we return success (but 0 channels)? > > Yes. I don't think it's that interesting though. Checking the devicetree > succeeded while no channels were found. I think returning 0 is very much > aligned with this. Right, but as I suggested, let's follow already established APIs that return -ENOENT and never 0 in similar cases. > > Shouldn't we do *cs = NULL; at the case of 0 channels if it's a success? > > I suppose you're right. > > But, as you pointed out in review of the 05/10: > > 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. > > I don't know whether to agree with you here. For majority of the ADC > drivers, having no channels in devicetree is indeed just another error, > which I think is not in any ways special. So...? (I see below your answer :-) > However, for 33,3333% of the users added in this patch, the "no channels > found" is not really an error condition ;) The BD79124 could have all > channels used for GPO - although this would probably be very very unusual. > (Why buying an ADC chip if you need just a GPO?). Still, this wouldn't be an > error. (And I need to handle this better in BD79124 probe - so thanks). ENOENT check is again established for optional/not_found cases. > > (Under success I assume that returned values are okay to go with, and cs in > > your case will be left uninitialised or contain something we don't control. > > I see your point although I wouldn't be concerned with cs not being NULL for > as long as number of channels is zero. > > Anyway, I think it makes sense to simplify ~67% of callers by returning > -ENODEV if there is no channels. The remaining ~33% can then check for the > -ENODEV and handle it separately from other returned errors. So, thanks. Not at all! -- With Best Regards, Andy Shevchenko