diff options
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r-- | drivers/iio/industrialio-buffer.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index dadd921a4a30..4fa273002c03 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -343,12 +343,12 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, } bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength); - kfree(trialmask); + bitmap_free(trialmask); return 0; err_invalid_mask: - kfree(trialmask); + bitmap_free(trialmask); return -EINVAL; } @@ -665,7 +665,7 @@ static void iio_free_scan_mask(struct iio_dev *indio_dev, { /* If the mask is dynamically allocated free it, otherwise do nothing */ if (!indio_dev->available_scan_masks) - kfree(mask); + bitmap_free(mask); } struct iio_device_config { @@ -735,8 +735,7 @@ static int iio_verify_update(struct iio_dev *indio_dev, } /* What scan mask do we actually have? */ - compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength), - sizeof(long), GFP_KERNEL); + compound_mask = bitmap_zalloc(indio_dev->masklength, GFP_KERNEL); if (compound_mask == NULL) return -ENOMEM; @@ -761,7 +760,7 @@ static int iio_verify_update(struct iio_dev *indio_dev, indio_dev->masklength, compound_mask, strict_scanmask); - kfree(compound_mask); + bitmap_free(compound_mask); if (scan_mask == NULL) return -EINVAL; } else { @@ -1302,9 +1301,8 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) channels[i].scan_index; } if (indio_dev->masklength && buffer->scan_mask == NULL) { - buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength), - sizeof(*buffer->scan_mask), - GFP_KERNEL); + buffer->scan_mask = bitmap_zalloc(indio_dev->masklength, + GFP_KERNEL); if (buffer->scan_mask == NULL) { ret = -ENOMEM; goto error_cleanup_dynamic; @@ -1333,7 +1331,7 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) return 0; error_free_scan_mask: - kfree(buffer->scan_mask); + bitmap_free(buffer->scan_mask); error_cleanup_dynamic: iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list); kfree(indio_dev->buffer->buffer_group.attrs); @@ -1346,7 +1344,7 @@ void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) if (!indio_dev->buffer) return; - kfree(indio_dev->buffer->scan_mask); + bitmap_free(indio_dev->buffer->scan_mask); kfree(indio_dev->buffer->buffer_group.attrs); kfree(indio_dev->buffer->scan_el_group.attrs); iio_free_chan_devattr_list(&indio_dev->buffer->scan_el_dev_attr_list); |