Skip to content

Commit

Permalink
USB: Convert ohci-pnx4008 to a new-style i2c driver
Browse files Browse the repository at this point in the history
The legacy i2c binding model will go away soon, convert ohci-pnx4008
to use the new binding model instead.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jean Delvare authored and Greg Kroah-Hartman committed Jan 7, 2009
1 parent dc023dc commit 3a407e7
Showing 1 changed file with 36 additions and 49 deletions.
85 changes: 36 additions & 49 deletions drivers/usb/host/ohci-pnx4008.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,65 +106,34 @@ extern int ocpi_enable(void);

static struct clk *usb_clk;

static int isp1301_probe(struct i2c_adapter *adap);
static int isp1301_detach(struct i2c_client *client);

static const unsigned short normal_i2c[] =
{ ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END };
static const unsigned short dummy_i2c_addrlist[] = { I2C_CLIENT_END };

static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = dummy_i2c_addrlist,
.ignore = dummy_i2c_addrlist,
};

struct i2c_driver isp1301_driver = {
.driver = {
.name = "isp1301_pnx",
},
.attach_adapter = isp1301_probe,
.detach_client = isp1301_detach,
};

static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
static int isp1301_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_client *c;
int err;

c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c)
return -ENOMEM;

strlcpy(c->name, "isp1301_pnx", I2C_NAME_SIZE);
c->flags = 0;
c->addr = addr;
c->adapter = adap;
c->driver = &isp1301_driver;

err = i2c_attach_client(c);
if (err) {
kfree(c);
return err;
}

isp1301_i2c_client = c;

return 0;
}

static int isp1301_probe(struct i2c_adapter *adap)
static int isp1301_remove(struct i2c_client *client)
{
return i2c_probe(adap, &addr_data, isp1301_attach);
}

static int isp1301_detach(struct i2c_client *client)
{
i2c_detach_client(client);
kfree(isp1301_i2c_client);
return 0;
}

const struct i2c_device_id isp1301_id[] = {
{ "isp1301_pnx", 0 },
{ }
};

struct i2c_driver isp1301_driver = {
.driver = {
.name = "isp1301_pnx",
},
.probe = isp1301_probe,
.remove = isp1301_remove,
.id_table = isp1301_id,
};

static void i2c_write(u8 buf, u8 subaddr)
{
char tmpbuf[2];
Expand Down Expand Up @@ -328,6 +297,8 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
struct usb_hcd *hcd = 0;
struct ohci_hcd *ohci;
const struct hc_driver *driver = &ohci_pnx4008_hc_driver;
struct i2c_adapter *i2c_adap;
struct i2c_board_info i2c_info;

int ret = 0, irq;

Expand All @@ -351,9 +322,20 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)

ret = i2c_add_driver(&isp1301_driver);
if (ret < 0) {
err("failed to connect I2C to ISP1301 USB Transceiver");
err("failed to add ISP1301 driver");
goto out;
}
i2c_adap = i2c_get_adapter(2);
memset(&i2c_info, 0, sizeof(struct i2c_board_info));
strlcpy(i2c_info.name, "isp1301_pnx", I2C_NAME_SIZE);
isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
normal_i2c);
i2c_put_adapter(i2c_adap);
if (!isp1301_i2c_client) {
err("failed to connect I2C to ISP1301 USB Transceiver");
ret = -ENODEV;
goto out_i2c_driver;
}

isp1301_configure();

Expand Down Expand Up @@ -429,6 +411,9 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
out2:
clk_put(usb_clk);
out1:
i2c_unregister_client(isp1301_i2c_client);
isp1301_i2c_client = NULL;
out_i2c_driver:
i2c_del_driver(&isp1301_driver);
out:
return ret;
Expand All @@ -445,6 +430,8 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev)
pnx4008_unset_usb_bits();
clk_disable(usb_clk);
clk_put(usb_clk);
i2c_unregister_client(isp1301_i2c_client);
isp1301_i2c_client = NULL;
i2c_del_driver(&isp1301_driver);

platform_set_drvdata(pdev, NULL);
Expand Down

0 comments on commit 3a407e7

Please sign in to comment.