mirror of https://github.com/ipxe/ipxe.git
[settings] Apply settings block name in register_settings()
Pass the settings block name as a parameter to register_settings(), rather than defining it with settings_init() (and then possibly changing it by directly manipulating settings->name). Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/1/head
parent
de6a59470b
commit
67b45186a5
|
@ -204,8 +204,7 @@ void nvo_init ( struct nvo_block *nvo, struct nvs_device *nvs,
|
||||||
struct nvo_fragment *fragments, struct refcnt *refcnt ) {
|
struct nvo_fragment *fragments, struct refcnt *refcnt ) {
|
||||||
nvo->nvs = nvs;
|
nvo->nvs = nvs;
|
||||||
nvo->fragments = fragments;
|
nvo->fragments = fragments;
|
||||||
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt,
|
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt, 0 );
|
||||||
"nvo", 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,7 +249,7 @@ int register_nvo ( struct nvo_block *nvo, struct settings *parent ) {
|
||||||
|
|
||||||
/* Verify and register options */
|
/* Verify and register options */
|
||||||
nvo_init_dhcpopts ( nvo );
|
nvo_init_dhcpopts ( nvo );
|
||||||
if ( ( rc = register_settings ( &nvo->settings, parent ) ) != 0 )
|
if ( ( rc = register_settings ( &nvo->settings, parent, "nvo" ) ) != 0 )
|
||||||
goto err_register;
|
goto err_register;
|
||||||
|
|
||||||
DBGC ( nvo, "NVO %p registered\n", nvo );
|
DBGC ( nvo, "NVO %p registered\n", nvo );
|
||||||
|
|
|
@ -281,9 +281,9 @@ static struct settings * autovivify_child_settings ( struct settings *parent,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy ( new_child->name, name, sizeof ( new_child->name ) );
|
memcpy ( new_child->name, name, sizeof ( new_child->name ) );
|
||||||
generic_settings_init ( &new_child->generic, NULL, new_child->name );
|
generic_settings_init ( &new_child->generic, NULL );
|
||||||
settings = &new_child->generic.settings;
|
settings = &new_child->generic.settings;
|
||||||
register_settings ( settings, parent );
|
register_settings ( settings, parent, new_child->name );
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,9 +422,11 @@ static void reprioritise_settings ( struct settings *settings ) {
|
||||||
*
|
*
|
||||||
* @v settings Settings block
|
* @v settings Settings block
|
||||||
* @v parent Parent settings block, or NULL
|
* @v parent Parent settings block, or NULL
|
||||||
|
* @v name Settings block name
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int register_settings ( struct settings *settings, struct settings *parent ) {
|
int register_settings ( struct settings *settings, struct settings *parent,
|
||||||
|
const char *name ) {
|
||||||
struct settings *old_settings;
|
struct settings *old_settings;
|
||||||
|
|
||||||
/* NULL parent => add to settings root */
|
/* NULL parent => add to settings root */
|
||||||
|
@ -432,6 +434,9 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
|
||||||
if ( parent == NULL )
|
if ( parent == NULL )
|
||||||
parent = &settings_root;
|
parent = &settings_root;
|
||||||
|
|
||||||
|
/* Apply settings block name */
|
||||||
|
settings->name = name;
|
||||||
|
|
||||||
/* Remove any existing settings with the same name */
|
/* Remove any existing settings with the same name */
|
||||||
if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
|
if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
|
||||||
unregister_settings ( old_settings );
|
unregister_settings ( old_settings );
|
||||||
|
|
|
@ -2061,7 +2061,7 @@ static int phantom_probe ( struct pci_device *pci,
|
||||||
assert ( phantom->port < PHN_MAX_NUM_PORTS );
|
assert ( phantom->port < PHN_MAX_NUM_PORTS );
|
||||||
settings_init ( &phantom->settings,
|
settings_init ( &phantom->settings,
|
||||||
&phantom_settings_operations,
|
&phantom_settings_operations,
|
||||||
&netdev->refcnt, "clp", PHN_CLP_TAG_MAGIC );
|
&netdev->refcnt, PHN_CLP_TAG_MAGIC );
|
||||||
|
|
||||||
/* Fix up PCI device */
|
/* Fix up PCI device */
|
||||||
adjust_pci_device ( pci );
|
adjust_pci_device ( pci );
|
||||||
|
@ -2111,7 +2111,7 @@ static int phantom_probe ( struct pci_device *pci,
|
||||||
/* Register settings blocks */
|
/* Register settings blocks */
|
||||||
parent_settings = netdev_settings ( netdev );
|
parent_settings = netdev_settings ( netdev );
|
||||||
if ( ( rc = register_settings ( &phantom->settings,
|
if ( ( rc = register_settings ( &phantom->settings,
|
||||||
parent_settings ) ) != 0 ) {
|
parent_settings, "clp" ) ) != 0 ) {
|
||||||
DBGC ( phantom, "Phantom %p could not register settings: "
|
DBGC ( phantom, "Phantom %p could not register settings: "
|
||||||
"%s\n", phantom, strerror ( rc ) );
|
"%s\n", phantom, strerror ( rc ) );
|
||||||
goto err_register_settings;
|
goto err_register_settings;
|
||||||
|
|
|
@ -489,8 +489,7 @@ netdev_settings ( struct net_device *netdev ) {
|
||||||
*/
|
*/
|
||||||
static inline __attribute__ (( always_inline )) void
|
static inline __attribute__ (( always_inline )) void
|
||||||
netdev_settings_init ( struct net_device *netdev ) {
|
netdev_settings_init ( struct net_device *netdev ) {
|
||||||
generic_settings_init ( &netdev->settings,
|
generic_settings_init ( &netdev->settings, &netdev->refcnt );
|
||||||
&netdev->refcnt, netdev->name );
|
|
||||||
netdev->settings.settings.op = &netdev_settings_operations;
|
netdev->settings.settings.op = &netdev_settings_operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ extern int generic_settings_fetch ( struct settings *settings,
|
||||||
extern void generic_settings_clear ( struct settings *settings );
|
extern void generic_settings_clear ( struct settings *settings );
|
||||||
|
|
||||||
extern int register_settings ( struct settings *settings,
|
extern int register_settings ( struct settings *settings,
|
||||||
struct settings *parent );
|
struct settings *parent, const char *name );
|
||||||
extern void unregister_settings ( struct settings *settings );
|
extern void unregister_settings ( struct settings *settings );
|
||||||
|
|
||||||
extern int store_setting ( struct settings *settings, struct setting *setting,
|
extern int store_setting ( struct settings *settings, struct setting *setting,
|
||||||
|
@ -252,19 +252,16 @@ extern struct setting user_class_setting __setting;
|
||||||
* @v settings Settings block
|
* @v settings Settings block
|
||||||
* @v op Settings block operations
|
* @v op Settings block operations
|
||||||
* @v refcnt Containing object reference counter, or NULL
|
* @v refcnt Containing object reference counter, or NULL
|
||||||
* @v name Settings block name
|
|
||||||
* @v tag_magic Tag magic
|
* @v tag_magic Tag magic
|
||||||
*/
|
*/
|
||||||
static inline void settings_init ( struct settings *settings,
|
static inline void settings_init ( struct settings *settings,
|
||||||
struct settings_operations *op,
|
struct settings_operations *op,
|
||||||
struct refcnt *refcnt,
|
struct refcnt *refcnt,
|
||||||
const char *name,
|
|
||||||
unsigned int tag_magic ) {
|
unsigned int tag_magic ) {
|
||||||
INIT_LIST_HEAD ( &settings->siblings );
|
INIT_LIST_HEAD ( &settings->siblings );
|
||||||
INIT_LIST_HEAD ( &settings->children );
|
INIT_LIST_HEAD ( &settings->children );
|
||||||
settings->op = op;
|
settings->op = op;
|
||||||
settings->refcnt = refcnt;
|
settings->refcnt = refcnt;
|
||||||
settings->name = name;
|
|
||||||
settings->tag_magic = tag_magic;
|
settings->tag_magic = tag_magic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,13 +270,11 @@ static inline void settings_init ( struct settings *settings,
|
||||||
*
|
*
|
||||||
* @v generics Generic settings block
|
* @v generics Generic settings block
|
||||||
* @v refcnt Containing object reference counter, or NULL
|
* @v refcnt Containing object reference counter, or NULL
|
||||||
* @v name Settings block name
|
|
||||||
*/
|
*/
|
||||||
static inline void generic_settings_init ( struct generic_settings *generics,
|
static inline void generic_settings_init ( struct generic_settings *generics,
|
||||||
struct refcnt *refcnt,
|
struct refcnt *refcnt ) {
|
||||||
const char *name ) {
|
|
||||||
settings_init ( &generics->settings, &generic_settings_operations,
|
settings_init ( &generics->settings, &generic_settings_operations,
|
||||||
refcnt, name, 0 );
|
refcnt, 0 );
|
||||||
INIT_LIST_HEAD ( &generics->list );
|
INIT_LIST_HEAD ( &generics->list );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,6 @@ static struct settings_operations smbios_settings_operations = {
|
||||||
/** SMBIOS settings */
|
/** SMBIOS settings */
|
||||||
static struct settings smbios_settings = {
|
static struct settings smbios_settings = {
|
||||||
.refcnt = NULL,
|
.refcnt = NULL,
|
||||||
.name = "smbios",
|
|
||||||
.tag_magic = SMBIOS_EMPTY_TAG,
|
.tag_magic = SMBIOS_EMPTY_TAG,
|
||||||
.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
|
.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
|
||||||
.children = LIST_HEAD_INIT ( smbios_settings.children ),
|
.children = LIST_HEAD_INIT ( smbios_settings.children ),
|
||||||
|
@ -136,7 +135,8 @@ static struct settings smbios_settings = {
|
||||||
static void smbios_init ( void ) {
|
static void smbios_init ( void ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( ( rc = register_settings ( &smbios_settings, NULL ) ) != 0 ) {
|
if ( ( rc = register_settings ( &smbios_settings, NULL,
|
||||||
|
"smbios" ) ) != 0 ) {
|
||||||
DBG ( "SMBIOS could not register settings: %s\n",
|
DBG ( "SMBIOS could not register settings: %s\n",
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -66,7 +66,8 @@ void store_cached_dhcpack ( userptr_t data, size_t len ) {
|
||||||
* device, which is usually what we want.
|
* device, which is usually what we want.
|
||||||
*/
|
*/
|
||||||
parent = netdev_settings ( last_opened_netdev() );
|
parent = netdev_settings ( last_opened_netdev() );
|
||||||
if ( ( rc = register_settings ( &dhcppkt->settings, parent ) ) != 0 )
|
if ( ( rc = register_settings ( &dhcppkt->settings, parent,
|
||||||
|
DHCP_SETTINGS_NAME ) ) != 0 )
|
||||||
DBG ( "DHCP could not register cached settings: %s\n",
|
DBG ( "DHCP could not register cached settings: %s\n",
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,5 @@ void dhcppkt_init ( struct dhcp_packet *dhcppkt, struct dhcphdr *data,
|
||||||
dhcppkt->len = ( offsetof ( struct dhcphdr, options ) +
|
dhcppkt->len = ( offsetof ( struct dhcphdr, options ) +
|
||||||
dhcppkt->options.len );
|
dhcppkt->options.len );
|
||||||
settings_init ( &dhcppkt->settings,
|
settings_init ( &dhcppkt->settings,
|
||||||
&dhcppkt_settings_operations, &dhcppkt->refcnt,
|
&dhcppkt_settings_operations, &dhcppkt->refcnt, 0 );
|
||||||
DHCP_SETTINGS_NAME, 0 );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ int register_netdev ( struct net_device *netdev ) {
|
||||||
|
|
||||||
/* Register per-netdev configuration settings */
|
/* Register per-netdev configuration settings */
|
||||||
if ( ( rc = register_settings ( netdev_settings ( netdev ),
|
if ( ( rc = register_settings ( netdev_settings ( netdev ),
|
||||||
NULL ) ) != 0 ) {
|
NULL, netdev->name ) ) != 0 ) {
|
||||||
DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
|
DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
|
||||||
netdev->name, strerror ( rc ) );
|
netdev->name, strerror ( rc ) );
|
||||||
goto err_register_settings;
|
goto err_register_settings;
|
||||||
|
|
|
@ -553,7 +553,8 @@ static void dhcp_request_rx ( struct dhcp_session *dhcp,
|
||||||
/* Register settings */
|
/* Register settings */
|
||||||
parent = netdev_settings ( dhcp->netdev );
|
parent = netdev_settings ( dhcp->netdev );
|
||||||
settings = &dhcppkt->settings;
|
settings = &dhcppkt->settings;
|
||||||
if ( ( rc = register_settings ( settings, parent ) ) != 0 ) {
|
if ( ( rc = register_settings ( settings, parent,
|
||||||
|
DHCP_SETTINGS_NAME ) ) != 0 ) {
|
||||||
DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
|
DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
|
||||||
dhcp, strerror ( rc ) );
|
dhcp, strerror ( rc ) );
|
||||||
dhcp_finished ( dhcp, rc );
|
dhcp_finished ( dhcp, rc );
|
||||||
|
@ -568,9 +569,8 @@ static void dhcp_request_rx ( struct dhcp_session *dhcp,
|
||||||
* without performing a ProxyDHCPREQUEST
|
* without performing a ProxyDHCPREQUEST
|
||||||
*/
|
*/
|
||||||
settings = &dhcp->proxy_offer->settings;
|
settings = &dhcp->proxy_offer->settings;
|
||||||
settings->name = PROXYDHCP_SETTINGS_NAME;
|
if ( ( rc = register_settings ( settings, NULL,
|
||||||
if ( ( rc = register_settings ( settings,
|
PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
|
||||||
NULL ) ) != 0 ) {
|
|
||||||
DBGC ( dhcp, "DHCP %p could not register "
|
DBGC ( dhcp, "DHCP %p could not register "
|
||||||
"proxy settings: %s\n",
|
"proxy settings: %s\n",
|
||||||
dhcp, strerror ( rc ) );
|
dhcp, strerror ( rc ) );
|
||||||
|
@ -670,8 +670,8 @@ static void dhcp_proxy_rx ( struct dhcp_session *dhcp,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Register settings */
|
/* Register settings */
|
||||||
settings->name = PROXYDHCP_SETTINGS_NAME;
|
if ( ( rc = register_settings ( settings, NULL,
|
||||||
if ( ( rc = register_settings ( settings, NULL ) ) != 0 ) {
|
PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
|
||||||
DBGC ( dhcp, "DHCP %p could not register proxy settings: %s\n",
|
DBGC ( dhcp, "DHCP %p could not register proxy settings: %s\n",
|
||||||
dhcp, strerror ( rc ) );
|
dhcp, strerror ( rc ) );
|
||||||
dhcp_finished ( dhcp, rc );
|
dhcp_finished ( dhcp, rc );
|
||||||
|
@ -809,8 +809,8 @@ static void dhcp_pxebs_rx ( struct dhcp_session *dhcp,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Register settings */
|
/* Register settings */
|
||||||
dhcppkt->settings.name = PXEBS_SETTINGS_NAME;
|
if ( ( rc = register_settings ( &dhcppkt->settings, NULL,
|
||||||
if ( ( rc = register_settings ( &dhcppkt->settings, NULL ) ) != 0 ) {
|
PXEBS_SETTINGS_NAME ) ) != 0 ) {
|
||||||
DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
|
DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
|
||||||
dhcp, strerror ( rc ) );
|
dhcp, strerror ( rc ) );
|
||||||
dhcp_finished ( dhcp, rc );
|
dhcp_finished ( dhcp, rc );
|
||||||
|
|
Loading…
Reference in New Issue