Commit 9ce50543 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: Drop __bitwise and typedefs for snd_device attributes

Using __bitwise and typedefs for the attributes of snd_device struct
isn't so useful, and rather it worsens the readability.  Let's drop
them and use the straightforward enum.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 483eb062
...@@ -48,32 +48,35 @@ struct completion; ...@@ -48,32 +48,35 @@ struct completion;
#define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000 #define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000
typedef int __bitwise snd_device_type_t; enum snd_device_type {
#define SNDRV_DEV_TOPLEVEL ((__force snd_device_type_t) 0) SNDRV_DEV_TOPLEVEL = 0,
#define SNDRV_DEV_CONTROL ((__force snd_device_type_t) 1) SNDRV_DEV_CONTROL = 1,
#define SNDRV_DEV_LOWLEVEL_PRE ((__force snd_device_type_t) 2) SNDRV_DEV_LOWLEVEL_PRE = 2,
#define SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000) SNDRV_DEV_LOWLEVEL_NORMAL = 0x1000,
#define SNDRV_DEV_PCM ((__force snd_device_type_t) 0x1001) SNDRV_DEV_PCM,
#define SNDRV_DEV_RAWMIDI ((__force snd_device_type_t) 0x1002) SNDRV_DEV_RAWMIDI,
#define SNDRV_DEV_TIMER ((__force snd_device_type_t) 0x1003) SNDRV_DEV_TIMER,
#define SNDRV_DEV_SEQUENCER ((__force snd_device_type_t) 0x1004) SNDRV_DEV_SEQUENCER,
#define SNDRV_DEV_HWDEP ((__force snd_device_type_t) 0x1005) SNDRV_DEV_HWDEP,
#define SNDRV_DEV_INFO ((__force snd_device_type_t) 0x1006) SNDRV_DEV_INFO,
#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007) SNDRV_DEV_BUS,
#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008) SNDRV_DEV_CODEC,
#define SNDRV_DEV_JACK ((__force snd_device_type_t) 0x1009) SNDRV_DEV_JACK,
#define SNDRV_DEV_COMPRESS ((__force snd_device_type_t) 0x100A) SNDRV_DEV_COMPRESS,
#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000) SNDRV_DEV_LOWLEVEL = 0x2000,
};
typedef int __bitwise snd_device_state_t;
#define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0) enum snd_device_state {
#define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1) SNDRV_DEV_BUILD,
#define SNDRV_DEV_DISCONNECTED ((__force snd_device_state_t) 2) SNDRV_DEV_REGISTERED,
SNDRV_DEV_DISCONNECTED,
typedef int __bitwise snd_device_cmd_t; };
#define SNDRV_DEV_CMD_PRE ((__force snd_device_cmd_t) 0)
#define SNDRV_DEV_CMD_NORMAL ((__force snd_device_cmd_t) 1) enum snd_device_cmd {
#define SNDRV_DEV_CMD_POST ((__force snd_device_cmd_t) 2) SNDRV_DEV_CMD_PRE,
SNDRV_DEV_CMD_NORMAL,
SNDRV_DEV_CMD_POST,
};
struct snd_device; struct snd_device;
...@@ -86,8 +89,8 @@ struct snd_device_ops { ...@@ -86,8 +89,8 @@ struct snd_device_ops {
struct snd_device { struct snd_device {
struct list_head list; /* list of registered devices */ struct list_head list; /* list of registered devices */
struct snd_card *card; /* card which holds this device */ struct snd_card *card; /* card which holds this device */
snd_device_state_t state; /* state of the device */ enum snd_device_state state; /* state of the device */
snd_device_type_t type; /* device type */ enum snd_device_type type; /* device type */
void *device_data; /* device structure */ void *device_data; /* device structure */
struct snd_device_ops *ops; /* operations */ struct snd_device_ops *ops; /* operations */
}; };
...@@ -311,14 +314,14 @@ int snd_card_file_remove(struct snd_card *card, struct file *file); ...@@ -311,14 +314,14 @@ int snd_card_file_remove(struct snd_card *card, struct file *file);
/* device.c */ /* device.c */
int snd_device_new(struct snd_card *card, snd_device_type_t type, int snd_device_new(struct snd_card *card, enum snd_device_type type,
void *device_data, struct snd_device_ops *ops); void *device_data, struct snd_device_ops *ops);
int snd_device_register(struct snd_card *card, void *device_data); int snd_device_register(struct snd_card *card, void *device_data);
int snd_device_register_all(struct snd_card *card); int snd_device_register_all(struct snd_card *card);
int snd_device_disconnect(struct snd_card *card, void *device_data); int snd_device_disconnect(struct snd_card *card, void *device_data);
int snd_device_disconnect_all(struct snd_card *card); int snd_device_disconnect_all(struct snd_card *card);
int snd_device_free(struct snd_card *card, void *device_data); int snd_device_free(struct snd_card *card, void *device_data);
int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd); int snd_device_free_all(struct snd_card *card, enum snd_device_cmd cmd);
/* isadma.c */ /* isadma.c */
......
...@@ -116,7 +116,7 @@ struct aoa_card { ...@@ -116,7 +116,7 @@ struct aoa_card {
struct snd_card *alsa_card; struct snd_card *alsa_card;
}; };
extern int aoa_snd_device_new(snd_device_type_t type, extern int aoa_snd_device_new(enum snd_device_type type,
void * device_data, struct snd_device_ops * ops); void * device_data, struct snd_device_ops * ops);
extern struct snd_card *aoa_get_card(void); extern struct snd_card *aoa_get_card(void);
extern int aoa_snd_ctl_add(struct snd_kcontrol* control); extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
......
...@@ -59,7 +59,7 @@ void aoa_alsa_cleanup(void) ...@@ -59,7 +59,7 @@ void aoa_alsa_cleanup(void)
} }
} }
int aoa_snd_device_new(snd_device_type_t type, int aoa_snd_device_new(enum snd_device_type type,
void * device_data, struct snd_device_ops * ops) void * device_data, struct snd_device_ops * ops)
{ {
struct snd_card *card = aoa_get_card(); struct snd_card *card = aoa_get_card();
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* *
* Return: Zero if successful, or a negative error code on failure. * Return: Zero if successful, or a negative error code on failure.
*/ */
int snd_device_new(struct snd_card *card, snd_device_type_t type, int snd_device_new(struct snd_card *card, enum snd_device_type type,
void *device_data, struct snd_device_ops *ops) void *device_data, struct snd_device_ops *ops)
{ {
struct snd_device *dev; struct snd_device *dev;
...@@ -223,7 +223,7 @@ int snd_device_disconnect_all(struct snd_card *card) ...@@ -223,7 +223,7 @@ int snd_device_disconnect_all(struct snd_card *card)
* release all the devices on the card. * release all the devices on the card.
* called from init.c * called from init.c
*/ */
int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) int snd_device_free_all(struct snd_card *card, enum snd_device_cmd cmd)
{ {
struct snd_device *dev; struct snd_device *dev;
int err; int err;
...@@ -231,11 +231,11 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) ...@@ -231,11 +231,11 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
if (snd_BUG_ON(!card)) if (snd_BUG_ON(!card))
return -ENXIO; return -ENXIO;
range_low = (__force unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE; range_low = (unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
__again: __again:
list_for_each_entry(dev, &card->devices, list) { list_for_each_entry(dev, &card->devices, list) {
type = (__force unsigned int)dev->type; type = (unsigned int)dev->type;
if (type >= range_low && type <= range_high) { if (type >= range_low && type <= range_high) {
if ((err = snd_device_free(card, dev->device_data)) < 0) if ((err = snd_device_free(card, dev->device_data)) < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment