From patchwork Tue Oct 21 17:19:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 39203 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A67A42039B for ; Tue, 21 Oct 2014 17:19:36 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf1094305lab.7 for ; Tue, 21 Oct 2014 10:19:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=e6tbtsYwpO/lZ7EAT20nr1wZygFwEBNjCHuhTcSESuw=; b=GheA8zr/TtokcZHy6rHJcxZyvcvsuUCxLJcvRPcCsTz89UN0gpoeID/db4+DP3tj1y WcstAIl74g7gyN3wjBtAIAntD3+z7Wezmxop28zVeNLp5ApRZTTrxh/BwAc4INtD8nzG JlURmQeYABLqZ22LiJDcMAGEtinWiw3xQKWoh4fIHugGNFYHQs+GGtdJe5xrcpy/hT7z R4wrLhkbqoXHGMpDJ1IMnC4nW3GbUfSbcYO3B/eePc2ZsFrKJdEdzDbXGvA8Gk1/rZ5z VNIMCNUBuQOzukuu1sV+gAjhJy872NFLtu8K50+cut8K6UcLpihTwdv8+uchUvSO8il/ Ka5g== X-Gm-Message-State: ALoCoQmuCsrPLWZ5lydh5uMYnGsZXswEJ+CAwS7DMfyBxbI9Pod7K41ZubNmRxhI4Lhi9168R3ec X-Received: by 10.152.28.4 with SMTP id x4mr717045lag.7.1413911975148; Tue, 21 Oct 2014 10:19:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.1 with SMTP id 1ls91212laq.59.gmail; Tue, 21 Oct 2014 10:19:34 -0700 (PDT) X-Received: by 10.112.77.129 with SMTP id s1mr20567419lbw.36.1413911974758; Tue, 21 Oct 2014 10:19:34 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id u2si19955593lal.70.2014.10.21.10.19.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 10:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id 10so1394508lbg.32 for ; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) X-Received: by 10.112.221.197 with SMTP id qg5mr35938734lbc.32.1413911973921; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp545244lbz; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) X-Received: by 10.112.26.71 with SMTP id j7mr4909241lbg.96.1413911973423; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id mi5si19967885lbc.61.2014.10.21.10.19.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 10:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so1430029lab.21 for ; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) X-Received: by 10.152.22.74 with SMTP id b10mr36154412laf.16.1413911973300; Tue, 21 Oct 2014 10:19:33 -0700 (PDT) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id uh7sm4791085lac.1.2014.10.21.10.19.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Oct 2014 10:19:32 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Chris Ball Subject: [PATCH 08/15] mmc: core: Let's callers of from mmc_get_ext_csd() do error handling Date: Tue, 21 Oct 2014 19:19:06 +0200 Message-Id: <1413911953-19012-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413911953-19012-1-git-send-email-ulf.hansson@linaro.org> References: <1413911953-19012-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The callers of mmc_get_ext_csd() need the flexibility to handle errors themselves, because they behave differently. Let's clean up mmc_get_ext_csd() with its friends and adopt the error handling as stated above. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 70 ++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f10f932..755019d 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -188,10 +188,8 @@ static int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) BUG_ON(!card); BUG_ON(!new_ext_csd); - *new_ext_csd = NULL; - if (!mmc_can_ext_csd(card)) - return 0; + return -EOPNOTSUPP; /* * As the ext_csd is so large and mostly unused, we don't store the @@ -202,32 +200,9 @@ static int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) return -ENOMEM; err = mmc_send_ext_csd(card, ext_csd); - if (err) { + if (err) kfree(ext_csd); - *new_ext_csd = NULL; - - /* If the host or the card can't do the switch, - * fail more gracefully. */ - if ((err != -EINVAL) - && (err != -ENOSYS) - && (err != -EFAULT)) - return err; - - /* - * High capacity cards should have this "magic" size - * stored in their CSD. - */ - if (card->csd.capacity == (4096 * 512)) { - pr_err("%s: unable to read EXT_CSD " - "on a possible high capacity card. " - "Card will be ignored.\n", - mmc_hostname(card->host)); - } else { - pr_warn("%s: unable to read EXT_CSD, performance might suffer\n", - mmc_hostname(card->host)); - err = 0; - } - } else + else *new_ext_csd = ext_csd; return err; @@ -395,9 +370,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) BUG_ON(!card); - if (!ext_csd) - return 0; - /* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */ card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE]; if (card->csd.structure == 3) { @@ -631,12 +603,36 @@ out: static int mmc_read_ext_csd(struct mmc_card *card) { - u8 *ext_csd = NULL; + u8 *ext_csd; int err; + if (!mmc_can_ext_csd(card)) + return 0; + err = mmc_get_ext_csd(card, &ext_csd); - if (err) + if (err) { + /* If the host or the card can't do the switch, + * fail more gracefully. */ + if ((err != -EINVAL) + && (err != -ENOSYS) + && (err != -EFAULT)) + return err; + + /* + * High capacity cards should have this "magic" size + * stored in their CSD. + */ + if (card->csd.capacity == (4096 * 512)) { + pr_err("%s: unable to read EXT_CSD on a possible high capacity card. Card will be ignored.\n", + mmc_hostname(card->host)); + } else { + pr_warn("%s: unable to read EXT_CSD, performance might suffer\n", + mmc_hostname(card->host)); + err = 0; + } + return err; + } err = mmc_decode_ext_csd(card, ext_csd); kfree(ext_csd); @@ -652,11 +648,8 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) return 0; err = mmc_get_ext_csd(card, &bw_ext_csd); - - if (err || bw_ext_csd == NULL) { - err = -EINVAL; - goto out; - } + if (err) + return err; /* only compare read only fields */ err = !((card->ext_csd.raw_partition_support == @@ -715,7 +708,6 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) if (err) err = -EINVAL; -out: kfree(bw_ext_csd); return err; }