|
24 | 24 |
|
25 | 25 | struct mchp_tc_data {
|
26 | 26 | const struct atmel_tcb_config *tc_cfg;
|
27 |
| - struct counter_device counter; |
28 | 27 | struct regmap *regmap;
|
29 | 28 | int qdec_mode;
|
30 | 29 | int num_channels;
|
@@ -296,16 +295,18 @@ static int mchp_tc_probe(struct platform_device *pdev)
|
296 | 295 | struct device_node *np = pdev->dev.of_node;
|
297 | 296 | const struct atmel_tcb_config *tcb_config;
|
298 | 297 | const struct of_device_id *match;
|
| 298 | + struct counter_device *counter; |
299 | 299 | struct mchp_tc_data *priv;
|
300 | 300 | char clk_name[7];
|
301 | 301 | struct regmap *regmap;
|
302 | 302 | struct clk *clk[3];
|
303 | 303 | int channel;
|
304 | 304 | int ret, i;
|
305 | 305 |
|
306 |
| - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
307 |
| - if (!priv) |
| 306 | + counter = devm_counter_alloc(&pdev->dev, sizeof(*priv)); |
| 307 | + if (!counter) |
308 | 308 | return -ENOMEM;
|
| 309 | + priv = counter_priv(counter); |
309 | 310 |
|
310 | 311 | match = of_match_node(atmel_tc_of_match, np->parent);
|
311 | 312 | tcb_config = match->data;
|
@@ -360,16 +361,19 @@ static int mchp_tc_probe(struct platform_device *pdev)
|
360 | 361 |
|
361 | 362 | priv->tc_cfg = tcb_config;
|
362 | 363 | priv->regmap = regmap;
|
363 |
| - priv->counter.name = dev_name(&pdev->dev); |
364 |
| - priv->counter.parent = &pdev->dev; |
365 |
| - priv->counter.ops = &mchp_tc_ops; |
366 |
| - priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts); |
367 |
| - priv->counter.counts = mchp_tc_counts; |
368 |
| - priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals); |
369 |
| - priv->counter.signals = mchp_tc_count_signals; |
370 |
| - priv->counter.priv = priv; |
371 |
| - |
372 |
| - return devm_counter_register(&pdev->dev, &priv->counter); |
| 364 | + counter->name = dev_name(&pdev->dev); |
| 365 | + counter->parent = &pdev->dev; |
| 366 | + counter->ops = &mchp_tc_ops; |
| 367 | + counter->num_counts = ARRAY_SIZE(mchp_tc_counts); |
| 368 | + counter->counts = mchp_tc_counts; |
| 369 | + counter->num_signals = ARRAY_SIZE(mchp_tc_count_signals); |
| 370 | + counter->signals = mchp_tc_count_signals; |
| 371 | + |
| 372 | + ret = devm_counter_add(&pdev->dev, counter); |
| 373 | + if (ret < 0) |
| 374 | + return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n"); |
| 375 | + |
| 376 | + return 0; |
373 | 377 | }
|
374 | 378 |
|
375 | 379 | static const struct of_device_id mchp_tc_dt_ids[] = {
|
|
0 commit comments