Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/ap: Externalize AP bus specific bitmap reading function

Rename hex2bitmap() to ap_hex2bitmap() and export it for external
use. This function will be used by the implementation of the vfio-ap
ap_config sysfs attribute.

Signed-off-by: "Jason J. Herne" <jjherne@linux.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Link: https://lore.kernel.org/r/20240415152555.13152-2-jjherne@linux.ibm.com
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Jason J. Herne and committed by
Alexander Gordeev
6e697394 ba05b39d

+25 -10
+3 -10
drivers/s390/crypto/ap_bus.c
··· 1043 1043 .notifier_call = ap_bus_cfg_chg, 1044 1044 }; 1045 1045 1046 - /* 1047 - * hex2bitmap() - parse hex mask string and set bitmap. 1048 - * Valid strings are "0x012345678" with at least one valid hex number. 1049 - * Rest of the bitmap to the right is padded with 0. No spaces allowed 1050 - * within the string, the leading 0x may be omitted. 1051 - * Returns the bitmask with exactly the bits set as given by the hex 1052 - * string (both in big endian order). 1053 - */ 1054 - static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) 1046 + int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits) 1055 1047 { 1056 1048 int i, n, b; 1057 1049 ··· 1070 1078 return -EINVAL; 1071 1079 return 0; 1072 1080 } 1081 + EXPORT_SYMBOL(ap_hex2bitmap); 1073 1082 1074 1083 /* 1075 1084 * modify_bitmap() - parse bitmask argument and modify an existing ··· 1136 1143 rc = modify_bitmap(str, newmap, bits); 1137 1144 } else { 1138 1145 memset(newmap, 0, size); 1139 - rc = hex2bitmap(str, newmap, bits); 1146 + rc = ap_hex2bitmap(str, newmap, bits); 1140 1147 } 1141 1148 return rc; 1142 1149 }
+22
drivers/s390/crypto/ap_bus.h
··· 344 344 struct mutex *lock); 345 345 346 346 /* 347 + * ap_hex2bitmap() - Convert a string containing a hexadecimal number (str) 348 + * into a bitmap (bitmap) with bits set that correspond to the bits represented 349 + * by the hex string. Input and output data is in big endian order. 350 + * 351 + * str - Input hex string of format "0x1234abcd". The leading "0x" is optional. 352 + * At least one digit is required. Must be large enough to hold the number of 353 + * bits represented by the bits parameter. 354 + * 355 + * bitmap - Pointer to a bitmap. Upon successful completion of this function, 356 + * this bitmap will have bits set to match the value of str. If bitmap is longer 357 + * than str, then the rightmost bits of bitmap are padded with zeros. Must be 358 + * large enough to hold the number of bits represented by the bits parameter. 359 + * 360 + * bits - Length, in bits, of the bitmap represented by str. Must be a multiple 361 + * of 8. 362 + * 363 + * Returns: 0 On success 364 + * -EINVAL If str format is invalid or bits is not a multiple of 8. 365 + */ 366 + int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits); 367 + 368 + /* 347 369 * Interface to wait for the AP bus to have done one initial ap bus 348 370 * scan and all detected APQNs have been bound to device drivers. 349 371 * If these both conditions are not fulfilled, this function blocks