mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
counter: ftm-quaddec: Convert to new counter registration
This fixes device lifetime issues where it was possible to free a live
struct device.
Fixes: a3b9a99980
("counter: add FlexTimer Module Quadrature decoder counter driver")
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211230150300.72196-19-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e99dec87a9
commit
b5d6547c8e
@ -26,7 +26,6 @@
|
||||
})
|
||||
|
||||
struct ftm_quaddec {
|
||||
struct counter_device counter;
|
||||
struct platform_device *pdev;
|
||||
void __iomem *ftm_base;
|
||||
bool big_endian;
|
||||
@ -259,15 +258,17 @@ static struct counter_count ftm_quaddec_counts = {
|
||||
|
||||
static int ftm_quaddec_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct counter_device *counter;
|
||||
struct ftm_quaddec *ftm;
|
||||
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
struct resource *io;
|
||||
int ret;
|
||||
|
||||
ftm = devm_kzalloc(&pdev->dev, sizeof(*ftm), GFP_KERNEL);
|
||||
if (!ftm)
|
||||
counter = devm_counter_alloc(&pdev->dev, sizeof(*ftm));
|
||||
if (!counter)
|
||||
return -ENOMEM;
|
||||
ftm = counter_priv(counter);
|
||||
|
||||
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!io) {
|
||||
@ -283,14 +284,13 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "Failed to map memory region\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
ftm->counter.name = dev_name(&pdev->dev);
|
||||
ftm->counter.parent = &pdev->dev;
|
||||
ftm->counter.ops = &ftm_quaddec_cnt_ops;
|
||||
ftm->counter.counts = &ftm_quaddec_counts;
|
||||
ftm->counter.num_counts = 1;
|
||||
ftm->counter.signals = ftm_quaddec_signals;
|
||||
ftm->counter.num_signals = ARRAY_SIZE(ftm_quaddec_signals);
|
||||
ftm->counter.priv = ftm;
|
||||
counter->name = dev_name(&pdev->dev);
|
||||
counter->parent = &pdev->dev;
|
||||
counter->ops = &ftm_quaddec_cnt_ops;
|
||||
counter->counts = &ftm_quaddec_counts;
|
||||
counter->num_counts = 1;
|
||||
counter->signals = ftm_quaddec_signals;
|
||||
counter->num_signals = ARRAY_SIZE(ftm_quaddec_signals);
|
||||
|
||||
mutex_init(&ftm->ftm_quaddec_mutex);
|
||||
|
||||
@ -300,9 +300,9 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_counter_register(&pdev->dev, &ftm->counter);
|
||||
ret = devm_counter_add(&pdev->dev, counter);
|
||||
if (ret)
|
||||
return ret;
|
||||
return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user