Skip to contentSkip to conversation

rfkill: Do not log errors for missing device path

PATCH Applied Marcus Prebble 3 participants 3 messages Nov 13, 2024 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rfkill: Do not log errors for missing device path

In the case of our products, we lack a physical RFKILL switch and do not have the rfkill module enabled in the kernel which resulted in an error message each time bluetoothd was started.

This commit looks at the errno code after failing to open the RFKILL device and only logs an error if it is something other than ENOENT (No such file or directory).

---
 src/rfkill.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
src/rfkill.c +11 -3
index 88cad1c9e..ac4a48d0a 100644
@@ -55,6 +55,7 @@ struct rfkill_event {
 	uint8_t  hard;
 };
 #define RFKILL_EVENT_SIZE_V1    8
+#define RFKILL_DEVICE_PATH      "/dev/rfkill"
 
 static int get_adapter_id_for_rfkill(uint32_t rfkill_id)
 {
@@ -88,7 +89,7 @@ int rfkill_get_blocked(uint16_t index)
 	int fd;
 	int blocked = -1;
 
-	fd = open("/dev/rfkill", O_RDWR);
+	fd = open(RFKILL_DEVICE_PATH, O_RDWR);
 	if (fd < 0) {
 		DBG("Failed to open RFKILL control device");
 		return -1;
@@ -178,9 +179,16 @@ void rfkill_init(void)
 	int fd;
 	GIOChannel *channel;
 
-	fd = open("/dev/rfkill", O_RDWR);
+	errno = 0;
+	fd = open(RFKILL_DEVICE_PATH, O_RDWR);
 	if (fd < 0) {
-		error("Failed to open RFKILL control device");
+		if (errno == ENOENT) {
+			DBG("No RFKILL device available at '%s'",
+				RFKILL_DEVICE_PATH);
+		} else {
+			error("Failed to open RFKILL control device: %s",
+				strerror(errno));
+		}
 		return;
 	}
 
Signature · 1 line
2.39.2
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=909312

---Test result---

Test Summary:

CheckPatch                    PASS      0.47 seconds
GitLint                       PASS      0.33 seconds
BuildEll                      PASS      20.66 seconds
BluezMake                     PASS      1660.50 seconds
MakeCheck                     PASS      13.44 seconds
MakeDistcheck                 PASS      163.50 seconds
CheckValgrind                 PASS      216.58 seconds
CheckSmatch                   PASS      276.84 seconds
bluezmakeextell               PASS      100.66 seconds
IncrementalBuild              PASS      1473.04 seconds
ScanBuild                     PASS      871.26 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Marcus Prebble
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Wed, 13 Nov 2024 15:12:56 +0100 you wrote:

In the case of our products, we lack a physical RFKILL switch and do not have the rfkill module enabled in the kernel which resulted in an error message each time bluetoothd was started.

This commit looks at the errno code after failing to open the RFKILL device and only logs an error if it is something other than ENOENT (No such file or directory).

[...]

Here is the summary with links:
- [BlueZ] rfkill: Do not log errors for missing device path

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=63f1ab560c42

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html