V4L/DVB (9521): V4L: struct device - replace bus_id with dev_name(), dev_set_name()
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 30 Oct 2008 03:51:46 +0000 (00:51 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 29 Dec 2008 19:53:26 +0000 (17:53 -0200)
This patch is part of a larger patch series which will remove
the "char bus_id[20]" name string from struct device. The device
name is managed in the kobject anyway, and without any size
limitation, and just needlessly copied into "struct device".

To set and read the device name dev_name(dev) and dev_set_name(dev)
must be used. If your code uses static kobjects, which it shouldn't
do, "const char *init_name" can be used to statically provide the
name the registered device should have. At registration time, the
init_name field is cleared, to enforce the use of dev_name(dev) to
access the device name at a later time.

We need to get rid of all occurrences of bus_id in the entire tree
to be able to enable the new interface. Please apply this patch,
and possibly convert any remaining remaining occurrences of bus_id.

We want to submit a patch to -next, which will remove bus_id from
"struct device", to find the remaining pieces to convert, and finally
switch over to the new api, which will remove the 20 bytes array
and does no longer have a size limitation.

Thanks,
Kay

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
14 files changed:
drivers/media/video/bt8xx/bttv-gpio.c
drivers/media/video/bt8xx/bttv.h
drivers/media/video/em28xx/em28xx-video.c
drivers/media/video/et61x251/et61x251_core.c
drivers/media/video/ir-kbd-i2c.c
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/sh_mobile_ceu_camera.c
drivers/media/video/sn9c102/sn9c102_core.c
drivers/media/video/soc_camera.c
drivers/media/video/usbvision/usbvision-video.c
drivers/media/video/v4l2-dev.c
drivers/media/video/zc0301/zc0301_core.c
include/media/soc_camera.h

index dce6dae5740efa55586cd9bf88e24a675e0cd41e..74c325e594a2eaf3509b139ef6b46a7a2f4d242a 100644 (file)
@@ -42,7 +42,7 @@ static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv)
        struct bttv_sub_driver *sub = to_bttv_sub_drv(drv);
        int len = strlen(sub->wanted);
 
-       if (0 == strncmp(dev->bus_id, sub->wanted, len))
+       if (0 == strncmp(dev_name(dev), sub->wanted, len))
                return 1;
        return 0;
 }
@@ -91,15 +91,14 @@ int bttv_sub_add_device(struct bttv_core *core, char *name)
        sub->dev.parent  = &core->pci->dev;
        sub->dev.bus     = &bttv_sub_bus_type;
        sub->dev.release = release_sub_device;
-       snprintf(sub->dev.bus_id,sizeof(sub->dev.bus_id),"%s%d",
-                name, core->nr);
+       dev_set_name(&sub->dev, "%s%d", name, core->nr);
 
        err = device_register(&sub->dev);
        if (0 != err) {
                kfree(sub);
                return err;
        }
-       printk("bttv%d: add subdevice \"%s\"\n", core->nr, sub->dev.bus_id);
+       printk("bttv%d: add subdevice \"%s\"\n", core->nr, dev_name(&sub->dev));
        list_add_tail(&sub->list,&core->subs);
        return 0;
 }
index 46cb90e0985b2ad7bbe8193da8291d16eaf6a38b..bc2c88499ab96c6b0c647c899b4358ddad130d24 100644 (file)
@@ -308,7 +308,7 @@ struct bttv_sub_device {
 
 struct bttv_sub_driver {
        struct device_driver   drv;
-       char                   wanted[BUS_ID_SIZE];
+       char                   wanted[20];
        int                    (*probe)(struct bttv_sub_device *sub);
        void                   (*remove)(struct bttv_sub_device *sub);
 };
index 4ea1f1e048979e51859652d93e24846a7f39fd3e..415dff830f88b2eccbc38c9b16bb83192b224ac5 100644 (file)
@@ -1271,7 +1271,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
        strlcpy(cap->driver, "em28xx", sizeof(cap->driver));
        strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card));
-       strlcpy(cap->bus_info, dev->udev->dev.bus_id, sizeof(cap->bus_info));
+       strlcpy(cap->bus_info, dev_name(&dev->udev->dev), sizeof(cap->bus_info));
 
        cap->version = EM28XX_VERSION_CODE;
 
@@ -1424,7 +1424,7 @@ static int radio_querycap(struct file *file, void  *priv,
 
        strlcpy(cap->driver, "em28xx", sizeof(cap->driver));
        strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card));
-       strlcpy(cap->bus_info, dev->udev->dev.bus_id, sizeof(cap->bus_info));
+       strlcpy(cap->bus_info, dev_name(&dev->udev->dev), sizeof(cap->bus_info));
 
        cap->version = EM28XX_VERSION_CODE;
        cap->capabilities = V4L2_CAP_TUNER;
index 9d0ef96c23ff47c6147059ee9b3a2b28b5986067..83c07112c59d64c4fb6832b01a5d1cedc174c07c 100644 (file)
@@ -1581,7 +1581,7 @@ et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg)
 
        strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
        if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
-               strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
+               strlcpy(cap.bus_info, dev_name(&cam->usbdev->dev),
                        sizeof(cap.bus_info));
 
        if (copy_to_user(arg, &cap, sizeof(cap)))
index efe849981ab7c3766bb61efe78e437ebc1bb6ff1..d4658c56eddc53974a7e96e59833f25a6af00e45 100644 (file)
@@ -385,10 +385,10 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
                goto err_out_detach;
        }
 
-       /* Phys addr can only be set after attaching (for ir->c.dev.bus_id) */
+       /* Phys addr can only be set after attaching (for ir->c.dev) */
        snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0",
-                ir->c.adapter->dev.bus_id,
-                ir->c.dev.bus_id);
+                dev_name(&ir->c.adapter->dev),
+                dev_name(&ir->c.dev));
 
        /* init + register input device */
        ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
index 5b81ba469641c89b302a777d9f41f62043609133..4358079f1966f4efa4a60eaded89e9c75e1866fd 100644 (file)
@@ -2395,7 +2395,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 
        scnprintf(hdw->bus_info,sizeof(hdw->bus_info),
                  "usb %s address %d",
-                 hdw->usb_dev->dev.bus_id,
+                 dev_name(&hdw->usb_dev->dev),
                  hdw->usb_dev->devnum);
 
        ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber;
index 733680f2131714a7f1642cf0f36655f28695b024..e641cd971453c2b6cb622ae1ff2c36d38cd7f831 100644 (file)
@@ -628,10 +628,10 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
 
        class_dev->class = &class_ptr->class;
        if (pvr2_hdw_get_sn(sfp->channel.hdw)) {
-               snprintf(class_dev->bus_id, BUS_ID_SIZE, "sn-%lu",
+               dev_set_name(class_dev, "sn-%lu",
                         pvr2_hdw_get_sn(sfp->channel.hdw));
        } else if (pvr2_hdw_get_unit_number(sfp->channel.hdw) >= 0) {
-               snprintf(class_dev->bus_id, BUS_ID_SIZE, "unit-%c",
+               dev_set_name(class_dev, "unit-%c",
                         pvr2_hdw_get_unit_number(sfp->channel.hdw) + 'a');
        } else {
                kfree(class_dev);
index 536b1a9b310ca602aa256493e742290c915f5674..63bc0a6e68b0b8074dd24bc50587530a5a20e440 100644 (file)
@@ -616,7 +616,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
 
        /* request irq */
        err = request_irq(pcdev->irq, sh_mobile_ceu_irq, IRQF_DISABLED,
-                         pdev->dev.bus_id, pcdev);
+                         dev_name(&pdev->dev), pcdev);
        if (err) {
                dev_err(&pdev->dev, "Unable to register CEU interrupt.\n");
                goto exit_release_mem;
@@ -633,8 +633,8 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
        pcdev->ici.priv = pcdev;
        pcdev->ici.dev.parent = &pdev->dev;
        pcdev->ici.nr = pdev->id;
-       pcdev->ici.drv_name = pdev->dev.bus_id,
-       pcdev->ici.ops = &sh_mobile_ceu_host_ops,
+       pcdev->ici.drv_name = dev_name(&pdev->dev);
+       pcdev->ici.ops = &sh_mobile_ceu_host_ops;
 
        err = soc_camera_host_register(&pcdev->ici);
        if (err)
index fcd2b62f92c43506456437fa3b46f7469fc4d25c..01a8efb8deb156f274ad54e514be0082783df6f2 100644 (file)
@@ -2162,7 +2162,7 @@ sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
 
        strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
        if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
-               strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
+               strlcpy(cap.bus_info, dev_name(&cam->usbdev->dev),
                        sizeof(cap.bus_info));
 
        if (copy_to_user(arg, &cap, sizeof(cap)))
index 66ebe5956a878ef45cb0a591d88cb2496bea3bc2..28cf5c94bd611fa4af0afd86e021f8c2a8cd3501 100644 (file)
@@ -783,7 +783,7 @@ int soc_camera_host_register(struct soc_camera_host *ici)
                return -EINVAL;
 
        /* Number might be equal to the platform device ID */
-       sprintf(ici->dev.bus_id, "camera_host%d", ici->nr);
+       dev_set_name(&ici->dev, "camera_host%d", ici->nr);
 
        mutex_lock(&list_lock);
        list_for_each_entry(ix, &hosts, list) {
@@ -867,8 +867,7 @@ int soc_camera_device_register(struct soc_camera_device *icd)
 
        icd->devnum = num;
        icd->dev.bus = &soc_camera_bus_type;
-       snprintf(icd->dev.bus_id, sizeof(icd->dev.bus_id),
-                "%u-%u", icd->iface, icd->devnum);
+       dev_set_name(&icd->dev, "%u-%u", icd->iface, icd->devnum);
 
        icd->dev.release = dummy_release;
 
index 062819cabec496c389c58d3bd82aaeb40dc67274..48c8c4399eb8ec5a26eb643c24b81c864fb9c182 100644 (file)
@@ -523,7 +523,7 @@ static int vidioc_querycap (struct file *file, void  *priv,
        strlcpy(vc->card,
                usbvision_device_data[usbvision->DevModel].ModelString,
                sizeof(vc->card));
-       strlcpy(vc->bus_info, usbvision->dev->dev.bus_id,
+       strlcpy(vc->bus_info, dev_name(&usbvision->dev->dev),
                sizeof(vc->bus_info));
        vc->version = USBVISION_DRIVER_VERSION;
        vc->capabilities = V4L2_CAP_VIDEO_CAPTURE |
index ead6d18e51adc4a2230f5acf1138c24f9d0ad928..682f48aadcac342f36579ddac5f89d6ea8120de3 100644 (file)
@@ -339,7 +339,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
        vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
        if (vfd->parent)
                vfd->dev.parent = vfd->parent;
-       sprintf(vfd->dev.bus_id, "%s%d", name_base, nr);
+       dev_set_name(&vfd->dev, "%s%d", name_base, nr);
        ret = device_register(&vfd->dev);
        if (ret < 0) {
                printk(KERN_ERR "%s: device_register failed\n", __func__);
index 9fc58170763827d241e50c7deb28a4077941e1c4..9d00e6056491b1a9baeb6fc305e48ee87bdd9f31 100644 (file)
@@ -1020,7 +1020,7 @@ zc0301_vidioc_querycap(struct zc0301_device* cam, void __user * arg)
 
        strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
        if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
-               strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
+               strlcpy(cap.bus_info, dev_name(&cam->usbdev->dev),
                        sizeof(cap.bus_info));
 
        if (copy_to_user(arg, &cap, sizeof(cap)))
index c5de7bb19fda759febc5a35aca76cf738a7afcc8..9231e2d908f2d536838043868632cdb894bb6b71 100644 (file)
@@ -56,7 +56,7 @@ struct soc_camera_host {
        struct device dev;
        unsigned char nr;                               /* Host number */
        void *priv;
-       char *drv_name;
+       const char *drv_name;
        struct soc_camera_host_ops *ops;
 };
 
@@ -107,7 +107,7 @@ extern int soc_camera_video_start(struct soc_camera_device *icd);
 extern void soc_camera_video_stop(struct soc_camera_device *icd);
 
 struct soc_camera_data_format {
-       char *name;
+       const char *name;
        unsigned int depth;
        __u32 fourcc;
        enum v4l2_colorspace colorspace;