public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH 2/2] drivers/core: Add support for devm_ functions
Date: Thu, 14 Mar 2013 20:24:47 -0700	[thread overview]
Message-ID: <1363317887-24009-3-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1363317887-24009-1-git-send-email-linux@roeck-us.net>

Add support for devm_device_create_file and devm_device_remove_file.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/base/core.c    |   18 ++++++++++++++++++
 include/linux/device.h |    4 ++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 56536f4b0..76ff488 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -568,6 +568,16 @@ int device_create_file(struct device *dev,
 	return error;
 }
 
+int devm_device_create_file(struct device *dev,
+			    const struct device_attribute *attr)
+{
+	int error = 0;
+	if (dev)
+		error = devm_sysfs_create_file(dev, &attr->attr);
+	return error;
+}
+EXPORT_SYMBOL_GPL(devm_device_create_file);
+
 /**
  * device_remove_file - remove sysfs attribute file.
  * @dev: device.
@@ -580,6 +590,14 @@ void device_remove_file(struct device *dev,
 		sysfs_remove_file(&dev->kobj, &attr->attr);
 }
 
+void devm_device_remove_file(struct device *dev,
+			     const struct device_attribute *attr)
+{
+	if (dev)
+		devm_sysfs_remove_file(dev, &attr->attr);
+}
+EXPORT_SYMBOL_GPL(devm_device_remove_file);
+
 /**
  * device_create_bin_file - create sysfs binary attribute file for device.
  * @dev: device.
diff --git a/include/linux/device.h b/include/linux/device.h
index 9d6464e..1c56fb7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -521,8 +521,12 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
 
 extern int device_create_file(struct device *device,
 			      const struct device_attribute *entry);
+extern int devm_device_create_file(struct device *device,
+				   const struct device_attribute *entry);
 extern void device_remove_file(struct device *dev,
 			       const struct device_attribute *attr);
+extern void devm_device_remove_file(struct device *dev,
+				    const struct device_attribute *attr);
 extern int __must_check device_create_bin_file(struct device *dev,
 					const struct bin_attribute *attr);
 extern void device_remove_bin_file(struct device *dev,
-- 
1.7.9.7


  parent reply	other threads:[~2013-03-15  3:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15  3:24 [RFC PATCH 0/2] fs: sysfs: Add devres support Guenter Roeck
2013-03-15  3:24 ` [RFC PATCH 1/2] fs: sysfs: Add support for devm_ functions Guenter Roeck
2013-03-15  3:24 ` Guenter Roeck [this message]
2013-03-16 16:21 ` [RFC PATCH 0/2] fs: sysfs: Add devres support Greg Kroah-Hartman
2013-03-16 18:12   ` Guenter Roeck
2013-03-16 19:50     ` Greg Kroah-Hartman
2013-03-16 21:25       ` Guenter Roeck
2013-03-17  6:30         ` [lm-sensors] " Guenter Roeck
2013-03-17 12:39         ` Jean Delvare
2013-03-17 13:19           ` Guenter Roeck
2013-03-17 14:54             ` Guenter Roeck
2013-03-18  8:02             ` Jean Delvare
2013-03-18 13:29               ` Guenter Roeck
2013-11-22 22:47   ` Dmitry Torokhov
2013-11-22 22:53     ` Greg Kroah-Hartman

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=1363317887-24009-3-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=gregkh@linuxfoundation.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox