Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755195AbdDDR5Q (ORCPT ); Tue, 4 Apr 2017 13:57:16 -0400 Received: from mga06.intel.com ([134.134.136.31]:45936 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754384AbdDDR5P (ORCPT ); Tue, 4 Apr 2017 13:57:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,275,1486454400"; d="scan'208";a="1150894121" From: thor.thayer@linux.intel.com To: bp@alien8.de, mchehab@kernel.org Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, thor.thayer@linux.intel.com.com, Thor Thayer Subject: [PATCHv2] EDAC, altera: Fix peripheral warnings for Cyclone5 Date: Tue, 4 Apr 2017 13:00:18 -0500 Message-Id: <1491328818-7815-1-git-send-email-thor.thayer@linux.intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2285 Lines: 69 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 --- v2 Change valid_model() return value from int to bool Change valid_model() name to is_a10_model() for clarity. Simplify expression - remove check for non-zero --- 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 c5a5b91..57aa968 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -1023,13 +1023,30 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) return ret; } +static bool is_a10_model(void) +{ + struct device_node *np = of_find_node_by_path("/"); + const char *model = of_get_property(np, "model", NULL); + + of_node_put(np); + if (!model || strncmp(model, "Altera SOCFPGA Arria 10", 23)) + return false; + + return true; +} + static int validate_parent_available(struct device_node *np); static const struct of_device_id altr_edac_a10_device_of_match[]; static int __init __maybe_unused altr_init_a10_ecc_device_type(char *compat) { int irq; - struct device_node *child, *np = of_find_compatible_node(NULL, NULL, - "altr,socfpga-a10-ecc-manager"); + struct device_node *child, *np; + + if (!is_a10_model()) + return -ENODEV; + + np = of_find_compatible_node(NULL, NULL, + "altr,socfpga-a10-ecc-manager"); if (!np) { edac_printk(KERN_ERR, EDAC_DEVICE, "ECC Manager not found\n"); return -ENODEV; @@ -1545,8 +1562,12 @@ static irqreturn_t altr_edac_a10_ecc_irq_portb(int irq, void *dev_id) static int __init socfpga_init_sdmmc_ecc(void) { int rc = -ENODEV; - struct device_node *child = of_find_compatible_node(NULL, NULL, - "altr,socfpga-sdmmc-ecc"); + struct device_node *child; + + if (!is_a10_model()) + return -ENODEV; + + child = of_find_compatible_node(NULL, NULL, "altr,socfpga-sdmmc-ecc"); if (!child) { edac_printk(KERN_WARNING, EDAC_DEVICE, "SDMMC node not found\n"); return -ENODEV; -- 1.9.1