From patchwork Mon Apr 29 23:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13647868 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 015EA199E80 for ; Mon, 29 Apr 2024 23:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434037; cv=none; b=TpBso0jbklen3cwAesZpYcxKA6dsK5gCEVMjV1iqBCrLZwF37ScJSnwIO8TPt16d1dyzv/fxsO0BN9hTF1NaKCpZsdzffG/05mhBT9ghGC4lkOlrTbayiwntE+2NbaNZ6cZeaaTy5YU/jSTeYjGfMrIO0W49xRV4e85/FZ4SnR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434037; c=relaxed/simple; bh=lue8tGKQodCQW7f9Ah8mLVDqX/DjwpQuD96ROdxcrKw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=mhbcMgwxfJwLpOtGW4EcsIy39Mmxjaplziaby45jjp3MDjaE1XWmyv9gpsUzF1P/Z+Ij+3JzVqC9nMNwY+ty7DpeGLEx+qZj3DMU7Km97V6Y5L7TB8rrv8b43Hou9Uf1U3Asr3A8tRe8Nah7pickakk8VB5++4wEpSMC9UfHLEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=n3CE4WKF; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="n3CE4WKF" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-233f389a61eso2596504fac.3 for ; Mon, 29 Apr 2024 16:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714434034; x=1715038834; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/RbyRopVLlo3z9muP6tADTHE5XtuugaNtZZWMLb0Jpk=; b=n3CE4WKF3ND/TUY3+9YxfL3fys9TCoaqxOAoU2s5yl/wugLbbqjrmzy7hFZ97Glvmk JyGNcQusHWdmW2pWMlEmf7dMRtSAIE5sqGVXlB4Z5DbOcXPYsvkkCqbLGYvlZxCnqScL EgJYtYOJ/NNBhJDq+u88rCVD2EiUhU0R4MXeJxBQNmx57OIJBNrzhVKXJO4XuQGLr9P2 4yA1AKRkzUNft0nZGrH/PWcbFFCFE7+Nz+uA3/pbu6io5P/gxUqCgV70Y1ylzoK+QNrJ MP8jLCPuqy+bKrkFUyYzafcI1oVYKyBNzyN48Axsc0+bgOP1kpCDNeofqGBvqT0z7JeJ CHMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714434034; x=1715038834; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/RbyRopVLlo3z9muP6tADTHE5XtuugaNtZZWMLb0Jpk=; b=PV3jTyPmvAHbKs7XIgv3vsxW1fptgfNIGYod6CI0jVorTT00hX87vjb5ob0jycPCa0 Cq1CbmsHO0P87C36+kDFQ5uba1x7o9eWgqyofsHLq7BVoFdrUgb5Fvg3MEOf7ttV9a1l eFP6ktMtpn47Cgxt3y2p2R0Lqw4jNXMsY6xmMvNXcUSFBs21srpkVahfSeONuTb5zyRX 3wANDeDKdyp8yuzLU+8s9VRZife7mCEMA1nj1AyXZrL6hD2zO5IJwnY65fdGIpDUl4u8 wXgDhUdp/d4R/AR9FJ18wxynoJBOaeYfz2LLj5UYb5vCTofNspbZnKDKHqqsCBS39O7D 8kjg== X-Forwarded-Encrypted: i=1; AJvYcCW/caUm7u5OCbvDrBZieYs8j+PStwDFpo+GBDvleCykElb1tYPGuIdJ+uVlzkt6FWexkgHtR4QWZhIsodWujG1URcCu1stFUUop X-Gm-Message-State: AOJu0Yyg0SpHkIlayAfOmbleSTATl2VeXHzG0fMczt6rlNrzQeRKKmmT tLO3GjgPwUALzwQjm0UjcXXmYOYhFNVccWvzAjFeAPVyXelShUPhrijetS5dZzY= X-Google-Smtp-Source: AGHT+IGP5WuztYu6eAOehmTgcCwU3XFCxmv4osL3pF9V/oN2vHxn21J6GhNMYPv+HR2qW2NPzbUEJw== X-Received: by 2002:a05:6870:f22a:b0:22e:c787:5fa2 with SMTP id t42-20020a056870f22a00b0022ec7875fa2mr12446265oao.58.1714434033950; Mon, 29 Apr 2024 16:40:33 -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 hp22-20020a0568709a9600b0023b58aa20afsm2144508oab.25.2024.04.29.16.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:40:33 -0700 (PDT) From: David Lechner To: Liam Girdwood , Mark Brown , Jean Delvare , Guenter Roeck , Jonathan Cameron , Dmitry Torokhov Cc: David Lechner , Jonathan Corbet , Support Opensource , Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Antoniu Miclaus , Greg Kroah-Hartman , 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, Jonathan Cameron Subject: [PATCH v2 0/7] regulator: new API for voltage reference supplies Date: Mon, 29 Apr 2024 18:40:08 -0500 Message-ID: <20240429-regulator-get-enable-get-votlage-v2-0-b1f11ab766c1@baylibre.com> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 In the IIO subsystem, we noticed a pattern in many drivers where we need to get, enable and get the voltage of a supply that provides a reference voltage. In these cases, we only need the voltage and not a handle to the regulator. Another common pattern is for chips to have an internal reference voltage that is used when an external reference is not available. There are also a few drivers outside of IIO that do the same. So we would like to propose a new regulator consumer API to handle these specific cases to avoid repeating the same boilerplate code in multiple drivers. As an example of how these functions are used, I have included a few patches to consumer drivers. But to avoid a giant patch bomb, I have omitted the iio/adc and iio/dac patches I have prepared from this series. I will send those separately but these will add 36 more users of devm_regulator_get_enable_read_voltage() in addition to the 6 here. In total, this will eliminate nearly 1000 lines of similar code and will simplify writing and reviewing new drivers in the future. --- Changes in v2: - Reworked regulator patch to remove dev_err_probe() and properly unwind - Combined two proposed functions into a single function - Renamed function to devm_regulator_get_enable_read_voltage() everywhere - Fixed other feedback on consumer patches (see individual patches) - Picked up Jonathan's Reviewed-bys (hopefully changes were trivial enough) - Link to v1: https://lore.kernel.org/r/20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@baylibre.com --- David Lechner (7): regulator: devres: add API for reference voltage supplies hwmon: (adc128d818) Use devm_regulator_get_enable_read_voltage() hwmon: (da9052) Use devm_regulator_get_enable_read_voltage() iio: addac: ad74115: Use devm_regulator_get_enable_read_voltage() iio: frequency: admv1013: Use devm_regulator_get_enable_read_voltage() staging: iio: impedance-analyzer: ad5933: Use devm_regulator_get_enable_read_voltage() Input: mpr121: Use devm_regulator_get_enable_read_voltage() Documentation/driver-api/driver-model/devres.rst | 1 + drivers/hwmon/adc128d818.c | 57 +++++++---------------- drivers/hwmon/da9052-hwmon.c | 38 ++++----------- drivers/iio/addac/ad74115.c | 40 ++++++---------- drivers/iio/frequency/admv1013.c | 40 ++++------------ drivers/input/keyboard/mpr121_touchkey.c | 45 ++---------------- drivers/regulator/devres.c | 59 ++++++++++++++++++++++++ drivers/staging/iio/impedance-analyzer/ad5933.c | 26 +---------- include/linux/regulator/consumer.h | 7 +++ 9 files changed, 124 insertions(+), 189 deletions(-) --- base-commit: 84c1815e46bdcb8bb0259db3d6cdd934cb70a0e9 change-id: 20240326-regulator-get-enable-get-votlage-5dedf40ff338