Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

interconnect: qcom: osm-l3: Mark more structures const

These structures aren't modified at runtime. Mark them const so they get
moved to read-only memory. We have to cast away const in one place when
we store into the data member of struct icc_node. This is paired with a
re-const of the data member when it is extracted in qcom_icc_set().

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Evan Green <evgreen@chromium.org>
Link: https://lore.kernel.org/r/20200914182112.513981-1-swboyd@chromium.org
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

authored by

Stephen Boyd and committed by
Georgi Djakov
b1a367bb d7e19be6

+10 -9
+10 -9
drivers/interconnect/qcom/osm-l3.c
··· 65 65 }; 66 66 67 67 struct qcom_icc_desc { 68 - struct qcom_icc_node **nodes; 68 + const struct qcom_icc_node **nodes; 69 69 size_t num_nodes; 70 70 unsigned int lut_row_size; 71 71 unsigned int reg_freq_lut; ··· 73 73 }; 74 74 75 75 #define DEFINE_QNODE(_name, _id, _buswidth, ...) \ 76 - static struct qcom_icc_node _name = { \ 76 + static const struct qcom_icc_node _name = { \ 77 77 .name = #_name, \ 78 78 .id = _id, \ 79 79 .buswidth = _buswidth, \ ··· 84 84 DEFINE_QNODE(sdm845_osm_apps_l3, SDM845_MASTER_OSM_L3_APPS, 16, SDM845_SLAVE_OSM_L3); 85 85 DEFINE_QNODE(sdm845_osm_l3, SDM845_SLAVE_OSM_L3, 16); 86 86 87 - static struct qcom_icc_node *sdm845_osm_l3_nodes[] = { 87 + static const struct qcom_icc_node *sdm845_osm_l3_nodes[] = { 88 88 [MASTER_OSM_L3_APPS] = &sdm845_osm_apps_l3, 89 89 [SLAVE_OSM_L3] = &sdm845_osm_l3, 90 90 }; ··· 100 100 DEFINE_QNODE(sc7180_osm_apps_l3, SC7180_MASTER_OSM_L3_APPS, 16, SC7180_SLAVE_OSM_L3); 101 101 DEFINE_QNODE(sc7180_osm_l3, SC7180_SLAVE_OSM_L3, 16); 102 102 103 - static struct qcom_icc_node *sc7180_osm_l3_nodes[] = { 103 + static const struct qcom_icc_node *sc7180_osm_l3_nodes[] = { 104 104 [MASTER_OSM_L3_APPS] = &sc7180_osm_apps_l3, 105 105 [SLAVE_OSM_L3] = &sc7180_osm_l3, 106 106 }; ··· 116 116 DEFINE_QNODE(sm8150_osm_apps_l3, SM8150_MASTER_OSM_L3_APPS, 32, SM8150_SLAVE_OSM_L3); 117 117 DEFINE_QNODE(sm8150_osm_l3, SM8150_SLAVE_OSM_L3, 32); 118 118 119 - static struct qcom_icc_node *sm8150_osm_l3_nodes[] = { 119 + static const struct qcom_icc_node *sm8150_osm_l3_nodes[] = { 120 120 [MASTER_OSM_L3_APPS] = &sm8150_osm_apps_l3, 121 121 [SLAVE_OSM_L3] = &sm8150_osm_l3, 122 122 }; ··· 132 132 DEFINE_QNODE(sm8250_epss_apps_l3, SM8250_MASTER_EPSS_L3_APPS, 32, SM8250_SLAVE_EPSS_L3); 133 133 DEFINE_QNODE(sm8250_epss_l3, SM8250_SLAVE_EPSS_L3, 32); 134 134 135 - static struct qcom_icc_node *sm8250_epss_l3_nodes[] = { 135 + static const struct qcom_icc_node *sm8250_epss_l3_nodes[] = { 136 136 [MASTER_EPSS_L3_APPS] = &sm8250_epss_apps_l3, 137 137 [SLAVE_EPSS_L3_SHARED] = &sm8250_epss_l3, 138 138 }; ··· 149 149 { 150 150 struct qcom_osm_l3_icc_provider *qp; 151 151 struct icc_provider *provider; 152 - struct qcom_icc_node *qn; 152 + const struct qcom_icc_node *qn; 153 153 struct icc_node *n; 154 154 unsigned int index; 155 155 u32 agg_peak = 0; ··· 194 194 const struct qcom_icc_desc *desc; 195 195 struct icc_onecell_data *data; 196 196 struct icc_provider *provider; 197 - struct qcom_icc_node **qnodes; 197 + const struct qcom_icc_node **qnodes; 198 198 struct icc_node *node; 199 199 size_t num_nodes; 200 200 struct clk *clk; ··· 286 286 } 287 287 288 288 node->name = qnodes[i]->name; 289 - node->data = qnodes[i]; 289 + /* Cast away const and add it back in qcom_icc_set() */ 290 + node->data = (void *)qnodes[i]; 290 291 icc_node_add(node, provider); 291 292 292 293 for (j = 0; j < qnodes[i]->num_links; j++)