Re: [PATCH] gpiolib: Allow user-selection

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Brownell
Date: Thursday, July 3, 2008 - 1:25 am

On Wednesday 02 July 2008, Andrew Morton wrote:

Should be addressed by the following, at least in
terms of build problems aginst linux-next.

The resulting kernel doesn't seem bootable on any
board I currently have set up for testing gpio calls.
The build dies in the TTY stack.

- Dave


=============	CUT HERE
Cope with some backwards-incompatible driver model API changes
now in the linux-next tree:

 - device_create() is going away, even for drivers using it safely,
   in favor of device_create_drvdata().
 - class->devices is gone, but testing class->p serves the same
   purpose (non-null when class is usable with driver model calls).
 - class_find_device() needs a new argument #2 (NULL)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/gpio/gpiolib.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

--- a/drivers/gpio/gpiolib.c	2008-07-02 23:29:58.000000000 -0700
+++ b/drivers/gpio/gpiolib.c	2008-07-03 00:04:57.000000000 -0700
@@ -429,7 +429,7 @@ int gpio_export(unsigned gpio, bool dire
 	int			status = -EINVAL;
 
 	/* can't export until sysfs is available ... */
-	if (!gpio_class.devices.next) {
+	if (!gpio_class.p) {
 		pr_debug("%s: called too early!\n", __func__);
 		return -ENOENT;
 	}
@@ -453,10 +453,9 @@ int gpio_export(unsigned gpio, bool dire
 	if (status == 0) {
 		struct device	*dev;
 
-		dev = device_create(&gpio_class, desc->chip->dev, 0,
-				"gpio%d", gpio);
+		dev = device_create_drvdata(&gpio_class, desc->chip->dev, 0,
+				desc, "gpio%d", gpio);
 		if (dev) {
-			dev_set_drvdata(dev, desc);
 			if (direction_may_change)
 				status = sysfs_create_group(&dev->kobj,
 						&gpio_attr_group);
@@ -506,7 +505,7 @@ void gpio_unexport(unsigned gpio)
 	if (test_bit(FLAG_EXPORT, &desc->flags)) {
 		struct device	*dev = NULL;
 
-		dev = class_find_device(&gpio_class, desc, match_export);
+		dev = class_find_device(&gpio_class, NULL, desc, match_export);
 		if (dev) {
 			clear_bit(FLAG_EXPORT, &desc->flags);
 			put_device(dev);
@@ -533,15 +532,14 @@ static int gpiochip_export(struct gpio_c
 	 * export this later, in gpiolib_sysfs_init() ... here we just
 	 * verify that _some_ field of gpio_class got initialized.
 	 */
-	if (!gpio_class.devices.next)
+	if (!gpio_class.p)
 		return 0;
 
 	/* use chip->base for the ID; it's already known to be unique */
 	mutex_lock(&sysfs_lock);
-	dev = device_create(&gpio_class, chip->dev, 0,
+	dev = device_create_drvdata(&gpio_class, chip->dev, 0, chip,
 			"gpiochip%d", chip->base);
 	if (dev) {
-		dev_set_drvdata(dev, chip);
 		status = sysfs_create_group(&dev->kobj,
 				&gpiochip_attr_group);
 	} else
@@ -572,7 +570,7 @@ static void gpiochip_unexport(struct gpi
 	struct device		*dev;
 
 	mutex_lock(&sysfs_lock);
-	dev = class_find_device(&gpio_class, chip, match_export);
+	dev = class_find_device(&gpio_class, NULL, chip, match_export);
 	if (dev) {
 		put_device(dev);
 		device_unregister(dev);

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] gpiolib: Allow user-selection, Michael Buesch, (Wed Jul 2, 2:46 pm)
Re: [PATCH] gpiolib: Allow user-selection, Andrew Morton, (Wed Jul 2, 5:04 pm)
Re: [PATCH] gpiolib: Allow user-selection, Michael Buesch, (Wed Jul 2, 5:26 pm)
Re: [PATCH] gpiolib: Allow user-selection, David Brownell, (Wed Jul 2, 10:00 pm)
Re: [PATCH] gpiolib: Allow user-selection, Andrew Morton, (Wed Jul 2, 10:08 pm)
Re: [PATCH] gpiolib: Allow user-selection, David Brownell, (Wed Jul 2, 10:41 pm)
Re: [PATCH] gpiolib: Allow user-selection, David Brownell, (Thu Jul 3, 1:25 am)
Re: [PATCH] gpiolib: Allow user-selection, Rene Herman, (Thu Jul 3, 1:36 am)
Re: [PATCH] gpiolib: Allow user-selection, Michael Buesch, (Thu Jul 3, 1:42 am)
Re: [PATCH] gpiolib: Allow user-selection, Andrew Morton, (Thu Jul 3, 2:01 am)
Re: [PATCH] gpiolib: Allow user-selection, Rene Herman, (Thu Jul 3, 3:19 am)
Re: [PATCH] gpiolib: Allow user-selection, Greg KH, (Thu Jul 3, 12:37 pm)
Re: [PATCH] gpiolib: Allow user-selection, David Brownell, (Thu Jul 3, 2:28 pm)
Re: [PATCH] gpiolib: Allow user-selection, Greg KH, (Thu Jul 3, 4:08 pm)
Re: [PATCH] gpiolib: Allow user-selection, David Brownell, (Fri Jul 11, 10:32 pm)