Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC, altera: Avoid unused function warnings

The recently added Arria10 OCRAM ECC support caused some new harmless
warnings about unused functions when it is disabled:

drivers/edac/altera_edac.c:1067:20: error: 'altr_edac_a10_ecc_irq' defined but not used [-Werror=unused-function]
drivers/edac/altera_edac.c:658:12: error: 'altr_check_ecc_deps' defined but not used [-Werror=unused-function]

This rearranges the code slightly to have those two functions inside
of the same #ifdef that hides their callers. It also manages to
avoid a forward declaration of the IRQ handler in the process.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thor Thayer <tthayer@opensource.altera.com>
Cc: Alan Tull <atull@opensource.altera.com>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Fixes: c7b4be8db8bc ("EDAC, altera: Add Arria10 OCRAM ECC support")
Link: http://lkml.kernel.org/r/1460837650-1237650-2-git-send-email-arnd@arndb.de
Signed-off-by: Borislav Petkov <bp@suse.de>

authored by

Arnd Bergmann and committed by
Borislav Petkov
1aa6eb5c 2c911f6c

+37 -41
+37 -41
drivers/edac/altera_edac.c
··· 649 649 return count; 650 650 } 651 651 652 - /* 653 - * Test for memory's ECC dependencies upon entry because platform specific 654 - * startup should have initialized the memory and enabled the ECC. 655 - * Can't turn on ECC here because accessing un-initialized memory will 656 - * cause CE/UE errors possibly causing an ABORT. 657 - */ 658 - static int altr_check_ecc_deps(struct altr_edac_device_dev *device) 659 - { 660 - void __iomem *base = device->base; 661 - const struct edac_device_prv_data *prv = device->data; 662 - 663 - if (readl(base + prv->ecc_en_ofst) & prv->ecc_enable_mask) 664 - return 0; 665 - 666 - edac_printk(KERN_ERR, EDAC_DEVICE, 667 - "%s: No ECC present or ECC disabled.\n", 668 - device->edac_dev_name); 669 - return -ENODEV; 670 - } 671 - 672 652 static const struct file_operations altr_edac_device_inject_fops = { 673 653 .open = simple_open, 674 654 .write = altr_edac_device_trig, ··· 828 848 /*********************** OCRAM EDAC Device Functions *********************/ 829 849 830 850 #ifdef CONFIG_EDAC_ALTERA_OCRAM 851 + /* 852 + * Test for memory's ECC dependencies upon entry because platform specific 853 + * startup should have initialized the memory and enabled the ECC. 854 + * Can't turn on ECC here because accessing un-initialized memory will 855 + * cause CE/UE errors possibly causing an ABORT. 856 + */ 857 + static int altr_check_ecc_deps(struct altr_edac_device_dev *device) 858 + { 859 + void __iomem *base = device->base; 860 + const struct edac_device_prv_data *prv = device->data; 861 + 862 + if (readl(base + prv->ecc_en_ofst) & prv->ecc_enable_mask) 863 + return 0; 864 + 865 + edac_printk(KERN_ERR, EDAC_DEVICE, 866 + "%s: No ECC present or ECC disabled.\n", 867 + device->edac_dev_name); 868 + return -ENODEV; 869 + } 831 870 832 871 static void *ocram_alloc_mem(size_t size, void **other) 833 872 { ··· 882 883 gen_pool_free((struct gen_pool *)other, (u32)p, size); 883 884 } 884 885 886 + static irqreturn_t altr_edac_a10_ecc_irq(struct altr_edac_device_dev *dci, 887 + bool sberr) 888 + { 889 + void __iomem *base = dci->base; 890 + 891 + if (sberr) { 892 + writel(ALTR_A10_ECC_SERRPENA, 893 + base + ALTR_A10_ECC_INTSTAT_OFST); 894 + edac_device_handle_ce(dci->edac_dev, 0, 0, dci->edac_dev_name); 895 + } else { 896 + writel(ALTR_A10_ECC_DERRPENA, 897 + base + ALTR_A10_ECC_INTSTAT_OFST); 898 + edac_device_handle_ue(dci->edac_dev, 0, 0, dci->edac_dev_name); 899 + panic("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n"); 900 + } 901 + return IRQ_HANDLED; 902 + } 903 + 885 904 const struct edac_device_prv_data ocramecc_data = { 886 905 .setup = altr_check_ecc_deps, 887 906 .ce_clear_mask = (ALTR_OCR_ECC_EN | ALTR_OCR_ECC_SERR), ··· 915 898 .trig_alloc_sz = ALTR_TRIG_OCRAM_BYTE_SIZE, 916 899 .inject_fops = &altr_edac_device_inject_fops, 917 900 }; 918 - 919 - static irqreturn_t altr_edac_a10_ecc_irq(struct altr_edac_device_dev *dci, 920 - bool sberr); 921 901 922 902 const struct edac_device_prv_data a10_ocramecc_data = { 923 903 .setup = altr_check_ecc_deps, ··· 1073 1059 local_irq_restore(flags); 1074 1060 1075 1061 return count; 1076 - } 1077 - 1078 - static irqreturn_t altr_edac_a10_ecc_irq(struct altr_edac_device_dev *dci, 1079 - bool sberr) 1080 - { 1081 - void __iomem *base = dci->base; 1082 - 1083 - if (sberr) { 1084 - writel(ALTR_A10_ECC_SERRPENA, 1085 - base + ALTR_A10_ECC_INTSTAT_OFST); 1086 - edac_device_handle_ce(dci->edac_dev, 0, 0, dci->edac_dev_name); 1087 - } else { 1088 - writel(ALTR_A10_ECC_DERRPENA, 1089 - base + ALTR_A10_ECC_INTSTAT_OFST); 1090 - edac_device_handle_ue(dci->edac_dev, 0, 0, dci->edac_dev_name); 1091 - panic("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n"); 1092 - } 1093 - return IRQ_HANDLED; 1094 1062 } 1095 1063 1096 1064 static irqreturn_t altr_edac_a10_irq_handler(int irq, void *dev_id)