Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes
Date: Wed, 12 Feb 2014 11:52:08 +0100
Message-ID: <1392202347-11774-2-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1392202347-11774-1-git-send-email-tiwai@suse.de>

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: Takashi Iwai <tiwai@suse.de>
---
 include/sound/core.h  | 63 +++++++++++++++++++++++++++------------------------
 sound/aoa/aoa.h       |  2 +-
 sound/aoa/core/alsa.c |  2 +-
 sound/core/device.c   |  8 +++----
 4 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index e946b2428ea0..7c407b588697 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -48,32 +48,35 @@ struct device_attribute;
 
 #define SNDRV_DEV_TYPE_RANGE_SIZE		0x1000
 
-typedef int __bitwise snd_device_type_t;
-#define	SNDRV_DEV_TOPLEVEL	((__force snd_device_type_t) 0)
-#define	SNDRV_DEV_CONTROL	((__force snd_device_type_t) 1)
-#define	SNDRV_DEV_LOWLEVEL_PRE	((__force snd_device_type_t) 2)
-#define	SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000)
-#define	SNDRV_DEV_PCM		((__force snd_device_type_t) 0x1001)
-#define	SNDRV_DEV_RAWMIDI	((__force snd_device_type_t) 0x1002)
-#define	SNDRV_DEV_TIMER		((__force snd_device_type_t) 0x1003)
-#define	SNDRV_DEV_SEQUENCER	((__force snd_device_type_t) 0x1004)
-#define	SNDRV_DEV_HWDEP		((__force snd_device_type_t) 0x1005)
-#define	SNDRV_DEV_INFO		((__force snd_device_type_t) 0x1006)
-#define	SNDRV_DEV_BUS		((__force snd_device_type_t) 0x1007)
-#define	SNDRV_DEV_CODEC		((__force snd_device_type_t) 0x1008)
-#define	SNDRV_DEV_JACK          ((__force snd_device_type_t) 0x1009)
-#define	SNDRV_DEV_COMPRESS	((__force snd_device_type_t) 0x100A)
-#define	SNDRV_DEV_LOWLEVEL	((__force snd_device_type_t) 0x2000)
-
-typedef int __bitwise snd_device_state_t;
-#define	SNDRV_DEV_BUILD		((__force snd_device_state_t) 0)
-#define	SNDRV_DEV_REGISTERED	((__force snd_device_state_t) 1)
-#define	SNDRV_DEV_DISCONNECTED	((__force snd_device_state_t) 2)
-
-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)	
-#define	SNDRV_DEV_CMD_POST	((__force snd_device_cmd_t) 2)
+enum snd_device_type {
+	SNDRV_DEV_TOPLEVEL	= 0,
+	SNDRV_DEV_CONTROL	= 1,
+	SNDRV_DEV_LOWLEVEL_PRE	= 2,
+	SNDRV_DEV_LOWLEVEL_NORMAL = 0x1000,
+	SNDRV_DEV_PCM,
+	SNDRV_DEV_RAWMIDI,
+	SNDRV_DEV_TIMER,
+	SNDRV_DEV_SEQUENCER,
+	SNDRV_DEV_HWDEP,
+	SNDRV_DEV_INFO,
+	SNDRV_DEV_BUS,
+	SNDRV_DEV_CODEC,
+	SNDRV_DEV_JACK,
+	SNDRV_DEV_COMPRESS,
+	SNDRV_DEV_LOWLEVEL	= 0x2000,
+};
+
+enum snd_device_state {
+	SNDRV_DEV_BUILD,
+	SNDRV_DEV_REGISTERED,
+	SNDRV_DEV_DISCONNECTED,
+};
+
+enum snd_device_cmd {
+	SNDRV_DEV_CMD_PRE,
+	SNDRV_DEV_CMD_NORMAL,
+	SNDRV_DEV_CMD_POST,
+};
 
 struct snd_device;
 
@@ -86,8 +89,8 @@ struct snd_device_ops {
 struct snd_device {
 	struct list_head list;		/* list of registered devices */
 	struct snd_card *card;		/* card which holds this device */
-	snd_device_state_t state;	/* state of the device */
-	snd_device_type_t type;		/* device type */
+	enum snd_device_state state;	/* state of the device */
+	enum snd_device_type type;	/* device type */
 	void *device_data;		/* device structure */
 	struct snd_device_ops *ops;	/* operations */
 };
@@ -310,14 +313,14 @@ void snd_card_unref(struct snd_card *card);
 
 /* 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);
 int snd_device_register(struct snd_card *card, void *device_data);
 int snd_device_register_all(struct snd_card *card);
 int snd_device_disconnect(struct snd_card *card, void *device_data);
 int snd_device_disconnect_all(struct snd_card *card);
 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 */
 
diff --git a/sound/aoa/aoa.h b/sound/aoa/aoa.h
index e08789484e30..34c668f27798 100644
--- a/sound/aoa/aoa.h
+++ b/sound/aoa/aoa.h
@@ -116,7 +116,7 @@ struct aoa_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);
 extern struct snd_card *aoa_get_card(void);
 extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
diff --git a/sound/aoa/core/alsa.c b/sound/aoa/core/alsa.c
index 9913bf222073..4a7e4e6b746f 100644
--- a/sound/aoa/core/alsa.c
+++ b/sound/aoa/core/alsa.c
@@ -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)
 {
 	struct snd_card *card = aoa_get_card();
diff --git a/sound/core/device.c b/sound/core/device.c
index df88defed176..6f734fe50296 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -41,7 +41,7 @@
  *
  * 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)
 {
 	struct snd_device *dev;
@@ -222,7 +222,7 @@ int snd_device_disconnect_all(struct snd_card *card)
  * release all the devices on the card.
  * 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;
 	int err;
@@ -230,11 +230,11 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
 
 	if (snd_BUG_ON(!card))
 		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;
       __again:
 	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 ((err = snd_device_free(card, dev->device_data)) < 0)
 				return err;
-- 
1.8.5.2

  reply index

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
2014-02-12 10:52 ` Takashi Iwai [this message]
2014-02-12 10:52 ` [PATCH 02/20] ALSA: Add SNDRV_DEV_CARD type Takashi Iwai
2014-02-12 10:52 ` [PATCH 03/20] ALSA: pci: Use SNDRV_DEV_CARD for card objects Takashi Iwai
2014-02-12 10:52 ` [PATCH 04/20] ALSA: isa: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 05/20] ALSA: drivers: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 06/20] ALSA: pcmcia: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 07/20] ALSA: usb-audio: Use proper SNDRV_DEV_* type Takashi Iwai
2014-02-12 10:52 ` [PATCH 08/20] ALSA: aoa: Use SNDRV_DEV_CODEC for AOA codec objects Takashi Iwai
2014-02-12 10:52 ` [PATCH 09/20] ALSA: mips: Use SNDRV_DEV_CARD for card objects Takashi Iwai
2014-02-12 10:52 ` [PATCH 10/20] ALSA: parisc: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 11/20] ALSA: ppc: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 12/20] ALSA: sh: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 13/20] ALSA: sparc: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 14/20] ALSA: i2c/ak413x: Use SNDRV_DEV_CODEC for ak413x codec objects Takashi Iwai
2014-02-12 10:52 ` [PATCH 15/20] ALSA: spi: Use SNDRV_DEV_CARD for card objects Takashi Iwai
2014-02-12 10:52 ` [PATCH 16/20] HID: prodikeys: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 17/20] staging: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 18/20] usb: gadget: " Takashi Iwai
2014-02-12 10:52 ` [PATCH 19/20] ALSA: Use priority list for managing device list Takashi Iwai
2014-02-12 10:52 ` [PATCH 20/20] ALSA: Clean up snd_device_*() codes Takashi Iwai
2014-02-14 11:59 ` [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392202347-11774-2-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git