summaryrefslogtreecommitdiff
path: root/hwmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'hwmon.c')
-rw-r--r--hwmon.c50
1 files changed, 50 insertions, 0 deletions
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 */
+