WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[PATCH] [pciback] Re: [Xen-devel] pciback_field_is_dup needs a fix

To: Keir Fraser <keir@xxxxxxxxxxxxx>
Subject: [PATCH] [pciback] Re: [Xen-devel] pciback_field_is_dup needs a fix
From: Chris <hap10@xxxxxxxxxxxxxx>
Date: Fri, 09 Mar 2007 16:26:15 -0500
Cc: Jambunathan K <jambunathan@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 09 Mar 2007 13:25:51 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C216D700.B1D6%keir@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C216D700.B1D6%keir@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)
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
<Prev in Thread] Current Thread [Next in Thread>