e10033841a065ee703d413b18de33cded6a5ec3f
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / radio-si4713.diff
1 --- kernel-power-2.6.28/drivers/media/radio/radio-si4713.c      2011-09-14 23:56:12.320096297 +0200
2 +++ kernel-power-2.6.28/drivers/media/radio/radio-si4713.c      2011-09-15 00:19:37.030080507 +0200
3 @@ -55,23 +55,10 @@
4  static int radio_nr = -1;      /* radio device minor (-1 ==> auto assign) */
5  
6  /* properties lock for write operations */
7 -static int config_locked;
8 +static int config_locked = 1;
9  
10 -/* saved power levels */
11 -static unsigned int max_pl;
12 -static unsigned int min_pl;
13 -
14 -/* structure for pid registration */
15 -struct pid_list {
16 -       pid_t pid;
17 -       struct list_head plist;
18 -};
19 -
20 -#define APP_MAX_NUM    2
21 -
22 -static int pid_count;
23 -static LIST_HEAD(pid_list_head);
24 -static struct si4713_device *si4713_dev;
25 +/* module param for initial power level */
26 +static int init_power_level = 120;
27  
28  /*
29   * Sysfs properties
30 @@ -193,16 +180,7 @@ static ssize_t si4713_lock_write(struct
31                                 const char *buf,
32                                 size_t count)
33  {
34 -       int l;
35 -
36 -       if (config_locked)
37 -               return -EPERM;
38 -
39 -       sscanf(buf, "%d", &l);
40 -
41 -       if (l != 0)
42 -               config_locked = 1;
43 -
44 +       sscanf(buf, "%d", &config_locked);
45         return count;
46  }
47  
48 @@ -219,7 +197,7 @@ static DEVICE_ATTR(lock, S_IRUGO | S_IWU
49  /*
50   * Power level property
51   */
52 -/* power_level (rw) 88 - 115 or 0 */
53 +/* power_level (rw) 88 - 120 or 0 */
54  static ssize_t si4713_power_level_write(struct device *dev,
55                                         struct device_attribute *attr,
56                                         const char *buf,
57 @@ -420,109 +398,13 @@ static irqreturn_t si4713_handler(int ir
58         return IRQ_HANDLED;
59  }
60  
61 -static int register_pid(pid_t pid)
62 -{
63 -       struct pid_list *pitem;
64 -
65 -       list_for_each_entry(pitem, &pid_list_head, plist) {
66 -               if (pitem->pid == pid)
67 -                       return -EINVAL;
68 -       }
69 -
70 -       pitem = kmalloc(sizeof(struct pid_list), GFP_KERNEL);
71 -
72 -       if (!pitem)
73 -               return -ENOMEM;
74 -
75 -       pitem->pid = pid;
76 -
77 -       list_add(&(pitem->plist), &pid_list_head);
78 -       pid_count++;
79 -
80 -       return 0;
81 -}
82 -
83 -static int unregister_pid(pid_t pid)
84 -{
85 -       struct pid_list *pitem, *n;
86 -
87 -       list_for_each_entry_safe(pitem, n, &pid_list_head, plist) {
88 -               if (pitem->pid == pid) {
89 -                       list_del(&(pitem->plist));
90 -                       pid_count--;
91 -
92 -                       kfree(pitem);
93 -
94 -                       return 0;
95 -               }
96 -       }
97 -       return -EINVAL;
98 -}
99 -
100  static int si4713_priv_ioctl(struct inode *inode, struct file *file,
101                 unsigned int cmd, unsigned long arg)
102  {
103 -       unsigned int pow;
104 -       int pl, rval;
105 -
106         if (cmd != LOCK_LOW_POWER && cmd != RELEASE_LOW_POWER)
107                 return video_ioctl2(inode, file, cmd, arg);
108 -
109 -       pl = si4713_get_power_level(si4713_dev);
110 -
111 -       if (pl < 0) {
112 -               rval = pl;
113 -               goto exit;
114 -       }
115 -
116 -       if (copy_from_user(&pow, (void __user *)arg, sizeof(pow))) {
117 -               rval = -EFAULT;
118 -               goto exit;
119 -       }
120 -
121 -       if (cmd == LOCK_LOW_POWER) {
122 -
123 -               if (pid_count == APP_MAX_NUM) {
124 -                       rval = -EPERM;
125 -                       goto exit;
126 -               }
127 -
128 -               if (pid_count == 0) {
129 -                       if (pow > pl) {
130 -                               rval = -EINVAL;
131 -                               goto exit;
132 -                       } else {
133 -                               /* Set max possible power level */
134 -                               max_pl = pl;
135 -                               min_pl = pow;
136 -                       }
137 -               }
138 -
139 -               rval = register_pid(current->pid);
140 -
141 -               if (rval)
142 -                       goto exit;
143 -
144 -               /* Lower min power level if asked */
145 -               if (pow < min_pl)
146 -                       min_pl = pow;
147 -               else
148 -                       pow = min_pl;
149 -
150 -       } else { /* RELEASE_LOW_POWER */
151 -               rval = unregister_pid(current->pid);
152 -
153 -               if (rval)
154 -                       goto exit;
155 -
156 -               if (pid_count == 0) {
157 -                       if (pow > max_pl)
158 -                               pow = max_pl;
159 -               }
160 -       }
161 -       rval = si4713_set_power_level(si4713_dev, pow);
162 -exit:
163 -       return rval;
164 +       else
165 +               return 0;
166  }
167  
168  /*
169 @@ -906,8 +788,11 @@ static int si4713_i2c_driver_probe(struc
170                 goto free_sysfs;
171         }
172  
173 -       /* save to global pointer for it to be accesible from ioctl() call */
174 -       si4713_dev = sdev;
175 +       rval = si4713_set_power_level(sdev, init_power_level);
176 +       if (rval < 0) {
177 +               dev_dbg(&client->dev, "Failed to set initial power level.\n");
178 +               goto free_sysfs;
179 +       }
180  
181         return 0;
182  
183 @@ -1013,6 +898,12 @@ module_param(radio_nr, int, 0);
184  MODULE_PARM_DESC(radio_nr,
185                  "Minor number for radio device (-1 ==> auto assign)");
186  
187 +module_param(init_power_level, int, 120);
188 +MODULE_PARM_DESC(init_power_level, "Initial value of power level (default 120)");
189 +
190 +module_param(config_locked, int, 1);
191 +MODULE_PARM_DESC(config_locked, "Lock power level configuration on init (default 1 - locked)");
192 +
193  MODULE_LICENSE("GPL");
194  MODULE_AUTHOR(DRIVER_AUTHOR);
195  MODULE_DESCRIPTION(DRIVER_DESC);