From 22b690334c0f49b11534cc2e331c9d5e17c4a0bc Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 6 Jun 2021 09:34:19 +0200 Subject: [PATCH] mt76: mt7915: do not fail if the cooling device could not be registered Signed-off-by: Felix Fietkau --- mt7915/init.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/mt7915/init.c b/mt7915/init.c index dc9433ff..e0272737 100644 --- a/mt7915/init.c +++ b/mt7915/init.c @@ -118,6 +118,9 @@ static void mt7915_unregister_thermal(struct mt7915_phy *phy) { struct wiphy *wiphy = phy->mt76->hw->wiphy; + if (!phy->cdev) + return; + sysfs_remove_link(&wiphy->dev.kobj, "cooling_device"); thermal_cooling_device_unregister(phy->cdev); } @@ -127,19 +130,14 @@ static int mt7915_thermal_init(struct mt7915_phy *phy) struct wiphy *wiphy = phy->mt76->hw->wiphy; struct thermal_cooling_device *cdev; struct device *hwmon; - int ret = 0; cdev = thermal_cooling_device_register(wiphy_name(wiphy), phy, &mt7915_thermal_ops); - if (IS_ERR(cdev)) - return PTR_ERR(cdev); - - ret = sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj, - "cooling_device"); - if (ret) - goto err; - - phy->cdev = cdev; + if (!IS_ERR(cdev)) { + phy->cdev = cdev; + sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj, + "cooling_device"); + } if (!IS_REACHABLE(CONFIG_HWMON)) return 0; @@ -147,16 +145,10 @@ static int mt7915_thermal_init(struct mt7915_phy *phy) hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, wiphy_name(wiphy), phy, mt7915_hwmon_groups); - if (IS_ERR(hwmon)) { - ret = PTR_ERR(hwmon); - goto err; - } + if (IS_ERR(hwmon)) + return PTR_ERR(hwmon); return 0; - -err: - mt7915_unregister_thermal(phy); - return ret; } static void