hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/misc/tsl2550.c
....@@ -1,22 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * tsl2550.c - Linux kernel modules for ambient light sensor
34 *
45 * Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it>
56 * Copyright (C) 2007 Eurotech S.p.A. <info@eurotech.it>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
207 */
218
229 #include <linux/module.h>
....@@ -161,16 +148,14 @@
161148 u16 c0 = count_lut[ch0];
162149 u16 c1 = count_lut[ch1];
163150
164
- /*
165
- * Calculate ratio.
166
- * Note: the "128" is a scaling factor
167
- */
168
- u8 r = 128;
169
-
170151 /* Avoid division by 0 and count 1 cannot be greater than count 0 */
171152 if (c1 <= c0)
172153 if (c0) {
173
- r = c1 * 128 / c0;
154
+ /*
155
+ * Calculate ratio.
156
+ * Note: the "128" is a scaling factor
157
+ */
158
+ u8 r = c1 * 128 / c0;
174159
175160 /* Calculate LUX */
176161 lux = ((c0 - c1) * ratio_lut[r]) / 256;
....@@ -349,7 +334,7 @@
349334 static int tsl2550_probe(struct i2c_client *client,
350335 const struct i2c_device_id *id)
351336 {
352
- struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
337
+ struct i2c_adapter *adapter = client->adapter;
353338 struct tsl2550_data *data;
354339 int *opmode, err = 0;
355340