From: himanshu bakshi <himanshu.bakshi478@gmail.com>
To: sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com
Cc: gregkh@linuxfoundation.org, linux-fbdev@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
himanshu bakshi <himanshu.bakshi478@gmail.com>
Subject: [PATCH] staging: sm750fb: Simplify M2XCLK divisor encoding
Date: Sun, 18 Oct 2026 14:56:51 +0530 [thread overview]
Message-ID: <20261018092651.49924-1-himanshu.bakshi478@gmail.com> (raw)
Replace the switch statement with a macro to encode the M2XCLK
divisor in the corresponding register bits.
This is my first Linux kernel patch.
Signed-off-by: himanshu bakshi <himanshu.bakshi478@gmail.com>
---
drivers/staging/sm750fb/ddk750_chip.c | 18 +++---------------
drivers/staging/sm750fb/ddk750_reg.h | 5 +----
2 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index aa78d0bc1..2cb849dea 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -109,21 +109,9 @@ static void set_memory_clock(unsigned int frequency)
/* Set the corresponding divisor in the register. */
reg = peek32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
- switch (divisor) {
- default:
- case 1:
- reg |= CURRENT_GATE_M2XCLK_DIV_1;
- break;
- case 2:
- reg |= CURRENT_GATE_M2XCLK_DIV_2;
- break;
- case 3:
- reg |= CURRENT_GATE_M2XCLK_DIV_3;
- break;
- case 4:
- reg |= CURRENT_GATE_M2XCLK_DIV_4;
- break;
- }
+ if (divisor == 0 || divisor > 4)
+ divisor = 1;
+ reg |= CURRENT_GATE_M2XCLK_DIV(divisor);
sm750_set_current_gate(reg);
}
diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h
index fe412ead7..b796e32ab 100644
--- a/drivers/staging/sm750fb/ddk750_reg.h
+++ b/drivers/staging/sm750fb/ddk750_reg.h
@@ -312,10 +312,7 @@
#define CURRENT_GATE_M2XCLK_112MHZ (0x2 << 12)
#define CURRENT_GATE_M2XCLK_84MHZ (0x3 << 12)
#else
- #define CURRENT_GATE_M2XCLK_DIV_1 (0x0 << 12)
- #define CURRENT_GATE_M2XCLK_DIV_2 (0x1 << 12)
- #define CURRENT_GATE_M2XCLK_DIV_3 (0x2 << 12)
- #define CURRENT_GATE_M2XCLK_DIV_4 (0x3 << 12)
+ #define CURRENT_GATE_M2XCLK_DIV(divisor) (((divisor) - 1) << 12)
#endif
#define CURRENT_GATE_VGA BIT(10)
#define CURRENT_GATE_PWM BIT(9)
--
2.56.0
next reply other threads:[~2026-10-18 9:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 9:26 himanshu bakshi [this message]
2026-10-23 13:36 ` [PATCH] staging: sm750fb: Simplify M2XCLK divisor encoding Greg KH
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=20261018092651.49924-1-himanshu.bakshi478@gmail.com \
--to=himanshu.bakshi478@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=sudipm.mukherjee@gmail.com \
--cc=teddy.wang@siliconmotion.com \
/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