x
Loading
 Loading
Hello, Guest | Login | Register

Porting Device Drivers to Linux 2.2: Part II

If you followed last issue’s
“Gearheads” column, all of your block and character devices should be running
under Linux 2.2, albeit possibly with warnings about obsolete PCI interfaces. In
this article, I will finish up with some of the smaller changes that may catch a
driver author, cover networking, and then look at the new PCI layer.

If you followed last issue’s “Gearheads” column, all of your block and character devices should be running under Linux 2.2, albeit possibly with warnings about obsolete PCI interfaces. In this article, I will finish up with some of the smaller changes that may catch a driver author, cover networking, and then look at the new PCI layer.

Figure 1

if(skb->protocol == htons(ETH_P_MYPROTO)) { /* The card requires we mask the addresses for this */ u8 v; skb = skb_cow(skb, 0); if(skb==NULL) return 1; /* Whoops no memory */ skb->data[4]&=0×7F; skb->data[5]&=0×7F; }


I’ll start with the small stuff, since that is nice and easy. The first of these is signal handling. Linux 2.2 has more signals as well as POSIX real-time signal queues. This fact changes the driver code to determine whether a process has received a signal.

In Linux 2.0, drivers check for signals directly. This is done with code such as:

if(current->signal & ~current->blocked) return -EINTR; 

which ensures that pressing Ctrl-C on the terminal will return the EINTR error code from the device driver function.

Linux 2.2 replaces this with a function which hides the implementation of signals, which also means that we can avoid changing drivers again in the future. The above code now becomes:

if(signal_pending(current)) return -EINTR; 

which is much cleaner.

The second, related issue is…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace