staging: sm750fb: Clean up helpers and fix DAC power-off handling
cover staging: sm750fb: Clean up helpers and fix DAC power-off handling
This series replaces the set_DAC macro with a local static function, corrects the DAC power-off bit handling, and removes an empty software I2C acknowledgement helper and its ineffective parameter.
The first and third patches preserve existing behavior. The second patch maps the extracted 0/1 DAC state to bit 20 rather than OR-ing it into bit 0 of MISC_CTRL.
Based on staging-next at 6628e7d4c6b (Linux 7.4-rc1).
Validation:
- All SM750 driver objects compiled and linked into sm750fb.o with W=1, CONFIG_FB=y, CONFIG_STAGING=y, and CONFIG_FB_SM750=m.
- A standalone mocked-register test checked 72 DAC state and register preservation cases: 36 failed before the fix and none failed afterward.
- checkpatch.pl reported no errors or warnings.
- git diff --check passed.
Hardware testing was not performed.
Ali Köse (3):
staging: sm750fb: Replace set_DAC macro with a static function
staging: sm750fb: Fix DAC power-off bit handling
staging: sm750fb: Remove empty software I2C acknowledgement helper
drivers/staging/sm750fb/ddk750_display.c | 9 ++++++++- drivers/staging/sm750fb/ddk750_power.h | 5 ----- drivers/staging/sm750fb/ddk750_swi2c.c | 19 ++----------------- 3 files changed, 10 insertions(+), 23 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0
PATCH 1/3 staging: sm750fb: Replace set_DAC macro with a static function
Replace the set_DAC macro with a static function named set_dac(). The helper has only one caller, so keep it local to ddk750_display.c and remove the macro from ddk750_power.h.
This provides parameter type checking and follows kernel naming conventions without changing the register operation.
--- drivers/staging/sm750fb/ddk750_display.c | 8 +++++++- drivers/staging/sm750fb/ddk750_power.h | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/staging/sm750fb/ddk750_display.c +7 -1
@@ -4,6 +4,12 @@#include "ddk750_display.h" #include "ddk750_power.h" +static void set_dac (unsigned int off) +{ +poke32 (MISC_CTRL , + (peek32 (MISC_CTRL ) & ~MISC_CTRL_DAC_POWER_OFF ) | off); +} +static void set_display_control (int ctrl,int disp_state) {/* state != 0 means turn on both timing & plane en_bit */
@@ -151,7 +157,7 @@ void ddk750_set_logical_disp_out(enum disp_output output) }if (output &DAC_USAGE ) -set_DAC ((output &DAC_MASK ) >>DAC_OFFSET ); +set_dac ((output &DAC_MASK ) >>DAC_OFFSET );if (output &DPMS_USAGE )ddk750_set_dpms ((output &DPMS_MASK ) >>DPMS_OFFSET );
drivers/staging/sm750fb/ddk750_power.h +0 -5
@@ -9,11 +9,6 @@ enum dpms { CRT_DPMS_OFF = 0x3, }; -#define set_DAC (off) { \ - poke32(MISC_CTRL, \ - (peek32(MISC_CTRL) & ~MISC_CTRL_DAC_POWER_OFF) | (off)); \ -} -void ddk750_set_dpms (enum dpms state);void sm750_set_power_mode (unsigned int mode);void sm750_set_current_gate (unsigned int gate);
Signature · 1 line
2.53.0
PATCH 2/3 staging: sm750fb: Fix DAC power-off bit handling
In reply to Ali KöseThe DAC state extracted by ddk750_set_logical_disp_out() is either 0 or 1, but MISC_CTRL_DAC_POWER_OFF occupies bit 20. OR-ing the extracted value directly into MISC_CTRL therefore clears the DAC power-off bit and, when off is requested, sets bit 0 instead.
Translate the state into MISC_CTRL_DAC_POWER_OFF before updating the register, preserving unrelated bits.
--- drivers/staging/sm750fb/ddk750_display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/sm750fb/ddk750_display.c +2 -1
@@ -7,7 +7,8 @@static void set_dac (unsigned int off) {poke32 (MISC_CTRL , - (peek32 (MISC_CTRL ) & ~MISC_CTRL_DAC_POWER_OFF ) | off); + (peek32 (MISC_CTRL ) & ~MISC_CTRL_DAC_POWER_OFF ) | + (off ?MISC_CTRL_DAC_POWER_OFF :0 )); }static void set_display_control (int ctrl,int disp_state)
Signature · 1 line
2.53.0
PATCH 3/3 staging: sm750fb: Remove empty software I2C acknowledgement helper
In reply to Ali Kösesw_i2c_ack() contains only a return statement, so calling it has no effect. Remove the empty helper and the ack parameter from sw_i2c_read_byte(), along with the parameter documentation.
Update the only caller to use the parameterless helper. The GPIO operations and existing I2C bus behavior remain unchanged.
--- drivers/staging/sm750fb/ddk750_swi2c.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +2 -17
@@ -201,14 +201,6 @@ static unsigned char sw_i2c_read_sda(void)return 0 ; } -/* -* This function sends ACK signal -*/ -static void sw_i2c_ack (void ) -{ -return ;/* Single byte read is ok without it. */ -} -/* * This function sends the start command to the slave device */
@@ -300,14 +292,10 @@ static long sw_i2c_write_byte(unsigned char data)/* * This function reads one byte from the slave device * -* Parameters: -* ack - Flag to indicate either to send the acknowledge -* message to the slave device or not -* * Return Value: * One byte data read from the Slave device */ -static unsigned char sw_i2c_read_byte (unsigned char ack) +static unsigned char sw_i2c_read_byte (void ) {int i;unsigned char data =0 ;
@@ -326,9 +314,6 @@ static unsigned char sw_i2c_read_byte(unsigned char ack) data |= (sw_i2c_read_sda () << i); } -if (ack) -sw_i2c_ack (); -/* Set the SCL Low and SDA High */ sw_i2c_scl (0 );sw_i2c_sda (1 );
@@ -458,7 +443,7 @@ unsigned char sm750_sw_i2c_read_reg(unsigned char addr, unsigned char reg)/* Get the bus again and get the data from the device read address */ sw_i2c_start ();sw_i2c_write_byte (addr +1 ); - data =sw_i2c_read_byte (1 ); + data =sw_i2c_read_byte ();/* Stop swI2C and release the bus */ sw_i2c_stop ();
Signature · 1 line
2.53.0