Patchwork [1/3] pci: replace the magic, 256, for the maximum of devfn

login
register
mail settings
Submitter Isaku Yamahata
Date Jan. 26, 2011, 9:45 a.m.
Message ID <76163938f7a687e924637b7118b4000d940d6465.1296034717.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/80496/
State New
Headers show

Comments

Isaku Yamahata - Jan. 26, 2011, 9:45 a.m.
Introduce symbol PCI_DEVFN_MAX for the maximum of devfn
and replace the magic, 256.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.h           |    2 ++
 hw/pci_internals.h |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
Michael S. Tsirkin - Jan. 26, 2011, 1:37 p.m.
On Wed, Jan 26, 2011 at 06:45:18PM +0900, Isaku Yamahata wrote:
> Introduce symbol PCI_DEVFN_MAX for the maximum of devfn
> and replace the magic, 256.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
>  hw/pci.h           |    2 ++
>  hw/pci_internals.h |    2 +-
>  2 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/pci.h b/hw/pci.h
> index 0d2753f..ffb04e8 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -16,7 +16,9 @@
>  #define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
>  #define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
>  #define PCI_FUNC(devfn)         ((devfn) & 0x07)
> +#define PCI_SLOT_MAX            32
>  #define PCI_FUNC_MAX            8
> +#define PCI_DEVFN_MAX           (PCI_SLOT_MAX * PCI_FUNC_MAX)

SLOT_MAX makes sense. I'd prefer open-coding PCI_DEVFN_MAX
if there's only one user.

>  
>  /* Class, Vendor and Device IDs from Linux's pci_ids.h */
>  #include "pci_ids.h"
> diff --git a/hw/pci_internals.h b/hw/pci_internals.h
> index e3c93a3..f17e681 100644
> --- a/hw/pci_internals.h
> +++ b/hw/pci_internals.h
> @@ -22,7 +22,7 @@ struct PCIBus {
>      pci_hotplug_fn hotplug;
>      DeviceState *hotplug_qdev;
>      void *irq_opaque;
> -    PCIDevice *devices[256];
> +    PCIDevice *devices[PCI_DEVFN_MAX];
>      PCIDevice *parent_dev;
>      target_phys_addr_t mem_base;
>  
> -- 
> 1.7.1.1

Patch

diff --git a/hw/pci.h b/hw/pci.h
index 0d2753f..ffb04e8 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -16,7 +16,9 @@ 
 #define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)         ((devfn) & 0x07)
+#define PCI_SLOT_MAX            32
 #define PCI_FUNC_MAX            8
+#define PCI_DEVFN_MAX           (PCI_SLOT_MAX * PCI_FUNC_MAX)
 
 /* Class, Vendor and Device IDs from Linux's pci_ids.h */
 #include "pci_ids.h"
diff --git a/hw/pci_internals.h b/hw/pci_internals.h
index e3c93a3..f17e681 100644
--- a/hw/pci_internals.h
+++ b/hw/pci_internals.h
@@ -22,7 +22,7 @@  struct PCIBus {
     pci_hotplug_fn hotplug;
     DeviceState *hotplug_qdev;
     void *irq_opaque;
-    PCIDevice *devices[256];
+    PCIDevice *devices[PCI_DEVFN_MAX];
     PCIDevice *parent_dev;
     target_phys_addr_t mem_base;