Received: by 10.213.65.68 with SMTP id h4csp2618174imn; Mon, 9 Apr 2018 06:29:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FnKtcZJfADrYHZXmgK2BtKMv139HfrUTsfC/UXvXIfbEFKUQO3GrI3Zt9JMsFZz5vq9vX X-Received: by 10.101.100.212 with SMTP id t20mr25759875pgv.112.1523280593149; Mon, 09 Apr 2018 06:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523280593; cv=none; d=google.com; s=arc-20160816; b=GeyPuspMWtAqvyjDd1STvkoPDt/9YI9jLn+TyL/Bva/nxLbjr0VZhuG761gJJRPf1N tuJtIm09JkHdQhdMBAxrzZPWfl4GlzGVdO9O6fD398l1E51rv2rz54qGfs2S8BVdixQI IX6MkMbC2y2dxZobcRXJy0L7y8zk9eP3n+JlE94thARMjQemDsTQdaIjoe/2qOFCf7S4 4R0i5ge+CbBvG7jLN2I6pRBsAZS2z0AkC6GYt7BaypnYK3sinkj9mttAyuhfg5octT8Q vxThxc+SL65DzYqHAG1QsSzv34xlxGiodgKdOYjJSSgekt0xQuiDe7ohK32rAWao6hh+ Jo0w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :dkim-signature:arc-authentication-results; bh=ovmJNzEcW+FwEl0EEEQ5bOgEs8MyK2ExSZWR8Bq0R2U=; b=lvME6rSGeZFt+C6iJ/oWVvHnAwPeUTW98mZ3vwPCUxy65fNMNX6yhG//xWoizKp+HB Z9glxceDYtRK4AtIgHKkMu8gU+G72Gm+SNPiM0NDmK9qDNpk+/LC1X8Yb9FDlv0P8/i6 hnO+IIwA4Yc6vee8c7TnYZJKtU+0xWMBfiOPqZEMXKvmMeAfZjm5lSqMRAt5on0LCsdV 312hvNaMh4SOrzixRLNRX0LoDAuf6FEwQMpMWALxYTcjVtPRPJ4ND7MhCS1r1XMjZroi l7dLeDyALvCRYu+ib6vj9iAIdPAIAnfOGZBfkwMFeJVSxBajLuVgSqeW3kCC/YjCdTPW xftQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@raspberrypi.org header.s=pp header.b=j+cXU8/+; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=qSWnX504; 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 o7si220530pgp.527.2018.04.09.06.29.16; Mon, 09 Apr 2018 06:29:53 -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; dkim=fail header.i=@raspberrypi.org header.s=pp header.b=j+cXU8/+; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=qSWnX504; 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 S1752298AbeDIN0U (ORCPT + 99 others); Mon, 9 Apr 2018 09:26:20 -0400 Received: from mx07-00252a01.pphosted.com ([62.209.51.214]:46001 "EHLO mx07-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbeDIN0S (ORCPT ); Mon, 9 Apr 2018 09:26:18 -0400 Received: from pps.filterd (m0102628.ppops.net [127.0.0.1]) by mx07-00252a01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w39DNkmT005935 for ; Mon, 9 Apr 2018 14:26:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp; bh=ovmJNzEcW+FwEl0EEEQ5bOgEs8MyK2ExSZWR8Bq0R2U=; b=j+cXU8/+DJf0owOKQMit7YzC5oO7CIpCumvOPfSzIFUR94ppMX+HZLFmUMw5pfzr+46D 0KITcAJnERnMhFWroWfBhoc+9ks2qbm3/UkG2OJxzMbHE+YwSJ3j/GOvxH9jsqs8rAfS 8k4z4c7FaR1apH2aR+l234Mhu7ZFz6PYJmklbCdeEKuI6aXuS5lcbY/pdYLTGmW04jYq QCgRmZgszAgWB2DpZ6qmPqFxn+Lb1ol+/Yyrar7RALULf7X7NdlWR0tFQHNSSP6ovMO5 gSX95871fnZcGKxDXIa4jZ6zSrNPilX2luLwkB2WQsiDeSPVBjv7zqZXSzGGnSoZnGc9 JQ== Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by mx07-00252a01.pphosted.com with ESMTP id 2h6s4k90uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Mon, 09 Apr 2018 14:26:17 +0100 Received: by mail-wr0-f197.google.com with SMTP id 31so6221085wrr.2 for ; Mon, 09 Apr 2018 06:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ovmJNzEcW+FwEl0EEEQ5bOgEs8MyK2ExSZWR8Bq0R2U=; b=qSWnX504ODfM5lwKW89NmJI0d/8MfT3oc3QRoDuQIQmpW+XNV6z3uF/3h+x68fWAf2 VB+Q+F8xgpBc6Rhvjv8XCoyK7NPwrWNtAw7j83Fa7qbxtM2fei/jMCbPz81Ibk0qPIUj 6KqLzBpaHhoJJB8zC28W8UOkMqwBTwW6l0Fj1owV4c3m8/JbjRWRifQZ3zNXlkKfEP0f ka1JIzdIflTIrVVP3CPsmYRe0F8Qq2kCCYkZp+5+yO+b8ABTHMjUPZ+IyfiuCW0Q6Bos x0XfbaZOiYg/o+oW+WoQcYftPP7QLhrY9v7zkjzTcdoKsFXjva8rpzCdIYjaTRTFDf4T gSNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ovmJNzEcW+FwEl0EEEQ5bOgEs8MyK2ExSZWR8Bq0R2U=; b=OQYrZg17ryKpIj5FDjcDIB3WhFPP3s1Mw2r2m/vYS2y0WIMRWWHh5ku21RgL77CpHj r3ufUPpBzF9yOEX9S1n3qe7/Df7UoukvJ2sSCkaigfslukvzu8cBa9tpKoZIRAuyos2y eY1piH2QWBmFoyUrFcVSbBAp07w+uYi2O9LOWrT+X2bEWev5oMAc1ZfukkZzQ2ozgNL/ XNEQPTF8oPTIlZPvkmISD1LIrxeR4sO1E3eCw+GuR+NOSeiNNJxAGOsUbwecrOQJGkpI zRp0vg3fvob9ylI0ycpJrzpboQ0eODay1zR2lj2KfHwhTo5nvM9+u3sKCWKoeGCX0hfq oZjA== X-Gm-Message-State: AElRT7GS0GCUceXElxT86+HB5NJ8lAn325s1LmRSdI2G5GKRMw83sTb9 G0im/smrSxE43Fkrky6AW2m/p7/JDvOG6hH4UE1XCvczNKjaZ1zz15vrblX5lAHccLUFoPME1+s 4m9Szm9jGn0Cc5MmA9T0VWSG4 X-Received: by 10.28.88.195 with SMTP id m186mr19693428wmb.113.1523280376539; Mon, 09 Apr 2018 06:26:16 -0700 (PDT) X-Received: by 10.28.88.195 with SMTP id m186mr19693400wmb.113.1523280376191; Mon, 09 Apr 2018 06:26:16 -0700 (PDT) Received: from ?IPv6:2a00:2381:fdf7:14:803d:a195:ce56:b202? ([2a00:2381:fdf7:14:803d:a195:ce56:b202]) by smtp.gmail.com with ESMTPSA id l73sm1062587wma.10.2018.04.09.06.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 06:26:15 -0700 (PDT) Subject: Re: [PATCH/RFC] soc: bcm2835: Make !RASPBERRYPI_FIRMWARE dummies return failure To: Stefan Wahren , Scott Branden , Florian Fainelli , Eric Anholt , Greg Kroah-Hartman , Geert Uytterhoeven , bcm-kernel-feedback-list@broadcom.com, Ray Jui , Dave Stevenson Cc: Arnd Bergmann , linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <1523178315-30562-1-git-send-email-geert@linux-m68k.org> <2047337098.98106.1523186884813@email.1und1.de> From: Phil Elwell Message-ID: <6542f11f-35c0-78ae-30f7-510797105c07@raspberrypi.org> Date: Mon, 9 Apr 2018 14:26:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <2047337098.98106.1523186884813@email.1und1.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-09_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/04/2018 12:28, Stefan Wahren wrote: > Hi Geert, > > [add Phil] > >> Geert Uytterhoeven hat am 8. April 2018 um 11:05 geschrieben: >> >> >> 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. > > i think this is more theoritical, because we need to get rpi_firmware first and in this case it's NULL. > >> >> Fix this by making the dummy functions return an error code (-ENOSYS) >> instead. > > Anyway i'm okay with the change. > >> >> Note that this assumes the firmware always fills in the requested data >> in the CONFIG_RASPBERRYPI_FIRMWARE=y case. > > Unfortunately i don't know. The firmware overwrites the request code with an error return value. If this appears and has an error value of zero (RPI_FIRMWARE_STATUS_SUCCESS) then the firmware has written any expected fields. > >> >> 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 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel