dm: key: add key type and key name interface

Change-Id: Ifd054c609d92557b15acb8e53580dddd72325ff8
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2017-10-27 17:42:18 +08:00
parent f1f9ed8232
commit 6e14addfbc
2 changed files with 24 additions and 0 deletions

View File

@ -17,6 +17,26 @@ int key_read(struct udevice *dev)
return ops->read(dev); return ops->read(dev);
} }
int key_type(struct udevice *dev)
{
const struct dm_key_ops *ops = dev_get_driver_ops(dev);
if (!ops || !ops->type)
return -ENOSYS;
return ops->type;
}
const char *key_name(struct udevice *dev)
{
const struct dm_key_ops *ops = dev_get_driver_ops(dev);
if (!ops || !ops->name)
return NULL;
return ops->name;
}
UCLASS_DRIVER(key) = { UCLASS_DRIVER(key) = {
.id = UCLASS_KEY, .id = UCLASS_KEY,
.name = "key", .name = "key",

View File

@ -14,9 +14,13 @@ enum key_state {
}; };
struct dm_key_ops { struct dm_key_ops {
int type;
const char *name;
int (*read)(struct udevice *dev); int (*read)(struct udevice *dev);
}; };
int key_read(struct udevice *dev); int key_read(struct udevice *dev);
int key_type(struct udevice *dev);
const char *key_label(struct udevice *dev);
#endif #endif