| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* NXP PCF50633 Main Battery Charger Driver |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * (C) 2006-2008 by Openmoko, Inc. |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Broken down from monstrous PCF50633 driver mainly by |
|---|
| 8 | 9 | * Harald Welte, Andy Green and Werner Almesberger |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 11 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 12 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 13 | | - * option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | 10 | */ |
|---|
| 16 | 11 | |
|---|
| 17 | 12 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 245 | 240 | */ |
|---|
| 246 | 241 | static DEVICE_ATTR(chg_curlim, S_IRUGO | S_IWUSR, show_chglim, set_chglim); |
|---|
| 247 | 242 | |
|---|
| 248 | | -static struct attribute *pcf50633_mbc_sysfs_entries[] = { |
|---|
| 243 | +static struct attribute *pcf50633_mbc_sysfs_attrs[] = { |
|---|
| 249 | 244 | &dev_attr_chgmode.attr, |
|---|
| 250 | 245 | &dev_attr_usb_curlim.attr, |
|---|
| 251 | 246 | &dev_attr_chg_curlim.attr, |
|---|
| 252 | 247 | NULL, |
|---|
| 253 | 248 | }; |
|---|
| 254 | 249 | |
|---|
| 255 | | -static const struct attribute_group mbc_attr_group = { |
|---|
| 256 | | - .name = NULL, /* put in device directory */ |
|---|
| 257 | | - .attrs = pcf50633_mbc_sysfs_entries, |
|---|
| 258 | | -}; |
|---|
| 250 | +ATTRIBUTE_GROUPS(pcf50633_mbc_sysfs); |
|---|
| 259 | 251 | |
|---|
| 260 | 252 | static void |
|---|
| 261 | 253 | pcf50633_mbc_irq_handler(int irq, void *data) |
|---|
| .. | .. |
|---|
| 390 | 382 | static int pcf50633_mbc_probe(struct platform_device *pdev) |
|---|
| 391 | 383 | { |
|---|
| 392 | 384 | struct power_supply_config psy_cfg = {}; |
|---|
| 385 | + struct power_supply_config usb_psy_cfg; |
|---|
| 393 | 386 | struct pcf50633_mbc *mbc; |
|---|
| 394 | 387 | int i; |
|---|
| 395 | 388 | u8 mbcs1; |
|---|
| .. | .. |
|---|
| 419 | 412 | return PTR_ERR(mbc->adapter); |
|---|
| 420 | 413 | } |
|---|
| 421 | 414 | |
|---|
| 415 | + usb_psy_cfg = psy_cfg; |
|---|
| 416 | + usb_psy_cfg.attr_grp = pcf50633_mbc_sysfs_groups; |
|---|
| 417 | + |
|---|
| 422 | 418 | mbc->usb = power_supply_register(&pdev->dev, &pcf50633_mbc_usb_desc, |
|---|
| 423 | | - &psy_cfg); |
|---|
| 419 | + &usb_psy_cfg); |
|---|
| 424 | 420 | if (IS_ERR(mbc->usb)) { |
|---|
| 425 | 421 | dev_err(mbc->pcf->dev, "failed to register usb\n"); |
|---|
| 426 | 422 | power_supply_unregister(mbc->adapter); |
|---|
| .. | .. |
|---|
| 435 | 431 | power_supply_unregister(mbc->usb); |
|---|
| 436 | 432 | return PTR_ERR(mbc->ac); |
|---|
| 437 | 433 | } |
|---|
| 438 | | - |
|---|
| 439 | | - if (sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group)) |
|---|
| 440 | | - dev_err(mbc->pcf->dev, "failed to create sysfs entries\n"); |
|---|
| 441 | 434 | |
|---|
| 442 | 435 | mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1); |
|---|
| 443 | 436 | if (mbcs1 & PCF50633_MBCS1_USBPRES) |
|---|
| .. | .. |
|---|
| 457 | 450 | for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++) |
|---|
| 458 | 451 | pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]); |
|---|
| 459 | 452 | |
|---|
| 460 | | - sysfs_remove_group(&pdev->dev.kobj, &mbc_attr_group); |
|---|
| 461 | 453 | power_supply_unregister(mbc->usb); |
|---|
| 462 | 454 | power_supply_unregister(mbc->adapter); |
|---|
| 463 | 455 | power_supply_unregister(mbc->ac); |
|---|