[pddf]: Update PDDF kernel modules with 5.10 kernel and fix some compilation (#9582)
- Why I did it There were compilation errors and warnings like, /usr/src/linux-headers-5.10.0-8-2-common/scripts/Makefile.build:69: You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead. fatal error: linux/platform_data/pca954x.h: No such file or directory hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info(). If PDDF kernel module compilation fails, the PDDF debian package was not detecting the break. - How I did it Modified the code with new kernel 5.10 APIs. Modified the Makefiles to use 'obj-m' instead of 'subdir-y' - How to verify it PDDF is supported on Accton platform. Load the build on AS7326 setup and check the 'dmesg'
This commit is contained in:
parent
b96533342f
commit
93247a6e24
@ -1 +1 @@
|
||||
subdir-m := modules
|
||||
obj-m := modules/
|
||||
|
@ -18,7 +18,7 @@ PACKAGE_PRE_NAME := sonic-platform-pddf
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MOD_SRC_DIR:= $(shell pwd)
|
||||
MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fan fan/driver fan/vendor_api mux gpio led psu psu/driver sysstatus xcvr xcvr/driver
|
||||
MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver
|
||||
MODULE_DIR:= modules
|
||||
UTILS_DIR := utils
|
||||
SERVICE_DIR := service
|
||||
@ -35,8 +35,10 @@ clean:
|
||||
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR) clean
|
||||
|
||||
build:
|
||||
set -e; \
|
||||
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR); \
|
||||
$(PYTHON) $(MOD_SRC_DIR)/setup.py build; \
|
||||
set +e
|
||||
|
||||
binary: binary-arch binary-indep
|
||||
# Nothing to do
|
||||
@ -50,11 +52,15 @@ binary-indep:
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME) $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME) usr/local/bin; \
|
||||
# Custom package commands
|
||||
set -e; \
|
||||
(for mod in $(MODULE_DIRS); do \
|
||||
cp $(MOD_SRC_DIR)/$(MODULE_DIR)/$${mod}/*.ko debian/$(PACKAGE_PRE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
done) ; \
|
||||
# Need to take a backup of symvers file for compilation of custom modules in various platforms
|
||||
cp $(MOD_SRC_DIR)/Module.symvers $(MOD_SRC_DIR)/Module.symvers.PDDF; \
|
||||
cp -r $(MOD_SRC_DIR)/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)/usr/local/bin/; \
|
||||
$(PYTHON) $(MOD_SRC_DIR)/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME) --install-layout=deb;
|
||||
$(PYTHON) $(MOD_SRC_DIR)/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME) --install-layout=deb; \
|
||||
set +e
|
||||
|
||||
# Resuming debhelper scripts
|
||||
dh_testroot
|
||||
|
@ -1 +1 @@
|
||||
subdir-m := client cpld cpldmux xcvr mux gpio psu fan led sysstatus
|
||||
obj-m := client/ cpld/ cpldmux/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/
|
||||
|
@ -1,4 +1,4 @@
|
||||
subdir-m := driver
|
||||
obj-m := pddf_cpld_module.o
|
||||
obj-m := driver/
|
||||
obj-m += pddf_cpld_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y:= -I$(M)/modules/include
|
||||
|
@ -30,9 +30,58 @@ static struct mutex list_lock;
|
||||
|
||||
struct cpld_client_node {
|
||||
struct i2c_client *client;
|
||||
char name[CPLD_CLIENT_NAME_LEN];
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg)
|
||||
{
|
||||
struct list_head *list_node = NULL;
|
||||
struct cpld_client_node *cpld_node = NULL;
|
||||
int ret = -EPERM;
|
||||
|
||||
mutex_lock(&list_lock);
|
||||
|
||||
list_for_each(list_node, &cpld_client_list)
|
||||
{
|
||||
cpld_node = list_entry(list_node, struct cpld_client_node, list);
|
||||
|
||||
if ((cpld_node->client->addr == cpld_addr) && (strncmp(cpld_node->name, name, strlen(name)) == 0)) {
|
||||
ret = i2c_smbus_read_byte_data(cpld_node->client, reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&list_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(board_i2c_cpld_read_new);
|
||||
|
||||
int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value)
|
||||
{
|
||||
struct list_head *list_node = NULL;
|
||||
struct cpld_client_node *cpld_node = NULL;
|
||||
int ret = -EIO;
|
||||
|
||||
mutex_lock(&list_lock);
|
||||
|
||||
list_for_each(list_node, &cpld_client_list)
|
||||
{
|
||||
cpld_node = list_entry(list_node, struct cpld_client_node, list);
|
||||
|
||||
if ((cpld_node->client->addr == cpld_addr) && (strncmp(cpld_node->name, name, strlen(name)) == 0)){
|
||||
ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&list_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(board_i2c_cpld_write_new);
|
||||
|
||||
int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg)
|
||||
{
|
||||
struct list_head *list_node = NULL;
|
||||
@ -128,7 +177,9 @@ static void board_i2c_cpld_add_client(struct i2c_client *client)
|
||||
}
|
||||
|
||||
node->client = client;
|
||||
|
||||
strcpy(node->name, (char *)client->dev.platform_data);
|
||||
dev_dbg(&client->dev, "Adding %s to the cpld client list\n", node->name);
|
||||
|
||||
mutex_lock(&list_lock);
|
||||
list_add(&node->list, &cpld_client_list);
|
||||
mutex_unlock(&list_lock);
|
||||
@ -188,8 +239,14 @@ exit:
|
||||
|
||||
static int board_i2c_cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_attribute_group);
|
||||
/* Platform data is just a char string */
|
||||
char *platdata = (char *)client->dev.platform_data;
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_attribute_group);
|
||||
board_i2c_cpld_remove_client(client);
|
||||
if (platdata)
|
||||
{
|
||||
kfree(platdata);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ EXPORT_SYMBOL(pddf_cpld_data);
|
||||
|
||||
static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count);
|
||||
static ssize_t store_pddf_cpld_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count);
|
||||
ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf);
|
||||
|
||||
extern void *get_device_table(char *name);
|
||||
extern void delete_device_table(char *name);
|
||||
@ -77,9 +77,8 @@ static ssize_t store_pddf_cpld_data(struct device *dev, struct device_attribute
|
||||
|
||||
return count;
|
||||
}
|
||||
EXPORT_SYMBOL(store_pddf_cpld_data);
|
||||
|
||||
ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf)
|
||||
static ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf)
|
||||
{
|
||||
int ret = 0;
|
||||
PDDF_ATTR *ptr = (PDDF_ATTR *)da;
|
||||
@ -91,7 +90,6 @@ ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, cha
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(show_pddf_cpld_data);
|
||||
|
||||
static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
|
||||
{
|
||||
@ -100,6 +98,7 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
struct i2c_adapter *adapter;
|
||||
static struct i2c_board_info board_info;
|
||||
struct i2c_client *client_ptr;
|
||||
char *pddf_cpld_name = NULL;
|
||||
|
||||
if (strncmp(buf, "add", strlen(buf)-1)==0)
|
||||
{
|
||||
@ -107,17 +106,19 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
|
||||
if (strncmp(device_ptr->dev_type, "i2c_cpld", strlen("i2c_cpld"))==0)
|
||||
{
|
||||
pddf_cpld_name = (char *)kzalloc(CPLD_CLIENT_NAME_LEN, GFP_KERNEL);
|
||||
if (pddf_cpld_name != NULL) strcpy(pddf_cpld_name, device_ptr->i2c_name);
|
||||
|
||||
board_info = (struct i2c_board_info) {
|
||||
.platform_data = (void *)NULL,
|
||||
.platform_data = (void *)pddf_cpld_name,
|
||||
};
|
||||
|
||||
board_info.addr = device_ptr->dev_addr;
|
||||
strcpy(board_info.type, device_ptr->dev_type);
|
||||
|
||||
/*pddf_dbg(KERN_ERR "Creating a client %s on 0x%x, platform_data 0x%x\n", board_info.type, board_info.addr, board_info.platform_data);*/
|
||||
client_ptr = i2c_new_client_device(adapter, &board_info);
|
||||
|
||||
if (client_ptr != NULL) {
|
||||
if (!IS_ERR(client_ptr)) {
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(CPLD, 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);
|
||||
@ -152,8 +153,12 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
{
|
||||
printk(KERN_ERR "PDDF_ERROR: %s: Invalid value for dev_ops %s", __FUNCTION__, buf);
|
||||
}
|
||||
goto clear_data;
|
||||
|
||||
free_data:
|
||||
if (board_info.platform_data)
|
||||
kfree(board_info.platform_data);
|
||||
clear_data:
|
||||
/*TODO: free the device_ptr->data is dynamically allocated*/
|
||||
memset(device_ptr, 0 , sizeof(NEW_DEV_ATTR));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
subdir-m := driver
|
||||
obj-m := pddf_cpldmux_module.o
|
||||
obj-m := driver/
|
||||
obj-m += pddf_cpldmux_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y:= -I$(M)/modules/include
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/platform_data/pca954x.h>
|
||||
#include <linux/i2c-mux.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include "pddf_client_defs.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
subdir-m := driver
|
||||
obj-m := pddf_fan_module.o
|
||||
obj-m := driver/
|
||||
obj-m += pddf_fan_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y:= -I$(M)/modules/include
|
||||
|
@ -64,20 +64,20 @@ int fan_update_hw(struct device *dev, struct fan_attr_info *info, FAN_DATA_ATTR
|
||||
{
|
||||
status = (sysfs_attr_data->pre_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
if (sysfs_attr_data->do_set != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->do_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
|
||||
}
|
||||
if (sysfs_attr_data->post_set != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->post_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
|
||||
mutex_unlock(&info->update_lock);
|
||||
@ -104,20 +104,20 @@ int fan_update_attr(struct device *dev, struct fan_attr_info *info, FAN_DATA_ATT
|
||||
{
|
||||
status = (sysfs_attr_data->pre_get)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
if (sysfs_attr_data->do_get != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->do_get)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
|
||||
}
|
||||
if (sysfs_attr_data->post_get != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->post_get)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute.ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
|
||||
|
||||
@ -346,7 +346,10 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void *
|
||||
val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset);
|
||||
}
|
||||
|
||||
painfo->val.intval = ((val & udata->mask) == udata->cmpval);
|
||||
if (val < 0)
|
||||
status = val;
|
||||
else
|
||||
painfo->val.intval = ((val & udata->mask) == udata->cmpval);
|
||||
|
||||
|
||||
return status;
|
||||
@ -355,7 +358,7 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void *
|
||||
int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
int status = 0;
|
||||
uint32_t val = 0;
|
||||
int val = 0;
|
||||
struct fan_attr_info *painfo = (struct fan_attr_info *)info;
|
||||
|
||||
if (strcmp(udata->devtype, "cpld") == 0)
|
||||
@ -375,10 +378,15 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info
|
||||
}
|
||||
}
|
||||
|
||||
if (udata->is_divisor)
|
||||
painfo->val.intval = udata->mult / (val >> 3);
|
||||
if (val < 0)
|
||||
status = val;
|
||||
else
|
||||
painfo->val.intval = udata->mult * val;
|
||||
{
|
||||
if (udata->is_divisor)
|
||||
painfo->val.intval = udata->mult / (val >> 3);
|
||||
else
|
||||
painfo->val.intval = udata->mult * val;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -471,7 +479,7 @@ int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udat
|
||||
int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
int status = 0;
|
||||
uint32_t val = 0;
|
||||
int val = 0;
|
||||
struct fan_attr_info *painfo = (struct fan_attr_info *)info;
|
||||
|
||||
if (strcmp(udata->devtype, "cpld") == 0)
|
||||
@ -491,15 +499,20 @@ int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info
|
||||
}
|
||||
}
|
||||
|
||||
val = val & udata->mask;
|
||||
painfo->val.intval = val;
|
||||
if (val < 0)
|
||||
status = val;
|
||||
else
|
||||
{
|
||||
val = val & udata->mask;
|
||||
painfo->val.intval = val;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *info)
|
||||
{
|
||||
int status = 0;
|
||||
uint32_t val = 0;
|
||||
int val = 0;
|
||||
struct fan_attr_info *painfo = (struct fan_attr_info *)info;
|
||||
|
||||
/*Assuming fan fault to be denoted by 1 byte only*/
|
||||
@ -512,8 +525,10 @@ int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *in
|
||||
val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset);
|
||||
}
|
||||
|
||||
val = val & udata->mask;
|
||||
painfo->val.intval = val;
|
||||
if (val < 0)
|
||||
status = val;
|
||||
else
|
||||
painfo->val.intval = ((val & udata->mask) == udata->cmpval);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ static int pddf_fan_probe(struct i2c_client *client,
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
|
@ -159,9 +159,9 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
board_info = i2c_get_fan_board_info(fdata, cdata);
|
||||
|
||||
/* Populate the platform data for fan */
|
||||
client_ptr = i2c_new_device(adapter, board_info);
|
||||
client_ptr = i2c_new_client_device(adapter, board_info);
|
||||
|
||||
if(client_ptr != NULL)
|
||||
if(!IS_ERR(client_ptr))
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(FAN, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name, (void *)client_ptr);
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
obj-m := pddf_gpio_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y := -I$(M)/modules/include
|
||||
|
@ -119,10 +119,10 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
board_info = i2c_get_gpio_board_info(gpio_ptr, device_ptr);
|
||||
|
||||
/*pddf_dbg(KERN_ERR "Creating a client %s on 0x%x, platform_data 0x%x\n", board_info->type, board_info->addr, board_info->platform_data);*/
|
||||
client_ptr = i2c_new_device(adapter, board_info);
|
||||
client_ptr = i2c_new_client_device(adapter, board_info);
|
||||
|
||||
i2c_put_adapter(adapter);
|
||||
if (client_ptr != NULL)
|
||||
if (!IS_ERR(client_ptr))
|
||||
{
|
||||
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);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef __PDDF_CPLD_DEFS_H__
|
||||
#define __PDDF_CPLD_DEFS_H__
|
||||
|
||||
#define CPLD_CLIENT_NAME_LEN 32
|
||||
/* CPLD DATA - DATA FOR CPLD CLIENT READ/WRITE*/
|
||||
typedef struct CPLD_DATA
|
||||
{
|
||||
|
@ -20,8 +20,6 @@
|
||||
#ifndef __PAL_MUX_DEFS_H__
|
||||
#define __PAL_MUX_DEFS_H__
|
||||
|
||||
#include <linux/platform_data/pca954x.h>
|
||||
|
||||
/* MUX CLIENT DATA - PLATFORM DATA FOR PSU CLIENT */
|
||||
typedef struct MUX_DATA
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ enum xcvr_sysfs_attributes {
|
||||
XCVR_ATTR_MAX
|
||||
};
|
||||
|
||||
extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value);
|
||||
extern int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg);
|
||||
extern int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value);
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGET := pddf_led_module
|
||||
obj-m := $(TARGET).o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y := -I$(M)/modules/include
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
obj-m := pddf_mux_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y := -I$(M)/modules/include
|
||||
|
@ -56,72 +56,49 @@ static const struct attribute_group pddf_mux_client_data_group = {
|
||||
.attrs = mux_attributes,
|
||||
};
|
||||
|
||||
struct i2c_board_info *i2c_get_mux_board_info(MUX_DATA* mdata, NEW_DEV_ATTR *device_data)
|
||||
{
|
||||
static struct i2c_board_info board_info;
|
||||
static struct pca954x_platform_mode platform_modes[8];
|
||||
static struct pca954x_platform_data mux_platform_data;
|
||||
int num_modes, i;
|
||||
|
||||
if (strncmp(device_data->dev_type, "pca9548", strlen("pca9548")) == 0)
|
||||
num_modes = 8;
|
||||
else if (strncmp(device_data->dev_type, "pca9546", strlen("pca9546")) == 0)
|
||||
num_modes = 6;
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "%s: Unknown type of mux device\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(i = 0; i < num_modes; i++) {
|
||||
platform_modes[i] = (struct pca954x_platform_mode) {
|
||||
.adap_id = (mdata->virt_bus + i),
|
||||
.deselect_on_exit = 1,
|
||||
};
|
||||
}
|
||||
|
||||
mux_platform_data = (struct pca954x_platform_data) {
|
||||
.modes = platform_modes,
|
||||
.num_modes = num_modes,
|
||||
};
|
||||
|
||||
board_info = (struct i2c_board_info) {
|
||||
.platform_data = &mux_platform_data,
|
||||
};
|
||||
|
||||
board_info.addr = device_data->dev_addr;
|
||||
strcpy(board_info.type, device_data->dev_type);
|
||||
|
||||
return &board_info;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
|
||||
{
|
||||
PDDF_ATTR *ptr = (PDDF_ATTR *)da;
|
||||
MUX_DATA *mux_ptr = (MUX_DATA *)(ptr->addr);
|
||||
NEW_DEV_ATTR *device_ptr = (NEW_DEV_ATTR *)(ptr->data);
|
||||
struct i2c_adapter *adapter;
|
||||
struct i2c_board_info *board_info;
|
||||
static struct i2c_board_info board_info;
|
||||
struct i2c_client *client_ptr;
|
||||
|
||||
if (strncmp(buf, "add", strlen(buf)-1)==0)
|
||||
{
|
||||
adapter = i2c_get_adapter(device_ptr->parent_bus);
|
||||
board_info = i2c_get_mux_board_info(mux_ptr, device_ptr);
|
||||
|
||||
client_ptr = i2c_new_device(adapter, board_info);
|
||||
|
||||
if (client_ptr != NULL)
|
||||
/* Supported types are pca_9540, pca_9542, pca_9543, pca_9544, pca_9545, pca_9546, pca_9547, pca_9548,
|
||||
* pca_9846, pca_9847, pca_9848, pca_9849
|
||||
*/
|
||||
if ( (strncmp(device_ptr->dev_type, "pca954", 6) == 0) ||
|
||||
(strncmp(device_ptr->dev_type, "pca984", 6) == 0) )
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(MUX, 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);
|
||||
adapter = i2c_get_adapter(device_ptr->parent_bus);
|
||||
board_info = (struct i2c_board_info) {
|
||||
.platform_data = NULL,
|
||||
};
|
||||
|
||||
board_info.addr = device_ptr->dev_addr;
|
||||
strcpy(board_info.type, device_ptr->dev_type);
|
||||
|
||||
|
||||
client_ptr = i2c_new_client_device(adapter, &board_info);
|
||||
|
||||
if (!IS_ERR(client_ptr))
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(MUX, 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
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
goto free_data;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
goto free_data;
|
||||
printk(KERN_ERR "%s: Unknown type of mux device %s\n", __FUNCTION__, device_ptr->dev_type);
|
||||
}
|
||||
}
|
||||
else if (strncmp(buf, "delete", strlen(buf)-1)==0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
subdir-m := driver
|
||||
obj-m := pddf_psu_module.o
|
||||
obj-m := driver/
|
||||
obj-m += pddf_psu_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y:= -I$(M)/modules/include
|
||||
|
@ -89,20 +89,20 @@ int psu_update_hw(struct device *dev, struct psu_attr_info *info, PSU_DATA_ATTR
|
||||
{
|
||||
status = (sysfs_attr_data->pre_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
if (sysfs_attr_data->do_set != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->do_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
|
||||
}
|
||||
if (sysfs_attr_data->post_set != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->post_set)(client, udata, info);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
|
||||
mutex_unlock(&info->update_lock);
|
||||
@ -128,20 +128,20 @@ int psu_update_attr(struct device *dev, struct psu_attr_info *data, PSU_DATA_ATT
|
||||
{
|
||||
status = (sysfs_attr_data->pre_get)(client, udata, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
if (sysfs_attr_data->do_get != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->do_get)(client, udata, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
|
||||
}
|
||||
if (sysfs_attr_data->post_get != NULL)
|
||||
{
|
||||
status = (sysfs_attr_data->post_get)(client, udata, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, udata->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status);
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
|
@ -224,7 +224,7 @@ static int psu_probe(struct i2c_client *client,
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
|
@ -160,9 +160,9 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
board_info = i2c_get_psu_board_info(pdata, cdata);
|
||||
|
||||
/* Populate the platform data for psu */
|
||||
client_ptr = i2c_new_device(adapter, board_info);
|
||||
client_ptr = i2c_new_client_device(adapter, board_info);
|
||||
|
||||
if(client_ptr != NULL)
|
||||
if(!IS_ERR(client_ptr))
|
||||
{
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(PSU, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name , (void *)client_ptr);
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGET := pddf_sysstatus_module
|
||||
obj-m := $(TARGET).o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y := -I$(M)/modules/include
|
||||
|
@ -1,4 +1,4 @@
|
||||
subdir-m := driver
|
||||
obj-m := pddf_xcvr_module.o
|
||||
obj-m := driver/
|
||||
obj-m += pddf_xcvr_module.o
|
||||
|
||||
CFLAGS_$(obj-m):= -I$(M)/modules/include
|
||||
ccflags-y:= -I$(M)/modules/include
|
||||
|
@ -47,36 +47,106 @@ int get_xcvr_module_attr_data(struct i2c_client *client, struct device *dev,
|
||||
int xcvr_i2c_cpld_read(XCVR_ATTR *info)
|
||||
{
|
||||
int status = -1;
|
||||
int retry = 10;
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
|
||||
if (info!=NULL)
|
||||
{
|
||||
if (info->len==1)
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
if (client_ptr)
|
||||
{
|
||||
status = board_i2c_cpld_read(info->devaddr , info->offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the I2C client for the CPLD */
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
if (client_ptr)
|
||||
if (info->len==1)
|
||||
{
|
||||
if (info->len==2)
|
||||
{
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, info->offset);
|
||||
while (retry)
|
||||
{
|
||||
status = board_i2c_cpld_read_new(info->devaddr, info->devname, info->offset);
|
||||
if (unlikely(status < 0))
|
||||
{
|
||||
msleep(60);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (info->len==2)
|
||||
{
|
||||
while(retry)
|
||||
{
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, info->offset);
|
||||
if (unlikely(status < 0))
|
||||
{
|
||||
msleep(60);
|
||||
retry--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
}
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
}
|
||||
|
||||
else
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int xcvr_i2c_cpld_write(XCVR_ATTR *info, uint32_t val)
|
||||
{
|
||||
int status = 0;
|
||||
unsigned int val_mask = 0, dnd_value = 0;
|
||||
uint32_t reg;
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_read_new(info->devaddr, info->devname, info->offset);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_read_word_swapped(client_ptr, info->offset);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
msleep(60);
|
||||
dnd_value = status & ~val_mask;
|
||||
if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_write_new(info->devaddr, info->devname, info->offset, (uint8_t)reg);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data)
|
||||
{
|
||||
int status = 0;
|
||||
@ -143,7 +213,7 @@ int sonic_i2c_get_mod_intr_status(struct i2c_client *client, XCVR_ATTR *info, st
|
||||
mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0;
|
||||
sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x\n", mod_intr, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strcmp(info->devtype, "eeprom") == 0)
|
||||
{
|
||||
/* get client client for eeprom - Not Applicable */
|
||||
@ -247,54 +317,15 @@ int sonic_i2c_get_mod_txfault(struct i2c_client *client, XCVR_ATTR *info, struct
|
||||
int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data)
|
||||
{
|
||||
int status = 0;
|
||||
unsigned int val_mask = 0, dnd_value = 0;
|
||||
uint32_t reg;
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
|
||||
if (strcmp(info->devtype, "cpld") == 0)
|
||||
{
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_read(info->devaddr , info->offset);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_read_word_data(client_ptr, info->offset);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
status = -1;
|
||||
}
|
||||
/*printk(KERN_ERR "sonic_i2c_set_mod_reset:client_ptr=0x%x, status=0x%x, offset=0x%x, len=%d\n", client_ptr, status, info->offset, info->len);*/
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
dnd_value = status & ~val_mask;
|
||||
if (((data->reset == 1) && (info->cmpval != 0)) || ((data->reset == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
status = xcvr_i2c_cpld_write(info, data->reset);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr reset\n", info->devtype);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -303,53 +334,15 @@ int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x
|
||||
int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data)
|
||||
{
|
||||
int status = 0;
|
||||
unsigned int val_mask = 0, dnd_value = 0;
|
||||
uint32_t reg;
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
|
||||
if (strcmp(info->devtype, "cpld") == 0)
|
||||
{
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_read(info->devaddr , info->offset);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_read_word_data(client_ptr, info->offset);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
dnd_value = status & ~val_mask;
|
||||
if (((data->lpmode == 1) && (info->cmpval != 0)) || ((data->lpmode == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
status = xcvr_i2c_cpld_write(info, data->lpmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr lpmode\n", info->devtype);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -358,53 +351,15 @@ int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct
|
||||
int sonic_i2c_set_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data)
|
||||
{
|
||||
int status = 0;
|
||||
unsigned int val_mask = 0, dnd_value = 0;
|
||||
uint32_t reg;
|
||||
struct i2c_client *client_ptr=NULL;
|
||||
|
||||
if (strcmp(info->devtype, "cpld") == 0)
|
||||
{
|
||||
val_mask = BIT_INDEX(info->mask);
|
||||
/* Get the I2C client for the CPLD */
|
||||
client_ptr = (struct i2c_client *)get_device_table(info->devname);
|
||||
|
||||
if (client_ptr)
|
||||
{
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_read(info->devaddr , info->offset);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_read_word_data(client_ptr, info->offset);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
return status;
|
||||
else
|
||||
{
|
||||
dnd_value = status & ~val_mask;
|
||||
if (((data->txdisable == 1) && (info->cmpval != 0)) || ((data->txdisable == 0) && (info->cmpval == 0)))
|
||||
reg = dnd_value | val_mask;
|
||||
else
|
||||
reg = dnd_value;
|
||||
if (info->len == 1)
|
||||
status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg);
|
||||
else if (info->len == 2)
|
||||
status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg);
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
status = xcvr_i2c_cpld_write(info, data->txdisable);
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr txdisable\n", info->devtype);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -433,20 +388,20 @@ ssize_t get_module_presence(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
return sprintf(buf, "%d\n", data->modpres);
|
||||
@ -478,20 +433,20 @@ ssize_t get_module_reset(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
}
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
@ -533,20 +488,20 @@ ssize_t set_module_reset(struct device *dev, struct device_attribute *da, const
|
||||
{
|
||||
status = (attr_ops->pre_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_set != NULL)
|
||||
{
|
||||
status = (attr_ops->do_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_set != NULL)
|
||||
{
|
||||
status = (attr_ops->post_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
@ -579,20 +534,20 @@ ssize_t get_module_intr_status(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
@ -645,20 +600,20 @@ ssize_t get_module_lpmode(struct device *dev, struct device_attribute *da, char
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
return sprintf(buf, "%d\n", data->lpmode);
|
||||
@ -699,20 +654,20 @@ ssize_t set_module_lpmode(struct device *dev, struct device_attribute *da, const
|
||||
{
|
||||
status = (attr_ops->pre_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_set != NULL)
|
||||
{
|
||||
status = (attr_ops->do_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_set != NULL)
|
||||
{
|
||||
status = (attr_ops->post_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
}
|
||||
@ -743,20 +698,20 @@ ssize_t get_module_rxlos(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
return sprintf(buf, "%d\n", data->rxlos);
|
||||
@ -789,20 +744,20 @@ ssize_t get_module_txdisable(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
return sprintf(buf, "%d\n", data->txdisable);
|
||||
@ -843,20 +798,20 @@ ssize_t set_module_txdisable(struct device *dev, struct device_attribute *da, co
|
||||
{
|
||||
status = (attr_ops->pre_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_set != NULL)
|
||||
{
|
||||
status = (attr_ops->do_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_set != NULL)
|
||||
{
|
||||
status = (attr_ops->post_set)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
}
|
||||
@ -887,20 +842,20 @@ ssize_t get_module_txfault(struct device *dev, struct device_attribute *da,
|
||||
{
|
||||
status = (attr_ops->pre_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
if (attr_ops->do_get != NULL)
|
||||
{
|
||||
status = (attr_ops->do_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
|
||||
}
|
||||
if (attr_ops->post_get != NULL)
|
||||
{
|
||||
status = (attr_ops->post_get)(client, attr_data, data);
|
||||
if (status!=0)
|
||||
printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname);
|
||||
dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status);
|
||||
}
|
||||
mutex_unlock(&data->update_lock);
|
||||
return sprintf(buf, "%d\n", data->txfault);
|
||||
|
@ -159,7 +159,7 @@ static int xcvr_probe(struct i2c_client *client,
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->xdev = hwmon_device_register(&client->dev);
|
||||
data->xdev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL);
|
||||
if (IS_ERR(data->xdev)) {
|
||||
status = PTR_ERR(data->xdev);
|
||||
goto exit_remove;
|
||||
|
@ -129,8 +129,8 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
board_info.addr = cdata->dev_addr;
|
||||
strcpy(board_info.type, cdata->dev_type);
|
||||
|
||||
client_ptr = i2c_new_device(adapter, &board_info);
|
||||
if (client_ptr != NULL) {
|
||||
client_ptr = i2c_new_client_device(adapter, &board_info);
|
||||
if (!IS_ERR(client_ptr)) {
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(XCVR, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name, (void *)client_ptr);
|
||||
add_device_table(cdata->i2c_name, (void*)client_ptr);
|
||||
@ -152,8 +152,8 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute *
|
||||
board_info.addr = cdata->dev_addr;
|
||||
strcpy(board_info.type, cdata->dev_type);
|
||||
|
||||
client_ptr = i2c_new_device(adapter, &board_info);
|
||||
if(client_ptr != NULL) {
|
||||
client_ptr = i2c_new_client_device(adapter, &board_info);
|
||||
if(!IS_ERR(client_ptr)) {
|
||||
i2c_put_adapter(adapter);
|
||||
pddf_dbg(XCVR, KERN_ERR "Created %s, type:%s client: 0x%p\n", cdata->i2c_name, cdata->dev_type, (void *)client_ptr);
|
||||
add_device_table(cdata->i2c_name, (void*)client_ptr);
|
||||
|
Reference in New Issue
Block a user