1 /* /driver/sensors/core/sensors_core.c
2 * Copyright (C) 2011 Samsung Electronics. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 #include <linux/module.h>
20 #include <linux/types.h>
21 #include <linux/init.h>
22 #include <linux/device.h>
24 #include <linux/err.h>
27 struct class *sensors_class;
28 EXPORT_SYMBOL_GPL(sensors_class);
32 * Create sysfs interface
34 static void set_sensor_attr(struct device *dev,
35 struct device_attribute *attributes[])
39 for (i = 0 ; attributes[i] != NULL ; i++) {
40 if ((device_create_file(dev, attributes[i])) < 0)
41 pr_err("Create_dev_file fail(attributes[%d] )\n", i);
45 int sensors_register(struct device *dev, void * drvdata,
46 struct device_attribute *attributes[], char *name)
51 sensors_class = class_create(THIS_MODULE, "sensors");
52 if (IS_ERR(sensors_class))
53 return PTR_ERR(sensors_class);
57 dev = device_create(sensors_class, NULL, 0, drvdata, "%s", name);
61 pr_err("[SENSORS CORE] device_create failed! [%d]\n", ret);
65 set_sensor_attr(dev, attributes);
70 EXPORT_SYMBOL_GPL(sensors_register);
72 void sensors_unregister(struct device *dev,struct device_attribute *attributes[])
76 if (sensors_class != NULL) {
77 for (i = 0 ; attributes[i] != NULL ; i++)
78 device_remove_file(dev, attributes[i]);
81 EXPORT_SYMBOL_GPL(sensors_unregister);
83 static int __init sensors_class_init(void)
85 pr_debug("[SENSORS CORE] sensors_class_init\n");
86 sensors_class = class_create(THIS_MODULE, "sensors");
88 if (IS_ERR(sensors_class))
89 return PTR_ERR(sensors_class);
91 sensors_class->dev_uevent = NULL;
96 static void __exit sensors_class_exit(void)
98 class_destroy(sensors_class);
102 /* exported for the APM Power driver, APM emulation */
104 subsys_initcall(sensors_class_init);
105 module_exit(sensors_class_exit);
107 MODULE_DESCRIPTION("Universal sensors core class");
108 MODULE_AUTHOR("Ryunkyun Park <ryun.park@samsung.com>");
109 MODULE_LICENSE("GPL");