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 ) {
|
||||
nvo->nvs = nvs;
|
||||
nvo->fragments = fragments;
|
||||
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt,
|
||||
"nvo", 0 );
|
||||
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +249,7 @@ int register_nvo ( struct nvo_block *nvo, struct settings *parent ) {
|
|||
|
||||
/* Verify and register options */
|
||||
nvo_init_dhcpopts ( nvo );
|
||||
if ( ( rc = register_settings ( &nvo->settings, parent ) ) != 0 )
|
||||
if ( ( rc = register_settings ( &nvo->settings, parent, "nvo" ) ) != 0 )
|
||||
goto err_register;
|
||||
|
||||
DBGC ( nvo, "NVO %p registered\n", nvo );
|
||||
|
|
|
@ -281,9 +281,9 @@ static struct settings * autovivify_child_settings ( struct settings *parent,
|
|||
return NULL;
|
||||
}
|
||||
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;
|
||||
register_settings ( settings, parent );
|
||||
register_settings ( settings, parent, new_child->name );
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
@ -422,9 +422,11 @@ static void reprioritise_settings ( struct settings *settings ) {
|
|||
*
|
||||
* @v settings Settings block
|
||||
* @v parent Parent settings block, or NULL
|
||||
* @v name Settings block name
|
||||
* @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;
|
||||
|
||||
/* NULL parent => add to settings root */
|
||||
|
@ -432,6 +434,9 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
|
|||
if ( parent == NULL )
|
||||
parent = &settings_root;
|
||||
|
||||
/* Apply settings block name */
|
||||
settings->name = name;
|
||||
|
||||
/* Remove any existing settings with the same name */
|
||||
if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
|
||||
unregister_settings ( old_settings );
|
||||
|
|
|
@ -2061,7 +2061,7 @@ static int phantom_probe ( struct pci_device *pci,
|
|||
assert ( phantom->port < PHN_MAX_NUM_PORTS );
|
||||
settings_init ( &phantom->settings,
|
||||
&phantom_settings_operations,
|
||||
&netdev->refcnt, "clp", PHN_CLP_TAG_MAGIC );
|
||||
&netdev->refcnt, PHN_CLP_TAG_MAGIC );
|
||||
|
||||
/* Fix up PCI device */
|
||||
adjust_pci_device ( pci );
|
||||
|
@ -2111,7 +2111,7 @@ static int phantom_probe ( struct pci_device *pci,
|
|||
/* Register settings blocks */
|
||||
parent_settings = netdev_settings ( netdev );
|
||||
if ( ( rc = register_settings ( &phantom->settings,
|
||||
parent_settings ) ) != 0 ) {
|
||||
parent_settings, "clp" ) ) != 0 ) {
|
||||
DBGC ( phantom, "Phantom %p could not register settings: "
|
||||
"%s\n", phantom, strerror ( rc ) );
|
||||
goto err_register_settings;
|
||||
|
|
|
@ -489,8 +489,7 @@ netdev_settings ( struct net_device *netdev ) {
|
|||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
netdev_settings_init ( struct net_device *netdev ) {
|
||||
generic_settings_init ( &netdev->settings,
|
||||
&netdev->refcnt, netdev->name );
|
||||
generic_settings_init ( &netdev->settings, &netdev->refcnt );
|
||||
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 int register_settings ( struct settings *settings,
|
||||
struct settings *parent );
|
||||
struct settings *parent, const char *name );
|
||||
extern void unregister_settings ( struct settings *settings );
|
||||
|
||||
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 op Settings block operations
|
||||
* @v refcnt Containing object reference counter, or NULL
|
||||
* @v name Settings block name
|
||||
* @v tag_magic Tag magic
|
||||
*/
|
||||
static inline void settings_init ( struct settings *settings,
|
||||
struct settings_operations *op,
|
||||
struct refcnt *refcnt,
|
||||
const char *name,
|
||||
unsigned int tag_magic ) {
|
||||
INIT_LIST_HEAD ( &settings->siblings );
|
||||
INIT_LIST_HEAD ( &settings->children );
|
||||
settings->op = op;
|
||||
settings->refcnt = refcnt;
|
||||
settings->name = name;
|
||||
settings->tag_magic = tag_magic;
|
||||
}
|
||||
|
||||
|
@ -273,13 +270,11 @@ static inline void settings_init ( struct settings *settings,
|
|||
*
|
||||
* @v generics Generic settings block
|
||||
* @v refcnt Containing object reference counter, or NULL
|
||||
* @v name Settings block name
|
||||
*/
|
||||
static inline void generic_settings_init ( struct generic_settings *generics,
|
||||
struct refcnt *refcnt,
|
||||
const char *name ) {
|
||||
struct refcnt *refcnt ) {
|
||||
settings_init ( &generics->settings, &generic_settings_operations,
|
||||
refcnt, name, 0 );
|
||||
refcnt, 0 );
|
||||
INIT_LIST_HEAD ( &generics->list );
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ static struct settings_operations smbios_settings_operations = {
|
|||
/** SMBIOS settings */
|
||||
static struct settings smbios_settings = {
|
||||
.refcnt = NULL,
|
||||
.name = "smbios",
|
||||
.tag_magic = SMBIOS_EMPTY_TAG,
|
||||
.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
|
||||
.children = LIST_HEAD_INIT ( smbios_settings.children ),
|
||||
|
@ -136,7 +135,8 @@ static struct settings smbios_settings = {
|
|||
static void smbios_init ( void ) {
|
||||
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",
|
||||
strerror ( rc ) );
|
||||
return;
|
||||
|
|
|
@ -66,7 +66,8 @@ void store_cached_dhcpack ( userptr_t data, size_t len ) {
|
|||
* device, which is usually what we want.
|
||||
*/
|
||||
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",
|
||||
strerror ( rc ) );
|
||||
|
||||
|
|
|
@ -279,6 +279,5 @@ void dhcppkt_init ( struct dhcp_packet *dhcppkt, struct dhcphdr *data,
|
|||
dhcppkt->len = ( offsetof ( struct dhcphdr, options ) +
|
||||
dhcppkt->options.len );
|
||||
settings_init ( &dhcppkt->settings,
|
||||
&dhcppkt_settings_operations, &dhcppkt->refcnt,
|
||||
DHCP_SETTINGS_NAME, 0 );
|
||||
&dhcppkt_settings_operations, &dhcppkt->refcnt, 0 );
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ int register_netdev ( struct net_device *netdev ) {
|
|||
|
||||
/* Register per-netdev configuration settings */
|
||||
if ( ( rc = register_settings ( netdev_settings ( netdev ),
|
||||
NULL ) ) != 0 ) {
|
||||
NULL, netdev->name ) ) != 0 ) {
|
||||
DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
|
||||
netdev->name, strerror ( rc ) );
|
||||
goto err_register_settings;
|
||||
|
|
|
@ -553,7 +553,8 @@ static void dhcp_request_rx ( struct dhcp_session *dhcp,
|
|||
/* Register settings */
|
||||
parent = netdev_settings ( dhcp->netdev );
|
||||
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",
|
||||
dhcp, strerror ( rc ) );
|
||||
dhcp_finished ( dhcp, rc );
|
||||
|
@ -568,9 +569,8 @@ static void dhcp_request_rx ( struct dhcp_session *dhcp,
|
|||
* without performing a ProxyDHCPREQUEST
|
||||
*/
|
||||
settings = &dhcp->proxy_offer->settings;
|
||||
settings->name = PROXYDHCP_SETTINGS_NAME;
|
||||
if ( ( rc = register_settings ( settings,
|
||||
NULL ) ) != 0 ) {
|
||||
if ( ( rc = register_settings ( settings, NULL,
|
||||
PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
|
||||
DBGC ( dhcp, "DHCP %p could not register "
|
||||
"proxy settings: %s\n",
|
||||
dhcp, strerror ( rc ) );
|
||||
|
@ -670,8 +670,8 @@ static void dhcp_proxy_rx ( struct dhcp_session *dhcp,
|
|||
return;
|
||||
|
||||
/* Register settings */
|
||||
settings->name = PROXYDHCP_SETTINGS_NAME;
|
||||
if ( ( rc = register_settings ( settings, NULL ) ) != 0 ) {
|
||||
if ( ( rc = register_settings ( settings, NULL,
|
||||
PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
|
||||
DBGC ( dhcp, "DHCP %p could not register proxy settings: %s\n",
|
||||
dhcp, strerror ( rc ) );
|
||||
dhcp_finished ( dhcp, rc );
|
||||
|
@ -809,8 +809,8 @@ static void dhcp_pxebs_rx ( struct dhcp_session *dhcp,
|
|||
return;
|
||||
|
||||
/* Register settings */
|
||||
dhcppkt->settings.name = PXEBS_SETTINGS_NAME;
|
||||
if ( ( rc = register_settings ( &dhcppkt->settings, NULL ) ) != 0 ) {
|
||||
if ( ( rc = register_settings ( &dhcppkt->settings, NULL,
|
||||
PXEBS_SETTINGS_NAME ) ) != 0 ) {
|
||||
DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
|
||||
dhcp, strerror ( rc ) );
|
||||
dhcp_finished ( dhcp, rc );
|
||||
|
|
Loading…
Reference in New Issue