Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee13...
[sfrench/cifs-2.6.git] / arch / sparc64 / solaris / misc.c
index 5284996780a78fa169243a364ba96f22827d7934..9c581328e76a191e3b4aa4903840276db2c3aab2 100644 (file)
@@ -4,7 +4,6 @@
  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  */
 
-#include <linux/config.h>
 #include <linux/module.h> 
 #include <linux/types.h>
 #include <linux/smp_lock.h>
@@ -12,6 +11,7 @@
 #include <linux/limits.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
+#include <linux/tty.h>
 #include <linux/mman.h>
 #include <linux/file.h>
 #include <linux/timex.h>
@@ -23,6 +23,7 @@
 #include <asm/oplib.h>
 #include <asm/idprom.h>
 #include <asm/smp.h>
+#include <asm/prom.h>
 
 #include "conv.h"
 
@@ -194,14 +195,17 @@ static char *machine(void)
        }
 }
 
-static char *platform(char *buffer)
+static char *platform(char *buffer, int sz)
 {
+       struct device_node *dp = of_find_node_by_path("/");
        int len;
 
        *buffer = 0;
-       len = prom_getproperty(prom_root_node, "name", buffer, 256);
-       if(len > 0)
-               buffer[len] = 0;
+       len = strlen(dp->name);
+       if (len > sz)
+               len = sz;
+       memcpy(buffer, dp->name, len);
+       buffer[len] = 0;
        if (*buffer) {
                char *p;
 
@@ -213,16 +217,22 @@ static char *platform(char *buffer)
        return "sun4u";
 }
 
-static char *serial(char *buffer)
+static char *serial(char *buffer, int sz)
 {
-       int node = prom_getchild(prom_root_node);
+       struct device_node *dp = of_find_node_by_path("/options");
        int len;
 
-       node = prom_searchsiblings(node, "options");
        *buffer = 0;
-       len = prom_getproperty(node, "system-board-serial#", buffer, 256);
-       if(len > 0)
-               buffer[len] = 0;
+       if (dp) {
+               char *val = of_get_property(dp, "system-board-serial#", &len);
+
+               if (val && len > 0) {
+                       if (len > sz)
+                               len = sz;
+                       memcpy(buffer, val, len);
+                       buffer[len] = 0;
+               }
+       }
        if (!*buffer)
                return "4512348717234";
        else
@@ -305,8 +315,8 @@ asmlinkage int solaris_sysinfo(int cmd, u32 buf, s32 count)
        case SI_MACHINE: r = machine(); break;
        case SI_ARCHITECTURE: r = "sparc"; break;
        case SI_HW_PROVIDER: r = "Sun_Microsystems"; break;
-       case SI_HW_SERIAL: r = serial(buffer); break;
-       case SI_PLATFORM: r = platform(buffer); break;
+       case SI_HW_SERIAL: r = serial(buffer, sizeof(buffer)); break;
+       case SI_PLATFORM: r = platform(buffer, sizeof(buffer)); break;
        case SI_SRPC_DOMAIN: r = ""; break;
        case SI_VERSION: r = "Generic"; break;
        default: return -EINVAL;
@@ -413,7 +423,9 @@ asmlinkage int solaris_procids(int cmd, s32 pid, s32 pgid)
                           Solaris setpgrp and setsid? */
                        ret = sys_setpgid(0, 0);
                        if (ret) return ret;
+                       mutex_lock(&tty_mutex);
                        current->signal->tty = NULL;
+                       mutex_unlock(&tty_mutex);
                        return process_group(current);
                }
        case 2: /* getsid */
@@ -727,20 +739,15 @@ struct exec_domain solaris_exec_domain = {
 
 extern int init_socksys(void);
 
-#ifdef MODULE
-
 MODULE_AUTHOR("Jakub Jelinek (jj@ultra.linux.cz), Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz)");
 MODULE_DESCRIPTION("Solaris binary emulation module");
 MODULE_LICENSE("GPL");
 
-#ifdef __sparc_v9__
 extern u32 tl0_solaris[8];
 #define update_ttable(x)                                                                               \
        tl0_solaris[3] = (((long)(x) - (long)tl0_solaris - 3) >> 2) | 0x40000000;                       \
        wmb();          \
        __asm__ __volatile__ ("flush %0" : : "r" (&tl0_solaris[3]))
-#else
-#endif 
 
 extern u32 solaris_sparc_syscall[];
 extern u32 solaris_syscall[];
@@ -748,7 +755,7 @@ extern void cleanup_socksys(void);
 
 extern u32 entry64_personality_patch;
 
-int init_module(void)
+static int __init solaris_init(void)
 {
        int ret;
 
@@ -768,19 +775,12 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+static void __exit solaris_exit(void)
 {
        update_ttable(solaris_syscall);
        cleanup_socksys();
        unregister_exec_domain(&solaris_exec_domain);
 }
 
-#else
-int init_solaris_emul(void)
-{
-       register_exec_domain(&solaris_exec_domain);
-       init_socksys();
-       return 0;
-}
-#endif
-
+module_init(solaris_init);
+module_exit(solaris_exit);