@ -571,6 +571,7 @@ static int stm32_i2c_choose_solution(struct stm32_i2c_setup *setup,
u32 dnf_delay ;
u32 dnf_delay ;
u32 tsync ;
u32 tsync ;
u16 l , h ;
u16 l , h ;
bool sol_found = false ;
int ret = 0 ;
int ret = 0 ;
af_delay_min = setup - > analog_filter ?
af_delay_min = setup - > analog_filter ?
@ -619,14 +620,15 @@ static int stm32_i2c_choose_solution(struct stm32_i2c_setup *setup,
clk_error_prev = clk_error ;
clk_error_prev = clk_error ;
v - > scll = l ;
v - > scll = l ;
v - > sclh = h ;
v - > sclh = h ;
s = v ;
sol_found = true ;
memcpy ( s , v , sizeof ( * s ) ) ;
}
}
}
}
}
}
}
}
}
}
if ( ! s ) {
if ( ! sol_found ) {
pr_err ( " %s: no solution at all \n " , __func__ ) ;
pr_err ( " %s: no solution at all \n " , __func__ ) ;
ret = - EPERM ;
ret = - EPERM ;
}
}
@ -638,7 +640,7 @@ static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
struct stm32_i2c_setup * setup ,
struct stm32_i2c_setup * setup ,
struct stm32_i2c_timings * output )
struct stm32_i2c_timings * output )
{
{
struct stm32_i2c_timings * v , * _v , * s ;
struct stm32_i2c_timings * v , * _v , s ;
struct list_head solutions ;
struct list_head solutions ;
int ret ;
int ret ;
@ -669,21 +671,20 @@ static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
return - EINVAL ;
return - EINVAL ;
}
}
s = NULL ;
INIT_LIST_HEAD ( & solutions ) ;
INIT_LIST_HEAD ( & solutions ) ;
ret = stm32_i2c_compute_solutions ( setup , & solutions ) ;
ret = stm32_i2c_compute_solutions ( setup , & solutions ) ;
if ( ret )
if ( ret )
goto exit ;
goto exit ;
ret = stm32_i2c_choose_solution ( setup , & solutions , s ) ;
ret = stm32_i2c_choose_solution ( setup , & solutions , & s ) ;
if ( ret )
if ( ret )
goto exit ;
goto exit ;
output - > presc = s - > presc ;
output - > presc = s . presc ;
output - > scldel = s - > scldel ;
output - > scldel = s . scldel ;
output - > sdadel = s - > sdadel ;
output - > sdadel = s . sdadel ;
output - > scll = s - > scll ;
output - > scll = s . scll ;
output - > sclh = s - > sclh ;
output - > sclh = s . sclh ;
debug ( " %s: Presc: %i, scldel: %i, sdadel: %i, scll: %i, sclh: %i \n " ,
debug ( " %s: Presc: %i, scldel: %i, sdadel: %i, scll: %i, sclh: %i \n " ,
__func__ , output - > presc ,
__func__ , output - > presc ,