From: Ben Hutchings <bhutchings@solarflare.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] PCI: revise VPD access interface
Date: Fri, 5 Sep 2008 12:02:23 +0100 [thread overview]
Message-ID: <20080905110222.GH7908@solarflare.com> (raw)
In-Reply-To: <20080904205718.626058270@vyatta.com>
Stephen Hemminger wrote:
> Change PCI VPD API which was only used by sysfs to something usable
> in drivers.
> * move iteration over multiple words to the low level
> * cleanup types of arguments
> * add exportable wrapper
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/drivers/pci/access.c 2008-09-04 10:16:52.000000000 -0700
> +++ b/drivers/pci/access.c 2008-09-04 10:19:47.000000000 -0700
[...]
> -static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size,
> - const char *buf)
> +static int pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count,
> + const void *buf)
> {
> struct pci_vpd_pci22 *vpd =
> container_of(dev->vpd, struct pci_vpd_pci22, base);
> - u32 val;
> + loff_t end = pos + count;
> int ret;
>
> - if (pos < 0 || pos > vpd->base.len || pos & 3 ||
> - size > vpd->base.len - pos || size < 4)
> + if (pos > vpd->base.len || pos & 3)
> return -EINVAL;
>
> - val = (u8) *buf++;
> - val |= ((u8) *buf++) << 8;
> - val |= ((u8) *buf++) << 16;
> - val |= ((u32)(u8) *buf++) << 24;
> -
> ret = mutex_lock_killable(&vpd->lock);
> if (ret)
> return ret;
> - ret = pci_vpd_pci22_wait(dev);
> - if (ret < 0)
> - goto out;
> - ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA,
> - val);
> - if (ret < 0)
> - goto out;
> - ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
> - pos | PCI_VPD_ADDR_F);
> - if (ret < 0)
> - goto out;
> - vpd->busy = true;
> - vpd->flag = 0;
> - ret = pci_vpd_pci22_wait(dev);
> -out:
> - mutex_unlock(&vpd->lock);
> - if (ret < 0)
> - return ret;
>
> - return 4;
> + while (pos < end) {
> + u32 val;
> +
> + ret = pci_vpd_pci22_wait(dev);
> + if (ret < 0)
> + break;
> + memcpy(&val, buf, sizeof(u32));
[...]
I'm not sure this is correct. pci_user_write_config_dword() expects a
value in host byte order, but this memcpy() makes val always little-endian.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2008-09-05 11:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-04 20:56 [PATCH 0/3] PCI VPD changes Stephen Hemminger
2008-09-04 20:56 ` [PATCH 1/3] PCI: vpd handle longer delays in access Stephen Hemminger
2008-09-05 9:11 ` Peter Zijlstra
2008-09-05 12:40 ` Matthew Wilcox
2008-09-08 20:40 ` Andrew Morton
2008-09-08 21:08 ` Stephen Hemminger
2008-09-08 21:26 ` Arjan van de Ven
2008-09-09 16:55 ` Stephen Hemminger
2008-09-09 17:01 ` Arjan van de Ven
2008-09-04 20:56 ` [PATCH 2/3] PCI: revise VPD access interface Stephen Hemminger
2008-09-05 11:02 ` Ben Hutchings [this message]
2008-09-08 20:46 ` Andrew Morton
2008-09-04 20:56 ` [PATCH 3/3] PCI: add interface to set visible size of VPD Stephen Hemminger
2008-09-05 11:07 ` Ben Hutchings
[not found] <20080827204626.4b65862f@extreme>
[not found] ` <20080828111323.GI7908@solarflare.com>
[not found] ` <20080903155316.1a0a5698@extreme>
2008-09-03 22:57 ` [PATCH 2/3] pci: revise VPD access interface Stephen Hemminger
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=20080905110222.GH7908@solarflare.com \
--to=bhutchings@solarflare.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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