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] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 4 Feb 2014 12:36:30 +0100
From:	Pavel Machek <pavel@....cz>
To:	Jenny TC <jenny.tc@...el.com>
Cc:	linux-kernel@...r.kernel.org,
	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	Anton Vorontsov <cbouatmailru@...il.com>,
	Anton Vorontsov <anton.vorontsov@...aro.org>,
	Kim Milo <Milo.Kim@...com>, Lee Jones <lee.jones@...aro.org>,
	Jingoo Han <jg1.han@...sung.com>,
	Chanwoo Choi <cw00.choi@...sung.com>,
	Sachin Kamat <sachin.kamat@...aro.org>,
	Lars-Peter Clausen <lars@...afoo.de>,
	Pali Rohár <pali.rohar@...il.com>,
	Rhyland Klein <rklein@...dia.com>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	David Woodhouse <dwmw2@...radead.org>,
	Tony Lindgren <tony@...mide.com>,
	Russell King <linux@....linux.org.uk>,
	Sebastian Reichel <sre@...g0.de>, aaro.koskinen@....fi,
	Pallala Ramakrishna <ramakrishna.pallala@...el.com>,
	freemangordon@....bg, linux-omap@...r.kernel.org
Subject: Re: [PATCH 2/4] power_supply: Introduce generic psy charging driver

Hi!

> +Throttling configuration example:
> +
> +struct psy_throttle_state my_throttle_states[] = {
> +
> +	/* Level 0:  Limit charge current to 1500mA. Normal Level */
> +	{
> +		.throttle_action = PSY_THROTTLE_CC_LIMIT,
> +		.throttle_val = 1500,
> +	},
> +
> +	/* Level 1: Limit charge current to 500mA */
> +	{
> +		.throttle_action = PSY_THROTTLE_CC_LIMIT,
> +		.throttle_val = 500,
> +	},
> +
> +	/*
> +	* Level 2: Disable charging: Stop charging, charger supply power to
> +	* platform.
> +	*/
> +	{
> +		.throttle_action = PSY_THROTTLE_DISABLE_CHARGING,
> +	},
> +
> +	/* Level 3: Disable charger: Battery start discharging */
> +	{
> +		.throttle_action = PSY_THROTTLE_DISABLE_CHARGER,
> +	},
> +
> +};


Does it make sense to have throttling description as a data, as
opposed to normal C code?

> +struct psy_charger_context {
> +	bool is_usb_cable_evt_reg;
> +	int psyc_cnt;
> +	int batt_status;
> +	/*cache battery and charger properties */

Comment coding style. Please run you patches through checkpatch.

> +	struct list_head evt_queue;
> +	struct mutex evt_lock;
> +	struct list_head event_queue;
> +	struct psy_batt_chrg_prof batt_property;

Again, please use full words in variable names. How am I supposed to
know what evt_queue is? Especially when you have event_queue, also?!

And please do it globally.

> +static void __power_supply_trigger_charging_handler(struct power_supply *psy)
> +{
> +	int i;
> +	struct power_supply *psb = NULL;
> +
> +
> +	if (is_trigger_charging_algo(psy)) {
> +		if (psy_is_battery(psy)) {
> +			if (trigger_algo(psy))
> +				enable_supplied_by_charging(psy, false);
> +			else
> +				enable_supplied_by_charging(psy, true);
> +		} else if (psy_is_charger(psy)) {
> +			for (i = 0; i < psy->num_supplicants; i++) {
> +				psb =
> +				    power_supply_get_by_name(psy->
> +							     supplied_to[i]);
> +
> +				if (psb && psy_is_battery(psb) &&
> +							psy_is_present(psb)) {
> +					if (trigger_algo(psb)) {
> +						psy_disable_charging(psy);
> +						break;
> +					} else if
> +						(psy_is_charging_can_be_enabled
> +								(psy)) {
> +						psy_enable_charging(psy);
> +						wait_for_charging_enabled(psy);
> +					}
> +				}
> +			}
> +		}
> +		update_sysfs(psy);
> +		power_supply_changed(psy);
> +	}
> +}

See coding style about excessive nesting. Please fix it globally.

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ