aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2008-07-14 03:59:00 -0400
committerHeiko Carstens <heiko.carstens@de.ibm.com>2008-07-14 04:02:11 -0400
commitfcc6ab335ba4d0f2b2548a910466c0dac767e5b1 (patch)
tree2a20c5b66c7e5528cb374034f0a3d7415d5a1a3a
parentda7c5af82879828409f6b81431ac2f9f353ab04e (diff)
[S390] cio: introduce isc_(un)register functions.
This interface makes it easy for drivers to register usage of different I/O interruption subclasses without needing to worry about possible other users of the same isc. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r--drivers/s390/cio/Makefile4
-rw-r--r--drivers/s390/cio/isc.c68
-rw-r--r--include/asm-s390/isc.h6
3 files changed, 76 insertions, 2 deletions
diff --git a/drivers/s390/cio/Makefile b/drivers/s390/cio/Makefile
index e199c927b7aa..6735ebb3c988 100644
--- a/drivers/s390/cio/Makefile
+++ b/drivers/s390/cio/Makefile
@@ -2,8 +2,8 @@
2# Makefile for the S/390 common i/o drivers 2# Makefile for the S/390 common i/o drivers
3# 3#
4 4
5obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o scsw.o fcx.o \ 5obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o scsw.o \
6 itcw.o 6 fcx.o itcw.o
7ccw_device-objs += device.o device_fsm.o device_ops.o 7ccw_device-objs += device.o device_fsm.o device_ops.o
8ccw_device-objs += device_id.o device_pgid.o device_status.o 8ccw_device-objs += device_id.o device_pgid.o device_status.o
9obj-y += ccw_device.o cmf.o 9obj-y += ccw_device.o cmf.o
diff --git a/drivers/s390/cio/isc.c b/drivers/s390/cio/isc.c
new file mode 100644
index 000000000000..c592087be0f1
--- /dev/null
+++ b/drivers/s390/cio/isc.c
@@ -0,0 +1,68 @@
1/*
2 * Functions for registration of I/O interruption subclasses on s390.
3 *
4 * Copyright IBM Corp. 2008
5 * Authors: Sebastian Ott <sebott@linux.vnet.ibm.com>
6 */
7
8#include <linux/spinlock.h>
9#include <linux/module.h>
10#include <asm/isc.h>
11
12static unsigned int isc_refs[MAX_ISC + 1];
13static DEFINE_SPINLOCK(isc_ref_lock);
14
15
16/**
17 * isc_register - register an I/O interruption subclass.
18 * @isc: I/O interruption subclass to register
19 *
20 * The number of users for @isc is increased. If this is the first user to
21 * register @isc, the corresponding I/O interruption subclass mask is enabled.
22 *
23 * Context:
24 * This function must not be called in interrupt context.
25 */
26void isc_register(unsigned int isc)
27{
28 if (isc > MAX_ISC) {
29 WARN_ON(1);
30 return;
31 }
32
33 spin_lock(&isc_ref_lock);
34 if (isc_refs[isc] == 0)
35 ctl_set_bit(6, 31 - isc);
36 isc_refs[isc]++;
37 spin_unlock(&isc_ref_lock);
38}
39EXPORT_SYMBOL_GPL(isc_register);
40
41/**
42 * isc_unregister - unregister an I/O interruption subclass.
43 * @isc: I/O interruption subclass to unregister
44 *
45 * The number of users for @isc is decreased. If this is the last user to
46 * unregister @isc, the corresponding I/O interruption subclass mask is
47 * disabled.
48 * Note: This function must not be called if isc_register() hasn't been called
49 * before by the driver for @isc.
50 *
51 * Context:
52 * This function must not be called in interrupt context.
53 */
54void isc_unregister(unsigned int isc)
55{
56 spin_lock(&isc_ref_lock);
57 /* check for misuse */
58 if (isc > MAX_ISC || isc_refs[isc] == 0) {
59 WARN_ON(1);
60 goto out_unlock;
61 }
62 if (isc_refs[isc] == 1)
63 ctl_clear_bit(6, 31 - isc);
64 isc_refs[isc]--;
65out_unlock:
66 spin_unlock(&isc_ref_lock);
67}
68EXPORT_SYMBOL_GPL(isc_unregister);
diff --git a/include/asm-s390/isc.h b/include/asm-s390/isc.h
index 533a1372234a..fe56f7b445ea 100644
--- a/include/asm-s390/isc.h
+++ b/include/asm-s390/isc.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_S390_ISC_H 1#ifndef _ASM_S390_ISC_H
2#define _ASM_S390_ISC_H 2#define _ASM_S390_ISC_H
3 3
4#include <linux/types.h>
5
4/* 6/*
5 * I/O interruption subclasses used by drivers. 7 * I/O interruption subclasses used by drivers.
6 * Please add all used iscs here so that it is possible to distribute 8 * Please add all used iscs here so that it is possible to distribute
@@ -15,4 +17,8 @@
15/* Adapter interrupts. */ 17/* Adapter interrupts. */
16#define QDIO_AIRQ_ISC IO_SCH_ISC /* I/O subchannel in qdio mode */ 18#define QDIO_AIRQ_ISC IO_SCH_ISC /* I/O subchannel in qdio mode */
17 19
20/* Functions for registration of I/O interruption subclasses */
21void isc_register(unsigned int isc);
22void isc_unregister(unsigned int isc);
23
18#endif /* _ASM_S390_ISC_H */ 24#endif /* _ASM_S390_ISC_H */