H A D | usbsevseg.c | 67 static void update_display_powered(struct usb_sevsegdev *mydev) update_display_powered() argument 71 if (mydev->powered && !mydev->has_interface_pm) { update_display_powered() 72 rc = usb_autopm_get_interface(mydev->intf); update_display_powered() 75 mydev->has_interface_pm = 1; update_display_powered() 78 if (mydev->shadow_power != 1) update_display_powered() 81 rc = usb_control_msg(mydev->udev, update_display_powered() 82 usb_sndctrlpipe(mydev->udev, 0), update_display_powered() 86 (0x00 * 0x100) + (mydev->powered ? 1 : 0), update_display_powered() 91 dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); update_display_powered() 93 if (!mydev->powered && mydev->has_interface_pm) { update_display_powered() 94 usb_autopm_put_interface(mydev->intf); update_display_powered() 95 mydev->has_interface_pm = 0; update_display_powered() 99 static void update_display_mode(struct usb_sevsegdev *mydev) update_display_mode() argument 103 if(mydev->shadow_power != 1) update_display_mode() 106 rc = usb_control_msg(mydev->udev, update_display_mode() 107 usb_sndctrlpipe(mydev->udev, 0), update_display_mode() 111 (mydev->mode_msb * 0x100) + mydev->mode_lsb, update_display_mode() 117 dev_dbg(&mydev->udev->dev, "mode retval = %d\n", rc); update_display_mode() 120 static void update_display_visual(struct usb_sevsegdev *mydev, gfp_t mf) update_display_visual() argument 127 if(mydev->shadow_power != 1) update_display_visual() 132 dev_err(&mydev->udev->dev, "out of memory\n"); update_display_visual() 137 for (i = 0; i < mydev->textlength; i++) update_display_visual() 138 buffer[i] = mydev->text[mydev->textlength-1-i]; update_display_visual() 140 rc = usb_control_msg(mydev->udev, update_display_visual() 141 usb_sndctrlpipe(mydev->udev, 0), update_display_visual() 145 (0 * 0x100) + mydev->textmode, /* mode */ update_display_visual() 147 mydev->textlength, update_display_visual() 151 dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); update_display_visual() 156 for (i = 0; i < sizeof(mydev->decimals); i++) update_display_visual() 157 decimals |= mydev->decimals[i] << i; update_display_visual() 159 rc = usb_control_msg(mydev->udev, update_display_visual() 160 usb_sndctrlpipe(mydev->udev, 0), update_display_visual() 170 dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); update_display_visual() 178 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ 180 return sprintf(buf, "%u\n", mydev->name); \ 187 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ 189 mydev->name = simple_strtoul(buf, NULL, 10); \ 190 update_fcn(mydev); \ 200 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); show_attr_text() local 202 return snprintf(buf, mydev->textlength, "%s\n", mydev->text); show_attr_text() 209 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); set_attr_text() local 212 if (end > sizeof(mydev->text)) set_attr_text() 215 memset(mydev->text, 0, sizeof(mydev->text)); set_attr_text() 216 mydev->textlength = end; set_attr_text() 219 memcpy(mydev->text, buf, end); set_attr_text() 221 update_display_visual(mydev, GFP_KERNEL); set_attr_text() 231 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); show_attr_decimals() local 235 for (i = 0; i < sizeof(mydev->decimals); i++) { show_attr_decimals() 236 pos = sizeof(mydev->decimals) - 1 - i; show_attr_decimals() 237 if (mydev->decimals[i] == 0) show_attr_decimals() 239 else if (mydev->decimals[i] == 1) show_attr_decimals() 245 buf[sizeof(mydev->decimals)] = '\n'; show_attr_decimals() 246 return sizeof(mydev->decimals) + 1; show_attr_decimals() 253 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); set_attr_decimals() local 257 if (end > sizeof(mydev->decimals)) set_attr_decimals() 264 memset(mydev->decimals, 0, sizeof(mydev->decimals)); set_attr_decimals() 267 mydev->decimals[end-1-i] = 1; set_attr_decimals() 269 update_display_visual(mydev, GFP_KERNEL); set_attr_decimals() 280 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); show_attr_textmode() local 286 if (mydev->textmode == i) { show_attr_textmode() 306 struct usb_sevsegdev *mydev = usb_get_intfdata(intf); set_attr_textmode() local 311 mydev->textmode = i; set_attr_textmode() 312 update_display_visual(mydev, GFP_KERNEL); set_attr_textmode() 345 struct usb_sevsegdev *mydev = NULL; sevseg_probe() local 348 mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL); sevseg_probe() 349 if (mydev == NULL) { sevseg_probe() 354 mydev->udev = usb_get_dev(udev); sevseg_probe() 355 mydev->intf = interface; sevseg_probe() 356 usb_set_intfdata(interface, mydev); sevseg_probe() 359 mydev->shadow_power = 1; /* currently active */ sevseg_probe() 360 mydev->has_interface_pm = 0; /* have not issued autopm_get */ sevseg_probe() 363 mydev->textmode = 0x02; /* ascii mode */ sevseg_probe() 364 mydev->mode_msb = 0x06; /* 6 characters */ sevseg_probe() 365 mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ sevseg_probe() 376 usb_put_dev(mydev->udev); sevseg_probe() 377 kfree(mydev); sevseg_probe() 384 struct usb_sevsegdev *mydev; sevseg_disconnect() local 386 mydev = usb_get_intfdata(interface); sevseg_disconnect() 389 usb_put_dev(mydev->udev); sevseg_disconnect() 390 kfree(mydev); sevseg_disconnect() 396 struct usb_sevsegdev *mydev; sevseg_suspend() local 398 mydev = usb_get_intfdata(intf); sevseg_suspend() 399 mydev->shadow_power = 0; sevseg_suspend() 406 struct usb_sevsegdev *mydev; sevseg_resume() local 408 mydev = usb_get_intfdata(intf); sevseg_resume() 409 mydev->shadow_power = 1; sevseg_resume() 410 update_display_mode(mydev); sevseg_resume() 411 update_display_visual(mydev, GFP_NOIO); sevseg_resume() 418 struct usb_sevsegdev *mydev; sevseg_reset_resume() local 420 mydev = usb_get_intfdata(intf); sevseg_reset_resume() 421 mydev->shadow_power = 1; sevseg_reset_resume() 422 update_display_mode(mydev); sevseg_reset_resume() 423 update_display_visual(mydev, GFP_NOIO); sevseg_reset_resume()
|