mmc: core: Normalize the error handling branch in sd_read_ext_regs()
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 30 Nov 2022 13:49:20 +0000 (21:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:17 +0000 (13:14 +0100)
[ Upstream commit fc02e2b52389c8fde02852b2f959c0b45f042bbd ]

Let's use pr_err() to output the error messages and let's extend a comment
to clarify why returning 0 (success) in one case make sense.

Fixes: c784f92769ae ("mmc: core: Read the SD function extension registers for power management")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
[Ulf: Clarified the comment and the commit-msg]
Link: https://lore.kernel.org/r/20221130134920.2109-1-thunder.leizhen@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mmc/core/sd.c

index 86a8a1f5658397fe07cc824ade0f38115a5669ce..592166e53dce8da7f6c826a8a189afb11b2ee7d0 100644 (file)
@@ -1252,7 +1252,7 @@ static int sd_read_ext_regs(struct mmc_card *card)
         */
        err = sd_read_ext_reg(card, 0, 0, 0, 512, gen_info_buf);
        if (err) {
-               pr_warn("%s: error %d reading general info of SD ext reg\n",
+               pr_err("%s: error %d reading general info of SD ext reg\n",
                        mmc_hostname(card->host), err);
                goto out;
        }
@@ -1266,7 +1266,12 @@ static int sd_read_ext_regs(struct mmc_card *card)
        /* Number of extensions to be find. */
        num_ext = gen_info_buf[4];
 
-       /* We support revision 0, but limit it to 512 bytes for simplicity. */
+       /*
+        * We only support revision 0 and limit it to 512 bytes for simplicity.
+        * No matter what, let's return zero to allow us to continue using the
+        * card, even if we can't support the features from the SD function
+        * extensions registers.
+        */
        if (rev != 0 || len > 512) {
                pr_warn("%s: non-supported SD ext reg layout\n",
                        mmc_hostname(card->host));
@@ -1281,7 +1286,7 @@ static int sd_read_ext_regs(struct mmc_card *card)
        for (i = 0; i < num_ext; i++) {
                err = sd_parse_ext_reg(card, gen_info_buf, &next_ext_addr);
                if (err) {
-                       pr_warn("%s: error %d parsing SD ext reg\n",
+                       pr_err("%s: error %d parsing SD ext reg\n",
                                mmc_hostname(card->host), err);
                        goto out;
                }