Received: by 10.213.65.68 with SMTP id h4csp1406229imn; Sun, 8 Apr 2018 02:45:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+sTHKL/DRnm9BThq2zE1gS4PRkkcafViHe1xUYmMQq9R4fWJhrMV/Jx9PeoD6w0U6HqF1/ X-Received: by 2002:a17:902:57ce:: with SMTP id g14-v6mr17407406plj.222.1523180730881; Sun, 08 Apr 2018 02:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523180730; cv=none; d=google.com; s=arc-20160816; b=j/q+3nBCbIs9nER7yVUZrqSHSfJiKWOhOp1hsajc9VKSodGzEhncAQIAn5y3YT6FXN ZJGrbIH8m320o5ZhfweEJFraBaoiBj+buFbHQ/uy1F3A30mzB4AdcTdZwYRAE71gWIgv 8b40RVtUZWkipWs/qZOMnHnpipP4nfK4x9h15OQlUDi9CtgiDctGe/sqTMWSPFzSaO2J YHVYFRR4SDh7KT38CRoEvnAhu0hrDv+L1vv/OwqNdE8Hsr4tMJ2ipARMwffKuq2IGSLC NtVUCByoX/Za5EWghX7SzDglkWQ5EvoKFP0AvjJEwKg8Qh+f2/2X4ENhAIJyyVQp2Z/q TSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=7MyG6f4VmHGfuFtkh4FDHnz6TIKdAtaBdDabUYMJ5JA=; b=Se5mlYL1PeNep0sIi9qc9t5MhNurZSyq9IbOwUHk7OYAgs+/x/u57AlqudYfmfPTgN 4CitcPQ+O8rRIOf/FRnR7/+nOogIr8xMnMYiQi7unNZ/p0/x4dLG1QrfFQEHwEvhGIIj dTWCATVaoQcVKHqIXAi0hH1U1Rt5K8VLCHNjalVaCoLpNLHb5AZuyTI8Ali7dpGebknW FPasht0OeanE09q41v+NAYlZoWwYG9NJH5RCpVJ/hS7A0Z3flfarDdBKX/2Urn6U1rFF ycOs0my4EB43TjxI586IqQqPAKOxXz5Tdm8lW+3C/k3jiIk48wNb68MHOiJC5Tn6mhkL /Cuw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si6808395plb.160.2018.04.08.02.44.53; Sun, 08 Apr 2018 02:45:30 -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 S1752718AbeDHJFZ (ORCPT + 99 others); Sun, 8 Apr 2018 05:05:25 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:39804 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752587AbeDHJFX (ORCPT ); Sun, 8 Apr 2018 05:05:23 -0400 Received: from ayla.of.borg ([84.194.111.163]) by albert.telenet-ops.be with bizsmtp id Xl5J1x00u3XaVaC06l5JT3; Sun, 08 Apr 2018 11:05:22 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1f56GE-0007ge-NU; Sun, 08 Apr 2018 11:05:18 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1f56GE-000866-L0; Sun, 08 Apr 2018 11:05:18 +0200 From: Geert Uytterhoeven To: Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Eric Anholt , Stefan Wahren , Dave Stevenson , Greg Kroah-Hartman Cc: Arnd Bergmann , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC] soc: bcm2835: Make !RASPBERRYPI_FIRMWARE dummies return failure Date: Sun, 8 Apr 2018 11:05:15 +0200 Message-Id: <1523178315-30562-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_RASPBERRYPI_FIRMWARE=n: drivers/gpio/gpio-raspberrypi-exp.c: In function ‘rpi_exp_gpio_get_polarity’: drivers/gpio/gpio-raspberrypi-exp.c:71: warning: ‘get.polarity’ is used uninitialized in this function drivers/gpio/gpio-raspberrypi-exp.c: In function ‘rpi_exp_gpio_get_direction’: drivers/gpio/gpio-raspberrypi-exp.c:150: warning: ‘get.direction’ is used uninitialized in this function The dummy firmware interface functions return 0, which means success, causing subsequent code to make use of the never initialized output parameter. Fix this by making the dummy functions return an error code (-ENOSYS) instead. Note that this assumes the firmware always fills in the requested data in the CONFIG_RASPBERRYPI_FIRMWARE=y case. Fixes: d45f1a563b92dac7 ("staging: vc04_services: fix up rpi firmware functions") Signed-off-by: Geert Uytterhoeven --- Should get.polarity resp. get.direction be preinitialized instead, like is done for get.state? static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off) { ... get.state = 0; /* storage for returned value */ ret = rpi_firmware_property(gpio->fw, RPI_FIRMWARE_GET_GPIO_STATE, &get, sizeof(get)); ... } This would avoid returning uninitialized data if the firmware did not fill in the requested data. --- include/soc/bcm2835/raspberrypi-firmware.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h index 50df5b28d2c9df6e..8ee8991aa099af3a 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -143,13 +143,13 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node); static inline int rpi_firmware_property(struct rpi_firmware *fw, u32 tag, void *data, size_t len) { - return 0; + return -ENOSYS; } static inline int rpi_firmware_property_list(struct rpi_firmware *fw, void *data, size_t tag_size) { - return 0; + return -ENOSYS; } static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) -- 2.7.4