From: sungmin82.ha Date: Fri, 17 Feb 2012 05:40:34 +0000 (+0900) Subject: [Title]modified for change directory and name of drivers to maru X-Git-Tag: 2.2.1_release^2~175 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de8adbcf35fd42e41fa662f7b7fe052f7a2d9ee3;p=sdk%2Femulator%2Femulator-kernel.git [Title]modified for change directory and name of drivers to maru [Type]Enhancement [Module]emulator-kernel drivers(jack,power_supply,usb_mass_storage,usb_mode) [Priority]Major [Jira#] // Jira Issue Number [Redmine#] // Redmine Isuue Number [Problem] // Problem Description [Cause] // Cause Description [Solution] // Solution Description [TestCase] // Executed the test-target (How to) Change-Id: I66c13bb99de06f71d10590324d4ade5302dca8ed --- diff --git a/arch/x86/configs/i386_emul_defconfig b/arch/x86/configs/i386_emul_defconfig index abe4c093b148..aaf2385743a0 100644 --- a/arch/x86/configs/i386_emul_defconfig +++ b/arch/x86/configs/i386_emul_defconfig @@ -1354,7 +1354,6 @@ CONFIG_I2C_I801=y CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y # CONFIG_GPIOLIB is not set # CONFIG_W1 is not set -CONFIG_POWER_SUPPLY=y # CONFIG_POWER_SUPPLY_DEBUG is not set # CONFIG_PDA_POWER is not set # CONFIG_BATTERY_DS2760 is not set @@ -2170,6 +2169,10 @@ CONFIG_MARU_TOUCHSCREEN=y CONFIG_MARU_FB=y CONFIG_MARU_CAMERA=y CONFIG_MARU_BACKLIGHT=y +CONFIG_MARU_JACK=y +CONFIG_MARU_POWER_SUPPLY=y +CONFIG_MARU_USB_MASS_STORAGE=y +CONFIG_MARU_USB_MODE=y CONFIG_X86_PLATFORM_DEVICES=y # CONFIG_ACER_WMI is not set # CONFIG_ASUS_LAPTOP is not set diff --git a/drivers/Makefile b/drivers/Makefile index ace2231bfd34..1d672be39c88 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -75,7 +75,6 @@ obj-$(CONFIG_RTC_LIB) += rtc/ obj-y += i2c/ media/ obj-$(CONFIG_PPS) += pps/ obj-$(CONFIG_W1) += w1/ -obj-$(CONFIG_POWER_SUPPLY) += power_supply/ obj-$(CONFIG_HWMON) += hwmon/ obj-$(CONFIG_THERMAL) += thermal/ obj-$(CONFIG_WATCHDOG) += watchdog/ @@ -111,8 +110,5 @@ obj-$(CONFIG_VLYNQ) += vlynq/ obj-$(CONFIG_STAGING) += staging/ obj-y += platform/ obj-y += ieee802154/ -obj-y += jack/ -obj-y += usb_mode/ -obj-y += usb_mass_storage/ obj-$(CONFIG_MARU) += maru/ diff --git a/drivers/jack/Kconfig b/drivers/jack/Kconfig deleted file mode 100644 index a3c5b97e4778..000000000000 --- a/drivers/jack/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# Character device configuration -# - -menu "Character devices" - -source "drivers/jack/Kconfig" - -config JACK - "jack" - - -endmenu diff --git a/drivers/jack/Makefile b/drivers/jack/Makefile deleted file mode 100644 index 27636fa6ebb5..000000000000 --- a/drivers/jack/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += mod_jack.o diff --git a/drivers/jack/mod_jack.c b/drivers/jack/mod_jack.c deleted file mode 100644 index ff64c4cd2062..000000000000 --- a/drivers/jack/mod_jack.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Virtual device node for event injector of emulator - * - * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Sungmin Ha - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - */ - -#include -#include -#include -#include - -int charger_online = 0; -int earjack_online = 0; -int earkey_online = 0; -int hdmi_online = 0; -int usb_online = 0; - -struct my_data { - int no; - char test[50]; -}; - -static ssize_t show_charger_online(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", charger_online); -} - -static ssize_t store_charger_online(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &charger_online); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_earjack_online(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", earjack_online); -} - -static ssize_t store_earjack_online(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &earjack_online); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_earkey_online(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", earkey_online); -} - -static ssize_t store_earkey_online(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &earkey_online); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_hdmi_online(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", hdmi_online); -} - -static ssize_t store_hdmi_online(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &hdmi_online); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_usb_online(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", usb_online); -} - -static ssize_t store_usb_online(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &usb_online); - return strnlen(buf, PAGE_SIZE); -} -static DEVICE_ATTR(charger_online, S_IRUGO | S_IWUSR, show_charger_online, store_charger_online); -static DEVICE_ATTR(earjack_online, S_IRUGO | S_IWUSR, show_earjack_online, store_earjack_online); -static DEVICE_ATTR(earkey_online, S_IRUGO | S_IWUSR, show_earkey_online, store_earkey_online); -static DEVICE_ATTR(hdmi_online, S_IRUGO | S_IWUSR, show_hdmi_online, store_hdmi_online); -static DEVICE_ATTR(usb_online, S_IRUGO | S_IWUSR, show_usb_online, store_usb_online); - -static int sysfs_test_create_file(struct device *dev) -{ - int result = 0; - - printk("[%d] [%s] \n", __LINE__, __FUNCTION__); - - result = device_create_file(dev, &dev_attr_charger_online); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - result = device_create_file(dev, &dev_attr_earjack_online); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - result = device_create_file(dev, &dev_attr_earkey_online); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - result = device_create_file(dev, &dev_attr_hdmi_online); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - result = device_create_file(dev, &dev_attr_usb_online); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - return 0; -} - - -static void sysfs_test_remove_file(struct device *dev) -{ - printk("[%s] \n", __FUNCTION__); - device_remove_file(dev, &dev_attr_charger_online); - device_remove_file(dev, &dev_attr_earjack_online); - device_remove_file(dev, &dev_attr_earkey_online); - device_remove_file(dev, &dev_attr_hdmi_online); - device_remove_file(dev, &dev_attr_usb_online); -} - -static void sysfs_test_dev_release(struct device *dev) {} - -static struct platform_device the_pdev = { - .name = "jack", - .id = -1, - .dev = { - .release = sysfs_test_dev_release, - } -}; - -static int __init sysfs_test_init(void) -{ - int err = 0; - struct my_data *data; - - printk("[%s] \n", __FUNCTION__); - - err = platform_device_register(&the_pdev); - if (err) { - printk("platform_device_register error\n"); - return err; - } - - data = kzalloc(sizeof(struct my_data), GFP_KERNEL); - if (!data) { - printk("[%s] kzalloc error\n", __FUNCTION__); - err = -ENOMEM; - goto alloc_err; - } - - dev_set_drvdata(&the_pdev.dev, (void*)data); - - err = sysfs_test_create_file(&the_pdev.dev); - if (err) { - printk("sysfs_create_file error\n"); - goto sysfs_err; - } - - return 0; - -sysfs_err: - kfree(data); - -alloc_err: - platform_device_unregister(&the_pdev); - return err; -} - -static void __exit sysfs_test_exit(void) -{ - void *data = dev_get_drvdata(&the_pdev.dev); - - printk("[%s] \n", __FUNCTION__); - - kfree(data); - sysfs_test_remove_file(&the_pdev.dev); - platform_device_unregister(&the_pdev); -} - -module_init(sysfs_test_init); -module_exit(sysfs_test_exit); - - -MODULE_LICENSE("GPL"); - - diff --git a/drivers/maru/Kconfig b/drivers/maru/Kconfig index 1743c1d3cf5e..e92ae35e40a4 100644 --- a/drivers/maru/Kconfig +++ b/drivers/maru/Kconfig @@ -31,3 +31,18 @@ config MARU_BACKLIGHT help Say Y to enable the backlight driver of MARU. +config MARU_JACK + tristate "MARU Jack Driver" + depends on MARU != n + +config MARU_POWER_SUPPLY + tristate "MARU Power supply Driver" + depends on MARU != n + +config MARU_USB_MASS_STORAGE + tristate "MARU Usb mass storage Driver" + depends on MARU != n + +config MARU_USB_MODE + tristate "MARU Usb mode Driver" + depends on MARU != n diff --git a/drivers/maru/Makefile b/drivers/maru/Makefile index 531bfb306e3b..491e496edbf5 100644 --- a/drivers/maru/Makefile +++ b/drivers/maru/Makefile @@ -4,3 +4,7 @@ obj-$(CONFIG_MARU_TOUCHSCREEN) += maru_touchscreen.o obj-$(CONFIG_MARU_FB) += maru_fb.o obj-$(CONFIG_MARU_CAMERA) += maru_camera.o obj-$(CONFIG_MARU_CAMERA) += maru_bl.o +obj-$(CONFIG_MARU_JACK) += maru_jack.o +obj-$(CONFIG_MARU_POWER_SUPPLY) += maru_power_supply.o +obj-$(CONFIG_MARU_USB_MASS_STORAGE) += maru_usb_mass_storage.o +obj-$(CONFIG_MARU_USB_MODE) += maru_usb_mode.o diff --git a/drivers/maru/maru_jack.c b/drivers/maru/maru_jack.c new file mode 100644 index 000000000000..ff64c4cd2062 --- /dev/null +++ b/drivers/maru/maru_jack.c @@ -0,0 +1,238 @@ +/* + * Virtual device node for event injector of emulator + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + */ + +#include +#include +#include +#include + +int charger_online = 0; +int earjack_online = 0; +int earkey_online = 0; +int hdmi_online = 0; +int usb_online = 0; + +struct my_data { + int no; + char test[50]; +}; + +static ssize_t show_charger_online(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", charger_online); +} + +static ssize_t store_charger_online(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &charger_online); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_earjack_online(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", earjack_online); +} + +static ssize_t store_earjack_online(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &earjack_online); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_earkey_online(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", earkey_online); +} + +static ssize_t store_earkey_online(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &earkey_online); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_hdmi_online(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", hdmi_online); +} + +static ssize_t store_hdmi_online(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &hdmi_online); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_usb_online(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", usb_online); +} + +static ssize_t store_usb_online(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &usb_online); + return strnlen(buf, PAGE_SIZE); +} +static DEVICE_ATTR(charger_online, S_IRUGO | S_IWUSR, show_charger_online, store_charger_online); +static DEVICE_ATTR(earjack_online, S_IRUGO | S_IWUSR, show_earjack_online, store_earjack_online); +static DEVICE_ATTR(earkey_online, S_IRUGO | S_IWUSR, show_earkey_online, store_earkey_online); +static DEVICE_ATTR(hdmi_online, S_IRUGO | S_IWUSR, show_hdmi_online, store_hdmi_online); +static DEVICE_ATTR(usb_online, S_IRUGO | S_IWUSR, show_usb_online, store_usb_online); + +static int sysfs_test_create_file(struct device *dev) +{ + int result = 0; + + printk("[%d] [%s] \n", __LINE__, __FUNCTION__); + + result = device_create_file(dev, &dev_attr_charger_online); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + result = device_create_file(dev, &dev_attr_earjack_online); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + result = device_create_file(dev, &dev_attr_earkey_online); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + result = device_create_file(dev, &dev_attr_hdmi_online); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + result = device_create_file(dev, &dev_attr_usb_online); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + return 0; +} + + +static void sysfs_test_remove_file(struct device *dev) +{ + printk("[%s] \n", __FUNCTION__); + device_remove_file(dev, &dev_attr_charger_online); + device_remove_file(dev, &dev_attr_earjack_online); + device_remove_file(dev, &dev_attr_earkey_online); + device_remove_file(dev, &dev_attr_hdmi_online); + device_remove_file(dev, &dev_attr_usb_online); +} + +static void sysfs_test_dev_release(struct device *dev) {} + +static struct platform_device the_pdev = { + .name = "jack", + .id = -1, + .dev = { + .release = sysfs_test_dev_release, + } +}; + +static int __init sysfs_test_init(void) +{ + int err = 0; + struct my_data *data; + + printk("[%s] \n", __FUNCTION__); + + err = platform_device_register(&the_pdev); + if (err) { + printk("platform_device_register error\n"); + return err; + } + + data = kzalloc(sizeof(struct my_data), GFP_KERNEL); + if (!data) { + printk("[%s] kzalloc error\n", __FUNCTION__); + err = -ENOMEM; + goto alloc_err; + } + + dev_set_drvdata(&the_pdev.dev, (void*)data); + + err = sysfs_test_create_file(&the_pdev.dev); + if (err) { + printk("sysfs_create_file error\n"); + goto sysfs_err; + } + + return 0; + +sysfs_err: + kfree(data); + +alloc_err: + platform_device_unregister(&the_pdev); + return err; +} + +static void __exit sysfs_test_exit(void) +{ + void *data = dev_get_drvdata(&the_pdev.dev); + + printk("[%s] \n", __FUNCTION__); + + kfree(data); + sysfs_test_remove_file(&the_pdev.dev); + platform_device_unregister(&the_pdev); +} + +module_init(sysfs_test_init); +module_exit(sysfs_test_exit); + + +MODULE_LICENSE("GPL"); + + diff --git a/drivers/maru/maru_power_supply.c b/drivers/maru/maru_power_supply.c new file mode 100644 index 000000000000..54ab5b4ff759 --- /dev/null +++ b/drivers/maru/maru_power_supply.c @@ -0,0 +1,113 @@ +/* + * Virtual device node for event injector of emulator + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + */ + +#include +#include +#include +#include + +static struct class *mtd_class; +static struct device* mtd_device; + +static int capacity = 100; +static int charge_full = 1; +static int charge_now = 0; + +static ssize_t show_capacity(struct device *dev, struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", capacity); +} + +static ssize_t store_capacity(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &capacity); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_charge_full(struct device *dev, struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", charge_full); +} + +static ssize_t store_charge_full(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &charge_full); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_charge_now(struct device *dev, struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", charge_now); +} + +static ssize_t store_charge_now(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &charge_now); + return strnlen(buf, PAGE_SIZE); +} + +static struct device_attribute ps_device_attributes[] = { + __ATTR(capacity, 0644, show_capacity, store_capacity), + __ATTR(charge_full, 0644, show_charge_full, store_charge_full), + __ATTR(charge_now, 0644, show_charge_now, store_charge_now), +}; + +struct device new_device_dev; + +static int __init sysfs_test_init(void) +{ + int err; + printk("[%s] \n", __FUNCTION__); + + mtd_class = class_create(THIS_MODULE, "power_supply"); + mtd_device = device_create(mtd_class, NULL, (dev_t)NULL, NULL, "battery"); + + err = device_create_file(mtd_device, &ps_device_attributes[0]); + err = device_create_file(mtd_device, &ps_device_attributes[1]); + err = device_create_file(mtd_device, &ps_device_attributes[2]); + + return 0; +} + +static void __exit sysfs_test_exit(void) +{ + printk("[%s] \n", __FUNCTION__); + class_destroy(mtd_class); +} + +module_init(sysfs_test_init); +module_exit(sysfs_test_exit); + + +MODULE_LICENSE("GPL"); + + diff --git a/drivers/maru/maru_usb_mass_storage.c b/drivers/maru/maru_usb_mass_storage.c new file mode 100644 index 000000000000..6a83b9ff0991 --- /dev/null +++ b/drivers/maru/maru_usb_mass_storage.c @@ -0,0 +1,239 @@ +/* + * Virtual device node for event injector of emulator + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + */ + +#include +#include +#include +#include + +static char mode[1024]; +static char file0[1024]; +static char file1[1024]; + +u64 file0_mask = 0x0000000000000000; +u64 file1_mask = 0x0000000000000001; + +struct my_data { + int no; + char test[50]; +}; + +static ssize_t show_mode(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%s", mode); +} + +static ssize_t store_mode(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%s", mode); + return strnlen(buf, PAGE_SIZE); +} + +static ssize_t show_file(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t ret = 0; + printk("[%s] \n", __FUNCTION__); + if(*(dev->dma_mask) == file0_mask) + ret = snprintf(buf, PAGE_SIZE, "%s", file0); + else + ret = snprintf(buf, PAGE_SIZE, "%s", file1); + + return ret; +} + +static ssize_t store_file(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + size_t ret; + printk("[%s]\n", __FUNCTION__); + if(*(dev->dma_mask) == file0_mask) + sscanf(buf, "%s", file0); + else + sscanf(buf, "%s", file1); + + ret = strnlen(buf, PAGE_SIZE); + if(ret == 0) + return 1; + else + return strnlen(buf, PAGE_SIZE); +} + +static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, show_mode, store_mode); +static DEVICE_ATTR(file, S_IRUGO | S_IWUSR, show_file, store_file); + +static int sysfs_lun0_create_file(struct device *dev) +{ + int result = 0; + + printk("[%d] [%s] \n", __LINE__, __FUNCTION__); + + result = device_create_file(dev, &dev_attr_mode); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + result = device_create_file(dev, &dev_attr_file); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + return 0; +} + +static int sysfs_lun1_create_file(struct device *dev) +{ + int result = 0; + + printk("[%d] [%s] \n", __LINE__, __FUNCTION__); + + result = device_create_file(dev, &dev_attr_file); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + return 0; +} + +static void sysfs_test_dev_release(struct device *dev) {} +static void sysfs_test_dev_release_lun0(struct device *dev) {} + +static struct platform_device the_pdev = { + .name = "usb_mass_storage", + .id = -1, + .dev = { + .release = sysfs_test_dev_release, + } +}; + +static struct platform_device the_pdev_sub1 = { + .name = "lun0", + .id = -1, + .dev = { + .release = sysfs_test_dev_release_lun0, + .parent = &the_pdev.dev, + .dma_mask = &file0_mask, + } +}; + +static struct platform_device the_pdev_sub2 = { + .name = "lun1", + .id = -1, + .dev = { + .release = sysfs_test_dev_release_lun0, + .parent = &the_pdev.dev, + .dma_mask = &file1_mask, + } +}; + +static int __init sysfs_test_init(void) +{ + int err = 0; + struct my_data *data; + + printk("[%s] \n", __FUNCTION__); + + memset(mode, 0, sizeof(mode)); + memset(file0, 0, sizeof(file0)); + memset(file1, 0, sizeof(file1)); + + err = platform_device_register(&the_pdev); + if (err) { + printk("platform_device_register error\n"); + return err; + } + + err = platform_device_register(&the_pdev_sub1); + if (err) { + printk("platform_device_register error\n"); + return err; + } + + err = platform_device_register(&the_pdev_sub2); + if (err) { + printk("platform_device_register error\n"); + return err; + } + + data = kzalloc(sizeof(struct my_data), GFP_KERNEL); + if (!data) { + printk("[%s] kzalloc error\n", __FUNCTION__); + err = -ENOMEM; + goto alloc_err; + } + + dev_set_drvdata(&the_pdev.dev, (void*)data); + dev_set_drvdata(&the_pdev_sub1.dev, (void*)data); + dev_set_drvdata(&the_pdev_sub2.dev, (void*)data); + + err = sysfs_lun0_create_file(&the_pdev_sub1.dev); + if (err) { + printk("sysfs_create_file error\n"); + goto sysfs_err; + } + + err = sysfs_lun1_create_file(&the_pdev_sub2.dev); + if (err) { + printk("sysfs_create_file error\n"); + goto sysfs_err; + } + + return 0; + +sysfs_err: + kfree(data); + +alloc_err: + platform_device_unregister(&the_pdev); + return err; +} + +static void __exit sysfs_test_exit(void) +{ + void *data = dev_get_drvdata(&the_pdev.dev); + + printk("[%s] \n", __FUNCTION__); + + kfree(data); + platform_device_unregister(&the_pdev_sub2); + platform_device_unregister(&the_pdev_sub1); + platform_device_unregister(&the_pdev); +} + +module_init(sysfs_test_init); +module_exit(sysfs_test_exit); + + +MODULE_LICENSE("GPL"); + + diff --git a/drivers/maru/maru_usb_mode.c b/drivers/maru/maru_usb_mode.c new file mode 100644 index 000000000000..c2a352051fed --- /dev/null +++ b/drivers/maru/maru_usb_mode.c @@ -0,0 +1,143 @@ +/* + * Virtual device node for event injector of emulator + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + */ + +#include +#include +#include +#include + +int UsbMenuSel = 0; + +struct my_data { + int no; + char test[50]; +}; + +static ssize_t show_UsbMenuSel(struct device *dev, + struct device_attribute *attr, char *buf) +{ + printk("[%s] \n", __FUNCTION__); + return snprintf(buf, PAGE_SIZE, "%d", UsbMenuSel); +} + +static ssize_t store_UsbMenuSel(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + printk("[%s] \n", __FUNCTION__); + sscanf(buf, "%d", &UsbMenuSel); + return strnlen(buf, PAGE_SIZE); +} + +static DEVICE_ATTR(UsbMenuSel, S_IRUGO | S_IWUSR, show_UsbMenuSel, store_UsbMenuSel); + +static int sysfs_test_create_file(struct device *dev) +{ + int result = 0; + + printk("[%d] [%s] \n", __LINE__, __FUNCTION__); + + result = device_create_file(dev, &dev_attr_UsbMenuSel); + if (result){ + printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); + return result; + } + + return 0; +} + + +static void sysfs_test_remove_file(struct device *dev) +{ + printk("[%s] \n", __FUNCTION__); + device_remove_file(dev, &dev_attr_UsbMenuSel); +} + +static void sysfs_test_dev_release(struct device *dev) {} + +static struct platform_device the_pdev = { + .name = "usb_mode", + .id = -1, + .dev = { + .release = sysfs_test_dev_release, + } +}; + +static int __init sysfs_test_init(void) +{ + int err = 0; + struct my_data *data; + + printk("[%s] \n", __FUNCTION__); + + err = platform_device_register(&the_pdev); + if (err) { + printk("platform_device_register error\n"); + return err; + } + + data = kzalloc(sizeof(struct my_data), GFP_KERNEL); + if (!data) { + printk("[%s] kzalloc error\n", __FUNCTION__); + err = -ENOMEM; + goto alloc_err; + } + + dev_set_drvdata(&the_pdev.dev, (void*)data); + + err = sysfs_test_create_file(&the_pdev.dev); + if (err) { + printk("sysfs_create_file error\n"); + goto sysfs_err; + } + + return 0; + +sysfs_err: + kfree(data); + +alloc_err: + platform_device_unregister(&the_pdev); + return err; +} + +static void __exit sysfs_test_exit(void) +{ + void *data = dev_get_drvdata(&the_pdev.dev); + + printk("[%s] \n", __FUNCTION__); + + kfree(data); + sysfs_test_remove_file(&the_pdev.dev); + platform_device_unregister(&the_pdev); +} + +module_init(sysfs_test_init); +module_exit(sysfs_test_exit); + + +MODULE_LICENSE("GPL"); + + diff --git a/drivers/power_supply/Kconfig b/drivers/power_supply/Kconfig deleted file mode 100644 index 6e49e2ad166d..000000000000 --- a/drivers/power_supply/Kconfig +++ /dev/null @@ -1,14 +0,0 @@ -# -# Character device configuration -# - -menu "Character devices" - -source "drivers/power_supply/Kconfig" - -config POWER_SUPPLY - "power supply" - - -endmenu - diff --git a/drivers/power_supply/Makefile b/drivers/power_supply/Makefile deleted file mode 100644 index e8ed86613908..000000000000 --- a/drivers/power_supply/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_POWER_SUPPLY) += mod_power_supply.o diff --git a/drivers/power_supply/mod_power_supply.c b/drivers/power_supply/mod_power_supply.c deleted file mode 100644 index 54ab5b4ff759..000000000000 --- a/drivers/power_supply/mod_power_supply.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Virtual device node for event injector of emulator - * - * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Sungmin Ha - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - */ - -#include -#include -#include -#include - -static struct class *mtd_class; -static struct device* mtd_device; - -static int capacity = 100; -static int charge_full = 1; -static int charge_now = 0; - -static ssize_t show_capacity(struct device *dev, struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", capacity); -} - -static ssize_t store_capacity(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &capacity); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_charge_full(struct device *dev, struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", charge_full); -} - -static ssize_t store_charge_full(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &charge_full); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_charge_now(struct device *dev, struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", charge_now); -} - -static ssize_t store_charge_now(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &charge_now); - return strnlen(buf, PAGE_SIZE); -} - -static struct device_attribute ps_device_attributes[] = { - __ATTR(capacity, 0644, show_capacity, store_capacity), - __ATTR(charge_full, 0644, show_charge_full, store_charge_full), - __ATTR(charge_now, 0644, show_charge_now, store_charge_now), -}; - -struct device new_device_dev; - -static int __init sysfs_test_init(void) -{ - int err; - printk("[%s] \n", __FUNCTION__); - - mtd_class = class_create(THIS_MODULE, "power_supply"); - mtd_device = device_create(mtd_class, NULL, (dev_t)NULL, NULL, "battery"); - - err = device_create_file(mtd_device, &ps_device_attributes[0]); - err = device_create_file(mtd_device, &ps_device_attributes[1]); - err = device_create_file(mtd_device, &ps_device_attributes[2]); - - return 0; -} - -static void __exit sysfs_test_exit(void) -{ - printk("[%s] \n", __FUNCTION__); - class_destroy(mtd_class); -} - -module_init(sysfs_test_init); -module_exit(sysfs_test_exit); - - -MODULE_LICENSE("GPL"); - - diff --git a/drivers/usb_mass_storage/Kconfig b/drivers/usb_mass_storage/Kconfig deleted file mode 100644 index a9e26ad21d89..000000000000 --- a/drivers/usb_mass_storage/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# Character device configuration -# - -menu "Character devices" - -source "drivers/usb_mass_storage/Kconfig" - -config USB_MASS_STORAGE - "usb mass storage" - - -endmenu diff --git a/drivers/usb_mass_storage/Makefile b/drivers/usb_mass_storage/Makefile deleted file mode 100644 index 026cbbd4a1c5..000000000000 --- a/drivers/usb_mass_storage/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += mod_usb_mass_storage.o diff --git a/drivers/usb_mass_storage/mod_usb_mass_storage.c b/drivers/usb_mass_storage/mod_usb_mass_storage.c deleted file mode 100644 index 6a83b9ff0991..000000000000 --- a/drivers/usb_mass_storage/mod_usb_mass_storage.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Virtual device node for event injector of emulator - * - * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Sungmin Ha - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - */ - -#include -#include -#include -#include - -static char mode[1024]; -static char file0[1024]; -static char file1[1024]; - -u64 file0_mask = 0x0000000000000000; -u64 file1_mask = 0x0000000000000001; - -struct my_data { - int no; - char test[50]; -}; - -static ssize_t show_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%s", mode); -} - -static ssize_t store_mode(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%s", mode); - return strnlen(buf, PAGE_SIZE); -} - -static ssize_t show_file(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = 0; - printk("[%s] \n", __FUNCTION__); - if(*(dev->dma_mask) == file0_mask) - ret = snprintf(buf, PAGE_SIZE, "%s", file0); - else - ret = snprintf(buf, PAGE_SIZE, "%s", file1); - - return ret; -} - -static ssize_t store_file(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - size_t ret; - printk("[%s]\n", __FUNCTION__); - if(*(dev->dma_mask) == file0_mask) - sscanf(buf, "%s", file0); - else - sscanf(buf, "%s", file1); - - ret = strnlen(buf, PAGE_SIZE); - if(ret == 0) - return 1; - else - return strnlen(buf, PAGE_SIZE); -} - -static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, show_mode, store_mode); -static DEVICE_ATTR(file, S_IRUGO | S_IWUSR, show_file, store_file); - -static int sysfs_lun0_create_file(struct device *dev) -{ - int result = 0; - - printk("[%d] [%s] \n", __LINE__, __FUNCTION__); - - result = device_create_file(dev, &dev_attr_mode); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - result = device_create_file(dev, &dev_attr_file); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - return 0; -} - -static int sysfs_lun1_create_file(struct device *dev) -{ - int result = 0; - - printk("[%d] [%s] \n", __LINE__, __FUNCTION__); - - result = device_create_file(dev, &dev_attr_file); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - return 0; -} - -static void sysfs_test_dev_release(struct device *dev) {} -static void sysfs_test_dev_release_lun0(struct device *dev) {} - -static struct platform_device the_pdev = { - .name = "usb_mass_storage", - .id = -1, - .dev = { - .release = sysfs_test_dev_release, - } -}; - -static struct platform_device the_pdev_sub1 = { - .name = "lun0", - .id = -1, - .dev = { - .release = sysfs_test_dev_release_lun0, - .parent = &the_pdev.dev, - .dma_mask = &file0_mask, - } -}; - -static struct platform_device the_pdev_sub2 = { - .name = "lun1", - .id = -1, - .dev = { - .release = sysfs_test_dev_release_lun0, - .parent = &the_pdev.dev, - .dma_mask = &file1_mask, - } -}; - -static int __init sysfs_test_init(void) -{ - int err = 0; - struct my_data *data; - - printk("[%s] \n", __FUNCTION__); - - memset(mode, 0, sizeof(mode)); - memset(file0, 0, sizeof(file0)); - memset(file1, 0, sizeof(file1)); - - err = platform_device_register(&the_pdev); - if (err) { - printk("platform_device_register error\n"); - return err; - } - - err = platform_device_register(&the_pdev_sub1); - if (err) { - printk("platform_device_register error\n"); - return err; - } - - err = platform_device_register(&the_pdev_sub2); - if (err) { - printk("platform_device_register error\n"); - return err; - } - - data = kzalloc(sizeof(struct my_data), GFP_KERNEL); - if (!data) { - printk("[%s] kzalloc error\n", __FUNCTION__); - err = -ENOMEM; - goto alloc_err; - } - - dev_set_drvdata(&the_pdev.dev, (void*)data); - dev_set_drvdata(&the_pdev_sub1.dev, (void*)data); - dev_set_drvdata(&the_pdev_sub2.dev, (void*)data); - - err = sysfs_lun0_create_file(&the_pdev_sub1.dev); - if (err) { - printk("sysfs_create_file error\n"); - goto sysfs_err; - } - - err = sysfs_lun1_create_file(&the_pdev_sub2.dev); - if (err) { - printk("sysfs_create_file error\n"); - goto sysfs_err; - } - - return 0; - -sysfs_err: - kfree(data); - -alloc_err: - platform_device_unregister(&the_pdev); - return err; -} - -static void __exit sysfs_test_exit(void) -{ - void *data = dev_get_drvdata(&the_pdev.dev); - - printk("[%s] \n", __FUNCTION__); - - kfree(data); - platform_device_unregister(&the_pdev_sub2); - platform_device_unregister(&the_pdev_sub1); - platform_device_unregister(&the_pdev); -} - -module_init(sysfs_test_init); -module_exit(sysfs_test_exit); - - -MODULE_LICENSE("GPL"); - - diff --git a/drivers/usb_mode/Kconfig b/drivers/usb_mode/Kconfig deleted file mode 100644 index 20670ebd80dd..000000000000 --- a/drivers/usb_mode/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# Character device configuration -# - -menu "Character devices" - -source "drivers/usb_mode/Kconfig" - -config USB_MODE - "usb_mode" - - -endmenu diff --git a/drivers/usb_mode/Makefile b/drivers/usb_mode/Makefile deleted file mode 100644 index e2917a4dfdbf..000000000000 --- a/drivers/usb_mode/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += mod_usb_mode.o diff --git a/drivers/usb_mode/mod_usb_mode.c b/drivers/usb_mode/mod_usb_mode.c deleted file mode 100644 index c2a352051fed..000000000000 --- a/drivers/usb_mode/mod_usb_mode.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Virtual device node for event injector of emulator - * - * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Sungmin Ha - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - */ - -#include -#include -#include -#include - -int UsbMenuSel = 0; - -struct my_data { - int no; - char test[50]; -}; - -static ssize_t show_UsbMenuSel(struct device *dev, - struct device_attribute *attr, char *buf) -{ - printk("[%s] \n", __FUNCTION__); - return snprintf(buf, PAGE_SIZE, "%d", UsbMenuSel); -} - -static ssize_t store_UsbMenuSel(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - printk("[%s] \n", __FUNCTION__); - sscanf(buf, "%d", &UsbMenuSel); - return strnlen(buf, PAGE_SIZE); -} - -static DEVICE_ATTR(UsbMenuSel, S_IRUGO | S_IWUSR, show_UsbMenuSel, store_UsbMenuSel); - -static int sysfs_test_create_file(struct device *dev) -{ - int result = 0; - - printk("[%d] [%s] \n", __LINE__, __FUNCTION__); - - result = device_create_file(dev, &dev_attr_UsbMenuSel); - if (result){ - printk("[%d] [%s] error \n", __LINE__, __FUNCTION__); - return result; - } - - return 0; -} - - -static void sysfs_test_remove_file(struct device *dev) -{ - printk("[%s] \n", __FUNCTION__); - device_remove_file(dev, &dev_attr_UsbMenuSel); -} - -static void sysfs_test_dev_release(struct device *dev) {} - -static struct platform_device the_pdev = { - .name = "usb_mode", - .id = -1, - .dev = { - .release = sysfs_test_dev_release, - } -}; - -static int __init sysfs_test_init(void) -{ - int err = 0; - struct my_data *data; - - printk("[%s] \n", __FUNCTION__); - - err = platform_device_register(&the_pdev); - if (err) { - printk("platform_device_register error\n"); - return err; - } - - data = kzalloc(sizeof(struct my_data), GFP_KERNEL); - if (!data) { - printk("[%s] kzalloc error\n", __FUNCTION__); - err = -ENOMEM; - goto alloc_err; - } - - dev_set_drvdata(&the_pdev.dev, (void*)data); - - err = sysfs_test_create_file(&the_pdev.dev); - if (err) { - printk("sysfs_create_file error\n"); - goto sysfs_err; - } - - return 0; - -sysfs_err: - kfree(data); - -alloc_err: - platform_device_unregister(&the_pdev); - return err; -} - -static void __exit sysfs_test_exit(void) -{ - void *data = dev_get_drvdata(&the_pdev.dev); - - printk("[%s] \n", __FUNCTION__); - - kfree(data); - sysfs_test_remove_file(&the_pdev.dev); - platform_device_unregister(&the_pdev); -} - -module_init(sysfs_test_init); -module_exit(sysfs_test_exit); - - -MODULE_LICENSE("GPL"); - -