diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-20 01:04:48 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-20 01:04:48 +0100 |
commit | 4adaf0ba0ea6a9f78c50fde67c10bbb8b43472b5 (patch) | |
tree | 96b0d001b7e9c7ed382c09c98bfb6c2e6068d012 | |
parent | ecc73a015d5670296febd3e07aae3301db3a4158 (diff) | |
download | neard-4adaf0ba0ea6a9f78c50fde67c10bbb8b43472b5.tar.gz neard-4adaf0ba0ea6a9f78c50fde67c10bbb8b43472b5.tar.bz2 neard-4adaf0ba0ea6a9f78c50fde67c10bbb8b43472b5.zip |
adapter: Make the power cycle upon driver error configurable
The default behaviour is to power cycle the adapter when receiving a
driver error.
-rw-r--r-- | doc/neard.conf.5 | 4 | ||||
-rw-r--r-- | src/adapter.c | 13 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/main.conf | 5 |
4 files changed, 26 insertions, 6 deletions
diff --git a/doc/neard.conf.5 b/doc/neard.conf.5 index 3f19cf3..2cb3ad6 100644 --- a/doc/neard.conf.5 +++ b/doc/neard.conf.5 @@ -39,5 +39,9 @@ into starting a new polling cycle whenever a target or a device are lost. .B DefaultPowered=\fPtrue|false\fP Automatically turn an adapter on when being discovered. Default value is false. +.TP +.B ResetOnError=\fPtrue|false\fP +Power cycle the adapter when getting a driver error from the kernel. +Default value is true. .SH "SEE ALSO" .BR neard (8) diff --git a/src/adapter.c b/src/adapter.c index 98331a5..0f821ee 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -857,15 +857,16 @@ int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx) static gboolean poll_error(gpointer user_data) { struct near_adapter *adapter = user_data; + bool reset; DBG("adapter %d", adapter->idx); - /* - * Resettting the adapter upon polling errors. - * This could be handled through a configuration setting. - */ - __near_netlink_adapter_enable(adapter->idx, false); - __near_netlink_adapter_enable(adapter->idx, true); + reset = near_setting_get_bool("ResetOnError"); + if (reset) { + near_error("Resetting nfc%d", adapter->idx); + __near_netlink_adapter_enable(adapter->idx, false); + __near_netlink_adapter_enable(adapter->idx, true); + } adapter_start_poll(adapter); @@ -37,9 +37,11 @@ static struct { bool constant_poll; bool default_powered; + bool reset_on_error; } near_settings = { .constant_poll = FALSE, .default_powered = FALSE, + .reset_on_error = TRUE, }; static GKeyFile *load_config(const char *file) @@ -85,6 +87,11 @@ static void parse_config(GKeyFile *config) if (!error) near_settings.default_powered = boolean; + boolean = g_key_file_get_boolean(config, "General", + "ResetOnError", &error); + if (!error) + near_settings.reset_on_error = boolean; + g_clear_error(&error); } @@ -208,6 +215,9 @@ bool near_setting_get_bool(const char *key) if (g_str_equal(key, "DefaultPowered")) return near_settings.default_powered; + if (g_str_equal(key, "ResetOnError")) + return near_settings.reset_on_error; + return false; } diff --git a/src/main.conf b/src/main.conf index ccaa871..70c2697 100644 --- a/src/main.conf +++ b/src/main.conf @@ -9,3 +9,8 @@ ConstantPoll = true # Automatically turn an adapter on when being discovered. # Default value is false. DefaultPowered = true + +# Power cycle the adapter when getting a driver error from +# the kernel. +# Default value is true. +ResetOnError = true |