public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PowerOP, PowerOP Sysfs 2/3
@ 2006-08-24  1:12 Eugeny S. Mints
  2006-08-25  5:58 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Eugeny S. Mints @ 2006-08-24  1:12 UTC (permalink / raw)
  To: pm list

[-- Attachment #1: Type: text/plain, Size: 33 bytes --]

Reference SysFS code for PowerOP

[-- Attachment #2: powerop.sysfs.patch --]
[-- Type: text/x-patch, Size: 3010 bytes --]

diff --git a/drivers/powerop/Kconfig b/drivers/powerop/Kconfig
index 94d2459..fe5c946 100644
--- a/drivers/powerop/Kconfig
+++ b/drivers/powerop/Kconfig
@@ -8,5 +8,10 @@ config POWEROP
 	bool "PowerOP Core"
 	help
 
+config POWEROP_SYSFS
+	bool "  Enable PowerOP sysfs interface"
+	depends on POWEROP && SYSFS
+	help
+ 
 endmenu
 
diff --git a/drivers/powerop/Makefile b/drivers/powerop/Makefile
index 131b983..1d430ce 100644
--- a/drivers/powerop/Makefile
+++ b/drivers/powerop/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_POWEROP)		+= powerop.o
+obj-$(CONFIG_POWEROP_SYSFS)     += powerop_sysfs.o
 
diff --git a/drivers/powerop/powerop_sysfs.c b/drivers/powerop/powerop_sysfs.c
new file mode 100644
index 0000000..6cfd45f
--- /dev/null
+++ b/drivers/powerop/powerop_sysfs.c
@@ -0,0 +1,99 @@
+/*
+ * PowerOP sysfs UI
+ *
+ * Author: Todd Poynor <tpoynor@mvista.com>
+ *
+ * 2005 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/powerop.h>
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+
+
+#define powerop_attr(_name) \
+static struct subsys_attribute _name##_attr = { \
+	.attr   = {				\
+		.name = __stringify(_name),	\
+		.mode = 0644,			\
+		.owner = THIS_MODULE,		\
+	},					\
+	.show   = _name##_show,                 \
+	.store  = _name##_store,                \
+}
+
+decl_subsys(powerop, NULL, NULL);
+static char active_name[32];
+
+static ssize_t active_show(struct subsystem * subsys, char * buf)
+{
+	return sprintf(buf, "%s\n", active_name);
+}
+
+static ssize_t active_store(struct subsystem * subsys, const char * buf,
+			    size_t n)
+{
+	int error;
+	
+	error = powerop_set_point(buf);
+	if (error != 0)
+		return error;
+
+	strcpy(active_name, buf);
+	return n;
+}
+
+powerop_attr(active);
+
+static struct attribute * g[] = {
+	&active_attr.attr,
+	NULL,
+};
+
+static struct attribute_group attr_group = {
+	.attrs = g,
+};
+
+static int __init powerop_sysfs_init(void)
+{
+        int error;
+
+	if ((error = subsystem_register(&powerop_subsys))) {
+		printk(KERN_ERR
+		       "PowerOP SysFS subsystem_register failed.\n");
+		return error;
+	}
+
+	if ((error =
+	     sysfs_create_group(&powerop_subsys.kset.kobj,&attr_group))) {
+		printk(KERN_ERR
+		       "PowerOP subsys sysfs_create_group failed.\n");
+		subsystem_unregister(&powerop_subsys);
+		return error;
+	}
+
+        return 0;
+}
+
+static void __exit powerop_sysfs_exit(void)
+{
+	sysfs_remove_group(&powerop_subsys.kset.kobj,&attr_group);
+	subsystem_unregister(&powerop_subsys);
+}
+
+module_init(powerop_sysfs_init);
+module_exit(powerop_sysfs_exit);
+
+MODULE_DESCRIPTION("PowerOP Power Management SysFS UI");
+MODULE_LICENSE("GPL");
+

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-25  5:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-24  1:12 [PATCH] PowerOP, PowerOP Sysfs 2/3 Eugeny S. Mints
2006-08-25  5:58 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox