]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - drivers/ieee1394/nodemgr.c
Merge with http://kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[linux-3.10.git] / drivers / ieee1394 / nodemgr.c
index f2453668acf56ee9ca5604aadcad9a729df2ee5f..082c7fd239f584a14f64604bb65fe770697eda02 100644 (file)
@@ -743,21 +743,20 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
                                              unsigned int generation)
 {
        struct hpsb_host *host = hi->host;
-        struct node_entry *ne;
-
-       ne = kmalloc(sizeof(struct node_entry), GFP_KERNEL);
-        if (!ne) return NULL;
+       struct node_entry *ne;
 
-       memset(ne, 0, sizeof(struct node_entry));
+       ne = kzalloc(sizeof(*ne), GFP_KERNEL);
+       if (!ne)
+               return NULL;
 
        ne->tpool = &host->tpool[nodeid & NODE_MASK];
 
-        ne->host = host;
-        ne->nodeid = nodeid;
+       ne->host = host;
+       ne->nodeid = nodeid;
        ne->generation = generation;
        ne->needs_probe = 1;
 
-        ne->guid = guid;
+       ne->guid = guid;
        ne->guid_vendor_id = (guid >> 40) & 0xffffff;
        ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id);
        ne->csr = csr;
@@ -787,7 +786,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
                   (host->node_id == nodeid) ? "Host" : "Node",
                   NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
 
-        return ne;
+       return ne;
 }
 
 
@@ -872,12 +871,10 @@ static struct unit_directory *nodemgr_process_unit_directory
        struct csr1212_keyval *kv;
        u8 last_key_id = 0;
 
-       ud = kmalloc(sizeof(struct unit_directory), GFP_KERNEL);
+       ud = kzalloc(sizeof(*ud), GFP_KERNEL);
        if (!ud)
                goto unit_directory_error;
 
-       memset (ud, 0, sizeof(struct unit_directory));
-
        ud->ne = ne;
        ud->ignore_driver = ignore_drivers;
        ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE;
@@ -937,10 +934,10 @@ static struct unit_directory *nodemgr_process_unit_directory
                        /* Logical Unit Number */
                        if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
                                if (ud->flags & UNIT_DIRECTORY_HAS_LUN) {
-                                       ud_child = kmalloc(sizeof(struct unit_directory), GFP_KERNEL);
+                                       ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL);
                                        if (!ud_child)
                                                goto unit_directory_error;
-                                       memcpy(ud_child, ud, sizeof(struct unit_directory));
+                                       memcpy(ud_child, ud, sizeof(*ud_child));
                                        nodemgr_register_device(ne, ud_child, &ne->device);
                                        ud_child = NULL;
                                        
@@ -1200,7 +1197,7 @@ static void nodemgr_node_scan_one(struct host_info *hi,
        struct csr1212_csr *csr;
        struct nodemgr_csr_info *ci;
 
-       ci = kmalloc(sizeof(struct nodemgr_csr_info), GFP_KERNEL);
+       ci = kmalloc(sizeof(*ci), GFP_KERNEL);
        if (!ci)
                return;
 
@@ -1410,14 +1407,28 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
        struct hpsb_host *host = hi->host;
        struct class *class = &nodemgr_ne_class;
        struct class_device *cdev;
+       struct node_entry *ne;
 
        /* Do some processing of the nodes we've probed. This pulls them
         * into the sysfs layer if needed, and can result in processing of
         * unit-directories, or just updating the node and it's
-        * unit-directories. */
+        * unit-directories.
+        *
+        * Run updates before probes. Usually, updates are time-critical
+        * while probes are time-consuming. (Well, those probes need some
+        * improvement...) */
+
        down_read(&class->subsys.rwsem);
-       list_for_each_entry(cdev, &class->children, node)
-               nodemgr_probe_ne(hi, container_of(cdev, struct node_entry, class_dev), generation);
+       list_for_each_entry(cdev, &class->children, node) {
+               ne = container_of(cdev, struct node_entry, class_dev);
+               if (!ne->needs_probe)
+                       nodemgr_probe_ne(hi, ne, generation);
+       }
+       list_for_each_entry(cdev, &class->children, node) {
+               ne = container_of(cdev, struct node_entry, class_dev);
+               if (ne->needs_probe)
+                       nodemgr_probe_ne(hi, ne, generation);
+       }
         up_read(&class->subsys.rwsem);
 
 
@@ -1448,7 +1459,8 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host)
        int ret = 1;
 
        packet = hpsb_make_phypacket(host,
-                       0x003c0000 | NODEID_TO_NODE(host->node_id) << 24);
+                       EXTPHYPACKET_TYPE_RESUME |
+                       NODEID_TO_NODE(host->node_id) << PHYPACKET_PORT_SHIFT);
        if (packet) {
                packet->no_waiter = 1;
                packet->generation = get_hpsb_generation(host);