Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp97314lqh; Wed, 27 Mar 2024 16:20:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQ3x1oevhuRmCacAV14WslCQAxT8VDMyT4rdqYo4L/6ZcqL6Kqn1Dxnx9MIPl3TPfEhyScQDWZj39elRN2pmWzdEgTc28tUVy+L9BMsg== X-Google-Smtp-Source: AGHT+IEBSp09xCozhIRxUZhj3E3nfO7f7mUD+YmJS18SkvGEFoWlr7P0SmUHH0UQ0XgDf3Ohn9aA X-Received: by 2002:a50:955d:0:b0:568:b4b7:3172 with SMTP id v29-20020a50955d000000b00568b4b73172mr855299eda.6.1711581629354; Wed, 27 Mar 2024 16:20:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711581629; cv=pass; d=google.com; s=arc-20160816; b=XU0+g0enxV9SXXvSpEOUeLY2lvWcCz8KzzbkR6oCC8Fkw4/Yg6HcAw9msMClZjzhVu zibFP4KlUT/g1BLr9QjcyxjPPzyLjir67f/+vygqcxlgJq/wcCn+CRLCg5Vb40IKEAeZ HowPpinmoq3PfKaC00uFiREZ3p/mrQoFxoYLzoqTWt3P53FKQYDc2fdpNjsr5BpbhBpw FrktyAp9QLDSyXdbm0QvV+p8gf+477BNMBit2lRxRG2irfTAFXfYOfSdKMswoORGZTit iftkMvR3izMk5PZuHtSIzABQcVOyBiRVAqgofdK1LjSl6Zt7PtCbBk4r+MJtBX0i5nV2 BwgQ== 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=pNmxlM+zWytQQYi7ZtjQVmkQiumnd7DNMgYQxgBRWM8=; fh=OrDejviQ3jEbu6g89sgLGLUaJ/rnDKGG+8BunPCDdvc=; b=kZfFoWzOLU2QxBB9Ke82AcM/9nOZrNBS3jCQgSnn7uC414o4OvMq3h7Cec1JJui3R+ g0a+NiaVO8VQCjc+TMNwu6tvpRyjVdbhTfaZYpgcsznqYdxWeQ9N1tg2QjA11QbCAJ9/ 0jarg6aQDayRsPZ68/jaNxl+1sIkSSxhiuNhwXXkHqzqbvYCX4Y77ap7bhf+U18bde2W ULKFkz+lndRiDhX+oGyuOzazT25UnNS8WX7Lv/Jic7vskD5b/a+QZN1uUFtYjpG4TQIm bSOtV7bb5MfCoFPPkLhmBH0w84B3WJnukCh+hRNp9jeyM2ebn6lhQHlfga87pFxgEsx6 /+Gg==; 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=0ABVGfHH; 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-122156-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122156-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u11-20020a50950b000000b0056bc0c65377si113908eda.278.2024.03.27.16.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 16:20:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122156-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=0ABVGfHH; 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-122156-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122156-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1ADE11F2AC9D for ; Wed, 27 Mar 2024 23:20:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA24415531A; Wed, 27 Mar 2024 23:19:06 +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="0ABVGfHH" Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 4256D154BF3 for ; Wed, 27 Mar 2024 23:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711581545; cv=none; b=eTcw2QANvzz+y4SDlnWEcysQcf7O0U/+oCRmmM2hEGuiSJzbloTfJ6RYzCG4rUY/38pU3cHdS95KiWQcNhyuX/yhCgywMioR+i3dH824pm1nTJ1CtB/IrocP4IZXlDtb1FGFAE/TvUODWGAPeaLu5ihtL/u3FtUbISgJXD/HYx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711581545; c=relaxed/simple; bh=Oin5ojSwy2humzjzfHVDPNnW4ZK/nwUgFx0t+HKuAB4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nuSi+qm3Aft1Sj72yyfwmAi54i4evucS31QGS9G7yw6ZiAg9UbpMltmxr8fAFBNtKOmtFwR4LCzYSjT+ZKDsXbDa47xL401txgPHqhTq36BfDw0CR/KoiXANpwyzFC1WxTAVnGJLDoMyDFkhW4aXJ9SxdZy3eThGVBC5ibT/DUY= 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=0ABVGfHH; arc=none smtp.client-ip=209.85.160.52 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-f52.google.com with SMTP id 586e51a60fabf-2218a0f55e1so216994fac.1 for ; Wed, 27 Mar 2024 16:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1711581542; x=1712186342; 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=pNmxlM+zWytQQYi7ZtjQVmkQiumnd7DNMgYQxgBRWM8=; b=0ABVGfHHvyHnYF5hd1OqQl1iZYDFAsoTAnFoz9PQIRq/QP3Nn5kLjbP9koIqKf69et BhjAm6OlMQkGbOryPs6WYrzUeqNPdYbOf0WbFbT99DvCHlwQDRnLpG8lyNXp42l778Bp I3+i+Rap1zbQuxQ+uLiaD6XlVBJ6BJBonKyRM9jZSc3k8WtzomIlXGCJq44eSDRHvDgQ uzXz4NaYW3l0S7fReJSm0W/iYRV7pbWxmgIKYRXJjt3ADDYsLxMoRTM84X1yD6zxRBPW T7YI6wmOxIBqyTAcJlFCBcB4MRMdK4VNOZJM+FW3by4lx/R8/6VNoNblqlBuPCAB48/i OdjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711581542; x=1712186342; 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=pNmxlM+zWytQQYi7ZtjQVmkQiumnd7DNMgYQxgBRWM8=; b=Nc88clWzy3nblMu54IR86rqzxYEsn//Z9RMZbtUtox0r9n7vikZiZUKoJLGq3qAi9/ p1KmALEEdPhTHjpbrpSHFkK06yoaq4RnSaR+oek/JHTOGHZCAzyr3VYHYkEKE8JY4LwT gFSYLKzeIszSlAFdxDCXUg8RTG9X0Y0w5W5cP72rQdTHsixbCC/tnkqKqt1Cy4X/anIA QwjrMLMrTzpRqZuayoPPLy3HvVxLUQBMDHo1/ei9Bsu0X9hDxEGjT7IY4M1TAQOIou3q 0p30wbNcAdIYXkx+VryhU+Eoz8MMrOQEn1xx4e8qyu1Iyu85MNcdvH6hwpRMnZ8yDafs Z7xg== X-Forwarded-Encrypted: i=1; AJvYcCXYTk8VIi8psNVVqB/IP8/hV4AdiFxxGEX38UrFC8iOwromdig/ozJkj7UReZSoFaNugaxuHKFlyN0w8+HlYNfaoBHhwVA/wyLGpB1f X-Gm-Message-State: AOJu0YzYLaxem5SP9Hg8RRbOMIP4oFLuarXFzQtTc37xYNCf1PpcpN9M 8LwFCeGO+UJqNrLjbesZkMgZEJye5TITtiL/4dUeDhAqEOWNnPsX7kIkDwD8MKg= X-Received: by 2002:a05:6871:2b2a:b0:22a:55bd:a048 with SMTP id dr42-20020a0568712b2a00b0022a55bda048mr1167094oac.5.1711581542433; Wed, 27 Mar 2024 16:19:02 -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 js3-20020a056870bac300b0022a0519183csm81381oab.2.2024.03.27.16.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 16:19:01 -0700 (PDT) From: David Lechner To: Jonathan Corbet , Liam Girdwood , Mark Brown , Jean Delvare , Guenter Roeck , Support Opensource , Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Antoniu Miclaus , Greg Kroah-Hartman , Dmitry Torokhov Cc: David Lechner , 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 Subject: [PATCH RFC 0/7] regulator: new APIs for voltage reference supplies Date: Wed, 27 Mar 2024 18:18:49 -0500 Message-ID: <20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@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 couple of new regulator consumer APIs 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 12 more users of devm_regulator_get_enable_get_voltage() and 24 more users of devm_regulator_get_optional_enable_get_voltage(). In total, this will eliminate nearly 1000 lines of similar code. --- David Lechner (7): regulator: devres: add APIs for reference supplies hwmon: (adc128d818) Use devm_regulator_get_optional_enable_get_voltage() hwmon: (da9052) Use devm_regulator_get_enable_get_voltage() iio: addac: ad74115: Use devm_regulator_get_enable_get_voltage() iio: frequency: admv1013: Use devm_regulator_get_enable_get_voltage() staging: iio: impedance-analyzer: admv1013: Use devm_regulator_get_enable_get_voltage() Input: mpr121: Use devm_regulator_get_enable_get_voltage() Documentation/driver-api/driver-model/devres.rst | 2 + drivers/hwmon/adc128d818.c | 55 +++++----------- drivers/hwmon/da9052-hwmon.c | 33 ++-------- drivers/iio/addac/ad74115.c | 28 +------- drivers/iio/frequency/admv1013.c | 37 +++-------- drivers/input/keyboard/mpr121_touchkey.c | 45 +------------ drivers/regulator/devres.c | 83 ++++++++++++++++++++++++ drivers/staging/iio/impedance-analyzer/ad5933.c | 24 +------ include/linux/regulator/consumer.h | 14 ++++ 9 files changed, 138 insertions(+), 183 deletions(-) --- base-commit: c5b2db5859957150ac6ed305ab41a4a92ca40cfb change-id: 20240326-regulator-get-enable-get-votlage-5dedf40ff338