Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 319880
b: refs/heads/master
c: 93abe8e
h: refs/heads/master
v: v3
  • Loading branch information
Viresh Kumar authored and Linus Torvalds committed Jul 31, 2012
1 parent e0170ca commit 943d09a
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 60 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bf7c27e9887af48952743753916f9cfbe900d0e9
refs/heads/master: 93abe8e4b13ae9a0428ce940a8a03ac72a7626f1
168 changes: 109 additions & 59 deletions trunk/include/linux/clk.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,43 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);

#endif

/**
* clk_prepare - prepare a clock source
* @clk: clock source
*
* This prepares the clock source for use.
*
* Must not be called from within atomic context.
*/
#ifdef CONFIG_HAVE_CLK_PREPARE
int clk_prepare(struct clk *clk);
#else
static inline int clk_prepare(struct clk *clk)
{
might_sleep();
return 0;
}
#endif

/**
* clk_unprepare - undo preparation of a clock source
* @clk: clock source
*
* This undoes a previously prepared clock. The caller must balance
* the number of prepare and unprepare calls.
*
* Must not be called from within atomic context.
*/
#ifdef CONFIG_HAVE_CLK_PREPARE
void clk_unprepare(struct clk *clk);
#else
static inline void clk_unprepare(struct clk *clk)
{
might_sleep();
}
#endif

#ifdef CONFIG_HAVE_CLK
/**
* clk_get - lookup and obtain a reference to a clock producer.
* @dev: device for clock "consumer"
Expand Down Expand Up @@ -121,24 +158,6 @@ struct clk *clk_get(struct device *dev, const char *id);
*/
struct clk *devm_clk_get(struct device *dev, const char *id);

/**
* clk_prepare - prepare a clock source
* @clk: clock source
*
* This prepares the clock source for use.
*
* Must not be called from within atomic context.
*/
#ifdef CONFIG_HAVE_CLK_PREPARE
int clk_prepare(struct clk *clk);
#else
static inline int clk_prepare(struct clk *clk)
{
might_sleep();
return 0;
}
#endif

/**
* clk_enable - inform the system when the clock source should be running.
* @clk: clock source
Expand Down Expand Up @@ -167,47 +186,6 @@ int clk_enable(struct clk *clk);
*/
void clk_disable(struct clk *clk);


/**
* clk_unprepare - undo preparation of a clock source
* @clk: clock source
*
* This undoes a previously prepared clock. The caller must balance
* the number of prepare and unprepare calls.
*
* Must not be called from within atomic context.
*/
#ifdef CONFIG_HAVE_CLK_PREPARE
void clk_unprepare(struct clk *clk);
#else
static inline void clk_unprepare(struct clk *clk)
{
might_sleep();
}
#endif

/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
static inline int clk_prepare_enable(struct clk *clk)
{
int ret;

ret = clk_prepare(clk);
if (ret)
return ret;
ret = clk_enable(clk);
if (ret)
clk_unprepare(clk);

return ret;
}

/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
static inline void clk_disable_unprepare(struct clk *clk)
{
clk_disable(clk);
clk_unprepare(clk);
}

/**
* clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
* This is only valid once the clock source has been enabled.
Expand Down Expand Up @@ -298,6 +276,78 @@ struct clk *clk_get_parent(struct clk *clk);
*/
struct clk *clk_get_sys(const char *dev_id, const char *con_id);

#else /* !CONFIG_HAVE_CLK */

static inline struct clk *clk_get(struct device *dev, const char *id)
{
return NULL;
}

static inline struct clk *devm_clk_get(struct device *dev, const char *id)
{
return NULL;
}

static inline void clk_put(struct clk *clk) {}

static inline void devm_clk_put(struct device *dev, struct clk *clk) {}

static inline int clk_enable(struct clk *clk)
{
return 0;
}

static inline void clk_disable(struct clk *clk) {}

static inline unsigned long clk_get_rate(struct clk *clk)
{
return 0;
}

static inline int clk_set_rate(struct clk *clk, unsigned long rate)
{
return 0;
}

static inline long clk_round_rate(struct clk *clk, unsigned long rate)
{
return 0;
}

static inline int clk_set_parent(struct clk *clk, struct clk *parent)
{
return 0;
}

static inline struct clk *clk_get_parent(struct clk *clk)
{
return NULL;
}

#endif

/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
static inline int clk_prepare_enable(struct clk *clk)
{
int ret;

ret = clk_prepare(clk);
if (ret)
return ret;
ret = clk_enable(clk);
if (ret)
clk_unprepare(clk);

return ret;
}

/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
static inline void clk_disable_unprepare(struct clk *clk)
{
clk_disable(clk);
clk_unprepare(clk);
}

/**
* clk_add_alias - add a new clock alias
* @alias: name for clock alias
Expand Down

0 comments on commit 943d09a

Please sign in to comment.