@@ -55,7 +55,7 @@ struct mlxsw_item {
55
55
};
56
56
57
57
static inline unsigned int
58
- __mlxsw_item_offset (struct mlxsw_item * item , unsigned short index ,
58
+ __mlxsw_item_offset (const struct mlxsw_item * item , unsigned short index ,
59
59
size_t typesize )
60
60
{
61
61
BUG_ON (index && !item -> step );
@@ -72,7 +72,8 @@ __mlxsw_item_offset(struct mlxsw_item *item, unsigned short index,
72
72
typesize );
73
73
}
74
74
75
- static inline u16 __mlxsw_item_get16 (char * buf , struct mlxsw_item * item ,
75
+ static inline u16 __mlxsw_item_get16 (const char * buf ,
76
+ const struct mlxsw_item * item ,
76
77
unsigned short index )
77
78
{
78
79
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (u16 ));
@@ -87,7 +88,7 @@ static inline u16 __mlxsw_item_get16(char *buf, struct mlxsw_item *item,
87
88
return tmp ;
88
89
}
89
90
90
- static inline void __mlxsw_item_set16 (char * buf , struct mlxsw_item * item ,
91
+ static inline void __mlxsw_item_set16 (char * buf , const struct mlxsw_item * item ,
91
92
unsigned short index , u16 val )
92
93
{
93
94
unsigned int offset = __mlxsw_item_offset (item , index ,
@@ -105,7 +106,8 @@ static inline void __mlxsw_item_set16(char *buf, struct mlxsw_item *item,
105
106
b [offset ] = cpu_to_be16 (tmp );
106
107
}
107
108
108
- static inline u32 __mlxsw_item_get32 (char * buf , struct mlxsw_item * item ,
109
+ static inline u32 __mlxsw_item_get32 (const char * buf ,
110
+ const struct mlxsw_item * item ,
109
111
unsigned short index )
110
112
{
111
113
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (u32 ));
@@ -120,7 +122,7 @@ static inline u32 __mlxsw_item_get32(char *buf, struct mlxsw_item *item,
120
122
return tmp ;
121
123
}
122
124
123
- static inline void __mlxsw_item_set32 (char * buf , struct mlxsw_item * item ,
125
+ static inline void __mlxsw_item_set32 (char * buf , const struct mlxsw_item * item ,
124
126
unsigned short index , u32 val )
125
127
{
126
128
unsigned int offset = __mlxsw_item_offset (item , index ,
@@ -138,7 +140,8 @@ static inline void __mlxsw_item_set32(char *buf, struct mlxsw_item *item,
138
140
b [offset ] = cpu_to_be32 (tmp );
139
141
}
140
142
141
- static inline u64 __mlxsw_item_get64 (char * buf , struct mlxsw_item * item ,
143
+ static inline u64 __mlxsw_item_get64 (const char * buf ,
144
+ const struct mlxsw_item * item ,
142
145
unsigned short index )
143
146
{
144
147
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (u64 ));
@@ -153,7 +156,7 @@ static inline u64 __mlxsw_item_get64(char *buf, struct mlxsw_item *item,
153
156
return tmp ;
154
157
}
155
158
156
- static inline void __mlxsw_item_set64 (char * buf , struct mlxsw_item * item ,
159
+ static inline void __mlxsw_item_set64 (char * buf , const struct mlxsw_item * item ,
157
160
unsigned short index , u64 val )
158
161
{
159
162
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (u64 ));
@@ -170,8 +173,8 @@ static inline void __mlxsw_item_set64(char *buf, struct mlxsw_item *item,
170
173
b [offset ] = cpu_to_be64 (tmp );
171
174
}
172
175
173
- static inline void __mlxsw_item_memcpy_from (char * buf , char * dst ,
174
- struct mlxsw_item * item ,
176
+ static inline void __mlxsw_item_memcpy_from (const char * buf , char * dst ,
177
+ const struct mlxsw_item * item ,
175
178
unsigned short index )
176
179
{
177
180
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (char ));
@@ -180,7 +183,7 @@ static inline void __mlxsw_item_memcpy_from(char *buf, char *dst,
180
183
}
181
184
182
185
static inline void __mlxsw_item_memcpy_to (char * buf , const char * src ,
183
- struct mlxsw_item * item ,
186
+ const struct mlxsw_item * item ,
184
187
unsigned short index )
185
188
{
186
189
unsigned int offset = __mlxsw_item_offset (item , index , sizeof (char ));
@@ -189,7 +192,8 @@ static inline void __mlxsw_item_memcpy_to(char *buf, const char *src,
189
192
}
190
193
191
194
static inline u16
192
- __mlxsw_item_bit_array_offset (struct mlxsw_item * item , u16 index , u8 * shift )
195
+ __mlxsw_item_bit_array_offset (const struct mlxsw_item * item ,
196
+ u16 index , u8 * shift )
193
197
{
194
198
u16 max_index , be_index ;
195
199
u16 offset ; /* byte offset inside the array */
@@ -212,7 +216,8 @@ __mlxsw_item_bit_array_offset(struct mlxsw_item *item, u16 index, u8 *shift)
212
216
return item -> offset + offset ;
213
217
}
214
218
215
- static inline u8 __mlxsw_item_bit_array_get (char * buf , struct mlxsw_item * item ,
219
+ static inline u8 __mlxsw_item_bit_array_get (const char * buf ,
220
+ const struct mlxsw_item * item ,
216
221
u16 index )
217
222
{
218
223
u8 shift , tmp ;
@@ -224,7 +229,8 @@ static inline u8 __mlxsw_item_bit_array_get(char *buf, struct mlxsw_item *item,
224
229
return tmp ;
225
230
}
226
231
227
- static inline void __mlxsw_item_bit_array_set (char * buf , struct mlxsw_item * item ,
232
+ static inline void __mlxsw_item_bit_array_set (char * buf ,
233
+ const struct mlxsw_item * item ,
228
234
u16 index , u8 val )
229
235
{
230
236
u8 shift , tmp ;
@@ -254,7 +260,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
254
260
.size = {.bits = _sizebits,}, \
255
261
.name = #_type "_" #_cname "_" #_iname, \
256
262
}; \
257
- static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(char *buf) \
263
+ static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
258
264
{ \
259
265
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
260
266
} \
@@ -275,7 +281,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
275
281
.name = #_type "_" #_cname "_" #_iname, \
276
282
}; \
277
283
static inline u16 \
278
- mlxsw_##_type##_##_cname##_##_iname##_get(char *buf, unsigned short index) \
284
+ mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
279
285
{ \
280
286
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
281
287
index); \
@@ -295,7 +301,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
295
301
.size = {.bits = _sizebits,}, \
296
302
.name = #_type "_" #_cname "_" #_iname, \
297
303
}; \
298
- static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(char *buf) \
304
+ static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
299
305
{ \
300
306
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
301
307
} \
@@ -316,7 +322,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
316
322
.name = #_type "_" #_cname "_" #_iname, \
317
323
}; \
318
324
static inline u32 \
319
- mlxsw_##_type##_##_cname##_##_iname##_get(char *buf, unsigned short index) \
325
+ mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
320
326
{ \
321
327
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
322
328
index); \
@@ -336,7 +342,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
336
342
.size = {.bits = _sizebits,}, \
337
343
.name = #_type "_" #_cname "_" #_iname, \
338
344
}; \
339
- static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(char *buf) \
345
+ static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
340
346
{ \
341
347
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
342
348
} \
@@ -357,7 +363,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
357
363
.name = #_type "_" #_cname "_" #_iname, \
358
364
}; \
359
365
static inline u64 \
360
- mlxsw_##_type##_##_cname##_##_iname##_get(char *buf, unsigned short index) \
366
+ mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
361
367
{ \
362
368
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
363
369
index); \
@@ -377,7 +383,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
377
383
.name = #_type "_" #_cname "_" #_iname, \
378
384
}; \
379
385
static inline void \
380
- mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(char *buf, char *dst) \
386
+ mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
381
387
{ \
382
388
__mlxsw_item_memcpy_from(buf, dst, \
383
389
&__ITEM_NAME(_type, _cname, _iname), 0); \
@@ -399,7 +405,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
399
405
.name = #_type "_" #_cname "_" #_iname, \
400
406
}; \
401
407
static inline void \
402
- mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(char *buf, \
408
+ mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
403
409
unsigned short index, \
404
410
char *dst) \
405
411
{ \
@@ -424,7 +430,7 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
424
430
.name = #_type "_" #_cname "_" #_iname, \
425
431
}; \
426
432
static inline u8 \
427
- mlxsw_##_type##_##_cname##_##_iname##_get(char *buf, u16 index) \
433
+ mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
428
434
{ \
429
435
return __mlxsw_item_bit_array_get(buf, \
430
436
&__ITEM_NAME(_type, _cname, _iname), \
0 commit comments