Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2011-2016 Synaptics Incorporated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2011 Unixphere
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/irqdomain.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/rmi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "rmi_bus.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "rmi_driver.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static int debug_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) module_param(debug_flags, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) MODULE_PARM_DESC(debug_flags, "control debugging information");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) void rmi_dbg(int flags, struct device *dev, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct va_format vaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	if (flags & debug_flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		vaf.fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		vaf.va = &args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		dev_printk(KERN_DEBUG, dev, "%pV", &vaf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) EXPORT_SYMBOL_GPL(rmi_dbg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * RMI Physical devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * Physical RMI device consists of several functions serving particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * purpose. For example F11 is a 2D touch sensor while F01 is a generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * function present in every RMI device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static void rmi_release_device(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct rmi_device *rmi_dev = to_rmi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	kfree(rmi_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static const struct device_type rmi_device_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	.name		= "rmi4_sensor",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	.release	= rmi_release_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) bool rmi_is_physical_device(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return dev->type == &rmi_device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * rmi_register_transport_device - register a transport device connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * on the RMI bus.  Transport drivers provide communication from the devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * on a bus (such as SPI, I2C, and so on) to the RMI4 sensor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @xport: the transport device to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) int rmi_register_transport_device(struct rmi_transport_dev *xport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	static atomic_t transport_device_count = ATOMIC_INIT(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	struct rmi_device *rmi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (!rmi_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	device_initialize(&rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	rmi_dev->xport = xport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	rmi_dev->number = atomic_inc_return(&transport_device_count) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	dev_set_name(&rmi_dev->dev, "rmi4-%02d", rmi_dev->number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	rmi_dev->dev.bus = &rmi_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	rmi_dev->dev.type = &rmi_device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	xport->rmi_dev = rmi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	error = device_add(&rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		goto err_put_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	rmi_dbg(RMI_DEBUG_CORE, xport->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		"%s: Registered %s as %s.\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		dev_name(rmi_dev->xport->dev), dev_name(&rmi_dev->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) err_put_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	put_device(&rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) EXPORT_SYMBOL_GPL(rmi_register_transport_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * rmi_unregister_transport_device - unregister a transport device connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * @xport: the transport driver to unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void rmi_unregister_transport_device(struct rmi_transport_dev *xport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct rmi_device *rmi_dev = xport->rmi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	device_del(&rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	put_device(&rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) EXPORT_SYMBOL(rmi_unregister_transport_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* Function specific stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static void rmi_release_function(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct rmi_function *fn = to_rmi_function(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	kfree(fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static const struct device_type rmi_function_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	.name		= "rmi4_function",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	.release	= rmi_release_function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) bool rmi_is_function_device(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	return dev->type == &rmi_function_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static int rmi_function_match(struct device *dev, struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	struct rmi_function_handler *handler = to_rmi_function_handler(drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct rmi_function *fn = to_rmi_function(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	return fn->fd.function_number == handler->func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static void rmi_function_of_probe(struct rmi_function *fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	char of_name[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct device_node *node = fn->rmi_dev->xport->dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	snprintf(of_name, sizeof(of_name), "rmi4-f%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		fn->fd.function_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	fn->dev.of_node = of_get_child_by_name(node, of_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static inline void rmi_function_of_probe(struct rmi_function *fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static struct irq_chip rmi_irq_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.name = "rmi4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static int rmi_create_function_irq(struct rmi_function *fn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				   struct rmi_function_handler *handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	int i, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	for (i = 0; i < fn->num_of_irqs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		set_bit(fn->irq_pos + i, fn->irq_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		fn->irq[i] = irq_create_mapping(drvdata->irqdomain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 						fn->irq_pos + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		irq_set_chip_data(fn->irq[i], fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		irq_set_chip_and_handler(fn->irq[i], &rmi_irq_chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 					 handle_simple_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		irq_set_nested_thread(fn->irq[i], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		error = devm_request_threaded_irq(&fn->dev, fn->irq[i], NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 					handler->attention, IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 					dev_name(&fn->dev), fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			dev_err(&fn->dev, "Error %d registering IRQ\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static int rmi_function_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct rmi_function *fn = to_rmi_function(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	struct rmi_function_handler *handler =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 					to_rmi_function_handler(dev->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	rmi_function_of_probe(fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (handler->probe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		error = handler->probe(fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (fn->num_of_irqs && handler->attention) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		error = rmi_create_function_irq(fn, handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static int rmi_function_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	struct rmi_function *fn = to_rmi_function(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	struct rmi_function_handler *handler =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 					to_rmi_function_handler(dev->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (handler->remove)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		handler->remove(fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int rmi_register_function(struct rmi_function *fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct rmi_device *rmi_dev = fn->rmi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	device_initialize(&fn->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	dev_set_name(&fn->dev, "%s.fn%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		     dev_name(&rmi_dev->dev), fn->fd.function_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	fn->dev.parent = &rmi_dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	fn->dev.type = &rmi_function_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	fn->dev.bus = &rmi_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	error = device_add(&fn->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		dev_err(&rmi_dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			"Failed device_register function device %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			dev_name(&fn->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		goto err_put_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Registered F%02X.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			fn->fd.function_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) err_put_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	put_device(&fn->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) void rmi_unregister_function(struct rmi_function *fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			fn->fd.function_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	device_del(&fn->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	of_node_put(fn->dev.of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	put_device(&fn->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	for (i = 0; i < fn->num_of_irqs; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		irq_dispose_mapping(fn->irq[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * rmi_register_function_handler - register a handler for an RMI function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  * @handler: RMI handler that should be registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  * @module: pointer to module that implements the handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  * @mod_name: name of the module implementing the handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)  * This function performs additional setup of RMI function handler and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)  * registers it with the RMI core so that it can be bound to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)  * RMI function devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int __rmi_register_function_handler(struct rmi_function_handler *handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 				     struct module *owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 				     const char *mod_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct device_driver *driver = &handler->driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	driver->bus = &rmi_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	driver->owner = owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	driver->mod_name = mod_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	driver->probe = rmi_function_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	driver->remove = rmi_function_remove;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	error = driver_register(driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		pr_err("driver_register() failed for %s, error: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			driver->name, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) EXPORT_SYMBOL_GPL(__rmi_register_function_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  * rmi_unregister_function_handler - unregister given RMI function handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * @handler: RMI handler that should be unregistered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  * This function unregisters given function handler from RMI core which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  * causes it to be unbound from the function devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) void rmi_unregister_function_handler(struct rmi_function_handler *handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	driver_unregister(&handler->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) EXPORT_SYMBOL_GPL(rmi_unregister_function_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /* Bus specific stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static int rmi_bus_match(struct device *dev, struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	bool physical = rmi_is_physical_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* First see if types are not compatible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	if (physical != rmi_is_physical_driver(drv))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	return physical || rmi_function_match(dev, drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct bus_type rmi_bus_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	.match		= rmi_bus_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	.name		= "rmi4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static struct rmi_function_handler *fn_handlers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	&rmi_f01_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) #ifdef CONFIG_RMI4_F03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	&rmi_f03_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) #ifdef CONFIG_RMI4_F11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	&rmi_f11_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) #ifdef CONFIG_RMI4_F12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	&rmi_f12_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) #ifdef CONFIG_RMI4_F30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	&rmi_f30_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #ifdef CONFIG_RMI4_F34
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	&rmi_f34_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #ifdef CONFIG_RMI4_F3A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	&rmi_f3a_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) #ifdef CONFIG_RMI4_F54
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	&rmi_f54_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) #ifdef CONFIG_RMI4_F55
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	&rmi_f55_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) static void __rmi_unregister_function_handlers(int start_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	for (i = start_idx; i >= 0; i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		rmi_unregister_function_handler(fn_handlers[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) static void rmi_unregister_function_handlers(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	__rmi_unregister_function_handlers(ARRAY_SIZE(fn_handlers) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) static int rmi_register_function_handlers(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	for (i = 0; i < ARRAY_SIZE(fn_handlers); i++)	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		ret = rmi_register_function_handler(fn_handlers[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 			pr_err("%s: error registering the RMI F%02x handler: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 				__func__, fn_handlers[i]->func, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 			goto err_unregister_function_handlers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) err_unregister_function_handlers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	__rmi_unregister_function_handlers(i - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) int rmi_of_property_read_u32(struct device *dev, u32 *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 				const char *prop, bool optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	u32 val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	retval = of_property_read_u32(dev->of_node, prop, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	if (retval && (!optional && retval == -EINVAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		dev_err(dev, "Failed to get %s value: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			prop, retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	*result = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) EXPORT_SYMBOL_GPL(rmi_of_property_read_u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static int __init rmi_bus_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	error = bus_register(&rmi_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		pr_err("%s: error registering the RMI bus: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			__func__, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	error = rmi_register_function_handlers();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		goto err_unregister_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	error = rmi_register_physical_driver();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		pr_err("%s: error registering the RMI physical driver: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			__func__, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		goto err_unregister_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) err_unregister_bus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	bus_unregister(&rmi_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) module_init(rmi_bus_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static void __exit rmi_bus_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	 * We should only ever get here if all drivers are unloaded, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	 * all we have to do at this point is unregister ourselves.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	rmi_unregister_physical_driver();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	rmi_unregister_function_handlers();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	bus_unregister(&rmi_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) module_exit(rmi_bus_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) MODULE_AUTHOR("Christopher Heiny <cheiny@synaptics.com");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) MODULE_DESCRIPTION("RMI bus");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) MODULE_LICENSE("GPL");