From patchwork Tue Oct 29 13:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13854919 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DFBA206071 for ; Tue, 29 Oct 2024 13:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207884; cv=none; b=WVQnVPiuSHXMA/o4QRN6cSc1HHQFID/x6eiUAUW4uyYa81uPjiDEKVC+1Z64St7c47p116SENK+9QABQMSylHbSEpAAFExVY259VTGDnpQlaB3yK4WrF6QKV7UjLUCMwy5xojikZ7G+tUBBpqGO5U4YC2H82BGeMjZG0mqBQ164= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207884; c=relaxed/simple; bh=tbrsLuMVRxfbdM+tKhvjJlm+GMhkqqKgd5n4oCIJnu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tF6W2ts+6kqYhvdKNC++Syf6YOjltNxCvNHuFu9TvpgTY6Mw7GYZCYtnlCu5Q0HdJkoKuU1EuUOWXQgjyYuC+hMBCaZsuAVX31KvuJqXtigLITMr1PWSfR8v82aJHJnjV3ctHzK9oYJCkzxtGa3P4QJWtkcVZeDk8BO7mJ3+lv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OqxefMWX; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OqxefMWX" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2fb3ce15172so56778831fa.0 for ; Tue, 29 Oct 2024 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730207880; x=1730812680; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vs9BGg0Sepok2r3m/1kt5IOrhPFaUnN/UPddfC1MiiU=; b=OqxefMWX1hnxIToCX4htUZQ4MfghaPkY1ANB8y1pPmzFVdfHaxJBw3jqIpB93T2I37 ruoCmWWmrcYSrmD+pTCqJzyM91cWFBHWhiea7wvesqQvxDA7jEoLQ4RvKFbnC6ShcGZW bTTz3CqkTIlXP7WszgLkBKOw2aeBcErMk4dvfi40farUnTS4G4aTFBf0unHatFHjtNtC SqYwID+zPGivVbJefXL9rH39zMAh3Yg5czs2kLrdph2Y/VvocudejHg1aOK9UOh2MNrb y1sp+6w8ppqITeDAPl7fG7T1ROxYp8JzyKZH/jYiWOi7Z9dKQBrD6qySy9HuQI9FBte0 9BPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730207880; x=1730812680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vs9BGg0Sepok2r3m/1kt5IOrhPFaUnN/UPddfC1MiiU=; b=K6/eRF8odnc6McLxFLsSi1qdYTdOVXwjYIAFujYHhFT6i6Hito9lSwPp3887OkI5Ym MJdJMYMcI3oDV58dDZvMAk6rTTYKdfEKiyWbm8yrOCXfEorxYqNJln7Lz9kB8anWTqQf L6y0iFmR0VudbWYYfBfQNEkRcJ8umvVv7AuFks4/IBKDQRfaWeeqPh8TU+PyloOzFJPP TqmCph8KVyE97/aX6m+BslWnpn+F/ERvRxJEgp1b6HorzsK5TRw2F1oAhWxiB5dWzc+4 DaO8hHxlchdrXCXVdPVyojG4Q72RoYsQPdqBkwdUP6pykff1grWWEWSq7p7bcZsuXAAy HwtA== X-Gm-Message-State: AOJu0YwoLleePAI0ZZNIRuTXWk7JIQIC3JFiIiI8q5aubqu/U4XyaeWn FQP9lWhd9E5HdASOzYJ89rwd290eG2Qum4sEmfYjWAM7pnA+VWojIiVZN3GDR7u1+EhMMK6Vljg u X-Google-Smtp-Source: AGHT+IE6CGzytnqqE1T09qa3lAI1opJSQ6Ui80bbcXBFon3dIlI5e5lZjNDAjRHa3/rmYcd7vsI7lw== X-Received: by 2002:a2e:a801:0:b0:2fb:4fd4:668a with SMTP id 38308e7fff4ca-2fcdc80b0d3mr7977101fa.22.1730207880378; Tue, 29 Oct 2024 06:18:00 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb45d1b5asm14898401fa.85.2024.10.29.06.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 06:17:58 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Victor Shih , Victor Shih , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mmc: core: Simplify sd_uhs2_power_up() Date: Tue, 29 Oct 2024 14:17:47 +0100 Message-ID: <20241029131752.226764-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029131752.226764-1-ulf.hansson@linaro.org> References: <20241029131752.226764-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop the redundant err-parameter and just return the result from host->ops->uhs2_control() instead. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd_uhs2.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/mmc/core/sd_uhs2.c b/drivers/mmc/core/sd_uhs2.c index ddd2291ad7c4..06857e1bbdb0 100644 --- a/drivers/mmc/core/sd_uhs2.c +++ b/drivers/mmc/core/sd_uhs2.c @@ -48,8 +48,6 @@ struct sd_uhs2_wait_active_state_data { static int sd_uhs2_power_up(struct mmc_host *host) { - int err; - if (host->ios.power_mode == MMC_POWER_ON) return 0; @@ -58,9 +56,7 @@ static int sd_uhs2_power_up(struct mmc_host *host) host->ios.timing = MMC_TIMING_UHS2_SPEED_A; host->ios.power_mode = MMC_POWER_ON; - err = host->ops->uhs2_control(host, UHS2_SET_IOS); - - return err; + return host->ops->uhs2_control(host, UHS2_SET_IOS); } static int sd_uhs2_power_off(struct mmc_host *host) From patchwork Tue Oct 29 13:17:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13854920 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F2B0206510 for ; Tue, 29 Oct 2024 13:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207886; cv=none; b=LLRUIrUu7vsqNqUqn4iSo7FLLa7hTZA1OkgEHqynYMirOyRTy737L+KQIUX02fghoJDz/og37gbiPyrv3ZriNbM7fkck33pvv+/011PXTC4iDHkjxhE2OXdCLBV7FVfBL3nlvvVjmqdgPVpQ0laAtgpMlc+4voJCWG5Z4nx+McE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207886; c=relaxed/simple; bh=ANkqoHmBlWeAyTzEEJnr47Kb6ijhafWnHmW225AcRh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ue2KgVAi7SbzsUbBffUhbIu/5gPo6Foh8qR9crYKwZqLFicV5IwZMClyxfTfpUbqVE3jTCLTwO73uG27Wyymv67qKZ9hnA6aS8lZx1bnErkdKtFHPseNd0L861XSMvgLbID5RgbJzAYErLIdwYmAo2/F7JI22pwPgeqYDo0ePlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Fn/dXq7N; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fn/dXq7N" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2fb599aac99so50381721fa.1 for ; Tue, 29 Oct 2024 06:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730207882; x=1730812682; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ECTIY6gQGhiQ/bshY9W31clyZwhWM9uKNHen6jEJgGY=; b=Fn/dXq7NLQbxGtcruPRmXUcYYUj/d+V5DJM58gCX0jhAkW2PCheM5BmCvfG81KkAO2 xZioetQvZUhY/WD0TZEkolKrtjGbvr8UUdn6Wcl5Oyl692VNdzXUSRCYw/ythOP2W5II gYgEQ3rNE5QBLECo4myHVv/KNSupQRaymLDmIAjGI/iO+r7K3i4EIJPthv/KlXk5cHaG i/6C9hocksefldIlVmQYLEcdMRRnNHo4EguBJeCmE26vZUkSzEXerh6iBh1HSZDomD6P mmK4jgQy7qjTFhsgH0iN6NkfI8nmBTpXuqHgKHh+Xl79KbQWIS3Cm1AWXR7uSoE0gtXK 1Eew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730207882; x=1730812682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ECTIY6gQGhiQ/bshY9W31clyZwhWM9uKNHen6jEJgGY=; b=TNceX6fTVvSBSHGKKwn3VHgFsmKKP0S8w3CZVuzJpIJpDCUSX9Wd+8Ht2sajcknyo3 VUqRZcTExjUqaFCSSXaksbSM1HC261fXVcaqrjFevJ94ykowXwxaFi6eMLXHoEE7bYoR WJ7dradq7ww1J8a/DM49EwSgFPhwdJVe8f9W4F7P8o3HRw55e47ITxOsP7B/MQm/dkJg B7FixjjpjB4VVZuVNnliNyrfswIreuVQ55pAD3aPPYt7z9iWS5bzjTsM/CMyiMZa8gvJ X76M4UYXVIfHsCw4D30LB3OvTrexnJaZgcBsuGBwBxrzBDxLYmq6WrvgJ38p95vSV4mE NqrA== X-Gm-Message-State: AOJu0Yzebqm/f/8s3nOTgkUJK5ZugyKjPlmmU1ObO6JeWPZOTCxUCyrp QJed4QxVqvLTShqk9X3KAQbCZt5ffIuRnk197cbJCGz2pr55Z5lfZPCxkjX2j9UzT/p7txfgm9w c X-Google-Smtp-Source: AGHT+IEuA9SbdruHeD5eBVnlwcAjleTiKR4nR44WwhRTZaq0GkM6heGs2eeyKJxyU8w6mf9sXe31DA== X-Received: by 2002:a2e:511a:0:b0:2fb:3c44:7f8b with SMTP id 38308e7fff4ca-2fcbe0a42d3mr44496351fa.43.1730207882276; Tue, 29 Oct 2024 06:18:02 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb45d1b5asm14898401fa.85.2024.10.29.06.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 06:18:01 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Victor Shih , Victor Shih , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mmc: core: Add error handling of sd_uhs2_power_up() Date: Tue, 29 Oct 2024 14:17:48 +0100 Message-ID: <20241029131752.226764-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029131752.226764-1-ulf.hansson@linaro.org> References: <20241029131752.226764-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In sd_uhs2_reinit() the call to sd_uhs2_power_up() lacks error handling, so let's add it. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd_uhs2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/sd_uhs2.c b/drivers/mmc/core/sd_uhs2.c index 06857e1bbdb0..f0d631b4bbd7 100644 --- a/drivers/mmc/core/sd_uhs2.c +++ b/drivers/mmc/core/sd_uhs2.c @@ -999,7 +999,9 @@ static int sd_uhs2_reinit(struct mmc_host *host) struct mmc_card *card = host->card; int err; - sd_uhs2_power_up(host); + err = sd_uhs2_power_up(host); + if (err) + return err; err = sd_uhs2_phy_init(host); if (err) From patchwork Tue Oct 29 13:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13854921 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D016206966 for ; Tue, 29 Oct 2024 13:18:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207889; cv=none; b=XcdkM154Op385rEM285DMraSVz9/vLynOIDqAv+7/HWlbfaRkJOqIDyi1zFQPuAwvcAiXwQK49U+ZTeCvPShNFuGwDJtpFBSCIxJiiH9GTkl2Ufao48JYW076wd7PwuEpNl4da0ci7RCkZ5AzGdzjjPZBgWIMQRrNoTdIpfdnp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730207889; c=relaxed/simple; bh=9Si5uHtdp0Lt+1Q+Ut2zNTQ7sHvOgpyLbpOxdbMF8Gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UaCMgn7c3nRHXU9R+/UUt7VuhD9GI/QTmAu8/r5VeKeCzXcoBZunzOu4EEoK/ChlP4AJKpAhsNGBWDFoBxFzNp9vwvO+eTda2PYN0SZ/ZhrEhazL1Ob921VoiYEFzOndjbDUdv3gQqgkwCtIvYVDP++fZ/zwCSjwju502NaY+to= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fz2X46MP; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fz2X46MP" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2f75c56f16aso50396281fa.0 for ; Tue, 29 Oct 2024 06:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730207885; x=1730812685; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JBgydnSYe7wOoT14t60TRfzkasKBAAiMFxpZtek6s10=; b=fz2X46MPAd2tAhqX6vceerhg/iQEovKIBvAKOgMqyBRQB1qHulN0nS1NQHr933Wd+s z7a/wIVktYX+1Q3qHDTZ9tghpuuMfUSdSLbx7RalBJ5kQZ4GUxtyfSXPBaxh1JqcPGu2 HnWOb9yGz6W5UQ7y6VwoUdmuZpC4wWuU9S/xciMrEgR/pKurg5hMwyS+1Sri2EavplVC G5zAKmfDulp8XtCdC4/HFch1vmLYVtTw5OMtHYbDsfdlIZFrMe5R6RmAf+R3SaZU38R2 tohe2AX6URVVfYDTvyua9u7yozQwOjFXq6OKRrBaluwHsi7NafrG3hXNYo2SKV6kBm82 lYmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730207885; x=1730812685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JBgydnSYe7wOoT14t60TRfzkasKBAAiMFxpZtek6s10=; b=pXlWBkXJUh5WAhJWP6qpGuiwZ3RJvFGjbBcI9iOMMCcQyeEIowDCmNe2q7WoE342Iq sNmtW0uoh6vLppr8qoD8y2GtkBT5fG2YXaJrp4LskgYb7l9Z7rE8L4E9V5jwLwTqT991 DFOw3EpdW9tl04vtDyGJq2XS4OwmzGYQyFVvX87zVZIOAiNE7bhHm1+RuNB4SBilr7Q4 vq2JPOJKzKfK/eWfhBb5da8P/HNztJmnobZJkcG9InkWkzLQeZvjYQQLFzbojeDQXCCg Q/Px/muVjP+DWb+EDOgvVqV/NVb7528gnrSu7FkKNVBcFzQpdldJlw40d3V1mwChyaIj biFA== X-Gm-Message-State: AOJu0Yz2NnFJOUS8AMD3I7olARId1WTE7LBvsjw0n+qkvAQP7wIF1L9l sSsAdeeFTTpbN/MkCADfSHeZa0DsgWBsrePVTH+ByejbUP3dMPyKhdc/h84QIvnJj+bor2q8FDf 3 X-Google-Smtp-Source: AGHT+IGDNrXtE4X1RXnTXnmnfBYVxYvy6Ye9s6ZWmMdqElCZB2ctE5tDPdQaGPHu6SfCJoDCLn32DA== X-Received: by 2002:a05:651c:2209:b0:2fb:6328:b633 with SMTP id 38308e7fff4ca-2fcbdf612eamr50249911fa.4.1730207885108; Tue, 29 Oct 2024 06:18:05 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb45d1b5asm14898401fa.85.2024.10.29.06.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 06:18:03 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Victor Shih , Victor Shih , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mmc: core: Fix error paths for UHS-II card init and re-init Date: Tue, 29 Oct 2024 14:17:49 +0100 Message-ID: <20241029131752.226764-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029131752.226764-1-ulf.hansson@linaro.org> References: <20241029131752.226764-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The error path didn't manage the removal of the allocated mmc_card correctly. Let's fix this to avoid potential memory leaks. While at it, move the assignment of host->card to slightly later in the init process and drop also a somewhat silly dev_warn() when CMD8 fails. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd_uhs2.c | 55 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/drivers/mmc/core/sd_uhs2.c b/drivers/mmc/core/sd_uhs2.c index f0d631b4bbd7..618b46c37857 100644 --- a/drivers/mmc/core/sd_uhs2.c +++ b/drivers/mmc/core/sd_uhs2.c @@ -827,24 +827,28 @@ static int sd_uhs2_init_card(struct mmc_host *host, struct mmc_card *oldcard) err = sd_uhs2_config_read(host, card); if (err) - return err; + goto err; err = sd_uhs2_config_write(host, card); if (err) - return err; + goto err; - host->card = card; /* If change speed to Range B, need to GO_DORMANT_STATE */ if (host->ios.timing == MMC_TIMING_UHS2_SPEED_B || host->ios.timing == MMC_TIMING_UHS2_SPEED_B_HD) { err = sd_uhs2_go_dormant_state(host, node_id); if (err) - return err; + goto err; } host->uhs2_sd_tran = true; - + host->card = card; return 0; + +err: + if (!oldcard) + mmc_remove_card(card); + return err; } /* @@ -855,7 +859,7 @@ static int sd_uhs2_init_card(struct mmc_host *host, struct mmc_card *oldcard) * survives a soft reset through the GO_DORMANT_STATE command. */ static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, - struct mmc_card *oldcard) + bool reinit) { int err; u32 cid[4]; @@ -873,17 +877,15 @@ static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, /* Send CMD8 to communicate SD interface operation condition */ err = mmc_send_if_cond(host, host->ocr_avail); - if (err) { - dev_warn(mmc_dev(host), "CMD8 error\n"); - goto err; - } + if (err) + return err; /* * Probe SD card working voltage. */ err = mmc_send_app_op_cond(host, 0, &ocr); if (err) - goto err; + return err; card->ocr = ocr; @@ -907,20 +909,18 @@ static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, err = mmc_send_app_op_cond(host, ocr, &rocr); if (err) - goto err; + return err; err = mmc_send_cid(host, cid); if (err) - goto err; + return err; - if (oldcard) { - if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) { + if (reinit) { + if (memcmp(cid, card->raw_cid, sizeof(cid)) != 0) { pr_debug("%s: Perhaps the card was replaced\n", mmc_hostname(host)); return -ENOENT; } - - card = oldcard; } else { memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); mmc_decode_cid(card); @@ -931,29 +931,29 @@ static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, */ err = mmc_send_relative_addr(host, &card->rca); if (err) - goto err; + return err; err = mmc_sd_get_csd(card, false); if (err) - goto err; + return err; /* * Select card, as all following commands rely on that. */ err = mmc_select_card(card); if (err) - goto err; + return err; /* * Fetch SCR from card. */ err = mmc_app_send_scr(card); if (err) - goto err; + return err; err = mmc_decode_scr(card); if (err) - goto err; + return err; /* * Switch to high power consumption mode. @@ -989,9 +989,6 @@ static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, kfree(status); return 0; - -err: - return err; } static int sd_uhs2_reinit(struct mmc_host *host) @@ -1011,7 +1008,7 @@ static int sd_uhs2_reinit(struct mmc_host *host) if (err) return err; - return sd_uhs2_legacy_init(host, card, card); + return sd_uhs2_legacy_init(host, card, true); } static void sd_uhs2_remove(struct mmc_host *host) @@ -1172,9 +1169,9 @@ static int sd_uhs2_attach(struct mmc_host *host) if (err) goto err; - err = sd_uhs2_legacy_init(host, host->card, NULL); + err = sd_uhs2_legacy_init(host, host->card, false); if (err) - goto err; + goto remove_card; mmc_attach_bus(host, &sd_uhs2_ops); @@ -1185,13 +1182,11 @@ static int sd_uhs2_attach(struct mmc_host *host) goto remove_card; mmc_claim_host(host); - return 0; remove_card: sd_uhs2_remove(host); mmc_claim_host(host); - err: mmc_detach_bus(host); sd_uhs2_power_off(host);