Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1284572 > unrolled thread

Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework

Started bySebastian Reichel <sre@kernel.org>
First post2015-12-05 17:30 +0100
Last post2015-12-07 06:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework Sebastian Reichel <sre@kernel.org> - 2015-12-05 17:30 +0100
    Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework Baolin Wang <baolin.wang@linaro.org> - 2015-12-07 06:30 +0100

#1284572 — Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework

FromSebastian Reichel <sre@kernel.org>
Date2015-12-05 17:30 +0100
SubjectRe: [PATCH v6 1/4] gadget: Introduce the usb charger framework
Message-ID<qCnSF-3my-1@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [next] | [standalone]


#1285012

FromBaolin Wang <baolin.wang@linaro.org>
Date2015-12-07 06:30 +0100
Message-ID<qCWx3-eR-5@gated-at.bofh.it>
In reply to#1284572
On 6 December 2015 at 00:27, Sebastian Reichel <sre@kernel.org> wrote:
> 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).
>

That sounds reasonable and I'll change that. Thanks.

> -- Sebastian



-- 
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web