[PATCH] Error in ATM_PHY_SIG_* logic on speedtch.c?

Aurelio Arroyo listas_sk3 at yahoo.es
Fri Jun 17 07:32:57 EDT 2005


El mié, 15-06-2005 a las 10:43 +0200, Duncan Sands escribió:
> Hi Aurelio,
> 
> > Now speedtch.c use this:
> >     0x00 => ATM_PHY_SIG_LOST
> >     0x08 => ATM_PHY_SIG_UNKNOWN
> >     0x10 => ATM_PHY_SIG_LOST
> >     0x20 => ATM_PHY_SIG_FOUND
> > 
> > But at 0x10 you don't lost the sync...
> > 
> > And if you get  0x00, 0x08, 0x10, 0x00 you lost the state change
and  
> > speedtch_start_synchro isn't it call.
> > 
> > I use this logic too at amedyn.c so I have to change it too.
> > 
> > Store and check last modem state?
> 
> another possibility would be to use ATM_PHY_SIG_UNKNOWN for the 0x10
> case.  But I reckon you are right: the best solution would be to store
and
> compare with the last state.  Want to code it up?

I remove the IF for state 0x00 too. I think is better send it two times
than never. In a slow and busy computer and/or whit a bad telephone line
sync can failed before poll status again.

I initialize last_state to 0xff.

I hope all are ok...

Index: speedtch.c
===================================================================
RCS file: /home/cvs/usbatm/speedtch.c,v
retrieving revision 1.59
diff -U3 -r1.59 speedtch.c
--- speedtch.c	11 Jun 2005 12:58:00 -0000	1.59
+++ speedtch.c	15 Jun 2005 17:27:42 -0000
@@ -99,6 +99,8 @@
 	struct usbatm_data *usbatm;
 
 	struct work_struct status_checker;
+	
+	unsigned char last_status;
 
 	int poll_delay; /* milliseconds */
 
@@ -442,30 +444,28 @@
 
 	switch (buf[OFFSET_7]) {
 	case 0:
-		if (atm_dev->signal != ATM_PHY_SIG_LOST) {
-			atm_dev->signal = ATM_PHY_SIG_LOST;
-			atm_info(usbatm, "ADSL line is down\n");
-			/* It'll never resync again unless we ask it to... */
-			ret = speedtch_start_synchro(instance);
-		}
+		atm_dev->signal = ATM_PHY_SIG_LOST;
+		atm_info(usbatm, "ADSL line is down\n");
+		/* It'll never resync again unless we ask it to... */
+		ret = speedtch_start_synchro(instance);
 		break;
 
 	case 0x08:
-		if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+		if (buf[OFFSET_7] != instance->last_status) {
 			atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
 			atm_info(usbatm, "ADSL line is blocked?\n");
 		}
 		break;
 
 	case 0x10:
-		if (atm_dev->signal != ATM_PHY_SIG_LOST) {
-			atm_dev->signal = ATM_PHY_SIG_LOST;
+		if (buf[OFFSET_7] != instance->last_status) {
+			atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
 			atm_info(usbatm, "ADSL line is synchronising\n");
 		}
 		break;
 
 	case 0x20:
-		if (atm_dev->signal != ATM_PHY_SIG_FOUND) {
+		if (buf[OFFSET_7] != instance->last_status) {
 			int down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
 				| (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24);
 			int up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
@@ -486,12 +486,13 @@
 		break;
 
 	default:
-		if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+		if (buf[OFFSET_7] != instance->last_status) {
 			atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
 			atm_info(usbatm, "Unknown line state %02x\n", buf[OFFSET_7]);
 		}
 		break;
 	}
+	instance->last_status = buf[OFFSET_7];
 }
 
 static void speedtch_status_poll(unsigned long data)
@@ -731,6 +732,7 @@
 	instance->status_checker.timer.function = speedtch_status_poll;
 	instance->status_checker.timer.data = (unsigned long)instance;
 	instance->poll_delay = MIN_POLL_DELAY;
+	instance->last_status = 0xff;
 
 	init_timer(&instance->resubmit_timer);
 	instance->resubmit_timer.function = speedtch_resubmit_int;



		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es




More information about the Usbatm mailing list