]> err.no Git - linux-2.6/blob - drivers/s390/char/sclp_config.c
Merge branch 'linux-2.6'
[linux-2.6] / 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 "sclp.h"
14
15 #define TAG     "sclp_config: "
16
17 struct conf_mgm_data {
18         u8 reserved;
19         u8 ev_qualifier;
20 } __attribute__((packed));
21
22 #define EV_QUAL_CAP_CHANGE      3
23
24 static struct work_struct sclp_cpu_capability_work;
25
26 static void sclp_cpu_capability_notify(struct work_struct *work)
27 {
28         int cpu;
29         struct sys_device *sysdev;
30
31         printk(KERN_WARNING TAG "cpu capability changed.\n");
32         get_online_cpus();
33         for_each_online_cpu(cpu) {
34                 sysdev = get_cpu_sysdev(cpu);
35                 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
36         }
37         put_online_cpus();
38 }
39
40 static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
41 {
42         struct conf_mgm_data *cdata;
43
44         cdata = (struct conf_mgm_data *)(evbuf + 1);
45         if (cdata->ev_qualifier == EV_QUAL_CAP_CHANGE)
46                 schedule_work(&sclp_cpu_capability_work);
47 }
48
49 static struct sclp_register sclp_conf_register =
50 {
51         .receive_mask = EVTYP_CONFMGMDATA_MASK,
52         .receiver_fn  = sclp_conf_receiver_fn,
53 };
54
55 static int __init sclp_conf_init(void)
56 {
57         int rc;
58
59         INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
60
61         rc = sclp_register(&sclp_conf_register);
62         if (rc) {
63                 printk(KERN_ERR TAG "failed to register (%d).\n", rc);
64                 return rc;
65         }
66
67         if (!(sclp_conf_register.sclp_receive_mask & EVTYP_CONFMGMDATA_MASK)) {
68                 printk(KERN_WARNING TAG "no configuration management.\n");
69                 sclp_unregister(&sclp_conf_register);
70                 rc = -ENOSYS;
71         }
72         return rc;
73 }
74
75 __initcall(sclp_conf_init);