Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: nvec: coding style fixes / add copyright notice

This patch fixes coding style and adds copyright notices.

Signed-off-by: Marc Dietrich <marvin24@gmx.de>
[jak@jak-linux.org: Merge later cleanup into that patch]
Signed-off-by: Julian Andres Klode <jak@jak-linux.org>
Acked-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Marc Dietrich and committed by
Greg Kroah-Hartman
162c7d8c 7974035c

+521 -420
+1 -4
drivers/staging/nvec/TODO
··· 1 1 ToDo list (incomplete, unordered) 2 - - convert mouse, keyboard, and power to platform devices 3 - - add copyright / driver author / license 4 2 - add compile as module support 5 - - move nvec devices to mfd cells? 6 - - adjust to kernel style 7 3 - fix clk usage 8 4 should not be using clk_get_sys(), but clk_get(&pdev->dev, conn) 9 5 where conn is either NULL if the device only has one clock, or 10 6 the device specific name if it has multiple clocks. 7 + - move half of the nvec init stuff to i2c-tegra.c
+138 -97
drivers/staging/nvec/nvec-keytable.h
··· 22 22 */ 23 23 24 24 static unsigned short code_tab_102us[] = { 25 - KEY_GRAVE, // 0x00 25 + /* 0x00 */ 26 + KEY_GRAVE, 26 27 KEY_ESC, 27 28 KEY_1, 28 29 KEY_2, ··· 39 38 KEY_EQUAL, 40 39 KEY_BACKSPACE, 41 40 KEY_TAB, 42 - KEY_Q, // 0x10 41 + /* 0x10 */ 42 + KEY_Q, 43 43 KEY_W, 44 44 KEY_E, 45 45 KEY_R, ··· 56 54 KEY_LEFTCTRL, 57 55 KEY_A, 58 56 KEY_S, 59 - KEY_D, // 0x20 57 + /* 0x20 */ 58 + KEY_D, 60 59 KEY_F, 61 60 KEY_G, 62 61 KEY_H, ··· 73 70 KEY_X, 74 71 KEY_C, 75 72 KEY_V, 76 - KEY_B, // 0x30 73 + /* 0x30 */ 74 + KEY_B, 77 75 KEY_N, 78 76 KEY_M, 79 77 KEY_COMMA, ··· 90 86 KEY_F3, 91 87 KEY_F4, 92 88 KEY_F5, 93 - KEY_F6, // 0x40 89 + /* 0x40 */ 90 + KEY_F6, 94 91 KEY_F7, 95 92 KEY_F8, 96 93 KEY_F9, 97 94 KEY_F10, 98 95 KEY_FN, 99 - 0, //VK_SCROLL 96 + /* VK_SCROLL */ 97 + 0, 100 98 KEY_KP7, 101 99 KEY_KP8, 102 100 KEY_KP9, ··· 108 102 KEY_KP6, 109 103 KEY_KPPLUS, 110 104 KEY_KP1, 111 - KEY_KP2, // 0x50 105 + /* 0x50 */ 106 + KEY_KP2, 112 107 KEY_KP3, 113 108 KEY_KP0, 114 109 KEY_KPDOT, 115 - KEY_MENU, //VK_SNAPSHOT 110 + /* VK_SNAPSHOT */ 111 + KEY_MENU, 116 112 KEY_POWER, 117 - KEY_102ND, //VK_OEM_102 henry+ 0x2B (43) BACKSLASH have been used,change to use 0X56 (86) 118 - KEY_F11, //VK_F11 119 - KEY_F12, //VK_F12 120 - 0, 121 - 0, 122 - 0, 123 - 0, 124 - 0, 125 - 0, 126 - 0, 127 - 0, // 60 113 + /* VK_OEM_102 */ 114 + KEY_102ND, 115 + KEY_F11, 116 + KEY_F12, 128 117 0, 129 118 0, 130 - KEY_SEARCH, // add search key map 131 - 0, 132 119 0, 133 120 0, 134 - 0, 135 - 0, 136 - 0, 137 - 0, 138 - 0, 139 - 0, 140 - 0, 141 - 0, 142 - 0, 143 - 0, // 70 144 121 0, 145 122 0, 146 - KEY_KP5, //73 for JP keyboard '\' key, report 0x4c 147 - 0, 123 + 0, 124 + /* 0x60 */ 148 125 0, 149 126 0, 150 - 0, 151 - 0, 152 - 0, 153 - 0, 154 - 0, 155 - 0, 156 - KEY_KP9, //7d for JP keyboard '|' key, report 0x49 127 + 0, 128 + KEY_SEARCH, 129 + 0, 130 + 0, 131 + 0, 132 + 0, 133 + 0, 134 + 0, 135 + 0, 136 + 0, 137 + 0, 138 + 0, 139 + 0, 140 + 0, 141 + /* 0x70 */ 142 + 0, 143 + 0, 144 + 0, 145 + KEY_KP5, 146 + 0, 147 + 0, 148 + 0, 149 + 0, 150 + 0, 151 + 0, 152 + 0, 153 + 0, 154 + 0, 155 + KEY_KP9, 157 156 }; 158 157 159 158 static unsigned short extcode_tab_us102[] = { ··· 178 167 0, 179 168 0, 180 169 0, 181 - 0, // 0xE0 0x10 182 - 0, 183 - 0, 184 - 0, 185 - 0, 186 - 0, 187 - 0, 188 - 0, 189 - 0, 190 - 0, //VK_MEDIA_NEXT_TRACK, 191 - 0, 192 - 0, 193 - 0, //VK_RETURN, 194 - KEY_RIGHTCTRL, //VK_RCONTROL, 195 - 0, 196 - 0, 197 - KEY_MUTE, // 0xE0 0x20 198 - 0, //VK_LAUNCH_APP1 199 - 0, //VK_MEDIA_PLAY_PAUSE 200 - 0, 201 - 0, //VK_MEDIA_STOP 170 + /* 0x10 */ 202 171 0, 203 172 0, 204 173 0, ··· 188 197 0, 189 198 0, 190 199 0, 200 + /* VK_MEDIA_NEXT_TRACK */ 191 201 0, 192 202 0, 193 - KEY_VOLUMEUP, // 0xE0 0x30 194 203 0, 195 - 0, //VK_BROWSER_HOME 204 + /* VK_RETURN */ 205 + 0, 206 + KEY_RIGHTCTRL, 196 207 0, 197 208 0, 198 - KEY_KPSLASH, //VK_DIVIDE 209 + /* 0x20 */ 210 + KEY_MUTE, 211 + /* VK_LAUNCH_APP1 */ 199 212 0, 200 - KEY_SYSRQ, //VK_SNAPSHOT 201 - KEY_RIGHTALT, //VK_RMENU 202 - 0, //VK_OEM_NV_BACKLIGHT_UP 203 - 0, //VK_OEM_NV_BACKLIGHT_DN 204 - 0, //VK_OEM_NV_BACKLIGHT_AUTOTOGGLE 205 - 0, //VK_OEM_NV_POWER_INFO 206 - 0, //VK_OEM_NV_WIFI_TOGGLE 207 - 0, //VK_OEM_NV_DISPLAY_SELECT 208 - 0, //VK_OEM_NV_AIRPLANE_TOGGLE 209 - 0, //0xE0 0x40 210 - KEY_LEFT, //VK_OEM_NV_RESERVED henry+ for JP keyboard 211 - 0, //VK_OEM_NV_RESERVED 212 - 0, //VK_OEM_NV_RESERVED 213 - 0, //VK_OEM_NV_RESERVED 214 - 0, //VK_OEM_NV_RESERVED 213 + /* VK_MEDIA_PLAY_PAUSE */ 214 + 0, 215 + 0, 216 + /* VK_MEDIA_STOP */ 217 + 0, 218 + 0, 219 + 0, 220 + 0, 221 + 0, 222 + 0, 223 + 0, 224 + 0, 225 + 0, 226 + 0, 227 + 0, 228 + 0, 229 + /* 0x30 */ 230 + KEY_VOLUMEUP, 231 + 0, 232 + /* VK_BROWSER_HOME */ 233 + 0, 234 + 0, 235 + 0, 236 + /* VK_DIVIDE */ 237 + KEY_KPSLASH, 238 + 0, 239 + /* VK_SNAPSHOT */ 240 + KEY_SYSRQ, 241 + /* VK_RMENU */ 242 + KEY_RIGHTALT, 243 + /* VK_OEM_NV_BACKLIGHT_UP */ 244 + 0, 245 + /* VK_OEM_NV_BACKLIGHT_DN */ 246 + 0, 247 + /* VK_OEM_NV_BACKLIGHT_AUTOTOGGLE */ 248 + 0, 249 + /* VK_OEM_NV_POWER_INFO */ 250 + 0, 251 + /* VK_OEM_NV_WIFI_TOGGLE */ 252 + 0, 253 + /* VK_OEM_NV_DISPLAY_SELECT */ 254 + 0, 255 + /* VK_OEM_NV_AIRPLANE_TOGGLE */ 256 + 0, 257 + /* 0x40 */ 258 + 0, 259 + KEY_LEFT, 260 + 0, 261 + 0, 262 + 0, 263 + 0, 215 264 KEY_CANCEL, 216 265 KEY_HOME, 217 266 KEY_UP, 218 - KEY_PAGEUP, //VK_PRIOR 267 + KEY_PAGEUP, 219 268 0, 220 269 KEY_LEFT, 221 270 0, 222 271 KEY_RIGHT, 223 272 0, 224 273 KEY_END, 225 - KEY_DOWN, // 0xE0 0x50 226 - KEY_PAGEDOWN, //VK_NEXT 274 + /* 0x50 */ 275 + KEY_DOWN, 276 + KEY_PAGEDOWN, 227 277 KEY_INSERT, 228 278 KEY_DELETE, 229 279 0, ··· 274 242 0, 275 243 0, 276 244 0, 277 - KEY_LEFTMETA, //VK_LWIN 278 - 0, //VK_RWIN 279 - KEY_ESC, //VK_APPS 280 - KEY_KPMINUS, //for power button workaround 281 - 0, 245 + KEY_LEFTMETA, 246 + 0, 247 + KEY_ESC, 248 + KEY_KPMINUS, 282 249 0, 283 250 0, 284 251 0, 285 252 0, 286 253 0, 287 - 0, //VK_BROWSER_SEARCH 288 - 0, //VK_BROWSER_FAVORITES 289 - 0, //VK_BROWSER_REFRESH 290 - 0, //VK_BROWSER_STOP 291 - 0, //VK_BROWSER_FORWARD 292 - 0, //VK_BROWSER_BACK 293 - 0, //VK_LAUNCH_APP2 294 - 0, //VK_LAUNCH_MAIL 295 - 0, //VK_LAUNCH_MEDIA_SELECT 254 + 0, 255 + /* VK_BROWSER_SEARCH */ 256 + 0, 257 + /* VK_BROWSER_FAVORITES */ 258 + 0, 259 + /* VK_BROWSER_REFRESH */ 260 + 0, 261 + /* VK_BROWSER_STOP */ 262 + 0, 263 + /* VK_BROWSER_FORWARD */ 264 + 0, 265 + /* VK_BROWSER_BACK */ 266 + 0, 267 + /* VK_LAUNCH_APP2 */ 268 + 0, 269 + /* VK_LAUNCH_MAIL */ 270 + 0, 271 + /* VK_LAUNCH_MEDIA_SELECT */ 272 + 0, 296 273 }; 297 274 298 - static unsigned short* code_tabs[] = {code_tab_102us, extcode_tab_us102 }; 275 + static unsigned short *code_tabs[] = { code_tab_102us, extcode_tab_us102 };
+96 -93
drivers/staging/nvec/nvec.c
··· 1 - // #define DEBUG 1 + /* 2 + * NVEC: NVIDIA compliant embedded controller interface 3 + * 4 + * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net> 5 + * 6 + * Authors: Pierre-Hugues Husson <phhusson@free.fr> 7 + * Ilya Petrov <ilya.muromec@gmail.com> 8 + * Marc Dietrich <marvin24@gmx.de> 9 + * 10 + * This file is subject to the terms and conditions of the GNU General Public 11 + * License. See the file "COPYING" in the main directory of this archive 12 + * for more details. 13 + * 14 + */ 2 15 3 - /* ToDo list (incomplete, unorderd) 4 - - convert mouse, keyboard, and power to platform devices 5 - */ 16 + /* #define DEBUG */ 6 17 7 - #include <asm/io.h> 8 18 #include <asm/irq.h> 19 + 9 20 #include <linux/completion.h> 10 21 #include <linux/interrupt.h> 22 + #include <linux/io.h> 11 23 #include <linux/irq.h> 12 24 #include <linux/slab.h> 13 25 #include <linux/gpio.h> ··· 28 16 #include <linux/input.h> 29 17 #include <linux/workqueue.h> 30 18 #include <linux/clk.h> 31 - #include <mach/iomap.h> 32 - #include <mach/clk.h> 19 + 33 20 #include <linux/semaphore.h> 34 21 #include <linux/list.h> 35 22 #include <linux/notifier.h> 36 23 #include <linux/platform_device.h> 37 24 #include <linux/mfd/core.h> 25 + 26 + #include <mach/iomap.h> 27 + #include <mach/clk.h> 28 + 38 29 #include "nvec.h" 39 30 40 - static unsigned char EC_DISABLE_EVENT_REPORTING[] = {'\x04','\x00','\x00'}; 41 - static unsigned char EC_ENABLE_EVENT_REPORTING[] = {'\x04','\x00','\x01'}; 42 - static unsigned char EC_GET_FIRMWARE_VERSION[] = {'\x07','\x15'}; 31 + static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00"; 32 + static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01"; 33 + static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15"; 43 34 44 35 static struct nvec_chip *nvec_power_handle; 45 36 46 37 static struct mfd_cell nvec_devices[] = { 47 38 { 48 - .name = "nvec-kbd", 49 - .id = 1, 39 + .name = "nvec-kbd", 40 + .id = 1, 50 41 }, 51 42 { 52 - .name = "nvec-mouse", 53 - .id = 1, 43 + .name = "nvec-mouse", 44 + .id = 1, 54 45 }, 55 46 { 56 - .name = "nvec-power", 57 - .id = 1, 47 + .name = "nvec-power", 48 + .id = 1, 58 49 }, 59 50 { 60 - .name = "nvec-power", 61 - .id = 2, 51 + .name = "nvec-power", 52 + .id = 2, 62 53 }, 63 54 }; 64 55 65 56 int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb, 66 - unsigned int events) 57 + unsigned int events) 67 58 { 68 59 return atomic_notifier_chain_register(&nvec->notifier_list, nb); 69 60 } 70 61 EXPORT_SYMBOL_GPL(nvec_register_notifier); 71 62 72 - static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type, 73 - void *data) 63 + static int nvec_status_notifier(struct notifier_block *nb, 64 + unsigned long event_type, void *data) 74 65 { 75 66 unsigned char *msg = (unsigned char *)data; 76 67 int i; 77 68 78 - if(event_type != NVEC_CNTL) 69 + if (event_type != NVEC_CNTL) 79 70 return NOTIFY_DONE; 80 71 81 - printk("unhandled msg type %ld, payload: ", event_type); 72 + printk(KERN_WARNING "unhandled msg type %ld, payload: ", event_type); 82 73 for (i = 0; i < msg[1]; i++) 83 74 printk("%0x ", msg[i+2]); 84 75 printk("\n"); ··· 89 74 return NOTIFY_OK; 90 75 } 91 76 92 - void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size) 77 + void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, 78 + short size) 93 79 { 94 80 struct nvec_msg *msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); 95 81 ··· 111 95 { 112 96 struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work); 113 97 114 - if(!list_empty(&nvec->tx_data)) { 98 + if (!list_empty(&nvec->tx_data)) 115 99 gpio_set_value(nvec->gpio, 0); 116 - } 117 100 } 118 101 119 102 static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) 120 103 { 121 104 int i; 122 105 123 - if((msg->data[0] & 1<<7) == 0 && msg->data[3]) { 124 - dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", msg->data[0], 125 - msg->data[1], msg->data[2], msg->data[3]); 106 + if ((msg->data[0] & 1 << 7) == 0 && msg->data[3]) { 107 + dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", 108 + msg->data[0], msg->data[1], msg->data[2], msg->data[3]); 126 109 return -EINVAL; 127 110 } 128 111 129 - if ((msg->data[0] >> 7 ) == 1 && (msg->data[0] & 0x0f) == 5) 130 - { 112 + if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) { 131 113 dev_warn(nvec->dev, "ec system event "); 132 - for (i=0; i < msg->data[1]; i++) 114 + for (i = 0; i < msg->data[1]; i++) 133 115 dev_warn(nvec->dev, "%02x ", msg->data[2+i]); 134 116 dev_warn(nvec->dev, "\n"); 135 117 } 136 118 137 - atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data); 119 + atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, 120 + msg->data); 138 121 139 122 return 0; 140 123 } 141 124 142 - static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, unsigned char *data, short size) 125 + static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, 126 + const unsigned char *data, short size) 143 127 { 144 128 down(&nvec->sync_write_mutex); 145 129 146 130 nvec->sync_write_pending = (data[1] << 8) + data[0]; 147 131 nvec_write_async(nvec, data, size); 148 132 149 - dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", nvec->sync_write_pending); 133 + dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", 134 + nvec->sync_write_pending); 150 135 wait_for_completion(&nvec->sync_write); 151 136 dev_dbg(nvec->dev, "nvec_sync_write: pong!\n"); 152 137 ··· 162 145 struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work); 163 146 struct nvec_msg *msg; 164 147 165 - while(!list_empty(&nvec->rx_data)) 166 - { 148 + while (!list_empty(&nvec->rx_data)) { 167 149 msg = list_first_entry(&nvec->rx_data, struct nvec_msg, node); 168 150 list_del_init(&msg->node); 169 151 170 - if(nvec->sync_write_pending == (msg->data[2] << 8) + msg->data[0]) 171 - { 152 + if (nvec->sync_write_pending == 153 + (msg->data[2] << 8) + msg->data[0]) { 172 154 dev_dbg(nvec->dev, "sync write completed!\n"); 173 155 nvec->sync_write_pending = 0; 174 156 nvec->last_sync_msg = msg; 175 157 complete(&nvec->sync_write); 176 158 } else { 177 159 parse_msg(nvec, msg); 178 - if((!msg) || (!msg->data)) 179 - dev_warn(nvec->dev, "attempt access zero pointer\n"); 160 + if ((!msg) || (!msg->data)) 161 + dev_warn(nvec->dev, 162 + "attempt access zero pointer\n"); 180 163 else { 181 164 kfree(msg->data); 182 165 kfree(msg); ··· 196 179 197 180 status = readl(base + I2C_SL_STATUS); 198 181 199 - if(!(status & I2C_SL_IRQ)) 200 - { 182 + if (!(status & I2C_SL_IRQ)) { 201 183 dev_warn(nvec->dev, "nvec Spurious IRQ\n"); 202 - //Yup, handled. ahum. 203 184 goto handled; 204 185 } 205 - if(status & END_TRANS && !(status & RCVD)) 206 - { 207 - //Reenable IRQ only when even has been sent 208 - //printk("Write sequence ended !\n"); 209 - //parse_msg(nvec); 186 + if (status & END_TRANS && !(status & RCVD)) { 210 187 nvec->state = NVEC_WAIT; 211 - if(nvec->rx->size > 1) 212 - { 188 + if (nvec->rx->size > 1) { 213 189 list_add_tail(&nvec->rx->node, &nvec->rx_data); 214 190 schedule_work(&nvec->rx_work); 215 191 } else { ··· 210 200 kfree(nvec->rx); 211 201 } 212 202 return IRQ_HANDLED; 213 - } else if(status & RNW) 214 - { 215 - // Work around for AP20 New Slave Hw Bug. Give 1us extra. 216 - // nvec/smbus/nvec_i2c_transport.c in NV`s crap for reference 217 - if(status & RCVD) 203 + } else if (status & RNW) { 204 + if (status & RCVD) 218 205 udelay(3); 219 206 220 - if(status & RCVD) 221 - { 207 + if (status & RCVD) 222 208 nvec->state = NVEC_WRITE; 223 - //Master wants something from us. New communication 224 - // dev_dbg(nvec->dev, "New read comm!\n"); 225 - } else { 226 - //Master wants something from us from a communication we've already started 227 - // dev_dbg(nvec->dev, "Read comm cont !\n"); 228 - } 229 - //if(msg_pos<msg_size) { 230 - if(list_empty(&nvec->tx_data)) 231 - { 209 + 210 + if (list_empty(&nvec->tx_data)) { 232 211 dev_err(nvec->dev, "nvec empty tx - sending no-op\n"); 233 212 to_send = 0x8a; 234 213 nvec_write_async(nvec, "\x07\x02", 2); 235 - // to_send = 0x01; 236 214 } else { 237 - msg = list_first_entry(&nvec->tx_data, struct nvec_msg, node); 238 - if(msg->pos < msg->size) { 215 + msg = 216 + list_first_entry(&nvec->tx_data, struct nvec_msg, 217 + node); 218 + if (msg->pos < msg->size) { 239 219 to_send = msg->data[msg->pos]; 240 220 msg->pos++; 241 221 } else { 242 - dev_err(nvec->dev, "nvec crap! %d\n", msg->size); 222 + dev_err(nvec->dev, "nvec crap! %d\n", 223 + msg->size); 243 224 to_send = 0x01; 244 225 } 245 226 246 - if(msg->pos >= msg->size) 247 - { 227 + if (msg->pos >= msg->size) { 248 228 list_del_init(&msg->node); 249 229 kfree(msg->data); 250 230 kfree(msg); ··· 251 251 goto handled; 252 252 } else { 253 253 received = readl(base + I2C_SL_RCVD); 254 - //Workaround? 255 - if(status & RCVD) { 254 + 255 + if (status & RCVD) { 256 256 writel(0, base + I2C_SL_RCVD); 257 257 goto handled; 258 258 } 259 259 260 - if (nvec->state == NVEC_WAIT) 261 - { 260 + if (nvec->state == NVEC_WAIT) { 262 261 nvec->state = NVEC_READ; 263 262 msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT); 264 263 msg->data = kzalloc(32, GFP_NOWAIT); ··· 271 272 msg->data[msg->pos] = received; 272 273 msg->pos++; 273 274 msg->size = msg->pos; 274 - dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", received, msg->pos); 275 + dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", 276 + received, msg->pos); 275 277 } 276 278 handled: 277 279 return IRQ_HANDLED; ··· 318 318 void __iomem *base; 319 319 320 320 nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL); 321 - if(nvec == NULL) { 321 + if (nvec == NULL) { 322 322 dev_err(&pdev->dev, "failed to reserve memory\n"); 323 323 return -ENOMEM; 324 324 } ··· 367 367 368 368 /* Set the gpio to low when we've got something to say */ 369 369 err = gpio_request(nvec->gpio, "nvec gpio"); 370 - if(err < 0) 370 + if (err < 0) 371 371 dev_err(nvec->dev, "couldn't request gpio\n"); 372 372 373 373 ATOMIC_INIT_NOTIFIER_HEAD(&nvec->notifier_list); ··· 392 392 393 393 /* enable event reporting */ 394 394 nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 395 - sizeof(EC_ENABLE_EVENT_REPORTING)); 395 + sizeof(EC_ENABLE_EVENT_REPORTING)); 396 396 397 397 nvec->nvec_status_notifier.notifier_call = nvec_status_notifier; 398 398 nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0); ··· 402 402 403 403 /* Get Firmware Version */ 404 404 msg = nvec_write_sync(nvec, EC_GET_FIRMWARE_VERSION, 405 - sizeof(EC_GET_FIRMWARE_VERSION)); 405 + sizeof(EC_GET_FIRMWARE_VERSION)); 406 406 407 407 dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", 408 - msg->data[4], msg->data[5], msg->data[6], msg->data[7]); 408 + msg->data[4], msg->data[5], msg->data[6], msg->data[7]); 409 409 410 410 kfree(msg->data); 411 411 kfree(msg); 412 412 413 413 ret = mfd_add_devices(nvec->dev, -1, nvec_devices, 414 - ARRAY_SIZE(nvec_devices), base, 0); 415 - if(ret) 414 + ARRAY_SIZE(nvec_devices), base, 0); 415 + if (ret) 416 416 dev_err(nvec->dev, "error adding subdevices\n"); 417 417 418 418 /* unmute speakers? */ ··· 460 460 return 0; 461 461 } 462 462 463 - static int tegra_nvec_resume(struct platform_device *pdev) { 464 - 463 + static int tegra_nvec_resume(struct platform_device *pdev) 464 + { 465 465 struct nvec_chip *nvec = platform_get_drvdata(pdev); 466 466 467 467 dev_dbg(nvec->dev, "resuming\n"); ··· 476 476 #define tegra_nvec_resume NULL 477 477 #endif 478 478 479 - static struct platform_driver nvec_device_driver = 480 - { 481 - .probe = tegra_nvec_probe, 482 - .remove = __devexit_p(tegra_nvec_remove), 479 + static struct platform_driver nvec_device_driver = { 480 + .probe = tegra_nvec_probe, 481 + .remove = __devexit_p(tegra_nvec_remove), 483 482 .suspend = tegra_nvec_suspend, 484 - .resume = tegra_nvec_resume, 485 - .driver = { 483 + .resume = tegra_nvec_resume, 484 + .driver = { 486 485 .name = "nvec", 487 486 .owner = THIS_MODULE, 488 487 } ··· 493 494 } 494 495 495 496 module_init(tegra_nvec_init); 497 + 496 498 MODULE_ALIAS("platform:nvec"); 499 + MODULE_DESCRIPTION("NVIDIA compliant embedded controller interface"); 500 + MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>"); 501 + MODULE_LICENSE("GPL");
+29 -9
drivers/staging/nvec/nvec.h
··· 1 + /* 2 + * NVEC: NVIDIA compliant embedded controller interface 3 + * 4 + * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net> 5 + * 6 + * Authors: Pierre-Hugues Husson <phhusson@free.fr> 7 + * Ilya Petrov <ilya.muromec@gmail.com> 8 + * Marc Dietrich <marvin24@gmx.de> 9 + * 10 + * This file is subject to the terms and conditions of the GNU General Public 11 + * License. See the file "COPYING" in the main directory of this archive 12 + * for more details. 13 + * 14 + */ 15 + 1 16 #ifndef __LINUX_MFD_NVEC 2 17 #define __LINUX_MFD_NVEC 3 18 ··· 32 17 } how_care; 33 18 34 19 typedef enum { 35 - NVEC_SYS=1, 20 + NVEC_SYS = 1, 36 21 NVEC_BAT, 37 22 NVEC_KBD = 5, 38 23 NVEC_PS2, ··· 42 27 } nvec_event; 43 28 44 29 typedef enum { 45 - NVEC_WAIT, 46 - NVEC_READ, 47 - NVEC_WRITE 30 + NVEC_WAIT, 31 + NVEC_READ, 32 + NVEC_WRITE 48 33 } nvec_state; 49 34 50 35 struct nvec_msg { ··· 79 64 struct work_struct rx_work, tx_work; 80 65 struct nvec_msg *rx, *tx; 81 66 82 - /* sync write stuff */ 67 + /* sync write stuff */ 83 68 struct semaphore sync_write_mutex; 84 69 struct completion sync_write; 85 70 u16 sync_write_pending; 86 71 struct nvec_msg *last_sync_msg; 87 72 }; 88 73 89 - extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size); 74 + extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, 75 + short size); 90 76 91 77 extern int nvec_register_notifier(struct nvec_chip *nvec, 92 - struct notifier_block *nb, unsigned int events); 78 + struct notifier_block *nb, 79 + unsigned int events); 93 80 94 81 extern int nvec_unregister_notifier(struct device *dev, 95 - struct notifier_block *nb, unsigned int events); 82 + struct notifier_block *nb, 83 + unsigned int events); 96 84 97 - const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data)); 85 + const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, 86 + how_care care_resp, 87 + void (*rt_handler) (unsigned char *data)); 98 88 99 89 #define I2C_CNFG 0x00 100 90 #define I2C_CNFG_PACKET_MODE_EN (1<<10)
+28 -8
drivers/staging/nvec/nvec_kbd.c
··· 1 + /* 2 + * nvec_kbd: keyboard driver for a NVIDIA compliant embedded controller 3 + * 4 + * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net> 5 + * 6 + * Authors: Pierre-Hugues Husson <phhusson@free.fr> 7 + * Marc Dietrich <marvin24@gmx.de> 8 + * 9 + * This file is subject to the terms and conditions of the GNU General Public 10 + * License. See the file "COPYING" in the main directory of this archive 11 + * for more details. 12 + * 13 + */ 14 + 1 15 #include <linux/module.h> 2 16 #include <linux/slab.h> 3 17 #include <linux/input.h> 4 18 #include <linux/delay.h> 5 19 #include <linux/platform_device.h> 20 + 6 21 #include "nvec-keytable.h" 7 22 #include "nvec.h" 8 23 9 24 #define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} 10 25 11 26 static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) 12 - + ARRAY_SIZE(extcode_tab_us102)]; 27 + + ARRAY_SIZE(extcode_tab_us102)]; 13 28 14 29 struct nvec_keys { 15 30 struct input_dev *input; ··· 35 20 static struct nvec_keys keys_dev; 36 21 37 22 static int nvec_keys_notifier(struct notifier_block *nb, 38 - unsigned long event_type, void *data) 23 + unsigned long event_type, void *data) 39 24 { 40 25 int code, state; 41 26 unsigned char *msg = (unsigned char *)data; ··· 53 38 code = msg[1] & 0x7f; 54 39 state = msg[1] & 0x80; 55 40 56 - input_report_key(keys_dev.input, code_tabs[_size][code], !state); 41 + input_report_key(keys_dev.input, code_tabs[_size][code], 42 + !state); 57 43 input_sync(keys_dev.input); 58 44 59 45 return NOTIFY_STOP; ··· 64 48 } 65 49 66 50 static int nvec_kbd_event(struct input_dev *dev, unsigned int type, 67 - unsigned int code, int value) 51 + unsigned int code, int value) 68 52 { 69 53 unsigned char buf[] = ACK_KBD_EVENT; 70 54 struct nvec_chip *nvec = keys_dev.nvec; ··· 141 125 } 142 126 143 127 static struct platform_driver nvec_kbd_driver = { 144 - .probe = nvec_kbd_probe, 145 - .driver = { 146 - .name = "nvec-kbd", 147 - .owner = THIS_MODULE, 128 + .probe = nvec_kbd_probe, 129 + .driver = { 130 + .name = "nvec-kbd", 131 + .owner = THIS_MODULE, 148 132 }, 149 133 }; 150 134 ··· 154 138 } 155 139 156 140 module_init(nvec_kbd_init); 141 + 142 + MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>"); 143 + MODULE_DESCRIPTION("NVEC keyboard driver"); 144 + MODULE_LICENSE("GPL");
+178 -170
drivers/staging/nvec/nvec_power.c
··· 1 + /* 2 + * nvec_power: power supply driver for a NVIDIA compliant embedded controller 3 + * 4 + * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net> 5 + * 6 + * Authors: Ilya Petrov <ilya.muromec@gmail.com> 7 + * Marc Dietrich <marvin24@gmx.de> 8 + * 9 + * This file is subject to the terms and conditions of the GNU General Public 10 + * License. See the file "COPYING" in the main directory of this archive 11 + * for more details. 12 + * 13 + */ 14 + 1 15 #include <linux/module.h> 2 16 #include <linux/platform_device.h> 3 17 #include <linux/err.h> ··· 19 5 #include <linux/slab.h> 20 6 #include <linux/workqueue.h> 21 7 #include <linux/delay.h> 8 + 22 9 #include "nvec.h" 23 10 24 - struct nvec_power 25 - { 11 + struct nvec_power { 26 12 struct notifier_block notifier; 27 13 struct delayed_work poller; 28 14 struct nvec_chip *nvec; ··· 72 58 u8 length; 73 59 u8 sub_type; 74 60 u8 status; 75 - union { /* payload */ 61 + /* payload */ 62 + union { 76 63 char plc[30]; 77 64 u16 plu; 78 65 s16 pls; ··· 84 69 static struct power_supply nvec_psy; 85 70 86 71 static int nvec_power_notifier(struct notifier_block *nb, 87 - unsigned long event_type, void *data) 72 + unsigned long event_type, void *data) 88 73 { 89 - struct nvec_power *power = container_of(nb, struct nvec_power, notifier); 74 + struct nvec_power *power = 75 + container_of(nb, struct nvec_power, notifier); 90 76 struct bat_response *res = (struct bat_response *)data; 91 77 92 78 if (event_type != NVEC_SYS) 93 79 return NOTIFY_DONE; 94 80 95 - if(res->sub_type == 0) 96 - { 97 - if (power->on != res->plu) 98 - { 81 + if (res->sub_type == 0) { 82 + if (power->on != res->plu) { 99 83 power->on = res->plu; 100 84 power_supply_changed(&nvec_psy); 101 85 } ··· 103 89 return NOTIFY_OK; 104 90 } 105 91 106 - static const int bat_init[] = 107 - { 92 + static const int bat_init[] = { 108 93 LAST_FULL_CHARGE_CAPACITY, DESIGN_CAPACITY, CRITICAL_CAPACITY, 109 94 MANUFACTURER, MODEL, TYPE, 110 95 }; ··· 113 100 int i; 114 101 char buf[] = { '\x02', '\x00' }; 115 102 116 - for (i = 0; i < ARRAY_SIZE(bat_init); i++) 117 - { 103 + for (i = 0; i < ARRAY_SIZE(bat_init); i++) { 118 104 buf[1] = bat_init[i]; 119 105 nvec_write_async(power->nvec, buf, 2); 120 106 } 121 107 } 122 108 123 109 static int nvec_power_bat_notifier(struct notifier_block *nb, 124 - unsigned long event_type, void *data) 110 + unsigned long event_type, void *data) 125 111 { 126 - struct nvec_power *power = container_of(nb, struct nvec_power, notifier); 112 + struct nvec_power *power = 113 + container_of(nb, struct nvec_power, notifier); 127 114 struct bat_response *res = (struct bat_response *)data; 128 115 int status_changed = 0; 129 116 130 117 if (event_type != NVEC_BAT) 131 118 return NOTIFY_DONE; 132 119 133 - switch(res->sub_type) 134 - { 135 - case SLOT_STATUS: 136 - if (res->plc[0] & 1) 137 - { 138 - if (power->bat_present == 0) 139 - { 140 - status_changed = 1; 141 - get_bat_mfg_data(power); 142 - } 120 + switch (res->sub_type) { 121 + case SLOT_STATUS: 122 + if (res->plc[0] & 1) { 123 + if (power->bat_present == 0) { 124 + status_changed = 1; 125 + get_bat_mfg_data(power); 126 + } 143 127 144 - power->bat_present = 1; 128 + power->bat_present = 1; 145 129 146 - switch ((res->plc[0] >> 1) & 3) 147 - { 148 - case 0: 149 - power->bat_status = POWER_SUPPLY_STATUS_NOT_CHARGING; 150 - break; 151 - case 1: 152 - power->bat_status = POWER_SUPPLY_STATUS_CHARGING; 153 - break; 154 - case 2: 155 - power->bat_status = POWER_SUPPLY_STATUS_DISCHARGING; 156 - break; 157 - default: 158 - power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; 159 - } 160 - } else { 161 - if (power->bat_present == 1) 162 - status_changed = 1; 163 - 164 - power->bat_present = 0; 130 + switch ((res->plc[0] >> 1) & 3) { 131 + case 0: 132 + power->bat_status = 133 + POWER_SUPPLY_STATUS_NOT_CHARGING; 134 + break; 135 + case 1: 136 + power->bat_status = 137 + POWER_SUPPLY_STATUS_CHARGING; 138 + break; 139 + case 2: 140 + power->bat_status = 141 + POWER_SUPPLY_STATUS_DISCHARGING; 142 + break; 143 + default: 165 144 power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; 166 145 } 167 - power->bat_cap = res->plc[1]; 168 - if (status_changed) 169 - power_supply_changed(&nvec_bat_psy); 170 - break; 171 - case VOLTAGE: 172 - power->bat_voltage_now = res->plu * 1000; 173 - break; 174 - case TIME_REMAINING: 175 - power->time_remain = res->plu * 3600; 176 - break; 177 - case CURRENT: 178 - power->bat_current_now = res->pls * 1000; 179 - break; 180 - case AVERAGE_CURRENT: 181 - power->bat_current_avg = res->pls * 1000; 182 - break; 183 - case CAPACITY_REMAINING: 184 - power->capacity_remain = res->plu * 1000; 185 - break; 186 - case LAST_FULL_CHARGE_CAPACITY: 187 - power->charge_last_full = res->plu * 1000; 188 - break; 189 - case DESIGN_CAPACITY: 190 - power->charge_full_design = res->plu * 1000; 191 - break; 192 - case CRITICAL_CAPACITY: 193 - power->critical_capacity = res->plu * 1000; 194 - break; 195 - case TEMPERATURE: 196 - power->bat_temperature = res->plu - 2732; 197 - break; 198 - case MANUFACTURER: 199 - memcpy(power->bat_manu, &res->plc, res->length-2); 200 - power->bat_model[res->length-2] = '\0'; 201 - break; 202 - case MODEL: 203 - memcpy(power->bat_model, &res->plc, res->length-2); 204 - power->bat_model[res->length-2] = '\0'; 205 - break; 206 - case TYPE: 207 - memcpy(power->bat_type, &res->plc, res->length-2); 208 - power->bat_type[res->length-2] = '\0'; 209 - /* this differs a little from the spec 210 - fill in more if you find some */ 211 - if (!strncmp(power->bat_type, "Li", 30)) 212 - power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION; 213 - else 214 - power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 215 - break; 216 - default: 217 - return NOTIFY_STOP; 146 + } else { 147 + if (power->bat_present == 1) 148 + status_changed = 1; 149 + 150 + power->bat_present = 0; 151 + power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN; 152 + } 153 + power->bat_cap = res->plc[1]; 154 + if (status_changed) 155 + power_supply_changed(&nvec_bat_psy); 156 + break; 157 + case VOLTAGE: 158 + power->bat_voltage_now = res->plu * 1000; 159 + break; 160 + case TIME_REMAINING: 161 + power->time_remain = res->plu * 3600; 162 + break; 163 + case CURRENT: 164 + power->bat_current_now = res->pls * 1000; 165 + break; 166 + case AVERAGE_CURRENT: 167 + power->bat_current_avg = res->pls * 1000; 168 + break; 169 + case CAPACITY_REMAINING: 170 + power->capacity_remain = res->plu * 1000; 171 + break; 172 + case LAST_FULL_CHARGE_CAPACITY: 173 + power->charge_last_full = res->plu * 1000; 174 + break; 175 + case DESIGN_CAPACITY: 176 + power->charge_full_design = res->plu * 1000; 177 + break; 178 + case CRITICAL_CAPACITY: 179 + power->critical_capacity = res->plu * 1000; 180 + break; 181 + case TEMPERATURE: 182 + power->bat_temperature = res->plu - 2732; 183 + break; 184 + case MANUFACTURER: 185 + memcpy(power->bat_manu, &res->plc, res->length - 2); 186 + power->bat_model[res->length - 2] = '\0'; 187 + break; 188 + case MODEL: 189 + memcpy(power->bat_model, &res->plc, res->length - 2); 190 + power->bat_model[res->length - 2] = '\0'; 191 + break; 192 + case TYPE: 193 + memcpy(power->bat_type, &res->plc, res->length - 2); 194 + power->bat_type[res->length - 2] = '\0'; 195 + /* this differs a little from the spec 196 + fill in more if you find some */ 197 + if (!strncmp(power->bat_type, "Li", 30)) 198 + power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION; 199 + else 200 + power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 201 + break; 202 + default: 203 + return NOTIFY_STOP; 218 204 } 219 205 220 206 return NOTIFY_STOP; 221 207 } 222 208 223 209 static int nvec_power_get_property(struct power_supply *psy, 224 - enum power_supply_property psp, 225 - union power_supply_propval *val) 210 + enum power_supply_property psp, 211 + union power_supply_propval *val) 226 212 { 227 213 struct nvec_power *power = dev_get_drvdata(psy->dev->parent); 228 214 switch (psp) { ··· 235 223 } 236 224 237 225 static int nvec_battery_get_property(struct power_supply *psy, 238 - enum power_supply_property psp, 239 - union power_supply_propval *val) 226 + enum power_supply_property psp, 227 + union power_supply_propval *val) 240 228 { 241 229 struct nvec_power *power = dev_get_drvdata(psy->dev->parent); 242 230 243 - switch(psp) 244 - { 245 - case POWER_SUPPLY_PROP_STATUS: 246 - val->intval = power->bat_status; 247 - break; 248 - case POWER_SUPPLY_PROP_CAPACITY: 249 - val->intval = power->bat_cap; 250 - break; 251 - case POWER_SUPPLY_PROP_PRESENT: 252 - val->intval = power->bat_present; 253 - break; 254 - case POWER_SUPPLY_PROP_VOLTAGE_NOW: 255 - val->intval = power->bat_voltage_now; 256 - break; 257 - case POWER_SUPPLY_PROP_CURRENT_NOW: 258 - val->intval = power->bat_current_now; 259 - break; 260 - case POWER_SUPPLY_PROP_CURRENT_AVG: 261 - val->intval = power->bat_current_avg; 262 - break; 263 - case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: 264 - val->intval = power->time_remain; 265 - break; 266 - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 267 - val->intval = power->charge_full_design; 268 - break; 269 - case POWER_SUPPLY_PROP_CHARGE_FULL: 270 - val->intval = power->charge_last_full; 271 - break; 272 - case POWER_SUPPLY_PROP_CHARGE_EMPTY: 273 - val->intval = power->critical_capacity; 274 - break; 275 - case POWER_SUPPLY_PROP_CHARGE_NOW: 276 - val->intval = power->capacity_remain; 277 - break; 278 - case POWER_SUPPLY_PROP_TEMP: 279 - val->intval = power->bat_temperature; 280 - break; 281 - case POWER_SUPPLY_PROP_MANUFACTURER: 282 - val->strval = power->bat_manu; 283 - break; 284 - case POWER_SUPPLY_PROP_MODEL_NAME: 285 - val->strval = power->bat_model; 286 - break; 287 - case POWER_SUPPLY_PROP_TECHNOLOGY: 288 - val->intval = power->bat_type_enum; 289 - break; 290 - default: 291 - return -EINVAL; 292 - } 231 + switch (psp) { 232 + case POWER_SUPPLY_PROP_STATUS: 233 + val->intval = power->bat_status; 234 + break; 235 + case POWER_SUPPLY_PROP_CAPACITY: 236 + val->intval = power->bat_cap; 237 + break; 238 + case POWER_SUPPLY_PROP_PRESENT: 239 + val->intval = power->bat_present; 240 + break; 241 + case POWER_SUPPLY_PROP_VOLTAGE_NOW: 242 + val->intval = power->bat_voltage_now; 243 + break; 244 + case POWER_SUPPLY_PROP_CURRENT_NOW: 245 + val->intval = power->bat_current_now; 246 + break; 247 + case POWER_SUPPLY_PROP_CURRENT_AVG: 248 + val->intval = power->bat_current_avg; 249 + break; 250 + case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: 251 + val->intval = power->time_remain; 252 + break; 253 + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 254 + val->intval = power->charge_full_design; 255 + break; 256 + case POWER_SUPPLY_PROP_CHARGE_FULL: 257 + val->intval = power->charge_last_full; 258 + break; 259 + case POWER_SUPPLY_PROP_CHARGE_EMPTY: 260 + val->intval = power->critical_capacity; 261 + break; 262 + case POWER_SUPPLY_PROP_CHARGE_NOW: 263 + val->intval = power->capacity_remain; 264 + break; 265 + case POWER_SUPPLY_PROP_TEMP: 266 + val->intval = power->bat_temperature; 267 + break; 268 + case POWER_SUPPLY_PROP_MANUFACTURER: 269 + val->strval = power->bat_manu; 270 + break; 271 + case POWER_SUPPLY_PROP_MODEL_NAME: 272 + val->strval = power->bat_model; 273 + break; 274 + case POWER_SUPPLY_PROP_TECHNOLOGY: 275 + val->intval = power->bat_type_enum; 276 + break; 277 + default: 278 + return -EINVAL; 279 + } 293 280 return 0; 294 281 } 295 282 ··· 321 310 }; 322 311 323 312 static struct power_supply nvec_bat_psy = { 324 - .name = "battery", 325 - .type = POWER_SUPPLY_TYPE_BATTERY, 326 - .properties = nvec_battery_props, 327 - .num_properties = ARRAY_SIZE(nvec_battery_props), 328 - .get_property = nvec_battery_get_property, 313 + .name = "battery", 314 + .type = POWER_SUPPLY_TYPE_BATTERY, 315 + .properties = nvec_battery_props, 316 + .num_properties = ARRAY_SIZE(nvec_battery_props), 317 + .get_property = nvec_battery_get_property, 329 318 }; 330 319 331 320 static struct power_supply nvec_psy = { ··· 338 327 .get_property = nvec_power_get_property, 339 328 }; 340 329 341 - static int counter = 0; 342 - static int const bat_iter[] = 343 - { 330 + static int counter; 331 + static int const bat_iter[] = { 344 332 SLOT_STATUS, VOLTAGE, CURRENT, CAPACITY_REMAINING, 345 333 #ifdef EC_FULL_DIAG 346 334 AVERAGE_CURRENT, TEMPERATURE, TIME_REMAINING, ··· 350 340 { 351 341 char buf[] = { '\x01', '\x00' }; 352 342 struct nvec_power *power = container_of(work, struct nvec_power, 353 - poller.work); 343 + poller.work); 354 344 355 345 if (counter >= ARRAY_SIZE(bat_iter)) 356 346 counter = 0; ··· 361 351 362 352 /* select a battery request function via round robin 363 353 doing it all at once seems to overload the power supply */ 364 - buf[0] = '\x02'; /* battery */ 365 - buf[1] = bat_iter[counter++]; 354 + buf[0] = '\x02'; /* battery */ 355 + buf[1] = bat_iter[counter++]; 366 356 nvec_write_async(power->nvec, buf, 2); 367 - 368 - // printk("%02x %02x\n", buf[0], buf[1]); 369 357 370 358 schedule_delayed_work(to_delayed_work(work), msecs_to_jiffies(5000)); 371 359 }; ··· 371 363 static int __devinit nvec_power_probe(struct platform_device *pdev) 372 364 { 373 365 struct power_supply *psy; 374 - struct nvec_power *power = kzalloc(sizeof(struct nvec_power), GFP_NOWAIT); 366 + struct nvec_power *power = 367 + kzalloc(sizeof(struct nvec_power), GFP_NOWAIT); 375 368 struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); 376 369 377 370 dev_set_drvdata(&pdev->dev, power); ··· 390 381 case BAT: 391 382 psy = &nvec_bat_psy; 392 383 393 - power->notifier.notifier_call = nvec_power_bat_notifier; 384 + power->notifier.notifier_call = nvec_power_bat_notifier; 394 385 break; 395 386 default: 396 387 kfree(power); ··· 407 398 408 399 static struct platform_driver nvec_power_driver = { 409 400 .probe = nvec_power_probe, 410 - // .remove = __devexit_p(nvec_power_remove), 411 401 .driver = { 412 - .name = "nvec-power", 413 - .owner = THIS_MODULE, 414 - } 402 + .name = "nvec-power", 403 + .owner = THIS_MODULE, 404 + } 415 405 }; 416 406 417 - static int __init nvec_power_init(void) 407 + static int __init nvec_power_init(void) 418 408 { 419 409 return platform_driver_register(&nvec_power_driver); 420 410 }
+51 -39
drivers/staging/nvec/nvec_ps2.c
··· 1 + /* 2 + * nvec_ps2: mouse driver for a NVIDIA compliant embedded controller 3 + * 4 + * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net> 5 + * 6 + * Authors: Pierre-Hugues Husson <phhusson@free.fr> 7 + * Ilya Petrov <ilya.muromec@gmail.com> 8 + * Marc Dietrich <marvin24@gmx.de> 9 + * 10 + * This file is subject to the terms and conditions of the GNU General Public 11 + * License. See the file "COPYING" in the main directory of this archive 12 + * for more details. 13 + * 14 + */ 15 + 1 16 #include <linux/module.h> 2 17 #include <linux/slab.h> 3 18 #include <linux/serio.h> 4 19 #include <linux/delay.h> 5 20 #include <linux/platform_device.h> 21 + 6 22 #include "nvec.h" 7 23 8 - #define START_STREAMING {'\x06','\x03','\x01'} 9 - #define STOP_STREAMING {'\x06','\x04'} 10 - #define SEND_COMMAND {'\x06','\x01','\xf4','\x01'} 24 + #define START_STREAMING {'\x06', '\x03', '\x01'} 25 + #define STOP_STREAMING {'\x06', '\x04'} 26 + #define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'} 11 27 12 - struct nvec_ps2 13 - { 28 + static const unsigned char MOUSE_RESET[] = {'\x06', '\x01', '\xff', '\x03'}; 29 + 30 + struct nvec_ps2 { 14 31 struct serio *ser_dev; 15 32 struct notifier_block notifier; 16 33 struct nvec_chip *nvec; ··· 48 31 nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); 49 32 } 50 33 51 - /* is this really needed? 52 - static void nvec_resp_handler(unsigned char *data) { 53 - serio_interrupt(ser_dev, data[4], 0); 54 - } 55 - */ 56 - 57 34 static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) 58 35 { 59 36 unsigned char buf[] = SEND_COMMAND; ··· 61 50 } 62 51 63 52 static int nvec_ps2_notifier(struct notifier_block *nb, 64 - unsigned long event_type, void *data) 53 + unsigned long event_type, void *data) 65 54 { 66 55 int i; 67 56 unsigned char *msg = (unsigned char *)data; 68 57 69 58 switch (event_type) { 70 - case NVEC_PS2_EVT: 71 - serio_interrupt(ps2_dev.ser_dev, msg[2], 0); 72 - return NOTIFY_STOP; 59 + case NVEC_PS2_EVT: 60 + serio_interrupt(ps2_dev.ser_dev, msg[2], 0); 61 + return NOTIFY_STOP; 73 62 74 - case NVEC_PS2: 75 - if (msg[2] == 1) 76 - for(i = 0; i < (msg[1] - 2); i++) 77 - serio_interrupt(ps2_dev.ser_dev, msg[i+4], 0); 78 - else if (msg[1] != 2) /* !ack */ 79 - { 80 - printk("nvec_ps2: unhandled mouse event "); 81 - for(i = 0; i <= (msg[1]+1); i++) 82 - printk("%02x ", msg[i]); 83 - printk(".\n"); 84 - } 63 + case NVEC_PS2: 64 + if (msg[2] == 1) 65 + for (i = 0; i < (msg[1] - 2); i++) 66 + serio_interrupt(ps2_dev.ser_dev, msg[i + 4], 0); 67 + else if (msg[1] != 2) { /* !ack */ 68 + print_hex_dump(KERN_WARNING, "unhandled mouse event: ", 69 + DUMP_PREFIX_NONE, 16, 1, 70 + msg, msg[1] + 2, true); 71 + } 85 72 86 - return NOTIFY_STOP; 73 + return NOTIFY_STOP; 87 74 } 88 75 89 76 return NOTIFY_DONE; 90 77 } 91 - 92 78 93 79 static int __devinit nvec_mouse_probe(struct platform_device *pdev) 94 80 { 95 81 struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); 96 82 struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL); 97 83 98 - ser_dev->id.type=SERIO_8042; 99 - ser_dev->write=ps2_sendcommand; 100 - ser_dev->open=ps2_startstreaming; 101 - ser_dev->close=ps2_stopstreaming; 84 + ser_dev->id.type = SERIO_8042; 85 + ser_dev->write = ps2_sendcommand; 86 + ser_dev->open = ps2_startstreaming; 87 + ser_dev->close = ps2_stopstreaming; 102 88 103 - strlcpy(ser_dev->name, "NVEC PS2", sizeof(ser_dev->name)); 104 - strlcpy(ser_dev->phys, "NVEC I2C slave", sizeof(ser_dev->phys)); 89 + strlcpy(ser_dev->name, "nvec mouse", sizeof(ser_dev->name)); 90 + strlcpy(ser_dev->phys, "nvec", sizeof(ser_dev->phys)); 105 91 106 92 ps2_dev.ser_dev = ser_dev; 107 93 ps2_dev.notifier.notifier_call = nvec_ps2_notifier; ··· 108 100 serio_register_port(ser_dev); 109 101 110 102 /* mouse reset */ 111 - nvec_write_async(nvec, "\x06\x01\xff\x03", 4); 103 + nvec_write_async(nvec, MOUSE_RESET, 4); 112 104 113 105 return 0; 114 106 } 115 107 116 108 static struct platform_driver nvec_mouse_driver = { 117 - .probe = nvec_mouse_probe, 118 - .driver = { 119 - .name = "nvec-mouse", 120 - .owner = THIS_MODULE, 109 + .probe = nvec_mouse_probe, 110 + .driver = { 111 + .name = "nvec-mouse", 112 + .owner = THIS_MODULE, 121 113 }, 122 114 }; 123 115 ··· 127 119 } 128 120 129 121 module_init(nvec_mouse_init); 122 + 123 + MODULE_DESCRIPTION("NVEC mouse driver"); 124 + MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>"); 125 + MODULE_LICENSE("GPL");