Commit bb93109e1544e2a4d12c2c35bf1af84c25a2699d
Exists in
master
and in
20 other branches
Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394
Pull firewire updates from Stefan Richter: "Make struct ieee1394_device_id.driver_data actually avaliable to 1394 protocol drivers. This is especially useful to 1394 audio drivers for model-specific parameters and methods" * tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394: firewire: remove support of fw_driver.driver.probe and .remove methods firewire: introduce fw_driver.probe and .remove methods
Showing 9 changed files Side-by-side Diff
drivers/firewire/core-device.c
... | ... | @@ -165,27 +165,46 @@ |
165 | 165 | return (match & id_table->match_flags) == id_table->match_flags; |
166 | 166 | } |
167 | 167 | |
168 | -static bool is_fw_unit(struct device *dev); | |
169 | - | |
170 | -static int fw_unit_match(struct device *dev, struct device_driver *drv) | |
168 | +static const struct ieee1394_device_id *unit_match(struct device *dev, | |
169 | + struct device_driver *drv) | |
171 | 170 | { |
172 | 171 | const struct ieee1394_device_id *id_table = |
173 | 172 | container_of(drv, struct fw_driver, driver)->id_table; |
174 | 173 | int id[] = {0, 0, 0, 0}; |
175 | 174 | |
176 | - /* We only allow binding to fw_units. */ | |
177 | - if (!is_fw_unit(dev)) | |
178 | - return 0; | |
179 | - | |
180 | 175 | get_modalias_ids(fw_unit(dev), id); |
181 | 176 | |
182 | 177 | for (; id_table->match_flags != 0; id_table++) |
183 | 178 | if (match_ids(id_table, id)) |
184 | - return 1; | |
179 | + return id_table; | |
185 | 180 | |
186 | - return 0; | |
181 | + return NULL; | |
187 | 182 | } |
188 | 183 | |
184 | +static bool is_fw_unit(struct device *dev); | |
185 | + | |
186 | +static int fw_unit_match(struct device *dev, struct device_driver *drv) | |
187 | +{ | |
188 | + /* We only allow binding to fw_units. */ | |
189 | + return is_fw_unit(dev) && unit_match(dev, drv) != NULL; | |
190 | +} | |
191 | + | |
192 | +static int fw_unit_probe(struct device *dev) | |
193 | +{ | |
194 | + struct fw_driver *driver = | |
195 | + container_of(dev->driver, struct fw_driver, driver); | |
196 | + | |
197 | + return driver->probe(fw_unit(dev), unit_match(dev, dev->driver)); | |
198 | +} | |
199 | + | |
200 | +static int fw_unit_remove(struct device *dev) | |
201 | +{ | |
202 | + struct fw_driver *driver = | |
203 | + container_of(dev->driver, struct fw_driver, driver); | |
204 | + | |
205 | + return driver->remove(fw_unit(dev)), 0; | |
206 | +} | |
207 | + | |
189 | 208 | static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) |
190 | 209 | { |
191 | 210 | int id[] = {0, 0, 0, 0}; |
... | ... | @@ -213,6 +232,8 @@ |
213 | 232 | struct bus_type fw_bus_type = { |
214 | 233 | .name = "firewire", |
215 | 234 | .match = fw_unit_match, |
235 | + .probe = fw_unit_probe, | |
236 | + .remove = fw_unit_remove, | |
216 | 237 | }; |
217 | 238 | EXPORT_SYMBOL(fw_bus_type); |
218 | 239 |
drivers/firewire/net.c
... | ... | @@ -1440,9 +1440,9 @@ |
1440 | 1440 | return 0; |
1441 | 1441 | } |
1442 | 1442 | |
1443 | -static int fwnet_probe(struct device *_dev) | |
1443 | +static int fwnet_probe(struct fw_unit *unit, | |
1444 | + const struct ieee1394_device_id *id) | |
1444 | 1445 | { |
1445 | - struct fw_unit *unit = fw_unit(_dev); | |
1446 | 1446 | struct fw_device *device = fw_parent_device(unit); |
1447 | 1447 | struct fw_card *card = device->card; |
1448 | 1448 | struct net_device *net; |
... | ... | @@ -1526,6 +1526,24 @@ |
1526 | 1526 | return ret; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | +/* | |
1530 | + * FIXME abort partially sent fragmented datagrams, | |
1531 | + * discard partially received fragmented datagrams | |
1532 | + */ | |
1533 | +static void fwnet_update(struct fw_unit *unit) | |
1534 | +{ | |
1535 | + struct fw_device *device = fw_parent_device(unit); | |
1536 | + struct fwnet_peer *peer = dev_get_drvdata(&unit->device); | |
1537 | + int generation; | |
1538 | + | |
1539 | + generation = device->generation; | |
1540 | + | |
1541 | + spin_lock_irq(&peer->dev->lock); | |
1542 | + peer->node_id = device->node_id; | |
1543 | + peer->generation = generation; | |
1544 | + spin_unlock_irq(&peer->dev->lock); | |
1545 | +} | |
1546 | + | |
1529 | 1547 | static void fwnet_remove_peer(struct fwnet_peer *peer, struct fwnet_device *dev) |
1530 | 1548 | { |
1531 | 1549 | struct fwnet_partial_datagram *pd, *pd_next; |
1532 | 1550 | |
... | ... | @@ -1542,9 +1560,9 @@ |
1542 | 1560 | kfree(peer); |
1543 | 1561 | } |
1544 | 1562 | |
1545 | -static int fwnet_remove(struct device *_dev) | |
1563 | +static void fwnet_remove(struct fw_unit *unit) | |
1546 | 1564 | { |
1547 | - struct fwnet_peer *peer = dev_get_drvdata(_dev); | |
1565 | + struct fwnet_peer *peer = dev_get_drvdata(&unit->device); | |
1548 | 1566 | struct fwnet_device *dev = peer->dev; |
1549 | 1567 | struct net_device *net; |
1550 | 1568 | int i; |
1551 | 1569 | |
... | ... | @@ -1569,28 +1587,8 @@ |
1569 | 1587 | } |
1570 | 1588 | |
1571 | 1589 | mutex_unlock(&fwnet_device_mutex); |
1572 | - | |
1573 | - return 0; | |
1574 | 1590 | } |
1575 | 1591 | |
1576 | -/* | |
1577 | - * FIXME abort partially sent fragmented datagrams, | |
1578 | - * discard partially received fragmented datagrams | |
1579 | - */ | |
1580 | -static void fwnet_update(struct fw_unit *unit) | |
1581 | -{ | |
1582 | - struct fw_device *device = fw_parent_device(unit); | |
1583 | - struct fwnet_peer *peer = dev_get_drvdata(&unit->device); | |
1584 | - int generation; | |
1585 | - | |
1586 | - generation = device->generation; | |
1587 | - | |
1588 | - spin_lock_irq(&peer->dev->lock); | |
1589 | - peer->node_id = device->node_id; | |
1590 | - peer->generation = generation; | |
1591 | - spin_unlock_irq(&peer->dev->lock); | |
1592 | -} | |
1593 | - | |
1594 | 1592 | static const struct ieee1394_device_id fwnet_id_table[] = { |
1595 | 1593 | { |
1596 | 1594 | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | |
1597 | 1595 | |
1598 | 1596 | |
... | ... | @@ -1614,10 +1612,10 @@ |
1614 | 1612 | .owner = THIS_MODULE, |
1615 | 1613 | .name = KBUILD_MODNAME, |
1616 | 1614 | .bus = &fw_bus_type, |
1617 | - .probe = fwnet_probe, | |
1618 | - .remove = fwnet_remove, | |
1619 | 1615 | }, |
1616 | + .probe = fwnet_probe, | |
1620 | 1617 | .update = fwnet_update, |
1618 | + .remove = fwnet_remove, | |
1621 | 1619 | .id_table = fwnet_id_table, |
1622 | 1620 | }; |
1623 | 1621 |
drivers/firewire/sbp2.c
... | ... | @@ -1128,11 +1128,10 @@ |
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | static struct scsi_host_template scsi_driver_template; |
1131 | -static int sbp2_remove(struct device *dev); | |
1131 | +static void sbp2_remove(struct fw_unit *unit); | |
1132 | 1132 | |
1133 | -static int sbp2_probe(struct device *dev) | |
1133 | +static int sbp2_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) | |
1134 | 1134 | { |
1135 | - struct fw_unit *unit = fw_unit(dev); | |
1136 | 1135 | struct fw_device *device = fw_parent_device(unit); |
1137 | 1136 | struct sbp2_target *tgt; |
1138 | 1137 | struct sbp2_logical_unit *lu; |
... | ... | @@ -1196,7 +1195,7 @@ |
1196 | 1195 | return 0; |
1197 | 1196 | |
1198 | 1197 | fail_remove: |
1199 | - sbp2_remove(dev); | |
1198 | + sbp2_remove(unit); | |
1200 | 1199 | return -ENOMEM; |
1201 | 1200 | |
1202 | 1201 | fail_shost_put: |
1203 | 1202 | |
... | ... | @@ -1222,9 +1221,8 @@ |
1222 | 1221 | } |
1223 | 1222 | } |
1224 | 1223 | |
1225 | -static int sbp2_remove(struct device *dev) | |
1224 | +static void sbp2_remove(struct fw_unit *unit) | |
1226 | 1225 | { |
1227 | - struct fw_unit *unit = fw_unit(dev); | |
1228 | 1226 | struct fw_device *device = fw_parent_device(unit); |
1229 | 1227 | struct sbp2_target *tgt = dev_get_drvdata(&unit->device); |
1230 | 1228 | struct sbp2_logical_unit *lu, *next; |
1231 | 1229 | |
... | ... | @@ -1261,10 +1259,9 @@ |
1261 | 1259 | kfree(lu); |
1262 | 1260 | } |
1263 | 1261 | scsi_remove_host(shost); |
1264 | - dev_notice(dev, "released target %d:0:0\n", shost->host_no); | |
1262 | + dev_notice(&unit->device, "released target %d:0:0\n", shost->host_no); | |
1265 | 1263 | |
1266 | 1264 | scsi_host_put(shost); |
1267 | - return 0; | |
1268 | 1265 | } |
1269 | 1266 | |
1270 | 1267 | #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e |
1271 | 1268 | |
1272 | 1269 | |
... | ... | @@ -1285,10 +1282,10 @@ |
1285 | 1282 | .owner = THIS_MODULE, |
1286 | 1283 | .name = KBUILD_MODNAME, |
1287 | 1284 | .bus = &fw_bus_type, |
1288 | - .probe = sbp2_probe, | |
1289 | - .remove = sbp2_remove, | |
1290 | 1285 | }, |
1286 | + .probe = sbp2_probe, | |
1291 | 1287 | .update = sbp2_update, |
1288 | + .remove = sbp2_remove, | |
1292 | 1289 | .id_table = sbp2_id_table, |
1293 | 1290 | }; |
1294 | 1291 |
drivers/media/firewire/firedtv-fw.c
... | ... | @@ -248,7 +248,7 @@ |
248 | 248 | /* Adjust the template string if models with longer names appear. */ |
249 | 249 | #define MAX_MODEL_NAME_LEN sizeof("FireDTV ????") |
250 | 250 | |
251 | -static int node_probe(struct device *dev) | |
251 | +static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) | |
252 | 252 | { |
253 | 253 | struct firedtv *fdtv; |
254 | 254 | char name[MAX_MODEL_NAME_LEN]; |
... | ... | @@ -258,8 +258,8 @@ |
258 | 258 | if (!fdtv) |
259 | 259 | return -ENOMEM; |
260 | 260 | |
261 | - dev_set_drvdata(dev, fdtv); | |
262 | - fdtv->device = dev; | |
261 | + dev_set_drvdata(&unit->device, fdtv); | |
262 | + fdtv->device = &unit->device; | |
263 | 263 | fdtv->isochannel = -1; |
264 | 264 | fdtv->voltage = 0xff; |
265 | 265 | fdtv->tone = 0xff; |
... | ... | @@ -269,7 +269,7 @@ |
269 | 269 | mutex_init(&fdtv->demux_mutex); |
270 | 270 | INIT_WORK(&fdtv->remote_ctrl_work, avc_remote_ctrl_work); |
271 | 271 | |
272 | - name_len = fw_csr_string(fw_unit(dev)->directory, CSR_MODEL, | |
272 | + name_len = fw_csr_string(unit->directory, CSR_MODEL, | |
273 | 273 | name, sizeof(name)); |
274 | 274 | for (i = ARRAY_SIZE(model_names); --i; ) |
275 | 275 | if (strlen(model_names[i]) <= name_len && |
... | ... | @@ -277,7 +277,7 @@ |
277 | 277 | break; |
278 | 278 | fdtv->type = i; |
279 | 279 | |
280 | - err = fdtv_register_rc(fdtv, dev); | |
280 | + err = fdtv_register_rc(fdtv, &unit->device); | |
281 | 281 | if (err) |
282 | 282 | goto fail_free; |
283 | 283 | |
284 | 284 | |
... | ... | @@ -307,9 +307,9 @@ |
307 | 307 | return err; |
308 | 308 | } |
309 | 309 | |
310 | -static int node_remove(struct device *dev) | |
310 | +static void node_remove(struct fw_unit *unit) | |
311 | 311 | { |
312 | - struct firedtv *fdtv = dev_get_drvdata(dev); | |
312 | + struct firedtv *fdtv = dev_get_drvdata(&unit->device); | |
313 | 313 | |
314 | 314 | fdtv_dvb_unregister(fdtv); |
315 | 315 | |
... | ... | @@ -320,7 +320,6 @@ |
320 | 320 | fdtv_unregister_rc(fdtv); |
321 | 321 | |
322 | 322 | kfree(fdtv); |
323 | - return 0; | |
324 | 323 | } |
325 | 324 | |
326 | 325 | static void node_update(struct fw_unit *unit) |
327 | 326 | |
328 | 327 | |
... | ... | @@ -391,10 +390,10 @@ |
391 | 390 | .owner = THIS_MODULE, |
392 | 391 | .name = "firedtv", |
393 | 392 | .bus = &fw_bus_type, |
394 | - .probe = node_probe, | |
395 | - .remove = node_remove, | |
396 | 393 | }, |
394 | + .probe = node_probe, | |
397 | 395 | .update = node_update, |
396 | + .remove = node_remove, | |
398 | 397 | .id_table = fdtv_id_table, |
399 | 398 | }; |
400 | 399 |
drivers/staging/fwserial/fwserial.c
... | ... | @@ -2446,9 +2446,9 @@ |
2446 | 2446 | * last peer for a given fw_card triggering the destruction of the same |
2447 | 2447 | * fw_serial for the same fw_card. |
2448 | 2448 | */ |
2449 | -static int fwserial_probe(struct device *dev) | |
2449 | +static int fwserial_probe(struct fw_unit *unit, | |
2450 | + const struct ieee1394_device_id *id) | |
2450 | 2451 | { |
2451 | - struct fw_unit *unit = fw_unit(dev); | |
2452 | 2452 | struct fw_serial *serial; |
2453 | 2453 | int err; |
2454 | 2454 | |
2455 | 2455 | |
... | ... | @@ -2470,9 +2470,9 @@ |
2470 | 2470 | * specific fw_card). If this is the last peer being removed, then trigger |
2471 | 2471 | * the destruction of the underlying TTYs. |
2472 | 2472 | */ |
2473 | -static int fwserial_remove(struct device *dev) | |
2473 | +static void fwserial_remove(struct fw_unit *unit) | |
2474 | 2474 | { |
2475 | - struct fwtty_peer *peer = dev_get_drvdata(dev); | |
2475 | + struct fwtty_peer *peer = dev_get_drvdata(&unit->device); | |
2476 | 2476 | struct fw_serial *serial = peer->serial; |
2477 | 2477 | int i; |
2478 | 2478 | |
... | ... | @@ -2492,8 +2492,6 @@ |
2492 | 2492 | kref_put(&serial->kref, fwserial_destroy); |
2493 | 2493 | } |
2494 | 2494 | mutex_unlock(&fwserial_list_mutex); |
2495 | - | |
2496 | - return 0; | |
2497 | 2495 | } |
2498 | 2496 | |
2499 | 2497 | /** |
2500 | 2498 | |
2501 | 2499 | |
... | ... | @@ -2538,10 +2536,10 @@ |
2538 | 2536 | .owner = THIS_MODULE, |
2539 | 2537 | .name = KBUILD_MODNAME, |
2540 | 2538 | .bus = &fw_bus_type, |
2541 | - .probe = fwserial_probe, | |
2542 | - .remove = fwserial_remove, | |
2543 | 2539 | }, |
2540 | + .probe = fwserial_probe, | |
2544 | 2541 | .update = fwserial_update, |
2542 | + .remove = fwserial_remove, | |
2545 | 2543 | .id_table = fwserial_id_table, |
2546 | 2544 | }; |
2547 | 2545 |
include/linux/firewire.h
... | ... | @@ -251,8 +251,10 @@ |
251 | 251 | |
252 | 252 | struct fw_driver { |
253 | 253 | struct device_driver driver; |
254 | + int (*probe)(struct fw_unit *unit, const struct ieee1394_device_id *id); | |
254 | 255 | /* Called when the parent device sits through a bus reset. */ |
255 | 256 | void (*update)(struct fw_unit *unit); |
257 | + void (*remove)(struct fw_unit *unit); | |
256 | 258 | const struct ieee1394_device_id *id_table; |
257 | 259 | }; |
258 | 260 |
sound/firewire/isight.c
... | ... | @@ -626,9 +626,9 @@ |
626 | 626 | return 0; |
627 | 627 | } |
628 | 628 | |
629 | -static int isight_probe(struct device *unit_dev) | |
629 | +static int isight_probe(struct fw_unit *unit, | |
630 | + const struct ieee1394_device_id *id) | |
630 | 631 | { |
631 | - struct fw_unit *unit = fw_unit(unit_dev); | |
632 | 632 | struct fw_device *fw_dev = fw_parent_device(unit); |
633 | 633 | struct snd_card *card; |
634 | 634 | struct isight *isight; |
... | ... | @@ -637,7 +637,7 @@ |
637 | 637 | err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card); |
638 | 638 | if (err < 0) |
639 | 639 | return err; |
640 | - snd_card_set_dev(card, unit_dev); | |
640 | + snd_card_set_dev(card, &unit->device); | |
641 | 641 | |
642 | 642 | isight = card->private_data; |
643 | 643 | isight->card = card; |
... | ... | @@ -674,7 +674,7 @@ |
674 | 674 | if (err < 0) |
675 | 675 | goto error; |
676 | 676 | |
677 | - dev_set_drvdata(unit_dev, isight); | |
677 | + dev_set_drvdata(&unit->device, isight); | |
678 | 678 | |
679 | 679 | return 0; |
680 | 680 | |
... | ... | @@ -686,23 +686,6 @@ |
686 | 686 | return err; |
687 | 687 | } |
688 | 688 | |
689 | -static int isight_remove(struct device *dev) | |
690 | -{ | |
691 | - struct isight *isight = dev_get_drvdata(dev); | |
692 | - | |
693 | - isight_pcm_abort(isight); | |
694 | - | |
695 | - snd_card_disconnect(isight->card); | |
696 | - | |
697 | - mutex_lock(&isight->mutex); | |
698 | - isight_stop_streaming(isight); | |
699 | - mutex_unlock(&isight->mutex); | |
700 | - | |
701 | - snd_card_free_when_closed(isight->card); | |
702 | - | |
703 | - return 0; | |
704 | -} | |
705 | - | |
706 | 689 | static void isight_bus_reset(struct fw_unit *unit) |
707 | 690 | { |
708 | 691 | struct isight *isight = dev_get_drvdata(&unit->device); |
... | ... | @@ -716,6 +699,21 @@ |
716 | 699 | } |
717 | 700 | } |
718 | 701 | |
702 | +static void isight_remove(struct fw_unit *unit) | |
703 | +{ | |
704 | + struct isight *isight = dev_get_drvdata(&unit->device); | |
705 | + | |
706 | + isight_pcm_abort(isight); | |
707 | + | |
708 | + snd_card_disconnect(isight->card); | |
709 | + | |
710 | + mutex_lock(&isight->mutex); | |
711 | + isight_stop_streaming(isight); | |
712 | + mutex_unlock(&isight->mutex); | |
713 | + | |
714 | + snd_card_free_when_closed(isight->card); | |
715 | +} | |
716 | + | |
719 | 717 | static const struct ieee1394_device_id isight_id_table[] = { |
720 | 718 | { |
721 | 719 | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | |
722 | 720 | |
723 | 721 | |
... | ... | @@ -732,10 +730,10 @@ |
732 | 730 | .owner = THIS_MODULE, |
733 | 731 | .name = KBUILD_MODNAME, |
734 | 732 | .bus = &fw_bus_type, |
735 | - .probe = isight_probe, | |
736 | - .remove = isight_remove, | |
737 | 733 | }, |
734 | + .probe = isight_probe, | |
738 | 735 | .update = isight_bus_reset, |
736 | + .remove = isight_remove, | |
739 | 737 | .id_table = isight_id_table, |
740 | 738 | }; |
741 | 739 |
sound/firewire/scs1x.c
... | ... | @@ -384,9 +384,8 @@ |
384 | 384 | kfree(scs->buffer); |
385 | 385 | } |
386 | 386 | |
387 | -static int scs_probe(struct device *unit_dev) | |
387 | +static int scs_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) | |
388 | 388 | { |
389 | - struct fw_unit *unit = fw_unit(unit_dev); | |
390 | 389 | struct fw_device *fw_dev = fw_parent_device(unit); |
391 | 390 | struct snd_card *card; |
392 | 391 | struct scs *scs; |
... | ... | @@ -395,7 +394,7 @@ |
395 | 394 | err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card); |
396 | 395 | if (err < 0) |
397 | 396 | return err; |
398 | - snd_card_set_dev(card, unit_dev); | |
397 | + snd_card_set_dev(card, &unit->device); | |
399 | 398 | |
400 | 399 | scs = card->private_data; |
401 | 400 | scs->card = card; |
... | ... | @@ -442,7 +441,7 @@ |
442 | 441 | if (err < 0) |
443 | 442 | goto err_card; |
444 | 443 | |
445 | - dev_set_drvdata(unit_dev, scs); | |
444 | + dev_set_drvdata(&unit->device, scs); | |
446 | 445 | |
447 | 446 | return 0; |
448 | 447 | |
449 | 448 | |
450 | 449 | |
... | ... | @@ -453,10 +452,21 @@ |
453 | 452 | return err; |
454 | 453 | } |
455 | 454 | |
456 | -static int scs_remove(struct device *dev) | |
455 | +static void scs_update(struct fw_unit *unit) | |
457 | 456 | { |
458 | - struct scs *scs = dev_get_drvdata(dev); | |
457 | + struct scs *scs = dev_get_drvdata(&unit->device); | |
458 | + __be64 data; | |
459 | 459 | |
460 | + data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | | |
461 | + scs->hss_handler.offset); | |
462 | + snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, | |
463 | + HSS1394_ADDRESS, &data, 8); | |
464 | +} | |
465 | + | |
466 | +static void scs_remove(struct fw_unit *unit) | |
467 | +{ | |
468 | + struct scs *scs = dev_get_drvdata(&unit->device); | |
469 | + | |
460 | 470 | snd_card_disconnect(scs->card); |
461 | 471 | |
462 | 472 | ACCESS_ONCE(scs->output) = NULL; |
463 | 473 | |
... | ... | @@ -467,21 +477,8 @@ |
467 | 477 | tasklet_kill(&scs->tasklet); |
468 | 478 | |
469 | 479 | snd_card_free_when_closed(scs->card); |
470 | - | |
471 | - return 0; | |
472 | 480 | } |
473 | 481 | |
474 | -static void scs_update(struct fw_unit *unit) | |
475 | -{ | |
476 | - struct scs *scs = dev_get_drvdata(&unit->device); | |
477 | - __be64 data; | |
478 | - | |
479 | - data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | | |
480 | - scs->hss_handler.offset); | |
481 | - snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, | |
482 | - HSS1394_ADDRESS, &data, 8); | |
483 | -} | |
484 | - | |
485 | 482 | static const struct ieee1394_device_id scs_id_table[] = { |
486 | 483 | { |
487 | 484 | .match_flags = IEEE1394_MATCH_VENDOR_ID | |
488 | 485 | |
489 | 486 | |
... | ... | @@ -508,10 +505,10 @@ |
508 | 505 | .owner = THIS_MODULE, |
509 | 506 | .name = KBUILD_MODNAME, |
510 | 507 | .bus = &fw_bus_type, |
511 | - .probe = scs_probe, | |
512 | - .remove = scs_remove, | |
513 | 508 | }, |
509 | + .probe = scs_probe, | |
514 | 510 | .update = scs_update, |
511 | + .remove = scs_remove, | |
515 | 512 | .id_table = scs_id_table, |
516 | 513 | }; |
517 | 514 |
sound/firewire/speakers.c
... | ... | @@ -663,45 +663,9 @@ |
663 | 663 | mutex_destroy(&fwspk->mutex); |
664 | 664 | } |
665 | 665 | |
666 | -static const struct device_info *fwspk_detect(struct fw_device *dev) | |
666 | +static int fwspk_probe(struct fw_unit *unit, | |
667 | + const struct ieee1394_device_id *id) | |
667 | 668 | { |
668 | - static const struct device_info griffin_firewave = { | |
669 | - .driver_name = "FireWave", | |
670 | - .short_name = "FireWave", | |
671 | - .long_name = "Griffin FireWave Surround", | |
672 | - .pcm_constraints = firewave_constraints, | |
673 | - .mixer_channels = 6, | |
674 | - .mute_fb_id = 0x01, | |
675 | - .volume_fb_id = 0x02, | |
676 | - }; | |
677 | - static const struct device_info lacie_speakers = { | |
678 | - .driver_name = "FWSpeakers", | |
679 | - .short_name = "FireWire Speakers", | |
680 | - .long_name = "LaCie FireWire Speakers", | |
681 | - .pcm_constraints = lacie_speakers_constraints, | |
682 | - .mixer_channels = 1, | |
683 | - .mute_fb_id = 0x01, | |
684 | - .volume_fb_id = 0x01, | |
685 | - }; | |
686 | - struct fw_csr_iterator i; | |
687 | - int key, value; | |
688 | - | |
689 | - fw_csr_iterator_init(&i, dev->config_rom); | |
690 | - while (fw_csr_iterator_next(&i, &key, &value)) | |
691 | - if (key == CSR_VENDOR) | |
692 | - switch (value) { | |
693 | - case VENDOR_GRIFFIN: | |
694 | - return &griffin_firewave; | |
695 | - case VENDOR_LACIE: | |
696 | - return &lacie_speakers; | |
697 | - } | |
698 | - | |
699 | - return NULL; | |
700 | -} | |
701 | - | |
702 | -static int fwspk_probe(struct device *unit_dev) | |
703 | -{ | |
704 | - struct fw_unit *unit = fw_unit(unit_dev); | |
705 | 669 | struct fw_device *fw_dev = fw_parent_device(unit); |
706 | 670 | struct snd_card *card; |
707 | 671 | struct fwspk *fwspk; |
708 | 672 | |
... | ... | @@ -711,17 +675,13 @@ |
711 | 675 | err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card); |
712 | 676 | if (err < 0) |
713 | 677 | return err; |
714 | - snd_card_set_dev(card, unit_dev); | |
678 | + snd_card_set_dev(card, &unit->device); | |
715 | 679 | |
716 | 680 | fwspk = card->private_data; |
717 | 681 | fwspk->card = card; |
718 | 682 | mutex_init(&fwspk->mutex); |
719 | 683 | fwspk->unit = fw_unit_get(unit); |
720 | - fwspk->device_info = fwspk_detect(fw_dev); | |
721 | - if (!fwspk->device_info) { | |
722 | - err = -ENODEV; | |
723 | - goto err_unit; | |
724 | - } | |
684 | + fwspk->device_info = (const struct device_info *)id->driver_data; | |
725 | 685 | |
726 | 686 | err = cmp_connection_init(&fwspk->connection, unit, 0); |
727 | 687 | if (err < 0) |
... | ... | @@ -756,7 +716,7 @@ |
756 | 716 | if (err < 0) |
757 | 717 | goto error; |
758 | 718 | |
759 | - dev_set_drvdata(unit_dev, fwspk); | |
719 | + dev_set_drvdata(&unit->device, fwspk); | |
760 | 720 | |
761 | 721 | return 0; |
762 | 722 | |
... | ... | @@ -770,22 +730,6 @@ |
770 | 730 | return err; |
771 | 731 | } |
772 | 732 | |
773 | -static int fwspk_remove(struct device *dev) | |
774 | -{ | |
775 | - struct fwspk *fwspk = dev_get_drvdata(dev); | |
776 | - | |
777 | - amdtp_out_stream_pcm_abort(&fwspk->stream); | |
778 | - snd_card_disconnect(fwspk->card); | |
779 | - | |
780 | - mutex_lock(&fwspk->mutex); | |
781 | - fwspk_stop_stream(fwspk); | |
782 | - mutex_unlock(&fwspk->mutex); | |
783 | - | |
784 | - snd_card_free_when_closed(fwspk->card); | |
785 | - | |
786 | - return 0; | |
787 | -} | |
788 | - | |
789 | 733 | static void fwspk_bus_reset(struct fw_unit *unit) |
790 | 734 | { |
791 | 735 | struct fwspk *fwspk = dev_get_drvdata(&unit->device); |
... | ... | @@ -803,6 +747,40 @@ |
803 | 747 | amdtp_out_stream_update(&fwspk->stream); |
804 | 748 | } |
805 | 749 | |
750 | +static void fwspk_remove(struct fw_unit *unit) | |
751 | +{ | |
752 | + struct fwspk *fwspk = dev_get_drvdata(&unit->device); | |
753 | + | |
754 | + amdtp_out_stream_pcm_abort(&fwspk->stream); | |
755 | + snd_card_disconnect(fwspk->card); | |
756 | + | |
757 | + mutex_lock(&fwspk->mutex); | |
758 | + fwspk_stop_stream(fwspk); | |
759 | + mutex_unlock(&fwspk->mutex); | |
760 | + | |
761 | + snd_card_free_when_closed(fwspk->card); | |
762 | +} | |
763 | + | |
764 | +static const struct device_info griffin_firewave = { | |
765 | + .driver_name = "FireWave", | |
766 | + .short_name = "FireWave", | |
767 | + .long_name = "Griffin FireWave Surround", | |
768 | + .pcm_constraints = firewave_constraints, | |
769 | + .mixer_channels = 6, | |
770 | + .mute_fb_id = 0x01, | |
771 | + .volume_fb_id = 0x02, | |
772 | +}; | |
773 | + | |
774 | +static const struct device_info lacie_speakers = { | |
775 | + .driver_name = "FWSpeakers", | |
776 | + .short_name = "FireWire Speakers", | |
777 | + .long_name = "LaCie FireWire Speakers", | |
778 | + .pcm_constraints = lacie_speakers_constraints, | |
779 | + .mixer_channels = 1, | |
780 | + .mute_fb_id = 0x01, | |
781 | + .volume_fb_id = 0x01, | |
782 | +}; | |
783 | + | |
806 | 784 | static const struct ieee1394_device_id fwspk_id_table[] = { |
807 | 785 | { |
808 | 786 | .match_flags = IEEE1394_MATCH_VENDOR_ID | |
... | ... | @@ -813,6 +791,7 @@ |
813 | 791 | .model_id = 0x00f970, |
814 | 792 | .specifier_id = SPECIFIER_1394TA, |
815 | 793 | .version = VERSION_AVC, |
794 | + .driver_data = (kernel_ulong_t)&griffin_firewave, | |
816 | 795 | }, |
817 | 796 | { |
818 | 797 | .match_flags = IEEE1394_MATCH_VENDOR_ID | |
... | ... | @@ -823,6 +802,7 @@ |
823 | 802 | .model_id = 0x00f970, |
824 | 803 | .specifier_id = SPECIFIER_1394TA, |
825 | 804 | .version = VERSION_AVC, |
805 | + .driver_data = (kernel_ulong_t)&lacie_speakers, | |
826 | 806 | }, |
827 | 807 | { } |
828 | 808 | }; |
829 | 809 | |
830 | 810 | |
... | ... | @@ -833,10 +813,10 @@ |
833 | 813 | .owner = THIS_MODULE, |
834 | 814 | .name = KBUILD_MODNAME, |
835 | 815 | .bus = &fw_bus_type, |
836 | - .probe = fwspk_probe, | |
837 | - .remove = fwspk_remove, | |
838 | 816 | }, |
817 | + .probe = fwspk_probe, | |
839 | 818 | .update = fwspk_bus_reset, |
819 | + .remove = fwspk_remove, | |
840 | 820 | .id_table = fwspk_id_table, |
841 | 821 | }; |
842 | 822 |