@@ -373,13 +373,15 @@ static const struct regmap_config ti_eqep_regmap16_config = {
373
373
static int ti_eqep_probe (struct platform_device * pdev )
374
374
{
375
375
struct device * dev = & pdev -> dev ;
376
+ struct counter_device * counter ;
376
377
struct ti_eqep_cnt * priv ;
377
378
void __iomem * base ;
378
379
int err ;
379
380
380
- priv = devm_kzalloc (dev , sizeof (* priv ), GFP_KERNEL );
381
- if (!priv )
381
+ counter = devm_counter_alloc (dev , sizeof (* priv ));
382
+ if (!counter )
382
383
return - ENOMEM ;
384
+ priv = counter_priv (counter );
383
385
384
386
base = devm_platform_ioremap_resource (pdev , 0 );
385
387
if (IS_ERR (base ))
@@ -395,16 +397,15 @@ static int ti_eqep_probe(struct platform_device *pdev)
395
397
if (IS_ERR (priv -> regmap16 ))
396
398
return PTR_ERR (priv -> regmap16 );
397
399
398
- priv -> counter .name = dev_name (dev );
399
- priv -> counter .parent = dev ;
400
- priv -> counter .ops = & ti_eqep_counter_ops ;
401
- priv -> counter .counts = ti_eqep_counts ;
402
- priv -> counter .num_counts = ARRAY_SIZE (ti_eqep_counts );
403
- priv -> counter .signals = ti_eqep_signals ;
404
- priv -> counter .num_signals = ARRAY_SIZE (ti_eqep_signals );
405
- priv -> counter .priv = priv ;
400
+ counter -> name = dev_name (dev );
401
+ counter -> parent = dev ;
402
+ counter -> ops = & ti_eqep_counter_ops ;
403
+ counter -> counts = ti_eqep_counts ;
404
+ counter -> num_counts = ARRAY_SIZE (ti_eqep_counts );
405
+ counter -> signals = ti_eqep_signals ;
406
+ counter -> num_signals = ARRAY_SIZE (ti_eqep_signals );
406
407
407
- platform_set_drvdata (pdev , priv );
408
+ platform_set_drvdata (pdev , counter );
408
409
409
410
/*
410
411
* Need to make sure power is turned on. On AM33xx, this comes from the
@@ -414,7 +415,7 @@ static int ti_eqep_probe(struct platform_device *pdev)
414
415
pm_runtime_enable (dev );
415
416
pm_runtime_get_sync (dev );
416
417
417
- err = counter_register ( & priv -> counter );
418
+ err = counter_add ( counter );
418
419
if (err < 0 ) {
419
420
pm_runtime_put_sync (dev );
420
421
pm_runtime_disable (dev );
@@ -426,10 +427,10 @@ static int ti_eqep_probe(struct platform_device *pdev)
426
427
427
428
static int ti_eqep_remove (struct platform_device * pdev )
428
429
{
429
- struct ti_eqep_cnt * priv = platform_get_drvdata (pdev );
430
+ struct counter_device * counter = platform_get_drvdata (pdev );
430
431
struct device * dev = & pdev -> dev ;
431
432
432
- counter_unregister (& priv -> counter );
433
+ counter_unregister (counter );
433
434
pm_runtime_put_sync (dev );
434
435
pm_runtime_disable (dev );
435
436
0 commit comments