From patchwork Wed Jan 29 22:37:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3554931 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9AA179F2E9 for ; Wed, 29 Jan 2014 22:38:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C485D2018E for ; Wed, 29 Jan 2014 22:38:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E68CF20170 for ; Wed, 29 Jan 2014 22:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751335AbaA2WiV (ORCPT ); Wed, 29 Jan 2014 17:38:21 -0500 Received: from mail-lb0-f170.google.com ([209.85.217.170]:48650 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398AbaA2WiU (ORCPT ); Wed, 29 Jan 2014 17:38:20 -0500 Received: by mail-lb0-f170.google.com with SMTP id u14so1999293lbd.29 for ; Wed, 29 Jan 2014 14:38:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WEQCcE6Qq9Xis95lBvYb/X0Rx+V1QASDp7GKYAkyHXE=; b=GJH/k+H50Zs0la63qcxDMLSfCVrxquX/RSlhukrXu2276aG29QZoiGECh1TtJJG9Gu /UK2PGn22GO8HxTDaPGTJCepNc5EYa9929pQSQy5/MZdH+gP5pgFGSIIJtYQam6Qha/p NuIVv6avpBKJlW39HottwiMF3N/UnRU1WuIcuMpTn8/IRrMRE26LBsvSJQjVcZNg46RZ NPRZ4vjGlHXjsp3Ht+j444sGmuliTI2l0qCE0lkuSTLFX67KRQnEcapwtY69Q8tMqcnc rhe3ydE4GqCGjmFXQSNNz7EtXWIlIZ6oCjBWIYQg2ZKBJnII91XAs74QfASkG284AgVy a7FA== X-Gm-Message-State: ALoCoQnFzYW66/ko9uq1LjjxZMOhAc3D25Yv4coDml3GWS09dnVKHiJxOQic0IPPTtDCBsOV915n X-Received: by 10.112.173.6 with SMTP id bg6mr6711453lbc.17.1391035099144; Wed, 29 Jan 2014 14:38:19 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id wt2sm3998221lbb.2.2014.01.29.14.38.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 14:38:18 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Dong Aisheng , Stephen Warren , Vladimir Zapolskiy , Adrian Hunter , Ulf Hansson Subject: [PATCH 04/13] mmc: core: Minor simplifications to __mmc_switch Date: Wed, 29 Jan 2014 23:37:56 +0100 Message-Id: <1391035085-2747-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391035085-2747-1-git-send-email-ulf.hansson@linaro.org> References: <1391035085-2747-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using several references to card->host, let's use a local variable. That means we can remove the BUG_ON verifications for the same pointers. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 5e1a2cb..04ecdb9 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -413,14 +413,12 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, unsigned int timeout_ms, bool use_busy_signal, bool send_status, bool ignore_crc) { + struct mmc_host *host = card->host; int err; struct mmc_command cmd = {0}; unsigned long timeout; u32 status = 0; - BUG_ON(!card); - BUG_ON(!card->host); - cmd.opcode = MMC_SWITCH; cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | (index << 16) | @@ -437,7 +435,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, if (index == EXT_CSD_SANITIZE_START) cmd.sanitize_busy = true; - err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); + err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); if (err) return err; @@ -449,7 +447,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, * CRC errors shall only be ignored in cases were CMD13 is used to poll * to detect busy completion. */ - if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) + if (host->caps & MMC_CAP_WAIT_WHILE_BUSY) ignore_crc = false; /* Must check status to be sure of no errors. */ @@ -460,9 +458,9 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, if (err) return err; } - if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) + if (host->caps & MMC_CAP_WAIT_WHILE_BUSY) break; - if (mmc_host_is_spi(card->host)) + if (mmc_host_is_spi(host)) break; /* @@ -478,18 +476,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, /* Timeout if the device never leaves the program state. */ if (time_after(jiffies, timeout)) { pr_err("%s: Card stuck in programming state! %s\n", - mmc_hostname(card->host), __func__); + mmc_hostname(host), __func__); return -ETIMEDOUT; } } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); - if (mmc_host_is_spi(card->host)) { + if (mmc_host_is_spi(host)) { if (status & R1_SPI_ILLEGAL_COMMAND) return -EBADMSG; } else { if (status & 0xFDFFA000) - pr_warning("%s: unexpected status %#x after " - "switch", mmc_hostname(card->host), status); + pr_warn("%s: unexpected status %#x after switch\n", + mmc_hostname(host), status); if (status & R1_SWITCH_ERROR) return -EBADMSG; }