Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a41d1224 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

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: default avatarTakashi Iwai <tiwai@suse.de>
parent ccc98865
Loading
Loading
Loading
Loading
+0 −72
Original line number Diff line number Diff line
@@ -481,78 +481,6 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
	return devices;
}

/*
 * destructor
 */
static void snd_hda_bus_free(struct hda_bus *bus)
{
	if (!bus)
		return;
	if (bus->ops.private_free)
		bus->ops.private_free(bus);
	snd_hdac_bus_exit(&bus->core);
	kfree(bus);
}

static int snd_hda_bus_dev_free(struct snd_device *device)
{
	snd_hda_bus_free(device->device_data);
	return 0;
}

static int snd_hda_bus_dev_disconnect(struct snd_device *device)
{
	struct hda_bus *bus = device->device_data;
	bus->shutdown = 1;
	return 0;
}

/**
 * snd_hda_bus_new - create a HDA bus
 * @card: the card entry
 * @busp: the pointer to store the created bus instance
 *
 * Returns 0 if successful, or a negative error code.
 */
int snd_hda_bus_new(struct snd_card *card,
		    const struct hdac_bus_ops *ops,
		    const struct hdac_io_ops *io_ops,
		    struct hda_bus **busp)
{
	struct hda_bus *bus;
	int err;
	static struct snd_device_ops dev_ops = {
		.dev_disconnect = snd_hda_bus_dev_disconnect,
		.dev_free = snd_hda_bus_dev_free,
	};

	if (busp)
		*busp = NULL;

	bus = kzalloc(sizeof(*bus), GFP_KERNEL);
	if (!bus)
		return -ENOMEM;

	err = snd_hdac_bus_init(&bus->core, card->dev, ops, io_ops);
	if (err < 0) {
		kfree(bus);
		return err;
	}

	bus->card = card;
	mutex_init(&bus->prepare_mutex);

	err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
	if (err < 0) {
		snd_hda_bus_free(bus);
		return err;
	}
	if (busp)
		*busp = bus;
	return 0;
}
EXPORT_SYMBOL_GPL(snd_hda_bus_new);

/*
 * read widget caps for each widget and store in cache
 */
+0 −3
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ struct hda_pcm_stream;

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

	struct snd_card *card;

	void *private_data;
	struct pci_dev *pci;
	const char *modelname;
	struct hda_bus_ops ops;
Loading