diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-06-16 05:21:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-16 05:21:27 -0400 |
commit | 688d22e23ab1caacb2c36c615854294b58f2ea47 (patch) | |
tree | 95c8163c0b1f56902f5537bc256d7e5507f56cee /drivers/lguest | |
parent | 7e0edc1bc343231029084761ebf59e522902eb49 (diff) | |
parent | 066519068ad2fbe98c7f45552b1f592903a9c8c8 (diff) |
Merge branch 'linus' into x86/xen
Diffstat (limited to 'drivers/lguest')
-rw-r--r-- | drivers/lguest/lguest_device.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 8080249957af..1a8de57289eb 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -20,14 +20,11 @@ | |||
20 | /* The pointer to our (page) of device descriptions. */ | 20 | /* The pointer to our (page) of device descriptions. */ |
21 | static void *lguest_devices; | 21 | static void *lguest_devices; |
22 | 22 | ||
23 | /* Unique numbering for lguest devices. */ | ||
24 | static unsigned int dev_index; | ||
25 | |||
26 | /* For Guests, device memory can be used as normal memory, so we cast away the | 23 | /* For Guests, device memory can be used as normal memory, so we cast away the |
27 | * __iomem to quieten sparse. */ | 24 | * __iomem to quieten sparse. */ |
28 | static inline void *lguest_map(unsigned long phys_addr, unsigned long pages) | 25 | static inline void *lguest_map(unsigned long phys_addr, unsigned long pages) |
29 | { | 26 | { |
30 | return (__force void *)ioremap(phys_addr, PAGE_SIZE*pages); | 27 | return (__force void *)ioremap_cache(phys_addr, PAGE_SIZE*pages); |
31 | } | 28 | } |
32 | 29 | ||
33 | static inline void lguest_unmap(void *addr) | 30 | static inline void lguest_unmap(void *addr) |
@@ -325,8 +322,10 @@ static struct device lguest_root = { | |||
325 | * As Andrew Tridgell says, "Untested code is buggy code". | 322 | * As Andrew Tridgell says, "Untested code is buggy code". |
326 | * | 323 | * |
327 | * It's worth reading this carefully: we start with a pointer to the new device | 324 | * It's worth reading this carefully: we start with a pointer to the new device |
328 | * descriptor in the "lguest_devices" page. */ | 325 | * descriptor in the "lguest_devices" page, and the offset into the device |
329 | static void add_lguest_device(struct lguest_device_desc *d) | 326 | * descriptor page so we can uniquely identify it if things go badly wrong. */ |
327 | static void add_lguest_device(struct lguest_device_desc *d, | ||
328 | unsigned int offset) | ||
330 | { | 329 | { |
331 | struct lguest_device *ldev; | 330 | struct lguest_device *ldev; |
332 | 331 | ||
@@ -334,18 +333,14 @@ static void add_lguest_device(struct lguest_device_desc *d) | |||
334 | * it. */ | 333 | * it. */ |
335 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); | 334 | ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); |
336 | if (!ldev) { | 335 | if (!ldev) { |
337 | printk(KERN_EMERG "Cannot allocate lguest dev %u\n", | 336 | printk(KERN_EMERG "Cannot allocate lguest dev %u type %u\n", |
338 | dev_index++); | 337 | offset, d->type); |
339 | return; | 338 | return; |
340 | } | 339 | } |
341 | 340 | ||
342 | /* This devices' parent is the lguest/ dir. */ | 341 | /* This devices' parent is the lguest/ dir. */ |
343 | ldev->vdev.dev.parent = &lguest_root; | 342 | ldev->vdev.dev.parent = &lguest_root; |
344 | /* We have a unique device index thanks to the dev_index counter. */ | 343 | /* We have a unique device index thanks to the dev_index counter. */ |
345 | ldev->vdev.index = dev_index++; | ||
346 | /* The device type comes straight from the descriptor. There's also a | ||
347 | * device vendor field in the virtio_device struct, which we leave as | ||
348 | * 0. */ | ||
349 | ldev->vdev.id.device = d->type; | 344 | ldev->vdev.id.device = d->type; |
350 | /* We have a simple set of routines for querying the device's | 345 | /* We have a simple set of routines for querying the device's |
351 | * configuration information and setting its status. */ | 346 | * configuration information and setting its status. */ |
@@ -357,8 +352,8 @@ static void add_lguest_device(struct lguest_device_desc *d) | |||
357 | * virtio_device and calls device_register(). This makes the bus | 352 | * virtio_device and calls device_register(). This makes the bus |
358 | * infrastructure look for a matching driver. */ | 353 | * infrastructure look for a matching driver. */ |
359 | if (register_virtio_device(&ldev->vdev) != 0) { | 354 | if (register_virtio_device(&ldev->vdev) != 0) { |
360 | printk(KERN_ERR "Failed to register lguest device %u\n", | 355 | printk(KERN_ERR "Failed to register lguest dev %u type %u\n", |
361 | ldev->vdev.index); | 356 | offset, d->type); |
362 | kfree(ldev); | 357 | kfree(ldev); |
363 | } | 358 | } |
364 | } | 359 | } |
@@ -379,7 +374,7 @@ static void scan_devices(void) | |||
379 | break; | 374 | break; |
380 | 375 | ||
381 | printk("Device at %i has size %u\n", i, desc_size(d)); | 376 | printk("Device at %i has size %u\n", i, desc_size(d)); |
382 | add_lguest_device(d); | 377 | add_lguest_device(d, i); |
383 | } | 378 | } |
384 | } | 379 | } |
385 | 380 | ||