lkml.org 
[lkml]   [2012]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Resend with Ack][PATCH v1] PCI: allow acpiphp to handle PCIe ports without native PCIe hotplug capability
Sure, let's try it.

On 2012-7-3 23:59, Bjorn Helgaas wrote:
> Thinking about this some more, this still leaves the callers
> responsible for using pcie_cap_has_*(), which feels pretty
> error-prone.
>
> I wonder if it'd be worth adding interfaces like:
>
> pcie_cap_read_word(const struct pci_dev *, int where, u16 *val);
> pcie_cap_read_dword(const struct pci_dev *, int where, u32 *val);
> pcie_cap_write_word(const struct pci_dev *, int where, u16 val);
> pcie_cap_write_dword(const struct pci_dev *, int where, u32 val);
>
> We might be able to encapsulate the v1/v2 differences inside these, e.g.,
>
> int pcie_cap_read_word(const struct pci_dev *dev, int where, u16 *val)
> {
> int pos;
>
> pos = pci_pcie_cap(dev);
> if (!pos)
> return -EINVAL;
>
> switch (where) {
> case PCI_EXP_FLAGS:
> case PCI_EXP_DEVCTL:
> case PCI_EXP_DEVSTA:
> return pci_read_config_word(dev, pos + where, val);
> case PCI_EXP_LNKCTL:
> case PCI_EXP_LNKSTA:
> if (pcie_cap_has_lnkctl(dev))
> return pci_read_config_word(dev, pos + where, val);
> else {
> *val = 0;
> return 0;
> }
> case PCI_EXP_SLTCTL:
> case PCI_EXP_SLTSTA:
> if (pcie_cap_has_sltctl(dev))
> return pci_read_config_word(dev, pos + where, val);
> else {
> *val = 0;
> if (where == PCI_EXP_SLTSTA && dev->pcie_type ==
> PCI_EXP_TYPE_DOWNSTREAM)
> *val = PCI_EXP_SLTSTA_PDS;
> return 0;
> ...
> };
> return -EINVAL;
> }
>
> Any thoughts?
>
> .
>




\
 
 \ /
  Last update: 2012-07-04 05:21    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site