|
@@ -92,23 +92,23 @@ void *vme_alloc_consistent(struct vme_resource *resource, size_t size,
|
|
{
|
|
{
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
- if (resource == NULL) {
|
|
|
|
|
|
+ if (!resource) {
|
|
printk(KERN_ERR "No resource\n");
|
|
printk(KERN_ERR "No resource\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
bridge = find_bridge(resource);
|
|
bridge = find_bridge(resource);
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find bridge\n");
|
|
printk(KERN_ERR "Can't find bridge\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->parent == NULL) {
|
|
|
|
|
|
+ if (!bridge->parent) {
|
|
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
|
|
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->alloc_consistent == NULL) {
|
|
|
|
|
|
+ if (!bridge->alloc_consistent) {
|
|
printk(KERN_ERR "alloc_consistent not supported by bridge %s\n",
|
|
printk(KERN_ERR "alloc_consistent not supported by bridge %s\n",
|
|
bridge->name);
|
|
bridge->name);
|
|
return NULL;
|
|
return NULL;
|
|
@@ -132,23 +132,23 @@ void vme_free_consistent(struct vme_resource *resource, size_t size,
|
|
{
|
|
{
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
- if (resource == NULL) {
|
|
|
|
|
|
+ if (!resource) {
|
|
printk(KERN_ERR "No resource\n");
|
|
printk(KERN_ERR "No resource\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
bridge = find_bridge(resource);
|
|
bridge = find_bridge(resource);
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find bridge\n");
|
|
printk(KERN_ERR "Can't find bridge\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->parent == NULL) {
|
|
|
|
|
|
+ if (!bridge->parent) {
|
|
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
|
|
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->free_consistent == NULL) {
|
|
|
|
|
|
+ if (!bridge->free_consistent) {
|
|
printk(KERN_ERR "free_consistent not supported by bridge %s\n",
|
|
printk(KERN_ERR "free_consistent not supported by bridge %s\n",
|
|
bridge->name);
|
|
bridge->name);
|
|
return;
|
|
return;
|
|
@@ -208,29 +208,27 @@ int vme_check_window(u32 aspace, unsigned long long vme_base,
|
|
{
|
|
{
|
|
int retval = 0;
|
|
int retval = 0;
|
|
|
|
|
|
|
|
+ if (vme_base + size < size)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
switch (aspace) {
|
|
switch (aspace) {
|
|
case VME_A16:
|
|
case VME_A16:
|
|
- if (((vme_base + size) > VME_A16_MAX) ||
|
|
|
|
- (vme_base > VME_A16_MAX))
|
|
|
|
|
|
+ if (vme_base + size > VME_A16_MAX)
|
|
retval = -EFAULT;
|
|
retval = -EFAULT;
|
|
break;
|
|
break;
|
|
case VME_A24:
|
|
case VME_A24:
|
|
- if (((vme_base + size) > VME_A24_MAX) ||
|
|
|
|
- (vme_base > VME_A24_MAX))
|
|
|
|
|
|
+ if (vme_base + size > VME_A24_MAX)
|
|
retval = -EFAULT;
|
|
retval = -EFAULT;
|
|
break;
|
|
break;
|
|
case VME_A32:
|
|
case VME_A32:
|
|
- if (((vme_base + size) > VME_A32_MAX) ||
|
|
|
|
- (vme_base > VME_A32_MAX))
|
|
|
|
|
|
+ if (vme_base + size > VME_A32_MAX)
|
|
retval = -EFAULT;
|
|
retval = -EFAULT;
|
|
break;
|
|
break;
|
|
case VME_A64:
|
|
case VME_A64:
|
|
- if ((size != 0) && (vme_base > U64_MAX + 1 - size))
|
|
|
|
- retval = -EFAULT;
|
|
|
|
|
|
+ /* The VME_A64_MAX limit is actually U64_MAX + 1 */
|
|
break;
|
|
break;
|
|
case VME_CRCSR:
|
|
case VME_CRCSR:
|
|
- if (((vme_base + size) > VME_CRCSR_MAX) ||
|
|
|
|
- (vme_base > VME_CRCSR_MAX))
|
|
|
|
|
|
+ if (vme_base + size > VME_CRCSR_MAX)
|
|
retval = -EFAULT;
|
|
retval = -EFAULT;
|
|
break;
|
|
break;
|
|
case VME_USER1:
|
|
case VME_USER1:
|
|
@@ -303,7 +301,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
|
|
struct vme_resource *resource = NULL;
|
|
struct vme_resource *resource = NULL;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
goto err_bus;
|
|
goto err_bus;
|
|
}
|
|
}
|
|
@@ -313,7 +311,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
|
|
slave_image = list_entry(slave_pos,
|
|
slave_image = list_entry(slave_pos,
|
|
struct vme_slave_resource, list);
|
|
struct vme_slave_resource, list);
|
|
|
|
|
|
- if (slave_image == NULL) {
|
|
|
|
|
|
+ if (!slave_image) {
|
|
printk(KERN_ERR "Registered NULL Slave resource\n");
|
|
printk(KERN_ERR "Registered NULL Slave resource\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -333,14 +331,13 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
|
|
}
|
|
}
|
|
|
|
|
|
/* No free image */
|
|
/* No free image */
|
|
- if (allocated_image == NULL)
|
|
|
|
|
|
+ if (!allocated_image)
|
|
goto err_image;
|
|
goto err_image;
|
|
|
|
|
|
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
|
|
|
|
- if (resource == NULL) {
|
|
|
|
- printk(KERN_WARNING "Unable to allocate resource structure\n");
|
|
|
|
|
|
+ resource = kmalloc(sizeof(*resource), GFP_KERNEL);
|
|
|
|
+ if (!resource)
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
- }
|
|
|
|
|
|
+
|
|
resource->type = VME_SLAVE;
|
|
resource->type = VME_SLAVE;
|
|
resource->entry = &allocated_image->list;
|
|
resource->entry = &allocated_image->list;
|
|
|
|
|
|
@@ -389,7 +386,7 @@ int vme_slave_set(struct vme_resource *resource, int enabled,
|
|
|
|
|
|
image = list_entry(resource->entry, struct vme_slave_resource, list);
|
|
image = list_entry(resource->entry, struct vme_slave_resource, list);
|
|
|
|
|
|
- if (bridge->slave_set == NULL) {
|
|
|
|
|
|
+ if (!bridge->slave_set) {
|
|
printk(KERN_ERR "Function not supported\n");
|
|
printk(KERN_ERR "Function not supported\n");
|
|
return -ENOSYS;
|
|
return -ENOSYS;
|
|
}
|
|
}
|
|
@@ -438,7 +435,7 @@ int vme_slave_get(struct vme_resource *resource, int *enabled,
|
|
|
|
|
|
image = list_entry(resource->entry, struct vme_slave_resource, list);
|
|
image = list_entry(resource->entry, struct vme_slave_resource, list);
|
|
|
|
|
|
- if (bridge->slave_get == NULL) {
|
|
|
|
|
|
+ if (!bridge->slave_get) {
|
|
printk(KERN_ERR "vme_slave_get not supported\n");
|
|
printk(KERN_ERR "vme_slave_get not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -465,7 +462,7 @@ void vme_slave_free(struct vme_resource *resource)
|
|
|
|
|
|
slave_image = list_entry(resource->entry, struct vme_slave_resource,
|
|
slave_image = list_entry(resource->entry, struct vme_slave_resource,
|
|
list);
|
|
list);
|
|
- if (slave_image == NULL) {
|
|
|
|
|
|
+ if (!slave_image) {
|
|
printk(KERN_ERR "Can't find slave resource\n");
|
|
printk(KERN_ERR "Can't find slave resource\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -505,7 +502,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
|
|
struct vme_resource *resource = NULL;
|
|
struct vme_resource *resource = NULL;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
goto err_bus;
|
|
goto err_bus;
|
|
}
|
|
}
|
|
@@ -515,7 +512,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
|
|
master_image = list_entry(master_pos,
|
|
master_image = list_entry(master_pos,
|
|
struct vme_master_resource, list);
|
|
struct vme_master_resource, list);
|
|
|
|
|
|
- if (master_image == NULL) {
|
|
|
|
|
|
+ if (!master_image) {
|
|
printk(KERN_WARNING "Registered NULL master resource\n");
|
|
printk(KERN_WARNING "Registered NULL master resource\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -536,16 +533,15 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
|
|
}
|
|
}
|
|
|
|
|
|
/* Check to see if we found a resource */
|
|
/* Check to see if we found a resource */
|
|
- if (allocated_image == NULL) {
|
|
|
|
|
|
+ if (!allocated_image) {
|
|
printk(KERN_ERR "Can't find a suitable resource\n");
|
|
printk(KERN_ERR "Can't find a suitable resource\n");
|
|
goto err_image;
|
|
goto err_image;
|
|
}
|
|
}
|
|
|
|
|
|
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
|
|
|
|
- if (resource == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate resource structure\n");
|
|
|
|
|
|
+ resource = kmalloc(sizeof(*resource), GFP_KERNEL);
|
|
|
|
+ if (!resource)
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
- }
|
|
|
|
|
|
+
|
|
resource->type = VME_MASTER;
|
|
resource->type = VME_MASTER;
|
|
resource->entry = &allocated_image->list;
|
|
resource->entry = &allocated_image->list;
|
|
|
|
|
|
@@ -594,7 +590,7 @@ int vme_master_set(struct vme_resource *resource, int enabled,
|
|
|
|
|
|
image = list_entry(resource->entry, struct vme_master_resource, list);
|
|
image = list_entry(resource->entry, struct vme_master_resource, list);
|
|
|
|
|
|
- if (bridge->master_set == NULL) {
|
|
|
|
|
|
+ if (!bridge->master_set) {
|
|
printk(KERN_WARNING "vme_master_set not supported\n");
|
|
printk(KERN_WARNING "vme_master_set not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -644,7 +640,7 @@ int vme_master_get(struct vme_resource *resource, int *enabled,
|
|
|
|
|
|
image = list_entry(resource->entry, struct vme_master_resource, list);
|
|
image = list_entry(resource->entry, struct vme_master_resource, list);
|
|
|
|
|
|
- if (bridge->master_get == NULL) {
|
|
|
|
|
|
+ if (!bridge->master_get) {
|
|
printk(KERN_WARNING "%s not supported\n", __func__);
|
|
printk(KERN_WARNING "%s not supported\n", __func__);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -676,7 +672,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
|
|
struct vme_master_resource *image;
|
|
struct vme_master_resource *image;
|
|
size_t length;
|
|
size_t length;
|
|
|
|
|
|
- if (bridge->master_read == NULL) {
|
|
|
|
|
|
+ if (!bridge->master_read) {
|
|
printk(KERN_WARNING "Reading from resource not supported\n");
|
|
printk(KERN_WARNING "Reading from resource not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -725,7 +721,7 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf,
|
|
struct vme_master_resource *image;
|
|
struct vme_master_resource *image;
|
|
size_t length;
|
|
size_t length;
|
|
|
|
|
|
- if (bridge->master_write == NULL) {
|
|
|
|
|
|
+ if (!bridge->master_write) {
|
|
printk(KERN_WARNING "Writing to resource not supported\n");
|
|
printk(KERN_WARNING "Writing to resource not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -776,7 +772,7 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
|
|
struct vme_bridge *bridge = find_bridge(resource);
|
|
struct vme_bridge *bridge = find_bridge(resource);
|
|
struct vme_master_resource *image;
|
|
struct vme_master_resource *image;
|
|
|
|
|
|
- if (bridge->master_rmw == NULL) {
|
|
|
|
|
|
+ if (!bridge->master_rmw) {
|
|
printk(KERN_WARNING "Writing to resource not supported\n");
|
|
printk(KERN_WARNING "Writing to resource not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -846,7 +842,7 @@ void vme_master_free(struct vme_resource *resource)
|
|
|
|
|
|
master_image = list_entry(resource->entry, struct vme_master_resource,
|
|
master_image = list_entry(resource->entry, struct vme_master_resource,
|
|
list);
|
|
list);
|
|
- if (master_image == NULL) {
|
|
|
|
|
|
+ if (!master_image) {
|
|
printk(KERN_ERR "Can't find master resource\n");
|
|
printk(KERN_ERR "Can't find master resource\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -886,7 +882,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
|
|
printk(KERN_ERR "No VME resource Attribute tests done\n");
|
|
printk(KERN_ERR "No VME resource Attribute tests done\n");
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
goto err_bus;
|
|
goto err_bus;
|
|
}
|
|
}
|
|
@@ -895,8 +891,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
|
|
list_for_each(dma_pos, &bridge->dma_resources) {
|
|
list_for_each(dma_pos, &bridge->dma_resources) {
|
|
dma_ctrlr = list_entry(dma_pos,
|
|
dma_ctrlr = list_entry(dma_pos,
|
|
struct vme_dma_resource, list);
|
|
struct vme_dma_resource, list);
|
|
-
|
|
|
|
- if (dma_ctrlr == NULL) {
|
|
|
|
|
|
+ if (!dma_ctrlr) {
|
|
printk(KERN_ERR "Registered NULL DMA resource\n");
|
|
printk(KERN_ERR "Registered NULL DMA resource\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -915,14 +910,13 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
|
|
}
|
|
}
|
|
|
|
|
|
/* Check to see if we found a resource */
|
|
/* Check to see if we found a resource */
|
|
- if (allocated_ctrlr == NULL)
|
|
|
|
|
|
+ if (!allocated_ctrlr)
|
|
goto err_ctrlr;
|
|
goto err_ctrlr;
|
|
|
|
|
|
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
|
|
|
|
- if (resource == NULL) {
|
|
|
|
- printk(KERN_WARNING "Unable to allocate resource structure\n");
|
|
|
|
|
|
+ resource = kmalloc(sizeof(*resource), GFP_KERNEL);
|
|
|
|
+ if (!resource)
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
- }
|
|
|
|
|
|
+
|
|
resource->type = VME_DMA;
|
|
resource->type = VME_DMA;
|
|
resource->entry = &allocated_ctrlr->list;
|
|
resource->entry = &allocated_ctrlr->list;
|
|
|
|
|
|
@@ -951,7 +945,6 @@ EXPORT_SYMBOL(vme_dma_request);
|
|
*/
|
|
*/
|
|
struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
|
|
struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
|
|
{
|
|
{
|
|
- struct vme_dma_resource *ctrlr;
|
|
|
|
struct vme_dma_list *dma_list;
|
|
struct vme_dma_list *dma_list;
|
|
|
|
|
|
if (resource->type != VME_DMA) {
|
|
if (resource->type != VME_DMA) {
|
|
@@ -959,15 +952,14 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
|
|
|
|
-
|
|
|
|
- dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
|
|
|
|
- if (dma_list == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for new DMA list\n");
|
|
|
|
|
|
+ dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
|
|
|
|
+ if (!dma_list)
|
|
return NULL;
|
|
return NULL;
|
|
- }
|
|
|
|
|
|
+
|
|
INIT_LIST_HEAD(&dma_list->entries);
|
|
INIT_LIST_HEAD(&dma_list->entries);
|
|
- dma_list->parent = ctrlr;
|
|
|
|
|
|
+ dma_list->parent = list_entry(resource->entry,
|
|
|
|
+ struct vme_dma_resource,
|
|
|
|
+ list);
|
|
mutex_init(&dma_list->mtx);
|
|
mutex_init(&dma_list->mtx);
|
|
|
|
|
|
return dma_list;
|
|
return dma_list;
|
|
@@ -990,17 +982,13 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type)
|
|
struct vme_dma_attr *attributes;
|
|
struct vme_dma_attr *attributes;
|
|
struct vme_dma_pattern *pattern_attr;
|
|
struct vme_dma_pattern *pattern_attr;
|
|
|
|
|
|
- attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
|
|
|
|
- if (attributes == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
|
|
|
|
|
|
+ attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
|
|
|
|
+ if (!attributes)
|
|
goto err_attr;
|
|
goto err_attr;
|
|
- }
|
|
|
|
|
|
|
|
- pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL);
|
|
|
|
- if (pattern_attr == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for pattern attributes\n");
|
|
|
|
|
|
+ pattern_attr = kmalloc(sizeof(*pattern_attr), GFP_KERNEL);
|
|
|
|
+ if (!pattern_attr)
|
|
goto err_pat;
|
|
goto err_pat;
|
|
- }
|
|
|
|
|
|
|
|
attributes->type = VME_DMA_PATTERN;
|
|
attributes->type = VME_DMA_PATTERN;
|
|
attributes->private = (void *)pattern_attr;
|
|
attributes->private = (void *)pattern_attr;
|
|
@@ -1034,19 +1022,13 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
|
|
|
|
|
|
/* XXX Run some sanity checks here */
|
|
/* XXX Run some sanity checks here */
|
|
|
|
|
|
- attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
|
|
|
|
- if (attributes == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
|
|
|
|
|
|
+ attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
|
|
|
|
+ if (!attributes)
|
|
goto err_attr;
|
|
goto err_attr;
|
|
- }
|
|
|
|
|
|
|
|
- pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL);
|
|
|
|
- if (pci_attr == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for PCI attributes\n");
|
|
|
|
|
|
+ pci_attr = kmalloc(sizeof(*pci_attr), GFP_KERNEL);
|
|
|
|
+ if (!pci_attr)
|
|
goto err_pci;
|
|
goto err_pci;
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
attributes->type = VME_DMA_PCI;
|
|
attributes->type = VME_DMA_PCI;
|
|
attributes->private = (void *)pci_attr;
|
|
attributes->private = (void *)pci_attr;
|
|
@@ -1081,18 +1063,13 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
|
|
struct vme_dma_attr *attributes;
|
|
struct vme_dma_attr *attributes;
|
|
struct vme_dma_vme *vme_attr;
|
|
struct vme_dma_vme *vme_attr;
|
|
|
|
|
|
- attributes = kmalloc(
|
|
|
|
- sizeof(struct vme_dma_attr), GFP_KERNEL);
|
|
|
|
- if (attributes == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
|
|
|
|
|
|
+ attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
|
|
|
|
+ if (!attributes)
|
|
goto err_attr;
|
|
goto err_attr;
|
|
- }
|
|
|
|
|
|
|
|
- vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL);
|
|
|
|
- if (vme_attr == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for VME attributes\n");
|
|
|
|
|
|
+ vme_attr = kmalloc(sizeof(*vme_attr), GFP_KERNEL);
|
|
|
|
+ if (!vme_attr)
|
|
goto err_vme;
|
|
goto err_vme;
|
|
- }
|
|
|
|
|
|
|
|
attributes->type = VME_DMA_VME;
|
|
attributes->type = VME_DMA_VME;
|
|
attributes->private = (void *)vme_attr;
|
|
attributes->private = (void *)vme_attr;
|
|
@@ -1148,7 +1125,7 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
int retval;
|
|
int retval;
|
|
|
|
|
|
- if (bridge->dma_list_add == NULL) {
|
|
|
|
|
|
+ if (!bridge->dma_list_add) {
|
|
printk(KERN_WARNING "Link List DMA generation not supported\n");
|
|
printk(KERN_WARNING "Link List DMA generation not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1181,7 +1158,7 @@ int vme_dma_list_exec(struct vme_dma_list *list)
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
int retval;
|
|
int retval;
|
|
|
|
|
|
- if (bridge->dma_list_exec == NULL) {
|
|
|
|
|
|
+ if (!bridge->dma_list_exec) {
|
|
printk(KERN_ERR "Link List DMA execution not supported\n");
|
|
printk(KERN_ERR "Link List DMA execution not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1210,14 +1187,14 @@ int vme_dma_list_free(struct vme_dma_list *list)
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
struct vme_bridge *bridge = list->parent->parent;
|
|
int retval;
|
|
int retval;
|
|
|
|
|
|
- if (bridge->dma_list_empty == NULL) {
|
|
|
|
|
|
+ if (!bridge->dma_list_empty) {
|
|
printk(KERN_WARNING "Emptying of Link Lists not supported\n");
|
|
printk(KERN_WARNING "Emptying of Link Lists not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
if (!mutex_trylock(&list->mtx)) {
|
|
if (!mutex_trylock(&list->mtx)) {
|
|
printk(KERN_ERR "Link List in use\n");
|
|
printk(KERN_ERR "Link List in use\n");
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return -EBUSY;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1342,8 +1319,7 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
|
|
|
|
|
|
call = bridge->irq[level - 1].callback[statid].func;
|
|
call = bridge->irq[level - 1].callback[statid].func;
|
|
priv_data = bridge->irq[level - 1].callback[statid].priv_data;
|
|
priv_data = bridge->irq[level - 1].callback[statid].priv_data;
|
|
-
|
|
|
|
- if (call != NULL)
|
|
|
|
|
|
+ if (call)
|
|
call(level, statid, priv_data);
|
|
call(level, statid, priv_data);
|
|
else
|
|
else
|
|
printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n",
|
|
printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n",
|
|
@@ -1374,7 +1350,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1384,7 +1360,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->irq_set == NULL) {
|
|
|
|
|
|
+ if (!bridge->irq_set) {
|
|
printk(KERN_ERR "Configuring interrupts not supported\n");
|
|
printk(KERN_ERR "Configuring interrupts not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1423,7 +1399,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1433,7 +1409,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->irq_set == NULL) {
|
|
|
|
|
|
+ if (!bridge->irq_set) {
|
|
printk(KERN_ERR "Configuring interrupts not supported\n");
|
|
printk(KERN_ERR "Configuring interrupts not supported\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1470,7 +1446,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1480,7 +1456,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->irq_generate == NULL) {
|
|
|
|
|
|
+ if (!bridge->irq_generate) {
|
|
printk(KERN_WARNING "Interrupt generation not supported\n");
|
|
printk(KERN_WARNING "Interrupt generation not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1508,7 +1484,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
|
|
struct vme_resource *resource = NULL;
|
|
struct vme_resource *resource = NULL;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
goto err_bus;
|
|
goto err_bus;
|
|
}
|
|
}
|
|
@@ -1517,8 +1493,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
|
|
list_for_each(lm_pos, &bridge->lm_resources) {
|
|
list_for_each(lm_pos, &bridge->lm_resources) {
|
|
lm = list_entry(lm_pos,
|
|
lm = list_entry(lm_pos,
|
|
struct vme_lm_resource, list);
|
|
struct vme_lm_resource, list);
|
|
-
|
|
|
|
- if (lm == NULL) {
|
|
|
|
|
|
+ if (!lm) {
|
|
printk(KERN_ERR "Registered NULL Location Monitor resource\n");
|
|
printk(KERN_ERR "Registered NULL Location Monitor resource\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -1535,14 +1510,13 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
|
|
}
|
|
}
|
|
|
|
|
|
/* Check to see if we found a resource */
|
|
/* Check to see if we found a resource */
|
|
- if (allocated_lm == NULL)
|
|
|
|
|
|
+ if (!allocated_lm)
|
|
goto err_lm;
|
|
goto err_lm;
|
|
|
|
|
|
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
|
|
|
|
- if (resource == NULL) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate resource structure\n");
|
|
|
|
|
|
+ resource = kmalloc(sizeof(*resource), GFP_KERNEL);
|
|
|
|
+ if (!resource)
|
|
goto err_alloc;
|
|
goto err_alloc;
|
|
- }
|
|
|
|
|
|
+
|
|
resource->type = VME_LM;
|
|
resource->type = VME_LM;
|
|
resource->entry = &allocated_lm->list;
|
|
resource->entry = &allocated_lm->list;
|
|
|
|
|
|
@@ -1612,7 +1586,7 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
|
|
|
|
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
|
|
|
|
- if (bridge->lm_set == NULL) {
|
|
|
|
|
|
+ if (!bridge->lm_set) {
|
|
printk(KERN_ERR "vme_lm_set not supported\n");
|
|
printk(KERN_ERR "vme_lm_set not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1648,7 +1622,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
|
|
|
|
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
|
|
|
|
- if (bridge->lm_get == NULL) {
|
|
|
|
|
|
+ if (!bridge->lm_get) {
|
|
printk(KERN_ERR "vme_lm_get not supported\n");
|
|
printk(KERN_ERR "vme_lm_get not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1685,7 +1659,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,
|
|
|
|
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
|
|
|
|
- if (bridge->lm_attach == NULL) {
|
|
|
|
|
|
+ if (!bridge->lm_attach) {
|
|
printk(KERN_ERR "vme_lm_attach not supported\n");
|
|
printk(KERN_ERR "vme_lm_attach not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1718,7 +1692,7 @@ int vme_lm_detach(struct vme_resource *resource, int monitor)
|
|
|
|
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
lm = list_entry(resource->entry, struct vme_lm_resource, list);
|
|
|
|
|
|
- if (bridge->lm_detach == NULL) {
|
|
|
|
|
|
+ if (!bridge->lm_detach) {
|
|
printk(KERN_ERR "vme_lm_detach not supported\n");
|
|
printk(KERN_ERR "vme_lm_detach not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1780,12 +1754,12 @@ int vme_slot_num(struct vme_dev *vdev)
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
printk(KERN_ERR "Can't find VME bus\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
- if (bridge->slot_get == NULL) {
|
|
|
|
|
|
+ if (!bridge->slot_get) {
|
|
printk(KERN_WARNING "vme_slot_num not supported\n");
|
|
printk(KERN_WARNING "vme_slot_num not supported\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1808,7 +1782,7 @@ int vme_bus_num(struct vme_dev *vdev)
|
|
struct vme_bridge *bridge;
|
|
struct vme_bridge *bridge;
|
|
|
|
|
|
bridge = vdev->bridge;
|
|
bridge = vdev->bridge;
|
|
- if (bridge == NULL) {
|
|
|
|
|
|
+ if (!bridge) {
|
|
pr_err("Can't find VME bus\n");
|
|
pr_err("Can't find VME bus\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -1888,7 +1862,7 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
|
|
struct vme_dev *tmp;
|
|
struct vme_dev *tmp;
|
|
|
|
|
|
for (i = 0; i < ndevs; i++) {
|
|
for (i = 0; i < ndevs; i++) {
|
|
- vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL);
|
|
|
|
|
|
+ vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
|
|
if (!vdev) {
|
|
if (!vdev) {
|
|
err = -ENOMEM;
|
|
err = -ENOMEM;
|
|
goto err_devalloc;
|
|
goto err_devalloc;
|
|
@@ -2020,30 +1994,26 @@ static int vme_bus_match(struct device *dev, struct device_driver *drv)
|
|
|
|
|
|
static int vme_bus_probe(struct device *dev)
|
|
static int vme_bus_probe(struct device *dev)
|
|
{
|
|
{
|
|
- int retval = -ENODEV;
|
|
|
|
struct vme_driver *driver;
|
|
struct vme_driver *driver;
|
|
struct vme_dev *vdev = dev_to_vme_dev(dev);
|
|
struct vme_dev *vdev = dev_to_vme_dev(dev);
|
|
|
|
|
|
driver = dev->platform_data;
|
|
driver = dev->platform_data;
|
|
|
|
+ if (driver->probe)
|
|
|
|
+ return driver->probe(vdev);
|
|
|
|
|
|
- if (driver->probe != NULL)
|
|
|
|
- retval = driver->probe(vdev);
|
|
|
|
-
|
|
|
|
- return retval;
|
|
|
|
|
|
+ return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
static int vme_bus_remove(struct device *dev)
|
|
static int vme_bus_remove(struct device *dev)
|
|
{
|
|
{
|
|
- int retval = -ENODEV;
|
|
|
|
struct vme_driver *driver;
|
|
struct vme_driver *driver;
|
|
struct vme_dev *vdev = dev_to_vme_dev(dev);
|
|
struct vme_dev *vdev = dev_to_vme_dev(dev);
|
|
|
|
|
|
driver = dev->platform_data;
|
|
driver = dev->platform_data;
|
|
|
|
+ if (driver->remove)
|
|
|
|
+ return driver->remove(vdev);
|
|
|
|
|
|
- if (driver->remove != NULL)
|
|
|
|
- retval = driver->remove(vdev);
|
|
|
|
-
|
|
|
|
- return retval;
|
|
|
|
|
|
+ return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
struct bus_type vme_bus_type = {
|
|
struct bus_type vme_bus_type = {
|