Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm

Pull OPP (Operating Performance Points) framework updates for v5.13
from Viresh Kumar:

"This adds devm variants for OPP APIs and updates few of the users
as well (Yangtao Li and Dmitry Osipenko)."

* 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
memory: samsung: exynos5422-dmc: Convert to use resource-managed OPP API
drm/panfrost: Convert to use resource-managed OPP API
drm/lima: Convert to use resource-managed OPP API
mmc: sdhci-msm: Convert to use resource-managed OPP API
spi: spi-qcom-qspi: Convert to use resource-managed OPP API
spi: spi-geni-qcom: Convert to use resource-managed OPP API
serial: qcom_geni_serial: Convert to use resource-managed OPP API
opp: Change return type of devm_pm_opp_attach_genpd()
opp: Change return type of devm_pm_opp_register_set_opp_helper()
opp: Add devres wrapper for dev_pm_opp_of_add_table
opp: Add devres wrapper for dev_pm_opp_set_supported_hw
opp: Add devres wrapper for dev_pm_opp_set_regulators
opp: Add devres wrapper for dev_pm_opp_set_clkname

+217 -165
+11 -36
drivers/gpu/drm/lima/lima_devfreq.c
··· 99 99 devm_devfreq_remove_device(ldev->dev, devfreq->devfreq); 100 100 devfreq->devfreq = NULL; 101 101 } 102 - 103 - dev_pm_opp_of_remove_table(ldev->dev); 104 - 105 - dev_pm_opp_put_regulators(devfreq->regulators_opp_table); 106 - dev_pm_opp_put_clkname(devfreq->clkname_opp_table); 107 - devfreq->regulators_opp_table = NULL; 108 - devfreq->clkname_opp_table = NULL; 109 102 } 110 103 111 104 int lima_devfreq_init(struct lima_device *ldev) 112 105 { 113 106 struct thermal_cooling_device *cooling; 114 107 struct device *dev = ldev->dev; 115 - struct opp_table *opp_table; 116 108 struct devfreq *devfreq; 117 109 struct lima_devfreq *ldevfreq = &ldev->devfreq; 118 110 struct dev_pm_opp *opp; ··· 117 125 118 126 spin_lock_init(&ldevfreq->lock); 119 127 120 - opp_table = dev_pm_opp_set_clkname(dev, "core"); 121 - if (IS_ERR(opp_table)) { 122 - ret = PTR_ERR(opp_table); 123 - goto err_fini; 124 - } 128 + ret = devm_pm_opp_set_clkname(dev, "core"); 129 + if (ret) 130 + return ret; 125 131 126 - ldevfreq->clkname_opp_table = opp_table; 127 - 128 - opp_table = dev_pm_opp_set_regulators(dev, 129 - (const char *[]){ "mali" }, 130 - 1); 131 - if (IS_ERR(opp_table)) { 132 - ret = PTR_ERR(opp_table); 133 - 132 + ret = devm_pm_opp_set_regulators(dev, (const char *[]){ "mali" }, 1); 133 + if (ret) { 134 134 /* Continue if the optional regulator is missing */ 135 135 if (ret != -ENODEV) 136 - goto err_fini; 137 - } else { 138 - ldevfreq->regulators_opp_table = opp_table; 136 + return ret; 139 137 } 140 138 141 - ret = dev_pm_opp_of_add_table(dev); 139 + ret = devm_pm_opp_of_add_table(dev); 142 140 if (ret) 143 - goto err_fini; 141 + return ret; 144 142 145 143 lima_devfreq_reset(ldevfreq); 146 144 147 145 cur_freq = clk_get_rate(ldev->clk_gpu); 148 146 149 147 opp = devfreq_recommended_opp(dev, &cur_freq, 0); 150 - if (IS_ERR(opp)) { 151 - ret = PTR_ERR(opp); 152 - goto err_fini; 153 - } 148 + if (IS_ERR(opp)) 149 + return PTR_ERR(opp); 154 150 155 151 lima_devfreq_profile.initial_freq = cur_freq; 156 152 dev_pm_opp_put(opp); ··· 147 167 DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); 148 168 if (IS_ERR(devfreq)) { 149 169 dev_err(dev, "Couldn't initialize GPU devfreq\n"); 150 - ret = PTR_ERR(devfreq); 151 - goto err_fini; 170 + return PTR_ERR(devfreq); 152 171 } 153 172 154 173 ldevfreq->devfreq = devfreq; ··· 159 180 ldevfreq->cooling = cooling; 160 181 161 182 return 0; 162 - 163 - err_fini: 164 - lima_devfreq_fini(ldev); 165 - return ret; 166 183 } 167 184 168 185 void lima_devfreq_record_busy(struct lima_devfreq *devfreq)
-3
drivers/gpu/drm/lima/lima_devfreq.h
··· 8 8 #include <linux/ktime.h> 9 9 10 10 struct devfreq; 11 - struct opp_table; 12 11 struct thermal_cooling_device; 13 12 14 13 struct lima_device; 15 14 16 15 struct lima_devfreq { 17 16 struct devfreq *devfreq; 18 - struct opp_table *clkname_opp_table; 19 - struct opp_table *regulators_opp_table; 20 17 struct thermal_cooling_device *cooling; 21 18 22 19 ktime_t busy_time;
+9 -28
drivers/gpu/drm/panfrost/panfrost_devfreq.c
··· 89 89 unsigned long cur_freq; 90 90 struct device *dev = &pfdev->pdev->dev; 91 91 struct devfreq *devfreq; 92 - struct opp_table *opp_table; 93 92 struct thermal_cooling_device *cooling; 94 93 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; 95 94 96 - opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, 97 - pfdev->comp->num_supplies); 98 - if (IS_ERR(opp_table)) { 99 - ret = PTR_ERR(opp_table); 95 + ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names, 96 + pfdev->comp->num_supplies); 97 + if (ret) { 100 98 /* Continue if the optional regulator is missing */ 101 99 if (ret != -ENODEV) { 102 100 DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n"); 103 - goto err_fini; 101 + return ret; 104 102 } 105 - } else { 106 - pfdevfreq->regulators_opp_table = opp_table; 107 103 } 108 104 109 - ret = dev_pm_opp_of_add_table(dev); 105 + ret = devm_pm_opp_of_add_table(dev); 110 106 if (ret) { 111 107 /* Optional, continue without devfreq */ 112 108 if (ret == -ENODEV) 113 109 ret = 0; 114 - goto err_fini; 110 + return ret; 115 111 } 116 112 pfdevfreq->opp_of_table_added = true; 117 113 ··· 118 122 cur_freq = clk_get_rate(pfdev->clock); 119 123 120 124 opp = devfreq_recommended_opp(dev, &cur_freq, 0); 121 - if (IS_ERR(opp)) { 122 - ret = PTR_ERR(opp); 123 - goto err_fini; 124 - } 125 + if (IS_ERR(opp)) 126 + return PTR_ERR(opp); 125 127 126 128 panfrost_devfreq_profile.initial_freq = cur_freq; 127 129 dev_pm_opp_put(opp); ··· 128 134 DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); 129 135 if (IS_ERR(devfreq)) { 130 136 DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n"); 131 - ret = PTR_ERR(devfreq); 132 - goto err_fini; 137 + return PTR_ERR(devfreq); 133 138 } 134 139 pfdevfreq->devfreq = devfreq; 135 140 ··· 139 146 pfdevfreq->cooling = cooling; 140 147 141 148 return 0; 142 - 143 - err_fini: 144 - panfrost_devfreq_fini(pfdev); 145 - return ret; 146 149 } 147 150 148 151 void panfrost_devfreq_fini(struct panfrost_device *pfdev) ··· 149 160 devfreq_cooling_unregister(pfdevfreq->cooling); 150 161 pfdevfreq->cooling = NULL; 151 162 } 152 - 153 - if (pfdevfreq->opp_of_table_added) { 154 - dev_pm_opp_of_remove_table(&pfdev->pdev->dev); 155 - pfdevfreq->opp_of_table_added = false; 156 - } 157 - 158 - dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table); 159 - pfdevfreq->regulators_opp_table = NULL; 160 163 } 161 164 162 165 void panfrost_devfreq_resume(struct panfrost_device *pfdev)
-2
drivers/gpu/drm/panfrost/panfrost_devfreq.h
··· 8 8 #include <linux/ktime.h> 9 9 10 10 struct devfreq; 11 - struct opp_table; 12 11 struct thermal_cooling_device; 13 12 14 13 struct panfrost_device; 15 14 16 15 struct panfrost_devfreq { 17 16 struct devfreq *devfreq; 18 - struct opp_table *regulators_opp_table; 19 17 struct thermal_cooling_device *cooling; 20 18 bool opp_of_table_added; 21 19
+3 -10
drivers/memory/samsung/exynos5422-dmc.c
··· 343 343 int idx; 344 344 unsigned long freq; 345 345 346 - ret = dev_pm_opp_of_add_table(dmc->dev); 346 + ret = devm_pm_opp_of_add_table(dmc->dev); 347 347 if (ret < 0) { 348 348 dev_err(dmc->dev, "Failed to get OPP table\n"); 349 349 return ret; ··· 354 354 dmc->opp = devm_kmalloc_array(dmc->dev, dmc->opp_count, 355 355 sizeof(struct dmc_opp_table), GFP_KERNEL); 356 356 if (!dmc->opp) 357 - goto err_opp; 357 + return -ENOMEM; 358 358 359 359 idx = dmc->opp_count - 1; 360 360 for (i = 0, freq = ULONG_MAX; i < dmc->opp_count; i++, freq--) { ··· 362 362 363 363 opp = dev_pm_opp_find_freq_floor(dmc->dev, &freq); 364 364 if (IS_ERR(opp)) 365 - goto err_opp; 365 + return PTR_ERR(opp); 366 366 367 367 dmc->opp[idx - i].freq_hz = freq; 368 368 dmc->opp[idx - i].volt_uv = dev_pm_opp_get_voltage(opp); ··· 371 371 } 372 372 373 373 return 0; 374 - 375 - err_opp: 376 - dev_pm_opp_of_remove_table(dmc->dev); 377 - 378 - return -EINVAL; 379 374 } 380 375 381 376 /** ··· 1561 1566 1562 1567 clk_disable_unprepare(dmc->mout_bpll); 1563 1568 clk_disable_unprepare(dmc->fout_bpll); 1564 - 1565 - dev_pm_opp_remove_table(dmc->dev); 1566 1569 1567 1570 return 0; 1568 1571 }
+5 -14
drivers/mmc/host/sdhci-msm.c
··· 264 264 struct clk_bulk_data bulk_clks[5]; 265 265 unsigned long clk_rate; 266 266 struct mmc_host *mmc; 267 - struct opp_table *opp_table; 268 267 bool use_14lpp_dll_reset; 269 268 bool tuning_done; 270 269 bool calibration_done; ··· 2550 2551 if (ret) 2551 2552 goto bus_clk_disable; 2552 2553 2553 - msm_host->opp_table = dev_pm_opp_set_clkname(&pdev->dev, "core"); 2554 - if (IS_ERR(msm_host->opp_table)) { 2555 - ret = PTR_ERR(msm_host->opp_table); 2554 + ret = devm_pm_opp_set_clkname(&pdev->dev, "core"); 2555 + if (ret) 2556 2556 goto bus_clk_disable; 2557 - } 2558 2557 2559 2558 /* OPP table is optional */ 2560 - ret = dev_pm_opp_of_add_table(&pdev->dev); 2559 + ret = devm_pm_opp_of_add_table(&pdev->dev); 2561 2560 if (ret && ret != -ENODEV) { 2562 2561 dev_err(&pdev->dev, "Invalid OPP table in Device tree\n"); 2563 - goto opp_put_clkname; 2562 + goto bus_clk_disable; 2564 2563 } 2565 2564 2566 2565 /* Vote for maximum clock rate for maximum performance */ ··· 2584 2587 ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), 2585 2588 msm_host->bulk_clks); 2586 2589 if (ret) 2587 - goto opp_cleanup; 2590 + goto bus_clk_disable; 2588 2591 2589 2592 /* 2590 2593 * xo clock is needed for FLL feature of cm_dll. ··· 2729 2732 clk_disable: 2730 2733 clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), 2731 2734 msm_host->bulk_clks); 2732 - opp_cleanup: 2733 - dev_pm_opp_of_remove_table(&pdev->dev); 2734 - opp_put_clkname: 2735 - dev_pm_opp_put_clkname(msm_host->opp_table); 2736 2735 bus_clk_disable: 2737 2736 if (!IS_ERR(msm_host->bus_clk)) 2738 2737 clk_disable_unprepare(msm_host->bus_clk); ··· 2747 2754 2748 2755 sdhci_remove_host(host, dead); 2749 2756 2750 - dev_pm_opp_of_remove_table(&pdev->dev); 2751 - dev_pm_opp_put_clkname(msm_host->opp_table); 2752 2757 pm_runtime_get_sync(&pdev->dev); 2753 2758 pm_runtime_disable(&pdev->dev); 2754 2759 pm_runtime_put_noidle(&pdev->dev);
+98 -24
drivers/opp/core.c
··· 1857 1857 } 1858 1858 EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw); 1859 1859 1860 + static void devm_pm_opp_supported_hw_release(void *data) 1861 + { 1862 + dev_pm_opp_put_supported_hw(data); 1863 + } 1864 + 1865 + /** 1866 + * devm_pm_opp_set_supported_hw() - Set supported platforms 1867 + * @dev: Device for which supported-hw has to be set. 1868 + * @versions: Array of hierarchy of versions to match. 1869 + * @count: Number of elements in the array. 1870 + * 1871 + * This is a resource-managed variant of dev_pm_opp_set_supported_hw(). 1872 + * 1873 + * Return: 0 on success and errorno otherwise. 1874 + */ 1875 + int devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, 1876 + unsigned int count) 1877 + { 1878 + struct opp_table *opp_table; 1879 + 1880 + opp_table = dev_pm_opp_set_supported_hw(dev, versions, count); 1881 + if (IS_ERR(opp_table)) 1882 + return PTR_ERR(opp_table); 1883 + 1884 + return devm_add_action_or_reset(dev, devm_pm_opp_supported_hw_release, 1885 + opp_table); 1886 + } 1887 + EXPORT_SYMBOL_GPL(devm_pm_opp_set_supported_hw); 1888 + 1860 1889 /** 1861 1890 * dev_pm_opp_set_prop_name() - Set prop-extn name 1862 1891 * @dev: Device for which the prop-name has to be set. ··· 2076 2047 } 2077 2048 EXPORT_SYMBOL_GPL(dev_pm_opp_put_regulators); 2078 2049 2050 + static void devm_pm_opp_regulators_release(void *data) 2051 + { 2052 + dev_pm_opp_put_regulators(data); 2053 + } 2054 + 2055 + /** 2056 + * devm_pm_opp_set_regulators() - Set regulator names for the device 2057 + * @dev: Device for which regulator name is being set. 2058 + * @names: Array of pointers to the names of the regulator. 2059 + * @count: Number of regulators. 2060 + * 2061 + * This is a resource-managed variant of dev_pm_opp_set_regulators(). 2062 + * 2063 + * Return: 0 on success and errorno otherwise. 2064 + */ 2065 + int devm_pm_opp_set_regulators(struct device *dev, 2066 + const char * const names[], 2067 + unsigned int count) 2068 + { 2069 + struct opp_table *opp_table; 2070 + 2071 + opp_table = dev_pm_opp_set_regulators(dev, names, count); 2072 + if (IS_ERR(opp_table)) 2073 + return PTR_ERR(opp_table); 2074 + 2075 + return devm_add_action_or_reset(dev, devm_pm_opp_regulators_release, 2076 + opp_table); 2077 + } 2078 + EXPORT_SYMBOL_GPL(devm_pm_opp_set_regulators); 2079 + 2079 2080 /** 2080 2081 * dev_pm_opp_set_clkname() - Set clk name for the device 2081 2082 * @dev: Device for which clk name is being set. ··· 2177 2118 dev_pm_opp_put_opp_table(opp_table); 2178 2119 } 2179 2120 EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname); 2121 + 2122 + static void devm_pm_opp_clkname_release(void *data) 2123 + { 2124 + dev_pm_opp_put_clkname(data); 2125 + } 2126 + 2127 + /** 2128 + * devm_pm_opp_set_clkname() - Set clk name for the device 2129 + * @dev: Device for which clk name is being set. 2130 + * @name: Clk name. 2131 + * 2132 + * This is a resource-managed variant of dev_pm_opp_set_clkname(). 2133 + * 2134 + * Return: 0 on success and errorno otherwise. 2135 + */ 2136 + int devm_pm_opp_set_clkname(struct device *dev, const char *name) 2137 + { 2138 + struct opp_table *opp_table; 2139 + 2140 + opp_table = dev_pm_opp_set_clkname(dev, name); 2141 + if (IS_ERR(opp_table)) 2142 + return PTR_ERR(opp_table); 2143 + 2144 + return devm_add_action_or_reset(dev, devm_pm_opp_clkname_release, 2145 + opp_table); 2146 + } 2147 + EXPORT_SYMBOL_GPL(devm_pm_opp_set_clkname); 2180 2148 2181 2149 /** 2182 2150 * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper ··· 2295 2209 * 2296 2210 * This is a resource-managed version of dev_pm_opp_register_set_opp_helper(). 2297 2211 * 2298 - * Return: pointer to 'struct opp_table' on success and errorno otherwise. 2212 + * Return: 0 on success and errorno otherwise. 2299 2213 */ 2300 - struct opp_table * 2301 - devm_pm_opp_register_set_opp_helper(struct device *dev, 2302 - int (*set_opp)(struct dev_pm_set_opp_data *data)) 2214 + int devm_pm_opp_register_set_opp_helper(struct device *dev, 2215 + int (*set_opp)(struct dev_pm_set_opp_data *data)) 2303 2216 { 2304 2217 struct opp_table *opp_table; 2305 - int err; 2306 2218 2307 2219 opp_table = dev_pm_opp_register_set_opp_helper(dev, set_opp); 2308 2220 if (IS_ERR(opp_table)) 2309 - return opp_table; 2221 + return PTR_ERR(opp_table); 2310 2222 2311 - err = devm_add_action_or_reset(dev, devm_pm_opp_unregister_set_opp_helper, 2312 - opp_table); 2313 - if (err) 2314 - return ERR_PTR(err); 2315 - 2316 - return opp_table; 2223 + return devm_add_action_or_reset(dev, devm_pm_opp_unregister_set_opp_helper, 2224 + opp_table); 2317 2225 } 2318 2226 EXPORT_SYMBOL_GPL(devm_pm_opp_register_set_opp_helper); 2319 2227 ··· 2460 2380 * 2461 2381 * This is a resource-managed version of dev_pm_opp_attach_genpd(). 2462 2382 * 2463 - * Return: pointer to 'struct opp_table' on success and errorno otherwise. 2383 + * Return: 0 on success and errorno otherwise. 2464 2384 */ 2465 - struct opp_table * 2466 - devm_pm_opp_attach_genpd(struct device *dev, const char **names, 2467 - struct device ***virt_devs) 2385 + int devm_pm_opp_attach_genpd(struct device *dev, const char **names, 2386 + struct device ***virt_devs) 2468 2387 { 2469 2388 struct opp_table *opp_table; 2470 - int err; 2471 2389 2472 2390 opp_table = dev_pm_opp_attach_genpd(dev, names, virt_devs); 2473 2391 if (IS_ERR(opp_table)) 2474 - return opp_table; 2392 + return PTR_ERR(opp_table); 2475 2393 2476 - err = devm_add_action_or_reset(dev, devm_pm_opp_detach_genpd, 2477 - opp_table); 2478 - if (err) 2479 - return ERR_PTR(err); 2480 - 2481 - return opp_table; 2394 + return devm_add_action_or_reset(dev, devm_pm_opp_detach_genpd, 2395 + opp_table); 2482 2396 } 2483 2397 EXPORT_SYMBOL_GPL(devm_pm_opp_attach_genpd); 2484 2398
+36
drivers/opp/of.c
··· 1104 1104 return ret; 1105 1105 } 1106 1106 1107 + static void devm_pm_opp_of_table_release(void *data) 1108 + { 1109 + dev_pm_opp_of_remove_table(data); 1110 + } 1111 + 1112 + /** 1113 + * devm_pm_opp_of_add_table() - Initialize opp table from device tree 1114 + * @dev: device pointer used to lookup OPP table. 1115 + * 1116 + * Register the initial OPP table with the OPP library for given device. 1117 + * 1118 + * The opp_table structure will be freed after the device is destroyed. 1119 + * 1120 + * Return: 1121 + * 0 On success OR 1122 + * Duplicate OPPs (both freq and volt are same) and opp->available 1123 + * -EEXIST Freq are same and volt are different OR 1124 + * Duplicate OPPs (both freq and volt are same) and !opp->available 1125 + * -ENOMEM Memory allocation failure 1126 + * -ENODEV when 'operating-points' property is not found or is invalid data 1127 + * in device node. 1128 + * -ENODATA when empty 'operating-points' property is found 1129 + * -EINVAL when invalid entries are found in opp-v2 table 1130 + */ 1131 + int devm_pm_opp_of_add_table(struct device *dev) 1132 + { 1133 + int ret; 1134 + 1135 + ret = dev_pm_opp_of_add_table(dev); 1136 + if (ret) 1137 + return ret; 1138 + 1139 + return devm_add_action_or_reset(dev, devm_pm_opp_of_table_release, dev); 1140 + } 1141 + EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table); 1142 + 1107 1143 /** 1108 1144 * dev_pm_opp_of_add_table() - Initialize opp table from device tree 1109 1145 * @dev: device pointer used to lookup OPP table.
+6 -10
drivers/spi/spi-geni-qcom.c
··· 691 691 mas->se.wrapper = dev_get_drvdata(dev->parent); 692 692 mas->se.base = base; 693 693 mas->se.clk = clk; 694 - mas->se.opp_table = dev_pm_opp_set_clkname(&pdev->dev, "se"); 695 - if (IS_ERR(mas->se.opp_table)) 696 - return PTR_ERR(mas->se.opp_table); 694 + 695 + ret = devm_pm_opp_set_clkname(&pdev->dev, "se"); 696 + if (ret) 697 + return ret; 697 698 /* OPP table is optional */ 698 - ret = dev_pm_opp_of_add_table(&pdev->dev); 699 + ret = devm_pm_opp_of_add_table(&pdev->dev); 699 700 if (ret && ret != -ENODEV) { 700 701 dev_err(&pdev->dev, "invalid OPP table in device tree\n"); 701 - goto put_clkname; 702 + return ret; 702 703 } 703 704 704 705 spi->bus_num = -1; ··· 751 750 free_irq(mas->irq, spi); 752 751 spi_geni_probe_runtime_disable: 753 752 pm_runtime_disable(dev); 754 - dev_pm_opp_of_remove_table(&pdev->dev); 755 - put_clkname: 756 - dev_pm_opp_put_clkname(mas->se.opp_table); 757 753 return ret; 758 754 } 759 755 ··· 764 766 765 767 free_irq(mas->irq, spi); 766 768 pm_runtime_disable(&pdev->dev); 767 - dev_pm_opp_of_remove_table(&pdev->dev); 768 - dev_pm_opp_put_clkname(mas->se.opp_table); 769 769 return 0; 770 770 } 771 771
+5 -13
drivers/spi/spi-qcom-qspi.c
··· 142 142 struct clk_bulk_data *clks; 143 143 struct qspi_xfer xfer; 144 144 struct icc_path *icc_path_cpu_to_qspi; 145 - struct opp_table *opp_table; 146 145 unsigned long last_speed; 147 146 /* Lock to protect data accessed by IRQs */ 148 147 spinlock_t lock; ··· 529 530 master->handle_err = qcom_qspi_handle_err; 530 531 master->auto_runtime_pm = true; 531 532 532 - ctrl->opp_table = dev_pm_opp_set_clkname(&pdev->dev, "core"); 533 - if (IS_ERR(ctrl->opp_table)) 534 - return PTR_ERR(ctrl->opp_table); 533 + ret = devm_pm_opp_set_clkname(&pdev->dev, "core"); 534 + if (ret) 535 + return ret; 535 536 /* OPP table is optional */ 536 - ret = dev_pm_opp_of_add_table(&pdev->dev); 537 + ret = devm_pm_opp_of_add_table(&pdev->dev); 537 538 if (ret && ret != -ENODEV) { 538 539 dev_err(&pdev->dev, "invalid OPP table in device tree\n"); 539 - goto exit_probe_put_clkname; 540 + return ret; 540 541 } 541 542 542 543 pm_runtime_use_autosuspend(dev); ··· 548 549 return 0; 549 550 550 551 pm_runtime_disable(dev); 551 - dev_pm_opp_of_remove_table(&pdev->dev); 552 - 553 - exit_probe_put_clkname: 554 - dev_pm_opp_put_clkname(ctrl->opp_table); 555 552 556 553 return ret; 557 554 } ··· 555 560 static int qcom_qspi_remove(struct platform_device *pdev) 556 561 { 557 562 struct spi_master *master = platform_get_drvdata(pdev); 558 - struct qcom_qspi *ctrl = spi_master_get_devdata(master); 559 563 560 564 /* Unregister _before_ disabling pm_runtime() so we stop transfers */ 561 565 spi_unregister_master(master); 562 566 563 567 pm_runtime_disable(&pdev->dev); 564 - dev_pm_opp_of_remove_table(&pdev->dev); 565 - dev_pm_opp_put_clkname(ctrl->opp_table); 566 568 567 569 return 0; 568 570 }
+8 -15
drivers/tty/serial/qcom_geni_serial.c
··· 1426 1426 if (of_property_read_bool(pdev->dev.of_node, "cts-rts-swap")) 1427 1427 port->cts_rts_swap = true; 1428 1428 1429 - port->se.opp_table = dev_pm_opp_set_clkname(&pdev->dev, "se"); 1430 - if (IS_ERR(port->se.opp_table)) 1431 - return PTR_ERR(port->se.opp_table); 1429 + ret = devm_pm_opp_set_clkname(&pdev->dev, "se"); 1430 + if (ret) 1431 + return ret; 1432 1432 /* OPP table is optional */ 1433 - ret = dev_pm_opp_of_add_table(&pdev->dev); 1433 + ret = devm_pm_opp_of_add_table(&pdev->dev); 1434 1434 if (ret && ret != -ENODEV) { 1435 1435 dev_err(&pdev->dev, "invalid OPP table in device tree\n"); 1436 - goto put_clkname; 1436 + return ret; 1437 1437 } 1438 1438 1439 1439 port->private_data.drv = drv; ··· 1443 1443 1444 1444 ret = uart_add_one_port(drv, uport); 1445 1445 if (ret) 1446 - goto err; 1446 + return ret; 1447 1447 1448 1448 irq_set_status_flags(uport->irq, IRQ_NOAUTOEN); 1449 1449 ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr, ··· 1451 1451 if (ret) { 1452 1452 dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret); 1453 1453 uart_remove_one_port(drv, uport); 1454 - goto err; 1454 + return ret; 1455 1455 } 1456 1456 1457 1457 /* ··· 1468 1468 if (ret) { 1469 1469 device_init_wakeup(&pdev->dev, false); 1470 1470 uart_remove_one_port(drv, uport); 1471 - goto err; 1471 + return ret; 1472 1472 } 1473 1473 } 1474 1474 1475 1475 return 0; 1476 - err: 1477 - dev_pm_opp_of_remove_table(&pdev->dev); 1478 - put_clkname: 1479 - dev_pm_opp_put_clkname(port->se.opp_table); 1480 - return ret; 1481 1476 } 1482 1477 1483 1478 static int qcom_geni_serial_remove(struct platform_device *pdev) ··· 1480 1485 struct qcom_geni_serial_port *port = platform_get_drvdata(pdev); 1481 1486 struct uart_driver *drv = port->private_data.drv; 1482 1487 1483 - dev_pm_opp_of_remove_table(&pdev->dev); 1484 - dev_pm_opp_put_clkname(port->se.opp_table); 1485 1488 dev_pm_clear_wake_irq(&pdev->dev); 1486 1489 device_init_wakeup(&pdev->dev, false); 1487 1490 uart_remove_one_port(drv, &port->uport);
+36 -8
include/linux/pm_opp.h
··· 144 144 145 145 struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); 146 146 void dev_pm_opp_put_supported_hw(struct opp_table *opp_table); 147 + int devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); 147 148 struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name); 148 149 void dev_pm_opp_put_prop_name(struct opp_table *opp_table); 149 150 struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * const names[], unsigned int count); 150 151 void dev_pm_opp_put_regulators(struct opp_table *opp_table); 152 + int devm_pm_opp_set_regulators(struct device *dev, const char * const names[], unsigned int count); 151 153 struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name); 152 154 void dev_pm_opp_put_clkname(struct opp_table *opp_table); 155 + int devm_pm_opp_set_clkname(struct device *dev, const char *name); 153 156 struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); 154 157 void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); 155 - struct opp_table *devm_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); 158 + int devm_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); 156 159 struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); 157 160 void dev_pm_opp_detach_genpd(struct opp_table *opp_table); 158 - struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); 161 + int devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); 159 162 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp); 160 163 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); 161 164 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); ··· 322 319 323 320 static inline void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) {} 324 321 322 + static inline int devm_pm_opp_set_supported_hw(struct device *dev, 323 + const u32 *versions, 324 + unsigned int count) 325 + { 326 + return -EOPNOTSUPP; 327 + } 328 + 325 329 static inline struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, 326 330 int (*set_opp)(struct dev_pm_set_opp_data *data)) 327 331 { ··· 337 327 338 328 static inline void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table) {} 339 329 340 - static inline struct opp_table * 341 - devm_pm_opp_register_set_opp_helper(struct device *dev, 330 + static inline int devm_pm_opp_register_set_opp_helper(struct device *dev, 342 331 int (*set_opp)(struct dev_pm_set_opp_data *data)) 343 332 { 344 - return ERR_PTR(-EOPNOTSUPP); 333 + return -EOPNOTSUPP; 345 334 } 346 335 347 336 static inline struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name) ··· 357 348 358 349 static inline void dev_pm_opp_put_regulators(struct opp_table *opp_table) {} 359 350 351 + static inline int devm_pm_opp_set_regulators(struct device *dev, 352 + const char * const names[], 353 + unsigned int count) 354 + { 355 + return -EOPNOTSUPP; 356 + } 357 + 360 358 static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name) 361 359 { 362 360 return ERR_PTR(-EOPNOTSUPP); 363 361 } 364 362 365 363 static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {} 364 + 365 + static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) 366 + { 367 + return -EOPNOTSUPP; 368 + } 366 369 367 370 static inline struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs) 368 371 { ··· 383 362 384 363 static inline void dev_pm_opp_detach_genpd(struct opp_table *opp_table) {} 385 364 386 - static inline struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, 387 - const char **names, struct device ***virt_devs) 365 + static inline int devm_pm_opp_attach_genpd(struct device *dev, 366 + const char **names, 367 + struct device ***virt_devs) 388 368 { 389 - return ERR_PTR(-EOPNOTSUPP); 369 + return -EOPNOTSUPP; 390 370 } 391 371 392 372 static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, ··· 441 419 int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); 442 420 int dev_pm_opp_of_add_table_noclk(struct device *dev, int index); 443 421 void dev_pm_opp_of_remove_table(struct device *dev); 422 + int devm_pm_opp_of_add_table(struct device *dev); 444 423 int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); 445 424 void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); 446 425 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); ··· 472 449 473 450 static inline void dev_pm_opp_of_remove_table(struct device *dev) 474 451 { 452 + } 453 + 454 + static inline int devm_pm_opp_of_add_table(struct device *dev) 455 + { 456 + return -EOPNOTSUPP; 475 457 } 476 458 477 459 static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)
-2
include/linux/qcom-geni-se.h
··· 47 47 * @num_clk_levels: Number of valid clock levels in clk_perf_tbl 48 48 * @clk_perf_tbl: Table of clock frequency input to serial engine clock 49 49 * @icc_paths: Array of ICC paths for SE 50 - * @opp_table: Pointer to the OPP table 51 50 */ 52 51 struct geni_se { 53 52 void __iomem *base; ··· 56 57 unsigned int num_clk_levels; 57 58 unsigned long *clk_perf_tbl; 58 59 struct geni_icc_path icc_paths[3]; 59 - struct opp_table *opp_table; 60 60 }; 61 61 62 62 /* Common SE registers */