@@ -75,6 +75,7 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip,
75
75
{
76
76
struct axi_pwmgen_waveform * wfhw = _wfhw ;
77
77
struct axi_pwmgen_ddata * ddata = axi_pwmgen_ddata_from_chip (chip );
78
+ int ret = 0 ;
78
79
79
80
if (wf -> period_length_ns == 0 ) {
80
81
* wfhw = (struct axi_pwmgen_waveform ){
@@ -91,12 +92,15 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip,
91
92
if (wfhw -> period_cnt == 0 ) {
92
93
/*
93
94
* The specified period is too short for the hardware.
94
- * Let's round .duty_cycle down to 0 to get a (somewhat)
95
- * valid result.
95
+ * So round up .period_cnt to 1 (i.e. the smallest
96
+ * possible period). With .duty_cycle and .duty_offset
97
+ * being less than or equal to .period, their rounded
98
+ * value must be 0.
96
99
*/
97
100
wfhw -> period_cnt = 1 ;
98
101
wfhw -> duty_cycle_cnt = 0 ;
99
102
wfhw -> duty_offset_cnt = 0 ;
103
+ ret = 1 ;
100
104
} else {
101
105
wfhw -> duty_cycle_cnt = min_t (u64 ,
102
106
mul_u64_u32_div (wf -> duty_length_ns , ddata -> clk_rate_hz , NSEC_PER_SEC ),
@@ -111,7 +115,7 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip,
111
115
pwm -> hwpwm , wf -> duty_length_ns , wf -> period_length_ns , wf -> duty_offset_ns ,
112
116
ddata -> clk_rate_hz , wfhw -> period_cnt , wfhw -> duty_cycle_cnt , wfhw -> duty_offset_cnt );
113
117
114
- return 0 ;
118
+ return ret ;
115
119
}
116
120
117
121
static int axi_pwmgen_round_waveform_fromhw (struct pwm_chip * chip , struct pwm_device * pwm ,
0 commit comments