Skip to content

Commit

Permalink
mmc: block: Use dev_set|get_drvdata()
Browse files Browse the repository at this point in the history
In most of the cases mmc_get|set_drvdata() didn't simplify code, which
should be the primary reason for such macros.

Let's remove them and convert to the common device_driver macros,
dev_set|get_drvdata() instead.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Ulf Hansson committed Nov 10, 2014
1 parent eaaceb6 commit fc95e30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 10 additions & 11 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct mmc_blk_data {

/*
* Only set in main mmc_blk_data associated
* with mmc_card with mmc_set_drvdata, and keeps
* with mmc_card with dev_set_drvdata, and keeps
* track of the current selected device partition.
*/
unsigned int part_curr;
Expand Down Expand Up @@ -642,7 +642,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card,
struct mmc_blk_data *md)
{
int ret;
struct mmc_blk_data *main_md = mmc_get_drvdata(card);
struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev);

if (main_md->part_curr == md->part_type)
return 0;
Expand Down Expand Up @@ -1004,7 +1004,8 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
err = mmc_hw_reset(host);
/* Ensure we switch back to the correct partition */
if (err != -EOPNOTSUPP) {
struct mmc_blk_data *main_md = mmc_get_drvdata(host->card);
struct mmc_blk_data *main_md =
dev_get_drvdata(&host->card->dev);
int part_err;

main_md->part_curr = main_md->part_type;
Expand Down Expand Up @@ -2093,7 +2094,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,

/*
* !subname implies we are creating main mmc_blk_data that will be
* associated with mmc_card with mmc_set_drvdata. Due to device
* associated with mmc_card with dev_set_drvdata. Due to device
* partitions, devidx will not coincide with a per-physical card
* index anymore so we keep track of a name index.
*/
Expand Down Expand Up @@ -2452,7 +2453,7 @@ static int mmc_blk_probe(struct device *dev)
if (mmc_blk_alloc_parts(card, md))
goto out;

mmc_set_drvdata(card, md);
dev_set_drvdata(dev, md);

if (mmc_add_disk(md))
goto out;
Expand Down Expand Up @@ -2485,7 +2486,7 @@ static int mmc_blk_probe(struct device *dev)
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 = dev_get_drvdata(dev);

mmc_blk_remove_parts(card, md);
pm_runtime_get_sync(&card->dev);
Expand All @@ -2496,16 +2497,15 @@ static int mmc_blk_remove(struct device *dev)
pm_runtime_disable(&card->dev);
pm_runtime_put_noidle(&card->dev);
mmc_blk_remove_req(md);
mmc_set_drvdata(card, NULL);
dev_set_drvdata(dev, NULL);

return 0;
}

static int _mmc_blk_suspend(struct device *dev)
{
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 = dev_get_drvdata(dev);

if (md) {
mmc_queue_suspend(&md->queue);
Expand All @@ -2530,8 +2530,7 @@ static int mmc_blk_suspend(struct device *dev)
static int mmc_blk_resume(struct device *dev)
{
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 = dev_get_drvdata(dev);

if (md) {
/*
Expand Down
2 changes: 0 additions & 2 deletions include/linux/mmc/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,6 @@ static inline int mmc_card_broken_irq_polling(const struct mmc_card *c)
#define mmc_dev_to_card(d) container_of(d, struct mmc_card, dev)

#define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)

extern int mmc_register_driver(struct device_driver *);
extern void mmc_unregister_driver(struct device_driver *);
Expand Down

0 comments on commit fc95e30

Please sign in to comment.