summaryrefslogtreecommitdiffstats
path: root/kernel/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/main.c')
-rw-r--r--kernel/main.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/kernel/main.c b/kernel/main.c
index a5a64fd..f662b94 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -85,10 +85,13 @@ static unsigned int nv_vgpu_get_available(struct mdev_type *mtype)
const char *name = mtype->sysfs_name;
unsigned int active = 0, max = 1;
- /* Type dirs may carry an extra "nvidia-" prefix vs our type names */
- if (str_has_prefix(name, "nvidia-"))
- name += strlen("nvidia-");
- info = nv_vgpu_find_type_info(name);
+ /*
+ * sysfs_name is our registered type name verbatim ("nvidia-vgpu-*").
+ * The mdev core prefixes only the type DIRECTORY with the parent
+ * driver string (mdev_type_add: "%s-%s", dev_driver_string, sysfs_name);
+ * it does not touch sysfs_name. Match it directly.
+ */
+ info = name ? nv_vgpu_find_type_info(name) : NULL;
if (info && info->max_instances)
max = info->max_instances;
@@ -116,8 +119,7 @@ static ssize_t nv_vgpu_show_description(struct mdev_type *mtype, char *buf)
const char *name = mtype->sysfs_name;
u32 vram_mb = 512, max_inst = 1;
- if (name && str_has_prefix(name, "nvidia-"))
- name += strlen("nvidia-");
+ /* sysfs_name is the registered type name; match it directly. */
info = name ? nv_vgpu_find_type_info(name) : NULL;
if (info) {
if (info->vram_mb)
@@ -563,15 +565,14 @@ static int nv_vgpu_mdev_create(struct mdev_device *mdev)
vgpu->state = NV_VGPU_STATE_UNINITIALIZED;
/*
* Bind the emulated FB size to this mdev's type (the type's vram_mb;
- * 0/absent keeps the 512 MiB default). The type dir may carry an
- * extra "nvidia-" prefix vs our registered names.
+ * 0/absent keeps the 512 MiB default). sysfs_name is the registered
+ * type name verbatim; match it directly (the mdev core only prefixes
+ * the type directory with the parent driver string).
*/
{
const char *tname = mdev->type ? mdev->type->sysfs_name : NULL;
struct nv_vgpu_type_info *tinfo;
- if (tname && str_has_prefix(tname, "nvidia-"))
- tname += strlen("nvidia-");
tinfo = tname ? nv_vgpu_find_type_info(tname) : NULL;
vgpu->fb_emul_size = (tinfo && tinfo->vram_mb) ?
(u64)tinfo->vram_mb << 20 : NV_VGPU_EMUL_FB_SIZE;