提交 af03c243 编写于 作者: T Takashi Iwai

ALSA: seq: Clean up device and driver structs

Use const string pointer instead of copying the id string to each
object.  Also drop the status and list fields of snd_seq_device struct
that are no longer used.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 7c37ae5c
...@@ -25,24 +25,16 @@ ...@@ -25,24 +25,16 @@
* registered device information * registered device information
*/ */
#define ID_LEN 32
/* status flag */
#define SNDRV_SEQ_DEVICE_FREE 0
#define SNDRV_SEQ_DEVICE_REGISTERED 1
struct snd_seq_device { struct snd_seq_device {
/* device info */ /* device info */
struct snd_card *card; /* sound card */ struct snd_card *card; /* sound card */
int device; /* device number */ int device; /* device number */
char id[ID_LEN]; /* driver id */ const char *id; /* driver id */
char name[80]; /* device name */ char name[80]; /* device name */
int argsize; /* size of the argument */ int argsize; /* size of the argument */
void *driver_data; /* private data for driver */ void *driver_data; /* private data for driver */
int status; /* flag - read only */
void *private_data; /* private data for the caller */ void *private_data; /* private data for the caller */
void (*private_free)(struct snd_seq_device *device); void (*private_free)(struct snd_seq_device *device);
struct list_head list; /* link to next device */
struct device dev; struct device dev;
}; };
...@@ -75,9 +67,11 @@ void snd_seq_device_load_drivers(void); ...@@ -75,9 +67,11 @@ void snd_seq_device_load_drivers(void);
#else #else
#define snd_seq_device_load_drivers() #define snd_seq_device_load_drivers()
#endif #endif
int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result); int snd_seq_device_new(struct snd_card *card, int device, const char *id,
int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize); int argsize, struct snd_seq_device **result);
int snd_seq_device_unregister_driver(char *id); 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)) #define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
......
...@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL"); ...@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
struct snd_seq_driver { struct snd_seq_driver {
struct device_driver driver; struct device_driver driver;
char id[ID_LEN]; const char *id;
int argsize; int argsize;
struct snd_seq_dev_ops ops; struct snd_seq_dev_ops ops;
}; };
...@@ -215,8 +215,8 @@ static void snd_seq_dev_release(struct device *dev) ...@@ -215,8 +215,8 @@ static void snd_seq_dev_release(struct device *dev)
* id = id of driver * id = id of driver
* result = return pointer (NULL allowed if unnecessary) * result = return pointer (NULL allowed if unnecessary)
*/ */
int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, int snd_seq_device_new(struct snd_card *card, int device, const char *id,
struct snd_seq_device **result) int argsize, struct snd_seq_device **result)
{ {
struct snd_seq_device *dev; struct snd_seq_device *dev;
int err; int err;
...@@ -239,9 +239,8 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, ...@@ -239,9 +239,8 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize,
/* set up device info */ /* set up device info */
dev->card = card; dev->card = card;
dev->device = device; dev->device = device;
strlcpy(dev->id, id, sizeof(dev->id)); dev->id = id;
dev->argsize = argsize; dev->argsize = argsize;
dev->status = SNDRV_SEQ_DEVICE_FREE;
device_initialize(&dev->dev); device_initialize(&dev->dev);
dev->dev.parent = &card->card_dev; dev->dev.parent = &card->card_dev;
...@@ -270,26 +269,16 @@ static int snd_seq_drv_probe(struct device *dev) ...@@ -270,26 +269,16 @@ static int snd_seq_drv_probe(struct device *dev)
{ {
struct snd_seq_driver *sdrv = to_seq_drv(dev->driver); struct snd_seq_driver *sdrv = to_seq_drv(dev->driver);
struct snd_seq_device *sdev = to_seq_dev(dev); struct snd_seq_device *sdev = to_seq_dev(dev);
int err;
err = sdrv->ops.init_device(sdev); return sdrv->ops.init_device(sdev);
if (err < 0)
return err;
sdev->status = SNDRV_SEQ_DEVICE_REGISTERED;
return 0;
} }
static int snd_seq_drv_remove(struct device *dev) static int snd_seq_drv_remove(struct device *dev)
{ {
struct snd_seq_driver *sdrv = to_seq_drv(dev->driver); struct snd_seq_driver *sdrv = to_seq_drv(dev->driver);
struct snd_seq_device *sdev = to_seq_dev(dev); struct snd_seq_device *sdev = to_seq_dev(dev);
int err;
err = sdrv->ops.free_device(sdev); return sdrv->ops.free_device(sdev);
if (err < 0)
return err;
sdev->status = SNDRV_SEQ_DEVICE_FREE;
return 0;
} }
/* /*
...@@ -297,8 +286,8 @@ static int snd_seq_drv_remove(struct device *dev) ...@@ -297,8 +286,8 @@ static int snd_seq_drv_remove(struct device *dev)
* id = driver id * id = driver id
* entry = driver operators - duplicated to each instance * entry = driver operators - duplicated to each instance
*/ */
int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int snd_seq_device_register_driver(const char *id,
int argsize) struct snd_seq_dev_ops *entry, int argsize)
{ {
struct snd_seq_driver *sdrv; struct snd_seq_driver *sdrv;
int err; int err;
...@@ -315,7 +304,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, ...@@ -315,7 +304,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
sdrv->driver.bus = &snd_seq_bus_type; sdrv->driver.bus = &snd_seq_bus_type;
sdrv->driver.probe = snd_seq_drv_probe; sdrv->driver.probe = snd_seq_drv_probe;
sdrv->driver.remove = snd_seq_drv_remove; sdrv->driver.remove = snd_seq_drv_remove;
strlcpy(sdrv->id, id, sizeof(sdrv->id)); sdrv->id = id;
sdrv->argsize = argsize; sdrv->argsize = argsize;
sdrv->ops = *entry; sdrv->ops = *entry;
...@@ -343,7 +332,7 @@ static int find_drv(struct device_driver *drv, void *data) ...@@ -343,7 +332,7 @@ static int find_drv(struct device_driver *drv, void *data)
/* /*
* unregister the specified driver * unregister the specified driver
*/ */
int snd_seq_device_unregister_driver(char *id) int snd_seq_device_unregister_driver(const char *id)
{ {
struct snd_seq_driver *sdrv = (struct snd_seq_driver *)id; struct snd_seq_driver *sdrv = (struct snd_seq_driver *)id;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册