Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp97844lqh; Wed, 27 Mar 2024 16:21:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhWsuotrZbrNhSsq1aaJcEgJkl0JnoFgf08ME65KaRSoXLwmPS/Sv8DWSzITD30Is7GQ0/ZvSZhPMCD27Jk02oDmy3oAINyohVPsgueQ== X-Google-Smtp-Source: AGHT+IFBSTtFtmpqviN+zZaFotdW73276xv0sTlQDCKVD2TesLonJqSS9Hmsiv3cleUX/9AeELCL X-Received: by 2002:a05:620a:7eb:b0:78a:68e:e7a9 with SMTP id k11-20020a05620a07eb00b0078a068ee7a9mr982083qkk.62.1711581719071; Wed, 27 Mar 2024 16:21:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711581719; cv=pass; d=google.com; s=arc-20160816; b=zZdT3+FMx/J+7lx85w5tKaFeTudw0Fd16tx2eK6M0wMHVxU5Tv4Kg0oR91YJerUQmj u7k/fiMdIS1WdolEUVttAcB0qJUnmNNU0V1fydlgOaoSggCHPvBlZnchHaWzRkY/Or6M td6vcgcKPYTEXTZSig/QSqDnQIA0Du/Wyo3q48FOzqOkezxo8n22bjsFSDMuj96vJRtz RU6l39DBCrZXx0gabYrLVeep/fxxevOohlQyXDMFQELFhWhQgkSEJQcc5MHCLZHA8lBd rnyQLM10M0Qv8amR/7tQr4uuklCreMI4emgfHjajW4VCOiS8PrBs4ca22VloeAcxLFLL ftHA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CJZsj0mH5Na8/6xZVfDNraoADX8hsL14D7DbLT7TMPI=; fh=d1kTb2u7d6TMwnarFEAFD3YIkegE7Gc3VCkqYQPmN9U=; b=xRVlm4HzvtqyUlLpl37Oq5QMkx6R+pOxSCqIUvcmcF6PFQbIG7CfwJ5MVDAwRdojm/ Xv7MUpAzY/meAtnliOTMsfulcZBRWO+EBdlJnf3FnmKzEpx2bz7cY1FmzUN5p8gC77+t JgzgjoSyHH3/r1et6bAMB9yqMMmC5ue47SDszLVQ2doOZfWWwtgS/clw3rvHn1H3SAhz aTV2a25d5qNOM+MdBvwn7DG18kwk7U3ZTzjHnGbNv7vPtAKH+L7g0oHCv2rsdlHO5VKM wO5emYmeKMxMBkUf4WgZ9mqljsJVfPx6LD8OcvcMvocQXh+3C4gwOMf01rhWw1iAXCGA 4JWA==; 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=eAqfAphT; 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-122163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122163-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ea19-20020a05620a489300b00789f29b0d27si275607qkb.566.2024.03.27.16.21.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 16:21:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=eAqfAphT; 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-122163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122163-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F25C71C2688B for ; Wed, 27 Mar 2024 23:21:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0451C156982; Wed, 27 Mar 2024 23:19:16 +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="eAqfAphT" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 8B6EA156643 for ; Wed, 27 Mar 2024 23:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711581554; cv=none; b=tFQUToOv2rEPYPw5u7ukvkaV5wEIMTDtAiCqnlAM+g0sRPYWOniRjawn08Lf6ot8XIDY/40n5ju/YrXIPYwlnsu9RFCyOaLGl/Rh3QAJsnPUrlYLDh3AB+ljASdjgMEPRAawzRIeqm504Uhwo1qNpbEwzDS1uVlQ7m5UW6Sz1FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711581554; c=relaxed/simple; bh=h9SozZx07F/ieSA3Tkw6/3vSYWM+YqSBRP3PPQIUB78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hHN1+cir6c4J+HK7F+4KAhsBta4arsF4ldmVRJ36BM3bJYt0EQy4pJeGHCM6tG3iagFMaKxWuSxodfpkdODVTvfdI7hBUEEi3gaSR0wZexQdwDtJFVzTnVFTFcu0t7vpELGSSGlarFhZBMzErWg5ze+/+wVIpTJH0ks5OM36Q9Y= 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=eAqfAphT; arc=none smtp.client-ip=209.85.160.50 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-f50.google.com with SMTP id 586e51a60fabf-229cbc52318so225219fac.2 for ; Wed, 27 Mar 2024 16:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1711581550; x=1712186350; darn=vger.kernel.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=CJZsj0mH5Na8/6xZVfDNraoADX8hsL14D7DbLT7TMPI=; b=eAqfAphTCe5xMLO7IDsfaBpiCj4b/x+7v8ccb8ODULuM2G7hkEN25kFJncN2sx/fvG QqUtlTjU4y695H2BTg3WTXcN767DuqbeSF6kh71SM1I0HU3UoyK8Q8jlsJwuNGAUdaqX v3y9v/LDcuEfFDJ4KrGbQzJPSwxGrC0/1sCznd7hZFChgt5v4WDZzdU2UoIMUeDGcrs/ PvpmycHNdqEKepsxWgg5WbEUrtho04hZf5xJ9rtPoZYW5V2jgvQTNy3hKTKqqAXl9uw2 AZCTB49zFOmtYTVDnDYwbARUFzNRGtTcij9x4iAXUwJ5fZatOfL/jouVCMKin9BmsZnq WBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711581550; x=1712186350; 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=CJZsj0mH5Na8/6xZVfDNraoADX8hsL14D7DbLT7TMPI=; b=wm/+jOKTrdvI2yEwuhvc+e9VzB2f38kRDFSmcXYqrR4dxOdA7xGfU+4Qr7N80xSgv/ GI1ZDleorXDro+JDNXWYKrPBNXCP0+cP28cBpN7AB+Zr8KTC90M/H/wLoICech5VQP3G o8IJnx7Wks7PHYocTGRVzYpzf7GvBuF8Ga11eMEPEixH9srNmsz/boq8Cu98Zqap/SQi 8+Z4OrPddff3hk8TERuLXenoyBwRIoFsMdFEZ5nyTAUS0lhsLXyCYp6wk6u2SEZGKvfm 7henSbFzkrdLNbZSMbHx0ViNJPc3nrrNJrY3lOSZw6Wf5P1RJj2kFTqAQWOzlFaL9Q/A AYmw== X-Forwarded-Encrypted: i=1; AJvYcCXgjxtZN5MRYOYtElO4xnqgm+Mb7IoZoRqtaKXw+yIa4JjU92eNIW1fv1Kc5py8hjt30fYLRIkS1TKugD4LaAgsd/SPbymFKBESC+ZN X-Gm-Message-State: AOJu0Yxb8lS1VMXeSJcOt7W8wa8I4sDgXyOe6rQldzfLQ+SaAGmpJedR bIp5oWDNtPR4jqVy4d6cmnh7V7HCr7oFG10w4XcRjPmeeI7QsIGtN2lDZlUFQXU= X-Received: by 2002:a05:6871:3a14:b0:221:9013:d783 with SMTP id pu20-20020a0568713a1400b002219013d783mr1213589oac.34.1711581550253; Wed, 27 Mar 2024 16:19:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 16:19:09 -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 7/7] Input: mpr121: Use devm_regulator_get_enable_get_voltage() Date: Wed, 27 Mar 2024 18:18:56 -0500 Message-ID: <20240327-regulator-get-enable-get-votlage-v1-7-5f4517faa059@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@baylibre.com> References: <20240327-regulator-get-enable-get-votlage-v1-0-5f4517faa059@baylibre.com> 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 We can reduce boilerplate code by using devm_regulator_get_enable_get_voltage(). Signed-off-by: David Lechner --- drivers/input/keyboard/mpr121_touchkey.c | 45 +++----------------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index d434753afab1..c59e7451f3cd 100644 --- a/drivers/input/keyboard/mpr121_touchkey.c +++ b/drivers/input/keyboard/mpr121_touchkey.c @@ -82,42 +82,6 @@ static const struct mpr121_init_register init_reg_table[] = { { AUTO_CONFIG_CTRL_ADDR, 0x0b }, }; -static void mpr121_vdd_supply_disable(void *data) -{ - struct regulator *vdd_supply = data; - - regulator_disable(vdd_supply); -} - -static struct regulator *mpr121_vdd_supply_init(struct device *dev) -{ - struct regulator *vdd_supply; - int err; - - vdd_supply = devm_regulator_get(dev, "vdd"); - if (IS_ERR(vdd_supply)) { - dev_err(dev, "failed to get vdd regulator: %ld\n", - PTR_ERR(vdd_supply)); - return vdd_supply; - } - - err = regulator_enable(vdd_supply); - if (err) { - dev_err(dev, "failed to enable vdd regulator: %d\n", err); - return ERR_PTR(err); - } - - err = devm_add_action_or_reset(dev, mpr121_vdd_supply_disable, - vdd_supply); - if (err) { - dev_err(dev, "failed to add disable regulator action: %d\n", - err); - return ERR_PTR(err); - } - - return vdd_supply; -} - static void mpr_touchkey_report(struct input_dev *dev) { struct mpr121_touchkey *mpr121 = input_get_drvdata(dev); @@ -233,7 +197,6 @@ static int mpr121_phys_init(struct mpr121_touchkey *mpr121, static int mpr_touchkey_probe(struct i2c_client *client) { struct device *dev = &client->dev; - struct regulator *vdd_supply; int vdd_uv; struct mpr121_touchkey *mpr121; struct input_dev *input_dev; @@ -241,11 +204,9 @@ static int mpr_touchkey_probe(struct i2c_client *client) int error; int i; - vdd_supply = mpr121_vdd_supply_init(dev); - if (IS_ERR(vdd_supply)) - return PTR_ERR(vdd_supply); - - vdd_uv = regulator_get_voltage(vdd_supply); + vdd_uv = devm_regulator_get_enable_get_voltage(dev, "vdd"); + if (vdd_uv < 0) + return vdd_uv; mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); if (!mpr121) -- 2.43.2