summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2017-01-19 19:37:50 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-20 14:42:51 -0500
commitcf1a56a4cf196a2922e66e9a8e0bf80d324c5548 (patch)
tree967b905290303ecf4280089f82fe018ce8b081fe /net/dsa
parent0b04680fdae464ee51409b8cb36005f6ef8bd689 (diff)
net: dsa: Remove hwmon support
Only the Marvell mv88e6xxx DSA driver made use of the HWMON support in DSA. The temperature sensor registers are actually in the embedded PHYs, and the PHY driver now supports it. So remove all HWMON support from DSA and drivers. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/Kconfig11
-rw-r--r--net/dsa/Makefile1
-rw-r--r--net/dsa/dsa.c4
-rw-r--r--net/dsa/dsa_priv.h9
-rw-r--r--net/dsa/hwmon.c147
5 files changed, 0 insertions, 172 deletions
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 39bb5b3a82f2..9649238eef40 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -15,17 +15,6 @@ config NET_DSA
15 15
16if NET_DSA 16if NET_DSA
17 17
18config NET_DSA_HWMON
19 bool "Distributed Switch Architecture HWMON support"
20 default y
21 depends on HWMON && !(NET_DSA=y && HWMON=m)
22 ---help---
23 Say Y if you want to expose thermal sensor data on switches supported
24 by the Distributed Switch Architecture.
25
26 Some of those switches contain thermal sensors. This data is available
27 via the hwmon sysfs interface and exposes the onboard sensors.
28
29# tagging formats 18# tagging formats
30config NET_DSA_TAG_BRCM 19config NET_DSA_TAG_BRCM
31 bool 20 bool
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index 560b6747c276..a3380ed0e0be 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -1,7 +1,6 @@
1# the core 1# the core
2obj-$(CONFIG_NET_DSA) += dsa_core.o 2obj-$(CONFIG_NET_DSA) += dsa_core.o
3dsa_core-y += dsa.o slave.o dsa2.o 3dsa_core-y += dsa.o slave.o dsa2.o
4dsa_core-$(CONFIG_NET_DSA_HWMON) += hwmon.o
5 4
6# tagging formats 5# tagging formats
7dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o 6dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 91f96e1bd2ec..77cb78767f1d 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -316,8 +316,6 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
316 if (ret) 316 if (ret)
317 return ret; 317 return ret;
318 318
319 dsa_hwmon_register(ds);
320
321 return 0; 319 return 0;
322} 320}
323 321
@@ -376,8 +374,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
376{ 374{
377 int port; 375 int port;
378 376
379 dsa_hwmon_unregister(ds);
380
381 /* Destroy network devices for physical switch ports. */ 377 /* Destroy network devices for physical switch ports. */
382 for (port = 0; port < DSA_MAX_PORTS; port++) { 378 for (port = 0; port < DSA_MAX_PORTS; port++) {
383 if (!(ds->enabled_port_mask & (1 << port))) 379 if (!(ds->enabled_port_mask & (1 << port)))
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 7e3385ec73f4..63ae1484abae 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -56,15 +56,6 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
56int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds); 56int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
57void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds); 57void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
58 58
59/* hwmon.c */
60#ifdef CONFIG_NET_DSA_HWMON
61void dsa_hwmon_register(struct dsa_switch *ds);
62void dsa_hwmon_unregister(struct dsa_switch *ds);
63#else
64static inline void dsa_hwmon_register(struct dsa_switch *ds) { }
65static inline void dsa_hwmon_unregister(struct dsa_switch *ds) { }
66#endif
67
68/* slave.c */ 59/* slave.c */
69extern const struct dsa_device_ops notag_netdev_ops; 60extern const struct dsa_device_ops notag_netdev_ops;
70void dsa_slave_mii_bus_init(struct dsa_switch *ds); 61void dsa_slave_mii_bus_init(struct dsa_switch *ds);
diff --git a/net/dsa/hwmon.c b/net/dsa/hwmon.c
deleted file mode 100644
index 08831a811278..000000000000
--- a/net/dsa/hwmon.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * net/dsa/hwmon.c - HWMON subsystem support
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#include <linux/ctype.h>
11#include <linux/hwmon.h>
12#include <net/dsa.h>
13
14#include "dsa_priv.h"
15
16static ssize_t temp1_input_show(struct device *dev,
17 struct device_attribute *attr, char *buf)
18{
19 struct dsa_switch *ds = dev_get_drvdata(dev);
20 int temp, ret;
21
22 ret = ds->ops->get_temp(ds, &temp);
23 if (ret < 0)
24 return ret;
25
26 return sprintf(buf, "%d\n", temp * 1000);
27}
28static DEVICE_ATTR_RO(temp1_input);
29
30static ssize_t temp1_max_show(struct device *dev,
31 struct device_attribute *attr, char *buf)
32{
33 struct dsa_switch *ds = dev_get_drvdata(dev);
34 int temp, ret;
35
36 ret = ds->ops->get_temp_limit(ds, &temp);
37 if (ret < 0)
38 return ret;
39
40 return sprintf(buf, "%d\n", temp * 1000);
41}
42
43static ssize_t temp1_max_store(struct device *dev,
44 struct device_attribute *attr, const char *buf,
45 size_t count)
46{
47 struct dsa_switch *ds = dev_get_drvdata(dev);
48 int temp, ret;
49
50 ret = kstrtoint(buf, 0, &temp);
51 if (ret < 0)
52 return ret;
53
54 ret = ds->ops->set_temp_limit(ds, DIV_ROUND_CLOSEST(temp, 1000));
55 if (ret < 0)
56 return ret;
57
58 return count;
59}
60static DEVICE_ATTR_RW(temp1_max);
61
62static ssize_t temp1_max_alarm_show(struct device *dev,
63 struct device_attribute *attr, char *buf)
64{
65 struct dsa_switch *ds = dev_get_drvdata(dev);
66 bool alarm;
67 int ret;
68
69 ret = ds->ops->get_temp_alarm(ds, &alarm);
70 if (ret < 0)
71 return ret;
72
73 return sprintf(buf, "%d\n", alarm);
74}
75static DEVICE_ATTR_RO(temp1_max_alarm);
76
77static struct attribute *dsa_hwmon_attrs[] = {
78 &dev_attr_temp1_input.attr, /* 0 */
79 &dev_attr_temp1_max.attr, /* 1 */
80 &dev_attr_temp1_max_alarm.attr, /* 2 */
81 NULL
82};
83
84static umode_t dsa_hwmon_attrs_visible(struct kobject *kobj,
85 struct attribute *attr, int index)
86{
87 struct device *dev = container_of(kobj, struct device, kobj);
88 struct dsa_switch *ds = dev_get_drvdata(dev);
89 const struct dsa_switch_ops *ops = ds->ops;
90 umode_t mode = attr->mode;
91
92 if (index == 1) {
93 if (!ops->get_temp_limit)
94 mode = 0;
95 else if (!ops->set_temp_limit)
96 mode &= ~S_IWUSR;
97 } else if (index == 2 && !ops->get_temp_alarm) {
98 mode = 0;
99 }
100 return mode;
101}
102
103static const struct attribute_group dsa_hwmon_group = {
104 .attrs = dsa_hwmon_attrs,
105 .is_visible = dsa_hwmon_attrs_visible,
106};
107__ATTRIBUTE_GROUPS(dsa_hwmon);
108
109void dsa_hwmon_register(struct dsa_switch *ds)
110{
111 const char *netname = netdev_name(ds->dst->master_netdev);
112 char hname[IFNAMSIZ + 1];
113 int i, j;
114
115 /* If the switch provides temperature accessors, register with hardware
116 * monitoring subsystem. Treat registration error as non-fatal.
117 */
118 if (!ds->ops->get_temp)
119 return;
120
121 /* Create valid hwmon 'name' attribute */
122 for (i = j = 0; i < IFNAMSIZ && netname[i]; i++) {
123 if (isalnum(netname[i]))
124 hname[j++] = netname[i];
125 }
126 hname[j] = '\0';
127 scnprintf(ds->hwmon_name, sizeof(ds->hwmon_name), "%s_dsa%d", hname,
128 ds->index);
129 ds->hwmon_dev = hwmon_device_register_with_groups(NULL, ds->hwmon_name,
130 ds, dsa_hwmon_groups);
131 if (IS_ERR(ds->hwmon_dev)) {
132 pr_warn("DSA: failed to register HWMON subsystem for switch %d\n",
133 ds->index);
134 ds->hwmon_dev = NULL;
135 } else {
136 pr_info("DSA: registered HWMON subsystem for switch %d\n",
137 ds->index);
138 }
139}
140
141void dsa_hwmon_unregister(struct dsa_switch *ds)
142{
143 if (ds->hwmon_dev) {
144 hwmon_device_unregister(ds->hwmon_dev);
145 ds->hwmon_dev = NULL;
146 }
147}