public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Yu <raise.sail@gmail.com>
To: Dmitry Torokhov <dtor@insightbb.com>
Cc: Li Yu <raise.sail@gmail.com>,
	yanghong@ccoss.com.cn,
	linux-usb-devel <linux-usb-devel@lists.sourceforge.net>,
	hongzhiyi@ccoss.com.cn, Jiri Kosina <jkosina@suse.cz>,
	Marcel Holtmann <marcel@holtmann.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [linux-usb-devel] [RFC] HID bus design overview.
Date: Thu, 05 Apr 2007 13:28:46 +0800	[thread overview]
Message-ID: <4614890E.4030908@gmail.com> (raw)
In-Reply-To: <200704042309.19344.dtor@insightbb.com>

Dmitry Torokhov wrote:
>> +static int hid_bus_match(struct device *dev, struct device_driver
>> *drv) +{
>> +	struct hid_driver *hid_drv;
>> +	struct hid_device *hid_dev;
>> +
>> +	hid_drv = to_hid_driver(drv);
>> +	hid_dev = to_hid_device(dev);
>> +
>> +	if (is_hid_driver_sticky(hid_drv))
>> +		/* the sticky driver match device do not pass here. */
>> +		return 0;
>> +	if (hid_dev->bus != hid_drv->bus)
>> +		return 0;
>>     
>
> How can this happen?
>
>   
Our HID driver just are some logical drivers, they are not attach some
physical devices directly. However, The HID core may include more than
one physical bus devices, I think HID drivers only take care of these
devices at one physical bus. So, compare here can avoid call 
hid_drv->match() across bus.
>> +	if (!hid_drv->match || hid_drv->match(hid_drv, hid_dev)) {
>> +		hid_dev->driver = hid_drv;
>>     
>
> This usually done in bus->probe() function, when we know for sure that
> driver binds to to the device.
>
>   
Yes, this may have a bit of hack, but this make hid_drv->probe() more
easier. And, as you seen, the hid_drv_probe() will check the actual
probe process is whether OK. If not so, the hid_drv_probe() will clean
this member.
>> +static void hid_bus_release(struct device *dev)
>> +{
>> +}
>> +
>> +struct device hid_bus = {
>> +	.bus_id   = "hidbus0",
>> +	.release  = hid_bus_release
>> +};
>> +
>> +static void hid_dev_release(struct device *dev)
>> +{
>> +}
>> +
>>     
>
> That will for sure raise Greg KH's blood pressure ;)
>
>   
Er, if not so, we will get some dump stack information in dmesg when
remove this module ......
>> +	for (i=0; hid_dev->attrs && hid_dev->attrs[i]; ++i) {
>> +		ret = device_create_file(&hid_dev->device, hid_dev->attrs[i]);
>> +		if (ret)
>> +			break;
>> +
>>     
>
> That should be handled via bus's device attributes and not open coded...
>
>   
I agree, this is another TODO.
>> - *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
>> - *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
>> + *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@@suse.cz>
>> + *  Copyright (c) 2005 Michael Haboustak <mike-@@cinci.rr.com> for Concept2, Inc
>>   *  Copyright (c) 2006 Jiri  Kosina
>>     
>
> Any particular reason for mangling addresses?
>
>   
I also want to who changed them! ~_~

>> +	if (interrupt)
>> +		local_irq_save(flags);
>> +	spin_lock(&hid_lock);
>> +	list_for_each_entry(driver, &hid_sticky_drivers, sticky_link) {
>> +		hook = driver->hook;
>> +		if (hook && hook->raw_event) {
>> +			ret = hook->raw_event(hid, type, data, size, interrupt);
>> +			if (!ret)
>> +				break;
>> +		}
>> +	}
>> +	spin_unlock(&hid_lock);
>> +	if (interrupt)
>> +		local_irq_restore(flags);
>> +
>>     
>
> This is scary. spin_lock_irqsave() and be done with it.
>
>   
May be, I really do not want to increase interrupt disabling time in our
action.

>> +int hid_open(struct hid_device *hid)
>> +{
>> +	struct hid_transport *tl;
>> +	int ret;
>> +
>> +	if (hid->driver->open)
>> +		return hid->driver->open(hid);
>> +	ret = 0;
>> +	spin_lock(&hid_lock);
>> +	tl =  hid_transports[hid->bus];
>> +	if (tl->open)
>> +		ret = tl->open(hid);
>> +	spin_unlock(&hid_lock);
>> +	return ret;
>> +}
>>     
>
> Spinlock is not the best choise here, I'd expect most ->open()
> implementation wait on some IO.
>
>   
Yes, I agree! Also, there have another code access hid_transports[]
without spin it!

  reply	other threads:[~2007-04-05  5:30 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-05  7:32 [DOC] The documentation for HID Simple Driver Interface 0.5.0 Li Yu
2007-03-05 20:44 ` Marcel Holtmann
2007-03-05 20:11   ` Dmitry Torokhov
2007-03-05 22:40     ` Marcel Holtmann
2007-03-06 13:25       ` Dmitry Torokhov
2007-03-06 13:47       ` Jiri Kosina
2007-03-06 18:57         ` Marcel Holtmann
2007-03-05 21:47   ` Jiri Kosina
2007-03-05 22:12 ` [linux-usb-devel] " Jiri Kosina
2007-03-05 22:27   ` Dmitry Torokhov
2007-03-06  1:37     ` Liyu
     [not found]     ` <45ECC5A4.20203@ccoss.com.cn>
2007-03-06  9:40       ` Jiri Kosina
2007-03-06 11:52       ` Harold Sargeant
2007-03-06  7:01   ` Robert Marquardt
2007-03-06  7:37     ` Jiri Kosina
2007-03-19 10:44 ` [RFC] HID bus design overview Li Yu
2007-03-26  8:27   ` [linux-usb-devel] " Marcel Holtmann
2007-03-28  1:58     ` Li Yu
     [not found]     ` <4609CAF2.3040303@ccoss.com.cn>
2007-03-28  7:51       ` Jiri Kosina
2007-03-28 19:00         ` Dmitry Torokhov
2007-03-28 19:13           ` Jiri Kosina
2007-03-30  3:06           ` Li Yu
2007-03-30  4:33             ` Dmitry Torokhov
2007-03-30  5:37               ` Li Yu
2007-03-30 16:13                 ` Dmitry Torokhov
2007-03-31 22:49               ` Jiri Kosina
2007-04-02  1:47                 ` Li Yu
2007-04-02  4:15                   ` Dmitry Torokhov
2007-04-02  7:07                     ` Li Yu
2007-04-02  7:42                       ` Greg KH
2007-04-02  9:34                       ` Jiri Kosina
2007-04-02 12:40                         ` Dmitry Torokhov
2007-04-02  4:09                 ` Dmitry Torokhov
2007-04-02  9:37                   ` Jiri Kosina
2007-04-02 10:14                     ` Robert Marquardt
2007-04-02 12:21           ` Marcel Holtmann
2007-04-02 12:33             ` Jiri Kosina
2007-04-02 16:47               ` Marcel Holtmann
2007-04-03  1:15                 ` Li Yu
2007-04-03  3:42                   ` Dmitry Torokhov
2007-04-03  8:57                   ` Jiri Kosina
2007-04-04  0:55                     ` Li Yu
2007-04-04 14:54                     ` Marcel Holtmann
2007-04-04 23:01                     ` Adam Kropelin
2007-04-04 23:12                       ` Jiri Kosina
2007-04-04 23:34                         ` Adam Kropelin
2007-04-05  8:36                           ` Jiri Kosina
2007-04-05 14:08                             ` Adam Kropelin
     [not found]                           ` <46189FE3.6050206@gmail.com>
2007-04-09  1:54                             ` [linux-usb-devel] HID bus prototype - 20070408 Li Yu
2007-04-10  9:40                             ` Jiri Kosina
2007-04-10 11:00                               ` [linux-usb-devel] " Li Yu
2007-04-05  1:25                     ` [linux-usb-devel] [RFC] HID bus design overview Li Yu
2007-04-05  3:09                       ` Dmitry Torokhov
2007-04-05  5:28                         ` Li Yu [this message]
2007-04-05  6:47                           ` Li Yu
2007-04-06  0:58                         ` Li Yu
2007-03-29  5:37         ` Li Yu
2007-03-29  9:24           ` Jiri Kosina
2007-04-02 12:19           ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2007-04-02 11:57 Nicolas Mailhot
2007-04-03  1:40 ` Li Yu
2007-04-03  3:41   ` Dmitry Torokhov
2007-04-03  9:00   ` Jiri Kosina
2007-04-05 18:10     ` Paul Walmsley

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=4614890E.4030908@gmail.com \
    --to=raise.sail@gmail.com \
    --cc=dtor@insightbb.com \
    --cc=hongzhiyi@ccoss.com.cn \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=marcel@holtmann.org \
    --cc=yanghong@ccoss.com.cn \
    /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