kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Tanure <tanure@linux.com>
To: kernelnewbies <Kernelnewbies@kernelnewbies.org>
Subject: USB Hid driver Help
Date: Mon, 3 Feb 2020 16:32:46 +0000	[thread overview]
Message-ID: <CAJX_Q+0rqonAGxtpt9uzQBK5bABcHb56tpqtj76r5QxyOBLPFg@mail.gmail.com> (raw)
In-Reply-To: <9c5082fe870a01cac0b1a7861c0c5a74e794963f.camel@surriel.com>

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

Hi,

I'm trying to write a Hid driver for MCP2210. But the USB Hid
specification is quite complicated.
I would like to know how to send and receive data to the device. Any
links to a good tutorial ?
This is my current driver is attached.

Thanks
Lucas

[-- Attachment #2: mcp2210.c --]
[-- Type: text/x-csrc, Size: 1058 bytes --]

#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");
	}

	return 0;
}

static const struct hid_device_id mcp2210_table[] = {
	{ HID_USB_DEVICE(0x04d8, 0x00de) },
	{}
};

MODULE_DEVICE_TABLE(hid, mcp2210_table);

static struct hid_driver mcp2210_driver = {
	.name = "MCP2210 USB SPI Driver",
	.probe = mcp2210_probe,
	.id_table = mcp2210_table,
};

module_hid_driver(mcp2210_driver);

MODULE_AUTHOR("Lucas Tanure <tanure@linux.com>");
MODULE_DESCRIPTION("Core driver for MCP2210 USB SPI adapter");
MODULE_LICENSE("GPL v2");

[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

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

  reply	other threads:[~2020-02-03 17:01 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     ` Lucas Tanure [this message]
2020-02-03 20:11       ` USB Hid driver Help Greg KH
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=CAJX_Q+0rqonAGxtpt9uzQBK5bABcHb56tpqtj76r5QxyOBLPFg@mail.gmail.com \
    --to=tanure@linux.com \
    --cc=Kernelnewbies@kernelnewbies.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).