Skip to content

Commit 79b92ba

Browse files
committed
Merge tag 'clk-imx-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux into clk-imx
Pull i.MX clk driver updates from Abel Vesa: - Minor clean-ups and error handling improvements in both composite-8m and SCU clock drivers - Fix for SAI_MCLK_SEL definition for i.MX8MP * tag 'clk-imx-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux: clk: imx: imx8mp: Fix SAI_MCLK_SEL definition clk: imx: scu: Use common error handling code in imx_clk_scu_alloc_dev() clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite() clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection
2 parents 6613476 + 13269dc commit 79b92ba

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

drivers/clk/imx/clk-composite-8m.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
212212
{
213213
struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
214214
struct clk_hw *div_hw, *gate_hw = NULL;
215-
struct clk_divider *div = NULL;
215+
struct clk_divider *div;
216216
struct clk_gate *gate = NULL;
217-
struct clk_mux *mux = NULL;
217+
struct clk_mux *mux;
218218
const struct clk_ops *divider_ops;
219219
const struct clk_ops *mux_ops;
220220

221221
mux = kzalloc(sizeof(*mux), GFP_KERNEL);
222222
if (!mux)
223-
goto fail;
223+
return ERR_CAST(hw);
224224

225225
mux_hw = &mux->hw;
226226
mux->reg = reg;
@@ -230,7 +230,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
230230

231231
div = kzalloc(sizeof(*div), GFP_KERNEL);
232232
if (!div)
233-
goto fail;
233+
goto free_mux;
234234

235235
div_hw = &div->hw;
236236
div->reg = reg;
@@ -260,7 +260,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
260260
if (!mcore_booted) {
261261
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
262262
if (!gate)
263-
goto fail;
263+
goto free_div;
264264

265265
gate_hw = &gate->hw;
266266
gate->reg = reg;
@@ -272,13 +272,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
272272
mux_hw, mux_ops, div_hw,
273273
divider_ops, gate_hw, &clk_gate_ops, flags);
274274
if (IS_ERR(hw))
275-
goto fail;
275+
goto free_gate;
276276

277277
return hw;
278278

279-
fail:
279+
free_gate:
280280
kfree(gate);
281+
free_div:
281282
kfree(div);
283+
free_mux:
282284
kfree(mux);
283285
return ERR_CAST(hw);
284286
}

drivers/clk/imx/clk-imx8mp-audiomix.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818

1919
#define CLKEN0 0x000
2020
#define CLKEN1 0x004
21-
#define SAI_MCLK_SEL(n) (0x300 + 4 * (n)) /* n in 0..5 */
21+
#define SAI1_MCLK_SEL 0x300
22+
#define SAI2_MCLK_SEL 0x304
23+
#define SAI3_MCLK_SEL 0x308
24+
#define SAI5_MCLK_SEL 0x30C
25+
#define SAI6_MCLK_SEL 0x310
26+
#define SAI7_MCLK_SEL 0x314
2227
#define PDM_SEL 0x318
2328
#define SAI_PLL_GNRL_CTL 0x400
2429

@@ -95,13 +100,13 @@ static const struct clk_parent_data clk_imx8mp_audiomix_pll_bypass_sels[] = {
95100
IMX8MP_CLK_AUDIOMIX_SAI##n##_MCLK1_SEL, {}, \
96101
clk_imx8mp_audiomix_sai##n##_mclk1_parents, \
97102
ARRAY_SIZE(clk_imx8mp_audiomix_sai##n##_mclk1_parents), \
98-
SAI_MCLK_SEL(n), 1, 0 \
103+
SAI##n##_MCLK_SEL, 1, 0 \
99104
}, { \
100105
"sai"__stringify(n)"_mclk2_sel", \
101106
IMX8MP_CLK_AUDIOMIX_SAI##n##_MCLK2_SEL, {}, \
102107
clk_imx8mp_audiomix_sai_mclk2_parents, \
103108
ARRAY_SIZE(clk_imx8mp_audiomix_sai_mclk2_parents), \
104-
SAI_MCLK_SEL(n), 4, 1 \
109+
SAI##n##_MCLK_SEL, 4, 1 \
105110
}, { \
106111
"sai"__stringify(n)"_ipg_cg", \
107112
IMX8MP_CLK_AUDIOMIX_SAI##n##_IPG, \

drivers/clk/imx/clk-scu.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -712,31 +712,29 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
712712
}
713713

714714
ret = platform_device_add_data(pdev, &clk, sizeof(clk));
715-
if (ret) {
716-
platform_device_put(pdev);
717-
return ERR_PTR(ret);
718-
}
715+
if (ret)
716+
goto put_device;
719717

720718
ret = driver_set_override(&pdev->dev, &pdev->driver_override,
721719
"imx-scu-clk", strlen("imx-scu-clk"));
722-
if (ret) {
723-
platform_device_put(pdev);
724-
return ERR_PTR(ret);
725-
}
720+
if (ret)
721+
goto put_device;
726722

727723
ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id);
728724
if (ret)
729725
pr_warn("%s: failed to attached the power domain %d\n",
730726
name, ret);
731727

732728
ret = platform_device_add(pdev);
733-
if (ret) {
734-
platform_device_put(pdev);
735-
return ERR_PTR(ret);
736-
}
729+
if (ret)
730+
goto put_device;
737731

738732
/* For API backwards compatiblilty, simply return NULL for success */
739733
return NULL;
734+
735+
put_device:
736+
platform_device_put(pdev);
737+
return ERR_PTR(ret);
740738
}
741739

742740
void imx_clk_scu_unregister(void)

0 commit comments

Comments
 (0)