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)  * compat.c - A series of functions to make it easier to convert drivers that use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *            the old isapnp APIs. If possible use the new APIs instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright 2002 Adam Belay <ambx1@neo.rr.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/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/isapnp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static void pnp_convert_id(char *buf, unsigned short vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 			   unsigned short device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	sprintf(buf, "%c%c%c%x%x%x%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		'A' + ((vendor >> 2) & 0x3f) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		'A' + ((vendor >> 8) & 0x1f) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		(device >> 4) & 0x0f, device & 0x0f,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		(device >> 12) & 0x0f, (device >> 8) & 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct pnp_dev *pnp_find_dev(struct pnp_card *card, unsigned short vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 			     unsigned short function, struct pnp_dev *from)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	char id[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	char any[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	pnp_convert_id(id, vendor, function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	if (card == NULL) {	/* look for a logical device from all cards */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		struct list_head *list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		list = pnp_global.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		if (from)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			list = from->global_list.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		while (list != &pnp_global) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 			struct pnp_dev *dev = global_to_pnp_dev(list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 			if (compare_pnp_id(dev->id, id) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			    (memcmp(id, any, 7) == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 				return dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			list = list->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		struct list_head *list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		list = card->devices.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		if (from) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			list = from->card_list.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 			if (from->card != card)	/* something is wrong */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 				return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		while (list != &card->devices) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 			struct pnp_dev *dev = card_to_pnp_dev(list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			if (compare_pnp_id(dev->id, id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 				return dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 			list = list->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) EXPORT_SYMBOL(pnp_find_dev);