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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 15 Mar 2020 12:00:35 +0100
From:   Tobias Schramm <t.schramm@...jaro.org>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Tobias Schramm <t.schramm@...jaro.org>
Cc:     Sebastian Reichel <sre@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Daniel Thompson <daniel.thompson@...aro.org>,
        Maxime Ripard <mripard@...nel.org>,
        Sam Ravnborg <sam@...nborg.org>,
        Heiko Stuebner <heiko.stuebner@...obroma-systems.com>,
        Stephan Gerhold <stephan@...hold.net>,
        Mark Brown <broonie@...nel.org>,
        Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        linux-pm@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 3/3] power: supply: add CellWise cw2015 fuel gauge
 driver

Hi Andy,

thanks for your feedback. Please find my comments inline.

> 
>> +				dev_err(cw_bat->dev,
>> +					 "Failed to upload battery info\n");
> 
> Indentation of the second line.
> 
I've seen quite a few different indentation styles used in kernel
source. Personally I'd indent like this:

		dev_warn(cw_bat->dev,
			 "some long error message");

However coding-style.rst specifies that spaces are never to be used for
indentation. May I assume they are ok for alignment though?


> And I'm thinking that we may refactor this function. So,
> 
> 	length = ..._count_u8(...);
> 	if (length < 0) {
> 		dev_warn(...);
> 	} else if (length != ...) {
> 		dev_err(...);
> 		...
> 	} else {
> 		...
> 	}
> 
> 
> 
>> +		if (length != CW2015_SIZE_BATINFO) {
>> +			dev_err(cw_bat->dev, "battery-profile must be %d bytes",
>> +				CW2015_SIZE_BATINFO);
>> +			return -EINVAL;
>> +		}
>> +
>> +		cw_bat->bat_profile = devm_kzalloc(dev, length, GFP_KERNEL);
>> +		if (!cw_bat->bat_profile) {
>> +			dev_err(cw_bat->dev,
>> +				"Failed to allocate memory for battery config info");
>> +			return -ENOMEM;
>> +		}
>> +
>> +		ret = device_property_read_u8_array(dev,
>> +						"cellwise,battery-profile",
>> +						cw_bat->bat_profile,
>> +						length);
>> +		if (ret)
>> +			return ret;
>> +	} else {
>> +		dev_warn(cw_bat->dev,
>> +			"No battery-profile found, rolling with current flash contents");
>> +	}
>> +
> 
> ...and here...
> 
>> +	cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS;
>> +	ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &value);
>> +	if (ret >= 0) {
>> +		dev_dbg(cw_bat->dev, "Overriding default monitor-interval with %u ms",
>> +			value);
>> +		cw_bat->poll_interval_ms = value;
>> +	}
> 
> 	ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &cw_bat->poll_interval_ms);
> 	if (ret) {
> 		dev_dbg(cw_bat->dev, "Use default\n");
> 		cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS;
> 	}
> 
> What do you think?
> 
Looks good to me. I'll use it just like that.

> 
>> +	int ret;
>> +	struct cw_battery *cw_bat;
> 
>> +	struct power_supply_config psy_cfg = { };
> 
> Don't you need 0 here?
> 
Yeah, that would be better. Think empty initializers are a GNU extension.


Best Regards,

Tobias

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ