Skip to content

Commit b1a367b

Browse files
bebarinoGeorgi Djakov
authored andcommitted
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>
1 parent d7e19be commit b1a367b

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/interconnect/qcom/osm-l3.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ struct qcom_icc_node {
6565
};
6666

6767
struct qcom_icc_desc {
68-
struct qcom_icc_node **nodes;
68+
const struct qcom_icc_node **nodes;
6969
size_t num_nodes;
7070
unsigned int lut_row_size;
7171
unsigned int reg_freq_lut;
7272
unsigned int reg_perf_state;
7373
};
7474

7575
#define DEFINE_QNODE(_name, _id, _buswidth, ...) \
76-
static struct qcom_icc_node _name = { \
76+
static const struct qcom_icc_node _name = { \
7777
.name = #_name, \
7878
.id = _id, \
7979
.buswidth = _buswidth, \
@@ -84,7 +84,7 @@ struct qcom_icc_desc {
8484
DEFINE_QNODE(sdm845_osm_apps_l3, SDM845_MASTER_OSM_L3_APPS, 16, SDM845_SLAVE_OSM_L3);
8585
DEFINE_QNODE(sdm845_osm_l3, SDM845_SLAVE_OSM_L3, 16);
8686

87-
static struct qcom_icc_node *sdm845_osm_l3_nodes[] = {
87+
static const struct qcom_icc_node *sdm845_osm_l3_nodes[] = {
8888
[MASTER_OSM_L3_APPS] = &sdm845_osm_apps_l3,
8989
[SLAVE_OSM_L3] = &sdm845_osm_l3,
9090
};
@@ -100,7 +100,7 @@ static const struct qcom_icc_desc sdm845_icc_osm_l3 = {
100100
DEFINE_QNODE(sc7180_osm_apps_l3, SC7180_MASTER_OSM_L3_APPS, 16, SC7180_SLAVE_OSM_L3);
101101
DEFINE_QNODE(sc7180_osm_l3, SC7180_SLAVE_OSM_L3, 16);
102102

103-
static struct qcom_icc_node *sc7180_osm_l3_nodes[] = {
103+
static const struct qcom_icc_node *sc7180_osm_l3_nodes[] = {
104104
[MASTER_OSM_L3_APPS] = &sc7180_osm_apps_l3,
105105
[SLAVE_OSM_L3] = &sc7180_osm_l3,
106106
};
@@ -116,7 +116,7 @@ static const struct qcom_icc_desc sc7180_icc_osm_l3 = {
116116
DEFINE_QNODE(sm8150_osm_apps_l3, SM8150_MASTER_OSM_L3_APPS, 32, SM8150_SLAVE_OSM_L3);
117117
DEFINE_QNODE(sm8150_osm_l3, SM8150_SLAVE_OSM_L3, 32);
118118

119-
static struct qcom_icc_node *sm8150_osm_l3_nodes[] = {
119+
static const struct qcom_icc_node *sm8150_osm_l3_nodes[] = {
120120
[MASTER_OSM_L3_APPS] = &sm8150_osm_apps_l3,
121121
[SLAVE_OSM_L3] = &sm8150_osm_l3,
122122
};
@@ -132,7 +132,7 @@ static const struct qcom_icc_desc sm8150_icc_osm_l3 = {
132132
DEFINE_QNODE(sm8250_epss_apps_l3, SM8250_MASTER_EPSS_L3_APPS, 32, SM8250_SLAVE_EPSS_L3);
133133
DEFINE_QNODE(sm8250_epss_l3, SM8250_SLAVE_EPSS_L3, 32);
134134

135-
static struct qcom_icc_node *sm8250_epss_l3_nodes[] = {
135+
static const struct qcom_icc_node *sm8250_epss_l3_nodes[] = {
136136
[MASTER_EPSS_L3_APPS] = &sm8250_epss_apps_l3,
137137
[SLAVE_EPSS_L3_SHARED] = &sm8250_epss_l3,
138138
};
@@ -149,7 +149,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
149149
{
150150
struct qcom_osm_l3_icc_provider *qp;
151151
struct icc_provider *provider;
152-
struct qcom_icc_node *qn;
152+
const struct qcom_icc_node *qn;
153153
struct icc_node *n;
154154
unsigned int index;
155155
u32 agg_peak = 0;
@@ -194,7 +194,7 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
194194
const struct qcom_icc_desc *desc;
195195
struct icc_onecell_data *data;
196196
struct icc_provider *provider;
197-
struct qcom_icc_node **qnodes;
197+
const struct qcom_icc_node **qnodes;
198198
struct icc_node *node;
199199
size_t num_nodes;
200200
struct clk *clk;
@@ -286,7 +286,8 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
286286
}
287287

288288
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];
290291
icc_node_add(node, provider);
291292

292293
for (j = 0; j < qnodes[i]->num_links; j++)

0 commit comments

Comments
 (0)