Commit febb02bd authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6: (53 commits)
  DVB: firedtv: FireDTV S2 problems with tuning solved
  DVB: firedtv: fix printk format mismatch
  ieee1394: constify device ID tables
  ieee1394: raw1394: add sparse annotations to raw1394_compat_write
  ieee1394: Storage class should be before const qualifier
  ieee1394: sbp2: follow up on "ieee1394: inherit ud vendor_id from node vendor_id"
  firewire: core: optimize propagation of BROADCAST_CHANNEL
  firewire: core: simplify broadcast channel allocation
  firewire: core: increase bus manager grace period
  firewire: core: drop unused call parameters of close_transaction
  firewire: cdev: add closure to async stream ioctl
  firewire: cdev: simplify FW_CDEV_IOC_SEND_REQUEST return value
  firewire: cdev: fix race of ioctl_send_request with bus reset
  firewire: cdev: secure add_descriptor ioctl
  firewire: cdev: amendment to "add ioctl to query maximum transmission speed"
  firewire: broadcast channel support
  firewire: implement asynchronous stream transmission
  firewire: core: normalize a function argument name
  firewire: normalize a variable name
  firewire: core: remove condition which is always false
  ...
parents 0b4d569d 32a0f488
...@@ -63,8 +63,7 @@ static int descriptor_count; ...@@ -63,8 +63,7 @@ static int descriptor_count;
#define BIB_CMC ((1) << 30) #define BIB_CMC ((1) << 30)
#define BIB_IMC ((1) << 31) #define BIB_IMC ((1) << 31)
static u32 * static u32 *generate_config_rom(struct fw_card *card, size_t *config_rom_length)
generate_config_rom(struct fw_card *card, size_t *config_rom_length)
{ {
struct fw_descriptor *desc; struct fw_descriptor *desc;
static u32 config_rom[256]; static u32 config_rom[256];
...@@ -128,8 +127,7 @@ generate_config_rom(struct fw_card *card, size_t *config_rom_length) ...@@ -128,8 +127,7 @@ generate_config_rom(struct fw_card *card, size_t *config_rom_length)
return config_rom; return config_rom;
} }
static void static void update_config_roms(void)
update_config_roms(void)
{ {
struct fw_card *card; struct fw_card *card;
u32 *config_rom; u32 *config_rom;
...@@ -141,8 +139,7 @@ update_config_roms(void) ...@@ -141,8 +139,7 @@ update_config_roms(void)
} }
} }
int int fw_core_add_descriptor(struct fw_descriptor *desc)
fw_core_add_descriptor(struct fw_descriptor *desc)
{ {
size_t i; size_t i;
...@@ -171,8 +168,7 @@ fw_core_add_descriptor(struct fw_descriptor *desc) ...@@ -171,8 +168,7 @@ fw_core_add_descriptor(struct fw_descriptor *desc)
return 0; return 0;
} }
void void fw_core_remove_descriptor(struct fw_descriptor *desc)
fw_core_remove_descriptor(struct fw_descriptor *desc)
{ {
mutex_lock(&card_mutex); mutex_lock(&card_mutex);
...@@ -185,12 +181,30 @@ fw_core_remove_descriptor(struct fw_descriptor *desc) ...@@ -185,12 +181,30 @@ fw_core_remove_descriptor(struct fw_descriptor *desc)
mutex_unlock(&card_mutex); mutex_unlock(&card_mutex);
} }
static int set_broadcast_channel(struct device *dev, void *data)
{
fw_device_set_broadcast_channel(fw_device(dev), (long)data);
return 0;
}
static void allocate_broadcast_channel(struct fw_card *card, int generation)
{
int channel, bandwidth = 0;
fw_iso_resource_manage(card, generation, 1ULL << 31,
&channel, &bandwidth, true);
if (channel == 31) {
card->broadcast_channel_allocated = true;
device_for_each_child(card->device, (void *)(long)generation,
set_broadcast_channel);
}
}
static const char gap_count_table[] = { static const char gap_count_table[] = {
63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
}; };
void void fw_schedule_bm_work(struct fw_card *card, unsigned long delay)
fw_schedule_bm_work(struct fw_card *card, unsigned long delay)
{ {
int scheduled; int scheduled;
...@@ -200,37 +214,38 @@ fw_schedule_bm_work(struct fw_card *card, unsigned long delay) ...@@ -200,37 +214,38 @@ fw_schedule_bm_work(struct fw_card *card, unsigned long delay)
fw_card_put(card); fw_card_put(card);
} }
static void static void fw_card_bm_work(struct work_struct *work)
fw_card_bm_work(struct work_struct *work)
{ {
struct fw_card *card = container_of(work, struct fw_card, work.work); struct fw_card *card = container_of(work, struct fw_card, work.work);
struct fw_device *root_device; struct fw_device *root_device;
struct fw_node *root_node, *local_node; struct fw_node *root_node;
unsigned long flags; unsigned long flags;
int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode; int root_id, new_root_id, irm_id, local_id;
int gap_count, generation, grace, rcode;
bool do_reset = false; bool do_reset = false;
bool root_device_is_running; bool root_device_is_running;
bool root_device_is_cmc; bool root_device_is_cmc;
__be32 lock_data[2]; __be32 lock_data[2];
spin_lock_irqsave(&card->lock, flags); spin_lock_irqsave(&card->lock, flags);
local_node = card->local_node;
root_node = card->root_node;
if (local_node == NULL) { if (card->local_node == NULL) {
spin_unlock_irqrestore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
goto out_put_card; goto out_put_card;
} }
fw_node_get(local_node);
fw_node_get(root_node);
generation = card->generation; generation = card->generation;
root_node = card->root_node;
fw_node_get(root_node);
root_device = root_node->data; root_device = root_node->data;
root_device_is_running = root_device && root_device_is_running = root_device &&
atomic_read(&root_device->state) == FW_DEVICE_RUNNING; atomic_read(&root_device->state) == FW_DEVICE_RUNNING;
root_device_is_cmc = root_device && root_device->cmc; root_device_is_cmc = root_device && root_device->cmc;
root_id = root_node->node_id; root_id = root_node->node_id;
grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); irm_id = card->irm_node->node_id;
local_id = card->local_node->node_id;
grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 8));
if (is_next_generation(generation, card->bm_generation) || if (is_next_generation(generation, card->bm_generation) ||
(card->bm_generation != generation && grace)) { (card->bm_generation != generation && grace)) {
...@@ -246,16 +261,15 @@ fw_card_bm_work(struct work_struct *work) ...@@ -246,16 +261,15 @@ fw_card_bm_work(struct work_struct *work)
* next generation. * next generation.
*/ */
irm_id = card->irm_node->node_id;
if (!card->irm_node->link_on) { if (!card->irm_node->link_on) {
new_root_id = local_node->node_id; new_root_id = local_id;
fw_notify("IRM has link off, making local node (%02x) root.\n", fw_notify("IRM has link off, making local node (%02x) root.\n",
new_root_id); new_root_id);
goto pick_me; goto pick_me;
} }
lock_data[0] = cpu_to_be32(0x3f); lock_data[0] = cpu_to_be32(0x3f);
lock_data[1] = cpu_to_be32(local_node->node_id); lock_data[1] = cpu_to_be32(local_id);
spin_unlock_irqrestore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
...@@ -269,9 +283,14 @@ fw_card_bm_work(struct work_struct *work) ...@@ -269,9 +283,14 @@ fw_card_bm_work(struct work_struct *work)
goto out; goto out;
if (rcode == RCODE_COMPLETE && if (rcode == RCODE_COMPLETE &&
lock_data[0] != cpu_to_be32(0x3f)) lock_data[0] != cpu_to_be32(0x3f)) {
/* Somebody else is BM, let them do the work. */
/* Somebody else is BM. Only act as IRM. */
if (local_id == irm_id)
allocate_broadcast_channel(card, generation);
goto out; goto out;
}
spin_lock_irqsave(&card->lock, flags); spin_lock_irqsave(&card->lock, flags);
...@@ -282,19 +301,18 @@ fw_card_bm_work(struct work_struct *work) ...@@ -282,19 +301,18 @@ fw_card_bm_work(struct work_struct *work)
* do a bus reset and pick the local node as * do a bus reset and pick the local node as
* root, and thus, IRM. * root, and thus, IRM.
*/ */
new_root_id = local_node->node_id; new_root_id = local_id;
fw_notify("BM lock failed, making local node (%02x) root.\n", fw_notify("BM lock failed, making local node (%02x) root.\n",
new_root_id); new_root_id);
goto pick_me; goto pick_me;
} }
} else if (card->bm_generation != generation) { } else if (card->bm_generation != generation) {
/* /*
* OK, we weren't BM in the last generation, and it's * We weren't BM in the last generation, and the last
* less than 100ms since last bus reset. Reschedule * bus reset is less than 125ms ago. Reschedule this job.
* this task 100ms from now.
*/ */
spin_unlock_irqrestore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 10)); fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8));
goto out; goto out;
} }
...@@ -310,7 +328,7 @@ fw_card_bm_work(struct work_struct *work) ...@@ -310,7 +328,7 @@ fw_card_bm_work(struct work_struct *work)
* Either link_on is false, or we failed to read the * Either link_on is false, or we failed to read the
* config rom. In either case, pick another root. * config rom. In either case, pick another root.
*/ */
new_root_id = local_node->node_id; new_root_id = local_id;
} else if (!root_device_is_running) { } else if (!root_device_is_running) {
/* /*
* If we haven't probed this device yet, bail out now * If we haven't probed this device yet, bail out now
...@@ -332,7 +350,7 @@ fw_card_bm_work(struct work_struct *work) ...@@ -332,7 +350,7 @@ fw_card_bm_work(struct work_struct *work)
* successfully read the config rom, but it's not * successfully read the config rom, but it's not
* cycle master capable. * cycle master capable.
*/ */
new_root_id = local_node->node_id; new_root_id = local_id;
} }
pick_me: pick_me:
...@@ -363,24 +381,27 @@ fw_card_bm_work(struct work_struct *work) ...@@ -363,24 +381,27 @@ fw_card_bm_work(struct work_struct *work)
card->index, new_root_id, gap_count); card->index, new_root_id, gap_count);
fw_send_phy_config(card, new_root_id, generation, gap_count); fw_send_phy_config(card, new_root_id, generation, gap_count);
fw_core_initiate_bus_reset(card, 1); fw_core_initiate_bus_reset(card, 1);
/* Will allocate broadcast channel after the reset. */
} else {
if (local_id == irm_id)
allocate_broadcast_channel(card, generation);
} }
out: out:
fw_node_put(root_node); fw_node_put(root_node);
fw_node_put(local_node);
out_put_card: out_put_card:
fw_card_put(card); fw_card_put(card);
} }
static void static void flush_timer_callback(unsigned long data)
flush_timer_callback(unsigned long data)
{ {
struct fw_card *card = (struct fw_card *)data; struct fw_card *card = (struct fw_card *)data;
fw_flush_transactions(card); fw_flush_transactions(card);
} }
void void fw_card_initialize(struct fw_card *card,
fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, const struct fw_card_driver *driver,
struct device *device) struct device *device)
{ {
static atomic_t index = ATOMIC_INIT(-1); static atomic_t index = ATOMIC_INIT(-1);
...@@ -406,13 +427,12 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, ...@@ -406,13 +427,12 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
} }
EXPORT_SYMBOL(fw_card_initialize); EXPORT_SYMBOL(fw_card_initialize);
int int fw_card_add(struct fw_card *card,
fw_card_add(struct fw_card *card,
u32 max_receive, u32 link_speed, u64 guid) u32 max_receive, u32 link_speed, u64 guid)
{ {
u32 *config_rom; u32 *config_rom;
size_t length; size_t length;
int err; int ret;
card->max_receive = max_receive; card->max_receive = max_receive;
card->link_speed = link_speed; card->link_speed = link_speed;
...@@ -423,13 +443,14 @@ fw_card_add(struct fw_card *card, ...@@ -423,13 +443,14 @@ fw_card_add(struct fw_card *card,
list_add_tail(&card->link, &card_list); list_add_tail(&card->link, &card_list);
mutex_unlock(&card_mutex); mutex_unlock(&card_mutex);
err = card->driver->enable(card, config_rom, length); ret = card->driver->enable(card, config_rom, length);
if (err < 0) { if (ret < 0) {
mutex_lock(&card_mutex); mutex_lock(&card_mutex);
list_del(&card->link); list_del(&card->link);
mutex_unlock(&card_mutex); mutex_unlock(&card_mutex);
} }
return err;
return ret;
} }
EXPORT_SYMBOL(fw_card_add); EXPORT_SYMBOL(fw_card_add);
...@@ -442,22 +463,19 @@ EXPORT_SYMBOL(fw_card_add); ...@@ -442,22 +463,19 @@ EXPORT_SYMBOL(fw_card_add);
* dummy driver just fails all IO. * dummy driver just fails all IO.
*/ */
static int static int dummy_enable(struct fw_card *card, u32 *config_rom, size_t length)
dummy_enable(struct fw_card *card, u32 *config_rom, size_t length)
{ {
BUG(); BUG();
return -1; return -1;
} }
static int static int dummy_update_phy_reg(struct fw_card *card, int address,
dummy_update_phy_reg(struct fw_card *card, int address,
int clear_bits, int set_bits) int clear_bits, int set_bits)
{ {
return -ENODEV; return -ENODEV;
} }
static int static int dummy_set_config_rom(struct fw_card *card,
dummy_set_config_rom(struct fw_card *card,
u32 *config_rom, size_t length) u32 *config_rom, size_t length)
{ {
/* /*
...@@ -468,26 +486,22 @@ dummy_set_config_rom(struct fw_card *card, ...@@ -468,26 +486,22 @@ dummy_set_config_rom(struct fw_card *card,
return -1; return -1;
} }
static void static void dummy_send_request(struct fw_card *card, struct fw_packet *packet)
dummy_send_request(struct fw_card *card, struct fw_packet *packet)
{ {
packet->callback(packet, card, -ENODEV); packet->callback(packet, card, -ENODEV);
} }
static void static void dummy_send_response(struct fw_card *card, struct fw_packet *packet)
dummy_send_response(struct fw_card *card, struct fw_packet *packet)
{ {
packet->callback(packet, card, -ENODEV); packet->callback(packet, card, -ENODEV);
} }
static int static int dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet)
dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet)
{ {
return -ENOENT; return -ENOENT;
} }
static int static int dummy_enable_phys_dma(struct fw_card *card,
dummy_enable_phys_dma(struct fw_card *card,
int node_id, int generation) int node_id, int generation)
{ {
return -ENODEV; return -ENODEV;
...@@ -503,16 +517,14 @@ static struct fw_card_driver dummy_driver = { ...@@ -503,16 +517,14 @@ static struct fw_card_driver dummy_driver = {
.enable_phys_dma = dummy_enable_phys_dma, .enable_phys_dma = dummy_enable_phys_dma,
}; };
void void fw_card_release(struct kref *kref)
fw_card_release(struct kref *kref)
{ {
struct fw_card *card = container_of(kref, struct fw_card, kref); struct fw_card *card = container_of(kref, struct fw_card, kref);
complete(&card->done); complete(&card->done);
} }
void void fw_core_remove_card(struct fw_card *card)
fw_core_remove_card(struct fw_card *card)
{ {
card->driver->update_phy_reg(card, 4, card->driver->update_phy_reg(card, 4,
PHY_LINK_ACTIVE | PHY_CONTENDER, 0); PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
...@@ -536,8 +548,7 @@ fw_core_remove_card(struct fw_card *card) ...@@ -536,8 +548,7 @@ fw_core_remove_card(struct fw_card *card)
} }
EXPORT_SYMBOL(fw_core_remove_card); EXPORT_SYMBOL(fw_core_remove_card);
int int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset)
fw_core_initiate_bus_reset(struct fw_card *card, int short_reset)
{ {
int reg = short_reset ? 5 : 1; int reg = short_reset ? 5 : 1;
int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET; int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET;
......
This diff is collapsed.
...@@ -18,22 +18,26 @@ ...@@ -18,22 +18,26 @@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <linux/module.h> #include <linux/ctype.h>
#include <linux/wait.h>
#include <linux/errno.h>
#include <linux/kthread.h>
#include <linux/device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/string.h> #include <linux/kobject.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/workqueue.h>
#include <asm/system.h> #include <asm/system.h>
#include <linux/ctype.h>
#include "fw-transaction.h"
#include "fw-topology.h"
#include "fw-device.h" #include "fw-device.h"
#include "fw-topology.h"
#include "fw-transaction.h"
void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 * p) void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 * p)
{ {
...@@ -132,8 +136,7 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) ...@@ -132,8 +136,7 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
vendor, model, specifier_id, version); vendor, model, specifier_id, version);
} }
static int static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
{ {
struct fw_unit *unit = fw_unit(dev); struct fw_unit *unit = fw_unit(dev);
char modalias[64]; char modalias[64];
...@@ -152,27 +155,6 @@ struct bus_type fw_bus_type = { ...@@ -152,27 +155,6 @@ struct bus_type fw_bus_type = {
}; };
EXPORT_SYMBOL(fw_bus_type); EXPORT_SYMBOL(fw_bus_type);
static void fw_device_release(struct device *dev)
{
struct fw_device *device = fw_device(dev);
struct fw_card *card = device->card;
unsigned long flags;
/*
* Take the card lock so we don't set this to NULL while a
* FW_NODE_UPDATED callback is being handled or while the
* bus manager work looks at this node.
*/
spin_lock_irqsave(&card->lock, flags);
device->node->data = NULL;
spin_unlock_irqrestore(&card->lock, flags);
fw_node_put(device->node);
kfree(device->config_rom);
kfree(device);
fw_card_put(card);
}
int fw_device_enable_phys_dma(struct fw_device *device) int fw_device_enable_phys_dma(struct fw_device *device)
{ {
int generation = device->generation; int generation = device->generation;
...@@ -191,8 +173,8 @@ struct config_rom_attribute { ...@@ -191,8 +173,8 @@ struct config_rom_attribute {
u32 key; u32 key;
}; };
static ssize_t static ssize_t show_immediate(struct device *dev,
show_immediate(struct device *dev, struct device_attribute *dattr, char *buf) struct device_attribute *dattr, char *buf)
{ {
struct config_rom_attribute *attr = struct config_rom_attribute *attr =
container_of(dattr, struct config_rom_attribute, attr); container_of(dattr, struct config_rom_attribute, attr);
...@@ -223,8 +205,8 @@ show_immediate(struct device *dev, struct device_attribute *dattr, char *buf) ...@@ -223,8 +205,8 @@ show_immediate(struct device *dev, struct device_attribute *dattr, char *buf)
#define IMMEDIATE_ATTR(name, key) \ #define IMMEDIATE_ATTR(name, key) \
{ __ATTR(name, S_IRUGO, show_immediate, NULL), key } { __ATTR(name, S_IRUGO, show_immediate, NULL), key }
static ssize_t static ssize_t show_text_leaf(struct device *dev,
show_text_leaf(struct device *dev, struct device_attribute *dattr, char *buf) struct device_attribute *dattr, char *buf)
{ {
struct config_rom_attribute *attr = struct config_rom_attribute *attr =
container_of(dattr, struct config_rom_attribute, attr); container_of(dattr, struct config_rom_attribute, attr);
...@@ -293,8 +275,7 @@ static struct config_rom_attribute config_rom_attributes[] = { ...@@ -293,8 +275,7 @@ static struct config_rom_attribute config_rom_attributes[] = {
TEXT_LEAF_ATTR(hardware_version_name, CSR_HARDWARE_VERSION), TEXT_LEAF_ATTR(hardware_version_name, CSR_HARDWARE_VERSION),
}; };
static void static void init_fw_attribute_group(struct device *dev,
init_fw_attribute_group(struct device *dev,
struct device_attribute *attrs, struct device_attribute *attrs,
struct fw_attribute_group *group) struct fw_attribute_group *group)
{ {
...@@ -319,8 +300,7 @@ init_fw_attribute_group(struct device *dev, ...@@ -319,8 +300,7 @@ init_fw_attribute_group(struct device *dev,
dev->groups = group->groups; dev->groups = group->groups;
} }
static ssize_t static ssize_t modalias_show(struct device *dev,
modalias_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct fw_unit *unit = fw_unit(dev); struct fw_unit *unit = fw_unit(dev);
...@@ -332,8 +312,7 @@ modalias_show(struct device *dev, ...@@ -332,8 +312,7 @@ modalias_show(struct device *dev,
return length + 1; return length + 1;
} }
static ssize_t static ssize_t rom_index_show(struct device *dev,
rom_index_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct fw_device *device = fw_device(dev->parent); struct fw_device *device = fw_device(dev->parent);
...@@ -349,8 +328,8 @@ static struct device_attribute fw_unit_attributes[] = { ...@@ -349,8 +328,8 @@ static struct device_attribute fw_unit_attributes[] = {
__ATTR_NULL, __ATTR_NULL,
}; };
static ssize_t static ssize_t config_rom_show(struct device *dev,
config_rom_show(struct device *dev, struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct fw_device *device = fw_device(dev); struct fw_device *device = fw_device(dev);
size_t length; size_t length;
...@@ -363,8 +342,8 @@ config_rom_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -363,8 +342,8 @@ config_rom_show(struct device *dev, struct device_attribute *attr, char *buf)
return length; return length;
} }
static ssize_t static ssize_t guid_show(struct device *dev,
guid_show(struct device *dev, struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct fw_device *device = fw_device(dev); struct fw_device *device = fw_device(dev);
int ret; int ret;
...@@ -383,8 +362,8 @@ static struct device_attribute fw_device_attributes[] = { ...@@ -383,8 +362,8 @@ static struct device_attribute fw_device_attributes[] = {
__ATTR_NULL, __ATTR_NULL,
}; };
static int static int read_rom(struct fw_device *device,
read_rom(struct fw_device *device, int generation, int index, u32 *data) int generation, int index, u32 *data)
{ {
int rcode; int rcode;
...@@ -539,7 +518,7 @@ static int read_bus_info_block(struct fw_device *device, int generation) ...@@ -539,7 +518,7 @@ static int read_bus_info_block(struct fw_device *device, int generation)
kfree(old_rom); kfree(old_rom);
ret = 0; ret = 0;
device->cmc = rom[2] & 1 << 30; device->cmc = rom[2] >> 30 & 1;
out: out:
kfree(rom); kfree(rom);
...@@ -679,11 +658,53 @@ static void fw_device_shutdown(struct work_struct *work) ...@@ -679,11 +658,53 @@ static void fw_device_shutdown(struct work_struct *work)
fw_device_put(device); fw_device_put(device);
} }
static void fw_device_release(struct device *dev)
{
struct fw_device *device = fw_device(dev);
struct fw_card *card = device->card;
unsigned long flags;
/*
* Take the card lock so we don't set this to NULL while a
* FW_NODE_UPDATED callback is being handled or while the
* bus manager work looks at this node.
*/
spin_lock_irqsave(&card->lock, flags);
device->node->data = NULL;
spin_unlock_irqrestore(&card->lock, flags);
fw_node_put(device->node);
kfree(device->config_rom);
kfree(device);
fw_card_put(card);
}
static struct device_type fw_device_type = { static struct device_type fw_device_type = {
.release = fw_device_release, .release = fw_device_release,
}; };
static void fw_device_update(struct work_struct *work); static int update_unit(struct device *dev, void *data)
{
struct fw_unit *unit = fw_unit(dev);
struct fw_driver *driver = (struct fw_driver *)dev->driver;
if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) {
down(&dev->sem);
driver->update(unit);
up(&dev->sem);
}
return 0;
}
static void fw_device_update(struct work_struct *work)
{
struct fw_device *device =
container_of(work, struct fw_device, work.work);
fw_device_cdev_update(device);
device_for_each_child(&device->device, NULL, update_unit);
}
/* /*
* If a device was pending for deletion because its node went away but its * If a device was pending for deletion because its node went away but its
...@@ -735,12 +756,50 @@ static int lookup_existing_device(struct device *dev, void *data) ...@@ -735,12 +756,50 @@ static int lookup_existing_device(struct device *dev, void *data)
return match; return match;
} }
enum { BC_UNKNOWN = 0, BC_UNIMPLEMENTED, BC_IMPLEMENTED, };
void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
{
struct fw_card *card = device->card;
__be32 data;
int rcode;
if (!card->broadcast_channel_allocated)
return;
if (device->bc_implemented == BC_UNKNOWN) {
rcode = fw_run_transaction(card, TCODE_READ_QUADLET_REQUEST,
device->node_id, generation, device->max_speed,
CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
&data, 4);
switch (rcode) {
case RCODE_COMPLETE:
if (data & cpu_to_be32(1 << 31)) {
device->bc_implemented = BC_IMPLEMENTED;
break;
}
/* else fall through to case address error */
case RCODE_ADDRESS_ERROR:
device->bc_implemented = BC_UNIMPLEMENTED;
}
}
if (device->bc_implemented == BC_IMPLEMENTED) {
data = cpu_to_be32(BROADCAST_CHANNEL_INITIAL |
BROADCAST_CHANNEL_VALID);
fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST,
device->node_id, generation, device->max_speed,
CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
&data, 4);
}
}
static void fw_device_init(struct work_struct *work) static void fw_device_init(struct work_struct *work)
{ {
struct fw_device *device = struct fw_device *device =
container_of(work, struct fw_device, work.work); container_of(work, struct fw_device, work.work);
struct device *revived_dev; struct device *revived_dev;
int minor, err; int minor, ret;
/* /*
* All failure paths here set node->data to NULL, so that we * All failure paths here set node->data to NULL, so that we
...@@ -776,12 +835,12 @@ static void fw_device_init(struct work_struct *work) ...@@ -776,12 +835,12 @@ static void fw_device_init(struct work_struct *work)
fw_device_get(device); fw_device_get(device);
down_write(&fw_device_rwsem); down_write(&fw_device_rwsem);
err = idr_pre_get(&fw_device_idr, GFP_KERNEL) ? ret = idr_pre_get(&fw_device_idr, GFP_KERNEL) ?
idr_get_new(&fw_device_idr, device, &minor) : idr_get_new(&fw_device_idr, device, &minor) :
-ENOMEM; -ENOMEM;
up_write(&fw_device_rwsem); up_write(&fw_device_rwsem);
if (err < 0) if (ret < 0)
goto error; goto error;
device->device.bus = &fw_bus_type; device->device.bus = &fw_bus_type;
...@@ -828,6 +887,8 @@ static void fw_device_init(struct work_struct *work) ...@@ -828,6 +887,8 @@ static void fw_device_init(struct work_struct *work)
device->config_rom[3], device->config_rom[4], device->config_rom[3], device->config_rom[4],
1 << device->max_speed); 1 << device->max_speed);
device->config_rom_retries = 0; device->config_rom_retries = 0;
fw_device_set_broadcast_channel(device, device->generation);
} }
/* /*
...@@ -851,29 +912,6 @@ static void fw_device_init(struct work_struct *work) ...@@ -851,29 +912,6 @@ static void fw_device_init(struct work_struct *work)
put_device(&device->device); /* our reference */ put_device(&device->device); /* our reference */
} }
static int update_unit(struct device *dev, void *data)
{
struct fw_unit *unit = fw_unit(dev);
struct fw_driver *driver = (struct fw_driver *)dev->driver;
if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) {
down(&dev->sem);
driver->update(unit);
up(&dev->sem);
}
return 0;
}
static void fw_device_update(struct work_struct *work)
{
struct fw_device *device =
container_of(work, struct fw_device, work.work);
fw_device_cdev_update(device);
device_for_each_child(&device->device, NULL, update_unit);
}
enum { enum {
REREAD_BIB_ERROR, REREAD_BIB_ERROR,
REREAD_BIB_GONE, REREAD_BIB_GONE,
...@@ -894,7 +932,7 @@ static int reread_bus_info_block(struct fw_device *device, int generation) ...@@ -894,7 +932,7 @@ static int reread_bus_info_block(struct fw_device *device, int generation)
if (i == 0 && q == 0) if (i == 0 && q == 0)
return REREAD_BIB_GONE; return REREAD_BIB_GONE;
if (i > device->config_rom_length || q != device->config_rom[i]) if (q != device->config_rom[i])
return REREAD_BIB_CHANGED; return REREAD_BIB_CHANGED;
} }
...@@ -1004,6 +1042,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) ...@@ -1004,6 +1042,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
device->node = fw_node_get(node); device->node = fw_node_get(node);
device->node_id = node->node_id; device->node_id = node->node_id;
device->generation = card->generation; device->generation = card->generation;
mutex_init(&device->client_list_mutex);
INIT_LIST_HEAD(&device->client_list); INIT_LIST_HEAD(&device->client_list);
/* /*
......
...@@ -19,10 +19,17 @@ ...@@ -19,10 +19,17 @@
#ifndef __fw_device_h #ifndef __fw_device_h
#define __fw_device_h #define __fw_device_h
#include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include <asm/atomic.h> #include <asm/atomic.h>
enum fw_device_state { enum fw_device_state {
...@@ -38,6 +45,9 @@ struct fw_attribute_group { ...@@ -38,6 +45,9 @@ struct fw_attribute_group {
struct attribute *attrs[11]; struct attribute *attrs[11];
}; };
struct fw_node;
struct fw_card;
/* /*
* Note, fw_device.generation always has to be read before fw_device.node_id. * Note, fw_device.generation always has to be read before fw_device.node_id.
* Use SMP memory barriers to ensure this. Otherwise requests will be sent * Use SMP memory barriers to ensure this. Otherwise requests will be sent
...@@ -61,13 +71,18 @@ struct fw_device { ...@@ -61,13 +71,18 @@ struct fw_device {
int node_id; int node_id;
int generation; int generation;
unsigned max_speed; unsigned max_speed;
bool cmc;
struct fw_card *card; struct fw_card *card;
struct device device; struct device device;
struct mutex client_list_mutex;
struct list_head client_list; struct list_head client_list;
u32 *config_rom; u32 *config_rom;
size_t config_rom_length; size_t config_rom_length;
int config_rom_retries; int config_rom_retries;
unsigned cmc:1;
unsigned bc_implemented:2;
struct delayed_work work; struct delayed_work work;
struct fw_attribute_group attribute_group; struct fw_attribute_group attribute_group;
}; };
...@@ -96,6 +111,7 @@ static inline void fw_device_put(struct fw_device *device) ...@@ -96,6 +111,7 @@ static inline void fw_device_put(struct fw_device *device)
struct fw_device *fw_device_get_by_devt(dev_t devt); struct fw_device *fw_device_get_by_devt(dev_t devt);
int fw_device_enable_phys_dma(struct fw_device *device); int fw_device_enable_phys_dma(struct fw_device *device);
void fw_device_set_broadcast_channel(struct fw_device *device, int generation);
void fw_device_cdev_update(struct fw_device *device); void fw_device_cdev_update(struct fw_device *device);
void fw_device_cdev_remove(struct fw_device *device); void fw_device_cdev_remove(struct fw_device *device);
...@@ -176,8 +192,7 @@ struct fw_driver { ...@@ -176,8 +192,7 @@ struct fw_driver {
const struct fw_device_id *id_table; const struct fw_device_id *id_table;
}; };
static inline struct fw_driver * static inline struct fw_driver *fw_driver(struct device_driver *drv)
fw_driver(struct device_driver *drv)
{ {
return container_of(drv, struct fw_driver, driver); return container_of(drv, struct fw_driver, driver);
} }
......
/* /*
* Isochronous IO functionality * Isochronous I/O functionality:
* - Isochronous DMA context management
* - Isochronous bus resource management (channels, bandwidth), client side
* *
* Copyright (C) 2006 Kristian Hoegsberg <krh@bitplanet.net> * Copyright (C) 2006 Kristian Hoegsberg <krh@bitplanet.net>
* *
...@@ -18,21 +20,25 @@ ...@@ -18,21 +20,25 @@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/vmalloc.h> #include <linux/errno.h>
#include <linux/firewire-constants.h>
#include <linux/kernel.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
#include "fw-transaction.h"
#include "fw-topology.h" #include "fw-topology.h"
#include "fw-device.h" #include "fw-transaction.h"
/*
* Isochronous DMA context management
*/
int int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
int page_count, enum dma_data_direction direction) int page_count, enum dma_data_direction direction)
{ {
int i, j, retval = -ENOMEM; int i, j;
dma_addr_t address; dma_addr_t address;
buffer->page_count = page_count; buffer->page_count = page_count;
...@@ -69,19 +75,21 @@ fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, ...@@ -69,19 +75,21 @@ fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
kfree(buffer->pages); kfree(buffer->pages);
out: out:
buffer->pages = NULL; buffer->pages = NULL;
return retval;
return -ENOMEM;
} }
int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma)
{ {
unsigned long uaddr; unsigned long uaddr;
int i, retval; int i, err;
uaddr = vma->vm_start; uaddr = vma->vm_start;
for (i = 0; i < buffer->page_count; i++) { for (i = 0; i < buffer->page_count; i++) {
retval = vm_insert_page(vma, uaddr, buffer->pages[i]); err = vm_insert_page(vma, uaddr, buffer->pages[i]);
if (retval) if (err)
return retval; return err;
uaddr += PAGE_SIZE; uaddr += PAGE_SIZE;
} }
...@@ -105,14 +113,14 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, ...@@ -105,14 +113,14 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer,
buffer->pages = NULL; buffer->pages = NULL;
} }
struct fw_iso_context * struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
fw_iso_context_create(struct fw_card *card, int type, int type, int channel, int speed, size_t header_size,
int channel, int speed, size_t header_size,
fw_iso_callback_t callback, void *callback_data) fw_iso_callback_t callback, void *callback_data)
{ {
struct fw_iso_context *ctx; struct fw_iso_context *ctx;
ctx = card->driver->allocate_iso_context(card, type, header_size); ctx = card->driver->allocate_iso_context(card,
type, channel, header_size);
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return ctx; return ctx;
...@@ -134,14 +142,13 @@ void fw_iso_context_destroy(struct fw_iso_context *ctx) ...@@ -134,14 +142,13 @@ void fw_iso_context_destroy(struct fw_iso_context *ctx)
card->driver->free_iso_context(ctx); card->driver->free_iso_context(ctx);
} }
int int fw_iso_context_start(struct fw_iso_context *ctx,
fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags) int cycle, int sync, int tags)
{ {
return ctx->card->driver->start_iso(ctx, cycle, sync, tags); return ctx->card->driver->start_iso(ctx, cycle, sync, tags);
} }
int int fw_iso_context_queue(struct fw_iso_context *ctx,
fw_iso_context_queue(struct fw_iso_context *ctx,
struct fw_iso_packet *packet, struct fw_iso_packet *packet,
struct fw_iso_buffer *buffer, struct fw_iso_buffer *buffer,
unsigned long payload) unsigned long payload)
...@@ -151,8 +158,170 @@ fw_iso_context_queue(struct fw_iso_context *ctx, ...@@ -151,8 +158,170 @@ fw_iso_context_queue(struct fw_iso_context *ctx,
return card->driver->queue_iso(ctx, packet, buffer, payload); return card->driver->queue_iso(ctx, packet, buffer, payload);
} }
int int fw_iso_context_stop(struct fw_iso_context *ctx)
fw_iso_context_stop(struct fw_iso_context *ctx)
{ {
return ctx->card->driver->stop_iso(ctx); return ctx->card->driver->stop_iso(ctx);
} }
/*
* Isochronous bus resource management (channels, bandwidth), client side
*/
static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
int bandwidth, bool allocate)
{
__be32 data[2];
int try, new, old = allocate ? BANDWIDTH_AVAILABLE_INITIAL : 0;
/*
* On a 1394a IRM with low contention, try < 1 is enough.
* On a 1394-1995 IRM, we need at least try < 2.
* Let's just do try < 5.
*/
for (try = 0; try < 5; try++) {
new = allocate ? old - bandwidth : old + bandwidth;
if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL)
break;
data[0] = cpu_to_be32(old);
data[1] = cpu_to_be32(new);
switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP,
irm_id, generation, SCODE_100,
CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE,
data, sizeof(data))) {
case RCODE_GENERATION:
/* A generation change frees all bandwidth. */
return allocate ? -EAGAIN : bandwidth;
case RCODE_COMPLETE:
if (be32_to_cpup(data) == old)
return bandwidth;
old = be32_to_cpup(data);
/* Fall through. */
}
}
return -EIO;
}
static int manage_channel(struct fw_card *card, int irm_id, int generation,
u32 channels_mask, u64 offset, bool allocate)
{
__be32 data[2], c, all, old;
int i, retry = 5;
old = all = allocate ? cpu_to_be32(~0) : 0;
for (i = 0; i < 32; i++) {
if (!(channels_mask & 1 << i))
continue;
c = cpu_to_be32(1 << (31 - i));
if ((old & c) != (all & c))
continue;
data[0] = old;
data[1] = old ^ c;
switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP,
irm_id, generation, SCODE_100,
offset, data, sizeof(data))) {
case RCODE_GENERATION:
/* A generation change frees all channels. */
return allocate ? -EAGAIN : i;
case RCODE_COMPLETE:
if (data[0] == old)
return i;
old = data[0];
/* Is the IRM 1394a-2000 compliant? */
if ((data[0] & c) == (data[1] & c))
continue;
/* 1394-1995 IRM, fall through to retry. */
default:
if (retry--)
i--;
}
}
return -EIO;
}
static void deallocate_channel(struct fw_card *card, int irm_id,
int generation, int channel)
{
u32 mask;
u64 offset;
mask = channel < 32 ? 1 << channel : 1 << (channel - 32);
offset = channel < 32 ? CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI :
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO;
manage_channel(card, irm_id, generation, mask, offset, false);
}
/**
* fw_iso_resource_manage - Allocate or deallocate a channel and/or bandwidth
*
* In parameters: card, generation, channels_mask, bandwidth, allocate
* Out parameters: channel, bandwidth
* This function blocks (sleeps) during communication with the IRM.
*
* Allocates or deallocates at most one channel out of channels_mask.
* channels_mask is a bitfield with MSB for channel 63 and LSB for channel 0.
* (Note, the IRM's CHANNELS_AVAILABLE is a big-endian bitfield with MSB for
* channel 0 and LSB for channel 63.)
* Allocates or deallocates as many bandwidth allocation units as specified.
*
* Returns channel < 0 if no channel was allocated or deallocated.
* Returns bandwidth = 0 if no bandwidth was allocated or deallocated.
*
* If generation is stale, deallocations succeed but allocations fail with
* channel = -EAGAIN.
*
* If channel allocation fails, no bandwidth will be allocated either.
* If bandwidth allocation fails, no channel will be allocated either.
* But deallocations of channel and bandwidth are tried independently
* of each other's success.
*/
void fw_iso_resource_manage(struct fw_card *card, int generation,
u64 channels_mask, int *channel, int *bandwidth,
bool allocate)
{
u32 channels_hi = channels_mask; /* channels 31...0 */
u32 channels_lo = channels_mask >> 32; /* channels 63...32 */
int irm_id, ret, c = -EINVAL;
spin_lock_irq(&card->lock);
irm_id = card->irm_node->node_id;
spin_unlock_irq(&card->lock);
if (channels_hi)
c = manage_channel(card, irm_id, generation, channels_hi,
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI, allocate);
if (channels_lo && c < 0) {
c = manage_channel(card, irm_id, generation, channels_lo,
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO, allocate);
if (c >= 0)
c += 32;
}
*channel = c;
if (allocate && channels_mask != 0 && c < 0)
*bandwidth = 0;
if (*bandwidth == 0)
return;
ret = manage_bandwidth(card, irm_id, generation, *bandwidth, allocate);
if (ret < 0)
*bandwidth = 0;
if (allocate && ret < 0 && c >= 0) {
deallocate_channel(card, irm_id, generation, c);
*channel = ret;
}
}
This diff is collapsed.
...@@ -392,16 +392,14 @@ static const struct { ...@@ -392,16 +392,14 @@ static const struct {
} }
}; };
static void static void free_orb(struct kref *kref)
free_orb(struct kref *kref)
{ {
struct sbp2_orb *orb = container_of(kref, struct sbp2_orb, kref); struct sbp2_orb *orb = container_of(kref, struct sbp2_orb, kref);
kfree(orb); kfree(orb);
} }
static void static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
sbp2_status_write(struct fw_card *card, struct fw_request *request,
int tcode, int destination, int source, int tcode, int destination, int source,
int generation, int speed, int generation, int speed,
unsigned long long offset, unsigned long long offset,
...@@ -451,8 +449,7 @@ sbp2_status_write(struct fw_card *card, struct fw_request *request, ...@@ -451,8 +449,7 @@ sbp2_status_write(struct fw_card *card, struct fw_request *request,
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
} }
static void static void complete_transaction(struct fw_card *card, int rcode,
complete_transaction(struct fw_card *card, int rcode,
void *payload, size_t length, void *data) void *payload, size_t length, void *data)
{ {
struct sbp2_orb *orb = data; struct sbp2_orb *orb = data;
...@@ -482,8 +479,7 @@ complete_transaction(struct fw_card *card, int rcode, ...@@ -482,8 +479,7 @@ complete_transaction(struct fw_card *card, int rcode,
kref_put(&orb->kref, free_orb); kref_put(&orb->kref, free_orb);
} }
static void static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
int node_id, int generation, u64 offset) int node_id, int generation, u64 offset)
{ {
struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
...@@ -531,8 +527,8 @@ static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) ...@@ -531,8 +527,8 @@ static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
return retval; return retval;
} }
static void static void complete_management_orb(struct sbp2_orb *base_orb,
complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) struct sbp2_status *status)
{ {
struct sbp2_management_orb *orb = struct sbp2_management_orb *orb =
container_of(base_orb, struct sbp2_management_orb, base); container_of(base_orb, struct sbp2_management_orb, base);
...@@ -542,10 +538,9 @@ complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) ...@@ -542,10 +538,9 @@ complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
complete(&orb->done); complete(&orb->done);
} }
static int static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, int generation, int function,
int generation, int function, int lun_or_login_id, int lun_or_login_id, void *response)
void *response)
{ {
struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
struct sbp2_management_orb *orb; struct sbp2_management_orb *orb;
...@@ -652,9 +647,8 @@ static void sbp2_agent_reset(struct sbp2_logical_unit *lu) ...@@ -652,9 +647,8 @@ static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
&d, sizeof(d)); &d, sizeof(d));
} }
static void static void complete_agent_reset_write_no_wait(struct fw_card *card,
complete_agent_reset_write_no_wait(struct fw_card *card, int rcode, int rcode, void *payload, size_t length, void *data)
void *payload, size_t length, void *data)
{ {
kfree(data); kfree(data);
} }
...@@ -1299,8 +1293,7 @@ static void sbp2_unmap_scatterlist(struct device *card_device, ...@@ -1299,8 +1293,7 @@ static void sbp2_unmap_scatterlist(struct device *card_device,
sizeof(orb->page_table), DMA_TO_DEVICE); sizeof(orb->page_table), DMA_TO_DEVICE);
} }
static unsigned int static unsigned int sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
{ {
int sam_status; int sam_status;
...@@ -1337,8 +1330,8 @@ sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) ...@@ -1337,8 +1330,8 @@ sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
} }
} }
static void static void complete_command_orb(struct sbp2_orb *base_orb,
complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) struct sbp2_status *status)
{ {
struct sbp2_command_orb *orb = struct sbp2_command_orb *orb =
container_of(base_orb, struct sbp2_command_orb, base); container_of(base_orb, struct sbp2_command_orb, base);
...@@ -1384,9 +1377,8 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) ...@@ -1384,9 +1377,8 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
orb->done(orb->cmd); orb->done(orb->cmd);
} }
static int static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, struct fw_device *device, struct sbp2_logical_unit *lu)
struct sbp2_logical_unit *lu)
{ {
struct scatterlist *sg = scsi_sglist(orb->cmd); struct scatterlist *sg = scsi_sglist(orb->cmd);
int i, n; int i, n;
...@@ -1584,9 +1576,8 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd) ...@@ -1584,9 +1576,8 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
* This is the concatenation of target port identifier and logical unit * This is the concatenation of target port identifier and logical unit
* identifier as per SAM-2...SAM-4 annex A. * identifier as per SAM-2...SAM-4 annex A.
*/ */
static ssize_t static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, struct device_attribute *attr, char *buf)
char *buf)
{ {
struct scsi_device *sdev = to_scsi_device(dev); struct scsi_device *sdev = to_scsi_device(dev);
struct sbp2_logical_unit *lu; struct sbp2_logical_unit *lu;
......
...@@ -314,8 +314,7 @@ typedef void (*fw_node_callback_t)(struct fw_card * card, ...@@ -314,8 +314,7 @@ typedef void (*fw_node_callback_t)(struct fw_card * card,
struct fw_node * node, struct fw_node * node,
struct fw_node * parent); struct fw_node * parent);
static void static void for_each_fw_node(struct fw_card *card, struct fw_node *root,
for_each_fw_node(struct fw_card *card, struct fw_node *root,
fw_node_callback_t callback) fw_node_callback_t callback)
{ {
struct list_head list; struct list_head list;
...@@ -349,8 +348,7 @@ for_each_fw_node(struct fw_card *card, struct fw_node *root, ...@@ -349,8 +348,7 @@ for_each_fw_node(struct fw_card *card, struct fw_node *root,
fw_node_put(node); fw_node_put(node);
} }
static void static void report_lost_node(struct fw_card *card,
report_lost_node(struct fw_card *card,
struct fw_node *node, struct fw_node *parent) struct fw_node *node, struct fw_node *parent)
{ {
fw_node_event(card, node, FW_NODE_DESTROYED); fw_node_event(card, node, FW_NODE_DESTROYED);
...@@ -360,8 +358,7 @@ report_lost_node(struct fw_card *card, ...@@ -360,8 +358,7 @@ report_lost_node(struct fw_card *card,
card->bm_retries = 0; card->bm_retries = 0;
} }
static void static void report_found_node(struct fw_card *card,
report_found_node(struct fw_card *card,
struct fw_node *node, struct fw_node *parent) struct fw_node *node, struct fw_node *parent)
{ {
int b_path = (node->phy_speed == SCODE_BETA); int b_path = (node->phy_speed == SCODE_BETA);
...@@ -415,8 +412,7 @@ static void move_tree(struct fw_node *node0, struct fw_node *node1, int port) ...@@ -415,8 +412,7 @@ static void move_tree(struct fw_node *node0, struct fw_node *node1, int port)
* found, lost or updated. Update the nodes in the card topology tree * found, lost or updated. Update the nodes in the card topology tree
* as we go. * as we go.
*/ */
static void static void update_tree(struct fw_card *card, struct fw_node *root)
update_tree(struct fw_card *card, struct fw_node *root)
{ {
struct list_head list0, list1; struct list_head list0, list1;
struct fw_node *node0, *node1, *next1; struct fw_node *node0, *node1, *next1;
...@@ -497,8 +493,8 @@ update_tree(struct fw_card *card, struct fw_node *root) ...@@ -497,8 +493,8 @@ update_tree(struct fw_card *card, struct fw_node *root)
} }
} }
static void static void update_topology_map(struct fw_card *card,
update_topology_map(struct fw_card *card, u32 *self_ids, int self_id_count) u32 *self_ids, int self_id_count)
{ {
int node_count; int node_count;
...@@ -510,10 +506,8 @@ update_topology_map(struct fw_card *card, u32 *self_ids, int self_id_count) ...@@ -510,10 +506,8 @@ update_topology_map(struct fw_card *card, u32 *self_ids, int self_id_count)
fw_compute_block_crc(card->topology_map); fw_compute_block_crc(card->topology_map);
} }
void void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,
fw_core_handle_bus_reset(struct fw_card *card, int self_id_count, u32 *self_ids)
int node_id, int generation,
int self_id_count, u32 * self_ids)
{ {
struct fw_node *local_node; struct fw_node *local_node;
unsigned long flags; unsigned long flags;
...@@ -532,6 +526,7 @@ fw_core_handle_bus_reset(struct fw_card *card, ...@@ -532,6 +526,7 @@ fw_core_handle_bus_reset(struct fw_card *card,
spin_lock_irqsave(&card->lock, flags); spin_lock_irqsave(&card->lock, flags);
card->broadcast_channel_allocated = false;
card->node_id = node_id; card->node_id = node_id;
/* /*
* Update node_id before generation to prevent anybody from using * Update node_id before generation to prevent anybody from using
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#ifndef __fw_topology_h #ifndef __fw_topology_h
#define __fw_topology_h #define __fw_topology_h
#include <linux/list.h>
#include <linux/slab.h>
#include <asm/atomic.h>
enum { enum {
FW_NODE_CREATED, FW_NODE_CREATED,
FW_NODE_UPDATED, FW_NODE_UPDATED,
...@@ -51,26 +56,22 @@ struct fw_node { ...@@ -51,26 +56,22 @@ struct fw_node {
struct fw_node *ports[0]; struct fw_node *ports[0];
}; };
static inline struct fw_node * static inline struct fw_node *fw_node_get(struct fw_node *node)
fw_node_get(struct fw_node *node)
{ {
atomic_inc(&node->ref_count); atomic_inc(&node->ref_count);
return node; return node;
} }
static inline void static inline void fw_node_put(struct fw_node *node)
fw_node_put(struct fw_node *node)
{ {
if (atomic_dec_and_test(&node->ref_count)) if (atomic_dec_and_test(&node->ref_count))
kfree(node); kfree(node);
} }
void struct fw_card;
fw_destroy_nodes(struct fw_card *card); void fw_destroy_nodes(struct fw_card *card);
int
fw_compute_block_crc(u32 *block);
int fw_compute_block_crc(u32 *block);
#endif /* __fw_topology_h */ #endif /* __fw_topology_h */
This diff is collapsed.
...@@ -82,14 +82,14 @@ ...@@ -82,14 +82,14 @@
#define CSR_SPEED_MAP 0x2000 #define CSR_SPEED_MAP 0x2000
#define CSR_SPEED_MAP_END 0x3000 #define CSR_SPEED_MAP_END 0x3000
#define BANDWIDTH_AVAILABLE_INITIAL 4915
#define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31) #define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31)
#define BROADCAST_CHANNEL_VALID (1 << 30) #define BROADCAST_CHANNEL_VALID (1 << 30)
#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) #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 fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
static inline void static inline void fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
{ {
u32 *dst = _dst; u32 *dst = _dst;
__be32 *src = _src; __be32 *src = _src;
...@@ -99,8 +99,7 @@ fw_memcpy_from_be32(void *_dst, void *_src, size_t size) ...@@ -99,8 +99,7 @@ fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
dst[i] = be32_to_cpu(src[i]); dst[i] = be32_to_cpu(src[i]);
} }
static inline void static inline void fw_memcpy_to_be32(void *_dst, void *_src, size_t size)
fw_memcpy_to_be32(void *_dst, void *_src, size_t size)
{ {
fw_memcpy_from_be32(_dst, _src, size); fw_memcpy_from_be32(_dst, _src, size);
} }
...@@ -125,8 +124,7 @@ typedef void (*fw_packet_callback_t)(struct fw_packet *packet, ...@@ -125,8 +124,7 @@ typedef void (*fw_packet_callback_t)(struct fw_packet *packet,
struct fw_card *card, int status); struct fw_card *card, int status);
typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode, typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
void *data, void *data, size_t length,
size_t length,
void *callback_data); void *callback_data);
/* /*
...@@ -141,12 +139,6 @@ typedef void (*fw_address_callback_t)(struct fw_card *card, ...@@ -141,12 +139,6 @@ typedef void (*fw_address_callback_t)(struct fw_card *card,
void *data, size_t length, void *data, size_t length,
void *callback_data); void *callback_data);
typedef void (*fw_bus_reset_callback_t)(struct fw_card *handle,
int node_id, int generation,
u32 *self_ids,
int self_id_count,
void *callback_data);
struct fw_packet { struct fw_packet {
int speed; int speed;
int generation; int generation;
...@@ -187,12 +179,6 @@ struct fw_transaction { ...@@ -187,12 +179,6 @@ struct fw_transaction {
void *callback_data; void *callback_data;
}; };
static inline struct fw_packet *
fw_packet(struct list_head *l)
{
return list_entry(l, struct fw_packet, link);
}
struct fw_address_handler { struct fw_address_handler {
u64 offset; u64 offset;
size_t length; size_t length;
...@@ -201,7 +187,6 @@ struct fw_address_handler { ...@@ -201,7 +187,6 @@ struct fw_address_handler {
struct list_head link; struct list_head link;
}; };
struct fw_address_region { struct fw_address_region {
u64 start; u64 start;
u64 end; u64 end;
...@@ -255,6 +240,7 @@ struct fw_card { ...@@ -255,6 +240,7 @@ struct fw_card {
int bm_retries; int bm_retries;
int bm_generation; int bm_generation;
bool broadcast_channel_allocated;
u32 broadcast_channel; u32 broadcast_channel;
u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4]; u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
}; };
...@@ -315,10 +301,8 @@ struct fw_iso_packet { ...@@ -315,10 +301,8 @@ struct fw_iso_packet {
struct fw_iso_context; struct fw_iso_context;
typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, typedef void (*fw_iso_callback_t)(struct fw_iso_context *context,
u32 cycle, u32 cycle, size_t header_length,
size_t header_length, void *header, void *data);
void *header,
void *data);
/* /*
* An iso buffer is just a set of pages mapped for DMA in the * An iso buffer is just a set of pages mapped for DMA in the
...@@ -344,36 +328,25 @@ struct fw_iso_context { ...@@ -344,36 +328,25 @@ struct fw_iso_context {
void *callback_data; void *callback_data;
}; };
int int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
fw_iso_buffer_init(struct fw_iso_buffer *buffer, int page_count, enum dma_data_direction direction);
struct fw_card *card, int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
int page_count, void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
enum dma_data_direction direction);
int
fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
void
fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
struct fw_iso_context *
fw_iso_context_create(struct fw_card *card, int type,
int channel, int speed, size_t header_size,
fw_iso_callback_t callback, void *callback_data);
void
fw_iso_context_destroy(struct fw_iso_context *ctx);
int struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
fw_iso_context_queue(struct fw_iso_context *ctx, int type, int channel, int speed, size_t header_size,
fw_iso_callback_t callback, void *callback_data);
int fw_iso_context_queue(struct fw_iso_context *ctx,
struct fw_iso_packet *packet, struct fw_iso_packet *packet,
struct fw_iso_buffer *buffer, struct fw_iso_buffer *buffer,
unsigned long payload); unsigned long payload);
int fw_iso_context_start(struct fw_iso_context *ctx,
int
fw_iso_context_start(struct fw_iso_context *ctx,
int cycle, int sync, int tags); int cycle, int sync, int tags);
int fw_iso_context_stop(struct fw_iso_context *ctx);
void fw_iso_context_destroy(struct fw_iso_context *ctx);
int void fw_iso_resource_manage(struct fw_card *card, int generation,
fw_iso_context_stop(struct fw_iso_context *ctx); u64 channels_mask, int *channel, int *bandwidth, bool allocate);
struct fw_card_driver { struct fw_card_driver {
/* /*
...@@ -415,7 +388,7 @@ struct fw_card_driver { ...@@ -415,7 +388,7 @@ struct fw_card_driver {
struct fw_iso_context * struct fw_iso_context *
(*allocate_iso_context)(struct fw_card *card, (*allocate_iso_context)(struct fw_card *card,
int type, size_t header_size); int type, int channel, size_t header_size);
void (*free_iso_context)(struct fw_iso_context *ctx); void (*free_iso_context)(struct fw_iso_context *ctx);
int (*start_iso)(struct fw_iso_context *ctx, int (*start_iso)(struct fw_iso_context *ctx,
...@@ -429,54 +402,45 @@ struct fw_card_driver { ...@@ -429,54 +402,45 @@ struct fw_card_driver {
int (*stop_iso)(struct fw_iso_context *ctx); int (*stop_iso)(struct fw_iso_context *ctx);
}; };
int int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
void void fw_send_request(struct fw_card *card, struct fw_transaction *t,
fw_send_request(struct fw_card *card, struct fw_transaction *t,
int tcode, int destination_id, int generation, int speed, int tcode, int destination_id, int generation, int speed,
unsigned long long offset, void *data, size_t length, unsigned long long offset, void *payload, size_t length,
fw_transaction_callback_t callback, void *callback_data); fw_transaction_callback_t callback, void *callback_data);
int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
int generation, int speed, unsigned long long offset,
void *data, size_t length);
int fw_cancel_transaction(struct fw_card *card, int fw_cancel_transaction(struct fw_card *card,
struct fw_transaction *transaction); struct fw_transaction *transaction);
void fw_flush_transactions(struct fw_card *card); void fw_flush_transactions(struct fw_card *card);
int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
int generation, int speed, unsigned long long offset,
void *payload, size_t length);
void fw_send_phy_config(struct fw_card *card, void fw_send_phy_config(struct fw_card *card,
int node_id, int generation, int gap_count); int node_id, int generation, int gap_count);
static inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
{
return tag << 14 | channel << 8 | sy;
}
/* /*
* Called by the topology code to inform the device code of node * Called by the topology code to inform the device code of node
* activity; found, lost, or updated nodes. * activity; found, lost, or updated nodes.
*/ */
void void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
fw_node_event(struct fw_card *card, struct fw_node *node, int event);
/* API used by card level drivers */ /* API used by card level drivers */
void void fw_card_initialize(struct fw_card *card,
fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, const struct fw_card_driver *driver, struct device *device);
struct device *device); int fw_card_add(struct fw_card *card,
int
fw_card_add(struct fw_card *card,
u32 max_receive, u32 link_speed, u64 guid); u32 max_receive, u32 link_speed, u64 guid);
void fw_core_remove_card(struct fw_card *card);
void fw_core_handle_bus_reset(struct fw_card *card, int node_id,
int generation, int self_id_count, u32 *self_ids);
void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
void extern int fw_irm_set_broadcast_channel_register(struct device *dev,
fw_core_remove_card(struct fw_card *card); void *data);
void
fw_core_handle_bus_reset(struct fw_card *card,
int node_id, int generation,
int self_id_count, u32 *self_ids);
void
fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
void
fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
#endif /* __fw_transaction_h */ #endif /* __fw_transaction_h */
...@@ -68,22 +68,22 @@ static struct hpsb_highlevel csr_highlevel = { ...@@ -68,22 +68,22 @@ static struct hpsb_highlevel csr_highlevel = {
.host_reset = host_reset, .host_reset = host_reset,
}; };
const static struct hpsb_address_ops map_ops = { static const struct hpsb_address_ops map_ops = {
.read = read_maps, .read = read_maps,
}; };
const static struct hpsb_address_ops fcp_ops = { static const struct hpsb_address_ops fcp_ops = {
.write = write_fcp, .write = write_fcp,
}; };
const static struct hpsb_address_ops reg_ops = { static const struct hpsb_address_ops reg_ops = {
.read = read_regs, .read = read_regs,
.write = write_regs, .write = write_regs,
.lock = lock_regs, .lock = lock_regs,
.lock64 = lock64_regs, .lock64 = lock64_regs,
}; };
const static struct hpsb_address_ops config_rom_ops = { static const struct hpsb_address_ops config_rom_ops = {
.read = read_config_rom, .read = read_config_rom,
}; };
......
...@@ -2171,7 +2171,7 @@ static const struct file_operations dv1394_fops= ...@@ -2171,7 +2171,7 @@ static const struct file_operations dv1394_fops=
* Export information about protocols/devices supported by this driver. * Export information about protocols/devices supported by this driver.
*/ */
#ifdef MODULE #ifdef MODULE
static struct ieee1394_device_id dv1394_id_table[] = { static const struct ieee1394_device_id dv1394_id_table[] = {
{ {
.match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
......
...@@ -181,7 +181,7 @@ static void ether1394_remove_host(struct hpsb_host *host); ...@@ -181,7 +181,7 @@ static void ether1394_remove_host(struct hpsb_host *host);
static void ether1394_host_reset(struct hpsb_host *host); static void ether1394_host_reset(struct hpsb_host *host);
/* Function for incoming 1394 packets */ /* Function for incoming 1394 packets */
const static struct hpsb_address_ops addr_ops = { static const struct hpsb_address_ops addr_ops = {
.write = ether1394_write, .write = ether1394_write,
}; };
...@@ -438,7 +438,7 @@ static int eth1394_update(struct unit_directory *ud) ...@@ -438,7 +438,7 @@ static int eth1394_update(struct unit_directory *ud)
return eth1394_new_node(hi, ud); return eth1394_new_node(hi, ud);
} }
static struct ieee1394_device_id eth1394_id_table[] = { static const struct ieee1394_device_id eth1394_id_table[] = {
{ {
.match_flags = (IEEE1394_MATCH_SPECIFIER_ID | .match_flags = (IEEE1394_MATCH_SPECIFIER_ID |
IEEE1394_MATCH_VERSION), IEEE1394_MATCH_VERSION),
......
...@@ -478,7 +478,7 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, ...@@ -478,7 +478,7 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
return retval; return retval;
} }
const static struct hpsb_address_ops dummy_ops; static const struct hpsb_address_ops dummy_ops;
/* dummy address spaces as lower and upper bounds of the host's a.s. list */ /* dummy address spaces as lower and upper bounds of the host's a.s. list */
static void init_hpsb_highlevel(struct hpsb_host *host) static void init_hpsb_highlevel(struct hpsb_host *host)
......
...@@ -484,7 +484,7 @@ static struct device_attribute *const fw_host_attrs[] = { ...@@ -484,7 +484,7 @@ static struct device_attribute *const fw_host_attrs[] = {
static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf) static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf)
{ {
struct hpsb_protocol_driver *driver; struct hpsb_protocol_driver *driver;
struct ieee1394_device_id *id; const struct ieee1394_device_id *id;
int length = 0; int length = 0;
char *scratch = buf; char *scratch = buf;
...@@ -658,7 +658,7 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv) ...@@ -658,7 +658,7 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
{ {
struct hpsb_protocol_driver *driver; struct hpsb_protocol_driver *driver;
struct unit_directory *ud; struct unit_directory *ud;
struct ieee1394_device_id *id; const struct ieee1394_device_id *id;
/* We only match unit directories */ /* We only match unit directories */
if (dev->platform_data != &nodemgr_ud_platform_data) if (dev->platform_data != &nodemgr_ud_platform_data)
......
...@@ -125,7 +125,7 @@ struct hpsb_protocol_driver { ...@@ -125,7 +125,7 @@ struct hpsb_protocol_driver {
* probe function below can implement further protocol * probe function below can implement further protocol
* dependent or vendor dependent checking. * dependent or vendor dependent checking.
*/ */
struct ieee1394_device_id *id_table; const struct ieee1394_device_id *id_table;
/* /*
* The update function is called when the node has just * The update function is called when the node has just
......
...@@ -90,7 +90,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store, ...@@ -90,7 +90,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store, static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
u64 addr, octlet_t data, octlet_t arg, int ext_tcode, u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
u16 flags); u16 flags);
const static struct hpsb_address_ops arm_ops = { static const struct hpsb_address_ops arm_ops = {
.read = arm_read, .read = arm_read,
.write = arm_write, .write = arm_write,
.lock = arm_lock, .lock = arm_lock,
...@@ -369,6 +369,7 @@ static const char __user *raw1394_compat_write(const char __user *buf) ...@@ -369,6 +369,7 @@ static const char __user *raw1394_compat_write(const char __user *buf)
{ {
struct compat_raw1394_req __user *cr = (typeof(cr)) buf; struct compat_raw1394_req __user *cr = (typeof(cr)) buf;
struct raw1394_request __user *r; struct raw1394_request __user *r;
r = compat_alloc_user_space(sizeof(struct raw1394_request)); r = compat_alloc_user_space(sizeof(struct raw1394_request));
#define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x)) #define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x))
...@@ -378,7 +379,8 @@ static const char __user *raw1394_compat_write(const char __user *buf) ...@@ -378,7 +379,8 @@ static const char __user *raw1394_compat_write(const char __user *buf)
C(tag) || C(tag) ||
C(sendb) || C(sendb) ||
C(recvb)) C(recvb))
return ERR_PTR(-EFAULT); return (__force const char __user *)ERR_PTR(-EFAULT);
return (const char __user *)r; return (const char __user *)r;
} }
#undef C #undef C
...@@ -389,6 +391,7 @@ static int ...@@ -389,6 +391,7 @@ static int
raw1394_compat_read(const char __user *buf, struct raw1394_request *r) raw1394_compat_read(const char __user *buf, struct raw1394_request *r)
{ {
struct compat_raw1394_req __user *cr = (typeof(cr)) buf; struct compat_raw1394_req __user *cr = (typeof(cr)) buf;
if (!access_ok(VERIFY_WRITE, cr, sizeof(struct compat_raw1394_req)) || if (!access_ok(VERIFY_WRITE, cr, sizeof(struct compat_raw1394_req)) ||
P(type) || P(type) ||
P(error) || P(error) ||
...@@ -400,6 +403,7 @@ raw1394_compat_read(const char __user *buf, struct raw1394_request *r) ...@@ -400,6 +403,7 @@ raw1394_compat_read(const char __user *buf, struct raw1394_request *r)
P(sendb) || P(sendb) ||
P(recvb)) P(recvb))
return -EFAULT; return -EFAULT;
return sizeof(struct compat_raw1394_req); return sizeof(struct compat_raw1394_req);
} }
#undef P #undef P
...@@ -2249,8 +2253,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer, ...@@ -2249,8 +2253,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
sizeof(struct compat_raw1394_req) != sizeof(struct compat_raw1394_req) !=
sizeof(struct raw1394_request)) { sizeof(struct raw1394_request)) {
buffer = raw1394_compat_write(buffer); buffer = raw1394_compat_write(buffer);
if (IS_ERR(buffer)) if (IS_ERR((__force void *)buffer))
return PTR_ERR(buffer); return PTR_ERR((__force void *)buffer);
} else } else
#endif #endif
if (count != sizeof(struct raw1394_request)) { if (count != sizeof(struct raw1394_request)) {
...@@ -2978,7 +2982,7 @@ static int raw1394_release(struct inode *inode, struct file *file) ...@@ -2978,7 +2982,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
* Export information about protocols/devices supported by this driver. * Export information about protocols/devices supported by this driver.
*/ */
#ifdef MODULE #ifdef MODULE
static struct ieee1394_device_id raw1394_id_table[] = { static const struct ieee1394_device_id raw1394_id_table[] = {
{ {
.match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
......
...@@ -265,7 +265,7 @@ static struct hpsb_highlevel sbp2_highlevel = { ...@@ -265,7 +265,7 @@ static struct hpsb_highlevel sbp2_highlevel = {
.host_reset = sbp2_host_reset, .host_reset = sbp2_host_reset,
}; };
const static struct hpsb_address_ops sbp2_ops = { static const struct hpsb_address_ops sbp2_ops = {
.write = sbp2_handle_status_write .write = sbp2_handle_status_write
}; };
...@@ -275,7 +275,7 @@ static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *, ...@@ -275,7 +275,7 @@ static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *,
static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64, static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64,
size_t, u16); size_t, u16);
const static struct hpsb_address_ops sbp2_physdma_ops = { static const struct hpsb_address_ops sbp2_physdma_ops = {
.read = sbp2_handle_physdma_read, .read = sbp2_handle_physdma_read,
.write = sbp2_handle_physdma_write, .write = sbp2_handle_physdma_write,
}; };
...@@ -285,7 +285,7 @@ const static struct hpsb_address_ops sbp2_physdma_ops = { ...@@ -285,7 +285,7 @@ const static struct hpsb_address_ops sbp2_physdma_ops = {
/* /*
* Interface to driver core and IEEE 1394 core * Interface to driver core and IEEE 1394 core
*/ */
static struct ieee1394_device_id sbp2_id_table[] = { static const struct ieee1394_device_id sbp2_id_table[] = {
{ {
.match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
.specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
...@@ -1413,8 +1413,7 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu, ...@@ -1413,8 +1413,7 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
"(firmware_revision 0x%06x, vendor_id 0x%06x," "(firmware_revision 0x%06x, vendor_id 0x%06x,"
" model_id 0x%06x)", " model_id 0x%06x)",
NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid), NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
workarounds, firmware_revision, workarounds, firmware_revision, ud->vendor_id,
ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
model); model);
/* We would need one SCSI host template for each target to adjust /* We would need one SCSI host template for each target to adjust
......
...@@ -1294,7 +1294,7 @@ static const struct file_operations video1394_fops= ...@@ -1294,7 +1294,7 @@ static const struct file_operations video1394_fops=
* Export information about protocols/devices supported by this driver. * Export information about protocols/devices supported by this driver.
*/ */
#ifdef MODULE #ifdef MODULE
static struct ieee1394_device_id video1394_id_table[] = { static const struct ieee1394_device_id video1394_id_table[] = {
{ {
.match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
.specifier_id = CAMERA_UNIT_SPEC_ID_ENTRY & 0xffffff, .specifier_id = CAMERA_UNIT_SPEC_ID_ENTRY & 0xffffff,
......
...@@ -115,7 +115,7 @@ static const char *debug_fcp_ctype(unsigned int ctype) ...@@ -115,7 +115,7 @@ static const char *debug_fcp_ctype(unsigned int ctype)
} }
static const char *debug_fcp_opcode(unsigned int opcode, static const char *debug_fcp_opcode(unsigned int opcode,
const u8 *data, size_t length) const u8 *data, int length)
{ {
switch (opcode) { switch (opcode) {
case AVC_OPCODE_VENDOR: break; case AVC_OPCODE_VENDOR: break;
...@@ -135,13 +135,14 @@ static const char *debug_fcp_opcode(unsigned int opcode, ...@@ -135,13 +135,14 @@ static const char *debug_fcp_opcode(unsigned int opcode,
case SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL: return "RegisterRC"; case SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL: return "RegisterRC";
case SFE_VENDOR_OPCODE_LNB_CONTROL: return "LNBControl"; case SFE_VENDOR_OPCODE_LNB_CONTROL: return "LNBControl";
case SFE_VENDOR_OPCODE_TUNE_QPSK: return "TuneQPSK"; case SFE_VENDOR_OPCODE_TUNE_QPSK: return "TuneQPSK";
case SFE_VENDOR_OPCODE_TUNE_QPSK2: return "TuneQPSK2";
case SFE_VENDOR_OPCODE_HOST2CA: return "Host2CA"; case SFE_VENDOR_OPCODE_HOST2CA: return "Host2CA";
case SFE_VENDOR_OPCODE_CA2HOST: return "CA2Host"; case SFE_VENDOR_OPCODE_CA2HOST: return "CA2Host";
} }
return "Vendor"; return "Vendor";
} }
static void debug_fcp(const u8 *data, size_t length) static void debug_fcp(const u8 *data, int length)
{ {
unsigned int subunit_type, subunit_id, op; unsigned int subunit_type, subunit_id, op;
const char *prefix = data[0] > 7 ? "FCP <- " : "FCP -> "; const char *prefix = data[0] > 7 ? "FCP <- " : "FCP -> ";
...@@ -266,6 +267,9 @@ static void avc_tuner_tuneqpsk(struct firedtv *fdtv, ...@@ -266,6 +267,9 @@ static void avc_tuner_tuneqpsk(struct firedtv *fdtv,
c->operand[0] = SFE_VENDOR_DE_COMPANYID_0; c->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
c->operand[1] = SFE_VENDOR_DE_COMPANYID_1; c->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
c->operand[2] = SFE_VENDOR_DE_COMPANYID_2; c->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
if (fdtv->type == FIREDTV_DVB_S2)
c->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK2;
else
c->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK; c->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK;
c->operand[4] = (params->frequency >> 24) & 0xff; c->operand[4] = (params->frequency >> 24) & 0xff;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment