Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af128a10 authored by Kay Sievers's avatar Kay Sievers Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (9521): V4L: struct device - replace bus_id with dev_name(), dev_set_name()



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: default avatarKay Sievers <kay.sievers@vrfy.org>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9b2fb337
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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;
}
+1 −1
Original line number Diff line number Diff line
@@ -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);
};
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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)))
+3 −3
Original line number Diff line number Diff line
@@ -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);
Loading