clk: hisilicon: clkdivider-hi6220: use kzalloc_flex
PATCH v2 1/1 clk: hisilicon: clkdivider-hi6220: use kzalloc_flex
Combine allocations using kzalloc_flex and a flexible array member.
---
v2: add missing transformation.
drivers/clk/hisilicon/clkdivider-hi6220.c | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/clk/hisilicon/clkdivider-hi6220.c +9 -17
@@ -26,8 +26,8 @@* @shift: shift to the divider bit field * @width: width of the divider bit field * @mask: mask for setting divider rate -* @table: the div table that the divider supports * @lock: register lock +* @->table: the div table that the divider supports */ struct hi6220_clk_divider {struct clk_hw hw;
@@ -35,8 +35,8 @@ struct hi6220_clk_divider {u8 shift;u8 width;u32 mask; -const struct clk_div_table *table;spinlock_t *lock; +struct clk_div_table table[]; };#define to_hi6220_clk_divider (_hw) \
@@ -108,24 +108,19 @@ struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,u32 max_div, min_div;int i; -/* allocate the divider */ - div =kzalloc_obj (*div); -if (!div) -return ERR_PTR (-ENOMEM ); -/* Init the divider table */ max_div =div_mask (width) +1 ; min_div =1 ; - table =kzalloc_objs (*table, max_div +1 ); -if (!table) { -kfree (div); +/* allocate the divider */ + div =kzalloc_flex (*div, table, max_div +1 ); +if (!div)return ERR_PTR (-ENOMEM ); - }for (i =0 ; i < max_div; i++) { - table[i].div = min_div + i; - table[i].val = table[i].div -1 ; + table = &div->table[i]; + table->div = min_div + i; + table->val = table->div -1 ; } init.name = name;
@@ -141,14 +136,11 @@ struct clk *hi6220_register_clkdiv(struct device *dev, const char *name, div->mask = mask_bit ?BIT (mask_bit) :0 ; div->lock = lock; div->hw.init = &init; - div->table = table;/* register the clock */ clk =clk_register (dev, &div->hw); -if (IS_ERR (clk)) { -kfree (table); +if (IS_ERR (clk))kfree (div); - }return clk; }
--
2.53.0
Quoted 13 lines · Rosen Penev
Combine allocations using
kzalloc_flexand a flexible array member.Signed-off-by Rosen Penev <[email protected]>---
v2: add missing transformation.drivers/clk/hisilicon/clkdivider-hi6220.c | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/clk/hisilicon/clkdivider-hi6220.c +0
-0
drivers/clk/hisilicon/clkdivider-hi6220.c line 30
Quoted 6 lines
drivers/clk/hisilicon/clkdivider-hi6220.c +1
-1@@ -26,8 +26,8 @@* @shift: shift to the divider bit field * @width: width of the divider bit field * @mask: mask for setting divider rate -* @table: the div table that the divider supports * @lock: register lock +* @->table: the div table that the divider supports
Why this change?
Brian
Quoted 10 lines · Brian Masney
Quoted 8 lines · Rosen Penev
Combine allocations using
kzalloc_flexand a flexible array member.Signed-off-by Rosen Penev <[email protected]>---
v2: add missing transformation.drivers/clk/hisilicon/clkdivider-hi6220.c | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-)
Quoted 13 lines
drivers/clk/hisilicon/clkdivider-hi6220.c line 30
Quoted 11 lines
drivers/clk/hisilicon/clkdivider-hi6220.c +1
-1@@ -26,8 +26,8 @@* @shift: shift to the divider bit field * @width: width of the divider bit field * @mask: mask for setting divider rate -* @table: the div table that the divider supports * @lock: register lock +* @->table: the div table that the divider supports Why this change?
Guess I monkey fingered this in vim... I just wanted ddjp
Quoted 3 lines
Brian
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Rosen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v7.0-rc6 next-20260330] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/clk-hisilicon-clkdivider-hi6220-use-kzalloc_flex/20260331-195943 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20260330210217.11168-1-rosenp%40gmail.com patch subject: [PATCHv2] clk: hisilicon: clkdivider-hi6220: use kzalloc_flex config: arm64-randconfig-002-20260401 (https://download.01.org/0day-ci/archive/20260401/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260401/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> Warning: drivers/clk/hisilicon/clkdivider-hi6220.c:39 struct member 'table' not described in 'hi6220_clk_divider' >> Warning: drivers/clk/hisilicon/clkdivider-hi6220.c:39 struct member 'table' not described in 'hi6220_clk_divider'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki