driver model: constify attribute groups
[safe/jmp/linux-2.6] / drivers / firewire / core-device.c
index 65d84dd..9d0dfcb 100644 (file)
@@ -59,7 +59,7 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value)
 }
 EXPORT_SYMBOL(fw_csr_iterator_next);
 
-static int is_fw_unit(struct device *dev);
+static bool is_fw_unit(struct device *dev);
 
 static int match_unit_directory(u32 *directory, u32 match_flags,
                                const struct ieee1394_device_id *id)
@@ -93,7 +93,7 @@ static int fw_unit_match(struct device *dev, struct device_driver *drv)
        if (!is_fw_unit(dev))
                return 0;
 
-       device = fw_device(unit->device.parent);
+       device = fw_parent_device(unit);
        id = container_of(drv, struct fw_driver, driver)->id_table;
 
        for (; id->match_flags != 0; id++) {
@@ -114,7 +114,7 @@ static int fw_unit_match(struct device *dev, struct device_driver *drv)
 
 static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
 {
-       struct fw_device *device = fw_device(unit->device.parent);
+       struct fw_device *device = fw_parent_device(unit);
        struct fw_csr_iterator ci;
 
        int key, value;
@@ -312,7 +312,7 @@ static void init_fw_attribute_group(struct device *dev,
        group->groups[0] = &group->group;
        group->groups[1] = NULL;
        group->group.attrs = group->attrs;
-       dev->groups = group->groups;
+       dev->groups = (const struct attribute_group **) group->groups;
 }
 
 static ssize_t modalias_show(struct device *dev,
@@ -580,7 +580,9 @@ static int read_bus_info_block(struct fw_device *device, int generation)
 
        kfree(old_rom);
        ret = 0;
-       device->cmc = rom[2] >> 30 & 1;
+       device->max_rec = rom[2] >> 12 & 0xf;
+       device->cmc     = rom[2] >> 30 & 1;
+       device->irmc    = rom[2] >> 31 & 1;
  out:
        kfree(rom);
 
@@ -599,7 +601,7 @@ static struct device_type fw_unit_type = {
        .release        = fw_unit_release,
 };
 
-static int is_fw_unit(struct device *dev)
+static bool is_fw_unit(struct device *dev)
 {
        return dev->type == &fw_unit_type;
 }
@@ -749,6 +751,11 @@ static struct device_type fw_device_type = {
        .release = fw_device_release,
 };
 
+static bool is_fw_device(struct device *dev)
+{
+       return dev->type == &fw_device_type;
+}
+
 static int update_unit(struct device *dev, void *data)
 {
        struct fw_unit *unit = fw_unit(dev);
@@ -785,6 +792,9 @@ static int lookup_existing_device(struct device *dev, void *data)
        struct fw_card *card = new->card;
        int match = 0;
 
+       if (!is_fw_device(dev))
+               return 0;
+
        down_read(&fw_device_rwsem); /* serialize config_rom access */
        spin_lock_irq(&card->lock);  /* serialize node access */
 
@@ -824,7 +834,7 @@ static int lookup_existing_device(struct device *dev, void *data)
 
 enum { BC_UNKNOWN = 0, BC_UNIMPLEMENTED, BC_IMPLEMENTED, };
 
-void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
+static void set_broadcast_channel(struct fw_device *device, int generation)
 {
        struct fw_card *card = device->card;
        __be32 data;
@@ -833,6 +843,20 @@ void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
        if (!card->broadcast_channel_allocated)
                return;
 
+       /*
+        * The Broadcast_Channel Valid bit is required by nodes which want to
+        * transmit on this channel.  Such transmissions are practically
+        * exclusive to IP over 1394 (RFC 2734).  IP capable nodes are required
+        * to be IRM capable and have a max_rec of 8 or more.  We use this fact
+        * to narrow down to which nodes we send Broadcast_Channel updates.
+        */
+       if (!device->irmc || device->max_rec < 8)
+               return;
+
+       /*
+        * Some 1394-1995 nodes crash if this 1394a-2000 register is written.
+        * Perform a read test first.
+        */
        if (device->bc_implemented == BC_UNKNOWN) {
                rcode = fw_run_transaction(card, TCODE_READ_QUADLET_REQUEST,
                                device->node_id, generation, device->max_speed,
@@ -860,6 +884,14 @@ void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
        }
 }
 
+int fw_device_set_broadcast_channel(struct device *dev, void *gen)
+{
+       if (is_fw_device(dev))
+               set_broadcast_channel(fw_device(dev), (long)gen);
+
+       return 0;
+}
+
 static void fw_device_init(struct work_struct *work)
 {
        struct fw_device *device =
@@ -958,7 +990,7 @@ static void fw_device_init(struct work_struct *work)
                                  1 << device->max_speed);
                device->config_rom_retries = 0;
 
-               fw_device_set_broadcast_channel(device, device->generation);
+               set_broadcast_channel(device, device->generation);
        }
 
        /*