public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: InputML <linux-input@atrey.karlin.mff.cuni.cz>
Cc: alsa-devel@alsa-project.org, LKML <linux-kernel@vger.kernel.org>,
	Vojtech Pavlik <vojtech@suse.cz>
Subject: [PATCH 10/10] Gameport: replace ->private with gameport_get/set_drvdata
Date: Fri, 11 Feb 2005 02:05:23 -0500	[thread overview]
Message-ID: <200502110205.25146.dtor_core@ameritech.net> (raw)
In-Reply-To: <200502110204.40128.dtor_core@ameritech.net>


===================================================================


ChangeSet@1.2158, 2005-02-11 01:23:40-05:00, dtor_core@ameritech.net
  Input: remove gameport->private in favor of using driver-specific data
         in device structure, add gameport_get/set_drvdata to access it.
  
  Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


 drivers/input/joystick/a3d.c        |   10 ++++++----
 drivers/input/joystick/adi.c        |    7 ++++---
 drivers/input/joystick/analog.c     |    7 +++++--
 drivers/input/joystick/cobra.c      |   10 ++++++----
 drivers/input/joystick/gf2k.c       |   10 ++++++----
 drivers/input/joystick/grip.c       |   10 ++++++----
 drivers/input/joystick/grip_mp.c    |    9 ++++++---
 drivers/input/joystick/guillemot.c  |    9 +++++----
 drivers/input/joystick/interact.c   |   10 ++++++----
 drivers/input/joystick/sidewinder.c |   10 ++++++----
 drivers/input/joystick/tmdc.c       |   10 ++++++----
 include/linux/gameport.h            |   15 ++++++++++++++-
 12 files changed, 76 insertions(+), 41 deletions(-)


===================================================================



diff -Nru a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
--- a/drivers/input/joystick/a3d.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/a3d.c	2005-02-11 01:41:08 -05:00
@@ -277,13 +277,13 @@
 	if (!(a3d = kcalloc(1, sizeof(struct a3d), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = a3d;
-
 	a3d->gameport = gameport;
 	init_timer(&a3d->timer);
 	a3d->timer.data = (long) a3d;
 	a3d->timer.function = a3d_timer;
 
+	gameport_set_drvdata(gameport, a3d);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -379,13 +379,14 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:  kfree(a3d);
+fail1:  gameport_set_drvdata(gameport, NULL);
+	kfree(a3d);
 	return err;
 }
 
 static void a3d_disconnect(struct gameport *gameport)
 {
-	struct a3d *a3d = gameport->private;
+	struct a3d *a3d = gameport_get_drvdata(gameport);
 
 	input_unregister_device(&a3d->dev);
 	if (a3d->adc) {
@@ -393,6 +394,7 @@
 		a3d->adc = NULL;
 	}
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(a3d);
 }
 
diff -Nru a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
--- a/drivers/input/joystick/adi.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/adi.c	2005-02-11 01:41:08 -05:00
@@ -474,13 +474,13 @@
 	if (!(port = kcalloc(1, sizeof(struct adi_port), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = port;
-
 	port->gameport = gameport;
 	init_timer(&port->timer);
 	port->timer.data = (long) port;
 	port->timer.function = adi_timer;
 
+	gameport_set_drvdata(gameport, port);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err) {
 		kfree(port);
@@ -524,12 +524,13 @@
 static void adi_disconnect(struct gameport *gameport)
 {
 	int i;
-	struct adi_port *port = gameport->private;
+	struct adi_port *port = gameport_get_drvdata(gameport);
 
 	for (i = 0; i < 2; i++)
 		if (port->adi[i].length > 0)
 			input_unregister_device(&port->adi[i].dev);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(port);
 }
 
diff -Nru a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
--- a/drivers/input/joystick/analog.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/analog.c	2005-02-11 01:41:08 -05:00
@@ -593,12 +593,13 @@
 {
 	int i, t, u, v;
 
-	gameport->private = port;
 	port->gameport = gameport;
 	init_timer(&port->timer);
 	port->timer.data = (long) port;
 	port->timer.function = analog_timer;
 
+	gameport_set_drvdata(gameport, port);
+
 	if (!gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {
 
 		analog_calibrate_timer(port);
@@ -672,6 +673,7 @@
 	err = analog_init_masks(port);
 	if (err) {
 		gameport_close(gameport);
+		gameport_set_drvdata(gameport, NULL);
 		kfree(port);
 		return err;
 	}
@@ -686,12 +688,13 @@
 static void analog_disconnect(struct gameport *gameport)
 {
 	int i;
-	struct analog_port *port = gameport->private;
+	struct analog_port *port = gameport_get_drvdata(gameport);
 
 	for (i = 0; i < 2; i++)
 		if (port->analog[i].mask)
 			input_unregister_device(&port->analog[i].dev);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n",
 		port->bads, port->reads, port->reads ? (port->bads * 100 / port->reads) : 0,
 		port->gameport->phys);
diff -Nru a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
--- a/drivers/input/joystick/cobra.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/cobra.c	2005-02-11 01:41:08 -05:00
@@ -170,13 +170,13 @@
 	if (!(cobra = kcalloc(1, sizeof(struct cobra), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = cobra;
-
 	cobra->gameport = gameport;
 	init_timer(&cobra->timer);
 	cobra->timer.data = (long) cobra;
 	cobra->timer.function = cobra_timer;
 
+	gameport_set_drvdata(gameport, cobra);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -226,19 +226,21 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(cobra);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(cobra);
 	return err;
 }
 
 static void cobra_disconnect(struct gameport *gameport)
 {
+	struct cobra *cobra = gameport_get_drvdata(gameport);
 	int i;
-	struct cobra *cobra = gameport->private;
 
 	for (i = 0; i < 2; i++)
 		if ((cobra->exists >> i) & 1)
 			input_unregister_device(cobra->dev + i);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(cobra);
 }
 
diff -Nru a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
--- a/drivers/input/joystick/gf2k.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/gf2k.c	2005-02-11 01:41:08 -05:00
@@ -249,13 +249,13 @@
 	if (!(gf2k = kcalloc(1, sizeof(struct gf2k), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = gf2k;
-
 	gf2k->gameport = gameport;
 	init_timer(&gf2k->timer);
 	gf2k->timer.data = (long) gf2k;
 	gf2k->timer.function = gf2k_timer;
 
+	gameport_set_drvdata(gameport, gf2k);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -345,16 +345,18 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(gf2k);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(gf2k);
 	return err;
 }
 
 static void gf2k_disconnect(struct gameport *gameport)
 {
-	struct gf2k *gf2k = gameport->private;
+	struct gf2k *gf2k = gameport_get_drvdata(gameport);
 
 	input_unregister_device(&gf2k->dev);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(gf2k);
 }
 
diff -Nru a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
--- a/drivers/input/joystick/grip.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/grip.c	2005-02-11 01:41:08 -05:00
@@ -310,13 +310,13 @@
 	if (!(grip = kcalloc(1, sizeof(struct grip), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = grip;
-
 	grip->gameport = gameport;
 	init_timer(&grip->timer);
 	grip->timer.data = (long) grip;
 	grip->timer.function = grip_timer;
 
+	gameport_set_drvdata(gameport, grip);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -386,19 +386,21 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(grip);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(grip);
 	return err;
 }
 
 static void grip_disconnect(struct gameport *gameport)
 {
-	struct grip *grip = gameport->private;
+	struct grip *grip = gameport_get_drvdata(gameport);
 	int i;
 
 	for (i = 0; i < 2; i++)
 		if (grip->mode[i])
 			input_unregister_device(grip->dev + i);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(grip);
 }
 
diff -Nru a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
--- a/drivers/input/joystick/grip_mp.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/grip_mp.c	2005-02-11 01:41:08 -05:00
@@ -626,12 +626,13 @@
 	if (!(grip = kcalloc(1, sizeof(struct grip_mp), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = grip;
 	grip->gameport = gameport;
 	init_timer(&grip->timer);
 	grip->timer.data = (long) grip;
 	grip->timer.function = grip_timer;
 
+	gameport_set_drvdata(gameport, grip);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -650,19 +651,21 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(grip);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(grip);
 	return err;
 }
 
 static void grip_disconnect(struct gameport *gameport)
 {
+	struct grip_mp *grip = gameport_get_drvdata(gameport);
 	int i;
-	struct grip_mp *grip = gameport->private;
 
 	for (i = 0; i < 4; i++)
 		if (grip->registered[i])
 			input_unregister_device(grip->dev + i);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(grip);
 }
 
diff -Nru a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
--- a/drivers/input/joystick/guillemot.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/guillemot.c	2005-02-11 01:41:08 -05:00
@@ -193,13 +193,13 @@
 	if (!(guillemot = kcalloc(1, sizeof(struct guillemot), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = guillemot;
-
 	guillemot->gameport = gameport;
 	init_timer(&guillemot->timer);
 	guillemot->timer.data = (long) guillemot;
 	guillemot->timer.function = guillemot_timer;
 
+	gameport_set_drvdata(gameport, guillemot);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -257,13 +257,14 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:  kfree(guillemot);
+fail1:  gameport_set_drvdata(gameport, NULL);
+	kfree(guillemot);
 	return err;
 }
 
 static void guillemot_disconnect(struct gameport *gameport)
 {
-	struct guillemot *guillemot = gameport->private;
+	struct guillemot *guillemot = gameport_get_drvdata(gameport);
 
 	printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys);
 	input_unregister_device(&guillemot->dev);
diff -Nru a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
--- a/drivers/input/joystick/interact.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/interact.c	2005-02-11 01:41:08 -05:00
@@ -223,13 +223,13 @@
 	if (!(interact = kcalloc(1, sizeof(struct interact), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = interact;
-
 	interact->gameport = gameport;
 	init_timer(&interact->timer);
 	interact->timer.data = (long) interact;
 	interact->timer.function = interact_timer;
 
+	gameport_set_drvdata(gameport, interact);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -291,16 +291,18 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:  kfree(interact);
+fail1:  gameport_set_drvdata(gameport, NULL);
+	kfree(interact);
 	return err;
 }
 
 static void interact_disconnect(struct gameport *gameport)
 {
-	struct interact *interact = gameport->private;
+	struct interact *interact = gameport_get_drvdata(gameport);
 
 	input_unregister_device(&interact->dev);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(interact);
 }
 
diff -Nru a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
--- a/drivers/input/joystick/sidewinder.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/sidewinder.c	2005-02-11 01:41:08 -05:00
@@ -605,13 +605,13 @@
 		goto fail1;
 	}
 
-	gameport->private = sw;
-
 	sw->gameport = gameport;
 	init_timer(&sw->timer);
 	sw->timer.data = (long) sw;
 	sw->timer.function = sw_timer;
 
+	gameport_set_drvdata(gameport, sw);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -770,7 +770,8 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(sw);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(sw);
 	kfree(buf);
 	kfree(idbuf);
 	return err;
@@ -778,12 +779,13 @@
 
 static void sw_disconnect(struct gameport *gameport)
 {
+	struct sw *sw = gameport_get_drvdata(gameport);
 	int i;
 
-	struct sw *sw = gameport->private;
 	for (i = 0; i < sw->number; i++)
 		input_unregister_device(sw->dev + i);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(sw);
 }
 
diff -Nru a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
--- a/drivers/input/joystick/tmdc.c	2005-02-11 01:41:08 -05:00
+++ b/drivers/input/joystick/tmdc.c	2005-02-11 01:41:08 -05:00
@@ -270,13 +270,13 @@
 	if (!(tmdc = kcalloc(1, sizeof(struct tmdc), GFP_KERNEL)))
 		return -ENOMEM;
 
-	gameport->private = tmdc;
-
 	tmdc->gameport = gameport;
 	init_timer(&tmdc->timer);
 	tmdc->timer.data = (long) tmdc;
 	tmdc->timer.function = tmdc_timer;
 
+	gameport_set_drvdata(gameport, tmdc);
+
 	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
 	if (err)
 		goto fail1;
@@ -347,19 +347,21 @@
 	return 0;
 
 fail2:	gameport_close(gameport);
-fail1:	kfree(tmdc);
+fail1:	gameport_set_drvdata(gameport, NULL);
+	kfree(tmdc);
 	return err;
 }
 
 static void tmdc_disconnect(struct gameport *gameport)
 {
-	struct tmdc *tmdc = gameport->private;
+	struct tmdc *tmdc = gameport_get_drvdata(gameport);
 	int i;
 
 	for (i = 0; i < 2; i++)
 		if (tmdc->exists & (1 << i))
 			input_unregister_device(tmdc->dev + i);
 	gameport_close(gameport);
+	gameport_set_drvdata(gameport, NULL);
 	kfree(tmdc);
 }
 
diff -Nru a/include/linux/gameport.h b/include/linux/gameport.h
--- a/include/linux/gameport.h	2005-02-11 01:41:08 -05:00
+++ b/include/linux/gameport.h	2005-02-11 01:41:08 -05:00
@@ -15,7 +15,6 @@
 
 struct gameport {
 
-	void *private;		/* Private pointer for joystick drivers */
 	void *port_data;	/* Private pointer for gameport drivers */
 	char name[32];
 	char phys[32];
@@ -89,6 +88,20 @@
 
 void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+
+/*
+ * Use the following fucntions to manipulate gameport's per-port
+ * driver-specific data.
+ */
+static inline void *gameport_get_drvdata(struct gameport *gameport)
+{
+	return dev_get_drvdata(&gameport->dev);
+}
+
+static inline void gameport_set_drvdata(struct gameport *gameport, void *data)
+{
+	dev_set_drvdata(&gameport->dev, data);
+}
 
 /*
  * Use the following fucntions to pin gameport's driver in process context

  reply	other threads:[~2005-02-11  7:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11  6:58 [PATCH 0/10] Convert gameport to driver model/sysfs Dmitry Torokhov
2005-02-11  6:59 ` [PATCH 1/10] Gameport: rename driver to port_data Dmitry Torokhov
2005-02-11  7:00   ` [PATCH 2/10] Gameport: rename gameport_dev to gameport_driver Dmitry Torokhov
2005-02-11  7:00     ` [PATCH 3/10] Gameport: connect() is mandatory Dmitry Torokhov
2005-02-11  7:01       ` [PATCH 4/10] Gameport: prepare to dynamic allocation Dmitry Torokhov
2005-02-11  7:02         ` [PATCH 5/10] Gameport: convert input/gameport " Dmitry Torokhov
2005-02-11  7:02           ` [PATCH 6/10] Gameport: convert sound/oss " Dmitry Torokhov
2005-02-11  7:03             ` [PATCH 7/10] Gameport: convert sound/alsa " Dmitry Torokhov
2005-02-11  7:04               ` [PATCH 8/10] Gameport: add "gameport" sysfs bus, add drivers Dmitry Torokhov
2005-02-11  7:04                 ` [PATCH 9/10] Gameport: complete sysfs integration Dmitry Torokhov
2005-02-11  7:05                   ` Dmitry Torokhov [this message]
2005-02-11  8:11 ` [PATCH 0/10] Convert gameport to driver model/sysfs Vojtech Pavlik

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=200502110205.25146.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.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