hp4x.c 2.0 KB
Newer Older
1 2 3 4
/*
 * HP4x Calculators Serial USB driver
 *
 * Copyright (C) 2005 Arthur Huillet (ahuillet@users.sf.net)
5
 * Copyright (C) 2001-2005 Greg Kroah-Hartman (greg@kroah.com)
6 7 8 9 10 11
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
A
Alan Cox 已提交
12 13
 * See Documentation/usb/usb-serial.txt for more information on using this
 * driver
14 15 16 17 18 19 20
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/usb.h>
21
#include <linux/usb/serial.h>
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

/*
 * Version Information
 */
#define DRIVER_VERSION "v1.00"
#define DRIVER_DESC "HP4x (48/49) Generic Serial driver"

#define HP_VENDOR_ID 0x03f0
#define HP49GP_PRODUCT_ID 0x0121

static struct usb_device_id id_table [] = {
	{ USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) },
	{ }					/* Terminating entry */
};

MODULE_DEVICE_TABLE(usb, id_table);

static struct usb_driver hp49gp_driver = {
40
	.name =		"hp4X",
41 42 43
	.probe =	usb_serial_probe,
	.disconnect =	usb_serial_disconnect,
	.id_table =	id_table,
44
	.no_dynamic_id = 	1,
45 46
};

47
static struct usb_serial_driver hp49gp_device = {
48 49
	.driver = {
		.owner =	THIS_MODULE,
50
		.name =		"hp4X",
51
	},
52
	.id_table =		id_table,
53
	.usb_driver = 		&hp49gp_driver,
54 55 56 57 58 59 60 61 62 63 64 65
	.num_ports =		1,
};

static int __init hp49gp_init(void)
{
	int retval;
	retval = usb_serial_register(&hp49gp_device);
	if (retval)
		goto failed_usb_serial_register;
	retval = usb_register(&hp49gp_driver);
	if (retval)
		goto failed_usb_register;
66 67
	printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
	       DRIVER_DESC "\n");
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
	return 0;
failed_usb_register:
	usb_serial_deregister(&hp49gp_device);
failed_usb_serial_register:
	return retval;
}

static void __exit hp49gp_exit(void)
{
	usb_deregister(&hp49gp_driver);
	usb_serial_deregister(&hp49gp_device);
}

module_init(hp49gp_init);
module_exit(hp49gp_exit);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");