Thread: [Linux1394-cvslog] rev 822 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2003-03-07 18:25:51
|
Author: bencollins Date: 2003-03-07 13:25:09 -0500 (Fri, 07 Mar 2003) New Revision: 822 Modified: trunk/hosts.h trunk/ieee1394_core.h trunk/nodemgr.c trunk/nodemgr.h Log: First crack at sysfs support. This makes the hosts register as fw-hostX where X is an ID. This ID is used for knodemgrd/X, /sys/bus/ieee1394/fw-hostX, and a few other places to keep things inline. Each node also creates a device. I will add device creation on a per unit-directory aswell. Then I'll make nodemgr start using driver core callbacks for probe/matching. Modified: trunk/ieee1394_core.h ============================================================================== --- trunk/ieee1394_core.h (original) +++ trunk/ieee1394_core.h 2003-03-07 13:25:10.000000000 -0500 @@ -231,4 +231,7 @@ /* the proc_fs entry for /proc/ieee1394 */ extern struct proc_dir_entry *ieee1394_procfs_entry; +/* Our sysfs bus entry */ +extern struct bus_type ieee1394_bus_type; + #endif /* _IEEE1394_CORE_H */ Modified: trunk/nodemgr.c ============================================================================== --- trunk/nodemgr.c (original) +++ trunk/nodemgr.c 2003-03-07 13:25:10.000000000 -0500 @@ -17,9 +17,8 @@ #include <linux/kmod.h> #include <linux/completion.h> #include <linux/delay.h> -#ifdef CONFIG_PROC_FS #include <linux/proc_fs.h> -#endif +#include <linux/pci.h> #include <asm/atomic.h> #include <asm/byteorder.h> @@ -60,20 +59,21 @@ * complete directory entry (be it a leaf or a directory). We then process * it and add the info to our structure for that particular node. * - * We verify CRC's along the way for each directory/block/leaf. The - * entire node structure is generic, and simply stores the information in - * a way that's easy to parse by the protocol interface. + * We verify CRC's along the way for each directory/block/leaf. The entire + * node structure is generic, and simply stores the information in a way + * that's easy to parse by the protocol interface. */ -/* The nodemgr maintains a number of data structures: the node list, - * the driver list, unit directory list and the host info list. The - * first three lists are accessed from process context only: /proc - * readers, insmod and rmmod, and the nodemgr thread. Access to these - * lists are serialized by means of the nodemgr_serialize mutex, which - * must be taken before accessing the structures and released - * afterwards. The host info list is only accessed during insmod, - * rmmod and from interrupt and allways only for a short period of - * time, so a spinlock is used to protect this list. +/* + * The nodemgr maintains a number of data structures: the node list, the + * driver list, unit directory list and the host info list. The first + * three lists are accessed from process context only: /proc readers, + * insmod and rmmod, and the nodemgr thread. Access to these lists are + * serialized by means of the nodemgr_serialize mutex, which must be taken + * before accessing the structures and released afterwards. The host info + * list is only accessed during insmod, rmmod and from interrupt and + * allways only for a short period of time, so a spinlock is used to + * protect this list. */ static DECLARE_MUTEX(nodemgr_serialize); @@ -93,6 +93,14 @@ struct completion exited; struct semaphore reset_sem; int pid; + unsigned int id; + char daemon_name[15]; +}; + +struct bus_type ieee1394_bus_type = { + .name = "ieee1394", + .hotplug = NULL, + .add = NULL, }; #ifdef CONFIG_PROC_FS @@ -352,6 +360,8 @@ if (!ne) return NULL; + memset(ne, 0, total_size); + if (size != 0) { ne->vendor_name = (const char *) &(ne->quadlets[2]); @@ -364,9 +374,10 @@ } static struct node_entry *nodemgr_create_node(octlet_t guid, quadlet_t busoptions, - struct hpsb_host *host, + struct host_info *hi, nodeid_t nodeid, unsigned int generation) { + struct hpsb_host *host = hi->host; struct node_entry *ne; ne = nodemgr_scan_root_directory (host, nodeid, generation); @@ -386,11 +397,17 @@ nodemgr_process_config_rom (ne, busoptions); - HPSB_DEBUG("%s added: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx] [%s] (%s)", + ne->device.parent = &host->device; + sprintf(ne->device.bus_id, "%u-" NODE_BUS_FMT, hi->id, NODE_BUS_ARGS(nodeid)); + sprintf(ne->device.name, "IEEE-1394 device %s", ne->device.bus_id); + ne->device.bus = &ieee1394_bus_type; + + device_register(&ne->device); + + HPSB_DEBUG("%s added: ID:BUS[%s] GUID[%016Lx] [%s] (%s)", (host->node_id == nodeid) ? "Host" : "Node", - NODE_BUS_ARGS(nodeid), (unsigned long long)guid, - ne->oui_name, - ne->vendor_name ?: "Unknown"); + ne->device.bus_id, (unsigned long long)guid, + ne->oui_name, ne->vendor_name ?: "Unknown"); return ne; } @@ -1098,6 +1115,7 @@ nodemgr_free_unit_directories(ne); list_del(&ne->list); + device_unregister(&ne->device); kfree(ne); return; @@ -1105,9 +1123,10 @@ /* This is where we probe the nodes for their information and provided * features. */ -static void nodemgr_node_probe_one(struct hpsb_host *host, +static void nodemgr_node_probe_one(struct host_info *hi, nodeid_t nodeid, int generation) { + struct hpsb_host *host = hi->host; struct node_entry *ne; quadlet_t buffer[5]; octlet_t guid; @@ -1135,7 +1154,7 @@ ne = find_entry_by_guid(guid); if (!ne) - nodemgr_create_node(guid, buffer[2], host, nodeid, generation); + nodemgr_create_node(guid, buffer[2], hi, nodeid, generation); else nodemgr_update_node(ne, buffer[2], host, nodeid, generation); @@ -1167,9 +1186,10 @@ return; } -static void nodemgr_node_probe(struct hpsb_host *host) +static void nodemgr_node_probe(struct host_info *hi) { int count; + struct hpsb_host *host = hi->host; struct selfid *sid = (struct selfid *)host->topology_map; nodeid_t nodeid = LOCAL_BUS; unsigned int generation; @@ -1198,7 +1218,7 @@ continue; } - nodemgr_node_probe_one(host, nodeid++, generation); + nodemgr_node_probe_one(hi, nodeid++, generation); } /* If we had a bus reset while we were scanning the bus, it is @@ -1264,9 +1284,9 @@ struct host_info *hi = (struct host_info *)__hi; /* No userlevel access needed */ - daemonize("knodemgrd"); + daemonize(hi->daemon_name); allow_signal(SIGTERM); - + /* Sit and wait for a signal to probe the nodes on the bus. This * happens when we get a bus reset. */ while (!down_interruptible(&hi->reset_sem) && @@ -1278,7 +1298,7 @@ continue; } - nodemgr_node_probe(hi->host); + nodemgr_node_probe(hi); nodemgr_do_irm_duties(hi->host); up(&nodemgr_serialize); @@ -1381,6 +1401,7 @@ { struct host_info *hi; unsigned long flags; + static unsigned int host_id = 0; hi = kmalloc(sizeof (struct host_info), in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL); @@ -1397,12 +1418,24 @@ init_completion(&hi->exited); sema_init(&hi->reset_sem, 0); + hi->id = host_id++; + + host->device.parent = &host->pdev->dev; + sprintf(host->device.bus_id, "fw-host%u", hi->id); + sprintf(host->device.name, "IEEE-1394 Host %s-%u", host->driver->name, hi->id); + host->device.bus = &ieee1394_bus_type; + + sprintf(hi->daemon_name, "knodemgrd/%u", hi->id); + + device_register(&host->device); + hi->pid = kernel_thread(nodemgr_host_thread, hi, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); if (hi->pid < 0) { - HPSB_ERR ("NodeMgr: failed to start NodeMgr thread for %s", - host->driver->name); + HPSB_ERR ("NodeMgr: failed to start %s thread for %s", + hi->daemon_name, host->driver->name); + device_unregister(&host->device); kfree(hi); return; } @@ -1482,6 +1515,8 @@ nodemgr_remove_node(ne); } + device_unregister(&host->device); + up(&nodemgr_serialize); return; @@ -1500,10 +1535,15 @@ void init_ieee1394_nodemgr(int disable_hotplug) { nodemgr_disable_hotplug = disable_hotplug; + + bus_register(&ieee1394_bus_type); + #ifdef CONFIG_PROC_FS - if (!create_proc_read_entry(PROC_ENTRY, 0444, ieee1394_procfs_entry, raw1394_read_proc, NULL)) + if (!create_proc_read_entry(PROC_ENTRY, 0444, ieee1394_procfs_entry, + raw1394_read_proc, NULL)) HPSB_ERR("Can't create devices procfs entry"); #endif + hl = hpsb_register_highlevel("Node manager", &nodemgr_ops); if (!hl) { HPSB_ERR("NodeMgr: out of memory during ieee1394 initialization"); @@ -1516,4 +1556,6 @@ #ifdef CONFIG_PROC_FS remove_proc_entry(PROC_ENTRY, ieee1394_procfs_entry); #endif + + bus_unregister(&ieee1394_bus_type); } Modified: trunk/nodemgr.h ============================================================================== --- trunk/nodemgr.h (original) +++ trunk/nodemgr.h 2003-03-07 13:25:10.000000000 -0500 @@ -20,6 +20,8 @@ #ifndef _IEEE1394_NODEMGR_H #define _IEEE1394_NODEMGR_H +#include <linux/device.h> + #define CONFIG_ROM_BUS_INFO_LENGTH(q) ((q) >> 24) #define CONFIG_ROM_BUS_CRC_LENGTH(q) (((q) >> 16) & 0xff) #define CONFIG_ROM_BUS_CRC(q) ((q) & 0xffff) @@ -116,6 +118,10 @@ struct list_head node_list; int count; /* Number of quadlets */ + + struct device device; + + /* XXX Must be last in the struct! */ quadlet_t quadlets[0]; }; @@ -137,6 +143,9 @@ const char *vendor_name; char *oui_name; + struct device device; + + /* XXX Must be last in the struct! */ quadlet_t quadlets[0]; }; Modified: trunk/hosts.h ============================================================================== --- trunk/hosts.h (original) +++ trunk/hosts.h 2003-03-07 13:25:10.000000000 -0500 @@ -1,6 +1,7 @@ #ifndef _IEEE1394_HOSTS_H #define _IEEE1394_HOSTS_H +#include <linux/device.h> #include <linux/wait.h> #include <linux/list.h> #include <asm/semaphore.h> @@ -64,6 +65,8 @@ struct hpsb_host_driver *driver; struct pci_dev *pdev; + + struct device device; }; |