GIT 6e530b05007d294884f670eccffe343191796864 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git commit Author: Stefan Richter Date: Sun May 27 23:14:05 2007 +0200 ieee1394: eth1394: revert parent device to that in 2.6.20 After ieee1394 was converted away from class_device like the networking subsystem was already in 2.6.21, eth1394's device may point to the fw-host device as its parent again like in 2.6.20. This affects userspace tools which examine the sysfs representation of eth1394's device. Signed-off-by: Stefan Richter commit d5a161129f6f3c2f1edae82b4ce7596f5bf40ec8 Author: Kay Sievers Date: Fri May 25 11:50:53 2007 +0200 ieee1394: convert ieee1394 from "struct class_device" to "struct device" Here is a straightforward conversion to "struct device". The "struct class_device" will be removed from the kernel. It seems to work fine for me with and without CONFIG_SYSFS_DEPRECATED set. Signed-off-by: Stefan Richter commit dd19a2b36f1d6adbf338e82616a64e41a3b129e9 Author: Stefan Richter Date: Mon May 21 18:52:06 2007 +0200 ieee1394: raw1394: Add ioctl() for 32bit userland on 64bit kernel, amendment Pointed out by Arnd Bergmann: PPC32 aligns this at 64bit, IA32 packs it. A kernel-wide available __compat_u64 which is 4-byte aligned on AMD64 and IA64 would be nicer though. Signed-off-by: Stefan Richter commit 6f32ff40cb6520fad1a56d8a4f583f3028b659b4 Author: Petr Vandrovec Date: Mon May 7 04:14:47 2007 +0200 ieee1394: raw1394: Add ioctl() for 32bit userland on 64bit kernel Add compat_ioctl. Although all structures are more or less same, raw1394_iso_packets got pointer inside, and raw1394_cycle_timer got unwanted padding in the middle. I did not add any translation for ioctls passing array of integers around as integers seem to have same size (32 bits) on all architectures supported by Linux. Signed-off-by: Petr Vandrovec Acked-by: Dan Dennedy Signed-off-by: Stefan Richter (split into 3 patches) commit ad9284c8991590e4094c6f5d93788403141856ad Author: Petr Vandrovec Date: Mon May 7 04:14:47 2007 +0200 ieee1394: raw1394: Fix write() for 32bit userland on 64bit kernel * write(fd, buf, 52) from 32bit app was returning 56. Most of callers did not care, but some (arm registration) did, and anyway it looks bad if request for writing 52 bytes returns 56. And returning sizeof anything in 'int' is not good as well. So all functions now return '0' instead of sizeof(struct raw1394_request) on success, and write() itself provides correct return value (it just returns value it was asked to write on success as raw1394 does not do any partial writes at all). * Related to this was problem that write() could have returned 0 when kernel state would become corrupted and moved to different state than opened/initialized/connected. Now it returns -EBADFD which seemed appropriate. Signed-off-by: Petr Vandrovec Acked-by: Dan Dennedy Signed-off-by: Stefan Richter (split into 3 patches) commit ab9c8ad4b0cecd7445de0cfa1d6bdbd9fa7e8059 Author: Petr Vandrovec Date: Mon May 7 04:14:47 2007 +0200 ieee1394: raw1394: Fix read() for 32bit userland on 64bit kernel read() always failed with -EFAULT. This was happening due to raw1394_compat_read copying data to wrong location - access_ok always failed as 'r' is kernel address, not user. Whole function just tried to copy data from 'r' to 'r', which is not good. Signed-off-by: Petr Vandrovec Acked-by: Dan Dennedy Signed-off-by: Stefan Richter (split into 3 patches) commit d69733136ad1dc6ec31d0b65c2d4eb47de2c668a Author: Stefan Richter Date: Fri May 11 23:04:08 2007 +0200 firewire: fw-sbp2: remove unused struct member cleanup after support of single-buffer requests was dropped Signed-off-by: Stefan Richter Signed-off-by: Kristian Hoegsberg commit 2fc889608b0ab3e920628b4cf4fb18505eec207f Author: Stefan Richter Date: Sat May 19 12:29:37 2007 +0200 ieee1394: add comments in struct hpsb_packet to clarify who is supposed to set what Signed-off-by: Stefan Richter commit 959053f1fe50ac78d88b174a74cb45fcb82f81d7 Author: Stefan Richter Date: Thu May 3 20:24:19 2007 +0200 ieee1394: ohci1394: remove dead CONFIG variable spotted by Robert P. J. Day Signed-off-by: Stefan Richter drivers/firewire/fw-sbp2.c | 6 - drivers/ieee1394/dv1394.c | 8 +- drivers/ieee1394/eth1394.c | 4 - drivers/ieee1394/hosts.c | 10 +- drivers/ieee1394/hosts.h | 2 drivers/ieee1394/ieee1394_core.h | 10 +- drivers/ieee1394/nodemgr.c | 118 ++++++++++++------------ drivers/ieee1394/nodemgr.h | 4 - drivers/ieee1394/ohci1394.c | 51 ++-------- drivers/ieee1394/raw1394.c | 186 +++++++++++++++++++++++++++++--------- drivers/ieee1394/video1394.c | 10 +- 11 files changed, 237 insertions(+), 172 deletions(-) diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index a98d391..25f2aa4 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c @@ -207,7 +207,6 @@ struct sbp2_command_orb { struct sbp2_pointer page_table[SG_ALL]; dma_addr_t page_table_bus; - dma_addr_t request_buffer_bus; }; /* @@ -882,11 +881,6 @@ complete_command_orb(struct sbp2_orb *ba dma_unmap_single(device->card->device, orb->page_table_bus, sizeof(orb->page_table_bus), DMA_TO_DEVICE); - if (orb->request_buffer_bus != 0) - dma_unmap_single(device->card->device, orb->request_buffer_bus, - sizeof(orb->request_buffer_bus), - DMA_FROM_DEVICE); - orb->cmd->result = result; orb->done(orb->cmd); kfree(orb); diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index 2081413..6572211 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -2280,7 +2280,7 @@ static void dv1394_remove_host(struct hp } while (video); if (found_ohci_card) - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2))); } @@ -2295,9 +2295,9 @@ static void dv1394_add_host(struct hpsb_ ohci = (struct ti_ohci *)host->hostdata; - class_device_create(hpsb_protocol_class, NULL, MKDEV( - IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), - NULL, "dv1394-%d", id); + device_create(hpsb_protocol_class, NULL, MKDEV( + IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), + "dv1394-%d", id); dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 5f026b5..2e1f2dd 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -599,9 +599,7 @@ static void ether1394_add_host(struct hp } SET_MODULE_OWNER(dev); - - /* This used to be &host->device in Linux 2.6.20 and before. */ - SET_NETDEV_DEV(dev, host->device.parent); + SET_NETDEV_DEV(dev, &host->device); priv = netdev_priv(dev); INIT_LIST_HEAD(&priv->ip_node_list); diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index bd0755c..7ea64ee 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c @@ -156,13 +156,13 @@ struct hpsb_host *hpsb_alloc_host(struct h->device.parent = dev; snprintf(h->device.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); - h->class_dev.dev = &h->device; - h->class_dev.class = &hpsb_host_class; - snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); + h->host_dev.parent = &h->device; + h->host_dev.class = &hpsb_host_class; + snprintf(h->host_dev.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); if (device_register(&h->device)) goto fail; - if (class_device_register(&h->class_dev)) { + if (device_register(&h->host_dev)) { device_unregister(&h->device); goto fail; } @@ -202,7 +202,7 @@ void hpsb_remove_host(struct hpsb_host * host->driver = &dummy_driver; highlevel_remove_host(host); - class_device_unregister(&host->class_dev); + device_unregister(&host->host_dev); device_unregister(&host->device); } diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h index feb55d0..979fd19 100644 --- a/drivers/ieee1394/hosts.h +++ b/drivers/ieee1394/hosts.h @@ -57,7 +57,7 @@ struct hpsb_host { struct hpsb_host_driver *driver; struct pci_dev *pdev; struct device device; - struct class_device class_dev; + struct device host_dev; struct delayed_work delayed_reset; unsigned config_roms:31; diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h index ad52652..11fd324 100644 --- a/drivers/ieee1394/ieee1394_core.h +++ b/drivers/ieee1394/ieee1394_core.h @@ -37,7 +37,7 @@ struct hpsb_packet { hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete } __attribute__((packed)) state; - /* These are core internal. */ + /* These are core-internal. */ signed char tlabel; signed char ack_code; unsigned char tcode; @@ -62,11 +62,15 @@ struct hpsb_packet { /* Store jiffies for implementing bus timeouts. */ unsigned long sendtime; - /* Sizes are in bytes. *data can be DMA-mapped. */ + /* Core-internal. */ size_t allocated_data_size; /* as allocated */ + + /* Sizes are in bytes. To be set by caller of hpsb_alloc_packet. */ size_t data_size; /* as filled in */ size_t header_size; /* as filled in, not counting the CRC */ - quadlet_t *data; + + /* Buffers */ + quadlet_t *data; /* can be DMA-mapped */ quadlet_t header[5]; quadlet_t embedded_data[0]; /* keep as last member */ }; diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 81b3864..8939552 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -154,7 +154,7 @@ struct host_info { }; static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static void nodemgr_resume_ne(struct node_entry *ne); static void nodemgr_remove_ne(struct node_entry *ne); @@ -165,37 +165,38 @@ struct bus_type ieee1394_bus_type = { .match = nodemgr_bus_match, }; -static void host_cls_release(struct class_device *class_dev) +static void host_cls_release(struct device *dev) { - put_device(&container_of((class_dev), struct hpsb_host, class_dev)->device); + put_device(&container_of((dev), struct hpsb_host, host_dev)->device); } struct class hpsb_host_class = { .name = "ieee1394_host", - .release = host_cls_release, + .dev_release = host_cls_release, }; -static void ne_cls_release(struct class_device *class_dev) +static void ne_cls_release(struct device *dev) { - put_device(&container_of((class_dev), struct node_entry, class_dev)->device); + put_device(&container_of((dev), struct node_entry, node_dev)->device); } static struct class nodemgr_ne_class = { .name = "ieee1394_node", - .release = ne_cls_release, + .dev_release = ne_cls_release, }; -static void ud_cls_release(struct class_device *class_dev) +static void ud_cls_release(struct device *dev) { - put_device(&container_of((class_dev), struct unit_directory, class_dev)->device); + put_device(&container_of((dev), struct unit_directory, unit_dev)->device); } /* The name here is only so that unit directory hotplug works with old - * style hotplug, which only ever did unit directories anyway. */ + * style hotplug, which only ever did unit directories anyway. + */ static struct class nodemgr_ud_class = { .name = "ieee1394", - .release = ud_cls_release, - .uevent = nodemgr_uevent, + .dev_release = ud_cls_release, + .dev_uevent = nodemgr_uevent, }; static struct hpsb_highlevel nodemgr_highlevel; @@ -730,11 +731,11 @@ static DEFINE_MUTEX(nodemgr_serialize_re static void nodemgr_remove_uds(struct node_entry *ne) { - struct class_device *cdev; + struct device *dev; struct unit_directory *tmp, *ud; - /* Iteration over nodemgr_ud_class.children has to be protected by - * nodemgr_ud_class.sem, but class_device_unregister() will eventually + /* Iteration over nodemgr_ud_class.devices has to be protected by + * nodemgr_ud_class.sem, but device_unregister() will eventually * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time, * release the semaphore, and then unregister the ud. Since this code * may be called from other contexts besides the knodemgrds, protect the @@ -744,9 +745,9 @@ static void nodemgr_remove_uds(struct no for (;;) { ud = NULL; down(&nodemgr_ud_class.sem); - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { - tmp = container_of(cdev, struct unit_directory, - class_dev); + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { + tmp = container_of(dev, struct unit_directory, + unit_dev); if (tmp->ne == ne) { ud = tmp; break; @@ -755,7 +756,7 @@ static void nodemgr_remove_uds(struct no up(&nodemgr_ud_class.sem); if (ud == NULL) break; - class_device_unregister(&ud->class_dev); + device_unregister(&ud->unit_dev); device_unregister(&ud->device); } mutex_unlock(&nodemgr_serialize_remove_uds); @@ -772,10 +773,9 @@ static void nodemgr_remove_ne(struct nod HPSB_DEBUG("Node removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); - nodemgr_remove_uds(ne); - class_device_unregister(&ne->class_dev); + device_unregister(&ne->node_dev); device_unregister(dev); put_device(dev); @@ -783,7 +783,9 @@ static void nodemgr_remove_ne(struct nod static int __nodemgr_remove_host_dev(struct device *dev, void *data) { - nodemgr_remove_ne(container_of(dev, struct node_entry, device)); + if (dev->bus == &ieee1394_bus_type) + nodemgr_remove_ne(container_of(dev, struct node_entry, + device)); return 0; } @@ -850,14 +852,14 @@ static struct node_entry *nodemgr_create snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx", (unsigned long long)(ne->guid)); - ne->class_dev.dev = &ne->device; - ne->class_dev.class = &nodemgr_ne_class; - snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", - (unsigned long long)(ne->guid)); + ne->node_dev.parent = &ne->device; + ne->node_dev.class = &nodemgr_ne_class; + snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx", + (unsigned long long)(ne->guid)); if (device_register(&ne->device)) goto fail_devreg; - if (class_device_register(&ne->class_dev)) + if (device_register(&ne->node_dev)) goto fail_classdevreg; get_device(&ne->device); @@ -885,12 +887,12 @@ fail_alloc: static struct node_entry *find_entry_by_guid(u64 guid) { - struct class_device *cdev; + struct device *dev; struct node_entry *ne, *ret_ne = NULL; down(&nodemgr_ne_class.sem); - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { - ne = container_of(cdev, struct node_entry, class_dev); + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { + ne = container_of(dev, struct node_entry, node_dev); if (ne->guid == guid) { ret_ne = ne; @@ -906,12 +908,12 @@ static struct node_entry *find_entry_by_ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid) { - struct class_device *cdev; + struct device *dev; struct node_entry *ne, *ret_ne = NULL; down(&nodemgr_ne_class.sem); - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { - ne = container_of(cdev, struct node_entry, class_dev); + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { + ne = container_of(dev, struct node_entry, node_dev); if (ne->host == host && ne->nodeid == nodeid) { ret_ne = ne; @@ -935,14 +937,14 @@ static void nodemgr_register_device(stru snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u", ne->device.bus_id, ud->id); - ud->class_dev.dev = &ud->device; - ud->class_dev.class = &nodemgr_ud_class; - snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", + ud->unit_dev.parent = &ud->device; + ud->unit_dev.class = &nodemgr_ud_class; + snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u", ne->device.bus_id, ud->id); if (device_register(&ud->device)) goto fail_devreg; - if (class_device_register(&ud->class_dev)) + if (device_register(&ud->unit_dev)) goto fail_classdevreg; get_device(&ud->device); @@ -1159,7 +1161,7 @@ static void nodemgr_process_root_directo #ifdef CONFIG_HOTPLUG -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct unit_directory *ud; @@ -1169,10 +1171,10 @@ static int nodemgr_uevent(struct class_d /* ieee1394:venNmoNspNverN */ char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; - if (!cdev) + if (!dev) return -ENODEV; - ud = container_of(cdev, struct unit_directory, class_dev); + ud = container_of(dev, struct unit_directory, unit_dev); if (ud->ne->in_limbo || ud->ignore_driver) return -ENODEV; @@ -1207,7 +1209,7 @@ #undef PUT_ENVP #else -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return -ENODEV; @@ -1378,7 +1380,7 @@ static void nodemgr_node_scan(struct hos static void nodemgr_suspend_ne(struct node_entry *ne) { - struct class_device *cdev; + struct device *dev; struct unit_directory *ud; HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", @@ -1388,8 +1390,8 @@ static void nodemgr_suspend_ne(struct no WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); down(&nodemgr_ud_class.sem); - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { - ud = container_of(cdev, struct unit_directory, class_dev); + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { + ud = container_of(dev, struct unit_directory, unit_dev); if (ud->ne != ne) continue; @@ -1404,15 +1406,15 @@ static void nodemgr_suspend_ne(struct no static void nodemgr_resume_ne(struct node_entry *ne) { - struct class_device *cdev; + struct device *dev; struct unit_directory *ud; ne->in_limbo = 0; device_remove_file(&ne->device, &dev_attr_ne_in_limbo); down(&nodemgr_ud_class.sem); - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { - ud = container_of(cdev, struct unit_directory, class_dev); + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { + ud = container_of(dev, struct unit_directory, unit_dev); if (ud->ne != ne) continue; @@ -1430,11 +1432,11 @@ static void nodemgr_update_pdrv(struct n { struct unit_directory *ud; struct hpsb_protocol_driver *pdrv; - struct class_device *cdev; + struct device *dev; down(&nodemgr_ud_class.sem); - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { - ud = container_of(cdev, struct unit_directory, class_dev); + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { + ud = container_of(dev, struct unit_directory, unit_dev); if (ud->ne != ne) continue; @@ -1509,7 +1511,7 @@ static void nodemgr_probe_ne(struct host static void nodemgr_node_probe(struct host_info *hi, int generation) { struct hpsb_host *host = hi->host; - struct class_device *cdev; + struct device *dev; struct node_entry *ne; /* Do some processing of the nodes we've probed. This pulls them @@ -1522,13 +1524,13 @@ static void nodemgr_node_probe(struct ho * improvement...) */ down(&nodemgr_ne_class.sem); - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { - ne = container_of(cdev, struct node_entry, class_dev); + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { + ne = container_of(dev, struct node_entry, node_dev); if (!ne->needs_probe) nodemgr_probe_ne(hi, ne, generation); } - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { - ne = container_of(cdev, struct node_entry, class_dev); + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { + ne = container_of(dev, struct node_entry, node_dev); if (ne->needs_probe) nodemgr_probe_ne(hi, ne, generation); } @@ -1756,13 +1758,13 @@ exit: */ int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) { - struct class_device *cdev; + struct device *dev; struct hpsb_host *host; int error = 0; down(&hpsb_host_class.sem); - list_for_each_entry(cdev, &hpsb_host_class.children, node) { - host = container_of(cdev, struct hpsb_host, class_dev); + list_for_each_entry(dev, &hpsb_host_class.devices, node) { + host = container_of(dev, struct hpsb_host, host_dev); if ((error = cb(host, data))) break; diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h index 4530b29..919e92e 100644 --- a/drivers/ieee1394/nodemgr.h +++ b/drivers/ieee1394/nodemgr.h @@ -84,7 +84,7 @@ struct unit_directory { int length; /* Number of quadlets */ struct device device; - struct class_device class_dev; + struct device unit_dev; struct csr1212_keyval *ud_kv; u32 lun; /* logical unit number immediate value */ @@ -107,7 +107,7 @@ struct node_entry { u32 capabilities; struct device device; - struct class_device class_dev; + struct device node_dev; /* Means this node is not attached anymore */ int in_limbo; diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 5dadfd2..a75b144 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -138,19 +138,6 @@ #else #define DBGMSG(fmt, args...) do {} while (0) #endif -#ifdef CONFIG_IEEE1394_OHCI_DMA_DEBUG -#define OHCI_DMA_ALLOC(fmt, args...) \ - HPSB_ERR("%s(%s)alloc(%d): "fmt, OHCI1394_DRIVER_NAME, __FUNCTION__, \ - ++global_outstanding_dmas, ## args) -#define OHCI_DMA_FREE(fmt, args...) \ - HPSB_ERR("%s(%s)free(%d): "fmt, OHCI1394_DRIVER_NAME, __FUNCTION__, \ - --global_outstanding_dmas, ## args) -static int global_outstanding_dmas = 0; -#else -#define OHCI_DMA_ALLOC(fmt, args...) do {} while (0) -#define OHCI_DMA_FREE(fmt, args...) do {} while (0) -#endif - /* print general (card independent) information */ #define PRINT_G(level, fmt, args...) \ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args) @@ -733,7 +720,6 @@ #endif pci_map_single(ohci->dev, packet->data, packet->data_size, PCI_DMA_TODEVICE)); - OHCI_DMA_ALLOC("single, block transmit packet"); d->prg_cpu[idx]->end.branchAddress = 0; d->prg_cpu[idx]->end.status = 0; @@ -783,7 +769,6 @@ #endif d->prg_cpu[idx]->end.address = cpu_to_le32( pci_map_single(ohci->dev, packet->data, packet->data_size, PCI_DMA_TODEVICE)); - OHCI_DMA_ALLOC("single, iso transmit packet"); d->prg_cpu[idx]->end.branchAddress = 0; d->prg_cpu[idx]->end.status = 0; @@ -2869,12 +2854,10 @@ #endif list_del_init(&packet->driver_list); hpsb_packet_sent(ohci->host, packet, ack); - if (datasize) { + if (datasize) pci_unmap_single(ohci->dev, cpu_to_le32(d->prg_cpu[d->sent_ind]->end.address), datasize, PCI_DMA_TODEVICE); - OHCI_DMA_FREE("single Xmit data packet"); - } d->sent_ind = (d->sent_ind+1)%d->num_desc; d->free_prgs++; @@ -2913,23 +2896,19 @@ static void free_dma_rcv_ctx(struct dma_ if (d->buf_cpu) { for (i=0; inum_desc; i++) - if (d->buf_cpu[i] && d->buf_bus[i]) { + if (d->buf_cpu[i] && d->buf_bus[i]) pci_free_consistent( ohci->dev, d->buf_size, d->buf_cpu[i], d->buf_bus[i]); - OHCI_DMA_FREE("consistent dma_rcv buf[%d]", i); - } kfree(d->buf_cpu); kfree(d->buf_bus); } if (d->prg_cpu) { for (i=0; inum_desc; i++) - if (d->prg_cpu[i] && d->prg_bus[i]) { - pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); - OHCI_DMA_FREE("consistent dma_rcv prg[%d]", i); - } + if (d->prg_cpu[i] && d->prg_bus[i]) + pci_pool_free(d->prg_pool, d->prg_cpu[i], + d->prg_bus[i]); pci_pool_destroy(d->prg_pool); - OHCI_DMA_FREE("dma_rcv prg pool"); kfree(d->prg_cpu); kfree(d->prg_bus); } @@ -2998,13 +2977,10 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, } num_allocs++; - OHCI_DMA_ALLOC("dma_rcv prg pool"); - for (i=0; inum_desc; i++) { d->buf_cpu[i] = pci_alloc_consistent(ohci->dev, d->buf_size, d->buf_bus+i); - OHCI_DMA_ALLOC("consistent dma_rcv buf[%d]", i); if (d->buf_cpu[i] != NULL) { memset(d->buf_cpu[i], 0, d->buf_size); @@ -3016,7 +2992,6 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, } d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i); - OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i); if (d->prg_cpu[i] != NULL) { memset(d->prg_cpu[i], 0, sizeof(struct dma_cmd)); @@ -3057,12 +3032,10 @@ static void free_dma_trm_ctx(struct dma_ if (d->prg_cpu) { for (i=0; inum_desc; i++) - if (d->prg_cpu[i] && d->prg_bus[i]) { - pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); - OHCI_DMA_FREE("pool dma_trm prg[%d]", i); - } + if (d->prg_cpu[i] && d->prg_bus[i]) + pci_pool_free(d->prg_pool, d->prg_cpu[i], + d->prg_bus[i]); pci_pool_destroy(d->prg_pool); - OHCI_DMA_FREE("dma_trm prg pool"); kfree(d->prg_cpu); kfree(d->prg_bus); } @@ -3108,11 +3081,8 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, } num_allocs++; - OHCI_DMA_ALLOC("dma_rcv prg pool"); - for (i = 0; i < d->num_desc; i++) { d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i); - OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i); if (d->prg_cpu[i] != NULL) { memset(d->prg_cpu[i], 0, sizeof(struct at_dma_prg)); @@ -3294,7 +3264,6 @@ #endif ohci->csr_config_rom_cpu = pci_alloc_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN, &ohci->csr_config_rom_bus); - OHCI_DMA_ALLOC("consistent csr_config_rom"); if (ohci->csr_config_rom_cpu == NULL) FAIL(-ENOMEM, "Failed to allocate buffer config rom"); ohci->init_state = OHCI_INIT_HAVE_CONFIG_ROM_BUFFER; @@ -3303,8 +3272,6 @@ #endif ohci->selfid_buf_cpu = pci_alloc_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE, &ohci->selfid_buf_bus); - OHCI_DMA_ALLOC("consistent selfid_buf"); - if (ohci->selfid_buf_cpu == NULL) FAIL(-ENOMEM, "Failed to allocate DMA buffer for self-id packets"); ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER; @@ -3490,13 +3457,11 @@ static void ohci1394_pci_remove(struct p pci_free_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE, ohci->selfid_buf_cpu, ohci->selfid_buf_bus); - OHCI_DMA_FREE("consistent selfid_buf"); case OHCI_INIT_HAVE_CONFIG_ROM_BUFFER: pci_free_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN, ohci->csr_config_rom_cpu, ohci->csr_config_rom_bus); - OHCI_DMA_FREE("consistent csr_config_rom"); case OHCI_INIT_HAVE_IOMAPPING: iounmap(ohci->registers); diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index f1d05ee..5958e12 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -459,7 +459,7 @@ #define P(x) __put_user(r->x, &cr->x) static int raw1394_compat_read(const char __user *buf, struct raw1394_request *r) { - struct compat_raw1394_req __user *cr = (typeof(cr)) r; + struct compat_raw1394_req __user *cr = (typeof(cr)) buf; if (!access_ok(VERIFY_WRITE, cr, sizeof(struct compat_raw1394_req)) || P(type) || P(error) || @@ -587,7 +587,7 @@ static int state_opened(struct file_info req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } static int state_initialized(struct file_info *fi, struct pending_request *req) @@ -601,7 +601,7 @@ static int state_initialized(struct file req->req.generation = atomic_read(&internal_generation); req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } switch (req->req.type) { @@ -673,7 +673,7 @@ out_set_card: } queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } static void handle_iso_listen(struct file_info *fi, struct pending_request *req) @@ -865,7 +865,7 @@ static int handle_async_request(struct f if (req->req.error) { req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } hpsb_set_packet_complete_task(packet, @@ -883,7 +883,7 @@ static int handle_async_request(struct f hpsb_free_tlabel(packet); queue_complete_req(req); } - return sizeof(struct raw1394_request); + return 0; } static int handle_iso_send(struct file_info *fi, struct pending_request *req, @@ -907,7 +907,7 @@ static int handle_iso_send(struct file_i req->req.error = RAW1394_ERROR_MEMFAULT; req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } req->req.length = 0; @@ -927,7 +927,7 @@ static int handle_iso_send(struct file_i queue_complete_req(req); } - return sizeof(struct raw1394_request); + return 0; } static int handle_async_send(struct file_info *fi, struct pending_request *req) @@ -943,7 +943,7 @@ static int handle_async_send(struct file req->req.error = RAW1394_ERROR_INVALID_ARG; req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } data_size = req->req.length - header_length; @@ -957,7 +957,7 @@ static int handle_async_send(struct file req->req.error = RAW1394_ERROR_MEMFAULT; req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } if (copy_from_user @@ -966,7 +966,7 @@ static int handle_async_send(struct file req->req.error = RAW1394_ERROR_MEMFAULT; req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } packet->type = hpsb_async; @@ -994,7 +994,7 @@ static int handle_async_send(struct file queue_complete_req(req); } - return sizeof(struct raw1394_request); + return 0; } static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer, @@ -1869,7 +1869,7 @@ static int arm_register(struct file_info spin_lock_irqsave(&host_info_lock, flags); list_add_tail(&addr->addr_list, &fi->addr_list); spin_unlock_irqrestore(&host_info_lock, flags); - return sizeof(struct raw1394_request); + return 0; } retval = hpsb_register_addrspace(&raw1394_highlevel, fi->host, &arm_ops, @@ -1887,7 +1887,7 @@ static int arm_register(struct file_info return (-EALREADY); } free_pending_request(req); /* immediate success or fail */ - return sizeof(struct raw1394_request); + return 0; } static int arm_unregister(struct file_info *fi, struct pending_request *req) @@ -1955,7 +1955,7 @@ static int arm_unregister(struct file_in vfree(addr->addr_space_buffer); kfree(addr); free_pending_request(req); /* immediate success or fail */ - return sizeof(struct raw1394_request); + return 0; } retval = hpsb_unregister_addrspace(&raw1394_highlevel, fi->host, @@ -1971,7 +1971,7 @@ static int arm_unregister(struct file_in vfree(addr->addr_space_buffer); kfree(addr); free_pending_request(req); /* immediate success or fail */ - return sizeof(struct raw1394_request); + return 0; } /* Copy data from ARM buffer(s) to user buffer. */ @@ -2013,7 +2013,7 @@ static int arm_get_buf(struct file_info * queue no response, and therefore nobody * will free it. */ free_pending_request(req); - return sizeof(struct raw1394_request); + return 0; } else { DBGMSG("arm_get_buf request exceeded mapping"); spin_unlock_irqrestore(&host_info_lock, flags); @@ -2065,7 +2065,7 @@ static int arm_set_buf(struct file_info * queue no response, and therefore nobody * will free it. */ free_pending_request(req); - return sizeof(struct raw1394_request); + return 0; } else { DBGMSG("arm_set_buf request exceeded mapping"); spin_unlock_irqrestore(&host_info_lock, flags); @@ -2086,7 +2086,7 @@ static int reset_notification(struct fil (req->req.misc == RAW1394_NOTIFY_ON)) { fi->notification = (u8) req->req.misc; free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */ - return sizeof(struct raw1394_request); + return 0; } /* error EINVAL (22) invalid argument */ return (-EINVAL); @@ -2119,12 +2119,12 @@ static int write_phypacket(struct file_i req->req.length = 0; queue_complete_req(req); } - return sizeof(struct raw1394_request); + return 0; } static int get_config_rom(struct file_info *fi, struct pending_request *req) { - int ret = sizeof(struct raw1394_request); + int ret = 0; quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL); int status; @@ -2154,7 +2154,7 @@ static int get_config_rom(struct file_in static int update_config_rom(struct file_info *fi, struct pending_request *req) { - int ret = sizeof(struct raw1394_request); + int ret = 0; quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL); if (!data) return -ENOMEM; @@ -2221,7 +2221,7 @@ static int modify_config_rom(struct file hpsb_update_config_rom_image(fi->host); free_pending_request(req); - return sizeof(struct raw1394_request); + return 0; } } @@ -2286,7 +2286,7 @@ static int modify_config_rom(struct file /* we have to free the request, because we queue no response, * and therefore nobody will free it */ free_pending_request(req); - return sizeof(struct raw1394_request); + return 0; } else { for (dentry = fi->csr1212_dirs[dr]->value.directory.dentries_head; @@ -2311,7 +2311,7 @@ static int state_connected(struct file_i case RAW1394_REQ_ECHO: queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; case RAW1394_REQ_ISO_SEND: print_old_iso_deprecation(); @@ -2335,24 +2335,24 @@ static int state_connected(struct file_i case RAW1394_REQ_ISO_LISTEN: print_old_iso_deprecation(); handle_iso_listen(fi, req); - return sizeof(struct raw1394_request); + return 0; case RAW1394_REQ_FCP_LISTEN: handle_fcp_listen(fi, req); - return sizeof(struct raw1394_request); + return 0; case RAW1394_REQ_RESET_BUS: if (req->req.misc == RAW1394_LONG_RESET) { DBGMSG("busreset called (type: LONG)"); hpsb_reset_bus(fi->host, LONG_RESET); free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */ - return sizeof(struct raw1394_request); + return 0; } if (req->req.misc == RAW1394_SHORT_RESET) { DBGMSG("busreset called (type: SHORT)"); hpsb_reset_bus(fi->host, SHORT_RESET); free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */ - return sizeof(struct raw1394_request); + return 0; } /* error EINVAL (22) invalid argument */ return (-EINVAL); @@ -2371,7 +2371,7 @@ static int state_connected(struct file_i req->req.generation = get_hpsb_generation(fi->host); req->req.length = 0; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } switch (req->req.type) { @@ -2384,7 +2384,7 @@ static int state_connected(struct file_i if (req->req.length == 0) { req->req.error = RAW1394_ERROR_INVALID_ARG; queue_complete_req(req); - return sizeof(struct raw1394_request); + return 0; } return handle_async_request(fi, req, node); @@ -2395,7 +2395,7 @@ static ssize_t raw1394_write(struct file { struct file_info *fi = (struct file_info *)file->private_data; struct pending_request *req; - ssize_t retval = 0; + ssize_t retval = -EBADFD; #ifdef CONFIG_COMPAT if (count == sizeof(struct compat_raw1394_req) && @@ -2437,6 +2437,9 @@ #endif if (retval < 0) { free_pending_request(req); + } else { + BUG_ON(retval); + retval = count; } return retval; @@ -2802,6 +2805,103 @@ static int raw1394_ioctl(struct inode *i return -EINVAL; } +#ifdef CONFIG_COMPAT +struct raw1394_iso_packets32 { + __u32 n_packets; + compat_uptr_t infos; +} __attribute__((packed)); + +struct raw1394_cycle_timer32 { + __u32 cycle_timer; + __u64 local_time; +} +#if defined(CONFIG_X86_64) || defined(CONFIG_IA64) +__attribute__((packed)) +#endif +; + +#define RAW1394_IOC_ISO_RECV_PACKETS32 \ + _IOW ('#', 0x25, struct raw1394_iso_packets32) +#define RAW1394_IOC_ISO_XMIT_PACKETS32 \ + _IOW ('#', 0x27, struct raw1394_iso_packets32) +#define RAW1394_IOC_GET_CYCLE_TIMER32 \ + _IOR ('#', 0x30, struct raw1394_cycle_timer32) + +static long raw1394_iso_xmit_recv_packets32(struct file *file, unsigned int cmd, + struct raw1394_iso_packets32 __user *arg) +{ + compat_uptr_t infos32; + void *infos; + long err = -EFAULT; + struct raw1394_iso_packets __user *dst = compat_alloc_user_space(sizeof(struct raw1394_iso_packets)); + + if (!copy_in_user(&dst->n_packets, &arg->n_packets, sizeof arg->n_packets) && + !copy_from_user(&infos32, &arg->infos, sizeof infos32)) { + infos = compat_ptr(infos32); + if (!copy_to_user(&dst->infos, &infos, sizeof infos)) + err = raw1394_ioctl(NULL, file, cmd, (unsigned long)dst); + } + return err; +} + +static long raw1394_read_cycle_timer32(struct file_info *fi, void __user * uaddr) +{ + struct raw1394_cycle_timer32 ct; + int err; + + err = hpsb_read_cycle_timer(fi->host, &ct.cycle_timer, &ct.local_time); + if (!err) + if (copy_to_user(uaddr, &ct, sizeof(ct))) + err = -EFAULT; + return err; +} + +static long raw1394_compat_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) +{ + struct file_info *fi = file->private_data; + void __user *argp = (void __user *)arg; + long err; + + lock_kernel(); + switch (cmd) { + /* These requests have same format as long as 'int' has same size. */ + case RAW1394_IOC_ISO_RECV_INIT: + case RAW1394_IOC_ISO_RECV_START: + case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL: + case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL: + case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK: + case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS: + case RAW1394_IOC_ISO_RECV_FLUSH: + case RAW1394_IOC_ISO_XMIT_RECV_STOP: + case RAW1394_IOC_ISO_XMIT_INIT: + case RAW1394_IOC_ISO_XMIT_START: + case RAW1394_IOC_ISO_XMIT_SYNC: + case RAW1394_IOC_ISO_GET_STATUS: + case RAW1394_IOC_ISO_SHUTDOWN: + case RAW1394_IOC_ISO_QUEUE_ACTIVITY: + err = raw1394_ioctl(NULL, file, cmd, arg); + break; + /* These request have different format. */ + case RAW1394_IOC_ISO_RECV_PACKETS32: + err = raw1394_iso_xmit_recv_packets32(file, RAW1394_IOC_ISO_RECV_PACKETS, argp); + break; + case RAW1394_IOC_ISO_XMIT_PACKETS32: + err = raw1394_iso_xmit_recv_packets32(file, RAW1394_IOC_ISO_XMIT_PACKETS, argp); + break; + case RAW1394_IOC_GET_CYCLE_TIMER32: + err = raw1394_read_cycle_timer32(fi, argp); + break; + default: + err = -EINVAL; + break; + } + unlock_kernel(); + + return err; +} +#endif + static unsigned int raw1394_poll(struct file *file, poll_table * pt) { struct file_info *fi = file->private_data; @@ -3041,7 +3141,9 @@ static const struct file_operations raw1 .write = raw1394_write, .mmap = raw1394_mmap, .ioctl = raw1394_ioctl, - // .compat_ioctl = ... someone needs to do this +#ifdef CONFIG_COMPAT + .compat_ioctl = raw1394_compat_ioctl, +#endif .poll = raw1394_poll, .open = raw1394_open, .release = raw1394_release, @@ -3054,9 +3156,9 @@ static int __init init_raw1394(void) hpsb_register_highlevel(&raw1394_highlevel); if (IS_ERR - (class_device_create - (hpsb_protocol_class, NULL, - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL, + (device_create( + hpsb_protocol_class, NULL, + MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), RAW1394_DEVICE_NAME))) { ret = -EFAULT; goto out_unreg; @@ -3083,9 +3185,9 @@ static int __init init_raw1394(void) goto out; out_dev: - class_device_destroy(hpsb_protocol_class, - MKDEV(IEEE1394_MAJOR, - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); + device_destroy(hpsb_protocol_class, + MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); out_unreg: hpsb_unregister_highlevel(&raw1394_highlevel); out: @@ -3094,9 +3196,9 @@ static int __init init_raw1394(void) static void __exit cleanup_raw1394(void) { - class_device_destroy(hpsb_protocol_class, - MKDEV(IEEE1394_MAJOR, - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); + device_destroy(hpsb_protocol_class, + MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); cdev_del(&raw1394_cdev); hpsb_unregister_highlevel(&raw1394_highlevel); hpsb_unregister_protocol(&raw1394_driver); diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 87ebd08..bd28adf 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -1340,9 +1340,9 @@ static void video1394_add_host (struct h hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; - class_device_create(hpsb_protocol_class, NULL, MKDEV( - IEEE1394_MAJOR, minor), - NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); + device_create(hpsb_protocol_class, NULL, + MKDEV(IEEE1394_MAJOR, minor), + "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); } @@ -1351,8 +1351,8 @@ static void video1394_remove_host (struc struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host); if (ohci) - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, - IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); return; }