netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
To: <netdev@vger.kernel.org>
Cc: Joakim Tjernlund <joakim.tjernlund@infinera.com>,
	<stable@vger.kernel.org>
Subject: [PATCH] net-sysfs: allow changing sysfs carrier when interface is down
Date: Thu, 2 Jun 2022 02:35:23 +0200	[thread overview]
Message-ID: <20220602003523.19530-1-joakim.tjernlund@infinera.com> (raw)

UP/DOWN and carrier are async events and it makes sense one can
adjust carrier in sysfs before bringing the interface up.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Cc: stable@vger.kernel.org
---
 net/core/net-sysfs.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index a4ae65263384..3418ef7ef2d8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -167,8 +167,6 @@ static DEVICE_ATTR_RO(broadcast);
 
 static int change_carrier(struct net_device *dev, unsigned long new_carrier)
 {
-	if (!netif_running(dev))
-		return -EINVAL;
 	return dev_change_carrier(dev, (bool)new_carrier);
 }
 
@@ -191,10 +189,7 @@ static ssize_t carrier_show(struct device *dev,
 {
 	struct net_device *netdev = to_net_dev(dev);
 
-	if (netif_running(netdev))
-		return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
-
-	return -EINVAL;
+	return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
 }
 static DEVICE_ATTR_RW(carrier);
 
-- 
2.35.1


             reply	other threads:[~2022-06-02  0:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  0:35 Joakim Tjernlund [this message]
2022-06-02  1:01 ` [PATCH] net-sysfs: allow changing sysfs carrier when interface is down Jakub Kicinski
2022-06-02  9:22   ` Joakim Tjernlund
2022-06-02 15:56     ` Stephen Hemminger
2022-06-02 16:26       ` Joakim Tjernlund
2022-06-02 16:57         ` Jakub Kicinski
2022-06-02 17:15           ` Joakim Tjernlund
2022-06-02 17:52             ` Jakub Kicinski
2022-06-02 18:01               ` Joakim Tjernlund
2022-06-05 18:50                 ` Andrew Lunn
2022-06-07 11:52                   ` Joakim Tjernlund
2022-06-02 18:14               ` Stephen Hemminger
2022-06-02 17:56             ` Stephen Hemminger
2022-06-02 18:09               ` Joakim Tjernlund
2022-06-02 18:38                 ` Joakim Tjernlund

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=20220602003523.19530-1-joakim.tjernlund@infinera.com \
    --to=joakim.tjernlund@infinera.com \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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).