Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754318AbdDDOYw (ORCPT ); Tue, 4 Apr 2017 10:24:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:49212 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752814AbdDDOYu (ORCPT ); Tue, 4 Apr 2017 10:24:50 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,275,1486454400"; d="scan'208";a="73437342" Reply-To: thor.thayer@linux.intel.com Subject: Re: [PATCH] EDAC, altera: Fix peripheral warnings for Cyclone5 References: <1491246066-22334-1-git-send-email-thor.thayer@linux.intel.com> <20170404095910.jhstk52dgy6brnhb@pd.tnic> To: Borislav Petkov Cc: mchehab@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, thor.thayer@linux.intel.com.com From: Thor Thayer Message-ID: Date: Tue, 4 Apr 2017 09:28:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170404095910.jhstk52dgy6brnhb@pd.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1896 Lines: 57 Hi Boris, On 04/04/2017 04:59 AM, Borislav Petkov wrote: > On Mon, Apr 03, 2017 at 02:01:06PM -0500, thor.thayer@linux.intel.com wrote: >> From: Thor Thayer >> >> The peripherals EDACs only exist on the Arria10 SoCFPGA. The Cyclone5 >> initialization has EDAC warnings when the peripherals aren't found >> in the device tree. Fix by checking for Arria10 in the init functions. >> >> Signed-off-by: Thor Thayer >> --- >> drivers/edac/altera_edac.c | 29 +++++++++++++++++++++++++---- >> 1 file changed, 25 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c >> index 6421cc3..98e83f5 100644 >> --- a/drivers/edac/altera_edac.c >> +++ b/drivers/edac/altera_edac.c >> @@ -1024,13 +1024,30 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) >> return ret; >> } >> >> +static int invalid_model(void) >> +{ >> + struct device_node *np = of_find_node_by_path("/"); > > That needs to have its return value checked, of course. > Actually, some of the of_ functions have validity checking in them. In this case, of_get_property() calls of_find_property() which returns NULL if np is 0 which is propagated back up to model so this code should be safe. In the case of the of_node_put() below, the node is also checked for non-NULL so I should be OK there. >> + const char *model = of_get_property(np, "model", NULL); >> + >> + of_node_put(np); >> + if (!model || strncmp(model, "Altera SOCFPGA Arria 10", 23) != 0) > > No need for the "!= 0" > OK. Thanks. >> + return -ENODEV; >> + >> + return 0; >> +} > > That function name "invalid_model" sounds like a boolean: is the model > invalid. So you can simply return bools and not -ENODEV as the context > you're using it is boolean. > Good point, thanks. I'll fix and re-submit. Thanks for reviewing!