Subject: Re: [patch 2/4] ppc: make pcibios_enable_device() use pcibios_enable_resources()

From: Benjamin Herrenschmidt <[email-masked]>
Date: Tue, 19 Feb 2008 17:26:54 +1100

On Mon, 2008-02-18 at 21:39 -0700, Bjorn Helgaas wrote:
> plain text document attachment (ppc-pcibios_enable_resources)
> pcibios_enable_device() has an almost verbatim copy of
> pcibios_enable_resources(), (the only difference is that
> pcibios_enable_resources() turns on PCI_COMMAND_MEMORY if
> there's a ROM resource).
> 
> The duplication might be intentional, but I don't see any callers
> of pcibios_enable_resources() on ppc, so I think it's more
> likely a historical accident.
> 
> This patch removes the duplication, making pcibios_enable_device()
> simply call pcibios_enable_resources() as x86 does.
> 
> Signed-off-by: Bjorn Helgaas <[email-masked]>

Ack. arch/ppc is being phased out soon anyway.

Ben.

> 
> Index: work6/arch/ppc/kernel/pci.c
> ===================================================================
> --- work6.orig/arch/ppc/kernel/pci.c	2008-02-18 10:43:50.000000000 -0700
> +++ work6/arch/ppc/kernel/pci.c	2008-02-18 11:31:23.000000000 -0700
> @@ -785,33 +785,11 @@
>  
>  int pcibios_enable_device(struct pci_dev *dev, int mask)
>  {
> -	u16 cmd, old_cmd;
> -	int idx;
> -	struct resource *r;
> -
>  	if (ppc_md.pcibios_enable_device_hook)
>  		if (ppc_md.pcibios_enable_device_hook(dev, 0))
>  			return -EINVAL;
> -		
> -	pci_read_config_word(dev, PCI_COMMAND, &cmd);
> -	old_cmd = cmd;
> -	for (idx=0; idx<6; idx++) {
> -		r = &dev->resource[idx];
> -		if (r->flags & IORESOURCE_UNSET) {
> -			printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
> -			return -EINVAL;
> -		}
> -		if (r->flags & IORESOURCE_IO)
> -			cmd |= PCI_COMMAND_IO;
> -		if (r->flags & IORESOURCE_MEM)
> -			cmd |= PCI_COMMAND_MEMORY;
> -	}
> -	if (cmd != old_cmd) {
> -		printk("PCI: Enabling device %s (%04x -> %04x)\n",
> -		       pci_name(dev), old_cmd, cmd);
> -		pci_write_config_word(dev, PCI_COMMAND, cmd);
> -	}
> -	return 0;
> +
> +	return pcibios_enable_resources(dev, mask);
>  }
>  
>  struct pci_controller*
>