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) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <asm/macio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 	struct platform_device *of;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 	const char *compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	int cplen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	int length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	of = &to_macio_device (dev)->ofdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	compat = of_get_property(of->dev.of_node, "compatible", &cplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	if (!compat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		*buf = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	while (cplen > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		int l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		length += sprintf (buf, "%s\n", compat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		buf += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		l = strlen (compat) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		compat += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		cplen -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	return length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static DEVICE_ATTR_RO(compatible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 			      char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	return of_device_modalias(dev, buf, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static ssize_t devspec_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 				struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	struct platform_device *ofdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	ofdev = to_platform_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	return sprintf(buf, "%pOF\n", ofdev->dev.of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static DEVICE_ATTR_RO(modalias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static DEVICE_ATTR_RO(devspec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static ssize_t name_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 			 struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return sprintf(buf, "%pOFn\n", dev->of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static DEVICE_ATTR_RO(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static ssize_t type_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			 struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	return sprintf(buf, "%s\n", of_node_get_device_type(dev->of_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static DEVICE_ATTR_RO(type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static struct attribute *macio_dev_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	&dev_attr_name.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	&dev_attr_type.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	&dev_attr_compatible.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	&dev_attr_modalias.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	&dev_attr_devspec.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static const struct attribute_group macio_dev_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	.attrs = macio_dev_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) const struct attribute_group *macio_dev_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	&macio_dev_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };