direct-io.hg

changeset 14330:a6316fc7a87f

pci back: Various fixes.

- remove superfluous call to pciback_field_is_dup()
- fix a variable type mismatch in pciback_field_is_dup()
- make readability improvements by using the OFFSET macro
- revises quirk data output via the sysfs quirks node so that
- displayed offset information includes base_offset.

Thanks to Jambunathan K. for giving such specific bug diagnosis.

Signed-off-by: Chris Bookholt <hap10@tycho.ncsc.mil>
author kfraser@localhost.localdomain
date Sat Mar 10 17:01:21 2007 +0000 (2007-03-10)
parents 9044a50c50ab
children 7db52e0ed133
files linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c	Sat Mar 10 16:59:57 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c	Sat Mar 10 17:01:21 2007 +0000
     1.3 @@ -349,17 +349,13 @@ void pciback_config_free_dev(struct pci_
     1.4  
     1.5  int pciback_config_add_field_offset(struct pci_dev *dev,
     1.6  				    struct config_field *field,
     1.7 -				    unsigned int offset)
     1.8 +				    unsigned int base_offset)
     1.9  {
    1.10  	int err = 0;
    1.11  	struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
    1.12  	struct config_field_entry *cfg_entry;
    1.13  	void *tmp;
    1.14  
    1.15 -	/* silently ignore duplicate fields */
    1.16 -	if (pciback_field_is_dup(dev, field->offset + offset))
    1.17 -		goto out;
    1.18 -
    1.19  	cfg_entry = kmalloc(sizeof(*cfg_entry), GFP_KERNEL);
    1.20  	if (!cfg_entry) {
    1.21  		err = -ENOMEM;
    1.22 @@ -368,7 +364,12 @@ int pciback_config_add_field_offset(stru
    1.23  
    1.24  	cfg_entry->data = NULL;
    1.25  	cfg_entry->field = field;
    1.26 -	cfg_entry->base_offset = offset;
    1.27 +	cfg_entry->base_offset = base_offset;
    1.28 +
    1.29 +	/* silently ignore duplicate fields */
    1.30 +	err = pciback_field_is_dup(dev,OFFSET(cfg_entry));
    1.31 +	if (err)
    1.32 +		goto out;
    1.33  
    1.34  	if (field->init) {
    1.35  		tmp = field->init(dev, OFFSET(cfg_entry));
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c	Sat Mar 10 16:59:57 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c	Sat Mar 10 17:01:21 2007 +0000
     2.3 @@ -32,16 +32,14 @@ static inline void register_quirk(struct
     2.4  	list_add_tail(&quirk->quirks_list, &pciback_quirks);
     2.5  }
     2.6  
     2.7 -int pciback_field_is_dup(struct pci_dev *dev, int reg)
     2.8 +int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg)
     2.9  {
    2.10  	int ret = 0;
    2.11  	struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
    2.12 -	struct config_field *field;
    2.13  	struct config_field_entry *cfg_entry;
    2.14  
    2.15  	list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
    2.16 -		field = cfg_entry->field;
    2.17 -		if (field->offset == reg) {
    2.18 +		if ( OFFSET(cfg_entry) == reg) {
    2.19  			ret = 1;
    2.20  			break;
    2.21  		}
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h	Sat Mar 10 16:59:57 2007 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h	Sat Mar 10 17:01:21 2007 +0000
     3.3 @@ -30,6 +30,6 @@ void pciback_config_field_free(struct co
     3.4  
     3.5  int pciback_config_quirk_release(struct pci_dev *dev);
     3.6  
     3.7 -int pciback_field_is_dup(struct pci_dev *dev, int reg);
     3.8 +int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg);
     3.9  
    3.10  #endif
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c	Sat Mar 10 16:59:57 2007 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c	Sat Mar 10 17:01:21 2007 +0000
     4.3 @@ -589,10 +589,6 @@ static int pcistub_reg_add(int domain, i
     4.4  	}
     4.5  	dev = psdev->dev;
     4.6  
     4.7 -	/* check for duplicate field */
     4.8 -	if (pciback_field_is_dup(dev, reg))
     4.9 -		goto out;
    4.10 -
    4.11  	field = kzalloc(sizeof(*field), GFP_ATOMIC);
    4.12  	if (!field) {
    4.13  		err = -ENOMEM;
    4.14 @@ -728,10 +724,10 @@ static ssize_t pcistub_quirk_show(struct
    4.15  			if (count >= PAGE_SIZE)
    4.16  				goto out;
    4.17  
    4.18 -			count += scnprintf(buf + count, PAGE_SIZE -
    4.19 -					   count, "\t\t%08x:%01x:%08x\n",
    4.20 -					   field->offset, field->size,
    4.21 -					   field->mask);
    4.22 +			count += scnprintf(buf + count, PAGE_SIZE - count,
    4.23 +					   "\t\t%08x:%01x:%08x\n",
    4.24 +					   cfg_entry->base_offset + field->offset, 
    4.25 +					   field->size, field->mask);
    4.26  		}
    4.27  	}
    4.28