Skip to content

Commit

Permalink
Refactoring s390 code and fix for bnc813835
Browse files Browse the repository at this point in the history
The s390_DeviceReady condition in handleOverview returned wrong results for
non-s390s; the rest is refactoring.
  • Loading branch information
mchf committed Apr 25, 2013
1 parent d2192d2 commit dab503d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 11 additions & 4 deletions src/lan/complex.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,21 @@ once you have installed the firmware.")));
return true;
}

/**
* Returns true if the device can be used (means handled as normal linux device)
* or false otherwise (it is used mainly at s390 based systems where a special
* handling is needed to run linux device emulation)
*/
define boolean DeviceReady( string devname)
{
return !Arch::s390() || s390_DriverLoaded( devname);
}


define void initIPv6 (string key) {
UI::ChangeWidget (`id (`ipv6), `Value, Lan::ipv6 ? true : false);
}


define symbol handleIPv6( string key, map event ) {
if (event["EventReason"]:""=="ValueChanged") Lan::SetIPv6((boolean)UI::QueryWidget (`id (`ipv6), `Value));
return nil;
Expand Down Expand Up @@ -314,8 +323,6 @@ void initOverview (string key) ``{
y2milestone("LanItems %1", LanItems::Items);
}



symbol handleOverview( string key, map event ) {

if (!disableItemsIfNM([`_hw_items, `_hw_sum, `add, `edit, `delete], false))
Expand Down Expand Up @@ -356,7 +363,7 @@ the interface will no longer be managed by NetworkManager.
if (! AddInterface ())
break;

if( !s390_DeviceReady( LanItems::getCurrentItem()[ "hwinfo", "dev_name"]:"") )
if( !DeviceReady( LanItems::getCurrentItem()[ "hwinfo", "dev_name"]:"") )
{
return `init_s390;
}
Expand Down
15 changes: 5 additions & 10 deletions src/lan/s390.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ const string sys_dir = "/sys/class/net";
*/
define boolean s390_DriverLoaded( string devname)
{
if( !Arch::s390())
return false;

if( IsEmptyString( devname))
return false;

return FileUtils::IsDirectory( sformat( "%1/%2", sys_dir, devname)) == true;
}

/**
* Returns true if running at s390 architecture and linux net device emulation was started successfully
*/
define boolean s390_DeviceReady( string devname)
{
return Arch::s390() && s390_DriverLoaded( devname);
}

/**
* Reads particular qeth attribute and returns its value as a string.
*
Expand All @@ -40,7 +35,7 @@ define boolean s390_DeviceReady( string devname)
*/
define string s390_ReadQethAttribute( string devname, string attrib)
{
if( !s390_DeviceReady( devname))
if( !s390_DriverLoaded( devname))
return nil;

string result = (string) SCR::Read( .target.string, sformat( "%1/%2/device/%3", sys_dir, devname, attrib));
Expand All @@ -66,7 +61,7 @@ define string s390_ReadQethAttribute( string devname, string attrib)
*/
define map<string, any> s390_ReadQethConfig( string devname)
{
if( !s390_DeviceReady( devname))
if( !s390_DriverLoaded( devname))
return $[];

map<string, any> result = $[];
Expand Down

0 comments on commit dab503d

Please sign in to comment.