.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * uvc_ctrl.c -- USB Video Class driver - Controls |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005-2010 |
---|
5 | 6 | * Laurent Pinchart (laurent.pinchart@ideasonboard.com) |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License as published by |
---|
9 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
10 | | - * (at your option) any later version. |
---|
11 | | - * |
---|
12 | 7 | */ |
---|
13 | 8 | |
---|
14 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
38 | 33 | * Controls |
---|
39 | 34 | */ |
---|
40 | 35 | |
---|
41 | | -static struct uvc_control_info uvc_ctrls[] = { |
---|
| 36 | +static const struct uvc_control_info uvc_ctrls[] = { |
---|
42 | 37 | { |
---|
43 | 38 | .entity = UVC_GUID_UVC_PROCESSING, |
---|
44 | 39 | .selector = UVC_PU_BRIGHTNESS_CONTROL, |
---|
.. | .. |
---|
354 | 349 | }, |
---|
355 | 350 | }; |
---|
356 | 351 | |
---|
357 | | -static struct uvc_menu_info power_line_frequency_controls[] = { |
---|
| 352 | +static const struct uvc_menu_info power_line_frequency_controls[] = { |
---|
358 | 353 | { 0, "Disabled" }, |
---|
359 | 354 | { 1, "50 Hz" }, |
---|
360 | 355 | { 2, "60 Hz" }, |
---|
361 | 356 | }; |
---|
362 | 357 | |
---|
363 | | -static struct uvc_menu_info exposure_auto_controls[] = { |
---|
| 358 | +static const struct uvc_menu_info exposure_auto_controls[] = { |
---|
364 | 359 | { 2, "Auto Mode" }, |
---|
365 | 360 | { 1, "Manual Mode" }, |
---|
366 | 361 | { 4, "Shutter Priority Mode" }, |
---|
.. | .. |
---|
421 | 416 | data[first+1] = min_t(int, abs(value), 0xff); |
---|
422 | 417 | } |
---|
423 | 418 | |
---|
424 | | -static struct uvc_control_mapping uvc_ctrl_mappings[] = { |
---|
| 419 | +static const struct uvc_control_mapping uvc_ctrl_mappings[] = { |
---|
425 | 420 | { |
---|
426 | 421 | .id = V4L2_CID_BRIGHTNESS, |
---|
427 | 422 | .name = "Brightness", |
---|
.. | .. |
---|
982 | 977 | s32 value = mapping->get(mapping, UVC_GET_CUR, data); |
---|
983 | 978 | |
---|
984 | 979 | if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { |
---|
985 | | - struct uvc_menu_info *menu = mapping->menu_info; |
---|
| 980 | + const struct uvc_menu_info *menu = mapping->menu_info; |
---|
986 | 981 | unsigned int i; |
---|
987 | 982 | |
---|
988 | 983 | for (i = 0; i < mapping->menu_count; ++i, ++menu) { |
---|
.. | .. |
---|
1029 | 1024 | { |
---|
1030 | 1025 | struct uvc_control_mapping *master_map = NULL; |
---|
1031 | 1026 | struct uvc_control *master_ctrl = NULL; |
---|
1032 | | - struct uvc_menu_info *menu; |
---|
| 1027 | + const struct uvc_menu_info *menu; |
---|
1033 | 1028 | unsigned int i; |
---|
1034 | 1029 | |
---|
1035 | 1030 | memset(v4l2_ctrl, 0, sizeof(*v4l2_ctrl)); |
---|
1036 | 1031 | v4l2_ctrl->id = mapping->id; |
---|
1037 | 1032 | v4l2_ctrl->type = mapping->v4l2_type; |
---|
1038 | | - strlcpy(v4l2_ctrl->name, mapping->name, sizeof(v4l2_ctrl->name)); |
---|
| 1033 | + strscpy(v4l2_ctrl->name, mapping->name, sizeof(v4l2_ctrl->name)); |
---|
1039 | 1034 | v4l2_ctrl->flags = 0; |
---|
1040 | 1035 | |
---|
1041 | 1036 | if (!(ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR)) |
---|
.. | .. |
---|
1149 | 1144 | int uvc_query_v4l2_menu(struct uvc_video_chain *chain, |
---|
1150 | 1145 | struct v4l2_querymenu *query_menu) |
---|
1151 | 1146 | { |
---|
1152 | | - struct uvc_menu_info *menu_info; |
---|
| 1147 | + const struct uvc_menu_info *menu_info; |
---|
1153 | 1148 | struct uvc_control_mapping *mapping; |
---|
1154 | 1149 | struct uvc_control *ctrl; |
---|
1155 | 1150 | u32 index = query_menu->index; |
---|
.. | .. |
---|
1195 | 1190 | } |
---|
1196 | 1191 | } |
---|
1197 | 1192 | |
---|
1198 | | - strlcpy(query_menu->name, menu_info->name, sizeof(query_menu->name)); |
---|
| 1193 | + strscpy(query_menu->name, menu_info->name, sizeof(query_menu->name)); |
---|
1199 | 1194 | |
---|
1200 | 1195 | done: |
---|
1201 | 1196 | mutex_unlock(&chain->ctrl_mutex); |
---|
.. | .. |
---|
2025 | 2020 | static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, |
---|
2026 | 2021 | const struct uvc_control_info *info) |
---|
2027 | 2022 | { |
---|
2028 | | - int ret = 0; |
---|
2029 | | - |
---|
2030 | 2023 | ctrl->info = *info; |
---|
2031 | 2024 | INIT_LIST_HEAD(&ctrl->info.mappings); |
---|
2032 | 2025 | |
---|
2033 | 2026 | /* Allocate an array to save control values (cur, def, max, etc.) */ |
---|
2034 | 2027 | ctrl->uvc_data = kzalloc(ctrl->info.size * UVC_CTRL_DATA_LAST + 1, |
---|
2035 | 2028 | GFP_KERNEL); |
---|
2036 | | - if (ctrl->uvc_data == NULL) { |
---|
2037 | | - ret = -ENOMEM; |
---|
2038 | | - goto done; |
---|
2039 | | - } |
---|
| 2029 | + if (!ctrl->uvc_data) |
---|
| 2030 | + return -ENOMEM; |
---|
2040 | 2031 | |
---|
2041 | 2032 | ctrl->initialized = 1; |
---|
2042 | 2033 | |
---|
.. | .. |
---|
2044 | 2035 | "entity %u\n", ctrl->info.entity, ctrl->info.selector, |
---|
2045 | 2036 | dev->udev->devpath, ctrl->entity->id); |
---|
2046 | 2037 | |
---|
2047 | | -done: |
---|
2048 | | - if (ret < 0) |
---|
2049 | | - kfree(ctrl->uvc_data); |
---|
2050 | | - return ret; |
---|
| 2038 | + return 0; |
---|
2051 | 2039 | } |
---|
2052 | 2040 | |
---|
2053 | 2041 | /* |
---|