Skip to content

Commit

Permalink
PM / Domains: Don't expose xlate and provider helper functions
Browse files Browse the repository at this point in the history
Functions __of_genpd_xlate_simple(), __of_genpd_xlate_onecell() and
__of_genpd_add_provider() are not used outside of the core generic PM
domain code. Therefore, reduce the number of APIs exposed by making
these static. At the same time don't expose the typedef for
genpd_xlate_t either and make this a local definition as well.

The functions are renamed to follow the naming conventions for static
functions in the generic PM domain core.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Jon Hunter authored and Rafael J. Wysocki committed Sep 13, 2016
1 parent f58d4e5 commit 892ebdc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 40 deletions.
49 changes: 37 additions & 12 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,10 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
EXPORT_SYMBOL_GPL(pm_genpd_init);

#ifdef CONFIG_PM_GENERIC_DOMAINS_OF

typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
void *data);

/*
* Device Tree based PM domain providers.
*
Expand All @@ -1340,8 +1344,8 @@ EXPORT_SYMBOL_GPL(pm_genpd_init);
* maps a PM domain specifier retrieved from the device tree to a PM domain.
*
* Two simple mapping functions have been provided for convenience:
* - __of_genpd_xlate_simple() for 1:1 device tree node to PM domain mapping.
* - __of_genpd_xlate_onecell() for mapping of multiple PM domains per node by
* - genpd_xlate_simple() for 1:1 device tree node to PM domain mapping.
* - genpd_xlate_onecell() for mapping of multiple PM domains per node by
* index.
*/

Expand All @@ -1366,26 +1370,25 @@ static LIST_HEAD(of_genpd_providers);
static DEFINE_MUTEX(of_genpd_mutex);

/**
* __of_genpd_xlate_simple() - Xlate function for direct node-domain mapping
* genpd_xlate_simple() - Xlate function for direct node-domain mapping
* @genpdspec: OF phandle args to map into a PM domain
* @data: xlate function private data - pointer to struct generic_pm_domain
*
* This is a generic xlate function that can be used to model PM domains that
* have their own device tree nodes. The private data of xlate function needs
* to be a valid pointer to struct generic_pm_domain.
*/
struct generic_pm_domain *__of_genpd_xlate_simple(
static struct generic_pm_domain *genpd_xlate_simple(
struct of_phandle_args *genpdspec,
void *data)
{
if (genpdspec->args_count != 0)
return ERR_PTR(-EINVAL);
return data;
}
EXPORT_SYMBOL_GPL(__of_genpd_xlate_simple);

/**
* __of_genpd_xlate_onecell() - Xlate function using a single index.
* genpd_xlate_onecell() - Xlate function using a single index.
* @genpdspec: OF phandle args to map into a PM domain
* @data: xlate function private data - pointer to struct genpd_onecell_data
*
Expand All @@ -1394,7 +1397,7 @@ EXPORT_SYMBOL_GPL(__of_genpd_xlate_simple);
* A single cell is used as an index into an array of PM domains specified in
* the genpd_onecell_data struct when registering the provider.
*/
struct generic_pm_domain *__of_genpd_xlate_onecell(
static struct generic_pm_domain *genpd_xlate_onecell(
struct of_phandle_args *genpdspec,
void *data)
{
Expand All @@ -1414,16 +1417,15 @@ struct generic_pm_domain *__of_genpd_xlate_onecell(

return genpd_data->domains[idx];
}
EXPORT_SYMBOL_GPL(__of_genpd_xlate_onecell);

/**
* __of_genpd_add_provider() - Register a PM domain provider for a node
* genpd_add_provider() - Register a PM domain provider for a node
* @np: Device node pointer associated with the PM domain provider.
* @xlate: Callback for decoding PM domain from phandle arguments.
* @data: Context pointer for @xlate callback.
*/
int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
void *data)
static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
void *data)
{
struct of_genpd_provider *cp;

Expand All @@ -1442,7 +1444,30 @@ int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,

return 0;
}
EXPORT_SYMBOL_GPL(__of_genpd_add_provider);

/**
* of_genpd_add_provider_simple() - Register a simple PM domain provider
* @np: Device node pointer associated with the PM domain provider.
* @genpd: Pointer to PM domain associated with the PM domain provider.
*/
int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd)
{
return genpd_add_provider(np, genpd_xlate_simple, genpd);
}
EXPORT_SYMBOL_GPL(of_genpd_add_provider_simple);

/**
* of_genpd_add_provider_onecell() - Register a onecell PM domain provider
* @np: Device node pointer associated with the PM domain provider.
* @data: Pointer to the data associated with the PM domain provider.
*/
int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data)
{
return genpd_add_provider(np, genpd_xlate_onecell, data);
}
EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);

/**
* of_genpd_del_provider() - Remove a previously registered PM domain provider
Expand Down
42 changes: 14 additions & 28 deletions include/linux/pm_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,32 @@ struct genpd_onecell_data {
unsigned int num_domains;
};

typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
void *data);

#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
void *data);
int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd);
int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data);
void of_genpd_del_provider(struct device_node *np);
struct generic_pm_domain *__of_genpd_xlate_simple(
struct of_phandle_args *genpdspec,
void *data);
struct generic_pm_domain *__of_genpd_xlate_onecell(
struct of_phandle_args *genpdspec,
void *data);
extern int of_genpd_add_device(struct of_phandle_args *args,
struct device *dev);
extern int of_genpd_add_subdomain(struct of_phandle_args *parent,
struct of_phandle_args *new_subdomain);

int genpd_dev_pm_attach(struct device *dev);
#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
static inline int __of_genpd_add_provider(struct device_node *np,
genpd_xlate_t xlate, void *data)
static inline int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd)
{
return 0;
return -ENOTSUPP;
}

static inline int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data)
{
return -ENOTSUPP;
}
static inline void of_genpd_del_provider(struct device_node *np) {}

#define __of_genpd_xlate_simple NULL
#define __of_genpd_xlate_onecell NULL
static inline void of_genpd_del_provider(struct device_node *np) {}

static inline int of_genpd_add_device(struct of_phandle_args *args,
struct device *dev)
Expand All @@ -235,17 +232,6 @@ static inline int genpd_dev_pm_attach(struct device *dev)
}
#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */

static inline int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd)
{
return __of_genpd_add_provider(np, __of_genpd_xlate_simple, genpd);
}
static inline int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data)
{
return __of_genpd_add_provider(np, __of_genpd_xlate_onecell, data);
}

#ifdef CONFIG_PM
extern int dev_pm_domain_attach(struct device *dev, bool power_on);
extern void dev_pm_domain_detach(struct device *dev, bool power_off);
Expand Down

0 comments on commit 892ebdc

Please sign in to comment.