Skip to content

Commit f12e658

Browse files
idoschkuba-moo
authored andcommitted
mlxsw: item: Annotate item helpers with '__maybe_unused'
mlxsw is using helpers to get / set fields in messages exchanged with the device. It is possible that some fields are only set or only get. This causes LLVM to emit warnings such as the following when building with W=1 [1]: drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c:2022:1: warning: unused function 'mlxsw_afa_sampler_mirror_agent_get' The fact that some fields are only set or only get is very much intentional and not indicative of functions that need to be removed. Therefore, annotate the item helpers with '__maybe_unused' to suppress these warnings. [1] https://lkml.org/lkml/2021/9/29/685 Cc: Nathan Chancellor <nathan@kernel.org> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20211008132315.90211-1-idosch@idosch.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e506342 commit f12e658

File tree

1 file changed

+32
-24
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+32
-24
lines changed

drivers/net/ethernet/mellanox/mlxsw/item.h

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
270270
.size = {.bits = _sizebits,}, \
271271
.name = #_type "_" #_cname "_" #_iname, \
272272
}; \
273-
static inline u8 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
273+
static inline u8 __maybe_unused \
274+
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
274275
{ \
275276
return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
276277
} \
277-
static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u8 val)\
278+
static inline void __maybe_unused \
279+
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u8 val) \
278280
{ \
279281
__mlxsw_item_set8(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
280282
}
@@ -290,13 +292,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
290292
.size = {.bits = _sizebits,}, \
291293
.name = #_type "_" #_cname "_" #_iname, \
292294
}; \
293-
static inline u8 \
295+
static inline u8 __maybe_unused \
294296
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
295297
{ \
296298
return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \
297299
index); \
298300
} \
299-
static inline void \
301+
static inline void __maybe_unused \
300302
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
301303
u8 val) \
302304
{ \
@@ -311,11 +313,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
311313
.size = {.bits = _sizebits,}, \
312314
.name = #_type "_" #_cname "_" #_iname, \
313315
}; \
314-
static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
316+
static inline u16 __maybe_unused \
317+
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
315318
{ \
316319
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
317320
} \
318-
static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val)\
321+
static inline void __maybe_unused \
322+
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val) \
319323
{ \
320324
__mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
321325
}
@@ -331,13 +335,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
331335
.size = {.bits = _sizebits,}, \
332336
.name = #_type "_" #_cname "_" #_iname, \
333337
}; \
334-
static inline u16 \
338+
static inline u16 __maybe_unused \
335339
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
336340
{ \
337341
return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
338342
index); \
339343
} \
340-
static inline void \
344+
static inline void __maybe_unused \
341345
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
342346
u16 val) \
343347
{ \
@@ -352,11 +356,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
352356
.size = {.bits = _sizebits,}, \
353357
.name = #_type "_" #_cname "_" #_iname, \
354358
}; \
355-
static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
359+
static inline u32 __maybe_unused \
360+
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
356361
{ \
357362
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
358363
} \
359-
static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val)\
364+
static inline void __maybe_unused \
365+
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val) \
360366
{ \
361367
__mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
362368
}
@@ -372,13 +378,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
372378
.size = {.bits = _sizebits,}, \
373379
.name = #_type "_" #_cname "_" #_iname, \
374380
}; \
375-
static inline u32 \
381+
static inline u32 __maybe_unused \
376382
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
377383
{ \
378384
return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
379385
index); \
380386
} \
381-
static inline void \
387+
static inline void __maybe_unused \
382388
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
383389
u32 val) \
384390
{ \
@@ -393,11 +399,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
393399
.size = {.bits = _sizebits,}, \
394400
.name = #_type "_" #_cname "_" #_iname, \
395401
}; \
396-
static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
402+
static inline u64 __maybe_unused \
403+
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
397404
{ \
398405
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
399406
} \
400-
static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val)\
407+
static inline void __maybe_unused \
408+
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val) \
401409
{ \
402410
__mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
403411
}
@@ -413,13 +421,13 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
413421
.size = {.bits = _sizebits,}, \
414422
.name = #_type "_" #_cname "_" #_iname, \
415423
}; \
416-
static inline u64 \
424+
static inline u64 __maybe_unused \
417425
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
418426
{ \
419427
return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
420428
index); \
421429
} \
422-
static inline void \
430+
static inline void __maybe_unused \
423431
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
424432
u64 val) \
425433
{ \
@@ -433,19 +441,19 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
433441
.size = {.bytes = _sizebytes,}, \
434442
.name = #_type "_" #_cname "_" #_iname, \
435443
}; \
436-
static inline void \
444+
static inline void __maybe_unused \
437445
mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
438446
{ \
439447
__mlxsw_item_memcpy_from(buf, dst, \
440448
&__ITEM_NAME(_type, _cname, _iname), 0); \
441449
} \
442-
static inline void \
450+
static inline void __maybe_unused \
443451
mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \
444452
{ \
445453
__mlxsw_item_memcpy_to(buf, src, \
446454
&__ITEM_NAME(_type, _cname, _iname), 0); \
447455
} \
448-
static inline char * \
456+
static inline char * __maybe_unused \
449457
mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \
450458
{ \
451459
return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
@@ -460,23 +468,23 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
460468
.size = {.bytes = _sizebytes,}, \
461469
.name = #_type "_" #_cname "_" #_iname, \
462470
}; \
463-
static inline void \
471+
static inline void __maybe_unused \
464472
mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
465473
unsigned short index, \
466474
char *dst) \
467475
{ \
468476
__mlxsw_item_memcpy_from(buf, dst, \
469477
&__ITEM_NAME(_type, _cname, _iname), index); \
470478
} \
471-
static inline void \
479+
static inline void __maybe_unused \
472480
mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
473481
unsigned short index, \
474482
const char *src) \
475483
{ \
476484
__mlxsw_item_memcpy_to(buf, src, \
477485
&__ITEM_NAME(_type, _cname, _iname), index); \
478486
} \
479-
static inline char * \
487+
static inline char * __maybe_unused \
480488
mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \
481489
{ \
482490
return __mlxsw_item_data(buf, \
@@ -491,14 +499,14 @@ static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
491499
.size = {.bytes = _sizebytes,}, \
492500
.name = #_type "_" #_cname "_" #_iname, \
493501
}; \
494-
static inline u8 \
502+
static inline u8 __maybe_unused \
495503
mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
496504
{ \
497505
return __mlxsw_item_bit_array_get(buf, \
498506
&__ITEM_NAME(_type, _cname, _iname), \
499507
index); \
500508
} \
501-
static inline void \
509+
static inline void __maybe_unused \
502510
mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \
503511
{ \
504512
return __mlxsw_item_bit_array_set(buf, \

0 commit comments

Comments
 (0)