aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-03-08 06:01:40 -0500
committerFelipe Balbi <balbi@ti.com>2013-03-18 05:18:09 -0400
commit790d3a5ab6e36fb06e99339afe35ecdec4d3b2cb (patch)
treeb4fed4344f3734d581561e14ce3763732f189935
parent94ae98433a397dd4695652fc62ca7bc784b08216 (diff)
usb: phy: isp1301: give it a context structure
this patch is a small preparation to fix isp1301 driver so that other platforms can use it. We're defining our private data structure to represent this device and adding the PHY to the PHY list. Later patches will come implementing proper PHY API and removing bogus code from ohci_nxp and lpc32xx_udc drivers. Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/phy/phy-isp1301.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index 18dbf7e37607..5e0f14369145 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -11,10 +11,19 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/mutex.h>
14#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/usb/phy.h>
15 17
16#define DRV_NAME "isp1301" 18#define DRV_NAME "isp1301"
17 19
20struct isp1301 {
21 struct usb_phy phy;
22 struct mutex mutex;
23
24 struct i2c_client *client;
25};
26
18static const struct i2c_device_id isp1301_id[] = { 27static const struct i2c_device_id isp1301_id[] = {
19 { "isp1301", 0 }, 28 { "isp1301", 0 },
20 { } 29 { }
@@ -25,12 +34,35 @@ static struct i2c_client *isp1301_i2c_client;
25static int isp1301_probe(struct i2c_client *client, 34static int isp1301_probe(struct i2c_client *client,
26 const struct i2c_device_id *i2c_id) 35 const struct i2c_device_id *i2c_id)
27{ 36{
37 struct isp1301 *isp;
38 struct usb_phy *phy;
39
40 isp = devm_kzalloc(&client->dev, sizeof(*isp), GFP_KERNEL);
41 if (!isp)
42 return -ENOMEM;
43
44 isp->client = client;
45 mutex_init(&isp->mutex);
46
47 phy = &isp->phy;
48 phy->label = DRV_NAME;
49 phy->type = USB_PHY_TYPE_USB2;
50
51 i2c_set_clientdata(client, isp);
52 usb_add_phy_dev(phy);
53
28 isp1301_i2c_client = client; 54 isp1301_i2c_client = client;
55
29 return 0; 56 return 0;
30} 57}
31 58
32static int isp1301_remove(struct i2c_client *client) 59static int isp1301_remove(struct i2c_client *client)
33{ 60{
61 struct isp1301 *isp = i2c_get_clientdata(client);
62
63 usb_remove_phy(&isp->phy);
64 isp1301_i2c_client = NULL;
65
34 return 0; 66 return 0;
35} 67}
36 68