EDAC, altera: Fix peripheral warnings for Cyclone5
Subsystems (2)
PATCH 1/1 EDAC, altera: Fix peripheral warnings for Cyclone5
From: Thor Thayer <[email protected]>
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.
--- drivers/edac/altera_edac.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
drivers/edac/altera_edac.c +25 -4
@@ -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 ("/" ); +const char *model =of_get_property (np,"model" ,NULL ); + +of_node_put (np); +if (!model ||strncmp (model,"Altera SOCFPGA Arria 10" ,23 ) !=0 ) +return -ENODEV ; + +return 0 ; +} +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 (invalid_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 ;
@@ -1546,8 +1563,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 (invalid_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 ;
Signature · 1 line
1.9.1
Borislav Petkov
maintainerQuoted 16 lines · On Mon, Apr 03, 2017 at 02:01:06PM -0500, [email protected] wrote:
From: Thor Thayer <[email protected]>
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 <[email protected]>--- drivers/edac/altera_edac.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)drivers/edac/altera_edac.c +0
-0
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1029
Quoted 6 lines
drivers/edac/altera_edac.c +3
-0@@ -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.
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1033
Quoted 4 lines
drivers/edac/altera_edac.c +4
-0+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"
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1037
Quoted 4 lines
drivers/edac/altera_edac.c +4
-0+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.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Hi Boris,
Quoted 20 lines · Borislav Petkov
Quoted 19 lines · On Mon, Apr 03, 2017 at 02:01:06PM -0500, [email protected] wrote:
From: Thor Thayer <[email protected]>
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 <[email protected]>--- drivers/edac/altera_edac.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)drivers/edac/altera_edac.c +0
-0@@ -1024,13 +1024,30 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port)return ret; }
Quoted 6 lines
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1029
Quoted 3 lines
drivers/edac/altera_edac.c +3
-0+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.
Quoted 7 lines
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1033
Quoted 4 lines
drivers/edac/altera_edac.c +4
-0+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.
Quoted 9 lines
drivers/edac/altera_edac.c static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) · line 1037
Quoted 4 lines
drivers/edac/altera_edac.c +4
-0+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-ENODEVas the context you're using it is boolean.
Good point, thanks. I'll fix and re-submit.
Thanks for reviewing!