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


Groups > linux.kernel > #1263933 > unrolled thread

[PATCH v5 0/5] Introduce usb charger framework to deal with the usb gadget power negotation

Started byBaolin Wang <baolin.wang@linaro.org>
First post2015-11-06 12:40 +0100
Last post2015-11-09 03:10 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v5 0/5] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang <baolin.wang@linaro.org> - 2015-11-06 12:40 +0100
    [PATCH v5 1/5] gadget: Introduce the notifier functions Baolin Wang <baolin.wang@linaro.org> - 2015-11-06 12:40 +0100
      Re: [PATCH v5 1/5] gadget: Introduce the notifier functions kbuild test robot <lkp@intel.com> - 2015-11-06 13:40 +0100
      Re: [PATCH v5 1/5] gadget: Introduce the notifier functions Greg KH <gregkh@linuxfoundation.org> - 2015-11-06 18:00 +0100
        Re: [PATCH v5 1/5] gadget: Introduce the notifier functions Mark Brown <broonie@kernel.org> - 2015-11-06 22:30 +0100
        Re: [PATCH v5 1/5] gadget: Introduce the notifier functions Baolin Wang <baolin.wang@linaro.org> - 2015-11-09 03:10 +0100

#1263933 — [PATCH v5 0/5] Introduce usb charger framework to deal with the usb gadget power negotation

FromBaolin Wang <baolin.wang@linaro.org>
Date2015-11-06 12:40 +0100
Subject[PATCH v5 0/5] Introduce usb charger framework to deal with the usb gadget power negotation
Message-ID<qrNx7-3U3-3@gated-at.bofh.it>
Currently the Linux kernel does not provide any standard integration of this
feature that integrates the USB subsystem with the system power regulation
provided by PMICs meaning that either vendors must add this in their kernels
or USB gadget devices based on Linux (such as mobile phones) may not behave
as they should. Thus provide a standard framework for doing this in kernel.

Now introduce one user with wm831x_power to support and test the usb charger,
which is pending testing. Moreover there may be other potential users will use
it in future.

Changes since v4:
 - Flesh out the port type detection which combines the USB negotiation and
 PMICs detection.
 - Supply the notification mechanism to userspace when charger state is changed.
 - Integrate with the vbus staff in the gadget API.

Baolin Wang (5):
  gadget: Introduce the notifier functions
  gadget: Introduce the usb charger framework
  gadget: Support for the usb charger framework
  gadget: Integrate with the usb gadget supporting for usb charger
  power: wm831x_power: Support USB charger current limit management

 drivers/power/wm831x_power.c      |   69 +++++
 drivers/usb/gadget/Kconfig        |    7 +
 drivers/usb/gadget/Makefile       |    1 +
 drivers/usb/gadget/charger.c      |  620 +++++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/udc/udc-core.c |   40 +++
 include/linux/mfd/wm831x/pdata.h  |    3 +
 include/linux/usb/gadget.h        |   27 ++
 include/linux/usb/usb_charger.h   |  152 +++++++++
 8 files changed, 919 insertions(+)
 create mode 100644 drivers/usb/gadget/charger.c
 create mode 100644 include/linux/usb/usb_charger.h

-- 
1.7.9.5

--
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] | [next] | [standalone]


#1263934 — [PATCH v5 1/5] gadget: Introduce the notifier functions

FromBaolin Wang <baolin.wang@linaro.org>
Date2015-11-06 12:40 +0100
Subject[PATCH v5 1/5] gadget: Introduce the notifier functions
Message-ID<qrNx8-3U3-37@gated-at.bofh.it>
In reply to#1263933
The usb charger framework is based on usb gadget. The usb charger
need to be notified the state changing of usb gadget to confirm the
usb charger state.

Thus this patch adds a notifier mechanism for usb gadget to report a
event to usb charger when the usb gadget state is changed.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/usb/gadget/udc/udc-core.c |   32 ++++++++++++++++++++++++++++++++
 include/linux/usb/gadget.h        |   18 ++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index f660afb..4238fc3 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -129,6 +129,32 @@ void usb_gadget_giveback_request(struct usb_ep *ep,
 }
 EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);
 
+int usb_gadget_register_notify(struct usb_gadget *gadget,
+			       struct notifier_block *nb)
+{
+	int ret;
+
+	mutex_lock(&gadget->lock);
+	ret = raw_notifier_chain_register(&gadget->nh, nb);
+	mutex_unlock(&gadget->lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(usb_gadget_register_notify);
+
+int usb_gadget_unregister_notify(struct usb_gadget *gadget,
+				 struct notifier_block *nb)
+{
+	int ret;
+
+	mutex_lock(&gadget->lock);
+	ret = raw_notifier_chain_unregister(&gadget->nh, nb);
+	mutex_unlock(&gadget->lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(usb_gadget_unregister_notify);
+
 /* ------------------------------------------------------------------------- */
 
 /**
@@ -226,6 +252,10 @@ static void usb_gadget_state_work(struct work_struct *work)
 	struct usb_gadget *gadget = work_to_gadget(work);
 	struct usb_udc *udc = gadget->udc;
 
+	mutex_lock(&gadget->lock);
+	raw_notifier_call_chain(&gadget->nh, gadget->state, gadget);
+	mutex_unlock(&gadget->lock);
+
 	if (udc)
 		sysfs_notify(&udc->dev.kobj, NULL, "state");
 }
@@ -364,6 +394,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
 
 	dev_set_name(&gadget->dev, "gadget");
 	INIT_WORK(&gadget->work, usb_gadget_state_work);
+	RAW_INIT_NOTIFIER_HEAD(&gadget->nh);
+	mutex_init(&gadget->lock);
 	gadget->dev.parent = parent;
 
 #ifdef	CONFIG_HAS_DMA
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c14a69b..755e8bc 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -609,6 +609,8 @@ struct usb_gadget {
 	unsigned			out_epnum;
 	unsigned			in_epnum;
 	struct usb_otg_caps		*otg_caps;
+	struct raw_notifier_head	nh;
+	struct mutex			lock;
 
 	unsigned			sg_supported:1;
 	unsigned			is_otg:1;
@@ -1183,6 +1185,22 @@ extern void usb_gadget_unmap_request(struct usb_gadget *gadget,
 
 /*-------------------------------------------------------------------------*/
 
+/**
+ * Register a notifiee to get notified by any attach status changes from
+ * the usb gadget
+ */
+int usb_gadget_register_notify(struct usb_gadget *gadget,
+			       struct notifier_block *nb);
+
+/*-------------------------------------------------------------------------*/
+
+
+/* Unregister a notifiee from the usb gadget */
+int usb_gadget_unregister_notify(struct usb_gadget *gadget,
+				 struct notifier_block *nb);
+
+/*-------------------------------------------------------------------------*/
+
 /* utility to set gadget state properly */
 
 extern void usb_gadget_set_state(struct usb_gadget *gadget,
-- 
1.7.9.5

--
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] | [next] | [standalone]


#1263980 — Re: [PATCH v5 1/5] gadget: Introduce the notifier functions

Fromkbuild test robot <lkp@intel.com>
Date2015-11-06 13:40 +0100
SubjectRe: [PATCH v5 1/5] gadget: Introduce the notifier functions
Message-ID<qrOtc-4v4-23@gated-at.bofh.it>
In reply to#1263934

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

Hi Baolin,

[auto build test WARNING on v4.3-rc7]
[also build test WARNING on next-20151106]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20151106-194008
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/usb/gadget.h:226: warning: No description found for parameter 'claimed'
>> include/linux/usb/gadget.h:628: warning: No description found for parameter 'nh'
>> include/linux/usb/gadget.h:628: warning: No description found for parameter 'lock'
   include/linux/usb/gadget.h:628: warning: No description found for parameter 'quirk_altset_not_supp'
   include/linux/usb/gadget.h:628: warning: No description found for parameter 'quirk_stall_not_supp'
   include/linux/usb/gadget.h:628: warning: No description found for parameter 'quirk_zlp_not_supp'
>> include/linux/usb/gadget.h:1193: warning: No description found for parameter 'gadget'
>> include/linux/usb/gadget.h:1193: warning: No description found for parameter 'nb'
   include/linux/usb/composite.h:501: warning: Excess struct/union/enum/typedef member 'setup_pending' description in 'usb_composite_dev'
   include/linux/usb/composite.h:501: warning: Excess struct/union/enum/typedef member 'os_desc_pending' description in 'usb_composite_dev'
   drivers/usb/gadget/function/f_acm.c:1: warning: no structured comments found
   drivers/usb/gadget/function/f_ecm.c:1: warning: no structured comments found
   drivers/usb/gadget/function/f_subset.c:1: warning: no structured comments found
   drivers/usb/gadget/function/f_obex.c:1: warning: no structured comments found
   drivers/usb/gadget/function/f_serial.c:1: warning: no structured comments found

vim +/nh +628 include/linux/usb/gadget.h

a64cbb7e92 include/linux/usb/gadget.h Baolin Wang     2015-11-06  612  	struct raw_notifier_head	nh;
a64cbb7e92 include/linux/usb/gadget.h Baolin Wang     2015-11-06  613  	struct mutex			lock;
d8318d7f6b include/linux/usb/gadget.h David Cohen     2013-12-09  614  
898c608678 include/linux/usb/gadget.h Felipe Balbi    2011-11-22  615  	unsigned			sg_supported:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  616  	unsigned			is_otg:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  617  	unsigned			is_a_peripheral:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  618  	unsigned			b_hnp_enable:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  619  	unsigned			a_hnp_support:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  620  	unsigned			a_alt_hnp_support:1;
0b2d2bbade include/linux/usb/gadget.h David Cohen     2013-12-09  621  	unsigned			quirk_ep_out_aligned_size:1;
ffd9a0fcbb include/linux/usb/gadget.h Robert Baldyga  2015-07-28  622  	unsigned			quirk_altset_not_supp:1;
02ded1b0d8 include/linux/usb/gadget.h Robert Baldyga  2015-07-28  623  	unsigned			quirk_stall_not_supp:1;
ca1023c81d include/linux/usb/gadget.h Robert Baldyga  2015-07-28  624  	unsigned			quirk_zlp_not_supp:1;
80b2502cea include/linux/usb/gadget.h Peter Chen      2015-01-28  625  	unsigned			is_selfpowered:1;
ccdf138fe3 include/linux/usb/gadget.h Robert Baldyga  2015-05-04  626  	unsigned			deactivated:1;
ccdf138fe3 include/linux/usb/gadget.h Robert Baldyga  2015-05-04  627  	unsigned			connected:1;
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16 @628  };
5702f75375 include/linux/usb/gadget.h Felipe Balbi    2013-07-17  629  #define work_to_gadget(w)	(container_of((w), struct usb_gadget, work))
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  630  
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  631  static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  632  	{ dev_set_drvdata(&gadget->dev, data); }
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  633  static inline void *get_gadget_data(struct usb_gadget *gadget)
^1da177e4c include/linux/usb_gadget.h Linus Torvalds  2005-04-16  634  	{ return dev_get_drvdata(&gadget->dev); }
f48cf80f93 include/linux/usb/gadget.h Fabien Chouteau 2010-04-23  635  static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
f48cf80f93 include/linux/usb/gadget.h Fabien Chouteau 2010-04-23  636  {

:::::: The code at line 628 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1264164 — Re: [PATCH v5 1/5] gadget: Introduce the notifier functions

FromGreg KH <gregkh@linuxfoundation.org>
Date2015-11-06 18:00 +0100
SubjectRe: [PATCH v5 1/5] gadget: Introduce the notifier functions
Message-ID<qrSwP-71N-23@gated-at.bofh.it>
In reply to#1263934
On Fri, Nov 06, 2015 at 07:35:10PM +0800, Baolin Wang wrote:
> The usb charger framework is based on usb gadget. The usb charger
> need to be notified the state changing of usb gadget to confirm the
> usb charger state.
> 
> Thus this patch adds a notifier mechanism for usb gadget to report a
> event to usb charger when the usb gadget state is changed.

I thought we said we did not want another notifier chain in the previous
versions of this patch?

> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> ---
>  drivers/usb/gadget/udc/udc-core.c |   32 ++++++++++++++++++++++++++++++++
>  include/linux/usb/gadget.h        |   18 ++++++++++++++++++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
> index f660afb..4238fc3 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -129,6 +129,32 @@ void usb_gadget_giveback_request(struct usb_ep *ep,
>  }
>  EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);
>  
> +int usb_gadget_register_notify(struct usb_gadget *gadget,
> +			       struct notifier_block *nb)
> +{
> +	int ret;
> +
> +	mutex_lock(&gadget->lock);
> +	ret = raw_notifier_chain_register(&gadget->nh, nb);
> +	mutex_unlock(&gadget->lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(usb_gadget_register_notify);
> +
> +int usb_gadget_unregister_notify(struct usb_gadget *gadget,
> +				 struct notifier_block *nb)
> +{
> +	int ret;
> +
> +	mutex_lock(&gadget->lock);
> +	ret = raw_notifier_chain_unregister(&gadget->nh, nb);
> +	mutex_unlock(&gadget->lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(usb_gadget_unregister_notify);
> +
>  /* ------------------------------------------------------------------------- */
>  
>  /**
> @@ -226,6 +252,10 @@ static void usb_gadget_state_work(struct work_struct *work)
>  	struct usb_gadget *gadget = work_to_gadget(work);
>  	struct usb_udc *udc = gadget->udc;
>  
> +	mutex_lock(&gadget->lock);
> +	raw_notifier_call_chain(&gadget->nh, gadget->state, gadget);
> +	mutex_unlock(&gadget->lock);
> +
>  	if (udc)
>  		sysfs_notify(&udc->dev.kobj, NULL, "state");
>  }
> @@ -364,6 +394,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
>  
>  	dev_set_name(&gadget->dev, "gadget");
>  	INIT_WORK(&gadget->work, usb_gadget_state_work);
> +	RAW_INIT_NOTIFIER_HEAD(&gadget->nh);
> +	mutex_init(&gadget->lock);
>  	gadget->dev.parent = parent;
>  
>  #ifdef	CONFIG_HAS_DMA
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index c14a69b..755e8bc 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -609,6 +609,8 @@ struct usb_gadget {
>  	unsigned			out_epnum;
>  	unsigned			in_epnum;
>  	struct usb_otg_caps		*otg_caps;
> +	struct raw_notifier_head	nh;
> +	struct mutex			lock;

You have to document what this lock protects.


>  
>  	unsigned			sg_supported:1;
>  	unsigned			is_otg:1;
> @@ -1183,6 +1185,22 @@ extern void usb_gadget_unmap_request(struct usb_gadget *gadget,
>  
>  /*-------------------------------------------------------------------------*/
>  
> +/**
> + * Register a notifiee to get notified by any attach status changes from
> + * the usb gadget
> + */

kerneldoc does not belong in a .h file.

And the kbuild system found lots of problems with this series, please
fix those at the very least :(

thanks,

greg k-h
--
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] | [next] | [standalone]


#1264570 — Re: [PATCH v5 1/5] gadget: Introduce the notifier functions

FromMark Brown <broonie@kernel.org>
Date2015-11-06 22:30 +0100
SubjectRe: [PATCH v5 1/5] gadget: Introduce the notifier functions
Message-ID<qrWK6-1yP-9@gated-at.bofh.it>
In reply to#1264164

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

On Fri, Nov 06, 2015 at 08:56:44AM -0800, Greg KH wrote:
> On Fri, Nov 06, 2015 at 07:35:10PM +0800, Baolin Wang wrote:

> > Thus this patch adds a notifier mechanism for usb gadget to report a
> > event to usb charger when the usb gadget state is changed.

> I thought we said we did not want another notifier chain in the previous
> versions of this patch?

Did we come up with anything better?

[toc] | [prev] | [next] | [standalone]


#1265273 — Re: [PATCH v5 1/5] gadget: Introduce the notifier functions

FromBaolin Wang <baolin.wang@linaro.org>
Date2015-11-09 03:10 +0100
SubjectRe: [PATCH v5 1/5] gadget: Introduce the notifier functions
Message-ID<qsK49-8r8-1@gated-at.bofh.it>
In reply to#1264164
On 7 November 2015 at 00:56, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Fri, Nov 06, 2015 at 07:35:10PM +0800, Baolin Wang wrote:

>>  #ifdef       CONFIG_HAS_DMA
>> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
>> index c14a69b..755e8bc 100644
>> --- a/include/linux/usb/gadget.h
>> +++ b/include/linux/usb/gadget.h
>> @@ -609,6 +609,8 @@ struct usb_gadget {
>>       unsigned                        out_epnum;
>>       unsigned                        in_epnum;
>>       struct usb_otg_caps             *otg_caps;
>> +     struct raw_notifier_head        nh;
>> +     struct mutex                    lock;
>
> You have to document what this lock protects.

OK.

>
>
>>
>>       unsigned                        sg_supported:1;
>>       unsigned                        is_otg:1;
>> @@ -1183,6 +1185,22 @@ extern void usb_gadget_unmap_request(struct usb_gadget *gadget,
>>
>>  /*-------------------------------------------------------------------------*/
>>
>> +/**
>> + * Register a notifiee to get notified by any attach status changes from
>> + * the usb gadget
>> + */
>
> kerneldoc does not belong in a .h file.
>

I'll remove the comments.

> And the kbuild system found lots of problems with this series, please
> fix those at the very least :(

I'm sorry for that, I'll check the patches again. Thanks for your comments.

>
> thanks,
>
> greg k-h



-- 
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