- * counter_register - register Counter to the system
- * @counter: pointer to Counter to register
- *
- * This function registers a Counter to the system. A sysfs "counter" directory
- * will be created and populated with sysfs attributes correlating with the
- * Counter Signals, Synapses, and Counts respectively.
- *
- * RETURNS:
- * 0 on success, negative error number on failure.
- */
-int counter_register(struct counter_device *const counter)
-{
- struct device *const dev = &counter->dev;
- int id;
- int err;
-
- counter->legacy_device = true;
-
- /* Acquire unique ID */
- id = ida_alloc(&counter_ida, GFP_KERNEL);
- if (id < 0)
- return id;
-
- mutex_init(&counter->ops_exist_lock);
-
- /* Configure device structure for Counter */
- dev->id = id;
- dev->type = &counter_device_type;
- dev->bus = &counter_bus_type;
- dev->devt = MKDEV(MAJOR(counter_devt), id);
- if (counter->parent) {
- dev->parent = counter->parent;
- dev->of_node = counter->parent->of_node;
- }
- device_initialize(dev);
-
- err = counter_sysfs_add(counter);
- if (err < 0)
- goto err_free_id;
-
- err = counter_chrdev_add(counter);
- if (err < 0)
- goto err_free_id;
-
- err = cdev_device_add(&counter->chrdev, dev);
- if (err < 0)
- goto err_remove_chrdev;
-
- return 0;
-
-err_remove_chrdev:
- counter_chrdev_remove(counter);
-err_free_id:
- put_device(dev);
- return err;
-}
-EXPORT_SYMBOL_GPL(counter_register);
-
-/**