From patchwork Fri Jun 21 22:11:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13708122 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 EFFB7C27C78 for ; Fri, 21 Jun 2024 22:12:46 +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=so6aBU+eDqnCDSaguZCLxm5y7z6KxLSHynmcPlHhQSc=; b=b6GiZ5GU7UgubDryiEA2jLSbQ0 9CSh5HZ0/zmzITprbI+2/G4HmhMU4Ej7pScGaPUzdbKEuP3cz0QqcB9waGlQ2fumnGratj0QelaKi io7ChyWlPw6Oi8+miVF4H5JxhDvyhMcEazRjwj9EFCWN6CzV50qkZKkxVX8KDsHaYCRbldHNvi8dW ooiF+FNC8fiAVAyzI+rK97LbHtsZQBdwZHWp4kcp7aJsvaajb5jQvG4ugYaG7jHESK6F6oOkJY56P xqGhvHc9MKpzdQCu8JrYc/dQPjaCQ4yldby7hzoRmsJSACafVipqaVV7u3eYSP4ES+kz1EdLd8/kX ZsmLVomg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUi-0000000AiNd-2VVD; Fri, 21 Jun 2024 22:12:32 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKmUL-0000000Ai5A-3NBs for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 22:12:11 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5babfde1c04so1116193eaf.2 for ; Fri, 21 Jun 2024 15:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719007929; x=1719612729; 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=so6aBU+eDqnCDSaguZCLxm5y7z6KxLSHynmcPlHhQSc=; b=NLxfOKV6KhKMKKLmkyFWP+Cl9NaAb+hoixhes9nKJEBWJ213H/Qwyw9pw7iuIMFvnq cteoxweqaOVYCgVv+aONQUelUY4zmaNKW7NdomCD/COHyKDFL+dFjA2QBoHnB0h5uBxt rGETjcoHTBHT6LFIPomfvuTQBLONZkZY5kyPRzQMlObHiEcWtOg1dh471OrIcCNUYdOd eNci5Mr8k4+9XmKVb/67O96NyTADAvltTxxSXtdJvCTG2FSSL8oYJ1i1PP82olKwv6j+ fAKlUQphDoPBlEMmYEFmMbFCKu1OciYfEefwJ3SNl9k9owfE2VYnQWUrXwDultnpMPem hc9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719007929; x=1719612729; 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=so6aBU+eDqnCDSaguZCLxm5y7z6KxLSHynmcPlHhQSc=; b=lVU1IS5CwmCjy6FEZX90zvsOtmLmtx20cipyzmuCLCRz3FWlVAPqdHapkwi5zIcVNl Hlh+j0EqoRc58JkssHI6GRmXR29T1MwzfbO4OOOlVt50Mp6Bx2uG8CkV8s7aThLx3wRZ JeguQvmqxidrH3Q95lEqj6PtH2OMKjVj+PFovHPJo+QOo+l7lIWqLrtaxU83CNNz17MQ 6ISMyHEpfDEduFxHnpRFHkhD3DzT/3XT1bkERiqZZr0phhG4m7mObDI0bUEGvzY4UQh4 /lEnRaJmCxXBe5c0btgfv0rqOTee/nYCERqy7mdIpoQiteJNmKGhNhLpHOPZ7sYC5hNv Rv5Q== X-Forwarded-Encrypted: i=1; AJvYcCW0kbT5+6xcAYndoLzffAhlgzjED/9QeE639IDe/xXjyyZIlIsaGLEhsKebuvtertAhUtZ8aTATM4nZ9gYgtPy08FVwc6yrXukcCrjw/qKmNB96HfY= X-Gm-Message-State: AOJu0Yx/2PLTH0nEQ8fJXpq/EO9SnWYOyAfbmaFySA1+SzC1mFHxe7f5 a5NVi1ms0fEnZXYuQFWEb+x1fGoo01wCzY6MAi+KhQhXpb0jYg5n+34/FFKYZII= X-Google-Smtp-Source: AGHT+IGCM/8sRsLCLqFNICTMywqS3PsKIuS/B/sed5essCH1YgcxL2TzQancR7MJmS3Wfz2Pkd4FGg== X-Received: by 2002:a4a:3c5b:0:b0:5bb:294a:cb90 with SMTP id 006d021491bc7-5c1adbf1d68mr9897886eaf.5.1719007928519; Fri, 21 Jun 2024 15:12:08 -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:08 -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 07/10] iio: adc: ti-adc108s102: use devm_regulator_get_enable_read_voltage() Date: Fri, 21 Jun 2024 17:11:54 -0500 Message-ID: <20240621-iio-regulator-refactor-round-2-v1-7-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_151209_977586_8613296E X-CRM114-Status: GOOD ( 14.57 ) 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 --- drivers/iio/adc/ti-adc108s102.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c index 69fcbbc7e418..9758ac801310 100644 --- a/drivers/iio/adc/ti-adc108s102.c +++ b/drivers/iio/adc/ti-adc108s102.c @@ -58,7 +58,6 @@ struct adc108s102_state { struct spi_device *spi; - struct regulator *reg; u32 va_millivolt; /* SPI transfer used by triggered buffer handler*/ struct spi_transfer ring_xfer; @@ -216,11 +215,6 @@ static const struct iio_info adc108s102_info = { .update_scan_mode = &adc108s102_update_scan_mode, }; -static void adc108s102_reg_disable(void *reg) -{ - regulator_disable(reg); -} - static int adc108s102_probe(struct spi_device *spi) { struct adc108s102_state *st; @@ -236,25 +230,9 @@ static int adc108s102_probe(struct spi_device *spi) if (ACPI_COMPANION(&spi->dev)) { st->va_millivolt = ADC108S102_VA_MV_ACPI_DEFAULT; } else { - st->reg = devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret < 0) { - dev_err(&spi->dev, "Cannot enable vref regulator\n"); - return ret; - } - ret = devm_add_action_or_reset(&spi->dev, adc108s102_reg_disable, - st->reg); - if (ret) - return ret; - - ret = regulator_get_voltage(st->reg); - if (ret < 0) { - dev_err(&spi->dev, "vref get voltage failed\n"); - return ret; - } + ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); + if (ret < 0) + return dev_err_probe(&spi->dev, ret, "failed get vref voltage\n"); st->va_millivolt = ret / 1000; }