Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <helgaas@kernel.org>
Subject: Re: [PATCH v2] PCI/VPD: Use unaligned access helpers in pci_vpd_read
Date: Mon, 10 May 2021 07:36:10 +0100	[thread overview]
Message-ID: <YJjUWulw8vkscdwg@infradead.org> (raw)
In-Reply-To: <5719b91c-9f91-0029-0a28-386f1cb29d31@gmail.com>

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;
  		}

  reply	other threads:[~2021-05-10  6:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 22:29 [PATCH v2] PCI/VPD: Use unaligned access helpers in pci_vpd_read Heiner Kallweit
2021-05-10  6:36 ` Christoph Hellwig [this message]
2021-05-10  7:09   ` Heiner Kallweit
2021-05-12  7:21     ` Christoph Hellwig
2021-05-12  7:56       ` Heiner Kallweit
2021-05-12 17:35         ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YJjUWulw8vkscdwg@infradead.org \
    --to=hch@infradead.org \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox