Skip to content

Commit

Permalink
cxl/mbox: Convert 'enabled_cmds' to DECLARE_BITMAP
Browse files Browse the repository at this point in the history
Define enabled_cmds as an embedded member of 'struct cxl_mem' rather
than a pointer to another dynamic allocation.

As this leaves only one user of cxl_cmd_count, just open code it and
delete the helper.

Acked-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/163116436415.2460985.10101824045493194813.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dan Williams committed Sep 21, 2021
1 parent 5a2328f commit ff56ab9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions drivers/cxl/core/mbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,6 @@ static int cxl_validate_cmd_from_user(struct cxl_mem *cxlm,
return 0;
}

#define cxl_cmd_count ARRAY_SIZE(cxl_mem_commands)

int cxl_query_cmd(struct cxl_memdev *cxlmd,
struct cxl_mem_query_commands __user *q)
{
Expand All @@ -332,7 +330,7 @@ int cxl_query_cmd(struct cxl_memdev *cxlmd,

/* returns the total number if 0 elements are requested. */
if (n_commands == 0)
return put_user(cxl_cmd_count, &q->n_commands);
return put_user(ARRAY_SIZE(cxl_mem_commands), &q->n_commands);

/*
* otherwise, return max(n_commands, total commands) cxl_command_info
Expand Down Expand Up @@ -794,14 +792,6 @@ struct cxl_mem *cxl_mem_create(struct device *dev)

mutex_init(&cxlm->mbox_mutex);
cxlm->dev = dev;
cxlm->enabled_cmds =
devm_kmalloc_array(dev, BITS_TO_LONGS(cxl_cmd_count),
sizeof(unsigned long),
GFP_KERNEL | __GFP_ZERO);
if (!cxlm->enabled_cmds) {
dev_err(dev, "No memory available for bitmap\n");
return ERR_PTR(-ENOMEM);
}

return cxlm;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/cxl/cxlmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct cxl_mem {
size_t lsa_size;
struct mutex mbox_mutex; /* Protects device mailbox and firmware */
char firmware_version[0x10];
unsigned long *enabled_cmds;
DECLARE_BITMAP(enabled_cmds, CXL_MEM_COMMAND_ID_MAX);

struct range pmem_range;
struct range ram_range;
Expand Down

0 comments on commit ff56ab9

Please sign in to comment.