Re: [PATCH v2] PCI/VPD: Use unaligned access helpers in pci_vpd_read

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

 



On Sat, May 08, 2021 at 12:29:15AM +0200, Heiner Kallweit wrote:
> +
> +		if (len == 4)  {
> +			put_unaligned_le32(val, buf);
> +		} else {
> +			cpu_to_le32s(&val);
> +			memcpy(buf, (u8 *)&val + skip, len);

cpu_to_le32s is a horrible API that breaks endianess annotations.

Is the intent of this code to only put 16 bits in?  Why not something
like:

		switch (len) {
		case 4:
			put_unaligned_le32(val, buf);
			break;
		case 2:
			put_unaligned_le16(val, buf + 2);
			break;
		case 1:
			buf[3] = val;
			break;
  		}



[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