linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, Vojtech Pavlik <vojtech@suse.cz>
Subject: [PATCH 17/24] ct82c710: convert to the new platform device interface
Date: Sat, 07 Jan 2006 12:16:16 -0500	[thread overview]
Message-ID: <20060107172101.507295000.dtor_core@ameritech.net> (raw)
In-Reply-To: 20060107171559.593824000.dtor_core@ameritech.net

[-- Attachment #1: ct82c710-convert-platform-intf.patch --]
[-- Type: text/plain, Size: 4354 bytes --]

Input: ct82c710 - convert to the new platform device interface

Do not use platform_device_register_simple() as it is going away,
implement ->probe() and ->remove() functions so manual binding and
unbinding will work with this driver.


Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/serio/ct82c710.c |   89 +++++++++++++++++++++++++++++------------
 1 files changed, 63 insertions(+), 26 deletions(-)

Index: work/drivers/input/serio/ct82c710.c
===================================================================
--- work.orig/drivers/input/serio/ct82c710.c
+++ work/drivers/input/serio/ct82c710.c
@@ -154,7 +154,7 @@ static int ct82c710_write(struct serio *
  * See if we can find a 82C710 device. Read mouse address.
  */
 
-static int __init ct82c710_probe(void)
+static int __init ct82c710_detect(void)
 {
 	outb_p(0x55, 0x2fa);				/* Any value except 9, ff or 36 */
 	outb_p(0xaa, 0x3fa);				/* Inverse of 55 */
@@ -163,7 +163,7 @@ static int __init ct82c710_probe(void)
 	outb_p(0x1b, 0x2fa);				/* Inverse of e4 */
 	outb_p(0x0f, 0x390);				/* Write index */
 	if (inb_p(0x391) != 0xe4)			/* Config address found? */
-		return -1;				/* No: no 82C710 here */
+		return -ENODEV;				/* No: no 82C710 here */
 
 	outb_p(0x0d, 0x390);				/* Write index */
 	ct82c710_iores.start = inb_p(0x391) << 2;	/* Get mouse I/O address */
@@ -175,51 +175,88 @@ static int __init ct82c710_probe(void)
 	return 0;
 }
 
-static struct serio * __init ct82c710_allocate_port(void)
+static int __devinit ct82c710_probe(struct platform_device *dev)
 {
-	struct serio *serio;
+	ct82c710_port = kzalloc(sizeof(struct serio), GFP_KERNEL);
+	if (!ct82c710_port)
+		return -ENOMEM;
 
-	serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
-	if (serio) {
-		memset(serio, 0, sizeof(struct serio));
-		serio->id.type = SERIO_8042;
-		serio->open = ct82c710_open;
-		serio->close = ct82c710_close;
-		serio->write = ct82c710_write;
-		serio->dev.parent = &ct82c710_device->dev;
-		strlcpy(serio->name, "C&T 82c710 mouse port", sizeof(serio->name));
-		snprintf(serio->phys, sizeof(serio->phys), "isa%04lx/serio0", CT82C710_DATA);
-	}
+	ct82c710_port->id.type = SERIO_8042;
+	ct82c710_port->dev.parent = &dev->dev;
+	ct82c710_port->open = ct82c710_open;
+	ct82c710_port->close = ct82c710_close;
+	ct82c710_port->write = ct82c710_write;
+	strlcpy(ct82c710_port->name, "C&T 82c710 mouse port",
+		sizeof(ct82c710_port->name));
+	snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys),
+		 "isa%04lx/serio0", CT82C710_DATA);
 
-	return serio;
+	serio_register_port(ct82c710_port);
+
+	return 0;
 }
 
-static int __init ct82c710_init(void)
+static int __devexit ct82c710_remove(struct platform_device *dev)
 {
-	if (ct82c710_probe())
-		return -ENODEV;
+	serio_unregister_port(ct82c710_port);
+
+	return 0;
+}
 
-	ct82c710_device = platform_device_register_simple("ct82c710", -1, &ct82c710_iores, 1);
-	if (IS_ERR(ct82c710_device))
-		return PTR_ERR(ct82c710_device);
+static struct platform_driver ct82c710_driver = {
+	.driver		= {
+		.name	= "ct82c710",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= ct82c710_probe,
+	.remove		= __devexit_p(ct82c710_remove),
+};
 
-	if (!(ct82c710_port = ct82c710_allocate_port())) {
-		platform_device_unregister(ct82c710_device);
-		return -ENOMEM;
+
+static int __init ct82c710_init(void)
+{
+	int error;
+
+	error = ct82c710_detect();
+	if (error)
+		return error;
+
+	error = platform_driver_register(&ct82c710_driver);
+	if (error)
+		return error;
+
+	ct82c710_device = platform_device_alloc("ct82c710", -1);
+	if (!ct82c710_device) {
+		error = -ENOMEM;
+		goto err_unregister_driver;
 	}
 
+	error = platform_device_add_resources(ct82c710_device, &ct82c710_iores, 1);
+	if (error)
+		goto err_free_device;
+
+	error = platform_device_add(ct82c710_device);
+	if (error)
+		goto err_free_device;
+
 	serio_register_port(ct82c710_port);
 
 	printk(KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n",
 		CT82C710_DATA, CT82C710_IRQ);
 
 	return 0;
+
+ err_free_device:
+	platform_device_put(ct82c710_device);
+ err_unregister_driver:
+	platform_driver_unregister(&ct82c710_driver);
+	return error;
 }
 
 static void __exit ct82c710_exit(void)
 {
-	serio_unregister_port(ct82c710_port);
 	platform_device_unregister(ct82c710_device);
+	platform_driver_unregister(&ct82c710_driver);
 }
 
 module_init(ct82c710_init);


  parent reply	other threads:[~2006-01-07 19:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-07 17:15 [PATCH 00/24] Input patches for 2.6.15 Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 01/24] evdev: consolidate compat and normal code Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 02/24] Mousedev: make module parameters visible in sysfs Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 03/24] logips2pp: add new signature (85) Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 04/24] Wistron: add Acer TravelMate 240 to DMI table Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 05/24] add the fn key to hid-debug.h Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 06/24] Add Geyser 2 support to appletouch driver Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 07/24] alps: add signature for HP ze1115 Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 08/24] psmouse: dont leave mouse asleep Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 09/24] i8042: disable MUX mode for Sharp MM20 Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 10/24] Add help entry for FM801 gameport driver to Kconfig Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 11/24] lifebook: add DMI signature of Fujitsu Lifebook B142 Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 12/24] pcspkr: register with driver core as a platfrom device Dmitry Torokhov
2006-01-10  6:41   ` Benjamin Herrenschmidt
2006-01-10  6:48     ` Dmitry Torokhov
2006-01-10  7:04       ` Benjamin Herrenschmidt
2006-01-10  7:09         ` Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 13/24] m68kspkr: " Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 14/24] sparcspkr: " Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 15/24] logips2pp: add signature of MouseMan Wheel Mouse (87) Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 16/24] i8042: convert to the new platform device interface Dmitry Torokhov
2006-01-07 17:16 ` Dmitry Torokhov [this message]
2006-01-07 17:16 ` [PATCH 18/24] maceps2: " Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 19/24] q40kbd: " Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 20/24] Wistron: switch " Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 21/24] atkbd: dont lose keymap settings when reconnecting keyboard Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 22/24] Add missing keys to hid-debug.h Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 23/24] i8042: Add OQO Zepto to noloop dmi table Dmitry Torokhov
2006-01-07 17:16 ` [PATCH 24/24] ibmasm: convert to dynamic input_dev allocation Dmitry Torokhov
2006-01-09 18:23   ` Vernon Mauery
2006-01-09 18:30     ` Dmitry Torokhov
2006-01-09 18:31     ` Vernon Mauery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060107172101.507295000.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).