mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bryan Wu <bryan.wu@canonical.com>
To: gregkh@linuxfoundation.org, ccross@android.com, hmh@hmh.eng.br,
	rpurdie@rpsys.net, linux-kernel@vger.kernel.org,
	linux-leds@vger.kernel.org
Subject: [PATCH 2/3] drivers: add a new device_create_file_uevent API
Date: Fri, 27 Jul 2012 12:02:42 +0800	[thread overview]
Message-ID: <1343361763-10307-3-git-send-email-bryan.wu@canonical.com> (raw)
In-Reply-To: <1343361763-10307-1-git-send-email-bryan.wu@canonical.com>

This will use sysfs_create_file_uevent to create a sysfs file and send out
a uevent to userspace application such as udev.

Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
 drivers/base/core.c    | 19 +++++++++++++++++++
 include/linux/device.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 346be8b..62fd266 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -538,6 +538,25 @@ int device_create_file(struct device *dev,
 }
 
 /**
+ * device_create_file_uevent - create sysfs attribute file for device
+ *				and send a uevent to userspace.
+ * @dev: device.
+ * @attr: device attribute descriptor.
+ * @desc: description about the uevent.
+ * @action: kobject uevent action type.
+ */
+int device_create_file_uevent(struct device *dev,
+		       const struct device_attribute *attr,
+		       const char *desc,
+		       enum kobject_action action)
+{
+	int error = 0;
+	if (dev)
+		error = sysfs_create_file_uevent(&dev->kobj, &attr->attr,
+						 desc, action);
+	return error;
+}
+/**
  * device_remove_file - remove sysfs attribute file.
  * @dev: device.
  * @attr: device attribute descriptor.
diff --git a/include/linux/device.h b/include/linux/device.h
index 6de9415..d1545f3 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -510,6 +510,10 @@ ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
 
 extern int device_create_file(struct device *device,
 			      const struct device_attribute *entry);
+extern int device_create_file_uevent(struct device *dev,
+				const struct device_attribute *attr,
+			       const char *desc,
+			       enum kobject_action action);
 extern void device_remove_file(struct device *dev,
 			       const struct device_attribute *attr);
 extern int __must_check device_create_bin_file(struct device *dev,
-- 
1.7.11.1


  parent reply	other threads:[~2012-07-27  4:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27  4:02 [PATCH 0/3] add new API to sysfs and device core code Bryan Wu
2012-07-27  4:02 ` [PATCH 1/3] sysfs: introduce a sysfs_create_file_uevent new API Bryan Wu
2012-07-27 15:52   ` Greg KH
2012-07-28 15:18     ` Bryan Wu
2012-07-27  4:02 ` Bryan Wu [this message]
2012-07-27  4:02 ` [PATCH 3/3] ledtrig-timer: convert to use device_create_file_uevent API Bryan Wu
2012-07-27 15:50 ` [PATCH 0/3] add new API to sysfs and device core code Greg KH
2012-07-27 19:38   ` Colin Cross

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=1343361763-10307-3-git-send-email-bryan.wu@canonical.com \
    --to=bryan.wu@canonical.com \
    --cc=ccross@android.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hmh@hmh.eng.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /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

all inboxes | Powered by JetHome®