netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: bridge@lists.linux-foundation.org, netdev@vger.kernel.org
Subject: [RFC PATCH] bridge sysfs binary file simplification
Date: Thu, 22 Aug 2013 11:30:48 -0700	[thread overview]
Message-ID: <20130822183048.GA6517@kroah.com> (raw)

From: Greg KH <gregkh@linuxfoundation.org>

Attribute groups now can handle binary sysfs files, so move the bridge
binary sysfs file to be part of the larger bridge group, saving code.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

-- 

Stephen, this moves the binary sysfs file to be within the bridge
subdirectory, a change from where it is today, right?  Was the file
created intentionally outside of the subdir, or was it meant to be
within it?

If tools can't handle this file moving, then never mind with this patch,
it is part of my larger "audit the sysfs binary files" work that I'm
currently doing.

Also note, the sysfs file size is currently set to be 0, is that
intentional?

 net/bridge/br_sysfs_br.c |   32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 394bb96b..0d5862ea 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -782,11 +782,6 @@ static struct attribute *bridge_attrs[] = {
 	NULL
 };
 
-static struct attribute_group bridge_group = {
-	.name = SYSFS_BRIDGE_ATTR,
-	.attrs = bridge_attrs,
-};
-
 /*
  * Export the forwarding information table as a binary file
  * The records are struct __fdb_entry.
@@ -815,10 +810,17 @@ static ssize_t brforward_read(struct file *filp, struct kobject *kobj,
 	return n;
 }
 
-static struct bin_attribute bridge_forward = {
-	.attr = { .name = SYSFS_BRIDGE_FDB,
-		  .mode = S_IRUGO, },
-	.read = brforward_read,
+static BIN_ATTR_RO(brforward, 0);
+
+static struct bin_attribute *bridge_bin_attrs[] = {
+	&bin_attr_brforward,
+	NULL,
+};
+
+static struct attribute_group bridge_group = {
+	.name = SYSFS_BRIDGE_ATTR,
+	.attrs = bridge_attrs,
+	.bin_attrs = bridge_bin_attrs,
 };
 
 /*
@@ -845,22 +847,13 @@ int br_sysfs_addbr(struct net_device *dev)
 		goto out1;
 	}
 
-	err = sysfs_create_bin_file(brobj, &bridge_forward);
-	if (err) {
-		pr_info("%s: can't create attribute file %s/%s\n",
-			__func__, dev->name, bridge_forward.attr.name);
-		goto out2;
-	}
-
 	br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
 	if (!br->ifobj) {
 		pr_info("%s: can't add kobject (directory) %s/%s\n",
 			__func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
-		goto out3;
+		goto out2;
 	}
 	return 0;
- out3:
-	sysfs_remove_bin_file(&dev->dev.kobj, &bridge_forward);
  out2:
 	sysfs_remove_group(&dev->dev.kobj, &bridge_group);
  out1:
@@ -874,6 +867,5 @@ void br_sysfs_delbr(struct net_device *dev)
 	struct net_bridge *br = netdev_priv(dev);
 
 	kobject_put(br->ifobj);
-	sysfs_remove_bin_file(kobj, &bridge_forward);
 	sysfs_remove_group(kobj, &bridge_group);
 }

                 reply	other threads:[~2013-08-22 18:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20130822183048.GA6517@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bridge@lists.linux-foundation.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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).