Quoting Nicolas Boichat (2019-03-08 06:46:01) > > > > + > > > +#define GATE_AUDIO0(_id, _name, _parent, _shift) \ > > > + GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, \ > > > + &mtk_clk_gate_ops_no_setclr) > > This macro (or variants that end up being equivalent) is repeated 103 > times in drivers/clk/mediatek/*. We can probably do better. My > suggestion is to do something like this: > #define GATE_MTK_CLK(reg, _id, _name, _parent, _shift) \ > GATE_MTK(_id, _name, _parent, ®##_cg_regs, _shift, \ > &mtk_clk_gate_ops_setclr_inv) > > and use GATE_MTK_CLK(audio0, ...) in the gate clock arrays. Feel free to send patches. > > > > +static int clk_mt8183_audio_probe(struct platform_device *pdev) > > > +{ > > > + struct clk_onecell_data *clk_data; > > > + int r; > > > + struct device_node *node = pdev->dev.of_node; > > > + > > > + clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK); > > > + > > > + mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks), > > > + clk_data); > > > + > > > + r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); > > > + if (r) > > > + return r; > > > + > > > + r = devm_of_platform_populate(&pdev->dev); > > > + if (r) > > > + of_clk_del_provider(node); > > > + > > > + return r; > > > +} > > This (almost exact) function is now repeated 33 times in > drivers/clk/mediatek, I think it's really time for a cleanup... Maybe > there should be a common helper in clk-gate.c (or another file, not > sure), that fetches the clocks (and number of clocks from .data field > in the structure below). > Yeah that would be great. I only tried to fix the problem where mtk has this duplicate code that probes platform drivers and finds things from it. See my branch on clk.git https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-mtk-of-plat-probe