From patchwork Mon Feb 2 10:24:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5760571 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 46CC59F302 for ; Mon, 2 Feb 2015 10:30:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 744D920154 for ; Mon, 2 Feb 2015 10:30:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4A76C2015E for ; Mon, 2 Feb 2015 10:30:39 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 822FB2614D6; Mon, 2 Feb 2015 11:30:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E17C426062D; Mon, 2 Feb 2015 11:25:06 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 40A8426060F; Mon, 2 Feb 2015 11:25:03 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 75FBD26050C for ; Mon, 2 Feb 2015 11:24:41 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AD342ACA9 for ; Mon, 2 Feb 2015 10:24:39 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Mon, 2 Feb 2015 11:24:27 +0100 Message-Id: <1422872678-4815-4-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422872678-4815-1-git-send-email-tiwai@suse.de> References: <1422872678-4815-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH 03/14] ALSA: Add a helper to initialize device X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new helper function snd_device_initialize() to initialize the device object for sound devices. Signed-off-by: Takashi Iwai --- include/sound/core.h | 2 ++ sound/core/init.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/sound/core.h b/include/sound/core.h index 39d14234961d..de7a878217d7 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -207,6 +207,8 @@ extern struct class *sound_class; void snd_request_card(int card); +void snd_device_initialize(struct device *dev, struct snd_card *card); + int snd_register_device_for_dev(int type, struct snd_card *card, int dev, const struct file_operations *f_ops, void *private_data, struct device *device, diff --git a/sound/core/init.c b/sound/core/init.c index 074875d68c15..2f730efe97b6 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -157,6 +157,25 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int), return mask; /* unchanged */ } +static void default_release(struct device *dev) +{ +} + +/** + * snd_device_initialize - Initialize struct device for sound devices + * @dev: device to initialize + * @card: card to assign, optional + */ +void snd_device_initialize(struct device *dev, struct snd_card *card) +{ + device_initialize(dev); + if (card) + dev->parent = &card->card_dev; + dev->class = sound_class; + dev->release = default_release; +} +EXPORT_SYMBOL_GPL(snd_device_initialize); + static int snd_card_do_free(struct snd_card *card); static const struct attribute_group *card_dev_attr_groups[];