From 210762268466634ddbfaddb48fdf5181ce4b5f2d Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 27 Aug 2011 18:53:03 +0200 Subject: firewire: move fw_device reference counting from drivers to core fw_unit device drivers invariably need to talk to the fw_unit's parent (an fw_device) and grandparent (an fw_card). firewire-core already maintains an fw_card reference for the entire lifetime of an fw_device. Likewise, let firewire-core maintain an fw_device reference for the entire lifetime of an fw_unit so that fw_unit drivers don't have to. Signed-off-by: Stefan Richter --- include/linux/firewire.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'include/linux/firewire.h') diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 84ccf8e04fa..6f1d7385e05 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -203,18 +203,6 @@ static inline int fw_device_is_shutdown(struct fw_device *device) return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; } -static inline struct fw_device *fw_device_get(struct fw_device *device) -{ - get_device(&device->device); - - return device; -} - -static inline void fw_device_put(struct fw_device *device) -{ - put_device(&device->device); -} - int fw_device_enable_phys_dma(struct fw_device *device); /* -- cgit v1.2.3-70-g09d2 From 26b4950de174bc96c27b77546370dec84fb75ae7 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 18 Feb 2012 22:03:14 +0100 Subject: firewire: core: prefix log messages with card name Associate all log messages from firewire-core with the respective card because some people have more than one card. E.g. firewire_ohci 0000:04:00.0: added OHCI v1.10 device as card 0, 8 IR + 8 IT contexts, quirks 0x0 firewire_ohci 0000:05:00.0: added OHCI v1.10 device as card 1, 8 IR + 8 IT contexts, quirks 0x0 firewire_core: created device fw0: GUID 0814438400000389, S800 firewire_core: phy config: new root=ffc1, gap_count=5 firewire_core: created device fw1: GUID 0814438400000388, S800 firewire_core: created device fw2: GUID 0001d202e06800d1, S800 turns into firewire_ohci 0000:04:00.0: added OHCI v1.10 device as card 0, 8 IR + 8 IT contexts, quirks 0x0 firewire_ohci 0000:05:00.0: added OHCI v1.10 device as card 1, 8 IR + 8 IT contexts, quirks 0x0 firewire_core 0000:04:00.0: created device fw0: GUID 0814438400000389, S800 firewire_core 0000:04:00.0: phy config: new root=ffc1, gap_count=5 firewire_core 0000:05:00.0: created device fw1: GUID 0814438400000388, S800 firewire_core 0000:04:00.0: created device fw2: GUID 0001d202e06800d1, S800 This increases the module size slightly; to keep this in check, turn the former printk wrapper macros into functions. Their implementation is largely copied from driver core's dev_printk counterparts. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 28 +++++++++++++---- drivers/firewire/core-cdev.c | 10 +++---- drivers/firewire/core-device.c | 60 +++++++++++++++++-------------------- drivers/firewire/core-topology.c | 18 +++++------ drivers/firewire/core-transaction.c | 4 +-- drivers/firewire/core.h | 6 ++++ include/linux/firewire.h | 3 -- 7 files changed, 72 insertions(+), 57 deletions(-) (limited to 'include/linux/firewire.h') diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 85661b060ed..b19db0f6a25 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -37,6 +37,22 @@ #include "core.h" +#define define_fw_printk_level(func, kern_level) \ +void func(const struct fw_card *card, const char *fmt, ...) \ +{ \ + struct va_format vaf; \ + va_list args; \ + \ + va_start(args, fmt); \ + vaf.fmt = fmt; \ + vaf.va = &args; \ + printk(kern_level KBUILD_MODNAME " %s: %pV", \ + dev_name(card->device), &vaf); \ + va_end(args); \ +} +define_fw_printk_level(fw_err, KERN_ERR); +define_fw_printk_level(fw_notice, KERN_NOTICE); + int fw_compute_block_crc(__be32 *block) { int length; @@ -260,7 +276,7 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation) fw_iso_resource_manage(card, generation, 1ULL << 31, &channel, &bandwidth, true); if (channel != 31) { - fw_notify("failed to allocate broadcast channel\n"); + fw_notice(card, "failed to allocate broadcast channel\n"); return; } card->broadcast_channel_allocated = true; @@ -343,14 +359,14 @@ static void bm_work(struct work_struct *work) if (!card->irm_node->link_on) { new_root_id = local_id; - fw_notify("%s, making local node (%02x) root.\n", + fw_notice(card, "%s, making local node (%02x) root\n", "IRM has link off", new_root_id); goto pick_me; } if (irm_is_1394_1995_only && !keep_this_irm) { new_root_id = local_id; - fw_notify("%s, making local node (%02x) root.\n", + fw_notice(card, "%s, making local node (%02x) root\n", "IRM is not 1394a compliant", new_root_id); goto pick_me; } @@ -405,7 +421,7 @@ static void bm_work(struct work_struct *work) * root, and thus, IRM. */ new_root_id = local_id; - fw_notify("%s, making local node (%02x) root.\n", + fw_notice(card, "%s, making local node (%02x) root\n", "BM lock failed", new_root_id); goto pick_me; } @@ -478,8 +494,8 @@ static void bm_work(struct work_struct *work) spin_unlock_irq(&card->lock); if (do_reset) { - fw_notify("phy config: card %d, new root=%x, gap_count=%d\n", - card->index, new_root_id, gap_count); + fw_notice(card, "phy config: new root=%x, gap_count=%d\n", + new_root_id, gap_count); fw_send_phy_config(card, new_root_id, generation, gap_count); reset_bus(card, true); /* Will allocate broadcast channel after the reset. */ diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 4799393247c..f5f5a9706fc 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -389,7 +389,7 @@ static void queue_bus_reset_event(struct client *client) e = kzalloc(sizeof(*e), GFP_KERNEL); if (e == NULL) { - fw_notify("Out of memory when allocating event\n"); + fw_notice(client->device->card, "out of memory when allocating event\n"); return; } @@ -691,7 +691,7 @@ static void handle_request(struct fw_card *card, struct fw_request *request, r = kmalloc(sizeof(*r), GFP_ATOMIC); e = kmalloc(sizeof(*e), GFP_ATOMIC); if (r == NULL || e == NULL) { - fw_notify("Out of memory when allocating event\n"); + fw_notice(card, "out of memory when allocating event\n"); goto failed; } r->card = card; @@ -928,7 +928,7 @@ static void iso_callback(struct fw_iso_context *context, u32 cycle, e = kmalloc(sizeof(*e) + header_length, GFP_ATOMIC); if (e == NULL) { - fw_notify("Out of memory when allocating event\n"); + fw_notice(context->card, "out of memory when allocating event\n"); return; } e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; @@ -948,7 +948,7 @@ static void iso_mc_callback(struct fw_iso_context *context, e = kmalloc(sizeof(*e), GFP_ATOMIC); if (e == NULL) { - fw_notify("Out of memory when allocating event\n"); + fw_notice(context->card, "out of memory when allocating event\n"); return; } e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL; @@ -1548,7 +1548,7 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p) list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC); if (e == NULL) { - fw_notify("Out of memory when allocating event\n"); + fw_notice(card, "out of memory when allocating event\n"); break; } e->phy_packet.closure = client->phy_receiver_closure; diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 4c6c7d8cdaf..afa7c83bd11 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -485,6 +485,7 @@ static int read_rom(struct fw_device *device, */ static int read_config_rom(struct fw_device *device, int generation) { + struct fw_card *card = device->card; const u32 *old_rom, *new_rom; u32 *rom, *stack; u32 sp, key; @@ -529,12 +530,12 @@ static int read_config_rom(struct fw_device *device, int generation) */ if ((rom[2] & 0x7) < device->max_speed || device->max_speed == SCODE_BETA || - device->card->beta_repeaters_present) { + card->beta_repeaters_present) { u32 dummy; /* for S1600 and S3200 */ if (device->max_speed == SCODE_BETA) - device->max_speed = device->card->link_speed; + device->max_speed = card->link_speed; while (device->max_speed > SCODE_100) { if (read_rom(device, generation, 0, &dummy) == @@ -576,9 +577,9 @@ static int read_config_rom(struct fw_device *device, int generation) * a firmware bug. Ignore this whole block, i.e. * simply set a fake block length of 0. */ - fw_error("skipped invalid ROM block %x at %llx\n", - rom[i], - i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); + fw_err(card, "skipped invalid ROM block %x at %llx\n", + rom[i], + i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); rom[i] = 0; end = i; } @@ -604,9 +605,10 @@ static int read_config_rom(struct fw_device *device, int generation) * the ROM don't have to check offsets all the time. */ if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) { - fw_error("skipped unsupported ROM entry %x at %llx\n", - rom[i], - i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); + fw_err(card, + "skipped unsupported ROM entry %x at %llx\n", + rom[i], + i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); rom[i] = 0; continue; } @@ -673,7 +675,7 @@ static void create_units(struct fw_device *device) */ unit = kzalloc(sizeof(*unit), GFP_KERNEL); if (unit == NULL) { - fw_error("failed to allocate memory for unit\n"); + fw_err(device->card, "out of memory for unit\n"); continue; } @@ -875,7 +877,7 @@ static int lookup_existing_device(struct device *dev, void *data) smp_wmb(); /* update node_id before generation */ old->generation = card->generation; old->config_rom_retries = 0; - fw_notify("rediscovered device %s\n", dev_name(dev)); + fw_notice(card, "rediscovered device %s\n", dev_name(dev)); PREPARE_DELAYED_WORK(&old->work, fw_device_update); fw_schedule_device_work(old, 0); @@ -956,6 +958,7 @@ static void fw_device_init(struct work_struct *work) { struct fw_device *device = container_of(work, struct fw_device, work.work); + struct fw_card *card = device->card; struct device *revived_dev; int minor, ret; @@ -972,16 +975,16 @@ static void fw_device_init(struct work_struct *work) fw_schedule_device_work(device, RETRY_DELAY); } else { if (device->node->link_on) - fw_notify("giving up on config rom for node id %x\n", + fw_notice(card, "giving up on Config ROM for node id %x\n", device->node_id); - if (device->node == device->card->root_node) - fw_schedule_bm_work(device->card, 0); + if (device->node == card->root_node) + fw_schedule_bm_work(card, 0); fw_device_release(&device->device); } return; } - revived_dev = device_find_child(device->card->device, + revived_dev = device_find_child(card->device, device, lookup_existing_device); if (revived_dev) { put_device(revived_dev); @@ -1004,7 +1007,7 @@ static void fw_device_init(struct work_struct *work) device->device.bus = &fw_bus_type; device->device.type = &fw_device_type; - device->device.parent = device->card->device; + device->device.parent = card->device; device->device.devt = MKDEV(fw_cdev_major, minor); dev_set_name(&device->device, "fw%d", minor); @@ -1016,7 +1019,7 @@ static void fw_device_init(struct work_struct *work) &device->attribute_group); if (device_add(&device->device)) { - fw_error("Failed to add device.\n"); + fw_err(card, "failed to add device\n"); goto error_with_cdev; } @@ -1037,18 +1040,10 @@ static void fw_device_init(struct work_struct *work) PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); fw_schedule_device_work(device, SHUTDOWN_DELAY); } else { - if (device->config_rom_retries) - fw_notify("created device %s: GUID %08x%08x, S%d00, " - "%d config ROM retries\n", - dev_name(&device->device), - device->config_rom[3], device->config_rom[4], - 1 << device->max_speed, - device->config_rom_retries); - else - fw_notify("created device %s: GUID %08x%08x, S%d00\n", - dev_name(&device->device), - device->config_rom[3], device->config_rom[4], - 1 << device->max_speed); + fw_notice(card, "created device %s: GUID %08x%08x, S%d00\n", + dev_name(&device->device), + device->config_rom[3], device->config_rom[4], + 1 << device->max_speed); device->config_rom_retries = 0; set_broadcast_channel(device, device->generation); @@ -1060,8 +1055,8 @@ static void fw_device_init(struct work_struct *work) * just end up running the IRM work a couple of extra times - * pretty harmless. */ - if (device->node == device->card->root_node) - fw_schedule_bm_work(device->card, 0); + if (device->node == card->root_node) + fw_schedule_bm_work(card, 0); return; @@ -1165,12 +1160,13 @@ static void fw_device_refresh(struct work_struct *work) FW_DEVICE_RUNNING) == FW_DEVICE_GONE) goto gone; - fw_notify("refreshed device %s\n", dev_name(&device->device)); + fw_notice(card, "refreshed device %s\n", dev_name(&device->device)); device->config_rom_retries = 0; goto out; give_up: - fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); + fw_notice(card, "giving up on refresh of device %s\n", + dev_name(&device->device)); gone: atomic_set(&device->state, FW_DEVICE_GONE); PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c index 94d3b494ddf..75a6b0df670 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -205,19 +205,19 @@ static struct fw_node *build_tree(struct fw_card *card, next_sid = count_ports(sid, &port_count, &child_port_count); if (next_sid == NULL) { - fw_error("Inconsistent extended self IDs.\n"); + fw_err(card, "inconsistent extended self IDs\n"); return NULL; } q = *sid; if (phy_id != SELF_ID_PHY_ID(q)) { - fw_error("PHY ID mismatch in self ID: %d != %d.\n", - phy_id, SELF_ID_PHY_ID(q)); + fw_err(card, "PHY ID mismatch in self ID: %d != %d\n", + phy_id, SELF_ID_PHY_ID(q)); return NULL; } if (child_port_count > stack_depth) { - fw_error("Topology stack underflow\n"); + fw_err(card, "topology stack underflow\n"); return NULL; } @@ -235,7 +235,7 @@ static struct fw_node *build_tree(struct fw_card *card, node = fw_node_create(q, port_count, card->color); if (node == NULL) { - fw_error("Out of memory while building topology.\n"); + fw_err(card, "out of memory while building topology\n"); return NULL; } @@ -284,8 +284,8 @@ static struct fw_node *build_tree(struct fw_card *card, */ if ((next_sid == end && parent_count != 0) || (next_sid < end && parent_count != 1)) { - fw_error("Parent port inconsistency for node %d: " - "parent_count=%d\n", phy_id, parent_count); + fw_err(card, "parent port inconsistency for node %d: " + "parent_count=%d\n", phy_id, parent_count); return NULL; } @@ -530,7 +530,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, */ if (!is_next_generation(generation, card->generation) && card->local_node != NULL) { - fw_notify("skipped bus generations, destroying all nodes\n"); + fw_notice(card, "skipped bus generations, destroying all nodes\n"); fw_destroy_nodes(card); card->bm_retries = 0; } @@ -557,7 +557,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, card->color++; if (local_node == NULL) { - fw_error("topology build failed\n"); + fw_err(card, "topology build failed\n"); /* FIXME: We need to issue a bus reset in this case. */ } else if (card->local_node == NULL) { card->local_node = local_node; diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index 855ab3f5936..426886a91bd 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -770,7 +770,7 @@ static struct fw_request *allocate_request(struct fw_card *card, break; default: - fw_error("ERROR - corrupt request received - %08x %08x %08x\n", + fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", p->header[0], p->header[1], p->header[2]); return NULL; } @@ -960,7 +960,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) if (&t->link == &card->transaction_list) { timed_out: - fw_notify("Unsolicited response (source %x, tlabel %x)\n", + fw_notice(card, "unsolicited response (source %x, tlabel %x)\n", source, tlabel); return; } diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index b5b34952cf1..62f57a4331e 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -1,6 +1,7 @@ #ifndef _FIREWIRE_CORE_H #define _FIREWIRE_CORE_H +#include #include #include #include @@ -24,6 +25,11 @@ struct fw_packet; /* -card */ +extern __printf(2, 3) +void fw_err(const struct fw_card *card, const char *fmt, ...); +extern __printf(2, 3) +void fw_notice(const struct fw_card *card, const char *fmt, ...); + /* bitfields within the PHY registers */ #define PHY_LINK_ACTIVE 0x80 #define PHY_CONTENDER 0x40 diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 6f1d7385e05..ab5b7a18dec 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -17,9 +17,6 @@ #include #include -#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) -#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) - #define CSR_REGISTER_BASE 0xfffff0000000ULL /* register offsets are relative to CSR_REGISTER_BASE */ -- cgit v1.2.3-70-g09d2 From 313162d0b83836e2f57e51b9b8650fb4b9c396ea Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 30 Jan 2012 11:46:54 -0500 Subject: device.h: audit and cleanup users in main include dir The header includes a lot of stuff, and it in turn gets a lot of use just for the basic "struct device" which appears so often. Clean up the users as follows: 1) For those headers only needing "struct device" as a pointer in fcn args, replace the include with exactly that. 2) For headers not really using anything from device.h, simply delete the include altogether. 3) For headers relying on getting device.h implicitly before being included themselves, now explicitly include device.h 4) For files in which doing #1 or #2 uncovers an implicit dependency on some other header, fix by explicitly adding the required header(s). Any C files that were implicitly relying on device.h to be present have already been dealt with in advance. Total removals from #1 and #2: 51. Total additions coming from #3: 9. Total other implicit dependencies from #4: 7. As of 3.3-rc1, there were 110, so a net removal of 42 gives about a 38% reduction in device.h presence in include/* Signed-off-by: Paul Gortmaker --- include/linux/amba/pl022.h | 2 -- include/linux/atmdev.h | 2 +- include/linux/attribute_container.h | 3 ++- include/linux/c2port.h | 3 ++- include/linux/cdrom.h | 1 - include/linux/cpu.h | 3 ++- include/linux/cpufreq.h | 1 - include/linux/crash_dump.h | 1 - include/linux/dma-buf.h | 2 +- include/linux/edac.h | 6 +++++- include/linux/fb.h | 1 - include/linux/firewire.h | 3 ++- include/linux/hwmon-sysfs.h | 2 ++ include/linux/hwmon.h | 2 +- include/linux/hwspinlock.h | 2 +- include/linux/ide.h | 3 ++- include/linux/ipmi.h | 2 +- include/linux/ipmi_smi.h | 3 ++- include/linux/jz4740-adc.h | 2 +- include/linux/maple.h | 2 +- include/linux/mfd/abx500.h | 3 ++- include/linux/mfd/abx500/ab5500.h | 2 +- include/linux/mfd/abx500/ab8500.h | 4 +++- include/linux/mfd/pm8xxx/pm8921.h | 1 - include/linux/mfd/stmpe.h | 4 +++- include/linux/mfd/tc3589x.h | 2 +- include/linux/mlx4/driver.h | 1 - include/linux/mmc/card.h | 1 + include/linux/mmc/core.h | 2 +- include/linux/mmc/host.h | 1 + include/linux/netdevice.h | 2 +- include/linux/of_device.h | 3 ++- include/linux/opp.h | 1 + include/linux/phy.h | 5 +++-- include/linux/pm_domain.h | 2 ++ include/linux/power_supply.h | 3 ++- include/linux/regmap.h | 2 +- include/linux/regulator/consumer.h | 3 ++- include/linux/rfkill.h | 2 +- include/linux/rio_drv.h | 1 - include/linux/serial_pnx8xxx.h | 1 - include/linux/spi/mmc_spi.h | 2 +- include/linux/wimax/debug.h | 2 +- include/media/media-device.h | 3 ++- include/media/v4l2-ctrls.h | 1 - include/media/v4l2-ioctl.h | 1 - include/net/mac80211.h | 3 ++- include/scsi/scsi_device.h | 2 +- include/sound/core.h | 5 ++--- include/sound/soc-dapm.h | 3 ++- include/trace/events/regmap.h | 2 +- include/trace/events/rpm.h | 3 ++- include/trace/events/writeback.h | 1 - 53 files changed, 68 insertions(+), 52 deletions(-) (limited to 'include/linux/firewire.h') diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index 572f637299c..9da37a45faf 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h @@ -25,8 +25,6 @@ #ifndef _SSP_PL022_H #define _SSP_PL022_H -#include - /** * whether SSP is in loopback mode or not */ diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h index f4ff882cb2d..52c940935bd 100644 --- a/include/linux/atmdev.h +++ b/include/linux/atmdev.h @@ -213,7 +213,6 @@ struct atm_cirange { #ifdef __KERNEL__ -#include #include /* wait_queue_head_t */ #include /* struct timeval */ #include @@ -249,6 +248,7 @@ struct k_atm_dev_stats { struct k_atm_aal_stats aal5; }; +struct device; enum { ATM_VF_ADDR, /* Address is in use. Set by anybody, cleared diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h index c3ab81428c6..896c6892f32 100644 --- a/include/linux/attribute_container.h +++ b/include/linux/attribute_container.h @@ -9,10 +9,11 @@ #ifndef _ATTRIBUTE_CONTAINER_H_ #define _ATTRIBUTE_CONTAINER_H_ -#include #include #include +struct device; + struct attribute_container { struct list_head node; struct klist containers; diff --git a/include/linux/c2port.h b/include/linux/c2port.h index a2f7d7413f3..4efabcb5134 100644 --- a/include/linux/c2port.h +++ b/include/linux/c2port.h @@ -9,11 +9,12 @@ * the Free Software Foundation */ -#include #include #define C2PORT_NAME_LEN 32 +struct device; + /* * C2 port basic structs */ diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h index 35eae4b6750..d35a12fbd8f 100644 --- a/include/linux/cdrom.h +++ b/include/linux/cdrom.h @@ -910,7 +910,6 @@ struct mode_page_header { #ifdef __KERNEL__ #include /* not really needed, later.. */ -#include #include struct packet_command diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 1f6587590a1..e3cdc3aec87 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -14,11 +14,12 @@ #ifndef _LINUX_CPU_H_ #define _LINUX_CPU_H_ -#include #include #include #include +struct device; + struct cpu { int node_id; /* The node which contains the CPU */ int hotpluggable; /* creates sysfs control file if hotpluggable */ diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 6216115c778..fad1382f861 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h index b936763f223..37e4f8da7cd 100644 --- a/include/linux/crash_dump.h +++ b/include/linux/crash_dump.h @@ -3,7 +3,6 @@ #ifdef CONFIG_CRASH_DUMP #include -#include #include #include diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index f8ac076afa5..887dcd48706 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -26,11 +26,11 @@ #include #include -#include #include #include #include +struct device; struct dma_buf; struct dma_buf_attachment; diff --git a/include/linux/edac.h b/include/linux/edac.h index 1cd3947987e..ba317e2930a 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h @@ -13,7 +13,11 @@ #define _LINUX_EDAC_H_ #include -#include +#include +#include +#include + +struct device; #define EDAC_OPSTATE_INVAL -1 #define EDAC_OPSTATE_POLL 0 diff --git a/include/linux/fb.h b/include/linux/fb.h index c18122f4054..9d509675034 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -407,7 +407,6 @@ struct fb_cursor { #include #include -#include #include #include #include diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 84ccf8e04fa..fba45b89689 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -2,7 +2,6 @@ #define _LINUX_FIREWIRE_H #include -#include #include #include #include @@ -68,6 +67,8 @@ #define CSR_MODEL 0x17 #define CSR_DIRECTORY_ID 0x20 +struct device; + struct fw_csr_iterator { const u32 *p; const u32 *end; diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index a90c09d331c..1c7b89ae6bd 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h @@ -20,6 +20,8 @@ #ifndef _LINUX_HWMON_SYSFS_H #define _LINUX_HWMON_SYSFS_H +#include + struct sensor_device_attribute{ struct device_attribute dev_attr; int index; diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index 6b6ee702b00..82b29ae6ebb 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -14,7 +14,7 @@ #ifndef _HWMON_H_ #define _HWMON_H_ -#include +struct device; struct device *hwmon_device_register(struct device *dev); diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index aad6bd4b3ef..3343298e40e 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -20,12 +20,12 @@ #include #include -#include /* hwspinlock mode argument */ #define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */ #define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */ +struct device; struct hwspinlock; struct hwspinlock_device; struct hwspinlock_ops; diff --git a/include/linux/ide.h b/include/linux/ide.h index 501370b61ee..7afe15f916d 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,8 @@ #define ERROR_RESET 3 /* Reset controller every 4th retry */ #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ +struct device; + /* Error codes returned in rq->errors to the higher part of the driver. */ enum { IDE_DRV_ERROR_GENERAL = 101, diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h index bbd156bb953..48dcba9b206 100644 --- a/include/linux/ipmi.h +++ b/include/linux/ipmi.h @@ -220,10 +220,10 @@ struct kernel_ipmi_msg { * The in-kernel interface. */ #include -#include #include struct module; +struct device; /* Opaque type for a IPMI message user. One of these is needed to send and receive messages. */ diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h index 3ef0d8b6aa6..fcb5d44ea63 100644 --- a/include/linux/ipmi_smi.h +++ b/include/linux/ipmi_smi.h @@ -36,10 +36,11 @@ #include #include -#include #include #include +struct device; + /* This files describes the interface for IPMI system management interface drivers to bind into the IPMI message handler. */ diff --git a/include/linux/jz4740-adc.h b/include/linux/jz4740-adc.h index 9053f95e968..8184578fbfa 100644 --- a/include/linux/jz4740-adc.h +++ b/include/linux/jz4740-adc.h @@ -2,7 +2,7 @@ #ifndef __LINUX_JZ4740_ADC #define __LINUX_JZ4740_ADC -#include +struct device; /* * jz4740_adc_set_config - Configure a JZ4740 adc device diff --git a/include/linux/maple.h b/include/linux/maple.h index d9a51b9b330..c37288b23e0 100644 --- a/include/linux/maple.h +++ b/include/linux/maple.h @@ -1,9 +1,9 @@ #ifndef __LINUX_MAPLE_H #define __LINUX_MAPLE_H -#include #include +struct device; extern struct bus_type maple_bus_type; /* Maple Bus command and response codes */ diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 9970337ff04..e20dd6ead1d 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -14,9 +14,10 @@ * Author: Rickard Andersson */ -#include #include +struct device; + #ifndef MFD_ABX500_H #define MFD_ABX500_H diff --git a/include/linux/mfd/abx500/ab5500.h b/include/linux/mfd/abx500/ab5500.h index a720051ae93..54f820ed73b 100644 --- a/include/linux/mfd/abx500/ab5500.h +++ b/include/linux/mfd/abx500/ab5500.h @@ -6,7 +6,7 @@ #ifndef MFD_AB5500_H #define MFD_AB5500_H -#include +struct device; enum ab5500_devid { AB5500_DEVID_ADC, diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h index 838c6b487cc..dca94396190 100644 --- a/include/linux/mfd/abx500/ab8500.h +++ b/include/linux/mfd/abx500/ab8500.h @@ -7,7 +7,9 @@ #ifndef MFD_AB8500_H #define MFD_AB8500_H -#include +#include + +struct device; /* * AB8500 bank addresses diff --git a/include/linux/mfd/pm8xxx/pm8921.h b/include/linux/mfd/pm8xxx/pm8921.h index d5517fd32d1..00fa3de7659 100644 --- a/include/linux/mfd/pm8xxx/pm8921.h +++ b/include/linux/mfd/pm8xxx/pm8921.h @@ -18,7 +18,6 @@ #ifndef __MFD_PM8921_H #define __MFD_PM8921_H -#include #include #define PM8921_NR_IRQS 256 diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h index ca1d7a34760..8c54de674b4 100644 --- a/include/linux/mfd/stmpe.h +++ b/include/linux/mfd/stmpe.h @@ -8,7 +8,9 @@ #ifndef __LINUX_MFD_STMPE_H #define __LINUX_MFD_STMPE_H -#include +#include + +struct device; enum stmpe_block { STMPE_BLOCK_GPIO = 1 << 0, diff --git a/include/linux/mfd/tc3589x.h b/include/linux/mfd/tc3589x.h index 16c76e124f9..3acb3a8e3af 100644 --- a/include/linux/mfd/tc3589x.h +++ b/include/linux/mfd/tc3589x.h @@ -7,7 +7,7 @@ #ifndef __LINUX_MFD_TC3589x_H #define __LINUX_MFD_TC3589x_H -#include +struct device; enum tx3589x_block { TC3589x_BLOCK_GPIO = 1 << 0, diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index e1eebf78cab..5f1298b1b5e 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h @@ -33,7 +33,6 @@ #ifndef MLX4_DRIVER_H #define MLX4_DRIVER_H -#include #include struct mlx4_dev; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 9f22ba572de..895978c9a16 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -10,6 +10,7 @@ #ifndef LINUX_MMC_CARD_H #define LINUX_MMC_CARD_H +#include #include #include diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 87a976cc565..2e6a681fceb 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -9,7 +9,7 @@ #define LINUX_MMC_CORE_H #include -#include +#include struct request; struct mmc_data; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 0beba1e5e1e..68558d743da 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0eac07c9525..fa568da2fcd 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -38,7 +38,6 @@ #include #include -#include #include #include #include @@ -56,6 +55,7 @@ #include struct netpoll_info; +struct device; struct phy_device; /* 802.11 specific */ struct wireless_dev; diff --git a/include/linux/of_device.h b/include/linux/of_device.h index ae5638480ef..b444adf692d 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -5,10 +5,11 @@ #include /* temporary until merge */ #ifdef CONFIG_OF_DEVICE -#include #include #include +struct device; + extern const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct device *dev); extern void of_device_make_bus_id(struct device *dev); diff --git a/include/linux/opp.h b/include/linux/opp.h index ee94b33080c..2a4e5faee90 100644 --- a/include/linux/opp.h +++ b/include/linux/opp.h @@ -19,6 +19,7 @@ #include struct opp; +struct device; enum opp_event { OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, diff --git a/include/linux/phy.h b/include/linux/phy.h index c599f7eca1e..6fe0a37d4ab 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -19,7 +19,6 @@ #define __PHY_H #include -#include #include #include #include @@ -88,6 +87,9 @@ typedef enum { IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */ #define MII_ADDR_C45 (1<<30) +struct device; +struct sk_buff; + /* * The Bus class for PHYs. Devices which provide access to * PHYs should register using this structure @@ -241,7 +243,6 @@ enum phy_state { PHY_RESUMING }; -struct sk_buff; /* phy_device: An instance of a PHY * diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index a03a0ad998b..fa2e20b621b 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -10,6 +10,8 @@ #define _LINUX_PM_DOMAIN_H #include +#include +#include #include enum gpd_status { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index fa9b962aec1..c38c13db883 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -13,10 +13,11 @@ #ifndef __LINUX_POWER_SUPPLY_H__ #define __LINUX_POWER_SUPPLY_H__ -#include #include #include +struct device; + /* * All voltages, currents, charges, energies, time and temperatures in uV, * µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise diff --git a/include/linux/regmap.h b/include/linux/regmap.h index eb93921cdd3..765736cbb50 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -13,10 +13,10 @@ * published by the Free Software Foundation. */ -#include #include struct module; +struct device; struct i2c_client; struct spi_device; diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index f2698a0edfc..10e0d33e8ff 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -35,7 +35,8 @@ #ifndef __LINUX_REGULATOR_CONSUMER_H_ #define __LINUX_REGULATOR_CONSUMER_H_ -#include +struct device; +struct notifier_block; /* * Regulator operating modes. diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h index c6c608482cb..6fdf02737e9 100644 --- a/include/linux/rfkill.h +++ b/include/linux/rfkill.h @@ -117,10 +117,10 @@ enum rfkill_user_states { #include #include #include -#include #include #include +struct device; /* this is opaque */ struct rfkill; diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h index 229b3ca2313..7f07470e1ed 100644 --- a/include/linux/rio_drv.h +++ b/include/linux/rio_drv.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/include/linux/serial_pnx8xxx.h b/include/linux/serial_pnx8xxx.h index de6c19c7f34..79ad87b0be3 100644 --- a/include/linux/serial_pnx8xxx.h +++ b/include/linux/serial_pnx8xxx.h @@ -20,7 +20,6 @@ #define _LINUX_SERIAL_PNX8XXX_H #include -#include #define PNX8XXX_NR_PORTS 2 diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h index 0f4eb165f25..32be8dbdf19 100644 --- a/include/linux/spi/mmc_spi.h +++ b/include/linux/spi/mmc_spi.h @@ -1,10 +1,10 @@ #ifndef __LINUX_SPI_MMC_SPI_H #define __LINUX_SPI_MMC_SPI_H -#include #include #include +struct device; struct mmc_host; /* Put this in platform_data of a device being used to manage an MMC/SD diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h index 57031b4d12f..aaf24ba12c4 100644 --- a/include/linux/wimax/debug.h +++ b/include/linux/wimax/debug.h @@ -154,9 +154,9 @@ #define __debug__h__ #include -#include #include +struct device; /* Backend stuff */ diff --git a/include/media/media-device.h b/include/media/media-device.h index 6a27d916c25..eaade9815bb 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -23,7 +23,6 @@ #ifndef _MEDIA_DEVICE_H #define _MEDIA_DEVICE_H -#include #include #include #include @@ -31,6 +30,8 @@ #include #include +struct device; + /** * struct media_device - Media device * @dev: Parent device diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index eeb3df63714..62e04dda22f 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -22,7 +22,6 @@ #define _V4L2_CTRLS_H #include -#include #include /* forward references */ diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 3f5d60fc5df..032ff21b28b 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -11,7 +11,6 @@ #include #include -#include #include #include /* need __user */ #include diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d49928ba5d0..f0605df39e9 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -87,6 +86,8 @@ * */ +struct device; + /** * enum ieee80211_max_queues - maximum number of queues * diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 77273f2fdd8..34dc8315d83 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -1,7 +1,6 @@ #ifndef _SCSI_SCSI_DEVICE_H #define _SCSI_SCSI_DEVICE_H -#include #include #include #include @@ -9,6 +8,7 @@ #include #include +struct device; struct request_queue; struct scsi_cmnd; struct scsi_lun; diff --git a/include/sound/core.h b/include/sound/core.h index 5ab255f196c..a4207163697 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -26,7 +26,6 @@ #include /* struct mutex */ #include /* struct rw_semaphore */ #include /* pm_message_t */ -#include #include /* number of supported soundcards */ @@ -39,10 +38,10 @@ #define CONFIG_SND_MAJOR 116 /* standard configuration */ /* forward declarations */ -#ifdef CONFIG_PCI struct pci_dev; -#endif struct module; +struct device; +struct device_attribute; /* device allocation stuff */ diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index d26a9b78477..ab0d84aeae1 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -13,10 +13,11 @@ #ifndef __LINUX_SND_SOC_DAPM_H #define __LINUX_SND_SOC_DAPM_H -#include #include #include +struct device; + /* widget has no PM register bit */ #define SND_SOC_NOPM -1 diff --git a/include/trace/events/regmap.h b/include/trace/events/regmap.h index 12fbf43524e..50fe9ba6144 100644 --- a/include/trace/events/regmap.h +++ b/include/trace/events/regmap.h @@ -4,10 +4,10 @@ #if !defined(_TRACE_REGMAP_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_REGMAP_H -#include #include #include +struct device; struct regmap; /* diff --git a/include/trace/events/rpm.h b/include/trace/events/rpm.h index d62c558bf64..33f85b68c22 100644 --- a/include/trace/events/rpm.h +++ b/include/trace/events/rpm.h @@ -7,7 +7,8 @@ #include #include -#include + +struct device; /* * The rpm_internal events are used for tracing some important diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h index 8588a891802..2d0dd3e03e4 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h @@ -5,7 +5,6 @@ #define _TRACE_WRITEBACK_H #include -#include #include #define show_inode_state(state) \ -- cgit v1.2.3-70-g09d2 From d1bbd20972936b9b178fda3eb1ec417cb27fdc01 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 18 Mar 2012 19:06:39 +0100 Subject: firewire: allow explicit flushing of iso packet completions Extend the kernel and userspace APIs to allow reporting all currently completed isochronous packets, even if the next interrupt packet has not yet been reached. This is required to determine the status of the packets at the end of a paused or stopped stream, and useful for more precise synchronization of audio streams. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 6 ++++ drivers/firewire/core-cdev.c | 12 +++++++ drivers/firewire/core-iso.c | 6 ++++ drivers/firewire/core.h | 2 ++ drivers/firewire/ohci.c | 78 ++++++++++++++++++++++++++++++++++++++----- include/linux/firewire-cdev.h | 35 ++++++++++++++++--- include/linux/firewire.h | 1 + 7 files changed, 127 insertions(+), 13 deletions(-) (limited to 'include/linux/firewire.h') diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index b19db0f6a25..cc595eba7ba 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -650,6 +650,11 @@ static void dummy_flush_queue_iso(struct fw_iso_context *ctx) { } +static int dummy_flush_iso_completions(struct fw_iso_context *ctx) +{ + return -ENODEV; +} + static const struct fw_card_driver dummy_driver_template = { .read_phy_reg = dummy_read_phy_reg, .update_phy_reg = dummy_update_phy_reg, @@ -662,6 +667,7 @@ static const struct fw_card_driver dummy_driver_template = { .set_iso_channels = dummy_set_iso_channels, .queue_iso = dummy_queue_iso, .flush_queue_iso = dummy_flush_queue_iso, + .flush_iso_completions = dummy_flush_iso_completions, }; void fw_card_release(struct kref *kref) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 4cb27dc542c..22c6df5f136 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -438,6 +438,7 @@ union ioctl_arg { struct fw_cdev_send_phy_packet send_phy_packet; struct fw_cdev_receive_phy_packets receive_phy_packets; struct fw_cdev_set_iso_channels set_iso_channels; + struct fw_cdev_flush_iso flush_iso; }; static int ioctl_get_info(struct client *client, union ioctl_arg *arg) @@ -1168,6 +1169,16 @@ static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg) return fw_iso_context_stop(client->iso_context); } +static int ioctl_flush_iso(struct client *client, union ioctl_arg *arg) +{ + struct fw_cdev_flush_iso *a = &arg->flush_iso; + + if (client->iso_context == NULL || a->handle != 0) + return -EINVAL; + + return fw_iso_context_flush_completions(client->iso_context); +} + static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) { struct fw_cdev_get_cycle_timer2 *a = &arg->get_cycle_timer2; @@ -1589,6 +1600,7 @@ static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = { [0x15] = ioctl_send_phy_packet, [0x16] = ioctl_receive_phy_packets, [0x17] = ioctl_set_iso_channels, + [0x18] = ioctl_flush_iso, }; static int dispatch_ioctl(struct client *client, diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 57c3973093a..2f432a20ce7 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -191,6 +191,12 @@ void fw_iso_context_queue_flush(struct fw_iso_context *ctx) } EXPORT_SYMBOL(fw_iso_context_queue_flush); +int fw_iso_context_flush_completions(struct fw_iso_context *ctx) +{ + return ctx->card->driver->flush_iso_completions(ctx); +} +EXPORT_SYMBOL(fw_iso_context_flush_completions); + int fw_iso_context_stop(struct fw_iso_context *ctx) { return ctx->card->driver->stop_iso(ctx); diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 62f57a4331e..9047f5547d9 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -106,6 +106,8 @@ struct fw_card_driver { void (*flush_queue_iso)(struct fw_iso_context *ctx); + int (*flush_iso_completions)(struct fw_iso_context *ctx); + int (*stop_iso)(struct fw_iso_context *ctx); }; diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 632562667a0..59e7894ae3b 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -172,6 +172,9 @@ struct iso_context { struct context context; void *header; size_t header_length; + unsigned long flushing_completions; + u32 mc_buffer_bus; + u16 mc_completed; u16 last_timestamp; u8 sync; u8 tags; @@ -2749,28 +2752,51 @@ static int handle_ir_buffer_fill(struct context *context, { struct iso_context *ctx = container_of(context, struct iso_context, context); + unsigned int req_count, res_count, completed; u32 buffer_dma; - if (last->res_count != 0) + req_count = le16_to_cpu(last->req_count); + res_count = le16_to_cpu(ACCESS_ONCE(last->res_count)); + completed = req_count - res_count; + buffer_dma = le32_to_cpu(last->data_address); + + if (completed > 0) { + ctx->mc_buffer_bus = buffer_dma; + ctx->mc_completed = completed; + } + + if (res_count != 0) /* Descriptor(s) not done yet, stop iteration */ return 0; - buffer_dma = le32_to_cpu(last->data_address); dma_sync_single_range_for_cpu(context->ohci->card.device, buffer_dma & PAGE_MASK, buffer_dma & ~PAGE_MASK, - le16_to_cpu(last->req_count), - DMA_FROM_DEVICE); + completed, DMA_FROM_DEVICE); - if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS)) + if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS)) { ctx->base.callback.mc(&ctx->base, - le32_to_cpu(last->data_address) + - le16_to_cpu(last->req_count), + buffer_dma + completed, ctx->base.callback_data); + ctx->mc_completed = 0; + } return 1; } +static void flush_ir_buffer_fill(struct iso_context *ctx) +{ + dma_sync_single_range_for_cpu(ctx->context.ohci->card.device, + ctx->mc_buffer_bus & PAGE_MASK, + ctx->mc_buffer_bus & ~PAGE_MASK, + ctx->mc_completed, DMA_FROM_DEVICE); + + ctx->base.callback.mc(&ctx->base, + ctx->mc_buffer_bus + ctx->mc_completed, + ctx->base.callback_data); + ctx->mc_completed = 0; +} + static inline void sync_it_packet_for_cpu(struct context *context, struct descriptor *pd) { @@ -2925,8 +2951,10 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, if (ret < 0) goto out_with_header; - if (type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) + if (type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) { set_multichannel_mask(ohci, 0); + ctx->mc_completed = 0; + } return &ctx->base; @@ -3388,6 +3416,39 @@ static void ohci_flush_queue_iso(struct fw_iso_context *base) reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); } +static int ohci_flush_iso_completions(struct fw_iso_context *base) +{ + struct iso_context *ctx = container_of(base, struct iso_context, base); + int ret = 0; + + tasklet_disable(&ctx->context.tasklet); + + if (!test_and_set_bit_lock(0, &ctx->flushing_completions)) { + context_tasklet((unsigned long)&ctx->context); + + switch (base->type) { + case FW_ISO_CONTEXT_TRANSMIT: + case FW_ISO_CONTEXT_RECEIVE: + if (ctx->header_length != 0) + flush_iso_completions(ctx); + break; + case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL: + if (ctx->mc_completed != 0) + flush_ir_buffer_fill(ctx); + break; + default: + ret = -ENOSYS; + } + + clear_bit_unlock(0, &ctx->flushing_completions); + smp_mb__after_clear_bit(); + } + + tasklet_enable(&ctx->context.tasklet); + + return ret; +} + static const struct fw_card_driver ohci_driver = { .enable = ohci_enable, .read_phy_reg = ohci_read_phy_reg, @@ -3405,6 +3466,7 @@ static const struct fw_card_driver ohci_driver = { .set_iso_channels = ohci_set_iso_channels, .queue_iso = ohci_queue_iso, .flush_queue_iso = ohci_flush_queue_iso, + .flush_iso_completions = ohci_flush_iso_completions, .start_iso = ohci_start_iso, .stop_iso = ohci_stop_iso, }; diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h index b9bd349c693..d5003695349 100644 --- a/include/linux/firewire-cdev.h +++ b/include/linux/firewire-cdev.h @@ -212,10 +212,11 @@ struct fw_cdev_event_request2 { * @header: Stripped headers, if any * * This event is sent when the controller has completed an &fw_cdev_iso_packet - * with the %FW_CDEV_ISO_INTERRUPT bit set, or when there have been so many - * completed packets without the interrupt bit set that the kernel's internal - * buffer for @header is about to overflow. (In the latter case, kernels with - * ABI version < 5 drop header data up to the next interrupt packet.) + * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with + * %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets + * without the interrupt bit set that the kernel's internal buffer for @header + * is about to overflow. (In the last case, kernels with ABI version < 5 drop + * header data up to the next interrupt packet.) * * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT): * @@ -271,7 +272,8 @@ struct fw_cdev_event_iso_interrupt { * This event is sent in multichannel contexts (context type * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer * chunks that have been completely filled and that have the - * %FW_CDEV_ISO_INTERRUPT bit set. + * %FW_CDEV_ISO_INTERRUPT bit set, or when explicitly requested with + * %FW_CDEV_IOC_FLUSH_ISO. * * The buffer is continuously filled with the following data, per packet: * - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt, @@ -421,6 +423,9 @@ union fw_cdev_event { #define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets) #define FW_CDEV_IOC_SET_ISO_CHANNELS _IOW('#', 0x17, struct fw_cdev_set_iso_channels) +/* available since kernel version 3.4 */ +#define FW_CDEV_IOC_FLUSH_ISO _IOW('#', 0x18, struct fw_cdev_flush_iso) + /* * ABI version history * 1 (2.6.22) - initial version @@ -445,6 +450,7 @@ union fw_cdev_event { * %FW_CDEV_IOC_SET_ISO_CHANNELS * 5 (3.4) - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to * avoid dropping data + * - added %FW_CDEV_IOC_FLUSH_ISO */ /** @@ -854,6 +860,25 @@ struct fw_cdev_stop_iso { __u32 handle; }; +/** + * struct fw_cdev_flush_iso - flush completed iso packets + * @handle: handle of isochronous context to flush + * + * For %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, + * report any completed packets. + * + * For %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL contexts, report the current + * offset in the receive buffer, if it has changed; this is typically in the + * middle of some buffer chunk. + * + * Any %FW_CDEV_EVENT_ISO_INTERRUPT or %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL + * events generated by this ioctl are sent synchronously, i.e., are available + * for reading from the file descriptor when this ioctl returns. + */ +struct fw_cdev_flush_iso { + __u32 handle; +}; + /** * struct fw_cdev_get_cycle_timer - read cycle timer register * @local_time: system time, in microseconds since the Epoch diff --git a/include/linux/firewire.h b/include/linux/firewire.h index ab5b7a18dec..cdc9b719e9c 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -426,6 +426,7 @@ int fw_iso_context_queue(struct fw_iso_context *ctx, struct fw_iso_buffer *buffer, unsigned long payload); void fw_iso_context_queue_flush(struct fw_iso_context *ctx); +int fw_iso_context_flush_completions(struct fw_iso_context *ctx); int fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags); int fw_iso_context_stop(struct fw_iso_context *ctx); -- cgit v1.2.3-70-g09d2