hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/power/supply/bq24257_charger.c
....@@ -1,22 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * TI BQ24257 charger driver
34 *
45 * Copyright (C) 2015 Intel Corporation
56 *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
167 * Datasheets:
17
- * http://www.ti.com/product/bq24250
18
- * http://www.ti.com/product/bq24251
19
- * http://www.ti.com/product/bq24257
8
+ * https://www.ti.com/product/bq24250
9
+ * https://www.ti.com/product/bq24251
10
+ * https://www.ti.com/product/bq24257
2011 */
2112
2213 #include <linux/module.h>
....@@ -845,7 +836,7 @@
845836 static DEVICE_ATTR(sysoff_enable, S_IWUSR | S_IRUGO,
846837 bq24257_sysfs_show_enable, bq24257_sysfs_set_enable);
847838
848
-static struct attribute *bq24257_charger_attr[] = {
839
+static struct attribute *bq24257_charger_sysfs_attrs[] = {
849840 &dev_attr_ovp_voltage.attr,
850841 &dev_attr_in_dpm_voltage.attr,
851842 &dev_attr_high_impedance_enable.attr,
....@@ -853,14 +844,13 @@
853844 NULL,
854845 };
855846
856
-static const struct attribute_group bq24257_attr_group = {
857
- .attrs = bq24257_charger_attr,
858
-};
847
+ATTRIBUTE_GROUPS(bq24257_charger_sysfs);
859848
860849 static int bq24257_power_supply_init(struct bq24257_device *bq)
861850 {
862851 struct power_supply_config psy_cfg = { .drv_data = bq, };
863852
853
+ psy_cfg.attr_grp = bq24257_charger_sysfs_groups;
864854 psy_cfg.supplied_to = bq24257_charger_supplied_to;
865855 psy_cfg.num_supplicants = ARRAY_SIZE(bq24257_charger_supplied_to);
866856
....@@ -960,7 +950,7 @@
960950 static int bq24257_probe(struct i2c_client *client,
961951 const struct i2c_device_id *id)
962952 {
963
- struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
953
+ struct i2c_adapter *adapter = client->adapter;
964954 struct device *dev = &client->dev;
965955 const struct acpi_device_id *acpi_id;
966956 struct bq24257_device *bq;
....@@ -1084,12 +1074,6 @@
10841074 return ret;
10851075 }
10861076
1087
- ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
1088
- if (ret < 0) {
1089
- dev_err(dev, "Can't create sysfs entries\n");
1090
- return ret;
1091
- }
1092
-
10931077 return 0;
10941078 }
10951079
....@@ -1099,8 +1083,6 @@
10991083
11001084 if (bq->iilimit_autoset_enable)
11011085 cancel_delayed_work_sync(&bq->iilimit_setup_work);
1102
-
1103
- sysfs_remove_group(&bq->charger->dev.kobj, &bq24257_attr_group);
11041086
11051087 bq24257_field_write(bq, F_RESET, 1); /* reset to defaults */
11061088
....@@ -1170,6 +1152,7 @@
11701152 };
11711153 MODULE_DEVICE_TABLE(of, bq24257_of_match);
11721154
1155
+#ifdef CONFIG_ACPI
11731156 static const struct acpi_device_id bq24257_acpi_match[] = {
11741157 { "BQ242500", BQ24250 },
11751158 { "BQ242510", BQ24251 },
....@@ -1177,6 +1160,7 @@
11771160 {},
11781161 };
11791162 MODULE_DEVICE_TABLE(acpi, bq24257_acpi_match);
1163
+#endif
11801164
11811165 static struct i2c_driver bq24257_driver = {
11821166 .driver = {