All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: unlisted-recipients:; (no To-header on input)
Cc: Grant Likely <grant.likely@secretlab.ca>,
	linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] Export device_add_attributes() so drivers can use it.
Date: Wed, 18 Feb 2009 08:11:34 -0700	[thread overview]
Message-ID: <20090218151132.476.81706.stgit@localhost.localdomain> (raw)

From: Grant Likely <grant.likely@secretlab.ca>

I find myself using the pattern of device_add_attributes() and
device_remove_attributes() frequently in my drivers.  Rather than
reinventing the wheel every time, I'm floating this patch to export
the symbols to see how it is received.  If this looks okay then I'll
rework my drivers and post additional patches to use these functions.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: linux-kernel@vger.kernel.org
CC: Greg Kroah-Hartman <gregkh@suse.de>
---

 drivers/base/core.c    |   10 ++++++----
 include/linux/device.h |    4 ++++
 2 files changed, 10 insertions(+), 4 deletions(-)


diff --git a/drivers/base/core.c b/drivers/base/core.c
index f3eae63..5393eb6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -302,8 +302,8 @@ out:
 static struct device_attribute uevent_attr =
 	__ATTR(uevent, S_IRUGO | S_IWUSR, show_uevent, store_uevent);
 
-static int device_add_attributes(struct device *dev,
-				 struct device_attribute *attrs)
+int device_add_attributes(struct device *dev,
+			  struct device_attribute *attrs)
 {
 	int error = 0;
 	int i;
@@ -320,9 +320,10 @@ static int device_add_attributes(struct device *dev,
 	}
 	return error;
 }
+EXPORT_SYMBOL(device_add_attributes);
 
-static void device_remove_attributes(struct device *dev,
-				     struct device_attribute *attrs)
+void device_remove_attributes(struct device *dev,
+			      struct device_attribute *attrs)
 {
 	int i;
 
@@ -330,6 +331,7 @@ static void device_remove_attributes(struct device *dev,
 		for (i = 0; attr_name(attrs[i]); i++)
 			device_remove_file(dev, &attrs[i]);
 }
+EXPORT_SYMBOL(device_remove_attributes);
 
 static int device_add_groups(struct device *dev,
 			     struct attribute_group **groups)
diff --git a/include/linux/device.h b/include/linux/device.h
index 45e5b19..2a64d84 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -310,6 +310,10 @@ extern int __must_check device_create_file(struct device *device,
 					   struct device_attribute *entry);
 extern void device_remove_file(struct device *dev,
 			       struct device_attribute *attr);
+extern int device_add_attributes(struct device *dev,
+				 struct device_attribute *attrs);
+extern void device_remove_attributes(struct device *dev,
+				     struct device_attribute *attrs);
 extern int __must_check device_create_bin_file(struct device *dev,
 					       struct bin_attribute *attr);
 extern void device_remove_bin_file(struct device *dev,


             reply	other threads:[~2009-02-18 15:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 15:11 Grant Likely [this message]
2009-02-18 15:29 ` [PATCH] Export device_add_attributes() so drivers can use it Greg KH
2009-02-18 15:45   ` Kay Sievers
2009-02-18 15:48     ` Grant Likely
2009-02-18 15:53       ` Kay Sievers
2009-02-18 16:34         ` Grant Likely
2009-02-18 16:49           ` Kay Sievers
2009-02-18 17:51             ` Grant Likely
2009-02-18 18:32               ` Kay Sievers
2009-02-18 18:39                 ` Greg KH
2009-02-18 19:14                   ` Kay Sievers
2009-02-19  6:50                   ` Grant Likely
2009-02-19 23:08                     ` Kay Sievers
2009-02-20 15:28                       ` Grant Likely
2009-02-20 18:35                         ` Greg KH
2009-02-26 22:28                         ` Kay Sievers
2009-02-26 23:52                           ` Grant Likely
2009-02-18 15:46   ` Grant Likely

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=20090218151132.476.81706.stgit@localhost.localdomain \
    --to=grant.likely@secretlab.ca \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.