linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: linux-usb@vger.kernel.org
Cc: benjamin.tissoires@redhat.com
Subject: Driver for something that's neither a device nor an interface driver?
Date: Fri, 27 Sep 2019 19:29:52 +0200	[thread overview]
Message-ID: <5e53febe013938d7b878de46a5ef9f18587bd4db.camel@hadess.net> (raw)

Hey,

I'm trying to write a "power supply" class driver for Apple MFi
devices, and struggling a little with the USB drivers.

To ask many Apple devices to draw more power, we need to make a call to
the device using a vendor command. It doesn't go to an interface, but
to the device itself.

The call done in the kernel would look something like:
usb_control_msg(mfi->udev, usb_sndctrlpipe(mfi->udev, 0), 
                0x40, /* Vendor-defined USB get enabled capabilities request. */
                USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
                current_ma, /* wValue, current offset */
                current_ma, /* wIndex, current offset */
                NULL, 0, USB_CTRL_GET_TIMEOUT);

But I can't figure out what type of driver I'd need to just be able to
export that power_supply interface.

Trying to use a "struct usb_device_driver" didn't work as probe
functions were never called, and a "struct usb_driver" gets unbound
after user-space and the ipheth drivers comes around.

This is my "struct usb_driver" attempt:
https://github.com/hadess/apple-mfi-fastcharge

Any ideas what type of driver, or what trick I should be using here?

Cheers


             reply	other threads:[~2019-09-27 17:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 17:29 Bastien Nocera [this message]
2019-09-27 17:38 ` Driver for something that's neither a device nor an interface driver? Greg KH
2019-09-27 17:44   ` Bastien Nocera
2019-09-27 18:57     ` Greg KH
2019-09-27 19:08       ` Bastien Nocera
2019-09-27 17:56 ` Alan Stern
2019-09-27 18:49   ` Bastien Nocera
2019-09-27 19:25     ` Greg KH
2019-09-27 20:12       ` Bastien Nocera
2019-09-28  7:39         ` Greg KH
2019-09-28 10:42           ` Bastien Nocera
2019-09-28 12:18             ` Greg KH
2019-09-28 12:37               ` Bastien Nocera
2019-09-28 12:57                 ` Greg KH
2019-09-27 20:21     ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e53febe013938d7b878de46a5ef9f18587bd4db.camel@hadess.net \
    --to=hadess@hadess.net \
    --cc=benjamin.tissoires@redhat.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).