Advertisement
techmik

Untitled

Aug 27th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 22.72 KB | None | 0 0
  1. techmik@techmik-acer ~/android/system/kernel/samsung/aries $ git diff led
  2. diff --git a/arch/arm/configs/aries_captivatemtd_defconfig b/arch/arm/configs/ar
  3. index d457f3b..6625461 100644
  4. --- a/arch/arm/configs/aries_captivatemtd_defconfig
  5. +++ b/arch/arm/configs/aries_captivatemtd_defconfig
  6. @@ -1117,7 +1117,6 @@ CONFIG_KEYBOARD_ATKBD=y
  7.  # CONFIG_KEYBOARD_XTKBD is not set
  8.  CONFIG_KEYPAD_CYPRESS_TOUCH=y
  9.  CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE=y
  10. -CONFIG_KEYPAD_CYPRESS_TOUCH_BLN=y
  11.  # CONFIG_INPUT_MOUSE is not set
  12.  # CONFIG_INPUT_JOYSTICK is not set
  13.  # CONFIG_INPUT_TABLET is not set
  14. diff --git a/arch/arm/mach-s5pv210/mach-aries.c b/arch/arm/mach-s5pv210/mach-ari
  15. index 6089dc4..ae8f6ca 100644
  16. --- a/arch/arm/mach-s5pv210/mach-aries.c
  17. +++ b/arch/arm/mach-s5pv210/mach-aries.c
  18. @@ -4461,7 +4461,7 @@ static unsigned int aries_sleep_gpio_table[][3] = {
  19.         // GPJ3 ---------------------------------------------------
  20.         { S5PV210_GPJ3(0), S3C_GPIO_SLP_INPUT,  S3C_GPIO_PULL_DOWN},    //_3_TOU
  21.         { S5PV210_GPJ3(1), S3C_GPIO_SLP_INPUT,  S3C_GPIO_PULL_DOWN},    //_3_TOU
  22. -       { S5PV210_GPJ3(2), S3C_GPIO_SLP_PREV,   S3C_GPIO_PULL_NONE},    //_3_GPI
  23. +       { S5PV210_GPJ3(2), S3C_GPIO_SLP_OUT0,   S3C_GPIO_PULL_NONE},    //_3_GPI
  24.  #if defined (CONFIG_SAMSUNG_CAPTIVATE)
  25.         { S5PV210_GPJ3(3), S3C_GPIO_SLP_OUT0,   S3C_GPIO_PULL_NONE},    //GPIO_G
  26.  #else
  27. diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
  28. index 7341aba..a94790c 100644
  29. --- a/drivers/input/keyboard/Kconfig
  30. +++ b/drivers/input/keyboard/Kconfig
  31. @@ -441,13 +441,4 @@ config KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
  32.         default n
  33.         help
  34.          Say Y here if your device uses legacy keycodes.
  35. -
  36. -config KEYPAD_CYPRESS_TOUCH_BLN
  37. -    bool "Cypress touch keypad: use backlight notification"
  38. -    depends on KEYPAD_CYPRESS_TOUCH
  39. -    default y
  40. -    help
  41. -      Say Y here to enable the backlighth notification
  42. -      for android led-notification (modified liblight needed)
  43. -
  44.  endif
  45. diff --git a/drivers/input/keyboard/cypress-touchkey.c b/drivers/input/keyboard/
  46. index 3ca9339..3188211 100755
  47. --- a/drivers/input/keyboard/cypress-touchkey.c
  48. +++ b/drivers/input/keyboard/cypress-touchkey.c
  49. @@ -1,6 +1,7 @@
  50.  /*
  51.   * Copyright 2006-2010, Cypress Semiconductor Corporation.
  52.   * Copyright (C) 2010, Samsung Electronics Co. Ltd. All Rights Reserved.
  53. + * Copyright (C) 2011 <kang@insecure.ws>
  54.   *
  55.   * This program is free software; you can redistribute it and/or
  56.   * modify it under the terms of the GNU General Public License
  57. @@ -19,6 +20,8 @@
  58.   *
  59.   */
  60.  #include <linux/module.h>
  61. +#include <linux/kernel.h>
  62. +#include <linux/timer.h>
  63.  #include <linux/init.h>
  64.  #include <linux/i2c.h>
  65.  #include <linux/slab.h>
  66. @@ -26,6 +29,7 @@
  67.  #include <linux/delay.h>
  68.  #include <linux/input.h>
  69.  #include <linux/earlysuspend.h>
  70. +#include <linux/miscdevice.h>
  71.  #include <linux/input/cypress-touchkey.h>
  72.  
  73.  #define SCANCODE_MASK          0x07
  74. @@ -38,17 +42,15 @@
  75.  #define OLD_BACKLIGHT_ON       0x1
  76.  #define OLD_BACKLIGHT_OFF      0x2
  77.  
  78. -#define DEVICE_NAME "cypress-touchkey"
  79. +#define BACKLIGHT_TIMEOUT      1600
  80.  
  81. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
  82. -#include <linux/miscdevice.h>
  83. -#define BACKLIGHTNOTIFICATION_VERSION 8
  84. +#define DEVICE_NAME "cypress-touchkey"
  85.  
  86. -bool bln_enabled = false; // indicates if BLN function is enabled/allowed (defa
  87. -bool bln_notification_ongoing= false; // indicates ongoing LED Notification
  88. -bool bln_blink_enabled = false;        // indicates blink is set
  89. -struct cypress_touchkey_devdata *bln_devdata; // keep a reference to the devdat
  90. -#endif
  91. +int bl_on = 0;
  92. +struct cypress_touchkey_devdata *bl_devdata;
  93. +static struct timer_list bl_timer;
  94. +static void bl_off(struct work_struct *bl_off_work);
  95. +static DECLARE_WORK(bl_off_work, bl_off);
  96.  
  97.  struct cypress_touchkey_devdata {
  98.         struct i2c_client *client;
  99. @@ -60,6 +62,7 @@ struct cypress_touchkey_devdata {
  100.         bool is_dead;
  101.         bool is_powering_on;
  102.         bool has_legacy_keycode;
  103. +       bool is_sleeping;
  104.  };
  105.  
  106.  static int i2c_touchkey_read_byte(struct cypress_touchkey_devdata *devdata,
  107. @@ -90,7 +93,6 @@ static int i2c_touchkey_write_byte(struct cypress_touchkey_dev
  108.  {
  109.         int ret;
  110.         int retry = 2;
  111. -    unsigned long flags;
  112.  
  113.         while (true) {
  114.                 ret = i2c_smbus_write_byte(devdata->client, val);
  115. @@ -118,6 +120,24 @@ static void all_keys_up(struct cypress_touchkey_devdata *de
  116.         input_sync(devdata->input_dev);
  117.  }
  118.  
  119. +static void bl_off(struct work_struct *bl_off_work)
  120. +{
  121. +       if (bl_devdata == NULL || unlikely(bl_devdata->is_dead) ||
  122. +               bl_devdata->is_powering_on || bl_on || bl_devdata->is_sleeping)
  123. +               return;
  124. +
  125. +       if (bl_devdata == NULL || unlikely(bl_devdata->is_dead) ||
  126. +               bl_devdata->is_powering_on || bl_devdata->is_sleeping)
  127. +               return;
  128. +
  129. +       i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_off);
  130. +}
  131. +
  132. +void bl_timer_callback(unsigned long data)
  133. +{
  134. +       schedule_work(&bl_off_work);
  135. +}
  136. +
  137.  static int recovery_routine(struct cypress_touchkey_devdata *devdata)
  138.  {
  139.         int ret = -1;
  140. @@ -141,7 +161,8 @@ static int recovery_routine(struct cypress_touchkey_devdata
  141.                 devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  142.                 ret = i2c_touchkey_read_byte(devdata, &data);
  143.                 if (!ret) {
  144. -                       enable_irq(irq_eint);
  145. +                       if (!devdata->is_sleeping)
  146. +                               enable_irq(irq_eint);
  147.                         goto out;
  148.                 }
  149.                 dev_err(&devdata->client->dev, "%s: i2c transfer error retry = "
  150. @@ -155,6 +176,9 @@ out:
  151.         return ret;
  152.  }
  153.  
  154. +// Accidental touch key prevention (see mxt224.c)
  155. +extern unsigned int touch_state_val;
  156. +
  157.  static irqreturn_t touchkey_interrupt_thread(int irq, void *touchkey_devdata)
  158.  {
  159.         u8 data;
  160. @@ -180,9 +204,15 @@ static irqreturn_t touchkey_interrupt_thread(int irq, void
  161.                                 "range\n", __func__);
  162.                         goto err;
  163.                 }
  164. -               input_report_key(devdata->input_dev,
  165. -                       devdata->pdata->keycode[scancode],
  166. -                       !(data & UPDOWN_EVENT_MASK));
  167. +
  168. +               /* Don't send down event while the touch screen is being pressed
  169. +                * to prevent accidental touch key hit.
  170. +                */
  171. +               if ((data & UPDOWN_EVENT_MASK) || !touch_state_val) {
  172. +                       input_report_key(devdata->input_dev,
  173. +                               devdata->pdata->keycode[scancode],
  174. +                               !(data & UPDOWN_EVENT_MASK));
  175. +               }
  176.         } else {
  177.                 for (i = 0; i < devdata->pdata->keycode_cnt; i++)
  178.                         input_report_key(devdata->input_dev,
  179. @@ -191,6 +221,7 @@ static irqreturn_t touchkey_interrupt_thread(int irq, void *
  180.         }
  181.  
  182.         input_sync(devdata->input_dev);
  183. +       mod_timer(&bl_timer, jiffies + msecs_to_jiffies(BACKLIGHT_TIMEOUT));
  184.  err:
  185.         return IRQ_HANDLED;
  186.  }
  187. @@ -200,12 +231,44 @@ static irqreturn_t touchkey_interrupt_handler(int irq, voi
  188.         struct cypress_touchkey_devdata *devdata = touchkey_devdata;
  189.  
  190.         if (devdata->is_powering_on) {
  191. +               dev_dbg(&devdata->client->dev, "%s: ignoring spurious boot "
  192. +                                       "interrupt\n", __func__);
  193.                 return IRQ_HANDLED;
  194.         }
  195.  
  196.         return IRQ_WAKE_THREAD;
  197.  }
  198.  
  199. +static void notify_led_on(void) {
  200. +    unsigned long flags;
  201. +       if (unlikely(bl_devdata->is_dead))
  202. +               return;
  203. +
  204. +       if (bl_devdata->is_sleeping) {
  205. +               bl_devdata->pdata->touchkey_sleep_onoff(TOUCHKEY_ON);
  206. +               bl_devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  207. +       }
  208. +       i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_on);
  209. +       bl_on = 1;
  210. +       printk(KERN_DEBUG "%s: notification led enabled\n", __FUNCTION__);
  211. +}
  212. +
  213. +static void notify_led_off(void) {
  214. +    unsigned long flags;
  215. +       if (unlikely(bl_devdata->is_dead))
  216. +               return;
  217. +
  218. +       if (bl_on)
  219. +               i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_off);
  220. +
  221. +       bl_devdata->pdata->touchkey_sleep_onoff(TOUCHKEY_OFF);
  222. +       if (bl_devdata->is_sleeping)
  223. +               bl_devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  224. +
  225. +       bl_on = 0;
  226. +       printk(KERN_DEBUG "%s: notification led disabled\n", __FUNCTION__);
  227. +}
  228. +
  229.  #ifdef CONFIG_HAS_EARLYSUSPEND
  230.  static void cypress_touchkey_early_suspend(struct early_suspend *h)
  231.  {
  232. @@ -218,17 +281,12 @@ static void cypress_touchkey_early_suspend(struct early_su
  233.                 return;
  234.  
  235.         disable_irq(devdata->client->irq);
  236. -
  237. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
  238. -       /*
  239. -        * Disallow powering off the touchkey controller
  240. -        * while a led notification is ongoing
  241. -        */
  242. -       if(!bln_notification_ongoing)
  243. -#endif
  244.         devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  245. -
  246.         all_keys_up(devdata);
  247. +       devdata->is_sleeping = true;
  248. +
  249. +       if (bl_on)
  250. +               notify_led_on();
  251.  }
  252.  
  253.  static void cypress_touchkey_early_resume(struct early_suspend *h)
  254. @@ -237,6 +295,7 @@ static void cypress_touchkey_early_resume(struct early_suspe
  255.                 container_of(h, struct cypress_touchkey_devdata, early_suspend);
  256.  
  257.         devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  258. +
  259.         if (i2c_touchkey_write_byte(devdata, devdata->backlight_on)) {
  260.                 devdata->is_dead = true;
  261.                 devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  262. @@ -247,179 +306,43 @@ static void cypress_touchkey_early_resume(struct early_su
  263.         devdata->is_dead = false;
  264.         enable_irq(devdata->client->irq);
  265.         devdata->is_powering_on = false;
  266. +       devdata->is_sleeping = false;
  267. +       mod_timer(&bl_timer, jiffies + msecs_to_jiffies(BACKLIGHT_TIMEOUT));
  268.  }
  269.  #endif
  270.  
  271. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
  272. -/* bln start */
  273. -
  274. -static void enable_touchkey_backlights(void){
  275. -       i2c_touchkey_write_byte(bln_devdata, bln_devdata->backlight_on);
  276. -}
  277. -
  278. -static void disable_touchkey_backlights(void){
  279. -       i2c_touchkey_write_byte(bln_devdata, bln_devdata->backlight_off);
  280. +static ssize_t led_status_read(struct device *dev, struct device_attribute *att
  281. +       return sprintf(buf,"%u\n", bl_on);
  282.  }
  283.  
  284. -static void enable_led_notification(void){
  285. -       if (bln_enabled){
  286. -               /* is_powering_on signals whether touchkey lights are used for t
  287. -               pr_info("%s: bln interface enabled\n", __FUNCTION__); //remove m
  288. -              
  289. -               if (bln_devdata->is_powering_on){
  290. -               pr_info("%s: not in touchmode\n", __FUNCTION__); //remove me
  291. -                       /* signal ongoing led notification */
  292. -                       bln_notification_ongoing = true;
  293. -
  294. -                       /*
  295. -                        * power on the touchkey controller
  296. -                        * This is actually not needed, but it is intentionally
  297. -                        * left for the case that the early_resume() function
  298. -                        * did not power on the touchkey controller for some rea
  299. -                        */
  300. -                       pr_info("%s: enable vdd\n", __FUNCTION__); //remove me
  301. -                       bln_devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  302. -
  303. -                       /* write to i2cbus, enable backlights */
  304. -                       pr_info("%s: enable lights\n", __FUNCTION__); //remove m
  305. -                       enable_touchkey_backlights();
  306. -
  307. -                       pr_info("%s: notification led enabled\n", __FUNCTION__);
  308. -               }
  309. -               else
  310. -                       pr_info("%s: cannot set notification led, touchkeys are
  311. -       }
  312. -}
  313. -
  314. -static void disable_led_notification(void){
  315. -       pr_info("%s: notification led disabled\n", __FUNCTION__);
  316. -
  317. -       /* disable the blink state */
  318. -       bln_blink_enabled = false;
  319. -
  320. -       /* if touchkeys lights are not used for touchmode */
  321. -       if (bln_devdata->is_powering_on){
  322. -               disable_touchkey_backlights();
  323. -       }
  324. -
  325. -       /* signal led notification is disabled */
  326. -       bln_notification_ongoing = false;
  327. -}
  328. -
  329. -static ssize_t backlightnotification_status_read(struct device *dev, struct dev
  330. -    return sprintf(buf,"%u\n",(bln_enabled ? 1 : 0));
  331. -}
  332. -static ssize_t backlightnotification_status_write(struct device *dev, struct de
  333. +static ssize_t led_status_write(struct device *dev, struct device_attribute *at
  334.  {
  335.         unsigned int data;
  336. -       if(sscanf(buf, "%u\n", &data) == 1) {
  337. -               pr_devel("%s: %u \n", __FUNCTION__, data);
  338. -               if(data == 0 || data == 1){
  339. -
  340. -                       if(data == 1){
  341. -                               pr_info("%s: backlightnotification function enab
  342. -                               bln_enabled = true;
  343. -                       }
  344. -
  345. -                       if(data == 0){
  346. -                               pr_info("%s: backlightnotification function disa
  347. -                               bln_enabled = false;
  348. -                               if (bln_notification_ongoing)
  349. -                                       disable_led_notification();
  350. -                       }
  351. -               }
  352. +
  353. +       if (sscanf(buf, "%u\n", &data)) {
  354. +               if (data == 1)
  355. +                       notify_led_on();
  356.                 else
  357. -                       pr_info("%s: invalid input range %u\n", __FUNCTION__, da
  358. +                       notify_led_off();
  359.         }
  360. -       else
  361. -               pr_info("%s: invalid input\n", __FUNCTION__);
  362. -
  363.         return size;
  364.  }
  365.  
  366. -static ssize_t notification_led_status_read(struct device *dev, struct device_a
  367. -       return sprintf(buf,"%u\n", (bln_notification_ongoing ? 1 : 0));
  368. -}
  369. -
  370. -static ssize_t notification_led_status_write(struct device *dev, struct device_
  371. -{
  372. -       unsigned int data;
  373. -
  374. -       if(sscanf(buf, "%u\n", &data) == 1) {
  375. -               if(data == 0 || data == 1){
  376. -                       pr_devel("%s: %u \n", __FUNCTION__, data);
  377. -                       if (data == 1)
  378. -                               enable_led_notification();
  379. -
  380. -                       if(data == 0)
  381. -                               disable_led_notification();
  382. -
  383. -               } else
  384. -                       pr_info("%s: wrong input %u\n", __FUNCTION__, data);
  385. -       } else
  386. -               pr_info("%s: input error\n", __FUNCTION__);
  387. +static DEVICE_ATTR(led, S_IRUGO | S_IWUGO , led_status_read, led_status_write);
  388.  
  389. -       return size;
  390. -}
  391. -
  392. -static ssize_t blink_control_read(struct device *dev, struct device_attribute *
  393. -       return sprintf(buf,"%u\n", (bln_blink_enabled ? 1 : 0));
  394. -}
  395. -
  396. -static ssize_t blink_control_write(struct device *dev, struct device_attribute
  397. -{
  398. -       unsigned int data;
  399. -
  400. -       if(sscanf(buf, "%u\n", &data) == 1) {
  401. -               if(data == 0 || data == 1){
  402. -                       if (bln_notification_ongoing){
  403. -                               pr_devel("%s: %u \n", __FUNCTION__, data);
  404. -                               if (data == 1){
  405. -                                       bln_blink_enabled = true;
  406. -                                       disable_touchkey_backlights();
  407. -                               }
  408. -
  409. -                               if(data == 0){
  410. -                                       bln_blink_enabled = false;
  411. -                                       enable_touchkey_backlights();
  412. -                               }
  413. -                       }
  414. -
  415. -               } else
  416. -                       pr_info("%s: wrong input %u\n", __FUNCTION__, data);
  417. -       } else
  418. -               pr_info("%s: input error\n", __FUNCTION__);
  419. -
  420. -       return size;
  421. -}
  422. -
  423. -static ssize_t backlightnotification_version(struct device *dev, struct device_
  424. -       return sprintf(buf, "%u\n", BACKLIGHTNOTIFICATION_VERSION);
  425. -}
  426. -
  427. -static DEVICE_ATTR(blink_control, S_IRUGO | S_IWUGO , blink_control_read, blink
  428. -static DEVICE_ATTR(enabled, S_IRUGO | S_IWUGO , backlightnotification_status_re
  429. -static DEVICE_ATTR(notification_led, S_IRUGO | S_IWUGO , notification_led_statu
  430. -static DEVICE_ATTR(version, S_IRUGO , backlightnotification_version, NULL);
  431. -
  432. -static struct attribute *bln_interface_attributes[] = {
  433. -               &dev_attr_blink_control.attr,
  434. -               &dev_attr_enabled.attr,
  435. -               &dev_attr_notification_led.attr,
  436. -               &dev_attr_version.attr,
  437. +static struct attribute *bl_led_attributes[] = {
  438. +               &dev_attr_led.attr,
  439.                 NULL
  440.  };
  441.  
  442. -static struct attribute_group bln_interface_attributes_group = {
  443. -               .attrs  = bln_interface_attributes,
  444. +static struct attribute_group bl_led_group = {
  445. +               .attrs  = bl_led_attributes,
  446.  };
  447.  
  448. -static struct miscdevice backlightnotification_device = {
  449. +static struct miscdevice bl_led_device = {
  450.                 .minor = MISC_DYNAMIC_MINOR,
  451. -               .name = "backlightnotification",
  452. +               .name = "notification",
  453.  };
  454. -/* bln end */
  455. -#endif
  456.  
  457.  static int cypress_touchkey_probe(struct i2c_client *client,
  458.                 const struct i2c_device_id *id)
  459. @@ -474,10 +397,12 @@ static int cypress_touchkey_probe(struct i2c_client *clien
  460.                 goto err_input_reg_dev;
  461.  
  462.         devdata->is_powering_on = true;
  463. +       devdata->is_sleeping = false;
  464.  
  465.         devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  466.  
  467.         err = i2c_master_recv(client, data, sizeof(data));
  468. +
  469.         if (err < sizeof(data)) {
  470.                 if (err >= 0)
  471.                         err = -EIO;
  472. @@ -487,8 +412,17 @@ static int cypress_touchkey_probe(struct i2c_client *client
  473.  
  474.         dev_info(dev, "%s: hardware rev1 = %#02x, rev2 = %#02x\n", __func__,
  475.                                 data[1], data[2]);
  476. +
  477. +#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
  478. +       devdata->has_legacy_keycode = true;
  479. +#else
  480. +       devdata->has_legacy_keycode = data[1] >= 0xc4 || data[1] < 0x9 ||
  481. +                                       (data[1] == 0x9 && data[2] < 0x9);
  482. +#endif
  483. +
  484.         if (data[1] < 0xc4 && (data[1] >= 0x8 ||
  485. -                               (data[1] == 0x8 && data[2] >= 0x9))) {
  486. +                               (data[1] == 0x8 && data[2] >= 0x9)) &&
  487. +                               devdata->has_legacy_keycode == false) {
  488.                 devdata->backlight_on = BACKLIGHT_ON;
  489.                 devdata->backlight_off = BACKLIGHT_OFF;
  490.         } else {
  491. @@ -496,24 +430,19 @@ static int cypress_touchkey_probe(struct i2c_client *clien
  492.                 devdata->backlight_off = OLD_BACKLIGHT_OFF;
  493.         }
  494.  
  495. -
  496. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
  497. -       devdata->has_legacy_keycode = true;
  498. -#else
  499. -       devdata->has_legacy_keycode = data[1] >= 0xc4 || data[1] < 0x9 ||
  500. -                       (data[1] == 0x9 && data[2] < 0x9);
  501. -#endif
  502. -
  503. -       err = i2c_touchkey_write_byte(devdata, devdata->backlight_on);
  504. +       err = i2c_touchkey_write_byte(devdata, devdata->backlight_off);
  505.         if (err) {
  506.                 dev_err(dev, "%s: touch keypad backlight on failed\n",
  507.                                 __func__);
  508. -               goto err_backlight_on;
  509. +               /* The device may not be responding because of bad firmware
  510. +                */
  511. +               goto err_backlight_off;
  512.         }
  513.  
  514. -       if (request_threaded_irq(client->irq, touchkey_interrupt_handler,
  515. +       err = request_threaded_irq(client->irq, touchkey_interrupt_handler,
  516.                                 touchkey_interrupt_thread, IRQF_TRIGGER_FALLING,
  517. -                               DEVICE_NAME, devdata)) {
  518. +                               DEVICE_NAME, devdata);
  519. +       if (err) {
  520.                 dev_err(dev, "%s: Can't allocate irq.\n", __func__);
  521.                 goto err_req_irq;
  522.         }
  523. @@ -526,37 +455,28 @@ static int cypress_touchkey_probe(struct i2c_client *clien
  524.  
  525.         devdata->is_powering_on = false;
  526.  
  527. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
  528. -       pr_info("%s misc_register(%s)\n", __FUNCTION__, backlightnotification_de
  529. -       err = misc_register(&backlightnotification_device);
  530. -       if (err) {
  531. -               pr_err("%s misc_register(%s) fail\n", __FUNCTION__, backlightnot
  532. -       }else {
  533. -               /*
  534. -                *  keep a reference to the devdata,
  535. -                *  misc driver does not give access to it (or i missed that som
  536. -                */
  537. -               bln_devdata = devdata;
  538. -
  539. -               /* add the backlightnotification attributes */
  540. -               if (sysfs_create_group(&backlightnotification_device.this_device
  541. -               {
  542. -                       pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
  543. -                       pr_err("Failed to create sysfs group for device (%s)!\n"
  544. -               }
  545. +       if (misc_register(&bl_led_device))
  546. +               printk("%s misc_register(%s) failed\n", __FUNCTION__, bl_led_dev
  547. +       else {
  548. +               if (sysfs_create_group(&bl_led_device.this_device->kobj, &bl_led
  549. +                       pr_err("failed to create sysfs group for device %s\n", b
  550.         }
  551. -#endif
  552. +
  553. +    bl_devdata = devdata;
  554. +       setup_timer(&bl_timer, bl_timer_callback, 0);
  555.  
  556.         return 0;
  557.  
  558.  err_req_irq:
  559. -err_backlight_on:
  560. -err_read:
  561. -       devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  562. +err_backlight_off:
  563.         input_unregister_device(input_dev);
  564. -       goto err_input_alloc_dev;
  565. +       goto touchkey_off;
  566.  err_input_reg_dev:
  567. +err_read:
  568.         input_free_device(input_dev);
  569. +touchkey_off:
  570. +       devdata->is_powering_on = false;
  571. +       devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  572.  err_input_alloc_dev:
  573.  err_null_keycodes:
  574.         kfree(devdata);
  575. @@ -567,20 +487,21 @@ static int __devexit i2c_touchkey_remove(struct i2c_client
  576.  {
  577.         struct cypress_touchkey_devdata *devdata = i2c_get_clientdata(client);
  578.  
  579. -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
  580. -       misc_deregister(&backlightnotification_device);
  581. -#endif
  582. -
  583.         dev_err(&client->dev, "%s: i2c_touchkey_remove\n", __func__);
  584. +
  585. +       misc_deregister(&bl_led_device);
  586.         unregister_early_suspend(&devdata->early_suspend);
  587.         /* If the device is dead IRQs are disabled, we need to rebalance them */
  588.         if (unlikely(devdata->is_dead))
  589.                 enable_irq(client->irq);
  590. -       else
  591. +       else {
  592.                 devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  593. +               devdata->is_powering_on = false;
  594. +       }
  595.         free_irq(client->irq, devdata);
  596.         all_keys_up(devdata);
  597.         input_unregister_device(devdata->input_dev);
  598. +    del_timer(&bl_timer);
  599.         kfree(devdata);
  600.         return 0;
  601.  }
  602. @@ -623,4 +544,3 @@ module_exit(touchkey_exit);
  603.  MODULE_LICENSE("GPL");
  604.  MODULE_AUTHOR("@@@");
  605.  MODULE_DESCRIPTION("cypress touch keypad");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement