Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Functions for registration of I/O interruption subclasses on s390.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright IBM Corp. 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Authors: Sebastian Ott <sebott@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/isc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static unsigned int isc_refs[MAX_ISC + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static DEFINE_SPINLOCK(isc_ref_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * isc_register - register an I/O interruption subclass.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @isc: I/O interruption subclass to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * The number of users for @isc is increased. If this is the first user to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * register @isc, the corresponding I/O interruption subclass mask is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * Context:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  *   This function must not be called in interrupt context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void isc_register(unsigned int isc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	if (isc > MAX_ISC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	spin_lock(&isc_ref_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (isc_refs[isc] == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		ctl_set_bit(6, 31 - isc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	isc_refs[isc]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	spin_unlock(&isc_ref_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) EXPORT_SYMBOL_GPL(isc_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)  * isc_unregister - unregister an I/O interruption subclass.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)  * @isc: I/O interruption subclass to unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  * The number of users for @isc is decreased. If this is the last user to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  * unregister @isc, the corresponding I/O interruption subclass mask is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  * disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  * Note: This function must not be called if isc_register() hasn't been called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  * before by the driver for @isc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  * Context:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  *   This function must not be called in interrupt context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void isc_unregister(unsigned int isc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	spin_lock(&isc_ref_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	/* check for misuse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (isc > MAX_ISC || isc_refs[isc] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	if (isc_refs[isc] == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		ctl_clear_bit(6, 31 - isc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	isc_refs[isc]--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	spin_unlock(&isc_ref_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) EXPORT_SYMBOL_GPL(isc_unregister);