Commit 01386c25 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: rtas proc fixes from David Altobelli

parent 5c6cce95
......@@ -128,6 +128,10 @@ config RTAS_FLASH
tristate "Firmware flash interface"
depends on !PPC_ISERIES
config PPC_RTAS
bool "Proc interface to RTAS"
depends on !PPC_ISERIES
endmenu
......
......@@ -25,9 +25,10 @@ obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
# Change this to pSeries only once we've got iSeries up to date
obj-y += open_pic.o xics.o pSeries_htab.o rtas.o \
rtas-proc.o chrp_setup.o i8259.o ras.o prom.o
chrp_setup.o i8259.o ras.o prom.o
obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_PROFILING) += profile.o
obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o
obj-$(CONFIG_PPC_RTAS) += rtas-proc.o
......@@ -115,9 +115,10 @@
/* Globals */
static struct proc_dir_entry *proc_rtas;
extern struct proc_dir_entry *proc_rtas;
static struct rtas_sensors sensors;
static struct device_node *rtas_node;
static struct device_node *rtas_node = NULL;
static unsigned long power_on_time = 0; /* Save the time the user set */
static char progress_led[MAX_LINELENGTH];
......@@ -200,13 +201,18 @@ void proc_rtas_init(void)
struct proc_dir_entry *entry;
rtas_node = find_devices("rtas");
if ((rtas_node == 0) || (naca->platform == PLATFORM_ISERIES_LPAR)) {
if ((rtas_node == NULL) || (naca->platform == PLATFORM_ISERIES_LPAR)) {
return;
}
if (proc_rtas == NULL) {
proc_rtas = proc_mkdir("rtas", 0);
if (proc_rtas == 0)
}
if (proc_rtas == NULL) {
printk(KERN_ERR "Failed to create /proc/rtas in proc_rtas_init\n");
return;
}
/* /proc/rtas entries */
......@@ -405,10 +411,14 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
j = sensors.sensor[i].quant;
/* A sensor may have multiple instances */
while (j >= 0) {
error = rtas_call(get_sensor_state, 2, 2, &ret,
sensors.sensor[i].token, sensors.sensor[i].quant-j);
sensors.sensor[i].token,
sensors.sensor[i].quant - j);
state = (int) ret;
n += ppc_rtas_process_sensor(sensors.sensor[i], state, error, buffer+n );
n += ppc_rtas_process_sensor(sensors.sensor[i], state,
error, buffer+n );
n += sprintf (buffer+n, "\n");
j--;
} /* while */
......@@ -426,6 +436,7 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
n = count;
else
*eof = 1;
memcpy(buf, buffer + off, n);
*start = buf;
kfree(buffer);
......@@ -436,10 +447,10 @@ static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
int ppc_rtas_find_all_sensors (void)
{
unsigned long *utmp;
int len, i, j;
unsigned int *utmp;
int len, i;
utmp = (unsigned long *) get_property(rtas_node, "rtas-sensors", &len);
utmp = (unsigned int *) get_property(rtas_node, "rtas-sensors", &len);
if (utmp == NULL) {
printk (KERN_ERR "error: could not get rtas-sensors\n");
return 1;
......@@ -447,9 +458,9 @@ int ppc_rtas_find_all_sensors (void)
sensors.quant = len / 8; /* int + int */
for (i=0, j=0; j<sensors.quant; i+=2, j++) {
sensors.sensor[j].token = utmp[i];
sensors.sensor[j].quant = utmp[i+1];
for (i=0; i<sensors.quant; i++) {
sensors.sensor[i].token = *utmp++;
sensors.sensor[i].quant = *utmp++;
}
return 0;
}
......@@ -515,6 +526,7 @@ int ppc_rtas_process_sensor(struct individual_sensor s, int state,
int n = 0;
/* What kind of sensor do we have here? */
switch (s.token) {
case KEY_SWITCH:
n += sprintf(buf+n, "Key switch:\t");
......@@ -698,9 +710,9 @@ int get_location_code(struct individual_sensor s, char * buffer)
ret = (char *) get_property(rtas_node, rstr, &llen);
n=0;
if (ret[0] == '\0')
if (ret == NULL || ret[0] == '\0') {
n += sprintf ( buffer+n, "--- ");/* does not have a location */
else {
} else {
char t[50];
ret += pos;
......
......@@ -49,6 +49,8 @@ static unsigned int rtas_error_log_max;
#define SURVEILLANCE_TIMEOUT 1
#define SURVEILLANCE_SCANRATE 1
struct proc_dir_entry *proc_rtas;
/*
* Since we use 32 bit RTAS, the physical address of this must be below
* 4G or else bad things happen. Allocate this in the kernel data and
......@@ -270,13 +272,16 @@ static int rtasd(void *unused)
static int __init rtas_init(void)
{
struct proc_dir_entry *rtas_dir, *entry;
struct proc_dir_entry *entry;
if (proc_rtas == NULL) {
proc_rtas = proc_mkdir("rtas", 0);
}
rtas_dir = proc_mkdir("rtas", 0);
if (!rtas_dir) {
printk(KERN_ERR "Failed to create rtas proc directory\n");
if (proc_rtas == NULL) {
printk(KERN_ERR "Failed to create /proc/rtas in rtas_init\n");
} else {
entry = create_proc_entry("error_log", S_IRUSR, rtas_dir);
entry = create_proc_entry("error_log", S_IRUSR, proc_rtas);
if (entry)
entry->proc_fops = &proc_rtas_log_operations;
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment