-#define RES_FUNC(name, command, valid_filters, strict_port) \
- static inline int _##name(struct rd *rd)\
- { \
- return _res_send_msg(rd, command, name##_parse_cb); \
- } \
- static inline int name(struct rd *rd) \
- {\
- int ret = rd_build_filter(rd, valid_filters); \
- if (ret) \
- return ret; \
- if ((uintptr_t)valid_filters != (uintptr_t)NULL) { \
- ret = rd_set_arg_to_devname(rd); \
- if (ret) \
- return ret;\
- } \
- if (strict_port) \
- return rd_exec_dev(rd, _##name); \
- else \
- return rd_exec_link(rd, _##name, strict_port); \
+#define RES_FUNC(name, command, valid_filters, strict_port, id) \
+ static inline int _##name(struct rd *rd) \
+ { \
+ uint32_t idx, _command; \
+ int ret; \
+ _command = res_get_command(command, rd); \
+ if (id) { \
+ ret = rd_doit_index(rd, &idx); \
+ if (ret) { \
+ rd->suppress_errors = true; \
+ ret = _res_send_idx_msg(rd, _command, \
+ name##_idx_parse_cb, \
+ idx, id); \
+ if (!ret || rd->show_raw) \
+ return ret; \
+ /* Fallback for old systems without .doit callbacks. \
+ * Kernel that supports raw, for sure supports doit. \
+ */ \
+ } \
+ } \
+ return _res_send_msg(rd, _command, name##_parse_cb); \
+ } \
+ static inline int name(struct rd *rd) \
+ { \
+ int ret = rd_build_filter(rd, valid_filters); \
+ if (ret) \
+ return ret; \
+ if ((uintptr_t)valid_filters != (uintptr_t)NULL) { \
+ ret = rd_set_arg_to_devname(rd); \
+ if (ret) \
+ return ret; \
+ } \
+ if (strict_port) \
+ return rd_exec_dev(rd, _##name); \
+ else \
+ return rd_exec_link(rd, _##name, strict_port); \