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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (c) 1999-2001 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^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)  *  82C710 C&T mouse port chip driver for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/serio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) MODULE_DESCRIPTION("82C710 C&T mouse port chip driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * ct82c710 interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define CT82C710_DEV_IDLE     0x01		/* Device Idle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define CT82C710_RX_FULL      0x02		/* Device Char received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define CT82C710_TX_IDLE      0x04		/* Device XMIT Idle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define CT82C710_RESET        0x08		/* Device Reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define CT82C710_INTS_ON      0x10		/* Device Interrupt On */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define CT82C710_ERROR_FLAG   0x20		/* Device Error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define CT82C710_CLEAR        0x40		/* Device Clear */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define CT82C710_ENABLE       0x80		/* Device Enable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define CT82C710_IRQ          12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define CT82C710_DATA         ct82c710_iores.start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define CT82C710_STATUS       (ct82c710_iores.start + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static struct serio *ct82c710_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static struct platform_device *ct82c710_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static struct resource ct82c710_iores;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * Interrupt handler for the 82C710 mouse port. A character
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * is waiting in the 82C710.
^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 irqreturn_t ct82c710_interrupt(int cpl, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	return serio_interrupt(ct82c710_port, inb(CT82C710_DATA), 0);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * Wait for device to send output char and flush any input char.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static int ct82c170_wait(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int timeout = 60000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	while ((inb(CT82C710_STATUS) & (CT82C710_RX_FULL | CT82C710_TX_IDLE | CT82C710_DEV_IDLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		       != (CT82C710_DEV_IDLE | CT82C710_TX_IDLE) && timeout) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		if (inb_p(CT82C710_STATUS) & CT82C710_RX_FULL) inb_p(CT82C710_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		udelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		timeout--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return !timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static void ct82c710_close(struct serio *serio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	if (ct82c170_wait())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		printk(KERN_WARNING "ct82c710.c: Device busy in close()\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	outb_p(inb_p(CT82C710_STATUS) & ~(CT82C710_ENABLE | CT82C710_INTS_ON), CT82C710_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (ct82c170_wait())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		printk(KERN_WARNING "ct82c710.c: Device busy in close()\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	free_irq(CT82C710_IRQ, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static int ct82c710_open(struct serio *serio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned char status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	err = request_irq(CT82C710_IRQ, ct82c710_interrupt, 0, "ct82c710", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	status = inb_p(CT82C710_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	status |= (CT82C710_ENABLE | CT82C710_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	outb_p(status, CT82C710_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	status &= ~(CT82C710_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	outb_p(status, CT82C710_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	status |= CT82C710_INTS_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	outb_p(status, CT82C710_STATUS);	/* Enable interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	while (ct82c170_wait()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		printk(KERN_ERR "ct82c710: Device busy in open()\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		status &= ~(CT82C710_ENABLE | CT82C710_INTS_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		outb_p(status, CT82C710_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		free_irq(CT82C710_IRQ, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^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)  * Write to the 82C710 mouse device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int ct82c710_write(struct serio *port, unsigned char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (ct82c170_wait()) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	outb_p(c, CT82C710_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * See if we can find a 82C710 device. Read mouse address.
^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) static int __init ct82c710_detect(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	outb_p(0x55, 0x2fa);				/* Any value except 9, ff or 36 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	outb_p(0xaa, 0x3fa);				/* Inverse of 55 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	outb_p(0x36, 0x3fa);				/* Address the chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	outb_p(0xe4, 0x3fa);				/* 390/4; 390 = config address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	outb_p(0x1b, 0x2fa);				/* Inverse of e4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	outb_p(0x0f, 0x390);				/* Write index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (inb_p(0x391) != 0xe4)			/* Config address found? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		return -ENODEV;				/* No: no 82C710 here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	outb_p(0x0d, 0x390);				/* Write index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	ct82c710_iores.start = inb_p(0x391) << 2;	/* Get mouse I/O address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	ct82c710_iores.end = ct82c710_iores.start + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	ct82c710_iores.flags = IORESOURCE_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	outb_p(0x0f, 0x390);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	outb_p(0x0f, 0x391);				/* Close config mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static int ct82c710_probe(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	ct82c710_port = kzalloc(sizeof(struct serio), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (!ct82c710_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	ct82c710_port->id.type = SERIO_8042;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	ct82c710_port->dev.parent = &dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	ct82c710_port->open = ct82c710_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ct82c710_port->close = ct82c710_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	ct82c710_port->write = ct82c710_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	strlcpy(ct82c710_port->name, "C&T 82c710 mouse port",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		sizeof(ct82c710_port->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		 "isa%16llx/serio0", (unsigned long long)CT82C710_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	serio_register_port(ct82c710_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	printk(KERN_INFO "serio: C&T 82c710 mouse port at %#llx irq %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		(unsigned long long)CT82C710_DATA, CT82C710_IRQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static int ct82c710_remove(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	serio_unregister_port(ct82c710_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static struct platform_driver ct82c710_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		.name	= "ct82c710",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	.probe		= ct82c710_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	.remove		= ct82c710_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^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 __init ct82c710_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	error = ct82c710_detect();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	error = platform_driver_register(&ct82c710_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	ct82c710_device = platform_device_alloc("ct82c710", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (!ct82c710_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		goto err_unregister_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	error = platform_device_add_resources(ct82c710_device, &ct82c710_iores, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		goto err_free_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	error = platform_device_add(ct82c710_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		goto err_free_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  err_free_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	platform_device_put(ct82c710_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  err_unregister_driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	platform_driver_unregister(&ct82c710_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static void __exit ct82c710_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	platform_device_unregister(ct82c710_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	platform_driver_unregister(&ct82c710_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) module_init(ct82c710_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) module_exit(ct82c710_exit);