Skip to content

Commit a41d122

Browse files
committed
ALSA: hda - Embed bus into controller object
... and replace with the existing hda-core helper codes. This reduces lots of lines, finally. Since struct hda_bus is now embedded into struct azx, snd_hda_bus_new() is moved and expanded from hda_codec.c to hda_controller.c, accordingly. Also private_free bus ops and private_data field are removed because we no longer need to point azx object from bus (we can use container_of()) The spin locks are consolidated into the single one, bus->reg_lock. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ccc9886 commit a41d122

7 files changed

Lines changed: 232 additions & 646 deletions

File tree

‎sound/pci/hda/hda_codec.c‎

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -481,78 +481,6 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
481481
return devices;
482482
}
483483

484-
/*
485-
* destructor
486-
*/
487-
static void snd_hda_bus_free(struct hda_bus *bus)
488-
{
489-
if (!bus)
490-
return;
491-
if (bus->ops.private_free)
492-
bus->ops.private_free(bus);
493-
snd_hdac_bus_exit(&bus->core);
494-
kfree(bus);
495-
}
496-
497-
static int snd_hda_bus_dev_free(struct snd_device *device)
498-
{
499-
snd_hda_bus_free(device->device_data);
500-
return 0;
501-
}
502-
503-
static int snd_hda_bus_dev_disconnect(struct snd_device *device)
504-
{
505-
struct hda_bus *bus = device->device_data;
506-
bus->shutdown = 1;
507-
return 0;
508-
}
509-
510-
/**
511-
* snd_hda_bus_new - create a HDA bus
512-
* @card: the card entry
513-
* @busp: the pointer to store the created bus instance
514-
*
515-
* Returns 0 if successful, or a negative error code.
516-
*/
517-
int snd_hda_bus_new(struct snd_card *card,
518-
const struct hdac_bus_ops *ops,
519-
const struct hdac_io_ops *io_ops,
520-
struct hda_bus **busp)
521-
{
522-
struct hda_bus *bus;
523-
int err;
524-
static struct snd_device_ops dev_ops = {
525-
.dev_disconnect = snd_hda_bus_dev_disconnect,
526-
.dev_free = snd_hda_bus_dev_free,
527-
};
528-
529-
if (busp)
530-
*busp = NULL;
531-
532-
bus = kzalloc(sizeof(*bus), GFP_KERNEL);
533-
if (!bus)
534-
return -ENOMEM;
535-
536-
err = snd_hdac_bus_init(&bus->core, card->dev, ops, io_ops);
537-
if (err < 0) {
538-
kfree(bus);
539-
return err;
540-
}
541-
542-
bus->card = card;
543-
mutex_init(&bus->prepare_mutex);
544-
545-
err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
546-
if (err < 0) {
547-
snd_hda_bus_free(bus);
548-
return err;
549-
}
550-
if (busp)
551-
*busp = bus;
552-
return 0;
553-
}
554-
EXPORT_SYMBOL_GPL(snd_hda_bus_new);
555-
556484
/*
557485
* read widget caps for each widget and store in cache
558486
*/

‎sound/pci/hda/hda_codec.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ struct hda_pcm_stream;
4242

4343
/* bus operators */
4444
struct hda_bus_ops {
45-
/* free the private data */
46-
void (*private_free)(struct hda_bus *);
4745
/* attach a PCM stream */
4846
int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec,
4947
struct hda_pcm *pcm);
@@ -73,7 +71,6 @@ struct hda_bus {
7371

7472
struct snd_card *card;
7573

76-
void *private_data;
7774
struct pci_dev *pci;
7875
const char *modelname;
7976
struct hda_bus_ops ops;

0 commit comments

Comments
 (0)