One less redirection.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
return 0;
}
-/* hdac_bus_ops translations */
-static int _hda_bus_command(struct hdac_bus *_bus, unsigned int cmd)
-{
- struct hda_bus *bus = container_of(_bus, struct hda_bus, core);
- return bus->ops.command(bus, cmd);
-}
-
-static int _hda_bus_get_response(struct hdac_bus *_bus, unsigned int addr,
- unsigned int *res)
-{
- struct hda_bus *bus = container_of(_bus, struct hda_bus, core);
- return bus->ops.get_response(bus, addr, res);
-}
-
-static const struct hdac_bus_ops bus_ops = {
- .command = _hda_bus_command,
- .get_response = _hda_bus_get_response,
-};
-
/**
* snd_hda_bus_new - create a HDA bus
* @card: the card entry
* Returns 0 if successful, or a negative error code.
*/
int snd_hda_bus_new(struct snd_card *card,
+ const struct hdac_bus_ops *ops,
struct hda_bus **busp)
{
struct hda_bus *bus;
if (!bus)
return -ENOMEM;
- err = snd_hdac_bus_init(&bus->core, card->dev, &bus_ops, NULL);
+ err = snd_hdac_bus_init(&bus->core, card->dev, ops, NULL);
if (err < 0) {
kfree(bus);
return err;
/* bus operators */
struct hda_bus_ops {
- /* send a single command */
- int (*command)(struct hda_bus *bus, unsigned int cmd);
- /* get a response from the last command */
- int (*get_response)(struct hda_bus *bus, unsigned int addr, unsigned int *res);
/* free the private data */
void (*private_free)(struct hda_bus *);
/* attach a PCM stream */
int primary_dig_out_type; /* primary digital out PCM type */
};
+/* from hdac_bus to hda_bus */
+#define to_hda_bus(bus) container_of(bus, struct hda_bus, core)
+
/*
* codec preset
*
/*
* constructors
*/
-int snd_hda_bus_new(struct snd_card *card, struct hda_bus **busp);
+int snd_hda_bus_new(struct snd_card *card,
+ const struct hdac_bus_ops *ops,
+ struct hda_bus **busp);
int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
unsigned int codec_addr, struct hda_codec **codecp);
int snd_hda_codec_configure(struct hda_codec *codec);
*/
/* send a command */
-static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
+static int azx_send_cmd(struct hdac_bus *_bus, unsigned int val)
{
+ struct hda_bus *bus = to_hda_bus(_bus);
struct azx *chip = bus->private_data;
if (chip->disabled)
}
/* get a response */
-static int azx_get_response(struct hda_bus *bus, unsigned int addr,
+static int azx_get_response(struct hdac_bus *_bus, unsigned int addr,
unsigned int *res)
{
+ struct hda_bus *bus = to_hda_bus(_bus);
struct azx *chip = bus->private_data;
if (chip->disabled)
return 0;
return azx_rirb_get_response(bus, addr, res);
}
+static const struct hdac_bus_ops bus_core_ops = {
+ .command = azx_send_cmd,
+ .get_response = azx_get_response,
+};
+
#ifdef CONFIG_SND_HDA_DSP_LOADER
/*
* DSP loading code (e.g. for CA0132)
{
unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
+ struct hdac_bus *bus = &chip->bus->core;
int err;
unsigned int res;
- mutex_lock(&chip->bus->core.cmd_mutex);
+ mutex_lock(&bus->cmd_mutex);
chip->probing = 1;
- azx_send_cmd(chip->bus, cmd);
- err = azx_get_response(chip->bus, addr, &res);
+ azx_send_cmd(bus, cmd);
+ err = azx_get_response(bus, addr, &res);
chip->probing = 0;
- mutex_unlock(&chip->bus->core.cmd_mutex);
+ mutex_unlock(&bus->cmd_mutex);
if (err < 0 || res == -1)
return -EIO;
dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
}
static struct hda_bus_ops bus_ops = {
- .command = azx_send_cmd,
- .get_response = azx_get_response,
.attach_pcm = azx_attach_pcm_stream,
.bus_reset = azx_bus_reset,
#ifdef CONFIG_SND_HDA_DSP_LOADER
struct hda_bus *bus;
int err;
- err = snd_hda_bus_new(chip->card, &bus);
+ err = snd_hda_bus_new(chip->card, &bus_core_ops, &bus);
if (err < 0)
return err;