Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp524441lqb; Thu, 29 Feb 2024 07:39:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxLGCN44GLyesyZXiRrNMZa2vRqiqKPo0S3ICitwYshQtCI0Lr6HSh6U560OQ9z7EKTOnvgEn7sBgfqgJ6eglKfJpbvS5zqYWzPjRUxg== X-Google-Smtp-Source: AGHT+IGNzWe1Xc5P7jp8GFmAcEUIV42xh1/pzk3RcPba+C0NUXvvikvZXRbGZCB/nTqrXc+Ss9DI X-Received: by 2002:a05:6e02:1c45:b0:365:c6d9:2d63 with SMTP id d5-20020a056e021c4500b00365c6d92d63mr2723322ilg.0.1709221192619; Thu, 29 Feb 2024 07:39:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709221192; cv=pass; d=google.com; s=arc-20160816; b=bLA1y4MTptfTqGqBO2hhHifSk5w6y9axxszIld+dv6HRAVevH1F6GGKgOqGKIaGCXe NRG8Dmlq0skVW8W0WnSAqMZnEiVXTHhVQN+KkrQ+yHIGsNihACrUffJSkJrkj7aQYy2K fQeCPl5AL1fWE+ZoeA5CH1uxulGjjWj/ua7exLwJDDGN1b4NAY8SdImExkZZBNbpymMh NtCUpaWp3DEGR75uvJ2S6whMRnyMnl9f1+/NJa9K0AgV+PYUG+7zKthnLOCrE6fXSc0q imSocflJg9Wf6Ok4l5+QXYqe2fkDfj5VF4djo/MZufPx8PcIrfjMmcMM/Oomgth6irqQ y1ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=QBLOLphE3NdfOJ934nKa7KCEvPg6yDpYhupj2MVRHGE=; fh=/BUCDmYyU95MpUn6naGntYliqQfTE4KS0Cso7lvisd8=; b=upbyy7CrwQbvC2cYyZqlTToV/MPGlb/S0jR4ADuvEhPysZWdrDNV0wK7PRicss33vU FpqY4PlvdkDJR19VtWl85mI/V4YVaDOeuC54DeZZ1sbKYUmXJHpeXsrho1WeDTKrROzk BQ+4XGhhk3OdQTSb4HUWWR6aUWNorhJ3YNOzkQAgt6Z0rn0Xk+89JrOS0iUp01oCuarj TZn2lsy6f5wIdRyvlwhFnAUjBUFMbvlZlbBzfT9xTYj4z9Rlxf9coYqpWFt67bMJrVwV lm06+BlzKn/rdKJxUr+L/eURHfV2J/V6K0JVAmfq+IfsQ3XfuagzRuy6l1Xd5EAkcbya sJgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Opfyu8Dk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-86931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u6-20020a63d346000000b005d24ebc7f36si1589183pgi.406.2024.02.29.07.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Opfyu8Dk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-86931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CE10CB21117 for ; Thu, 29 Feb 2024 15:35:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7CFF1468F6; Thu, 29 Feb 2024 15:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Opfyu8Dk" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0404013A877; Thu, 29 Feb 2024 15:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709220906; cv=none; b=D50dPyUU8xKs7/h4puCwlhbaijNciTQPEEI5TsbyeUJGpLydxh2qoZgi9jC7VhM75YqNI0hGhL2NqhpK7SMDu6Lf9ycfjGyt2TsAbjl3n6+vlTc5a2j5bd3lmPBawRSMLt6wQb50LTly4iCYzddsJQRF2cBSBUppYG8fgu2x/78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709220906; c=relaxed/simple; bh=zuPfxtCT90QQiUBaYCzb22chu+yUsCqPEAv1MWn4DQw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fSaHZZkBYV3hnK7igjwR8JnsEcZN93GIx3W6p3oVcAB5FTPGCHRCC9ZgLuiEMkmpQFFRipM/PtG5cEatbvrkB//kIF2uoxH0dPK1/OW+F0+xm5YYr7PN71l2KZXzevtPy834TcOaTFXXZmbw5wEaKJK5e6zMSTu4EhXsLbhHM/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Opfyu8Dk; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-513230201b2so889882e87.1; Thu, 29 Feb 2024 07:35:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709220903; x=1709825703; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QBLOLphE3NdfOJ934nKa7KCEvPg6yDpYhupj2MVRHGE=; b=Opfyu8Dk8hDEsDsJKG+E+uVxezTSqYrTJ/kQXYKghJEj6NW1TS6QPRVsGfBc2D6Zsn BmpK/+WT8IjDPspTuojrTGSzKs+wWdKn5VSH7jqnuOv5JC1TC5bmCwHGinJBpmAzGuga qjMvLa7Y9hSmO1OsnHAnRIoO4Tf5/S3hGr51V+lU6AXCUL70lOVAo0xSl4EJUJleabwm QchJbI5u2RwzPWw/Fdc8g+UgG5VSF2RWjOYWxtVm5Equa9jhypuSHtmr0aEw8cuNyR9L ohfuZqRYuCq+f7TyOfns8B2Xt77L3yFTio7PELlhAFUfQribzqGBcRsdE9/47+YO5Mg3 USmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709220903; x=1709825703; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QBLOLphE3NdfOJ934nKa7KCEvPg6yDpYhupj2MVRHGE=; b=q6AslzePoL9SbprgLvXtwCw4X/RVK4pEp/1XBzK9Ie1j2TXdnDxu8E4XqVhnElPOaE Kac8mSGAHuU4H9rAi6fpbku34uvi4VtKLESDKjKd1ADOK6xr+rMPdDXbhkWjukm/gN3s sUZqo1eGXVCXENpJ7Ar3KQ8BDEtMF9WbAMF7jLIa7JvgjZK0XAE9xSv5e7Ao3IeJyEHr tGgLXKlnRO1bgDBLj8jMqx/0mAKvDdRTBCCysfvnHnOLs/besJ6MWxAYQQEwFiPe28cy tyTYJPMqldB9bTYgKODdNL3xMojSjivjQTL6nbXoP5JxCIudPkDWA2CB/b4HaEwywgm6 5poQ== X-Forwarded-Encrypted: i=1; AJvYcCU2th6vTWkRcHZYGfD49pyjKhGsUHUrlWGtSBfmeqnS1hvPa25UdJxDgAeoANlCzfPQMyHfVWTKaqnyM3gJqTmJuTtjn4A4MZRgxTLpgYTnpwsovUnhDUjtVwR4sX9GjCdV5HjAlbYPXfyQFnos6EBIXxBkdbKMZ40hOY2FC20ZQLJJPg== X-Gm-Message-State: AOJu0YyMnEmIDMHCW3M8VovnmXvWJsvlreMuF45AFerXSCl7Jvx42lNF rjRBV1M/5FvYZqMUDZtScIHf5/oy5YEUOl8z0YYCJR2W3xA/07Zh X-Received: by 2002:a05:6512:2f1:b0:512:f1a5:709 with SMTP id m17-20020a05651202f100b00512f1a50709mr1562593lfq.41.1709220902833; Thu, 29 Feb 2024 07:35:02 -0800 (PST) Received: from ?IPV6:2001:14ba:7426:df00::2? (drtxq0yyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:7426:df00::2]) by smtp.gmail.com with ESMTPSA id u15-20020ac243cf000000b0051321818dc8sm284628lfl.259.2024.02.29.07.35.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 07:35:02 -0800 (PST) Message-ID: Date: Thu, 29 Feb 2024 17:35:01 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 5/5] iio: light: Add support for APDS9306 Light Sensor Content-Language: en-US, en-GB To: Andy Shevchenko Cc: Subhajit Ghosh , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marek Vasut , Anshul Dalal , Javier Carrasco , Matt Ranostay , Stefan Windfeldt-Prytz , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240228122408.18619-1-subhajit.ghosh@tweaklogic.com> <20240228122408.18619-6-subhajit.ghosh@tweaklogic.com> <45386f39-a034-4d70-a6d4-8804c27aadce@tweaklogic.com> <21ecfb62-30b7-4073-bad6-46a9e08e08b0@gmail.com> From: Matti Vaittinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/29/24 15:42, Andy Shevchenko wrote: > On Thu, Feb 29, 2024 at 02:58:52PM +0200, Matti Vaittinen wrote: >> On 2/29/24 14:34, Subhajit Ghosh wrote: >>> On 29/2/24 03:57, Andy Shevchenko wrote: >>>> On Wed, Feb 28, 2024 at 03:08:56PM +0200, Matti Vaittinen wrote: >>>>> On 2/28/24 14:24, Subhajit Ghosh wrote: > > ... > >>>>>> +    if (gain_new < 0) { >>>>>> +        dev_err_ratelimited(dev, "Unsupported gain with time\n"); >>>>>> +        return gain_new; >>>>>> +    } >>>> >>>> What is the difference between negative response from the function >>>> itself and >>>> similar in gain_new? >>>> >>> -ve response form the function is an error condition. >>> -ve value in gain_new means - no valid gains could be computed. >>> In case of error conditions from the function, the gain_new is also set >>> to -1. >>> My use case is valid hardware gain so I went for checking only gain_new. >>> Matti will be the best person to answer on this. >> >> I now rely on the kerneldoc for the >> iio_gts_find_new_gain_by_old_gain_time() as it seems reasonable to me: >> >> * Return: 0 if an exactly matching supported new gain was found. When a >> * non-zero value is returned, the @new_gain will be set to a negative or >> * positive value. The negative value means that no gain could be computed. >> * Positive value will be the "best possible new gain there could be". There >> * can be two reasons why finding the "best possible" new gain is not deemed >> * successful. 1) This new value cannot be supported by the hardware. 2) The >> new >> * gain required to maintain the scale would not be an integer. In this case, >> * the "best possible" new gain will be a floored optimal gain, which may or >> * may not be supported by the hardware. > >> Eg, if ret is zero, there is no need to check validity of the gain_new but >> it is guaranteed to be one of the supported gains. > > Right, but this kernel doc despite being so verbose does not fully answer my > question. What is the semantic of that "negative value"? Current approach is to always investigate the function return value as error if the 'new_gain' is negative. Or, caller specific error if new_gain is unsuitable in some other way. When this is done, the absolute value of the negative 'new_gain' does not matter. > I would expect to have > the error code there (maybe different to what the function returns), but at > least be able to return it to the upper layers if needed. I am not sure I see the benefit of returning the new_gain over returning the error returned by the function. Well, maybe the benefit to be able to not evaluate the value returned by the iio_gts_find_new_gain_by_old_gain_time() - although I'm not sure I love it. > Hence 2 ARs I see: > 1) clarify the kernel documentation there; > 2) update the semantic of the gain_new to simplify caller's code. Yes, I agree. Patches welcome :) By the very least the kerneldoc can be improved. I'm undecided on benefits of having the error code in 'new_gain'. The GTS API fixes shouldn't be required in the context of this driver series though. Yours, --Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~