diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2008-02-24 14:03:42 -0500 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2008-02-24 14:03:42 -0500 |
commit | a92b36ed33800435a2356a78489e129aaf30f673 (patch) | |
tree | 80b6e75757409a446ec890c7e4f692b7201293fd /drivers | |
parent | c9a2c46d7f32a884510b20f0cfa79a2c6a2f1413 (diff) |
i2c-pxa: Misc fixes
While working on the PCA9564-platform driver, I sometimes had a glimpse at the
pxa-driver. I found some suspicious places, and this patch contains my
suggestions. Note: They are not tested, due to no hardware.
[JD: Some more fixes.]
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Mike Rapoport <mike@compulab.co.il>
Tested-by: Eric Miao <ymiao3@marvell.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/i2c-pxa.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 2b557bfd7f70..2d2087ad708f 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -999,7 +999,14 @@ static int i2c_pxa_probe(struct platform_device *dev) | |||
999 | spin_lock_init(&i2c->lock); | 999 | spin_lock_init(&i2c->lock); |
1000 | init_waitqueue_head(&i2c->wait); | 1000 | init_waitqueue_head(&i2c->wait); |
1001 | 1001 | ||
1002 | sprintf(i2c->adap.name, "pxa_i2c-i2c.%u", dev->id); | 1002 | /* |
1003 | * If "dev->id" is negative we consider it as zero. | ||
1004 | * The reason to do so is to avoid sysfs names that only make | ||
1005 | * sense when there are multiple adapters. | ||
1006 | */ | ||
1007 | i2c->adap.nr = dev->id != -1 ? dev->id : 0; | ||
1008 | snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa_i2c-i2c.%u", | ||
1009 | i2c->adap.nr); | ||
1003 | 1010 | ||
1004 | i2c->clk = clk_get(&dev->dev, "I2CCLK"); | 1011 | i2c->clk = clk_get(&dev->dev, "I2CCLK"); |
1005 | if (IS_ERR(i2c->clk)) { | 1012 | if (IS_ERR(i2c->clk)) { |
@@ -1050,13 +1057,6 @@ static int i2c_pxa_probe(struct platform_device *dev) | |||
1050 | i2c->adap.algo_data = i2c; | 1057 | i2c->adap.algo_data = i2c; |
1051 | i2c->adap.dev.parent = &dev->dev; | 1058 | i2c->adap.dev.parent = &dev->dev; |
1052 | 1059 | ||
1053 | /* | ||
1054 | * If "dev->id" is negative we consider it as zero. | ||
1055 | * The reason to do so is to avoid sysfs names that only make | ||
1056 | * sense when there are multiple adapters. | ||
1057 | */ | ||
1058 | i2c->adap.nr = dev->id != -1 ? dev->id : 0; | ||
1059 | |||
1060 | ret = i2c_add_numbered_adapter(&i2c->adap); | 1060 | ret = i2c_add_numbered_adapter(&i2c->adap); |
1061 | if (ret < 0) { | 1061 | if (ret < 0) { |
1062 | printk(KERN_INFO "I2C: Failed to add bus\n"); | 1062 | printk(KERN_INFO "I2C: Failed to add bus\n"); |
@@ -1080,6 +1080,7 @@ eadapt: | |||
1080 | ereqirq: | 1080 | ereqirq: |
1081 | clk_disable(i2c->clk); | 1081 | clk_disable(i2c->clk); |
1082 | i2c_pxa_disable(dev); | 1082 | i2c_pxa_disable(dev); |
1083 | iounmap(i2c->reg_base); | ||
1083 | eremap: | 1084 | eremap: |
1084 | clk_put(i2c->clk); | 1085 | clk_put(i2c->clk); |
1085 | eclk: | 1086 | eclk: |
@@ -1089,7 +1090,7 @@ emalloc: | |||
1089 | return ret; | 1090 | return ret; |
1090 | } | 1091 | } |
1091 | 1092 | ||
1092 | static int i2c_pxa_remove(struct platform_device *dev) | 1093 | static int __exit i2c_pxa_remove(struct platform_device *dev) |
1093 | { | 1094 | { |
1094 | struct pxa_i2c *i2c = platform_get_drvdata(dev); | 1095 | struct pxa_i2c *i2c = platform_get_drvdata(dev); |
1095 | 1096 | ||
@@ -1103,6 +1104,7 @@ static int i2c_pxa_remove(struct platform_device *dev) | |||
1103 | clk_put(i2c->clk); | 1104 | clk_put(i2c->clk); |
1104 | i2c_pxa_disable(dev); | 1105 | i2c_pxa_disable(dev); |
1105 | 1106 | ||
1107 | iounmap(i2c->reg_base); | ||
1106 | release_mem_region(i2c->iobase, i2c->iosize); | 1108 | release_mem_region(i2c->iobase, i2c->iosize); |
1107 | kfree(i2c); | 1109 | kfree(i2c); |
1108 | 1110 | ||
@@ -1111,9 +1113,10 @@ static int i2c_pxa_remove(struct platform_device *dev) | |||
1111 | 1113 | ||
1112 | static struct platform_driver i2c_pxa_driver = { | 1114 | static struct platform_driver i2c_pxa_driver = { |
1113 | .probe = i2c_pxa_probe, | 1115 | .probe = i2c_pxa_probe, |
1114 | .remove = i2c_pxa_remove, | 1116 | .remove = __exit_p(i2c_pxa_remove), |
1115 | .driver = { | 1117 | .driver = { |
1116 | .name = "pxa2xx-i2c", | 1118 | .name = "pxa2xx-i2c", |
1119 | .owner = THIS_MODULE, | ||
1117 | }, | 1120 | }, |
1118 | }; | 1121 | }; |
1119 | 1122 | ||
@@ -1122,7 +1125,7 @@ static int __init i2c_adap_pxa_init(void) | |||
1122 | return platform_driver_register(&i2c_pxa_driver); | 1125 | return platform_driver_register(&i2c_pxa_driver); |
1123 | } | 1126 | } |
1124 | 1127 | ||
1125 | static void i2c_adap_pxa_exit(void) | 1128 | static void __exit i2c_adap_pxa_exit(void) |
1126 | { | 1129 | { |
1127 | platform_driver_unregister(&i2c_pxa_driver); | 1130 | platform_driver_unregister(&i2c_pxa_driver); |
1128 | } | 1131 | } |