Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp469786lqh; Thu, 28 Mar 2024 07:21:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZSRPIY/t78mTA0Hhgmej1FldGVBb3JKDyTJtKnlFpeSj8sQytWUovRORYQ9bP7Jyek/xpoSnGVwRVWdttaDWIol9fWmfNszQYqNUgCg== X-Google-Smtp-Source: AGHT+IFgOqR5VpY/Z0MVNz4t1+NH5474jOhZkPeU4r7mYrSftU8RL9FjwJ/PPNLB9O6eeJvogI9C X-Received: by 2002:a67:f059:0:b0:478:32d2:96d with SMTP id q25-20020a67f059000000b0047832d2096dmr1658809vsm.14.1711635717913; Thu, 28 Mar 2024 07:21:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711635717; cv=pass; d=google.com; s=arc-20160816; b=AhF2ASGpahvZiYS+CwbT//JUIrPXmvBLgV4mfc2OYVqJmdx+9tilMY7eyitvPovuZW 2buohx6REG81EE4qfxlKQKTn59J+X9QNEHtUGsnqu3Ar37Adc2zvtZDxymfAsA6DNDhB TbAJ59S5i6hR75LtI6OTx9bh3RTPSKoXQ8z6HP1W8uyBbJNj/JyeWo8UNzqMvKdttX5o AsSmO02dZW1/KzcC6Dcb56wQu1leHoYm+cpS6QxaglLr2BKpIEQzmdMFWypSCuOgTGZv 0volMvQAik7wGdtSzuk9y83KjeNsrOfCXooYjRMRRjDyfWlCeN+UK+EMzwUiMrJJeqBH h3SQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=AmWwBIBqq23yyGjUvxAU5HnslFihAHwgCqwzWgQeXwo=; fh=NbtzYSGyln1NBy3dwjrRwMhypQlB/UwbJ7oBc05rlIE=; b=HwgHO1r38MGk3r5kwQ0GRZqnvMbzkKswnECaWbzio6nu3sz1v3ufk0euhaMMzilj+7 5F2r8sb5fC6noc730dFQP+V9ZXkML3+z/kYbVS27FrLq5Lv9Tcs3TkcG8Pwnm9AYAeoC M/gPGWipWHQfxro68x4p3oCr7XcxWenddDLOrXAX/5aM+Ak2sLbCqfA52/vdUwLOtO2y X8GVRt4fBPhr9yBGc8+D139SW9YlAzx5Yt2uYXpX0TIpkZ8g2/WNVGGYgG9klDjv7vJz LP6CGJGGV0B7dtzHOyIVDS9s2NPtA6h6NK+Zu8jvauYYvp13xjjzQomBdQwDMow7OCXe Ca4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iZGw97JH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 o16-20020a0561020e1000b00478334a6ed9si218646vst.109.2024.03.28.07.21.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123062-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=@kernel.org header.s=k20201202 header.b=iZGw97JH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 15D741C2133A for ; Thu, 28 Mar 2024 14:21:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF7F012F370; Thu, 28 Mar 2024 14:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iZGw97JH" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D6D7812A157; Thu, 28 Mar 2024 14:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635657; cv=none; b=q/3+jeD74MQleA3o3sijF7enck89dOvvjLY/tMMrBNbszuox5SM7JSMJL8Yz7Tjw8dxLrXNfDJcCUzgLFvuh1r/pmnka0LRS+VAi/ZgBCDGzgHhW70btKhAUuN5xWl/F9D8t5OyxE0beIGVjSl9NAGHlZM7arQxmk2a3MoJ7FVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711635657; c=relaxed/simple; bh=/mzKcAcVee2eDwo7xSaEAAot3AENIEbBi8tazumkqxw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=olpUBa1c1kLdSWQ8mRcwmQ3J3qxhuPwDPoWRsjwlHP0M0oJMZNyRr91BlsjIHwy2RqEf+LSc6Oj6UvK3bQ2xnApOnWyd75Rz/C+WhzGdZgw04zWYyZvIh1SHHSarHSFN+Set+aFarCGTP0spkXhUorJTho2M9m1lVdF2rwA7WqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iZGw97JH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F07FAC433F1; Thu, 28 Mar 2024 14:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711635656; bh=/mzKcAcVee2eDwo7xSaEAAot3AENIEbBi8tazumkqxw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iZGw97JHpv2rPipXEAsc3DpK4QsdoAqKyqoFPu3f9fMs2GYquXDrM9QwWUGKem+Gv teYRiV8pcY3RtLVO4rIVxoHtSK5G0WdW8tujyxd/nZtKoKO/utXKpkiE2cFTSTmgn0 nVXtrG4+iH4CGFQ6RM/tR/H9YwlpktlfW2cwJyendK1+V2Z20gGF3ysd1y0MOZLD/r pW1XLdPX9cbT6edtiZY1CFDMkw/M4HMLCOh6dXJjWfN5WTR6mYquAJLbP5pSz+/a1Y RZjt+8VyzXSHGxhhRB8q8UHLz4s8G5MapjJL84wBv6Kcfyp35NXjbxTDTCIOD+ub1R uDzbZk7mzN6XA== Date: Thu, 28 Mar 2024 14:20:38 +0000 From: Jonathan Cameron To: David Lechner Cc: Jonathan Corbet , Liam Girdwood , Mark Brown , Jean Delvare , Guenter Roeck , 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 Subject: Re: [PATCH RFC 3/7] hwmon: (da9052) Use devm_regulator_get_enable_get_voltage() Message-ID: <20240328142038.33ad68bc@jic23-huawei> In-Reply-To: <20240327-regulator-get-enable-get-votlage-v1-3-5f4517faa059@baylibre.com> References: <20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@baylibre.com> <20240327-regulator-get-enable-get-votlage-v1-3-5f4517faa059@baylibre.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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. > } > @@ -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. Thanks, Jonathan > - regulator_disable(hwmon->tsiref); > - } > } > > static struct platform_driver da9052_hwmon_driver = { >