Friday, March 25, 2016

Linux Upgrade

<< Prev: kzalloc Crash       Next: Compiler Dysfunction >>

About this time, I noticed that Linux had been merrily marching on while I worked. I had started with the driver from Linux 4.4.1, and now they were up to Linux 4.4.3. Not a huge difference, but it seemed like a good time to check my theory that if I kept close to the original source, I could update easily. After all, if that didn't work, this whole approach was flawed.

The basic procedure turned out to be easy enough:

  1. I copied the updated source into the project tree
    • Now the "current state" represented the Linux code
    • A diff against source control might represent the inverse of a change I made -- if I reverted it, I'd be back to my original change
    • Or, a diff against source control might represent a change they made that wasn't in my project yet
  2. I removed the dvm/ directory for the firmware I'm not working with yet
  3. I moved iwl-7000.c and iwl-8000.c to the corresponding .h versions (I had changed them to headers since in my version there is no actual code just a bunch of declarations)
  4. I copied declarations from iwl-drv.c to iwl-drv.h (the iwl_drv struct and etc.)
  5. I copied declarations from pcie/drv.c code into device-list.h (the device list array)
  6. I had to go through file by file and examine the diffs and revert the changes that need it from theirs to mine
    • One common one was #include revisions
    • There were also a variety of minor syntax changes (MALLOC and etc.)
    • Plus any meatier changes, like all the debugging I added to the firmware parsing process

That last part was the tedious part. In the grand scheme of things I've made very few changes, and it was already a lot to review. Using a decent IDE made it all straightforward, but the time-taken-to-benefit ratio was still not in my favor.

Especially when I got through, only to discover that there were no changes except whitespace. Oops. That would have been good to know ahead of time.

Guess what? It turns out that's easy to check ahead of time. Here are the diffs from 4.4.1 to 4.4.3 (none). Whereas here are the diffs from 4.4.3 to today's current 4.4.6 (minor changes).

You know what would be really clever?

Instead of dumping the whole updated source tree and needing to review every single change... I could just apply the individual patches called out by the diffs above. Then instead of needing to review a thousand unchanged bits, I'd only need to massage the actual changed parts.

Someday, I promise, I'll come up with the better approach on the first try. Well, perhaps 'hope' would be a better word. :)

<< Prev: kzalloc Crash       Next: Compiler Dysfunction >>

No comments:

Post a Comment