Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68e24113 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

USB: serial: rework usb_serial_register/deregister_drivers()



This reworks the usb_serial_register_drivers() and
usb_serial_deregister_drivers() to not need a pointer to a struct
usb_driver anymore.  The usb_driver structure is now created dynamically
and registered and unregistered as needed.

This saves lines of code in each usb-serial driver.  All in-kernel users
of these functions were also fixed up at this time.  The pl2303 driver
was tested that everything worked properly.

Thanks for the idea to do this from Alan Stern.

Cc: Adhir Ramjiawan <adhirramjiawan0@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Al Borchers <alborchers@steinerpoint.com>
Cc: Aleksey Babahin <tamerlan311@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Worsley <amworsley@gmail.com>
Cc: Bart Hartgers <bart.hartgers@gmail.com>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Dan Williams <dcbw@redhat.com>
Cc: Donald Lee <donald@asix.com.tw>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Gary Brubaker <xavyer@ix.netcom.com>
Cc: Jesper Juhl <jj@chaosbits.net>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Julia Lawall <julia@diku.dk>
Cc: Kautuk Consul <consul.kautuk@gmail.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Lonnie Mendez <dignome@gmail.com>
Cc: Matthias Bruestle and Harald Welte <support@reiner-sct.com>
Cc: Matthias Urlichs <smurf@smurf.noris.de>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Michal Sroczynski <msroczyn@gmail.com>
Cc: "Michał Wróbel" <michal.wrobel@flytronic.pl>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Peter Berger <pberger@brimson.com>
Cc: Preston Fick <preston.fick@silabs.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Rigbert Hamisch <rigbert@gmx.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Simon Arlott <simon@fire.lp0.eu>
Cc: Support Department <support@connecttech.com>
Cc: Thomas Tuttle <ttuttle@chromium.org>
Cc: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Cc: Wang YanQing <Udknight@gmail.com>
Cc: William Greathouse <wgreathouse@smva.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d56ba320
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ static bool debug;
#define FOURTHCHAR	((unsigned char *)(urb->transfer_buffer))[i + 3]
#define FIFTHCHAR	((unsigned char *)(urb->transfer_buffer))[i + 4]

static const struct usb_device_id quausb2_id_table[] = {
static const struct usb_device_id id_table[] = {
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU2_100)},
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_100)},
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_400)},
@@ -126,14 +126,7 @@ static const struct usb_device_id quausb2_id_table[] = {
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU2_400)},
	{}	/* Terminating entry */
};

MODULE_DEVICE_TABLE(usb, quausb2_id_table);

/* custom structures we need go here */
static struct usb_driver quausb2_usb_driver = {
	.name = "quatech-usb2-serial",
	.id_table = quausb2_id_table,
};
MODULE_DEVICE_TABLE(usb, id_table);

/**
 * quatech2_port: Structure in which to keep all the messy stuff that this
@@ -1922,7 +1915,7 @@ static struct usb_serial_driver quatech2_device = {
		.name = "quatech_usb2",
	},
	.description = DRIVER_DESC,
	.id_table = quausb2_id_table,
	.id_table = id_table,
	.num_ports = 8,
	.open = qt2_open,
	.close = qt2_close,
@@ -1947,7 +1940,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
	&quatech2_device, NULL
};

module_usb_serial_driver(quausb2_usb_driver, serial_drivers);
module_usb_serial_driver(serial_drivers, id_table);

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
+4 −10
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ static bool debug;
#define MODEM_CTRL          0x40
#define RS232_MODE          0x00

static const struct usb_device_id serqt_id_table[] = {
static const struct usb_device_id id_table[] = {
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU200)},
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100)},
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU200)},
@@ -152,8 +152,7 @@ static const struct usb_device_id serqt_id_table[] = {
	{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU100_2)},
	{}			/* Terminating entry */
};

MODULE_DEVICE_TABLE(usb, serqt_id_table);
MODULE_DEVICE_TABLE(usb, id_table);

struct qt_get_device_data {
	__u8 porta;
@@ -195,11 +194,6 @@ struct quatech_port {
	char closePending;
};

static struct usb_driver serqt_usb_driver = {
	.name = "quatech-usb-serial",
	.id_table = serqt_id_table,
};

static int port_paranoia_check(struct usb_serial_port *port,
			       const char *function)
{
@@ -1544,7 +1538,7 @@ static struct usb_serial_driver quatech_device = {
		   .name = "serqt",
		   },
	.description = DRIVER_DESC,
	.id_table = serqt_id_table,
	.id_table = id_table,
	.num_ports = 8,
	.open = qt_open,
	.close = qt_close,
@@ -1567,7 +1561,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
	&quatech_device, NULL
};

module_usb_serial_driver(serqt_usb_driver, serial_drivers);
module_usb_serial_driver(serial_drivers, id_table);

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
+1 −6
Original line number Diff line number Diff line
@@ -170,11 +170,6 @@ static void aircable_process_read_urb(struct urb *urb)
	tty_kref_put(tty);
}

static struct usb_driver aircable_driver = {
	.name =		"aircable",
	.id_table =	id_table,
};

static struct usb_serial_driver aircable_device = {
	.driver = {
		.owner =	THIS_MODULE,
@@ -194,7 +189,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
	&aircable_device, NULL
};

module_usb_serial_driver(aircable_driver, serial_drivers);
module_usb_serial_driver(serial_drivers, id_table);

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
+1 −6
Original line number Diff line number Diff line
@@ -714,11 +714,6 @@ static void ark3116_process_read_urb(struct urb *urb)
	tty_kref_put(tty);
}

static struct usb_driver ark3116_driver = {
	.name =		"ark3116",
	.id_table =	id_table,
};

static struct usb_serial_driver ark3116_device = {
	.driver = {
		.owner =	THIS_MODULE,
@@ -745,7 +740,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
	&ark3116_device, NULL
};

module_usb_serial_driver(ark3116_driver, serial_drivers);
module_usb_serial_driver(serial_drivers, id_table);

MODULE_LICENSE("GPL");

+4 −9
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty,
					unsigned int set, unsigned int clear);


static const struct usb_device_id id_table_combined[] = {
static const struct usb_device_id id_table[] = {
	{ USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
	{ USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
	{ USB_DEVICE(PERACOM_VID, PERACOM_PID) },
@@ -71,12 +71,7 @@ static const struct usb_device_id id_table_combined[] = {
	{ USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) },
	{ }	/* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, id_table_combined);

static struct usb_driver belkin_driver = {
	.name =		"belkin",
	.id_table =	id_table_combined,
};
MODULE_DEVICE_TABLE(usb, id_table);

/* All of the device info needed for the serial converters */
static struct usb_serial_driver belkin_device = {
@@ -85,7 +80,7 @@ static struct usb_serial_driver belkin_device = {
		.name =		"belkin",
	},
	.description =		"Belkin / Peracom / GoHubs USB Serial Adapter",
	.id_table =		id_table_combined,
	.id_table =		id_table,
	.num_ports =		1,
	.open =			belkin_sa_open,
	.close =		belkin_sa_close,
@@ -513,7 +508,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty,
	return retval;
}

module_usb_serial_driver(belkin_driver, serial_drivers);
module_usb_serial_driver(serial_drivers, id_table);

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
Loading