+static int
+cdev_set_bdev(int cdev, int bdev)
+{
+ extern int chrtoblk_add(int cdev, int bdev);
+
+ return (chrtoblk_set(cdev, bdev));
+}
+
+int
+cdevsw_add_with_bdev(int index, struct cdevsw * csw, int bdev)
+{
+ index = cdevsw_add(index, csw);
+ if (index < 0) {
+ return (index);
+ }
+ if (cdev_set_bdev(index, bdev) < 0) {
+ cdevsw_remove(index, csw);
+ return (-1);
+ }
+ return (index);
+}
+