Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755482AbbLGF1I (ORCPT ); Mon, 7 Dec 2015 00:27:08 -0500 Received: from mail-yk0-f173.google.com ([209.85.160.173]:33771 "EHLO mail-yk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754696AbbLGF1F (ORCPT ); Mon, 7 Dec 2015 00:27:05 -0500 MIME-Version: 1.0 In-Reply-To: <20151205162721.GB30410@earth> References: <2ae29947ff92198d5613bfb2b925f3f4ba3b2a53.1447654606.git.baolin.wang@linaro.org> <20151205162721.GB30410@earth> Date: Mon, 7 Dec 2015 13:27:03 +0800 Message-ID: Subject: Re: [PATCH v6 1/4] gadget: Introduce the usb charger framework From: Baolin Wang To: Sebastian Reichel Cc: Felipe Balbi , Greg KH , Dmitry Eremin-Solenikov , David Woodhouse , Peter Chen , Alan Stern , r.baldyga@samsung.com, yoshihiro.shimoda.uh@renesas.com, Lee Jones , Mark Brown , ckeepax@opensource.wolfsonmicro.com, patches@opensource.wolfsonmicro.com, linux-pm@vger.kernel.org, USB , device-mainlining@lists.linuxfoundation.org, LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2015 Lines: 60 On 6 December 2015 at 00:27, Sebastian Reichel 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/