[alsa-devel] [RFC 02/11] ALSA: hda - Add generic helper function to register/unregister driver

Takashi Iwai tiwai at suse.de
Mon Apr 13 13:50:18 CEST 2015


At Sun, 12 Apr 2015 18:06:09 +0530,
Subhransu S. Prusty wrote:
> 
> From: Jeeja KP <jeeja.kp at intel.com>
> 
> ASOC HD codec drivers will use the generic functions
> to register/unregister driver
> 
> Signed-off-by: Jeeja KP <jeeja.kp at intel.com>
> Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty at intel.com>
> Signed-off-by: Vinod Koul <vinod.koul at intel.com>
> ---
>  include/sound/hdaudio.h |  3 +++
>  sound/hda/hdac_bus.c    | 21 +++++++++++++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index 3628a09..b63cd03 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -153,6 +153,9 @@ struct hdac_driver {
>  
>  #define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver)
>  
> +int snd_hdac_driver_register(struct hdac_driver *drv);
> +void snd_hdac_driver_unregister(struct hdac_driver *drv);
> +
>  /*
>   * HD-audio bus base driver
>   */
> diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c
> index f0ee295..4ecb4ec 100644
> --- a/sound/hda/hdac_bus.c
> +++ b/sound/hda/hdac_bus.c
> @@ -219,3 +219,24 @@ int snd_hdac_bus_match_id(struct hdac_device *dev,
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(snd_hdac_bus_match_id);
> +
> +/**
> + * snd_hdac_driver_register - register a driver for hda devices
> + * @drv: hdac driver structure
> + */
> +int snd_hdac_driver_register(struct hdac_driver *drv)
> +{
> +	drv->driver.bus = &snd_hda_bus_type;
> +	return driver_register(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(snd_hdac_driver_register);
> +
> +/**
> + * snd_hdac_driver_unregister - unregister a driver for hda devices
> + * @drv: hdac driver structure
> + */
> +void snd_hdac_driver_unregister(struct hdac_driver *drv)
> +{
> +	driver_unregister(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(snd_hdac_driver_unregister);

Hrm, I see no big merits to wrap such a single function call.
Once when struct hdac_driver itself is embedded, another redirection
is needed.


thanks,

Takashi


More information about the Alsa-devel mailing list