Linux Power Management development
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: balbi@ti.com, gregkh@linuxfoundation.org, dbaryshkov@gmail.com,
	dwmw2@infradead.org, peter.chen@freescale.com,
	stern@rowland.harvard.edu, r.baldyga@samsung.com,
	yoshihiro.shimoda.uh@renesas.com, lee.jones@linaro.org,
	broonie@kernel.org, ckeepax@opensource.wolfsonmicro.com,
	patches@opensource.wolfsonmicro.com, linux-pm@vger.kernel.org,
	linux-usb@vger.kernel.org,
	device-mainlining@lists.linuxfoundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework
Date: Sat, 5 Dec 2015 17:27:21 +0100	[thread overview]
Message-ID: <20151205162721.GB30410@earth> (raw)
In-Reply-To: <2ae29947ff92198d5613bfb2b925f3f4ba3b2a53.1447654606.git.baolin.wang@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-12-05 16:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16  6:33 [PATCH v6 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang
2015-11-16  6:33 ` [PATCH v6 1/4] gadget: Introduce the usb charger framework Baolin Wang
2015-12-05 16:27   ` Sebastian Reichel [this message]
2015-12-07  5:27     ` Baolin Wang
2015-11-16  6:33 ` [PATCH v6 2/4] gadget: Support for " Baolin Wang
2015-11-16  6:33 ` [PATCH v6 3/4] gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang
2015-11-16  6:33 ` [PATCH v6 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang
2015-11-16 16:24   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151205162721.GB30410@earth \
    --to=sre@kernel.org \
    --cc=balbi@ti.com \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=dbaryshkov@gmail.com \
    --cc=device-mainlining@lists.linuxfoundation.org \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=peter.chen@freescale.com \
    --cc=r.baldyga@samsung.com \
    --cc=stern@rowland.harvard.edu \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox