Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp513228lqh; Thu, 28 Mar 2024 08:20:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvQ5xuzxeZP8Js6vdh6lpWP6H91GcMWDIPgjzL85JPLYlGJfdIMzS/PSm4azqH48YIe6ZDWH7Xkn+A45HBA08dUTBV18TBCjkhU1mJxA== X-Google-Smtp-Source: AGHT+IEhBTmxQ4LELKDCO1mArFP78zf1Ib82ocX8tXK7trG8UlL/jHPiKtuj631ChYZXByGAwzOD X-Received: by 2002:a05:622a:102:b0:431:80cd:56ae with SMTP id u2-20020a05622a010200b0043180cd56aemr3719761qtw.40.1711639216639; Thu, 28 Mar 2024 08:20:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711639216; cv=pass; d=google.com; s=arc-20160816; b=FUeXCt5ttVgAOtTv3A4geXhSasWJVINTnKHAnMmjmSJ/mVosyBZvOzHai2bne+lXeT JmNTMDxvPTLSv2cjvZyGib8NyKNCRbkoox9/qGp0NsCTiuXRW+1YFP+c5M+/Ut2rKAmk vH7820MeGRYcbHE1A33mV4g9jrYIi0lRDuwIWe/ydek3lHxkMrjsQJsrZin5SJuK1/5P Rtx6rMiOcL3qZPlheDA+I+vaZY3F/aK7c8j1wpGMpOn03Vl0C7aRfBF39GXqSIMSMn98 Hcs/qg8i4RkwAP+prMxqfgq6lgCCqry5yToY2QkxGTsk1ztSqJz3a50FD7e7kGpiesWr /HnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=wP9XDSz3beDmB4MkZT4uxEi0warODrL0TB+LR7vpVbc=; fh=v47+X93NYWc+wUudZ2Os/fq6Afu+IEB6rVJ3x4p1RBc=; b=IoPxF1gQ+Vy1jD4VbiJfb6WgHPTMFl5msblNPqTEKmLjaAIyxvQJAZwEB4GSuZypNf kA8PNIZx4QuW43OVMBWYcAhNTpessH12D2UrcieVCsanBYspBanN75ZgdprQC1zcBT3j YE4jGbXVHuE8eYtDel51WG/Y3GKm9mqsQiy38eoHVZemsbxxtTSACjqqBSxdiyrLVLQe L+h84TkQWBdLyRrBs2X0P0kQPeap7XrJIWIf7rVquRluRf5Y6VYJsi3urYwJMu4NQe7K nFmT+v9VYPcmdNfwWWW7ehsxH854rfZeURCgDmeFI81fbnghcEGb4q2fw9Up4yFLd7Un mWEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S1cgr2Oq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123141-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l6-20020a05622a050600b004313f52bc18si1566668qtx.139.2024.03.28.08.20.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 08:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S1cgr2Oq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123141-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123141-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 52D0C1C2B249 for ; Thu, 28 Mar 2024 15:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D06BB12EBED; Thu, 28 Mar 2024 15:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S1cgr2Oq" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 03F50199BC; Thu, 28 Mar 2024 15:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711639206; cv=none; b=JmJl4C/vVpsfuXS0N7A6Ptk6BoL2ru580yY27JIMFYj0e4eK8LOhTMS0ZuZk+2hzHmJGHZO+e9K0ZH7KlIsNjBU2GOuJpB7MBblIbuIeJPO8jjNndqFgzbposhZJ1b2cFHDUjMg4Gbt8FrxSYOWGlkOmT4qKmBs6u5unTHRfGHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711639206; c=relaxed/simple; bh=HwbPY3jeUMYWWEnpfO1UCtVg49OhuXLDecjbGHww9a4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lBkTeouSqfRbAth85Eu7YwKbwIrA2TSSDK6ZCms1BD4mDOQwD2Jmxws5WWC+HLIu1VkHMVtdTNlCy38obhYrS0be3l2+AYAkVcvPLFQ98A5DhWgfZHKq7hILhTyTI0WKdb9o8h7Iftoq1LoNPdjZzqiX8geVbQM2BQlQQFF3T9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S1cgr2Oq; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1e0d82d441bso10083325ad.3; Thu, 28 Mar 2024 08:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711639204; x=1712244004; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=wP9XDSz3beDmB4MkZT4uxEi0warODrL0TB+LR7vpVbc=; b=S1cgr2Oqq09bNNLmm59NEbkroMOyASUwcKoRnLrBIkwhq5jOwUj6tq/i2evofD1dBz vFibSKOxU7uea5IINcgYw19osOp5hesmB9GTurMf1nbOraQxNnLTGExiGZczIhShcd19 9Yt/53a2fhqKNdIcHMnKRFwYhForqllRpOC1Hx0cxUF4cfxUSn1i2ZH97oxEbis7f0Fh 4g8hA/I+aBQLVZHWEsj4o7MelU+Wc6TfYyqkGbydZmlObo0uSXD9Jac+dTZTLDAZC5Gc poOZdyeYP5F9V/2sPZh453dmqsyI4RtwWmeVAhH/MBm+OTunfBVvoLhjkh3MwCegFWv0 v6gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711639204; x=1712244004; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wP9XDSz3beDmB4MkZT4uxEi0warODrL0TB+LR7vpVbc=; b=B/zLqkFyyG+h0zaFwUJT0I3tQmuDMaMBYB6RJIho8mtM82yc5xrDEykO7lvH4DmHED 2p0ErDRuJe7pSs8kmidjhAOht9UW8eSUcsMEbIqFJvH3Q2FaHtcCUDOJLfp+UPGsnMxt r/hrhAqYNYtOLY3hpHc1A8rv/32Tb/V5K0poPj2Th5TE0RYBlDGnRQqWvrHk8psv59n9 vS82tPesIQmttpNbvc17wBP+fmRMEJZigcOOcMzouxqsPKGt2Y2DN4E8n8hdn0eeWMDT ih7wqLa9BzPlmhLyMfOhWIbzKHNJzummjdz1sOmfqL832ulFtptMfwTtuPOB6Ngjm1JQ xX/w== X-Forwarded-Encrypted: i=1; AJvYcCXhlg7DjOra1znWMtCAnzT/sZZwht8eJfrxvYx4tQDiYrGnZbUNdHsdmgB82pO9imA8ISRD9RsBOj5E1mkFS/SpSWSbUvti+si/Ye01Yn2qR9srCQmpEf3hyyrXXJzqmsnQM0kAzXD6idrx/P6LG+wShD5u6s3jvJs102O8/GSGG8yzQHIZWkO10Xav4q6mkT5fyIaj4/zywKtsGNNkbyU51XBYOwcOrVulXprNXr2EfKXiqUnS6vC6bjZnlg== X-Gm-Message-State: AOJu0YwnNDTLVlochwamMOCEkVLxCVpU+LY//W8PFDWnS2UmRmquRzw0 KK96Tbpb/LZfZ6i2QBWTzi9cCgLRkumx6BEPelPrVgbVQpE+gtHs X-Received: by 2002:a17:902:c204:b0:1e0:1bb2:b38f with SMTP id 4-20020a170902c20400b001e01bb2b38fmr2482444pll.59.1711639204181; Thu, 28 Mar 2024 08:20:04 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x7-20020a170902ec8700b001ddddc8c41fsm1701345plg.157.2024.03.28.08.20.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Mar 2024 08:20:03 -0700 (PDT) Sender: Guenter Roeck Message-ID: <13405bc9-3c97-4063-87b3-45a7e686fa50@roeck-us.net> Date: Thu, 28 Mar 2024 08:20:00 -0700 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 RFC 3/7] hwmon: (da9052) Use devm_regulator_get_enable_get_voltage() Content-Language: en-US To: Jonathan Cameron , David Lechner Cc: Jonathan Corbet , Liam Girdwood , Mark Brown , Jean Delvare , Support Opensource , Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Antoniu Miclaus , Greg Kroah-Hartman , Dmitry Torokhov , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-input@vger.kernel.org References: <20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@baylibre.com> <20240327-regulator-get-enable-get-votlage-v1-3-5f4517faa059@baylibre.com> <20240328142038.33ad68bc@jic23-huawei> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo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4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240328142038.33ad68bc@jic23-huawei> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/28/24 07:20, Jonathan Cameron wrote: > On Wed, 27 Mar 2024 18:18:52 -0500 > David Lechner wrote: > >> We can reduce boilerplate code by using >> devm_regulator_get_enable_get_voltage(). >> >> Signed-off-by: David Lechner > > A few comments inline, but nothing substantial. > > Reviewed-by: Jonathan Cameron >> --- >> drivers/hwmon/da9052-hwmon.c | 33 +++++++-------------------------- >> 1 file changed, 7 insertions(+), 26 deletions(-) >> >> diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c >> index 2bd7ae8100d7..70e7bc72e980 100644 >> --- a/drivers/hwmon/da9052-hwmon.c >> +++ b/drivers/hwmon/da9052-hwmon.c >> @@ -26,7 +26,6 @@ struct da9052_hwmon { >> struct mutex hwmon_lock; >> bool tsi_as_adc; >> int tsiref_mv; >> - struct regulator *tsiref; >> struct completion tsidone; >> }; >> >> @@ -414,32 +413,19 @@ static int da9052_hwmon_probe(struct platform_device *pdev) >> device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc"); >> >> if (hwmon->tsi_as_adc) { >> - hwmon->tsiref = devm_regulator_get(pdev->dev.parent, "tsiref"); >> - if (IS_ERR(hwmon->tsiref)) { >> - err = PTR_ERR(hwmon->tsiref); >> - dev_err(&pdev->dev, "failed to get tsiref: %d", err); >> + err = devm_regulator_get_enable_get_voltage(pdev->dev.parent, >> + "tsiref"); >> + if (err < 0) >> return err; >> - } >> - >> - err = regulator_enable(hwmon->tsiref); >> - if (err) >> - return err; >> - >> - hwmon->tsiref_mv = regulator_get_voltage(hwmon->tsiref); >> - if (hwmon->tsiref_mv < 0) { >> - err = hwmon->tsiref_mv; >> - goto exit_regulator; >> - } >> >> /* convert from microvolt (DT) to millivolt (hwmon) */ >> - hwmon->tsiref_mv /= 1000; >> + hwmon->tsiref_mv = err / 1000; >> > > Using a variable called err for a good value is a bit ugly but fair enough if that > is precedence in this driver. > It isn't. The existing code assigns the return value from regulator_get_voltage() to hwmon->tsiref_mv and then evaluates it. I would not oppose introducing a variable such as tsiref_uv, but not the misuse of 'err'. I am not going to accept the code as suggested. It is bad style, and it would invite others to use it as precedent when trying to introduce similar code. >> } >> @@ -483,10 +466,8 @@ static void da9052_hwmon_remove(struct platform_device *pdev) >> { >> struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); >> >> - if (hwmon->tsi_as_adc) { >> + if (hwmon->tsi_as_adc) >> da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); > Superficially looks like devm_da9052_request_irq could be added that > uses devm_request_threaded_irq() to allow dropping this remaining handling. > That should be a separate series of patches. A local solution might be to use devm_add_action_or_reset(), but that should also be a separate patch. Thanks, Guenter