From patchwork Fri Jun 21 22:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13708121 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 C7EF4C27C78 for ; Fri, 21 Jun 2024 22:12:39 +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=x480k30HvbgguxGycHu5EFcSQYfeSDwQqt26z/bkWhw=; b=j7UQXMltr2kOxFhcY/O4FDFKoh W5l7iKtdaVfkYwXBEzjszpAZYGqk3QuSC+qJ3tPSk9TiI+jusFyGWmfKXukqmD0X44jHhe33VHr5g crkQ99I4TgQgdQ2jFgRvAPhGXccovpIrCor9kK8oIMfpaRvcADhHHa2fFoEez8LQ6Ib8tvJhVq4db iNiYLNqhc1pM96o2etzbSAeKKCEFfRWBKnenbynIur9C1TqVaG9B8Bin3amVOy1nnRKK/D5py/BXQ y3PfoHFkeLz9/ls1CjUD9AZaAZop9x8sE/MtYVxt4MexOLZEcdFhONyehGjazJrZSW+hG4bOG86AA 9D5K2Ufw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUZ-0000000AiFh-2DvC; Fri, 21 Jun 2024 22:12:23 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUK-0000000Ai4g-3Ce5 for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 22:12:10 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5c1d6064557so699838eaf.2 for ; Fri, 21 Jun 2024 15:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719007928; x=1719612728; 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=x480k30HvbgguxGycHu5EFcSQYfeSDwQqt26z/bkWhw=; b=W7rNmIkaQyJ9fKqfMckqzfDFDAo8y38OAR9uy4YvPur4PDfRKMFVUcoaH0zPKNBQSj Fonv1RhAahNZ23qLiE84pW14/adwPNtMOojgmXOD61129EPDeUMVyCTv03++wT+Crh3g H8lvB1l4b0NVLI9k2oyIdj05dCxYMl0sXJZqQmpnuIzk14SIIWp/WttftBYIwOiqaRfQ KBhq58nUJlweTunTRR678f2guNzbH2MiM/ohviWSiNdY4xmgePE2aWsd8+3IAp64xASH UxL8v55PyLy9K+rEAIsEMy96+1mL3neexh2QKQd7SgwbfRxDeYqvJtWMCtIArUjFw9xL 2jng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719007928; x=1719612728; 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=x480k30HvbgguxGycHu5EFcSQYfeSDwQqt26z/bkWhw=; b=MZqhIewuKVZxLmZIF7h9jFcYUgaAEsXaowq/8dLi1KZo5c8d/qL/Q22MuD9E9GRh3c cm6h1D0skQQUEKd1VUWUkonUtoOOYGMfNA0slECr0FUHg8Aiz5o1VNuVRivqBwgFq3xG 6JfvRh6yfyMNQZsx0te8nzTaoWywdbbBY4OUHrzt0B771k0a6YNsOM52JQ+P+xAui27r l6WVLrlp8EZ6xqWWiwl6bIGEkZtewcv2rUNj8UezSjkcUBIr5KQaRpVZEUl516o3R8dM r27RYg6OM9kimfEFKulsH3sK+pR2Ss1S2rngAQwXjlAVajomQYo3T1buoiex/SexQvOA Bv8g== X-Forwarded-Encrypted: i=1; AJvYcCVbxryB8uKJyO98e2PxpUrxM60F4usazy2lrneyemez9b/b9f9+fiL9hiRTkJOmYcxgPkV8G1lN6BalrWv6slIBAxrQ+A4NdAB0W7rLaQidOu2ylgo= X-Gm-Message-State: AOJu0YxadVbq4hbX90pNATCEmNr9pvOliY5rOcaAT5yGsgn9vdPUP/5n /5CQaoW8OKPwuO3McGDnLiKhogZtxUQc+Ugx8SDr1HbFcJXpkPpoUWMBijQlBEc= X-Google-Smtp-Source: AGHT+IG+VM3BqlCHEFeC4J9E/NMCgNrxfHHKT6M7Y8Cy0YuF/8Q782d8FLdKsjcTjtElrN8SZRNxMQ== X-Received: by 2002:a4a:3c1e:0:b0:5bd:b100:8ab1 with SMTP id 006d021491bc7-5c1adbeb0e3mr9929583eaf.7.1719007927729; Fri, 21 Jun 2024 15:12:07 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 15:12:07 -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 06/10] iio: adc: max1363: use devm_regulator_get_enable_read_voltage() Date: Fri, 21 Jun 2024 17:11:53 -0500 Message-ID: <20240621-iio-regulator-refactor-round-2-v1-6-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_151208_920142_D3087D61 X-CRM114-Status: GOOD ( 13.32 ) 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 devm_regulator_get_enable_read_voltage() to simplify the code. Signed-off-by: David Lechner Reviewed-by: Nuno Sa --- drivers/iio/adc/max1363.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 8b5bc96cb9fb..bf4b6dc53fd2 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1561,18 +1561,12 @@ static const struct of_device_id max1363_of_match[] = { }; MODULE_DEVICE_TABLE(of, max1363_of_match); -static void max1363_reg_disable(void *reg) -{ - regulator_disable(reg); -} - static int max1363_probe(struct i2c_client *client) { const struct i2c_device_id *id = i2c_client_get_device_id(client); int ret; struct max1363_state *st; struct iio_dev *indio_dev; - struct regulator *vref; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(struct max1363_state)); @@ -1589,26 +1583,12 @@ static int max1363_probe(struct i2c_client *client) st->chip_info = i2c_get_match_data(client); st->client = client; - st->vref_uv = st->chip_info->int_vref_mv * 1000; - vref = devm_regulator_get_optional(&client->dev, "vref"); - if (!IS_ERR(vref)) { - int vref_uv; - - ret = regulator_enable(vref); - if (ret) - return ret; - - ret = devm_add_action_or_reset(&client->dev, max1363_reg_disable, vref); - if (ret) - return ret; + ret = devm_regulator_get_enable_read_voltage(&client->dev, "vref"); + if (ret < 0 && ret != -ENODEV) + return ret; - st->vref = vref; - vref_uv = regulator_get_voltage(vref); - if (vref_uv <= 0) - return -EINVAL; - st->vref_uv = vref_uv; - } + st->vref_uv = ret == -ENODEV ? st->chip_info->int_vref_mv * 1000 : ret; if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { st->send = i2c_master_send;