mmc: usdhi6rol0: handle probe deferral for regulator
Subsystems (2)
PATCH 1/3 mmc: usdhi6rol0: handle probe deferral for regulator
We ignore errors from mmc_regulator_get_supply() because the usage of the regulators is optional for the driver, but we still need to check for and handle EPROBE_DEFER, like it's done in for example dw_mmc. Otherwise we might end up not using the specified regulators just because of probe order.
--- drivers/mmc/host/usdhi6rol0.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/usdhi6rol0.c +4 -2
@@ -1715,12 +1715,14 @@ static int usdhi6_probe(struct platform_device *pdev)if (!mmc)return -ENOMEM ; + ret =mmc_regulator_get_supply (mmc); +if (ret == -EPROBE_DEFER ) + goto e_free_mmc; + ret =mmc_of_parse (mmc);if (ret <0 ) goto e_free_mmc; -mmc_regulator_get_supply (mmc); - host =mmc_priv (mmc); host->mmc = mmc; host->wait =USDHI6_WAIT_FOR_REQUEST ;
Signature · 1 line
1.7.10.4
PATCH 2/3 mmc: usdhi6rol0: fix NULL pointer deref in debug print
host->sg is only set when we're transferring multiple blocks. Check for its availibility before dereferencing it in the timeout work debug print.
--- drivers/mmc/host/usdhi6rol0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +2 -1
@@ -1634,6 +1634,7 @@ static void usdhi6_timeout_work(struct work_struct *work) struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);struct mmc_request *mrq = host->mrq;struct mmc_data *data = mrq ? mrq->data :NULL ; +struct scatterlist *sg = host->sg ?: data->sg; dev_warn(mmc_dev(host->mmc), "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",
@@ -1669,7 +1670,7 @@ static void usdhi6_timeout_work(struct work_struct *work)"%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n" , data->flags &MMC_DATA_READ ?'R' :'W' , host->page_idx, host->offset, data->blocks, data->blksz, data->sg_len, - sg_dma_len(host->sg), host->sg->offset); + sg_dma_len(sg), sg->offset);usdhi6_sg_unmap (host, true);/* * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped
Signature · 1 line
1.7.10.4
Ulf Hansson
AppliedRe: [PATCH 2/3] mmc: usdhi6rol0: fix NULL pointer deref in debug print
Quoted 5 lines · Rabin Vincent
host->sgis only set when we're transferring multiple blocks. Check for its availibility before dereferencing it in the timeout work debug print.Signed-off-by Rabin Vincent <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 28 lines
--- drivers/mmc/host/usdhi6rol0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/host/usdhi6rol0.c +2
-2@@ -1634,6 +1634,7 @@ static void usdhi6_timeout_work(struct work_struct *work) struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);struct mmc_request *mrq = host->mrq;struct mmc_data *data = mrq ? mrq->data :NULL ; +struct scatterlist *sg = host->sg ?: data->sg; dev_warn(mmc_dev(host->mmc), "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",@@ -1669,7 +1670,7 @@ static void usdhi6_timeout_work(struct work_struct *work)"%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n" , data->flags &MMC_DATA_READ ?'R' :'W' , host->page_idx, host->offset, data->blocks, data->blksz, data->sg_len, - sg_dma_len(host->sg), host->sg->offset); + sg_dma_len(sg), sg->offset);usdhi6_sg_unmap (host, true);/* * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped -- 1.7.10.4
PATCH 3/3 mmc: usdhi6rol0: fix ack register write
In reply to Rabin VincentThe intent appears to be to clear only the bits which are set in status (by setting them to zero in the ack write), like in the other interrupt handlers, and not to always clear everything (by always writing zero). Use the correct not operator.
--- drivers/mmc/host/usdhi6rol0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +1 -1
@@ -1611,7 +1611,7 @@ static irqreturn_t usdhi6_cd(int irq, void *dev_id)return IRQ_NONE ;/* Ack */ -usdhi6_write (host,USDHI6_SD_INFO1 , !status); +usdhi6_write (host,USDHI6_SD_INFO1 , ~status); if (!work_pending(&mmc->detect.work) && (((status & USDHI6_SD_INFO1_CARD_INSERT) &&
Signature · 1 line
1.7.10.4
Ulf Hansson
AppliedRe: [PATCH 3/3] mmc: usdhi6rol0: fix ack register write
Quoted 6 lines · Rabin Vincent
The intent appears to be to clear only the bits which are set in status (by setting them to zero in the ack write), like in the other interrupt handlers, and not to always clear everything (by always writing zero). Use the correct not operator.
Signed-off-by Rabin Vincent <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 20 lines
--- drivers/mmc/host/usdhi6rol0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mmc/host/usdhi6rol0.c +1
-2@@ -1611,7 +1611,7 @@ static irqreturn_t usdhi6_cd(int irq, void *dev_id)return IRQ_NONE ;/* Ack */ -usdhi6_write (host,USDHI6_SD_INFO1 , !status); +usdhi6_write (host,USDHI6_SD_INFO1 , ~status); if (!work_pending(&mmc->detect.work) && (((status & USDHI6_SD_INFO1_CARD_INSERT) && --1.7.10.4
Ulf Hansson
AppliedQuoted 7 lines · Rabin Vincent
We ignore errors from
mmc_regulator_get_supply()because the usage of the regulators is optional for the driver, but we still need to check for and handleEPROBE_DEFER, like it's done in for exampledw_mmc. Otherwise we might end up not using the specified regulators just because of probe order.Signed-off-by Rabin Vincent <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 28 lines
--- drivers/mmc/host/usdhi6rol0.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/mmc/host/usdhi6rol0.c +4
-3@@ -1715,12 +1715,14 @@ static int usdhi6_probe(struct platform_device *pdev)if (!mmc)return -ENOMEM ; + ret =mmc_regulator_get_supply (mmc); +if (ret == -EPROBE_DEFER ) + goto e_free_mmc; + ret =mmc_of_parse (mmc);if (ret <0 ) goto e_free_mmc; -mmc_regulator_get_supply (mmc); - host =mmc_priv (mmc); host->mmc = mmc; host->wait =USDHI6_WAIT_FOR_REQUEST ; --1.7.10.4