@@ -66,7 +66,7 @@ use alloc::{
6666 format,
6767 string:: { String , ToString } ,
6868} ;
69- use core:: mem;
69+ use core:: { mem, str :: FromStr } ;
7070use log:: { error, warn} ;
7171use misc:: { ArgNum , LocalNum } ;
7272use name_object:: Target ;
@@ -171,7 +171,7 @@ impl AmlContext {
171171 format ! ( "buf {:X?}" , abbreviated)
172172 }
173173
174- if stream. len ( ) == 0 {
174+ if stream. is_empty ( ) {
175175 return Err ( AmlError :: UnexpectedEndOfStream ) ;
176176 }
177177
@@ -287,7 +287,7 @@ impl AmlContext {
287287 self . namespace . clone ( ) . traverse ( |path, level : & NamespaceLevel | match level. typ {
288288 LevelType :: Device => {
289289 let status = if level. values . contains_key ( & NameSeg :: from_str ( "_STA" ) . unwrap ( ) ) {
290- self . invoke_method ( & AmlName :: from_str ( "_STA" ) . unwrap ( ) . resolve ( & path) ?, Args :: default ( ) ) ?
290+ self . invoke_method ( & AmlName :: from_str ( "_STA" ) . unwrap ( ) . resolve ( path) ?, Args :: default ( ) ) ?
291291 . as_status ( ) ?
292292 } else {
293293 StatusObject :: default ( )
@@ -298,7 +298,7 @@ impl AmlContext {
298298 */
299299 if status. present && level. values . contains_key ( & NameSeg :: from_str ( "_INI" ) . unwrap ( ) ) {
300300 log:: info!( "Invoking _INI at level: {}" , path) ;
301- self . invoke_method ( & AmlName :: from_str ( "_INI" ) . unwrap ( ) . resolve ( & path) ?, Args :: default ( ) ) ?;
301+ self . invoke_method ( & AmlName :: from_str ( "_INI" ) . unwrap ( ) . resolve ( path) ?, Args :: default ( ) ) ?;
302302 }
303303
304304 /*
@@ -339,7 +339,7 @@ impl AmlContext {
339339
340340 /// Get the current value of a local by its local number. Can only be executed from inside a control method.
341341 pub ( crate ) fn local ( & self , local : LocalNum ) -> Result < & AmlValue , AmlError > {
342- if let None = self . method_context {
342+ if self . method_context . is_none ( ) {
343343 return Err ( AmlError :: NotExecutingControlMethod ) ;
344344 }
345345 if local > 7 {
@@ -384,7 +384,7 @@ impl AmlContext {
384384 }
385385
386386 Target :: Arg ( arg_num) => {
387- if let None = self . method_context {
387+ if self . method_context . is_none ( ) {
388388 return Err ( AmlError :: NotExecutingControlMethod ) ;
389389 }
390390
@@ -399,7 +399,7 @@ impl AmlContext {
399399 }
400400
401401 Target :: Local ( local_num) => {
402- if let None = self . method_context {
402+ if self . method_context . is_none ( ) {
403403 return Err ( AmlError :: NotExecutingControlMethod ) ;
404404 }
405405
@@ -454,49 +454,53 @@ impl AmlContext {
454454 AmlName :: from_str ( "\\ _OSI" ) . unwrap ( ) ,
455455 AmlValue :: native_method ( 1 , false , 0 , |context| {
456456 let value = context. current_arg ( 0 ) ?. clone ( ) ;
457- Ok ( match value. as_string ( context) ?. as_str ( ) {
458- "Windows 2000" => true , // 2000
459- "Windows 2001" => true , // XP
460- "Windows 2001 SP1" => true , // XP SP1
461- "Windows 2001 SP2" => true , // XP SP2
462- "Windows 2001.1" => true , // Server 2003
463- "Windows 2001.1 SP1" => true , // Server 2003 SP1
464- "Windows 2006" => true , // Vista
465- "Windows 2006 SP1" => true , // Vista SP1
466- "Windows 2006 SP2" => true , // Vista SP2
467- "Windows 2006.1" => true , // Server 2008
468- "Windows 2009" => true , // 7 and Server 2008 R2
469- "Windows 2012" => true , // 8 and Server 2012
470- "Windows 2013" => true , // 8.1 and Server 2012 R2
471- "Windows 2015" => true , // 10
472- "Windows 2016" => true , // 10 version 1607
473- "Windows 2017" => true , // 10 version 1703
474- "Windows 2017.2" => true , // 10 version 1709
475- "Windows 2018" => true , // 10 version 1803
476- "Windows 2018.2" => true , // 10 version 1809
477- "Windows 2019" => true , // 10 version 1903
478-
479- "Darwin" => true ,
480-
481- "Linux" => {
482- // TODO: should we allow users to specify that this should be true? Linux has a
483- // command line option for this.
484- warn ! ( "ACPI evaluated `_OSI(\" Linux\" )`. This is a bug. Reporting no support." ) ;
485- false
486- }
487-
488- "Extended Address Space Descriptor" => true ,
489- // TODO: support module devices
490- "Module Device" => false ,
491- "3.0 Thermal Model" => true ,
492- "3.0 _SCP Extensions" => true ,
493- // TODO: support processor aggregator devices
494- "Processor Aggregator Device" => false ,
457+ Ok (
458+ if match value. as_string ( context) ?. as_str ( ) {
459+ "Windows 2000" => true , // 2000
460+ "Windows 2001" => true , // XP
461+ "Windows 2001 SP1" => true , // XP SP1
462+ "Windows 2001 SP2" => true , // XP SP2
463+ "Windows 2001.1" => true , // Server 2003
464+ "Windows 2001.1 SP1" => true , // Server 2003 SP1
465+ "Windows 2006" => true , // Vista
466+ "Windows 2006 SP1" => true , // Vista SP1
467+ "Windows 2006 SP2" => true , // Vista SP2
468+ "Windows 2006.1" => true , // Server 2008
469+ "Windows 2009" => true , // 7 and Server 2008 R2
470+ "Windows 2012" => true , // 8 and Server 2012
471+ "Windows 2013" => true , // 8.1 and Server 2012 R2
472+ "Windows 2015" => true , // 10
473+ "Windows 2016" => true , // 10 version 1607
474+ "Windows 2017" => true , // 10 version 1703
475+ "Windows 2017.2" => true , // 10 version 1709
476+ "Windows 2018" => true , // 10 version 1803
477+ "Windows 2018.2" => true , // 10 version 1809
478+ "Windows 2019" => true , // 10 version 1903
479+
480+ "Darwin" => true ,
481+
482+ "Linux" => {
483+ // TODO: should we allow users to specify that this should be true? Linux has a
484+ // command line option for this.
485+ warn ! ( "ACPI evaluated `_OSI(\" Linux\" )`. This is a bug. Reporting no support." ) ;
486+ false
487+ }
495488
496- _ => false ,
497- }
498- . then_some ( AmlValue :: ones ( ) )
499- . unwrap_or ( AmlValue :: zero ( ) ) )
489+ "Extended Address Space Descriptor" => true ,
490+ // TODO: support module devices
491+ "Module Device" => false ,
492+ "3.0 Thermal Model" => true ,
493+ "3.0 _SCP Extensions" => true ,
494+ // TODO: support processor aggregator devices
495+ "Processor Aggregator Device" => false ,
496+
497+ _ => false ,
498+ } {
499+ AmlValue :: ones ( )
500+ } else {
501+ AmlValue :: zero ( )
502+ } ,
503+ )
500504 } ) ,
501505 )
502506 . unwrap ( ) ;
0 commit comments