Commit 6685ac62 authored by Ulf Hansson's avatar Ulf Hansson

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: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 0967edc6
...@@ -2425,8 +2425,9 @@ static const struct mmc_fixup blk_fixups[] = ...@@ -2425,8 +2425,9 @@ static const struct mmc_fixup blk_fixups[] =
END_FIXUP END_FIXUP
}; };
static int mmc_blk_probe(struct mmc_card *card) static int mmc_blk_probe(struct device *dev)
{ {
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_blk_data *md, *part_md; struct mmc_blk_data *md, *part_md;
char cap_str[10]; char cap_str[10];
...@@ -2481,8 +2482,9 @@ static int mmc_blk_probe(struct mmc_card *card) ...@@ -2481,8 +2482,9 @@ static int mmc_blk_probe(struct mmc_card *card)
return 0; return 0;
} }
static void mmc_blk_remove(struct mmc_card *card) static int mmc_blk_remove(struct device *dev)
{ {
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_blk_data *md = mmc_get_drvdata(card); struct mmc_blk_data *md = mmc_get_drvdata(card);
mmc_blk_remove_parts(card, md); mmc_blk_remove_parts(card, md);
...@@ -2495,11 +2497,14 @@ static void mmc_blk_remove(struct mmc_card *card) ...@@ -2495,11 +2497,14 @@ static void mmc_blk_remove(struct mmc_card *card)
pm_runtime_put_noidle(&card->dev); pm_runtime_put_noidle(&card->dev);
mmc_blk_remove_req(md); mmc_blk_remove_req(md);
mmc_set_drvdata(card, NULL); mmc_set_drvdata(card, NULL);
return 0;
} }
static int _mmc_blk_suspend(struct mmc_card *card) static int _mmc_blk_suspend(struct device *dev)
{ {
struct mmc_blk_data *part_md; struct mmc_blk_data *part_md;
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_blk_data *md = mmc_get_drvdata(card); struct mmc_blk_data *md = mmc_get_drvdata(card);
if (md) { if (md) {
...@@ -2511,16 +2516,15 @@ static int _mmc_blk_suspend(struct mmc_card *card) ...@@ -2511,16 +2516,15 @@ static int _mmc_blk_suspend(struct mmc_card *card)
return 0; return 0;
} }
static void mmc_blk_shutdown(struct mmc_card *card) static void mmc_blk_shutdown(struct device *dev)
{ {
_mmc_blk_suspend(card); _mmc_blk_suspend(dev);
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int mmc_blk_suspend(struct device *dev) static int mmc_blk_suspend(struct device *dev)
{ {
struct mmc_card *card = mmc_dev_to_card(dev); return _mmc_blk_suspend(dev);
return _mmc_blk_suspend(card);
} }
static int mmc_blk_resume(struct device *dev) static int mmc_blk_resume(struct device *dev)
...@@ -2546,11 +2550,9 @@ static int mmc_blk_resume(struct device *dev) ...@@ -2546,11 +2550,9 @@ static int mmc_blk_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(mmc_blk_pm_ops, mmc_blk_suspend, mmc_blk_resume); static SIMPLE_DEV_PM_OPS(mmc_blk_pm_ops, mmc_blk_suspend, mmc_blk_resume);
static struct mmc_driver mmc_driver = { static struct device_driver mmc_driver = {
.drv = {
.name = "mmcblk", .name = "mmcblk",
.pm = &mmc_blk_pm_ops, .pm = &mmc_blk_pm_ops,
},
.probe = mmc_blk_probe, .probe = mmc_blk_probe,
.remove = mmc_blk_remove, .remove = mmc_blk_remove,
.shutdown = mmc_blk_shutdown, .shutdown = mmc_blk_shutdown,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/mmc/mmc.h> #include <linux/mmc/mmc.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/device.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/swap.h> /* For nr_free_buffer_pages() */ #include <linux/swap.h> /* For nr_free_buffer_pages() */
...@@ -2997,8 +2998,9 @@ static int mmc_test_register_dbgfs_file(struct mmc_card *card) ...@@ -2997,8 +2998,9 @@ static int mmc_test_register_dbgfs_file(struct mmc_card *card)
return ret; return ret;
} }
static int mmc_test_probe(struct mmc_card *card) static int mmc_test_probe(struct device *dev)
{ {
struct mmc_card *card = mmc_dev_to_card(dev);
int ret; int ret;
if (!mmc_card_mmc(card) && !mmc_card_sd(card)) if (!mmc_card_mmc(card) && !mmc_card_sd(card))
...@@ -3013,20 +3015,22 @@ static int mmc_test_probe(struct mmc_card *card) ...@@ -3013,20 +3015,22 @@ static int mmc_test_probe(struct mmc_card *card)
return 0; return 0;
} }
static void mmc_test_remove(struct mmc_card *card) static int mmc_test_remove(struct device *dev)
{ {
struct mmc_card *card = mmc_dev_to_card(dev);
mmc_test_free_result(card); mmc_test_free_result(card);
mmc_test_free_dbgfs_file(card); mmc_test_free_dbgfs_file(card);
return 0;
} }
static void mmc_test_shutdown(struct mmc_card *card) static void mmc_test_shutdown(struct device *dev)
{ {
} }
static struct mmc_driver mmc_driver = { static struct device_driver mmc_driver = {
.drv = {
.name = "mmc_test", .name = "mmc_test",
},
.probe = mmc_test_probe, .probe = mmc_test_probe,
.remove = mmc_test_remove, .remove = mmc_test_remove,
.shutdown = mmc_test_shutdown, .shutdown = mmc_test_shutdown,
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "sdio_cis.h" #include "sdio_cis.h"
#include "bus.h" #include "bus.h"
#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv)
static ssize_t type_show(struct device *dev, static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -106,33 +104,14 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) ...@@ -106,33 +104,14 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
return retval; return retval;
} }
static int mmc_bus_probe(struct device *dev)
{
struct mmc_driver *drv = to_mmc_driver(dev->driver);
struct mmc_card *card = mmc_dev_to_card(dev);
return drv->probe(card);
}
static int mmc_bus_remove(struct device *dev)
{
struct mmc_driver *drv = to_mmc_driver(dev->driver);
struct mmc_card *card = mmc_dev_to_card(dev);
drv->remove(card);
return 0;
}
static void mmc_bus_shutdown(struct device *dev) static void mmc_bus_shutdown(struct device *dev)
{ {
struct mmc_driver *drv = to_mmc_driver(dev->driver);
struct mmc_card *card = mmc_dev_to_card(dev); struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_host *host = card->host; struct mmc_host *host = card->host;
int ret; int ret;
if (dev->driver && drv->shutdown) if (dev->driver && dev->driver->shutdown)
drv->shutdown(card); dev->driver->shutdown(dev);
if (host->bus_ops->shutdown) { if (host->bus_ops->shutdown) {
ret = host->bus_ops->shutdown(host); ret = host->bus_ops->shutdown(host);
...@@ -201,8 +180,6 @@ static struct bus_type mmc_bus_type = { ...@@ -201,8 +180,6 @@ static struct bus_type mmc_bus_type = {
.dev_groups = mmc_dev_groups, .dev_groups = mmc_dev_groups,
.match = mmc_bus_match, .match = mmc_bus_match,
.uevent = mmc_bus_uevent, .uevent = mmc_bus_uevent,
.probe = mmc_bus_probe,
.remove = mmc_bus_remove,
.shutdown = mmc_bus_shutdown, .shutdown = mmc_bus_shutdown,
.pm = &mmc_bus_pm_ops, .pm = &mmc_bus_pm_ops,
}; };
...@@ -221,24 +198,22 @@ void mmc_unregister_bus(void) ...@@ -221,24 +198,22 @@ void mmc_unregister_bus(void)
* mmc_register_driver - register a media driver * mmc_register_driver - register a media driver
* @drv: MMC media driver * @drv: MMC media driver
*/ */
int mmc_register_driver(struct mmc_driver *drv) int mmc_register_driver(struct device_driver *drv)
{ {
drv->drv.bus = &mmc_bus_type; drv->bus = &mmc_bus_type;
return driver_register(&drv->drv); return driver_register(drv);
} }
EXPORT_SYMBOL(mmc_register_driver); EXPORT_SYMBOL(mmc_register_driver);
/** /**
* mmc_unregister_driver - unregister a media driver * mmc_unregister_driver - unregister a media driver
* @drv: MMC media driver * @drv: MMC media driver
*/ */
void mmc_unregister_driver(struct mmc_driver *drv) void mmc_unregister_driver(struct device_driver *drv)
{ {
drv->drv.bus = &mmc_bus_type; drv->bus = &mmc_bus_type;
driver_unregister(&drv->drv); driver_unregister(drv);
} }
EXPORT_SYMBOL(mmc_unregister_driver); EXPORT_SYMBOL(mmc_unregister_driver);
static void mmc_release_card(struct device *dev) static void mmc_release_card(struct device *dev)
......
...@@ -513,20 +513,8 @@ static inline int mmc_card_broken_irq_polling(const struct mmc_card *c) ...@@ -513,20 +513,8 @@ static inline int mmc_card_broken_irq_polling(const struct mmc_card *c)
#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev) #define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d) #define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
/* extern int mmc_register_driver(struct device_driver *);
* MMC device driver (e.g., Flash card, I/O card...) extern void mmc_unregister_driver(struct device_driver *);
*/
struct mmc_driver {
struct device_driver drv;
int (*probe)(struct mmc_card *);
void (*remove)(struct mmc_card *);
int (*suspend)(struct mmc_card *);
int (*resume)(struct mmc_card *);
void (*shutdown)(struct mmc_card *);
};
extern int mmc_register_driver(struct mmc_driver *);
extern void mmc_unregister_driver(struct mmc_driver *);
extern void mmc_fixup_device(struct mmc_card *card, extern void mmc_fixup_device(struct mmc_card *card,
const struct mmc_fixup *table); const struct mmc_fixup *table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment