summaryrefslogtreecommitdiffstats
path: root/fs/efivarfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/efivarfs.c')
-rw-r--r--fs/efivarfs.c115
1 files changed, 20 insertions, 95 deletions
diff --git a/fs/efivarfs.c b/fs/efivarfs.c
index 9eadda4121..b199318061 100644
--- a/fs/efivarfs.c
+++ b/fs/efivarfs.c
@@ -3,9 +3,6 @@
*
* Copyright (c) 2014 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
@@ -31,7 +28,7 @@
#include <wchar.h>
#include <linux/err.h>
#include <linux/ctype.h>
-#include <efi/efi.h>
+#include <efi/efi-payload.h>
#include <efi/efi-device.h>
struct efivarfs_inode {
@@ -50,83 +47,8 @@ struct efivarfs_priv {
struct list_head inodes;
};
-static int char_to_nibble(char c)
-{
- int ret = tolower(c);
-
- return ret <= '9' ? ret - '0' : ret - 'a' + 10;
-}
-
-static int read_byte_str(const char *str, u8 *out)
-{
- if (!isxdigit(*str) || !isxdigit(*(str + 1)))
- return -EINVAL;
-
- *out = (char_to_nibble(*str) << 4) | char_to_nibble(*(str + 1));
-
- return 0;
-}
-
-static int efi_guid_parse(const char *str, efi_guid_t *guid)
-{
- int i, ret;
- u8 idx[] = { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
-
- for (i = 0; i < 16; i++) {
- ret = read_byte_str(str, &guid->b[idx[i]]);
- if (ret)
- return ret;
- str += 2;
-
- switch (i) {
- case 3:
- case 5:
- case 7:
- case 9:
- if (*str != '-')
- return -EINVAL;
- str++;
- break;
- }
- }
-
- return 0;
-}
-
-static int efivarfs_parse_filename(const char *filename, efi_guid_t *vendor, s16 **name)
-{
- int len, ret;
- const char *guidstr;
- s16 *varname;
- int i;
-
- if (*filename == '/')
- filename++;
-
- len = strlen(filename);
-
- if (len < sizeof("-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"))
- return -EINVAL;
-
- guidstr = filename + len - sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
- if (*guidstr != '-')
- return -EINVAL;
-
- guidstr++;
-
- ret = efi_guid_parse(guidstr, vendor);
-
- varname = xzalloc((guidstr - filename) * sizeof(s16));
-
- for (i = 0; i < guidstr - filename - 1; i++)
- varname[i] = filename[i];
-
- *name = varname;
-
- return 0;
-}
-
-static int efivars_create(struct device_d *dev, const char *pathname, mode_t mode)
+static int efivars_create(struct device *dev, const char *pathname,
+ mode_t mode)
{
struct efivarfs_priv *priv = dev->priv;
struct efivarfs_inode *inode;
@@ -172,7 +94,7 @@ static int efivars_create(struct device_d *dev, const char *pathname, mode_t mod
return 0;
}
-static int efivars_unlink(struct device_d *dev, const char *pathname)
+static int efivars_unlink(struct device *dev, const char *pathname)
{
struct efivarfs_priv *priv = dev->priv;
struct efivarfs_inode *inode, *tmp;
@@ -203,7 +125,7 @@ struct efivars_file {
u32 attributes;
};
-static int efivarfs_open(struct device_d *dev, FILE *f, const char *filename)
+static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
{
struct efivars_file *efile;
efi_status_t efiret;
@@ -248,7 +170,7 @@ out:
return ret;
}
-static int efivarfs_close(struct device_d *dev, FILE *f)
+static int efivarfs_close(struct device *dev, FILE *f)
{
struct efivars_file *efile = f->priv;
@@ -258,7 +180,8 @@ static int efivarfs_close(struct device_d *dev, FILE *f)
return 0;
}
-static int efivarfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insize)
+static int efivarfs_read(struct device *_dev, FILE *f, void *buf,
+ size_t insize)
{
struct efivars_file *efile = f->priv;
@@ -267,7 +190,8 @@ static int efivarfs_read(struct device_d *_dev, FILE *f, void *buf, size_t insiz
return insize;
}
-static int efivarfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t insize)
+static int efivarfs_write(struct device *_dev, FILE *f, const void *buf,
+ size_t insize)
{
struct efivars_file *efile = f->priv;
efi_status_t efiret;
@@ -288,7 +212,7 @@ static int efivarfs_write(struct device_d *_dev, FILE *f, const void *buf, size_
return insize;
}
-static int efivarfs_truncate(struct device_d *dev, FILE *f, loff_t size)
+static int efivarfs_truncate(struct device *dev, FILE *f, loff_t size)
{
struct efivars_file *efile = f->priv;
efi_status_t efiret;
@@ -307,7 +231,7 @@ static int efivarfs_truncate(struct device_d *dev, FILE *f, loff_t size)
return 0;
}
-static DIR *efivarfs_opendir(struct device_d *dev, const char *pathname)
+static DIR *efivarfs_opendir(struct device *dev, const char *pathname)
{
struct efivarfs_priv *priv = dev->priv;
struct efivarfs_dir *edir;
@@ -318,7 +242,7 @@ static DIR *efivarfs_opendir(struct device_d *dev, const char *pathname)
return &edir->dir;
}
-static struct dirent *efivarfs_readdir(struct device_d *dev, DIR *dir)
+static struct dirent *efivarfs_readdir(struct device *dev, DIR *dir)
{
struct efivarfs_priv *priv = dev->priv;
struct efivarfs_dir *edir = container_of(dir, struct efivarfs_dir, dir);
@@ -336,7 +260,7 @@ static struct dirent *efivarfs_readdir(struct device_d *dev, DIR *dir)
return &dir->d;
}
-static int efivarfs_closedir(struct device_d *dev, DIR *dir)
+static int efivarfs_closedir(struct device *dev, DIR *dir)
{
struct efivarfs_dir *edir = container_of(dir, struct efivarfs_dir, dir);
@@ -345,7 +269,8 @@ static int efivarfs_closedir(struct device_d *dev, DIR *dir)
return 0;
}
-static int efivarfs_stat(struct device_d *dev, const char *filename, struct stat *s)
+static int efivarfs_stat(struct device *dev, const char *filename,
+ struct stat *s)
{
efi_guid_t vendor;
s16 *name;
@@ -370,7 +295,7 @@ static int efivarfs_stat(struct device_d *dev, const char *filename, struct stat
return 0;
}
-static int efivarfs_probe(struct device_d *dev)
+static int efivarfs_probe(struct device *dev)
{
efi_status_t efiret;
efi_guid_t vendor;
@@ -409,7 +334,7 @@ static int efivarfs_probe(struct device_d *dev)
return 0;
}
-static void efivarfs_remove(struct device_d *dev)
+static void efivarfs_remove(struct device *dev)
{
struct efivarfs_priv *priv = dev->priv;
struct efivarfs_inode *inode, *tmp;
@@ -422,7 +347,7 @@ static void efivarfs_remove(struct device_d *dev)
free(priv);
}
-static struct fs_driver_d efivarfs_driver = {
+static struct fs_driver efivarfs_driver = {
.create = efivars_create,
.unlink = efivars_unlink,
.open = efivarfs_open,
@@ -446,4 +371,4 @@ static int efivarfs_init(void)
return register_fs_driver(&efivarfs_driver);
}
-coredevice_initcall(efivarfs_init);
+coredevice_efi_initcall(efivarfs_init);