linux/drivers/watchdog/pcwd_usb.c

// SPDX-License-Identifier: GPL-2.0+
/*
 *	Berkshire USB-PC Watchdog Card Driver
 *
 *	(c) Copyright 2004-2007 Wim Van Sebroeck <[email protected]>.
 *
 *	Based on source code of the following authors:
 *	  Ken Hollis <[email protected]>,
 *	  Alan Cox <[email protected]>,
 *	  Matt Domsch <[email protected]>,
 *	  Rob Radez <[email protected]>,
 *	  Greg Kroah-Hartman <[email protected]>
 *
 *	Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
 *	provide warranty for any of this software. This material is
 *	provided "AS-IS" and at no charge.
 *
 *	Thanks also to Simon Machell at Berkshire Products Inc. for
 *	providing the test hardware. More info is available at
 *	http://www.berkprod.com/ or http://www.pcwatchdog.com/
 */

#define pr_fmt(fmt)

#include <linux/module.h>	/* For module specific items */
#include <linux/moduleparam.h>	/* For new moduleparam's */
#include <linux/types.h>	/* For standard types (like size_t) */
#include <linux/errno.h>	/* For the -ENODEV/... values */
#include <linux/kernel.h>	/* For printk/panic/... */
#include <linux/delay.h>	/* For mdelay function */
#include <linux/miscdevice.h>	/* For struct miscdevice */
#include <linux/watchdog.h>	/* For the watchdog specific items */
#include <linux/notifier.h>	/* For notifier support */
#include <linux/reboot.h>	/* For reboot_notifier stuff */
#include <linux/init.h>		/* For __init/__exit/... */
#include <linux/fs.h>		/* For file operations */
#include <linux/usb.h>		/* For USB functions */
#include <linux/slab.h>		/* For kmalloc, ... */
#include <linux/mutex.h>	/* For mutex locking */
#include <linux/hid.h>		/* For HID_REQ_SET_REPORT & HID_DT_REPORT */
#include <linux/uaccess.h>	/* For copy_to_user/put_user/... */


/* Module and Version Information */
#define DRIVER_VERSION
#define DRIVER_AUTHOR
#define DRIVER_DESC
#define DRIVER_NAME

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

#define WATCHDOG_HEARTBEAT
static int heartbeat =;
module_param(heartbeat, int, 0);
MODULE_PARM_DESC();

static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC();

/* The vendor and product id's for the USB-PC Watchdog card */
#define USB_PCWD_VENDOR_ID
#define USB_PCWD_PRODUCT_ID

/* table of devices that work with this driver */
static const struct usb_device_id usb_pcwd_table[] =;
MODULE_DEVICE_TABLE(usb, usb_pcwd_table);

/* according to documentation max. time to process a command for the USB
 * watchdog card is 100 or 200 ms, so we give it 250 ms to do it's job */
#define USB_COMMAND_TIMEOUT

/* Watchdog's internal commands */
#define CMD_READ_TEMP
#define CMD_TRIGGER
#define CMD_GET_STATUS
#define CMD_GET_FIRMWARE_VERSION
#define CMD_GET_DIP_SWITCH_SETTINGS
#define CMD_READ_WATCHDOG_TIMEOUT
#define CMD_WRITE_WATCHDOG_TIMEOUT
#define CMD_ENABLE_WATCHDOG
#define CMD_DISABLE_WATCHDOG

/* Watchdog's Dip Switch heartbeat values */
static const int heartbeat_tbl[] =;

/* We can only use 1 card due to the /dev/watchdog restriction */
static int cards_found;

/* some internal variables */
static unsigned long is_active;
static char expect_release;

/* Structure to hold all of our device specific stuff */
struct usb_pcwd_private {};
static struct usb_pcwd_private *usb_pcwd_device;

/* prevent races between open() and disconnect() */
static DEFINE_MUTEX(disconnect_mutex);

/* local function prototypes */
static int usb_pcwd_probe(struct usb_interface *interface,
						const struct usb_device_id *id);
static void usb_pcwd_disconnect(struct usb_interface *interface);

/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver usb_pcwd_driver =;


static void usb_pcwd_intr_done(struct urb *urb)
{}

static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
		unsigned char cmd, unsigned char *msb, unsigned char *lsb)
{}

static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd)
{}

static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd)
{}

static int usb_pcwd_keepalive(struct usb_pcwd_private *usb_pcwd)
{}

static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t)
{}

static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
							int *temperature)
{}

static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
								int *time_left)
{}

/*
 *	/dev/watchdog handling
 */

static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
						size_t len, loff_t *ppos)
{}

static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
						unsigned long arg)
{}

static int usb_pcwd_open(struct inode *inode, struct file *file)
{}

static int usb_pcwd_release(struct inode *inode, struct file *file)
{}

/*
 *	/dev/temperature handling
 */

static ssize_t usb_pcwd_temperature_read(struct file *file, char __user *data,
				size_t len, loff_t *ppos)
{}

static int usb_pcwd_temperature_open(struct inode *inode, struct file *file)
{}

static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)
{}

/*
 *	Notify system
 */

static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code,
								void *unused)
{}

/*
 *	Kernel Interfaces
 */

static const struct file_operations usb_pcwd_fops =;

static struct miscdevice usb_pcwd_miscdev =;

static const struct file_operations usb_pcwd_temperature_fops =;

static struct miscdevice usb_pcwd_temperature_miscdev =;

static struct notifier_block usb_pcwd_notifier =;

/**
 *	usb_pcwd_delete
 */
static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd)
{}

/**
 *	usb_pcwd_probe
 *
 *	Called by the usb core when a new device is connected that it thinks
 *	this driver might be interested in.
 */
static int usb_pcwd_probe(struct usb_interface *interface,
						const struct usb_device_id *id)
{}


/**
 *	usb_pcwd_disconnect
 *
 *	Called by the usb core when the device is removed from the system.
 *
 *	This routine guarantees that the driver will not submit any more urbs
 *	by clearing dev->udev.
 */
static void usb_pcwd_disconnect(struct usb_interface *interface)
{}

module_usb_driver();