Re: [PATCH 2/2] watchdog: add real function on MOXA V2100 watchdogdriver

From: Alan Cox
Date: Tue Apr 26 2011 - 06:51:27 EST


> + superio_set_logic_device(7); /* logic device 7 */
> + superio_set_reg((swtd_ack_time/1000), 0x73); /* Reg:F6,30 sec */
> +}

If the time is configurable then you want to support that ideally.

> +static void swtd_reboot(void *unused)

No - the watchdog driver needs to deal with hardware reboot, randomly
trying to exec things which may not even be where you expect isn't safe.
User space watchdog daemons can manage their own shutdown just fine. The
watchdog is there to catch the actual hang case.


> + superio_set_reg(1000/1000, 0x73);
> +
> + return NOTIFY_OK;
> +
> + spin_unlock_bh(&swtd_lock);

Wrong order - your lock is left locked !


> +static struct miscdevice wdt_miscdev = {
> + .minor = MOXA_WATCHDOG_MINOR,
> + .name = "swtd",
> + .fops = &moxa_swtd_fops,
> +};

This should use the standard watchdog device


> +moxa_swtd_init_err3:
> + remove_proc_entry("driver/swtd", NULL);
> +moxa_swtd_init_err2:
> + if (timer_pending(&timer_swtd))
> + del_timer(&timer_swtd);

del_timer_sync to ensure it has run

You also need to sort out locking.

There is also no test to ensure the hardware is present so the driver
isn't safe to load on any PC hardware

Is there a magic signature to detect the hardware ?

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/