summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/phantom
diff options
context:
space:
mode:
authorMichael Brown2011-03-22 17:56:35 +0100
committerMichael Brown2011-03-22 20:54:58 +0100
commitf5fd4dec3bab362a2ff7844859914e1f191fb905 (patch)
tree607eacef2f79c016a0c3c3031de2bb7d8aa7e331 /src/drivers/net/phantom
parent[forcedeth] Clear the MII link status register on link status changes (diff)
downloadipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.tar.gz
ipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.tar.xz
ipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.zip
[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.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index 1060103c..a55319ea 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,
};