From patchwork Wed Aug 12 03:07:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 6995391 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 8DA779F344 for ; Wed, 12 Aug 2015 03:08:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A6C6203AD for ; Wed, 12 Aug 2015 03:08:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 589C820270 for ; Wed, 12 Aug 2015 03:08:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id AAAEB26062F; Wed, 12 Aug 2015 05:08:10 +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=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 8944F2605D8; Wed, 12 Aug 2015 05:08:01 +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 193072605DD; Wed, 12 Aug 2015 05:08:01 +0200 (CEST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by alsa0.perex.cz (Postfix) with ESMTP id DA8822605D3 for ; Wed, 12 Aug 2015 05:07:53 +0200 (CEST) Received: by pabyb7 with SMTP id yb7so4216363pab.0 for ; Tue, 11 Aug 2015 20:07:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=MNHnWZ6H5W/jZTrHqbBmM+AJDseY0OlbmTd9be3c5kA=; b=hHbKvd5jSTCFlc/rk9foW5iZ4p2WUf+ui/koC2bUQjgGowAxbJo9ofcX1if6teBFd1 K9XRCMq8IcdJIijpUEdgh2s05FCIoXB4775sMiW+CP62yW5oo8w0/6qb4iAbHrhXgAQR aTX2WHzRoYARupTrDkBtC5k21jcih3zKU70pvRaeZ+hoBQT6fj8Sha2J1yzLL2e+EdF7 zI56xAm67dXyzembhSPbYN86Qdlikh7l7Ts9ZIJH6GvkKnFoaJwgVL2FI9c9D8RPkKaI W9MogdbdFAKMAWUXZM2ZqBfmTX+1wnwgFa4LdPVdYdhKbfwDl8SAMi4aBs6gwY72/FNe OkKg== X-Gm-Message-State: ALoCoQl+M0OW6gKZZh45qf15ADrcu2A8wQfTVz34vipgzsX1b71AuLVnIroSR0pleoWxC7K7GdOF X-Received: by 10.66.184.9 with SMTP id eq9mr49884779pac.103.1439348871891; Tue, 11 Aug 2015 20:07:51 -0700 (PDT) Received: from phoenix (59-115-240-142.dynamic.hinet.net. [59.115.240.142]) by smtp.gmail.com with ESMTPSA id bd5sm4382255pdb.41.2015.08.11.20.07.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Aug 2015 20:07:51 -0700 (PDT) Message-ID: <1439348866.3594.2.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Wed, 12 Aug 2015 11:07:46 +0800 X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Cc: Brian Austin , alsa-devel@alsa-project.org, Liam Girdwood , Paul Handrigan Subject: [alsa-devel] [PATCH 1/4] ASoC: cs35l32: Use case range at appropriate places 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Use case range syntax makes the code shorter with better readability when we have a large number of continuous switch cases. Below are the summary of readable/volatile/precious registers. The readable registers: 0x01 ~ 0x0D, 0x0F ~ 0x1C The volatile registers: 0x01 ~ 0x05, 0x15 ~ 0x18 The precious registers: 0x15 ~ 0x18 No functional change with this patch. Signed-off-by: Axel Lin --- sound/soc/codecs/cs35l32.c | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c index 203c720..44c30fe 100644 --- a/sound/soc/codecs/cs35l32.c +++ b/sound/soc/codecs/cs35l32.c @@ -74,33 +74,8 @@ static const struct reg_default cs35l32_reg_defaults[] = { static bool cs35l32_readable_register(struct device *dev, unsigned int reg) { switch (reg) { - case CS35L32_DEVID_AB: - case CS35L32_DEVID_CD: - case CS35L32_DEVID_E: - case CS35L32_FAB_ID: - case CS35L32_REV_ID: - case CS35L32_PWRCTL1: - case CS35L32_PWRCTL2: - case CS35L32_CLK_CTL: - case CS35L32_BATT_THRESHOLD: - case CS35L32_VMON: - case CS35L32_BST_CPCP_CTL: - case CS35L32_IMON_SCALING: - case CS35L32_AUDIO_LED_MNGR: - case CS35L32_ADSP_CTL: - case CS35L32_CLASSD_CTL: - case CS35L32_PROTECT_CTL: - case CS35L32_INT_MASK_1: - case CS35L32_INT_MASK_2: - case CS35L32_INT_MASK_3: - case CS35L32_INT_STATUS_1: - case CS35L32_INT_STATUS_2: - case CS35L32_INT_STATUS_3: - case CS35L32_LED_STATUS: - case CS35L32_FLASH_MODE: - case CS35L32_MOVIE_MODE: - case CS35L32_FLASH_TIMER: - case CS35L32_FLASH_INHIBIT: + case CS35L32_DEVID_AB ... CS35L32_AUDIO_LED_MNGR: + case CS35L32_ADSP_CTL ... CS35L32_FLASH_INHIBIT: return true; default: return false; @@ -110,15 +85,8 @@ static bool cs35l32_readable_register(struct device *dev, unsigned int reg) static bool cs35l32_volatile_register(struct device *dev, unsigned int reg) { switch (reg) { - case CS35L32_DEVID_AB: - case CS35L32_DEVID_CD: - case CS35L32_DEVID_E: - case CS35L32_FAB_ID: - case CS35L32_REV_ID: - case CS35L32_INT_STATUS_1: - case CS35L32_INT_STATUS_2: - case CS35L32_INT_STATUS_3: - case CS35L32_LED_STATUS: + case CS35L32_DEVID_AB ... CS35L32_REV_ID: + case CS35L32_INT_STATUS_1 ... CS35L32_LED_STATUS: return true; default: return false; @@ -128,10 +96,7 @@ static bool cs35l32_volatile_register(struct device *dev, unsigned int reg) static bool cs35l32_precious_register(struct device *dev, unsigned int reg) { switch (reg) { - case CS35L32_INT_STATUS_1: - case CS35L32_INT_STATUS_2: - case CS35L32_INT_STATUS_3: - case CS35L32_LED_STATUS: + case CS35L32_INT_STATUS_1 ... CS35L32_LED_STATUS: return true; default: return false;