staging: gasket: core: fix function param line continuation style

Fix multi-line alignment formatting to look like:
      int ret = long_function_name(device, VARIABLE1, VARIABLE2,
                                   VARIABLE3, VARIABLE4);

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Todd Poynor 2018-07-31 13:24:39 -07:00 committed by Greg Kroah-Hartman
parent 6d2bd645cb
commit 88c8a377c0
2 changed files with 179 additions and 183 deletions

View File

@ -103,8 +103,9 @@ enum gasket_sysfs_attribute_type {
}; };
/* Perform a standard Gasket callback. */ /* Perform a standard Gasket callback. */
static inline int check_and_invoke_callback( static inline int
struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) check_and_invoke_callback(struct gasket_dev *gasket_dev,
int (*cb_function)(struct gasket_dev *))
{ {
int ret = 0; int ret = 0;
@ -119,8 +120,9 @@ static inline int check_and_invoke_callback(
} }
/* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */ /* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */
static inline int gasket_check_and_invoke_callback_nolock( static inline int
struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *)) gasket_check_and_invoke_callback_nolock(struct gasket_dev *gasket_dev,
int (*cb_function)(struct gasket_dev *))
{ {
int ret = 0; int ret = 0;
@ -147,8 +149,8 @@ static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info)
* *
* Returns the located slot number on success or a negative number on failure. * Returns the located slot number on success or a negative number on failure.
*/ */
static int gasket_find_dev_slot( static int gasket_find_dev_slot(struct gasket_internal_desc *internal_desc,
struct gasket_internal_desc *internal_desc, const char *kobj_name) const char *kobj_name)
{ {
int i; int i;
@ -186,9 +188,9 @@ static int gasket_find_dev_slot(
* *
* Returns 0 if successful, a negative error code otherwise. * Returns 0 if successful, a negative error code otherwise.
*/ */
static int gasket_alloc_dev( static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
struct gasket_internal_desc *internal_desc, struct device *parent, struct device *parent, struct gasket_dev **pdev,
struct gasket_dev **pdev, const char *kobj_name) const char *kobj_name)
{ {
int dev_idx; int dev_idx;
const struct gasket_driver_desc *driver_desc = const struct gasket_driver_desc *driver_desc =
@ -228,7 +230,7 @@ static int gasket_alloc_dev(
gasket_dev->dev_idx); gasket_dev->dev_idx);
dev_info->devt = dev_info->devt =
MKDEV(driver_desc->major, driver_desc->minor + MKDEV(driver_desc->major, driver_desc->minor +
gasket_dev->dev_idx); gasket_dev->dev_idx);
dev_info->device = device_create(internal_desc->class, parent, dev_info->device = device_create(internal_desc->class, parent,
dev_info->devt, gasket_dev, dev_info->name); dev_info->devt, gasket_dev, dev_info->name);
@ -371,8 +373,8 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num)
* *
* Returns 0 on success and a negative value otherwise. * Returns 0 on success and a negative value otherwise.
*/ */
static int gasket_setup_pci( static int gasket_setup_pci(struct pci_dev *pci_dev,
struct pci_dev *pci_dev, struct gasket_dev *gasket_dev) struct gasket_dev *gasket_dev)
{ {
int i, mapped_bars, ret; int i, mapped_bars, ret;
@ -421,8 +423,8 @@ static int gasket_get_hw_status(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;
status = gasket_check_and_invoke_callback_nolock( status = gasket_check_and_invoke_callback_nolock(gasket_dev,
gasket_dev, driver_desc->device_status_cb); driver_desc->device_status_cb);
if (status != GASKET_STATUS_ALIVE) { if (status != GASKET_STATUS_ALIVE) {
dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n", dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n",
status); status);
@ -437,8 +439,7 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev)
} }
for (i = 0; i < driver_desc->num_page_tables; ++i) { for (i = 0; i < driver_desc->num_page_tables; ++i) {
status = gasket_page_table_system_status( status = gasket_page_table_system_status(gasket_dev->page_table[i]);
gasket_dev->page_table[i]);
if (status != GASKET_STATUS_ALIVE) { if (status != GASKET_STATUS_ALIVE) {
dev_dbg(gasket_dev->dev, dev_dbg(gasket_dev->dev,
"Page table %d reported status %d.\n", "Page table %d reported status %d.\n",
@ -450,8 +451,10 @@ static int gasket_get_hw_status(struct gasket_dev *gasket_dev)
return GASKET_STATUS_ALIVE; return GASKET_STATUS_ALIVE;
} }
static ssize_t gasket_write_mappable_regions( static ssize_t
char *buf, const struct gasket_driver_desc *driver_desc, int bar_index) gasket_write_mappable_regions(char *buf,
const struct gasket_driver_desc *driver_desc,
int bar_index)
{ {
int i; int i;
ssize_t written; ssize_t written;
@ -478,8 +481,8 @@ static ssize_t gasket_write_mappable_regions(
return total_written; return total_written;
} }
static ssize_t gasket_sysfs_data_show( static ssize_t gasket_sysfs_data_show(struct device *device,
struct device *device, struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int i, ret = 0; int i, ret = 0;
ssize_t current_written = 0; ssize_t current_written = 0;
@ -532,54 +535,49 @@ static ssize_t gasket_sysfs_data_show(
} }
break; break;
case ATTR_DRIVER_VERSION: case ATTR_DRIVER_VERSION:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%s\n",
buf, PAGE_SIZE, "%s\n", gasket_dev->internal_desc->driver_desc->driver_version);
gasket_dev->internal_desc->driver_desc->driver_version);
break; break;
case ATTR_FRAMEWORK_VERSION: case ATTR_FRAMEWORK_VERSION:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%s\n",
buf, PAGE_SIZE, "%s\n", GASKET_FRAMEWORK_VERSION); GASKET_FRAMEWORK_VERSION);
break; break;
case ATTR_DEVICE_TYPE: case ATTR_DEVICE_TYPE:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%s\n",
buf, PAGE_SIZE, "%s\n", gasket_dev->internal_desc->driver_desc->name);
gasket_dev->internal_desc->driver_desc->name);
break; break;
case ATTR_HARDWARE_REVISION: case ATTR_HARDWARE_REVISION:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%d\n",
buf, PAGE_SIZE, "%d\n", gasket_dev->hardware_revision); gasket_dev->hardware_revision);
break; break;
case ATTR_PCI_ADDRESS: case ATTR_PCI_ADDRESS:
ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name); ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name);
break; break;
case ATTR_STATUS: case ATTR_STATUS:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%s\n",
buf, PAGE_SIZE, "%s\n", gasket_num_name_lookup(gasket_dev->status,
gasket_num_name_lookup( gasket_status_name_table));
gasket_dev->status, gasket_status_name_table));
break; break;
case ATTR_IS_DEVICE_OWNED: case ATTR_IS_DEVICE_OWNED:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%d\n",
buf, PAGE_SIZE, "%d\n", gasket_dev->dev_info.ownership.is_owned);
gasket_dev->dev_info.ownership.is_owned);
break; break;
case ATTR_DEVICE_OWNER: case ATTR_DEVICE_OWNER:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%d\n",
buf, PAGE_SIZE, "%d\n", gasket_dev->dev_info.ownership.owner);
gasket_dev->dev_info.ownership.owner);
break; break;
case ATTR_WRITE_OPEN_COUNT: case ATTR_WRITE_OPEN_COUNT:
ret = snprintf( ret = snprintf(buf, PAGE_SIZE, "%d\n",
buf, PAGE_SIZE, "%d\n", gasket_dev->dev_info.ownership.write_open_count);
gasket_dev->dev_info.ownership.write_open_count);
break; break;
case ATTR_RESET_COUNT: case ATTR_RESET_COUNT:
ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count);
break; break;
case ATTR_USER_MEM_RANGES: case ATTR_USER_MEM_RANGES:
for (i = 0; i < GASKET_NUM_BARS; ++i) { for (i = 0; i < GASKET_NUM_BARS; ++i) {
current_written = gasket_write_mappable_regions( current_written =
buf, driver_desc, i); gasket_write_mappable_regions(buf, driver_desc,
i);
buf += current_written; buf += current_written;
ret += current_written; ret += current_written;
} }
@ -622,9 +620,9 @@ static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = {
}; };
/* Add a char device and related info. */ /* Add a char device and related info. */
static int gasket_add_cdev( static int gasket_add_cdev(struct gasket_cdev_info *dev_info,
struct gasket_cdev_info *dev_info, const struct file_operations *file_ops,
const struct file_operations *file_ops, struct module *owner) struct module *owner)
{ {
int ret; int ret;
@ -672,8 +670,8 @@ static void gasket_disable_dev(struct gasket_dev *gasket_dev)
* Precondition: Called with g_mutex held (to avoid a race on return). * Precondition: Called with g_mutex held (to avoid a race on return).
* Returns NULL if no matching device was found. * Returns NULL if no matching device was found.
*/ */
static struct gasket_internal_desc *lookup_internal_desc( static struct gasket_internal_desc *
struct pci_dev *pci_dev) lookup_internal_desc(struct pci_dev *pci_dev)
{ {
int i; int i;
@ -693,9 +691,9 @@ static struct gasket_internal_desc *lookup_internal_desc(
* that the provided descriptor/range is of adequate size to hold the range to * that the provided descriptor/range is of adequate size to hold the range to
* be mapped. * be mapped.
*/ */
static bool gasket_mmap_has_permissions( static bool gasket_mmap_has_permissions(struct gasket_dev *gasket_dev,
struct gasket_dev *gasket_dev, struct vm_area_struct *vma, struct vm_area_struct *vma,
int bar_permissions) int bar_permissions)
{ {
int requested_permissions; int requested_permissions;
/* Always allow sysadmin to access. */ /* Always allow sysadmin to access. */
@ -735,8 +733,9 @@ static bool gasket_mmap_has_permissions(
* Verifies that the input address is within the region allocated to coherent * Verifies that the input address is within the region allocated to coherent
* buffer. * buffer.
*/ */
static bool gasket_is_coherent_region( static bool
const struct gasket_driver_desc *driver_desc, ulong address) gasket_is_coherent_region(const struct gasket_driver_desc *driver_desc,
ulong address)
{ {
struct gasket_coherent_buffer_desc coh_buff_desc = struct gasket_coherent_buffer_desc coh_buff_desc =
driver_desc->coherent_buffer_description; driver_desc->coherent_buffer_description;
@ -750,8 +749,8 @@ static bool gasket_is_coherent_region(
return false; return false;
} }
static int gasket_get_bar_index( static int gasket_get_bar_index(const struct gasket_dev *gasket_dev,
const struct gasket_dev *gasket_dev, ulong phys_addr) ulong phys_addr)
{ {
int i; int i;
const struct gasket_driver_desc *driver_desc; const struct gasket_driver_desc *driver_desc;
@ -786,10 +785,11 @@ static int gasket_get_bar_index(
* *
* Returns true if there's anything to map, and false otherwise. * Returns true if there's anything to map, and false otherwise.
*/ */
static bool gasket_mm_get_mapping_addrs( static bool
const struct gasket_mappable_region *region, ulong bar_offset, gasket_mm_get_mapping_addrs(const struct gasket_mappable_region *region,
ulong requested_length, struct gasket_mappable_region *mappable_region, ulong bar_offset, ulong requested_length,
ulong *virt_offset) struct gasket_mappable_region *mappable_region,
ulong *virt_offset)
{ {
ulong range_start = region->start; ulong range_start = region->start;
ulong range_length = region->length_bytes; ulong range_length = region->length_bytes;
@ -835,8 +835,8 @@ static bool gasket_mm_get_mapping_addrs(
*/ */
mappable_region->start = bar_offset; mappable_region->start = bar_offset;
*virt_offset = 0; *virt_offset = 0;
mappable_region->length_bytes = min( mappable_region->length_bytes =
requested_length, range_end - bar_offset); min(requested_length, range_end - bar_offset);
return true; return true;
} }
@ -852,9 +852,9 @@ static bool gasket_mm_get_mapping_addrs(
* The offset is written into bar_offset on success. * The offset is written into bar_offset on success.
* Returns zero on success, anything else on error. * Returns zero on success, anything else on error.
*/ */
static int gasket_mm_vma_bar_offset( static int gasket_mm_vma_bar_offset(const struct gasket_dev *gasket_dev,
const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma, const struct vm_area_struct *vma,
ulong *bar_offset) ulong *bar_offset)
{ {
ulong raw_offset; ulong raw_offset;
int bar_index; int bar_index;
@ -877,9 +877,9 @@ static int gasket_mm_vma_bar_offset(
return 0; return 0;
} }
int gasket_mm_unmap_region( int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, struct vm_area_struct *vma,
const struct gasket_mappable_region *map_region) const struct gasket_mappable_region *map_region)
{ {
ulong bar_offset; ulong bar_offset;
ulong virt_offset; ulong virt_offset;
@ -893,9 +893,9 @@ int gasket_mm_unmap_region(
if (ret) if (ret)
return ret; return ret;
if (!gasket_mm_get_mapping_addrs( if (!gasket_mm_get_mapping_addrs(map_region, bar_offset,
map_region, bar_offset, vma->vm_end - vma->vm_start, vma->vm_end - vma->vm_start,
&mappable_region, &virt_offset)) &mappable_region, &virt_offset))
return 1; return 1;
/* /*
@ -904,18 +904,17 @@ int gasket_mm_unmap_region(
* *
* Next multiple of y: ceil_div(x, y) * y * Next multiple of y: ceil_div(x, y) * y
*/ */
zap_vma_ptes( zap_vma_ptes(vma, vma->vm_start + virt_offset,
vma, vma->vm_start + virt_offset, DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) *
DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) * PAGE_SIZE);
PAGE_SIZE);
return 0; return 0;
} }
EXPORT_SYMBOL(gasket_mm_unmap_region); EXPORT_SYMBOL(gasket_mm_unmap_region);
/* Maps a virtual address + range to a physical offset of a BAR. */ /* Maps a virtual address + range to a physical offset of a BAR. */
static enum do_map_region_status do_map_region( static enum do_map_region_status
const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
struct gasket_mappable_region *mappable_region) struct gasket_mappable_region *mappable_region)
{ {
/* Maximum size of a single call to io_remap_pfn_range. */ /* Maximum size of a single call to io_remap_pfn_range. */
/* I pulled this number out of thin air. */ /* I pulled this number out of thin air. */
@ -944,10 +943,9 @@ static enum do_map_region_status do_map_region(
virt_base = vma->vm_start + virt_offset; virt_base = vma->vm_start + virt_offset;
bar_index = bar_index =
gasket_get_bar_index( gasket_get_bar_index(gasket_dev,
gasket_dev, (vma->vm_pgoff << PAGE_SHIFT) +
(vma->vm_pgoff << PAGE_SHIFT) + driver_desc->legacy_mmap_address_offset);
driver_desc->legacy_mmap_address_offset);
phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset; phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;
while (mapped_bytes < map_length) { while (mapped_bytes < map_length) {
/* /*
@ -957,10 +955,10 @@ static enum do_map_region_status do_map_region(
chunk_size = min(max_chunk_size, map_length - mapped_bytes); chunk_size = min(max_chunk_size, map_length - mapped_bytes);
cond_resched(); cond_resched();
ret = io_remap_pfn_range( ret = io_remap_pfn_range(vma, virt_base + mapped_bytes,
vma, virt_base + mapped_bytes, (phys_base + mapped_bytes) >>
(phys_base + mapped_bytes) >> PAGE_SHIFT, PAGE_SHIFT, chunk_size,
chunk_size, vma->vm_page_prot); vma->vm_page_prot);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, dev_err(gasket_dev->dev,
"Error remapping PFN range.\n"); "Error remapping PFN range.\n");
@ -984,8 +982,8 @@ static enum do_map_region_status do_map_region(
} }
/* Map a region of coherent memory. */ /* Map a region of coherent memory. */
static int gasket_mmap_coherent( static int gasket_mmap_coherent(struct gasket_dev *gasket_dev,
struct gasket_dev *gasket_dev, struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
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;
@ -1008,10 +1006,9 @@ static int gasket_mmap_coherent(
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
ret = remap_pfn_range( ret = remap_pfn_range(vma, vma->vm_start,
vma, vma->vm_start, (gasket_dev->coherent_buffer.phys_base) >>
(gasket_dev->coherent_buffer.phys_base) >> PAGE_SHIFT, PAGE_SHIFT, requested_length, vma->vm_page_prot);
requested_length, vma->vm_page_prot);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n", dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n",
ret); ret);
@ -1022,9 +1019,9 @@ static int gasket_mmap_coherent(
/* Record the user virtual to dma_address mapping that was /* Record the user virtual to dma_address mapping that was
* created by the kernel. * created by the kernel.
*/ */
gasket_set_user_virt( gasket_set_user_virt(gasket_dev, requested_length,
gasket_dev, requested_length, gasket_dev->coherent_buffer.phys_base,
gasket_dev->coherent_buffer.phys_base, vma->vm_start); vma->vm_start);
return 0; return 0;
} }
@ -1058,8 +1055,8 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma)
raw_offset = (vma->vm_pgoff << PAGE_SHIFT) + raw_offset = (vma->vm_pgoff << PAGE_SHIFT) +
driver_desc->legacy_mmap_address_offset; driver_desc->legacy_mmap_address_offset;
vma_size = vma->vm_end - vma->vm_start; vma_size = vma->vm_end - vma->vm_start;
trace_gasket_mmap_entry( trace_gasket_mmap_entry(gasket_dev->dev_info.name, raw_offset,
gasket_dev->dev_info.name, raw_offset, vma_size); vma_size);
/* /*
* Check if the raw offset is within a bar region. If not, check if it * Check if the raw offset is within a bar region. If not, check if it
@ -1103,8 +1100,10 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma)
} }
if (driver_desc->get_mappable_regions_cb) { if (driver_desc->get_mappable_regions_cb) {
ret = driver_desc->get_mappable_regions_cb( ret = driver_desc->get_mappable_regions_cb(gasket_dev,
gasket_dev, bar_index, &map_regions, &num_map_regions); bar_index,
&map_regions,
&num_map_regions);
if (ret) if (ret)
return ret; return ret;
} else { } else {
@ -1231,8 +1230,8 @@ static int gasket_open(struct inode *inode, struct file *filp)
/* If the node is not owned, assign it to the current TGID. */ /* If the node is not owned, assign it to the current TGID. */
if (!ownership->is_owned) { if (!ownership->is_owned) {
ret = gasket_check_and_invoke_callback_nolock( ret = gasket_check_and_invoke_callback_nolock(gasket_dev,
gasket_dev, driver_desc->device_open_cb); driver_desc->device_open_cb);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, dev_err(gasket_dev->dev,
"Error in device open cb: %d\n", ret); "Error in device open cb: %d\n", ret);
@ -1298,16 +1297,14 @@ static int gasket_release(struct inode *inode, struct file *file)
driver_desc->device_reset_cb(gasket_dev, 0); driver_desc->device_reset_cb(gasket_dev, 0);
for (i = 0; i < driver_desc->num_page_tables; ++i) { for (i = 0; i < driver_desc->num_page_tables; ++i) {
gasket_page_table_unmap_all( gasket_page_table_unmap_all(gasket_dev->page_table[i]);
gasket_dev->page_table[i]); gasket_page_table_garbage_collect(gasket_dev->page_table[i]);
gasket_page_table_garbage_collect(
gasket_dev->page_table[i]);
gasket_free_coherent_memory_all(gasket_dev, i); gasket_free_coherent_memory_all(gasket_dev, i);
} }
/* Closes device, enters power save. */ /* Closes device, enters power save. */
gasket_check_and_invoke_callback_nolock( gasket_check_and_invoke_callback_nolock(gasket_dev,
gasket_dev, driver_desc->device_close_cb); driver_desc->device_close_cb);
} }
} }
@ -1367,21 +1364,21 @@ static const struct file_operations gasket_file_ops = {
}; };
/* Perform final init and marks the device as active. */ /* Perform final init and marks the device as active. */
static int gasket_enable_dev( static int gasket_enable_dev(struct gasket_internal_desc *internal_desc,
struct gasket_internal_desc *internal_desc, struct gasket_dev *gasket_dev)
struct gasket_dev *gasket_dev)
{ {
int tbl_idx; int tbl_idx;
int ret; int ret;
const struct gasket_driver_desc *driver_desc = const struct gasket_driver_desc *driver_desc =
internal_desc->driver_desc; internal_desc->driver_desc;
ret = gasket_interrupt_init( ret = gasket_interrupt_init(gasket_dev, driver_desc->name,
gasket_dev, driver_desc->name, driver_desc->interrupt_type,
driver_desc->interrupt_type, driver_desc->interrupts, driver_desc->interrupts,
driver_desc->num_interrupts, driver_desc->interrupt_pack_width, driver_desc->num_interrupts,
driver_desc->interrupt_bar_index, driver_desc->interrupt_pack_width,
driver_desc->wire_interrupt_offsets); 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);
@ -1392,12 +1389,11 @@ static int gasket_enable_dev(
for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) { for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) {
dev_dbg(gasket_dev->dev, "Initializing page table %d.\n", dev_dbg(gasket_dev->dev, "Initializing page table %d.\n",
tbl_idx); tbl_idx);
ret = gasket_page_table_init( ret = gasket_page_table_init(&gasket_dev->page_table[tbl_idx],
&gasket_dev->page_table[tbl_idx], &gasket_dev->bar_data[driver_desc->page_table_bar_index],
&gasket_dev->bar_data[ &driver_desc->page_table_configs[tbl_idx],
driver_desc->page_table_bar_index], gasket_dev->dev,
&driver_desc->page_table_configs[tbl_idx], gasket_dev->pci_dev);
gasket_dev->dev, gasket_dev->pci_dev);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, dev_err(gasket_dev->dev,
"Couldn't init page table %d: %d\n", "Couldn't init page table %d: %d\n",
@ -1415,8 +1411,8 @@ static int gasket_enable_dev(
* hardware_revision_cb returns a positive integer (the rev) if * hardware_revision_cb returns a positive integer (the rev) if
* successful.) * successful.)
*/ */
ret = check_and_invoke_callback( ret = check_and_invoke_callback(gasket_dev,
gasket_dev, driver_desc->hardware_revision_cb); driver_desc->hardware_revision_cb);
if (ret < 0) { if (ret < 0) {
dev_err(gasket_dev->dev, dev_err(gasket_dev->dev,
"Error getting hardware revision: %d\n", ret); "Error getting hardware revision: %d\n", ret);
@ -1436,8 +1432,8 @@ static int gasket_enable_dev(
if (gasket_dev->status == GASKET_STATUS_DEAD) if (gasket_dev->status == GASKET_STATUS_DEAD)
dev_err(gasket_dev->dev, "Device reported as unhealthy.\n"); dev_err(gasket_dev->dev, "Device reported as unhealthy.\n");
ret = gasket_add_cdev( ret = gasket_add_cdev(&gasket_dev->dev_info, &gasket_file_ops,
&gasket_dev->dev_info, &gasket_file_ops, driver_desc->module); driver_desc->module);
if (ret) if (ret)
return ret; return ret;
@ -1452,8 +1448,8 @@ static int gasket_enable_dev(
* *
* Returns 0 if successful and a negative value otherwise. * Returns 0 if successful and a negative value otherwise.
*/ */
static int gasket_pci_probe( static int gasket_pci_probe(struct pci_dev *pci_dev,
struct pci_dev *pci_dev, const struct pci_device_id *id) const struct pci_device_id *id)
{ {
int ret; int ret;
const char *kobj_name = dev_name(&pci_dev->dev); const char *kobj_name = dev_name(&pci_dev->dev);
@ -1497,8 +1493,8 @@ static int gasket_pci_probe(
goto fail2; goto fail2;
} }
ret = gasket_sysfs_create_mapping( ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
gasket_dev->dev_info.device, gasket_dev); gasket_dev);
if (ret) if (ret)
goto fail3; goto fail3;
@ -1513,13 +1509,13 @@ static int gasket_pci_probe(
"Cannot create sysfs pci link: %d\n", ret); "Cannot create sysfs pci link: %d\n", ret);
goto fail3; goto fail3;
} }
ret = gasket_sysfs_create_entries( ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
gasket_dev->dev_info.device, gasket_sysfs_generic_attrs); gasket_sysfs_generic_attrs);
if (ret) if (ret)
goto fail4; goto fail4;
ret = check_and_invoke_callback( ret = check_and_invoke_callback(gasket_dev,
gasket_dev, driver_desc->sysfs_setup_cb); driver_desc->sysfs_setup_cb);
if (ret) { if (ret) {
dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret); dev_err(gasket_dev->dev, "Error in sysfs setup cb: %d\n", ret);
goto fail5; goto fail5;
@ -1611,8 +1607,8 @@ static void gasket_pci_remove(struct pci_dev *pci_dev)
* *
* The table must have a NULL name pointer at the end. * The table must have a NULL name pointer at the end.
*/ */
const char *gasket_num_name_lookup( const char *gasket_num_name_lookup(uint num,
uint num, const struct gasket_num_name *table) const struct gasket_num_name *table)
{ {
uint i = 0; uint i = 0;
@ -1677,8 +1673,8 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type)
} }
EXPORT_SYMBOL(gasket_reset_nolock); EXPORT_SYMBOL(gasket_reset_nolock);
gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( gasket_ioctl_permissions_cb_t
struct gasket_dev *gasket_dev) gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev)
{ {
return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb; return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb;
} }
@ -1713,9 +1709,9 @@ struct device *gasket_get_device(struct gasket_dev *dev)
* Description: Busy waits for a specific combination of bits to be set on a * Description: Busy waits for a specific combination of bits to be set on a
* Gasket register. * Gasket register.
**/ **/
int gasket_wait_with_reschedule( int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, u64 offset, u64 mask, u64 val,
uint max_retries, u64 delay_ms) uint max_retries, u64 delay_ms)
{ {
uint retries = 0; uint retries = 0;
u64 tmp; u64 tmp;
@ -1797,17 +1793,17 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc)
* depends on KBUILD_MODNAME, and this is a shared file. * depends on KBUILD_MODNAME, and this is a shared file.
*/ */
pr_debug("Registering PCI driver.\n"); pr_debug("Registering PCI driver.\n");
ret = __pci_register_driver( ret = __pci_register_driver(&internal->pci, driver_desc->module,
&internal->pci, driver_desc->module, driver_desc->name); driver_desc->name);
if (ret) { if (ret) {
pr_err("cannot register pci driver [ret=%d]\n", ret); pr_err("cannot register pci driver [ret=%d]\n", ret);
goto fail1; goto fail1;
} }
pr_debug("Registering char driver.\n"); pr_debug("Registering char driver.\n");
ret = register_chrdev_region( ret = register_chrdev_region(MKDEV(driver_desc->major,
MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX, driver_desc->minor), GASKET_DEV_MAX,
driver_desc->name); driver_desc->name);
if (ret) { if (ret) {
pr_err("cannot register char driver [ret=%d]\n", ret); pr_err("cannot register char driver [ret=%d]\n", ret);
goto fail2; goto fail2;
@ -1853,8 +1849,8 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
return; return;
} }
unregister_chrdev_region( unregister_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor),
MKDEV(driver_desc->major, driver_desc->minor), GASKET_DEV_MAX); GASKET_DEV_MAX);
pci_unregister_driver(&internal_desc->pci); pci_unregister_driver(&internal_desc->pci);

View File

@ -318,11 +318,11 @@ struct gasket_dev {
}; };
/* Type of the ioctl handler callback. */ /* Type of the ioctl handler callback. */
typedef long (*gasket_ioctl_handler_cb_t) typedef long (*gasket_ioctl_handler_cb_t)(struct file *file, uint cmd,
(struct file *file, uint cmd, void __user *argp); void __user *argp);
/* Type of the ioctl permissions check callback. See below. */ /* Type of the ioctl permissions check callback. See below. */
typedef int (*gasket_ioctl_permissions_cb_t)( typedef int (*gasket_ioctl_permissions_cb_t)(struct file *filp, uint cmd,
struct file *filp, uint cmd, void __user *argp); void __user *argp);
/* /*
* Device type descriptor. * Device type descriptor.
@ -457,8 +457,8 @@ struct gasket_driver_desc {
* descriptor for an open file is closed. This call is intended to * descriptor for an open file is closed. This call is intended to
* handle any per-user or per-fd cleanup. * handle any per-user or per-fd cleanup.
*/ */
int (*device_release_cb)( int (*device_release_cb)(struct gasket_dev *gasket_dev,
struct gasket_dev *gasket_dev, struct file *file); struct file *file);
/* /*
* device_close_cb: Callback for when a device node is closed for the * device_close_cb: Callback for when a device node is closed for the
@ -527,10 +527,10 @@ struct gasket_driver_desc {
* information is then compared to mmap request to determine which * information is then compared to mmap request to determine which
* regions to actually map. * regions to actually map.
*/ */
int (*get_mappable_regions_cb)( int (*get_mappable_regions_cb)(struct gasket_dev *gasket_dev,
struct gasket_dev *gasket_dev, int bar_index, int bar_index,
struct gasket_mappable_region **mappable_regions, struct gasket_mappable_region **mappable_regions,
int *num_mappable_regions); int *num_mappable_regions);
/* /*
* ioctl_permissions_cb: Check permissions for generic ioctls. * ioctl_permissions_cb: Check permissions for generic ioctls.
@ -631,16 +631,16 @@ int gasket_reset_nolock(struct gasket_dev *gasket_dev, uint reset_type);
*/ */
/* Unmaps the specified mappable region from a VMA. */ /* Unmaps the specified mappable region from a VMA. */
int gasket_mm_unmap_region( int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, struct vm_area_struct *vma,
const struct gasket_mappable_region *map_region); const struct gasket_mappable_region *map_region);
/* /*
* Get the ioctl permissions callback. * Get the ioctl permissions callback.
* @gasket_dev: Gasket device structure. * @gasket_dev: Gasket device structure.
*/ */
gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb( gasket_ioctl_permissions_cb_t
struct gasket_dev *gasket_dev); gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev);
/** /**
* Lookup a name by number in a num_name table. * Lookup a name by number in a num_name table.
@ -648,37 +648,37 @@ gasket_ioctl_permissions_cb_t gasket_get_ioctl_permissions_cb(
* @table: Array of num_name structures, the table for the lookup. * @table: Array of num_name structures, the table for the lookup.
* *
*/ */
const char *gasket_num_name_lookup( const char *gasket_num_name_lookup(uint num,
uint num, const struct gasket_num_name *table); const struct gasket_num_name *table);
/* Handy inlines */ /* Handy inlines */
static inline ulong gasket_dev_read_64( static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar,
struct gasket_dev *gasket_dev, int bar, ulong location) ulong location)
{ {
return readq(&gasket_dev->bar_data[bar].virt_base[location]); return readq(&gasket_dev->bar_data[bar].virt_base[location]);
} }
static inline void gasket_dev_write_64( static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value,
struct gasket_dev *dev, u64 value, int bar, ulong location) int bar, ulong location)
{ {
writeq(value, &dev->bar_data[bar].virt_base[location]); writeq(value, &dev->bar_data[bar].virt_base[location]);
} }
static inline void gasket_dev_write_32( static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value,
struct gasket_dev *dev, u32 value, int bar, ulong location) int bar, ulong location)
{ {
writel(value, &dev->bar_data[bar].virt_base[location]); writel(value, &dev->bar_data[bar].virt_base[location]);
} }
static inline u32 gasket_dev_read_32( static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar,
struct gasket_dev *dev, int bar, ulong location) ulong location)
{ {
return readl(&dev->bar_data[bar].virt_base[location]); return readl(&dev->bar_data[bar].virt_base[location]);
} }
static inline void gasket_read_modify_write_64( static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar,
struct gasket_dev *dev, int bar, ulong location, u64 value, ulong location, u64 value,
u64 mask_width, u64 mask_shift) u64 mask_width, u64 mask_shift)
{ {
u64 mask, tmp; u64 mask, tmp;
@ -688,9 +688,9 @@ static inline void gasket_read_modify_write_64(
gasket_dev_write_64(dev, tmp, bar, location); gasket_dev_write_64(dev, tmp, bar, location);
} }
static inline void gasket_read_modify_write_32( static inline void gasket_read_modify_write_32(struct gasket_dev *dev, int bar,
struct gasket_dev *dev, int bar, ulong location, u32 value, ulong location, u32 value,
u32 mask_width, u32 mask_shift) u32 mask_width, u32 mask_shift)
{ {
u32 mask, tmp; u32 mask, tmp;
@ -707,8 +707,8 @@ const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev);
struct device *gasket_get_device(struct gasket_dev *dev); struct device *gasket_get_device(struct gasket_dev *dev);
/* Helper function, Asynchronous waits on a given set of bits. */ /* Helper function, Asynchronous waits on a given set of bits. */
int gasket_wait_with_reschedule( int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, u64 offset, u64 mask, u64 val,
uint max_retries, u64 delay_ms); uint max_retries, u64 delay_ms);
#endif /* __GASKET_CORE_H__ */ #endif /* __GASKET_CORE_H__ */