HCI USB driver update. Support for SCO over HCI U SB.

HCI USB driver update. Support for SCO over HCI U SB.

Post by Perez-Gonzalez, Inak » Thu, 08 May 2003 07:10:07




> +int usb_init_urb(struct urb *urb)
> +{
> +  if (!urb)
> +          return -EINVAL;
> ...
> ...
> ...

>            mem_flags);
>    if (!urb) {
>            err("alloc_urb: kmalloc failed");
> -          return NULL;
> +          goto exit;
> +  }
> +  if (usb_init_urb(urb)) {
> +          kfree(urb);
> +          urb = NULL;
>    }

If usb_init_urb() is already testing for !urb, why
test it again? No doubt the compiler will probably
catch it if inlining ... but I think the best is
for usb_init_urb() to assume that urb is not NULL.
Let the caller make that sure.

Sorry if this is a dup ... I am catching up with
my mail ...

I?aky Prez-Gonzlez -- Not speaking for Intel -- all opinions are my own
(and my fault)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

HCI USB driver update. Support for SCO over HCI U SB.

Post by Greg K » Thu, 08 May 2003 07:50:06




> > +int usb_init_urb(struct urb *urb)
> > +{
> > +     if (!urb)
> > +             return -EINVAL;
> > ...
> > ...
> > ...

> >               mem_flags);
> >       if (!urb) {
> >               err("alloc_urb: kmalloc failed");
> > -             return NULL;
> > +             goto exit;
> > +     }
> > +     if (usb_init_urb(urb)) {
> > +             kfree(urb);
> > +             urb = NULL;
> >       }

> If usb_init_urb() is already testing for !urb, why
> test it again? No doubt the compiler will probably
> catch it if inlining ... but I think the best is
> for usb_init_urb() to assume that urb is not NULL.
> Let the caller make that sure.

Because people other than usb_alloc_urb() can call usb_init_urb().
Yeah, I can remove the check, then any invalid caller will oops on the
first line of usb_init_urb().  I don't mind, was just trying to program
a bit more defensibly.  You know, make it a "hardened driver"  :)

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

HCI USB driver update. Support for SCO over HCI U SB.

Post by Perez-Gonzalez, Inak » Thu, 08 May 2003 08:00:07



> > If usb_init_urb() is already testing for !urb, why
> > test it again? No doubt the compiler will probably
> > catch it if inlining ... but I think the best is
> > for usb_init_urb() to assume that urb is not NULL.
> > Let the caller make that sure.

> Because people other than usb_alloc_urb() can call usb_init_urb().
> Yeah, I can remove the check, then any invalid caller will oops on the

Just documenting it should do :]

Quote:> first line of usb_init_urb().  I don't mind, was just trying to program
> a bit more defensibly.  You know, make it a "hardened driver"  :)

Stab right in the heart :] I think we all agree we prefer "hardened
coders".

I?aky Prez-Gonzlez -- Not speaking for Intel -- all opinions are my own
(and my fault)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. HCI USB driver update. Support for SCO over HCI USB.


Max, you need to be very careful with this:

You aren't calling usb_alloc_urb() and:

You aren't calling usb_free_urb() as you are embedding a struct urb
within your struct _urb structure.  Any reason you can't use a struct
urb * instead and call the usb core's functions to create and return a
urb?

Otherwise any changes to the internal urb structures, and the
usb_alloc_urb() and usb_free_urb() functions will have to be mirrored
here in your functions, and I know I will forget to do that :)

Other than that, it's nice to see Bluetooth SCO support for Linux, very
nice job.

thaks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Need Quick Linux Lesson

3. 2.4.19 Bluetooth [4/5] HCI USB driver update

4. SIMPLE MODE BOOT WITH DISK FULL

5. linux-2.5.8-pre1/drivers/usb/uhci.o locks up hard

6. nvidia 420-D and linux ok?

7. More Bluetooth 2.5.x HCI, L2CAP and RFCOMM updates.

8. Morningstar PPP on SCO w/ Worldnet

9. difference between Sun StarOffice and MS Word's HCI design.

10. What kernel does HCI Linux use?

11. PATCH: update emu10k1 driver (SB Live, Audigy etc)

12. SB PCI128 and SB Live! Value support

13. SB Live driver does SB Live Value?