Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp246078ima; Fri, 1 Feb 2019 02:41:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IYINTyFPU0hILZArzcJZFPsbl9j8oEu9A+xKh9Y9rn6bJ4h+IBEb/oftNHX67Kic5l8/l2m X-Received: by 2002:a63:f94c:: with SMTP id q12mr1637264pgk.91.1549017688518; Fri, 01 Feb 2019 02:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549017688; cv=none; d=google.com; s=arc-20160816; b=yIIMrTvDT33S3UtYrpNCdNgwBDyxB+aVIRF8T0EQu9v/1BfOvNUzj4UFS8mYSr7Uoj dkU4F3X2wMXYfTupaEQuyud3UfJSh32OJT3Lt+9GeY3XFlD+txTYmtFZ/E9jbtNtEi1h +zAXYAsRmTlzEltAEtvzQ8lrVIHkK446UW59JEveojTK93qLR90LiyJ1kvqrJ5aQGMm6 I2A3uhYccutIOs6dscKfoGIN21sbxkEl4k4xvdCommM7Sjo8OeKPf0iwwEeROz/Z2ZNS rbL2NuFF2CbjY0f7pmywoPJ85Ll90kBvxQeae1mSZHWzgrp73X0bfnCwjd301ZGr8u8a tNbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=R1tWhegF95Ycb1ff3/hmKZRxh9qQ/h+QlVabzpucfVk=; b=IQ0pT/3yjXRo+PoQ88EcNbeeKWJECCm9z9gRbqdl3qchC29tm9hHEZjahpL0CnGaNu 4NqzmF11NgqY9/LxleZcOFovc20NzwpuipYpDAgq0ei1y5IY18XyhTlywYMA5OqPqsIU GUVTKvfcL6Dk7qES49RoU9lW/kSisdrxHs+KuGuOHbqyViMc4fUyCdaqcoeEZh3wtZ2n d9C8h/niR5dRB7FNbgzhOuTXdtk8D5KfoDk53ZaKX9iIoU7UgOVy/v3sOumQEzGHAJ14 SU7iVxMVOYZghN7ZrdBlEcmVg5jhbfsvIKm9g+XEGTmvJnQtT94yGbwhX+2mgB0wLSrf ZiHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si372815pgs.17.2019.02.01.02.41.12; Fri, 01 Feb 2019 02:41:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729754AbfBAKjD (ORCPT + 99 others); Fri, 1 Feb 2019 05:39:03 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:52111 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728225AbfBAKjD (ORCPT ); Fri, 1 Feb 2019 05:39:03 -0500 Received: from [192.168.178.52] ([109.104.54.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTznO-1ghJ2329Lu-00Qzyb; Fri, 01 Feb 2019 11:38:09 +0100 Subject: Re: [PATCH 2/2] hwmon: pwm-fan: Add optional regulator support To: Guenter Roeck Cc: Kamil Debski , Bartlomiej Zolnierkiewicz , Jean Delvare , Rob Herring , Mark Rutland , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1548781631-5736-1-git-send-email-stefan.wahren@i2se.com> <1548781631-5736-2-git-send-email-stefan.wahren@i2se.com> <20190131175651.GA16231@roeck-us.net> From: Stefan Wahren Message-ID: <2c05a0dc-6e5a-97a7-bc79-f01275fe956c@i2se.com> Date: Fri, 1 Feb 2019 11:38:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190131175651.GA16231@roeck-us.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:FQhik6GlkG+GRHwI71D6o38ToirX14WEn7lWHN+O921h12g2SM4 QXrTSwWbaJW+XufOW6C2jT2pA6LfJ2zy3UJyxOMPZwFxOrSUuL7z71Zi4P7X8DuY7r8Fyx3 zGBKmCb8xdTgKNn9zmTzfbfRaDFeU+oOsXY/3orGhCEhGOhgYsZ6sInzmFDabDe0A03RFMh hWErOFgxUYgdBrK5tOsZQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:ApUoyVgIt/s=:U9HybeiVYat0tmxGIawnBy YbIAHQwnImgYCFNJvKgdfrIjFcxYoVnidAbuSP1Jdk7wb+Swl3Z/yHJahRBlQQ2LD0Bf2P+X9 3zVvl6WY58FVKa9Uj1CZX85s2SKbFw3BQP5MSCjkkwrQPRw1h4pRRw980TY+BVXkWO1SjI2fd YkaMNlR4f4y+4cR5iHAIVyMS9GYIfjK+OwJ5OYxTFg27+F6MfeKLO12HVaBIt06kLkPgzc9QA OeKtgDbq/Krise3eqzggpvrf8+R6TNtUsMPm2NS0dchopzFfJPDYvCUwHrCFIjram4RhoP+jb gNdVDGf1pDx/50TUZ7viYeFSXuZCwhb4ahuylbKfiSnVNKH1v1hX8cl20Vk6YihzqZ8k038zM sHC+2GfpoEvfKL6l5sAU9NiiYzQSn9kh57kzs6VusBgVi/dcKjGmbrCXyPRVq+Fxf0A9/07zb bkSXbLlEj9FdhKyfAlpAXlgM6GaBUzsB9fLZh5upiUk2nnpOrz/Izykkaq4gM7zDYltSdAuUB rfVgiR2uN5SjPDpkoajhYDOgRzhC0uVjGhTErbbrg6WX3Yhh3cSaOGCVJNae5FGkR8I6dxCBl mx9evL+o4WGlUz6/WkZc4pGfJXxZ3Sza/4AEQSQ7eZ2OvZ1p54ij/nkkWMph/sSTT2BEomgeo 8mPTVM2zKCFKnAiREN2zrRGeCZvsTNrFN9QI6WR9FQ99n6mSXEPK1JwOxrOvtLm8cD+vR2u7s 0Sb/A/q46rY6qyF9Wdu3MuaMJCnm4yBK11hWiyENr3uFBiMC3C4OWZQyhXc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, Am 31.01.19 um 18:56 schrieb Guenter Roeck: > On Tue, Jan 29, 2019 at 06:07:11PM +0100, Stefan Wahren wrote: >> This adds optional regulator support to the pwm-fan driver. This is >> necessary for pwm fans which are powered by a switchable supply. >> >> Signed-off-by: Stefan Wahren >> --- >> drivers/hwmon/pwm-fan.c | 35 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 35 insertions(+) >> >> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c >> index 2c94482..9e0591e 100644 >> --- a/drivers/hwmon/pwm-fan.c >> +++ b/drivers/hwmon/pwm-fan.c >> @@ -23,6 +23,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> >> @@ -31,6 +32,7 @@ >> struct pwm_fan_ctx { >> struct mutex lock; >> struct pwm_device *pwm; >> + struct regulator *reg_en; >> unsigned int pwm_value; >> unsigned int pwm_fan_state; >> unsigned int pwm_fan_max_state; >> @@ -244,6 +246,23 @@ static int pwm_fan_probe(struct platform_device *pdev) >> return ret; >> } >> >> + ctx->reg_en = devm_regulator_get_optional(&pdev->dev, "fan"); >> + if (!IS_ERR(ctx->reg_en)) { > It is customary to handle the error case first. > >> + ret = regulator_enable(ctx->reg_en); >> + if (ret) >> + dev_err(&pdev->dev, >> + "Failed to enable fan supply: %d\n", ret); >> + } else { >> + switch (PTR_ERR(ctx->reg_en)) { >> + case -ENODEV: >> + case -ENOSYS: > Does devm_regulator_get_optional() ever return -ENOSYS ? > I glanced through other calls to devm_regulator_get_optional(), > but I don't see that check anywhere. sorry, i mixed this up with. In case CONFIG_REGULATOR=n we are getting -ENODEV. Thanks Stefan