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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *               2005-2007 Takahiro Hirofuchi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "usbip_common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "utils.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "sysfs_utils.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int modify_match_busid(char *busid, int add)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	char attr_name[] = "match_busid";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	char command[SYSFS_BUS_ID_SIZE + 4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	char match_busid_attr_path[SYSFS_PATH_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	int cmd_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	snprintf(match_busid_attr_path, sizeof(match_busid_attr_path),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		 "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		 SYSFS_BUS_TYPE, SYSFS_DRIVERS_NAME, USBIP_HOST_DRV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		 attr_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	if (add)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 				    busid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 				    busid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	rc = write_sysfs_attribute(match_busid_attr_path, command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 				   cmd_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (rc < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		dbg("failed to write match_busid: %s", strerror(errno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }