From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com,
bhutchings@solarflare.com, mirqus@gmail.com,
shemminger@vyatta.com, greearb@candelatech.com, fbl@redhat.com,
john.r.fastabend@intel.com
Subject: [patch net-next 2/4] net: allow to change carrier via sysfs
Date: Fri, 28 Dec 2012 10:49:38 +0100 [thread overview]
Message-ID: <1356688180-3549-3-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1356688180-3549-1-git-send-email-jiri@resnulli.us>
Make carrier writable
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/core/net-sysfs.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 28c5f5a..29c884a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -126,6 +126,19 @@ static ssize_t show_broadcast(struct device *dev,
return -EINVAL;
}
+static int change_carrier(struct net_device *net, unsigned long new_carrier)
+{
+ if (!netif_running(net))
+ return -EINVAL;
+ return dev_change_carrier(net, (bool) new_carrier);
+}
+
+static ssize_t store_carrier(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ return netdev_store(dev, attr, buf, len, change_carrier);
+}
+
static ssize_t show_carrier(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -331,7 +344,7 @@ static struct device_attribute net_class_attributes[] = {
__ATTR(link_mode, S_IRUGO, show_link_mode, NULL),
__ATTR(address, S_IRUGO, show_address, NULL),
__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
- __ATTR(carrier, S_IRUGO, show_carrier, NULL),
+ __ATTR(carrier, S_IRUGO | S_IWUSR, show_carrier, store_carrier),
__ATTR(speed, S_IRUGO, show_speed, NULL),
__ATTR(duplex, S_IRUGO, show_duplex, NULL),
__ATTR(dormant, S_IRUGO, show_dormant, NULL),
--
1.8.0
next prev parent reply other threads:[~2012-12-28 9:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-28 9:49 [patch net-next V3,repost 0/4] net: allow to change carrier from userspace Jiri Pirko
2012-12-28 9:49 ` [patch net-next 1/4] net: add change_carrier netdev op Jiri Pirko
2012-12-28 9:49 ` Jiri Pirko [this message]
2012-12-28 9:49 ` [patch net-next 3/4] rtnl: expose carrier value with possibility to set it Jiri Pirko
2012-12-28 9:49 ` [patch net-next 4/4] dummy: implement carrier change Jiri Pirko
2012-12-28 13:18 ` [patch net-next V3,repost 0/4] net: allow to change carrier from userspace Flavio Leitner
2012-12-28 23:21 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2012-12-19 9:35 [patch net-next V3 " Jiri Pirko
2012-12-19 9:35 ` [patch net-next 2/4] net: allow to change carrier via sysfs Jiri Pirko
2012-12-18 22:14 [patch net-next V2 0/4] net: allow to change carrier from userspace Jiri Pirko
2012-12-18 22:14 ` [patch net-next 2/4] net: allow to change carrier via sysfs Jiri Pirko
2012-12-12 10:58 [patch net-next 0/4] net: allow to change carrier from userspace Jiri Pirko
2012-12-12 10:58 ` [patch net-next 2/4] net: allow to change carrier via sysfs Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356688180-3549-3-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fbl@redhat.com \
--cc=greearb@candelatech.com \
--cc=john.r.fastabend@intel.com \
--cc=mirqus@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).