Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F343C742A7 for ; Wed, 8 Mar 2023 11:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbjCHLN1 (ORCPT ); Wed, 8 Mar 2023 06:13:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjCHLNY (ORCPT ); Wed, 8 Mar 2023 06:13:24 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC332200F; Wed, 8 Mar 2023 03:13:22 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id q11-20020a056830440b00b00693c1a62101so8792636otv.0; Wed, 08 Mar 2023 03:13:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678274002; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=S/SG6WOmPhOG71pPi5Yr9q4aa/gX/p7YkTAPW6zFDIc=; b=X5VImF6iyuON7wQbt/hgP5hAcIrRHVHyWGIQN47mTDS3wJE+geuIIQWk0Bb29Fo0js 1DaHsOUOJnkddj3+4HGYKBcoMKVwr/dyfa6zYYTadHEaw/I1dTS2rJr0cMl5YuqS6VlS wZetyyqJujU9l5yByig8Dk6FnibDmK6G/tm4Daf5mlM7MZzMrOmolksypaVCOuKSPhKa FkvfB3rsIPeLOhJnvUba3Ff1r8Zp2g9b6BwuYKKNi2Ajdg17Ja7bEFlSxDGbN0U0Y1nX Oz5GHmoBgGXadpi9ACdqGJpkJIUvm6w5IHO3AJGgBlltvrdJuyKn6fcPPdeaXhlLe5Rz XiDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678274002; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S/SG6WOmPhOG71pPi5Yr9q4aa/gX/p7YkTAPW6zFDIc=; b=trpCuv+U+BtNagdE+xX3JITJFDeCyXGpQYm3HVLIhqNloGc7UqucAbg0LMrmeNzaHA ps/p4EP6KPIkxINRVGKyNgmJAYabrO4X7HKzsoBUX+aTKmGiuy7mVX7NL+WfoMCMVvMI OUO/z8qj7UBfKlSzqKxBSocRApQwHeG9akCeO2Ra7TtOsOpSPr7XF16lymIpEocDHh/v dqvNWm8cLbl08TJknCPiqkFDxD5ot6bngerWk7bP+qxvpIsGQA4/R30t9by560kaIEXx Jylq1U/t1+oXU46fRQkkMKWxM7MJtHqN9cK+8ABVtyZHJBgvCT9v9KcyT3GWStj7PkyI 2jIA== X-Gm-Message-State: AO0yUKW9V9Txof0ejFGSGl/McPtJrU1H4KK6hvMLzirmar7D3I5S1wYq 23kJKZUBwVcb4bwJxLEW+j0= X-Google-Smtp-Source: AK7set9VrBcrbK9lcrHwfsTbcu29MFWbWFH4ZXvocllXC900l1IaHbqInI9Xg/9Y1VIfXDaKOOuS7Q== X-Received: by 2002:a9d:7105:0:b0:684:c3ad:962f with SMTP id n5-20020a9d7105000000b00684c3ad962fmr7793475otj.7.1678274001991; Wed, 08 Mar 2023 03:13:21 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k3-20020a9d4b83000000b00690e6d56670sm6428791otf.25.2023.03.08.03.13.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Mar 2023 03:13:21 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Wed, 8 Mar 2023 03:13:18 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v1 2/2] hwmon: ina2xx: add optional regulator support Content-Language: en-US To: Svyatoslav Ryhel , Krzysztof Kozlowski Cc: Jean Delvare , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230308094024.14115-1-clamor95@gmail.com> <20230308094024.14115-3-clamor95@gmail.com> <378db0d7-4d5a-a445-3e1a-ee6d8da5a9e2@linaro.org> From: Guenter Roeck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/8/23 02:35, Svyatoslav Ryhel wrote: > ср, 8 бер. 2023 р. о 12:25 Krzysztof Kozlowski > пише: >> >> On 08/03/2023 10:40, Svyatoslav Ryhel wrote: >>> Some devices may need a specific supply provided >>> for this sensor to work properly, like p895 does. >>> >>> Signed-off-by: Svyatoslav Ryhel >>> --- >>> drivers/hwmon/ina2xx.c | 12 ++++++++++++ >>> 1 file changed, 12 insertions(+) >>> >>> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c >>> index 00fc70305a89..4a3e2b1bbe8b 100644 >>> --- a/drivers/hwmon/ina2xx.c >>> +++ b/drivers/hwmon/ina2xx.c >>> @@ -119,6 +119,7 @@ struct ina2xx_data { >>> long power_lsb_uW; >>> struct mutex config_lock; >>> struct regmap *regmap; >>> + struct regulator *vdd_supply; >>> >>> const struct attribute_group *groups[INA2XX_MAX_ATTRIBUTE_GROUPS]; >>> }; >>> @@ -656,6 +657,17 @@ static int ina2xx_probe(struct i2c_client *client) >>> return PTR_ERR(data->regmap); >>> } >>> >>> + data->vdd_supply = devm_regulator_get_optional(dev, "vdd"); >>> + if (IS_ERR(data->vdd_supply)) >>> + return dev_err_probe(dev, PTR_ERR(data->vdd_supply), >>> + "failed to get vdd regulator\n"); >>> + >>> + ret = regulator_enable(data->vdd_supply); >>> + if (ret < 0) { >>> + dev_err(dev, "failed to enable vdd power supply\n"); >>> + return ret; >> >> And where is disable? On each error path, removal etc. >> > > error path ok, should I create a remove function just to disable the regulator? > Use devm_add_action_or_reset(). Guenter >> Best regards, >> Krzysztof >>