Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114484
b: refs/heads/master
c: 9def255
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Oct 14, 2008
1 parent cdf3bc5 commit 782c125
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 67a37308ae37f8948d3c26f75a18f0ddb77ac198
refs/heads/master: 9def255631bb742264d334d77819e1ae5278a515
39 changes: 8 additions & 31 deletions trunk/drivers/i2c/busses/i2c-parport-light.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ static struct i2c_adapter parport_adapter = {
static int __devinit i2c_parport_probe(struct platform_device *pdev)
{
int err;
struct resource *res;

res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!request_region(res->start, res->end - res->start + 1, DRVNAME))
return -EBUSY;

/* Reset hardware to a sane state (SCL and SDA high) */
parport_setsda(NULL, 1);
Expand All @@ -138,29 +133,19 @@ static int __devinit i2c_parport_probe(struct platform_device *pdev)

parport_adapter.dev.parent = &pdev->dev;
err = i2c_bit_add_bus(&parport_adapter);
if (err) {
if (err)
dev_err(&pdev->dev, "Unable to register with I2C\n");
goto exit_region;
}
return 0;

exit_region:
release_region(res->start, res->end - res->start + 1);
return err;
}

static int __devexit i2c_parport_remove(struct platform_device *pdev)
{
struct resource *res;

i2c_del_adapter(&parport_adapter);

/* Un-init if needed (power off...) */
if (adapter_parm[type].init.val)
line_set(0, &adapter_parm[type].init);

res = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(res->start, res->end - res->start + 1);
return 0;
}

Expand All @@ -175,12 +160,6 @@ static struct platform_driver i2c_parport_driver = {

static int __init i2c_parport_device_add(u16 address)
{
struct resource res = {
.start = address,
.end = address + 2,
.name = DRVNAME,
.flags = IORESOURCE_IO,
};
int err;

pdev = platform_device_alloc(DRVNAME, -1);
Expand All @@ -190,13 +169,6 @@ static int __init i2c_parport_device_add(u16 address)
goto exit;
}

err = platform_device_add_resources(pdev, &res, 1);
if (err) {
printk(KERN_ERR DRVNAME ": Device resource addition failed "
"(%d)\n", err);
goto exit_device_put;
}

err = platform_device_add(pdev);
if (err) {
printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
Expand Down Expand Up @@ -231,13 +203,16 @@ static int __init i2c_parport_init(void)
base = DEFAULT_BASE;
}

if (!request_region(base, 3, DRVNAME))
return -EBUSY;

if (!adapter_parm[type].getscl.val)
parport_algo_data.getscl = NULL;

/* Sets global pdev as a side effect */
err = i2c_parport_device_add(base);
if (err)
goto exit;
goto exit_release;

err = platform_driver_register(&i2c_parport_driver);
if (err)
Expand All @@ -247,14 +222,16 @@ static int __init i2c_parport_init(void)

exit_device:
platform_device_unregister(pdev);
exit:
exit_release:
release_region(base, 3);
return err;
}

static void __exit i2c_parport_exit(void)
{
platform_driver_unregister(&i2c_parport_driver);
platform_device_unregister(pdev);
release_region(base, 3);
}

MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
Expand Down

0 comments on commit 782c125

Please sign in to comment.