Re: [PATCH] PCI: access.c: Piggyback user config access on pci_read/write_*()
On 6/4/2018 11:09 AM, Keith Busch wrote: > On Mon, Jun 04, 2018 at 10:48:02AM -0500, Alexandru Gagniuc wrote: >> +++ b/drivers/pci/access.c >> @@ -223,16 +223,9 @@ int pci_user_read_config_##size >> \ >> (struct pci_dev *dev, int pos, type *val) \ >> { \ >> int ret = PCIBIOS_SUCCESSFUL; \ >> -u32 data = -1; \ >> if (PCI_##size##_BAD) \ >> return -EINVAL; \ >> -raw_spin_lock_irq(_lock); \ >> -if (unlikely(dev->block_cfg_access))\ >> -pci_wait_cfg(dev); \ >> -ret = dev->bus->ops->read(dev->bus, dev->devfn, \ >> -pos, sizeof(type), ); \ >> -raw_spin_unlock_irq(_lock); \ >> -*val = (type)data; \ >> +ret = pci_read_config_##size(dev, pos, val);\ >> return pcibios_err_to_errno(ret); \ >> } \ > > If it wasn't for the block_cfg_access check for user access, this would > have been a nice code reuse cleanup. Great fresh catch! I'll get that fixed in v2. Alex
Re: [PATCH] PCI: access.c: Piggyback user config access on pci_read/write_*()
On 6/4/2018 11:09 AM, Keith Busch wrote: > On Mon, Jun 04, 2018 at 10:48:02AM -0500, Alexandru Gagniuc wrote: >> +++ b/drivers/pci/access.c >> @@ -223,16 +223,9 @@ int pci_user_read_config_##size >> \ >> (struct pci_dev *dev, int pos, type *val) \ >> { \ >> int ret = PCIBIOS_SUCCESSFUL; \ >> -u32 data = -1; \ >> if (PCI_##size##_BAD) \ >> return -EINVAL; \ >> -raw_spin_lock_irq(_lock); \ >> -if (unlikely(dev->block_cfg_access))\ >> -pci_wait_cfg(dev); \ >> -ret = dev->bus->ops->read(dev->bus, dev->devfn, \ >> -pos, sizeof(type), ); \ >> -raw_spin_unlock_irq(_lock); \ >> -*val = (type)data; \ >> +ret = pci_read_config_##size(dev, pos, val);\ >> return pcibios_err_to_errno(ret); \ >> } \ > > If it wasn't for the block_cfg_access check for user access, this would > have been a nice code reuse cleanup. Great fresh catch! I'll get that fixed in v2. Alex
Re: [PATCH] PCI: access.c: Piggyback user config access on pci_read/write_*()
On Mon, Jun 04, 2018 at 10:48:02AM -0500, Alexandru Gagniuc wrote: > +++ b/drivers/pci/access.c > @@ -223,16 +223,9 @@ int pci_user_read_config_##size > \ > (struct pci_dev *dev, int pos, type *val) \ > {\ > int ret = PCIBIOS_SUCCESSFUL; \ > - u32 data = -1; \ > if (PCI_##size##_BAD) \ > return -EINVAL; \ > - raw_spin_lock_irq(_lock); \ > - if (unlikely(dev->block_cfg_access))\ > - pci_wait_cfg(dev); \ > - ret = dev->bus->ops->read(dev->bus, dev->devfn, \ > - pos, sizeof(type), ); \ > - raw_spin_unlock_irq(_lock); \ > - *val = (type)data; \ > + ret = pci_read_config_##size(dev, pos, val);\ > return pcibios_err_to_errno(ret); \ > }\ If it wasn't for the block_cfg_access check for user access, this would have been a nice code reuse cleanup.
Re: [PATCH] PCI: access.c: Piggyback user config access on pci_read/write_*()
On Mon, Jun 04, 2018 at 10:48:02AM -0500, Alexandru Gagniuc wrote: > +++ b/drivers/pci/access.c > @@ -223,16 +223,9 @@ int pci_user_read_config_##size > \ > (struct pci_dev *dev, int pos, type *val) \ > {\ > int ret = PCIBIOS_SUCCESSFUL; \ > - u32 data = -1; \ > if (PCI_##size##_BAD) \ > return -EINVAL; \ > - raw_spin_lock_irq(_lock); \ > - if (unlikely(dev->block_cfg_access))\ > - pci_wait_cfg(dev); \ > - ret = dev->bus->ops->read(dev->bus, dev->devfn, \ > - pos, sizeof(type), ); \ > - raw_spin_unlock_irq(_lock); \ > - *val = (type)data; \ > + ret = pci_read_config_##size(dev, pos, val);\ > return pcibios_err_to_errno(ret); \ > }\ If it wasn't for the block_cfg_access check for user access, this would have been a nice code reuse cleanup.