aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xen-pciback/conf_space_header.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 19:40:51 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 20:58:35 -0400
commita92336a1176b2119eaa990a1e8bf3109665fdbc6 (patch)
treeaf8ac49b47136acddb5320b9a62be2361bfaf99c /drivers/xen/xen-pciback/conf_space_header.c
parentc288b67b9b4d65790e1a1a1fd982330730b68f46 (diff)
xen/pciback: Drop two backends, squash and cleanup some code.
- Remove the slot and controller controller backend as they are not used. - Document the find pciback_[read|write]_config_[byte|word|dword] to make it easier to find. - Collapse the code from conf_space_capability_msi into pciback_ops.c - Collapse conf_space_capability_[pm|vpd].c in conf_space_capability.c [and remove the conf_space_capability.h file] - Rename all visible functions from pciback to xen_pcibk. - Rename all the printk/pr_info, etc that use the "pciback" to say "xen-pciback". - Convert functions that are not referenced outside the code to be static to save on name space. - Do the same thing for structures that are internal to the driver. - Run checkpatch.pl after the renames and fixup its warnings and fix any compile errors caused by the variable rename - Cleanup any structs that checkpath.pl commented about or just look odd. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/xen-pciback/conf_space_header.c')
-rw-r--r--drivers/xen/xen-pciback/conf_space_header.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c
index 22ad0f560669..da3cbdfcb5dc 100644
--- a/drivers/xen/xen-pciback/conf_space_header.c
+++ b/drivers/xen/xen-pciback/conf_space_header.c
@@ -15,6 +15,7 @@ struct pci_bar_info {
15 int which; 15 int which;
16}; 16};
17 17
18#define DRV_NAME "xen-pciback"
18#define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO)) 19#define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO))
19#define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER) 20#define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER)
20 21
@@ -23,7 +24,7 @@ static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)
23 int i; 24 int i;
24 int ret; 25 int ret;
25 26
26 ret = pciback_read_config_word(dev, offset, value, data); 27 ret = xen_pcibk_read_config_word(dev, offset, value, data);
27 if (!atomic_read(&dev->enable_cnt)) 28 if (!atomic_read(&dev->enable_cnt))
28 return ret; 29 return ret;
29 30
@@ -39,13 +40,13 @@ static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)
39 40
40static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) 41static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
41{ 42{
42 struct pciback_dev_data *dev_data; 43 struct xen_pcibk_dev_data *dev_data;
43 int err; 44 int err;
44 45
45 dev_data = pci_get_drvdata(dev); 46 dev_data = pci_get_drvdata(dev);
46 if (!pci_is_enabled(dev) && is_enable_cmd(value)) { 47 if (!pci_is_enabled(dev) && is_enable_cmd(value)) {
47 if (unlikely(verbose_request)) 48 if (unlikely(verbose_request))
48 printk(KERN_DEBUG "pciback: %s: enable\n", 49 printk(KERN_DEBUG DRV_NAME ": %s: enable\n",
49 pci_name(dev)); 50 pci_name(dev));
50 err = pci_enable_device(dev); 51 err = pci_enable_device(dev);
51 if (err) 52 if (err)
@@ -54,7 +55,7 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
54 dev_data->enable_intx = 1; 55 dev_data->enable_intx = 1;
55 } else if (pci_is_enabled(dev) && !is_enable_cmd(value)) { 56 } else if (pci_is_enabled(dev) && !is_enable_cmd(value)) {
56 if (unlikely(verbose_request)) 57 if (unlikely(verbose_request))
57 printk(KERN_DEBUG "pciback: %s: disable\n", 58 printk(KERN_DEBUG DRV_NAME ": %s: disable\n",
58 pci_name(dev)); 59 pci_name(dev));
59 pci_disable_device(dev); 60 pci_disable_device(dev);
60 if (dev_data) 61 if (dev_data)
@@ -63,7 +64,7 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
63 64
64 if (!dev->is_busmaster && is_master_cmd(value)) { 65 if (!dev->is_busmaster && is_master_cmd(value)) {
65 if (unlikely(verbose_request)) 66 if (unlikely(verbose_request))
66 printk(KERN_DEBUG "pciback: %s: set bus master\n", 67 printk(KERN_DEBUG DRV_NAME ": %s: set bus master\n",
67 pci_name(dev)); 68 pci_name(dev));
68 pci_set_master(dev); 69 pci_set_master(dev);
69 } 70 }
@@ -71,12 +72,12 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
71 if (value & PCI_COMMAND_INVALIDATE) { 72 if (value & PCI_COMMAND_INVALIDATE) {
72 if (unlikely(verbose_request)) 73 if (unlikely(verbose_request))
73 printk(KERN_DEBUG 74 printk(KERN_DEBUG
74 "pciback: %s: enable memory-write-invalidate\n", 75 DRV_NAME ": %s: enable memory-write-invalidate\n",
75 pci_name(dev)); 76 pci_name(dev));
76 err = pci_set_mwi(dev); 77 err = pci_set_mwi(dev);
77 if (err) { 78 if (err) {
78 printk(KERN_WARNING 79 printk(KERN_WARNING
79 "pciback: %s: cannot enable " 80 DRV_NAME ": %s: cannot enable "
80 "memory-write-invalidate (%d)\n", 81 "memory-write-invalidate (%d)\n",
81 pci_name(dev), err); 82 pci_name(dev), err);
82 value &= ~PCI_COMMAND_INVALIDATE; 83 value &= ~PCI_COMMAND_INVALIDATE;
@@ -91,7 +92,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
91 struct pci_bar_info *bar = data; 92 struct pci_bar_info *bar = data;
92 93
93 if (unlikely(!bar)) { 94 if (unlikely(!bar)) {
94 printk(KERN_WARNING "pciback: driver data not found for %s\n", 95 printk(KERN_WARNING DRV_NAME ": driver data not found for %s\n",
95 pci_name(dev)); 96 pci_name(dev));
96 return XEN_PCI_ERR_op_failed; 97 return XEN_PCI_ERR_op_failed;
97 } 98 }
@@ -125,7 +126,7 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
125 struct pci_bar_info *bar = data; 126 struct pci_bar_info *bar = data;
126 127
127 if (unlikely(!bar)) { 128 if (unlikely(!bar)) {
128 printk(KERN_WARNING "pciback: driver data not found for %s\n", 129 printk(KERN_WARNING DRV_NAME ": driver data not found for %s\n",
129 pci_name(dev)); 130 pci_name(dev));
130 return XEN_PCI_ERR_op_failed; 131 return XEN_PCI_ERR_op_failed;
131 } 132 }
@@ -153,7 +154,7 @@ static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
153 struct pci_bar_info *bar = data; 154 struct pci_bar_info *bar = data;
154 155
155 if (unlikely(!bar)) { 156 if (unlikely(!bar)) {
156 printk(KERN_WARNING "pciback: driver data not found for %s\n", 157 printk(KERN_WARNING DRV_NAME ": driver data not found for %s\n",
157 pci_name(dev)); 158 pci_name(dev));
158 return XEN_PCI_ERR_op_failed; 159 return XEN_PCI_ERR_op_failed;
159 } 160 }
@@ -227,7 +228,7 @@ static void bar_release(struct pci_dev *dev, int offset, void *data)
227 kfree(data); 228 kfree(data);
228} 229}
229 230
230static int pciback_read_vendor(struct pci_dev *dev, int offset, 231static int xen_pcibk_read_vendor(struct pci_dev *dev, int offset,
231 u16 *value, void *data) 232 u16 *value, void *data)
232{ 233{
233 *value = dev->vendor; 234 *value = dev->vendor;
@@ -235,7 +236,7 @@ static int pciback_read_vendor(struct pci_dev *dev, int offset,
235 return 0; 236 return 0;
236} 237}
237 238
238static int pciback_read_device(struct pci_dev *dev, int offset, 239static int xen_pcibk_read_device(struct pci_dev *dev, int offset,
239 u16 *value, void *data) 240 u16 *value, void *data)
240{ 241{
241 *value = dev->device; 242 *value = dev->device;
@@ -272,12 +273,12 @@ static const struct config_field header_common[] = {
272 { 273 {
273 .offset = PCI_VENDOR_ID, 274 .offset = PCI_VENDOR_ID,
274 .size = 2, 275 .size = 2,
275 .u.w.read = pciback_read_vendor, 276 .u.w.read = xen_pcibk_read_vendor,
276 }, 277 },
277 { 278 {
278 .offset = PCI_DEVICE_ID, 279 .offset = PCI_DEVICE_ID,
279 .size = 2, 280 .size = 2,
280 .u.w.read = pciback_read_device, 281 .u.w.read = xen_pcibk_read_device,
281 }, 282 },
282 { 283 {
283 .offset = PCI_COMMAND, 284 .offset = PCI_COMMAND,
@@ -293,24 +294,24 @@ static const struct config_field header_common[] = {
293 { 294 {
294 .offset = PCI_INTERRUPT_PIN, 295 .offset = PCI_INTERRUPT_PIN,
295 .size = 1, 296 .size = 1,
296 .u.b.read = pciback_read_config_byte, 297 .u.b.read = xen_pcibk_read_config_byte,
297 }, 298 },
298 { 299 {
299 /* Any side effects of letting driver domain control cache line? */ 300 /* Any side effects of letting driver domain control cache line? */
300 .offset = PCI_CACHE_LINE_SIZE, 301 .offset = PCI_CACHE_LINE_SIZE,
301 .size = 1, 302 .size = 1,
302 .u.b.read = pciback_read_config_byte, 303 .u.b.read = xen_pcibk_read_config_byte,
303 .u.b.write = pciback_write_config_byte, 304 .u.b.write = xen_pcibk_write_config_byte,
304 }, 305 },
305 { 306 {
306 .offset = PCI_LATENCY_TIMER, 307 .offset = PCI_LATENCY_TIMER,
307 .size = 1, 308 .size = 1,
308 .u.b.read = pciback_read_config_byte, 309 .u.b.read = xen_pcibk_read_config_byte,
309 }, 310 },
310 { 311 {
311 .offset = PCI_BIST, 312 .offset = PCI_BIST,
312 .size = 1, 313 .size = 1,
313 .u.b.read = pciback_read_config_byte, 314 .u.b.read = xen_pcibk_read_config_byte,
314 .u.b.write = bist_write, 315 .u.b.write = bist_write,
315 }, 316 },
316 {} 317 {}
@@ -356,26 +357,26 @@ static const struct config_field header_1[] = {
356 {} 357 {}
357}; 358};
358 359
359int pciback_config_header_add_fields(struct pci_dev *dev) 360int xen_pcibk_config_header_add_fields(struct pci_dev *dev)
360{ 361{
361 int err; 362 int err;
362 363
363 err = pciback_config_add_fields(dev, header_common); 364 err = xen_pcibk_config_add_fields(dev, header_common);
364 if (err) 365 if (err)
365 goto out; 366 goto out;
366 367
367 switch (dev->hdr_type) { 368 switch (dev->hdr_type) {
368 case PCI_HEADER_TYPE_NORMAL: 369 case PCI_HEADER_TYPE_NORMAL:
369 err = pciback_config_add_fields(dev, header_0); 370 err = xen_pcibk_config_add_fields(dev, header_0);
370 break; 371 break;
371 372
372 case PCI_HEADER_TYPE_BRIDGE: 373 case PCI_HEADER_TYPE_BRIDGE:
373 err = pciback_config_add_fields(dev, header_1); 374 err = xen_pcibk_config_add_fields(dev, header_1);
374 break; 375 break;
375 376
376 default: 377 default:
377 err = -EINVAL; 378 err = -EINVAL;
378 printk(KERN_ERR "pciback: %s: Unsupported header type %d!\n", 379 printk(KERN_ERR DRV_NAME ": %s: Unsupported header type %d!\n",
379 pci_name(dev), dev->hdr_type); 380 pci_name(dev), dev->hdr_type);
380 break; 381 break;
381 } 382 }