Skip to content

Commit 4c92b5b

Browse files
committed
Merge branch 'pcmcia' of git://ftp.arm.linux.org.uk/~rmk/linux-arm
Pull ARM pcmcia updates from Russell King: "A series of changes updating the PXA and SA11x0 PCMCIA code to use devm_* APIs, and resolve some resource leaks in doing so. This results in a few small cleanups which are included in this set. FYI, the recommit of these today is to add Robert Jarzmik's reviewed-by tags, which I'd forgotten to add from mid-July" * 'pcmcia' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: pcmcia: soc_common: remove skt_dev_info's clk pointer pcmcia: sa11xx_base.c: remove useless init/exit functions pcmcia: sa1111: simplify clk handing in sa1111_pcmcia_add() pcmcia: sa1111: update socket driver to use devm_clk_get() API pcmcia: pxa2xx: convert memory allocation to devm_* API pcmcia: pxa2xx: update socket driver to use devm_clk_get() API pcmcia: sa11x0: convert memory allocation to devm_* API pcmcia: sa11x0: fix missing clk_put() in sa11x0 socket drivers
2 parents c706c7e + fca8b80 commit 4c92b5b

5 files changed

Lines changed: 14 additions & 37 deletions

File tree

‎drivers/pcmcia/pxa2xx_base.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,20 +296,18 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
296296
goto err0;
297297
}
298298

299-
clk = clk_get(&dev->dev, NULL);
299+
clk = devm_clk_get(&dev->dev, NULL);
300300
if (IS_ERR(clk))
301301
return -ENODEV;
302302

303303
pxa2xx_drv_pcmcia_ops(ops);
304304

305-
sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
306-
if (!sinfo) {
307-
clk_put(clk);
305+
sinfo = devm_kzalloc(&dev->dev, SKT_DEV_INFO_SIZE(ops->nr),
306+
GFP_KERNEL);
307+
if (!sinfo)
308308
return -ENOMEM;
309-
}
310309

311310
sinfo->nskt = ops->nr;
312-
sinfo->clk = clk;
313311

314312
/* Initialize processor specific parameters */
315313
for (i = 0; i < ops->nr; i++) {
@@ -332,8 +330,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
332330
err1:
333331
while (--i >= 0)
334332
soc_pcmcia_remove_one(&sinfo->skt[i]);
335-
clk_put(clk);
336-
kfree(sinfo);
333+
337334
err0:
338335
return ret;
339336
}
@@ -343,13 +340,9 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
343340
struct skt_dev_info *sinfo = platform_get_drvdata(dev);
344341
int i;
345342

346-
platform_set_drvdata(dev, NULL);
347-
348343
for (i = 0; i < sinfo->nskt; i++)
349344
soc_pcmcia_remove_one(&sinfo->skt[i]);
350345

351-
clk_put(sinfo->clk);
352-
kfree(sinfo);
353346
return 0;
354347
}
355348

‎drivers/pcmcia/sa1100_generic.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
9393
for (i = 0; i < sinfo->nskt; i++)
9494
soc_pcmcia_remove_one(&sinfo->skt[i]);
9595

96-
clk_put(sinfo->clk);
97-
kfree(sinfo);
9896
return 0;
9997
}
10098

‎drivers/pcmcia/sa1111_generic.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,13 @@ int sa1111_pcmcia_add(struct sa1111_dev *dev, struct pcmcia_low_level *ops,
135135
int (*add)(struct soc_pcmcia_socket *))
136136
{
137137
struct sa1111_pcmcia_socket *s;
138+
struct clk *clk;
138139
int i, ret = 0;
139140

141+
clk = devm_clk_get(&dev->dev, NULL);
142+
if (IS_ERR(clk))
143+
return PTR_ERR(clk);
144+
140145
ops->socket_state = sa1111_pcmcia_socket_state;
141146

142147
for (i = 0; i < ops->nr; i++) {
@@ -145,12 +150,8 @@ int sa1111_pcmcia_add(struct sa1111_dev *dev, struct pcmcia_low_level *ops,
145150
return -ENOMEM;
146151

147152
s->soc.nr = ops->first + i;
148-
s->soc.clk = clk_get(&dev->dev, NULL);
149-
if (IS_ERR(s->soc.clk)) {
150-
ret = PTR_ERR(s->soc.clk);
151-
kfree(s);
152-
return ret;
153-
}
153+
s->soc.clk = clk;
154+
154155
soc_pcmcia_init_one(&s->soc, ops, &dev->dev);
155156
s->dev = dev;
156157
if (s->soc.nr) {
@@ -226,7 +227,6 @@ static int pcmcia_remove(struct sa1111_dev *dev)
226227
for (; s; s = next) {
227228
next = s->next;
228229
soc_pcmcia_remove_one(&s->soc);
229-
clk_put(s->soc.clk);
230230
kfree(s);
231231
}
232232

‎drivers/pcmcia/sa11xx_base.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,17 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
222222
int i, ret = 0;
223223
struct clk *clk;
224224

225-
clk = clk_get(dev, NULL);
225+
clk = devm_clk_get(dev, NULL);
226226
if (IS_ERR(clk))
227227
return PTR_ERR(clk);
228228

229229
sa11xx_drv_pcmcia_ops(ops);
230230

231-
sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
231+
sinfo = devm_kzalloc(dev, SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
232232
if (!sinfo)
233233
return -ENOMEM;
234234

235235
sinfo->nskt = nr;
236-
sinfo->clk = clk;
237236

238237
/* Initialize processor specific parameters */
239238
for (i = 0; i < nr; i++) {
@@ -251,8 +250,6 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
251250
if (ret) {
252251
while (--i >= 0)
253252
soc_pcmcia_remove_one(&sinfo->skt[i]);
254-
clk_put(clk);
255-
kfree(sinfo);
256253
} else {
257254
dev_set_drvdata(dev, sinfo);
258255
}
@@ -261,16 +258,6 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
261258
}
262259
EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
263260

264-
static int __init sa11xx_pcmcia_init(void)
265-
{
266-
return 0;
267-
}
268-
fs_initcall(sa11xx_pcmcia_init);
269-
270-
static void __exit sa11xx_pcmcia_exit(void) {}
271-
272-
module_exit(sa11xx_pcmcia_exit);
273-
274261
MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
275262
MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver");
276263
MODULE_LICENSE("Dual MPL/GPL");

‎drivers/pcmcia/soc_common.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct soc_pcmcia_socket {
6868

6969
struct skt_dev_info {
7070
int nskt;
71-
struct clk *clk;
7271
struct soc_pcmcia_socket skt[0];
7372
};
7473

0 commit comments

Comments
 (0)