mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 18:13:26 -04:00
PCI: Cleanup dev->resource + resno to use pci_resource_n()
Replace pointer arithmetic in finding the correct resource entry with the pci_resource_n() helper. Link: https://lore.kernel.org/r/20250207162301.2842-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
2014c95afe
commit
addb30c5bd
@@ -952,7 +952,7 @@ void pci_iov_remove(struct pci_dev *dev)
|
||||
void pci_iov_update_resource(struct pci_dev *dev, int resno)
|
||||
{
|
||||
struct pci_sriov *iov = dev->is_physfn ? dev->sriov : NULL;
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
int vf_bar = resno - PCI_IOV_RESOURCES;
|
||||
struct pci_bus_region region;
|
||||
u16 cmd;
|
||||
|
||||
@@ -1884,7 +1884,7 @@ static void pci_restore_rebar_state(struct pci_dev *pdev)
|
||||
|
||||
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
||||
bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX;
|
||||
res = pdev->resource + bar_idx;
|
||||
res = pci_resource_n(pdev, bar_idx);
|
||||
size = pci_rebar_bytes_to_size(resource_size(res));
|
||||
ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
|
||||
ctrl |= FIELD_PREP(PCI_REBAR_CTRL_BAR_SIZE, size);
|
||||
|
||||
@@ -621,7 +621,7 @@ static void quirk_io(struct pci_dev *dev, int pos, unsigned int size,
|
||||
{
|
||||
u32 region;
|
||||
struct pci_bus_region bus_region;
|
||||
struct resource *res = dev->resource + pos;
|
||||
struct resource *res = pci_resource_n(dev, pos);
|
||||
const char *res_name = pci_resource_name(dev, pos);
|
||||
|
||||
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (pos << 2), ®ion);
|
||||
@@ -671,7 +671,7 @@ static void quirk_io_region(struct pci_dev *dev, int port,
|
||||
{
|
||||
u16 region;
|
||||
struct pci_bus_region bus_region;
|
||||
struct resource *res = dev->resource + nr;
|
||||
struct resource *res = pci_resource_n(dev, nr);
|
||||
|
||||
pci_read_config_word(dev, port, ®ion);
|
||||
region &= ~(size - 1);
|
||||
|
||||
@@ -29,7 +29,7 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
|
||||
u16 cmd;
|
||||
u32 new, check, mask;
|
||||
int reg;
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
const char *res_name = pci_resource_name(dev, resno);
|
||||
|
||||
/* Per SR-IOV spec 3.4.1.11, VF BARs are RO zero */
|
||||
@@ -262,7 +262,7 @@ resource_size_t __weak pcibios_align_resource(void *data,
|
||||
static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
|
||||
int resno, resource_size_t size, resource_size_t align)
|
||||
{
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
resource_size_t min;
|
||||
int ret;
|
||||
|
||||
@@ -325,7 +325,7 @@ static int _pci_assign_resource(struct pci_dev *dev, int resno,
|
||||
|
||||
int pci_assign_resource(struct pci_dev *dev, int resno)
|
||||
{
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
const char *res_name = pci_resource_name(dev, resno);
|
||||
resource_size_t align, size;
|
||||
int ret;
|
||||
@@ -372,7 +372,7 @@ EXPORT_SYMBOL(pci_assign_resource);
|
||||
int pci_reassign_resource(struct pci_dev *dev, int resno,
|
||||
resource_size_t addsize, resource_size_t min_align)
|
||||
{
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
const char *res_name = pci_resource_name(dev, resno);
|
||||
unsigned long flags;
|
||||
resource_size_t new_size;
|
||||
@@ -411,7 +411,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno,
|
||||
|
||||
void pci_release_resource(struct pci_dev *dev, int resno)
|
||||
{
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
const char *res_name = pci_resource_name(dev, resno);
|
||||
|
||||
pci_info(dev, "%s %pR: releasing\n", res_name, res);
|
||||
@@ -428,7 +428,7 @@ EXPORT_SYMBOL(pci_release_resource);
|
||||
|
||||
int pci_resize_resource(struct pci_dev *dev, int resno, int size)
|
||||
{
|
||||
struct resource *res = dev->resource + resno;
|
||||
struct resource *res = pci_resource_n(dev, resno);
|
||||
struct pci_host_bridge *host;
|
||||
int old, ret;
|
||||
u32 sizes;
|
||||
|
||||
Reference in New Issue
Block a user