Re: [PATCH 5/5] In verbose mode, display contents of VPD if possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  static void
> +cap_vpd(struct device *d)
> +{
> +  word res_addr = 0, res_len, part_pos, part_len;
> +  byte key[2], buf[256];
> +  byte tag;
> +
> +  printf("Vital Product Data\n");
> +
> +  while (res_addr <= PCI_VPD_ADDR_MASK) {
> +    if (!pci_read_vpd(d->dev, res_addr, &tag, 1))
> +      break;

Please keep the indentation style consistent with the rest of the file.

> +    case 0x82:
> +      printf("\t\tProduct Name: ");
> +      while (part_pos < res_len) {
> +	part_len = res_len - part_pos;
> +	if (part_len > sizeof(buf))
> +	    part_len = sizeof(buf);
> +	if (!pci_read_vpd(d->dev, res_addr + part_pos, buf, part_len))
> +	  break;
> +	fwrite(buf, 1, part_len, stdout);

You should definitely check whether the characters are printable
(both here and in the Alphanumeric content case).

> +	if ((key[0] == 'E' && key[1] == 'C') ||
> +	    (key[0] == 'P' && key[1] == 'N') ||
> +	    (key[0] == 'S' && key[1] == 'N') ||
> +	    key[0] == 'V' ||
> +	    key[0] == 'Y') {
> +	  /* Alphanumeric content */
> +	  printf("\t\t\t%c%c: %.*s\n", key[0], key[1], part_len, buf);

I think that it would be nice to accompany the attributes which we
recognize with an explanation (a more verbose name).

> +	  /* XXX should verify checksum? */

Would be nice, definitely.

> +    }
> +      
> +    res_addr += res_len;

Trailing whitespace.

				Have a nice fortnight
-- 
Martin `MJ' Mares                          <mj@xxxxxx>   http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
If a train station is where the train stops, what is a work station?
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux