|
@@ -564,6 +564,31 @@ int setting_applies ( struct settings *settings,
|
564
|
564
|
settings->op->applies ( settings, setting ) : 1 );
|
565
|
565
|
}
|
566
|
566
|
|
|
567
|
+/**
|
|
568
|
+ * Find setting applicable to settings block, if any
|
|
569
|
+ *
|
|
570
|
+ * @v settings Settings block
|
|
571
|
+ * @v setting Setting
|
|
572
|
+ * @ret setting Applicable setting, if any
|
|
573
|
+ */
|
|
574
|
+static const struct setting *
|
|
575
|
+applicable_setting ( struct settings *settings, const struct setting *setting ){
|
|
576
|
+ const struct setting *applicable;
|
|
577
|
+
|
|
578
|
+ /* If setting is already applicable, use it */
|
|
579
|
+ if ( setting_applies ( settings, setting ) )
|
|
580
|
+ return setting;
|
|
581
|
+
|
|
582
|
+ /* Otherwise, look for a matching predefined setting which does apply */
|
|
583
|
+ for_each_table_entry ( applicable, SETTINGS ) {
|
|
584
|
+ if ( ( setting_cmp ( setting, applicable ) == 0 ) &&
|
|
585
|
+ ( setting_applies ( settings, applicable ) ) )
|
|
586
|
+ return applicable;
|
|
587
|
+ }
|
|
588
|
+
|
|
589
|
+ return NULL;
|
|
590
|
+}
|
|
591
|
+
|
567
|
592
|
/**
|
568
|
593
|
* Store value of setting
|
569
|
594
|
*
|
|
@@ -580,7 +605,7 @@ int store_setting ( struct settings *settings, const struct setting *setting,
|
580
|
605
|
/* Find target settings block */
|
581
|
606
|
settings = settings_target ( settings );
|
582
|
607
|
|
583
|
|
- /* Fail if tag does not apply to this settings block */
|
|
608
|
+ /* Fail if setting does not apply to this settings block */
|
584
|
609
|
if ( ! setting_applies ( settings, setting ) )
|
585
|
610
|
return -ENOTTY;
|
586
|
611
|
|
|
@@ -628,6 +653,7 @@ int store_setting ( struct settings *settings, const struct setting *setting,
|
628
|
653
|
int fetch_setting ( struct settings *settings, const struct setting *setting,
|
629
|
654
|
struct settings **origin, struct setting *fetched,
|
630
|
655
|
void *data, size_t len ) {
|
|
656
|
+ const struct setting *applicable;
|
631
|
657
|
struct settings *child;
|
632
|
658
|
struct setting tmp;
|
633
|
659
|
int ret;
|
|
@@ -646,11 +672,11 @@ int fetch_setting ( struct settings *settings, const struct setting *setting,
|
646
|
672
|
if ( ! settings->op->fetch )
|
647
|
673
|
return -ENOTSUP;
|
648
|
674
|
|
649
|
|
- /* Try this block first, if applicable */
|
650
|
|
- if ( setting_applies ( settings, setting ) ) {
|
|
675
|
+ /* Try this block first, if an applicable setting exists */
|
|
676
|
+ if ( ( applicable = applicable_setting ( settings, setting ) ) ) {
|
651
|
677
|
|
652
|
678
|
/* Create modifiable copy of setting */
|
653
|
|
- memcpy ( &tmp, setting, sizeof ( tmp ) );
|
|
679
|
+ memcpy ( &tmp, applicable, sizeof ( tmp ) );
|
654
|
680
|
if ( ( ret = settings->op->fetch ( settings, &tmp,
|
655
|
681
|
data, len ) ) >= 0 ) {
|
656
|
682
|
|