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]
Message-Id: <c74d23e8bb444500e82f3732f51e8ffadb9e3a18.1443057232.git.baolin.wang@linaro.org>
Date:	Thu, 24 Sep 2015 10:39:26 -0700
From:	Baolin Wang <baolin.wang@...aro.org>
To:	balbi@...com, sre@...nel.org, dbaryshkov@...il.com,
	dwmw2@...radead.org
Cc:	gregkh@...uxfoundation.org, peter.chen@...escale.com,
	stern@...land.harvard.edu, r.baldyga@...sung.com, sojka@...ica.cz,
	yoshihiro.shimoda.uh@...esas.com, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, sameo@...ux.intel.com,
	lee.jones@...aro.org, ckeepax@...nsource.wolfsonmicro.com,
	broonie@...nel.org, patches@...nsource.wolfsonmicro.com,
	linux-pm@...r.kernel.org,
	device-mainlining@...ts.linuxfoundation.org, baolin.wang@...aro.org
Subject: [PATCH v4 4/5] gadget: Integrate with the usb gadget supporting for usb charger

When the usb gadget supporting for usb charger is ready, the usb charger
should get the type by the 'get_charger_type' callback which is implemented
by the usb gadget operations, and get the usb charger pointer from struct
'usb_gadget'.

Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
 drivers/usb/gadget/charger.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/charger.c b/drivers/usb/gadget/charger.c
index 35b46c1..a919f38 100644
--- a/drivers/usb/gadget/charger.c
+++ b/drivers/usb/gadget/charger.c
@@ -181,6 +181,13 @@ int usb_charger_unregister_notify(struct usb_charger *uchger,
 enum usb_charger_type
 usb_charger_detect_type(struct usb_charger *uchger)
 {
+	if (uchger->gadget && uchger->gadget->ops
+	    && uchger->gadget->ops->get_charger_type)
+		uchger->type =
+			uchger->gadget->ops->get_charger_type(uchger->gadget);
+	else
+		uchger->type = UNKNOWN_TYPE;
+
 	return uchger->type;
 }
 
@@ -313,7 +320,8 @@ static int
 usb_charger_plug_by_gadget(struct notifier_block *nb,
 			   unsigned long state, void *data)
 {
-	struct usb_charger *uchger = NULL;
+	struct usb_gadget *gadget = (struct usb_gadget *)data;
+	struct usb_charger *uchger = gadget->charger;
 	enum usb_charger_state uchger_state;
 
 	if (!uchger)
@@ -480,6 +488,7 @@ int usb_charger_init(struct usb_gadget *ugadget)
 
 	/* register a notifier on a usb gadget device */
 	uchger->gadget = ugadget;
+	ugadget->charger = uchger;
 	uchger->old_gadget_state = ugadget->state;
 	uchger->gadget_nb.notifier_call = usb_charger_plug_by_gadget;
 	usb_gadget_register_notify(ugadget, &uchger->gadget_nb);
@@ -503,7 +512,7 @@ fail:
 
 int usb_charger_exit(struct usb_gadget *ugadget)
 {
-	struct usb_charger *uchger = NULL;
+	struct usb_charger *uchger = ugadget->charger;
 
 	if (!uchger)
 		return -EINVAL;
-- 
1.9.1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ