drivers/phy/cadence: Constify static structs
cover drivers/phy/cadence: Constify static structs
Constify a number of static structs that are never changed to allow the compiler to put them in read-only memory.
Rikard Falkeborn (3):
phy: cadence: Sierra: Constify static structs
phy: cadence: salvo: Constify cdns_nxp_sequence_pair
phy: cadence: torrent: Constify regmap_config structs
drivers/phy/cadence/phy-cadence-salvo.c | 6 +++--- drivers/phy/cadence/phy-cadence-sierra.c | 24 +++++++++++------------ drivers/phy/cadence/phy-cadence-torrent.c | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/3 phy: cadence: Sierra: Constify static structs
The static cdns_reg_pairs and regmap_config structs are not modified and can be made const. This allows the compiler to put them in read-only memory.
--- drivers/phy/cadence/phy-cadence-sierra.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/phy/cadence/phy-cadence-sierra.c +12 -12
@@ -172,10 +172,10 @@ struct cdns_sierra_data {u32 pcie_ln_regs;u32 usb_cmn_regs;u32 usb_ln_regs; -struct cdns_reg_pairs *pcie_cmn_vals; -struct cdns_reg_pairs *pcie_ln_vals; -struct cdns_reg_pairs *usb_cmn_vals; -struct cdns_reg_pairs *usb_ln_vals; +const struct cdns_reg_pairs *pcie_cmn_vals; +const struct cdns_reg_pairs *pcie_ln_vals; +const struct cdns_reg_pairs *usb_cmn_vals; +const struct cdns_reg_pairs *usb_ln_vals; };struct cdns_regmap_cdb_context {
@@ -233,7 +233,7 @@ static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val) .reg_read = cdns_regmap_read, \ } -static struct regmap_config cdns_sierra_lane_cdb_config[] = { +static const struct regmap_config cdns_sierra_lane_cdb_config[] = {SIERRA_LANE_CDB_REGMAP_CONF ("0" ),SIERRA_LANE_CDB_REGMAP_CONF ("1" ),SIERRA_LANE_CDB_REGMAP_CONF ("2" ),
@@ -252,7 +252,7 @@ static struct regmap_config cdns_sierra_lane_cdb_config[] = { SIERRA_LANE_CDB_REGMAP_CONF("15"), }; -static struct regmap_config cdns_sierra_common_cdb_config = { +static const struct regmap_config cdns_sierra_common_cdb_config = { .name ="sierra_common_cdb" , .reg_stride =1 , .fast_io = true,
@@ -260,7 +260,7 @@ static struct regmap_config cdns_sierra_common_cdb_config = { .reg_read = cdns_regmap_read, }; -static struct regmap_config cdns_sierra_phy_config_ctrl_config = { +static const struct regmap_config cdns_sierra_phy_config_ctrl_config = { .name ="sierra_phy_config_ctrl" , .reg_stride =1 , .fast_io = true,
@@ -274,7 +274,7 @@ static int cdns_sierra_phy_init(struct phy *gphy)struct cdns_sierra_phy *phy =dev_get_drvdata (gphy->dev.parent);struct regmap *regmap;int i, j; -struct cdns_reg_pairs *cmn_vals, *ln_vals; +const struct cdns_reg_pairs *cmn_vals, *ln_vals;u32 num_cmn_regs, num_ln_regs;/* Initialise the PHY registers, unless auto configured */
@@ -654,7 +654,7 @@ static int cdns_sierra_phy_remove(struct platform_device *pdev) }/* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */ -static struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = { +static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = { {0x2106 ,SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG }, {0x2106 ,SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG }, {0x8A06 ,SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG },
@@ -663,7 +663,7 @@ static struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = { };/* refclk100MHz_32b_PCIe_ln_ext_ssc */ -static struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = { +static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = { {0x813E ,SIERRA_CLKPATHCTRL_TMR_PREG }, {0x8047 ,SIERRA_RX_CREQ_FLTR_A_MODE3_PREG }, {0x808F ,SIERRA_RX_CREQ_FLTR_A_MODE2_PREG },
@@ -674,7 +674,7 @@ static struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = { };/* refclk100MHz_20b_USB_cmn_pll_ext_ssc */ -static struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = { +static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = { {0x2085 ,SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG }, {0x2085 ,SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG }, {0x0000 ,SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG },
@@ -682,7 +682,7 @@ static struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = { };/* refclk100MHz_20b_USB_ln_ext_ssc */ -static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = { +static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = { {0xFE0A ,SIERRA_DET_STANDEC_A_PREG }, {0x000F ,SIERRA_DET_STANDEC_B_PREG }, {0x55A5 ,SIERRA_DET_STANDEC_C_PREG },
Signature · 1 line
2.28.0
PATCH 2/3 phy: cadence: salvo: Constify cdns_nxp_sequence_pair
In reply to Rikard Falkeborncdns_nxp_sequence_pair[] are never modified and can be made const to allow the compiler to put them in read-only memory.
--- drivers/phy/cadence/phy-cadence-salvo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/cadence/phy-cadence-salvo.c +3 -3
@@ -97,7 +97,7 @@ struct cdns_reg_pairs {struct cdns_salvo_data {u8 reg_offset_shift; -struct cdns_reg_pairs *init_sequence_val; +const struct cdns_reg_pairs *init_sequence_val;u8 init_sequence_length; };
@@ -126,7 +126,7 @@ static void cdns_salvo_write(struct cdns_salvo_phy *salvo_phy,* Below bringup sequence pair are from Cadence PHY's User Guide * and NXP platform tuning results. */ -static struct cdns_reg_pairs cdns_nxp_sequence_pair[] = { +static const struct cdns_reg_pairs cdns_nxp_sequence_pair[] = { {0x0830 ,PHY_PMA_CMN_CTRL1 }, {0x0010 ,TB_ADDR_CMN_DIAG_HSCLK_SEL }, {0x00f0 ,TB_ADDR_CMN_PLL0_VCOCAL_INIT_TMR },
@@ -217,7 +217,7 @@ static int cdns_salvo_phy_init(struct phy *phy)return ret;for (i =0 ; i < data->init_sequence_length; i++) { -struct cdns_reg_pairs *reg_pair = data->init_sequence_val + i; +const struct cdns_reg_pairs *reg_pair = data->init_sequence_val + i;cdns_salvo_write (salvo_phy, reg_pair->off, reg_pair->val); }
Signature · 1 line
2.28.0
RE: [PATCH 2/3] phy: cadence: salvo: Constify cdns_nxp_sequence_pair
Quoted 6 lines
cdns_nxp_sequence_pair[] are never modified and can be made const to allow the compiler to put them in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>
Peter
Quoted 39 lines
--- drivers/phy/cadence/phy-cadence-salvo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/phy/cadence/phy-cadence-salvo.c +2
-2@@ -97,7 +97,7 @@ struct cdns_reg_pairs {struct cdns_salvo_data {u8 reg_offset_shift; -struct cdns_reg_pairs *init_sequence_val; +const struct cdns_reg_pairs *init_sequence_val;u8 init_sequence_length; };@@ -126,7 +126,7 @@ static void cdns_salvo_write(struct cdns_salvo_phy*salvo_phy, * Below bringup sequence pair are from Cadence PHY's User Guide * and NXP platform tuning results. */ -static struct cdns_reg_pairs cdns_nxp_sequence_pair[] = { +static const struct cdns_reg_pairs cdns_nxp_sequence_pair[] = { {0x0830 ,PHY_PMA_CMN_CTRL1 }, {0x0010 ,TB_ADDR_CMN_DIAG_HSCLK_SEL },drivers/phy/cadence/phy-cadence-salvo.c +1
-2{0x00f0, TB_ADDR_CMN_PLL0_VCOCAL_INIT_TMR},@@ -217,7 +217,7 @@ static int cdns_salvo_phy_init(struct phy *phy)return ret;for (i =0 ; i < data->init_sequence_length; i++) { -struct cdns_reg_pairs *reg_pair = data->init_sequence_val + i; +const struct cdns_reg_pairs *reg_pair = data->init_sequence_val + i;cdns_salvo_write (salvo_phy, reg_pair->off, reg_pair->val); } --2.28.0
PATCH 3/3 phy: cadence: torrent: Constify regmap_config structs
In reply to Rikard FalkebornThe regmap_config structs are never modified and can be made const to allow the compiler to put them in read-only memory.
--- drivers/phy/cadence/phy-cadence-torrent.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +6 -6
@@ -331,21 +331,21 @@ static int cdns_regmap_dptx_read(void *context, unsigned int reg, .reg_read = cdns_regmap_read, \ } -static struct regmap_config cdns_torrent_tx_lane_cdb_config[] = { +static const struct regmap_config cdns_torrent_tx_lane_cdb_config[] = {TORRENT_TX_LANE_CDB_REGMAP_CONF ("0" ),TORRENT_TX_LANE_CDB_REGMAP_CONF ("1" ),TORRENT_TX_LANE_CDB_REGMAP_CONF ("2" ),TORRENT_TX_LANE_CDB_REGMAP_CONF ("3" ), }; -static struct regmap_config cdns_torrent_rx_lane_cdb_config[] = { +static const struct regmap_config cdns_torrent_rx_lane_cdb_config[] = {TORRENT_RX_LANE_CDB_REGMAP_CONF ("0" ),TORRENT_RX_LANE_CDB_REGMAP_CONF ("1" ),TORRENT_RX_LANE_CDB_REGMAP_CONF ("2" ),TORRENT_RX_LANE_CDB_REGMAP_CONF ("3" ), }; -static struct regmap_config cdns_torrent_common_cdb_config = { +static const struct regmap_config cdns_torrent_common_cdb_config = { .name ="torrent_common_cdb" , .reg_stride =1 , .fast_io = true,
@@ -353,7 +353,7 @@ static struct regmap_config cdns_torrent_common_cdb_config = { .reg_read = cdns_regmap_read, }; -static struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = { +static const struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = { .name ="torrent_phy_pcs_cmn_cdb" , .reg_stride =1 , .fast_io = true,
@@ -361,7 +361,7 @@ static struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = { .reg_read = cdns_regmap_read, }; -static struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = { +static const struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = { .name ="torrent_phy_pma_cmn_cdb" , .reg_stride =1 , .fast_io = true,
@@ -369,7 +369,7 @@ static struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = { .reg_read = cdns_regmap_read, }; -static struct regmap_config cdns_torrent_dptx_phy_config = { +static const struct regmap_config cdns_torrent_dptx_phy_config = { .name ="torrent_dptx_phy" , .reg_stride =1 , .fast_io = true,
Signature · 1 line
2.28.0
Quoted 2 lines · Rikard Falkeborn
Constify a number of static structs that are never changed to allow the compiler to put them in read-only memory.
Applied, thanks
Signature · 1 line
~Vinod