From 4f9e0c38c5e991e2d050d13e28be74b93ab704c0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 16 Oct 2015 11:35:49 +0200 Subject: ALSA: hda - Add a common helper to give the codec modalias string This patch provide a new common helper function, snd_hdac_codec_modalias(), to give the codec modalias name string. This function will be used by multiple places in the later patches. Reviewed-by: Vinod Koul Tested-by: Subhransu S Prusty Signed-off-by: Takashi Iwai --- sound/hda/hdac_device.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sound/hda/hdac_device.c') diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 4b06b26cee06..bbdb25f5bbb9 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -185,6 +185,21 @@ int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name) } EXPORT_SYMBOL_GPL(snd_hdac_device_set_chip_name); +/** + * snd_hdac_codec_modalias - give the module alias name + * @codec: HDAC device + * @buf: string buffer to store + * @size: string buffer size + * + * Returns the size of string, like snprintf(), or a negative error code. + */ +int snd_hdac_codec_modalias(struct hdac_device *codec, char *buf, size_t size) +{ + return snprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n", + codec->vendor_id, codec->revision_id, codec->type); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_modalias); + /** * snd_hdac_make_cmd - compose a 32bit command word to be sent to the * HD-audio controller -- cgit v1.2.3