Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1688135lqa; Mon, 29 Apr 2024 16:41:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWO7rm4GQQiMBk8irnbsQN+kEQkY3pp69xvNZZqXxBQn4cL80noSOMyiXewQZ0nzN4ljFgnNQoHgzFIol6AAR39dBoHWpnpX6bO5eE2+Q== X-Google-Smtp-Source: AGHT+IG5vcHlnXLe7q8D5Q0RUX4SC6Viv7Xx0bZwRjLcxMNPzf+n6Gtgx/SxzjgJXbupk8WS5P+n X-Received: by 2002:a17:902:d506:b0:1eb:1008:2dca with SMTP id b6-20020a170902d50600b001eb10082dcamr11720541plg.49.1714434076803; Mon, 29 Apr 2024 16:41:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714434076; cv=pass; d=google.com; s=arc-20160816; b=fmMNwucm2p5BVC4dBgwbFdYZBiyI41Os2O0OiwHSmBGOuWEMcx1hS/zJYyhwXza/Z1 0ME7A2kspt/xeqsBJNe7zL5QcvgEQFXA8VdZrbx9bnmBAD918jXaWANhrBLYxGu8ye13 ZM99YZIrFrm1RVumWEEG0wdYKmVj+vYe/e82QG24tk1l1YRbEmMKaXv+Lv3t5a5taNPn Jefwko4AUVFh1KXUuIqk/6/pztF7iuBiC2Tic7FMQvUXTXSC+O4FwKcazwHdJDygzzT7 XCl86J7RhybZLv2fkKQLgpxg5jwJAoywKECbe1H1nuojhS5nMkxCvF+rzS3XV2XF+/KK Vmyg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=/RbyRopVLlo3z9muP6tADTHE5XtuugaNtZZWMLb0Jpk=; fh=E6KX4Oh6EOwCG8hO6K4FsbA4gm7tbVCP3ut5pSgEXJs=; b=yn9835hcR1voO/iVOKBaI9X2IfVsZ1Q6BJL9tmG0hOBEBT22SJ2C4a1mBoU6ptv51U 9nmu0+xo9os9HZl1RWpGOXUWl5eJW9VM3zibS7Mrx2F9+i0cMJCAI6L2NfklLUg7GjsU qX8hCLzvHe9gzLdS5dgKhsfamE+OMq2P5DdVB0iCkxVpntdqplObohHBVoMC55EvvNOi Uha87VYSM7DV1mB8Id2HcK1j8iPIgurA8PiJ+tcAyt4tVbfUGNeWffFV+Zp96uLgSgyJ 7k68EiZE8buYofAXHnZ+2hnkkvZqkSFvhnq3bkiuNwSbDLd+DgWmnBTJgpmJq8d40v9K 2Zjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=n3CE4WKF; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-163160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163160-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e12-20020a170902b78c00b001e236d13214si20669401pls.175.2024.04.29.16.41.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=n3CE4WKF; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-163160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163160-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 658C8282B5A for ; Mon, 29 Apr 2024 23:41:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02F50199EA4; Mon, 29 Apr 2024 23:40:40 +0000 (UTC) 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: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 E7F50194C7E for ; Mon, 29 Apr 2024 23:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434038; cv=none; b=ZhZ88lRGBiKraiFQSCM8nWT0BxGDoFC3tEprnYOvWPeA0vti1FuJeh6ENp5A8he2z1zkXaKaKiD9o/gZcdt4v0XE8JmQtJ5cjiF17Y5aqeGcAi9VCLRwMvzPMaqlalhW3vw3wA5j0uoyC3xzU/S/ijDbUwEcaJdI4Rf1uz8txUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434038; c=relaxed/simple; bh=lue8tGKQodCQW7f9Ah8mLVDqX/DjwpQuD96ROdxcrKw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XdNJgLUItmLYC6LO6Z2JQxsyDjNl7QypaKEjuQ6mhtTZN21+ukO8+CrFnExTXeD46YCcX0sxjII4TvX3DgtoTXEaYIVH9iGKtpsg0SwmRZdUatkQHVhWA0cEe5NHVm/8ozvO4uf4V1Lfjj5/rzgAW8A3Zr1ImMrJr/gYvLULoCs= 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.41 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 Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-23319017c4cso3290510fac.2 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=j65TntN2ZoWKmZ0UDWeDAqDE6rfbQ+S1rvfbrrcT0CczIHZ2xo26trN6yz6qrSNJBm 0b3uiS23Fe8pYTg94XkKaq6WKyAz05ftc8N8ghqhk2cc+oNA9c189GIF29mQRGSP/ITq RitHSPfO02cm1x3eIcEjlenYSek1vBV1M9GA6pH45jfDQ64/5UgRH2Wgy7oKYpTJXs3A UTv4Hs9Ti8yi8D5mrYJ/DipMkr+EqB+u5Hqi5+vFqOEBg6sLVNaFjMezBUwsl2yu1NoC xYLvHlVEEUxWo9q0hLJZzNdSWEuNiOLzwiLDbPClVFdnqzvY86i2+B3IHmWHXCz/Mfnt SW7Q== X-Forwarded-Encrypted: i=1; AJvYcCWYa1j0OvgiRzhxVK5cEuXLTpwAiiDYqtQMyEC+slbnXqQisZpIZowbLXoQ1z7vtMnCqrFh+2Ms4oH/4m3fvuKLSZ/yq1q8fVc14BiZ X-Gm-Message-State: AOJu0YzIWdsfF8OlKl896isZqruUyrDdVfUCpVU00PObfXLho92ypKIL REersnvMt7A8Z7hEce4HOALTi8UXPsXLc0J+yc6sn6vwG/54GAKHkf22cZSwNCtfZEvSds6JEZw Q 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.12.4 Content-Transfer-Encoding: 8bit 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