.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * TI BQ24257 charger driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2015 Intel Corporation |
---|
5 | 6 | * |
---|
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 | | - * |
---|
16 | 7 | * 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 |
---|
20 | 11 | */ |
---|
21 | 12 | |
---|
22 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
845 | 836 | static DEVICE_ATTR(sysoff_enable, S_IWUSR | S_IRUGO, |
---|
846 | 837 | bq24257_sysfs_show_enable, bq24257_sysfs_set_enable); |
---|
847 | 838 | |
---|
848 | | -static struct attribute *bq24257_charger_attr[] = { |
---|
| 839 | +static struct attribute *bq24257_charger_sysfs_attrs[] = { |
---|
849 | 840 | &dev_attr_ovp_voltage.attr, |
---|
850 | 841 | &dev_attr_in_dpm_voltage.attr, |
---|
851 | 842 | &dev_attr_high_impedance_enable.attr, |
---|
.. | .. |
---|
853 | 844 | NULL, |
---|
854 | 845 | }; |
---|
855 | 846 | |
---|
856 | | -static const struct attribute_group bq24257_attr_group = { |
---|
857 | | - .attrs = bq24257_charger_attr, |
---|
858 | | -}; |
---|
| 847 | +ATTRIBUTE_GROUPS(bq24257_charger_sysfs); |
---|
859 | 848 | |
---|
860 | 849 | static int bq24257_power_supply_init(struct bq24257_device *bq) |
---|
861 | 850 | { |
---|
862 | 851 | struct power_supply_config psy_cfg = { .drv_data = bq, }; |
---|
863 | 852 | |
---|
| 853 | + psy_cfg.attr_grp = bq24257_charger_sysfs_groups; |
---|
864 | 854 | psy_cfg.supplied_to = bq24257_charger_supplied_to; |
---|
865 | 855 | psy_cfg.num_supplicants = ARRAY_SIZE(bq24257_charger_supplied_to); |
---|
866 | 856 | |
---|
.. | .. |
---|
960 | 950 | static int bq24257_probe(struct i2c_client *client, |
---|
961 | 951 | const struct i2c_device_id *id) |
---|
962 | 952 | { |
---|
963 | | - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
---|
| 953 | + struct i2c_adapter *adapter = client->adapter; |
---|
964 | 954 | struct device *dev = &client->dev; |
---|
965 | 955 | const struct acpi_device_id *acpi_id; |
---|
966 | 956 | struct bq24257_device *bq; |
---|
.. | .. |
---|
1084 | 1074 | return ret; |
---|
1085 | 1075 | } |
---|
1086 | 1076 | |
---|
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 | | - |
---|
1093 | 1077 | return 0; |
---|
1094 | 1078 | } |
---|
1095 | 1079 | |
---|
.. | .. |
---|
1099 | 1083 | |
---|
1100 | 1084 | if (bq->iilimit_autoset_enable) |
---|
1101 | 1085 | cancel_delayed_work_sync(&bq->iilimit_setup_work); |
---|
1102 | | - |
---|
1103 | | - sysfs_remove_group(&bq->charger->dev.kobj, &bq24257_attr_group); |
---|
1104 | 1086 | |
---|
1105 | 1087 | bq24257_field_write(bq, F_RESET, 1); /* reset to defaults */ |
---|
1106 | 1088 | |
---|
.. | .. |
---|
1170 | 1152 | }; |
---|
1171 | 1153 | MODULE_DEVICE_TABLE(of, bq24257_of_match); |
---|
1172 | 1154 | |
---|
| 1155 | +#ifdef CONFIG_ACPI |
---|
1173 | 1156 | static const struct acpi_device_id bq24257_acpi_match[] = { |
---|
1174 | 1157 | { "BQ242500", BQ24250 }, |
---|
1175 | 1158 | { "BQ242510", BQ24251 }, |
---|
.. | .. |
---|
1177 | 1160 | {}, |
---|
1178 | 1161 | }; |
---|
1179 | 1162 | MODULE_DEVICE_TABLE(acpi, bq24257_acpi_match); |
---|
| 1163 | +#endif |
---|
1180 | 1164 | |
---|
1181 | 1165 | static struct i2c_driver bq24257_driver = { |
---|
1182 | 1166 | .driver = { |
---|