Jan Beulich
2008-Oct-17 15:39 UTC
[Xen-devel] [PATCH] linux/pciback: constify struct config_field instances
... plus the necessary adjustments to declarations. Also simplify the static list terminators. As usual, written and tested on 2.6.27 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2008-10-14/drivers/xen/pciback/conf_space.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space.c 2008-10-17 11:36:12.000000000 +0200 @@ -31,11 +31,11 @@ DEFINE_PCI_CONFIG(write, word, u16) DEFINE_PCI_CONFIG(write, dword, u32) static int conf_space_read(struct pci_dev *dev, - struct config_field_entry *entry, int offset, - u32 * value) + const struct config_field_entry *entry, + int offset, u32 *value) { int ret = 0; - struct config_field *field = entry->field; + const struct config_field *field = entry->field; *value = 0; @@ -59,11 +59,11 @@ static int conf_space_read(struct pci_de } static int conf_space_write(struct pci_dev *dev, - struct config_field_entry *entry, int offset, - u32 value) + const struct config_field_entry *entry, + int offset, u32 value) { int ret = 0; - struct config_field *field = entry->field; + const struct config_field *field = entry->field; switch (field->size) { case 1: @@ -140,8 +140,8 @@ int pciback_config_read(struct pci_dev * { int err = 0; struct pciback_dev_data *dev_data = pci_get_drvdata(dev); - struct config_field_entry *cfg_entry; - struct config_field *field; + const struct config_field_entry *cfg_entry; + const struct config_field *field; int req_start, req_end, field_start, field_end; /* if read fails for any reason, return 0 (as if device didn''t respond) */ u32 value = 0, tmp_val; @@ -202,8 +202,8 @@ int pciback_config_write(struct pci_dev { int err = 0, handled = 0; struct pciback_dev_data *dev_data = pci_get_drvdata(dev); - struct config_field_entry *cfg_entry; - struct config_field *field; + const struct config_field_entry *cfg_entry; + const struct config_field *field; u32 tmp_val; int req_start, req_end, field_start, field_end; @@ -290,7 +290,7 @@ void pciback_config_free_dyn_fields(stru { struct pciback_dev_data *dev_data = pci_get_drvdata(dev); struct config_field_entry *cfg_entry, *t; - struct config_field *field; + const struct config_field *field; dev_dbg(&dev->dev, "free-ing dynamically allocated virtual configuration space fields\n"); @@ -299,7 +299,7 @@ void pciback_config_free_dyn_fields(stru field = cfg_entry->field; if (field->clean) { - field->clean(field); + field->clean((struct config_field *)field); if (cfg_entry->data) kfree(cfg_entry->data); @@ -314,8 +314,8 @@ void pciback_config_free_dyn_fields(stru void pciback_config_reset_dev(struct pci_dev *dev) { struct pciback_dev_data *dev_data = pci_get_drvdata(dev); - struct config_field_entry *cfg_entry; - struct config_field *field; + const struct config_field_entry *cfg_entry; + const struct config_field *field; dev_dbg(&dev->dev, "resetting virtual configuration space\n"); @@ -331,7 +331,7 @@ void pciback_config_free_dev(struct pci_ { struct pciback_dev_data *dev_data = pci_get_drvdata(dev); struct config_field_entry *cfg_entry, *t; - struct config_field *field; + const struct config_field *field; dev_dbg(&dev->dev, "free-ing virtual configuration space fields\n"); @@ -348,7 +348,7 @@ void pciback_config_free_dev(struct pci_ } int pciback_config_add_field_offset(struct pci_dev *dev, - struct config_field *field, + const struct config_field *field, unsigned int base_offset) { int err = 0; Index: head-2008-10-14/drivers/xen/pciback/conf_space.h ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space.h 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space.h 2008-10-17 11:22:33.000000000 +0200 @@ -59,7 +59,7 @@ struct config_field { struct config_field_entry { struct list_head list; - struct config_field *field; + const struct config_field *field; unsigned int base_offset; void *data; }; @@ -70,17 +70,17 @@ struct config_field_entry { * the first entry in an array (of which the ending is marked by size==0) */ int pciback_config_add_field_offset(struct pci_dev *dev, - struct config_field *field, + const struct config_field *field, unsigned int offset); static inline int pciback_config_add_field(struct pci_dev *dev, - struct config_field *field) + const struct config_field *field) { return pciback_config_add_field_offset(dev, field, 0); } static inline int pciback_config_add_fields(struct pci_dev *dev, - struct config_field *field) + const struct config_field *field) { int i, err = 0; for (i = 0; field[i].size != 0; i++) { @@ -92,7 +92,7 @@ static inline int pciback_config_add_fie } static inline int pciback_config_add_fields_offset(struct pci_dev *dev, - struct config_field *field, + const struct config_field *field, unsigned int offset) { int i, err = 0; Index: head-2008-10-14/drivers/xen/pciback/conf_space_capability.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space_capability.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space_capability.c 2008-10-17 11:14:51.000000000 +0200 @@ -13,16 +13,14 @@ static LIST_HEAD(capabilities); -static struct config_field caplist_header[] = { +static const struct config_field caplist_header[] = { { .offset = PCI_CAP_LIST_ID, .size = 2, /* encompass PCI_CAP_LIST_ID & PCI_CAP_LIST_NEXT */ .u.w.read = pciback_read_config_word, .u.w.write = NULL, }, - { - .size = 0, - }, + {} }; static inline void register_capability(struct pciback_config_capability *cap) Index: head-2008-10-14/drivers/xen/pciback/conf_space_capability.h ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space_capability.h 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space_capability.h 2008-10-17 11:16:15.000000000 +0200 @@ -17,7 +17,7 @@ struct pciback_config_capability { int capability; /* If the device has the capability found above, add these fields */ - struct config_field *fields; + const struct config_field *fields; }; #endif Index: head-2008-10-14/drivers/xen/pciback/conf_space_capability_pm.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space_capability_pm.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space_capability_pm.c 2008-10-17 11:16:49.000000000 +0200 @@ -94,7 +94,7 @@ static void *pm_ctrl_init(struct pci_dev return ERR_PTR(err); } -static struct config_field caplist_pm[] = { +static const struct config_field caplist_pm[] = { { .offset = PCI_PM_PMC, .size = 2, @@ -117,9 +117,7 @@ static struct config_field caplist_pm[] .size = 1, .u.b.read = pciback_read_config_byte, }, - { - .size = 0, - }, + {} }; struct pciback_config_capability pciback_config_capability_pm = { Index: head-2008-10-14/drivers/xen/pciback/conf_space_capability_vpd.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space_capability_vpd.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space_capability_vpd.c 2008-10-17 11:16:35.000000000 +0200 @@ -18,7 +18,7 @@ static int vpd_address_write(struct pci_ return pci_write_config_word(dev, offset, value); } -static struct config_field caplist_vpd[] = { +static const struct config_field caplist_vpd[] = { { .offset = PCI_VPD_ADDR, .size = 2, @@ -31,9 +31,7 @@ static struct config_field caplist_vpd[] .u.dw.read = pciback_read_config_dword, .u.dw.write = NULL, }, - { - .size = 0, - }, + {} }; struct pciback_config_capability pciback_config_capability_vpd = { Index: head-2008-10-14/drivers/xen/pciback/conf_space_header.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/conf_space_header.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/conf_space_header.c 2008-10-17 11:15:22.000000000 +0200 @@ -210,7 +210,7 @@ static int bist_write(struct pci_dev *de return err; } -static struct config_field header_common[] = { +static const struct config_field header_common[] = { { .offset = PCI_COMMAND, .size = 2, @@ -245,9 +245,7 @@ static struct config_field header_common .u.b.read = pciback_read_config_byte, .u.b.write = bist_write, }, - { - .size = 0, - }, + {} }; #define CFG_FIELD_BAR(reg_offset) \ @@ -272,7 +270,7 @@ static struct config_field header_common .u.dw.write = rom_write, \ } -static struct config_field header_0[] = { +static const struct config_field header_0[] = { CFG_FIELD_BAR(PCI_BASE_ADDRESS_0), CFG_FIELD_BAR(PCI_BASE_ADDRESS_1), CFG_FIELD_BAR(PCI_BASE_ADDRESS_2), @@ -280,18 +278,14 @@ static struct config_field header_0[] = CFG_FIELD_BAR(PCI_BASE_ADDRESS_4), CFG_FIELD_BAR(PCI_BASE_ADDRESS_5), CFG_FIELD_ROM(PCI_ROM_ADDRESS), - { - .size = 0, - }, + {} }; -static struct config_field header_1[] = { +static const struct config_field header_1[] = { CFG_FIELD_BAR(PCI_BASE_ADDRESS_0), CFG_FIELD_BAR(PCI_BASE_ADDRESS_1), CFG_FIELD_ROM(PCI_ROM_ADDRESS1), - { - .size = 0, - }, + {} }; int pciback_config_header_add_fields(struct pci_dev *dev) Index: head-2008-10-14/drivers/xen/pciback/pci_stub.c ==================================================================--- head-2008-10-14.orig/drivers/xen/pciback/pci_stub.c 2008-10-17 12:20:11.000000000 +0200 +++ head-2008-10-14/drivers/xen/pciback/pci_stub.c 2008-10-17 11:12:50.000000000 +0200 @@ -467,7 +467,7 @@ static void pcistub_remove(struct pci_de } } -static struct pci_device_id pcistub_ids[] = { +static const struct pci_device_id pcistub_ids[] = { { .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, @@ -700,8 +700,8 @@ static ssize_t pcistub_quirk_show(struct extern struct list_head pciback_quirks; struct pciback_config_quirk *quirk; struct pciback_dev_data *dev_data; - struct config_field *field; - struct config_field_entry *cfg_entry; + const struct config_field *field; + const struct config_field_entry *cfg_entry; spin_lock_irqsave(&device_ids_lock, flags); list_for_each_entry(quirk, &pciback_quirks, quirks_list) { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel