How to Write a Linux USB Device Driver

Greg shares his USB driver skeleton and shows how it can be customized for your specific device.
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Not Necessarily a Good Thing

Anonymous's picture

"His free software is being used by more people than any closed-source projects he has ever been paid to develop."

No disrespect to Greg, but that's not necessarily a good tagline to go by. My first reading of that implied that his code is so bad he had to give it away...or that his closed-source projects were unusable.

Perhaps you should try "Greg's software is widely used in the open source community."

Sample code for linux usb device driver

Anonymous's picture

Dear Sir,

I am a student of Computer Engineering, i am studying linux at present and need a linux code for my college code does any body has such code a sample test code for the pen drive....

Regards
Rahul

You can refer to Essential

Anonymous's picture

You can refer to Essential Linux Device Drivers writtennn by Sreekrishnan Venkateswaran. Its a very good book with lots of code examples.

http://www.amazon.com/Essential-Device-Drivers-Sreekrishnan-Venkateswara....

-- Alakesh

Using the devfs_fs_kernel.h

vishy@honeywell's picture

Hi,

I went thru a few comments on the devfs_fs_kernel.h . This header file is included by most of the FS c files .. so only if the CONFIG_DEVFS_FS is enabled(made y) will the method do something. Otherwise the method returns 0 or NULL based on the return type of the func. Thus if a device is to be registered using the DEVFS make sure that the CONFIG_DEVFS_FS is set which causes the right method to be called.

rgds
vishy

Re: Kernel Korner: How to Write a Linux USB Device Driver

Anonymous's picture

I found in kernel2.4.18,the devfs_register() is defined as:
static inline devfs_handle_t devfs_register (devfs_handle_t dir,
const char *name,
unsigned int flags,
unsigned int major,
unsigned int minor,
umode_t mode,
void *ops, void *info)
{
return NULL;
}

file is :devfs_fs_kernel.h
How can I finish register a device file?

Re: Kernel Korner: How to Write a Linux USB Device Driver

Anonymous's picture

good article.

How about "how to write a file system driver" for linux?

Re: Kernel Korner: How to Write a Linux USB Device Driver

Anonymous's picture

I found in kernel2.4.18,the devfs_register() is defined as:
static inline devfs_handle_t devfs_register (devfs_handle_t dir,
const char *name,
unsigned int flags,
unsigned int major,
unsigned int minor,
umode_t mode,
void *ops, void *info)
{
return NULL;
}

file is :devfs_fs_kernel.h
How can I finish register a device file?

Thanx

Sumanta Sathua's picture

Thanx a lot to Greg Kroah-Hartman .Really this article helped me a lot to write a USB device driver.

Please Note, this article was

J.Flores's picture

Please Note, this article was written on 2001, now (jun-2005) a lot of changes has been done on Linux kernel 2.6.x.... just keep it in mind.

Try to download Chapter 13: USB of Linux Device Drivers (3rd Ed.) at http://www.oreilly.com/catalog/linuxdrive3/

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix