mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Rhodes <sean@starlabs.systems>
To: linux-kernel@vger.kernel.org
Cc: Sean Rhodes <sean@starlabs.systems>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 3/3] drivers/card_reader/rtsx_usb: Fix clock switching logic
Date: Tue, 19 Nov 2024 12:19:12 +0000	[thread overview]
Message-ID: <20241119121912.12383-3-sean@starlabs.systems> (raw)
In-Reply-To: <20241119121912.12383-1-sean@starlabs.systems>

Fix the `rtsx_usb_switch_clock` function to ensure the `card_clock`
parameter is not inadvertently modified during the function's
execution. This change:
- Introduces a `hardware_clock` variable to store the original clock
  value, preserving the integrity of the `card_clock` parameter.
- Updates the assignment of `ucr->cur_clk` to use `original_card_clock`.

This adjustment aligns the behavior with the intended logic and
prevents unintended side effects from modifying input parameters.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
 drivers/misc/cardreader/rtsx_usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index 285a748748d7..f5936c021777 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -406,6 +406,7 @@ int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock,
 {
 	int ret;
 	u8 n, clk_divider, mcu_cnt, div;
+	unsigned int original_card_clock = card_clock;
 
 	if (!card_clock) {
 		ucr->cur_clk = 0;
@@ -494,7 +495,7 @@ int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock,
 	if (ret < 0)
 		return ret;
 
-	ucr->cur_clk = card_clock;
+	ucr->cur_clk = original_card_clock;
 
 	return 0;
 }
-- 
2.43.0


  parent reply	other threads:[~2024-11-19 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 12:19 [PATCH 1/3] Revert "staging: remove rts5139 driver code" Sean Rhodes
2024-11-19 12:19 ` [PATCH 2/3] drivers/card_reader/rtsx_usb: Add interrupt based detection Sean Rhodes
2024-11-19 12:19 ` Sean Rhodes [this message]
2025-01-07 15:27 ` [PATCH 1/3] Revert "staging: remove rts5139 driver code" Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241119121912.12383-3-sean@starlabs.systems \
    --to=sean@starlabs.systems \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®