Re: [RFC 2/4] firewire: dynamic cdev allocation below firewire major

From: Stefan Richter
Date: Sun Feb 05 2006 - 08:26:12 EST


Johannes Berg wrote:
This patch implements dynamic minor number allocation below the 171
major allocated for ieee1394. Since on today's systems one doesn't need
to have fixed device numbers any more we could just use any, but it's
probably still useful to use the ieee1394 major number for any firewire
related devices (like mem1394).
[...]
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -186,19 +186,38 @@ void hpsb_packet_received(struct hpsb_ho
* 171:0-255, the various drivers must then cdev_add() their cdev
* objects to handle their respective sub-regions.
*
+ * Alternatively, drivers may use a dynamic minor number character
+ * device by using the functions hpsb_cdev_add and hpsb_cdev_del.
+ * hpsb_cdev_add requires an initialised struct cdev and will add
+ * it with cdev_add() automatically, reserving a new minor number
+ * for the new device (unless cdev_add() fails). It returns the
+ * status of cdev_add(), or -ENODEV if no minor could be allocated.

This comment should be moved to the implementations of respective functions and be formatted as described by Documentation/kernel-doc-nano-HOWTO.txt. (We should eventually check all exported ieee1394 symbols if they are documented that way.)

+ * Currently 64 minor numbers are reserved for that, if necessary
+ * this number can be increased by simply adjusting the constant
+ * IEEE1394_MINOR_DYNAMIC_FIRST.
+ *
* Minor device number block allocations:
*
* Block 0 ( 0- 15) raw1394
* Block 1 ( 16- 31) video1394
* Block 2 ( 32- 47) dv1394
*
- * Blocks 3-14 free for future allocation
+ * Blocks 3-10 free for future allocation
*
+ * Block 11 (176-191) dynamic allocation region
+ * Block 12 (192-207) dynamic allocation region
+ * Block 13 (208-223) dynamic allocation region
+ * Block 14 (224-239) dynamic allocation region
* Block 15 (240-255) reserved for drivers under development, etc.
*/
#define IEEE1394_MAJOR 171
+#define IEEE1394_MINOR_DYNAMIC_FIRST 176
+#define IEEE1394_MINOR_DYNAMIC_LAST 239
+#define IEEE1394_MINOR_DYNAMIC_COUNT (IEEE1394_MINOR_DYNAMIC_LAST-IEEE1394_MINOR_DYNAMIC_FIRST+1)
+
#define IEEE1394_MINOR_BLOCK_RAW1394 0
#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
#define IEEE1394_MINOR_BLOCK_DV1394 2
@@ -218,6 +237,11 @@ static inline unsigned char ieee1394_fil
return file->f_dentry->d_inode->i_cindex;
}
+/* add a dynamic ieee1394 device */
+int hpsb_cdev_add(struct cdev *chardev);
+/* remove a dynamic ieee1394 device */
+void hpsb_cdev_del(struct cdev *chardev);
[...]

Again, better no comment here than these two which are not very enlightening.
--
Stefan Richter
-=====-=-==- --=- --=-=
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/