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: 101867 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp531338qgf; Tue, 6 Sep 2016 05:51:53 -0700 (PDT) X-Received: by 10.98.204.135 with SMTP id j7mr17207635pfk.54.1473166312964; Tue, 06 Sep 2016 05:51:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si35350685pax.227.2016.09.06.05.51.52; Tue, 06 Sep 2016 05:51:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932870AbcIFMvu (ORCPT + 27 others); Tue, 6 Sep 2016 08:51:50 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:58070 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754997AbcIFMvo (ORCPT ); Tue, 6 Sep 2016 08:51:44 -0400 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 Cc: Arnd Bergmann , Carlo Caione , Kevin Hilman , Neil Armstrong , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org 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= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/pwm/pwm-meson.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.9.0 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);