From patchwork Tue Sep 6 12:50:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9316633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4D50A607D3 for ; Tue, 6 Sep 2016 12:52:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ED9128C56 for ; Tue, 6 Sep 2016 12:52:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 323F628C9E; Tue, 6 Sep 2016 12:52:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0EE928C56 for ; Tue, 6 Sep 2016 12:52:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhFr4-0001Dv-Lx; Tue, 06 Sep 2016 12:51:58 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhFqk-00010n-Oy; Tue, 06 Sep 2016 12:51:41 +0000 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0LfGuG-1bIrFA2Lxg-00omKo; Tue, 06 Sep 2016 14:50:32 +0200 From: Arnd Bergmann To: Thierry Reding Subject: [PATCH] pwm: meson: handle unknown ID values Date: Tue, 6 Sep 2016 14:50:47 +0200 Message-Id: <20160906125106.1511562-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:eC3TdEBFhMI6O5IMWSo1tngGEUP94BCOAWDjjsvg0l0IUwJj4J8 g2DiZc0IgL413ep1c8hSxN5vicLbT3NFUEJ2IL6t/UdIiix/IMOAQIgWxaNXiqRAkqxYR6c oVpl3AH/OwDNkulEWyrGmsIpePLGwl3DcFlbqK7C58LupC+0aWyf5VaJ2Iof3d4ii/fklDx VO7fR9C4ZNhfYjv7oACVw== X-UI-Out-Filterresults: notjunk:1; V01:K0:OxY9qZYBAmU=:xVTnVdHtu/byfSkFC03xvU pizqAf4j5xE0/jiRMlGrheytcSzzQEokjoQpiyInOTF3QNhMaHmaWA0kE3gp5YMT1v7CDlQbl LMDRDdvV0Nd110HwvogD7KFLdxf2xYnDVkKhqGWBf5ztPb2Tg0v6CwTkLOVVkB7VowuGTEX6+ COGkDRYaGz340OS4J4guRxc3RD1uao54wLWSAq5wABxOjaUvV81REJBL2CLEOizYKNuDdXHu+ BQT8yNpQlbTd2qENxyXa75k6FYQwhbnkjVieMRejfxkL8G2M0spJNzitJJIJrtTMei52Fu+/G h4uwC+SX/UirMTDVZmjHjot0TbJ595Sucxn/052NRbRaiRraUQ9g0NGme3Y2tunWU/9erFBTE cFEGn3kSysH4ec23DAnOLScsxsRyNt1URO84zK7wLf/wEoVMwO/RwK8HaYxXWgfETl2EyUur6 jZh6iKwfJvuiHojTBuTv0o3Gxnd9qbvnX5+AS2Lil1E2SzqcN7i/Pitx3JojsCua6w7OrAbbD MQwJIqdc1nWv5r5NCoewjzwtaAdVY1hQCLwI+l3UVuFgoDLaoyGW+Cpd2gw4ujE/tYdsiuPDk jM3CZZV6MiloYeCHiaEIPMNMyPS+nDRZ8YkNuOyAv6/CaGuiTCsUPmoeRL5CESjC2ILr/OeUM Ezlbzkt9r3tDb8+5vzov92GXdAExt7eYIirU1bIzNcKNi7TqBIh+hdEHXYvA5aAW83BU= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160906_055139_269233_621E3153 X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Arnd Bergmann , Neil Armstrong , Kevin Hilman , linux-kernel@vger.kernel.org, Carlo Caione , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When building with -Wmaybe-uninitialized, we get a couple of harmless warnings about three functions in this new driver that don't look safe to the compiler: drivers/pwm/pwm-meson.c: In function 'meson_pwm_get_state': drivers/pwm/pwm-meson.c:355:26: error: 'mask' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/pwm/pwm-meson.c: In function 'meson_pwm_disable': drivers/pwm/pwm-meson.c:263:13: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/pwm/pwm-meson.c: In function 'meson_pwm_apply': drivers/pwm/pwm-meson.c:231:13: error: 'clk_shift' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/pwm/pwm-meson.c:231:36: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/pwm/pwm-meson.c:231:24: error: 'clk_enable' may be used uninitialized in this function [-Werror=maybe-uninitialized] Specifically, if we have a device with an id other than 0 or 1, this would result in undefined behavior. This is currently not possible, but the compiler cannot be expected to know this. This patch adds a 'default' clause to let the compiler know what to do instead, which shuts up the warning and makes the code slightly more resiliant in case it gets extended to other identifiers. Signed-off-by: Arnd Bergmann Acked-by: Neil Armstrong --- drivers/pwm/pwm-meson.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 566f5cb81021..25abd95dcc7b 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -242,6 +242,9 @@ static void meson_pwm_enable(struct meson_pwm *meson, clk_enable = MISC_B_CLK_EN; enable = MISC_B_EN; break; + + default: + return; } value = readl(meson->base + REG_MISC_AB); @@ -270,6 +273,9 @@ static void meson_pwm_disable(struct meson_pwm *meson, unsigned int id) case 1: enable = MISC_B_EN; break; + + default: + return; } value = readl(meson->base + REG_MISC_AB); @@ -349,6 +355,10 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, case 1: mask = MISC_B_EN; break; + + default: + state->enabled = 0; + return; } value = readl(meson->base + REG_MISC_AB);