mirror of
https://github.com/torvalds/linux.git
synced 2024-11-29 07:31:29 +00:00
s390/dasd: split up dasd_eckd_read_conf
Move the cabling check out of dasd_eckd_read_conf and split it up into separate functions to improve readability and re-use functions. Signed-off-by: Stefan Haberland <sth@linux.ibm.com> Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com> Link: https://lore.kernel.org/r/20211020115124.1735254-4-sth@linux.ibm.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
10c78e53ee
commit
23596961b4
@ -1071,15 +1071,55 @@ static void dasd_eckd_read_fc_security(struct dasd_device *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dasd_eckd_get_uid_string(struct dasd_eckd_private *private,
|
||||||
|
char *print_uid)
|
||||||
|
{
|
||||||
|
struct dasd_uid *uid;
|
||||||
|
|
||||||
|
uid = &private->uid;
|
||||||
|
if (strlen(uid->vduit) > 0)
|
||||||
|
snprintf(print_uid, sizeof(*print_uid),
|
||||||
|
"%s.%s.%04x.%02x.%s",
|
||||||
|
uid->vendor, uid->serial, uid->ssid,
|
||||||
|
uid->real_unit_addr, uid->vduit);
|
||||||
|
else
|
||||||
|
snprintf(print_uid, sizeof(*print_uid),
|
||||||
|
"%s.%s.%04x.%02x",
|
||||||
|
uid->vendor, uid->serial, uid->ssid,
|
||||||
|
uid->real_unit_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dasd_eckd_check_cabling(struct dasd_device *device,
|
||||||
|
void *conf_data, __u8 lpm)
|
||||||
|
{
|
||||||
|
struct dasd_eckd_private *private = device->private;
|
||||||
|
char print_path_uid[60], print_device_uid[60];
|
||||||
|
struct dasd_eckd_private path_private;
|
||||||
|
|
||||||
|
path_private.conf_data = conf_data;
|
||||||
|
path_private.conf_len = DASD_ECKD_RCD_DATA_SIZE;
|
||||||
|
if (dasd_eckd_identify_conf_parts(&path_private))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (dasd_eckd_compare_path_uid(device, &path_private)) {
|
||||||
|
dasd_eckd_get_uid_string(&path_private, print_path_uid);
|
||||||
|
dasd_eckd_get_uid_string(private, print_device_uid);
|
||||||
|
dev_err(&device->cdev->dev,
|
||||||
|
"Not all channel paths lead to the same device, path %02X leads to device %s instead of %s\n",
|
||||||
|
lpm, print_path_uid, print_device_uid);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int dasd_eckd_read_conf(struct dasd_device *device)
|
static int dasd_eckd_read_conf(struct dasd_device *device)
|
||||||
{
|
{
|
||||||
void *conf_data;
|
void *conf_data;
|
||||||
int conf_len, conf_data_saved;
|
int conf_len, conf_data_saved;
|
||||||
int rc, path_err, pos;
|
int rc, path_err, pos;
|
||||||
__u8 lpm, opm;
|
__u8 lpm, opm;
|
||||||
struct dasd_eckd_private *private, path_private;
|
struct dasd_eckd_private *private;
|
||||||
struct dasd_uid *uid;
|
|
||||||
char print_path_uid[60], print_device_uid[60];
|
|
||||||
|
|
||||||
private = device->private;
|
private = device->private;
|
||||||
opm = ccw_device_get_path_mask(device->cdev);
|
opm = ccw_device_get_path_mask(device->cdev);
|
||||||
@ -1123,59 +1163,11 @@ static int dasd_eckd_read_conf(struct dasd_device *device)
|
|||||||
*/
|
*/
|
||||||
dasd_eckd_generate_uid(device);
|
dasd_eckd_generate_uid(device);
|
||||||
conf_data_saved++;
|
conf_data_saved++;
|
||||||
} else {
|
} else if (dasd_eckd_check_cabling(device, conf_data, lpm)) {
|
||||||
path_private.conf_data = conf_data;
|
dasd_path_add_cablepm(device, lpm);
|
||||||
path_private.conf_len = DASD_ECKD_RCD_DATA_SIZE;
|
path_err = -EINVAL;
|
||||||
if (dasd_eckd_identify_conf_parts(
|
kfree(conf_data);
|
||||||
&path_private)) {
|
continue;
|
||||||
path_private.conf_data = NULL;
|
|
||||||
path_private.conf_len = 0;
|
|
||||||
kfree(conf_data);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (dasd_eckd_compare_path_uid(
|
|
||||||
device, &path_private)) {
|
|
||||||
uid = &path_private.uid;
|
|
||||||
if (strlen(uid->vduit) > 0)
|
|
||||||
snprintf(print_path_uid,
|
|
||||||
sizeof(print_path_uid),
|
|
||||||
"%s.%s.%04x.%02x.%s",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid, uid->real_unit_addr,
|
|
||||||
uid->vduit);
|
|
||||||
else
|
|
||||||
snprintf(print_path_uid,
|
|
||||||
sizeof(print_path_uid),
|
|
||||||
"%s.%s.%04x.%02x",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid,
|
|
||||||
uid->real_unit_addr);
|
|
||||||
uid = &private->uid;
|
|
||||||
if (strlen(uid->vduit) > 0)
|
|
||||||
snprintf(print_device_uid,
|
|
||||||
sizeof(print_device_uid),
|
|
||||||
"%s.%s.%04x.%02x.%s",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid, uid->real_unit_addr,
|
|
||||||
uid->vduit);
|
|
||||||
else
|
|
||||||
snprintf(print_device_uid,
|
|
||||||
sizeof(print_device_uid),
|
|
||||||
"%s.%s.%04x.%02x",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid,
|
|
||||||
uid->real_unit_addr);
|
|
||||||
dev_err(&device->cdev->dev,
|
|
||||||
"Not all channel paths lead to "
|
|
||||||
"the same device, path %02X leads to "
|
|
||||||
"device %s instead of %s\n", lpm,
|
|
||||||
print_path_uid, print_device_uid);
|
|
||||||
path_err = -EINVAL;
|
|
||||||
dasd_path_add_cablepm(device, lpm);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
path_private.conf_data = NULL;
|
|
||||||
path_private.conf_len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = pathmask_to_pos(lpm);
|
pos = pathmask_to_pos(lpm);
|
||||||
@ -1300,7 +1292,6 @@ static void dasd_eckd_path_available_action(struct dasd_device *device,
|
|||||||
struct pe_handler_work_data *data)
|
struct pe_handler_work_data *data)
|
||||||
{
|
{
|
||||||
struct dasd_eckd_private path_private;
|
struct dasd_eckd_private path_private;
|
||||||
struct dasd_uid *uid;
|
|
||||||
__u8 path_rcd_buf[DASD_ECKD_RCD_DATA_SIZE];
|
__u8 path_rcd_buf[DASD_ECKD_RCD_DATA_SIZE];
|
||||||
__u8 lpm, opm, npm, ppm, epm, hpfpm, cablepm;
|
__u8 lpm, opm, npm, ppm, epm, hpfpm, cablepm;
|
||||||
struct dasd_conf_data *conf_data;
|
struct dasd_conf_data *conf_data;
|
||||||
@ -1397,19 +1388,8 @@ static void dasd_eckd_path_available_action(struct dasd_device *device,
|
|||||||
if (rebuild_device_uid(device, data) ||
|
if (rebuild_device_uid(device, data) ||
|
||||||
dasd_eckd_compare_path_uid(
|
dasd_eckd_compare_path_uid(
|
||||||
device, &path_private)) {
|
device, &path_private)) {
|
||||||
uid = &path_private.uid;
|
dasd_eckd_get_uid_string(&path_private,
|
||||||
if (strlen(uid->vduit) > 0)
|
print_uid);
|
||||||
snprintf(print_uid, sizeof(print_uid),
|
|
||||||
"%s.%s.%04x.%02x.%s",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid, uid->real_unit_addr,
|
|
||||||
uid->vduit);
|
|
||||||
else
|
|
||||||
snprintf(print_uid, sizeof(print_uid),
|
|
||||||
"%s.%s.%04x.%02x",
|
|
||||||
uid->vendor, uid->serial,
|
|
||||||
uid->ssid,
|
|
||||||
uid->real_unit_addr);
|
|
||||||
dev_err(&device->cdev->dev,
|
dev_err(&device->cdev->dev,
|
||||||
"The newly added channel path %02X "
|
"The newly added channel path %02X "
|
||||||
"will not be used because it leads "
|
"will not be used because it leads "
|
||||||
@ -5820,15 +5800,7 @@ static int dasd_eckd_reload_device(struct dasd_device *device)
|
|||||||
dasd_eckd_get_uid(device, &uid);
|
dasd_eckd_get_uid(device, &uid);
|
||||||
|
|
||||||
if (old_base != uid.base_unit_addr) {
|
if (old_base != uid.base_unit_addr) {
|
||||||
if (strlen(uid.vduit) > 0)
|
dasd_eckd_get_uid_string(private, print_uid);
|
||||||
snprintf(print_uid, sizeof(print_uid),
|
|
||||||
"%s.%s.%04x.%02x.%s", uid.vendor, uid.serial,
|
|
||||||
uid.ssid, uid.base_unit_addr, uid.vduit);
|
|
||||||
else
|
|
||||||
snprintf(print_uid, sizeof(print_uid),
|
|
||||||
"%s.%s.%04x.%02x", uid.vendor, uid.serial,
|
|
||||||
uid.ssid, uid.base_unit_addr);
|
|
||||||
|
|
||||||
dev_info(&device->cdev->dev,
|
dev_info(&device->cdev->dev,
|
||||||
"An Alias device was reassigned to a new base device "
|
"An Alias device was reassigned to a new base device "
|
||||||
"with UID: %s\n", print_uid);
|
"with UID: %s\n", print_uid);
|
||||||
|
Loading…
Reference in New Issue
Block a user