diff mbox series

[3/3] rfkill: support hard block reason in C code

Message ID 20210206153411.19097-3-markus.theil@tu-ilmenau.de
State New
Headers show
Series [1/3] rfkill: update rfkill.h | expand

Commit Message

Markus Theil Feb. 6, 2021, 3:34 p.m. UTC
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 rfkill.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/rfkill.c b/rfkill.c
index 6b5ca2c..253ee46 100644
--- a/rfkill.c
+++ b/rfkill.c
@@ -58,9 +58,10 @@  static void rfkill_event(void)
 		}
 
 		gettimeofday(&tv, NULL);
-		printf("%ld.%06u: idx %u type %u op %u soft %u hard %u\n",
+		printf("%ld.%06u: idx %u type %u op %u soft %u hard %u hard block reasons 0x%02x\n",
 			(long) tv.tv_sec, (unsigned int) tv.tv_usec,
-			event.idx, event.type, event.op, event.soft, event.hard);
+			event.idx, event.type, event.op, event.soft, event.hard,
+			event.hard_block_reasons);
 		fflush(stdout);
 	}
 
@@ -244,6 +245,16 @@  static int rfkill_list(const char *param)
 						type2string(event.type));
 		printf("\tSoft blocked: %s\n", event.soft ? "yes" : "no");
 		printf("\tHard blocked: %s\n", event.hard ? "yes" : "no");
+		if (len >= RFKILL_EVENT_SIZE_V1 + 1) {
+			printf("\tHard block reasons: ");
+			if (event.hard_block_reasons == 0)
+				printf("[NONE]");
+			if (event.hard_block_reasons & RFKILL_HARD_BLOCK_NOT_OWNER)
+				printf("[NOT_OWNER]");
+			if (event.hard_block_reasons & RFKILL_HARD_BLOCK_SIGNAL)
+				printf("[SIGNAL]");
+			printf("\n");
+		}
 	}
 
 	close(fd);