kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Lucas Tanure <tanure@linux.com>
Cc: kernelnewbies <Kernelnewbies@kernelnewbies.org>
Subject: Re: USB Hid driver Help
Date: Mon, 3 Feb 2020 20:11:02 +0000	[thread overview]
Message-ID: <20200203201102.GA3888053@kroah.com> (raw)
In-Reply-To: <CAJX_Q+0rqonAGxtpt9uzQBK5bABcHb56tpqtj76r5QxyOBLPFg@mail.gmail.com>

On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote:
> Hi,
> 
> I'm trying to write a Hid driver for MCP2210.

What type of device is this?

> But the USB Hid specification is quite complicated.

The kernel should do it "all for you" already, why do you need to create
a custom HID driver for this device?

What type of HID reports does the device export and why doesn't the
existing kernel drivers work for you?

> I would like to know how to send and receive data to the device. Any
> links to a good tutorial ?

HID has the idea of "reports" and data comes in and out in that specific
format, all depending on how the device describes itself.  There's isn't
usually a normal "send/receive" type of thing, but it all depends on the
type of device.

> This is my current driver is attached.
> 
> Thanks
> Lucas

> #define DEBUG
> #include <linux/module.h>
> #include <linux/hid.h>
> #include <linux/usb.h>
> 
> static int mcp2210_probe(struct hid_device *hdev,
> 			 const struct hid_device_id *id)
> {
> 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> 	int ret = 0;
> 
> 	hid_dbg(hdev, "%s\n", __FUNCTION__);
> 
> 	ret = hid_parse(hdev);
> 	if (ret) {
> 		hid_err(hdev, "parse failed\n");
> 		return ret;
> 	} else {
> 		hid_dbg(hdev, "parse success\n");
> 	}
> 
> 	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> 	if (ret) {
> 		hid_err(hdev, "hw start failed\n");
> 		return ret;
> 	} else {
> 		hid_dbg(hdev, "start success\n");
> 	}

Does this all work?

What fails?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2020-02-03 20:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 23:12 Introduction & Query on Newbie Website Status Jack Winch
2020-02-01 12:20 ` Cindy Sue Causey
2020-02-02 23:26 ` Anuz Pratap Singh Tomar
2020-02-03  0:36   ` Rik van Riel
2020-02-03 16:32     ` USB Hid driver Help Lucas Tanure
2020-02-03 20:11       ` Greg KH [this message]
2020-02-03 22:00         ` Lucas Tanure
2020-02-04 13:27           ` Lucas Tanure
2020-02-04 18:15             ` Lucas Tanure
2020-02-03 19:49     ` Introduction & Query on Newbie Website Status Jack Winch
2020-02-03 20:10       ` Rik van Riel
2020-02-05 15:46         ` Jack Winch

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=20200203201102.GA3888053@kroah.com \
    --to=greg@kroah.com \
    --cc=Kernelnewbies@kernelnewbies.org \
    --cc=tanure@linux.com \
    /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).