diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2014-10-06 07:51:40 -0400 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2014-11-10 06:40:33 -0500 |
commit | 6685ac62b2f08fcff77dc35c6b8bff1b74aaa408 (patch) | |
tree | 8fb75914fa7c3bea075f659b1f40524317e47a0c | |
parent | 0967edc6ef5c3c181cabde3178ea9f33e5130e4a (diff) |
mmc: core: Convert mmc_driver to device_driver
The struct mmc_driver adds an extra layer on top of the struct
device_driver. That would be fine, if there were a good reason, but
that's not the case.
Let's simplify code by converting to the common struct device_driver
instead and thus also removing superfluous overhead.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | drivers/mmc/card/block.c | 26 | ||||
-rw-r--r-- | drivers/mmc/card/mmc_test.c | 18 | ||||
-rw-r--r-- | drivers/mmc/core/bus.c | 41 | ||||
-rw-r--r-- | include/linux/mmc/card.h | 16 |
4 files changed, 35 insertions, 66 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index dfbdfb995dd3..70569d9b5c74 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -2425,8 +2425,9 @@ static const struct mmc_fixup blk_fixups[] = | |||
2425 | END_FIXUP | 2425 | END_FIXUP |
2426 | }; | 2426 | }; |
2427 | 2427 | ||
2428 | static int mmc_blk_probe(struct mmc_card *card) | 2428 | static int mmc_blk_probe(struct device *dev) |
2429 | { | 2429 | { |
2430 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
2430 | struct mmc_blk_data *md, *part_md; | 2431 | struct mmc_blk_data *md, *part_md; |
2431 | char cap_str[10]; | 2432 | char cap_str[10]; |
2432 | 2433 | ||
@@ -2481,8 +2482,9 @@ static int mmc_blk_probe(struct mmc_card *card) | |||
2481 | return 0; | 2482 | return 0; |
2482 | } | 2483 | } |
2483 | 2484 | ||
2484 | static void mmc_blk_remove(struct mmc_card *card) | 2485 | static int mmc_blk_remove(struct device *dev) |
2485 | { | 2486 | { |
2487 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
2486 | struct mmc_blk_data *md = mmc_get_drvdata(card); | 2488 | struct mmc_blk_data *md = mmc_get_drvdata(card); |
2487 | 2489 | ||
2488 | mmc_blk_remove_parts(card, md); | 2490 | mmc_blk_remove_parts(card, md); |
@@ -2495,11 +2497,14 @@ static void mmc_blk_remove(struct mmc_card *card) | |||
2495 | pm_runtime_put_noidle(&card->dev); | 2497 | pm_runtime_put_noidle(&card->dev); |
2496 | mmc_blk_remove_req(md); | 2498 | mmc_blk_remove_req(md); |
2497 | mmc_set_drvdata(card, NULL); | 2499 | mmc_set_drvdata(card, NULL); |
2500 | |||
2501 | return 0; | ||
2498 | } | 2502 | } |
2499 | 2503 | ||
2500 | static int _mmc_blk_suspend(struct mmc_card *card) | 2504 | static int _mmc_blk_suspend(struct device *dev) |
2501 | { | 2505 | { |
2502 | struct mmc_blk_data *part_md; | 2506 | struct mmc_blk_data *part_md; |
2507 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
2503 | struct mmc_blk_data *md = mmc_get_drvdata(card); | 2508 | struct mmc_blk_data *md = mmc_get_drvdata(card); |
2504 | 2509 | ||
2505 | if (md) { | 2510 | if (md) { |
@@ -2511,16 +2516,15 @@ static int _mmc_blk_suspend(struct mmc_card *card) | |||
2511 | return 0; | 2516 | return 0; |
2512 | } | 2517 | } |
2513 | 2518 | ||
2514 | static void mmc_blk_shutdown(struct mmc_card *card) | 2519 | static void mmc_blk_shutdown(struct device *dev) |
2515 | { | 2520 | { |
2516 | _mmc_blk_suspend(card); | 2521 | _mmc_blk_suspend(dev); |
2517 | } | 2522 | } |
2518 | 2523 | ||
2519 | #ifdef CONFIG_PM_SLEEP | 2524 | #ifdef CONFIG_PM_SLEEP |
2520 | static int mmc_blk_suspend(struct device *dev) | 2525 | static int mmc_blk_suspend(struct device *dev) |
2521 | { | 2526 | { |
2522 | struct mmc_card *card = mmc_dev_to_card(dev); | 2527 | return _mmc_blk_suspend(dev); |
2523 | return _mmc_blk_suspend(card); | ||
2524 | } | 2528 | } |
2525 | 2529 | ||
2526 | static int mmc_blk_resume(struct device *dev) | 2530 | static int mmc_blk_resume(struct device *dev) |
@@ -2546,11 +2550,9 @@ static int mmc_blk_resume(struct device *dev) | |||
2546 | 2550 | ||
2547 | static SIMPLE_DEV_PM_OPS(mmc_blk_pm_ops, mmc_blk_suspend, mmc_blk_resume); | 2551 | static SIMPLE_DEV_PM_OPS(mmc_blk_pm_ops, mmc_blk_suspend, mmc_blk_resume); |
2548 | 2552 | ||
2549 | static struct mmc_driver mmc_driver = { | 2553 | static struct device_driver mmc_driver = { |
2550 | .drv = { | 2554 | .name = "mmcblk", |
2551 | .name = "mmcblk", | 2555 | .pm = &mmc_blk_pm_ops, |
2552 | .pm = &mmc_blk_pm_ops, | ||
2553 | }, | ||
2554 | .probe = mmc_blk_probe, | 2556 | .probe = mmc_blk_probe, |
2555 | .remove = mmc_blk_remove, | 2557 | .remove = mmc_blk_remove, |
2556 | .shutdown = mmc_blk_shutdown, | 2558 | .shutdown = mmc_blk_shutdown, |
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 0c0fc52d42c5..b0643432d6d9 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/mmc/host.h> | 14 | #include <linux/mmc/host.h> |
15 | #include <linux/mmc/mmc.h> | 15 | #include <linux/mmc/mmc.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/device.h> | ||
17 | 18 | ||
18 | #include <linux/scatterlist.h> | 19 | #include <linux/scatterlist.h> |
19 | #include <linux/swap.h> /* For nr_free_buffer_pages() */ | 20 | #include <linux/swap.h> /* For nr_free_buffer_pages() */ |
@@ -2997,8 +2998,9 @@ err: | |||
2997 | return ret; | 2998 | return ret; |
2998 | } | 2999 | } |
2999 | 3000 | ||
3000 | static int mmc_test_probe(struct mmc_card *card) | 3001 | static int mmc_test_probe(struct device *dev) |
3001 | { | 3002 | { |
3003 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
3002 | int ret; | 3004 | int ret; |
3003 | 3005 | ||
3004 | if (!mmc_card_mmc(card) && !mmc_card_sd(card)) | 3006 | if (!mmc_card_mmc(card) && !mmc_card_sd(card)) |
@@ -3013,20 +3015,22 @@ static int mmc_test_probe(struct mmc_card *card) | |||
3013 | return 0; | 3015 | return 0; |
3014 | } | 3016 | } |
3015 | 3017 | ||
3016 | static void mmc_test_remove(struct mmc_card *card) | 3018 | static int mmc_test_remove(struct device *dev) |
3017 | { | 3019 | { |
3020 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
3021 | |||
3018 | mmc_test_free_result(card); | 3022 | mmc_test_free_result(card); |
3019 | mmc_test_free_dbgfs_file(card); | 3023 | mmc_test_free_dbgfs_file(card); |
3024 | |||
3025 | return 0; | ||
3020 | } | 3026 | } |
3021 | 3027 | ||
3022 | static void mmc_test_shutdown(struct mmc_card *card) | 3028 | static void mmc_test_shutdown(struct device *dev) |
3023 | { | 3029 | { |
3024 | } | 3030 | } |
3025 | 3031 | ||
3026 | static struct mmc_driver mmc_driver = { | 3032 | static struct device_driver mmc_driver = { |
3027 | .drv = { | 3033 | .name = "mmc_test", |
3028 | .name = "mmc_test", | ||
3029 | }, | ||
3030 | .probe = mmc_test_probe, | 3034 | .probe = mmc_test_probe, |
3031 | .remove = mmc_test_remove, | 3035 | .remove = mmc_test_remove, |
3032 | .shutdown = mmc_test_shutdown, | 3036 | .shutdown = mmc_test_shutdown, |
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 2f375283c423..5ca562ccfcf3 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include "sdio_cis.h" | 25 | #include "sdio_cis.h" |
26 | #include "bus.h" | 26 | #include "bus.h" |
27 | 27 | ||
28 | #define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) | ||
29 | |||
30 | static ssize_t type_show(struct device *dev, | 28 | static ssize_t type_show(struct device *dev, |
31 | struct device_attribute *attr, char *buf) | 29 | struct device_attribute *attr, char *buf) |
32 | { | 30 | { |
@@ -106,33 +104,14 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
106 | return retval; | 104 | return retval; |
107 | } | 105 | } |
108 | 106 | ||
109 | static int mmc_bus_probe(struct device *dev) | ||
110 | { | ||
111 | struct mmc_driver *drv = to_mmc_driver(dev->driver); | ||
112 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
113 | |||
114 | return drv->probe(card); | ||
115 | } | ||
116 | |||
117 | static int mmc_bus_remove(struct device *dev) | ||
118 | { | ||
119 | struct mmc_driver *drv = to_mmc_driver(dev->driver); | ||
120 | struct mmc_card *card = mmc_dev_to_card(dev); | ||
121 | |||
122 | drv->remove(card); | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static void mmc_bus_shutdown(struct device *dev) | 107 | static void mmc_bus_shutdown(struct device *dev) |
128 | { | 108 | { |
129 | struct mmc_driver *drv = to_mmc_driver(dev->driver); | ||
130 | struct mmc_card *card = mmc_dev_to_card(dev); | 109 | struct mmc_card *card = mmc_dev_to_card(dev); |
131 | struct mmc_host *host = card->host; | 110 | struct mmc_host *host = card->host; |
132 | int ret; | 111 | int ret; |
133 | 112 | ||
134 | if (dev->driver && drv->shutdown) | 113 | if (dev->driver && dev->driver->shutdown) |
135 | drv->shutdown(card); | 114 | dev->driver->shutdown(dev); |
136 | 115 | ||
137 | if (host->bus_ops->shutdown) { | 116 | if (host->bus_ops->shutdown) { |
138 | ret = host->bus_ops->shutdown(host); | 117 | ret = host->bus_ops->shutdown(host); |
@@ -201,8 +180,6 @@ static struct bus_type mmc_bus_type = { | |||
201 | .dev_groups = mmc_dev_groups, | 180 | .dev_groups = mmc_dev_groups, |
202 | .match = mmc_bus_match, | 181 | .match = mmc_bus_match, |
203 | .uevent = mmc_bus_uevent, | 182 | .uevent = mmc_bus_uevent, |
204 | .probe = mmc_bus_probe, | ||
205 | .remove = mmc_bus_remove, | ||
206 | .shutdown = mmc_bus_shutdown, | 183 | .shutdown = mmc_bus_shutdown, |
207 | .pm = &mmc_bus_pm_ops, | 184 | .pm = &mmc_bus_pm_ops, |
208 | }; | 185 | }; |
@@ -221,24 +198,22 @@ void mmc_unregister_bus(void) | |||
221 | * mmc_register_driver - register a media driver | 198 | * mmc_register_driver - register a media driver |
222 | * @drv: MMC media driver | 199 | * @drv: MMC media driver |
223 | */ | 200 | */ |
224 | int mmc_register_driver(struct mmc_driver *drv) | 201 | int mmc_register_driver(struct device_driver *drv) |
225 | { | 202 | { |
226 | drv->drv.bus = &mmc_bus_type; | 203 | drv->bus = &mmc_bus_type; |
227 | return driver_register(&drv->drv); | 204 | return driver_register(drv); |
228 | } | 205 | } |
229 | |||
230 | EXPORT_SYMBOL(mmc_register_driver); | 206 | EXPORT_SYMBOL(mmc_register_driver); |
231 | 207 | ||
232 | /** | 208 | /** |
233 | * mmc_unregister_driver - unregister a media driver | 209 | * mmc_unregister_driver - unregister a media driver |
234 | * @drv: MMC media driver | 210 | * @drv: MMC media driver |
235 | */ | 211 | */ |
236 | void mmc_unregister_driver(struct mmc_driver *drv) | 212 | void mmc_unregister_driver(struct device_driver *drv) |
237 | { | 213 | { |
238 | drv->drv.bus = &mmc_bus_type; | 214 | drv->bus = &mmc_bus_type; |
239 | driver_unregister(&drv->drv); | 215 | driver_unregister(drv); |
240 | } | 216 | } |
241 | |||
242 | EXPORT_SYMBOL(mmc_unregister_driver); | 217 | EXPORT_SYMBOL(mmc_unregister_driver); |
243 | 218 | ||
244 | static void mmc_release_card(struct device *dev) | 219 | static void mmc_release_card(struct device *dev) |
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index b0692d28f8e6..cf54afe5d863 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h | |||
@@ -513,20 +513,8 @@ static inline int mmc_card_broken_irq_polling(const struct mmc_card *c) | |||
513 | #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev) | 513 | #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev) |
514 | #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d) | 514 | #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d) |
515 | 515 | ||
516 | /* | 516 | extern int mmc_register_driver(struct device_driver *); |
517 | * MMC device driver (e.g., Flash card, I/O card...) | 517 | extern void mmc_unregister_driver(struct device_driver *); |
518 | */ | ||
519 | struct mmc_driver { | ||
520 | struct device_driver drv; | ||
521 | int (*probe)(struct mmc_card *); | ||
522 | void (*remove)(struct mmc_card *); | ||
523 | int (*suspend)(struct mmc_card *); | ||
524 | int (*resume)(struct mmc_card *); | ||
525 | void (*shutdown)(struct mmc_card *); | ||
526 | }; | ||
527 | |||
528 | extern int mmc_register_driver(struct mmc_driver *); | ||
529 | extern void mmc_unregister_driver(struct mmc_driver *); | ||
530 | 518 | ||
531 | extern void mmc_fixup_device(struct mmc_card *card, | 519 | extern void mmc_fixup_device(struct mmc_card *card, |
532 | const struct mmc_fixup *table); | 520 | const struct mmc_fixup *table); |