Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (11246): hdpvr: convert printing macros to v4l2_* with struct v4l2_device

it gives us a nice and unique prefix per device

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Janne Grunau and committed by
Mauro Carvalho Chehab
9ef77adf 06630aec

+75 -64
+11 -11
drivers/media/video/hdpvr/hdpvr-control.c
··· 40 40 dev->usbc_buf, 1, 10000); 41 41 42 42 mutex_unlock(&dev->usbc_mutex); 43 - dev_dbg(&dev->udev->dev, 44 - "config call request for value 0x%x returned %d\n", value, 45 - ret); 43 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 44 + "config call request for value 0x%x returned %d\n", value, 45 + ret); 46 46 47 47 return ret < 0 ? ret : 0; 48 48 } ··· 57 57 58 58 vidinf = kzalloc(sizeof(struct hdpvr_video_info), GFP_KERNEL); 59 59 if (!vidinf) { 60 - dev_err(&dev->udev->dev, "out of memory"); 60 + v4l2_err(&dev->v4l2_dev, "out of memory\n"); 61 61 goto err; 62 62 } 63 63 ··· 78 78 if (hdpvr_debug & MSG_INFO) { 79 79 hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf, 80 80 sizeof(print_buf), 0); 81 - dev_dbg(&dev->udev->dev, "get video info returned: %d, %s\n", 82 - ret, print_buf); 81 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 82 + "get video info returned: %d, %s\n", ret, print_buf); 83 83 } 84 84 #endif 85 85 mutex_unlock(&dev->usbc_mutex); ··· 111 111 if (hdpvr_debug & MSG_INFO) { 112 112 hex_dump_to_buffer(dev->usbc_buf, 3, 16, 1, print_buf, 113 113 sizeof(print_buf), 0); 114 - dev_dbg(&dev->udev->dev, 115 - "get input lines info returned: %d, %s\n", ret, 116 - print_buf); 114 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 115 + "get input lines info returned: %d, %s\n", ret, 116 + print_buf); 117 117 } 118 118 #endif 119 119 lines = dev->usbc_buf[1] << 8 | dev->usbc_buf[0]; ··· 155 155 dev->usbc_buf[1] = 1; 156 156 else { 157 157 mutex_unlock(&dev->usbc_mutex); 158 - dev_err(&dev->udev->dev, "invalid audio codec %d\n", 159 - codec); 158 + v4l2_err(&dev->v4l2_dev, "invalid audio codec %d\n", 159 + codec); 160 160 ret = -EINVAL; 161 161 goto error; 162 162 }
+31 -25
drivers/media/video/hdpvr/hdpvr-core.c
··· 125 125 size_t buf_size = 46; 126 126 char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL); 127 127 if (!print_buf) { 128 - dev_err(&dev->udev->dev, "Out of memory"); 128 + v4l2_err(&dev->v4l2_dev, "Out of memory\n"); 129 129 goto error; 130 130 } 131 131 #endif ··· 138 138 dev->usbc_buf, 46, 139 139 10000); 140 140 if (ret != 46) { 141 - dev_err(&dev->udev->dev, 142 - "unexpected answer of status request, len %d", ret); 141 + v4l2_err(&dev->v4l2_dev, 142 + "unexpected answer of status request, len %d\n", ret); 143 143 goto error; 144 144 } 145 145 #ifdef HDPVR_DEBUG 146 146 else { 147 147 hex_dump_to_buffer(dev->usbc_buf, 46, 16, 1, print_buf, 148 148 sizeof(print_buf), 0); 149 - dev_dbg(&dev->udev->dev, 150 - "Status request returned, len %d: %s\n", 151 - ret, print_buf); 149 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 150 + "Status request returned, len %d: %s\n", 151 + ret, print_buf); 152 152 } 153 153 #endif 154 154 if (dev->usbc_buf[1] == HDPVR_FIRMWARE_VERSION) { ··· 156 156 } else if (dev->usbc_buf[1] == HDPVR_FIRMWARE_VERSION_AC3) { 157 157 dev->flags |= HDPVR_FLAG_AC3_CAP; 158 158 } else if (dev->usbc_buf[1] > HDPVR_FIRMWARE_VERSION_AC3) { 159 - dev_notice(&dev->udev->dev, "untested firmware version 0x%x, " 160 - "the driver might not work\n", dev->usbc_buf[1]); 159 + v4l2_info(&dev->v4l2_dev, "untested firmware version 0x%x, " 160 + "the driver might not work\n", dev->usbc_buf[1]); 161 161 dev->flags |= HDPVR_FLAG_AC3_CAP; 162 162 } else { 163 - dev_err(&dev->udev->dev, "unknown firmware version 0x%x\n", 163 + v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n", 164 164 dev->usbc_buf[1]); 165 165 ret = -EINVAL; 166 166 goto error; ··· 169 169 response = dev->usbc_buf+38; 170 170 #ifdef HDPVR_DEBUG 171 171 hex_dump_to_buffer(response, 8, 16, 1, print_buf, sizeof(print_buf), 0); 172 - dev_dbg(&dev->udev->dev, "challenge: %s\n", print_buf); 172 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "challenge: %s\n", 173 + print_buf); 173 174 #endif 174 175 challenge(response); 175 176 #ifdef HDPVR_DEBUG 176 177 hex_dump_to_buffer(response, 8, 16, 1, print_buf, sizeof(print_buf), 0); 177 - dev_dbg(&dev->udev->dev, " response: %s\n", print_buf); 178 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, " response: %s\n", 179 + print_buf); 178 180 #endif 179 181 180 182 msleep(100); ··· 186 184 0x0000, 0x0000, 187 185 response, 8, 188 186 10000); 189 - dev_dbg(&dev->udev->dev, "magic request returned %d\n", ret); 187 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 188 + "magic request returned %d\n", ret); 190 189 mutex_unlock(&dev->usbc_mutex); 191 190 192 191 retval = ret != 8; ··· 217 214 CTRL_LOW_PASS_FILTER_VALUE, CTRL_DEFAULT_INDEX, 218 215 buf, 4, 219 216 1000); 220 - dev_dbg(&dev->udev->dev, "control request returned %d\n", ret); 217 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 218 + "control request returned %d\n", ret); 221 219 mutex_unlock(&dev->usbc_mutex); 222 220 223 221 vidinf = get_video_info(dev); 224 222 if (!vidinf) 225 - dev_dbg(&dev->udev->dev, 223 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 226 224 "no valid video signal or device init failed\n"); 227 225 else 228 226 kfree(vidinf); ··· 235 231 usb_sndctrlpipe(dev->udev, 0), 236 232 0xd4, 0x38, 0, 0, buf, 1, 237 233 1000); 238 - dev_dbg(&dev->udev->dev, "control request returned %d\n", ret); 234 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 235 + "control request returned %d\n", ret); 239 236 240 237 /* boost analog audio */ 241 238 buf[0] = boost_audio; ··· 244 239 usb_sndctrlpipe(dev->udev, 0), 245 240 0xd5, 0x38, 0, 0, buf, 1, 246 241 1000); 247 - dev_dbg(&dev->udev->dev, "control request returned %d\n", ret); 242 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 243 + "control request returned %d\n", ret); 248 244 mutex_unlock(&dev->usbc_mutex); 249 245 250 246 dev->status = STATUS_IDLE; ··· 296 290 mutex_init(&dev->usbc_mutex); 297 291 dev->usbc_buf = kmalloc(64, GFP_KERNEL); 298 292 if (!dev->usbc_buf) { 299 - dev_err(&dev->udev->dev, "Out of memory"); 293 + v4l2_err(&dev->v4l2_dev, "Out of memory\n"); 300 294 goto error; 301 295 } 302 296 ··· 338 332 339 333 } 340 334 if (!dev->bulk_in_endpointAddr) { 341 - err("Could not find bulk-in endpoint"); 335 + v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); 342 336 goto error; 343 337 } 344 338 345 339 /* init the device */ 346 340 if (hdpvr_device_init(dev)) { 347 - err("device init failed"); 341 + v4l2_err(&dev->v4l2_dev, "device init failed\n"); 348 342 goto error; 349 343 } 350 344 351 345 mutex_lock(&dev->io_mutex); 352 346 if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) { 353 - err("allocating transfer buffers failed"); 347 + v4l2_err(&dev->v4l2_dev, 348 + "allocating transfer buffers failed\n"); 354 349 goto error; 355 350 } 356 351 mutex_unlock(&dev->io_mutex); 357 352 358 353 if (hdpvr_register_videodev(dev, &interface->dev, 359 354 video_nr[atomic_inc_return(&dev_nr)])) { 360 - err("registering videodev failed"); 355 + v4l2_err(&dev->v4l2_dev, "registering videodev failed\n"); 361 356 goto error; 362 357 } 363 358 ··· 366 359 /* until i2c is working properly */ 367 360 retval = 0; /* hdpvr_register_i2c_adapter(dev); */ 368 361 if (retval < 0) { 369 - err("registering i2c adapter failed"); 362 + v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n"); 370 363 goto error; 371 364 } 372 365 #endif /* CONFIG_I2C */ ··· 375 368 usb_set_intfdata(interface, dev); 376 369 377 370 /* let the user know what node this device is now attached to */ 378 - v4l2_info(dev->video_dev, "device now attached to /dev/video%d\n", 371 + v4l2_info(&dev->v4l2_dev, "device now attached to /dev/video%d\n", 379 372 dev->video_dev->minor); 380 373 return 0; 381 374 ··· 425 418 426 419 atomic_dec(&dev_nr); 427 420 428 - printk(KERN_INFO "Hauppauge HD PVR: device /dev/video%d disconnected\n", 429 - minor); 421 + v4l2_info(&dev->v4l2_dev, "device /dev/video%d disconnected\n", minor); 430 422 431 423 v4l2_device_unregister(&dev->v4l2_dev); 432 424 kfree(dev->usbc_buf);
+33 -28
drivers/media/video/hdpvr/hdpvr-video.c
··· 28 28 29 29 #define BULK_URB_TIMEOUT 1250 /* 1.25 seconds */ 30 30 31 - #define print_buffer_status() v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev,\ 32 - "%s:%d buffer stat: %d free, %d proc\n",\ 33 - __func__, __LINE__, \ 34 - list_size(&dev->free_buff_list), \ 35 - list_size(&dev->rec_buff_list)) 31 + #define print_buffer_status() { \ 32 + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, \ 33 + "%s:%d buffer stat: %d free, %d proc\n", \ 34 + __func__, __LINE__, \ 35 + list_size(&dev->free_buff_list), \ 36 + list_size(&dev->rec_buff_list)); } 36 37 37 38 struct hdpvr_fh { 38 39 struct hdpvr_device *dev; ··· 124 123 struct hdpvr_buffer *buf; 125 124 struct urb *urb; 126 125 127 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 126 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 128 127 "allocating %u buffers\n", count); 129 128 130 129 for (i = 0; i < count; i++) { 131 130 132 131 buf = kzalloc(sizeof(struct hdpvr_buffer), GFP_KERNEL); 133 132 if (!buf) { 134 - err("cannot allocate buffer"); 133 + v4l2_err(&dev->v4l2_dev, "cannot allocate buffer\n"); 135 134 goto exit; 136 135 } 137 136 buf->dev = dev; 138 137 139 138 urb = usb_alloc_urb(0, GFP_KERNEL); 140 139 if (!urb) { 141 - err("cannot allocate urb"); 140 + v4l2_err(&dev->v4l2_dev, "cannot allocate urb\n"); 142 141 goto exit; 143 142 } 144 143 buf->urb = urb; ··· 146 145 mem = usb_buffer_alloc(dev->udev, dev->bulk_in_size, GFP_KERNEL, 147 146 &urb->transfer_dma); 148 147 if (!mem) { 149 - err("cannot allocate usb transfer buffer"); 148 + v4l2_err(&dev->v4l2_dev, 149 + "cannot allocate usb transfer buffer\n"); 150 150 goto exit; 151 151 } 152 152 ··· 180 178 buf = list_entry(dev->free_buff_list.next, struct hdpvr_buffer, 181 179 buff_list); 182 180 if (buf->status != BUFSTAT_AVAILABLE) { 183 - err("buffer not marked as availbale"); 181 + v4l2_err(&dev->v4l2_dev, 182 + "buffer not marked as availbale\n"); 184 183 ret = -EFAULT; 185 184 goto err; 186 185 } ··· 191 188 urb->actual_length = 0; 192 189 ret = usb_submit_urb(urb, GFP_KERNEL); 193 190 if (ret) { 194 - err("usb_submit_urb in %s returned %d", __func__, ret); 191 + v4l2_err(&dev->v4l2_dev, 192 + "usb_submit_urb in %s returned %d\n", 193 + __func__, ret); 195 194 if (++err_count > 2) 196 195 break; 197 196 continue; ··· 233 228 while (dev->status == STATUS_STREAMING) { 234 229 235 230 if (hdpvr_submit_buffers(dev)) { 236 - v4l2_err(dev->video_dev, "couldn't submit buffers\n"); 231 + v4l2_err(&dev->v4l2_dev, "couldn't submit buffers\n"); 237 232 goto error; 238 233 } 239 234 if (wait_event_interruptible(dev->wait_buffer, ··· 242 237 goto error; 243 238 } 244 239 245 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 240 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 246 241 "transmit worker exited\n"); 247 242 return; 248 243 error: 249 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 244 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 250 245 "transmit buffers errored\n"); 251 246 dev->status = STATUS_ERROR; 252 247 } ··· 265 260 vidinf = get_video_info(dev); 266 261 267 262 if (vidinf) { 268 - v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 263 + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 269 264 "video signal: %dx%d@%dhz\n", vidinf->width, 270 265 vidinf->height, vidinf->fps); 271 266 kfree(vidinf); ··· 274 269 ret = usb_control_msg(dev->udev, 275 270 usb_sndctrlpipe(dev->udev, 0), 276 271 0xb8, 0x38, 0x1, 0, NULL, 0, 8000); 277 - v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 272 + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 278 273 "encoder start control request returned %d\n", ret); 279 274 280 275 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); ··· 282 277 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); 283 278 queue_work(dev->workqueue, &dev->worker); 284 279 285 - v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 280 + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 286 281 "streaming started\n"); 287 282 dev->status = STATUS_STREAMING; 288 283 289 284 return 0; 290 285 } 291 286 msleep(250); 292 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 287 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 293 288 "no video signal at input %d\n", dev->options.video_input); 294 289 return -EAGAIN; 295 290 } ··· 335 330 336 331 dev = (struct hdpvr_device *)video_get_drvdata(video_devdata(file)); 337 332 if (!dev) { 338 - err("open failing with with ENODEV"); 333 + v4l2_err(&dev->v4l2_dev, "open failing with with ENODEV\n"); 339 334 retval = -ENODEV; 340 335 goto err; 341 336 } 342 337 343 338 fh = kzalloc(sizeof(struct hdpvr_fh), GFP_KERNEL); 344 339 if (!fh) { 345 - err("Out of memory?"); 340 + v4l2_err(&dev->v4l2_dev, "Out of memory\n"); 346 341 goto err; 347 342 } 348 343 /* lock the device to allow correctly handling errors ··· 401 396 mutex_lock(&dev->io_mutex); 402 397 if (dev->status == STATUS_IDLE) { 403 398 if (hdpvr_start_streaming(dev)) { 404 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 405 - "start_streaming failed"); 399 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 400 + "start_streaming failed\n"); 406 401 ret = -EIO; 407 402 msleep(200); 408 403 dev->status = STATUS_IDLE; ··· 450 445 451 446 if (copy_to_user(buffer, urb->transfer_buffer + buf->pos, 452 447 cnt)) { 453 - err("read: copy_to_user failed"); 448 + v4l2_err(&dev->v4l2_dev, "read: copy_to_user failed\n"); 454 449 if (!ret) 455 450 ret = -EFAULT; 456 451 goto err; ··· 498 493 499 494 if (dev->status == STATUS_IDLE) { 500 495 if (hdpvr_start_streaming(dev)) { 501 - v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 502 - "start_streaming failed"); 496 + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 497 + "start_streaming failed\n"); 503 498 dev->status = STATUS_IDLE; 504 499 } 505 500 ··· 1135 1130 res = hdpvr_stop_streaming(dev); 1136 1131 break; 1137 1132 default: 1138 - v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 1133 + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 1139 1134 "Unsupported encoder cmd %d\n", a->cmd); 1140 1135 res = -EINVAL; 1141 1136 } ··· 1202 1197 /* setup and register video device */ 1203 1198 dev->video_dev = video_device_alloc(); 1204 1199 if (!dev->video_dev) { 1205 - err("video_device_alloc() failed"); 1200 + v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n"); 1206 1201 goto error; 1207 1202 } 1208 1203 ··· 1212 1207 video_set_drvdata(dev->video_dev, dev); 1213 1208 1214 1209 if (video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum)) { 1215 - err("V4L2 device registration failed"); 1210 + v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); 1216 1211 goto error; 1217 1212 } 1218 1213