From patchwork Tue Mar 31 05:34:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 244630 List-Id: U-Boot discussion From: rayagonda.kokatanur at broadcom.com (Rayagonda Kokatanur) Date: Tue, 31 Mar 2020 11:04:03 +0530 Subject: [PATCH v1 1/4] drivers: mmc: iproc_sdhci: fix possible memory leak In-Reply-To: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> References: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> Message-ID: <20200331053406.23063-2-rayagonda.kokatanur@broadcom.com> From: Bharat Kumar Reddy Gooty Free the pointer variable 'iproc_sdhci' upon failure to fix possible memory leak. Signed-off-by: Bharat Kumar Reddy Gooty Signed-off-by: Rayagonda Kokatanur --- drivers/mmc/iproc_sdhci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 831dd32eb7..36ecdba5c6 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -176,8 +176,7 @@ static int iproc_sdhci_probe(struct udevice *dev) u32 f_min_max[2]; int ret; - iproc_host = (struct sdhci_iproc_host *) - malloc(sizeof(struct sdhci_iproc_host)); + iproc_host = malloc(sizeof(struct sdhci_iproc_host)); if (!iproc_host) { printf("%s: sdhci host malloc fail!\n", __func__); return -ENOMEM; @@ -198,6 +197,7 @@ static int iproc_sdhci_probe(struct udevice *dev) "clock-freq-min-max", f_min_max, 2); if (ret) { printf("sdhci: clock-freq-min-max not found\n"); + free(iproc_host); return ret; } host->max_clk = f_min_max[1]; @@ -212,8 +212,10 @@ static int iproc_sdhci_probe(struct udevice *dev) ret = sdhci_setup_cfg(&plat->cfg, &iproc_host->host, f_min_max[1], f_min_max[0]); - if (ret) + if (ret) { + free(iproc_host); return ret; + } iproc_host->host.mmc = &plat->mmc; iproc_host->host.mmc->dev = dev; From patchwork Tue Mar 31 05:34:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 244631 List-Id: U-Boot discussion From: rayagonda.kokatanur at broadcom.com (Rayagonda Kokatanur) Date: Tue, 31 Mar 2020 11:04:04 +0530 Subject: [PATCH v1 2/4] drivers: mmc: iproc_sdhci: enable broken R1B response quirk In-Reply-To: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> References: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> Message-ID: <20200331053406.23063-3-rayagonda.kokatanur@broadcom.com> From: Bharat Kumar Reddy Gooty Enable SDHCI_QUIRK_BROKEN_R1B quirk. Signed-off-by: Bharat Kumar Reddy Gooty Signed-off-by: Rayagonda Kokatanur --- drivers/mmc/iproc_sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 36ecdba5c6..f65a1e543d 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -188,7 +188,7 @@ static int iproc_sdhci_probe(struct udevice *dev) host->ioaddr = (void *)devfdt_get_addr(dev); host->voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34; - host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE; + host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B; host->host_caps = MMC_MODE_DDR_52MHz; host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0); host->ops = &sdhci_platform_ops; From patchwork Tue Mar 31 05:34:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 244632 List-Id: U-Boot discussion From: rayagonda.kokatanur at broadcom.com (Rayagonda Kokatanur) Date: Tue, 31 Mar 2020 11:04:05 +0530 Subject: [PATCH v1 3/4] drivers: mmc: iproc_sdhci: fix compilation warning In-Reply-To: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> References: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> Message-ID: <20200331053406.23063-4-rayagonda.kokatanur@broadcom.com> set_ios_post return type changed from void to int, correcting the same to fix compilation warning. Signed-off-by: Rayagonda Kokatanur Signed-off-by: Bharat Kumar Reddy Gooty --- drivers/mmc/iproc_sdhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index f65a1e543d..0f4d608869 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -136,7 +136,7 @@ static void sdhci_iproc_writeb(struct sdhci_host *host, u8 val, int reg) } #endif -static void sdhci_iproc_set_ios_post(struct sdhci_host *host) +static int sdhci_iproc_set_ios_post(struct sdhci_host *host) { u32 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); @@ -147,6 +147,8 @@ static void sdhci_iproc_set_ios_post(struct sdhci_host *host) ctrl |= UHS_DDR50_BUS_SPEED; sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); + + return 0; } static struct sdhci_ops sdhci_platform_ops = { From patchwork Tue Mar 31 05:34:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 244633 List-Id: U-Boot discussion From: rayagonda.kokatanur at broadcom.com (Rayagonda Kokatanur) Date: Tue, 31 Mar 2020 11:04:06 +0530 Subject: [PATCH v1 4/4] drivers: mmc: iproc_sdhci: move host.mmc init before sdhci_setup_cfg In-Reply-To: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> References: <20200331053406.23063-1-rayagonda.kokatanur@broadcom.com> Message-ID: <20200331053406.23063-5-rayagonda.kokatanur@broadcom.com> move host.mmc before sdhci_setup_cfg Signed-off-by: Rayagonda Kokatanur Signed-off-by: Bharat Kumar Reddy Gooty --- drivers/mmc/iproc_sdhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 0f4d608869..c2319b4134 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -212,6 +212,11 @@ static int iproc_sdhci_probe(struct udevice *dev) memcpy(&iproc_host->host, host, sizeof(struct sdhci_host)); + iproc_host->host.mmc = &plat->mmc; + iproc_host->host.mmc->dev = dev; + iproc_host->host.mmc->priv = &iproc_host->host; + upriv->mmc = iproc_host->host.mmc; + ret = sdhci_setup_cfg(&plat->cfg, &iproc_host->host, f_min_max[1], f_min_max[0]); if (ret) { @@ -219,11 +224,6 @@ static int iproc_sdhci_probe(struct udevice *dev) return ret; } - iproc_host->host.mmc = &plat->mmc; - iproc_host->host.mmc->dev = dev; - iproc_host->host.mmc->priv = &iproc_host->host; - upriv->mmc = iproc_host->host.mmc; - return sdhci_probe(dev); }