From: Takashi Iwai Subject: Re: [PATCH] ASoC: Ensure we generate a driver name Date: Tue, 20 Sep 2011 15:11:08 +0200 Message-ID: References: <1316523514-21967-1-git-send-email-broonie@opensource.wolfsonmicro.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 8668F1039E5 for ; Tue, 20 Sep 2011 15:11:09 +0200 (CEST) In-Reply-To: <1316523514-21967-1-git-send-email-broonie@opensource.wolfsonmicro.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, Liam Girdwood List-Id: alsa-devel@alsa-project.org At Tue, 20 Sep 2011 13:58:34 +0100, Mark Brown wrote: > > Commit 873bd4c (ASoC: Don't set invalid name string to snd_card->driver > field) broke generation of a driver name for all ASoC cards relying on the > automatic generation of one. Fix this by using the old default with spaces > replaced by underscores. > > Signed-off-by: Mark Brown > --- > sound/soc/soc-core.c | 17 ++++++++++++++--- > 1 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c > index 10e5cde..3096c0d 100644 > --- a/sound/soc/soc-core.c > +++ b/sound/soc/soc-core.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1432,9 +1433,19 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) > "%s", card->name); > snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), > "%s", card->long_name ? card->long_name : card->name); > - if (card->driver_name) > - strlcpy(card->snd_card->driver, card->driver_name, > - sizeof(card->snd_card->driver)); > + snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), > + "%s", card->driver_name ? card->driver_name : card->name); > + for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) { Should check card->snd_card->driver[i] != 0 here, too. thanks, Takashi > + switch (card->snd_card->driver[i]) { > + case '_': > + case '-': > + break; > + default: > + if (!isalnum(card->snd_card->driver[i])) > + card->snd_card->driver[i] = '_'; > + break; > + } > + } > > if (card->late_probe) { > ret = card->late_probe(card); > -- > 1.7.6.3 >