Re: USB-skeleton kref query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 22, 2006 at 06:07:03PM +0530, Mukund JB. wrote:
> Dear Linux Team,
> 
> I am trying to understand the USB Architecture and write my own client
> driver under Linux and some mew concepts of 2.6.x.

What kind of "client driver"?

> My point of about kref 
> ----------------------
> Used when the multiple threads are involved within the driver.
> I am not sure whether this can be when there are no thread within the
> driver and to control the Process synchronization. Can I get some
> clarity on this?

Have you read the kref documentation that is in the kernel tree:
	Documentation/kref.txt

That should explain how they should be used.

> Main Question
> -------------
> I have seen that kref_init () is issues in probe.	// no issue with
> this
> 
> Device memory allocation and Kref_get() call are issued in open context.
> Fine.ok.
> 
> In that case kref_put should be called in close context or any error
> context. Right?
> Yes, I find these two being issued in the usb-skeleton driver.
> 
> But, I find additional kref_put() call in disconnect? That too without
> any condition checking? Why do I need it here?

Because the disconnect call to kref_put() matches the call to
kref_init() in probe.  If you don't do this, you will leak memory.

Also, have you read the Linux USB documentation?  It's automatically
built for you when you run:
	make psdocs
or
	make pdfdocs
and will be in the Documentation/DocBook/usb.* file


Hope this helps,

greg k-h

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux