Skip to content

Commit a91bf3b

Browse files
ij-intelstorulf
authored andcommitted
mmc: sdhci-pci-o2micro: Convert PCIBIOS_* return codes to errnos
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: 3d757dd ("mmc: sdhci-pci-o2micro: add Bayhub new chip GG8 support for UHS-I") Fixes: d599005 ("mmc: sdhci-pci-o2micro: Add missing checks in sdhci_pci_o2_probe") Fixes: 706adf6 ("mmc: sdhci-pci-o2micro: Add SeaBird SeaEagle SD3 support") Fixes: 01acf69 ("mmc: sdhci-pci: add support of O2Micro/BayHubTech SD hosts") Fixes: 26daa1e ("mmc: sdhci: Disable ADMA on some O2Micro SD/MMC parts.") Cc: [email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent ebc4fc3 commit a91bf3b

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
823823
ret = pci_read_config_byte(chip->pdev,
824824
O2_SD_LOCK_WP, &scratch);
825825
if (ret)
826-
return ret;
826+
goto read_fail;
827827
scratch &= 0x7f;
828828
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
829829

@@ -834,7 +834,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
834834
ret = pci_read_config_byte(chip->pdev,
835835
O2_SD_CLKREQ, &scratch);
836836
if (ret)
837-
return ret;
837+
goto read_fail;
838838
scratch |= 0x20;
839839
pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch);
840840

@@ -843,7 +843,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
843843
*/
844844
ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch);
845845
if (ret)
846-
return ret;
846+
goto read_fail;
847847
scratch |= 0x01;
848848
pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch);
849849
pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73);
@@ -856,15 +856,15 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
856856
ret = pci_read_config_byte(chip->pdev,
857857
O2_SD_INF_MOD, &scratch);
858858
if (ret)
859-
return ret;
859+
goto read_fail;
860860
scratch |= 0x08;
861861
pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch);
862862

863863
/* Lock WP */
864864
ret = pci_read_config_byte(chip->pdev,
865865
O2_SD_LOCK_WP, &scratch);
866866
if (ret)
867-
return ret;
867+
goto read_fail;
868868
scratch |= 0x80;
869869
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
870870
break;
@@ -875,7 +875,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
875875
ret = pci_read_config_byte(chip->pdev,
876876
O2_SD_LOCK_WP, &scratch);
877877
if (ret)
878-
return ret;
878+
goto read_fail;
879879

880880
scratch &= 0x7f;
881881
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)
886886
O2_SD_FUNC_REG0,
887887
&scratch_32);
888888
if (ret)
889-
return ret;
889+
goto read_fail;
890890
scratch_32 = ((scratch_32 & 0xFF000000) >> 24);
891891

892892
/* Check Whether subId is 0x11 or 0x12 */
@@ -898,7 +898,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
898898
O2_SD_FUNC_REG4,
899899
&scratch_32);
900900
if (ret)
901-
return ret;
901+
goto read_fail;
902902

903903
/* Enable Base Clk setting change */
904904
scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET;
@@ -921,7 +921,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
921921
ret = pci_read_config_dword(chip->pdev,
922922
O2_SD_CLK_SETTING, &scratch_32);
923923
if (ret)
924-
return ret;
924+
goto read_fail;
925925

926926
scratch_32 &= ~(0xFF00);
927927
scratch_32 |= 0x07E0C800;
@@ -931,14 +931,14 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
931931
ret = pci_read_config_dword(chip->pdev,
932932
O2_SD_CLKREQ, &scratch_32);
933933
if (ret)
934-
return ret;
934+
goto read_fail;
935935
scratch_32 |= 0x3;
936936
pci_write_config_dword(chip->pdev, O2_SD_CLKREQ, scratch_32);
937937

938938
ret = pci_read_config_dword(chip->pdev,
939939
O2_SD_PLL_SETTING, &scratch_32);
940940
if (ret)
941-
return ret;
941+
goto read_fail;
942942

943943
scratch_32 &= ~(0x1F3F070E);
944944
scratch_32 |= 0x18270106;
@@ -949,7 +949,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
949949
ret = pci_read_config_dword(chip->pdev,
950950
O2_SD_CAP_REG2, &scratch_32);
951951
if (ret)
952-
return ret;
952+
goto read_fail;
953953
scratch_32 &= ~(0xE0);
954954
pci_write_config_dword(chip->pdev,
955955
O2_SD_CAP_REG2, scratch_32);
@@ -961,7 +961,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
961961
ret = pci_read_config_byte(chip->pdev,
962962
O2_SD_LOCK_WP, &scratch);
963963
if (ret)
964-
return ret;
964+
goto read_fail;
965965
scratch |= 0x80;
966966
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
967967
break;
@@ -971,15 +971,15 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
971971
ret = pci_read_config_byte(chip->pdev,
972972
O2_SD_LOCK_WP, &scratch);
973973
if (ret)
974-
return ret;
974+
goto read_fail;
975975

976976
scratch &= 0x7f;
977977
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
978978

979979
ret = pci_read_config_dword(chip->pdev,
980980
O2_SD_PLL_SETTING, &scratch_32);
981981
if (ret)
982-
return ret;
982+
goto read_fail;
983983

984984
if ((scratch_32 & 0xff000000) == 0x01000000) {
985985
scratch_32 &= 0x0000FFFF;
@@ -998,7 +998,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
998998
O2_SD_FUNC_REG4,
999999
&scratch_32);
10001000
if (ret)
1001-
return ret;
1001+
goto read_fail;
10021002
scratch_32 |= (1 << 22);
10031003
pci_write_config_dword(chip->pdev,
10041004
O2_SD_FUNC_REG4, scratch_32);
@@ -1017,7 +1017,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10171017
ret = pci_read_config_byte(chip->pdev,
10181018
O2_SD_LOCK_WP, &scratch);
10191019
if (ret)
1020-
return ret;
1020+
goto read_fail;
10211021
scratch |= 0x80;
10221022
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10231023
break;
@@ -1028,7 +1028,7 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10281028
/* UnLock WP */
10291029
ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
10301030
if (ret)
1031-
return ret;
1031+
goto read_fail;
10321032
scratch &= 0x7f;
10331033
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10341034

@@ -1057,13 +1057,16 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
10571057
/* Lock WP */
10581058
ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
10591059
if (ret)
1060-
return ret;
1060+
goto read_fail;
10611061
scratch |= 0x80;
10621062
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
10631063
break;
10641064
}
10651065

10661066
return 0;
1067+
1068+
read_fail:
1069+
return pcibios_err_to_errno(ret);
10671070
}
10681071

10691072
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)