firewire: core: prepare for non-core children of card devices

The IP-over-1394 driver will add child devices beneath card devices
which are not of type fw_device. Hence firewire-core's callbacks in
device_for_each_child() and device_find_child() need to check for the
device type now.

Initial version written by Jay Fenlason.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

+22 -12
+1 -7
drivers/firewire/core-card.c
··· 190 190 mutex_unlock(&card_mutex); 191 191 } 192 192 193 - static int set_broadcast_channel(struct device *dev, void *data) 194 - { 195 - fw_device_set_broadcast_channel(fw_device(dev), (long)data); 196 - return 0; 197 - } 198 - 199 193 static void allocate_broadcast_channel(struct fw_card *card, int generation) 200 194 { 201 195 int channel, bandwidth = 0; ··· 199 205 if (channel == 31) { 200 206 card->broadcast_channel_allocated = true; 201 207 device_for_each_child(card->device, (void *)(long)generation, 202 - set_broadcast_channel); 208 + fw_device_set_broadcast_channel); 203 209 } 204 210 } 205 211
+20 -4
drivers/firewire/core-device.c
··· 59 59 } 60 60 EXPORT_SYMBOL(fw_csr_iterator_next); 61 61 62 - static int is_fw_unit(struct device *dev); 62 + static bool is_fw_unit(struct device *dev); 63 63 64 64 static int match_unit_directory(u32 *directory, u32 match_flags, 65 65 const struct ieee1394_device_id *id) ··· 599 599 .release = fw_unit_release, 600 600 }; 601 601 602 - static int is_fw_unit(struct device *dev) 602 + static bool is_fw_unit(struct device *dev) 603 603 { 604 604 return dev->type == &fw_unit_type; 605 605 } ··· 749 749 .release = fw_device_release, 750 750 }; 751 751 752 + static bool is_fw_device(struct device *dev) 753 + { 754 + return dev->type == &fw_device_type; 755 + } 756 + 752 757 static int update_unit(struct device *dev, void *data) 753 758 { 754 759 struct fw_unit *unit = fw_unit(dev); ··· 789 784 struct fw_device *new = data; 790 785 struct fw_card *card = new->card; 791 786 int match = 0; 787 + 788 + if (!is_fw_device(dev)) 789 + return 0; 792 790 793 791 down_read(&fw_device_rwsem); /* serialize config_rom access */ 794 792 spin_lock_irq(&card->lock); /* serialize node access */ ··· 832 824 833 825 enum { BC_UNKNOWN = 0, BC_UNIMPLEMENTED, BC_IMPLEMENTED, }; 834 826 835 - void fw_device_set_broadcast_channel(struct fw_device *device, int generation) 827 + static void set_broadcast_channel(struct fw_device *device, int generation) 836 828 { 837 829 struct fw_card *card = device->card; 838 830 __be32 data; ··· 866 858 CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL, 867 859 &data, 4); 868 860 } 861 + } 862 + 863 + int fw_device_set_broadcast_channel(struct device *dev, void *gen) 864 + { 865 + if (is_fw_device(dev)) 866 + set_broadcast_channel(fw_device(dev), (long)gen); 867 + 868 + return 0; 869 869 } 870 870 871 871 static void fw_device_init(struct work_struct *work) ··· 974 958 1 << device->max_speed); 975 959 device->config_rom_retries = 0; 976 960 977 - fw_device_set_broadcast_channel(device, device->generation); 961 + set_broadcast_channel(device, device->generation); 978 962 } 979 963 980 964 /*
+1 -1
drivers/firewire/core.h
··· 124 124 extern int fw_cdev_major; 125 125 126 126 struct fw_device *fw_device_get_by_devt(dev_t devt); 127 - void fw_device_set_broadcast_channel(struct fw_device *device, int generation); 127 + int fw_device_set_broadcast_channel(struct device *dev, void *gen); 128 128 void fw_node_event(struct fw_card *card, struct fw_node *node, int event); 129 129 130 130