aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2013-06-09 12:15:00 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2013-06-09 12:15:00 -0400
commit94a87157cde95d38b9cdf1116e4f0fd93f6d25df (patch)
tree42cb11cbab50860a66d3e4191c43a85cf42bd77f
parent317ddd256b9c24b0d78fa8018f80f1e495481a10 (diff)
firewire: introduce fw_driver.probe and .remove methods
FireWire upper layer drivers are converted from generic struct driver.probe() and .remove() to bus-specific struct fw_driver.probe() and .remove(). The new .probe() adds a const struct ieee1394_device_id *id argument, indicating the entry in the driver's device identifiers table which matched the fw_unit to be probed. This new argument is used by the snd-firewire-speakers driver to look up device-specific parameters and methods. There is at least one other FireWire audio driver currently in development in which this will be useful too. The new .remove() drops the unused error return code. Although all in-tree drivers are being converted to the new methods, support for the old methods is left in place in this commit. This allows public developer trees to merge this commit and then move to the new fw_driver methods. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Acked-by: Clemens Ladisch <clemens@ladisch.de> (for sound/firewire/) Cc: Peter Hurley <peter@hurleysoftware.com> (for drivers/staging/fwserial/)
-rw-r--r--drivers/firewire/core-device.c45
-rw-r--r--drivers/firewire/net.c50
-rw-r--r--drivers/firewire/sbp2.c17
-rw-r--r--drivers/media/firewire/firedtv-fw.c19
-rw-r--r--drivers/staging/fwserial/fwserial.c14
-rw-r--r--include/linux/firewire.h2
-rw-r--r--sound/firewire/isight.c44
-rw-r--r--sound/firewire/scs1x.c39
-rw-r--r--sound/firewire/speakers.c106
9 files changed, 166 insertions, 170 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 664a6ff0a823..c152edd6cd3a 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -165,25 +165,50 @@ static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
165 return (match & id_table->match_flags) == id_table->match_flags; 165 return (match & id_table->match_flags) == id_table->match_flags;
166} 166}
167 167
168static bool is_fw_unit(struct device *dev); 168static const struct ieee1394_device_id *unit_match(struct device *dev,
169 169 struct device_driver *drv)
170static int fw_unit_match(struct device *dev, struct device_driver *drv)
171{ 170{
172 const struct ieee1394_device_id *id_table = 171 const struct ieee1394_device_id *id_table =
173 container_of(drv, struct fw_driver, driver)->id_table; 172 container_of(drv, struct fw_driver, driver)->id_table;
174 int id[] = {0, 0, 0, 0}; 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 get_modalias_ids(fw_unit(dev), id); 175 get_modalias_ids(fw_unit(dev), id);
181 176
182 for (; id_table->match_flags != 0; id_table++) 177 for (; id_table->match_flags != 0; id_table++)
183 if (match_ids(id_table, id)) 178 if (match_ids(id_table, id))
184 return 1; 179 return id_table;
185 180
186 return 0; 181 return NULL;
182}
183
184static bool is_fw_unit(struct device *dev);
185
186static 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
192static int fw_unit_probe(struct device *dev)
193{
194 struct fw_driver *driver =
195 container_of(dev->driver, struct fw_driver, driver);
196
197 if (driver->probe)
198 return driver->probe(fw_unit(dev), unit_match(dev, dev->driver));
199 else
200 return driver->driver.probe(dev);
201}
202
203static int fw_unit_remove(struct device *dev)
204{
205 struct fw_driver *driver =
206 container_of(dev->driver, struct fw_driver, driver);
207
208 if (driver->remove)
209 return driver->remove(fw_unit(dev)), 0;
210 else
211 return driver->driver.remove(dev);
187} 212}
188 213
189static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) 214static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
@@ -213,6 +238,8 @@ static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
213struct bus_type fw_bus_type = { 238struct bus_type fw_bus_type = {
214 .name = "firewire", 239 .name = "firewire",
215 .match = fw_unit_match, 240 .match = fw_unit_match,
241 .probe = fw_unit_probe,
242 .remove = fw_unit_remove,
216}; 243};
217EXPORT_SYMBOL(fw_bus_type); 244EXPORT_SYMBOL(fw_bus_type);
218 245
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 815b0fcbe918..6b895986dc22 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1440,9 +1440,9 @@ static int fwnet_add_peer(struct fwnet_device *dev,
1440 return 0; 1440 return 0;
1441} 1441}
1442 1442
1443static int fwnet_probe(struct device *_dev) 1443static 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 struct fw_device *device = fw_parent_device(unit); 1446 struct fw_device *device = fw_parent_device(unit);
1447 struct fw_card *card = device->card; 1447 struct fw_card *card = device->card;
1448 struct net_device *net; 1448 struct net_device *net;
@@ -1526,6 +1526,24 @@ static int fwnet_probe(struct device *_dev)
1526 return ret; 1526 return ret;
1527} 1527}
1528 1528
1529/*
1530 * FIXME abort partially sent fragmented datagrams,
1531 * discard partially received fragmented datagrams
1532 */
1533static 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
1529static void fwnet_remove_peer(struct fwnet_peer *peer, struct fwnet_device *dev) 1547static void fwnet_remove_peer(struct fwnet_peer *peer, struct fwnet_device *dev)
1530{ 1548{
1531 struct fwnet_partial_datagram *pd, *pd_next; 1549 struct fwnet_partial_datagram *pd, *pd_next;
@@ -1542,9 +1560,9 @@ static void fwnet_remove_peer(struct fwnet_peer *peer, struct fwnet_device *dev)
1542 kfree(peer); 1560 kfree(peer);
1543} 1561}
1544 1562
1545static int fwnet_remove(struct device *_dev) 1563static 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 struct fwnet_device *dev = peer->dev; 1566 struct fwnet_device *dev = peer->dev;
1549 struct net_device *net; 1567 struct net_device *net;
1550 int i; 1568 int i;
@@ -1569,26 +1587,6 @@ static int fwnet_remove(struct device *_dev)
1569 } 1587 }
1570 1588
1571 mutex_unlock(&fwnet_device_mutex); 1589 mutex_unlock(&fwnet_device_mutex);
1572
1573 return 0;
1574}
1575
1576/*
1577 * FIXME abort partially sent fragmented datagrams,
1578 * discard partially received fragmented datagrams
1579 */
1580static 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} 1590}
1593 1591
1594static const struct ieee1394_device_id fwnet_id_table[] = { 1592static const struct ieee1394_device_id fwnet_id_table[] = {
@@ -1614,10 +1612,10 @@ static struct fw_driver fwnet_driver = {
1614 .owner = THIS_MODULE, 1612 .owner = THIS_MODULE,
1615 .name = KBUILD_MODNAME, 1613 .name = KBUILD_MODNAME,
1616 .bus = &fw_bus_type, 1614 .bus = &fw_bus_type,
1617 .probe = fwnet_probe,
1618 .remove = fwnet_remove,
1619 }, 1615 },
1616 .probe = fwnet_probe,
1620 .update = fwnet_update, 1617 .update = fwnet_update,
1618 .remove = fwnet_remove,
1621 .id_table = fwnet_id_table, 1619 .id_table = fwnet_id_table,
1622}; 1620};
1623 1621
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 47674b913843..281029daf98c 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1128,11 +1128,10 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1128} 1128}
1129 1129
1130static struct scsi_host_template scsi_driver_template; 1130static struct scsi_host_template scsi_driver_template;
1131static int sbp2_remove(struct device *dev); 1131static void sbp2_remove(struct fw_unit *unit);
1132 1132
1133static int sbp2_probe(struct device *dev) 1133static int sbp2_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
1134{ 1134{
1135 struct fw_unit *unit = fw_unit(dev);
1136 struct fw_device *device = fw_parent_device(unit); 1135 struct fw_device *device = fw_parent_device(unit);
1137 struct sbp2_target *tgt; 1136 struct sbp2_target *tgt;
1138 struct sbp2_logical_unit *lu; 1137 struct sbp2_logical_unit *lu;
@@ -1196,7 +1195,7 @@ static int sbp2_probe(struct device *dev)
1196 return 0; 1195 return 0;
1197 1196
1198 fail_remove: 1197 fail_remove:
1199 sbp2_remove(dev); 1198 sbp2_remove(unit);
1200 return -ENOMEM; 1199 return -ENOMEM;
1201 1200
1202 fail_shost_put: 1201 fail_shost_put:
@@ -1222,9 +1221,8 @@ static void sbp2_update(struct fw_unit *unit)
1222 } 1221 }
1223} 1222}
1224 1223
1225static int sbp2_remove(struct device *dev) 1224static void sbp2_remove(struct fw_unit *unit)
1226{ 1225{
1227 struct fw_unit *unit = fw_unit(dev);
1228 struct fw_device *device = fw_parent_device(unit); 1226 struct fw_device *device = fw_parent_device(unit);
1229 struct sbp2_target *tgt = dev_get_drvdata(&unit->device); 1227 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1230 struct sbp2_logical_unit *lu, *next; 1228 struct sbp2_logical_unit *lu, *next;
@@ -1261,10 +1259,9 @@ static int sbp2_remove(struct device *dev)
1261 kfree(lu); 1259 kfree(lu);
1262 } 1260 }
1263 scsi_remove_host(shost); 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 scsi_host_put(shost); 1264 scsi_host_put(shost);
1267 return 0;
1268} 1265}
1269 1266
1270#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e 1267#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
@@ -1285,10 +1282,10 @@ static struct fw_driver sbp2_driver = {
1285 .owner = THIS_MODULE, 1282 .owner = THIS_MODULE,
1286 .name = KBUILD_MODNAME, 1283 .name = KBUILD_MODNAME,
1287 .bus = &fw_bus_type, 1284 .bus = &fw_bus_type,
1288 .probe = sbp2_probe,
1289 .remove = sbp2_remove,
1290 }, 1285 },
1286 .probe = sbp2_probe,
1291 .update = sbp2_update, 1287 .update = sbp2_update,
1288 .remove = sbp2_remove,
1292 .id_table = sbp2_id_table, 1289 .id_table = sbp2_id_table,
1293}; 1290};
1294 1291
diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c
index e24ec539a5fd..247f0e7cb5f7 100644
--- a/drivers/media/firewire/firedtv-fw.c
+++ b/drivers/media/firewire/firedtv-fw.c
@@ -248,7 +248,7 @@ static const char * const model_names[] = {
248/* Adjust the template string if models with longer names appear. */ 248/* Adjust the template string if models with longer names appear. */
249#define MAX_MODEL_NAME_LEN sizeof("FireDTV ????") 249#define MAX_MODEL_NAME_LEN sizeof("FireDTV ????")
250 250
251static int node_probe(struct device *dev) 251static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
252{ 252{
253 struct firedtv *fdtv; 253 struct firedtv *fdtv;
254 char name[MAX_MODEL_NAME_LEN]; 254 char name[MAX_MODEL_NAME_LEN];
@@ -258,8 +258,8 @@ static int node_probe(struct device *dev)
258 if (!fdtv) 258 if (!fdtv)
259 return -ENOMEM; 259 return -ENOMEM;
260 260
261 dev_set_drvdata(dev, fdtv); 261 dev_set_drvdata(&unit->device, fdtv);
262 fdtv->device = dev; 262 fdtv->device = &unit->device;
263 fdtv->isochannel = -1; 263 fdtv->isochannel = -1;
264 fdtv->voltage = 0xff; 264 fdtv->voltage = 0xff;
265 fdtv->tone = 0xff; 265 fdtv->tone = 0xff;
@@ -269,7 +269,7 @@ static int node_probe(struct device *dev)
269 mutex_init(&fdtv->demux_mutex); 269 mutex_init(&fdtv->demux_mutex);
270 INIT_WORK(&fdtv->remote_ctrl_work, avc_remote_ctrl_work); 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 name, sizeof(name)); 273 name, sizeof(name));
274 for (i = ARRAY_SIZE(model_names); --i; ) 274 for (i = ARRAY_SIZE(model_names); --i; )
275 if (strlen(model_names[i]) <= name_len && 275 if (strlen(model_names[i]) <= name_len &&
@@ -277,7 +277,7 @@ static int node_probe(struct device *dev)
277 break; 277 break;
278 fdtv->type = i; 278 fdtv->type = i;
279 279
280 err = fdtv_register_rc(fdtv, dev); 280 err = fdtv_register_rc(fdtv, &unit->device);
281 if (err) 281 if (err)
282 goto fail_free; 282 goto fail_free;
283 283
@@ -307,9 +307,9 @@ fail_free:
307 return err; 307 return err;
308} 308}
309 309
310static int node_remove(struct device *dev) 310static 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 fdtv_dvb_unregister(fdtv); 314 fdtv_dvb_unregister(fdtv);
315 315
@@ -320,7 +320,6 @@ static int node_remove(struct device *dev)
320 fdtv_unregister_rc(fdtv); 320 fdtv_unregister_rc(fdtv);
321 321
322 kfree(fdtv); 322 kfree(fdtv);
323 return 0;
324} 323}
325 324
326static void node_update(struct fw_unit *unit) 325static void node_update(struct fw_unit *unit)
@@ -391,10 +390,10 @@ static struct fw_driver fdtv_driver = {
391 .owner = THIS_MODULE, 390 .owner = THIS_MODULE,
392 .name = "firedtv", 391 .name = "firedtv",
393 .bus = &fw_bus_type, 392 .bus = &fw_bus_type,
394 .probe = node_probe,
395 .remove = node_remove,
396 }, 393 },
394 .probe = node_probe,
397 .update = node_update, 395 .update = node_update,
396 .remove = node_remove,
398 .id_table = fdtv_id_table, 397 .id_table = fdtv_id_table,
399}; 398};
400 399
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index e5818a1c2262..a8399f9c9392 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -2438,9 +2438,9 @@ free_ports:
2438 * last peer for a given fw_card triggering the destruction of the same 2438 * last peer for a given fw_card triggering the destruction of the same
2439 * fw_serial for the same fw_card. 2439 * fw_serial for the same fw_card.
2440 */ 2440 */
2441static int fwserial_probe(struct device *dev) 2441static int fwserial_probe(struct fw_unit *unit,
2442 const struct ieee1394_device_id *id)
2442{ 2443{
2443 struct fw_unit *unit = fw_unit(dev);
2444 struct fw_serial *serial; 2444 struct fw_serial *serial;
2445 int err; 2445 int err;
2446 2446
@@ -2462,9 +2462,9 @@ static int fwserial_probe(struct device *dev)
2462 * specific fw_card). If this is the last peer being removed, then trigger 2462 * specific fw_card). If this is the last peer being removed, then trigger
2463 * the destruction of the underlying TTYs. 2463 * the destruction of the underlying TTYs.
2464 */ 2464 */
2465static int fwserial_remove(struct device *dev) 2465static void fwserial_remove(struct fw_unit *unit)
2466{ 2466{
2467 struct fwtty_peer *peer = dev_get_drvdata(dev); 2467 struct fwtty_peer *peer = dev_get_drvdata(&unit->device);
2468 struct fw_serial *serial = peer->serial; 2468 struct fw_serial *serial = peer->serial;
2469 int i; 2469 int i;
2470 2470
@@ -2484,8 +2484,6 @@ static int fwserial_remove(struct device *dev)
2484 kref_put(&serial->kref, fwserial_destroy); 2484 kref_put(&serial->kref, fwserial_destroy);
2485 } 2485 }
2486 mutex_unlock(&fwserial_list_mutex); 2486 mutex_unlock(&fwserial_list_mutex);
2487
2488 return 0;
2489} 2487}
2490 2488
2491/** 2489/**
@@ -2530,10 +2528,10 @@ static struct fw_driver fwserial_driver = {
2530 .owner = THIS_MODULE, 2528 .owner = THIS_MODULE,
2531 .name = KBUILD_MODNAME, 2529 .name = KBUILD_MODNAME,
2532 .bus = &fw_bus_type, 2530 .bus = &fw_bus_type,
2533 .probe = fwserial_probe,
2534 .remove = fwserial_remove,
2535 }, 2531 },
2532 .probe = fwserial_probe,
2536 .update = fwserial_update, 2533 .update = fwserial_update,
2534 .remove = fwserial_remove,
2537 .id_table = fwserial_id_table, 2535 .id_table = fwserial_id_table,
2538}; 2536};
2539 2537
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 191501afd7fb..3b0e820375ab 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -251,8 +251,10 @@ struct ieee1394_device_id;
251 251
252struct fw_driver { 252struct fw_driver {
253 struct device_driver driver; 253 struct device_driver driver;
254 int (*probe)(struct fw_unit *unit, const struct ieee1394_device_id *id);
254 /* Called when the parent device sits through a bus reset. */ 255 /* Called when the parent device sits through a bus reset. */
255 void (*update)(struct fw_unit *unit); 256 void (*update)(struct fw_unit *unit);
257 void (*remove)(struct fw_unit *unit);
256 const struct ieee1394_device_id *id_table; 258 const struct ieee1394_device_id *id_table;
257}; 259};
258 260
diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
index d428ffede4f3..58a5afefdc69 100644
--- a/sound/firewire/isight.c
+++ b/sound/firewire/isight.c
@@ -626,9 +626,9 @@ static u64 get_unit_base(struct fw_unit *unit)
626 return 0; 626 return 0;
627} 627}
628 628
629static int isight_probe(struct device *unit_dev) 629static 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 struct fw_device *fw_dev = fw_parent_device(unit); 632 struct fw_device *fw_dev = fw_parent_device(unit);
633 struct snd_card *card; 633 struct snd_card *card;
634 struct isight *isight; 634 struct isight *isight;
@@ -637,7 +637,7 @@ static int isight_probe(struct device *unit_dev)
637 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card); 637 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card);
638 if (err < 0) 638 if (err < 0)
639 return err; 639 return err;
640 snd_card_set_dev(card, unit_dev); 640 snd_card_set_dev(card, &unit->device);
641 641
642 isight = card->private_data; 642 isight = card->private_data;
643 isight->card = card; 643 isight->card = card;
@@ -674,7 +674,7 @@ static int isight_probe(struct device *unit_dev)
674 if (err < 0) 674 if (err < 0)
675 goto error; 675 goto error;
676 676
677 dev_set_drvdata(unit_dev, isight); 677 dev_set_drvdata(&unit->device, isight);
678 678
679 return 0; 679 return 0;
680 680
@@ -686,23 +686,6 @@ error:
686 return err; 686 return err;
687} 687}
688 688
689static 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
706static void isight_bus_reset(struct fw_unit *unit) 689static void isight_bus_reset(struct fw_unit *unit)
707{ 690{
708 struct isight *isight = dev_get_drvdata(&unit->device); 691 struct isight *isight = dev_get_drvdata(&unit->device);
@@ -716,6 +699,21 @@ static void isight_bus_reset(struct fw_unit *unit)
716 } 699 }
717} 700}
718 701
702static 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
719static const struct ieee1394_device_id isight_id_table[] = { 717static const struct ieee1394_device_id isight_id_table[] = {
720 { 718 {
721 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | 719 .match_flags = IEEE1394_MATCH_SPECIFIER_ID |
@@ -732,10 +730,10 @@ static struct fw_driver isight_driver = {
732 .owner = THIS_MODULE, 730 .owner = THIS_MODULE,
733 .name = KBUILD_MODNAME, 731 .name = KBUILD_MODNAME,
734 .bus = &fw_bus_type, 732 .bus = &fw_bus_type,
735 .probe = isight_probe,
736 .remove = isight_remove,
737 }, 733 },
734 .probe = isight_probe,
738 .update = isight_bus_reset, 735 .update = isight_bus_reset,
736 .remove = isight_remove,
739 .id_table = isight_id_table, 737 .id_table = isight_id_table,
740}; 738};
741 739
diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
index 844a555c3b1e..1f5920d6eacc 100644
--- a/sound/firewire/scs1x.c
+++ b/sound/firewire/scs1x.c
@@ -384,9 +384,8 @@ static void scs_card_free(struct snd_card *card)
384 kfree(scs->buffer); 384 kfree(scs->buffer);
385} 385}
386 386
387static int scs_probe(struct device *unit_dev) 387static 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 struct fw_device *fw_dev = fw_parent_device(unit); 389 struct fw_device *fw_dev = fw_parent_device(unit);
391 struct snd_card *card; 390 struct snd_card *card;
392 struct scs *scs; 391 struct scs *scs;
@@ -395,7 +394,7 @@ static int scs_probe(struct device *unit_dev)
395 err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card); 394 err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card);
396 if (err < 0) 395 if (err < 0)
397 return err; 396 return err;
398 snd_card_set_dev(card, unit_dev); 397 snd_card_set_dev(card, &unit->device);
399 398
400 scs = card->private_data; 399 scs = card->private_data;
401 scs->card = card; 400 scs->card = card;
@@ -440,7 +439,7 @@ static int scs_probe(struct device *unit_dev)
440 if (err < 0) 439 if (err < 0)
441 goto err_card; 440 goto err_card;
442 441
443 dev_set_drvdata(unit_dev, scs); 442 dev_set_drvdata(&unit->device, scs);
444 443
445 return 0; 444 return 0;
446 445
@@ -451,9 +450,20 @@ err_card:
451 return err; 450 return err;
452} 451}
453 452
454static int scs_remove(struct device *dev) 453static void scs_update(struct fw_unit *unit)
455{ 454{
456 struct scs *scs = dev_get_drvdata(dev); 455 struct scs *scs = dev_get_drvdata(&unit->device);
456 __be64 data;
457
458 data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
459 scs->hss_handler.offset);
460 snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
461 HSS1394_ADDRESS, &data, 8);
462}
463
464static void scs_remove(struct fw_unit *unit)
465{
466 struct scs *scs = dev_get_drvdata(&unit->device);
457 467
458 snd_card_disconnect(scs->card); 468 snd_card_disconnect(scs->card);
459 469
@@ -465,19 +475,6 @@ static int scs_remove(struct device *dev)
465 tasklet_kill(&scs->tasklet); 475 tasklet_kill(&scs->tasklet);
466 476
467 snd_card_free_when_closed(scs->card); 477 snd_card_free_when_closed(scs->card);
468
469 return 0;
470}
471
472static void scs_update(struct fw_unit *unit)
473{
474 struct scs *scs = dev_get_drvdata(&unit->device);
475 __be64 data;
476
477 data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
478 scs->hss_handler.offset);
479 snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
480 HSS1394_ADDRESS, &data, 8);
481} 478}
482 479
483static const struct ieee1394_device_id scs_id_table[] = { 480static const struct ieee1394_device_id scs_id_table[] = {
@@ -506,10 +503,10 @@ static struct fw_driver scs_driver = {
506 .owner = THIS_MODULE, 503 .owner = THIS_MODULE,
507 .name = KBUILD_MODNAME, 504 .name = KBUILD_MODNAME,
508 .bus = &fw_bus_type, 505 .bus = &fw_bus_type,
509 .probe = scs_probe,
510 .remove = scs_remove,
511 }, 506 },
507 .probe = scs_probe,
512 .update = scs_update, 508 .update = scs_update,
509 .remove = scs_remove,
513 .id_table = scs_id_table, 510 .id_table = scs_id_table,
514}; 511};
515 512
diff --git a/sound/firewire/speakers.c b/sound/firewire/speakers.c
index d6846557f270..2c6386503940 100644
--- a/sound/firewire/speakers.c
+++ b/sound/firewire/speakers.c
@@ -663,45 +663,9 @@ static void fwspk_card_free(struct snd_card *card)
663 mutex_destroy(&fwspk->mutex); 663 mutex_destroy(&fwspk->mutex);
664} 664}
665 665
666static const struct device_info *fwspk_detect(struct fw_device *dev) 666static 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
702static int fwspk_probe(struct device *unit_dev)
703{
704 struct fw_unit *unit = fw_unit(unit_dev);
705 struct fw_device *fw_dev = fw_parent_device(unit); 669 struct fw_device *fw_dev = fw_parent_device(unit);
706 struct snd_card *card; 670 struct snd_card *card;
707 struct fwspk *fwspk; 671 struct fwspk *fwspk;
@@ -711,17 +675,13 @@ static int fwspk_probe(struct device *unit_dev)
711 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card); 675 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card);
712 if (err < 0) 676 if (err < 0)
713 return err; 677 return err;
714 snd_card_set_dev(card, unit_dev); 678 snd_card_set_dev(card, &unit->device);
715 679
716 fwspk = card->private_data; 680 fwspk = card->private_data;
717 fwspk->card = card; 681 fwspk->card = card;
718 mutex_init(&fwspk->mutex); 682 mutex_init(&fwspk->mutex);
719 fwspk->unit = fw_unit_get(unit); 683 fwspk->unit = fw_unit_get(unit);
720 fwspk->device_info = fwspk_detect(fw_dev); 684 fwspk->device_info = (const struct device_info *)id->driver_data;
721 if (!fwspk->device_info) {
722 err = -ENODEV;
723 goto err_unit;
724 }
725 685
726 err = cmp_connection_init(&fwspk->connection, unit, 0); 686 err = cmp_connection_init(&fwspk->connection, unit, 0);
727 if (err < 0) 687 if (err < 0)
@@ -756,7 +716,7 @@ static int fwspk_probe(struct device *unit_dev)
756 if (err < 0) 716 if (err < 0)
757 goto error; 717 goto error;
758 718
759 dev_set_drvdata(unit_dev, fwspk); 719 dev_set_drvdata(&unit->device, fwspk);
760 720
761 return 0; 721 return 0;
762 722
@@ -770,22 +730,6 @@ error:
770 return err; 730 return err;
771} 731}
772 732
773static 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
789static void fwspk_bus_reset(struct fw_unit *unit) 733static void fwspk_bus_reset(struct fw_unit *unit)
790{ 734{
791 struct fwspk *fwspk = dev_get_drvdata(&unit->device); 735 struct fwspk *fwspk = dev_get_drvdata(&unit->device);
@@ -803,6 +747,40 @@ static void fwspk_bus_reset(struct fw_unit *unit)
803 amdtp_out_stream_update(&fwspk->stream); 747 amdtp_out_stream_update(&fwspk->stream);
804} 748}
805 749
750static 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
764static 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
774static 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
806static const struct ieee1394_device_id fwspk_id_table[] = { 784static const struct ieee1394_device_id fwspk_id_table[] = {
807 { 785 {
808 .match_flags = IEEE1394_MATCH_VENDOR_ID | 786 .match_flags = IEEE1394_MATCH_VENDOR_ID |
@@ -813,6 +791,7 @@ static const struct ieee1394_device_id fwspk_id_table[] = {
813 .model_id = 0x00f970, 791 .model_id = 0x00f970,
814 .specifier_id = SPECIFIER_1394TA, 792 .specifier_id = SPECIFIER_1394TA,
815 .version = VERSION_AVC, 793 .version = VERSION_AVC,
794 .driver_data = (kernel_ulong_t)&griffin_firewave,
816 }, 795 },
817 { 796 {
818 .match_flags = IEEE1394_MATCH_VENDOR_ID | 797 .match_flags = IEEE1394_MATCH_VENDOR_ID |
@@ -823,6 +802,7 @@ static const struct ieee1394_device_id fwspk_id_table[] = {
823 .model_id = 0x00f970, 802 .model_id = 0x00f970,
824 .specifier_id = SPECIFIER_1394TA, 803 .specifier_id = SPECIFIER_1394TA,
825 .version = VERSION_AVC, 804 .version = VERSION_AVC,
805 .driver_data = (kernel_ulong_t)&lacie_speakers,
826 }, 806 },
827 { } 807 { }
828}; 808};
@@ -833,10 +813,10 @@ static struct fw_driver fwspk_driver = {
833 .owner = THIS_MODULE, 813 .owner = THIS_MODULE,
834 .name = KBUILD_MODNAME, 814 .name = KBUILD_MODNAME,
835 .bus = &fw_bus_type, 815 .bus = &fw_bus_type,
836 .probe = fwspk_probe,
837 .remove = fwspk_remove,
838 }, 816 },
817 .probe = fwspk_probe,
839 .update = fwspk_bus_reset, 818 .update = fwspk_bus_reset,
819 .remove = fwspk_remove,
840 .id_table = fwspk_id_table, 820 .id_table = fwspk_id_table,
841}; 821};
842 822