summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorMichael Brown2013-12-03 17:48:56 +0100
committerMichael Brown2013-12-05 01:37:02 +0100
commit22001cb206c1320aee27f679a63d2171d35e99c5 (patch)
treea972bb914371a68d4925dcc007238dcb836546ba /src/drivers
parent[fbcon] Add support for displaying a cursor (diff)
downloadipxe-22001cb206c1320aee27f679a63d2171d35e99c5.tar.gz
ipxe-22001cb206c1320aee27f679a63d2171d35e99c5.tar.xz
ipxe-22001cb206c1320aee27f679a63d2171d35e99c5.zip
[settings] Explicitly separate the concept of a completed fetched setting
The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/block/ibft.c10
-rw-r--r--src/drivers/bus/pci_settings.c4
-rw-r--r--src/drivers/net/phantom/phantom.c11
3 files changed, 14 insertions, 11 deletions
diff --git a/src/drivers/block/ibft.c b/src/drivers/block/ibft.c
index 75ca51a9c..0700f8c4f 100644
--- a/src/drivers/block/ibft.c
+++ b/src/drivers/block/ibft.c
@@ -107,7 +107,7 @@ static void ibft_set_ipaddr ( struct ibft_ipaddr *ipaddr, struct in_addr in ) {
* @v count Maximum number of IP addresses
*/
static void ibft_set_ipaddr_setting ( struct ibft_ipaddr *ipaddr,
- struct setting *setting,
+ const struct setting *setting,
unsigned int count ) {
struct in_addr in[count];
unsigned int i;
@@ -183,11 +183,13 @@ static int ibft_set_string ( struct ibft_strings *strings,
*/
static int ibft_set_string_setting ( struct ibft_strings *strings,
struct ibft_string *string,
- struct setting *setting ) {
+ const struct setting *setting ) {
+ struct settings *origin;
+ struct setting fetched;
int len;
char *dest;
- len = fetch_setting_len ( NULL, setting );
+ len = fetch_setting ( NULL, setting, &origin, &fetched, NULL, 0 );
if ( len < 0 ) {
string->offset = 0;
string->len = 0;
@@ -197,7 +199,7 @@ static int ibft_set_string_setting ( struct ibft_strings *strings,
dest = ibft_alloc_string ( strings, string, len );
if ( ! dest )
return -ENOBUFS;
- fetch_string_setting ( NULL, setting, dest, ( len + 1 ) );
+ fetch_string_setting ( origin, &fetched, dest, ( len + 1 ));
return 0;
}
diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c
index a4d7b9334..db20452e0 100644
--- a/src/drivers/bus/pci_settings.c
+++ b/src/drivers/bus/pci_settings.c
@@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
/** PCI device settings scope */
-static struct settings_scope pci_settings_scope;
+static const struct settings_scope pci_settings_scope;
/**
* Check applicability of PCI device setting
@@ -42,7 +42,7 @@ static struct settings_scope pci_settings_scope;
* @ret applies Setting applies within this settings block
*/
static int pci_settings_applies ( struct settings *settings __unused,
- struct setting *setting ) {
+ const struct setting *setting ) {
return ( setting->scope == &pci_settings_scope );
}
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index 7f2fe0b63..e70ded08c 100644
--- a/src/drivers/net/phantom/phantom.c
+++ b/src/drivers/net/phantom/phantom.c
@@ -1455,7 +1455,7 @@ static struct net_device_operations phantom_operations = {
*/
/** Phantom CLP settings scope */
-static struct settings_scope phantom_settings_scope;
+static const struct settings_scope phantom_settings_scope;
/** Phantom CLP data
*
@@ -1656,7 +1656,7 @@ static int phantom_clp_fetch ( struct phantom_nic *phantom, unsigned int port,
/** A Phantom CLP setting */
struct phantom_clp_setting {
/** iPXE setting */
- struct setting *setting;
+ const struct setting *setting;
/** Setting number */
unsigned int clp_setting;
};
@@ -1673,7 +1673,8 @@ static struct phantom_clp_setting clp_settings[] = {
* @v clp_setting Setting number, or 0 if not found
*/
static unsigned int
-phantom_clp_setting ( struct phantom_nic *phantom, struct setting *setting ) {
+phantom_clp_setting ( struct phantom_nic *phantom,
+ const struct setting *setting ) {
struct phantom_clp_setting *clp_setting;
unsigned int i;
@@ -1703,7 +1704,7 @@ phantom_clp_setting ( struct phantom_nic *phantom, struct setting *setting ) {
* @ret applies Setting applies within this settings block
*/
static int phantom_setting_applies ( struct settings *settings,
- struct setting *setting ) {
+ const struct setting *setting ) {
struct phantom_nic *phantom =
container_of ( settings, struct phantom_nic, settings );
unsigned int clp_setting;
@@ -1723,7 +1724,7 @@ static int phantom_setting_applies ( struct settings *settings,
* @ret rc Return status code
*/
static int phantom_store_setting ( struct settings *settings,
- struct setting *setting,
+ const struct setting *setting,
const void *data, size_t len ) {
struct phantom_nic *phantom =
container_of ( settings, struct phantom_nic, settings );