summaryrefslogtreecommitdiff
path: root/include/sound/seq_device.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-12 13:43:22 +0100
committerTakashi Iwai <tiwai@suse.de>2015-02-12 14:15:54 +0100
commit056622053b8ae02978678ac1321b5bd956e7c812 (patch)
treee2c0602b6efd90dc7d6e760bd7cd4ab0567104ee /include/sound/seq_device.h
parentaf03c243a1f014145dae34368fe975b2f08ed964 (diff)
ALSA: seq: Define driver object in each driver
This patch moves the driver object initialization and allocation to each driver's module init/exit code like other normal drivers. The snd_seq_driver struct is now published in seq_device.h, and each driver is responsible to define it with proper driver attributes (name, probe and remove) with snd_seq_driver specific attributes as id and argsize fields. The helper functions snd_seq_driver_register(), snd_seq_driver_unregister() and module_snd_seq_driver() are used for simplifying codes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/seq_device.h')
-rw-r--r--include/sound/seq_device.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/sound/seq_device.h b/include/sound/seq_device.h
index b13cd2930d32..ddc0d504cf39 100644
--- a/include/sound/seq_device.h
+++ b/include/sound/seq_device.h
@@ -41,8 +41,10 @@ struct snd_seq_device {
#define to_seq_dev(_dev) \
container_of(_dev, struct snd_seq_device, dev)
+/* sequencer driver */
+
/* driver operators
- * init_device:
+ * probe:
* Initialize the device with given parameters.
* Typically,
* 1. call snd_hwdep_new
@@ -50,15 +52,19 @@ struct snd_seq_device {
* 3. call snd_hwdep_register
* 4. store the instance to dev->driver_data pointer.
*
- * free_device:
+ * remove:
* Release the private data.
* Typically, call snd_device_free(dev->card, dev->driver_data)
*/
-struct snd_seq_dev_ops {
- int (*init_device)(struct snd_seq_device *dev);
- int (*free_device)(struct snd_seq_device *dev);
+struct snd_seq_driver {
+ struct device_driver driver;
+ char *id;
+ int argsize;
};
+#define to_seq_drv(_drv) \
+ container_of(_drv, struct snd_seq_driver, driver)
+
/*
* prototypes
*/
@@ -69,12 +75,17 @@ void snd_seq_device_load_drivers(void);
#endif
int snd_seq_device_new(struct snd_card *card, int device, const char *id,
int argsize, struct snd_seq_device **result);
-int snd_seq_device_register_driver(const char *id,
- struct snd_seq_dev_ops *entry, int argsize);
-int snd_seq_device_unregister_driver(const char *id);
#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
+int __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
+ struct module *mod);
+#define snd_seq_driver_register(drv) \
+ __snd_seq_driver_register(drv, THIS_MODULE)
+void snd_seq_driver_unregister(struct snd_seq_driver *drv);
+
+#define module_snd_seq_driver(drv) \
+ module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
/*
* id strings for generic devices