[as4630-54pe] Modify to read correct psu SN and ID (#5389)

Co-authored-by: Jostar Yang <jostar_yang@accton.com.tw>
This commit is contained in:
jostar-yang 2021-07-25 07:45:07 +08:00 committed by GitHub
parent a3a7944543
commit 24cc827b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View File

@ -35,7 +35,7 @@
#include <linux/dmi.h>
#define MAX_MODEL_NAME 20
#define MAX_SERIAL_NUMBER 18
#define MAX_SERIAL_NUMBER 19
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf);
@ -90,8 +90,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct as4630_54pe_psu_data *data = as4630_54pe_psu_update_device(dev);
u8 status = 0;
//printk("data->status=0x%x, attr->index=%d,data->index=%d \n", data->status, attr->index, data->index);
if (attr->index == PSU_PRESENT) {
if(data->index==0)
status = !( (data->status >> 5) & 0x1);
@ -267,7 +266,6 @@ static struct as4630_54pe_psu_data *as4630_54pe_psu_update_device(struct device
/* Read psu status */
status = as4630_54pe_cpld_read(0x60, 0x22);
//printk("status=0x%x in %s\n", status, __FUNCTION__);
if (status < 0) {
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
}
@ -286,21 +284,36 @@ static struct as4630_54pe_psu_data *as4630_54pe_psu_update_device(struct device
if (status < 0) {
data->model_name[0] = '\0';
dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr);
printk("unable to read model name from (0x%x)\n", client->addr);
}
else {
else if(!strncmp(data->model_name, "YPEB1200", strlen("YPEB1200")))
{
if (data->model_name[9]=='A' && data->model_name[10]=='M')
{
data->model_name[8]='A';
data->model_name[9]='M';
data->model_name[strlen("YPEB1200AM")]='\0';
}
else
data->model_name[strlen("YPEB1200")]='\0';
}
else
{
data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0';
}
/* Read from offset 0x2e ~ 0x3d (16 bytes) */
/* Read from offset 0x35 ~ 0x46 (18 bytes) */
status = as4630_54pe_psu_read_block(client, 0x35,data->serial_number, MAX_SERIAL_NUMBER);
if (status < 0)
{
data->serial_number[0] = '\0';
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x2e)\n", client->addr);
printk("unable to read model name from (0x%x) offset(0x2e)\n", client->addr);
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x35)\n", client->addr);
}
data->serial_number[MAX_SERIAL_NUMBER-1]='\0';
if (!strncmp(data->model_name, "YPEB1200AM", strlen("YPEB1200AM"))) /*for YPEB1200AM, SN length=18*/
{
data->serial_number[MAX_SERIAL_NUMBER-1]='\0';
}
else
data->serial_number[MAX_SERIAL_NUMBER-2]='\0';
}
data->last_updated = jiffies;

View File

@ -21,8 +21,7 @@
try:
import commands
import getopt
import sys
import getopt, sys
import logging
import logging.config
import logging.handlers