Skip to content

Commit 8247dac

Browse files
committed
OPP: Drop redundant *_opp_attach|detach_genpd()
JIRA: https://issues.redhat.com/browse/RHEL-75956 commit d6caca3 Author: Ulf Hansson <ulf.hansson@linaro.org> Date: Wed Oct 2 14:22:32 2024 +0200 OPP: Drop redundant *_opp_attach|detach_genpd() All users of *_opp_attach|detach_genpd(), have been converted to use dev|devm_pm_domain_attach|detach_list(), hence let's drop it along with its corresponding exported functions. Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20241002122232.194245-12-ulf.hansson@linaro.org Signed-off-by: José Expósito <jexposit@redhat.com>
1 parent 66cb690 commit 8247dac

File tree

3 files changed

+3
-169
lines changed

3 files changed

+3
-169
lines changed

drivers/opp/core.c

Lines changed: 1 addition & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,119 +2360,6 @@ static void _opp_put_config_regulators_helper(struct opp_table *opp_table)
23602360
opp_table->config_regulators = NULL;
23612361
}
23622362

2363-
static void _opp_detach_genpd(struct opp_table *opp_table)
2364-
{
2365-
int index;
2366-
2367-
for (index = 0; index < opp_table->required_opp_count; index++) {
2368-
if (!opp_table->required_devs[index])
2369-
continue;
2370-
2371-
dev_pm_domain_detach(opp_table->required_devs[index], false);
2372-
opp_table->required_devs[index] = NULL;
2373-
}
2374-
}
2375-
2376-
/*
2377-
* Multiple generic power domains for a device are supported with the help of
2378-
* virtual genpd devices, which are created for each consumer device - genpd
2379-
* pair. These are the device structures which are attached to the power domain
2380-
* and are required by the OPP core to set the performance state of the genpd.
2381-
* The same API also works for the case where single genpd is available and so
2382-
* we don't need to support that separately.
2383-
*
2384-
* This helper will normally be called by the consumer driver of the device
2385-
* "dev", as only that has details of the genpd names.
2386-
*
2387-
* This helper needs to be called once with a list of all genpd to attach.
2388-
* Otherwise the original device structure will be used instead by the OPP core.
2389-
*
2390-
* The order of entries in the names array must match the order in which
2391-
* "required-opps" are added in DT.
2392-
*/
2393-
static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
2394-
const char * const *names, struct device ***virt_devs)
2395-
{
2396-
struct device *virt_dev, *gdev;
2397-
struct opp_table *genpd_table;
2398-
int index = 0, ret = -EINVAL;
2399-
const char * const *name = names;
2400-
2401-
if (!opp_table->required_devs) {
2402-
dev_err(dev, "Required OPPs not available, can't attach genpd\n");
2403-
return -EINVAL;
2404-
}
2405-
2406-
/* Genpd core takes care of propagation to parent genpd */
2407-
if (opp_table->is_genpd) {
2408-
dev_err(dev, "%s: Operation not supported for genpds\n", __func__);
2409-
return -EOPNOTSUPP;
2410-
}
2411-
2412-
/* Checking only the first one is enough ? */
2413-
if (opp_table->required_devs[0])
2414-
return 0;
2415-
2416-
while (*name) {
2417-
if (index >= opp_table->required_opp_count) {
2418-
dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n",
2419-
*name, opp_table->required_opp_count, index);
2420-
goto err;
2421-
}
2422-
2423-
virt_dev = dev_pm_domain_attach_by_name(dev, *name);
2424-
if (IS_ERR_OR_NULL(virt_dev)) {
2425-
ret = virt_dev ? PTR_ERR(virt_dev) : -ENODEV;
2426-
dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret);
2427-
goto err;
2428-
}
2429-
2430-
/*
2431-
* The required_opp_tables parsing is not perfect, as the OPP
2432-
* core does the parsing solely based on the DT node pointers.
2433-
* The core sets the required_opp_tables entry to the first OPP
2434-
* table in the "opp_tables" list, that matches with the node
2435-
* pointer.
2436-
*
2437-
* If the target DT OPP table is used by multiple devices and
2438-
* they all create separate instances of 'struct opp_table' from
2439-
* it, then it is possible that the required_opp_tables entry
2440-
* may be set to the incorrect sibling device.
2441-
*
2442-
* Cross check it again and fix if required.
2443-
*/
2444-
gdev = dev_to_genpd_dev(virt_dev);
2445-
if (IS_ERR(gdev)) {
2446-
ret = PTR_ERR(gdev);
2447-
goto err;
2448-
}
2449-
2450-
genpd_table = _find_opp_table(gdev);
2451-
if (!IS_ERR(genpd_table)) {
2452-
if (genpd_table != opp_table->required_opp_tables[index]) {
2453-
dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]);
2454-
opp_table->required_opp_tables[index] = genpd_table;
2455-
} else {
2456-
dev_pm_opp_put_opp_table(genpd_table);
2457-
}
2458-
}
2459-
2460-
opp_table->required_devs[index] = virt_dev;
2461-
index++;
2462-
name++;
2463-
}
2464-
2465-
if (virt_devs)
2466-
*virt_devs = opp_table->required_devs;
2467-
2468-
return 0;
2469-
2470-
err:
2471-
_opp_detach_genpd(opp_table);
2472-
return ret;
2473-
2474-
}
2475-
24762363
static int _opp_set_required_dev(struct opp_table *opp_table,
24772364
struct device *dev,
24782365
struct device *required_dev,
@@ -2540,9 +2427,6 @@ static void _opp_clear_config(struct opp_config_data *data)
25402427
if (data->flags & OPP_CONFIG_REQUIRED_DEV)
25412428
_opp_put_required_dev(data->opp_table,
25422429
data->required_dev_index);
2543-
else if (data->flags & OPP_CONFIG_GENPD)
2544-
_opp_detach_genpd(data->opp_table);
2545-
25462430
if (data->flags & OPP_CONFIG_REGULATOR)
25472431
_opp_put_regulators(data->opp_table);
25482432
if (data->flags & OPP_CONFIG_SUPPORTED_HW)
@@ -2654,20 +2538,7 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config)
26542538
data->flags |= OPP_CONFIG_REGULATOR;
26552539
}
26562540

2657-
/* Attach genpds */
2658-
if (config->genpd_names) {
2659-
if (config->required_dev) {
2660-
ret = -EINVAL;
2661-
goto err;
2662-
}
2663-
2664-
ret = _opp_attach_genpd(opp_table, dev, config->genpd_names,
2665-
config->virt_devs);
2666-
if (ret)
2667-
goto err;
2668-
2669-
data->flags |= OPP_CONFIG_GENPD;
2670-
} else if (config->required_dev) {
2541+
if (config->required_dev) {
26712542
ret = _opp_set_required_dev(opp_table, dev,
26722543
config->required_dev,
26732544
config->required_dev_index);

drivers/opp/opp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ extern struct list_head opp_tables;
3434
#define OPP_CONFIG_REGULATOR_HELPER BIT(2)
3535
#define OPP_CONFIG_PROP_NAME BIT(3)
3636
#define OPP_CONFIG_SUPPORTED_HW BIT(4)
37-
#define OPP_CONFIG_GENPD BIT(5)
38-
#define OPP_CONFIG_REQUIRED_DEV BIT(6)
37+
#define OPP_CONFIG_REQUIRED_DEV BIT(5)
3938

4039
/**
4140
* struct opp_config_data - data for set config operations

include/linux/pm_opp.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table,
6262
* @supported_hw: Array of hierarchy of versions to match.
6363
* @supported_hw_count: Number of elements in the array.
6464
* @regulator_names: Array of pointers to the names of the regulator, NULL terminated.
65-
* @genpd_names: Null terminated array of pointers containing names of genpd to
66-
* attach. Mutually exclusive with required_dev.
67-
* @virt_devs: Pointer to return the array of genpd virtual devices. Mutually
68-
* exclusive with required_dev.
69-
* @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs.
65+
* @required_dev: The required OPP device.
7066
* @required_dev_index: The index of the required OPP for the @required_dev.
7167
*
7268
* This structure contains platform specific OPP configurations for the device.
@@ -80,8 +76,6 @@ struct dev_pm_opp_config {
8076
const unsigned int *supported_hw;
8177
unsigned int supported_hw_count;
8278
const char * const *regulator_names;
83-
const char * const *genpd_names;
84-
struct device ***virt_devs;
8579
struct device *required_dev;
8680
unsigned int required_dev_index;
8781
};
@@ -677,36 +671,6 @@ static inline void dev_pm_opp_put_config_regulators(int token)
677671
dev_pm_opp_clear_config(token);
678672
}
679673

680-
/* genpd helpers */
681-
static inline int dev_pm_opp_attach_genpd(struct device *dev,
682-
const char * const *names,
683-
struct device ***virt_devs)
684-
{
685-
struct dev_pm_opp_config config = {
686-
.genpd_names = names,
687-
.virt_devs = virt_devs,
688-
};
689-
690-
return dev_pm_opp_set_config(dev, &config);
691-
}
692-
693-
static inline void dev_pm_opp_detach_genpd(int token)
694-
{
695-
dev_pm_opp_clear_config(token);
696-
}
697-
698-
static inline int devm_pm_opp_attach_genpd(struct device *dev,
699-
const char * const *names,
700-
struct device ***virt_devs)
701-
{
702-
struct dev_pm_opp_config config = {
703-
.genpd_names = names,
704-
.virt_devs = virt_devs,
705-
};
706-
707-
return devm_pm_opp_set_config(dev, &config);
708-
}
709-
710674
/* prop-name helpers */
711675
static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name)
712676
{

0 commit comments

Comments
 (0)