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/)
This commit is contained in:
Stefan Richter
2013-06-09 18:15:00 +02:00
parent 317ddd256b
commit 94a87157cd
9 changed files with 169 additions and 173 deletions

View File

@@ -626,9 +626,9 @@ static u64 get_unit_base(struct fw_unit *unit)
return 0;
}
static int isight_probe(struct device *unit_dev)
static int isight_probe(struct fw_unit *unit,
const struct ieee1394_device_id *id)
{
struct fw_unit *unit = fw_unit(unit_dev);
struct fw_device *fw_dev = fw_parent_device(unit);
struct snd_card *card;
struct isight *isight;
@@ -637,7 +637,7 @@ static int isight_probe(struct device *unit_dev)
err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card);
if (err < 0)
return err;
snd_card_set_dev(card, unit_dev);
snd_card_set_dev(card, &unit->device);
isight = card->private_data;
isight->card = card;
@@ -674,7 +674,7 @@ static int isight_probe(struct device *unit_dev)
if (err < 0)
goto error;
dev_set_drvdata(unit_dev, isight);
dev_set_drvdata(&unit->device, isight);
return 0;
@@ -686,23 +686,6 @@ error:
return err;
}
static int isight_remove(struct device *dev)
{
struct isight *isight = dev_get_drvdata(dev);
isight_pcm_abort(isight);
snd_card_disconnect(isight->card);
mutex_lock(&isight->mutex);
isight_stop_streaming(isight);
mutex_unlock(&isight->mutex);
snd_card_free_when_closed(isight->card);
return 0;
}
static void isight_bus_reset(struct fw_unit *unit)
{
struct isight *isight = dev_get_drvdata(&unit->device);
@@ -716,6 +699,21 @@ static void isight_bus_reset(struct fw_unit *unit)
}
}
static void isight_remove(struct fw_unit *unit)
{
struct isight *isight = dev_get_drvdata(&unit->device);
isight_pcm_abort(isight);
snd_card_disconnect(isight->card);
mutex_lock(&isight->mutex);
isight_stop_streaming(isight);
mutex_unlock(&isight->mutex);
snd_card_free_when_closed(isight->card);
}
static const struct ieee1394_device_id isight_id_table[] = {
{
.match_flags = IEEE1394_MATCH_SPECIFIER_ID |
@@ -732,10 +730,10 @@ static struct fw_driver isight_driver = {
.owner = THIS_MODULE,
.name = KBUILD_MODNAME,
.bus = &fw_bus_type,
.probe = isight_probe,
.remove = isight_remove,
},
.probe = isight_probe,
.update = isight_bus_reset,
.remove = isight_remove,
.id_table = isight_id_table,
};