diff options
Diffstat (limited to 'drivers/staging/greybus')
-rw-r--r-- | drivers/staging/greybus/camera.c | 4 | ||||
-rw-r--r-- | drivers/staging/greybus/fw-management.c | 48 | ||||
-rw-r--r-- | drivers/staging/greybus/gpio.c | 16 |
3 files changed, 28 insertions, 40 deletions
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index 5d80ace41d8e..ec9fddfc0b14 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c @@ -1165,8 +1165,8 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam) gcam->debugfs.buffers[i].length = 0; debugfs_create_file_aux(entry->name, entry->mask, - gcam->debugfs.root, gcam, entry, - &gb_camera_debugfs_ops); + gcam->debugfs.root, gcam, entry, + &gb_camera_debugfs_ops); } return 0; diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c index a47385175582..152949c23d65 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -123,17 +123,11 @@ static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt, fw_info->major = le16_to_cpu(response.major); fw_info->minor = le16_to_cpu(response.minor); - strscpy_pad(fw_info->firmware_tag, response.firmware_tag); - - /* - * The firmware-tag should be NULL terminated, otherwise throw error but - * don't fail. - */ - if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { + ret = strscpy_pad(fw_info->firmware_tag, response.firmware_tag); + if (ret == -E2BIG) dev_err(fw_mgmt->parent, - "fw-version: firmware-tag is not NULL terminated\n"); - fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0'; - } + "fw-version: truncated firmware tag: %s\n", + fw_info->firmware_tag); return 0; } @@ -152,14 +146,12 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, } request.load_method = load_method; - strscpy_pad(request.firmware_tag, tag); - /* - * The firmware-tag should be NULL terminated, otherwise throw error and - * fail. - */ - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { - dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); + ret = strscpy_pad(request.firmware_tag, tag); + if (ret == -E2BIG) { + dev_err(fw_mgmt->parent, + "load-and-validate: truncated firmware tag: %s\n", + request.firmware_tag); return -EINVAL; } @@ -248,14 +240,11 @@ static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt, struct gb_fw_mgmt_backend_fw_version_response response; int ret; - strscpy_pad(request.firmware_tag, fw_info->firmware_tag); - - /* - * The firmware-tag should be NULL terminated, otherwise throw error and - * fail. - */ - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { - dev_err(fw_mgmt->parent, "backend-version: firmware-tag is not NULL terminated\n"); + ret = strscpy_pad(request.firmware_tag, fw_info->firmware_tag); + if (ret == -E2BIG) { + dev_err(fw_mgmt->parent, + "backend-fw-version: truncated firmware tag: %s\n", + request.firmware_tag); return -EINVAL; } @@ -302,13 +291,10 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, int ret; ret = strscpy_pad(request.firmware_tag, tag); - - /* - * The firmware-tag should be NULL terminated, otherwise throw error and - * fail. - */ if (ret == -E2BIG) { - dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL terminated\n"); + dev_err(fw_mgmt->parent, + "backend-fw-update: truncated firmware tag: %s\n", + request.firmware_tag); return -EINVAL; } diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index 16bcf7fc8158..f81c34160f72 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -185,8 +185,8 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc, return 0; } -static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc, - u8 which, bool value_high) +static int gb_gpio_set_value_operation(struct gb_gpio_controller *ggc, + u8 which, bool value_high) { struct device *dev = &ggc->gbphy_dev->dev; struct gb_gpio_set_value_request request; @@ -195,7 +195,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc, if (ggc->lines[which].direction == 1) { dev_warn(dev, "refusing to set value of input gpio %u\n", which); - return; + return -EPERM; } request.which = which; @@ -204,10 +204,12 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc, &request, sizeof(request), NULL, 0); if (ret) { dev_err(dev, "failed to set value of gpio %u\n", which); - return; + return ret; } ggc->lines[which].value = request.value; + + return 0; } static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc, @@ -457,11 +459,11 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned int offset) return ggc->lines[which].value; } -static void gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) +static int gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { struct gb_gpio_controller *ggc = gpiochip_get_data(chip); - gb_gpio_set_value_operation(ggc, (u8)offset, !!value); + return gb_gpio_set_value_operation(ggc, (u8)offset, !!value); } static int gb_gpio_set_config(struct gpio_chip *chip, unsigned int offset, @@ -555,7 +557,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, gpio->direction_input = gb_gpio_direction_input; gpio->direction_output = gb_gpio_direction_output; gpio->get = gb_gpio_get; - gpio->set = gb_gpio_set; + gpio->set_rv = gb_gpio_set; gpio->set_config = gb_gpio_set_config; gpio->base = -1; /* Allocate base dynamically */ gpio->ngpio = ggc->line_max + 1; |