lkml.org 
[lkml]   [2021]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH 3/4] usb: xhci-plat: add xhci_plat_priv_overwrite
    From
    Add an overwrite to platform specific callback for setting up the
    xhci_vendor_ops, allow vendor to store the xhci_vendor_ops and
    overwrite them when xhci_plat_probe invoked.

    This change is depend on Commit in this patch series
    ("usb: host: add xhci hooks for USB offload"), vendor needs
    to invoke xhci_plat_register_vendor_ops() to register the vendor specific
    vendor_ops. And the vendor_ops will overwrite the vendor_ops inside
    xhci_plat_priv in xhci_vendor_init() during xhci-plat-hcd probe.

    Signed-off-by: Howard Yen <howardyen@google.com>
    ---
    drivers/usb/host/xhci-plat.c | 20 ++++++++++++++++++++
    drivers/usb/host/xhci-plat.h | 7 +++++++
    2 files changed, 27 insertions(+)

    diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
    index 5f8e69089654..a8e217494831 100644
    --- a/drivers/usb/host/xhci-plat.c
    +++ b/drivers/usb/host/xhci-plat.c
    @@ -163,9 +163,26 @@ static const struct of_device_id usb_xhci_of_match[] = {
    MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
    #endif

    +static struct xhci_plat_priv_overwrite xhci_plat_vendor_overwrite;
    +
    +int xhci_plat_register_vendor_ops(struct xhci_vendor_ops *vendor_ops)
    +{
    + if (vendor_ops == NULL)
    + return -EINVAL;
    +
    + xhci_plat_vendor_overwrite.vendor_ops = vendor_ops;
    +
    + return 0;
    +}
    +EXPORT_SYMBOL_GPL(xhci_plat_register_vendor_ops);
    +
    static int xhci_vendor_init(struct xhci_hcd *xhci)
    {
    struct xhci_vendor_ops *ops = xhci_vendor_get_ops(xhci);
    + struct xhci_plat_priv *priv = xhci_to_priv(xhci);
    +
    + if (xhci_plat_vendor_overwrite.vendor_ops)
    + ops = priv->vendor_ops = xhci_plat_vendor_overwrite.vendor_ops;

    if (ops && ops->vendor_init)
    return ops->vendor_init(xhci);
    @@ -175,9 +192,12 @@ static int xhci_vendor_init(struct xhci_hcd *xhci)
    static void xhci_vendor_cleanup(struct xhci_hcd *xhci)
    {
    struct xhci_vendor_ops *ops = xhci_vendor_get_ops(xhci);
    + struct xhci_plat_priv *priv = xhci_to_priv(xhci);

    if (ops && ops->vendor_cleanup)
    ops->vendor_cleanup(xhci);
    +
    + priv->vendor_ops = NULL;
    }

    static int xhci_plat_probe(struct platform_device *pdev)
    diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
    index 2b2d090c4c01..d85802725208 100644
    --- a/drivers/usb/host/xhci-plat.h
    +++ b/drivers/usb/host/xhci-plat.h
    @@ -22,4 +22,11 @@ struct xhci_plat_priv {

    #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
    #define xhci_to_priv(x) ((struct xhci_plat_priv *)(x)->priv)
    +
    +struct xhci_plat_priv_overwrite {
    + struct xhci_vendor_ops *vendor_ops;
    +};
    +
    +int xhci_plat_register_vendor_ops(struct xhci_vendor_ops *vendor_ops);
    +
    #endif /* _XHCI_PLAT_H */
    --
    2.30.0.284.gd98b1dd5eaa7-goog
    \
     
     \ /
      Last update: 2021-01-19 14:11    [W:3.833 / U:0.292 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site