Skip to content

Commit 6176fad

Browse files
committed
Merge branch 'topic/seq-cleanup' into for-next
2 parents 66c21c5 + 54a721a commit 6176fad

File tree

12 files changed

+256
-576
lines changed

12 files changed

+256
-576
lines changed

include/sound/seq_device.h

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,67 @@
2525
* registered device information
2626
*/
2727

28-
#define ID_LEN 32
29-
30-
/* status flag */
31-
#define SNDRV_SEQ_DEVICE_FREE 0
32-
#define SNDRV_SEQ_DEVICE_REGISTERED 1
33-
3428
struct snd_seq_device {
3529
/* device info */
3630
struct snd_card *card; /* sound card */
3731
int device; /* device number */
38-
char id[ID_LEN]; /* driver id */
32+
const char *id; /* driver id */
3933
char name[80]; /* device name */
4034
int argsize; /* size of the argument */
4135
void *driver_data; /* private data for driver */
42-
int status; /* flag - read only */
4336
void *private_data; /* private data for the caller */
4437
void (*private_free)(struct snd_seq_device *device);
45-
struct list_head list; /* link to next device */
38+
struct device dev;
4639
};
4740

41+
#define to_seq_dev(_dev) \
42+
container_of(_dev, struct snd_seq_device, dev)
43+
44+
/* sequencer driver */
4845

4946
/* driver operators
50-
* init_device:
47+
* probe:
5148
* Initialize the device with given parameters.
5249
* Typically,
5350
* 1. call snd_hwdep_new
5451
* 2. allocate private data and initialize it
5552
* 3. call snd_hwdep_register
5653
* 4. store the instance to dev->driver_data pointer.
5754
*
58-
* free_device:
55+
* remove:
5956
* Release the private data.
6057
* Typically, call snd_device_free(dev->card, dev->driver_data)
6158
*/
62-
struct snd_seq_dev_ops {
63-
int (*init_device)(struct snd_seq_device *dev);
64-
int (*free_device)(struct snd_seq_device *dev);
59+
struct snd_seq_driver {
60+
struct device_driver driver;
61+
char *id;
62+
int argsize;
6563
};
6664

65+
#define to_seq_drv(_drv) \
66+
container_of(_drv, struct snd_seq_driver, driver)
67+
6768
/*
6869
* prototypes
6970
*/
71+
#ifdef CONFIG_MODULES
7072
void snd_seq_device_load_drivers(void);
71-
int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result);
72-
int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize);
73-
int snd_seq_device_unregister_driver(char *id);
73+
#else
74+
#define snd_seq_device_load_drivers()
75+
#endif
76+
int snd_seq_device_new(struct snd_card *card, int device, const char *id,
77+
int argsize, struct snd_seq_device **result);
7478

7579
#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
7680

81+
int __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
82+
struct module *mod);
83+
#define snd_seq_driver_register(drv) \
84+
__snd_seq_driver_register(drv, THIS_MODULE)
85+
void snd_seq_driver_unregister(struct snd_seq_driver *drv);
86+
87+
#define module_snd_seq_driver(drv) \
88+
module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
7789

7890
/*
7991
* id strings for generic devices

include/sound/seq_kernel.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,9 @@ int snd_seq_event_port_attach(int client, struct snd_seq_port_callback *pcbp,
9999
int snd_seq_event_port_detach(int client, int port);
100100

101101
#ifdef CONFIG_MODULES
102-
void snd_seq_autoload_lock(void);
103-
void snd_seq_autoload_unlock(void);
104102
void snd_seq_autoload_init(void);
105-
#define snd_seq_autoload_exit() snd_seq_autoload_lock()
103+
void snd_seq_autoload_exit(void);
106104
#else
107-
#define snd_seq_autoload_lock()
108-
#define snd_seq_autoload_unlock()
109105
#define snd_seq_autoload_init()
110106
#define snd_seq_autoload_exit()
111107
#endif

sound/core/seq/oss/seq_oss.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,20 @@ static unsigned int odev_poll(struct file *file, poll_table * wait);
6565
* module interface
6666
*/
6767

68+
static struct snd_seq_driver seq_oss_synth_driver = {
69+
.driver = {
70+
.name = KBUILD_MODNAME,
71+
.probe = snd_seq_oss_synth_probe,
72+
.remove = snd_seq_oss_synth_remove,
73+
},
74+
.id = SNDRV_SEQ_DEV_ID_OSS,
75+
.argsize = sizeof(struct snd_seq_oss_reg),
76+
};
77+
6878
static int __init alsa_seq_oss_init(void)
6979
{
7080
int rc;
71-
static struct snd_seq_dev_ops ops = {
72-
snd_seq_oss_synth_register,
73-
snd_seq_oss_synth_unregister,
74-
};
7581

76-
snd_seq_autoload_lock();
7782
if ((rc = register_device()) < 0)
7883
goto error;
7984
if ((rc = register_proc()) < 0) {
@@ -86,8 +91,8 @@ static int __init alsa_seq_oss_init(void)
8691
goto error;
8792
}
8893

89-
if ((rc = snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OSS, &ops,
90-
sizeof(struct snd_seq_oss_reg))) < 0) {
94+
rc = snd_seq_driver_register(&seq_oss_synth_driver);
95+
if (rc < 0) {
9196
snd_seq_oss_delete_client();
9297
unregister_proc();
9398
unregister_device();
@@ -98,13 +103,12 @@ static int __init alsa_seq_oss_init(void)
98103
snd_seq_oss_synth_init();
99104

100105
error:
101-
snd_seq_autoload_unlock();
102106
return rc;
103107
}
104108

105109
static void __exit alsa_seq_oss_exit(void)
106110
{
107-
snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_OSS);
111+
snd_seq_driver_unregister(&seq_oss_synth_driver);
108112
snd_seq_oss_delete_client();
109113
unregister_proc();
110114
unregister_device();

sound/core/seq/oss/seq_oss_synth.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ snd_seq_oss_synth_init(void)
9898
* registration of the synth device
9999
*/
100100
int
101-
snd_seq_oss_synth_register(struct snd_seq_device *dev)
101+
snd_seq_oss_synth_probe(struct device *_dev)
102102
{
103+
struct snd_seq_device *dev = to_seq_dev(_dev);
103104
int i;
104105
struct seq_oss_synth *rec;
105106
struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
@@ -149,8 +150,9 @@ snd_seq_oss_synth_register(struct snd_seq_device *dev)
149150

150151

151152
int
152-
snd_seq_oss_synth_unregister(struct snd_seq_device *dev)
153+
snd_seq_oss_synth_remove(struct device *_dev)
153154
{
155+
struct snd_seq_device *dev = to_seq_dev(_dev);
154156
int index;
155157
struct seq_oss_synth *rec = dev->driver_data;
156158
unsigned long flags;

sound/core/seq/oss/seq_oss_synth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include <sound/seq_device.h>
2929

3030
void snd_seq_oss_synth_init(void);
31-
int snd_seq_oss_synth_register(struct snd_seq_device *dev);
32-
int snd_seq_oss_synth_unregister(struct snd_seq_device *dev);
31+
int snd_seq_oss_synth_probe(struct device *dev);
32+
int snd_seq_oss_synth_remove(struct device *dev);
3333
void snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp);
3434
void snd_seq_oss_synth_setup_midi(struct seq_oss_devinfo *dp);
3535
void snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp);

0 commit comments

Comments
 (0)