mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zkey: Generalize the adapter serial number handling
Different crypto card types use different serial number formats. Generalize the handling of serial numbers so that the majority of the code does not have to care about the card type when dealing with it. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
ce4704f365
commit
d91e728e3c
@@ -558,7 +558,7 @@ int select_cca_adapter(struct cca_lib *cca, int card, int domain, bool verbose)
|
||||
{
|
||||
unsigned int adapters, adapter;
|
||||
char adapter_serialnr[9];
|
||||
char apqn_serialnr[9];
|
||||
char apqn_serialnr[SERIALNR_LENGTH];
|
||||
char temp[10];
|
||||
int rc, found = 0;
|
||||
|
||||
|
||||
@@ -224,10 +224,10 @@ out:
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 8 character ASCII serial number string of an card from the sysfs.
|
||||
* Gets the 8-16 character ASCII serial number string of an card from the sysfs.
|
||||
*
|
||||
* @param[in] card card number
|
||||
* @param[out] serialnr Result buffer
|
||||
* @param[out] serialnr Result buffer. Must be at least SERIALNR_LENGTH long.
|
||||
* @param[in] verbose if true, verbose messages are printed
|
||||
*
|
||||
* @returns 0 if the serial number was returned. -ENODEV if the APQN is not
|
||||
@@ -235,7 +235,7 @@ out:
|
||||
* -ENOTSUP if the serialnr sysfs attribute is not available, because
|
||||
* the zcrypt kernel module is on an older level.
|
||||
*/
|
||||
int sysfs_get_serialnr(int card, char serialnr[9], bool verbose)
|
||||
int sysfs_get_serialnr(int card, char *serialnr, bool verbose)
|
||||
{
|
||||
char *dev_path;
|
||||
int rc = 0;
|
||||
@@ -251,7 +251,8 @@ int sysfs_get_serialnr(int card, char serialnr[9], bool verbose)
|
||||
rc = -ENODEV;
|
||||
goto out;
|
||||
}
|
||||
if (util_file_read_line(serialnr, 9, "%s/serialnr", dev_path) != 0) {
|
||||
if (util_file_read_line(serialnr, SERIALNR_LENGTH, "%s/serialnr",
|
||||
dev_path) != 0) {
|
||||
rc = -ENOTSUP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ int sysfs_get_card_level(int card);
|
||||
|
||||
enum card_type sysfs_get_card_type(int card);
|
||||
|
||||
int sysfs_get_serialnr(int card, char serialnr[9], bool verbose);
|
||||
#define SERIALNR_LENGTH 17
|
||||
|
||||
int sysfs_get_serialnr(int card, char *serialnr, bool verbose);
|
||||
|
||||
struct fw_version {
|
||||
unsigned int major;
|
||||
|
||||
Reference in New Issue
Block a user