Skip to contentSkip to conversation

simple class for adb

PATCH Applied Olaf Hering 6 participants 6 messages May 1, 2004 – May 4, 2004 Linux for power macintosh

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 simple class for adb

This adds /sys/class/adb/, removes unused devfs lines and updates a comment to match reality.

drivers/macintosh/adb.c +13 -6
diff -p -purN linux-2.6.6-rc3/drivers/macintosh/adb.c linux-2.6.6-rc3.adb/drivers/macintosh/adb.c
@@ -10,7 +10,7 @@
  *
  * To do:
  *
- * - /proc/adb to list the devices and infos
+ * - /sys/bus/adb to list the devices and infos
  * - more /dev/adb to allow userland to receive the
  *   flow of auto-polling datas from a given device.
  * - move bus probe to a kernel thread
@@ -23,7 +23,6 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
@@ -36,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
+#include <linux/device.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #ifdef CONFIG_PPC
@@ -75,6 +75,8 @@ static struct adb_driver *adb_driver_lis
 	NULL
 };
 
+static struct class_simple *adb_dev_class;
+
 struct adb_driver *adb_controller;
 struct notifier_block *adb_client_list = NULL;
 static int adb_got_sleep;
@@ -883,6 +889,7 @@ out:
 }
 
 static struct file_operations adb_fops = {
+	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
 	.read		= adb_read,
 	.write		= adb_write,
@@ -893,9 +900,13 @@ static struct file_operations adb_fops =
 static void
 adbdev_init(void)
 {
-	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops))
+	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) {
 		printk(KERN_ERR "adb: unable to get major %d\n", ADB_MAJOR);
-	else
-		devfs_mk_cdev(MKDEV(ADB_MAJOR, 0),
-				S_IFCHR | S_IRUSR | S_IWUSR, "adb");
+		return;
+	}
+	adb_dev_class = class_simple_create(THIS_MODULE, "adb");
+	if (IS_ERR(adb_dev_class)) {
+		return;
+	}
+	class_simple_device_add(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb");
 }

--
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#1 lore raw
Quoted 2 lines · Olaf Hering

This adds /sys/class/adb/, removes unused devfs lines and updates a comment to match reality.

I'm not sure I want to keep /dev/adb forever.... This is at best a workaround so that udev creates it. Ultimately, we want a real adb bus in the device-model and a different mecanism to send special commands to the system controller. I think somebody from the m68k folks is already working on the ADB bus stuff though.

Ben.

Quoted 54 lines

diff -p -purN linux-2.6.6-rc3/drivers/macintosh/adb.c linux-2.6.6-rc3.adb/drivers/macintosh/adb.c

drivers/macintosh/adb.c +6 -4
@@ -10,7 +10,7 @@
  *
  * To do:
  *
- * - /proc/adb to list the devices and infos
+ * - /sys/bus/adb to list the devices and infos
  * - more /dev/adb to allow userland to receive the
  *   flow of auto-polling datas from a given device.
  * - move bus probe to a kernel thread
@@ -23,7 +23,6 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
@@ -36,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
+#include <linux/device.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #ifdef CONFIG_PPC
@@ -75,6 +75,8 @@ static struct adb_driver *adb_driver_lis
 	NULL
 };
 
+static struct class_simple *adb_dev_class;
+
 struct adb_driver *adb_controller;
 struct notifier_block *adb_client_list = NULL;
 static int adb_got_sleep;
@@ -883,6 +889,7 @@ out:
 }
 
 static struct file_operations adb_fops = {
+	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
 	.read		= adb_read,
 	.write		= adb_write,
@@ -893,9 +900,13 @@ static struct file_operations adb_fops =
 static void
 adbdev_init(void)
 {
-	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops))
+	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) {
 		printk(KERN_ERR "adb: unable to get major %d\n", ADB_MAJOR);
-	else

drivers/macintosh/adb.c static struct file_operations adb_fops = · line 912

Quoted 10 lines
drivers/macintosh/adb.c +7 -2
-		devfs_mk_cdev(MKDEV(ADB_MAJOR, 0),
-				S_IFCHR | S_IRUSR | S_IWUSR, "adb");
+		return;
+	}
+	adb_dev_class = class_simple_create(THIS_MODULE, "adb");
+	if (IS_ERR(adb_dev_class)) {
+		return;
+	}
+	class_simple_device_add(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb");
 }

--
Benjamin Herrenschmidt <[email protected]>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 5 lines · Benjamin Herrenschmidt

I'm not sure I want to keep /dev/adb forever.... This is at best a workaround so that udev creates it. Ultimately, we want a real adb bus in the device-model and a different mecanism to send special commands to the system controller. I think somebody from the m68k folks is already working on the ADB bus stuff though.

Slowly but surely, yes. Although perhaps just slowly. I've got part of it written, but I haven't had any time the last month or so due to my real job. I will probably have more time to finish up the new ADB subsystem later this month.

I definitely agree on getting rid of most of the reasons for /dev/adb, but I'm not sure what all people use through it. I know the trackpad tool uses it, but I'm not sure of anything else. Does the sleep stuff use /dev/adb or /dev/pmu?

Brad Boyer
[email protected]

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw
Quoted 13 lines · Brad Boyer gracefully
Quoted 5 lines · Benjamin Herrenschmidt

I'm not sure I want to keep /dev/adb forever.... This is at best a workaround so that udev creates it. Ultimately, we want a real adb bus in the device-model and a different mecanism to send special commands to the system controller. I think somebody from the m68k folks is already working on the ADB bus stuff though.

Slowly but surely, yes. Although perhaps just slowly. I've got part of it written, but I haven't had any time the last month or so due to my real job. I will probably have more time to finish up the new ADB subsystem later this month.

Quoted 11 lines

I definitely agree on getting rid of most of the reasons for /dev/adb, but I'm not sure what all people use through it. I know the trackpad tool uses it, but I'm not sure of anything else. Does the sleep stuff use /dev/adb or /dev/pmu?

Brad Boyer
[email protected]

Hi all,

I'm not sure it is related but I noticed on my ibook 2.2,
kernel <= 2.6.5, that sometimes some keyboards event are missed. With xev, I keep seeing a key pushed (and repeating) whereas I released it. To bring the system back to normal, I have to press and release the repeating key, just to generate a release event, I guess.

Since it seems to be ppc-specific, I suspect adb. Does it make sense ? Is it a known problem ?

--
Cedric

"[Of course] I'm French! Why do think I have this outrageous accent, you silly king-a?!" Monty Python and the Holy Grail

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#4 lore raw
In reply to Olaf Hering
Quoted 2 lines · Olaf Hering

This adds /sys/class/adb/, removes unused devfs lines and updates a comment to match reality.

And it still compiles on m68k.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/