.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * tsl2550.c - Linux kernel modules for ambient light sensor |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it> |
---|
5 | 6 | * 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. |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
161 | 148 | u16 c0 = count_lut[ch0]; |
---|
162 | 149 | u16 c1 = count_lut[ch1]; |
---|
163 | 150 | |
---|
164 | | - /* |
---|
165 | | - * Calculate ratio. |
---|
166 | | - * Note: the "128" is a scaling factor |
---|
167 | | - */ |
---|
168 | | - u8 r = 128; |
---|
169 | | - |
---|
170 | 151 | /* Avoid division by 0 and count 1 cannot be greater than count 0 */ |
---|
171 | 152 | if (c1 <= c0) |
---|
172 | 153 | 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; |
---|
174 | 159 | |
---|
175 | 160 | /* Calculate LUX */ |
---|
176 | 161 | lux = ((c0 - c1) * ratio_lut[r]) / 256; |
---|
.. | .. |
---|
349 | 334 | static int tsl2550_probe(struct i2c_client *client, |
---|
350 | 335 | const struct i2c_device_id *id) |
---|
351 | 336 | { |
---|
352 | | - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
---|
| 337 | + struct i2c_adapter *adapter = client->adapter; |
---|
353 | 338 | struct tsl2550_data *data; |
---|
354 | 339 | int *opmode, err = 0; |
---|
355 | 340 | |
---|