Adding support for extra GPIO chips in the common PDDF driver (#16082)

This commit is contained in:
FuzailBrcm 2023-08-11 22:01:18 +05:30 committed by GitHub
parent 3500f69fdb
commit bb8ce50cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@
* PDDF generic kernle module to create the I2C client for pca955x type of GPIO module * 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/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/jiffies.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 || if (strncmp(device_data->dev_type, "pca9554", strlen("pca9554")) == 0 ||
strncmp(device_data->dev_type, "pca9534", strlen("pca9534")) == 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; def_num_gpios = 0x8;
else if (strncmp(device_data->dev_type, "pca9555", strlen("pca9555")) == 0 || 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, "pca9535", strlen("pca9535")) == 0 ||
strncmp(device_data->dev_type, "pca9539", strlen("pca9539")) == 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; 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 || else if (strncmp(device_data->dev_type, "pca9698", strlen("pca9698")) == 0 ||
strncmp(device_data->dev_type, "pca9505", strlen("pca9505")) == 0) strncmp(device_data->dev_type, "pca9505", strlen("pca9505")) == 0)
def_num_gpios = 0x28; def_num_gpios = 0x28;
@ -158,9 +165,18 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
} }
free_data: 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)); memset(gpio_ptr, 0, sizeof(GPIO_DATA));
#endif
/*TODO: free the device_ptr->data is dynamically allocated*/ /*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)); memset(device_ptr, 0 , sizeof(NEW_DEV_ATTR));
#endif
return count; return count;
} }