Re: [PATCH 2/2] usb: otg: introduce otg_notify_event and otg_get_last_event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 6, 2010 at 12:10 PM, Arnaud Mandy
<ext-arnaud.2.mandy@xxxxxxxxx> wrote:
> otg_notify_event is a simpler way to call the notifier and saving
> the last_event andd data in otg_transceiver.
>
> otg_get_last_event allow drivers to get the last event
> in case the event has been notified before the driver was probed.
> It can also help in the future in making state machine based on last event.
>
> Signed-off-by: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx>
> ---
>  drivers/usb/otg/twl4030-usb.c |    6 ++----
>  include/linux/usb/otg.h       |   18 ++++++++++++++++++
>  2 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
> index 8032a4c..f69b502 100644
> --- a/drivers/usb/otg/twl4030-usb.c
> +++ b/drivers/usb/otg/twl4030-usb.c
> @@ -507,8 +507,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
>                else
>                        twl4030_phy_resume(twl);
>
> -               atomic_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");
>
> @@ -529,8 +528,7 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl)
>                        twl->asleep = 0;
>                }
>
> -               atomic_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 22dfd43..026b89a 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;
>
> @@ -226,6 +228,22 @@ otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
>        return atomic_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 atomic_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);
> +}
> +
Should this be static?

If drivers need to get the last event they need to call this function
in which case you need to export this function.

Regards,
Maulik
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux