aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/pwrseq_emmc.c
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2015-02-11 23:36:11 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2015-03-23 09:13:42 -0400
commit0f12a0ce4ce4a47d8a34399a3f22d4ce7fd2d908 (patch)
tree45881949b4b087be7de8c7527b3ae0ec31a11cbc /drivers/mmc/core/pwrseq_emmc.c
parentd34712d2e3db9b241d0484a6e3839c6b7ef9df78 (diff)
mmc: pwrseq: simplify alloc/free hooks
The alloc() and free() hooks required each pwrseq implementation to set host->pwrseq themselves. This is error-prone and could be done at a higher level if alloc() was changed to return a pointer to a struct mmc_pwrseq instead of an error code. This patch performs this change and moves the burden of maintaining host->pwrseq from the power sequence hooks to the pwrseq code. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/core/pwrseq_emmc.c')
-rw-r--r--drivers/mmc/core/pwrseq_emmc.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c
index a2d545904fbf..9d6d2fb21796 100644
--- a/drivers/mmc/core/pwrseq_emmc.c
+++ b/drivers/mmc/core/pwrseq_emmc.c
@@ -49,7 +49,6 @@ static void mmc_pwrseq_emmc_free(struct mmc_host *host)
49 unregister_restart_handler(&pwrseq->reset_nb); 49 unregister_restart_handler(&pwrseq->reset_nb);
50 gpiod_put(pwrseq->reset_gpio); 50 gpiod_put(pwrseq->reset_gpio);
51 kfree(pwrseq); 51 kfree(pwrseq);
52 host->pwrseq = NULL;
53} 52}
54 53
55static struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { 54static struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = {
@@ -67,14 +66,15 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
67 return NOTIFY_DONE; 66 return NOTIFY_DONE;
68} 67}
69 68
70int mmc_pwrseq_emmc_alloc(struct mmc_host *host, struct device *dev) 69struct mmc_pwrseq *mmc_pwrseq_emmc_alloc(struct mmc_host *host,
70 struct device *dev)
71{ 71{
72 struct mmc_pwrseq_emmc *pwrseq; 72 struct mmc_pwrseq_emmc *pwrseq;
73 int ret = 0; 73 int ret = 0;
74 74
75 pwrseq = kzalloc(sizeof(struct mmc_pwrseq_emmc), GFP_KERNEL); 75 pwrseq = kzalloc(sizeof(struct mmc_pwrseq_emmc), GFP_KERNEL);
76 if (!pwrseq) 76 if (!pwrseq)
77 return -ENOMEM; 77 return ERR_PTR(-ENOMEM);
78 78
79 pwrseq->reset_gpio = gpiod_get_index(dev, "reset", 0, GPIOD_OUT_LOW); 79 pwrseq->reset_gpio = gpiod_get_index(dev, "reset", 0, GPIOD_OUT_LOW);
80 if (IS_ERR(pwrseq->reset_gpio)) { 80 if (IS_ERR(pwrseq->reset_gpio)) {
@@ -92,10 +92,9 @@ int mmc_pwrseq_emmc_alloc(struct mmc_host *host, struct device *dev)
92 register_restart_handler(&pwrseq->reset_nb); 92 register_restart_handler(&pwrseq->reset_nb);
93 93
94 pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops; 94 pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops;
95 host->pwrseq = &pwrseq->pwrseq;
96 95
97 return 0; 96 return &pwrseq->pwrseq;
98free: 97free:
99 kfree(pwrseq); 98 kfree(pwrseq);
100 return ret; 99 return ERR_PTR(ret);
101} 100}