Re: [RFC] Watchdog device class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rudolf,

> > It's not about different approaches: we have to find the best thing for watchdog
> > devicesi, so the best thing is to talk about pro's and con's and see what we should 
> > do best. (I for instance didn't come to the sysfs part yet of my code (which would
> > be in watchdog_sysfs.c)
> 
> Ok I will look into your code.

Please have a look at the experimental code in the linux-2.6-watchdog-experimental git tree
(http://www.kernel.org/git/?p=linux/kernel/git/wim/linux-2.6-watchdog-experimental.git;a=summary).

It's a first draft of the generic code. (it's split into tree main parts: the core code, the 
/dev/watchdog code and the sysfs code). (Note: I used Greg's new "class" device setup).
And it basically uses the following operations and watchdog_device structure:

struct watchdog_ops {
	/* mandatory routines */
	int	(*start)(struct watchdog_device *);			/* operation = start watchdog */
	int	(*stop)(struct watchdog_device *);			/* operation = stop watchdog */
	int	(*keepalive)(struct watchdog_device *);			/* operation = send keepalive ping */
	/* optional routines */
	int	(*set_heartbeat)(struct watchdog_device *,int);		/* operation = set watchdog's heartbeat */
	int	(*get_status)(struct watchdog_device *,int *);		/* operation = get the watchdog's status */
	int	(*get_timeleft)(struct watchdog_device *, int *);	/* operation = get the time left before reboot */
	int	(*sys_restart)(struct watchdog_device *);		/* operation = force a system_restart for rebooting */
};

struct watchdog_device {
	unsigned char name[32];				/* The watchdog's 'identity' */
	unsigned long options;				/* The supported capabilities/options */
	unsigned long firmware;				/* The Watchdog's Firmware version */
	int heartbeat;					/* The watchdog's heartbeat */
	int nowayout;					/* The nowayout setting for this watchdog */
	int bootstatus;					/* The watchdog's bootstatus */
	int temppanic;					/* wether or not to panic on temperature trip's */
	struct watchdog_ops *watchdog_ops;		/* link to watchdog_ops */

	/* watchdog status (register/unregister) state machine */
	enum { WATCHDOG_UNINITIALIZED=0,
               WATCHDOG_REGISTERED,			/* completed register_watchdogdevice */
               WATCHDOG_STARTED,			/* watchdog device started */
               WATCHDOG_STOPPED,			/* watchdog device stopped */
               WATCHDOG_UNREGISTERED,			/* completed unregister_watchdogdevice */
	} watchdog_state;

	struct semaphore sem;				/* locks this structure */

	struct device *cdev;				/* Sysfs watchdog class device */

	/* From here on everything is device dependent */
	void	*private;
};

There are still a number of things to be added:
* have a list under register_watchdogdevice so that we can register multiple watchdog devices
(Note: only one watchdog device will be linked to /dev/watchdog)
* add pre-timeout stuff
* clean-up sysfs code
* do proper locking
* add documentation
* make docbook ready
* decide how we will handle the old temperature ioctl
...

All comments/suggestions are welcome. Let's see/discuss what's missing, what we should do different, ...

Greetings,
Wim.

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux