Subject: Re: [PATCH 3/9] pasemi_mac: Abstract out register access

From: Jeff Garzik <[email-masked]>
Date: Mon, 02 Jul 2007 08:32:24 -0400

Olof Johansson wrote:
> Abstract out the PCI config read/write accesses into reg read/write ones, still
> calling the pci accessors on the back end.
> 
> Signed-off-by: Olof Johansson <[email-masked]>
> 
> 
> Index: netdev-2.6/drivers/net/pasemi_mac.c
> ===================================================================
> --- netdev-2.6.orig/drivers/net/pasemi_mac.c
> +++ netdev-2.6/drivers/net/pasemi_mac.c
> @@ -81,6 +81,48 @@ MODULE_PARM_DESC(debug, "PA Semi MAC bit
>  
>  static struct pasdma_status *dma_status;
>  
> +static unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
> +{
> +	unsigned int val;
> +
> +	pci_read_config_dword(mac->iob_pdev, reg, &val);
> +	return val;
> +}
> +
> +static void write_iob_reg(struct pasemi_mac *mac, unsigned int reg,
> +			  unsigned int val)
> +{
> +	pci_write_config_dword(mac->iob_pdev, reg, val);
> +}
> +
> +static unsigned int read_mac_reg(struct pasemi_mac *mac, unsigned int reg)
> +{
> +	unsigned int val;
> +
> +	pci_read_config_dword(mac->pdev, reg, &val);
> +	return val;
> +}
> +
> +static void write_mac_reg(struct pasemi_mac *mac, unsigned int reg,
> +			  unsigned int val)
> +{
> +	pci_write_config_dword(mac->pdev, reg, val);
> +}
> +
> +static unsigned int read_dma_reg(struct pasemi_mac *mac, unsigned int reg)
> +{
> +	unsigned int val;
> +
> +	pci_read_config_dword(mac->dma_pdev, reg, &val);
> +	return val;
> +}
> +
> +static void write_dma_reg(struct pasemi_mac *mac, unsigned int reg,
> +			  unsigned int val)
> +{
> +	pci_write_config_dword(mac->dma_pdev, reg, val);
> +}

The general concept is fine, but you should use 'u32' and similar 
size-based types for your input and output values.