All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 00/20] snd_device_* cleanups
@ 2014-02-12 10:52 Takashi Iwai
  2014-02-12 10:52 ` [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes Takashi Iwai
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

This batch is aimed for cleanups of snd_device_*() usages.
The major change is to introduce SNDRV_DEV_CARD type and use it for
the card-level object instead of SNDRV_DEV_LOWLEVEL.  The rest are
simplification of snd_device_*() calls and management.


Takashi

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 02/20] ALSA: Add SNDRV_DEV_CARD type Takashi Iwai
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 02/20] ALSA: Add SNDRV_DEV_CARD type
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
  2014-02-12 10:52 ` [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 03/20] ALSA: pci: Use SNDRV_DEV_CARD for card objects Takashi Iwai
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

Define the new SNDRV_DEV_CARD that is used for managing the top-level
card (chip) object.  So far, we used SNDRV_DEV_LOWLEVEL for this
purpose, but it doesn't fit properly; the "lowlevel" doesn't match
with the object it's assigned (where the card/chip object is rather a
top-level one).  And since the device register/free order will be more
strictly ordered in the later patch, we should place this object in
the right order position.

This patch alone just adds SNDRV_DEV_CARD as equivalent as
SNDRV_DEV_LOWLEVEL.  In the later patch, the value will be adjusted
appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 Documentation/DocBook/writing-an-alsa-driver.tmpl | 10 +++++-----
 include/sound/core.h                              |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl
index d0056a4e9c53..c6119a30169b 100644
--- a/Documentation/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl
@@ -462,7 +462,7 @@
            */
           ....
 
-          err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+          err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
           if (err < 0) {
                   snd_mychip_free(chip);
                   return err;
@@ -870,8 +870,8 @@
       callback pointers (<parameter>&amp;ops</parameter>). The
       device-level defines the type of components and the order of
       registration and de-registration.  For most components, the
-      device-level is already defined.  For a user-defined component,
-      you can use <constant>SNDRV_DEV_LOWLEVEL</constant>.
+      device-level is already defined.  For a user-defined card component,
+      you can use <constant>SNDRV_DEV_CARD</constant>.
       </para>
 
       <para>
@@ -1018,7 +1018,7 @@
           .dev_free =        snd_mychip_dev_free,
   };
   ....
-  snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+  snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 ]]>
             </programlisting>
           </informalexample>
@@ -1171,7 +1171,7 @@
           /* (2) initialization of the chip hardware */
           .... /*   (not implemented in this document) */
 
-          err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+          err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
           if (err < 0) {
                   snd_mychip_free(chip);
                   return err;
diff --git a/include/sound/core.h b/include/sound/core.h
index 7c407b588697..127b908a2422 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -64,6 +64,7 @@ enum snd_device_type {
 	SNDRV_DEV_JACK,
 	SNDRV_DEV_COMPRESS,
 	SNDRV_DEV_LOWLEVEL	= 0x2000,
+	SNDRV_DEV_CARD = SNDRV_DEV_LOWLEVEL,
 };
 
 enum snd_device_state {
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 03/20] ALSA: pci: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
  2014-02-12 10:52 ` [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes Takashi Iwai
  2014-02-12 10:52 ` [PATCH 02/20] ALSA: Add SNDRV_DEV_CARD type Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 04/20] ALSA: isa: " Takashi Iwai
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ad1889.c                  | 2 +-
 sound/pci/ali5451/ali5451.c         | 2 +-
 sound/pci/als300.c                  | 2 +-
 sound/pci/atiixp.c                  | 2 +-
 sound/pci/atiixp_modem.c            | 2 +-
 sound/pci/au88x0/au88x0.c           | 2 +-
 sound/pci/aw2/aw2-alsa.c            | 2 +-
 sound/pci/azt3328.c                 | 2 +-
 sound/pci/bt87x.c                   | 2 +-
 sound/pci/ca0106/ca0106_main.c      | 2 +-
 sound/pci/cmipci.c                  | 2 +-
 sound/pci/cs4281.c                  | 2 +-
 sound/pci/cs46xx/cs46xx_lib.c       | 2 +-
 sound/pci/cs5530.c                  | 2 +-
 sound/pci/cs5535audio/cs5535audio.c | 2 +-
 sound/pci/ctxfi/ctatc.c             | 2 +-
 sound/pci/echoaudio/echoaudio.c     | 2 +-
 sound/pci/emu10k1/emu10k1_main.c    | 2 +-
 sound/pci/emu10k1/emu10k1x.c        | 2 +-
 sound/pci/ens1370.c                 | 2 +-
 sound/pci/es1938.c                  | 2 +-
 sound/pci/es1968.c                  | 2 +-
 sound/pci/fm801.c                   | 2 +-
 sound/pci/hda/hda_intel.c           | 2 +-
 sound/pci/ice1712/ice1712.c         | 2 +-
 sound/pci/ice1712/ice1724.c         | 2 +-
 sound/pci/intel8x0.c                | 2 +-
 sound/pci/intel8x0m.c               | 2 +-
 sound/pci/korg1212/korg1212.c       | 2 +-
 sound/pci/lola/lola.c               | 2 +-
 sound/pci/lx6464es/lx6464es.c       | 2 +-
 sound/pci/maestro3.c                | 2 +-
 sound/pci/mixart/mixart.c           | 2 +-
 sound/pci/nm256/nm256.c             | 2 +-
 sound/pci/pcxhr/pcxhr.c             | 2 +-
 sound/pci/riptide/riptide.c         | 2 +-
 sound/pci/sis7019.c                 | 2 +-
 sound/pci/sonicvibes.c              | 2 +-
 sound/pci/trident/trident_main.c    | 2 +-
 sound/pci/via82xx.c                 | 2 +-
 sound/pci/via82xx_modem.c           | 2 +-
 sound/pci/vx222/vx222.c             | 2 +-
 sound/pci/ymfpci/ymfpci_main.c      | 2 +-
 43 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index ba4da1ed0444..6b134caf12ca 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -960,7 +960,7 @@ snd_ad1889_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_ad1889_free(chip);
 		return err;
 	}
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 115b1120319a..5802f9778ff7 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2212,7 +2212,7 @@ static int snd_ali_create(struct snd_card *card,
 	}
 
 	snd_ali_printk("snd_device_new is called.\n");
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, codec, &ops);
 	if (err < 0) {
 		snd_ali_free(codec);
 		return err;
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 9acd88ab93a4..ad45cd7d3f56 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -755,7 +755,7 @@ static int snd_als300_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 						chip, &ops)) < 0) {
 		snd_als300_free(chip);
 		return err;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 85f893b5cc99..04f0c19d57fa 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1652,7 +1652,7 @@ static int snd_atiixp_create(struct snd_card *card,
 	pci_set_master(pci);
 	synchronize_irq(chip->irq);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_atiixp_free(chip);
 		return err;
 	}
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 2b3244a85cf8..3c87b8f5df51 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1277,7 +1277,7 @@ static int snd_atiixp_create(struct snd_card *card,
 	pci_set_master(pci);
 	synchronize_irq(chip->irq);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_atiixp_free(chip);
 		return err;
 	}
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index afb1b44b741e..5ad6f95bb06e 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -207,7 +207,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
 	// End of PCI setup.
 
 	// Register alsa root device.
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		goto alloc_out;
 	}
 
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index e9dabee42805..3c5ca5485b3f 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -312,7 +312,7 @@ static int snd_aw2_create(struct snd_card *card,
 	}
 	chip->irq = pci->irq;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		free_irq(chip->irq, (void *)chip);
 		iounmap(chip->iobase_virt);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 641c235ab4d8..dd9799f1413d 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -2570,7 +2570,7 @@ snd_azf3328_create(struct snd_card *card,
 
 	snd_azf3328_debug_show_ports(chip);
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0)
 		goto out_err;
 
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 06dc7d97cc0c..d4875505adae 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -769,7 +769,7 @@ static int snd_bt87x_create(struct snd_card *card,
 	pci_set_master(pci);
 	synchronize_irq(chip->irq);
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0)
 		goto fail;
 
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index f659c7a89c0c..87a6765eb0b1 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1736,7 +1736,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
 
 	ca0106_init_chip(chip, 0);
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_ca0106_free(chip);
 		return err;
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 66c0558ce449..43db4a98b9db 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3164,7 +3164,7 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
 	sprintf(card->longname, "%s%s at %#lx, irq %i",
 		card->shortname, modelstr, cm->iobase, cm->irq);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, cm, &ops)) < 0) {
 		snd_cmipci_free(cm);
 		return err;
 	}
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 2bd55177b1ae..54e927b9fbee 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1395,7 +1395,7 @@ static int snd_cs4281_create(struct snd_card *card,
 		return tmp;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_cs4281_free(chip);
 		return err;
 	}
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 28766478f81c..829bbc3ac8ec 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -4040,7 +4040,7 @@ int snd_cs46xx_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_cs46xx_free(chip);
 		return err;
 	}
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
index 8037e8600a72..f008b097bb53 100644
--- a/sound/pci/cs5530.c
+++ b/sound/pci/cs5530.c
@@ -238,7 +238,7 @@ static int snd_cs5530_create(struct snd_card *card,
 		return err;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_cs5530_free(chip);
 		return err;
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index 051b3e28e341..5e790fa02e1a 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -320,7 +320,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
 	cs5535au->irq = pci->irq;
 	pci_set_master(pci);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 				  cs5535au, &ops)) < 0)
 		goto sndfail;
 
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index af632bd08323..2c83ce856d11 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1735,7 +1735,7 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
 		goto error1;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, atc, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, atc, &ops);
 	if (err < 0)
 		goto error1;
 
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 1ef77c0d39ec..1f665ff104f2 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -2028,7 +2028,7 @@ static int snd_echo_create(struct snd_card *card,
 	}
 	DE_INIT(("Card init OK\n"));
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_echo_free(chip);
 		return err;
 	}
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 75504da63613..df02ec2ab72e 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -2013,7 +2013,7 @@ int snd_emu10k1_create(struct snd_card *card,
 		goto error;
 	snd_emu10k1_audio_enable(emu);
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, emu, &ops);
 	if (err < 0)
 		goto error;
 
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 3988eaa778cf..f35862a45b2a 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1013,7 +1013,7 @@ static int snd_emu10k1x_create(struct snd_card *card,
 
 	outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 				  chip, &ops)) < 0) {
 		snd_emu10k1x_free(chip);
 		return err;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 0f89d2a2090e..607478451ed4 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2173,7 +2173,7 @@ static int snd_ensoniq_create(struct snd_card *card,
 
 	snd_ensoniq_chip_init(ensoniq);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, ensoniq, &ops)) < 0) {
 		snd_ensoniq_free(ensoniq);
 		return err;
 	}
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 33489bcc0aff..b6133a974f23 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1653,7 +1653,7 @@ static int snd_es1938_create(struct snd_card *card,
 
 	snd_es1938_chip_init(chip);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_es1938_free(chip);
 		return err;
 	}
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 87e9cd5d3ceb..d19a5a3eb2e0 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2778,7 +2778,7 @@ static int snd_es1968_create(struct snd_card *card,
 
 	snd_es1968_chip_init(chip);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_es1968_free(chip);
 		return err;
 	}
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 8b6af212cbfe..9c69579895c2 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1246,7 +1246,7 @@ static int snd_fm801_create(struct snd_card *card,
 		chip->irq = -1;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_fm801_free(chip);
 		return err;
 	}
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 0870f5f3ed1c..1d4069e08947 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -3584,7 +3584,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
 		}
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_printk(KERN_ERR SFX "%s: Error creating device [card]!\n",
 		   pci_name(chip->pci));
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 99c022a0d612..659079754861 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2633,7 +2633,7 @@ static int snd_ice1712_create(struct snd_card *card,
 	     ICEREG(ice, IRQMASK));
 	outb(0x00, ICEMT(ice, IRQ));
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, ice, &ops);
 	if (err < 0) {
 		snd_ice1712_free(ice);
 		return err;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index cf1ba116a772..1afedc6646d8 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2603,7 +2603,7 @@ static int snd_vt1724_create(struct snd_card *card,
 		return -EIO;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, ice, &ops);
 	if (err < 0) {
 		snd_vt1724_free(ice);
 		return err;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index ff24acf06bdd..04f7c7771da7 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -3212,7 +3212,7 @@ static int snd_intel8x0_create(struct snd_card *card,
 	}
 	chip->irq = pci->irq;
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_intel8x0_free(chip);
 		return err;
 	}
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index f8c72bd8a3cd..b030211da513 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1238,7 +1238,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_intel8x0m_free(chip);
 		return err;
 	}
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 8f36d77f01e5..164b6109178e 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2372,7 +2372,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (rc)
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
-        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
+        if ((err = snd_device_new(card, SNDRV_DEV_CARD, korg1212, &ops)) < 0) {
                 snd_korg1212_free(korg1212);
                 return err;
         }
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 56d4f94daea2..5bc7ec244e32 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -678,7 +678,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
 	if (err < 0)
 		goto errout;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
 		goto errout;
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index b9743d4fa1cc..ad750bcfb061 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1039,7 +1039,7 @@ static int snd_lx6464es_create(struct snd_card *card,
 	}
 	chip->irq = pci->irq;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0)
 		goto device_new_failed;
 
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 076c3ec000c0..6af776c91b50 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2664,7 +2664,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 		snd_printk(KERN_WARNING "can't allocate apm buffer\n");
 #endif
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_m3_free(chip);
 		return err;
 	}
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 9ab057bb9859..79f3b736664c 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1022,7 +1022,7 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
 	chip->chip_idx = idx;
 	chip->mgr = mgr;
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_mixart_chip_free(chip);
 		return err;
 	}
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index b7afd9c8dcd7..4bcf2e27250d 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1623,7 +1623,7 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
 
 	// pci_set_master(pci); /* needed? */
 	
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0)
 		goto __error;
 
 	*chip_ret = chip;
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 3880f6da9a87..042c35002459 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1233,7 +1233,7 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
 			chip->nb_streams_capt = 1;	/* or 1 stereo stream */
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		pcxhr_chip_free(chip);
 		return err;
 	}
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index b4a8278241b1..93c37643556e 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1911,7 +1911,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_riptide_free(chip);
 		return err;
 	}
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 6b26b93e001d..0ea1fa86e204 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1400,7 +1400,7 @@ static int sis_chip_create(struct snd_card *card,
 	voice->num = SIS_CAPTURE_CHAN_AC97_PCM_IN;
 	voice->ctrl_base = SIS_CAPTURE_DMA_ADDR(sis->ioaddr, voice->num);
 
-	rc = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sis, &ops);
+	rc = snd_device_new(card, SNDRV_DEV_CARD, sis, &ops);
 	if (rc)
 		goto error_out_cleanup;
 
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 9ff408fff7b0..5930bca1dca2 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1385,7 +1385,7 @@ static int snd_sonicvibes_create(struct snd_card *card,
 #endif
 	sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, sonic, &ops)) < 0) {
 		snd_sonicvibes_free(sonic);
 		return err;
 	}
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 4f3c4be30a48..3ffe84593ddc 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3638,7 +3638,7 @@ int snd_trident_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, trident, &ops)) < 0) {
 		snd_trident_free(trident);
 		return err;
 	}
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 20d2eeeecf47..c01f8b91254e 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2431,7 +2431,7 @@ static int snd_via82xx_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_via82xx_free(chip);
 		return err;
 	}
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 519740154824..9b43453e358f 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1151,7 +1151,7 @@ static int snd_via82xx_create(struct snd_card *card,
 		return err;
 	}
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_via82xx_free(chip);
 		return err;
 	}
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index 4323556c13f8..f070f0e4d282 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -176,7 +176,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
 	}
 	chip->irq = pci->irq;
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_vx222_free(chip);
 		return err;
 	}
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index c7e98ff4f80f..eef437d85df7 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2480,7 +2480,7 @@ int snd_ymfpci_create(struct snd_card *card,
 	}
 #endif
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_ymfpci_free(chip);
 		return err;
 	}
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 04/20] ALSA: isa: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (2 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 03/20] ALSA: pci: Use SNDRV_DEV_CARD for card objects Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 05/20] ALSA: drivers: " Takashi Iwai
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/isa/ad1816a/ad1816a_lib.c | 2 +-
 sound/isa/es1688/es1688_lib.c   | 2 +-
 sound/isa/es18xx.c              | 2 +-
 sound/isa/gus/gus_main.c        | 2 +-
 sound/isa/msnd/msnd_pinnacle.c  | 2 +-
 sound/isa/sb/sb_common.c        | 2 +-
 sound/isa/wss/wss_lib.c         | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index f0fd98e695e3..c51f8ed7e34f 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -645,7 +645,7 @@ int snd_ad1816a_create(struct snd_card *card,
 	snd_ad1816a_init(chip);
 
 	/* Register device */
-	if ((error = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((error = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_ad1816a_free(chip);
 		return error;
 	}
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index b3b4f15e45ba..9c9a544c7099 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -700,7 +700,7 @@ int snd_es1688_create(struct snd_card *card,
 		goto exit;
 
 	/* Register device */
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 exit:
 	if (err)
 		snd_es1688_free(chip);
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 1c16830af3d8..fab372543d1a 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1831,7 +1831,7 @@ static int snd_es18xx_new_device(struct snd_card *card,
 		snd_es18xx_free(card);
 		return -ENODEV;
 	}
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_es18xx_free(card);
 		return err;
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 4490ee442ff4..cf47edd254c4 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -220,7 +220,7 @@ int snd_gus_create(struct snd_card *card,
 	gus->gf1.pcm_channels = pcm_channels;
 	gus->gf1.volume_ramp = 25;
 	gus->gf1.smooth_pan = 1;
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, gus, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, gus, &ops)) < 0) {
 		snd_gus_free(gus);
 		return err;
 	}
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
index 5016bf957f51..78425fea9206 100644
--- a/sound/isa/msnd/msnd_pinnacle.c
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -578,7 +578,7 @@ static int snd_msnd_attach(struct snd_card *card)
 		goto err_release_region;
 
 	/* Register device */
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0)
 		goto err_release_region;
 
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 3ef990602cdd..bf4303de0252 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -285,7 +285,7 @@ int snd_sbdsp_create(struct snd_card *card,
 		snd_sbdsp_free(chip);
 		return err;
 	}
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_sbdsp_free(chip);
 		return err;
 	}
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 360b08b03e1d..fe40a7d884f0 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -1884,7 +1884,7 @@ int snd_wss_create(struct snd_card *card,
 #endif
 
 	/* Register device */
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_wss_free(chip);
 		return err;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 05/20] ALSA: drivers: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (3 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 04/20] ALSA: isa: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 06/20] ALSA: pcmcia: " Takashi Iwai
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/drivers/ml403-ac97cr.c  | 2 +-
 sound/drivers/pcsp/pcsp.c     | 2 +-
 sound/drivers/serial-u16550.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index 33ed76530d0b..8868910e8ddf 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -1185,7 +1185,7 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
 		return err;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ml403_ac97cr, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, ml403_ac97cr, &ops);
 	if (err < 0) {
 		PDEBUG(INIT_FAILURE, "probe(): snd_device_new() failed!\n");
 		snd_ml403_ac97cr_free(ml403_ac97cr);
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 36808cdab06f..c4493f4e63da 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -87,7 +87,7 @@ static int snd_pcsp_create(struct snd_card *card)
 	pcsp_chip.dma = -1;
 
 	/* Register device */
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, &pcsp_chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, &pcsp_chip, &ops);
 	if (err < 0)
 		return err;
 
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 9ad4414fa25c..b2822409ce12 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -836,7 +836,7 @@ static int snd_uart16550_create(struct snd_card *card,
 	uart->timer_running = 0;
 
 	/* Register device */
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, uart, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, uart, &ops)) < 0) {
 		snd_uart16550_free(uart);
 		return err;
 	}
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 06/20] ALSA: pcmcia: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (4 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 05/20] ALSA: drivers: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 07/20] ALSA: usb-audio: Use proper SNDRV_DEV_* type Takashi Iwai
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pcmcia/pdaudiocf/pdaudiocf.c | 2 +-
 sound/pcmcia/vx/vxpocket.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 56bda124cd4a..07e365de5c3c 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -125,7 +125,7 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
 		return -ENOMEM;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, pdacf, &ops);
 	if (err < 0) {
 		kfree(pdacf);
 		snd_card_free(card);
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 786e7e139c9e..e2db031deb2c 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -147,7 +147,7 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl,
 	if (!chip)
 		return -ENOMEM;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		kfree(chip);
 		return err;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 07/20] ALSA: usb-audio: Use proper SNDRV_DEV_* type
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (5 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 06/20] ALSA: pcmcia: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 08/20] ALSA: aoa: Use SNDRV_DEV_CODEC for AOA codec objects Takashi Iwai
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

Replace SNDRV_DEV_LOWLEVEL with more proper types, SNDRV_DEV_CARD for
the chip objects and SNDRV_DEV_CODEC for the mixer objects.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/card.c  | 2 +-
 sound/usb/mixer.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 0cfdc2d3b631..ee914a1166ed 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -384,7 +384,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
 	INIT_LIST_HEAD(&chip->midi_list);
 	INIT_LIST_HEAD(&chip->mixer_list);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0) {
 		snd_usb_audio_free(chip);
 		snd_card_free(card);
 		return err;
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index aa9bc19aae68..8c152b02da5a 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2373,7 +2373,7 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
 
 	snd_usb_mixer_apply_create_quirk(mixer);
 
-	err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops);
+	err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops);
 	if (err < 0)
 		goto _error;
 
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 08/20] ALSA: aoa: Use SNDRV_DEV_CODEC for AOA codec objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (6 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 07/20] ALSA: usb-audio: Use proper SNDRV_DEV_* type Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 09/20] ALSA: mips: Use SNDRV_DEV_CARD for card objects Takashi Iwai
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/aoa/codecs/onyx.c   | 2 +-
 sound/aoa/codecs/tas.c    | 2 +-
 sound/aoa/codecs/toonie.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 4cedc6950d72..f01bffb702bc 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -889,7 +889,7 @@ static int onyx_init_codec(struct aoa_codec *codec)
 		return -ENODEV;
 	}
 
-	if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, onyx, &ops)) {
+	if (aoa_snd_device_new(SNDRV_DEV_CODEC, onyx, &ops)) {
 		printk(KERN_ERR PFX "failed to create onyx snd device!\n");
 		return -ENODEV;
 	}
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index c491ae0f749c..cf3c6303b7e3 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -826,7 +826,7 @@ static int tas_init_codec(struct aoa_codec *codec)
 		return -ENODEV;
 	}
 
-	if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, tas, &ops)) {
+	if (aoa_snd_device_new(SNDRV_DEV_CODEC, tas, &ops)) {
 		printk(KERN_ERR PFX "failed to create tas snd device!\n");
 		return -ENODEV;
 	}
diff --git a/sound/aoa/codecs/toonie.c b/sound/aoa/codecs/toonie.c
index 69d2cb601f2a..7e8c3417cd85 100644
--- a/sound/aoa/codecs/toonie.c
+++ b/sound/aoa/codecs/toonie.c
@@ -92,7 +92,7 @@ static int toonie_init_codec(struct aoa_codec *codec)
 	if (toonie->codec.connected != 1)
 		return -ENOTCONN;
 
-	if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, toonie, &ops)) {
+	if (aoa_snd_device_new(SNDRV_DEV_CODEC, toonie, &ops)) {
 		printk(KERN_ERR PFX "failed to create toonie snd device!\n");
 		return -ENODEV;
 	}
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 09/20] ALSA: mips: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (7 preceding siblings ...)
  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 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 10/20] ALSA: parisc: " Takashi Iwai
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/mips/hal2.c       | 2 +-
 sound/mips/sgio2audio.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 23441b9e6148..beb08fc00d9e 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -864,7 +864,7 @@ static int hal2_create(struct snd_card *card, struct snd_hal2 **rchip)
 	hpc3->pbus_dmacfg[hal2->dac.pbus.pbusnr][0] = 0x8208844;
 	hpc3->pbus_dmacfg[hal2->adc.pbus.pbusnr][0] = 0x8208844;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, hal2, &hal2_ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, hal2, &hal2_ops);
 	if (err < 0) {
 		free_irq(SGI_HPCDMA_IRQ, hal2);
 		kfree(hal2);
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c
index 04bb06c03ec8..c87d2b7e61ca 100644
--- a/sound/mips/sgio2audio.c
+++ b/sound/mips/sgio2audio.c
@@ -905,7 +905,7 @@ static int snd_sgio2audio_create(struct snd_card *card,
 		return err;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_sgio2audio_free(chip);
 		return err;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 10/20] ALSA: parisc: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (8 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 09/20] ALSA: mips: Use SNDRV_DEV_CARD for card objects Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 11/20] ALSA: ppc: " Takashi Iwai
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/parisc/harmony.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index 4b20be79c1dd..8664bfc4185c 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -954,7 +954,7 @@ snd_harmony_create(struct snd_card *card,
 	spin_lock_init(&h->mixer_lock);
 	spin_lock_init(&h->lock);
 
-        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+        if ((err = snd_device_new(card, SNDRV_DEV_CARD,
                                   h, &ops)) < 0) {
                 goto free_and_ret;
         }
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 11/20] ALSA: ppc: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (9 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 10/20] ALSA: parisc: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 12/20] ALSA: sh: " Takashi Iwai
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/ppc/pmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 7a43c0c38316..2bb0d674cb59 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1343,7 +1343,7 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
 	/* Reset dbdma channels */
 	snd_pmac_dbdma_reset(chip);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops)) < 0)
 		goto __error;
 
 	*chip_return = chip;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 12/20] ALSA: sh: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (10 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 11/20] ALSA: ppc: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 13/20] ALSA: sparc: " Takashi Iwai
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/sh/sh_dac_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c
index d1fb74dabbd1..8ae769e62084 100644
--- a/sound/sh/sh_dac_audio.c
+++ b/sound/sh/sh_dac_audio.c
@@ -378,7 +378,7 @@ static int snd_sh_dac_create(struct snd_card *card,
 		return -ENOMEM;
 	}
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (err < 0) {
 		snd_sh_dac_free(chip);
 		return err;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 13/20] ALSA: sparc: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (11 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 12/20] ALSA: sh: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 14/20] ALSA: i2c/ak413x: Use SNDRV_DEV_CODEC for ak413x codec objects Takashi Iwai
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/sparc/amd7930.c | 2 +-
 sound/sparc/cs4231.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index 4a85e1433472..a543172cad60 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -992,7 +992,7 @@ static int snd_amd7930_create(struct snd_card *card,
 
 	spin_unlock_irqrestore(&amd->lock, flags);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 				  amd, &snd_amd7930_dev_ops)) < 0) {
 		snd_amd7930_free(amd);
 		return err;
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index dabc1ad331e2..72a4b53e4d33 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -1855,7 +1855,7 @@ static int snd_cs4231_sbus_create(struct snd_card *card,
 	}
 	snd_cs4231_init(chip);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 				  chip, &snd_cs4231_sbus_dev_ops)) < 0) {
 		snd_cs4231_sbus_free(chip);
 		return err;
@@ -2047,7 +2047,7 @@ static int snd_cs4231_ebus_create(struct snd_card *card,
 	}
 	snd_cs4231_init(chip);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
+	if ((err = snd_device_new(card, SNDRV_DEV_CARD,
 				  chip, &snd_cs4231_ebus_dev_ops)) < 0) {
 		snd_cs4231_ebus_free(chip);
 		return err;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 14/20] ALSA: i2c/ak413x: Use SNDRV_DEV_CODEC for ak413x codec objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (12 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 13/20] ALSA: sparc: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 15/20] ALSA: spi: Use SNDRV_DEV_CARD for card objects Takashi Iwai
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/i2c/other/ak4113.c | 2 +-
 sound/i2c/other/ak4114.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c
index e04e750a77ed..1a3a6fa27158 100644
--- a/sound/i2c/other/ak4113.c
+++ b/sound/i2c/other/ak4113.c
@@ -98,7 +98,7 @@ int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read,
 			AK4113_CINT | AK4113_STC);
 	chip->rcs1 = reg_read(chip, AK4113_REG_RCS1);
 	chip->rcs2 = reg_read(chip, AK4113_REG_RCS2);
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops);
 	if (err < 0)
 		goto __fail;
 
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 15ae0250eace..c7f56339415d 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -111,7 +111,7 @@ int snd_ak4114_create(struct snd_card *card,
 	chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
 	chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);
 
-	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
+	if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0)
 		goto __fail;
 
 	if (r_ak4114)
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 15/20] ALSA: spi: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (13 preceding siblings ...)
  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 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 16/20] HID: prodikeys: " Takashi Iwai
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/spi/at73c213.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 39522367897c..27564a08c759 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -919,7 +919,7 @@ static int snd_at73c213_dev_init(struct snd_card *card,
 	if (retval)
 		goto out_irq;
 
-	retval = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+	retval = snd_device_new(card, SNDRV_DEV_CARD, chip, &ops);
 	if (retval)
 		goto out_irq;
 
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 16/20] HID: prodikeys: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (14 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 15/20] ALSA: spi: Use SNDRV_DEV_CARD for card objects Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 17/20] staging: " Takashi Iwai
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/hid/hid-prodikeys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
index 91fab975063c..1085e7bbba3f 100644
--- a/drivers/hid/hid-prodikeys.c
+++ b/drivers/hid/hid-prodikeys.c
@@ -634,7 +634,7 @@ static int pcmidi_snd_initialise(struct pcmidi_snd *pm)
 	pm->card = card;
 
 	/* Setup sound device */
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pm, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, pm, &ops);
 	if (err < 0) {
 		pk_error("failed to create pc-midi sound device: error %d\n",
 			err);
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 17/20] staging: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (15 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 16/20] HID: prodikeys: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 18/20] usb: gadget: " Takashi Iwai
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/staging/media/go7007/snd-go7007.c      | 2 +-
 drivers/staging/media/solo6x10/solo6x10-g723.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/go7007/snd-go7007.c b/drivers/staging/media/go7007/snd-go7007.c
index 9eb2a20ae40a..32c5032284a3 100644
--- a/drivers/staging/media/go7007/snd-go7007.c
+++ b/drivers/staging/media/go7007/snd-go7007.c
@@ -251,7 +251,7 @@ int go7007_snd_init(struct go7007 *go)
 		kfree(gosnd);
 		return ret;
 	}
-	ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
+	ret = snd_device_new(gosnd->card, SNDRV_DEV_CARD, go,
 			&go7007_snd_device_ops);
 	if (ret < 0) {
 		kfree(gosnd);
diff --git a/drivers/staging/media/solo6x10/solo6x10-g723.c b/drivers/staging/media/solo6x10/solo6x10-g723.c
index 74f037b6166c..e825256a1f48 100644
--- a/drivers/staging/media/solo6x10/solo6x10-g723.c
+++ b/drivers/staging/media/solo6x10/solo6x10-g723.c
@@ -379,7 +379,7 @@ int solo_g723_init(struct solo_dev *solo_dev)
 	sprintf(card->longname, "%s on %s IRQ %d", card->shortname,
 		pci_name(solo_dev->pdev), solo_dev->pdev->irq);
 
-	ret = snd_device_new(card, SNDRV_DEV_LOWLEVEL, solo_dev, &ops);
+	ret = snd_device_new(card, SNDRV_DEV_CARD, solo_dev, &ops);
 	if (ret < 0)
 		goto snd_error;
 
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 18/20] usb: gadget: Use SNDRV_DEV_CARD for card objects
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (16 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 17/20] staging: " Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-12 10:52 ` [PATCH 19/20] ALSA: Use priority list for managing device list Takashi Iwai
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

... instead of SNDRV_DEV_LOWLEVEL.
No functional change at this point.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/usb/gadget/f_midi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c
index 807b31c0edc3..f7f79bb99c7e 100644
--- a/drivers/usb/gadget/f_midi.c
+++ b/drivers/usb/gadget/f_midi.c
@@ -672,7 +672,7 @@ static int f_midi_register_card(struct f_midi *midi)
 	}
 	midi->card = card;
 
-	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, midi, &ops);
+	err = snd_device_new(card, SNDRV_DEV_CARD, midi, &ops);
 	if (err < 0) {
 		ERROR(midi, "snd_device_new() failed: error %d\n", err);
 		goto fail;
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 19/20] ALSA: Use priority list for managing device list
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (17 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 18/20] usb: gadget: " Takashi Iwai
@ 2014-02-12 10:52 ` 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
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

Basically, the device type specifies the priority of the device to be
registered / freed, too.  However, the priority value isn't well
utilized but only it's checked as a group.  This results in
inconsistent register and free order (where each of them should be in
reversed direction).

This patch simplifies the device list management code by simply
inserting a list entry at creation time in an incremental order for
the priority value.  Since we can just follow the link for register,
disconnect and free calls, we don't have to specify the group; so the
whole enum definitions are also simplified as well.

The visible change to outside is that now the SNDRV_DEV_CARD object is
registered before others (control, PCM, etc) and, in return, released
after others.  The priority of some components
(e.g. SNDRV_DEV_COMPRESS) are also adjusted as well.

Also, the unused SNDRV_DEV_TOPLEVEL, SNDRV_DEV_LOWLEVEL_PRE and
SNDRV_DEV_LOWLEVEL_NORMAL are removed as a cleanup.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/core.h | 28 ++++++++--------------
 sound/core/device.c  | 66 +++++++++++++++++++++++++++++-----------------------
 sound/core/init.c    | 14 +++--------
 3 files changed, 50 insertions(+), 58 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index 127b908a2422..07a7ab9a49bf 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -46,25 +46,23 @@ struct device_attribute;
 
 /* device allocation stuff */
 
-#define SNDRV_DEV_TYPE_RANGE_SIZE		0x1000
-
+/* type of the object used in snd_device_*()
+ * this also defines the calling order
+ */
 enum snd_device_type {
-	SNDRV_DEV_TOPLEVEL	= 0,
-	SNDRV_DEV_CONTROL	= 1,
-	SNDRV_DEV_LOWLEVEL_PRE	= 2,
-	SNDRV_DEV_LOWLEVEL_NORMAL = 0x1000,
+	SNDRV_DEV_CARD,
+	SNDRV_DEV_BUS,
+	SNDRV_DEV_CODEC,
+	SNDRV_DEV_CONTROL,
 	SNDRV_DEV_PCM,
+	SNDRV_DEV_COMPRESS,
 	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,
-	SNDRV_DEV_CARD = SNDRV_DEV_LOWLEVEL,
+	SNDRV_DEV_LOWLEVEL,
 };
 
 enum snd_device_state {
@@ -73,12 +71,6 @@ enum snd_device_state {
 	SNDRV_DEV_DISCONNECTED,
 };
 
-enum snd_device_cmd {
-	SNDRV_DEV_CMD_PRE,
-	SNDRV_DEV_CMD_NORMAL,
-	SNDRV_DEV_CMD_POST,
-};
-
 struct snd_device;
 
 struct snd_device_ops {
@@ -321,7 +313,7 @@ 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, enum snd_device_cmd cmd);
+int snd_device_free_all(struct snd_card *card);
 
 /* isadma.c */
 
diff --git a/sound/core/device.c b/sound/core/device.c
index 6f734fe50296..b6f9d6702c69 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -45,6 +45,7 @@ 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;
+	struct list_head *p;
 
 	if (snd_BUG_ON(!card || !device_data || !ops))
 		return -ENXIO;
@@ -53,17 +54,36 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type,
 		snd_printk(KERN_ERR "Cannot allocate device\n");
 		return -ENOMEM;
 	}
+	INIT_LIST_HEAD(&dev->list);
 	dev->card = card;
 	dev->type = type;
 	dev->state = SNDRV_DEV_BUILD;
 	dev->device_data = device_data;
 	dev->ops = ops;
-	list_add(&dev->list, &card->devices);	/* add to the head of list */
+
+	/* insert the entry in an incrementally sorted list */
+	list_for_each_prev(p, &card->devices) {
+		struct snd_device *pdev = list_entry(p, struct snd_device, list);
+		if ((unsigned int)pdev->type <= (unsigned int)type)
+			break;
+	}
+
+	list_add(&dev->list, p);
 	return 0;
 }
-
 EXPORT_SYMBOL(snd_device_new);
 
+static struct snd_device *look_for_dev(struct snd_card *card, void *device_data)
+{
+	struct snd_device *dev;
+
+	list_for_each_entry(dev, &card->devices, list)
+		if (dev->device_data == device_data)
+			return dev;
+
+	return NULL;
+}
+
 /**
  * snd_device_free - release the device from the card
  * @card: the card instance
@@ -82,9 +102,8 @@ int snd_device_free(struct snd_card *card, void *device_data)
 	
 	if (snd_BUG_ON(!card || !device_data))
 		return -ENXIO;
-	list_for_each_entry(dev, &card->devices, list) {
-		if (dev->device_data != device_data)
-			continue;
+	dev = look_for_dev(card, device_data);
+	if (dev) {
 		/* unlink */
 		list_del(&dev->list);
 		if (dev->state == SNDRV_DEV_REGISTERED &&
@@ -103,7 +122,6 @@ int snd_device_free(struct snd_card *card, void *device_data)
 		   __builtin_return_address(0));
 	return -ENXIO;
 }
-
 EXPORT_SYMBOL(snd_device_free);
 
 /**
@@ -125,9 +143,8 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
 
 	if (snd_BUG_ON(!card || !device_data))
 		return -ENXIO;
-	list_for_each_entry(dev, &card->devices, list) {
-		if (dev->device_data != device_data)
-			continue;
+	dev = look_for_dev(card, device_data);
+	if (dev) {
 		if (dev->state == SNDRV_DEV_REGISTERED &&
 		    dev->ops->dev_disconnect) {
 			if (dev->ops->dev_disconnect(dev))
@@ -161,9 +178,8 @@ int snd_device_register(struct snd_card *card, void *device_data)
 
 	if (snd_BUG_ON(!card || !device_data))
 		return -ENXIO;
-	list_for_each_entry(dev, &card->devices, list) {
-		if (dev->device_data != device_data)
-			continue;
+	dev = look_for_dev(card, device_data);
+	if (dev) {
 		if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
 			if ((err = dev->ops->dev_register(dev)) < 0)
 				return err;
@@ -176,7 +192,6 @@ int snd_device_register(struct snd_card *card, void *device_data)
 	snd_BUG();
 	return -ENXIO;
 }
-
 EXPORT_SYMBOL(snd_device_register);
 
 /*
@@ -211,7 +226,7 @@ int snd_device_disconnect_all(struct snd_card *card)
 
 	if (snd_BUG_ON(!card))
 		return -ENXIO;
-	list_for_each_entry(dev, &card->devices, list) {
+	list_for_each_entry_reverse(dev, &card->devices, list) {
 		if (snd_device_disconnect(card, dev->device_data) < 0)
 			err = -ENXIO;
 	}
@@ -222,24 +237,17 @@ 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, enum snd_device_cmd cmd)
+int snd_device_free_all(struct snd_card *card)
 {
-	struct snd_device *dev;
-	int err;
-	unsigned int range_low, range_high, type;
+	struct snd_device *dev, *next;
+	int ret = 0;
 
 	if (snd_BUG_ON(!card))
 		return -ENXIO;
-	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 = (unsigned int)dev->type;
-		if (type >= range_low && type <= range_high) {
-			if ((err = snd_device_free(card, dev->device_data)) < 0)
-				return err;
-			goto __again;
-		}
+	list_for_each_entry_safe_reverse(dev, next, &card->devices, list) {
+		int err = snd_device_free(card, dev->device_data);
+		if (err < 0)
+			ret = err;
 	}
-	return 0;
+	return ret;
 }
diff --git a/sound/core/init.c b/sound/core/init.c
index f4d3ac633ff8..0115034914c9 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -248,7 +248,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
 	return 0;
 
       __error_ctl:
-	snd_device_free_all(card, SNDRV_DEV_CMD_PRE);
+	snd_device_free_all(card);
       __error:
 	kfree(card);
   	return err;
@@ -436,16 +436,8 @@ static int snd_card_do_free(struct snd_card *card)
 	if (snd_mixer_oss_notify_callback)
 		snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE);
 #endif
-	if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) {
-		snd_printk(KERN_ERR "unable to free all devices (pre)\n");
-		/* Fatal, but this situation should never occur */
-	}
-	if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) {
-		snd_printk(KERN_ERR "unable to free all devices (normal)\n");
-		/* Fatal, but this situation should never occur */
-	}
-	if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) {
-		snd_printk(KERN_ERR "unable to free all devices (post)\n");
+	if (snd_device_free_all(card) < 0) {
+		snd_printk(KERN_ERR "unable to free all devices\n");
 		/* Fatal, but this situation should never occur */
 	}
 	if (card->private_free)
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 20/20] ALSA: Clean up snd_device_*() codes
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (18 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 19/20] ALSA: Use priority list for managing device list Takashi Iwai
@ 2014-02-12 10:52 ` Takashi Iwai
  2014-02-14 11:59 ` [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-12 10:52 UTC (permalink / raw)
  To: alsa-devel

A few code cleanups and optimizations.  In addition, drop
snd_device_disconnect() that isn't used at all.

Another slight difference by this change is that now the device state
will become always SNDRV_DEV_REGISTERED no matter whether dev_register
ops is present or not.  It's for better consistency.  There should be
no impact for the current tree, as the state isn't checked.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/core.h |   1 -
 sound/core/device.c  | 104 +++++++++++++++++++++------------------------------
 2 files changed, 42 insertions(+), 63 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index 07a7ab9a49bf..fb05573215d3 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -310,7 +310,6 @@ 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);
diff --git a/sound/core/device.c b/sound/core/device.c
index b6f9d6702c69..d622bcd4ff53 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -73,6 +73,31 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type,
 }
 EXPORT_SYMBOL(snd_device_new);
 
+static int __snd_device_disconnect(struct snd_device *dev)
+{
+	if (dev->state == SNDRV_DEV_REGISTERED) {
+		if (dev->ops->dev_disconnect &&
+		    dev->ops->dev_disconnect(dev))
+			snd_printk(KERN_ERR "device disconnect failure\n");
+		dev->state = SNDRV_DEV_DISCONNECTED;
+	}
+	return 0;
+}
+
+static int __snd_device_free(struct snd_device *dev)
+{
+	/* unlink */
+	list_del(&dev->list);
+
+	__snd_device_disconnect(dev);
+	if (dev->ops->dev_free) {
+		if (dev->ops->dev_free(dev))
+			snd_printk(KERN_ERR "device free failure\n");
+	}
+	kfree(dev);
+	return 0;
+}
+
 static struct snd_device *look_for_dev(struct snd_card *card, void *device_data)
 {
 	struct snd_device *dev;
@@ -103,59 +128,25 @@ int snd_device_free(struct snd_card *card, void *device_data)
 	if (snd_BUG_ON(!card || !device_data))
 		return -ENXIO;
 	dev = look_for_dev(card, device_data);
-	if (dev) {
-		/* unlink */
-		list_del(&dev->list);
-		if (dev->state == SNDRV_DEV_REGISTERED &&
-		    dev->ops->dev_disconnect)
-			if (dev->ops->dev_disconnect(dev))
-				snd_printk(KERN_ERR
-					   "device disconnect failure\n");
-		if (dev->ops->dev_free) {
-			if (dev->ops->dev_free(dev))
-				snd_printk(KERN_ERR "device free failure\n");
-		}
-		kfree(dev);
-		return 0;
-	}
+	if (dev)
+		return __snd_device_free(dev);
 	snd_printd("device free %p (from %pF), not found\n", device_data,
 		   __builtin_return_address(0));
 	return -ENXIO;
 }
 EXPORT_SYMBOL(snd_device_free);
 
-/**
- * snd_device_disconnect - disconnect the device
- * @card: the card instance
- * @device_data: the data pointer to disconnect
- *
- * Turns the device into the disconnection state, invoking
- * dev_disconnect callback, if the device was already registered.
- *
- * Usually called from snd_card_disconnect().
- *
- * Return: Zero if successful, or a negative error code on failure or if the
- * device not found.
- */
-int snd_device_disconnect(struct snd_card *card, void *device_data)
+static int __snd_device_register(struct snd_device *dev)
 {
-	struct snd_device *dev;
-
-	if (snd_BUG_ON(!card || !device_data))
-		return -ENXIO;
-	dev = look_for_dev(card, device_data);
-	if (dev) {
-		if (dev->state == SNDRV_DEV_REGISTERED &&
-		    dev->ops->dev_disconnect) {
-			if (dev->ops->dev_disconnect(dev))
-				snd_printk(KERN_ERR "device disconnect failure\n");
-			dev->state = SNDRV_DEV_DISCONNECTED;
+	if (dev->state == SNDRV_DEV_BUILD) {
+		if (dev->ops->dev_register) {
+			int err = dev->ops->dev_register(dev);
+			if (err < 0)
+				return err;
 		}
-		return 0;
+		dev->state = SNDRV_DEV_REGISTERED;
 	}
-	snd_printd("device disconnect %p (from %pF), not found\n", device_data,
-		   __builtin_return_address(0));
-	return -ENXIO;
+	return 0;
 }
 
 /**
@@ -174,21 +165,12 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
 int snd_device_register(struct snd_card *card, void *device_data)
 {
 	struct snd_device *dev;
-	int err;
 
 	if (snd_BUG_ON(!card || !device_data))
 		return -ENXIO;
 	dev = look_for_dev(card, device_data);
-	if (dev) {
-		if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
-			if ((err = dev->ops->dev_register(dev)) < 0)
-				return err;
-			dev->state = SNDRV_DEV_REGISTERED;
-			return 0;
-		}
-		snd_printd("snd_device_register busy\n");
-		return -EBUSY;
-	}
+	if (dev)
+		return __snd_device_register(dev);
 	snd_BUG();
 	return -ENXIO;
 }
@@ -206,11 +188,9 @@ int snd_device_register_all(struct snd_card *card)
 	if (snd_BUG_ON(!card))
 		return -ENXIO;
 	list_for_each_entry(dev, &card->devices, list) {
-		if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
-			if ((err = dev->ops->dev_register(dev)) < 0)
-				return err;
-			dev->state = SNDRV_DEV_REGISTERED;
-		}
+		err = __snd_device_register(dev);
+		if (err < 0)
+			return err;
 	}
 	return 0;
 }
@@ -227,7 +207,7 @@ int snd_device_disconnect_all(struct snd_card *card)
 	if (snd_BUG_ON(!card))
 		return -ENXIO;
 	list_for_each_entry_reverse(dev, &card->devices, list) {
-		if (snd_device_disconnect(card, dev->device_data) < 0)
+		if (__snd_device_disconnect(dev) < 0)
 			err = -ENXIO;
 	}
 	return err;
@@ -245,7 +225,7 @@ int snd_device_free_all(struct snd_card *card)
 	if (snd_BUG_ON(!card))
 		return -ENXIO;
 	list_for_each_entry_safe_reverse(dev, next, &card->devices, list) {
-		int err = snd_device_free(card, dev->device_data);
+		int err = __snd_device_free(dev);
 		if (err < 0)
 			ret = err;
 	}
-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RFC 00/20] snd_device_* cleanups
  2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
                   ` (19 preceding siblings ...)
  2014-02-12 10:52 ` [PATCH 20/20] ALSA: Clean up snd_device_*() codes Takashi Iwai
@ 2014-02-14 11:59 ` Takashi Iwai
  20 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-02-14 11:59 UTC (permalink / raw)
  To: alsa-devel

At Wed, 12 Feb 2014 11:52:07 +0100,
Takashi Iwai wrote:
> 
> This batch is aimed for cleanups of snd_device_*() usages.
> The major change is to introduce SNDRV_DEV_CARD type and use it for
> the card-level object instead of SNDRV_DEV_LOWLEVEL.  The rest are
> simplification of snd_device_*() calls and management.

I'll postpone (or disregard) this series except for a couple of
patches that change from SNDRV_DEV_LOWLEVEL to SNDRV_DEV_CODEC.  They
have been merged to for-next branch.

The card-level objects can be better handled in card's private_free in
the end, as it seems...


Takashi

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-02-14 11:59 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 10:52 [PATCH RFC 00/20] snd_device_* cleanups Takashi Iwai
2014-02-12 10:52 ` [PATCH 01/20] ALSA: Drop __bitwise and typedefs for snd_device attributes Takashi Iwai
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.