From patchwork Thu Jun 4 08:13:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 6544691 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 150089F326 for ; Thu, 4 Jun 2015 08:14:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39EF720752 for ; Thu, 4 Jun 2015 08:14:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C8FA12074E for ; Thu, 4 Jun 2015 08:14:29 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D42282606D6; Thu, 4 Jun 2015 10:14:28 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5084C26065C; Thu, 4 Jun 2015 10:14:20 +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 A1DB326067B; Thu, 4 Jun 2015 10:14:18 +0200 (CEST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177]) by alsa0.perex.cz (Postfix) with ESMTP id D1DE42605C0 for ; Thu, 4 Jun 2015 10:14:12 +0200 (CEST) Received: by lbcmx3 with SMTP id mx3so22349095lbc.1 for ; Thu, 04 Jun 2015 01:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=s0VuGMKMvA6v3Ky/Xr/TbCzFhHLhXbXyVMfHaBhnVHQ=; b=QKHen0YL3zXB6zzAhXznziry/4+H1JFLy5ukcl0JsG8WAcuCvk9++aT7qFF3amuJwj UD6A53uca3H37pT+V2z+F7uImN20QbJvPIsHZt5LryeIbpGk5yh2l6gBEYVZJiUpXasJ 8BJbcLLi+6e2Y785twR0opGo+0n3lQ3dT8g7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=s0VuGMKMvA6v3Ky/Xr/TbCzFhHLhXbXyVMfHaBhnVHQ=; b=mlRAIKiHFZF1syNkGECkQHx9y1f0V8U3L24iwkX2UmOQghZJFbdktT1fLPZZyHXUhS eIsWiN2vFo4yA1NdDzMVQbcSrtl0cJ3u9TE4FxixH6virC4b2cu6CuJgpC8aLNhS4SC4 K+xIjEifoPT9K6zEup3Etm8kkVXG2sKI2jbIiOJjL5tTZ9vT/RA8F0q22IHNXk0w+ENS C/bqfUV46twJF7VCqSpwzledBUupv19I7Y3HVeXoqrRstUcYNiGk5HRbMPoC/QLKeBag 8VvTwCXsVVB/M+W4YH5lYTo0L+m7O1q17py2fjnvzdY4ReY7DvD3rS7kUpdi8Tgbu+G4 Mpzg== X-Gm-Message-State: ALoCoQk77kBfyz9JBMESeUaE8QHt62QiG3Q+ROjXp+DKRCwSvWn4d5Uk3DjhD1gx+WYlAE9DoDfJ X-Received: by 10.112.28.74 with SMTP id z10mr17964850lbg.48.1433405652393; Thu, 04 Jun 2015 01:14:12 -0700 (PDT) Received: from spencer.imf.au.dk ([130.225.20.51]) by mx.google.com with ESMTPSA id fj10sm473681lbc.29.2015.06.04.01.14.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 01:14:11 -0700 (PDT) From: Rasmus Villemoes To: Vinod Koul , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Date: Thu, 4 Jun 2015 10:13:53 +0200 Message-Id: <1433405633-18656-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 Cc: alsa-devel@alsa-project.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: Intel: mrfld: simplify sst_fill_widget_module_info 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 Some tiny improvements, cutting 180 bytes off the generated code. - use strchr() for single-character needle - compute index using pointer subtraction instead of two strlen() calls - factor out the common check for whether the initial part of kctl->id.name (before the space) is identical to w->name. Signed-off-by: Rasmus Villemoes Acked-by: Vinod Koul --- sound/soc/intel/atom/sst-atom-controls.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 90aa5c0476f3..16670feeee6a 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1280,36 +1280,32 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, down_read(&card->controls_rwsem); list_for_each_entry(kctl, &card->controls, list) { - idx = strstr(kctl->id.name, " "); + idx = strchr(kctl->id.name, ' '); if (idx == NULL) continue; - index = strlen(kctl->id.name) - strlen(idx); + index = idx - (char*)kctl->id.name; + if (strncmp(kctl->id.name, w->name, index)) + continue; - if (strstr(kctl->id.name, "Volume") && - !strncmp(kctl->id.name, w->name, index)) + if (strstr(kctl->id.name, "Volume")) ret = sst_fill_module_list(kctl, w, SST_MODULE_GAIN); - else if (strstr(kctl->id.name, "params") && - !strncmp(kctl->id.name, w->name, index)) + else if (strstr(kctl->id.name, "params")) ret = sst_fill_module_list(kctl, w, SST_MODULE_ALGO); else if (strstr(kctl->id.name, "Switch") && - !strncmp(kctl->id.name, w->name, index) && strstr(kctl->id.name, "Gain")) { struct sst_gain_mixer_control *mc = (void *)kctl->private_value; mc->w = w; - } else if (strstr(kctl->id.name, "interleaver") && - !strncmp(kctl->id.name, w->name, index)) { + } else if (strstr(kctl->id.name, "interleaver")) { struct sst_enum *e = (void *)kctl->private_value; e->w = w; - } else if (strstr(kctl->id.name, "deinterleaver") && - !strncmp(kctl->id.name, w->name, index)) { - + } else if (strstr(kctl->id.name, "deinterleaver")) { struct sst_enum *e = (void *)kctl->private_value; e->w = w;