Print this page
LOCAL: disk-lights work 2


 820                         topo_hdl_free(thp, wp, sizeof (topo_walk_t));
 821                         return (NULL);
 822                 }
 823                 topo_node_unlock(node);
 824                 topo_node_hold(child);
 825                 wp->tw_node = child;
 826         } else {
 827                 topo_node_unlock(node);
 828                 topo_node_hold(node); /* rele at walk end */
 829                 wp->tw_node = node;
 830         }
 831 
 832         wp->tw_root = node;
 833         wp->tw_cb = cb_f;
 834         wp->tw_pdata = pdata;
 835         wp->tw_thp = thp;
 836         wp->tw_mod = mod;
 837 
 838         return (wp);
 839 }






















































 820                         topo_hdl_free(thp, wp, sizeof (topo_walk_t));
 821                         return (NULL);
 822                 }
 823                 topo_node_unlock(node);
 824                 topo_node_hold(child);
 825                 wp->tw_node = child;
 826         } else {
 827                 topo_node_unlock(node);
 828                 topo_node_hold(node); /* rele at walk end */
 829                 wp->tw_node = node;
 830         }
 831 
 832         wp->tw_root = node;
 833         wp->tw_cb = cb_f;
 834         wp->tw_pdata = pdata;
 835         wp->tw_thp = thp;
 836         wp->tw_mod = mod;
 837 
 838         return (wp);
 839 }
 840 
 841 /*
 842  * Walk the direct children of the given node.
 843  */
 844 int
 845 topo_node_child_walk(topo_hdl_t *thp, tnode_t *pnode, topo_walk_cb_t cb_f,
 846     void *arg, int *errp)
 847 {
 848         int ret = TOPO_WALK_TERMINATE;
 849         tnode_t *cnode;
 850 
 851         topo_node_hold(pnode);
 852 
 853         /*
 854          * First Child:
 855          */
 856         topo_node_lock(pnode);
 857         cnode = topo_child_first(pnode);
 858         topo_node_unlock(pnode);
 859 
 860         if (cnode == NULL) {
 861                 *errp = ETOPO_WALK_EMPTY;
 862                 ret = TOPO_WALK_ERR;
 863                 goto out;
 864         }
 865 
 866         while (cnode != NULL) {
 867                 int iret;
 868 
 869                 /*
 870                  * Call the walker callback:
 871                  */
 872                 topo_node_hold(cnode);
 873                 iret = cb_f(thp, cnode, arg);
 874                 topo_node_rele(cnode);
 875                 if (iret != TOPO_WALK_NEXT) {
 876                         ret = iret;
 877                         break;
 878                 }
 879 
 880                 /*
 881                  * Next child:
 882                  */
 883                 topo_node_lock(pnode);
 884                 cnode = topo_child_next(pnode, cnode);
 885                 topo_node_unlock(pnode);
 886         }
 887 
 888 out:
 889         topo_node_rele(pnode);
 890         return (ret);
 891 }