Build-a-Driver Introduction

This series is the result of trying to figure out a meaningful way to share what I'm learning that fits into the way I am working, and creates minimal overhead.  I hope it's helpful to the next new IIO driver writer.

I'm tasked with adding support for the MCP9808 Temperature Sensor.  That will include reading the temperature and setting the measurement resolution.  These posts will present that driver development through a series of pre-patches that add functionality bit by bit, building to a patch that's ready to submit to the Linux kernel community.

You are probably familiar with the development tactic where you take an existing driver and reshape it to meet your devices needs.  This is sort of the inverse. I throw everything out and only pull in what is needed at each step.  Ideally, this will force me to think about every line of code. And, I can already tell you, since I've done the first pre-patch, that creates some fun in kernel oops!

Dummy!!! I use the dummy driver as a reference as well as other drivers in iio/temperature and iio/humidity.  Dummy has more than you will need, but it is the **correct** model.  To illustrate, recently iio had an issue with indio_dev->name's being set incorrectly.  It's a tough problem once the driver has been released, because it's not something we can change later without fear of breaking an application.  The dummy is doing the name assignment correctly, but the error perpetuated itself via copy/paste from one incorrect driver to the next.  Respect the Dummy!

Trying to be a purist here and not put in anything that anticipates what comes next.  ie...don't use a case-statement where an if-statement will suffice for now.  Each patch will compile without warnings and will be checkpatch'd, but not cocci-check'd or smatch'd (yet).

Each blog post will contain notes and an updated driver.

I'll point you directly to the MCP9808 GIST if you want to peek at revision history.

Here are the pre-Patches I'm planning:
All leading up to:
Now that I've made up this plan, let's see if I can follow it!

Labels: , ,