Re: [PATCH 09/29] staging: comedi: addi_apci_1032: simplify the PCI bar reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012/11/05 09:36 PM, H Hartley Sweeten wrote:
> This board has a 93c76 eeprom. Knowing this information allows
> simplifying the code that reads the PCI bars to get the iobase
> addresses used in the driver.
> 
> Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
> Cc: Ian Abbott <abbotti@xxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/staging/comedi/drivers/addi_apci_1032.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c
> index 70cada4..8ea9fea 100644
> --- a/drivers/staging/comedi/drivers/addi_apci_1032.c
> +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
> @@ -88,22 +88,10 @@ static int apci1032_attach_pci(struct comedi_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	if (!this_board->pc_EepromChip ||
> -	    !strcmp(this_board->pc_EepromChip, ADDIDATA_9054)) {
> -		if (this_board->i_IorangeBase1)
> -			dev->iobase = pci_resource_start(pcidev, 1);
> -		else
> -			dev->iobase = pci_resource_start(pcidev, 0);
> -
> -		devpriv->iobase = dev->iobase;
> -		devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
> -		devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
> -	} else {
> -		dev->iobase = pci_resource_start(pcidev, 2);
> -		devpriv->iobase = pci_resource_start(pcidev, 2);
> -		devpriv->dw_AiBase = ioremap(pci_resource_start(pcidev, 3),
> -					     this_board->i_IorangeBase3);
> -	}
> +	dev->iobase = pci_resource_start(pcidev, 2);
> +	devpriv->iobase = pci_resource_start(pcidev, 2);
> +	devpriv->dw_AiBase = ioremap(pci_resource_start(pcidev, 3),
> +				     this_board->i_IorangeBase3);
>  	devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
>  
>  	/* Initialize parameters that can be overridden in EEPROM */
> 

You know, I think this simplification actually used the wrong branch of
the `if`.  `this_board->pc_EepromChip` is `ADDIDATA_93C76` ("93C76")
which doesn't match `ADDIDATA_9054` ("9054").  Also,
`this_board->i_IorangeBase1` is `APCI1032_ADDRESS_RANGE` (20, but should
probably be rounded up to 32).  This implies:

	dev->iobase = pci_resource_start(pcidev, 1);
	devpriv->iobase = dev->iobase;
	devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
	devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);

in the original.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>             )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587              )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux