@@ -66,7 +66,7 @@ use alloc::{
66
66
format,
67
67
string:: { String , ToString } ,
68
68
} ;
69
- use core:: mem;
69
+ use core:: { mem, str :: FromStr } ;
70
70
use log:: { error, warn} ;
71
71
use misc:: { ArgNum , LocalNum } ;
72
72
use name_object:: Target ;
@@ -171,7 +171,7 @@ impl AmlContext {
171
171
format ! ( "buf {:X?}" , abbreviated)
172
172
}
173
173
174
- if stream. len ( ) == 0 {
174
+ if stream. is_empty ( ) {
175
175
return Err ( AmlError :: UnexpectedEndOfStream ) ;
176
176
}
177
177
@@ -287,7 +287,7 @@ impl AmlContext {
287
287
self . namespace . clone ( ) . traverse ( |path, level : & NamespaceLevel | match level. typ {
288
288
LevelType :: Device => {
289
289
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 ( ) ) ?
291
291
. as_status ( ) ?
292
292
} else {
293
293
StatusObject :: default ( )
@@ -298,7 +298,7 @@ impl AmlContext {
298
298
*/
299
299
if status. present && level. values . contains_key ( & NameSeg :: from_str ( "_INI" ) . unwrap ( ) ) {
300
300
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 ( ) ) ?;
302
302
}
303
303
304
304
/*
@@ -339,7 +339,7 @@ impl AmlContext {
339
339
340
340
/// Get the current value of a local by its local number. Can only be executed from inside a control method.
341
341
pub ( crate ) fn local ( & self , local : LocalNum ) -> Result < & AmlValue , AmlError > {
342
- if let None = self . method_context {
342
+ if self . method_context . is_none ( ) {
343
343
return Err ( AmlError :: NotExecutingControlMethod ) ;
344
344
}
345
345
if local > 7 {
@@ -384,7 +384,7 @@ impl AmlContext {
384
384
}
385
385
386
386
Target :: Arg ( arg_num) => {
387
- if let None = self . method_context {
387
+ if self . method_context . is_none ( ) {
388
388
return Err ( AmlError :: NotExecutingControlMethod ) ;
389
389
}
390
390
@@ -399,7 +399,7 @@ impl AmlContext {
399
399
}
400
400
401
401
Target :: Local ( local_num) => {
402
- if let None = self . method_context {
402
+ if self . method_context . is_none ( ) {
403
403
return Err ( AmlError :: NotExecutingControlMethod ) ;
404
404
}
405
405
@@ -454,49 +454,53 @@ impl AmlContext {
454
454
AmlName :: from_str ( "\\ _OSI" ) . unwrap ( ) ,
455
455
AmlValue :: native_method ( 1 , false , 0 , |context| {
456
456
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
+ }
495
488
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
+ )
500
504
} ) ,
501
505
)
502
506
. unwrap ( ) ;
0 commit comments