From b22da3d8526a935aa31e086e63f60ff3246cb61c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Sat, 09 Dec 2023 07:24:11 +0000 Subject: [PATCH] add stmac read mac form eeprom --- kernel/drivers/media/usb/uvc/uvc_ctrl.c | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-) diff --git a/kernel/drivers/media/usb/uvc/uvc_ctrl.c b/kernel/drivers/media/usb/uvc/uvc_ctrl.c index cb60464..f479d89 100644 --- a/kernel/drivers/media/usb/uvc/uvc_ctrl.c +++ b/kernel/drivers/media/usb/uvc/uvc_ctrl.c @@ -1,14 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * uvc_ctrl.c -- USB Video Class driver - Controls * * Copyright (C) 2005-2010 * Laurent Pinchart (laurent.pinchart@ideasonboard.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * */ #include <linux/kernel.h> @@ -38,7 +33,7 @@ * Controls */ -static struct uvc_control_info uvc_ctrls[] = { +static const struct uvc_control_info uvc_ctrls[] = { { .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_BRIGHTNESS_CONTROL, @@ -354,13 +349,13 @@ }, }; -static struct uvc_menu_info power_line_frequency_controls[] = { +static const struct uvc_menu_info power_line_frequency_controls[] = { { 0, "Disabled" }, { 1, "50 Hz" }, { 2, "60 Hz" }, }; -static struct uvc_menu_info exposure_auto_controls[] = { +static const struct uvc_menu_info exposure_auto_controls[] = { { 2, "Auto Mode" }, { 1, "Manual Mode" }, { 4, "Shutter Priority Mode" }, @@ -421,7 +416,7 @@ data[first+1] = min_t(int, abs(value), 0xff); } -static struct uvc_control_mapping uvc_ctrl_mappings[] = { +static const struct uvc_control_mapping uvc_ctrl_mappings[] = { { .id = V4L2_CID_BRIGHTNESS, .name = "Brightness", @@ -982,7 +977,7 @@ s32 value = mapping->get(mapping, UVC_GET_CUR, data); if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { - struct uvc_menu_info *menu = mapping->menu_info; + const struct uvc_menu_info *menu = mapping->menu_info; unsigned int i; for (i = 0; i < mapping->menu_count; ++i, ++menu) { @@ -1029,13 +1024,13 @@ { struct uvc_control_mapping *master_map = NULL; struct uvc_control *master_ctrl = NULL; - struct uvc_menu_info *menu; + const struct uvc_menu_info *menu; unsigned int i; memset(v4l2_ctrl, 0, sizeof(*v4l2_ctrl)); v4l2_ctrl->id = mapping->id; v4l2_ctrl->type = mapping->v4l2_type; - strlcpy(v4l2_ctrl->name, mapping->name, sizeof(v4l2_ctrl->name)); + strscpy(v4l2_ctrl->name, mapping->name, sizeof(v4l2_ctrl->name)); v4l2_ctrl->flags = 0; if (!(ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR)) @@ -1149,7 +1144,7 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, struct v4l2_querymenu *query_menu) { - struct uvc_menu_info *menu_info; + const struct uvc_menu_info *menu_info; struct uvc_control_mapping *mapping; struct uvc_control *ctrl; u32 index = query_menu->index; @@ -1195,7 +1190,7 @@ } } - strlcpy(query_menu->name, menu_info->name, sizeof(query_menu->name)); + strscpy(query_menu->name, menu_info->name, sizeof(query_menu->name)); done: mutex_unlock(&chain->ctrl_mutex); @@ -2025,18 +2020,14 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, const struct uvc_control_info *info) { - int ret = 0; - ctrl->info = *info; INIT_LIST_HEAD(&ctrl->info.mappings); /* Allocate an array to save control values (cur, def, max, etc.) */ ctrl->uvc_data = kzalloc(ctrl->info.size * UVC_CTRL_DATA_LAST + 1, GFP_KERNEL); - if (ctrl->uvc_data == NULL) { - ret = -ENOMEM; - goto done; - } + if (!ctrl->uvc_data) + return -ENOMEM; ctrl->initialized = 1; @@ -2044,10 +2035,7 @@ "entity %u\n", ctrl->info.entity, ctrl->info.selector, dev->udev->devpath, ctrl->entity->id); -done: - if (ret < 0) - kfree(ctrl->uvc_data); - return ret; + return 0; } /* -- Gitblit v1.6.2