Reputation: 55
I am looking at the Linux 4.14 kernel's include/linux/clk.h
file, and have noticed that some of the functions are declared, and then later defined to return 0 or NULL.
For example:
struct clk *clk_get(struct device *dev, const char *id);
...
static inline struct clk *clk_get(struct device *dev, const char *id)
{
return NULL;
}
What is the purpose of doing this? I see multiple C source files that fully define this function and still include linux/clk.h
.
Upvotes: 1
Views: 154
Reputation: 5211
Linux kernel comes with lots of configuration parameters. For this particular function, you get the service if CONFIG_HAVE_CLK parameter is defined:
#ifdef CONFIG_HAVE_CLK
/**
* clk_get - lookup and obtain a reference to a clock producer.
* @dev: device for clock "consumer"
* @id: clock consumer ID
*
* Returns a struct clk corresponding to the clock producer, or
* valid IS_ERR() condition containing errno. The implementation
* uses @dev and @id to determine the clock consumer, and thereby
* the clock producer. (IOW, @id may be identical strings, but
* clk_get may return different clock producers depending on @dev.)
*
* Drivers must assume that the clock source is not enabled.
*
* clk_get should not be called from within interrupt context.
*/
struct clk *clk_get(struct device *dev, const char *id);
[...]
#else /* !CONFIG_HAVE_CLK */
static inline struct clk *clk_get(struct device *dev, const char *id)
{
return NULL;
}
[...]
This parameter is defined in arch/Kconfig as:
config HAVE_CLK
bool
help
The <linux/clk.h> calls support software clock gating and
thus are a key power management tool on many systems.
Upvotes: 3