Search
SailfishOS Open Build Service
>
Projects
>
home:dcthang:branches:nemo:devel:hw:ti:omap3:n900
>
kernel-adaptation-n900
> linux-2.6-usb-otg-introduce-otg_notify_event-and-otg_get_last_.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File linux-2.6-usb-otg-introduce-otg_notify_event-and-otg_get_last_.patch of Package kernel-adaptation-n900
From bb70bd42b5391f928257ede38a3fc105897d1bbd Mon Sep 17 00:00:00 2001 From: Heikki Krogerus <ext-heikki.krogerus@nokia.com> Date: Tue, 19 Oct 2010 15:14:11 +0200 Subject: [PATCH 05/42] usb: otg: introduce otg_notify_event and otg_get_last_event otg_notify_event is a simpler way to call the notifier. otg_get_last_event allows drivers to get the last event in case the event has been notified before the driver has probed. Signed-off-by: Heikki Krogerus <ext-heikki.krogerus@nokia.com> --- drivers/power/isp1704_charger.c | 4 ++++ drivers/usb/musb/musb_gadget.c | 11 +++++------ drivers/usb/otg/twl4030-usb.c | 3 +-- include/linux/usb/otg.h | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index 7251218..bc88c5c 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c @@ -318,6 +318,10 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) dev_info(isp->dev, "registered with product id %s\n", isp->model); + ret = otg_get_last_event(isp->otg); + if (ret) + dev_warn(isp->dev, "failed to get last event\n"); + return 0; fail2: power_supply_unregister(&isp->psy); diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 927a420..5d0f038 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1588,12 +1588,11 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) { struct musb *musb = gadget_to_musb(gadget); - /* REVISIT we shouldn't need to be passing - * this kind of value to userland. We have - * now the blocking notifier for transceivers - * which could very well handle this - */ - musb->power_draw = mA; + if (musb->power_draw != mA && mA > 0) { + musb->power_draw = mA; + otg_notify_event(musb->xceiv, USB_EVENT_ENUMERATED, + &musb->power_draw); + } schedule_work(&musb->irq_work); if (!musb->xceiv->set_power) diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index d335f48..f55cb0d 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c @@ -512,8 +512,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) else twl4030_phy_resume(twl); - blocking_notifier_call_chain(&twl->otg.notifier, status, - twl->otg.gadget); + otg_notify_event(&twl->otg, status, twl->otg.gadget); } sysfs_notify(&twl->dev->kobj, NULL, "vbus"); diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 2ad773a..890d541 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -64,6 +64,8 @@ struct otg_transceiver { const char *label; unsigned int flags; + void *last_event_data; + u8 last_event; u8 default_a; enum usb_otg_state state; @@ -248,6 +250,22 @@ otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) return blocking_notifier_chain_register(&otg->notifier, nb); } +static inline int +otg_notify_event(struct otg_transceiver *otg, enum usb_xceiv_events event, + void *data) +{ + otg->last_event = event; + otg->last_event_data = data; + + return blocking_notifier_call_chain(&otg->notifier, event, data); +} + +static inline int +otg_get_last_event(struct otg_transceiver *otg) +{ + return otg_notify_event(otg, otg->last_event, otg->last_event_data); +} + static inline void otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb) { -- 1.7.0.4