PageRenderTime 71ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/arm/mach-msm/lge/lge_ats_uevent.c

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase
C | 99 lines | 71 code | 14 blank | 14 comment | 7 complexity | f254374b5a6cc70bcadbd14ef179c603 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /* drivers/misc/lge_ats_uevent.c
  2. *
  3. * Copyright (C) 2010 LGE.
  4. * Author: Munyoung Hwang <munyoung.hwang@lge.com>
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/platform_device.h>
  16. static void ats_uevent_send(struct device *dev, char *cmd)
  17. {
  18. char *str;
  19. char *envp[3];
  20. if(cmd) {
  21. str = strchr(cmd, ' ');
  22. if(!str || !(str+1)) {
  23. printk(KERN_ERR"%s: cmd format is invalid\n", __func__);
  24. return;
  25. }
  26. *str = '\0';
  27. envp[0] = cmd;
  28. envp[1] = str + 1;
  29. envp[2] = NULL;
  30. kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
  31. }
  32. }
  33. static ssize_t ats_uevent_cmd_store(struct device *dev, struct device_attribute *attr,
  34. const char *buf, size_t size)
  35. {
  36. char *cmd;
  37. int len;
  38. cmd = kstrdup(buf, size);
  39. if(cmd) {
  40. printk(KERN_INFO"%s: send cmd: %s\n", __func__, cmd);
  41. len = strlen(cmd);
  42. if(cmd[len-1] == '\n')
  43. cmd[len-1] = '\0';
  44. ats_uevent_send(dev, cmd);
  45. kfree(cmd);
  46. }
  47. return size;
  48. }
  49. static DEVICE_ATTR(cmd, S_IRUSR | S_IWUSR, NULL, ats_uevent_cmd_store);
  50. static int ats_uevent_probe(struct platform_device *pdev)
  51. {
  52. int ret;
  53. ret = device_create_file(&pdev->dev, &dev_attr_cmd);
  54. if(ret < 0) {
  55. printk(KERN_ERR "%s: Error while creating device file\n", __func__);
  56. return ret;
  57. }
  58. return 0;
  59. }
  60. static int ats_uevent_remove(struct platform_device *pdev)
  61. {
  62. device_remove_file(&pdev->dev, &dev_attr_cmd);
  63. return 0;
  64. }
  65. static struct platform_driver ats_uevent_driver = {
  66. .probe = ats_uevent_probe,
  67. .remove = ats_uevent_remove,
  68. .driver = {
  69. .name = "ats_uevent",
  70. },
  71. };
  72. static int __init ats_uevent_init(void)
  73. {
  74. printk(KERN_INFO "%s: ats uevent driver\n", __func__);
  75. return platform_driver_register(&ats_uevent_driver);
  76. }
  77. static void __exit ats_uevent_exit(void)
  78. {
  79. platform_driver_unregister(&ats_uevent_driver);
  80. }
  81. module_init(ats_uevent_init);
  82. module_exit(ats_uevent_exit);
  83. MODULE_AUTHOR("LG Electronics Inc.");
  84. MODULE_DESCRIPTION("ATS uevent device driver");
  85. MODULE_LICENSE("GPL");