Patchwork [11/20] pci: clean up of pci_init_wmask().

login
register
mail settings
Submitter Isaku Yamahata
Date Nov. 12, 2009, 5:58 a.m.
Message ID <1258005528-25383-12-git-send-email-yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/38210/
State New
Headers show

Comments

Isaku Yamahata - Nov. 12, 2009, 5:58 a.m.
This patch replaces for loop by memset in pci_init_wmask().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Michael S. Tsirkin - Nov. 12, 2009, 10:18 a.m.
On Thu, Nov 12, 2009 at 02:58:39PM +0900, Isaku Yamahata wrote:
> This patch replaces for loop by memset in pci_init_wmask().
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/pci.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 67818b7..9698efb 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -426,15 +426,15 @@ static void pci_init_cmask(PCIDevice *dev)
>  
>  static void pci_init_wmask(PCIDevice *dev)
>  {
> -    int i;
>      int config_size = pci_config_size(dev);
>  
>      dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff;
>      dev->wmask[PCI_INTERRUPT_LINE] = 0xff;
>      pci_set_word(dev->wmask + PCI_COMMAND,
>                   PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
> -    for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
> -        dev->wmask[i] = 0xff;
> +
> +    memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff,
> +           config_size - PCI_CONFIG_HEADER_SIZE);
>  }
>  
>  static void pci_init_wmask_bridge(PCIDevice *d)
> -- 
> 1.6.0.2

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 67818b7..9698efb 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -426,15 +426,15 @@  static void pci_init_cmask(PCIDevice *dev)
 
 static void pci_init_wmask(PCIDevice *dev)
 {
-    int i;
     int config_size = pci_config_size(dev);
 
     dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff;
     dev->wmask[PCI_INTERRUPT_LINE] = 0xff;
     pci_set_word(dev->wmask + PCI_COMMAND,
                  PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-    for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
-        dev->wmask[i] = 0xff;
+
+    memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff,
+           config_size - PCI_CONFIG_HEADER_SIZE);
 }
 
 static void pci_init_wmask_bridge(PCIDevice *d)