[PARISC] Add os_id_to_string helper
authorKyle McMartin <kyle@parisc-linux.org>
Sun, 25 Jun 2006 16:58:57 +0000 (16:58 +0000)
committerKyle McMartin <kyle@hera.kernel.org>
Tue, 27 Jun 2006 23:28:43 +0000 (23:28 +0000)
Add a helper to asm/pdc.h to translate OS_ID values to strings
and use it in the pdc_stable driver.

Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
drivers/parisc/pdc_stable.c
include/asm-parisc/pdc.h

index 97b345858043a2f1572c477888b0530176a97496..ea1b7a63598e1c4fc87ee001a66293cb2fe92b37 100644 (file)
@@ -622,22 +622,12 @@ static ssize_t
 pdcs_osid_read(struct subsystem *entry, char *buf)
 {
        char *out = buf;
-       char *tmpstr = NULL;
 
        if (!entry || !buf)
                return -EINVAL;
 
-       switch (pdcs_osid) {
-               case 0x0000:    tmpstr = "No OS"; break;
-               case 0x0001:    tmpstr = "HP-UX"; break;
-               case 0x0002:    tmpstr = "MPE-iX"; break;
-               case 0x0003:    tmpstr = "OSF"; break;
-               case 0x0004:    tmpstr = "HP-RT"; break;
-               case 0x0005:    tmpstr = "Novell Netware"; break;
-               case 0x0006:    tmpstr = "Linux"; break;
-               default:        tmpstr = "Unknown"; break;
-       }
-       out += sprintf(out, "%s dependent data (0x%.4x)\n", tmpstr, pdcs_osid);
+       out += sprintf(out, "%s dependent data (0x%.4x)\n",
+               os_id_to_string(pdcs_osid), pdcs_osid);
 
        return out - buf;
 }
index 33bff615d6e1922ba0fbaf9ba2c4f01aa6ab732c..7a21f106ade6bc7326bd62f158c39b1fa87329e9 100644 (file)
@@ -284,6 +284,19 @@ typedef struct {
 #define OS_ID_NOVEL            5       /* NOVELL OS            */
 #define OS_ID_LINUX            6       /* Linux                */
 
+static inline char * os_id_to_string(u16 os_id) {
+       switch(os_id) {
+       case OS_ID_NONE:        return "No OS";
+       case OS_ID_HPUX:        return "HP-UX";
+       case OS_ID_MPEXL:       return "MPE-iX";
+       case OS_ID_OSF:         return "OSF";
+       case OS_ID_HPRT:        return "HP-RT";
+       case OS_ID_NOVEL:       return "Novell Netware";
+       case OS_ID_LINUX:       return "Linux";
+       default:        return "Unknown";
+       }
+}
+
 
 /* constants for PDC_CHASSIS */
 #define OSTAT_OFF              0