9
0
Fork 0

Merge branch 'for-next/state'

This commit is contained in:
Sascha Hauer 2016-11-14 12:35:52 +01:00
commit f55e379fca
8 changed files with 24 additions and 16 deletions

View File

@ -51,8 +51,8 @@ variable. The node name may end with ``@<ADDRESS>``, but the suffix is
stripped from the variable name.
State variables have a type. Currenty supported types are: ``uint8``,
``uint32``, ``enum32``, ``mac`` address or ``string``. Variable length
strings are not planned.
``uint32``, ``enum32``, ``mac`` address or ``string`` (fixed length string).
Variable length strings are not planned.
Required properties:

View File

@ -47,7 +47,7 @@ struct state_backend_storage_bucket_circular {
struct device_d *dev;
};
struct state_backend_storage_bucket_circular_meta {
struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta {
uint32_t magic;
uint32_t written_length;
};

View File

@ -32,7 +32,7 @@ struct state_backend_storage_bucket_direct {
struct device_d *dev;
};
struct state_backend_storage_bucket_direct_meta {
struct __attribute__((__packed__)) state_backend_storage_bucket_direct_meta {
uint32_t magic;
uint32_t written_length;
};

View File

@ -37,7 +37,7 @@ struct state_backend_format_raw {
struct device_d *dev;
};
struct backend_raw_header {
struct __attribute__((__packed__)) backend_raw_header {
uint32_t magic;
uint16_t reserved;
uint16_t data_len;

View File

@ -466,9 +466,10 @@ struct state *state_new_from_node(struct device_node *node, char *path,
of_path = partition_node->full_name;
ret = of_find_path_by_node(partition_node, &path, 0);
}
if (!path) {
pr_err("state failed to parse path to backend\n");
ret = -EINVAL;
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&state->dev, "state failed to parse path to backend: %s\n",
strerror(-ret));
goto out_release_state;
}
}
@ -487,7 +488,7 @@ struct state *state_new_from_node(struct device_node *node, char *path,
&storage_type);
if (ret) {
storage_type = NULL;
pr_info("No backend-storage-type found, using default.\n");
dev_info(&state->dev, "No backend-storage-type found, using default.\n");
}
ret = state_backend_init(&state->backend, &state->dev, node,
@ -511,10 +512,10 @@ struct state *state_new_from_node(struct device_node *node, char *path,
ret = state_load(state);
if (ret) {
pr_warn("Failed to load persistent state, continuing with defaults, %d\n", ret);
dev_warn(&state->dev, "Failed to load persistent state, continuing with defaults, %d\n", ret);
}
pr_info("New state registered '%s'\n", alias);
dev_info(&state->dev, "New state registered '%s'\n", alias);
return state;

View File

@ -441,9 +441,9 @@ static struct variable_type types[] = {
{
.type = STATE_TYPE_U8,
.type_name = "uint8",
.export = state_uint32_export,
.import = state_uint32_import,
.create = state_uint8_create,
.export = state_uint32_export,
.import = state_uint32_import,
.create = state_uint8_create,
}, {
.type = STATE_TYPE_U32,
.type_name = "uint32",

View File

@ -28,8 +28,12 @@ static int state_probe(struct device_d *dev)
bool readonly = false;
state = state_new_from_node(np, NULL, 0, 0, readonly);
if (IS_ERR(state))
return PTR_ERR(state);
if (IS_ERR(state)) {
int ret = PTR_ERR(state);
if (ret == -ENODEV)
ret = -EPROBE_DEFER;
return ret;
}
return 0;
}

View File

@ -66,6 +66,9 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
return -ENODEV;
}
if (!dev->driver)
return -ENODEV;
device_detect(dev);
if (part)