# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1173546081 0
# Node ID a6316fc7a87f7f2e7ce0bf1e37c70e4924a13be1
# Parent 9044a50c50ab3b30eee356a8a4273ed79a00a036
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@xxxxxxxxxxxxxx>
---
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c | 13 +++++------
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c | 6 +----
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h | 2 -
linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c | 12 +++-------
4 files changed, 14 insertions(+), 19 deletions(-)
diff -r 9044a50c50ab -r a6316fc7a87f
linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Sat Mar 10
16:59:57 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c Sat Mar 10
17:01:21 2007 +0000
@@ -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 9044a50c50ab -r a6316fc7a87f
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 Sat Mar
10 16:59:57 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.c Sat Mar
10 17:01:21 2007 +0000
@@ -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 9044a50c50ab -r a6316fc7a87f
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 Sat Mar
10 16:59:57 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space_quirks.h Sat Mar
10 17:01:21 2007 +0000
@@ -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 9044a50c50ab -r a6316fc7a87f
linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Sat Mar 10
16:59:57 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/pci_stub.c Sat Mar 10
17:01:21 2007 +0000
@@ -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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|