pc-bios/s390-ccw: Move the inner logic of find_subch() to a separate function
Move the code to a separate function to be able to re-use it from a different spot later. Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-Id: <20200806105349.632-5-thuth@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
f3180b0266
commit
d2cf4af1f4
@ -51,29 +51,19 @@ unsigned int get_loadparm_index(void)
|
||||
return atoui(loadparm_str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the subchannel connected to the given device (dev_no) and fill in the
|
||||
* subchannel information block (schib) with the connected subchannel's info.
|
||||
* NOTE: The global variable blk_schid is updated to contain the subchannel
|
||||
* information.
|
||||
*
|
||||
* If the caller gives dev_no=-1 then the user did not specify a boot device.
|
||||
* In this case we'll just use the first potentially bootable device we find.
|
||||
*/
|
||||
static bool find_subch(int dev_no)
|
||||
static int is_dev_possibly_bootable(int dev_no, int sch_no)
|
||||
{
|
||||
Schib schib;
|
||||
int i, r;
|
||||
bool is_virtio;
|
||||
Schib schib;
|
||||
int r;
|
||||
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
blk_schid.sch_no = i;
|
||||
blk_schid.sch_no = sch_no;
|
||||
r = stsch_err(blk_schid, &schib);
|
||||
if ((r == 3) || (r == -EIO)) {
|
||||
break;
|
||||
if (r == 3 || r == -EIO) {
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!schib.pmcw.dnv) {
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
enable_subchannel(blk_schid);
|
||||
@ -85,7 +75,7 @@ static bool find_subch(int dev_no)
|
||||
*/
|
||||
is_virtio = virtio_is_supported(blk_schid);
|
||||
|
||||
/* No specific devno given, just return 1st possibly bootable device */
|
||||
/* No specific devno given, just return whether the device is possibly bootable */
|
||||
if (dev_no < 0) {
|
||||
switch (cutype) {
|
||||
case CU_TYPE_VIRTIO:
|
||||
@ -98,12 +88,12 @@ static bool find_subch(int dev_no)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
return false;
|
||||
case CU_TYPE_DASD_3990:
|
||||
case CU_TYPE_DASD_2107:
|
||||
return true;
|
||||
default:
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +101,31 @@ static bool find_subch(int dev_no)
|
||||
if (schib.pmcw.dev == dev_no) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the subchannel connected to the given device (dev_no) and fill in the
|
||||
* subchannel information block (schib) with the connected subchannel's info.
|
||||
* NOTE: The global variable blk_schid is updated to contain the subchannel
|
||||
* information.
|
||||
*
|
||||
* If the caller gives dev_no=-1 then the user did not specify a boot device.
|
||||
* In this case we'll just use the first potentially bootable device we find.
|
||||
*/
|
||||
static bool find_subch(int dev_no)
|
||||
{
|
||||
int i, r;
|
||||
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
r = is_dev_possibly_bootable(dev_no, i);
|
||||
if (r < 0) {
|
||||
break;
|
||||
}
|
||||
if (r == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user