From patchwork Tue Oct 21 17:19:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 39201 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 905E024039 for ; Tue, 21 Oct 2014 17:19:33 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id fb4sf772854wid.0 for ; Tue, 21 Oct 2014 10:19:32 -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=sePavE2rRhJ4C+uu5mBjMSBOFJs+74BiF7EMafbHXsQ=; b=bHZ9bng0Q7A0oSdm7kQe6/AYl6ZHAHa+YEqgIOTQ9P1PAq6ys86+SMbvx23Pfw3Mqs B4bFzkkhgoF+51ixtaAlnFWbvJtyD3in9Hr/NwLiQRiOGpLYASnoMkOg4WaWDsqDxe4f nkvfgnnOx98FuiV8CWWYGAWHt1nLq68+/5ngOcrIzXrpj/H3Oii0b5iQVJd/PNWtayDM LHPb9powy9fDJaB6lsoLaUB1mBxDczDLlCHPhpTg3y35fvs5nWbCWCKD9eFYNWPn7R5m QCzn7cBIOnoxl+veOl3nsYx0NR8a1N7xKMI94ecQTSkNTwKNN8lFcIaHNwcyO0ZT3ROR sNdg== X-Gm-Message-State: ALoCoQluEHt+rWxMcbakl1smRX3FZ1xAc1ezpKSDg5LN0EkATmtphlRbdW6ePnjL5Fg3pW6ICmlv X-Received: by 10.112.138.202 with SMTP id qs10mr5341910lbb.5.1413911972435; Tue, 21 Oct 2014 10:19:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.72 with SMTP id q8ls70746laq.98.gmail; Tue, 21 Oct 2014 10:19:32 -0700 (PDT) X-Received: by 10.112.148.130 with SMTP id ts2mr4909884lbb.43.1413911972200; Tue, 21 Oct 2014 10:19:32 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id xk6si20001622lbb.22.2014.10.21.10.19.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 10:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so1421823lam.22 for ; Tue, 21 Oct 2014 10:19:32 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr35923938lbc.23.1413911972111; Tue, 21 Oct 2014 10:19:32 -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 c5csp545236lbz; Tue, 21 Oct 2014 10:19:31 -0700 (PDT) X-Received: by 10.152.36.230 with SMTP id t6mr11845828laj.88.1413911971499; Tue, 21 Oct 2014 10:19:31 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id mi5si19967709lbc.61.2014.10.21.10.19.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 10:19:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id z12so1410231lbi.16 for ; Tue, 21 Oct 2014 10:19:31 -0700 (PDT) X-Received: by 10.112.135.229 with SMTP id pv5mr36116830lbb.52.1413911971385; Tue, 21 Oct 2014 10:19:31 -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.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Oct 2014 10:19:30 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Chris Ball Subject: [PATCH 07/15] mmc: core: Fetch and decode EXT_CSD from mmc_read_ext_csd() Date: Tue, 21 Oct 2014 19:19:05 +0200 Message-Id: <1413911953-19012-8-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.215.49 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: , As a step in cleaning up code around reading/decoding EXT_CSD, convert the current mmc_read_ext_csd(), to handle both fetching the EXT_CSD and decoding its data. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 24dc30f..f10f932 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -388,7 +388,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) /* * Decode extended CSD. */ -static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) +static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) { int err = 0, idx; unsigned int part_size; @@ -629,6 +629,20 @@ out: return err; } +static int mmc_read_ext_csd(struct mmc_card *card) +{ + u8 *ext_csd = NULL; + int err; + + err = mmc_get_ext_csd(card, &ext_csd); + if (err) + return err; + + err = mmc_decode_ext_csd(card, ext_csd); + kfree(ext_csd); + return err; +} + static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) { u8 *bw_ext_csd; @@ -1234,7 +1248,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, int err; u32 cid[4]; u32 rocr; - u8 *ext_csd = NULL; BUG_ON(!host); WARN_ON(!host->claimed); @@ -1343,14 +1356,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } if (!oldcard) { - /* - * Fetch and process extended CSD. - */ - - err = mmc_get_ext_csd(card, &ext_csd); - if (err) - goto free_card; - err = mmc_read_ext_csd(card, ext_csd); + /* Read extended CSD. */ + err = mmc_read_ext_csd(card); if (err) goto free_card; @@ -1527,15 +1534,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, if (!oldcard) host->card = card; - kfree(ext_csd); return 0; free_card: if (!oldcard) mmc_remove_card(card); err: - kfree(ext_csd); - return err; }