lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 1 Feb 2019 11:38:06 +0100
From:   Stefan Wahren <stefan.wahren@...e.com>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     Kamil Debski <kamil@...as.org>,
        Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
        Jean Delvare <jdelvare@...e.com>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] hwmon: pwm-fan: Add optional regulator support

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 <stefan.wahren@...e.com>
>> ---
>>  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 <linux/of.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/pwm.h>
>> +#include <linux/regulator/consumer.h>
>>  #include <linux/sysfs.h>
>>  #include <linux/thermal.h>
>>  
>> @@ -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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ