ACPI: thinkpad-acpi: add development version tag
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / asus_oled / asus_oled.c
blob8a05725cb1d05ed6966eb8ce465bd194fe332820
1 /*
2 * Asus OLED USB driver
4 * Copyright (C) 2007,2008 Jakub Schmidtke (sjakub@gmail.com)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 * This module is based on usbled and asus-laptop modules.
26 * Asus OLED support is based on asusoled program taken from
27 * https://launchpad.net/asusoled/.
32 #include <linux/kernel.h>
33 #include <linux/errno.h>
34 #include <linux/init.h>
35 #include <linux/slab.h>
36 #include <linux/module.h>
37 #include <linux/usb.h>
38 #include <linux/platform_device.h>
39 #include <linux/ctype.h>
41 #define ASUS_OLED_VERSION "0.04-dev"
42 #define ASUS_OLED_NAME "asus-oled"
43 #define ASUS_OLED_UNDERSCORE_NAME "asus_oled"
45 #define ASUS_OLED_ERROR "Asus OLED Display Error: "
47 #define ASUS_OLED_STATIC 's'
48 #define ASUS_OLED_ROLL 'r'
49 #define ASUS_OLED_FLASH 'f'
51 #define ASUS_OLED_MAX_WIDTH 1792
52 #define ASUS_OLED_DISP_HEIGHT 32
53 #define ASUS_OLED_PACKET_BUF_SIZE 256
55 MODULE_AUTHOR("Jakub Schmidtke, sjakub@gmail.com");
56 MODULE_DESCRIPTION("Asus OLED Driver v" ASUS_OLED_VERSION);
57 MODULE_LICENSE("GPL");
59 static struct class *oled_class;
60 static int oled_num;
62 static uint start_off;
64 module_param(start_off, uint, 0644);
66 MODULE_PARM_DESC(start_off,
67 "Set to 1 to switch off OLED display after it is attached");
69 enum oled_pack_mode{
70 PACK_MODE_G1,
71 PACK_MODE_G50,
72 PACK_MODE_LAST
75 struct oled_dev_desc_str {
76 uint16_t idVendor;
77 uint16_t idProduct;
78 /* width of display */
79 uint16_t devWidth;
80 /* formula to be used while packing the picture */
81 enum oled_pack_mode packMode;
82 const char *devDesc;
85 /* table of devices that work with this driver */
86 static struct usb_device_id id_table[] = {
87 /* Asus G1/G2 (and variants)*/
88 { USB_DEVICE(0x0b05, 0x1726) },
89 /* Asus G50V (and possibly others - G70? G71?)*/
90 { USB_DEVICE(0x0b05, 0x175b) },
91 { },
94 /* parameters of specific devices */
95 static struct oled_dev_desc_str oled_dev_desc_table[] = {
96 { 0x0b05, 0x1726, 128, PACK_MODE_G1, "G1/G2" },
97 { 0x0b05, 0x175b, 256, PACK_MODE_G50, "G50" },
98 { },
101 MODULE_DEVICE_TABLE(usb, id_table);
103 struct asus_oled_header {
104 uint8_t magic1;
105 uint8_t magic2;
106 uint8_t flags;
107 uint8_t value3;
108 uint8_t buffer1;
109 uint8_t buffer2;
110 uint8_t value6;
111 uint8_t value7;
112 uint8_t value8;
113 uint8_t padding2[7];
114 } __attribute((packed));
116 struct asus_oled_packet {
117 struct asus_oled_header header;
118 uint8_t bitmap[ASUS_OLED_PACKET_BUF_SIZE];
119 } __attribute((packed));
121 struct asus_oled_dev {
122 struct usb_device *udev;
123 uint8_t pic_mode;
124 uint16_t dev_width;
125 enum oled_pack_mode pack_mode;
126 size_t height;
127 size_t width;
128 size_t x_shift;
129 size_t y_shift;
130 size_t buf_offs;
131 uint8_t last_val;
132 size_t buf_size;
133 char *buf;
134 uint8_t enabled;
135 struct device *dev;
138 static void setup_packet_header(struct asus_oled_packet *packet, char flags,
139 char value3, char buffer1, char buffer2, char value6,
140 char value7, char value8)
142 memset(packet, 0, sizeof(struct asus_oled_header));
143 packet->header.magic1 = 0x55;
144 packet->header.magic2 = 0xaa;
145 packet->header.flags = flags;
146 packet->header.value3 = value3;
147 packet->header.buffer1 = buffer1;
148 packet->header.buffer2 = buffer2;
149 packet->header.value6 = value6;
150 packet->header.value7 = value7;
151 packet->header.value8 = value8;
154 static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
156 int a;
157 int retval;
158 int act_len;
159 struct asus_oled_packet *packet;
161 packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
163 if (!packet) {
164 dev_err(&odev->udev->dev, "out of memory\n");
165 return;
168 setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00);
170 if (enabl)
171 packet->bitmap[0] = 0xaf;
172 else
173 packet->bitmap[0] = 0xae;
175 for (a = 0; a < 1; a++) {
176 retval = usb_bulk_msg(odev->udev,
177 usb_sndbulkpipe(odev->udev, 2),
178 packet,
179 sizeof(struct asus_oled_header) + 1,
180 &act_len,
181 -1);
183 if (retval)
184 dev_dbg(&odev->udev->dev, "retval = %d\n", retval);
187 odev->enabled = enabl;
189 kfree(packet);
192 static ssize_t set_enabled(struct device *dev, struct device_attribute *attr,
193 const char *buf, size_t count)
195 struct usb_interface *intf = to_usb_interface(dev);
196 struct asus_oled_dev *odev = usb_get_intfdata(intf);
197 unsigned long value;
198 if (strict_strtoul(buf, 10, &value))
199 return -EINVAL;
201 enable_oled(odev, value);
203 return count;
206 static ssize_t class_set_enabled(struct device *device,
207 struct device_attribute *attr,
208 const char *buf, size_t count)
210 struct asus_oled_dev *odev =
211 (struct asus_oled_dev *) dev_get_drvdata(device);
212 unsigned long value;
214 if (strict_strtoul(buf, 10, &value))
215 return -EINVAL;
217 enable_oled(odev, value);
219 return count;
222 static ssize_t get_enabled(struct device *dev, struct device_attribute *attr,
223 char *buf)
225 struct usb_interface *intf = to_usb_interface(dev);
226 struct asus_oled_dev *odev = usb_get_intfdata(intf);
228 return sprintf(buf, "%d\n", odev->enabled);
231 static ssize_t class_get_enabled(struct device *device,
232 struct device_attribute *attr, char *buf)
234 struct asus_oled_dev *odev =
235 (struct asus_oled_dev *) dev_get_drvdata(device);
237 return sprintf(buf, "%d\n", odev->enabled);
240 static void send_packets(struct usb_device *udev,
241 struct asus_oled_packet *packet,
242 char *buf, uint8_t p_type, size_t p_num)
244 size_t i;
245 int act_len;
247 for (i = 0; i < p_num; i++) {
248 int retval;
250 switch (p_type) {
251 case ASUS_OLED_ROLL:
252 setup_packet_header(packet, 0x40, 0x80, p_num,
253 i + 1, 0x00, 0x01, 0xff);
254 break;
255 case ASUS_OLED_STATIC:
256 setup_packet_header(packet, 0x10 + i, 0x80, 0x01,
257 0x01, 0x00, 0x01, 0x00);
258 break;
259 case ASUS_OLED_FLASH:
260 setup_packet_header(packet, 0x10 + i, 0x80, 0x01,
261 0x01, 0x00, 0x00, 0xff);
262 break;
265 memcpy(packet->bitmap, buf + (ASUS_OLED_PACKET_BUF_SIZE*i),
266 ASUS_OLED_PACKET_BUF_SIZE);
268 retval = usb_bulk_msg(udev, usb_sndctrlpipe(udev, 2),
269 packet, sizeof(struct asus_oled_packet),
270 &act_len, -1);
272 if (retval)
273 dev_dbg(&udev->dev, "retval = %d\n", retval);
277 static void send_packet(struct usb_device *udev,
278 struct asus_oled_packet *packet,
279 size_t offset, size_t len, char *buf, uint8_t b1,
280 uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5,
281 uint8_t b6) {
282 int retval;
283 int act_len;
285 setup_packet_header(packet, b1, b2, b3, b4, b5, b6, 0x00);
286 memcpy(packet->bitmap, buf + offset, len);
288 retval = usb_bulk_msg(udev,
289 usb_sndctrlpipe(udev, 2),
290 packet,
291 sizeof(struct asus_oled_packet),
292 &act_len,
293 -1);
295 if (retval)
296 dev_dbg(&udev->dev, "retval = %d\n", retval);
300 static void send_packets_g50(struct usb_device *udev,
301 struct asus_oled_packet *packet, char *buf)
303 send_packet(udev, packet, 0, 0x100, buf,
304 0x10, 0x00, 0x02, 0x01, 0x00, 0x01);
305 send_packet(udev, packet, 0x100, 0x080, buf,
306 0x10, 0x00, 0x02, 0x02, 0x80, 0x00);
308 send_packet(udev, packet, 0x180, 0x100, buf,
309 0x11, 0x00, 0x03, 0x01, 0x00, 0x01);
310 send_packet(udev, packet, 0x280, 0x100, buf,
311 0x11, 0x00, 0x03, 0x02, 0x00, 0x01);
312 send_packet(udev, packet, 0x380, 0x080, buf,
313 0x11, 0x00, 0x03, 0x03, 0x80, 0x00);
317 static void send_data(struct asus_oled_dev *odev)
319 size_t packet_num = odev->buf_size / ASUS_OLED_PACKET_BUF_SIZE;
320 struct asus_oled_packet *packet;
322 packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
324 if (!packet) {
325 dev_err(&odev->udev->dev, "out of memory\n");
326 return;
329 if (odev->pack_mode == PACK_MODE_G1) {
330 /* When sending roll-mode data the display updated only
331 first packet. I have no idea why, but when static picture
332 is sent just before rolling picture everything works fine. */
333 if (odev->pic_mode == ASUS_OLED_ROLL)
334 send_packets(odev->udev, packet, odev->buf,
335 ASUS_OLED_STATIC, 2);
337 /* Only ROLL mode can use more than 2 packets.*/
338 if (odev->pic_mode != ASUS_OLED_ROLL && packet_num > 2)
339 packet_num = 2;
341 send_packets(odev->udev, packet, odev->buf,
342 odev->pic_mode, packet_num);
343 } else if (odev->pack_mode == PACK_MODE_G50) {
344 send_packets_g50(odev->udev, packet, odev->buf);
347 kfree(packet);
350 static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count)
352 while (count-- > 0 && val) {
353 size_t x = odev->buf_offs % odev->width;
354 size_t y = odev->buf_offs / odev->width;
355 size_t i;
357 x += odev->x_shift;
358 y += odev->y_shift;
360 switch (odev->pack_mode) {
361 case PACK_MODE_G1:
362 /* i = (x/128)*640 + 127 - x + (y/8)*128;
363 This one for 128 is the same, but might be better
364 for different widths? */
365 i = (x/odev->dev_width)*640 +
366 odev->dev_width - 1 - x +
367 (y/8)*odev->dev_width;
368 break;
370 case PACK_MODE_G50:
371 i = (odev->dev_width - 1 - x)/8 + y*odev->dev_width/8;
372 break;
374 default:
375 i = 0;
376 printk(ASUS_OLED_ERROR "Unknown OLED Pack Mode: %d!\n",
377 odev->pack_mode);
378 break;
381 if (i >= odev->buf_size) {
382 printk(ASUS_OLED_ERROR "Buffer overflow! Report a bug:"
383 "offs: %d >= %d i: %d (x: %d y: %d)\n",
384 (int) odev->buf_offs, (int) odev->buf_size,
385 (int) i, (int) x, (int) y);
386 return -EIO;
389 switch (odev->pack_mode) {
390 case PACK_MODE_G1:
391 odev->buf[i] &= ~(1<<(y%8));
392 break;
394 case PACK_MODE_G50:
395 odev->buf[i] &= ~(1<<(x%8));
396 break;
398 default:
399 /* cannot get here; stops gcc complaining*/
403 odev->last_val = val;
404 odev->buf_offs++;
407 return 0;
410 static ssize_t odev_set_picture(struct asus_oled_dev *odev,
411 const char *buf, size_t count)
413 size_t offs = 0, max_offs;
415 if (count < 1)
416 return 0;
418 if (tolower(buf[0]) == 'b') {
419 /* binary mode, set the entire memory*/
421 size_t i;
423 odev->buf_size = (odev->dev_width * ASUS_OLED_DISP_HEIGHT) / 8;
425 kfree(odev->buf);
426 odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
428 memset(odev->buf, 0xff, odev->buf_size);
430 for (i = 1; i < count && i <= 32 * 32; i++) {
431 odev->buf[i-1] = buf[i];
432 odev->buf_offs = i-1;
435 odev->width = odev->dev_width / 8;
436 odev->height = ASUS_OLED_DISP_HEIGHT;
437 odev->x_shift = 0;
438 odev->y_shift = 0;
439 odev->last_val = 0;
441 send_data(odev);
443 return count;
446 if (buf[0] == '<') {
447 size_t i;
448 size_t w = 0, h = 0;
449 size_t w_mem, h_mem;
451 if (count < 10 || buf[2] != ':')
452 goto error_header;
455 switch (tolower(buf[1])) {
456 case ASUS_OLED_STATIC:
457 case ASUS_OLED_ROLL:
458 case ASUS_OLED_FLASH:
459 odev->pic_mode = buf[1];
460 break;
461 default:
462 printk(ASUS_OLED_ERROR "Wrong picture mode: '%c'.\n",
463 buf[1]);
464 return -EIO;
465 break;
468 for (i = 3; i < count; ++i) {
469 if (buf[i] >= '0' && buf[i] <= '9') {
470 w = 10*w + (buf[i] - '0');
472 if (w > ASUS_OLED_MAX_WIDTH)
473 goto error_width;
474 } else if (tolower(buf[i]) == 'x') {
475 break;
476 } else {
477 goto error_width;
481 for (++i; i < count; ++i) {
482 if (buf[i] >= '0' && buf[i] <= '9') {
483 h = 10*h + (buf[i] - '0');
485 if (h > ASUS_OLED_DISP_HEIGHT)
486 goto error_height;
487 } else if (tolower(buf[i]) == '>') {
488 break;
489 } else {
490 goto error_height;
494 if (w < 1 || w > ASUS_OLED_MAX_WIDTH)
495 goto error_width;
497 if (h < 1 || h > ASUS_OLED_DISP_HEIGHT)
498 goto error_height;
500 if (i >= count || buf[i] != '>')
501 goto error_header;
503 offs = i+1;
505 if (w % (odev->dev_width) != 0)
506 w_mem = (w/(odev->dev_width) + 1)*(odev->dev_width);
507 else
508 w_mem = w;
510 if (h < ASUS_OLED_DISP_HEIGHT)
511 h_mem = ASUS_OLED_DISP_HEIGHT;
512 else
513 h_mem = h;
515 odev->buf_size = w_mem * h_mem / 8;
517 kfree(odev->buf);
518 odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
520 if (odev->buf == NULL) {
521 odev->buf_size = 0;
522 printk(ASUS_OLED_ERROR "Out of memory!\n");
523 return -ENOMEM;
526 memset(odev->buf, 0xff, odev->buf_size);
528 odev->buf_offs = 0;
529 odev->width = w;
530 odev->height = h;
531 odev->x_shift = 0;
532 odev->y_shift = 0;
533 odev->last_val = 0;
535 if (odev->pic_mode == ASUS_OLED_FLASH) {
536 if (h < ASUS_OLED_DISP_HEIGHT/2)
537 odev->y_shift = (ASUS_OLED_DISP_HEIGHT/2 - h)/2;
538 } else {
539 if (h < ASUS_OLED_DISP_HEIGHT)
540 odev->y_shift = (ASUS_OLED_DISP_HEIGHT - h)/2;
543 if (w < (odev->dev_width))
544 odev->x_shift = ((odev->dev_width) - w)/2;
547 max_offs = odev->width * odev->height;
549 while (offs < count && odev->buf_offs < max_offs) {
550 int ret = 0;
552 if (buf[offs] == '1' || buf[offs] == '#') {
553 ret = append_values(odev, 1, 1);
554 if (ret < 0)
555 return ret;
556 } else if (buf[offs] == '0' || buf[offs] == ' ') {
557 ret = append_values(odev, 0, 1);
558 if (ret < 0)
559 return ret;
560 } else if (buf[offs] == '\n') {
561 /* New line detected. Lets assume, that all characters
562 till the end of the line were equal to the last
563 character in this line.*/
564 if (odev->buf_offs % odev->width != 0)
565 ret = append_values(odev, odev->last_val,
566 odev->width -
567 (odev->buf_offs %
568 odev->width));
569 if (ret < 0)
570 return ret;
573 offs++;
576 if (odev->buf_offs >= max_offs)
577 send_data(odev);
579 return count;
581 error_width:
582 printk(ASUS_OLED_ERROR "Wrong picture width specified.\n");
583 return -EIO;
585 error_height:
586 printk(ASUS_OLED_ERROR "Wrong picture height specified.\n");
587 return -EIO;
589 error_header:
590 printk(ASUS_OLED_ERROR "Wrong picture header.\n");
591 return -EIO;
594 static ssize_t set_picture(struct device *dev, struct device_attribute *attr,
595 const char *buf, size_t count)
597 struct usb_interface *intf = to_usb_interface(dev);
599 return odev_set_picture(usb_get_intfdata(intf), buf, count);
602 static ssize_t class_set_picture(struct device *device,
603 struct device_attribute *attr,
604 const char *buf, size_t count)
606 return odev_set_picture((struct asus_oled_dev *)
607 dev_get_drvdata(device), buf, count);
610 #define ASUS_OLED_DEVICE_ATTR(_file) dev_attr_asus_oled_##_file
612 static DEVICE_ATTR(asus_oled_enabled, S_IWUSR | S_IRUGO,
613 get_enabled, set_enabled);
614 static DEVICE_ATTR(asus_oled_picture, S_IWUSR , NULL, set_picture);
616 static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO,
617 class_get_enabled, class_set_enabled);
618 static DEVICE_ATTR(picture, S_IWUSR, NULL, class_set_picture);
620 static int asus_oled_probe(struct usb_interface *interface,
621 const struct usb_device_id *id)
623 struct usb_device *udev = interface_to_usbdev(interface);
624 struct asus_oled_dev *odev = NULL;
625 int retval = -ENOMEM;
626 uint16_t dev_width = 0;
627 enum oled_pack_mode pack_mode = PACK_MODE_LAST;
628 const struct oled_dev_desc_str *dev_desc = oled_dev_desc_table;
629 const char *desc = NULL;
631 if (!id) {
632 /* Even possible? Just to make sure...*/
633 dev_err(&interface->dev, "No usb_device_id provided!\n");
634 return -ENODEV;
637 for (; dev_desc->idVendor; dev_desc++) {
638 if (dev_desc->idVendor == id->idVendor
639 && dev_desc->idProduct == id->idProduct) {
640 dev_width = dev_desc->devWidth;
641 desc = dev_desc->devDesc;
642 pack_mode = dev_desc->packMode;
643 break;
647 if (!desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) {
648 dev_err(&interface->dev,
649 "Missing or incomplete device description!\n");
650 return -ENODEV;
653 odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL);
655 if (odev == NULL) {
656 dev_err(&interface->dev, "Out of memory\n");
657 return -ENOMEM;
660 odev->udev = usb_get_dev(udev);
661 odev->pic_mode = ASUS_OLED_STATIC;
662 odev->dev_width = dev_width;
663 odev->pack_mode = pack_mode;
664 odev->height = 0;
665 odev->width = 0;
666 odev->x_shift = 0;
667 odev->y_shift = 0;
668 odev->buf_offs = 0;
669 odev->buf_size = 0;
670 odev->last_val = 0;
671 odev->buf = NULL;
672 odev->enabled = 1;
673 odev->dev = NULL;
675 usb_set_intfdata(interface, odev);
677 retval = device_create_file(&interface->dev,
678 &ASUS_OLED_DEVICE_ATTR(enabled));
679 if (retval)
680 goto err_files;
682 retval = device_create_file(&interface->dev,
683 &ASUS_OLED_DEVICE_ATTR(picture));
684 if (retval)
685 goto err_files;
687 odev->dev = device_create(oled_class, &interface->dev, MKDEV(0, 0),
688 NULL, "oled_%d", ++oled_num);
690 if (IS_ERR(odev->dev)) {
691 retval = PTR_ERR(odev->dev);
692 goto err_files;
695 dev_set_drvdata(odev->dev, odev);
697 retval = device_create_file(odev->dev, &dev_attr_enabled);
698 if (retval)
699 goto err_class_enabled;
701 retval = device_create_file(odev->dev, &dev_attr_picture);
702 if (retval)
703 goto err_class_picture;
705 dev_info(&interface->dev,
706 "Attached Asus OLED device: %s [width %u, pack_mode %d]\n",
707 desc, odev->dev_width, odev->pack_mode);
709 if (start_off)
710 enable_oled(odev, 0);
712 return 0;
714 err_class_picture:
715 device_remove_file(odev->dev, &dev_attr_picture);
717 err_class_enabled:
718 device_remove_file(odev->dev, &dev_attr_enabled);
719 device_unregister(odev->dev);
721 err_files:
722 device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
723 device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));
725 usb_set_intfdata(interface, NULL);
726 usb_put_dev(odev->udev);
727 kfree(odev);
729 return retval;
732 static void asus_oled_disconnect(struct usb_interface *interface)
734 struct asus_oled_dev *odev;
736 odev = usb_get_intfdata(interface);
737 usb_set_intfdata(interface, NULL);
739 device_remove_file(odev->dev, &dev_attr_picture);
740 device_remove_file(odev->dev, &dev_attr_enabled);
741 device_unregister(odev->dev);
743 device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));
744 device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
746 usb_put_dev(odev->udev);
748 kfree(odev->buf);
750 kfree(odev);
752 dev_info(&interface->dev, "Disconnected Asus OLED device\n");
755 static struct usb_driver oled_driver = {
756 .name = ASUS_OLED_NAME,
757 .probe = asus_oled_probe,
758 .disconnect = asus_oled_disconnect,
759 .id_table = id_table,
762 static ssize_t version_show(struct class *dev, char *buf)
764 return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n",
765 ASUS_OLED_VERSION);
768 static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
770 static int __init asus_oled_init(void)
772 int retval = 0;
773 oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME);
775 if (IS_ERR(oled_class)) {
776 err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class");
777 return PTR_ERR(oled_class);
780 retval = class_create_file(oled_class, &class_attr_version);
781 if (retval) {
782 err("Error creating class version file");
783 goto error;
786 retval = usb_register(&oled_driver);
788 if (retval) {
789 err("usb_register failed. Error number %d", retval);
790 goto error;
793 return retval;
795 error:
796 class_destroy(oled_class);
797 return retval;
800 static void __exit asus_oled_exit(void)
802 class_remove_file(oled_class, &class_attr_version);
803 class_destroy(oled_class);
805 usb_deregister(&oled_driver);
808 module_init(asus_oled_init);
809 module_exit(asus_oled_exit);