Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pwm: cros-ec: Don't care about consumers in .get_state()

The get_state() callback is never called (in a visible way) after there
is a consumer for a pwm device. The core handles loosing the information
about duty_cycle just fine.

Simplify the driver accordingly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20240607084416.897777-6-u.kleine-koenig@baylibre.com
[Drop kdoc comment for channel to make W=1 builds happy]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
f7d5463e 33c651a3

+1 -33
+1 -33
drivers/pwm/pwm-cros-ec.c
··· 20 20 * 21 21 * @ec: Pointer to EC device 22 22 * @use_pwm_type: Use PWM types instead of generic channels 23 - * @channel: array with per-channel data 24 23 */ 25 24 struct cros_ec_pwm_device { 26 25 struct cros_ec_device *ec; 27 26 bool use_pwm_type; 28 - struct cros_ec_pwm *channel; 29 - }; 30 - 31 - /** 32 - * struct cros_ec_pwm - per-PWM driver data 33 - * @duty_cycle: cached duty cycle 34 - */ 35 - struct cros_ec_pwm { 36 - u16 duty_cycle; 37 27 }; 38 28 39 29 static inline struct cros_ec_pwm_device *pwm_to_cros_ec_pwm(struct pwm_chip *chip) ··· 125 135 const struct pwm_state *state) 126 136 { 127 137 struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); 128 - struct cros_ec_pwm *channel = &ec_pwm->channel[pwm->hwpwm]; 129 138 u16 duty_cycle; 130 139 int ret; 131 140 ··· 145 156 if (ret < 0) 146 157 return ret; 147 158 148 - channel->duty_cycle = state->duty_cycle; 149 - 150 159 return 0; 151 160 } 152 161 ··· 152 165 struct pwm_state *state) 153 166 { 154 167 struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); 155 - struct cros_ec_pwm *channel = &ec_pwm->channel[pwm->hwpwm]; 156 168 int ret; 157 169 158 170 ret = cros_ec_pwm_get_duty(ec_pwm->ec, ec_pwm->use_pwm_type, pwm->hwpwm); ··· 161 175 } 162 176 163 177 state->enabled = (ret > 0); 178 + state->duty_cycle = ret; 164 179 state->period = EC_PWM_MAX_DUTY; 165 180 state->polarity = PWM_POLARITY_NORMAL; 166 - 167 - /* 168 - * Note that "disabled" and "duty cycle == 0" are treated the same. If 169 - * the cached duty cycle is not zero, used the cached duty cycle. This 170 - * ensures that the configured duty cycle is kept across a disable and 171 - * enable operation and avoids potentially confusing consumers. 172 - * 173 - * For the case of the initial hardware readout, channel->duty_cycle 174 - * will be 0 and the actual duty cycle read from the EC is used. 175 - */ 176 - if (ret == 0 && channel->duty_cycle > 0) 177 - state->duty_cycle = channel->duty_cycle; 178 - else 179 - state->duty_cycle = ret; 180 181 181 182 return 0; 182 183 } ··· 263 290 /* PWM chip */ 264 291 chip->ops = &cros_ec_pwm_ops; 265 292 chip->of_xlate = cros_ec_pwm_xlate; 266 - 267 - ec_pwm->channel = devm_kcalloc(dev, chip->npwm, sizeof(*ec_pwm->channel), 268 - GFP_KERNEL); 269 - if (!ec_pwm->channel) 270 - return -ENOMEM; 271 293 272 294 dev_dbg(dev, "Probed %u PWMs\n", chip->npwm); 273 295