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:	Sat, 5 Dec 2015 17:27:21 +0100
From:	Sebastian Reichel <sre@...nel.org>
To:	Baolin Wang <baolin.wang@...aro.org>
Cc:	balbi@...com, gregkh@...uxfoundation.org, dbaryshkov@...il.com,
	dwmw2@...radead.org, peter.chen@...escale.com,
	stern@...land.harvard.edu, r.baldyga@...sung.com,
	yoshihiro.shimoda.uh@...esas.com, lee.jones@...aro.org,
	broonie@...nel.org, ckeepax@...nsource.wolfsonmicro.com,
	patches@...nsource.wolfsonmicro.com, linux-pm@...r.kernel.org,
	linux-usb@...r.kernel.org,
	device-mainlining@...ts.linuxfoundation.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework

Hi,

On Mon, Nov 16, 2015 at 02:33:31PM +0800, Baolin Wang wrote:
> +static ssize_t cur_limit_show(struct device *dev,
> +			      struct device_attribute *attr,
> +			      char *buf)
> +{
> +	struct usb_charger *uchger = dev_to_uchger(dev);
> +
> +	return scnprintf(buf, PAGE_SIZE, "%d %d %d %d\n",
> +			 uchger->cur_limit.sdp_cur_limit,
> +			 uchger->cur_limit.dcp_cur_limit,
> +			 uchger->cur_limit.cdp_cur_limit,
> +			 uchger->cur_limit.aca_cur_limit);
> +}
> +
> +static ssize_t cur_limit_store(struct device *dev,
> +			       struct device_attribute *attr,
> +			       const char *buf, size_t count)
> +{
> +	struct usb_charger *uchger = dev_to_uchger(dev);
> +	struct usb_charger_cur_limit cur;
> +	int ret;
> +
> +	ret = sscanf(buf, "%d %d %d %d",
> +		     &cur.sdp_cur_limit, &cur.dcp_cur_limit,
> +		     &cur.cdp_cur_limit, &cur.aca_cur_limit);
> +	if (ret == 0)
> +		return -EINVAL;
> +
> +	ret = usb_charger_set_cur_limit(uchger, &cur);
> +	if (ret < 0)
> +		return ret;
> +
> +	return count;
> +}
> +static DEVICE_ATTR_RW(cur_limit);

I think this functionality should be provided with one file per
type. This makes it easier to parse the values from userspace
and makes it possible to extend the frameworks functionality
(e.g. when new types are added in a newer revision of the USB
standard).

-- Sebastian

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ