usb: otg: nop: Start using struct usb_otg

Use struct usb_otg members with OTG specific functions instead
of usb_phy members.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Heikki Krogerus 2012-02-13 13:24:10 +02:00 committed by Felipe Balbi
parent 1d4c9293ae
commit 41adf10933

View file

@ -33,7 +33,7 @@
#include <linux/slab.h> #include <linux/slab.h>
struct nop_usb_xceiv { struct nop_usb_xceiv {
struct usb_phy otg; struct usb_phy phy;
struct device *dev; struct device *dev;
}; };
@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void)
} }
EXPORT_SYMBOL(usb_nop_xceiv_unregister); EXPORT_SYMBOL(usb_nop_xceiv_unregister);
static inline struct nop_usb_xceiv *xceiv_to_nop(struct usb_phy *x)
{
return container_of(x, struct nop_usb_xceiv, otg);
}
static int nop_set_suspend(struct usb_phy *x, int suspend) static int nop_set_suspend(struct usb_phy *x, int suspend)
{ {
return 0; return 0;
} }
static int nop_set_peripheral(struct usb_phy *x, static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
struct usb_gadget *gadget)
{ {
struct nop_usb_xceiv *nop; if (!otg)
if (!x)
return -ENODEV; return -ENODEV;
nop = xceiv_to_nop(x);
if (!gadget) { if (!gadget) {
nop->otg.gadget = NULL; otg->gadget = NULL;
return -ENODEV; return -ENODEV;
} }
nop->otg.gadget = gadget; otg->gadget = gadget;
nop->otg.state = OTG_STATE_B_IDLE; otg->phy->state = OTG_STATE_B_IDLE;
return 0; return 0;
} }
static int nop_set_host(struct usb_phy *x, struct usb_bus *host) static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
{ {
struct nop_usb_xceiv *nop; if (!otg)
if (!x)
return -ENODEV; return -ENODEV;
nop = xceiv_to_nop(x);
if (!host) { if (!host) {
nop->otg.host = NULL; otg->host = NULL;
return -ENODEV; return -ENODEV;
} }
nop->otg.host = host; otg->host = host;
return 0; return 0;
} }
@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
if (!nop) if (!nop)
return -ENOMEM; return -ENOMEM;
nop->dev = &pdev->dev; nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL);
nop->otg.dev = nop->dev; if (!nop->phy.otg) {
nop->otg.label = "nop-xceiv"; kfree(nop);
nop->otg.state = OTG_STATE_UNDEFINED; return -ENOMEM;
nop->otg.set_host = nop_set_host; }
nop->otg.set_peripheral = nop_set_peripheral;
nop->otg.set_suspend = nop_set_suspend;
err = otg_set_transceiver(&nop->otg); nop->dev = &pdev->dev;
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend;
nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;
err = usb_set_transceiver(&nop->phy);
if (err) { if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n", dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err); err);
@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, nop); platform_set_drvdata(pdev, nop);
ATOMIC_INIT_NOTIFIER_HEAD(&nop->otg.notifier); ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier);
return 0; return 0;
exit: exit:
kfree(nop->phy.otg);
kfree(nop); kfree(nop);
return err; return err;
} }
@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
{ {
struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
otg_set_transceiver(NULL); usb_set_transceiver(NULL);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(nop->phy.otg);
kfree(nop); kfree(nop);
return 0; return 0;