Skip to content

Commit a92b36e

Browse files
Wolfram SangJean Delvare
authored andcommitted
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>
1 parent c9a2c46 commit a92b36e

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎drivers/i2c/busses/i2c-pxa.c‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,14 @@ static int i2c_pxa_probe(struct platform_device *dev)
999999
spin_lock_init(&i2c->lock);
10001000
init_waitqueue_head(&i2c->wait);
10011001

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);
10031010

10041011
i2c->clk = clk_get(&dev->dev, "I2CCLK");
10051012
if (IS_ERR(i2c->clk)) {
@@ -1050,13 +1057,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
10501057
i2c->adap.algo_data = i2c;
10511058
i2c->adap.dev.parent = &dev->dev;
10521059

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-
10601060
ret = i2c_add_numbered_adapter(&i2c->adap);
10611061
if (ret < 0) {
10621062
printk(KERN_INFO "I2C: Failed to add bus\n");
@@ -1080,6 +1080,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
10801080
ereqirq:
10811081
clk_disable(i2c->clk);
10821082
i2c_pxa_disable(dev);
1083+
iounmap(i2c->reg_base);
10831084
eremap:
10841085
clk_put(i2c->clk);
10851086
eclk:
@@ -1089,7 +1090,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
10891090
return ret;
10901091
}
10911092

1092-
static int i2c_pxa_remove(struct platform_device *dev)
1093+
static int __exit i2c_pxa_remove(struct platform_device *dev)
10931094
{
10941095
struct pxa_i2c *i2c = platform_get_drvdata(dev);
10951096

@@ -1103,6 +1104,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
11031104
clk_put(i2c->clk);
11041105
i2c_pxa_disable(dev);
11051106

1107+
iounmap(i2c->reg_base);
11061108
release_mem_region(i2c->iobase, i2c->iosize);
11071109
kfree(i2c);
11081110

@@ -1111,9 +1113,10 @@ static int i2c_pxa_remove(struct platform_device *dev)
11111113

11121114
static struct platform_driver i2c_pxa_driver = {
11131115
.probe = i2c_pxa_probe,
1114-
.remove = i2c_pxa_remove,
1116+
.remove = __exit_p(i2c_pxa_remove),
11151117
.driver = {
11161118
.name = "pxa2xx-i2c",
1119+
.owner = THIS_MODULE,
11171120
},
11181121
};
11191122

@@ -1122,7 +1125,7 @@ static int __init i2c_adap_pxa_init(void)
11221125
return platform_driver_register(&i2c_pxa_driver);
11231126
}
11241127

1125-
static void i2c_adap_pxa_exit(void)
1128+
static void __exit i2c_adap_pxa_exit(void)
11261129
{
11271130
platform_driver_unregister(&i2c_pxa_driver);
11281131
}

0 commit comments

Comments
 (0)