This is a follow-up to pciback changes made earlier today that add
several 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@xxxxxxxxxxxxxx>
diff -r 6ff2a1286484 linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Fri Mar 09
16:04:19 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Fri Mar 09
16:07:38 2007 -0500
@@ -349,16 +349,12 @@ void pciback_config_free_dev(struct pci_
int pciback_config_add_field_offset(struct pci_dev *dev,
struct config_field *field,
- unsigned int offset)
+ unsigned int base_offset)
{
int err = 0;
struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
struct config_field_entry *cfg_entry;
void *tmp;
-
- /* silently ignore duplicate fields */
- if (pciback_field_is_dup(dev, field->offset + offset))
- goto out;
cfg_entry = kmalloc(sizeof(*cfg_entry), GFP_KERNEL);
if (!cfg_entry) {
@@ -368,7 +364,12 @@ int pciback_config_add_field_offset(stru
cfg_entry->data = NULL;
cfg_entry->field = field;
- cfg_entry->base_offset = offset;
+ cfg_entry->base_offset = base_offset;
+
+ /* silently ignore duplicate fields */
+ err = pciback_field_is_dup(dev,OFFSET(cfg_entry));
+ if (err)
+ goto out;
if (field->init) {
tmp = field->init(dev, OFFSET(cfg_entry));
diff -r 6ff2a1286484
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c Fri Mar
09 16:04:19 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c Fri Mar
09 16:07:38 2007 -0500
@@ -32,16 +32,14 @@ static inline void register_quirk(struct
list_add_tail(&quirk->quirks_list, &pciback_quirks);
}
-int pciback_field_is_dup(struct pci_dev *dev, int reg)
+int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg)
{
int ret = 0;
struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
- struct config_field *field;
struct config_field_entry *cfg_entry;
list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
- field = cfg_entry->field;
- if (field->offset == reg) {
+ if ( OFFSET(cfg_entry) == reg) {
ret = 1;
break;
}
diff -r 6ff2a1286484
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h Fri Mar
09 16:04:19 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h Fri Mar
09 16:07:38 2007 -0500
@@ -30,6 +30,6 @@ void pciback_config_field_free(struct co
int pciback_config_quirk_release(struct pci_dev *dev);
-int pciback_field_is_dup(struct pci_dev *dev, int reg);
+int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg);
#endif
diff -r 6ff2a1286484 linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Fri Mar 09
16:04:19 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Fri Mar 09
16:07:38 2007 -0500
@@ -589,10 +589,6 @@ static int pcistub_reg_add(int domain, i
}
dev = psdev->dev;
- /* check for duplicate field */
- if (pciback_field_is_dup(dev, reg))
- goto out;
-
field = kzalloc(sizeof(*field), GFP_ATOMIC);
if (!field) {
err = -ENOMEM;
@@ -728,10 +724,10 @@ static ssize_t pcistub_quirk_show(struct
if (count >= PAGE_SIZE)
goto out;
- count += scnprintf(buf + count, PAGE_SIZE -
- count, "\t\t%08x:%01x:%08x\n",
- field->offset, field->size,
- field->mask);
+ count += scnprintf(buf + count, PAGE_SIZE - count,
+ "\t\t%08x:%01x:%08x\n",
+ cfg_entry->base_offset +
field->offset,
+ field->size, field->mask);
}
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|