* [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported
@ 2013-10-02 15:57 David Herrmann
2013-10-02 15:57 ` [PATCH bluez v2 2/2] bnep: improve error-msg if bnep.ko is not loaded David Herrmann
2013-10-03 6:56 ` [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported Johan Hedberg
0 siblings, 2 replies; 3+ messages in thread
From: David Herrmann @ 2013-10-02 15:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcel Holtmann, Johan Hedberg, David Herrmann
Allow plugins to return -ENOSYS during registration and handle it as
"not-supported" error. It makes the error messages slightly more useful in
case kernel-support is missing for a particular subsystem.
---
src/plugin.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/plugin.c b/src/plugin.c
index 51c98bc..9c3225e 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -119,6 +119,7 @@ gboolean plugin_init(const char *enable, const char *disable)
const char *file;
char **cli_disabled, **cli_enabled;
unsigned int i;
+ int err;
/* Make a call to BtIO API so its symbols got resolved before the
* plugins are loaded. */
@@ -196,8 +197,14 @@ start:
for (list = plugins; list; list = list->next) {
struct bluetooth_plugin *plugin = list->data;
- if (plugin->desc->init() < 0) {
- error("Failed to init %s plugin", plugin->desc->name);
+ err = plugin->desc->init();
+ if (err < 0) {
+ if (err == -ENOSYS)
+ warn("System does not support %s plugin",
+ plugin->desc->name);
+ else
+ error("Failed to init %s plugin",
+ plugin->desc->name);
continue;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH bluez v2 2/2] bnep: improve error-msg if bnep.ko is not loaded
2013-10-02 15:57 [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported David Herrmann
@ 2013-10-02 15:57 ` David Herrmann
2013-10-03 6:56 ` [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported Johan Hedberg
1 sibling, 0 replies; 3+ messages in thread
From: David Herrmann @ 2013-10-02 15:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcel Holtmann, Johan Hedberg, David Herrmann
bnep.ko, besides others, can be disabled in custom kernels if
network-support is not required. To avoid strange error messages, handle
EPROTONOSUPPORT as a special case and emit a warning that kernel support
is missing.
---
profiles/network/common.c | 7 ++++++-
profiles/network/manager.c | 16 +++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/profiles/network/common.c b/profiles/network/common.c
index e069892..0b291bd 100644
--- a/profiles/network/common.c
+++ b/profiles/network/common.c
@@ -110,8 +110,13 @@ int bnep_init(void)
if (ctl < 0) {
int err = -errno;
- error("Failed to open control socket: %s (%d)",
+
+ if (err == -EPROTONOSUPPORT)
+ warn("kernel lacks bnep-protocol support");
+ else
+ error("Failed to open control socket: %s (%d)",
strerror(-err), -err);
+
return err;
}
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index 03b1b3d..6617687 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#include <errno.h>
#include <stdbool.h>
#include <bluetooth/bluetooth.h>
@@ -169,11 +170,20 @@ static struct btd_profile nap_profile = {
static int network_init(void)
{
+ int err;
+
read_config(CONFIGDIR "/network.conf");
- if (bnep_init()) {
- error("Can't init bnep module");
- return -1;
+ err = bnep_init();
+ if (err) {
+ if (err == -EPROTONOSUPPORT) {
+ info("bnep module not available, disabling plugin");
+ err = -ENOSYS;
+ } else {
+ error("Can't init bnep module");
+ }
+
+ return err;
}
/*
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported
2013-10-02 15:57 [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported David Herrmann
2013-10-02 15:57 ` [PATCH bluez v2 2/2] bnep: improve error-msg if bnep.ko is not loaded David Herrmann
@ 2013-10-03 6:56 ` Johan Hedberg
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2013-10-03 6:56 UTC (permalink / raw)
To: David Herrmann; +Cc: linux-bluetooth, Marcel Holtmann
Hi David,
On Wed, Oct 02, 2013, David Herrmann wrote:
> Allow plugins to return -ENOSYS during registration and handle it as
> "not-supported" error. It makes the error messages slightly more useful in
> case kernel-support is missing for a particular subsystem.
> ---
> src/plugin.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
Both patches have been applied after a couple of minor tweaks: remove
one of the three logs in the bnep failure case (we don't need that many)
and restrict scope of the err variable in plugin.c.
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-03 6:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 15:57 [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported David Herrmann
2013-10-02 15:57 ` [PATCH bluez v2 2/2] bnep: improve error-msg if bnep.ko is not loaded David Herrmann
2013-10-03 6:56 ` [PATCH bluez v2 1/2] plugin: handle ENOSYS as not-supported Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.