Char Device Driver with Port Expansion using MCP23017?

I am new to Linux Kernel Development and I want to implement a Char device driver which handles Port expansion using a MCP23017 with a RaspberryPi (Raspbian Wheezy) using C. Here is the datesheet of mcp23017

A control for port expansion (MCP23017) is required. A less of a driver in the true sense, but more with porting functions in a driver.   The module is addressed via I2C. I need to implement the following functions in the driver:

· Configuration of the I2C address

· Configuration of the IOs

· Configuration of Pull-Ups

· Configuration of interrupts

· Read / write the IOs

It is important that up to 8 modules can be opened/operated simultaneously (8 is the max. possible number of addresses of the block).

I have seen a number of examples in the internet and implemented a simple char device driver with init, open, read and write functions and also tested I2C operations for MCP23017. I have got a brief idea about a device driver but don't know how to further implement the functions.

I would like to know/clarified about the following:

    How does the dev_open work? How can I try to open a device through a linux command and check if the device is opened/ the number of times the device is opened through dmesg command?

    I want 8 different modules to be opened simultaneously using the device driver and the Configuration of the MCP23017 IOs, Pullups and Interrupts. How is it done?


/home/pi/i2c_gpio/mcp23017.c: In function ‘mcp23s08_direction_input’:
/home/pi/i2c_gpio/mcp23017.c:269:9: error: implicit declaration of function     
‘gpiochip_get_data’ [-Werror=implicit-function-declaration]
struct mcp23s08 *mcp = gpiochip_get_data(chip);     

/home/pi/i2c_gpio/mcp23017.c: In function ‘mcp23s08_probe_one’:
/home/pi/i2c_gpio/mcp23017.c:615:11: error: ‘struct gpio_chip’ has no        
member  named ‘parent’
mcp->chip.parent = dev;                 

/home/pi/i2c_gpio/mcp23017.c:681:2: error: implicit declaration of 
function ‘gpiochip_add_data’ [-Werror=implicit-function-declaration]
status = gpiochip_add_data(&mcp->chip, mcp);

iceng20 days ago

What do you need so many ports for ?