clk drivers: Terminate clk_div_table with sentinel element
Subsystems (3)
v4 cover clk drivers: Terminate clk_div_table with sentinel element
I noticed that some of the clk_div_tables in different drivers are not terminated with a sentinel element. This may cause the code in clk-divider.c to read garbage that happens to be beyond the end.
This patchset fixed all instances of this bug that I could find, except for a case in drivers/phy/ti/phy-j721e-wiz.c that is already fixed in linux-next:
https://lore.kernel.org/lkml/[email protected]/
In this version of the patchset, I addressed Philippe Mathieu-Daudé's style comments. As far as I found it reasonable, I simply updated the existing patches, but in the case of the Actions Semiconductor drivers, I made a bigger cleanup in a separate patch.
v4:
- Various style fixes
v3:
- Change the Actions patch according to Mani's comment
v2:
- Add Fixes tags
Jonathan Neuschäfer (5):
clk: actions: Terminate clk_div_table with sentinel element
clk: loongson1: Terminate clk_div_table with sentinel element
clk: hisilicon: Terminate clk_div_table with sentinel element
clk: clps711x: Terminate clk_div_table with sentinel element
clk: actions: Make sentinel elements more obvious
drivers/clk/actions/owl-s500.c | 16 ++++++++-------- drivers/clk/actions/owl-s700.c | 17 ++++++++++------- drivers/clk/actions/owl-s900.c | 26 +++++++++++++------------- drivers/clk/clk-clps711x.c | 2 ++ drivers/clk/hisilicon/clk-hi3559a.c | 4 ++-- drivers/clk/loongson1/clk-loongson1c.c | 1 + 6 files changed, 36 insertions(+), 30 deletions(-)
--
2.34.1
PATCH v4 1/5 clk: actions: Terminate clk_div_table with sentinel element
In order that the end of a clk_div_table can be detected, it must be terminated with a sentinel element (.div = 0).
In owl-s900.s, the { 0, 8 } element was probably meant to be just that, so this patch changes { 0, 8 } to { 0, 0 }.
---
v4:
- Remove trailing commas
v3:
- Interpret { 0, 8 } as a typo of { 0, 0 }, the sentinel element
- Add R-b tag
v2:
- Add Fixes tags
--- drivers/clk/actions/owl-s700.c | 1 + drivers/clk/actions/owl-s900.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/clk/actions/owl-s700.c +1 -0
@@ -162,6 +162,7 @@ static struct clk_div_table hdmia_div_table[] = {static struct clk_div_table rmii_div_table[] = { {0 ,4 }, {1 ,10 }, + {0 ,0 } };/* divider clocks */
drivers/clk/actions/owl-s900.c +1 -1
@@ -140,7 +140,7 @@ static struct clk_div_table rmii_ref_div_table[] = {static struct clk_div_table usb3_mac_div_table[] = { {1 ,2 }, {2 ,3 }, {3 ,4 }, - {0 ,8 }, + {0 ,0 } };static struct clk_div_table i2s_div_table[] = {
--
2.34.1
Re: [PATCH v4 1/5] clk: actions: Terminate clk_div_table with sentinel element
Quoting Jonathan Neuschäfer (2022-02-17 16:09:17)
Quoted 11 lines
In order that the end of a
clk_div_tablecan be detected, it must be terminated with a sentinel element (.div = 0).In owl-s900.s, the { 0, 8 } element was probably meant to be just that, so this patch changes { 0, 8 } to { 0, 0 }.
Fixes d47317ca4ade1 ("clk: actions: Add S700 SoC clock support")Fixes d85d20053e195 ("clk: actions: Add S900 SoC clock support")Signed-off-by Jonathan Neuschäfer <[email protected]>Reviewed-by Manivannan Sadhasivam <[email protected]>---
Applied to clk-next
PATCH v4 2/5 clk: loongson1: Terminate clk_div_table with sentinel element
In reply to Jonathan NeuschäferIn order that the end of a clk_div_table can be detected, it must be terminated with a sentinel element (.div = 0).
---
v4:
- remove trailing comma
v3:
- no changes
v2:
- Add Fixes and R-b tags
--- drivers/clk/loongson1/clk-loongson1c.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/loongson1/clk-loongson1c.c +1 -0
@@ -37,6 +37,7 @@ static const struct clk_div_table ahb_div_table[] = { [1] = { .val = 1, .div = 4 }, [2] = { .val = 2, .div = 3 }, [3] = { .val = 3, .div = 3 }, + [4] = { /* sentinel */ } };void __init ls1x_clk_init (void )
--
2.34.1
Re: [PATCH v4 2/5] clk: loongson1: Terminate clk_div_table with sentinel element
Quoting Jonathan Neuschäfer (2022-02-17 16:09:18)
Quoted 7 lines
In order that the end of a
clk_div_tablecan be detected, it must be terminated with a sentinel element (.div = 0).Fixes b4626a7f4892 ("CLK: Add Loongson1C clock support")Signed-off-by Jonathan Neuschäfer <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>---
Applied to clk-next
PATCH v4 3/5 clk: hisilicon: Terminate clk_div_table with sentinel element
In reply to Jonathan NeuschäferIn order that the end of a clk_div_table can be detected, it must be terminated with a sentinel element (.div = 0).
---
v4:
- add /* sentinel */ comment into sentinel element
v3:
- no changes
v2:
- Add Fixes tag
--- drivers/clk/hisilicon/clk-hi3559a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/hisilicon/clk-hi3559a.c +2 -2
@@ -611,8 +611,8 @@ static struct hisi_mux_clock hi3559av100_shub_mux_clks[] = {/* shub div clk */ -static struct clk_div_table shub_spi_clk_table[] = {{0 ,8 }, {1 ,4 }, {2 ,2 }}; -static struct clk_div_table shub_uart_div_clk_table[] = {{1 ,8 }, {2 ,4 }}; +static struct clk_div_table shub_spi_clk_table[] = {{0 ,8 }, {1 ,4 }, {2 ,2 }, {/*sentinel*/ }}; +static struct clk_div_table shub_uart_div_clk_table[] = {{1 ,8 }, {2 ,4 }, {/*sentinel*/ }};static struct hisi_divider_clock hi3559av100_shub_div_clks[] = { {HI3559AV100_SHUB_SPI_SOURCE_CLK ,"clk_spi_clk" ,"shub_clk" ,0 ,0x20 ,24 ,2 ,
--
2.34.1
Re: [PATCH v4 3/5] clk: hisilicon: Terminate clk_div_table with sentinel element
Quoting Jonathan Neuschäfer (2022-02-17 16:09:19)
Quoted 6 lines
In order that the end of a
clk_div_tablecan be detected, it must be terminated with a sentinel element (.div = 0).Fixes 6c81966107dc0 ("clk: hisilicon: Add clock driver for hi3559A SoC")Signed-off-by Jonathan Neuschäfer <[email protected]>---
Applied to clk-next
PATCH v4 4/5 clk: clps711x: Terminate clk_div_table with sentinel element
In reply to Jonathan NeuschäferIn order that the end of a clk_div_table can be detected, it must be terminated with a sentinel element (.div = 0).
---
v4:
- Change style to { /* sentinel */ }
v3:
- no changes
v2:
- Add Fixes tag
--- drivers/clk/clk-clps711x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/clk-clps711x.c +2 -0
@@ -28,11 +28,13 @@ static const struct clk_div_table spi_div_table[] = { { .val = 1, .div = 8, }, { .val = 2, .div = 2, }, { .val = 3, .div = 1, }, + {/* sentinel */ } };static const struct clk_div_table timer_div_table[] = { { .val =0 , .div =256 , }, { .val =1 , .div =1 , }, + {/* sentinel */ } }; struct clps711x_clk {
--
2.34.1
Re: [PATCH v4 4/5] clk: clps711x: Terminate clk_div_table with sentinel element
Quoting Jonathan Neuschäfer (2022-02-17 16:09:20)
Quoted 6 lines
In order that the end of a
clk_div_tablecan be detected, it must be terminated with a sentinel element (.div = 0).Fixes 631c53478973d ("clk: Add CLPS711X clk driver")Signed-off-by Jonathan Neuschäfer <[email protected]>---
Applied to clk-next
PATCH v4 5/5 clk: actions: Make sentinel elements more obvious
In reply to Jonathan NeuschäferThe sentinel elements of various tables in drivers/clk/actions can be a bit hard to recognize. Make them easier to see by changing the style from { 0, 0 } to { /* sentinel */ }.
---
v4:
- New patch
--- drivers/clk/actions/owl-s500.c | 16 ++++++++-------- drivers/clk/actions/owl-s700.c | 18 ++++++++++-------- drivers/clk/actions/owl-s900.c | 26 +++++++++++++------------- 3 files changed, 31 insertions(+), 29 deletions(-)
drivers/clk/actions/owl-s500.c +8 -8
@@ -95,7 +95,7 @@static const struct clk_pll_table clk_audio_pll_table[] = { {0 ,45158400 }, {1 ,49152000 }, - {0 ,0 }, + {/* sentinel */ } };/* pll clocks */
@@ -138,46 +138,46 @@ static struct clk_factor_table sd_factor_table[] = { { 272, 1, 17 * 128 }, { 273, 1, 18 * 128 }, { 274, 1, 19 * 128 }, { 275, 1, 20 * 128 }, { 276, 1, 21 * 128 }, { 277, 1, 22 * 128 }, { 278, 1, 23 * 128 }, { 279, 1, 24 * 128 }, { 280, 1, 25 * 128 }, - { 0, 0, 0 }, + { /* sentinel */ } };static struct clk_factor_table de_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,2 ,5 }, {4 ,1 ,3 }, {5 ,1 ,4 }, {6 ,1 ,6 }, {7 ,1 ,8 }, {8 ,1 ,12 }, - {0 ,0 ,0 }, + {/* sentinel */ } };static struct clk_factor_table hde_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,2 ,5 }, {4 ,1 ,3 }, {5 ,1 ,4 }, {6 ,1 ,6 }, {7 ,1 ,8 }, - {0 ,0 ,0 }, + {/* sentinel */ } };static struct clk_div_table rmii_ref_div_table[] = { {0 ,4 }, {1 ,10 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table std12rate_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,3 }, {3 ,4 }, {4 ,5 }, {5 ,6 }, {6 ,7 }, {7 ,8 }, {8 ,9 }, {9 ,10 }, {10 ,11 }, {11 ,12 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table i2s_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,3 }, {3 ,4 }, {4 ,6 }, {5 ,8 }, {6 ,12 }, {7 ,16 }, {8 ,24 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table nand_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,4 }, {3 ,6 }, {4 ,8 }, {5 ,10 }, {6 ,12 }, {7 ,14 }, {8 ,16 }, {9 ,18 }, {10 ,20 }, {11 ,22 }, - {0 ,0 }, + {/* sentinel */ } };/* mux clock */
drivers/clk/actions/owl-s700.c +10 -8
@@ -73,7 +73,7 @@static struct clk_pll_table clk_audio_pll_table[] = { {0 ,45158400 }, {1 ,49152000 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_pll_table clk_cvbs_pll_table[] = {
@@ -82,7 +82,8 @@ static struct clk_pll_table clk_cvbs_pll_table[] = { {33, 35 * 12000000}, {34, 36 * 12000000}, {35, 37 * 12000000}, {36, 38 * 12000000}, {37, 39 * 12000000}, {38, 40 * 12000000}, {39, 41 * 12000000}, {40, 42 * 12000000}, {41, 43 * 12000000}, - {42, 44 * 12000000}, {43, 45 * 12000000}, {0, 0}, + {42, 44 * 12000000}, {43, 45 * 12000000}, + { /* sentinel */ } };/* pll clocks */
@@ -137,7 +138,7 @@ static struct clk_factor_table sd_factor_table[] = { {276, 1, 21 * 128}, {277, 1, 22 * 128}, {278, 1, 23 * 128}, {279, 1, 24 * 128}, {280, 1, 25 * 128}, {281, 1, 26 * 128}, - {0, 0}, + { /* sentinel */ } }; static struct clk_factor_table lcd_factor_table[] = {
@@ -150,19 +151,19 @@ static struct clk_factor_table lcd_factor_table[] = { {256, 1, 1 * 7}, {257, 1, 2 * 7}, {258, 1, 3 * 7}, {259, 1, 4 * 7}, {260, 1, 5 * 7}, {261, 1, 6 * 7}, {262, 1, 7 * 7}, {263, 1, 8 * 7}, {264, 1, 9 * 7}, {265, 1, 10 * 7}, {266, 1, 11 * 7}, {267, 1, 12 * 7}, - {0, 0}, + { /* sentinel */ } };static struct clk_div_table hdmia_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,3 }, {3 ,4 }, {4 ,6 }, {5 ,8 }, {6 ,12 }, {7 ,16 }, {8 ,24 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table rmii_div_table[] = { {0 ,4 }, {1 ,10 }, - {0 ,0 } + {/* sentinel */ } };/* divider clocks */
@@ -179,13 +180,14 @@ static OWL_DIVIDER(clk_rmii_ref, "rmii_ref", "ethernet_pll", CMU_ETHERNETPLL, 2,static struct clk_factor_table de_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,2 ,5 }, {4 ,1 ,3 }, {5 ,1 ,4 }, {6 ,1 ,6 }, {7 ,1 ,8 }, - {8 ,1 ,12 }, {0 ,0 ,0 }, + {8 ,1 ,12 }, + {/* sentinel */ } };static struct clk_factor_table hde_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,2 ,5 }, {4 ,1 ,3 }, {5 ,1 ,4 }, {6 ,1 ,6 }, {7 ,1 ,8 }, - {0 ,0 ,0 }, + {/* sentinel */ } };/* gate clocks */
drivers/clk/actions/owl-s900.c +13 -13
@@ -73,12 +73,12 @@static struct clk_pll_table clk_audio_pll_table[] = { {0 ,45158400 }, {1 ,49152000 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_pll_table clk_edp_pll_table[] = { {0 ,810000000 }, {1 ,135000000 }, {2 ,270000000 }, - {0 ,0 }, + {/* sentinel */ } };/* pll clocks */
@@ -120,41 +120,41 @@ static struct clk_div_table nand_div_table[] = { { 4, 8 }, { 5, 10 }, { 6, 12 }, { 7, 14 }, { 8, 16 }, { 9, 18 }, { 10, 20 }, { 11, 22 }, { 12, 24 }, { 13, 26 }, { 14, 28 }, { 15, 30 }, - { 0, 0 }, + { /* sentinel */ } };static struct clk_div_table apb_div_table[] = { {1 ,2 }, {2 ,3 }, {3 ,4 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table eth_mac_div_table[] = { {0 ,2 }, {1 ,4 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table rmii_ref_div_table[] = { {0 ,4 }, {1 ,10 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table usb3_mac_div_table[] = { {1 ,2 }, {2 ,3 }, {3 ,4 }, - {0 ,0 } + {/* sentinel */ } };static struct clk_div_table i2s_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,3 }, {3 ,4 }, {4 ,6 }, {5 ,8 }, {6 ,12 }, {7 ,16 }, {8 ,24 }, - {0 ,0 }, + {/* sentinel */ } };static struct clk_div_table hdmia_div_table[] = { {0 ,1 }, {1 ,2 }, {2 ,3 }, {3 ,4 }, {4 ,6 }, {5 ,8 }, {6 ,12 }, {7 ,16 }, {8 ,24 }, - {0 ,0 }, + {/* sentinel */ } };/* divider clocks */
@@ -185,24 +185,24 @@ static struct clk_factor_table sd_factor_table[] = { { 280, 1, 25 * 128 }, { 281, 1, 26 * 128 }, { 282, 1, 27 * 128 }, { 283, 1, 28 * 128 }, { 284, 1, 29 * 128 }, { 285, 1, 30 * 128 }, { 286, 1, 31 * 128 }, { 287, 1, 32 * 128 }, - { 0, 0 }, + { /* sentinel */ } };static struct clk_factor_table dmm_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,1 ,3 }, {4 ,1 ,4 }, - {0 ,0 ,0 }, + {/* sentinel */ } };static struct clk_factor_table noc_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,1 ,3 }, {4 ,1 ,4 }, - {0 ,0 ,0 }, + {/* sentinel */ } };static struct clk_factor_table bisp_factor_table[] = { {0 ,1 ,1 }, {1 ,2 ,3 }, {2 ,1 ,2 }, {3 ,2 ,5 }, {4 ,1 ,3 }, {5 ,1 ,4 }, {6 ,1 ,6 }, {7 ,1 ,8 }, - {0 ,0 ,0 }, + {/* sentinel */ } };/* factor clocks */
--
2.34.1
Re: [PATCH v4 5/5] clk: actions: Make sentinel elements more obvious
Quoting Jonathan Neuschäfer (2022-02-17 16:09:21)
Quoted 6 lines
The sentinel elements of various tables in
drivers/clk/actionscan be a bit hard to recognize. Make them easier to see by changing the style from { 0, 0 } to { /* sentinel */ }.Signed-off-by Jonathan Neuschäfer <[email protected]>---
Applied to clk-next