usbsevseg.c (87d8a69709d971913e6cc7210450fcb8be963667) | usbsevseg.c (4c1f5c88aaffacb2831353b6d3c1557be52071a2) |
---|---|
1/* 2 * USB 7 Segment Driver 3 * 4 * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> 5 * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as --- 35 unchanged lines hidden (view full) --- 44 u8 mode_msb; 45 u8 mode_lsb; 46 u8 decimals[MAXLEN]; 47 u8 textmode; 48 u8 text[MAXLEN]; 49 u16 textlength; 50 51 u8 shadow_power; /* for PM */ | 1/* 2 * USB 7 Segment Driver 3 * 4 * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> 5 * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as --- 35 unchanged lines hidden (view full) --- 44 u8 mode_msb; 45 u8 mode_lsb; 46 u8 decimals[MAXLEN]; 47 u8 textmode; 48 u8 text[MAXLEN]; 49 u16 textlength; 50 51 u8 shadow_power; /* for PM */ |
52 u8 has_interface_pm; |
|
52}; 53 54/* sysfs_streq can't replace this completely 55 * If the device was in hex mode, and the user wanted a 0, 56 * if str commands are used, we would assume the end of string 57 * so mem commands are used. 58 */ 59inline size_t my_memlen(const char *buf, size_t count) 60{ 61 if (count > 0 && buf[count-1] == '\n') 62 return count - 1; 63 else 64 return count; 65} 66 67static void update_display_powered(struct usb_sevsegdev *mydev) 68{ 69 int rc; 70 | 53}; 54 55/* sysfs_streq can't replace this completely 56 * If the device was in hex mode, and the user wanted a 0, 57 * if str commands are used, we would assume the end of string 58 * so mem commands are used. 59 */ 60inline size_t my_memlen(const char *buf, size_t count) 61{ 62 if (count > 0 && buf[count-1] == '\n') 63 return count - 1; 64 else 65 return count; 66} 67 68static void update_display_powered(struct usb_sevsegdev *mydev) 69{ 70 int rc; 71 |
71 if (!mydev->shadow_power && mydev->powered) { | 72 if (mydev->powered && !mydev->has_interface_pm) { |
72 rc = usb_autopm_get_interface(mydev->intf); 73 if (rc < 0) 74 return; | 73 rc = usb_autopm_get_interface(mydev->intf); 74 if (rc < 0) 75 return; |
76 mydev->has_interface_pm = 1; |
|
75 } 76 | 77 } 78 |
79 if (mydev->shadow_power != 1) 80 return; 81 |
|
77 rc = usb_control_msg(mydev->udev, 78 usb_sndctrlpipe(mydev->udev, 0), 79 0x12, 80 0x48, 81 (80 * 0x100) + 10, /* (power mode) */ 82 (0x00 * 0x100) + (mydev->powered ? 1 : 0), 83 NULL, 84 0, 85 2000); 86 if (rc < 0) 87 dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); 88 | 82 rc = usb_control_msg(mydev->udev, 83 usb_sndctrlpipe(mydev->udev, 0), 84 0x12, 85 0x48, 86 (80 * 0x100) + 10, /* (power mode) */ 87 (0x00 * 0x100) + (mydev->powered ? 1 : 0), 88 NULL, 89 0, 90 2000); 91 if (rc < 0) 92 dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); 93 |
89 if (mydev->shadow_power && !mydev->powered) | 94 if (!mydev->powered && mydev->has_interface_pm) { |
90 usb_autopm_put_interface(mydev->intf); | 95 usb_autopm_put_interface(mydev->intf); |
96 mydev->has_interface_pm = 0; 97 } |
|
91} 92 93static void update_display_mode(struct usb_sevsegdev *mydev) 94{ 95 int rc; 96 97 if(mydev->shadow_power != 1) 98 return; --- 247 unchanged lines hidden (view full) --- 346 dev_err(&interface->dev, "Out of memory\n"); 347 goto error_mem; 348 } 349 350 mydev->udev = usb_get_dev(udev); 351 mydev->intf = interface; 352 usb_set_intfdata(interface, mydev); 353 | 98} 99 100static void update_display_mode(struct usb_sevsegdev *mydev) 101{ 102 int rc; 103 104 if(mydev->shadow_power != 1) 105 return; --- 247 unchanged lines hidden (view full) --- 353 dev_err(&interface->dev, "Out of memory\n"); 354 goto error_mem; 355 } 356 357 mydev->udev = usb_get_dev(udev); 358 mydev->intf = interface; 359 usb_set_intfdata(interface, mydev); 360 |
361 /* PM */ 362 mydev->shadow_power = 1; /* currently active */ 363 mydev->has_interface_pm = 0; /* have not issued autopm_get */ 364 |
|
354 /*set defaults */ 355 mydev->textmode = 0x02; /* ascii mode */ 356 mydev->mode_msb = 0x06; /* 6 characters */ 357 mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ 358 359 rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp); 360 if (rc) 361 goto error; --- 90 unchanged lines hidden --- | 365 /*set defaults */ 366 mydev->textmode = 0x02; /* ascii mode */ 367 mydev->mode_msb = 0x06; /* 6 characters */ 368 mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ 369 370 rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp); 371 if (rc) 372 goto error; --- 90 unchanged lines hidden --- |