diff options
-rw-r--r-- | drivers/firmware/qemu_fw_cfg.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index e7ea2b3b1d11..7978844f6b37 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c | |||
@@ -211,7 +211,9 @@ static const struct { | |||
211 | /* fw_cfg_sysfs_entry type */ | 211 | /* fw_cfg_sysfs_entry type */ |
212 | struct fw_cfg_sysfs_entry { | 212 | struct fw_cfg_sysfs_entry { |
213 | struct kobject kobj; | 213 | struct kobject kobj; |
214 | struct fw_cfg_file f; | 214 | u32 size; |
215 | u16 select; | ||
216 | char name[FW_CFG_MAX_FILE_PATH]; | ||
215 | struct list_head list; | 217 | struct list_head list; |
216 | }; | 218 | }; |
217 | 219 | ||
@@ -275,17 +277,17 @@ struct fw_cfg_sysfs_attribute fw_cfg_sysfs_attr_##_attr = { \ | |||
275 | 277 | ||
276 | static ssize_t fw_cfg_sysfs_show_size(struct fw_cfg_sysfs_entry *e, char *buf) | 278 | static ssize_t fw_cfg_sysfs_show_size(struct fw_cfg_sysfs_entry *e, char *buf) |
277 | { | 279 | { |
278 | return sprintf(buf, "%u\n", e->f.size); | 280 | return sprintf(buf, "%u\n", e->size); |
279 | } | 281 | } |
280 | 282 | ||
281 | static ssize_t fw_cfg_sysfs_show_key(struct fw_cfg_sysfs_entry *e, char *buf) | 283 | static ssize_t fw_cfg_sysfs_show_key(struct fw_cfg_sysfs_entry *e, char *buf) |
282 | { | 284 | { |
283 | return sprintf(buf, "%u\n", e->f.select); | 285 | return sprintf(buf, "%u\n", e->select); |
284 | } | 286 | } |
285 | 287 | ||
286 | static ssize_t fw_cfg_sysfs_show_name(struct fw_cfg_sysfs_entry *e, char *buf) | 288 | static ssize_t fw_cfg_sysfs_show_name(struct fw_cfg_sysfs_entry *e, char *buf) |
287 | { | 289 | { |
288 | return sprintf(buf, "%s\n", e->f.name); | 290 | return sprintf(buf, "%s\n", e->name); |
289 | } | 291 | } |
290 | 292 | ||
291 | static FW_CFG_SYSFS_ATTR(size); | 293 | static FW_CFG_SYSFS_ATTR(size); |
@@ -336,13 +338,13 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj, | |||
336 | { | 338 | { |
337 | struct fw_cfg_sysfs_entry *entry = to_entry(kobj); | 339 | struct fw_cfg_sysfs_entry *entry = to_entry(kobj); |
338 | 340 | ||
339 | if (pos > entry->f.size) | 341 | if (pos > entry->size) |
340 | return -EINVAL; | 342 | return -EINVAL; |
341 | 343 | ||
342 | if (count > entry->f.size - pos) | 344 | if (count > entry->size - pos) |
343 | count = entry->f.size - pos; | 345 | count = entry->size - pos; |
344 | 346 | ||
345 | fw_cfg_read_blob(entry->f.select, buf, pos, count); | 347 | fw_cfg_read_blob(entry->select, buf, pos, count); |
346 | return count; | 348 | return count; |
347 | } | 349 | } |
348 | 350 | ||
@@ -461,11 +463,13 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) | |||
461 | return -ENOMEM; | 463 | return -ENOMEM; |
462 | 464 | ||
463 | /* set file entry information */ | 465 | /* set file entry information */ |
464 | memcpy(&entry->f, f, sizeof(struct fw_cfg_file)); | 466 | entry->size = be32_to_cpu(f->size); |
467 | entry->select = be16_to_cpu(f->select); | ||
468 | memcpy(entry->name, f->name, FW_CFG_MAX_FILE_PATH); | ||
465 | 469 | ||
466 | /* register entry under "/sys/firmware/qemu_fw_cfg/by_key/" */ | 470 | /* register entry under "/sys/firmware/qemu_fw_cfg/by_key/" */ |
467 | err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype, | 471 | err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype, |
468 | fw_cfg_sel_ko, "%d", entry->f.select); | 472 | fw_cfg_sel_ko, "%d", entry->select); |
469 | if (err) | 473 | if (err) |
470 | goto err_register; | 474 | goto err_register; |
471 | 475 | ||
@@ -475,7 +479,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) | |||
475 | goto err_add_raw; | 479 | goto err_add_raw; |
476 | 480 | ||
477 | /* try adding "/sys/firmware/qemu_fw_cfg/by_name/" symlink */ | 481 | /* try adding "/sys/firmware/qemu_fw_cfg/by_name/" symlink */ |
478 | fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->f.name); | 482 | fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->name); |
479 | 483 | ||
480 | /* success, add entry to global cache */ | 484 | /* success, add entry to global cache */ |
481 | fw_cfg_sysfs_cache_enlist(entry); | 485 | fw_cfg_sysfs_cache_enlist(entry); |
@@ -507,8 +511,6 @@ static int fw_cfg_register_dir_entries(void) | |||
507 | fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(count), dir_size); | 511 | fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(count), dir_size); |
508 | 512 | ||
509 | for (i = 0; i < count; i++) { | 513 | for (i = 0; i < count; i++) { |
510 | dir[i].size = be32_to_cpu(dir[i].size); | ||
511 | dir[i].select = be16_to_cpu(dir[i].select); | ||
512 | ret = fw_cfg_register_file(&dir[i]); | 514 | ret = fw_cfg_register_file(&dir[i]); |
513 | if (ret) | 515 | if (ret) |
514 | break; | 516 | break; |