lkml.org 
[lkml]   [2012]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 01/13] clk: Add non CONFIG_HAVE_CLK routines
    Date
    Many drivers are shared between architectures that may or may not have HAVE_CLK
    selected for them. To remove compilation errors for them we enclose clk_*()
    calls in these drivers within #ifdef CONFIG_HAVE_CLK, #endif.

    This patch removes the need of these CONFIG_HAVE_CLK statements, by introducing
    dummy routines when HAVE_CLK is not selected by platforms. So, definition of
    these routines will always be available. These calls will return error for
    platforms that don't select HAVE_CLK.

    Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
    ---
    include/linux/clk.h | 160 ++++++++++++++++++++++++++++++++-------------------
    1 files changed, 101 insertions(+), 59 deletions(-)
    diff --git a/include/linux/clk.h b/include/linux/clk.h
    index b025272..6e1c63e 100644
    --- a/include/linux/clk.h
    +++ b/include/linux/clk.h
    @@ -84,23 +84,6 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);
    #endif /* !CONFIG_COMMON_CLK */

    /**
    - * clk_get - lookup and obtain a reference to a clock producer.
    - * @dev: device for clock "consumer"
    - * @id: clock comsumer 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);
    -
    -/**
    * clk_prepare - prepare a clock source
    * @clk: clock source
    *
    @@ -119,6 +102,42 @@ static inline int clk_prepare(struct clk *clk)
    #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"
    + * @id: clock comsumer 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);
    +
    +/**
    * clk_enable - inform the system when the clock source should be running.
    * @clk: clock source
    *
    @@ -146,47 +165,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.
    @@ -206,7 +184,6 @@ unsigned long clk_get_rate(struct clk *clk);
    */
    void clk_put(struct clk *clk);

    -
    /*
    * The remaining APIs are optional for machine class support.
    */
    @@ -265,6 +242,71 @@ 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 ERR_PTR(-ENODEV);
    +}
    +
    +static inline void clk_put(struct clk *clk) {}
    +
    +static inline int clk_enable(struct clk *clk)
    +{
    + return -ENODEV;
    +}
    +
    +static inline void clk_disable(struct clk *clk) {}
    +
    +static inline unsigned long clk_get_rate(struct clk *clk)
    +{
    + return -ENODEV;
    +}
    +
    +static inline int clk_set_rate(struct clk *clk, unsigned long rate)
    +{
    + return -ENODEV;
    +}
    +
    +static inline long clk_round_rate(struct clk *clk, unsigned long rate)
    +{
    + return -ENODEV;
    +}
    +
    +static inline int clk_set_parent(struct clk *clk, struct clk *parent)
    +{
    + return -ENODEV;
    +}
    +
    +static inline struct clk *clk_get_parent(struct clk *clk)
    +{
    + return ERR_PTR(-ENODEV);
    +}
    +
    +#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
    --
    1.7.9


    \
     
     \ /
      Last update: 2012-04-21 13:53    [from the cache]
    ©2003-2014 Jasper Spaans. Advertise on this site