Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bluetooth-rfkill-event/bluetooth-rfkill-event.service b/bluetooth-rfkill-event/bluetooth-rfkill-event.service
- index 453fd36..742e1af 100644
- --- a/bluetooth-rfkill-event/bluetooth-rfkill-event.service
- +++ b/bluetooth-rfkill-event/bluetooth-rfkill-event.service
- @@ -6,7 +6,7 @@ Before=bluetooth.service
- Type=simple
- EnvironmentFile=-/etc/sysconfig/bluetooth-rfkill-event
- EnvironmentFile=-/etc/sysconfig/bluetooth-rfkill-event-hciattach
- -ExecStart=/usr/sbin/bluetooth_rfkill_event $DEBUG $BTMODULE $CONFIGFILE
- +ExecStart=/usr/sbin/bluetooth_rfkill_event $DEBUG $BTMODULE $CONFIGFILE $RFKILLNAME
- Restart=on-failure
- [Install]
- diff --git a/bluetooth-rfkill-event/bluetooth-rfkill-event.sysconfig b/bluetooth-rfkill-event/bluetooth-rfkill-event.sysconfig
- index 64f296c..60546a9 100644
- --- a/bluetooth-rfkill-event/bluetooth-rfkill-event.sysconfig
- +++ b/bluetooth-rfkill-event/bluetooth-rfkill-event.sysconfig
- @@ -2,3 +2,4 @@
- # DEBUG -- debug options
- # BTMODULE -- name of bluetooth kernel module to load/unload, if any
- # CONFIGFILE -- name of configuration file to use
- +# RFKILLNAME -- name of rfkill device
- diff --git a/bluetooth-rfkill-event/bluetooth_rfkill_event.c b/bluetooth-rfkill-event/bluetooth_rfkill_event.c
- index 290c59e..201b627 100644
- --- a/bluetooth-rfkill-event/bluetooth_rfkill_event.c
- +++ b/bluetooth-rfkill-event/bluetooth_rfkill_event.c
- @@ -75,7 +75,7 @@ enum rfkill_switch_type {
- /* list of all supported chips:
- name is defined in the kernel driver implementing rfkill interface for power */
- -#define BCM_RFKILL_NAME "bcm43xx Bluetooth\n"
- +#define DEFAULT_BCM_RFKILL_NAME "bcm43xx Bluetooth"
- #define BCM_43341_UART_DEV "/dev/ttyMFD0"
- #define BD_ADD_FACTORY_FILE "/factory/bluetooth_address"
- char factory_bd_add[18];
- @@ -130,8 +130,10 @@ char hciattach_options[PATH_MAX];
- char hci_uart_default_dev[PATH_MAX] = BCM_43341_UART_DEV;
- gboolean hci_dev_registered;
- +gboolean patcher_started;
- char *bt_module = NULL;
- char *config_file = DEFAULT_CONFIG_FILE;
- +char *bcm_rfkill_name = DEFAULT_BCM_RFKILL_NAME;
- GHashTable *switch_hash = NULL; /* hash index to metadata about the switch */
- struct main_opts {
- @@ -907,6 +909,7 @@ void free_hci()
- } else {
- INFO("No %s process to be found", hciattach);
- }
- + patcher_started = false;
- }
- void attach_hci()
- @@ -919,8 +922,9 @@ void attach_hci()
- snprintf(hci_execute, sizeof(hci_execute), "%s %s", hciattach, hciattach_options);
- r = system_timeout(hci_execute);
- + patcher_started = WIFEXITED(r) && !WEXITSTATUS(r);
- INFO("executing %s %s", hci_execute,
- - (WIFEXITED(r) && !WEXITSTATUS(r)) ? "succeeded" : "failed");
- + patcher_started ? "succeeded" : "failed");
- if (!WIFEXITED(r) || WEXITSTATUS(r))
- FATAL("Failed to execute %s, exiting", hci_execute);
- @@ -1042,6 +1046,7 @@ static int rfkill_switch_add(struct rfkill_event *event)
- int fd_name = -1;
- int r = -1;
- int type;
- + int len;
- DEBUG("");
- @@ -1065,8 +1070,12 @@ static int rfkill_switch_add(struct rfkill_event *event)
- goto out;
- }
- + len = strlen(sysname);
- + if (sysname[len-1] == '\n')
- + sysname[len-1] = '\0';
- +
- /* based on chip read its config file, if any, and define the hciattach utility used to dowload the patch */
- - if (!strncmp(BCM_RFKILL_NAME, sysname, sizeof(BCM_RFKILL_NAME))) {
- + if (!strncmp(bcm_rfkill_name, sysname, len-1)) {
- read_config(config_file);
- snprintf(hciattach, sizeof(hciattach), patcher_impl[main_opts.patcher].name);
- type = BT_PWR;
- @@ -1112,12 +1121,13 @@ int main(int argc, char **argv)
- { "btmodule", required_argument, NULL, 'b' },
- { "config", required_argument, NULL, 'c' },
- { "debug", no_argument, NULL, 'd' },
- + { "rfkill", required_argument, NULL, 'r' },
- { "stderr", no_argument, NULL, 's' },
- { 0, 0, 0, 0 }
- };
- int c;
- - c = getopt_long(argc, argv, ":b:c:ds", opts, NULL);
- + c = getopt_long(argc, argv, ":b:c:dr:s", opts, NULL);
- if (c == -1)
- break;
- @@ -1133,6 +1143,9 @@ int main(int argc, char **argv)
- case 'd':
- log_debug = 1;
- break;
- + case 'r':
- + bcm_rfkill_name = optarg;
- + break;
- case 's':
- log_stderr = 1;
- break;
- @@ -1148,6 +1161,9 @@ int main(int argc, char **argv)
- random_default_bdaddr();
- DEBUG("Default bdaddr: %s", default_bd_addr);
- + DEBUG("Stop patcher if it's running now");
- + free_hci();
- +
- /* If Bluetooth kernel module is specified, try to unload and
- reload it before starting up. */
- if (bt_module) {
- @@ -1239,8 +1255,8 @@ int main(int argc, char **argv)
- {
- /* if unblock is for power interface: download patch and eventually register hci device */
- INFO("BT power driver unblocked");
- - free_hci();
- - attach_hci();
- + if (!patcher_started)
- + attach_hci();
- /* force to unblock also the bluetooth hci rfkill interface if hci device was registered */
- if (hci_dev_registered)
- rfkill_bluetooth_unblock();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement