Skip to content

Commit 9a6cd4b

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: mmc: sdhci: Check mrq != NULL in sdhci_tasklet_finish mmc: sdhci: Check mrq->cmd in sdhci_tasklet_finish mmc: tmio: fix .set_ios(MMC_POWER_UP) handling mmc: fix a race between card-detect rescan and clock-gate work instances mmc: omap: Fix possible NULL pointer deref mmc: core: mmc_add_card(): fix missing break in switch statement mmc: sdhci-pci: Fix error case in sdhci_pci_probe_slot()
2 parents bab0dcc + 0c9c99a commit 9a6cd4b

7 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎drivers/mmc/core/bus.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ int mmc_add_card(struct mmc_card *card)
284284
type = "SD-combo";
285285
if (mmc_card_blockaddr(card))
286286
type = "SDHC-combo";
287+
break;
287288
default:
288289
type = "?";
289290
break;

‎drivers/mmc/core/host.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host)
9494
spin_unlock_irqrestore(&host->clk_lock, flags);
9595
return;
9696
}
97-
mutex_lock(&host->clk_gate_mutex);
97+
mmc_claim_host(host);
9898
spin_lock_irqsave(&host->clk_lock, flags);
9999
if (!host->clk_requests) {
100100
spin_unlock_irqrestore(&host->clk_lock, flags);
@@ -104,7 +104,7 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host)
104104
pr_debug("%s: gated MCI clock\n", mmc_hostname(host));
105105
}
106106
spin_unlock_irqrestore(&host->clk_lock, flags);
107-
mutex_unlock(&host->clk_gate_mutex);
107+
mmc_release_host(host);
108108
}
109109

110110
/*
@@ -130,7 +130,7 @@ void mmc_host_clk_ungate(struct mmc_host *host)
130130
{
131131
unsigned long flags;
132132

133-
mutex_lock(&host->clk_gate_mutex);
133+
mmc_claim_host(host);
134134
spin_lock_irqsave(&host->clk_lock, flags);
135135
if (host->clk_gated) {
136136
spin_unlock_irqrestore(&host->clk_lock, flags);
@@ -140,7 +140,7 @@ void mmc_host_clk_ungate(struct mmc_host *host)
140140
}
141141
host->clk_requests++;
142142
spin_unlock_irqrestore(&host->clk_lock, flags);
143-
mutex_unlock(&host->clk_gate_mutex);
143+
mmc_release_host(host);
144144
}
145145

146146
/**
@@ -215,7 +215,6 @@ static inline void mmc_host_clk_init(struct mmc_host *host)
215215
host->clk_gated = false;
216216
INIT_WORK(&host->clk_gate_work, mmc_host_clk_gate_work);
217217
spin_lock_init(&host->clk_lock);
218-
mutex_init(&host->clk_gate_mutex);
219218
}
220219

221220
/**

‎drivers/mmc/host/omap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
832832
return IRQ_HANDLED;
833833
}
834834

835-
if (end_command)
835+
if (end_command && host->cmd)
836836
mmc_omap_cmd_done(host, host->cmd);
837837
if (host->data != NULL) {
838838
if (transfer_error)

‎drivers/mmc/host/sdhci-pci.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
957957
host->ioaddr = pci_ioremap_bar(pdev, bar);
958958
if (!host->ioaddr) {
959959
dev_err(&pdev->dev, "failed to remap registers\n");
960+
ret = -ENOMEM;
960961
goto release;
961962
}
962963

‎drivers/mmc/host/sdhci.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,13 @@ static void sdhci_tasklet_finish(unsigned long param)
13341334

13351335
host = (struct sdhci_host*)param;
13361336

1337+
/*
1338+
* If this tasklet gets rescheduled while running, it will
1339+
* be run again afterwards but without any active request.
1340+
*/
1341+
if (!host->mrq)
1342+
return;
1343+
13371344
spin_lock_irqsave(&host->lock, flags);
13381345

13391346
del_timer(&host->timer);
@@ -1345,7 +1352,7 @@ static void sdhci_tasklet_finish(unsigned long param)
13451352
* upon error conditions.
13461353
*/
13471354
if (!(host->flags & SDHCI_DEVICE_DEAD) &&
1348-
(mrq->cmd->error ||
1355+
((mrq->cmd && mrq->cmd->error) ||
13491356
(mrq->data && (mrq->data->error ||
13501357
(mrq->data->stop && mrq->data->stop->error))) ||
13511358
(host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {

‎drivers/mmc/host/tmio_mmc_pio.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
728728
tmio_mmc_set_clock(host, ios->clock);
729729

730730
/* Power sequence - OFF -> UP -> ON */
731-
if (ios->power_mode == MMC_POWER_OFF || !ios->clock) {
731+
if (ios->power_mode == MMC_POWER_UP) {
732+
/* power up SD bus */
733+
if (host->set_pwr)
734+
host->set_pwr(host->pdev, 1);
735+
} else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) {
732736
/* power down SD bus */
733737
if (ios->power_mode == MMC_POWER_OFF && host->set_pwr)
734738
host->set_pwr(host->pdev, 0);
735739
tmio_mmc_clk_stop(host);
736-
} else if (ios->power_mode == MMC_POWER_UP) {
737-
/* power up SD bus */
738-
if (host->set_pwr)
739-
host->set_pwr(host->pdev, 1);
740740
} else {
741741
/* start bus clock */
742742
tmio_mmc_clk_start(host);

‎include/linux/mmc/host.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ struct mmc_host {
183183
struct work_struct clk_gate_work; /* delayed clock gate */
184184
unsigned int clk_old; /* old clock value cache */
185185
spinlock_t clk_lock; /* lock for clk fields */
186-
struct mutex clk_gate_mutex; /* mutex for clock gating */
187186
#endif
188187

189188
/* host specific block data */

0 commit comments

Comments
 (0)