Re: [DO NOT MERGE v8 08/36] clocksource: sh_tmu: CLOCKSOURCE support.
From: Andy Shevchenko
Date: Wed May 29 2024 - 08:56:44 EST
On Wed, May 29, 2024 at 05:00:54PM +0900, Yoshinori Sato wrote:
> Allows initialization as CLOCKSOURCE.
..
> - dev_info(&ch->tmu->pdev->dev, "ch%u: used for %s clock events\n",
> - ch->index, periodic ? "periodic" : "oneshot");
> + pr_info("%s ch%u: used for %s clock events\n",
> + ch->tmu->name, ch->index, periodic ? "periodic" : "oneshot");
This is a step back change. We should use dev_*() if we have a device
available. And I believe this is the case (at least for the previous boards),
no?
..
> - ch->irq = platform_get_irq(tmu->pdev, index);
> + if (tmu->np)
> + ch->irq = of_irq_get(tmu->np, index);
> + else if (tmu->pdev)
> + ch->irq = platform_get_irq(tmu->pdev, index);
I found these changes counterproductive. Instead better to have up to three
files to cover:
- the common code (library)
- the platform device support
- the pure OF support.
..
> - res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
> - if (!res) {
> - dev_err(&tmu->pdev->dev, "failed to get I/O memory\n");
> - return -ENXIO;
> + if (tmu->pdev) {
> + res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + pr_err("sh_tmu failed to get I/O memory\n");
> + return -ENXIO;
> + }
> +
> + tmu->mapbase = ioremap(res->start, resource_size(res));
devm_platform_ioremap_resource() should be good to have.
Again, consider proper splitting.
> }
> + if (tmu->np)
> + tmu->mapbase = of_iomap(tmu->np, 0);
So, how many boards are non-OF compatible? Maybe makes sense to move them to OF
and drop these platform code entirely from everywhere?
..
> + tmu->name = dev_name(&pdev->dev);
> + tmu->clk = clk_get(&tmu->pdev->dev, "fck");
devm_ approach can help a lot in case of platform device code.
> + if (IS_ERR(tmu->clk)) {
> + dev_err(&tmu->pdev->dev, "cannot get clock\n");
> + return PTR_ERR(tmu->clk);
return dev_err_probe() ?
> + }
--
With Best Regards,
Andy Shevchenko