Skip to content

Commit

Permalink
Merge tag 'clk-fixes-for-linus' of ssh://gitolite.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
 "Two fixes for the NKMP clks on Allwinner SoCs, a locking fix for
  clkdev where we forgot to hold a lock while iterating a list that can
  change, and finally a build fix that adds some stubs for clk APIs that
  are used by devfreq drivers on platforms without the clk APIs"

* tag 'clk-fixes-for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/clk/linux:
  clk: Add missing stubs for a few functions
  clkdev: Hold clocks_mutex while iterating clocks list
  clk: sunxi-ng: nkmp: Explain why zero width check is needed
  clk: sunxi-ng: nkmp: Avoid GENMASK(-1, 0)
  • Loading branch information
torvalds committed May 3, 2019
2 parents 46572f7 + b88c9f4 commit 8f76216
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions drivers/clk/clkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
if (con_id)
best_possible += 1;

lockdep_assert_held(&clocks_mutex);

list_for_each_entry(p, &clocks, node) {
match = 0;
if (p->dev_id) {
Expand Down Expand Up @@ -402,7 +404,10 @@ void devm_clk_release_clkdev(struct device *dev, const char *con_id,
struct clk_lookup *cl;
int rval;

mutex_lock(&clocks_mutex);
cl = clk_find(dev_id, con_id);
mutex_unlock(&clocks_mutex);

WARN_ON(!cl);
rval = devres_release(dev, devm_clkdev_release,
devm_clk_match_clkdev, cl);
Expand Down
24 changes: 19 additions & 5 deletions drivers/clk/sunxi-ng/ccu_nkmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw);
u32 n_mask, k_mask, m_mask, p_mask;
u32 n_mask = 0, k_mask = 0, m_mask = 0, p_mask = 0;
struct _ccu_nkmp _nkmp;
unsigned long flags;
u32 reg;
Expand All @@ -186,10 +186,24 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,

ccu_nkmp_find_best(parent_rate, rate, &_nkmp);

n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1, nkmp->n.shift);
k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1, nkmp->k.shift);
m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1, nkmp->m.shift);
p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1, nkmp->p.shift);
/*
* If width is 0, GENMASK() macro may not generate expected mask (0)
* as it falls under undefined behaviour by C standard due to shifts
* which are equal or greater than width of left operand. This can
* be easily avoided by explicitly checking if width is 0.
*/
if (nkmp->n.width)
n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1,
nkmp->n.shift);
if (nkmp->k.width)
k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1,
nkmp->k.shift);
if (nkmp->m.width)
m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1,
nkmp->m.shift);
if (nkmp->p.width)
p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1,
nkmp->p.shift);

spin_lock_irqsave(nkmp->common.lock, flags);

Expand Down
16 changes: 16 additions & 0 deletions include/linux/clk.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,22 @@ static inline bool clk_has_parent(struct clk *clk, struct clk *parent)
return true;
}

static inline int clk_set_rate_range(struct clk *clk, unsigned long min,
unsigned long max)
{
return 0;
}

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

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

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

0 comments on commit 8f76216

Please sign in to comment.