Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[pandora-kernel.git] / drivers / s390 / char / sclp_config.c
1 /*
2  *  drivers/s390/char/sclp_config.c
3  *
4  *    Copyright IBM Corp. 2007
5  *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6  */
7
8 #include <linux/init.h>
9 #include <linux/errno.h>
10 #include <linux/cpu.h>
11 #include <linux/sysdev.h>
12 #include <linux/workqueue.h>
13 #include <asm/smp.h>
14 #include "sclp.h"
15
16 #define TAG     "sclp_config: "
17
18 struct conf_mgm_data {
19         u8 reserved;
20         u8 ev_qualifier;
21 } __attribute__((packed));
22
23 #define EV_QUAL_CPU_CHANGE      1
24 #define EV_QUAL_CAP_CHANGE      3
25
26 static struct work_struct sclp_cpu_capability_work;
27 static struct work_struct sclp_cpu_change_work;
28
29 static void sclp_cpu_capability_notify(struct work_struct *work)
30 {
31         int cpu;
32         struct sys_device *sysdev;
33
34         printk(KERN_WARNING TAG "cpu capability changed.\n");
35         get_online_cpus();
36         for_each_online_cpu(cpu) {
37                 sysdev = get_cpu_sysdev(cpu);
38                 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
39         }
40         put_online_cpus();
41 }
42
43 static void __ref sclp_cpu_change_notify(struct work_struct *work)
44 {
45         smp_rescan_cpus();
46 }
47
48 static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
49 {
50         struct conf_mgm_data *cdata;
51
52         cdata = (struct conf_mgm_data *)(evbuf + 1);
53         switch (cdata->ev_qualifier) {
54         case EV_QUAL_CPU_CHANGE:
55                 schedule_work(&sclp_cpu_change_work);
56                 break;
57         case EV_QUAL_CAP_CHANGE:
58                 schedule_work(&sclp_cpu_capability_work);
59                 break;
60         }
61 }
62
63 static struct sclp_register sclp_conf_register =
64 {
65         .receive_mask = EVTYP_CONFMGMDATA_MASK,
66         .receiver_fn  = sclp_conf_receiver_fn,
67 };
68
69 static int __init sclp_conf_init(void)
70 {
71         int rc;
72
73         INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
74         INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
75
76         rc = sclp_register(&sclp_conf_register);
77         if (rc)
78                 return rc;
79
80         if (!(sclp_conf_register.sclp_send_mask & EVTYP_CONFMGMDATA_MASK)) {
81                 printk(KERN_WARNING TAG "no configuration management.\n");
82                 sclp_unregister(&sclp_conf_register);
83                 rc = -ENOSYS;
84         }
85         return rc;
86 }
87
88 __initcall(sclp_conf_init);