From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Question about card names Date: Wed, 29 May 2019 07:29:08 +0200 Message-ID: References: <87y32px4vw.wl-kuninori.morimoto.gx@renesas.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 mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BCCE8F8072E for ; Wed, 29 May 2019 07:29:09 +0200 (CEST) In-Reply-To: <87y32px4vw.wl-kuninori.morimoto.gx@renesas.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Kuninori Morimoto Cc: Linux-ALSA List-Id: alsa-devel@alsa-project.org On Wed, 29 May 2019 06:41:35 +0200, Kuninori Morimoto wrote: > > > Hi ALSA ML > > snd_soc_instantiate_card() setups card->snd_card's > "shortname", "longname", "driver" names. (= 1,2,3). > > But, it cares only card->snd_card->driver (= 4). > I think we need to care about all naming, but why only driver ?? Do you mean the normalization of strings, or do you suggest to make mandatory? The normalization isn't needed for other name strings. The driver name is somewhat special, as it's used as a key for searches in the user-space. > static int snd_soc_instantiate_card(struct snd_soc_card *card) > { > ... > 1=> snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), > "%s", card->name); > 2=> snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), > "%s", card->long_name ? card->long_name : card->name); > 3=> 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++) { > switch (card->snd_card->driver[i]) { > x=> case '_': > x=> case '-': > case '\0': > break; > default: > if (!isalnum(card->snd_card->driver[i])) > 4=> card->snd_card->driver[i] = '_'; > break; > } > } > ... > } > > And, it seems in this loop, it breaks check if it finds "_" or "-" (= x). > If my understanding was correct, > the naming "abcd??efg" will be fixed to "abcd__efg", > but, it do nothing if name was for example "-abcd??efg". We do replace the two '?' in the latter case, too. It's a break statement in a switch block, i.e. just skip the case. Takashi