Pull media fix from Mauro Carvalho Chehab: "A revert for a regression in the uvcvideo driver" * tag 'media/v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: Revert "media: uvcvideo: Require entities to have a non-zero unique ID"
Unified · Split
| @@ -790,27 +790,14 @@ static const u8 uvc_media_transport_input_guid[16] = · 789 unmodified lines | ||
| 790 | 790 | UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; |
| 791 | 791 | static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; |
| 792 | 792 | |
| 793 | −static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev, u16 type, | |
| 794 | − u16 id, unsigned int num_pads, | |
| 795 | − unsigned int extra_size) | |
| 793 | +static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, | |
| 794 | + unsigned int num_pads, unsigned int extra_size) | |
| 796 | 795 | { |
| 797 | 796 | struct uvc_entity *entity; |
| 798 | 797 | unsigned int num_inputs; |
| 799 | 798 | unsigned int size; |
| 800 | 799 | unsigned int i; |
| 801 | 800 | |
| 802 | − /* Per UVC 1.1+ spec 3.7.2, the ID should be non-zero. */ | |
| 803 | − if (id == 0) { | |
| 804 | − dev_err(&dev->udev->dev, "Found Unit with invalid ID 0.\n"); | |
| 805 | − return ERR_PTR(-EINVAL); | |
| 806 | − } | |
| 807 | − | |
| 808 | − /* Per UVC 1.1+ spec 3.7.2, the ID is unique. */ | |
| 809 | − if (uvc_entity_by_id(dev, id)) { | |
| 810 | − dev_err(&dev->udev->dev, "Found multiple Units with ID %u\n", id); | |
| 811 | − return ERR_PTR(-EINVAL); | |
| 812 | − } | |
| 813 | − | |
| 814 | 801 | extra_size = roundup(extra_size, sizeof(*entity->pads)); |
| 815 | 802 | if (num_pads) |
| 816 | 803 | num_inputs = type & UVC_TERM_OUTPUT ? num_pads : num_pads - 1; |
| @@ -820,7 +807,7 @@ static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev, u16 type, · 3 unmodified lines | ||
| 820 | 807 | + num_inputs; |
| 821 | 808 | entity = kzalloc(size, GFP_KERNEL); |
| 822 | 809 | if (entity == NULL) |
| 823 | − return ERR_PTR(-ENOMEM); | |
| 810 | + return NULL; | |
| 824 | 811 | |
| 825 | 812 | entity->id = id; |
| 826 | 813 | entity->type = type; |
| @@ -932,10 +919,10 @@ static int uvc_parse_vendor_control(struct uvc_device *dev, · 105 unmodified lines | ||
| 932 | 919 | break; |
| 933 | 920 | } |
| 934 | 921 | |
| 935 | − unit = uvc_alloc_new_entity(dev, UVC_VC_EXTENSION_UNIT, | |
| 936 | − buffer[3], p + 1, 2 * n); | |
| 937 | − if (IS_ERR(unit)) | |
| 938 | − return PTR_ERR(unit); | |
| 922 | + unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3], | |
| 923 | + p + 1, 2*n); | |
| 924 | + if (unit == NULL) | |
| 925 | + return -ENOMEM; | |
| 939 | 926 | |
| 940 | 927 | memcpy(unit->guid, &buffer[4], 16); |
| 941 | 928 | unit->extension.bNumControls = buffer[20]; |
| @@ -1044,10 +1031,10 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 102 unmodified lines | ||
| 1044 | 1031 | return -EINVAL; |
| 1045 | 1032 | } |
| 1046 | 1033 | |
| 1047 | − term = uvc_alloc_new_entity(dev, type | UVC_TERM_INPUT, | |
| 1048 | − buffer[3], 1, n + p); | |
| 1049 | − if (IS_ERR(term)) | |
| 1050 | − return PTR_ERR(term); | |
| 1034 | + term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3], | |
| 1035 | + 1, n + p); | |
| 1036 | + if (term == NULL) | |
| 1037 | + return -ENOMEM; | |
| 1051 | 1038 | |
| 1052 | 1039 | if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) { |
| 1053 | 1040 | term->camera.bControlSize = n; |
| @@ -1103,10 +1090,10 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 49 unmodified lines | ||
| 1103 | 1090 | return 0; |
| 1104 | 1091 | } |
| 1105 | 1092 | |
| 1106 | − term = uvc_alloc_new_entity(dev, type | UVC_TERM_OUTPUT, | |
| 1107 | − buffer[3], 1, 0); | |
| 1108 | − if (IS_ERR(term)) | |
| 1109 | − return PTR_ERR(term); | |
| 1093 | + term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3], | |
| 1094 | + 1, 0); | |
| 1095 | + if (term == NULL) | |
| 1096 | + return -ENOMEM; | |
| 1110 | 1097 | |
| 1111 | 1098 | memcpy(term->baSourceID, &buffer[7], 1); |
| 1112 | 1099 | |
| @@ -1125,10 +1112,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 12 unmodified lines | ||
| 1125 | 1112 | return -EINVAL; |
| 1126 | 1113 | } |
| 1127 | 1114 | |
| 1128 | − unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], | |
| 1129 | − p + 1, 0); | |
| 1130 | − if (IS_ERR(unit)) | |
| 1131 | − return PTR_ERR(unit); | |
| 1115 | + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0); | |
| 1116 | + if (unit == NULL) | |
| 1117 | + return -ENOMEM; | |
| 1132 | 1118 | |
| 1133 | 1119 | memcpy(unit->baSourceID, &buffer[5], p); |
| 1134 | 1120 | |
| @@ -1148,9 +1134,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 13 unmodified lines | ||
| 1148 | 1134 | return -EINVAL; |
| 1149 | 1135 | } |
| 1150 | 1136 | |
| 1151 | − unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 2, n); | |
| 1152 | − if (IS_ERR(unit)) | |
| 1153 | − return PTR_ERR(unit); | |
| 1137 | + unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n); | |
| 1138 | + if (unit == NULL) | |
| 1139 | + return -ENOMEM; | |
| 1154 | 1140 | |
| 1155 | 1141 | memcpy(unit->baSourceID, &buffer[4], 1); |
| 1156 | 1142 | unit->processing.wMaxMultiplier = |
| @@ -1177,10 +1163,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev, · 20 unmodified lines | ||
| 1177 | 1163 | return -EINVAL; |
| 1178 | 1164 | } |
| 1179 | 1165 | |
| 1180 | − unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], | |
| 1181 | − p + 1, n); | |
| 1182 | − if (IS_ERR(unit)) | |
| 1183 | − return PTR_ERR(unit); | |
| 1166 | + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n); | |
| 1167 | + if (unit == NULL) | |
| 1168 | + return -ENOMEM; | |
| 1184 | 1169 | |
| 1185 | 1170 | memcpy(unit->guid, &buffer[4], 16); |
| 1186 | 1171 | unit->extension.bNumControls = buffer[20]; |
| @@ -1320,10 +1305,9 @@ static int uvc_gpio_parse(struct uvc_device *dev) · 133 unmodified lines | ||
| 1320 | 1305 | return dev_err_probe(&dev->intf->dev, irq, |
| 1321 | 1306 | "No IRQ for privacy GPIO\n"); |
| 1322 | 1307 | |
| 1323 | − unit = uvc_alloc_new_entity(dev, UVC_EXT_GPIO_UNIT, | |
| 1324 | − UVC_EXT_GPIO_UNIT_ID, 0, 1); | |
| 1325 | − if (IS_ERR(unit)) | |
| 1326 | − return PTR_ERR(unit); | |
| 1308 | + unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); | |
| 1309 | + if (!unit) | |
| 1310 | + return -ENOMEM; | |
| 1327 | 1311 | |
| 1328 | 1312 | unit->gpio.gpio_privacy = gpio_privacy; |
| 1329 | 1313 | unit->gpio.irq = irq; |