Print this page
7215 usba logging through cmn_err (via usba_bus_ctl) output erroneously includes tab
7216 usba logging through cmn_err (via usba_bus_ctl) output truncates (leading) some device names

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/usb/usba/usba.c
          +++ new/usr/src/uts/common/io/usb/usba/usba.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   *
  25   25   * Copyright 2014 Garrett D'Amore <garrett@damore.org>
       26 + * Copyright 2016 James S. Blachly, MD <james.blachly@gmail.com>
  26   27   */
  27   28  
  28   29  
  29   30  /*
  30   31   * USBA: Solaris USB Architecture support
  31   32   */
  32   33  #define USBA_FRAMEWORK
  33   34  #include <sys/usb/usba/usba_impl.h>
  34   35  #include <sys/usb/usba/hcdi_impl.h>
  35   36  #include <sys/usb/hubd/hub.h>
  36   37  #include <sys/fs/dv_node.h>
  37   38  
  38      -static int usba_str_startcmp(char *, char *);
  39      -
  40   39  /*
  41   40   * USBA private variables and tunables
  42   41   */
  43   42  static kmutex_t usba_mutex;
  44   43  
  45   44  /* mutex to protect usba_root_hubs */
  46   45  static kmutex_t usba_hub_mutex;
  47   46  
  48   47  typedef struct usba_root_hub_ent {
  49   48          dev_info_t *dip;
↓ open down ↓ 210 lines elided ↑ open up ↑
 260  259                              0xff00) >> 8,
 261  260                              hub_usba_device->usb_dev_descr->bcdUSB & 0xff,
 262  261                              usba_is_root_hub(hubdip) ? "root" : "external",
 263  262                              ddi_node_name(rdip), ddi_get_name_addr(rdip),
 264  263                              ddi_driver_name(rdip),
 265  264                              ddi_get_instance(rdip), usba_device->usb_addr);
 266  265  
 267  266                          name = kmem_alloc(MAXNAMELEN, KM_SLEEP);
 268  267                          (void) usba_get_mfg_prod_sn_str(rdip, name, MAXNAMELEN);
 269  268                          if (name[0] != '\0') {
 270      -                                cmn_err(CE_CONT, "?\t%s\n", name);
      269 +                                cmn_err(CE_CONT, "?%s\n", name);
 271  270                          }
 272  271                          kmem_free(name, MAXNAMELEN);
 273  272  
 274  273                  } else { /* harden USBA against this case; if it happens */
 275  274  
 276  275                          cmn_err(CE_CONT,
 277  276                              "?USB-device: %s@%s, %s%d\n",
 278  277                              ddi_node_name(rdip), ddi_get_name_addr(rdip),
 279  278                              ddi_driver_name(rdip), ddi_get_instance(rdip));
 280  279                  }
↓ open down ↓ 2542 lines elided ↑ open up ↑
2823 2822                          (void) strcpy(ud->usb_serialno_str, tmpbuf);
2824 2823                          mutex_exit(&ud->usb_mutex);
2825 2824                  }
2826 2825          }
2827 2826  
2828 2827          kmem_free(tmpbuf, USB_MAXSTRINGLEN);
2829 2828  }
2830 2829  
2831 2830  
2832 2831  /*
2833      - * usba_str_startcmp:
2834      - *      Return the number of characters duplicated from the beginning of the
2835      - *      string.  Return -1 if a complete duplicate.
2836      - *
2837      - * Arguments:
2838      - *      Two strings to compare.
2839      - */
2840      -static int usba_str_startcmp(char *first, char *second)
2841      -{
2842      -        int num_same_chars = 0;
2843      -        while (*first == *second++) {
2844      -                if (*first++ == '\0') {
2845      -                        return (-1);
2846      -                }
2847      -                num_same_chars++;
2848      -        }
2849      -
2850      -        return (num_same_chars);
2851      -}
2852      -
2853      -
2854      -/*
2855 2832   * usba_get_mfg_prod_sn_str:
2856 2833   *      Return a string containing mfg, product, serial number strings.
2857 2834   *      Remove duplicates if some strings are the same.
2858 2835   *
2859 2836   * Arguments:
2860 2837   *      dip     - pointer to dev info
2861 2838   *      buffer  - Where string is returned
2862 2839   *      buflen  - Length of buffer
2863 2840   *
2864 2841   * Returns:
↓ open down ↓ 1 lines elided ↑ open up ↑
2866 2843   */
2867 2844  char *
2868 2845  usba_get_mfg_prod_sn_str(
2869 2846      dev_info_t  *dip,
2870 2847      char        *buffer,
2871 2848      int         buflen)
2872 2849  {
2873 2850          usba_device_t *usba_device = usba_get_usba_device(dip);
2874 2851          int return_len = 0;
2875 2852          int len = 0;
2876      -        int duplen;
2877 2853  
2878 2854          buffer[0] = '\0';
2879 2855          buffer[buflen-1] = '\0';
2880 2856  
     2857 +        /* Manufacturer string exists. */
2881 2858          if ((usba_device->usb_mfg_str) &&
2882 2859              ((len = strlen(usba_device->usb_mfg_str)) != 0)) {
2883 2860                  (void) strncpy(buffer, usba_device->usb_mfg_str, buflen - 1);
2884 2861                  return_len = min(buflen - 1, len);
2885 2862          }
2886 2863  
2887 2864          /* Product string exists to append. */
2888 2865          if ((usba_device->usb_product_str) &&
2889 2866              ((len = strlen(usba_device->usb_product_str)) != 0)) {
2890      -
2891      -                /* Append only parts of string that don't match mfg string. */
2892      -                duplen = usba_str_startcmp(buffer,
2893      -                    usba_device->usb_product_str);
2894      -
2895      -                if (duplen != -1) {             /* Not a complete match. */
2896      -                        if (return_len > 0) {
2897      -                                buffer[return_len++] = ' ';
2898      -                        }
2899      -
2900      -                        /* Skip over the dup part of the concat'ed string. */
2901      -                        len -= duplen;
2902      -                        (void) strncpy(&buffer[return_len],
2903      -                            &usba_device->usb_product_str[duplen],
2904      -                            buflen - return_len - 1);
2905      -                        return_len = min(buflen - 1, return_len + len);
     2867 +                if (return_len > 0) {
     2868 +                        buffer[return_len++] = ' ';
2906 2869                  }
     2870 +                (void) strncpy(&buffer[return_len],
     2871 +                    usba_device->usb_product_str, buflen - return_len - 1);
     2872 +                return_len = min(buflen - 1, return_len + len);
2907 2873          }
2908 2874  
     2875 +        /* Serial number string exists to append. */
2909 2876          if ((usba_device->usb_serialno_str) &&
2910 2877              ((len = strlen(usba_device->usb_serialno_str)) != 0)) {
2911 2878                  if (return_len > 0) {
2912 2879                          buffer[return_len++] = ' ';
2913 2880                  }
2914 2881                  (void) strncpy(&buffer[return_len],
2915 2882                      usba_device->usb_serialno_str,
2916 2883                      buflen - return_len - 1);
2917 2884          }
2918 2885  
↓ open down ↓ 336 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX