Merge tag 'media/v6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

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"

+27 -43
+27 -43
drivers/media/usb/uvc/uvc_driver.c
··· 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 - 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 800 814 801 extra_size = roundup(extra_size, sizeof(*entity->pads)); 815 802 if (num_pads) ··· 807 820 + num_inputs; 808 821 entity = kzalloc(size, GFP_KERNEL); 809 822 if (entity == NULL) 810 - return ERR_PTR(-ENOMEM); 823 + return NULL; 811 824 812 825 entity->id = id; 813 826 entity->type = type; ··· 919 932 break; 920 933 } 921 934 922 - unit = uvc_alloc_new_entity(dev, UVC_VC_EXTENSION_UNIT, 923 - buffer[3], p + 1, 2 * n); 924 - if (IS_ERR(unit)) 925 - return PTR_ERR(unit); 935 + unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3], 936 + p + 1, 2*n); 937 + if (unit == NULL) 938 + return -ENOMEM; 926 939 927 940 memcpy(unit->guid, &buffer[4], 16); 928 941 unit->extension.bNumControls = buffer[20]; ··· 1031 1044 return -EINVAL; 1032 1045 } 1033 1046 1034 - term = uvc_alloc_new_entity(dev, type | UVC_TERM_INPUT, 1035 - buffer[3], 1, n + p); 1036 - if (IS_ERR(term)) 1037 - return PTR_ERR(term); 1047 + term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3], 1048 + 1, n + p); 1049 + if (term == NULL) 1050 + return -ENOMEM; 1038 1051 1039 1052 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) { 1040 1053 term->camera.bControlSize = n; ··· 1090 1103 return 0; 1091 1104 } 1092 1105 1093 - term = uvc_alloc_new_entity(dev, type | UVC_TERM_OUTPUT, 1094 - buffer[3], 1, 0); 1095 - if (IS_ERR(term)) 1096 - return PTR_ERR(term); 1106 + term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3], 1107 + 1, 0); 1108 + if (term == NULL) 1109 + return -ENOMEM; 1097 1110 1098 1111 memcpy(term->baSourceID, &buffer[7], 1); 1099 1112 ··· 1112 1125 return -EINVAL; 1113 1126 } 1114 1127 1115 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 1116 - p + 1, 0); 1117 - if (IS_ERR(unit)) 1118 - return PTR_ERR(unit); 1128 + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0); 1129 + if (unit == NULL) 1130 + return -ENOMEM; 1119 1131 1120 1132 memcpy(unit->baSourceID, &buffer[5], p); 1121 1133 ··· 1134 1148 return -EINVAL; 1135 1149 } 1136 1150 1137 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 2, n); 1138 - if (IS_ERR(unit)) 1139 - return PTR_ERR(unit); 1151 + unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n); 1152 + if (unit == NULL) 1153 + return -ENOMEM; 1140 1154 1141 1155 memcpy(unit->baSourceID, &buffer[4], 1); 1142 1156 unit->processing.wMaxMultiplier = ··· 1163 1177 return -EINVAL; 1164 1178 } 1165 1179 1166 - unit = uvc_alloc_new_entity(dev, buffer[2], buffer[3], 1167 - p + 1, n); 1168 - if (IS_ERR(unit)) 1169 - return PTR_ERR(unit); 1180 + unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n); 1181 + if (unit == NULL) 1182 + return -ENOMEM; 1170 1183 1171 1184 memcpy(unit->guid, &buffer[4], 16); 1172 1185 unit->extension.bNumControls = buffer[20]; ··· 1305 1320 return dev_err_probe(&dev->intf->dev, irq, 1306 1321 "No IRQ for privacy GPIO\n"); 1307 1322 1308 - unit = uvc_alloc_new_entity(dev, UVC_EXT_GPIO_UNIT, 1309 - UVC_EXT_GPIO_UNIT_ID, 0, 1); 1310 - if (IS_ERR(unit)) 1311 - return PTR_ERR(unit); 1323 + unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); 1324 + if (!unit) 1325 + return -ENOMEM; 1312 1326 1313 1327 unit->gpio.gpio_privacy = gpio_privacy; 1314 1328 unit->gpio.irq = irq;