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/

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState