@@ -40,15 +40,18 @@ struct pwm_fan_ctx {
40
40
41
41
static int __set_pwm (struct pwm_fan_ctx * ctx , unsigned long pwm )
42
42
{
43
+ struct pwm_args pargs ;
43
44
unsigned long duty ;
44
45
int ret = 0 ;
45
46
47
+ pwm_get_args (ctx -> pwm , & pargs );
48
+
46
49
mutex_lock (& ctx -> lock );
47
50
if (ctx -> pwm_value == pwm )
48
51
goto exit_set_pwm_err ;
49
52
50
- duty = DIV_ROUND_UP (pwm * (ctx -> pwm -> period - 1 ), MAX_PWM );
51
- ret = pwm_config (ctx -> pwm , duty , ctx -> pwm -> period );
53
+ duty = DIV_ROUND_UP (pwm * (pargs . period - 1 ), MAX_PWM );
54
+ ret = pwm_config (ctx -> pwm , duty , pargs . period );
52
55
if (ret )
53
56
goto exit_set_pwm_err ;
54
57
@@ -215,6 +218,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
215
218
{
216
219
struct thermal_cooling_device * cdev ;
217
220
struct pwm_fan_ctx * ctx ;
221
+ struct pwm_args pargs ;
218
222
struct device * hwmon ;
219
223
int duty_cycle ;
220
224
int ret ;
@@ -233,11 +237,19 @@ static int pwm_fan_probe(struct platform_device *pdev)
233
237
234
238
platform_set_drvdata (pdev , ctx );
235
239
240
+ /*
241
+ * FIXME: pwm_apply_args() should be removed when switching to the
242
+ * atomic PWM API.
243
+ */
244
+ pwm_apply_args (ctx -> pwm );
245
+
236
246
/* Set duty cycle to maximum allowed */
237
- duty_cycle = ctx -> pwm -> period - 1 ;
247
+ pwm_get_args (ctx -> pwm , & pargs );
248
+
249
+ duty_cycle = pargs .period - 1 ;
238
250
ctx -> pwm_value = MAX_PWM ;
239
251
240
- ret = pwm_config (ctx -> pwm , duty_cycle , ctx -> pwm -> period );
252
+ ret = pwm_config (ctx -> pwm , duty_cycle , pargs . period );
241
253
if (ret ) {
242
254
dev_err (& pdev -> dev , "Failed to configure PWM\n" );
243
255
return ret ;
@@ -303,14 +315,16 @@ static int pwm_fan_suspend(struct device *dev)
303
315
static int pwm_fan_resume (struct device * dev )
304
316
{
305
317
struct pwm_fan_ctx * ctx = dev_get_drvdata (dev );
318
+ struct pwm_args pargs ;
306
319
unsigned long duty ;
307
320
int ret ;
308
321
309
322
if (ctx -> pwm_value == 0 )
310
323
return 0 ;
311
324
312
- duty = DIV_ROUND_UP (ctx -> pwm_value * (ctx -> pwm -> period - 1 ), MAX_PWM );
313
- ret = pwm_config (ctx -> pwm , duty , ctx -> pwm -> period );
325
+ pwm_get_args (ctx -> pwm , & pargs );
326
+ duty = DIV_ROUND_UP (ctx -> pwm_value * (pargs .period - 1 ), MAX_PWM );
327
+ ret = pwm_config (ctx -> pwm , duty , pargs .period );
314
328
if (ret )
315
329
return ret ;
316
330
return pwm_enable (ctx -> pwm );
0 commit comments