From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4C613AE70B for ; Tue, 17 Mar 2026 11:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773748192; cv=none; b=rmWVZknBJOUrQhlUHXXC7E0yu/mmiS5CWkoCci4m9gK7E7bzvVNZHUNizJIgnjlHY79xw7BTJoKMQ+t0baPdc6XfIFRf26djFX2xgrSzYOQA6c3pKLdeW284WWSGudEaZLmZSyZGZ5fif3p8GcDD1FtNw5sFcMd4rQsJAN27Evw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773748192; c=relaxed/simple; bh=ElWfHroQIHg43juAArLvBER9My8/Tgzdi6OI2knhwoA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LFnOEornmJa/BpPFTt3PgifhaV00m/w/oiG5Nf91HCdIjDpkvU9HnFAZjxUEIyNAu7C1PpnpPpN/mH7OUnfJdlsCiFRQNSADdX+uyS6KsyniLcGh5unfAZuwKjizRHEdaTHluJOAHGDGiVkhP1R1WEqKURhPvlYk8DyPJMscU5o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t7RRzmBc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t7RRzmBc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CE92C19425; Tue, 17 Mar 2026 11:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773748192; bh=ElWfHroQIHg43juAArLvBER9My8/Tgzdi6OI2knhwoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7RRzmBcsMc+zThr7YWVoEDjpcLqmCNAJXzmnkaJYGaiERVipf/svjVRzw5qh1Y85 0UI1Wx6SUquwdFnJC6TcL+yvkeBIvIF4TDx5ct1EDp5RmZwf8uLwYD6UYnZazLUmEl Zy/SMdDGEVbdm2XvgP6LPgTlfAxTMtiE2d7gzmpslSUpzO0Gb3TPkX/rp8Ps1VzrPT 3zFmu6zL9ooRME1E28qgkSD/NZWWEC5kInTQmcM95gqlZrXRO0DZAbTQsBsMRwVQIz N74ET0KKngO9+Wq0T+5OLRNtMN1EgVfzQjHVgYeesbDZpVGO9tsk6V9lxV1ew2d+QN pi3oRWF/APejA== From: Sasha Levin To: stable@vger.kernel.org Cc: Ulf Hansson , Adrian Hunter , Sasha Levin Subject: [PATCH 5.10.y 2/4] mmc: core: Drop superfluous validations in mmc_hw|sw_reset() Date: Tue, 17 Mar 2026 07:49:47 -0400 Message-ID: <20260317114949.126875-2-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260317114949.126875-1-sashal@kernel.org> References: <2026031713-defeat-mobster-d0a8@gregkh> <20260317114949.126875-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ulf Hansson [ Upstream commit fefdd3c91e0a7b3cbb3f25925d93a57c45cb0f31 ] The mmc_hw|sw_reset() APIs are designed to be called solely from upper layers, which means drivers that operates on top of the struct mmc_card, like the mmc block device driver and an SDIO functional driver. Additionally, as long as the struct mmc_host has a valid pointer to a struct mmc_card, the corresponding host->bus_ops pointer stays valid and assigned. For these reasons, let's drop the superfluous reference counting and the redundant validations in mmc_hw|sw_reset(). Signed-off-by: Ulf Hansson Reviewed-by: Adrian Hunter Link: https://lore.kernel.org/r/20210212131532.236775-1-ulf.hansson@linaro.org Stable-dep-of: 901084c51a0a ("mmc: core: Avoid bitfield RMW for claim/retune flags") Signed-off-by: Sasha Levin --- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/core.c | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 71ecdb13477a5..2756a5f149f1d 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -987,7 +987,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, md->reset_done |= type; err = mmc_hw_reset(host); /* Ensure we switch back to the correct partition */ - if (err != -EOPNOTSUPP) { + if (err) { struct mmc_blk_data *main_md = dev_get_drvdata(&host->card->dev); int part_err; diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d8169c8c3f405..cef46bae60b6a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2096,18 +2096,7 @@ int mmc_hw_reset(struct mmc_host *host) { int ret; - if (!host->card) - return -EINVAL; - - mmc_bus_get(host); - if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) { - mmc_bus_put(host); - return -EOPNOTSUPP; - } - ret = host->bus_ops->hw_reset(host); - mmc_bus_put(host); - if (ret < 0) pr_warn("%s: tried to HW reset card, got error %d\n", mmc_hostname(host), ret); @@ -2120,18 +2109,10 @@ int mmc_sw_reset(struct mmc_host *host) { int ret; - if (!host->card) - return -EINVAL; - - mmc_bus_get(host); - if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) { - mmc_bus_put(host); + if (!host->bus_ops->sw_reset) return -EOPNOTSUPP; - } ret = host->bus_ops->sw_reset(host); - mmc_bus_put(host); - if (ret) pr_warn("%s: tried to SW reset card, got error %d\n", mmc_hostname(host), ret); -- 2.51.0