Re: [PATCH v6 4/8] clocksource/drivers/timer-gxp: Add HPE GXP Timer

From: Arnd Bergmann
Date: Tue May 03 2022 - 06:34:27 EST


On Mon, May 2, 2022 at 10:40 PM <nick.hawkins@xxxxxxx> wrote:
>
> +config GXP_TIMER
> + bool "GXP timer driver" if COMPILE_TEST
> + depends on ARCH_HPE
> + default y

I don't think this does what you intended: with the COMPILE_TEST option,
you make it possible to disable the driver when ARCH_HPE is set,
but you don't allow enabling it on other platforms, which is actually the
point of compile testing.

Maybe instead use

config GXP_TIMER
bool "GXP timer driver" if COMPILE_TEST && !ARCH_HPE
default ARCH_HPE

Also change the prompt to be more specific and mention HPE,
as the 'GXP timer' is not a particularly obvious name for random
users.

You probably also need

select TIMER_OF if OF


> +/*
> + * This probe gets called after the timer is already up and running. This will create
> + * the watchdog device as a child since the registers are shared.
> + */
> +
> +static int gxp_timer_probe(struct platform_device *pdev)
> +{
> + struct platform_device *gxp_watchdog_device;
> + struct device *dev = &pdev->dev;
> +
> + if (!gxp_timer) {
> + pr_err("Gxp Timer not initialized, cannot create watchdog");
> + return -ENOMEM;
> + }
> +
> + gxp_watchdog_device = platform_device_alloc("gxp-wdt", -1);
> + if (!gxp_watchdog_device) {
> + pr_err("Timer failed to allocate gxp-wdt");
> + return -ENOMEM;
> + }
> +
> + /* Pass the base address (counter) as platform data and nothing else */
> + gxp_watchdog_device->dev.platform_data = gxp_timer->counter;
> + gxp_watchdog_device->dev.parent = dev;
> +
> + return platform_device_add(gxp_watchdog_device);
> +}

This looks good to me now.

Arnd