gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / tty / serdev / core.c
blobc5f0d936b003ae597c7ac05cce724793311e7492
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2016-2017 Linaro Ltd., Rob Herring <robh@kernel.org>
5 * Based on drivers/spmi/spmi.c:
6 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
7 */
9 #include <linux/acpi.h>
10 #include <linux/errno.h>
11 #include <linux/idr.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/of.h>
15 #include <linux/of_device.h>
16 #include <linux/pm_domain.h>
17 #include <linux/pm_runtime.h>
18 #include <linux/sched.h>
19 #include <linux/serdev.h>
20 #include <linux/slab.h>
21 #include <linux/platform_data/x86/apple.h>
23 static bool is_registered;
24 static DEFINE_IDA(ctrl_ida);
26 static ssize_t modalias_show(struct device *dev,
27 struct device_attribute *attr, char *buf)
29 int len;
31 len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
32 if (len != -ENODEV)
33 return len;
35 return of_device_modalias(dev, buf, PAGE_SIZE);
37 static DEVICE_ATTR_RO(modalias);
39 static struct attribute *serdev_device_attrs[] = {
40 &dev_attr_modalias.attr,
41 NULL,
43 ATTRIBUTE_GROUPS(serdev_device);
45 static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env)
47 int rc;
49 /* TODO: platform modalias */
51 rc = acpi_device_uevent_modalias(dev, env);
52 if (rc != -ENODEV)
53 return rc;
55 return of_device_uevent_modalias(dev, env);
58 static void serdev_device_release(struct device *dev)
60 struct serdev_device *serdev = to_serdev_device(dev);
61 kfree(serdev);
64 static const struct device_type serdev_device_type = {
65 .groups = serdev_device_groups,
66 .uevent = serdev_device_uevent,
67 .release = serdev_device_release,
70 static bool is_serdev_device(const struct device *dev)
72 return dev->type == &serdev_device_type;
75 static void serdev_ctrl_release(struct device *dev)
77 struct serdev_controller *ctrl = to_serdev_controller(dev);
78 ida_simple_remove(&ctrl_ida, ctrl->nr);
79 kfree(ctrl);
82 static const struct device_type serdev_ctrl_type = {
83 .release = serdev_ctrl_release,
86 static int serdev_device_match(struct device *dev, struct device_driver *drv)
88 if (!is_serdev_device(dev))
89 return 0;
91 /* TODO: platform matching */
92 if (acpi_driver_match_device(dev, drv))
93 return 1;
95 return of_driver_match_device(dev, drv);
98 /**
99 * serdev_device_add() - add a device previously constructed via serdev_device_alloc()
100 * @serdev: serdev_device to be added
102 int serdev_device_add(struct serdev_device *serdev)
104 struct serdev_controller *ctrl = serdev->ctrl;
105 struct device *parent = serdev->dev.parent;
106 int err;
108 dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr);
110 /* Only a single slave device is currently supported. */
111 if (ctrl->serdev) {
112 dev_err(&serdev->dev, "controller busy\n");
113 return -EBUSY;
115 ctrl->serdev = serdev;
117 err = device_add(&serdev->dev);
118 if (err < 0) {
119 dev_err(&serdev->dev, "Can't add %s, status %pe\n",
120 dev_name(&serdev->dev), ERR_PTR(err));
121 goto err_clear_serdev;
124 dev_dbg(&serdev->dev, "device %s registered\n", dev_name(&serdev->dev));
126 return 0;
128 err_clear_serdev:
129 ctrl->serdev = NULL;
130 return err;
132 EXPORT_SYMBOL_GPL(serdev_device_add);
135 * serdev_device_remove(): remove an serdev device
136 * @serdev: serdev_device to be removed
138 void serdev_device_remove(struct serdev_device *serdev)
140 struct serdev_controller *ctrl = serdev->ctrl;
142 device_unregister(&serdev->dev);
143 ctrl->serdev = NULL;
145 EXPORT_SYMBOL_GPL(serdev_device_remove);
147 int serdev_device_open(struct serdev_device *serdev)
149 struct serdev_controller *ctrl = serdev->ctrl;
150 int ret;
152 if (!ctrl || !ctrl->ops->open)
153 return -EINVAL;
155 ret = ctrl->ops->open(ctrl);
156 if (ret)
157 return ret;
159 ret = pm_runtime_get_sync(&ctrl->dev);
160 if (ret < 0) {
161 pm_runtime_put_noidle(&ctrl->dev);
162 goto err_close;
165 return 0;
167 err_close:
168 if (ctrl->ops->close)
169 ctrl->ops->close(ctrl);
171 return ret;
173 EXPORT_SYMBOL_GPL(serdev_device_open);
175 void serdev_device_close(struct serdev_device *serdev)
177 struct serdev_controller *ctrl = serdev->ctrl;
179 if (!ctrl || !ctrl->ops->close)
180 return;
182 pm_runtime_put(&ctrl->dev);
184 ctrl->ops->close(ctrl);
186 EXPORT_SYMBOL_GPL(serdev_device_close);
188 static void devm_serdev_device_release(struct device *dev, void *dr)
190 serdev_device_close(*(struct serdev_device **)dr);
193 int devm_serdev_device_open(struct device *dev, struct serdev_device *serdev)
195 struct serdev_device **dr;
196 int ret;
198 dr = devres_alloc(devm_serdev_device_release, sizeof(*dr), GFP_KERNEL);
199 if (!dr)
200 return -ENOMEM;
202 ret = serdev_device_open(serdev);
203 if (ret) {
204 devres_free(dr);
205 return ret;
208 *dr = serdev;
209 devres_add(dev, dr);
211 return 0;
213 EXPORT_SYMBOL_GPL(devm_serdev_device_open);
215 void serdev_device_write_wakeup(struct serdev_device *serdev)
217 complete(&serdev->write_comp);
219 EXPORT_SYMBOL_GPL(serdev_device_write_wakeup);
222 * serdev_device_write_buf() - write data asynchronously
223 * @serdev: serdev device
224 * @buf: data to be written
225 * @count: number of bytes to write
227 * Write data to the device asynchronously.
229 * Note that any accepted data has only been buffered by the controller; use
230 * serdev_device_wait_until_sent() to make sure the controller write buffer
231 * has actually been emptied.
233 * Return: The number of bytes written (less than count if not enough room in
234 * the write buffer), or a negative errno on errors.
236 int serdev_device_write_buf(struct serdev_device *serdev,
237 const unsigned char *buf, size_t count)
239 struct serdev_controller *ctrl = serdev->ctrl;
241 if (!ctrl || !ctrl->ops->write_buf)
242 return -EINVAL;
244 return ctrl->ops->write_buf(ctrl, buf, count);
246 EXPORT_SYMBOL_GPL(serdev_device_write_buf);
249 * serdev_device_write() - write data synchronously
250 * @serdev: serdev device
251 * @buf: data to be written
252 * @count: number of bytes to write
253 * @timeout: timeout in jiffies, or 0 to wait indefinitely
255 * Write data to the device synchronously by repeatedly calling
256 * serdev_device_write() until the controller has accepted all data (unless
257 * interrupted by a timeout or a signal).
259 * Note that any accepted data has only been buffered by the controller; use
260 * serdev_device_wait_until_sent() to make sure the controller write buffer
261 * has actually been emptied.
263 * Note that this function depends on serdev_device_write_wakeup() being
264 * called in the serdev driver write_wakeup() callback.
266 * Return: The number of bytes written (less than count if interrupted),
267 * -ETIMEDOUT or -ERESTARTSYS if interrupted before any bytes were written, or
268 * a negative errno on errors.
270 int serdev_device_write(struct serdev_device *serdev,
271 const unsigned char *buf, size_t count,
272 long timeout)
274 struct serdev_controller *ctrl = serdev->ctrl;
275 int written = 0;
276 int ret;
278 if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup)
279 return -EINVAL;
281 if (timeout == 0)
282 timeout = MAX_SCHEDULE_TIMEOUT;
284 mutex_lock(&serdev->write_lock);
285 do {
286 reinit_completion(&serdev->write_comp);
288 ret = ctrl->ops->write_buf(ctrl, buf, count);
289 if (ret < 0)
290 break;
292 written += ret;
293 buf += ret;
294 count -= ret;
296 if (count == 0)
297 break;
299 timeout = wait_for_completion_interruptible_timeout(&serdev->write_comp,
300 timeout);
301 } while (timeout > 0);
302 mutex_unlock(&serdev->write_lock);
304 if (ret < 0)
305 return ret;
307 if (timeout <= 0 && written == 0) {
308 if (timeout == -ERESTARTSYS)
309 return -ERESTARTSYS;
310 else
311 return -ETIMEDOUT;
314 return written;
316 EXPORT_SYMBOL_GPL(serdev_device_write);
318 void serdev_device_write_flush(struct serdev_device *serdev)
320 struct serdev_controller *ctrl = serdev->ctrl;
322 if (!ctrl || !ctrl->ops->write_flush)
323 return;
325 ctrl->ops->write_flush(ctrl);
327 EXPORT_SYMBOL_GPL(serdev_device_write_flush);
329 int serdev_device_write_room(struct serdev_device *serdev)
331 struct serdev_controller *ctrl = serdev->ctrl;
333 if (!ctrl || !ctrl->ops->write_room)
334 return 0;
336 return serdev->ctrl->ops->write_room(ctrl);
338 EXPORT_SYMBOL_GPL(serdev_device_write_room);
340 unsigned int serdev_device_set_baudrate(struct serdev_device *serdev, unsigned int speed)
342 struct serdev_controller *ctrl = serdev->ctrl;
344 if (!ctrl || !ctrl->ops->set_baudrate)
345 return 0;
347 return ctrl->ops->set_baudrate(ctrl, speed);
350 EXPORT_SYMBOL_GPL(serdev_device_set_baudrate);
352 void serdev_device_set_flow_control(struct serdev_device *serdev, bool enable)
354 struct serdev_controller *ctrl = serdev->ctrl;
356 if (!ctrl || !ctrl->ops->set_flow_control)
357 return;
359 ctrl->ops->set_flow_control(ctrl, enable);
361 EXPORT_SYMBOL_GPL(serdev_device_set_flow_control);
363 int serdev_device_set_parity(struct serdev_device *serdev,
364 enum serdev_parity parity)
366 struct serdev_controller *ctrl = serdev->ctrl;
368 if (!ctrl || !ctrl->ops->set_parity)
369 return -ENOTSUPP;
371 return ctrl->ops->set_parity(ctrl, parity);
373 EXPORT_SYMBOL_GPL(serdev_device_set_parity);
375 void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
377 struct serdev_controller *ctrl = serdev->ctrl;
379 if (!ctrl || !ctrl->ops->wait_until_sent)
380 return;
382 ctrl->ops->wait_until_sent(ctrl, timeout);
384 EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
386 int serdev_device_get_tiocm(struct serdev_device *serdev)
388 struct serdev_controller *ctrl = serdev->ctrl;
390 if (!ctrl || !ctrl->ops->get_tiocm)
391 return -ENOTSUPP;
393 return ctrl->ops->get_tiocm(ctrl);
395 EXPORT_SYMBOL_GPL(serdev_device_get_tiocm);
397 int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
399 struct serdev_controller *ctrl = serdev->ctrl;
401 if (!ctrl || !ctrl->ops->set_tiocm)
402 return -ENOTSUPP;
404 return ctrl->ops->set_tiocm(ctrl, set, clear);
406 EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
408 static int serdev_drv_probe(struct device *dev)
410 const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
411 int ret;
413 ret = dev_pm_domain_attach(dev, true);
414 if (ret)
415 return ret;
417 ret = sdrv->probe(to_serdev_device(dev));
418 if (ret)
419 dev_pm_domain_detach(dev, true);
421 return ret;
424 static int serdev_drv_remove(struct device *dev)
426 const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
427 if (sdrv->remove)
428 sdrv->remove(to_serdev_device(dev));
430 dev_pm_domain_detach(dev, true);
432 return 0;
435 static struct bus_type serdev_bus_type = {
436 .name = "serial",
437 .match = serdev_device_match,
438 .probe = serdev_drv_probe,
439 .remove = serdev_drv_remove,
443 * serdev_device_alloc() - Allocate a new serdev device
444 * @ctrl: associated controller
446 * Caller is responsible for either calling serdev_device_add() to add the
447 * newly allocated controller, or calling serdev_device_put() to discard it.
449 struct serdev_device *serdev_device_alloc(struct serdev_controller *ctrl)
451 struct serdev_device *serdev;
453 serdev = kzalloc(sizeof(*serdev), GFP_KERNEL);
454 if (!serdev)
455 return NULL;
457 serdev->ctrl = ctrl;
458 device_initialize(&serdev->dev);
459 serdev->dev.parent = &ctrl->dev;
460 serdev->dev.bus = &serdev_bus_type;
461 serdev->dev.type = &serdev_device_type;
462 init_completion(&serdev->write_comp);
463 mutex_init(&serdev->write_lock);
464 return serdev;
466 EXPORT_SYMBOL_GPL(serdev_device_alloc);
469 * serdev_controller_alloc() - Allocate a new serdev controller
470 * @parent: parent device
471 * @size: size of private data
473 * Caller is responsible for either calling serdev_controller_add() to add the
474 * newly allocated controller, or calling serdev_controller_put() to discard it.
475 * The allocated private data region may be accessed via
476 * serdev_controller_get_drvdata()
478 struct serdev_controller *serdev_controller_alloc(struct device *parent,
479 size_t size)
481 struct serdev_controller *ctrl;
482 int id;
484 if (WARN_ON(!parent))
485 return NULL;
487 ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL);
488 if (!ctrl)
489 return NULL;
491 id = ida_simple_get(&ctrl_ida, 0, 0, GFP_KERNEL);
492 if (id < 0) {
493 dev_err(parent,
494 "unable to allocate serdev controller identifier.\n");
495 goto err_free;
498 ctrl->nr = id;
500 device_initialize(&ctrl->dev);
501 ctrl->dev.type = &serdev_ctrl_type;
502 ctrl->dev.bus = &serdev_bus_type;
503 ctrl->dev.parent = parent;
504 ctrl->dev.of_node = parent->of_node;
505 serdev_controller_set_drvdata(ctrl, &ctrl[1]);
507 dev_set_name(&ctrl->dev, "serial%d", id);
509 pm_runtime_no_callbacks(&ctrl->dev);
510 pm_suspend_ignore_children(&ctrl->dev, true);
512 dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id);
513 return ctrl;
515 err_free:
516 kfree(ctrl);
518 return NULL;
520 EXPORT_SYMBOL_GPL(serdev_controller_alloc);
522 static int of_serdev_register_devices(struct serdev_controller *ctrl)
524 struct device_node *node;
525 struct serdev_device *serdev = NULL;
526 int err;
527 bool found = false;
529 for_each_available_child_of_node(ctrl->dev.of_node, node) {
530 if (!of_get_property(node, "compatible", NULL))
531 continue;
533 dev_dbg(&ctrl->dev, "adding child %pOF\n", node);
535 serdev = serdev_device_alloc(ctrl);
536 if (!serdev)
537 continue;
539 serdev->dev.of_node = node;
541 err = serdev_device_add(serdev);
542 if (err) {
543 dev_err(&serdev->dev,
544 "failure adding device. status %pe\n",
545 ERR_PTR(err));
546 serdev_device_put(serdev);
547 } else
548 found = true;
550 if (!found)
551 return -ENODEV;
553 return 0;
556 #ifdef CONFIG_ACPI
558 #define SERDEV_ACPI_MAX_SCAN_DEPTH 32
560 struct acpi_serdev_lookup {
561 acpi_handle device_handle;
562 acpi_handle controller_handle;
563 int n;
564 int index;
567 static int acpi_serdev_parse_resource(struct acpi_resource *ares, void *data)
569 struct acpi_serdev_lookup *lookup = data;
570 struct acpi_resource_uart_serialbus *sb;
571 acpi_status status;
573 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
574 return 1;
576 if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
577 return 1;
579 if (lookup->index != -1 && lookup->n++ != lookup->index)
580 return 1;
582 sb = &ares->data.uart_serial_bus;
584 status = acpi_get_handle(lookup->device_handle,
585 sb->resource_source.string_ptr,
586 &lookup->controller_handle);
587 if (ACPI_FAILURE(status))
588 return 1;
591 * NOTE: Ideally, we would also want to retreive other properties here,
592 * once setting them before opening the device is supported by serdev.
595 return 1;
598 static int acpi_serdev_do_lookup(struct acpi_device *adev,
599 struct acpi_serdev_lookup *lookup)
601 struct list_head resource_list;
602 int ret;
604 lookup->device_handle = acpi_device_handle(adev);
605 lookup->controller_handle = NULL;
606 lookup->n = 0;
608 INIT_LIST_HEAD(&resource_list);
609 ret = acpi_dev_get_resources(adev, &resource_list,
610 acpi_serdev_parse_resource, lookup);
611 acpi_dev_free_resource_list(&resource_list);
613 if (ret < 0)
614 return -EINVAL;
616 return 0;
619 static int acpi_serdev_check_resources(struct serdev_controller *ctrl,
620 struct acpi_device *adev)
622 struct acpi_serdev_lookup lookup;
623 int ret;
625 if (acpi_bus_get_status(adev) || !adev->status.present)
626 return -EINVAL;
628 /* Look for UARTSerialBusV2 resource */
629 lookup.index = -1; // we only care for the last device
631 ret = acpi_serdev_do_lookup(adev, &lookup);
632 if (ret)
633 return ret;
636 * Apple machines provide an empty resource template, so on those
637 * machines just look for immediate children with a "baud" property
638 * (from the _DSM method) instead.
640 if (!lookup.controller_handle && x86_apple_machine &&
641 !acpi_dev_get_property(adev, "baud", ACPI_TYPE_BUFFER, NULL))
642 acpi_get_parent(adev->handle, &lookup.controller_handle);
644 /* Make sure controller and ResourceSource handle match */
645 if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle)
646 return -ENODEV;
648 return 0;
651 static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl,
652 struct acpi_device *adev)
654 struct serdev_device *serdev;
655 int err;
657 serdev = serdev_device_alloc(ctrl);
658 if (!serdev) {
659 dev_err(&ctrl->dev, "failed to allocate serdev device for %s\n",
660 dev_name(&adev->dev));
661 return AE_NO_MEMORY;
664 ACPI_COMPANION_SET(&serdev->dev, adev);
665 acpi_device_set_enumerated(adev);
667 err = serdev_device_add(serdev);
668 if (err) {
669 dev_err(&serdev->dev,
670 "failure adding ACPI serdev device. status %pe\n",
671 ERR_PTR(err));
672 serdev_device_put(serdev);
675 return AE_OK;
678 static const struct acpi_device_id serdev_acpi_devices_blacklist[] = {
679 { "INT3511", 0 },
680 { "INT3512", 0 },
681 { },
684 static acpi_status acpi_serdev_add_device(acpi_handle handle, u32 level,
685 void *data, void **return_value)
687 struct serdev_controller *ctrl = data;
688 struct acpi_device *adev;
690 if (acpi_bus_get_device(handle, &adev))
691 return AE_OK;
693 if (acpi_device_enumerated(adev))
694 return AE_OK;
696 /* Skip if black listed */
697 if (!acpi_match_device_ids(adev, serdev_acpi_devices_blacklist))
698 return AE_OK;
700 if (acpi_serdev_check_resources(ctrl, adev))
701 return AE_OK;
703 return acpi_serdev_register_device(ctrl, adev);
707 static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
709 acpi_status status;
711 if (!has_acpi_companion(ctrl->dev.parent))
712 return -ENODEV;
714 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
715 SERDEV_ACPI_MAX_SCAN_DEPTH,
716 acpi_serdev_add_device, NULL, ctrl, NULL);
717 if (ACPI_FAILURE(status))
718 dev_warn(&ctrl->dev, "failed to enumerate serdev slaves\n");
720 if (!ctrl->serdev)
721 return -ENODEV;
723 return 0;
725 #else
726 static inline int acpi_serdev_register_devices(struct serdev_controller *ctrl)
728 return -ENODEV;
730 #endif /* CONFIG_ACPI */
733 * serdev_controller_add() - Add an serdev controller
734 * @ctrl: controller to be registered.
736 * Register a controller previously allocated via serdev_controller_alloc() with
737 * the serdev core.
739 int serdev_controller_add(struct serdev_controller *ctrl)
741 int ret_of, ret_acpi, ret;
743 /* Can't register until after driver model init */
744 if (WARN_ON(!is_registered))
745 return -EAGAIN;
747 ret = device_add(&ctrl->dev);
748 if (ret)
749 return ret;
751 pm_runtime_enable(&ctrl->dev);
753 ret_of = of_serdev_register_devices(ctrl);
754 ret_acpi = acpi_serdev_register_devices(ctrl);
755 if (ret_of && ret_acpi) {
756 dev_dbg(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n",
757 ERR_PTR(ret_of), ERR_PTR(ret_acpi));
758 ret = -ENODEV;
759 goto err_rpm_disable;
762 dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n",
763 ctrl->nr, &ctrl->dev);
764 return 0;
766 err_rpm_disable:
767 pm_runtime_disable(&ctrl->dev);
768 device_del(&ctrl->dev);
769 return ret;
771 EXPORT_SYMBOL_GPL(serdev_controller_add);
773 /* Remove a device associated with a controller */
774 static int serdev_remove_device(struct device *dev, void *data)
776 struct serdev_device *serdev = to_serdev_device(dev);
777 if (dev->type == &serdev_device_type)
778 serdev_device_remove(serdev);
779 return 0;
783 * serdev_controller_remove(): remove an serdev controller
784 * @ctrl: controller to remove
786 * Remove a serdev controller. Caller is responsible for calling
787 * serdev_controller_put() to discard the allocated controller.
789 void serdev_controller_remove(struct serdev_controller *ctrl)
791 int dummy;
793 if (!ctrl)
794 return;
796 dummy = device_for_each_child(&ctrl->dev, NULL,
797 serdev_remove_device);
798 pm_runtime_disable(&ctrl->dev);
799 device_del(&ctrl->dev);
801 EXPORT_SYMBOL_GPL(serdev_controller_remove);
804 * serdev_driver_register() - Register client driver with serdev core
805 * @sdrv: client driver to be associated with client-device.
807 * This API will register the client driver with the serdev framework.
808 * It is typically called from the driver's module-init function.
810 int __serdev_device_driver_register(struct serdev_device_driver *sdrv, struct module *owner)
812 sdrv->driver.bus = &serdev_bus_type;
813 sdrv->driver.owner = owner;
815 /* force drivers to async probe so I/O is possible in probe */
816 sdrv->driver.probe_type = PROBE_PREFER_ASYNCHRONOUS;
818 return driver_register(&sdrv->driver);
820 EXPORT_SYMBOL_GPL(__serdev_device_driver_register);
822 static void __exit serdev_exit(void)
824 bus_unregister(&serdev_bus_type);
825 ida_destroy(&ctrl_ida);
827 module_exit(serdev_exit);
829 static int __init serdev_init(void)
831 int ret;
833 ret = bus_register(&serdev_bus_type);
834 if (ret)
835 return ret;
837 is_registered = true;
838 return 0;
840 /* Must be before serial drivers register */
841 postcore_initcall(serdev_init);
843 MODULE_AUTHOR("Rob Herring <robh@kernel.org>");
844 MODULE_LICENSE("GPL v2");
845 MODULE_DESCRIPTION("Serial attached device bus");