Skip to content

Commit 8a4d731

Browse files
masneybbroonie
authored andcommitted
ASoC: codecs: da7219: convert from round_rate() to determine_rate()
The round_rate() clk ops is deprecated, so migrate this driver from round_rate() to determine_rate() using the Coccinelle semantic patch on the cover letter of this series. Signed-off-by: Brian Masney <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 347e9f5 commit 8a4d731

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

sound/soc/codecs/da7219.c

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,8 +1982,8 @@ static unsigned long da7219_wclk_recalc_rate(struct clk_hw *hw,
19821982
}
19831983
}
19841984

1985-
static long da7219_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
1986-
unsigned long *parent_rate)
1985+
static int da7219_wclk_determine_rate(struct clk_hw *hw,
1986+
struct clk_rate_request *req)
19871987
{
19881988
struct da7219_priv *da7219 =
19891989
container_of(hw, struct da7219_priv,
@@ -1992,28 +1992,30 @@ static long da7219_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
19921992
if (!da7219->master)
19931993
return -EINVAL;
19941994

1995-
if (rate < 11025)
1996-
return 8000;
1997-
else if (rate < 12000)
1998-
return 11025;
1999-
else if (rate < 16000)
2000-
return 12000;
2001-
else if (rate < 22050)
2002-
return 16000;
2003-
else if (rate < 24000)
2004-
return 22050;
2005-
else if (rate < 32000)
2006-
return 24000;
2007-
else if (rate < 44100)
2008-
return 32000;
2009-
else if (rate < 48000)
2010-
return 44100;
2011-
else if (rate < 88200)
2012-
return 48000;
2013-
else if (rate < 96000)
2014-
return 88200;
1995+
if (req->rate < 11025)
1996+
req->rate = 8000;
1997+
else if (req->rate < 12000)
1998+
req->rate = 11025;
1999+
else if (req->rate < 16000)
2000+
req->rate = 12000;
2001+
else if (req->rate < 22050)
2002+
req->rate = 16000;
2003+
else if (req->rate < 24000)
2004+
req->rate = 22050;
2005+
else if (req->rate < 32000)
2006+
req->rate = 24000;
2007+
else if (req->rate < 44100)
2008+
req->rate = 32000;
2009+
else if (req->rate < 48000)
2010+
req->rate = 44100;
2011+
else if (req->rate < 88200)
2012+
req->rate = 48000;
2013+
else if (req->rate < 96000)
2014+
req->rate = 88200;
20152015
else
2016-
return 96000;
2016+
req->rate = 96000;
2017+
2018+
return 0;
20172019
}
20182020

20192021
static int da7219_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2070,15 +2072,15 @@ static unsigned long da7219_bclk_get_factor(unsigned long rate,
20702072
return 256;
20712073
}
20722074

2073-
static long da7219_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
2074-
unsigned long *parent_rate)
2075+
static int da7219_bclk_determine_rate(struct clk_hw *hw,
2076+
struct clk_rate_request *req)
20752077
{
20762078
struct da7219_priv *da7219 =
20772079
container_of(hw, struct da7219_priv,
20782080
dai_clks_hw[DA7219_DAI_BCLK_IDX]);
20792081
unsigned long factor;
20802082

2081-
if (!*parent_rate || !da7219->master)
2083+
if (!req->best_parent_rate || !da7219->master)
20822084
return -EINVAL;
20832085

20842086
/*
@@ -2088,9 +2090,11 @@ static long da7219_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
20882090
* parent WCLK rate set and find the appropriate multiplier of BCLK to
20892091
* get the rounded down BCLK value.
20902092
*/
2091-
factor = da7219_bclk_get_factor(rate, *parent_rate);
2093+
factor = da7219_bclk_get_factor(req->rate, req->best_parent_rate);
2094+
2095+
req->rate = req->best_parent_rate * factor;
20922096

2093-
return *parent_rate * factor;
2097+
return 0;
20942098
}
20952099

20962100
static int da7219_bclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2116,12 +2120,12 @@ static const struct clk_ops da7219_dai_clk_ops[DA7219_DAI_NUM_CLKS] = {
21162120
.unprepare = da7219_wclk_unprepare,
21172121
.is_prepared = da7219_wclk_is_prepared,
21182122
.recalc_rate = da7219_wclk_recalc_rate,
2119-
.round_rate = da7219_wclk_round_rate,
2123+
.determine_rate = da7219_wclk_determine_rate,
21202124
.set_rate = da7219_wclk_set_rate,
21212125
},
21222126
[DA7219_DAI_BCLK_IDX] = {
21232127
.recalc_rate = da7219_bclk_recalc_rate,
2124-
.round_rate = da7219_bclk_round_rate,
2128+
.determine_rate = da7219_bclk_determine_rate,
21252129
.set_rate = da7219_bclk_set_rate,
21262130
},
21272131
};

0 commit comments

Comments
 (0)