@@ -29,7 +29,6 @@ struct stm32_timer_regs {
29
29
};
30
30
31
31
struct stm32_timer_cnt {
32
- struct counter_device counter ;
33
32
struct regmap * regmap ;
34
33
struct clk * clk ;
35
34
u32 max_arr ;
@@ -317,31 +316,38 @@ static int stm32_timer_cnt_probe(struct platform_device *pdev)
317
316
struct stm32_timers * ddata = dev_get_drvdata (pdev -> dev .parent );
318
317
struct device * dev = & pdev -> dev ;
319
318
struct stm32_timer_cnt * priv ;
319
+ struct counter_device * counter ;
320
+ int ret ;
320
321
321
322
if (IS_ERR_OR_NULL (ddata ))
322
323
return - EINVAL ;
323
324
324
- priv = devm_kzalloc (dev , sizeof (* priv ), GFP_KERNEL );
325
- if (!priv )
325
+ counter = devm_counter_alloc (dev , sizeof (* priv ));
326
+ if (!counter )
326
327
return - ENOMEM ;
327
328
329
+ priv = counter_priv (counter );
330
+
328
331
priv -> regmap = ddata -> regmap ;
329
332
priv -> clk = ddata -> clk ;
330
333
priv -> max_arr = ddata -> max_arr ;
331
334
332
- priv -> counter .name = dev_name (dev );
333
- priv -> counter .parent = dev ;
334
- priv -> counter .ops = & stm32_timer_cnt_ops ;
335
- priv -> counter .counts = & stm32_counts ;
336
- priv -> counter .num_counts = 1 ;
337
- priv -> counter .signals = stm32_signals ;
338
- priv -> counter .num_signals = ARRAY_SIZE (stm32_signals );
339
- priv -> counter .priv = priv ;
335
+ counter -> name = dev_name (dev );
336
+ counter -> parent = dev ;
337
+ counter -> ops = & stm32_timer_cnt_ops ;
338
+ counter -> counts = & stm32_counts ;
339
+ counter -> num_counts = 1 ;
340
+ counter -> signals = stm32_signals ;
341
+ counter -> num_signals = ARRAY_SIZE (stm32_signals );
340
342
341
343
platform_set_drvdata (pdev , priv );
342
344
343
345
/* Register Counter device */
344
- return devm_counter_register (dev , & priv -> counter );
346
+ ret = devm_counter_add (dev , counter );
347
+ if (ret < 0 )
348
+ dev_err_probe (dev , ret , "Failed to add counter\n" );
349
+
350
+ return ret ;
345
351
}
346
352
347
353
static int __maybe_unused stm32_timer_cnt_suspend (struct device * dev )
0 commit comments