From patchwork Fri Jun 21 22:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13708118 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 27222C27C78 for ; Fri, 21 Jun 2024 22:12:29 +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:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cA2vZ5H4zhrRVMGC41BbSeo0sgv1/DHDpLqlssCbQtI=; b=sNBuFAfTfvouU2F4Ehe6NlIVxT VTiiI9DB3V4Bu+BYlBDHVtWsGZW1F0P2XwGoNuObUgOtPRJusIcUjTKbG/4nLzofXzItvTWWZCEUd 8lO/jWtSeLF7xX5aY3QZaG9kI3BH1NbIDlRPf5y4qUyWxwr9itBFFZ5v8k030wR8iDMAG8aZLazG7 M0CrYwWS6+3bfscC/C5AgR0JlvwSYdrveN+xOUjA6yCWko7fF9C4dKwOIgtHkR/zrHHLgcuAierpX 1eTOdOWx/piYeNQF5vEGnZuKMQYHYwRP4FVIuelp71vY+reawy+QZEFBzoOrjfb7+En5k94bvB2mR 67wXaRjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUP-0000000Ai83-2BcV; Fri, 21 Jun 2024 22:12:13 +0000 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUH-0000000Ai2f-1VvT for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 22:12:07 +0000 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5b970a97e8eso1389238eaf.1 for ; Fri, 21 Jun 2024 15:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719007924; x=1719612724; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cA2vZ5H4zhrRVMGC41BbSeo0sgv1/DHDpLqlssCbQtI=; b=fkCvG2IKxLJ5e6hU676N3v+RuZJOzYf8kxM1J/hlg4/lvR878MBFgLLAKOR5jIx217 AVdxjniK+nNp/pw7wMaiCWKDHusd1yj5e1QbvtpPC28j1AqU+hE/l2FS1wqrWv/yw0uL Fz9Fygt1KQ5ykqH+Gg9QScpWYGff18IRAZWShDl2tko4bpgX4C/Hu8sdza20TC8j9e8B Y3eRk3cNzse8D2auGEG94YHEPn5nD5vm1ZLB2CUKs1Jbbc/11FjXzkTaommLOG2SMAIn tVngXVUitlxr7ryTuy6c6++OaR5+1Ou4h/SQPez0D/RkFQCL6VNmDmwFyO7N97RO7iX7 PfJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719007924; x=1719612724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cA2vZ5H4zhrRVMGC41BbSeo0sgv1/DHDpLqlssCbQtI=; b=bXMJ2vJsaQBw/t7+V91ckHwDKdUsneO/AJhYePO/d+1fWiZvpdJWzMKE4vheExgu/V HjXjq+jZNDcmwJLisZYcMi4n3IfNbPlqqHYqw4SOPimGdkKdW07Gey4KXt7pAn6r+bvP P3+RAQWIkmqbZ/wnG5GtGmsUmRClyA/hksAmpAqhCTWyjBVoUXP+7dp+ZD8V9TGpysb8 aleFqMbyq4V3vUNd/8KRCHH5Yhl9YzaG9DK2HEkFcfM1Gr6dqwpbUCn9CgrF93AApp+p Mz+Rmn1ju488t8064DOwIX9iWDdLKzj2KiYm7fJGOpYV/U2WqXtjPx2QiDcS6lRF7EK5 J14A== X-Forwarded-Encrypted: i=1; AJvYcCXWfTmzf7pXXv1QPnj+8cGyrA0aG7NxPIwuuCE6YQSQrxM/JPumg6oqV2EmebSg5QWjXXZGMHZ73SbhS/drcE2IuzKRLmv4FbSHCi+k9JxAYyZZIUU= X-Gm-Message-State: AOJu0Yx697YBwmUNrn3ZCpPPPXXoUhdc7eqQVRqde08DqjIk+8yfefyP pUd6V5O73P8NMYKgZwYc7qpJzngKMXRFgOQMboHUPSh1+v9AdqWtzqRDjRBpqrQ= X-Google-Smtp-Source: AGHT+IGPEjYzZuYy0PUyybo/Jr5W5tkGRhnX5VFZ0jGpJucieHOIXpFu0GRrOvhhGuVkoDgVWKm7XQ== X-Received: by 2002:a4a:7619:0:b0:5bb:288:e955 with SMTP id 006d021491bc7-5c1adc6fb4emr9863944eaf.8.1719007924414; Fri, 21 Jun 2024 15:12:04 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5c1d94fb2a4sm329837eaf.10.2024.06.21.15.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 15:12:04 -0700 (PDT) From: David Lechner To: Jonathan Cameron Cc: David Lechner , Joel Stanley , Andrew Jeffery , Liam Girdwood , Mark Brown , Andreas Klinger , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/10] iio: adc: hx711: use devm_regulator_get_enable_read_voltage() Date: Fri, 21 Jun 2024 17:11:49 -0500 Message-ID: <20240621-iio-regulator-refactor-round-2-v1-2-49e50cd0b99a@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240621-iio-regulator-refactor-round-2-v1-0-49e50cd0b99a@baylibre.com> References: <20240621-iio-regulator-refactor-round-2-v1-0-49e50cd0b99a@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_151205_432070_FDE75A6B X-CRM114-Status: GOOD ( 15.97 ) 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 Use the devm_regulator_get_enable_read_voltage() helper to simplify the code. Signed-off-by: David Lechner Reviewed-by: Andreas Klinger --- drivers/iio/adc/hx711.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index fef97c1d226a..6efdc971689c 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -80,7 +80,6 @@ struct hx711_data { struct device *dev; struct gpio_desc *gpiod_pd_sck; struct gpio_desc *gpiod_dout; - struct regulator *reg_avdd; int gain_set; /* gain set on device */ int gain_chan_a; /* gain for channel A */ struct mutex lock; @@ -497,11 +496,7 @@ static int hx711_probe(struct platform_device *pdev) return PTR_ERR(hx711_data->gpiod_dout); } - hx711_data->reg_avdd = devm_regulator_get(dev, "avdd"); - if (IS_ERR(hx711_data->reg_avdd)) - return PTR_ERR(hx711_data->reg_avdd); - - ret = regulator_enable(hx711_data->reg_avdd); + ret = devm_regulator_get_enable_read_voltage(dev, "avdd"); if (ret < 0) return ret; @@ -517,9 +512,6 @@ static int hx711_probe(struct platform_device *pdev) * approximately to fit into a 32 bit number: * 1 LSB = (AVDD * 100) / GAIN / 1678 [10^-9 mV] */ - ret = regulator_get_voltage(hx711_data->reg_avdd); - if (ret < 0) - goto error_regulator; /* we need 10^-9 mV */ ret *= 100; @@ -559,7 +551,7 @@ static int hx711_probe(struct platform_device *pdev) hx711_trigger, NULL); if (ret < 0) { dev_err(dev, "setup of iio triggered buffer failed\n"); - goto error_regulator; + return ret; } ret = iio_device_register(indio_dev); @@ -573,25 +565,17 @@ static int hx711_probe(struct platform_device *pdev) error_buffer: iio_triggered_buffer_cleanup(indio_dev); -error_regulator: - regulator_disable(hx711_data->reg_avdd); - return ret; } static void hx711_remove(struct platform_device *pdev) { - struct hx711_data *hx711_data; struct iio_dev *indio_dev; indio_dev = platform_get_drvdata(pdev); - hx711_data = iio_priv(indio_dev); iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - - regulator_disable(hx711_data->reg_avdd); } static const struct of_device_id of_hx711_match[] = {