diff options
author | Bjørn Mork <bjorn@mork.no> | 2016-01-08 23:17:22 +0100 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2016-01-08 23:17:22 +0100 |
commit | 01b38f77e8752ab3e4042eae8856b82741896986 (patch) | |
tree | 292b580addc1d290c2903ba1d93bc5993eadc6a8 | |
parent | 69146ec22f4021cea90edf5e97bfdbf648534fe7 (diff) | |
parent | b7392cfb3a759535043125fc20e12b00b7d953c3 (diff) |
Merge branch 'hwmon' into bmork-current20160108
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | dev.h | 4 | ||||
-rw-r--r-- | hwmon.c | 56 | ||||
-rw-r--r-- | hwmon.h | 20 | ||||
-rw-r--r-- | main.c | 5 |
5 files changed, 86 insertions, 0 deletions
@@ -7,6 +7,7 @@ mwlwifi-objs += fwcmd.o mwlwifi-objs += tx.o mwlwifi-objs += rx.o mwlwifi-objs += isr.o +mwlwifi-objs += hwmon.o mwlwifi-$(CONFIG_DEBUG_FS) += debugfs.o ifeq (1, $(BUILD_MFG)) mwlwifi-objs += mfg.o @@ -376,6 +376,10 @@ struct mwl_priv { bool mfg_mode; +#if IS_ENABLED(CONFIG_HWMON) + struct device *hwmon; +#endif + #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_phy; u32 reg_type; @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 Bjørn Mork <bjorn@mork.no> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#include <linux/hwmon.h> +#include "sysadpt.h" +#include "dev.h" +#include "fwcmd.h" +#include "hwmon.h" + +#if IS_ENABLED(CONFIG_HWMON) +static ssize_t temp1_input_show(struct device *device, + struct device_attribute *devattr, + char *buf) +{ + u32 temp; + struct ieee80211_hw *hw = dev_get_drvdata(device); + int ret = mwl_fwcmd_get_temp(hw, &temp); + + /* 'temp' appears to be Fahrenheit despite the 'celcius' field name */ + return ret < 0 ? ret : snprintf(buf, PAGE_SIZE, "%d\n", (temp - 32) * 1000 * 5 / 9); +} +static DEVICE_ATTR_RO(temp1_input); + +static struct attribute *mwl_hwmon_attrs[] = { + &dev_attr_temp1_input.attr, + NULL, +}; +ATTRIBUTE_GROUPS(mwl_hwmon); + +int mwl_hwmon_register(struct ieee80211_hw *hw) +{ + struct mwl_priv *priv = hw->priv; + struct device *hwmon; + + hwmon = hwmon_device_register_with_groups(priv->dev, wiphy_name(hw->wiphy), + hw, mwl_hwmon_groups); + if (!IS_ERR(hwmon)) + priv->hwmon = hwmon; + return PTR_ERR_OR_ZERO(hwmon); +} + +void mwl_hwmon_unregister(struct ieee80211_hw *hw) +{ + struct mwl_priv *priv = hw->priv; + + if (priv->hwmon) + hwmon_device_unregister(priv->hwmon); + priv->hwmon = NULL; +} +#endif /* CONFIG_HWMON */ + @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2016 Bjørn Mork <bjorn@mork.no> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#ifndef _MWL_HWMON_H_ +#define _MWL_HWMON_H_ + +#if IS_ENABLED(CONFIG_HWMON) +int mwl_hwmon_register(struct ieee80211_hw *hw); +void mwl_hwmon_unregister(struct ieee80211_hw *hw); +#else +static inline int mwl_hwmon_register(struct ieee80211_hw *hw) { return 0; } +static inline void mwl_hwmon_unregister(struct ieee80211_hw *hw) {} +#endif + +#endif /* _MWL_HWMON_H_ */ @@ -30,6 +30,7 @@ #ifdef SUPPORT_MFG #include "mfg.h" #endif +#include "hwmon.h" #ifdef CONFIG_DEBUG_FS #include "debugfs.h" #endif @@ -822,6 +823,8 @@ static int mwl_probe(struct pci_dev *pdev, const struct pci_device_id *id) (priv->antenna_tx == ANTENNA_TX_4_AUTO) ? "4" : "2", (priv->antenna_rx == ANTENNA_RX_4_AUTO) ? "4" : "2"); + mwl_hwmon_register(hw); + #ifdef CONFIG_DEBUG_FS mwl_debugfs_init(hw); #endif @@ -853,6 +856,8 @@ static void mwl_remove(struct pci_dev *pdev) if (!hw) return; + mwl_hwmon_unregister(hw); + priv = hw->priv; mwl_wl_deinit(priv); |