17 #include <linux/kernel.h>
18 #include <linux/errno.h>
20 #include <linux/slab.h>
21 #include <linux/module.h>
24 #define DRIVER_VERSION "v1.0"
25 #define DRIVER_AUTHOR "Erik Rigtorp"
26 #define DRIVER_DESC "Cypress USB Thermometer driver"
28 #define USB_SKEL_VENDOR_ID 0x04b4
29 #define USB_SKEL_PRODUCT_ID 0x0002
52 static struct usb_driver cytherm_driver = {
54 .probe = cytherm_probe,
55 .disconnect = cytherm_disconnect,
64 #define WRITE_RAM 0x03
65 #define READ_PORT 0x04
66 #define WRITE_PORT 0x05
70 static int vendor_command(
struct usb_device *
dev,
unsigned char request,
79 USB_CTRL_GET_TIMEOUT);
84 #define BRIGHTNESS 0x2c
85 #define BRIGHTNESS_SEM 0x2b
90 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
99 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
121 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
126 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
134 show_brightness, set_brightness);
144 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
160 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
166 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
171 return sprintf(buf,
"%c%i.%i", sign ?
'-' :
'+', temp >> 1,
172 5*(temp - ((temp >> 1) << 1)));
190 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
204 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
228 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
239 retval = vendor_command(cytherm->
udev,
READ_PORT, 0, 0, buffer, 8);
241 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
247 return sprintf(buf,
"%d", retval);
254 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
276 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
288 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
299 retval = vendor_command(cytherm->
udev,
READ_PORT, 1, 0, buffer, 8);
301 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
307 return sprintf(buf,
"%d", retval);
314 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
336 dev_dbg(&cytherm->
udev->dev,
"retval = %d\n", retval);
350 struct usb_device *
udev = interface_to_usbdev(interface);
356 dev_err (&interface->dev,
"Out of memory\n");
362 usb_set_intfdata (interface, dev);
383 "Cypress thermometer device now attached\n");
391 usb_set_intfdata (interface,
NULL);
398 static void cytherm_disconnect(
struct usb_interface *interface)
402 dev = usb_get_intfdata (interface);
411 usb_set_intfdata (interface,
NULL);
417 dev_info(&interface->dev,
"Cypress thermometer now disconnected\n");