Lines Matching refs:device

191 static const struct ieee1394_device_id *unit_match(struct device *dev,  in unit_match()
207 static bool is_fw_unit(const struct device *dev);
209 static int fw_unit_match(struct device *dev, const struct device_driver *drv) in fw_unit_match()
215 static int fw_unit_probe(struct device *dev) in fw_unit_probe()
223 static void fw_unit_remove(struct device *dev) in fw_unit_remove()
242 static int fw_unit_uevent(const struct device *dev, struct kobj_uevent_env *env) in fw_unit_uevent()
263 int fw_device_enable_phys_dma(struct fw_device *device) in fw_device_enable_phys_dma() argument
265 int generation = device->generation; in fw_device_enable_phys_dma()
270 return device->card->driver->enable_phys_dma(device->card, in fw_device_enable_phys_dma()
271 device->node_id, in fw_device_enable_phys_dma()
281 static ssize_t show_immediate(struct device *dev, in show_immediate()
329 static ssize_t show_text_leaf(struct device *dev, in show_text_leaf()
408 static void init_fw_attribute_group(struct device *dev, in init_fw_attribute_group()
432 static ssize_t modalias_show(struct device *dev, in modalias_show()
444 static ssize_t rom_index_show(struct device *dev, in rom_index_show()
447 struct fw_device *device = fw_device(dev->parent); in rom_index_show() local
450 return sysfs_emit(buf, "%td\n", unit->directory - device->config_rom); in rom_index_show()
459 static ssize_t config_rom_show(struct device *dev, in config_rom_show()
462 struct fw_device *device = fw_device(dev); in config_rom_show() local
467 length = device->config_rom_length * 4; in config_rom_show()
468 memcpy(buf, device->config_rom, length); in config_rom_show()
473 static ssize_t guid_show(struct device *dev, in guid_show()
476 struct fw_device *device = fw_device(dev); in guid_show() local
480 return sysfs_emit(buf, "0x%08x%08x\n", device->config_rom[3], device->config_rom[4]); in guid_show()
483 static ssize_t is_local_show(struct device *dev, in is_local_show()
486 struct fw_device *device = fw_device(dev); in is_local_show() local
488 return sysfs_emit(buf, "%u\n", device->is_local); in is_local_show()
513 static ssize_t units_show(struct device *dev, in units_show()
516 struct fw_device *device = fw_device(dev); in units_show() local
522 fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); in units_show()
621 static int read_rom(struct fw_device *device, int generation, int speed, int index, u32 *data) in read_rom() argument
630 rcode = fw_run_transaction(device->card, in read_rom()
631 TCODE_READ_QUADLET_REQUEST, device->node_id, in read_rom()
653 static int read_config_rom(struct fw_device *device, int generation) in read_config_rom() argument
655 struct fw_card *card = device->card; in read_config_rom()
674 ret = read_rom(device, generation, speed, i, &rom[i]); in read_config_rom()
692 WRITE_ONCE(device->quirks, quirks); in read_config_rom()
717 ret = read_rom(device, generation, speed, i, &rom[i]); in read_config_rom()
741 ret = read_rom(device, generation, speed, i, &rom[i]); in read_config_rom()
771 WRITE_ONCE(device->quirks, quirks); in read_config_rom()
776 speed = device->node->max_speed; in read_config_rom()
792 if (read_rom(device, generation, speed, 0, &dummy) == in read_config_rom()
799 device->max_speed = speed; in read_config_rom()
801 old_rom = device->config_rom; in read_config_rom()
807 device->config_rom = new_rom; in read_config_rom()
808 device->config_rom_length = length; in read_config_rom()
811 device->max_rec = rom[2] >> 12 & 0xf; in read_config_rom()
812 device->cmc = rom[2] >> 30 & 1; in read_config_rom()
813 device->irmc = rom[2] >> 31 & 1; in read_config_rom()
818 static void fw_unit_release(struct device *dev) in fw_unit_release()
831 static bool is_fw_unit(const struct device *dev) in is_fw_unit()
836 static void create_units(struct fw_device *device) in create_units() argument
843 fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); in create_units()
857 unit->device.bus = &fw_bus_type; in create_units()
858 unit->device.type = &fw_unit_type; in create_units()
859 unit->device.parent = &device->device; in create_units()
860 dev_set_name(&unit->device, "%s.%d", dev_name(&device->device), i++); in create_units()
865 init_fw_attribute_group(&unit->device, in create_units()
869 fw_device_get(device); in create_units()
870 if (device_register(&unit->device) < 0) { in create_units()
871 put_device(&unit->device); in create_units()
877 static int shutdown_unit(struct device *device, void *data) in shutdown_unit() argument
879 device_unregister(device); in shutdown_unit()
896 struct fw_device *device; in fw_device_get_by_devt() local
898 device = xa_load(&fw_device_xa, MINOR(devt)); in fw_device_get_by_devt()
899 if (device) in fw_device_get_by_devt()
900 fw_device_get(device); in fw_device_get_by_devt()
902 return device; in fw_device_get_by_devt()
908 static void fw_schedule_device_work(struct fw_device *device, in fw_schedule_device_work() argument
911 queue_delayed_work(fw_workqueue, &device->work, delay); in fw_schedule_device_work()
932 struct fw_device *device = from_work(device, work, work.work); in fw_device_shutdown() local
934 if (time_is_after_jiffies64(device->card->reset_jiffies + SHUTDOWN_DELAY) in fw_device_shutdown()
935 && !list_empty(&device->card->link)) { in fw_device_shutdown()
936 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_shutdown()
940 if (atomic_cmpxchg(&device->state, in fw_device_shutdown()
945 fw_device_cdev_remove(device); in fw_device_shutdown()
946 device_for_each_child(&device->device, NULL, shutdown_unit); in fw_device_shutdown()
947 device_unregister(&device->device); in fw_device_shutdown()
949 xa_erase(&fw_device_xa, MINOR(device->device.devt)); in fw_device_shutdown()
951 fw_device_put(device); in fw_device_shutdown()
954 static void fw_device_release(struct device *dev) in fw_device_release()
956 struct fw_device *device = fw_device(dev); in fw_device_release() local
957 struct fw_card *card = device->card; in fw_device_release()
965 fw_node_set_device(device->node, NULL); in fw_device_release()
967 fw_node_put(device->node); in fw_device_release()
968 kfree(device->config_rom); in fw_device_release()
969 kfree(device); in fw_device_release()
977 static bool is_fw_device(const struct device *dev) in is_fw_device()
982 static int update_unit(struct device *dev, void *data) in update_unit()
998 struct fw_device *device = from_work(device, work, work.work); in fw_device_update() local
1000 fw_device_cdev_update(device); in fw_device_update()
1001 device_for_each_child(&device->device, NULL, update_unit); in fw_device_update()
1006 static void set_broadcast_channel(struct fw_device *device, int generation) in set_broadcast_channel() argument
1008 struct fw_card *card = device->card; in set_broadcast_channel()
1022 if (!device->irmc || device->max_rec < 8) in set_broadcast_channel()
1029 if (device->bc_implemented == BC_UNKNOWN) { in set_broadcast_channel()
1031 device->node_id, generation, device->max_speed, in set_broadcast_channel()
1037 device->bc_implemented = BC_IMPLEMENTED; in set_broadcast_channel()
1042 device->bc_implemented = BC_UNIMPLEMENTED; in set_broadcast_channel()
1046 if (device->bc_implemented == BC_IMPLEMENTED) { in set_broadcast_channel()
1050 device->node_id, generation, device->max_speed, in set_broadcast_channel()
1056 int fw_device_set_broadcast_channel(struct device *dev, void *gen) in fw_device_set_broadcast_channel()
1064 static int compare_configuration_rom(struct device *dev, const void *data) in compare_configuration_rom()
1078 struct fw_device *device = from_work(device, work, work.work); in fw_device_init() local
1079 struct fw_card *card = device->card; in fw_device_init()
1080 struct device *found; in fw_device_init()
1090 ret = read_config_rom(device, device->generation); in fw_device_init()
1092 if (device->config_rom_retries < MAX_RETRIES && in fw_device_init()
1093 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { in fw_device_init()
1094 device->config_rom_retries++; in fw_device_init()
1095 fw_schedule_device_work(device, RETRY_DELAY); in fw_device_init()
1097 if (device->node->link_on) in fw_device_init()
1099 device->node_id, in fw_device_init()
1101 if (device->node == card->root_node) in fw_device_init()
1103 fw_device_release(&device->device); in fw_device_init()
1114 found = device_find_child(card->device, device->config_rom, in fw_device_init()
1125 struct fw_node *current_node = device->node; in fw_device_init()
1128 device->node = obsolete_node; in fw_device_init()
1129 fw_node_set_device(device->node, device); in fw_device_init()
1133 reused->max_speed = device->max_speed; in fw_device_init()
1149 fw_device_release(&device->device); in fw_device_init()
1157 device_initialize(&device->device); in fw_device_init()
1159 fw_device_get(device); in fw_device_init()
1162 ret = xa_alloc(&fw_device_xa, &minor, device, XA_LIMIT(0, MINORMASK), GFP_KERNEL); in fw_device_init()
1166 device->device.bus = &fw_bus_type; in fw_device_init()
1167 device->device.type = &fw_device_type; in fw_device_init()
1168 device->device.parent = card->device; in fw_device_init()
1169 device->device.devt = MKDEV(fw_cdev_major, minor); in fw_device_init()
1170 dev_set_name(&device->device, "fw%d", minor); in fw_device_init()
1172 BUILD_BUG_ON(ARRAY_SIZE(device->attribute_group.attrs) < in fw_device_init()
1175 init_fw_attribute_group(&device->device, in fw_device_init()
1177 &device->attribute_group); in fw_device_init()
1179 if (device_add(&device->device)) { in fw_device_init()
1184 create_units(device); in fw_device_init()
1195 if (atomic_cmpxchg(&device->state, in fw_device_init()
1198 device->workfn = fw_device_shutdown; in fw_device_init()
1199 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_init()
1202 dev_name(&device->device), in fw_device_init()
1203 device->config_rom[3], device->config_rom[4], in fw_device_init()
1204 1 << device->max_speed, device->quirks); in fw_device_init()
1205 device->config_rom_retries = 0; in fw_device_init()
1207 set_broadcast_channel(device, device->generation); in fw_device_init()
1209 add_device_randomness(&device->config_rom[3], 8); in fw_device_init()
1218 if (device->node == card->root_node) in fw_device_init()
1226 fw_device_put(device); // fw_device_xa's reference. in fw_device_init()
1228 put_device(&device->device); /* our reference */ in fw_device_init()
1232 static int reread_config_rom(struct fw_device *device, int generation, in reread_config_rom() argument
1239 rcode = read_rom(device, generation, device->max_speed, i, &q); in reread_config_rom()
1247 if (q != device->config_rom[i]) { in reread_config_rom()
1259 struct fw_device *device = from_work(device, work, work.work); in fw_device_refresh() local
1260 struct fw_card *card = device->card; in fw_device_refresh()
1261 int ret, node_id = device->node_id; in fw_device_refresh()
1264 ret = reread_config_rom(device, device->generation, &changed); in fw_device_refresh()
1269 if (atomic_cmpxchg(&device->state, in fw_device_refresh()
1275 device->config_rom_retries = 0; in fw_device_refresh()
1283 device_for_each_child(&device->device, NULL, shutdown_unit); in fw_device_refresh()
1285 ret = read_config_rom(device, device->generation); in fw_device_refresh()
1289 fw_device_cdev_update(device); in fw_device_refresh()
1290 create_units(device); in fw_device_refresh()
1293 kobject_uevent(&device->device.kobj, KOBJ_CHANGE); in fw_device_refresh()
1295 if (atomic_cmpxchg(&device->state, in fw_device_refresh()
1300 fw_notice(card, "refreshed device %s\n", dev_name(&device->device)); in fw_device_refresh()
1301 device->config_rom_retries = 0; in fw_device_refresh()
1305 if (device->config_rom_retries < MAX_RETRIES && in fw_device_refresh()
1306 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { in fw_device_refresh()
1307 device->config_rom_retries++; in fw_device_refresh()
1308 fw_schedule_device_work(device, RETRY_DELAY); in fw_device_refresh()
1313 dev_name(&device->device), fw_rcode_string(ret)); in fw_device_refresh()
1315 atomic_set(&device->state, FW_DEVICE_GONE); in fw_device_refresh()
1316 device->workfn = fw_device_shutdown; in fw_device_refresh()
1317 fw_schedule_device_work(device, SHUTDOWN_DELAY); in fw_device_refresh()
1325 struct fw_device *device = from_work(device, to_delayed_work(work), work); in fw_device_workfn() local
1326 device->workfn(work); in fw_device_workfn()
1331 struct fw_device *device; in fw_node_event() local
1342 device = kzalloc_obj(*device, GFP_ATOMIC); in fw_node_event()
1343 if (device == NULL) in fw_node_event()
1356 atomic_set(&device->state, FW_DEVICE_INITIALIZING); in fw_node_event()
1357 device->card = fw_card_get(card); in fw_node_event()
1358 device->node = fw_node_get(node); in fw_node_event()
1359 device->node_id = node->node_id; in fw_node_event()
1360 device->generation = card->generation; in fw_node_event()
1361 device->is_local = node == card->local_node; in fw_node_event()
1362 mutex_init(&device->client_list_mutex); in fw_node_event()
1363 INIT_LIST_HEAD(&device->client_list); in fw_node_event()
1370 fw_node_set_device(node, device); in fw_node_event()
1378 device->workfn = fw_device_init; in fw_node_event()
1379 INIT_DELAYED_WORK(&device->work, fw_device_workfn); in fw_node_event()
1380 fw_schedule_device_work(device, INITIAL_DELAY); in fw_node_event()
1385 device = fw_node_get_device(node); in fw_node_event()
1386 if (device == NULL) in fw_node_event()
1389 device->node_id = node->node_id; in fw_node_event()
1391 device->generation = card->generation; in fw_node_event()
1392 if (atomic_cmpxchg(&device->state, in fw_node_event()
1395 device->workfn = fw_device_refresh; in fw_node_event()
1396 fw_schedule_device_work(device, in fw_node_event()
1397 device->is_local ? 0 : INITIAL_DELAY); in fw_node_event()
1402 device = fw_node_get_device(node); in fw_node_event()
1403 if (device == NULL) in fw_node_event()
1406 device->node_id = node->node_id; in fw_node_event()
1408 device->generation = card->generation; in fw_node_event()
1409 if (atomic_read(&device->state) == FW_DEVICE_RUNNING) { in fw_node_event()
1410 device->workfn = fw_device_update; in fw_node_event()
1411 fw_schedule_device_work(device, 0); in fw_node_event()
1432 device = fw_node_get_device(node); in fw_node_event()
1433 if (atomic_xchg(&device->state, in fw_node_event()
1435 device->workfn = fw_device_shutdown; in fw_node_event()
1436 fw_schedule_device_work(device, in fw_node_event()