kernel-power git -> kernel-bfs
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / option_disable_indicator_led.diff
1 --- a/include/media/adp1653.h   2011-10-03 18:06:48.000000000 +0200
2 +++ b/include/media/adp1653.h   2011-10-08 21:22:27.348047579 +0200
3 @@ -27,6 +27,7 @@
4  
5  #include <linux/videodev2.h>
6  #include <linux/i2c.h>
7 +#include <linux/device.h>
8  #include <media/v4l2-int-device.h>
9  #include <media/smiaregs.h>
10  
11 @@ -75,6 +76,7 @@ struct adp1653_flash {
12         u32 flash_intensity;
13         u32 torch_intensity;
14         u32 indicator_intensity;
15 +       u32 indicator_disabled;
16  
17         struct v4l2_int_device *v4l2_int_device;
18  
19 --- a/drivers/media/video/adp1653.c     2011-10-09 01:11:26.601046961 +0200
20 +++ b/drivers/media/video/adp1653.c     2011-10-09 00:49:42.339046573 +0200
21 @@ -56,7 +56,8 @@ static int adp1653_update_hw(struct v4l2
22         if (flash->power != V4L2_POWER_ON)
23                 return 0;
24  
25 -       out_sel |= flash->indicator_intensity << ADP1653_REG_OUT_SEL_ILED_SHIFT;
26 +       if (! flash->indicator_disabled)
27 +               out_sel |= flash->indicator_intensity << ADP1653_REG_OUT_SEL_ILED_SHIFT;
28         /* Set torch intensity to zero--prevents false triggering of SC Fault */
29         rval = i2c_smbus_write_byte_data(flash->i2c_client,
30                                          ADP1653_REG_OUT_SEL, out_sel);
31 @@ -490,6 +491,37 @@ static int adp1653_resume(struct i2c_cli
32  
33  #endif /* CONFIG_PM */
34  
35 +static ssize_t disable_indicator_led_show(struct device *dev, 
36 +                        struct device_attribute *attr, char *buf)
37 +{
38 +       struct adp1653_flash *flash = dev_get_drvdata(dev);
39 +
40 +       return sprintf(buf, "%u\n", flash->indicator_disabled);
41 +}
42 +
43 +static ssize_t disable_indicator_led_store(struct device *dev,
44 +                        struct device_attribute *attr,
45 +                        const char *buf, size_t count)
46 +{
47 +       struct adp1653_flash *flash = dev_get_drvdata(dev);
48 +       unsigned long res;
49 +       int i;
50 +
51 +       if (strict_strtoul(buf, 10, &res) < 0)
52 +               return -EINVAL;
53 +       i = res ? 1 : 0;
54 +
55 +       if (i == flash->indicator_disabled)
56 +               goto out;
57 +
58 +       flash->indicator_disabled = i;
59 +       adp1653_update_hw(flash->v4l2_int_device);
60 +out:
61 +       return count;
62 +}
63 +
64 +static DEVICE_ATTR(disable_indicator_led, S_IRUGO|S_IWUSR, disable_indicator_led_show, disable_indicator_led_store);
65 +
66  static int adp1653_probe(struct i2c_client *client,
67                          const struct i2c_device_id *devid)
68  {
69 @@ -507,7 +539,13 @@ static int adp1653_probe(struct i2c_clie
70         flash->v4l2_int_device = &adp1653_int_device;
71  
72         flash->i2c_client = client;
73 -       i2c_set_clientdata(client, flash);
74 +       i2c_set_clientdata(client, flash); /* => dev_set_drvdata(&client->dev, flash) */
75 +
76 +       flash->indicator_disabled = 0;
77 +       rval = device_create_file(&client->dev, &dev_attr_disable_indicator_led);
78 +       if (rval < 0)
79 +               dev_warn(&client->dev, "can't create sysfs file for %s: %d\n",
80 +                        dev_attr_disable_indicator_led.attr.name, rval);
81  
82         rval = v4l2_int_device_register(flash->v4l2_int_device);
83         if (rval)
84 @@ -523,6 +561,7 @@ static int __exit adp1653_remove(struct
85         if (!client->adapter)
86                 return -ENODEV; /* our client isn't attached */
87  
88 +       device_remove_file(&client->dev, &dev_attr_disable_indicator_led);
89         v4l2_int_device_unregister(flash->v4l2_int_device);
90         i2c_set_clientdata(client, NULL);
91