| .. | .. |
|---|
| 448 | 448 | if (!info) |
|---|
| 449 | 449 | return -EINVAL; |
|---|
| 450 | 450 | |
|---|
| 451 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 452 | | - if (ret < 0) { |
|---|
| 453 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 451 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 452 | + if (ret < 0) |
|---|
| 454 | 453 | return ret; |
|---|
| 455 | | - } |
|---|
| 456 | 454 | |
|---|
| 457 | 455 | ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v); |
|---|
| 458 | 456 | if (ret) |
|---|
| .. | .. |
|---|
| 483 | 481 | if (ret < 0) |
|---|
| 484 | 482 | return ret; |
|---|
| 485 | 483 | |
|---|
| 486 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 487 | | - if (ret < 0) { |
|---|
| 488 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 484 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 485 | + if (ret < 0) |
|---|
| 489 | 486 | return ret; |
|---|
| 490 | | - } |
|---|
| 491 | 487 | |
|---|
| 492 | 488 | ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v); |
|---|
| 493 | 489 | if (ret) |
|---|
| .. | .. |
|---|
| 506 | 502 | struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); |
|---|
| 507 | 503 | int ret; |
|---|
| 508 | 504 | |
|---|
| 509 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 505 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 510 | 506 | if (ret < 0) { |
|---|
| 511 | 507 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); |
|---|
| 512 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 513 | 508 | return ret; |
|---|
| 514 | 509 | } |
|---|
| 515 | 510 | |
|---|
| .. | .. |
|---|
| 539 | 534 | int ret; |
|---|
| 540 | 535 | u8 val; |
|---|
| 541 | 536 | |
|---|
| 542 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 537 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 543 | 538 | if (ret < 0) { |
|---|
| 544 | 539 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); |
|---|
| 545 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 546 | 540 | return ret; |
|---|
| 547 | 541 | } |
|---|
| 548 | 542 | |
|---|
| .. | .. |
|---|
| 1083 | 1077 | |
|---|
| 1084 | 1078 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1085 | 1079 | |
|---|
| 1086 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1087 | | - if (ret < 0) { |
|---|
| 1088 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1080 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1081 | + if (ret < 0) |
|---|
| 1089 | 1082 | return ret; |
|---|
| 1090 | | - } |
|---|
| 1091 | 1083 | |
|---|
| 1092 | 1084 | switch (psp) { |
|---|
| 1093 | 1085 | case POWER_SUPPLY_PROP_CHARGE_TYPE: |
|---|
| .. | .. |
|---|
| 1157 | 1149 | |
|---|
| 1158 | 1150 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1159 | 1151 | |
|---|
| 1160 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1161 | | - if (ret < 0) { |
|---|
| 1162 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1152 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1153 | + if (ret < 0) |
|---|
| 1163 | 1154 | return ret; |
|---|
| 1164 | | - } |
|---|
| 1165 | 1155 | |
|---|
| 1166 | 1156 | switch (psp) { |
|---|
| 1167 | 1157 | case POWER_SUPPLY_PROP_ONLINE: |
|---|
| .. | .. |
|---|
| 1213 | 1203 | struct bq24190_dev_info *bdi = |
|---|
| 1214 | 1204 | container_of(work, struct bq24190_dev_info, |
|---|
| 1215 | 1205 | input_current_limit_work.work); |
|---|
| 1206 | + union power_supply_propval val; |
|---|
| 1207 | + int ret; |
|---|
| 1216 | 1208 | |
|---|
| 1217 | | - power_supply_set_input_current_limit_from_supplier(bdi->charger); |
|---|
| 1209 | + ret = power_supply_get_property_from_supplier(bdi->charger, |
|---|
| 1210 | + POWER_SUPPLY_PROP_CURRENT_MAX, |
|---|
| 1211 | + &val); |
|---|
| 1212 | + if (ret) |
|---|
| 1213 | + return; |
|---|
| 1214 | + |
|---|
| 1215 | + bq24190_charger_set_property(bdi->charger, |
|---|
| 1216 | + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, |
|---|
| 1217 | + &val); |
|---|
| 1218 | + power_supply_changed(bdi->charger); |
|---|
| 1218 | 1219 | } |
|---|
| 1219 | 1220 | |
|---|
| 1220 | 1221 | /* Sync the input-current-limit with our parent supply (if we have one) */ |
|---|
| .. | .. |
|---|
| 1420 | 1421 | dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); |
|---|
| 1421 | 1422 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1422 | 1423 | |
|---|
| 1423 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1424 | | - if (ret < 0) { |
|---|
| 1425 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1424 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1425 | + if (ret < 0) |
|---|
| 1426 | 1426 | return ret; |
|---|
| 1427 | | - } |
|---|
| 1428 | 1427 | |
|---|
| 1429 | 1428 | switch (psp) { |
|---|
| 1430 | 1429 | case POWER_SUPPLY_PROP_STATUS: |
|---|
| .. | .. |
|---|
| 1468 | 1467 | dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); |
|---|
| 1469 | 1468 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1470 | 1469 | |
|---|
| 1471 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1472 | | - if (ret < 0) { |
|---|
| 1473 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1470 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1471 | + if (ret < 0) |
|---|
| 1474 | 1472 | return ret; |
|---|
| 1475 | | - } |
|---|
| 1476 | 1473 | |
|---|
| 1477 | 1474 | switch (psp) { |
|---|
| 1478 | 1475 | case POWER_SUPPLY_PROP_ONLINE: |
|---|
| .. | .. |
|---|
| 1626 | 1623 | int error; |
|---|
| 1627 | 1624 | |
|---|
| 1628 | 1625 | bdi->irq_event = true; |
|---|
| 1629 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1626 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1630 | 1627 | if (error < 0) { |
|---|
| 1631 | 1628 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1632 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1633 | 1629 | return IRQ_NONE; |
|---|
| 1634 | 1630 | } |
|---|
| 1635 | 1631 | bq24190_check_status(bdi); |
|---|
| .. | .. |
|---|
| 1849 | 1845 | struct bq24190_dev_info *bdi = i2c_get_clientdata(client); |
|---|
| 1850 | 1846 | int error; |
|---|
| 1851 | 1847 | |
|---|
| 1852 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1853 | | - if (error < 0) { |
|---|
| 1848 | + cancel_delayed_work_sync(&bdi->input_current_limit_work); |
|---|
| 1849 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1850 | + if (error < 0) |
|---|
| 1854 | 1851 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1855 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1856 | | - } |
|---|
| 1857 | 1852 | |
|---|
| 1858 | 1853 | bq24190_register_reset(bdi); |
|---|
| 1859 | 1854 | if (bdi->battery) |
|---|
| .. | .. |
|---|
| 1902 | 1897 | struct bq24190_dev_info *bdi = i2c_get_clientdata(client); |
|---|
| 1903 | 1898 | int error; |
|---|
| 1904 | 1899 | |
|---|
| 1905 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1906 | | - if (error < 0) { |
|---|
| 1900 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1901 | + if (error < 0) |
|---|
| 1907 | 1902 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1908 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1909 | | - } |
|---|
| 1910 | 1903 | |
|---|
| 1911 | 1904 | bq24190_register_reset(bdi); |
|---|
| 1912 | 1905 | |
|---|
| .. | .. |
|---|
| 1927 | 1920 | bdi->f_reg = 0; |
|---|
| 1928 | 1921 | bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */ |
|---|
| 1929 | 1922 | |
|---|
| 1930 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1931 | | - if (error < 0) { |
|---|
| 1923 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1924 | + if (error < 0) |
|---|
| 1932 | 1925 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1933 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1934 | | - } |
|---|
| 1935 | 1926 | |
|---|
| 1936 | 1927 | bq24190_register_reset(bdi); |
|---|
| 1937 | 1928 | bq24190_set_config(bdi); |
|---|