ALSA: seq: Use bus specific probe and remove
Subsystems (2)
v2 cover ALSA: seq: Use bus specific probe and remove
Hello,
here comes a v2 for my series previously posted at
https://lore.kernel.org/all/[email protected]
.
The only change is fixing a build problem I introduced in the opl4 driver (and that I didn't notice because I usually compile test for ARCH=arm64 where this driver isn't built).
Best regards
Uwe
Uwe Kleine-König (9):
ALSA: seq: Use bus specific probe and remove
ALSA: seq: midi: Convert to snd_seq bus probe mechanism
ALSA: seq: ump: Convert to snd_seq bus probe mechanism
ALSA: opl3: Convert to snd_seq bus probe mechanism
ALSA: opl4: Convert to snd_seq bus probe mechanism
ALSA: sb: Convert to snd_seq bus probe mechanism
ALSA: emu10k1: Convert to snd_seq bus probe mechanism
ALSA: seq: oss: Convert to snd_seq bus probe mechanism
ALSA: seq: Refuse to probe seq drivers with non-bus probe or remove
include/sound/seq_device.h | 2 ++ sound/core/seq/oss/seq_oss.c | 4 ++-- sound/core/seq/oss/seq_oss_synth.c | 12 ++++-------- sound/core/seq/oss/seq_oss_synth.h | 4 ++-- sound/core/seq/seq_midi.c | 15 ++++++--------- sound/core/seq/seq_ump_client.c | 11 ++++------- sound/core/seq_device.c | 26 +++++++++++++++++++++++++- sound/drivers/opl3/opl3_seq.c | 13 +++++-------- sound/drivers/opl4/opl4_seq.c | 13 +++++-------- sound/isa/sb/emu8000_synth.c | 13 +++++-------- sound/pci/emu10k1/emu10k1_synth.c | 13 +++++-------- 11 files changed, 65 insertions(+), 61 deletions(-)
base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
Signature · 1 line
2.47.3
PATCH v2 1/9 ALSA: seq: Use bus specific probe and remove
Introduce a bus specific probe and remove function. For now this only allows to get rid of a cast of the generic device to an snd_seq device in the drivers and changes the remove prototype to return void---a non-zero return value is ignored anyhow.
The objective is to get rid of users of struct device callbacks .probe(), .remove() and .shutdown() to eventually remove these. Until all snd_seq drivers are converted this results in a runtime warning about the drivers needing an update because there is a bus probe function and a driver probe function.
--- include/sound/seq_device.h | 2 ++ sound/core/seq_device.c | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
include/sound/seq_device.h +2 -0
@@ -43,6 +43,8 @@ struct snd_seq_device {* Typically, call snd_device_free(dev->card, dev->driver_data) */ struct snd_seq_driver { +int (*probe)(struct snd_seq_device *dev); +void (*remove)(struct snd_seq_device *dev);struct device_driver driver;char *id;int argsize;
sound/core/seq_device.c +47 -0
68 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 2/9 ALSA: seq: midi: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
Note that the remove callback returns void now. The actual return value was ignored before (see device_remove() in drivers/base/dd.c), so there is no problem introduced by converting return -ENODEV to return.
--- sound/core/seq/seq_midi.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
sound/core/seq/seq_midi.c +6 -9
@@ -265,9 +265,8 @@ static void snd_seq_midisynth_delete(struct seq_midisynth *msynth)/* register new midi synth port */ static int -snd_seq_midisynth_probe (struct device *_dev) +snd_seq_midisynth_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct seq_midisynth_client *client;struct seq_midisynth *msynth, *ms; struct snd_seq_port_info *port __free(kfree) = NULL;
@@ -411,10 +410,9 @@ snd_seq_midisynth_probe(struct device *_dev) }/* release midi synth port */ -static int -snd_seq_midisynth_remove (struct device *_dev) +static void +snd_seq_midisynth_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct seq_midisynth_client *client;struct seq_midisynth *msynth;struct snd_card *card = dev->card;
@@ -423,7 +421,7 @@ snd_seq_midisynth_remove(struct device *_dev)guard (mutex)(®ister_mutex); client = synths[card->number];if (client ==NULL || client->ports[device] ==NULL ) -return -ENODEV ; +return ; ports = client->ports_per_device[device]; client->ports_per_device[device] =0 ; msynth = client->ports[device];
@@ -437,14 +435,13 @@ snd_seq_midisynth_remove(struct device *_dev) synths[card->number] =NULL ;kfree (client); } -return 0 ; }static struct snd_seq_driver seq_midisynth_driver = { + .probe = snd_seq_midisynth_probe, + .remove = snd_seq_midisynth_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_seq_midisynth_probe, - .remove = snd_seq_midisynth_remove, }, .id =SNDRV_SEQ_DEV_ID_MIDISYNTH , .argsize =0 ,
Signature · 1 line
2.47.3
PATCH v2 3/9 ALSA: seq: ump: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
--- sound/core/seq/seq_ump_client.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/core/seq/seq_ump_client.c +4 -7
@@ -452,9 +452,8 @@ static const struct snd_seq_ump_ops seq_ump_ops = { };/* create a sequencer client and ports for the given UMP endpoint */ -static int snd_seq_ump_probe (struct device *_dev) +static int snd_seq_ump_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_ump_endpoint *ump = dev->private_data;struct snd_card *card = dev->card;struct seq_ump_client *client;
@@ -513,21 +512,19 @@ static int snd_seq_ump_probe(struct device *_dev) }/* remove a sequencer client */ -static int snd_seq_ump_remove (struct device *_dev) +static void snd_seq_ump_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_ump_endpoint *ump = dev->private_data;if (ump->seq_client)seq_ump_client_free (ump->seq_client); -return 0 ; }static struct snd_seq_driver seq_ump_driver = { + .probe = snd_seq_ump_probe, + .remove = snd_seq_ump_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_seq_ump_probe, - .remove = snd_seq_ump_remove, }, .id =SNDRV_SEQ_DEV_ID_UMP , .argsize =0 ,
Signature · 1 line
2.47.3
PATCH v2 4/9 ALSA: opl3: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
Note that the remove callback returns void now. The actual return value was ignored before (see device_remove() in drivers/base/dd.c), so there is no problem introduced by converting return -EINVAL to return.
--- sound/drivers/opl3/opl3_seq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
sound/drivers/opl3/opl3_seq.c +5 -8
@@ -201,9 +201,8 @@ static int snd_opl3_synth_create_port(struct snd_opl3 * opl3)/* ------------------------------ */ -static int snd_opl3_seq_probe (struct device *_dev) +static int snd_opl3_seq_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_opl3 *opl3;int client, err;char name[32 ];
@@ -244,14 +243,13 @@ static int snd_opl3_seq_probe(struct device *_dev)return 0 ; } -static int snd_opl3_seq_remove (struct device *_dev) +static void snd_opl3_seq_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_opl3 *opl3; opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR (dev);if (opl3 ==NULL ) -return -EINVAL ; +return ;#if IS_ENABLED (CONFIG_SND_SEQUENCER_OSS )snd_opl3_free_seq_oss (opl3);
@@ -260,14 +258,13 @@ static int snd_opl3_seq_remove(struct device *_dev)snd_seq_delete_kernel_client (opl3->seq_client); opl3->seq_client =-1 ; } -return 0 ; }static struct snd_seq_driver opl3_seq_driver = { + .probe = snd_opl3_seq_probe, + .remove = snd_opl3_seq_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_opl3_seq_probe, - .remove = snd_opl3_seq_remove, }, .id =SNDRV_SEQ_DEV_ID_OPL3 , .argsize =sizeof (struct snd_opl3 *),
Signature · 1 line
2.47.3
PATCH v2 5/9 ALSA: opl4: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
--- sound/drivers/opl4/opl4_seq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
sound/drivers/opl4/opl4_seq.c +5 -8
@@ -118,9 +118,8 @@ static void snd_opl4_seq_free_port(void *private_data)snd_midi_channel_free_set (opl4->chset); } -static int snd_opl4_seq_probe (struct device *_dev) +static int snd_opl4_seq_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_opl4 *opl4;int client;struct snd_seq_port_callback pcallbacks;
@@ -175,27 +174,25 @@ static int snd_opl4_seq_probe(struct device *_dev)return 0 ; } -static int snd_opl4_seq_remove (struct device *_dev) +static void snd_opl4_seq_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_opl4 *opl4; opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR (dev);if (!opl4) -return -EINVAL ; +return ;if (opl4->seq_client >=0 ) {snd_seq_delete_kernel_client (opl4->seq_client); opl4->seq_client =-1 ; } -return 0 ; }static struct snd_seq_driver opl4_seq_driver = { + .probe = snd_opl4_seq_probe, + .remove = snd_opl4_seq_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_opl4_seq_probe, - .remove = snd_opl4_seq_remove, }, .id =SNDRV_SEQ_DEV_ID_OPL4 , .argsize =sizeof (struct snd_opl4 *),
Signature · 1 line
2.47.3
PATCH v2 6/9 ALSA: sb: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
--- sound/isa/sb/emu8000_synth.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
sound/isa/sb/emu8000_synth.c +5 -8
@@ -21,9 +21,8 @@ MODULE_LICENSE("GPL");/* * create a new hardware dependent device for Emu8000 */ -static int snd_emu8000_probe (struct device *_dev) +static int snd_emu8000_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_emu8000 *hw;struct snd_emux *emu;
@@ -81,13 +80,12 @@ static int snd_emu8000_probe(struct device *_dev)/* * free all resources */ -static int snd_emu8000_remove (struct device *_dev) +static void snd_emu8000_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_emu8000 *hw;if (dev->driver_data ==NULL ) -return 0 ;/* no synth was allocated actually */ +return ;/* no synth was allocated actually */ hw = dev->driver_data;if (hw->pcm)
@@ -96,7 +94,6 @@ static int snd_emu8000_remove(struct device *_dev)snd_util_memhdr_free (hw->memhdr); hw->emu =NULL ; hw->memhdr =NULL ; -return 0 ; }/*
@@ -104,10 +101,10 @@ static int snd_emu8000_remove(struct device *_dev)*/ static struct snd_seq_driver emu8000_driver = { + .probe = snd_emu8000_probe, + .remove = snd_emu8000_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_emu8000_probe, - .remove = snd_emu8000_remove, }, .id =SNDRV_SEQ_DEV_ID_EMU8000 , .argsize =sizeof (struct snd_emu8000 *),
Signature · 1 line
2.47.3
PATCH v2 7/9 ALSA: emu10k1: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
--- sound/pci/emu10k1/emu10k1_synth.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
sound/pci/emu10k1/emu10k1_synth.c +5 -8
@@ -16,9 +16,8 @@ MODULE_LICENSE("GPL");/* * create a new hardware dependent device for Emu10k1 */ -static int snd_emu10k1_synth_probe (struct device *_dev) +static int snd_emu10k1_synth_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_emux *emux;struct snd_emu10k1 *hw;struct snd_emu10k1_synth_arg *arg;
@@ -64,14 +63,13 @@ static int snd_emu10k1_synth_probe(struct device *_dev)return 0 ; } -static int snd_emu10k1_synth_remove (struct device *_dev) +static void snd_emu10k1_synth_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);struct snd_emux *emux;struct snd_emu10k1 *hw;if (dev->driver_data ==NULL ) -return 0 ;/* not registered actually */ +return ;/* not registered actually */ emux = dev->driver_data;
@@ -82,7 +80,6 @@ static int snd_emu10k1_synth_remove(struct device *_dev) }snd_emux_free (emux); -return 0 ; }/*
@@ -90,10 +87,10 @@ static int snd_emu10k1_synth_remove(struct device *_dev)*/ static struct snd_seq_driver emu10k1_synth_driver = { + .probe = snd_emu10k1_synth_probe, + .remove = snd_emu10k1_synth_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_emu10k1_synth_probe, - .remove = snd_emu10k1_synth_remove, }, .id =SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH , .argsize =sizeof (struct snd_emu10k1_synth_arg ),
Signature · 1 line
2.47.3
PATCH v2 8/9 ALSA: seq: oss: Convert to snd_seq bus probe mechanism
In reply to Uwe Kleine-KönigThe snd_seq bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.
Note that the remove callback returns void now. The actual return value was ignored before (see device_remove() in drivers/base/dd.c), so there is no problem introduced by converting return -EINVAL to return.
--- sound/core/seq/oss/seq_oss.c | 4 ++-- sound/core/seq/oss/seq_oss_synth.c | 12 ++++-------- sound/core/seq/oss/seq_oss_synth.h | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
sound/core/seq/oss/seq_oss.c +2 -2
@@ -54,10 +54,10 @@ static __poll_t odev_poll(struct file *file, poll_table * wait);*/ static struct snd_seq_driver seq_oss_synth_driver = { + .probe = snd_seq_oss_synth_probe, + .remove = snd_seq_oss_synth_remove, .driver = { .name =KBUILD_MODNAME , - .probe = snd_seq_oss_synth_probe, - .remove = snd_seq_oss_synth_remove, }, .id =SNDRV_SEQ_DEV_ID_OSS , .argsize =sizeof (struct snd_seq_oss_reg ),
sound/core/seq/oss/seq_oss_synth.c +4 -8
@@ -80,9 +80,8 @@ snd_seq_oss_synth_init(void)* registration of the synth device */ int -snd_seq_oss_synth_probe (struct device *_dev) +snd_seq_oss_synth_probe (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);int i;struct seq_oss_synth *rec;struct snd_seq_oss_reg *reg =SNDRV_SEQ_DEVICE_ARGPTR (dev);
@@ -128,10 +127,9 @@ snd_seq_oss_synth_probe(struct device *_dev) } -int -snd_seq_oss_synth_remove (struct device *_dev) +void +snd_seq_oss_synth_remove (struct snd_seq_device *dev) { -struct snd_seq_device *dev =to_seq_dev (_dev);int index;struct seq_oss_synth *rec = dev->driver_data;
@@ -142,7 +140,7 @@ snd_seq_oss_synth_remove(struct device *_dev) }if (index >= max_synth_devs) {pr_err ("ALSA: seq_oss: can't unregister synth\n" ); -return -EINVAL ; +return ; } synth_devs[index] =NULL ;if (index == max_synth_devs -1 ) {
@@ -160,8 +158,6 @@ snd_seq_oss_synth_remove(struct device *_dev)snd_use_lock_sync (&rec->use_lock);kfree (rec); - -return 0 ; }
sound/core/seq/oss/seq_oss_synth.h +2 -2
@@ -15,8 +15,8 @@#include <sound/seq_device.h> void snd_seq_oss_synth_init (void ); -int snd_seq_oss_synth_probe (struct device *dev); -int snd_seq_oss_synth_remove (struct device *dev); +int snd_seq_oss_synth_probe (struct snd_seq_device *dev); +void snd_seq_oss_synth_remove (struct snd_seq_device *dev);void snd_seq_oss_synth_setup (struct seq_oss_devinfo *dp);void snd_seq_oss_synth_setup_midi (struct seq_oss_devinfo *dp);void snd_seq_oss_synth_cleanup (struct seq_oss_devinfo *dp);
Signature · 1 line
2.47.3
PATCH v2 9/9 ALSA: seq: Refuse to probe seq drivers with non-bus probe or remove
In reply to Uwe Kleine-KönigNow that all in-tree seq drivers are converted to bus methods, let old-style drivers fails to probe until driver methods are removed.
--- sound/core/seq_device.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-)
sound/core/seq_device.c +2 -25
@@ -264,40 +264,17 @@ int snd_seq_device_new(struct snd_card *card, int device, const char *id, }EXPORT_SYMBOL (snd_seq_device_new); -static int snd_seq_driver_legacy_probe (struct snd_seq_device *sdev) -{ -struct device *dev = &sdev->dev; -struct device_driver *driver = dev->driver; - -return driver->probe (dev); -} - -static void snd_seq_driver_legacy_remove (struct snd_seq_device *sdev) -{ -struct device *dev = &sdev->dev; -struct device_driver *driver = dev->driver; -int ret; - - ret = driver->remove (dev); -if (unlikely (ret)) -dev_warn (dev,"Ignoring return value of remove callback (%pe)\n" ,ERR_PTR (ret)); -} -/* * driver registration */ int __snd_seq_driver_register (struct snd_seq_driver *drv,struct module *mod) { -if (WARN_ON (!drv->driver.name || !drv->id)) +if (WARN_ON (!drv->driver.name || !drv->id || drv->driver.probe || drv->driver.remove))return -EINVAL ; + drv->driver.bus = &snd_seq_bus_type; drv->driver.owner = mod; -if (!drv->probe && drv->driver.probe) - drv->probe = snd_seq_driver_legacy_probe; -if (!drv->remove && drv->driver.remove) - drv->remove = snd_seq_driver_legacy_remove; -return driver_register (&drv->driver); }EXPORT_SYMBOL_GPL (__snd_seq_driver_register);
Signature · 1 line
2.47.3
Takashi Iwai
AppliedQuoted 14 lines · Uwe Kleine-König
Hello,
here comes a v2 for my series previously posted at
https://lore.kernel.org/all/[email protected]
.The only change is fixing a build problem I introduced in the opl4 driver (and that I didn't notice because I usually compile test for ARCH=arm64 where this driver isn't built).
Best regards
Uwe
Quoted 10 lines
Uwe Kleine-König (9):
ALSA: seq: Use bus specific probe and remove
ALSA: seq: midi: Convert tosnd_seqbus probe mechanism
ALSA: seq: ump: Convert tosnd_seqbus probe mechanism
ALSA: opl3: Convert tosnd_seqbus probe mechanism
ALSA: opl4: Convert tosnd_seqbus probe mechanism
ALSA: sb: Convert tosnd_seqbus probe mechanism
ALSA: emu10k1: Convert tosnd_seqbus probe mechanism
ALSA: seq: oss: Convert tosnd_seqbus probe mechanism
ALSA: seq: Refuse to probe seq drivers with non-bus probe or remove
Applied all patches to for-next branch now.
thanks,
Takashi