diff --git a/sys/compat/linuxkpi/common/src/linuxkpi_usb.c b/sys/compat/linuxkpi/common/src/linuxkpi_usb.c --- a/sys/compat/linuxkpi/common/src/linuxkpi_usb.c +++ b/sys/compat/linuxkpi/common/src/linuxkpi_usb.c @@ -1167,6 +1167,25 @@ /* ---------------------------------------------------------------------------- */ /* Internal helper functions for the native device interface. */ +static int +lkpi_usb_fill_dev(device_t bsddev, struct device *dev, const char *name) +{ + int error; + + error = kobject_init_and_add(&dev->kobj, &linux_dev_ktype, + &linux_root_device.kobj, name); + if (error != 0) + return (error); + + dev->bsddev = bsddev; + dev->parent = &linux_root_device; + + spin_lock_init(&dev->devres_lock); + INIT_LIST_HEAD(&dev->devres_head); + + return (0); +} + /* * lkpi_usb_create_device() * @@ -1188,8 +1207,7 @@ uint8_t pass; uint8_t iface_no; - error = kobject_init_and_add(&udev->dev.kobj, &linux_dev_ktype, - &linux_root_device.kobj, device_get_nameunit(dev)); + error = lkpi_usb_fill_dev(dev, &udev->dev, device_get_nameunit(dev)); if (error != 0) return (error); @@ -1270,11 +1288,9 @@ p_ui->cur_altsetting = p_uhi - 1; p_ui->bsd_iface_index = iface_index; p_ui->udev = udev; - - error = kobject_init_and_add(&p_ui->dev.kobj, &linux_dev_ktype, - &linux_root_device.kobj, dev_name(&udev->dev)); + error = lkpi_usb_fill_dev(p_ui->subdev, /* XXX ? */ + &p_ui->dev, dev_name(&udev->dev)); WARN_ON(error != 0); - p_ui->dev.bsddev = p_ui->subdev; /* XXX ? */ p_ui++; }