diff options
author | Michael Brown <mcb30@ipxe.org> | 2011-03-22 16:56:35 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2011-03-22 19:54:58 +0000 |
commit | f5fd4dec3bab362a2ff7844859914e1f191fb905 (patch) | |
tree | 607eacef2f79c016a0c3c3031de2bb7d8aa7e331 /src/drivers/net/phantom | |
parent | 9215b7f4c0e24cceeac42d8ced5b4af824c4b011 (diff) | |
download | ipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.tar.gz |
[settings] Formalise notion of setting applicability
Expose a function setting_applies() to allow a caller to determine
whether or not a particular setting is applicable to a particular
settings block.
Restrict DHCP-backed settings blocks to accepting only DHCP-based
settings.
Restrict network device settings blocks to accepting only DHCP-based
settings and network device-specific settings such as "mac".
Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/phantom')
-rw-r--r-- | src/drivers/net/phantom/phantom.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c index 1060103c7..a55319ea6 100644 --- a/src/drivers/net/phantom/phantom.c +++ b/src/drivers/net/phantom/phantom.c @@ -1698,6 +1698,24 @@ phantom_clp_setting ( struct phantom_nic *phantom, struct setting *setting ) { } /** + * Check applicability of Phantom CLP setting + * + * @v settings Settings block + * @v setting Setting + * @ret applies Setting applies within this settings block + */ +static int phantom_setting_applies ( struct settings *settings, + struct setting *setting ) { + struct phantom_nic *phantom = + container_of ( settings, struct phantom_nic, settings ); + unsigned int clp_setting; + + /* Find Phantom setting equivalent to iPXE setting */ + clp_setting = phantom_clp_setting ( phantom, setting ); + return ( clp_setting != 0 ); +} + +/** * Store Phantom CLP setting * * @v settings Settings block @@ -1716,8 +1734,7 @@ static int phantom_store_setting ( struct settings *settings, /* Find Phantom setting equivalent to iPXE setting */ clp_setting = phantom_clp_setting ( phantom, setting ); - if ( ! clp_setting ) - return -ENOTSUP; + assert ( clp_setting != 0 ); /* Store setting */ if ( ( rc = phantom_clp_store ( phantom, phantom->port, @@ -1750,8 +1767,7 @@ static int phantom_fetch_setting ( struct settings *settings, /* Find Phantom setting equivalent to iPXE setting */ clp_setting = phantom_clp_setting ( phantom, setting ); - if ( ! clp_setting ) - return -ENOTSUP; + assert ( clp_setting != 0 ); /* Fetch setting */ if ( ( read_len = phantom_clp_fetch ( phantom, phantom->port, @@ -1767,6 +1783,7 @@ static int phantom_fetch_setting ( struct settings *settings, /** Phantom CLP settings operations */ static struct settings_operations phantom_settings_operations = { + .applies = phantom_setting_applies, .store = phantom_store_setting, .fetch = phantom_fetch_setting, }; |