Adding support for extra GPIO chips in the common PDDF driver (#16082)
This commit is contained in:
parent
3500f69fdb
commit
bb8ce50cbe
@ -16,6 +16,7 @@
|
||||
* PDDF generic kernle module to create the I2C client for pca955x type of GPIO module
|
||||
*/
|
||||
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
@ -67,13 +68,19 @@ struct i2c_board_info *i2c_get_gpio_board_info(GPIO_DATA* mdata, NEW_DEV_ATTR *d
|
||||
|
||||
if (strncmp(device_data->dev_type, "pca9554", strlen("pca9554")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9534", strlen("pca9534")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9538", strlen("pca9538")) == 0)
|
||||
strncmp(device_data->dev_type, "pca9538", strlen("pca9538")) == 0 ||
|
||||
strncmp(device_data->dev_type, "tca6408", strlen("tca6408")) == 0 ||
|
||||
strncmp(device_data->dev_type, "tca9554", strlen("tca9554")) == 0)
|
||||
def_num_gpios = 0x8;
|
||||
else if (strncmp(device_data->dev_type, "pca9555", strlen("pca9555")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9535", strlen("pca9535")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9539", strlen("pca9539")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9575", strlen("pca9575")) == 0)
|
||||
strncmp(device_data->dev_type, "pca9575", strlen("pca9575")) == 0 ||
|
||||
strncmp(device_data->dev_type, "tca6416", strlen("tca6416")) == 0 ||
|
||||
strncmp(device_data->dev_type, "tca9539", strlen("tca9539")) == 0)
|
||||
def_num_gpios = 0x10;
|
||||
else if (strncmp(device_data->dev_type, "tca6424", strlen("tca6424")) == 0)
|
||||
def_num_gpios = 0x18;
|
||||
else if (strncmp(device_data->dev_type, "pca9698", strlen("pca9698")) == 0 ||
|
||||
strncmp(device_data->dev_type, "pca9505", strlen("pca9505")) == 0)
|
||||
def_num_gpios = 0x28;
|
||||
@ -82,7 +89,7 @@ struct i2c_board_info *i2c_get_gpio_board_info(GPIO_DATA* mdata, NEW_DEV_ATTR *d
|
||||
printk(KERN_ERR "%s: Unknown type of gpio device\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(mdata->gpio_base == 0) {
|
||||
base = base_gpio_num;
|
||||
base_gpio_num += def_num_gpios;
|
||||
@ -127,7 +134,7 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
pddf_dbg(GPIO, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr);
|
||||
add_device_table(device_ptr->i2c_name, (void*)client_ptr);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
kfree(board_info);
|
||||
goto free_data;
|
||||
@ -158,9 +165,18 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
}
|
||||
|
||||
free_data:
|
||||
|
||||
#ifdef __STDC_LIB_EXT1__
|
||||
memset_s(gpio_ptr, sizeof(GPIO_DATA), 0, sizeof(GPIO_DATA));
|
||||
#else
|
||||
memset(gpio_ptr, 0, sizeof(GPIO_DATA));
|
||||
#endif
|
||||
/*TODO: free the device_ptr->data is dynamically allocated*/
|
||||
#ifdef __STDC_LIB_EXT1__
|
||||
memset_s(device_ptr, sizeof(NEW_DEV_ATTR), 0 , sizeof(NEW_DEV_ATTR));
|
||||
#else
|
||||
memset(device_ptr, 0 , sizeof(NEW_DEV_ATTR));
|
||||
#endif
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -177,14 +193,14 @@ int __init gpio_data_init(void)
|
||||
pddf_dbg(GPIO, "GPIO_DATA MODULE.. init\n");
|
||||
|
||||
device_kobj = get_device_i2c_kobj();
|
||||
if(!device_kobj)
|
||||
if(!device_kobj)
|
||||
return -ENOMEM;
|
||||
|
||||
gpio_kobj = kobject_create_and_add("gpio", device_kobj);
|
||||
if(!gpio_kobj)
|
||||
if(!gpio_kobj)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
|
||||
|
||||
ret = sysfs_create_group(gpio_kobj, &pddf_clients_data_group);
|
||||
if (ret)
|
||||
{
|
||||
|
Reference in New Issue
Block a user