|
From: Peter K. <pk...@us...> - 2001-03-27 19:32:30
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.154 1.155=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.93 1.94=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Improved LED blink.
The diff of the modified file(s):
--- bluetooth.c 2001/03/20 15:29:49 1.154
+++ bluetooth.c 2001/03/27 19:32:27 1.155
@@ -162,11 +162,18 @@
=20
#ifdef __CRIS__
#define BT_FLASH_LED_TIME (HZ/50) /* 20 ms */
+#define BT_FLASH_LED_PAUSE (HZ/100) /* 10 ms */
+
+#define NO_BLUETOOTH_ACTIVITY 0
+#define BLUETOOTH_ACTIVITY 1
=20
static struct timer_list bt_clear_led_timer;
-static int bt_led_clear_time;
+static int bt_led_next_time;
+static int bt_led_active;
static void bt_clear_led(unsigned long dummy);
+static void bt_set_leds(int active);
#endif
+
static void bt_flash_led(void);
=20
#ifdef CONFIG_BLUETOOTH_USE_INBUFFER
@@ -1835,20 +1842,48 @@
static void
bt_clear_led(unsigned long dummy)
{
- if (jiffies > bt_led_clear_time)
- LED_ACTIVE_SET(0);
+ if (bt_led_active && jiffies > bt_led_next_time) {
+ bt_set_leds(NO_BLUETOOTH_ACTIVITY);
+
+ /* Set the earliest time we may set the LED */
+ bt_led_next_time =3D jiffies + BT_FLASH_LED_PAUSE;
+ bt_led_active =3D 0;
+ }
+
bt_clear_led_timer.expires =3D jiffies + HZ/10;
add_timer(&bt_clear_led_timer);
}
=20
-void bt_flash_led(void)
+static void
+bt_flash_led(void)
{
- LED_ACTIVE_SET(1);
- bt_led_clear_time =3D jiffies + BT_FLASH_LED_TIME;=20
+ if (!bt_led_active && jiffies > bt_led_next_time) {
+ bt_set_leds(BLUETOOTH_ACTIVITY);
+
+ /* Set the earliest time we may clear the LED */
+ bt_led_next_time =3D jiffies + BT_FLASH_LED_TIME;
+ bt_led_active =3D 1;
+ }
+}
+
+static void
+bt_set_leds(int active)
+{
+ extern int bt_connections;
+ int light_leds =3D ((!bt_connections && active =3D=3D BLUETOOTH_ACTIVITY)=
||
+ (bt_connections && active =3D=3D NO_BLUETOOTH_ACTIVITY));
+
+ if (light_leds) {
+ LED_ACTIVE_SET(LED_GREEN);
+ }
+ else {
+ LED_ACTIVE_SET(LED_OFF);
+ }
}
=20
#else
-void bt_flash_led(void)
+static void
+bt_flash_led(void)
{
/* blink blink :) */
}
--- l2cap.c 2001/03/12 16:09:37 1.93
+++ l2cap.c 2001/03/27 19:32:28 1.94
@@ -253,6 +253,10 @@
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
+#ifdef __CRIS__
+int bt_connections =3D 0;
+#endif
+
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
static l2cap_layer l2capmain; /* Main structure */
@@ -275,6 +279,10 @@
init_con_list();
l2cap->cid_count =3D MIN_CID; /* Moved from init_con_list */
=20=20=20=20=20=20=20=20=20
+#ifdef __CRIS__
+ bt_connections =3D 0;
+#endif
+
/* Set all upper layers to default */
=20
l2cap_protocol_default(&default_protocol);
@@ -361,6 +369,11 @@
=20
free_list();
remove_all_upper();
+
+#ifdef __CRIS__
+ bt_connections =3D 0;
+#endif
+
/*ALWAYS SUCCESS*/
return 0;
}
@@ -1315,6 +1328,10 @@
con->hci_hdl =3D con_hdl;
con->link_up =3D TRUE;
=20
+#ifdef __CRIS__
+ bt_connections++;
+#endif
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
/* Check if a ping is to be sent */
if (con->ping_sent) {
D_STATE("baseband up, now send ping\n");
@@ -1427,7 +1444,13 @@
/* flush old buffers waiting to be sent on this handle */
btmem_flushhandle((u16)con_hdl);
//btmem_reset();
- return;
+
+#ifdef __CRIS__
+ if (bt_connections > 0)
+ bt_connections--;
+ else
+ D_ERR(__FUNCTION__ ": bt_connections =3D=3D 0\n");
+#endif
}
=20
/* FIXME - lp_qos_violation_ind() */
|