From patchwork Wed Feb 26 06:47:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 3721261 X-Patchwork-Delegate: tiwai@suse.de 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA0699F2F7 for ; Wed, 26 Feb 2014 06:49:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDE96201D3 for ; Wed, 26 Feb 2014 06:49:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9E29A20148 for ; Wed, 26 Feb 2014 06:49:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D3D45265792; Wed, 26 Feb 2014 07:49:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: 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 E56A62656C7; Wed, 26 Feb 2014 07:47:51 +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 BFFFE2656B9; Wed, 26 Feb 2014 07:47:48 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 28DFD265512 for ; Wed, 26 Feb 2014 07:47:38 +0100 (CET) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E753C75022 for ; Wed, 26 Feb 2014 06:47:37 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 26 Feb 2014 07:47:25 +0100 Message-Id: <1393397252-11690-4-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393397252-11690-1-git-send-email-tiwai@suse.de> References: <1393397252-11690-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH 03/10] ALSA: hwdep: Allow to assign the given parent 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 Just like PCM, allow hwdep to be assigned to a different parent device than the card. It'll be used for the HD-audio codec device in the later patches. Signed-off-by: Takashi Iwai --- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index 193a3c57ed25..ae04a3ec9c77 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -68,6 +68,7 @@ struct snd_hwdep { wait_queue_head_t open_wait; void *private_data; void (*private_free) (struct snd_hwdep *hwdep); + struct device *dev; const struct attribute_group **groups; struct mutex open_mutex; diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 825cd2847940..d6eb3ef3e3c7 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -416,6 +416,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; struct snd_card *card = hwdep->card; + struct device *dev; int err; char name[32]; @@ -426,10 +427,14 @@ static int snd_hwdep_dev_register(struct snd_device *device) } list_add_tail(&hwdep->list, &snd_hwdep_devices); sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, - hwdep->card, hwdep->device, - &snd_hwdep_f_ops, hwdep, name)) < 0) { - dev_err(card->dev, + dev = hwdep->dev; + if (!dev) + dev = snd_card_get_device_link(hwdep->card); + err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP, + hwdep->card, hwdep->device, + &snd_hwdep_f_ops, hwdep, name, dev); + if (err < 0) { + dev_err(dev, "unable to register hardware dependent device %i:%i\n", card->number, hwdep->device); list_del(&hwdep->list); @@ -445,7 +450,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) dev_set_drvdata(d, hwdep->private_data); err = sysfs_create_groups(&d->kobj, hwdep->groups); if (err < 0) - dev_warn(card->dev, + dev_warn(dev, "hwdep %d:%d: cannot create sysfs groups\n", card->number, hwdep->device); put_device(d); @@ -456,13 +461,13 @@ static int snd_hwdep_dev_register(struct snd_device *device) hwdep->ossreg = 0; if (hwdep->oss_type >= 0) { if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) { - dev_warn(card->dev, + dev_warn(dev, "only hwdep device 0 can be registered as OSS direct FM device!\n"); } else { if (snd_register_oss_device(hwdep->oss_type, card, hwdep->device, &snd_hwdep_f_ops, hwdep) < 0) { - dev_err(card->dev, + dev_err(dev, "unable to register OSS compatibility device %i:%i\n", card->number, hwdep->device); } else