Commit 8b872d6f authored by Todd Poynor's avatar Todd Poynor Committed by Greg Kroah-Hartman

staging: gasket: interrupt: simplify interrupt init parameters

Pass the gasket driver descriptor to the interrupt init function, rather
than exploding out separate parameters from various fields of that
structure.  This allows us to make more localized changes to the types
of interrupts supported (MSIX vs. wire, etc.) without affecting the
calling sequence, and seems nicer for simplification purposes.
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 62af1652
...@@ -1357,13 +1357,7 @@ int gasket_enable_device(struct gasket_dev *gasket_dev) ...@@ -1357,13 +1357,7 @@ int gasket_enable_device(struct gasket_dev *gasket_dev)
const struct gasket_driver_desc *driver_desc = const struct gasket_driver_desc *driver_desc =
gasket_dev->internal_desc->driver_desc; gasket_dev->internal_desc->driver_desc;
ret = gasket_interrupt_init(gasket_dev, driver_desc->name, ret = gasket_interrupt_init(gasket_dev);
driver_desc->interrupt_type,
driver_desc->interrupts,
driver_desc->num_interrupts,
driver_desc->interrupt_pack_width,
driver_desc->interrupt_bar_index,
driver_desc->wire_interrupt_offsets);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, dev_err(gasket_dev->dev,
"Critical failure to allocate interrupts: %d\n", ret); "Critical failure to allocate interrupts: %d\n", ret);
......
...@@ -331,31 +331,30 @@ static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = { ...@@ -331,31 +331,30 @@ static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = {
GASKET_END_OF_ATTR_ARRAY, GASKET_END_OF_ATTR_ARRAY,
}; };
int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, int gasket_interrupt_init(struct gasket_dev *gasket_dev)
int type,
const struct gasket_interrupt_desc *interrupts,
int num_interrupts, int pack_width, int bar_index,
const struct gasket_wire_interrupt_offsets *wire_int_offsets)
{ {
int ret; int ret;
struct gasket_interrupt_data *interrupt_data; struct gasket_interrupt_data *interrupt_data;
const struct gasket_driver_desc *driver_desc =
gasket_get_driver_desc(gasket_dev);
interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data), interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data),
GFP_KERNEL); GFP_KERNEL);
if (!interrupt_data) if (!interrupt_data)
return -ENOMEM; return -ENOMEM;
gasket_dev->interrupt_data = interrupt_data; gasket_dev->interrupt_data = interrupt_data;
interrupt_data->name = name; interrupt_data->name = driver_desc->name;
interrupt_data->type = type; interrupt_data->type = driver_desc->interrupt_type;
interrupt_data->pci_dev = gasket_dev->pci_dev; interrupt_data->pci_dev = gasket_dev->pci_dev;
interrupt_data->num_interrupts = num_interrupts; interrupt_data->num_interrupts = driver_desc->num_interrupts;
interrupt_data->interrupts = interrupts; interrupt_data->interrupts = driver_desc->interrupts;
interrupt_data->interrupt_bar_index = bar_index; interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
interrupt_data->pack_width = pack_width; interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0; interrupt_data->num_configured = 0;
interrupt_data->wire_interrupt_offsets = wire_int_offsets; interrupt_data->wire_interrupt_offsets =
driver_desc->wire_interrupt_offsets;
interrupt_data->eventfd_ctxs = kcalloc(num_interrupts, interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
sizeof(struct eventfd_ctx *), sizeof(struct eventfd_ctx *),
GFP_KERNEL); GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) { if (!interrupt_data->eventfd_ctxs) {
...@@ -363,7 +362,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, ...@@ -363,7 +362,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
return -ENOMEM; return -ENOMEM;
} }
interrupt_data->interrupt_counts = kcalloc(num_interrupts, interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts,
sizeof(ulong), sizeof(ulong),
GFP_KERNEL); GFP_KERNEL);
if (!interrupt_data->interrupt_counts) { if (!interrupt_data->interrupt_counts) {
......
...@@ -24,30 +24,8 @@ struct gasket_interrupt_data; ...@@ -24,30 +24,8 @@ struct gasket_interrupt_data;
/* /*
* Initialize the interrupt module. * Initialize the interrupt module.
* @gasket_dev: The Gasket device structure for the device to be initted. * @gasket_dev: The Gasket device structure for the device to be initted.
* @type: Type of the interrupt. (See gasket_interrupt_type).
* @name: The name to associate with these interrupts.
* @interrupts: An array of all interrupt descriptions for this device.
* @num_interrupts: The length of the @interrupts array.
* @pack_width: The width, in bits, of a single field in a packed interrupt reg.
* @bar_index: The bar containing all interrupt registers.
*
* Allocates and initializes data to track interrupt state for a device.
* After this call, no interrupts will be configured/delivered; call
* gasket_interrupt_set_vector[_packed] to associate each interrupt with an
* __iomem location, then gasket_interrupt_set_eventfd to associate an eventfd
* with an interrupt.
*
* If num_interrupts interrupts are not available, this call will return a
* negative error code. In that case, gasket_interrupt_cleanup should still be
* called. Returns 0 on success (which can include a device where interrupts
* are not possible to set up, but is otherwise OK; that device will report
* status LAMED.)
*/ */
int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, int gasket_interrupt_init(struct gasket_dev *gasket_dev);
int type,
const struct gasket_interrupt_desc *interrupts,
int num_interrupts, int pack_width, int bar_index,
const struct gasket_wire_interrupt_offsets *wire_int_offsets);
/* /*
* Clean up a device's interrupt structure. * Clean up a device's interrupt structure.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment