Now that the code has been refactored enough,
switching over to using ->plat_start() and
->init_quirk() becomes a very simple patch.

After this patch, there are no further uses for
xhci_plat_type_is() which will be removed in a
follow-up patch.

Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda...@renesas.com>
Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
---
 drivers/usb/host/xhci-plat.c | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 9bdf016d9080..fcbf003ac16a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -37,6 +37,24 @@ static const struct xhci_driver_overrides 
xhci_plat_overrides __initconst = {
        .start = xhci_plat_start,
 };
 
+static void xhci_priv_plat_start(struct usb_hcd *hcd)
+{
+       struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+
+       if (priv->plat_start)
+               priv->plat_start(hcd);
+}
+
+static int xhci_priv_init_quirk(struct usb_hcd *hcd)
+{
+       struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+
+       if (!priv->init_quirk)
+               return 0;
+
+       return priv->init_quirk(hcd);
+}
+
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
        struct usb_hcd *hcd = xhci_to_hcd(xhci);
@@ -65,44 +83,38 @@ static int xhci_plat_setup(struct usb_hcd *hcd)
 {
        int ret;
 
-       if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) ||
-           xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) {
-               ret = xhci_rcar_init_quirk(hcd);
-               if (ret)
-                       return ret;
-       }
 
-       if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) {
-               ret = xhci_mvebu_mbus_init_quirk(hcd);
-               if (ret)
-                       return ret;
-       }
+       ret = xhci_priv_init_quirk(hcd);
+       if (ret)
+               return ret;
 
        return xhci_gen_setup(hcd, xhci_plat_quirks);
 }
 
 static int xhci_plat_start(struct usb_hcd *hcd)
 {
-       if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) ||
-           xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3))
-               xhci_rcar_start(hcd);
-
+       xhci_priv_plat_start(hcd);
        return xhci_run(hcd);
 }
 
 #ifdef CONFIG_OF
 static const struct xhci_plat_priv xhci_plat_marvell_armada = {
        .type = XHCI_PLAT_TYPE_MARVELL_ARMADA,
+       .init_quirk = xhci_mvebu_mbus_init_quirk,
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
        .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2,
        .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
+       .init_quirk = xhci_rcar_init_quirk,
+       .plat_start = xhci_rcar_start,
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
        .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3,
        .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2,
+       .init_quirk = xhci_rcar_init_quirk,
+       .plat_start = xhci_rcar_start,
 };
 
 static const struct of_device_id usb_xhci_of_match[] = {
-- 
2.8.1

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

Reply via email to