@@ -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-
24762363static 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 );
0 commit comments