[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:
parent
a3a7944543
commit
24cc827b73
@ -35,7 +35,7 @@
|
|||||||
#include <linux/dmi.h>
|
#include <linux/dmi.h>
|
||||||
|
|
||||||
#define MAX_MODEL_NAME 20
|
#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_status(struct device *dev, struct device_attribute *da, char *buf);
|
||||||
static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf);
|
static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf);
|
||||||
@ -91,7 +91,6 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
|
|||||||
struct as4630_54pe_psu_data *data = as4630_54pe_psu_update_device(dev);
|
struct as4630_54pe_psu_data *data = as4630_54pe_psu_update_device(dev);
|
||||||
u8 status = 0;
|
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 (attr->index == PSU_PRESENT) {
|
||||||
if(data->index==0)
|
if(data->index==0)
|
||||||
status = !( (data->status >> 5) & 0x1);
|
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 */
|
/* Read psu status */
|
||||||
status = as4630_54pe_cpld_read(0x60, 0x22);
|
status = as4630_54pe_cpld_read(0x60, 0x22);
|
||||||
//printk("status=0x%x in %s\n", status, __FUNCTION__);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
|
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) {
|
if (status < 0) {
|
||||||
data->model_name[0] = '\0';
|
data->model_name[0] = '\0';
|
||||||
dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr);
|
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';
|
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);
|
status = as4630_54pe_psu_read_block(client, 0x35,data->serial_number, MAX_SERIAL_NUMBER);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
data->serial_number[0] = '\0';
|
data->serial_number[0] = '\0';
|
||||||
dev_dbg(&client->dev, "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);
|
||||||
printk("unable to read model name from (0x%x) offset(0x2e)\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;
|
data->last_updated = jiffies;
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import commands
|
import commands
|
||||||
import getopt
|
import getopt, sys
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
Reference in New Issue
Block a user