Lines Matching refs:device
171 static const struct ieee1394_device_id *unit_match(struct device *dev, in unit_match()
187 static bool is_fw_unit(struct device *dev);
189 static int fw_unit_match(struct device *dev, struct device_driver *drv) in fw_unit_match()
195 static int fw_unit_probe(struct device *dev) in fw_unit_probe()
203 static int fw_unit_remove(struct device *dev) in fw_unit_remove()
222 static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) in fw_unit_uevent()
243 int fw_device_enable_phys_dma(struct fw_device *device) in fw_device_enable_phys_dma() argument
245 int generation = device->generation; in fw_device_enable_phys_dma()
250 return device->card->driver->enable_phys_dma(device->card, in fw_device_enable_phys_dma()
251 device->node_id, in fw_device_enable_phys_dma()
261 static ssize_t show_immediate(struct device *dev, in show_immediate()
293 static ssize_t show_text_leaf(struct device *dev, in show_text_leaf()
346 static void init_fw_attribute_group(struct device *dev, in init_fw_attribute_group()
370 static ssize_t modalias_show(struct device *dev, in modalias_show()
382 static ssize_t rom_index_show(struct device *dev, in rom_index_show()
385 struct fw_device *device = fw_device(dev->parent); in rom_index_show() local
389 (int)(unit->directory - device->config_rom)); in rom_index_show()
398 static ssize_t config_rom_show(struct device *dev, in config_rom_show()
401 struct fw_device *device = fw_device(dev); in config_rom_show() local
405 length = device->config_rom_length * 4; in config_rom_show()
406 memcpy(buf, device->config_rom, length); in config_rom_show()
412 static ssize_t guid_show(struct device *dev, in guid_show()
415 struct fw_device *device = fw_device(dev); in guid_show() local
420 device->config_rom[3], device->config_rom[4]); in guid_show()
426 static ssize_t is_local_show(struct device *dev, in is_local_show()
429 struct fw_device *device = fw_device(dev); in is_local_show() local
431 return sprintf(buf, "%u\n", device->is_local); in is_local_show()
456 static ssize_t units_show(struct device *dev, in units_show()
459 struct fw_device *device = fw_device(dev); in units_show() local
464 fw_csr_iterator_init(&ci, &device->config_rom[5]); in units_show()
488 static int read_rom(struct fw_device *device, in read_rom() argument
498 rcode = fw_run_transaction(device->card, in read_rom()
499 TCODE_READ_QUADLET_REQUEST, device->node_id, in read_rom()
500 generation, device->max_speed, offset, data, 4); in read_rom()
520 static int read_config_rom(struct fw_device *device, int generation) in read_config_rom() argument
522 struct fw_card *card = device->card; in read_config_rom()
536 device->max_speed = SCODE_100; in read_config_rom()
540 ret = read_rom(device, generation, i, &rom[i]); in read_config_rom()
557 device->max_speed = device->node->max_speed; in read_config_rom()
568 if ((rom[2] & 0x7) < device->max_speed || in read_config_rom()
569 device->max_speed == SCODE_BETA || in read_config_rom()
574 if (device->max_speed == SCODE_BETA) in read_config_rom()
575 device->max_speed = card->link_speed; in read_config_rom()
577 while (device->max_speed > SCODE_100) { in read_config_rom()
578 if (read_rom(device, generation, 0, &dummy) == in read_config_rom()
581 device->max_speed--; in read_config_rom()
610 ret = read_rom(device, generation, i, &rom[i]); in read_config_rom()
634 ret = read_rom(device, generation, i, &rom[i]); in read_config_rom()
661 old_rom = device->config_rom; in read_config_rom()
669 device->config_rom = new_rom; in read_config_rom()
670 device->config_rom_length = length; in read_config_rom()
675 device->max_rec = rom[2] >> 12 & 0xf; in read_config_rom()
676 device->cmc = rom[2] >> 30 & 1; in read_config_rom()
677 device->irmc = rom[2] >> 31 & 1; in read_config_rom()
684 static void fw_unit_release(struct device *dev) in fw_unit_release()
697 static bool is_fw_unit(struct device *dev) in is_fw_unit()
702 static void create_units(struct fw_device *device) in create_units() argument
709 fw_csr_iterator_init(&ci, &device->config_rom[5]); in create_units()
723 unit->device.bus = &fw_bus_type; in create_units()
724 unit->device.type = &fw_unit_type; in create_units()
725 unit->device.parent = &device->device; in create_units()
726 dev_set_name(&unit->device, "%s.%d", dev_name(&device->device), i++); in create_units()
731 init_fw_attribute_group(&unit->device, in create_units()
735 if (device_register(&unit->device) < 0) in create_units()
738 fw_device_get(device); in create_units()
746 static int shutdown_unit(struct device *device, void *data) in shutdown_unit() argument
748 device_unregister(device); in shutdown_unit()
766 struct fw_device *device; in fw_device_get_by_devt() local
769 device = idr_find(&fw_device_idr, MINOR(devt)); in fw_device_get_by_devt()
770 if (device) in fw_device_get_by_devt()
771 fw_device_get(device); in fw_device_get_by_devt()
774 return device; in fw_device_get_by_devt()
780 static void fw_schedule_device_work(struct fw_device *device, in fw_schedule_device_work() argument
783 queue_delayed_work(fw_workqueue, &device->work, delay); in fw_schedule_device_work()
804 struct fw_device *device = in fw_device_shutdown() local
806 int minor = MINOR(device->device.devt); in fw_device_shutdown()
809 device->card->reset_jiffies + SHUTDOWN_DELAY) in fw_device_shutdown()
810 && !list_empty(&device->card->link)) { in fw_device_shutdown()
811 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_shutdown()
815 if (atomic_cmpxchg(&device->state, in fw_device_shutdown()
820 fw_device_cdev_remove(device); in fw_device_shutdown()
821 device_for_each_child(&device->device, NULL, shutdown_unit); in fw_device_shutdown()
822 device_unregister(&device->device); in fw_device_shutdown()
828 fw_device_put(device); in fw_device_shutdown()
831 static void fw_device_release(struct device *dev) in fw_device_release()
833 struct fw_device *device = fw_device(dev); in fw_device_release() local
834 struct fw_card *card = device->card; in fw_device_release()
843 device->node->data = NULL; in fw_device_release()
846 fw_node_put(device->node); in fw_device_release()
847 kfree(device->config_rom); in fw_device_release()
848 kfree(device); in fw_device_release()
856 static bool is_fw_device(struct device *dev) in is_fw_device()
861 static int update_unit(struct device *dev, void *data) in update_unit()
877 struct fw_device *device = in fw_device_update() local
880 fw_device_cdev_update(device); in fw_device_update()
881 device_for_each_child(&device->device, NULL, update_unit); in fw_device_update()
890 static int lookup_existing_device(struct device *dev, void *data) in lookup_existing_device()
939 static void set_broadcast_channel(struct fw_device *device, int generation) in set_broadcast_channel() argument
941 struct fw_card *card = device->card; in set_broadcast_channel()
955 if (!device->irmc || device->max_rec < 8) in set_broadcast_channel()
962 if (device->bc_implemented == BC_UNKNOWN) { in set_broadcast_channel()
964 device->node_id, generation, device->max_speed, in set_broadcast_channel()
970 device->bc_implemented = BC_IMPLEMENTED; in set_broadcast_channel()
975 device->bc_implemented = BC_UNIMPLEMENTED; in set_broadcast_channel()
979 if (device->bc_implemented == BC_IMPLEMENTED) { in set_broadcast_channel()
983 device->node_id, generation, device->max_speed, in set_broadcast_channel()
989 int fw_device_set_broadcast_channel(struct device *dev, void *gen) in fw_device_set_broadcast_channel()
999 struct fw_device *device = in fw_device_init() local
1001 struct fw_card *card = device->card; in fw_device_init()
1002 struct device *revived_dev; in fw_device_init()
1011 ret = read_config_rom(device, device->generation); in fw_device_init()
1013 if (device->config_rom_retries < MAX_RETRIES && in fw_device_init()
1014 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { in fw_device_init()
1015 device->config_rom_retries++; in fw_device_init()
1016 fw_schedule_device_work(device, RETRY_DELAY); in fw_device_init()
1018 if (device->node->link_on) in fw_device_init()
1020 device->node_id, in fw_device_init()
1022 if (device->node == card->root_node) in fw_device_init()
1024 fw_device_release(&device->device); in fw_device_init()
1029 revived_dev = device_find_child(card->device, in fw_device_init()
1030 device, lookup_existing_device); in fw_device_init()
1033 fw_device_release(&device->device); in fw_device_init()
1038 device_initialize(&device->device); in fw_device_init()
1040 fw_device_get(device); in fw_device_init()
1042 minor = idr_alloc(&fw_device_idr, device, 0, 1 << MINORBITS, in fw_device_init()
1049 device->device.bus = &fw_bus_type; in fw_device_init()
1050 device->device.type = &fw_device_type; in fw_device_init()
1051 device->device.parent = card->device; in fw_device_init()
1052 device->device.devt = MKDEV(fw_cdev_major, minor); in fw_device_init()
1053 dev_set_name(&device->device, "fw%d", minor); in fw_device_init()
1055 BUILD_BUG_ON(ARRAY_SIZE(device->attribute_group.attrs) < in fw_device_init()
1058 init_fw_attribute_group(&device->device, in fw_device_init()
1060 &device->attribute_group); in fw_device_init()
1062 if (device_add(&device->device)) { in fw_device_init()
1067 create_units(device); in fw_device_init()
1078 if (atomic_cmpxchg(&device->state, in fw_device_init()
1081 device->workfn = fw_device_shutdown; in fw_device_init()
1082 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_init()
1085 dev_name(&device->device), in fw_device_init()
1086 device->config_rom[3], device->config_rom[4], in fw_device_init()
1087 1 << device->max_speed); in fw_device_init()
1088 device->config_rom_retries = 0; in fw_device_init()
1090 set_broadcast_channel(device, device->generation); in fw_device_init()
1092 add_device_randomness(&device->config_rom[3], 8); in fw_device_init()
1101 if (device->node == card->root_node) in fw_device_init()
1111 fw_device_put(device); /* fw_device_idr's reference */ in fw_device_init()
1113 put_device(&device->device); /* our reference */ in fw_device_init()
1117 static int reread_config_rom(struct fw_device *device, int generation, in reread_config_rom() argument
1124 rcode = read_rom(device, generation, i, &q); in reread_config_rom()
1132 if (q != device->config_rom[i]) { in reread_config_rom()
1144 struct fw_device *device = in fw_device_refresh() local
1146 struct fw_card *card = device->card; in fw_device_refresh()
1147 int ret, node_id = device->node_id; in fw_device_refresh()
1150 ret = reread_config_rom(device, device->generation, &changed); in fw_device_refresh()
1155 if (atomic_cmpxchg(&device->state, in fw_device_refresh()
1161 device->config_rom_retries = 0; in fw_device_refresh()
1169 device_for_each_child(&device->device, NULL, shutdown_unit); in fw_device_refresh()
1171 ret = read_config_rom(device, device->generation); in fw_device_refresh()
1175 fw_device_cdev_update(device); in fw_device_refresh()
1176 create_units(device); in fw_device_refresh()
1179 kobject_uevent(&device->device.kobj, KOBJ_CHANGE); in fw_device_refresh()
1181 if (atomic_cmpxchg(&device->state, in fw_device_refresh()
1186 fw_notice(card, "refreshed device %s\n", dev_name(&device->device)); in fw_device_refresh()
1187 device->config_rom_retries = 0; in fw_device_refresh()
1191 if (device->config_rom_retries < MAX_RETRIES && in fw_device_refresh()
1192 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { in fw_device_refresh()
1193 device->config_rom_retries++; in fw_device_refresh()
1194 fw_schedule_device_work(device, RETRY_DELAY); in fw_device_refresh()
1199 dev_name(&device->device), fw_rcode_string(ret)); in fw_device_refresh()
1201 atomic_set(&device->state, FW_DEVICE_GONE); in fw_device_refresh()
1202 device->workfn = fw_device_shutdown; in fw_device_refresh()
1203 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_refresh()
1211 struct fw_device *device = container_of(to_delayed_work(work), in fw_device_workfn() local
1213 device->workfn(work); in fw_device_workfn()
1218 struct fw_device *device; in fw_node_event() local
1229 device = kzalloc(sizeof(*device), GFP_ATOMIC); in fw_node_event()
1230 if (device == NULL) in fw_node_event()
1243 atomic_set(&device->state, FW_DEVICE_INITIALIZING); in fw_node_event()
1244 device->card = fw_card_get(card); in fw_node_event()
1245 device->node = fw_node_get(node); in fw_node_event()
1246 device->node_id = node->node_id; in fw_node_event()
1247 device->generation = card->generation; in fw_node_event()
1248 device->is_local = node == card->local_node; in fw_node_event()
1249 mutex_init(&device->client_list_mutex); in fw_node_event()
1250 INIT_LIST_HEAD(&device->client_list); in fw_node_event()
1257 node->data = device; in fw_node_event()
1265 device->workfn = fw_device_init; in fw_node_event()
1266 INIT_DELAYED_WORK(&device->work, fw_device_workfn); in fw_node_event()
1267 fw_schedule_device_work(device, INITIAL_DELAY); in fw_node_event()
1272 device = node->data; in fw_node_event()
1273 if (device == NULL) in fw_node_event()
1276 device->node_id = node->node_id; in fw_node_event()
1278 device->generation = card->generation; in fw_node_event()
1279 if (atomic_cmpxchg(&device->state, in fw_node_event()
1282 device->workfn = fw_device_refresh; in fw_node_event()
1283 fw_schedule_device_work(device, in fw_node_event()
1284 device->is_local ? 0 : INITIAL_DELAY); in fw_node_event()
1289 device = node->data; in fw_node_event()
1290 if (device == NULL) in fw_node_event()
1293 device->node_id = node->node_id; in fw_node_event()
1295 device->generation = card->generation; in fw_node_event()
1296 if (atomic_read(&device->state) == FW_DEVICE_RUNNING) { in fw_node_event()
1297 device->workfn = fw_device_update; in fw_node_event()
1298 fw_schedule_device_work(device, 0); in fw_node_event()
1319 device = node->data; in fw_node_event()
1320 if (atomic_xchg(&device->state, in fw_node_event()
1322 device->workfn = fw_device_shutdown; in fw_node_event()
1323 fw_schedule_device_work(device, in fw_node_event()