From: Nathan F. <nf...@au...> - 2009-08-25 16:56:10
|
Applied. -Nathan Robert Jennings wrote: > Add HEA ports as a new connector type to lsslot. Ports will be sorted on > location code, not name, so the output might look as follows (debug output > included). > > # ./lsslot -d 4 -c port > Getting node types 0x00000004 > > DR nodes list > ============== > /proc/device-tree/lhea@23c00400: > drc index: 0x23c00400 description: HEA I/O Slot > drc name: HEA 1 > loc code: U789D.001.DQDYGLC-P1 > /proc/device-tree/lhea@23c00400/ethernet@23e00300: > drc index: 0x23e00300 description: HEA Port I/O Slot > drc name: Port 4 > loc code: U789D.001.DQDYGLC-P1-C10-T1 > /proc/device-tree/lhea@23c00400/ethernet@23e00000: > drc index: 0x23e00000 description: HEA Port I/O Slot > drc name: Port 1 > loc code: U789D.001.DQDYGLC-P1-C10-T2 > > LHEA port name Description > Port 4 HEA Port I/O Slot > Port 1 HEA Port I/O Slot > > Signed-off-by: Robert Jennings <rc...@li...> > > --- > I am correcting an error in the format for printing with delimiters. > > --- > src/drmgr/lsslot.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > src/drmgr/lsslot.h | 1 + > 2 files changed, 97 insertions(+) > > Index: b/src/drmgr/lsslot.c > =================================================================== > --- a/src/drmgr/lsslot.c > +++ b/src/drmgr/lsslot.c > @@ -410,6 +410,8 @@ parse_options(int argc, char *argv[], st > opts->slot_type = CPU; > else if (! strcmp(optarg, "mem")) > opts->slot_type = MEM; > + else if (! strcmp(optarg, "port")) > + opts->slot_type = PORT; > else { > printf("\nThe specified connector type " > "is invalid.\n\n"); > @@ -463,6 +465,7 @@ parse_options(int argc, char *argv[], st > /* Validate the options */ > switch (opts->slot_type) { > case SLOT: > + case PORT: > /* The a,b,o,p flags are not valid for slot */ > if (opts->a_flag || opts->b_flag || opts->o_flag || > opts->p_flag) > @@ -748,6 +751,95 @@ lsslot_chrp_mem(void) > return 0; > } > > +/** > + * lsslot_chrp_port > + * @brief Print LHEA ports based on command line options > + * > + * @param opts > + * @returns 0 on success, !0 otherwise > + */ > +int > +lsslot_chrp_port(struct cmd_opts *opts) > +{ > + struct dr_node *all_nodes; /* Pointer to list of all node info */ > + struct dr_node *node; /* Used to traverse list of node info */ > + struct dr_node *child; /* Used to traverse list of children */ > + char fmt[128]; > + struct print_node *p; > + char *sheading = "LHEA port name"; /* Used in printing headers */ > + char *dheading = "Description"; /* Used in printing headers */ > + int rc = 0; > + > + /* Set initial column sizes */ > + max_sname = MAX(max_sname, strlen(sheading)); > + max_desc = MAX(max_desc, strlen(dheading)); > + > + all_nodes = get_dlpar_nodes(HEA_NODES); > + > + /* If nothing returned, then no hot plug node */ > + if (all_nodes == NULL) { > + err_msg("There are no LHEA ports on this system.\n"); > + return 1; > + } > + > + print_node_list(all_nodes); > + > + /* Otherwise, run through the node list looking for the nodes > + * we want to print > + */ > + for (node = all_nodes; node; node = node->next) { > + if (node->skip) > + continue; > + > + for (child = node->children; child; child = child->next) { > + if (child->skip) > + continue; > + /* If there is a search parameter, add matching ports. > + * If there is no search, add all the ports. > + */ > + if (opts->s_name != NULL) { > + if (cmp_drcname(child->drc_name, opts->s_name)) > + insert_print_node(child); > + } else > + insert_print_node(child); > + } > + } > + > + if (print_list == NULL) { > + /* If nothing to print, display message based on if > + * user specified a slot or a device name. > + */ > + if (opts->s_name != NULL) { > + err_msg("The specified port was not found.\n"); > + rc = 1; > + } > + goto lsslot_port_exit; > + } > + > + /* This creates a format string so that port name and description > + * prints out in the required field width. When the -F flag is > + * specified, the format string contains the delimiting character > + * which the user specified at the command line. > + */ > + if (opts->delim != NULL) > + sprintf(fmt, "%s%s%s\n", "%s", opts->delim, "%s"); > + else { > + sprintf(fmt, "%%-%ds%%-%ds\n", max_sname + 2, max_desc + 2); > + /* Print out the header. */ > + printf(fmt, sheading, dheading); > + } > + > + /* Now run through the list of ports we actually want to print */ > + for (p = print_list; p != NULL; p = p->next) { > + printf(fmt, p->node->drc_name, p->desc); > + } > + > +lsslot_port_exit: > + free_print_list(); > + free_node(all_nodes); > + return rc; > +} > + > int > main(int argc, char *argv[]) > { > @@ -788,6 +880,10 @@ main(int argc, char *argv[]) > case MEM: > rc = lsslot_chrp_mem(); > break; > + > + case PORT: > + rc = lsslot_chrp_port(&opts); > + break; > } > > dr_unlock(); > Index: b/src/drmgr/lsslot.h > =================================================================== > --- a/src/drmgr/lsslot.h > +++ b/src/drmgr/lsslot.h > @@ -18,6 +18,7 @@ struct cmd_opts { > #define PHB 2 > #define CPU 3 > #define MEM 4 > +#define PORT 5 > > int a_flag; > int o_flag; > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Powerpc-utils-devel mailing list > Pow...@li... > https://lists.sourceforge.net/lists/listinfo/powerpc-utils-devel |