summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2016-01-06 14:54:13 +0100
committerBjørn Mork <bjorn@mork.no>2016-01-06 14:54:13 +0100
commitc16c23c661c01728421a0da4de468c9c1a1409a4 (patch)
treed3ec3b74a98c15f79c6e3832d72f22986197e625
parentf988b02dad561cef24a68180a56eecf1700cfa36 (diff)
parent35254b34f3f4a22750f85b71d4e7e4c74d9ef285 (diff)
Merge branch 'hwmon' into bmork-current20160106-2
-rw-r--r--Makefile1
-rw-r--r--dev.h4
-rw-r--r--hwmon.c50
-rw-r--r--hwmon.h16
-rw-r--r--main.c5
5 files changed, 76 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 11b812c..fa0391f 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/dev.h b/dev.h
index f97330f..a167767 100644
--- a/dev.h
+++ b/dev.h
@@ -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;
diff --git a/hwmon.c b/hwmon.c
new file mode 100644
index 0000000..7332023
--- /dev/null
+++ b/hwmon.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Bjørn Mork <bjorn@mork.no>
+ */
+
+#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);
+
+ return ret < 0 ? ret : snprintf(buf, PAGE_SIZE, "%d\n", temp * 1000);
+}
+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),
+ priv, 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 */
+
diff --git a/hwmon.h b/hwmon.h
new file mode 100644
index 0000000..edcdb2f
--- /dev/null
+++ b/hwmon.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2016 Bjørn Mork <bjorn@mork.no>
+ */
+
+#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_ */
diff --git a/main.c b/main.c
index 3fbd596..4425ce3 100644
--- a/main.c
+++ b/main.c
@@ -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);