pcmcia: dtl1_cs: fix pcmcia_loop_config logic
PATCH 1/1 pcmcia: dtl1_cs: fix pcmcia_loop_config logic
pcmcia_loop_config returns 0 on success.
--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/bluetooth/dtl1_cs.c +1 -1
@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed; i =pcmcia_request_irq (link, &link->irq);
Signature · 1 line
1.5.6.5
Hi,
On Fri, Feb 27, 2009 at 5:54 PM, Philipp Zabel <[email protected]> wr= ote:
Quoted 19 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>---
=A0drivers/bluetooth/dtl1_cs.c | =A0 =A02 +- =A01 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +0
-0@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)=A0 =A0 =A0 =A0/* Look for a generic full-sized window */ =A0 =A0 =A0 =A0link->io.NumPorts1 =3D 8;
- =A0 =A0 =A0 if (!pcmcia_loop_config(link,dtl1_confcheck, NULL))
+ =A0 =A0 =A0 if (pcmcia_loop_config(link, dtl1_confcheck, NULL)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto failed;
Quoted 3 lines
=A0 =A0 =A0 =A0i =3D
pcmcia_request_irq(link, &link->irq); --
1.5.6.5
with this change my Nokia DTL-1 CF card gets detected, but the interface stays down.
# hciconfig hci0 up Can't init device hci0: Connection timed out (110)
I added some printk's to dtl_write and dtl_receive to dump the TX/RX bytes and rx_count (in parentheses):
pcmcia 1.0: pcmcia: registering new device pcmcia1.0dtl1_receive: 80(4) 10(3) 02(2) 00(1) 0f(2) 00(1) <6>
Bluetooth: Nokia control data =3D 0f 00dtl1_write: 81 00 03 00 03 0c 00 00dtl1_interrupt: RLSIdtl1_receive: 00(4)dtl1_receive: 80(3) 10(2) 02(1) 00(528) 0f(527) 00(526)dtl1_receive: 84(525) 00(524) 06(523) 00(522) 0e(521) 04(520) 04(519) 03(51=
8)dtl1_receive: 0c(517) 00(516)dtl1_write: 81 00 03 00 03 0c 00 00dtl1_interrupt: RLSIdtl1_receive: 00(515)dtl1_receive: 80(514) 10(513) 02(512) 00(511) 0f(510) 00(509)dtl1_receive: 84(508) 00(507) 06(506) 00(505) 0e(504) 04(503) 04(502)dtl1_receive: 03(501)dtl1_receive: 0c(500)dtl1_receive: 00(499)
It seems the culprit is the stray zero byte read after the RLSI interrupt causing the 0x80 packet type to be interpreted as length. I can work around this error with the following patch:
drivers/bluetooth/dtl1_cs.c +3 -3
@@ -210,6 +210,7 @@ static void dtl1_receive(dtl1_info_t *info)unsigned int iobase;nsh_t *nsh; int boguscount =3D 0; +__u8 byte;if (!info) {BT_ERR ("Unknown device" );
@@ -230,10 +231,16 @@ static void dtl1_receive(dtl1_info_t *info)return ; } - *skb_put(info->rx_skb, 1) =3D inb(iobase + UART_RX); - nsh =3D (nsh_t *)info->rx_skb->data; + byte =3D inb(iobase + UART_RX); - info->rx_count--; + if ((info->rx_state =3D=3D RECV_WAIT_NSH) &&
(info->rx_count =3D=3D NSHL) && (byte =3D=3D 0)) {
+ continue;
+ } else {
+ *skb_put(info->rx_skb, 1) =3D byte;
+ nsh =3D (nsh_t *)info->rx_skb->data;
+
+ info->rx_count--;
+ }
if (info->rx_count =3D=3D 0) {But I fear this just covers up an error somewhere else. Can this RSLI error and zero byte read be avoided somehow?
regards
Philipp
Marcel Holtmann
maintainerHi Philipp.
Quoted 87 lines
Quoted 21 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +1
-2@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed; i =pcmcia_request_irq (link, &link->irq); --Quoted 1 line
1.5.6.5
with this change my Nokia DTL-1 CF card gets detected, but the interface stays down.
# hciconfig hci0 up Can't init device hci0: Connection timed out (110)I added some printk's to
dtl_writeanddtl_receiveto dump the TX/RX bytes andrx_count(in parentheses):pcmcia 1.0: pcmcia: registering new device pcmcia1.0
dtl1_receive: 80(4) 10(3) 02(2) 00(1) 0f(2) 00(1) <6>
Bluetooth: Nokia control data = 0f 00dtl1_write: 81 00 03 00 03 0c 00 00dtl1_interrupt: RLSIdtl1_receive: 00(4)dtl1_receive: 80(3) 10(2) 02(1) 00(528) 0f(527) 00(526)dtl1_receive: 84(525) 00(524) 06(523) 00(522) 0e(521) 04(520) 04(519) 03(518)dtl1_receive: 0c(517) 00(516)dtl1_write: 81 00 03 00 03 0c 00 00dtl1_interrupt: RLSIdtl1_receive: 00(515)dtl1_receive: 80(514) 10(513) 02(512) 00(511) 0f(510) 00(509)dtl1_receive: 84(508) 00(507) 06(506) 00(505) 0e(504) 04(503) 04(502)dtl1_receive: 03(501)dtl1_receive: 0c(500)dtl1_receive: 00(499)It seems the culprit is the stray zero byte read after the RLSI interrupt causing the
0x80packet type to be interpreted as length. I can work around this error with the following patch:drivers/bluetooth/dtl1_cs.c +10
-3@@ -210,6 +210,7 @@ static void dtl1_receive(dtl1_info_t *info)unsigned int iobase;nsh_t *nsh;int boguscount =0 ; +__u8 byte;if (!info) {BT_ERR ("Unknown device" );@@ -230,10 +231,16 @@ static void dtl1_receive(dtl1_info_t *info)return ; } - *skb_put (info->rx_skb,1 ) =inb (iobase +UART_RX ); - nsh = (nsh_t *)info->rx_skb->data; + byte =inb (iobase +UART_RX ); - info->rx_count--; +if ((info->rx_state ==RECV_WAIT_NSH ) && (info->rx_count ==NSHL ) && (byte ==0 )) { +continue ; + }else { + *skb_put (info->rx_skb,1 ) = byte; + nsh = (nsh_t *)info->rx_skb->data; + + info->rx_count--; + }if (info->rx_count ==0 ) {
Quoted 2 lines
But I fear this just covers up an error somewhere else. Can this RSLI error and zero byte read be avoided somehow?
The dtl1 driver is more reverse engineered than that we really know how this Nokia protocol works. I would have to check with my DTL-1 and DTL-4 cards to see if this a general problem. However that has to wait until April when I can pick them up again.
Regards
Marcel
Wolfram Sang
Acked-byHi,
Quoted 22 lines · pHilipp Zabel
Hi,
Quoted 19 lines · Philipp Zabel
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +1
-1@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed;
Quoted 6 lines
Quoted 3 lines
drivers/bluetooth/dtl1_cs.c +0
-1i =pcmcia_request_irq (link, &link->irq); --1.5.6.5
with this change my Nokia DTL-1 CF card gets detected, but the interface stays down.
I am reviewing patches which came through the pcmcia-list since the last upstream commit last year.
IMHO the above patch could be queued, even though there seem to be further issues with the driver. What do you think?
So, for the above patch:
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Hi Wolfram,
Quoted 30 lines
Quoted 20 lines · Philipp Zabel
Quoted 19 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +1
-1@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed;Quoted 6 lines
Quoted 3 lines
drivers/bluetooth/dtl1_cs.c +0
-1i =pcmcia_request_irq (link, &link->irq); --1.5.6.5
with this change my Nokia DTL-1 CF card gets detected, but the interface stays down.
I am reviewing patches which came through the pcmcia-list since the last upstream commit last year.
Quoted 6 lines
IMHO the above patch could be queued, even though there seem to be further issues with the driver. What do you think?
So, for the above patch:
Acked-by Wolfram Sang <[email protected]>
can we change it into if (pcmcia_loop_config(...) < 0) to it perfectly clear here.
Regards
Marcel
Quoted 34 lines
Quoted 34 lines
Quoted 21 lines · Philipp Zabel
Quoted 19 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +1
-1@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed;Quoted 6 lines
Quoted 3 lines
drivers/bluetooth/dtl1_cs.c +0
-1i =pcmcia_request_irq (link, &link->irq); --1.5.6.5
with this change my Nokia DTL-1 CF card gets detected, but the interface stays down.
I am reviewing patches which came through the pcmcia-list since the last upstream commit last year.
IMHO the above patch could be queued, even though there seem to be further issues with the driver. What do you think?
Quoted 6 lines
Quoted 3 lines
So, for the above patch:
Acked-by Wolfram Sang <[email protected]>can we change it into if (
pcmcia_loop_config(...)< 0) to it perfectly clear here.
Yup, I'd like that better, too.
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Marcel Holtmann
maintainerHi Philipp,
Quoted 12 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>--- drivers/bluetooth/dtl1_cs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +0
-0
drivers/bluetooth/dtl1_cs.c static int dtl1_config(struct pcmcia_device *link) · line 622
Quoted 8 lines
drivers/bluetooth/dtl1_cs.c +1
-1@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)/* Look for a generic full-sized window */ link->io.NumPorts1 =8 ; -if (!pcmcia_loop_config (link, dtl1_confcheck,NULL )) +if (pcmcia_loop_config (link, dtl1_confcheck,NULL )) goto failed; i =pcmcia_request_irq (link, &link->irq);
can you check the other Bluetooth PCMCIA drivers, too. One of the PCMCIA subsystem changes might have screwed this up and affects more drivers than expected.
Regards
Marcel
Hi Marcel,
On Sat, Feb 28, 2009 at 10:35 PM, Marcel Holtmann <[email protected]> wro= te:
Quoted 21 lines
Hi Philipp,
Quoted 19 lines
pcmcia_loop_configreturns 0 on success.Signed-off-by Philipp Zabel <[email protected]>---
=A0drivers/bluetooth/dtl1_cs.c | =A0 =A02 +- =A01 files changed, 1 insertions(+), 1 deletions(-)drivers/bluetooth/dtl1_cs.c +0
-0@@ -616,7 +616,7 @@ static int dtl1_config(struct pcmcia_device *link)=A0 =A0 =A0 /* Look for a generic full-sized window */ =A0 =A0 =A0
link->io.NumPorts1=3D 8;
- =A0 =A0 if (!pcmcia_loop_config(link,dtl1_confcheck, NULL))
+ =A0 =A0 if (pcmcia_loop_config(link, dtl1_confcheck, NULL)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto failed;
Quoted 3 lines
Quoted 1 line
=A0 =A0 =A0 i =3D
pcmcia_request_irq(link, &link->irq);can you check the other Bluetooth PCMCIA drivers, too.
bluecard_cs doesn't use pcmcia_loop_config. bt3c_cs and btuart_cs both have something like
if (!pcmcia_loop_config(...)) goto found_port;
instead, which looks fine.
Quoted 3 lines
One of the PCMCIA
subsystem changes might have screwed this up and affects more drivers than expected.
"pcmcia: use pcmcia_loop_config in bluetooth drivers" (ed58872aa33e16a0d5352080e47c65fa14e6ad1c) only touched bt3_cs, btuart_cs and dtl1_cs.
regards
Philipp