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

tg3: unconditionally select HWMON support when tg3 is enabled.

There is the seldom used corner case where HWMON=m at the same
time as TIGON3=y (typically randconfigs) which will cause a link
fail like:

drivers/built-in.o: In function `tg3_close':
tg3.c:(.text+0x16bd86): undefined reference to `hwmon_device_unregister'
drivers/built-in.o: In function `tg3_hwmon_open':
tg3.c:(.text+0x16fc4b): undefined reference to `hwmon_device_register'
make[1]: *** [vmlinux] Error 1

Fix it as suggested by DaveM[1] by having the Kconfig logic simply
select HWMON when TIGON3 is selected. This gets rid of all the
extra IS_ENABLED ifdeffery in tg3.c as a side benefit.

[1] http://marc.info/?l=linux-netdev&m=134250573718151&w=2

Cc: Michael Chan <mchan@broadcom.com>
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reported-by: Anisse Astier <anisse@astier.eu>
Suggested-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Paul Gortmaker and committed by
David S. Miller
de0a4148 d4e62648

+1 -9
+1
drivers/net/ethernet/broadcom/Kconfig
··· 101 101 tristate "Broadcom Tigon3 support" 102 102 depends on PCI 103 103 select PHYLIB 104 + select HWMON 104 105 ---help--- 105 106 This driver supports Broadcom Tigon3 based gigabit Ethernet cards. 106 107
-9
drivers/net/ethernet/broadcom/tg3.c
··· 44 44 #include <linux/prefetch.h> 45 45 #include <linux/dma-mapping.h> 46 46 #include <linux/firmware.h> 47 - #if IS_ENABLED(CONFIG_HWMON) 48 47 #include <linux/hwmon.h> 49 48 #include <linux/hwmon-sysfs.h> 50 - #endif 51 49 52 50 #include <net/checksum.h> 53 51 #include <net/ip.h> ··· 9592 9594 return tg3_reset_hw(tp, reset_phy); 9593 9595 } 9594 9596 9595 - #if IS_ENABLED(CONFIG_HWMON) 9596 9597 static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) 9597 9598 { 9598 9599 int i; ··· 9644 9647 .attrs = tg3_attributes, 9645 9648 }; 9646 9649 9647 - #endif 9648 - 9649 9650 static void tg3_hwmon_close(struct tg3 *tp) 9650 9651 { 9651 - #if IS_ENABLED(CONFIG_HWMON) 9652 9652 if (tp->hwmon_dev) { 9653 9653 hwmon_device_unregister(tp->hwmon_dev); 9654 9654 tp->hwmon_dev = NULL; 9655 9655 sysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group); 9656 9656 } 9657 - #endif 9658 9657 } 9659 9658 9660 9659 static void tg3_hwmon_open(struct tg3 *tp) 9661 9660 { 9662 - #if IS_ENABLED(CONFIG_HWMON) 9663 9661 int i, err; 9664 9662 u32 size = 0; 9665 9663 struct pci_dev *pdev = tp->pdev; ··· 9686 9694 dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n"); 9687 9695 sysfs_remove_group(&pdev->dev.kobj, &tg3_group); 9688 9696 } 9689 - #endif 9690 9697 } 9691 9698 9692 9699