From patchwork Fri May 1 03:10:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jie, Yang" X-Patchwork-Id: 6307961 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 509E49F373 for ; Fri, 1 May 2015 03:08:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A7DE2013A for ; Fri, 1 May 2015 03:08:42 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D3E66201EF for ; Fri, 1 May 2015 03:08:40 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0559526049E; Fri, 1 May 2015 05:08:39 +0200 (CEST) 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 3DEB6260452; Fri, 1 May 2015 05:08:14 +0200 (CEST) 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 14AA1260447; Fri, 1 May 2015 05:08:12 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id E06092605E5 for ; Fri, 1 May 2015 05:06:56 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 30 Apr 2015 20:06:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,348,1427785200"; d="scan'208";a="703638838" Received: from keyon-u1310.sh.intel.com ([10.239.13.15]) by fmsmga001.fm.intel.com with ESMTP; 30 Apr 2015 20:06:54 -0700 From: Jie Yang To: tiwai@suse.de Date: Fri, 1 May 2015 11:10:29 +0800 Message-Id: <1430449829-10568-1-git-send-email-yang.jie@intel.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, broonie@kernel.org, liam.r.girdwood@intel.com Subject: [alsa-devel] [PATCH] ALSA: jack: fix a randconfig build issue 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 There may be no input_dev for jack(e.g. phantom jack), when CONFIG_INPUT is not selected, building errors such as: undefined reference to `input_xxx'... Here add #ifdef judgement to fix the issue. Signed-off-by: Jie Yang --- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/sound/jack.h b/include/sound/jack.h index 23bede1..c1010f9 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -72,7 +72,9 @@ enum snd_jack_types { #define SND_JACK_SWITCH_TYPES 6 struct snd_jack { +#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list; struct snd_card *card; int registered; diff --git a/sound/core/jack.c b/sound/core/jack.c index eb66327..3a1901e 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -32,6 +32,7 @@ struct snd_jack_kctl { unsigned int mask_bits; /* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { SW_HEADPHONE_INSERT, SW_MICROPHONE_INSERT, @@ -40,9 +41,11 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { SW_VIDEOOUT_INSERT, SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect(struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data; if (!jack->input_dev) @@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(struct snd_device *device) input_unregister_device(jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev = NULL; +#endif return 0; } @@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct snd_device *device) { struct snd_jack *jack = device->device_data; struct snd_card *card = device->card; - int err, i; + int err = 0; snprintf(jack->name, sizeof(jack->name), "%s %s", card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev) return 0; @@ -98,7 +104,7 @@ static int snd_jack_dev_register(struct snd_device *device) jack->input_dev->dev.parent = snd_card_get_device_link(card); /* Add capabilities for any keys that are enabled */ - for (i = 0; i < ARRAY_SIZE(jack->key); i++) { + for (int i = 0; i < ARRAY_SIZE(jack->key); i++) { int testbit = SND_JACK_BTN_0 >> i; if (!(jack->type & testbit)) @@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct snd_device *device) err = input_register_device(jack->input_dev); if (err == 0) jack->registered = 1; +#endif return err; } @@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, struct snd_jack *jack; struct snd_jack_kctl *jack_kctl = NULL; int err; - int i; static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, @@ -230,26 +236,31 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, /* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev = input_allocate_device(); if (jack->input_dev == NULL) { err = -ENOMEM; - goto fail_input; + goto error; } jack->input_dev->phys = "ALSA"; - jack->type = type; - - for (i = 0; i < SND_JACK_SWITCH_TYPES; i++) + for (int i = 0; i < SND_JACK_SWITCH_TYPES; i++) if (type & (1 << i)) input_set_capability(jack->input_dev, EV_SW, jack_switch_types[i]); +#endif + jack->type = type; } err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); - if (err < 0) - goto fail_input; + if (err < 0) { +#ifdef CONFIG_INPUT + input_free_device(jack->input_dev); +#endif + goto error; + } jack->card = card; INIT_LIST_HEAD(&jack->kctl_list); @@ -261,8 +272,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, return 0; -fail_input: - input_free_device(jack->input_dev); +error: kfree(jack->id); kfree(jack); return err; @@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new); */ void snd_jack_set_parent(struct snd_jack *jack, struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON(jack->registered); if (!jack->input_dev) return; jack->input_dev->dev.parent = parent; +#endif } EXPORT_SYMBOL(snd_jack_set_parent); @@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key); void snd_jack_report(struct snd_jack *jack, int status) { struct snd_jack_kctl *jack_kctl; - int i; if (!jack) return; @@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack, int status) snd_kctl_jack_report(jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev) return; - for (i = 0; i < ARRAY_SIZE(jack->key); i++) { + for (int i = 0; i < ARRAY_SIZE(jack->key); i++) { int testbit = SND_JACK_BTN_0 >> i; if (jack->type & testbit) @@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack, int status) } input_sync(jack->input_dev); - +#endif } EXPORT_SYMBOL(snd_jack_report);