forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/light/tsl2563.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/iio/light/tsl2563.c
34 *
....@@ -8,20 +9,6 @@
89 *
910 * Converted to IIO driver
1011 * Amit Kucheria <amit.kucheria@verdurent.com>
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * version 2 as published by the Free Software Foundation.
15
- *
16
- * This program is distributed in the hope that it will be useful, but
17
- * WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
- * General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24
- * 02110-1301 USA
2512 */
2613
2714 #include <linux/module.h>
....@@ -82,7 +69,7 @@
8269 #define TSL2563_TIMING_GAIN16 0x10
8370 #define TSL2563_TIMING_GAIN1 0x00
8471
85
-#define TSL2563_INT_DISBLED 0x00
72
+#define TSL2563_INT_DISABLED 0x00
8673 #define TSL2563_INT_LEVEL 0x10
8774 #define TSL2563_INT_PERSIST(n) ((n) & 0x0F)
8875
....@@ -726,7 +713,7 @@
726713
727714 chip = iio_priv(indio_dev);
728715
729
- i2c_set_clientdata(client, chip);
716
+ i2c_set_clientdata(client, indio_dev);
730717 chip->client = client;
731718
732719 err = tsl2563_detect(chip);
....@@ -763,7 +750,6 @@
763750 indio_dev->name = client->name;
764751 indio_dev->channels = tsl2563_channels;
765752 indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels);
766
- indio_dev->dev.parent = &client->dev;
767753 indio_dev->modes = INDIO_DIRECT_MODE;
768754
769755 if (client->irq)
....@@ -810,8 +796,8 @@
810796
811797 static int tsl2563_remove(struct i2c_client *client)
812798 {
813
- struct tsl2563_chip *chip = i2c_get_clientdata(client);
814
- struct iio_dev *indio_dev = iio_priv_to_dev(chip);
799
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
800
+ struct tsl2563_chip *chip = iio_priv(indio_dev);
815801
816802 iio_device_unregister(indio_dev);
817803 if (!chip->int_enabled)
....@@ -829,7 +815,8 @@
829815 #ifdef CONFIG_PM_SLEEP
830816 static int tsl2563_suspend(struct device *dev)
831817 {
832
- struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
818
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
819
+ struct tsl2563_chip *chip = iio_priv(indio_dev);
833820 int ret;
834821
835822 mutex_lock(&chip->lock);
....@@ -847,7 +834,8 @@
847834
848835 static int tsl2563_resume(struct device *dev)
849836 {
850
- struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
837
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
838
+ struct tsl2563_chip *chip = iio_priv(indio_dev);
851839 int ret;
852840
853841 mutex_lock(&chip->lock);