Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1691517lqa; Mon, 29 Apr 2024 16:50:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUORVNYwDYoh4NpZdUzg/2G/3Z4fVWUeUMqal1rrKv0Wpu+Ev11FmqP/392WFciuZg3RuBHJr+ghN+n4E+2MM3lNT7BRG7CfudU/Zuz/A== X-Google-Smtp-Source: AGHT+IEfGvByPdg+syxpFkP3IievlJLBPgx74Xd6tIShcQmryS0VSLZ8brPgMTIERbiiPxfhu151 X-Received: by 2002:a17:90b:78d:b0:2a5:badb:30ea with SMTP id l13-20020a17090b078d00b002a5badb30eamr10806792pjz.36.1714434634823; Mon, 29 Apr 2024 16:50:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714434634; cv=pass; d=google.com; s=arc-20160816; b=NXbIvcpasftwAXrQys7fI/T/UAZknAhNRFean+sbiIFkkRlzWiCEh5jkMLh9YpcgPA 1+QmjyuVw54iK3jI+MXbu/2FdCj9fAbpUvSBBXBcLz72euT2GWxZ494pEvzAyzFuq0j1 kb6dXznONpZpQSayOHMzFRiaFLvMLNlJ2Cvx6BzYEcRWDreIqPTFmxeZCRtYPgemeCxa PRfHONQ3pPXoMI2IQY2BSKPki1/45bryuzs7i7QiCQBALWr4GBotcqy+sl7rimXqfINO hbUXggUJAjsnCcITu16edWqbJwyY5zcEXf5Ml4HcoPutoO7Ss04LK+jJ1T8ilzlB1W43 88hQ== 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=8cubJgWS5pQ7P3B0LhmHJm/4bbMow1xJhT8KxVswt/M=; fh=KMkJ4YWNPJE5ukkms53nQcDODuZoOSicy9zEeFlk9KQ=; b=rXhkCmTBkiLyt5erBd7LWUhjLpOMAA3pKcbWWYBsvb2B+RMEgwHKhIWhljhY+Dh+qV OSvyls+Q7E18KRcghcwFpwOPEh3dtX4JU0IoznYZRAkh1TzLX56toNQfhHwa0QwMfltQ wv4ye7n9Ah6obbb2UCRJJOCdZkhIn0jbPZYfH0woh+taplW13QX+KYLeXYGxPq17+JWV p/K+aJqtrxyNQcPFLw+qXa9Oyh07AipoBt8y3a0CvHhPapy0yzPHewobnCTnRxsaSWhw AOsRtxVZpYW5U4DXkl4r7EOTSFxYT1NxuPyKsKHiCvkthSnhV7FcLHAAknsUey/oI8dX h9bw==; 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=bduqQ5a+; 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-163165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163165-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u1-20020a17090a0c4100b002a5d3134d32si22593300pje.39.2024.04.29.16.50.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:50:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=bduqQ5a+; 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-163165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163165-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 599E0B23B68 for ; Mon, 29 Apr 2024 23:42:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 464711A38FB; Mon, 29 Apr 2024 23:40:45 +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="bduqQ5a+" Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 77FED19DF78 for ; Mon, 29 Apr 2024 23:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434044; cv=none; b=nXd1VM1rKwp2CnqUnKyDiKZ53kGZ18r4iZ/DLr6ejeCABCZZaJHdtlUgiQdtEsi3fo6LOh2GuDA3z8xTHSJed8LwurHXQyFraxQwGvUOOtJDDnj93Gg6xfvzXv/+KQ57cU7DebQKB43XvVl28wWjwoE3crM4QF1CwxpOnBRD1XU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434044; c=relaxed/simple; bh=4b44S3VIMtdkbxcMOARrPEB6+EsrH1npp+wwSXp0/Y8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RtoZpFTNXbYJk7rRCfJ8yvXXrgSkMM2JyPxAAoXQIpVH6dlLa5JhIWrJ8LLMpxauPfcem/S0754S/xvQJJwRNcYaDA8NUwQ8Vygo+apqyobiFNVL/uLSYrkaFX7rtUtlCAqNa2pc6wouW/IL+UprT68cT2jzad4cug/A7W6PUik= 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=bduqQ5a+; arc=none smtp.client-ip=209.85.161.42 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-oo1-f42.google.com with SMTP id 006d021491bc7-5aa362cc2ccso3592340eaf.3 for ; Mon, 29 Apr 2024 16:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714434040; x=1715038840; 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=8cubJgWS5pQ7P3B0LhmHJm/4bbMow1xJhT8KxVswt/M=; b=bduqQ5a+j6loGrmIgbI8tMn11NJphoFzKCIbBzmNfndnCaiQUMzWt+B0+ictA1WVtS GZxyBFLnXLCZeYn3MdZwLEkjs+vMX3yHnNMq5xp9flDqXYcoTnBKcH+OArn2ljmrKh1I ODn9jZUMfRGn6hIcCvoR9qN4dTVH185Lm1N+iNiuTr9S2BYPOb7BmjAsry94d4fxBkmi rhZbIzTGTOEkZ9c7SqI3THA24S9cfBUEU7Ha33/xcvos3s9ecDM6udVr8DwxZR8azH8w VKkBxWgAjars0jJdUyFR+bYmLQo1DZdHEpLjCQhU1V0afc730679HinA70Th/YfDgd9a 1x0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714434040; x=1715038840; 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=8cubJgWS5pQ7P3B0LhmHJm/4bbMow1xJhT8KxVswt/M=; b=LaO7KDKce1AdLxDLmQph+odzArPkPwdJdbkxIAc5t5uEBNcsYLgJeqR5INQXAXtC6A 6Qale1Ftl+B5Ox/QTwiDS+26Og/wHX+Gz/84Mq7rjGFEo0GPoRsHfb2MzunekzMD/ADq 3PBtzCQKkr3vWsIdK5NcrO3m2IqKdzyxbIhOLW+J3mxZp4laEtn+N7w10RThVTDgBxWq T0i5AlydhAbKArAirvD+EAMv0glHzbUXOWIH9oCFGBRWyfah2OL+J/1jpdVrc0qXh40X LW2o3BwJyUSeFDzPuzlfNWIfpzE9qxm83XlIO8PpQKukralU0KXRA05jq37GdqlPRbuY gTBA== X-Forwarded-Encrypted: i=1; AJvYcCXykIzd0Tv7LkNPrE0czy7V2u01o/QGgURaAq2cydv+XclgvbNn/g7Ay6ichJ2JZeVX1BbQA7SLRZwiVtpgHecikJxS6UeQiH4Nr+0C X-Gm-Message-State: AOJu0Yzncqvsuo8mFeGj8Vyw1Zp63h001tgp9D6zteuo43MAmwZ9xp3O 1u5nxFUylTkHw0cg33DQMAsPcCMmpd5Vc+OfGC2ri83a6Ks/E7PBQB9FkzHvb673VKfxlIoWTSn K X-Received: by 2002:a05:6870:8a0f:b0:23c:6020:6733 with SMTP id p15-20020a0568708a0f00b0023c60206733mr6514806oaq.27.1714434040496; Mon, 29 Apr 2024 16:40:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:40:40 -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 6/7] staging: iio: impedance-analyzer: ad5933: Use devm_regulator_get_enable_read_voltage() Date: Mon, 29 Apr 2024 18:40:14 -0500 Message-ID: <20240429-regulator-get-enable-get-votlage-v2-6-b1f11ab766c1@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240429-regulator-get-enable-get-votlage-v2-0-b1f11ab766c1@baylibre.com> References: <20240429-regulator-get-enable-get-votlage-v2-0-b1f11ab766c1@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_read_voltage(). Reviewed-by: Jonathan Cameron Signed-off-by: David Lechner --- v2 changes: * fixed wrong driver name in patch subject * renamed to devm_regulator_get_enable_read_voltage() * restored error message --- drivers/staging/iio/impedance-analyzer/ad5933.c | 26 ++----------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 9149d41fe65b..b7af5fe63e09 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -84,7 +84,6 @@ struct ad5933_state { struct i2c_client *client; - struct regulator *reg; struct clk *mclk; struct delayed_work work; struct mutex lock; /* Protect sensor state */ @@ -660,13 +659,6 @@ static void ad5933_work(struct work_struct *work) } } -static void ad5933_reg_disable(void *data) -{ - struct ad5933_state *st = data; - - regulator_disable(st->reg); -} - static int ad5933_probe(struct i2c_client *client) { const struct i2c_device_id *id = i2c_client_get_device_id(client); @@ -685,23 +677,9 @@ static int ad5933_probe(struct i2c_client *client) mutex_init(&st->lock); - st->reg = devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) { - dev_err(&client->dev, "Failed to enable specified VDD supply\n"); - return ret; - } - - ret = devm_add_action_or_reset(&client->dev, ad5933_reg_disable, st); - if (ret) - return ret; - - ret = regulator_get_voltage(st->reg); + ret = devm_regulator_get_enable_read_voltage(&client->dev, "vdd"); if (ret < 0) - return ret; + return dev_err_probe(&client->dev, ret, "failed to get vdd voltage\n"); st->vref_mv = ret / 1000; -- 2.43.2