Skip to content

Commit 099d541

Browse files
author
Stefan Richter
committed
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>
1 parent e034d24 commit 099d541

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎drivers/firewire/core-card.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ void fw_core_remove_descriptor(struct fw_descriptor *desc)
190190
mutex_unlock(&card_mutex);
191191
}
192192

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-
199193
static void allocate_broadcast_channel(struct fw_card *card, int generation)
200194
{
201195
int channel, bandwidth = 0;
@@ -205,7 +199,7 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation)
205199
if (channel == 31) {
206200
card->broadcast_channel_allocated = true;
207201
device_for_each_child(card->device, (void *)(long)generation,
208-
set_broadcast_channel);
202+
fw_device_set_broadcast_channel);
209203
}
210204
}
211205

‎drivers/firewire/core-device.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value)
5959
}
6060
EXPORT_SYMBOL(fw_csr_iterator_next);
6161

62-
static int is_fw_unit(struct device *dev);
62+
static bool is_fw_unit(struct device *dev);
6363

6464
static int match_unit_directory(u32 *directory, u32 match_flags,
6565
const struct ieee1394_device_id *id)
@@ -599,7 +599,7 @@ static struct device_type fw_unit_type = {
599599
.release = fw_unit_release,
600600
};
601601

602-
static int is_fw_unit(struct device *dev)
602+
static bool is_fw_unit(struct device *dev)
603603
{
604604
return dev->type == &fw_unit_type;
605605
}
@@ -749,6 +749,11 @@ static struct device_type fw_device_type = {
749749
.release = fw_device_release,
750750
};
751751

752+
static bool is_fw_device(struct device *dev)
753+
{
754+
return dev->type == &fw_device_type;
755+
}
756+
752757
static int update_unit(struct device *dev, void *data)
753758
{
754759
struct fw_unit *unit = fw_unit(dev);
@@ -785,6 +790,9 @@ static int lookup_existing_device(struct device *dev, void *data)
785790
struct fw_card *card = new->card;
786791
int match = 0;
787792

793+
if (!is_fw_device(dev))
794+
return 0;
795+
788796
down_read(&fw_device_rwsem); /* serialize config_rom access */
789797
spin_lock_irq(&card->lock); /* serialize node access */
790798

@@ -824,7 +832,7 @@ static int lookup_existing_device(struct device *dev, void *data)
824832

825833
enum { BC_UNKNOWN = 0, BC_UNIMPLEMENTED, BC_IMPLEMENTED, };
826834

827-
void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
835+
static void set_broadcast_channel(struct fw_device *device, int generation)
828836
{
829837
struct fw_card *card = device->card;
830838
__be32 data;
@@ -860,6 +868,14 @@ void fw_device_set_broadcast_channel(struct fw_device *device, int generation)
860868
}
861869
}
862870

871+
int fw_device_set_broadcast_channel(struct device *dev, void *gen)
872+
{
873+
if (is_fw_device(dev))
874+
set_broadcast_channel(fw_device(dev), (long)gen);
875+
876+
return 0;
877+
}
878+
863879
static void fw_device_init(struct work_struct *work)
864880
{
865881
struct fw_device *device =
@@ -958,7 +974,7 @@ static void fw_device_init(struct work_struct *work)
958974
1 << device->max_speed);
959975
device->config_rom_retries = 0;
960976

961-
fw_device_set_broadcast_channel(device, device->generation);
977+
set_broadcast_channel(device, device->generation);
962978
}
963979

964980
/*

‎drivers/firewire/core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extern struct idr fw_device_idr;
124124
extern int fw_cdev_major;
125125

126126
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);
128128
void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
129129

130130

0 commit comments

Comments
 (0)