[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>
This commit is contained in:
Michael Brown
2013-12-03 16:48:56 +00:00
parent a2638a8edd
commit 22001cb206
37 changed files with 620 additions and 573 deletions
+8 -7
View File
@@ -36,27 +36,27 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
/** Network device predefined settings */
struct setting mac_setting __setting ( SETTING_NETDEV ) = {
const struct setting mac_setting __setting ( SETTING_NETDEV ) = {
.name = "mac",
.description = "MAC address",
.type = &setting_type_hex,
};
struct setting bustype_setting __setting ( SETTING_NETDEV ) = {
const struct setting bustype_setting __setting ( SETTING_NETDEV ) = {
.name = "bustype",
.description = "Bus type",
.type = &setting_type_string,
};
struct setting busloc_setting __setting ( SETTING_NETDEV ) = {
const struct setting busloc_setting __setting ( SETTING_NETDEV ) = {
.name = "busloc",
.description = "Bus location",
.type = &setting_type_uint32,
};
struct setting busid_setting __setting ( SETTING_NETDEV ) = {
const struct setting busid_setting __setting ( SETTING_NETDEV ) = {
.name = "busid",
.description = "Bus ID",
.type = &setting_type_hex,
};
struct setting chip_setting __setting ( SETTING_NETDEV ) = {
const struct setting chip_setting __setting ( SETTING_NETDEV ) = {
.name = "chip",
.description = "Chip",
.type = &setting_type_string,
@@ -194,7 +194,7 @@ static int netdev_fetch_chip ( struct net_device *netdev, void *data,
/** A network device setting operation */
struct netdev_setting_operation {
/** Setting */
struct setting *setting;
const struct setting *setting;
/** Store setting (or NULL if not supported)
*
* @v netdev Network device
@@ -232,7 +232,8 @@ static struct netdev_setting_operation netdev_setting_operations[] = {
* @v len Length of setting data
* @ret rc Return status code
*/
static int netdev_store ( struct settings *settings, struct setting *setting,
static int netdev_store ( struct settings *settings,
const struct setting *setting,
const void *data, size_t len ) {
struct net_device *netdev = container_of ( settings, struct net_device,
settings.settings );