All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: failing to force-claim USB interface
@ 2004-01-19 18:04 David Brownell
  0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2004-01-19 18:04 UTC (permalink / raw)
  To: Martin F Krafft; +Cc: linux-kernel

> I am trying to make use of the usbfs USBDEVFS_DISCONNECT ioctl, and
> I am failing.

Appended, see a snippet of code which worked reliably way back on
the original 2.4 patch.  Maybe you tripped on the precondition?
Or maybe this is just broken so far in 2.6.

A fair amount of usbfs code is at least slightly broken in 2.6;
some usbcore driver model changes are still needed in the area
of this particular ioctl.  (Which got mangled more than most
during its evolution.)  Was this with a 2.6.1 kernel?

I'm thinking this kind of thing ought to be generically doable
with sysfs, maybe with symlink/unlink syscalls between device
and driver nodes.

- Dave


     if (ioctl (fd, USBDEVFS_CLAIMINTERFACE, &ifno) < 0) {
#ifdef  USBDEVFS_DISCONNECT
         int                             saved_errno = errno;
         struct usbdevfs_ioctl           command;
         int                             retval;

         /*
          * maybe we need to boot a kernel driver off before we
          * can bind to this.  a "polite" unbind might be nice;
          * for now we expect apps to adopt a reasonble policy,
          * checking if it's claimed already (when it matters).
          */
         if (saved_errno != EBUSY)
             return -errno;
         command.ifno = ifno;
         command.ioctl_code = USBDEVFS_DISCONNECT;
         command.data = 0;
         retval = ioctl (fd, USBDEVFS_IOCTL, &command);
         if (retval < 0)
             return -saved_errno;

         if (ioctl (fd, USBDEVFS_CLAIMINTERFACE, &ifno) < 0)
             return -errno;
#else
         return -errno;
#endif
     }
     return 0;




^ permalink raw reply	[flat|nested] 2+ messages in thread

* failing to force-claim USB interface
@ 2004-01-19 15:46 Martin F Krafft
  0 siblings, 0 replies; 2+ messages in thread
From: Martin F Krafft @ 2004-01-19 15:46 UTC (permalink / raw)
  To: linux kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

I am trying to make use of the usbfs USBDEVFS_DISCONNECT ioctl, and
I am failing. Here is the code:

  struct usb_device *dev;
  [...]
  sprintf(path, "/proc/bus/usb/%s/%s", dev->bus->dirname, dev->filename);
  int fd = open(path);
  struct usbdevfs_ioctl command = { 0, USBDEVFS_DISCONNECT, 0 };
  ioctl (fd, USBDEVFS_IOCTL, &command) < 0

However, the ioctl always fails. I am not sure whether I am using
the right values for the file descriptor passed to ioctl(), or what
the interface number (first parameter of usbdevfs_ioctl) is.

Maybe someone could offer me some advice or tell me to RTFM (but
please specify TM to FR).

Thanks,

-- 
Martin F. Krafft                Artificial Intelligence Laboratory
Ph.D. Student                   Department of Information Technology
Email: krafft@ailab.ch          University of Zurich
Tel: +41.(0)1.63-54323          Andreasstrasse 15, Office 2.20
http://ailab.ch/people/krafft   CH-8050 Zurich, Switzerland
 
Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver!
 
click the start menu and select 'shut down.'

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-19 17:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 18:04 failing to force-claim USB interface David Brownell
  -- strict thread matches above, loose matches on Subject: below --
2004-01-19 15:46 Martin F Krafft

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.