Kernel Newbies archive on lore.kernel.org
 help / color / 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
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 index

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 publically 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

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git