Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2699294imc; Sat, 23 Feb 2019 09:04:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKWH1FSajjlgoF/aa3E2s6qve9CHyTm92yPiI+nBukgmduHYSbU7sEQWA6dznWmHBfY4O0 X-Received: by 2002:a62:4ec5:: with SMTP id c188mr10316245pfb.230.1550941492965; Sat, 23 Feb 2019 09:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550941492; cv=none; d=google.com; s=arc-20160816; b=uR1NjM3c1Ch9Ap3uDCjaL201fpenOgQyWiLfW7YB4NUTZ7Wa8nN8M/85wTRmdUS/yC YXLE60P5OPmad1OO4g4RisPyUSQZEUTI9pPmIbH5pM28XxFVOvDpuKLA6jJFp40Ugqui 6TjrTivuRRJ5MmxjAMqDLZ75J+ikR2IDNtNIYX6Llhb3uYnYOMgwlKUMZSrI8Bc+2Zsx vsKRiHqnaItliL4t1FK5HwxASpvrB+wWLtS8qappViKBEEiqdSFYJp3riCCsd8/BSoCR L/979HOWPqQQMV1Josaaj9yyxTvnUnfcc6eJkhPnEgm4kqOwMEitkAe6QATCMx13UsXG 83+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JKQkewid9S+ZnRN5ogKVvGR/1DZ82vhJpgTsx5PShUI=; b=awZDpwMvuiumi8EQYRvXeMVgK7qdbu0iKkdy7ival37IaqrfQBozmjISW/dHJGTEBa wpVdt8I2q7XxSyiKonp5d62x4gITCkVOsB1ivWFq+kD0xVefQNNtWl9YDUpS6G5fwwXk Ffbu3zobexX2WrPXYMAgQ15pMVcpsVAcI9tglNIrgW33ETKeNo3dwIJyu/ZyYEsO3tBm OhCgVG/K67+w2rTuLx+VYDjfSihDTiLuXKqzyfAte82D9s80Z/gvosVCyCA4iW7cV1Ph oo3k7eE/IxXG/gPQZ+bRzoaqu/MT6VjGhqmK+52hwb5N3iK4GhAtesi80BJbABxDjpln qQMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="O/LZ7hLp"; 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 m5si4166897plt.12.2019.02.23.09.04.37; Sat, 23 Feb 2019 09:04:52 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b="O/LZ7hLp"; 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 S1727719AbfBWRDk (ORCPT + 99 others); Sat, 23 Feb 2019 12:03:40 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35971 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbfBWRDj (ORCPT ); Sat, 23 Feb 2019 12:03:39 -0500 Received: by mail-pl1-f194.google.com with SMTP id k2so2529122plt.3; Sat, 23 Feb 2019 09:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JKQkewid9S+ZnRN5ogKVvGR/1DZ82vhJpgTsx5PShUI=; b=O/LZ7hLpNCit6VNRuQvNbdVblcanInuw92aAUAbSFxyrbQV+Ox/pebSXEvtiN+iRRr 9mAtk70iJONDkjf8iE/kZuerWm/janmk6ShoI0ZkRuRcD/jN4sPIuFudSVObwvsahVQw oyEDM3jlcS3F7Ug1XxVhKzLSGZhpXx6JrBOanhWg5zrZ4k6Wf99OdaKgnKdbNhO1Ia16 KvcQRt0Gw0q0krltpVUL7GmXN5bScGINjfhLzFqyHsn+QWmsg1zaB7yda1dl2Ck1DP6b hccNecVi2WkMdae7tYRFxB+mjPuoV7vYq8o/QYzxaN0mX2ngBjvyxHyrZjzJfnoMEFLl F/jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=JKQkewid9S+ZnRN5ogKVvGR/1DZ82vhJpgTsx5PShUI=; b=rDttIc/GunlFpKLZ66x94IX67bE/7yeb1Iq+B4+YFVdVO+n1JY5oorXeSS4sieekiH u05jzm3Om4ojj1pF0WSp0hlP5f4oAThwa68MVziAdlIrzbTRI5mKNiqfxvtykjKqtYsC uR4myKS4longEVZxqwpQZppB5g50ivmTi3ThEM1ci5a3mOtEBDM0b6w6v/wURv0At1fq UO5c0wRv1GZ8h7nBdlAbRG8n2LzE44hkDiNTZHSqM9OeFRSMY15cEGHxg03aWmlCnMYJ 99KY4cE0lOL9nKWQQIGGFjtEICdnKKgAYlTJKffcOh0bKxTatd4LaZFdtQYHHP05KUip 5dTg== X-Gm-Message-State: AHQUAuZQ+ssjyMTIFovaeSww+OGhLl2llZts6JrEyz/94mmDbS/uFy/3 W3zJ8U/VYb4vlGXehFMVXTQ= X-Received: by 2002:a17:902:87:: with SMTP id a7mr416906pla.295.1550941418664; Sat, 23 Feb 2019 09:03:38 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t71sm5681349pgd.15.2019.02.23.09.03.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Feb 2019 09:03:38 -0800 (PST) Date: Sat, 23 Feb 2019 09:03:37 -0800 From: Guenter Roeck To: Stefan Wahren 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 Subject: Re: [PATCH V3 2/2] hwmon: pwm-fan: Add optional regulator support Message-ID: <20190223170337.GA14857@roeck-us.net> References: <1550843124-10992-1-git-send-email-stefan.wahren@i2se.com> <1550843124-10992-3-git-send-email-stefan.wahren@i2se.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550843124-10992-3-git-send-email-stefan.wahren@i2se.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 22, 2019 at 02:45:24PM +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 Applied to hwmon-next. Thanks, Guenter > --- > drivers/hwmon/pwm-fan.c | 43 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c > index 2c94482..167221c 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; > @@ -231,6 +233,21 @@ static int pwm_fan_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, ctx); > > + ctx->reg_en = devm_regulator_get_optional(&pdev->dev, "fan"); > + if (IS_ERR(ctx->reg_en)) { > + if (PTR_ERR(ctx->reg_en) != -ENODEV) > + return PTR_ERR(ctx->reg_en); > + > + ctx->reg_en = NULL; > + } else { > + ret = regulator_enable(ctx->reg_en); > + if (ret) { > + dev_err(&pdev->dev, > + "Failed to enable fan supply: %d\n", ret); > + return ret; > + } > + } > + > ctx->pwm_value = MAX_PWM; > > /* Set duty cycle to maximum allowed and enable PWM output */ > @@ -241,7 +258,7 @@ static int pwm_fan_probe(struct platform_device *pdev) > ret = pwm_apply_state(ctx->pwm, &state); > if (ret) { > dev_err(&pdev->dev, "Failed to configure PWM\n"); > - return ret; > + goto err_reg_disable; > } > > hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan", > @@ -277,6 +294,10 @@ static int pwm_fan_probe(struct platform_device *pdev) > state.enabled = false; > pwm_apply_state(ctx->pwm, &state); > > +err_reg_disable: > + if (ctx->reg_en) > + regulator_disable(ctx->reg_en); > + > return ret; > } > > @@ -287,6 +308,10 @@ static int pwm_fan_remove(struct platform_device *pdev) > thermal_cooling_device_unregister(ctx->cdev); > if (ctx->pwm_value) > pwm_disable(ctx->pwm); > + > + if (ctx->reg_en) > + regulator_disable(ctx->reg_en); > + > return 0; > } > > @@ -307,6 +332,14 @@ static int pwm_fan_suspend(struct device *dev) > pwm_disable(ctx->pwm); > } > > + if (ctx->reg_en) { > + ret = regulator_disable(ctx->reg_en); > + if (ret) { > + dev_err(dev, "Failed to disable fan supply: %d\n", ret); > + return ret; > + } > + } > + > return 0; > } > > @@ -317,6 +350,14 @@ static int pwm_fan_resume(struct device *dev) > unsigned long duty; > int ret; > > + if (ctx->reg_en) { > + ret = regulator_enable(ctx->reg_en); > + if (ret) { > + dev_err(dev, "Failed to enable fan supply: %d\n", ret); > + return ret; > + } > + } > + > if (ctx->pwm_value == 0) > return 0; >