* [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos
@ 2024-05-27 13:24 Ilpo Järvinen
2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2024-05-27 13:24 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, Fengguang Wu, Pierre Ossman,
linux-mmc, linux-kernel
Cc: Ilpo Järvinen, stable
jmicron_pmos() and sdhci_pci_probe() use pci_{read,write}_config_byte()
that return PCIBIOS_* codes. The return code is then returned as is by
jmicron_probe() and sdhci_pci_probe(). Similarly, the return code is
also returned as is from jmicron_resume(). Both probe and resume
functions should return normal errnos.
Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
errno before returning them the fix these issues.
Fixes: 7582041ff3d4 ("mmc: sdhci-pci: fix simple_return.cocci warnings")
Fixes: 45211e215984 ("sdhci: toggle JMicron PMOS setting")
Cc: stable@vger.kernel.org
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/mmc/host/sdhci-pci-core.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index ef89ec382bfe..23e6ba70144c 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1326,7 +1326,7 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch);
if (ret)
- return ret;
+ goto fail;
/*
* Turn PMOS on [bit 0], set over current detection to 2.4 V
@@ -1337,7 +1337,10 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
else
scratch &= ~0x47;
- return pci_write_config_byte(chip->pdev, 0xAE, scratch);
+ ret = pci_write_config_byte(chip->pdev, 0xAE, scratch);
+
+fail:
+ return pcibios_err_to_errno(ret);
}
static int jmicron_probe(struct sdhci_pci_chip *chip)
@@ -2202,7 +2205,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
if (ret)
- return ret;
+ return pcibios_err_to_errno(ret);
slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
dev_dbg(&pdev->dev, "found %d slot(s)\n", slots);
@@ -2211,7 +2214,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
if (ret)
- return ret;
+ return pcibios_err_to_errno(ret);
first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] mmc: sdhci-pci-o2micro: Convert PCIBIOS_* return codes to errnos 2024-05-27 13:24 [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos Ilpo Järvinen @ 2024-05-27 13:24 ` Ilpo Järvinen 2024-06-03 7:16 ` Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson 2024-06-03 7:16 ` [PATCH 1/2] mmc: sdhci-pci: " Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson 2 siblings, 2 replies; 6+ messages in thread From: Ilpo Järvinen @ 2024-05-27 13:24 UTC (permalink / raw) To: Adrian Hunter, Ulf Hansson, Chevron Li, Dinghao Liu, Adam Lee, Chris Ball, Peter Guo, Jennifer Li, linux-mmc, linux-kernel Cc: Ilpo Järvinen, stable sdhci_pci_o2_probe() uses pci_read_config_{byte,dword}() that return PCIBIOS_* codes. The return code is then returned as is but as sdhci_pci_o2_probe() is probe function chain, it should return normal errnos. Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning them. Add a label for read failure so that the conversion can be done in one place rather than on all of the return statements. Fixes: 3d757ddbd68c ("mmc: sdhci-pci-o2micro: add Bayhub new chip GG8 support for UHS-I") Fixes: d599005afde8 ("mmc: sdhci-pci-o2micro: Add missing checks in sdhci_pci_o2_probe") Fixes: 706adf6bc31c ("mmc: sdhci-pci-o2micro: Add SeaBird SeaEagle SD3 support") Fixes: 01acf6917aed ("mmc: sdhci-pci: add support of O2Micro/BayHubTech SD hosts") Fixes: 26daa1ed40c6 ("mmc: sdhci: Disable ADMA on some O2Micro SD/MMC parts.") Cc: stable@vger.kernel.org Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> --- drivers/mmc/host/sdhci-pci-o2micro.c | 41 +++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c index d4a02184784a..058bef1c7e41 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -823,7 +823,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch &= 0x7f; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); @@ -834,7 +834,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_CLKREQ, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x20; pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch); @@ -843,7 +843,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) */ ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x01; pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch); pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73); @@ -856,7 +856,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_INF_MOD, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x08; pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch); @@ -864,7 +864,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x80; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); break; @@ -875,7 +875,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch &= 0x7f; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); @@ -886,7 +886,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) O2_SD_FUNC_REG0, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 = ((scratch_32 & 0xFF000000) >> 24); /* Check Whether subId is 0x11 or 0x12 */ @@ -898,7 +898,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) O2_SD_FUNC_REG4, &scratch_32); if (ret) - return ret; + goto read_fail; /* Enable Base Clk setting change */ scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET; @@ -921,7 +921,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_dword(chip->pdev, O2_SD_CLK_SETTING, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 &= ~(0xFF00); scratch_32 |= 0x07E0C800; @@ -931,14 +931,14 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_dword(chip->pdev, O2_SD_CLKREQ, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 |= 0x3; pci_write_config_dword(chip->pdev, O2_SD_CLKREQ, scratch_32); ret = pci_read_config_dword(chip->pdev, O2_SD_PLL_SETTING, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 &= ~(0x1F3F070E); scratch_32 |= 0x18270106; @@ -949,7 +949,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_dword(chip->pdev, O2_SD_CAP_REG2, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 &= ~(0xE0); pci_write_config_dword(chip->pdev, O2_SD_CAP_REG2, scratch_32); @@ -961,7 +961,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x80; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); break; @@ -971,7 +971,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch &= 0x7f; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); @@ -979,7 +979,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_dword(chip->pdev, O2_SD_PLL_SETTING, &scratch_32); if (ret) - return ret; + goto read_fail; if ((scratch_32 & 0xff000000) == 0x01000000) { scratch_32 &= 0x0000FFFF; @@ -998,7 +998,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) O2_SD_FUNC_REG4, &scratch_32); if (ret) - return ret; + goto read_fail; scratch_32 |= (1 << 22); pci_write_config_dword(chip->pdev, O2_SD_FUNC_REG4, scratch_32); @@ -1017,7 +1017,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x80; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); break; @@ -1028,7 +1028,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) /* UnLock WP */ ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch &= 0x7f; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); @@ -1057,13 +1057,16 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) /* Lock WP */ ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); if (ret) - return ret; + goto read_fail; scratch |= 0x80; pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); break; } return 0; + +read_fail: + return pcibios_err_to_errno(ret); } #ifdef CONFIG_PM_SLEEP -- 2.39.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mmc: sdhci-pci-o2micro: Convert PCIBIOS_* return codes to errnos 2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen @ 2024-06-03 7:16 ` Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson 1 sibling, 0 replies; 6+ messages in thread From: Adrian Hunter @ 2024-06-03 7:16 UTC (permalink / raw) To: Ilpo Järvinen, Ulf Hansson, Chevron Li, Dinghao Liu, Adam Lee, Chris Ball, Peter Guo, Jennifer Li, linux-mmc, linux-kernel Cc: stable On 27/05/24 16:24, Ilpo Järvinen wrote: > sdhci_pci_o2_probe() uses pci_read_config_{byte,dword}() that return > PCIBIOS_* codes. The return code is then returned as is but as > sdhci_pci_o2_probe() is probe function chain, it should return normal > errnos. > > Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal > errno before returning them. Add a label for read failure so that the > conversion can be done in one place rather than on all of the return > statements. > > Fixes: 3d757ddbd68c ("mmc: sdhci-pci-o2micro: add Bayhub new chip GG8 support for UHS-I") > Fixes: d599005afde8 ("mmc: sdhci-pci-o2micro: Add missing checks in sdhci_pci_o2_probe") > Fixes: 706adf6bc31c ("mmc: sdhci-pci-o2micro: Add SeaBird SeaEagle SD3 support") > Fixes: 01acf6917aed ("mmc: sdhci-pci: add support of O2Micro/BayHubTech SD hosts") > Fixes: 26daa1ed40c6 ("mmc: sdhci: Disable ADMA on some O2Micro SD/MMC parts.") > Cc: stable@vger.kernel.org > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> > --- > drivers/mmc/host/sdhci-pci-o2micro.c | 41 +++++++++++++++------------- > 1 file changed, 22 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c > index d4a02184784a..058bef1c7e41 100644 > --- a/drivers/mmc/host/sdhci-pci-o2micro.c > +++ b/drivers/mmc/host/sdhci-pci-o2micro.c > @@ -823,7 +823,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > > @@ -834,7 +834,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_CLKREQ, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x20; > pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch); > > @@ -843,7 +843,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > */ > ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x01; > pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch); > pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73); > @@ -856,7 +856,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_INF_MOD, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x08; > pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch); > > @@ -864,7 +864,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -875,7 +875,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > @@ -886,7 +886,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG0, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 = ((scratch_32 & 0xFF000000) >> 24); > > /* Check Whether subId is 0x11 or 0x12 */ > @@ -898,7 +898,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG4, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > /* Enable Base Clk setting change */ > scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET; > @@ -921,7 +921,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CLK_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > scratch_32 &= ~(0xFF00); > scratch_32 |= 0x07E0C800; > @@ -931,14 +931,14 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CLKREQ, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 |= 0x3; > pci_write_config_dword(chip->pdev, O2_SD_CLKREQ, scratch_32); > > ret = pci_read_config_dword(chip->pdev, > O2_SD_PLL_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > scratch_32 &= ~(0x1F3F070E); > scratch_32 |= 0x18270106; > @@ -949,7 +949,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CAP_REG2, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 &= ~(0xE0); > pci_write_config_dword(chip->pdev, > O2_SD_CAP_REG2, scratch_32); > @@ -961,7 +961,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -971,7 +971,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > @@ -979,7 +979,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_PLL_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > if ((scratch_32 & 0xff000000) == 0x01000000) { > scratch_32 &= 0x0000FFFF; > @@ -998,7 +998,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG4, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 |= (1 << 22); > pci_write_config_dword(chip->pdev, > O2_SD_FUNC_REG4, scratch_32); > @@ -1017,7 +1017,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -1028,7 +1028,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > /* UnLock WP */ > ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > > @@ -1057,13 +1057,16 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > /* Lock WP */ > ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > } > > return 0; > + > +read_fail: > + return pcibios_err_to_errno(ret); > } > > #ifdef CONFIG_PM_SLEEP ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mmc: sdhci-pci-o2micro: Convert PCIBIOS_* return codes to errnos 2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen 2024-06-03 7:16 ` Adrian Hunter @ 2024-06-04 11:13 ` Ulf Hansson 1 sibling, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2024-06-04 11:13 UTC (permalink / raw) To: Ilpo Järvinen Cc: Adrian Hunter, Chevron Li, Dinghao Liu, Adam Lee, Chris Ball, Peter Guo, Jennifer Li, linux-mmc, linux-kernel, stable On Mon, 27 May 2024 at 15:25, Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > > sdhci_pci_o2_probe() uses pci_read_config_{byte,dword}() that return > PCIBIOS_* codes. The return code is then returned as is but as > sdhci_pci_o2_probe() is probe function chain, it should return normal > errnos. > > Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal > errno before returning them. Add a label for read failure so that the > conversion can be done in one place rather than on all of the return > statements. > > Fixes: 3d757ddbd68c ("mmc: sdhci-pci-o2micro: add Bayhub new chip GG8 support for UHS-I") > Fixes: d599005afde8 ("mmc: sdhci-pci-o2micro: Add missing checks in sdhci_pci_o2_probe") > Fixes: 706adf6bc31c ("mmc: sdhci-pci-o2micro: Add SeaBird SeaEagle SD3 support") > Fixes: 01acf6917aed ("mmc: sdhci-pci: add support of O2Micro/BayHubTech SD hosts") > Fixes: 26daa1ed40c6 ("mmc: sdhci: Disable ADMA on some O2Micro SD/MMC parts.") > Cc: stable@vger.kernel.org > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Applied for fixes, thanks! Kind regards Uffe > --- > drivers/mmc/host/sdhci-pci-o2micro.c | 41 +++++++++++++++------------- > 1 file changed, 22 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c > index d4a02184784a..058bef1c7e41 100644 > --- a/drivers/mmc/host/sdhci-pci-o2micro.c > +++ b/drivers/mmc/host/sdhci-pci-o2micro.c > @@ -823,7 +823,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > > @@ -834,7 +834,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_CLKREQ, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x20; > pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch); > > @@ -843,7 +843,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > */ > ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x01; > pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch); > pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73); > @@ -856,7 +856,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_INF_MOD, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x08; > pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch); > > @@ -864,7 +864,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -875,7 +875,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > @@ -886,7 +886,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG0, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 = ((scratch_32 & 0xFF000000) >> 24); > > /* Check Whether subId is 0x11 or 0x12 */ > @@ -898,7 +898,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG4, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > /* Enable Base Clk setting change */ > scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET; > @@ -921,7 +921,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CLK_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > scratch_32 &= ~(0xFF00); > scratch_32 |= 0x07E0C800; > @@ -931,14 +931,14 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CLKREQ, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 |= 0x3; > pci_write_config_dword(chip->pdev, O2_SD_CLKREQ, scratch_32); > > ret = pci_read_config_dword(chip->pdev, > O2_SD_PLL_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > scratch_32 &= ~(0x1F3F070E); > scratch_32 |= 0x18270106; > @@ -949,7 +949,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_CAP_REG2, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 &= ~(0xE0); > pci_write_config_dword(chip->pdev, > O2_SD_CAP_REG2, scratch_32); > @@ -961,7 +961,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -971,7 +971,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > @@ -979,7 +979,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_dword(chip->pdev, > O2_SD_PLL_SETTING, &scratch_32); > if (ret) > - return ret; > + goto read_fail; > > if ((scratch_32 & 0xff000000) == 0x01000000) { > scratch_32 &= 0x0000FFFF; > @@ -998,7 +998,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > O2_SD_FUNC_REG4, > &scratch_32); > if (ret) > - return ret; > + goto read_fail; > scratch_32 |= (1 << 22); > pci_write_config_dword(chip->pdev, > O2_SD_FUNC_REG4, scratch_32); > @@ -1017,7 +1017,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > ret = pci_read_config_byte(chip->pdev, > O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > @@ -1028,7 +1028,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > /* UnLock WP */ > ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch &= 0x7f; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > > @@ -1057,13 +1057,16 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) > /* Lock WP */ > ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); > if (ret) > - return ret; > + goto read_fail; > scratch |= 0x80; > pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); > break; > } > > return 0; > + > +read_fail: > + return pcibios_err_to_errno(ret); > } > > #ifdef CONFIG_PM_SLEEP > -- > 2.39.2 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos 2024-05-27 13:24 [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos Ilpo Järvinen 2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen @ 2024-06-03 7:16 ` Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson 2 siblings, 0 replies; 6+ messages in thread From: Adrian Hunter @ 2024-06-03 7:16 UTC (permalink / raw) To: Ilpo Järvinen, Ulf Hansson, Fengguang Wu, Pierre Ossman, linux-mmc, linux-kernel Cc: stable On 27/05/24 16:24, Ilpo Järvinen wrote: > jmicron_pmos() and sdhci_pci_probe() use pci_{read,write}_config_byte() > that return PCIBIOS_* codes. The return code is then returned as is by > jmicron_probe() and sdhci_pci_probe(). Similarly, the return code is > also returned as is from jmicron_resume(). Both probe and resume > functions should return normal errnos. > > Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal > errno before returning them the fix these issues. > > Fixes: 7582041ff3d4 ("mmc: sdhci-pci: fix simple_return.cocci warnings") > Fixes: 45211e215984 ("sdhci: toggle JMicron PMOS setting") > Cc: stable@vger.kernel.org > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> > --- > drivers/mmc/host/sdhci-pci-core.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c > index ef89ec382bfe..23e6ba70144c 100644 > --- a/drivers/mmc/host/sdhci-pci-core.c > +++ b/drivers/mmc/host/sdhci-pci-core.c > @@ -1326,7 +1326,7 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on) > > ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch); > if (ret) > - return ret; > + goto fail; > > /* > * Turn PMOS on [bit 0], set over current detection to 2.4 V > @@ -1337,7 +1337,10 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on) > else > scratch &= ~0x47; > > - return pci_write_config_byte(chip->pdev, 0xAE, scratch); > + ret = pci_write_config_byte(chip->pdev, 0xAE, scratch); > + > +fail: > + return pcibios_err_to_errno(ret); > } > > static int jmicron_probe(struct sdhci_pci_chip *chip) > @@ -2202,7 +2205,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, > > ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots); > if (ret) > - return ret; > + return pcibios_err_to_errno(ret); > > slots = PCI_SLOT_INFO_SLOTS(slots) + 1; > dev_dbg(&pdev->dev, "found %d slot(s)\n", slots); > @@ -2211,7 +2214,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, > > ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar); > if (ret) > - return ret; > + return pcibios_err_to_errno(ret); > > first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK; > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos 2024-05-27 13:24 [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos Ilpo Järvinen 2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen 2024-06-03 7:16 ` [PATCH 1/2] mmc: sdhci-pci: " Adrian Hunter @ 2024-06-04 11:13 ` Ulf Hansson 2 siblings, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2024-06-04 11:13 UTC (permalink / raw) To: Ilpo Järvinen Cc: Adrian Hunter, Fengguang Wu, Pierre Ossman, linux-mmc, linux-kernel, stable On Mon, 27 May 2024 at 15:24, Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > > jmicron_pmos() and sdhci_pci_probe() use pci_{read,write}_config_byte() > that return PCIBIOS_* codes. The return code is then returned as is by > jmicron_probe() and sdhci_pci_probe(). Similarly, the return code is > also returned as is from jmicron_resume(). Both probe and resume > functions should return normal errnos. > > Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal > errno before returning them the fix these issues. > > Fixes: 7582041ff3d4 ("mmc: sdhci-pci: fix simple_return.cocci warnings") > Fixes: 45211e215984 ("sdhci: toggle JMicron PMOS setting") > Cc: stable@vger.kernel.org > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Applied for fixes, thanks! Kind regards Uffe > --- > drivers/mmc/host/sdhci-pci-core.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c > index ef89ec382bfe..23e6ba70144c 100644 > --- a/drivers/mmc/host/sdhci-pci-core.c > +++ b/drivers/mmc/host/sdhci-pci-core.c > @@ -1326,7 +1326,7 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on) > > ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch); > if (ret) > - return ret; > + goto fail; > > /* > * Turn PMOS on [bit 0], set over current detection to 2.4 V > @@ -1337,7 +1337,10 @@ static int jmicron_pmos(struct sdhci_pci_chip *chip, int on) > else > scratch &= ~0x47; > > - return pci_write_config_byte(chip->pdev, 0xAE, scratch); > + ret = pci_write_config_byte(chip->pdev, 0xAE, scratch); > + > +fail: > + return pcibios_err_to_errno(ret); > } > > static int jmicron_probe(struct sdhci_pci_chip *chip) > @@ -2202,7 +2205,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, > > ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots); > if (ret) > - return ret; > + return pcibios_err_to_errno(ret); > > slots = PCI_SLOT_INFO_SLOTS(slots) + 1; > dev_dbg(&pdev->dev, "found %d slot(s)\n", slots); > @@ -2211,7 +2214,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, > > ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar); > if (ret) > - return ret; > + return pcibios_err_to_errno(ret); > > first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK; > > -- > 2.39.2 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-04 11:14 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-05-27 13:24 [PATCH 1/2] mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos Ilpo Järvinen 2024-05-27 13:24 ` [PATCH 2/2] mmc: sdhci-pci-o2micro: " Ilpo Järvinen 2024-06-03 7:16 ` Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson 2024-06-03 7:16 ` [PATCH 1/2] mmc: sdhci-pci: " Adrian Hunter 2024-06-04 11:13 ` Ulf Hansson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox