| @@ -27,6 +27,7 @@ · 26 unmodified lines |
| 27 | 27 | #include <linux/input.h> |
| 28 | 28 | #include <linux/interrupt.h> |
| 29 | 29 | #include <linux/module.h> |
| 30 | +#include <linux/platform_device.h> |
| 30 | 31 | |
| 31 | 32 | #define ATMEL_TP_I2C_ADDR 0x4b |
| 32 | 33 | #define ATMEL_TP_I2C_BL_ADDR 0x25 |
| @@ -40,7 +41,7 @@ static struct i2c_client *als; · 7 unmodified lines |
| 40 | 41 | static struct i2c_client *tp; |
| 41 | 42 | static struct i2c_client *ts; |
| 42 | 43 | |
| 43 | | −const char *i2c_adapter_names[] = { |
| 44 | +static const char *i2c_adapter_names[] = { |
| 44 | 45 | "SMBus I801 adapter", |
| 45 | 46 | "i915 gmbus vga", |
| 46 | 47 | "i915 gmbus panel", |
| @@ -53,20 +54,33 @@ enum i2c_adapter_type { · 6 unmodified lines |
| 53 | 54 | I2C_ADAPTER_PANEL, |
| 54 | 55 | }; |
| 55 | 56 | |
| 56 | | −static struct i2c_board_info __initdata cyapa_device = { |
| 57 | +struct i2c_peripheral { |
| 58 | + int (*add)(enum i2c_adapter_type type); |
| 59 | + enum i2c_adapter_type type; |
| 60 | +}; |
| 61 | + |
| 62 | +#define MAX_I2C_PERIPHERALS 3 |
| 63 | + |
| 64 | +struct chromeos_laptop { |
| 65 | + struct i2c_peripheral i2c_peripherals[MAX_I2C_PERIPHERALS]; |
| 66 | +}; |
| 67 | + |
| 68 | +static struct chromeos_laptop *cros_laptop; |
| 69 | + |
| 70 | +static struct i2c_board_info cyapa_device = { |
| 57 | 71 | I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR), |
| 58 | 72 | .flags = I2C_CLIENT_WAKE, |
| 59 | 73 | }; |
| 60 | 74 | |
| 61 | | −static struct i2c_board_info __initdata isl_als_device = { |
| 75 | +static struct i2c_board_info isl_als_device = { |
| 62 | 76 | I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR), |
| 63 | 77 | }; |
| 64 | 78 | |
| 65 | | −static struct i2c_board_info __initdata tsl2583_als_device = { |
| 79 | +static struct i2c_board_info tsl2583_als_device = { |
| 66 | 80 | I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR), |
| 67 | 81 | }; |
| 68 | 82 | |
| 69 | | −static struct i2c_board_info __initdata tsl2563_als_device = { |
| 83 | +static struct i2c_board_info tsl2563_als_device = { |
| 70 | 84 | I2C_BOARD_INFO("tsl2563", TAOS_ALS_I2C_ADDR), |
| 71 | 85 | }; |
| 72 | 86 | |
| @@ -89,7 +103,7 @@ static struct mxt_platform_data atmel_224s_tp_platform_data = { · 16 unmodified lines |
| 89 | 103 | .config_length = 0, |
| 90 | 104 | }; |
| 91 | 105 | |
| 92 | | −static struct i2c_board_info __initdata atmel_224s_tp_device = { |
| 106 | +static struct i2c_board_info atmel_224s_tp_device = { |
| 93 | 107 | I2C_BOARD_INFO("atmel_mxt_tp", ATMEL_TP_I2C_ADDR), |
| 94 | 108 | .platform_data = &atmel_224s_tp_platform_data, |
| 95 | 109 | .flags = I2C_CLIENT_WAKE, |
| @@ -110,13 +124,13 @@ static struct mxt_platform_data atmel_1664s_platform_data = { · 14 unmodified lines |
| 110 | 124 | .config_length = 0, |
| 111 | 125 | }; |
| 112 | 126 | |
| 113 | | −static struct i2c_board_info __initdata atmel_1664s_device = { |
| 127 | +static struct i2c_board_info atmel_1664s_device = { |
| 114 | 128 | I2C_BOARD_INFO("atmel_mxt_ts", ATMEL_TS_I2C_ADDR), |
| 115 | 129 | .platform_data = &atmel_1664s_platform_data, |
| 116 | 130 | .flags = I2C_CLIENT_WAKE, |
| 117 | 131 | }; |
| 118 | 132 | |
| 119 | | −static struct i2c_client __init *__add_probed_i2c_device( |
| 133 | +static struct i2c_client *__add_probed_i2c_device( |
| 120 | 134 | const char *name, |
| 121 | 135 | int bus, |
| 122 | 136 | struct i2c_board_info *info, |
| @@ -169,7 +183,7 @@ static struct i2c_client __init *__add_probed_i2c_device( · 46 unmodified lines |
| 169 | 183 | return client; |
| 170 | 184 | } |
| 171 | 185 | |
| 172 | | −static int __init __find_i2c_adap(struct device *dev, void *data) |
| 186 | +static int __find_i2c_adap(struct device *dev, void *data) |
| 173 | 187 | { |
| 174 | 188 | const char *name = data; |
| 175 | 189 | static const char *prefix = "i2c-"; |
| @@ -180,7 +194,7 @@ static int __init __find_i2c_adap(struct device *dev, void *data) · 4 unmodified lines |
| 180 | 194 | return (strncmp(adapter->name, name, strlen(name)) == 0); |
| 181 | 195 | } |
| 182 | 196 | |
| 183 | | −static int __init find_i2c_adapter_num(enum i2c_adapter_type type) |
| 197 | +static int find_i2c_adapter_num(enum i2c_adapter_type type) |
| 184 | 198 | { |
| 185 | 199 | struct device *dev = NULL; |
| 186 | 200 | struct i2c_adapter *adapter; |
| @@ -189,8 +203,9 @@ static int __init find_i2c_adapter_num(enum i2c_adapter_type type) · 2 unmodified lines |
| 189 | 203 | dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, |
| 190 | 204 | __find_i2c_adap); |
| 191 | 205 | if (!dev) { |
| 192 | | − pr_err("%s: i2c adapter %s not found on system.\n", __func__, |
| 193 | | − name); |
| 206 | + /* Adapters may appear later. Deferred probing will retry */ |
| 207 | + pr_notice("%s: i2c adapter %s not found on system.\n", __func__, |
| 208 | + name); |
| 194 | 209 | return -ENODEV; |
| 195 | 210 | } |
| 196 | 211 | adapter = to_i2c_adapter(dev); |
| @@ -205,7 +220,7 @@ static int __init find_i2c_adapter_num(enum i2c_adapter_type type) · 8 unmodified lines |
| 205 | 220 | * Returns NULL if no devices found. |
| 206 | 221 | * See Documentation/i2c/instantiating-devices for more information. |
| 207 | 222 | */ |
| 208 | | −static __init struct i2c_client *add_probed_i2c_device( |
| 223 | +static struct i2c_client *add_probed_i2c_device( |
| 209 | 224 | const char *name, |
| 210 | 225 | enum i2c_adapter_type type, |
| 211 | 226 | struct i2c_board_info *info, |
| @@ -222,7 +237,7 @@ static __init struct i2c_client *add_probed_i2c_device( · 10 unmodified lines |
| 222 | 237 | * info->addr. |
| 223 | 238 | * Returns NULL if no device found. |
| 224 | 239 | */ |
| 225 | | −static __init struct i2c_client *add_i2c_device(const char *name, |
| 240 | +static struct i2c_client *add_i2c_device(const char *name, |
| 226 | 241 | enum i2c_adapter_type type, |
| 227 | 242 | struct i2c_board_info *info) |
| 228 | 243 | { |
| @@ -233,161 +248,259 @@ static __init struct i2c_client *add_i2c_device(const char *name, · 4 unmodified lines |
| 233 | 248 | addr_list); |
| 234 | 249 | } |
| 235 | 250 | |
| 236 | | − |
| 237 | | −static struct i2c_client __init *add_smbus_device(const char *name, |
| 238 | | − struct i2c_board_info *info) |
| 251 | +static int setup_cyapa_tp(enum i2c_adapter_type type) |
| 239 | 252 | { |
| 240 | | − return add_i2c_device(name, I2C_ADAPTER_SMBUS, info); |
| 241 | | −} |
| 253 | + if (tp) |
| 254 | + return 0; |
| 242 | 255 | |
| 243 | | −static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id) |
| 244 | | −{ |
| 245 | | − /* add cyapa touchpad on smbus */ |
| 246 | | − tp = add_smbus_device("trackpad", &cyapa_device); |
| 247 | | − return 0; |
| 256 | + /* add cyapa touchpad */ |
| 257 | + tp = add_i2c_device("trackpad", type, &cyapa_device); |
| 258 | + return (!tp) ? -EAGAIN : 0; |
| 248 | 259 | } |
| 249 | 260 | |
| 250 | | −static int __init setup_atmel_224s_tp(const struct dmi_system_id *id) |
| 261 | +static int setup_atmel_224s_tp(enum i2c_adapter_type type) |
| 251 | 262 | { |
| 252 | 263 | const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR, |
| 253 | 264 | ATMEL_TP_I2C_ADDR, |
| 254 | 265 | I2C_CLIENT_END }; |
| 266 | + if (tp) |
| 267 | + return 0; |
| 255 | 268 | |
| 256 | | − /* add atmel mxt touchpad on VGA DDC GMBus */ |
| 257 | | − tp = add_probed_i2c_device("trackpad", I2C_ADAPTER_VGADDC, |
| 269 | + /* add atmel mxt touchpad */ |
| 270 | + tp = add_probed_i2c_device("trackpad", type, |
| 258 | 271 | &atmel_224s_tp_device, addr_list); |
| 259 | | − return 0; |
| 272 | + return (!tp) ? -EAGAIN : 0; |
| 260 | 273 | } |
| 261 | 274 | |
| 262 | | −static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id) |
| 275 | +static int setup_atmel_1664s_ts(enum i2c_adapter_type type) |
| 263 | 276 | { |
| 264 | 277 | const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR, |
| 265 | 278 | ATMEL_TS_I2C_ADDR, |
| 266 | 279 | I2C_CLIENT_END }; |
| 280 | + if (ts) |
| 281 | + return 0; |
| 267 | 282 | |
| 268 | | − /* add atmel mxt touch device on PANEL GMBus */ |
| 269 | | − ts = add_probed_i2c_device("touchscreen", I2C_ADAPTER_PANEL, |
| 283 | + /* add atmel mxt touch device */ |
| 284 | + ts = add_probed_i2c_device("touchscreen", type, |
| 270 | 285 | &atmel_1664s_device, addr_list); |
| 271 | | − return 0; |
| 286 | + return (!ts) ? -EAGAIN : 0; |
| 272 | 287 | } |
| 273 | 288 | |
| 274 | | − |
| 275 | | −static int __init setup_isl29018_als(const struct dmi_system_id *id) |
| 289 | +static int setup_isl29018_als(enum i2c_adapter_type type) |
| 276 | 290 | { |
| 291 | + if (als) |
| 292 | + return 0; |
| 293 | + |
| 277 | 294 | /* add isl29018 light sensor */ |
| 278 | | − als = add_smbus_device("lightsensor", &isl_als_device); |
| 279 | | − return 0; |
| 295 | + als = add_i2c_device("lightsensor", type, &isl_als_device); |
| 296 | + return (!als) ? -EAGAIN : 0; |
| 280 | 297 | } |
| 281 | 298 | |
| 282 | | −static int __init setup_isl29023_als(const struct dmi_system_id *id) |
| 299 | +static int setup_tsl2583_als(enum i2c_adapter_type type) |
| 283 | 300 | { |
| 284 | | − /* add isl29023 light sensor on Panel GMBus */ |
| 285 | | − als = add_i2c_device("lightsensor", I2C_ADAPTER_PANEL, |
| 286 | | − &isl_als_device); |
| 287 | | − return 0; |
| 301 | + if (als) |
| 302 | + return 0; |
| 303 | + |
| 304 | + /* add tsl2583 light sensor */ |
| 305 | + als = add_i2c_device(NULL, type, &tsl2583_als_device); |
| 306 | + return (!als) ? -EAGAIN : 0; |
| 288 | 307 | } |
| 289 | 308 | |
| 290 | | −static int __init setup_tsl2583_als(const struct dmi_system_id *id) |
| 309 | +static int setup_tsl2563_als(enum i2c_adapter_type type) |
| 291 | 310 | { |
| 292 | | − /* add tsl2583 light sensor on smbus */ |
| 293 | | − als = add_smbus_device(NULL, &tsl2583_als_device); |
| 294 | | − return 0; |
| 311 | + if (als) |
| 312 | + return 0; |
| 313 | + |
| 314 | + /* add tsl2563 light sensor */ |
| 315 | + als = add_i2c_device(NULL, type, &tsl2563_als_device); |
| 316 | + return (!als) ? -EAGAIN : 0; |
| 295 | 317 | } |
| 296 | 318 | |
| 297 | | −static int __init setup_tsl2563_als(const struct dmi_system_id *id) |
| 319 | +static int __init chromeos_laptop_dmi_matched(const struct dmi_system_id *id) |
| 298 | 320 | { |
| 299 | | − /* add tsl2563 light sensor on smbus */ |
| 300 | | − als = add_smbus_device(NULL, &tsl2563_als_device); |
| 301 | | − return 0; |
| 321 | + cros_laptop = (void *)id->driver_data; |
| 322 | + pr_debug("DMI Matched %s.\n", id->ident); |
| 323 | + |
| 324 | + /* Indicate to dmi_scan that processing is done. */ |
| 325 | + return 1; |
| 302 | 326 | } |
| 303 | 327 | |
| 304 | | −static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = { |
| 305 | | − { |
| 306 | | − .ident = "Samsung Series 5 550 - Touchpad", |
| 307 | | − .matches = { |
| 308 | | − DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), |
| 309 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"), |
| 310 | | − }, |
| 311 | | − .callback = setup_cyapa_smbus_tp, |
| 328 | +static int chromeos_laptop_probe(struct platform_device *pdev) |
| 329 | +{ |
| 330 | + int i; |
| 331 | + int ret = 0; |
| 332 | + |
| 333 | + for (i = 0; i < MAX_I2C_PERIPHERALS; i++) { |
| 334 | + struct i2c_peripheral *i2c_dev; |
| 335 | + |
| 336 | + i2c_dev = &cros_laptop->i2c_peripherals[i]; |
| 337 | + |
| 338 | + /* No more peripherals. */ |
| 339 | + if (i2c_dev->add == NULL) |
| 340 | + break; |
| 341 | + |
| 342 | + /* Add the device. Set -EPROBE_DEFER on any failure */ |
| 343 | + if (i2c_dev->add(i2c_dev->type)) |
| 344 | + ret = -EPROBE_DEFER; |
| 345 | + } |
| 346 | + |
| 347 | + return ret; |
| 348 | +} |
| 349 | + |
| 350 | +static struct chromeos_laptop samsung_series_5_550 = { |
| 351 | + .i2c_peripherals = { |
| 352 | + /* Touchpad. */ |
| 353 | + { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS }, |
| 354 | + /* Light Sensor. */ |
| 355 | + { .add = setup_isl29018_als, I2C_ADAPTER_SMBUS }, |
| 312 | 356 | }, |
| 313 | | − { |
| 314 | | − .ident = "Chromebook Pixel - Touchscreen", |
| 315 | | − .matches = { |
| 316 | | − DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), |
| 317 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Link"), |
| 318 | | − }, |
| 319 | | − .callback = setup_atmel_1664s_ts, |
| 357 | +}; |
| 358 | + |
| 359 | +static struct chromeos_laptop samsung_series_5 = { |
| 360 | + .i2c_peripherals = { |
| 361 | + /* Light Sensor. */ |
| 362 | + { .add = setup_tsl2583_als, I2C_ADAPTER_SMBUS }, |
| 363 | + }, |
| 364 | +}; |
| 365 | + |
| 366 | +static struct chromeos_laptop chromebook_pixel = { |
| 367 | + .i2c_peripherals = { |
| 368 | + /* Touch Screen. */ |
| 369 | + { .add = setup_atmel_1664s_ts, I2C_ADAPTER_PANEL }, |
| 370 | + /* Touchpad. */ |
| 371 | + { .add = setup_atmel_224s_tp, I2C_ADAPTER_VGADDC }, |
| 372 | + /* Light Sensor. */ |
| 373 | + { .add = setup_isl29018_als, I2C_ADAPTER_PANEL }, |
| 374 | + }, |
| 375 | +}; |
| 376 | + |
| 377 | +static struct chromeos_laptop acer_c7_chromebook = { |
| 378 | + .i2c_peripherals = { |
| 379 | + /* Touchpad. */ |
| 380 | + { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS }, |
| 381 | + }, |
| 382 | +}; |
| 383 | + |
| 384 | +static struct chromeos_laptop acer_ac700 = { |
| 385 | + .i2c_peripherals = { |
| 386 | + /* Light Sensor. */ |
| 387 | + { .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS }, |
| 320 | 388 | }, |
| 389 | +}; |
| 390 | + |
| 391 | +static struct chromeos_laptop hp_pavilion_14_chromebook = { |
| 392 | + .i2c_peripherals = { |
| 393 | + /* Touchpad. */ |
| 394 | + { .add = setup_cyapa_tp, I2C_ADAPTER_SMBUS }, |
| 395 | + }, |
| 396 | +}; |
| 397 | + |
| 398 | +static struct chromeos_laptop cr48 = { |
| 399 | + .i2c_peripherals = { |
| 400 | + /* Light Sensor. */ |
| 401 | + { .add = setup_tsl2563_als, I2C_ADAPTER_SMBUS }, |
| 402 | + }, |
| 403 | +}; |
| 404 | + |
| 405 | +#define _CBDD(board_) \ |
| 406 | + .callback = chromeos_laptop_dmi_matched, \ |
| 407 | + .driver_data = (void *)&board_ |
| 408 | + |
| 409 | +static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = { |
| 321 | 410 | { |
| 322 | | − .ident = "Chromebook Pixel - Touchpad", |
| 411 | + .ident = "Samsung Series 5 550", |
| 323 | 412 | .matches = { |
| 324 | | − DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), |
| 325 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Link"), |
| 413 | + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), |
| 414 | + DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"), |
| 326 | 415 | }, |
| 327 | | − .callback = setup_atmel_224s_tp, |
| 416 | + _CBDD(samsung_series_5_550), |
| 328 | 417 | }, |
| 329 | 418 | { |
| 330 | | − .ident = "Samsung Series 5 550 - Light Sensor", |
| 419 | + .ident = "Samsung Series 5", |
| 331 | 420 | .matches = { |
| 332 | | − DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"), |
| 333 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"), |
| 421 | + DMI_MATCH(DMI_PRODUCT_NAME, "Alex"), |
| 334 | 422 | }, |
| 335 | | − .callback = setup_isl29018_als, |
| 423 | + _CBDD(samsung_series_5), |
| 336 | 424 | }, |
| 337 | 425 | { |
| 338 | | − .ident = "Chromebook Pixel - Light Sensor", |
| 426 | + .ident = "Chromebook Pixel", |
| 339 | 427 | .matches = { |
| 340 | 428 | DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), |
| 341 | 429 | DMI_MATCH(DMI_PRODUCT_NAME, "Link"), |
| 342 | 430 | }, |
| 343 | | − .callback = setup_isl29023_als, |
| 431 | + _CBDD(chromebook_pixel), |
| 344 | 432 | }, |
| 345 | 433 | { |
| 346 | | − .ident = "Acer C7 Chromebook - Touchpad", |
| 434 | + .ident = "Acer C7 Chromebook", |
| 347 | 435 | .matches = { |
| 348 | 436 | DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"), |
| 349 | 437 | }, |
| 350 | | − .callback = setup_cyapa_smbus_tp, |
| 438 | + _CBDD(acer_c7_chromebook), |
| 351 | 439 | }, |
| 352 | 440 | { |
| 353 | | − .ident = "HP Pavilion 14 Chromebook - Touchpad", |
| 441 | + .ident = "Acer AC700", |
| 354 | 442 | .matches = { |
| 355 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"), |
| 443 | + DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"), |
| 356 | 444 | }, |
| 357 | | − .callback = setup_cyapa_smbus_tp, |
| 445 | + _CBDD(acer_ac700), |
| 358 | 446 | }, |
| 359 | 447 | { |
| 360 | | − .ident = "Samsung Series 5 - Light Sensor", |
| 448 | + .ident = "HP Pavilion 14 Chromebook", |
| 361 | 449 | .matches = { |
| 362 | | − DMI_MATCH(DMI_PRODUCT_NAME, "Alex"), |
| 450 | + DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"), |
| 363 | 451 | }, |
| 364 | | − .callback = setup_tsl2583_als, |
| 452 | + _CBDD(hp_pavilion_14_chromebook), |
| 365 | 453 | }, |
| 366 | 454 | { |
| 367 | | − .ident = "Cr-48 - Light Sensor", |
| 455 | + .ident = "Cr-48", |
| 368 | 456 | .matches = { |
| 369 | 457 | DMI_MATCH(DMI_PRODUCT_NAME, "Mario"), |
| 370 | 458 | }, |
| 371 | | − .callback = setup_tsl2563_als, |
| 372 | | − }, |
| 373 | | − { |
| 374 | | − .ident = "Acer AC700 - Light Sensor", |
| 375 | | − .matches = { |
| 376 | | − DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"), |
| 377 | | − }, |
| 378 | | − .callback = setup_tsl2563_als, |
| 459 | + _CBDD(cr48), |
| 379 | 460 | }, |
| 380 | 461 | { } |
| 381 | 462 | }; |
| 382 | 463 | MODULE_DEVICE_TABLE(dmi, chromeos_laptop_dmi_table); |
| 383 | 464 | |
| 465 | +static struct platform_device *cros_platform_device; |
| 466 | + |
| 467 | +static struct platform_driver cros_platform_driver = { |
| 468 | + .driver = { |
| 469 | + .name = "chromeos_laptop", |
| 470 | + .owner = THIS_MODULE, |
| 471 | + }, |
| 472 | + .probe = chromeos_laptop_probe, |
| 473 | +}; |
| 474 | + |
| 384 | 475 | static int __init chromeos_laptop_init(void) |
| 385 | 476 | { |
| 477 | + int ret; |
| 386 | 478 | if (!dmi_check_system(chromeos_laptop_dmi_table)) { |
| 387 | 479 | pr_debug("%s unsupported system.\n", __func__); |
| 388 | 480 | return -ENODEV; |
| 389 | 481 | } |
| 482 | + |
| 483 | + ret = platform_driver_register(&cros_platform_driver); |
| 484 | + if (ret) |
| 485 | + return ret; |
| 486 | + |
| 487 | + cros_platform_device = platform_device_alloc("chromeos_laptop", -1); |
| 488 | + if (!cros_platform_device) { |
| 489 | + ret = -ENOMEM; |
| 490 | + goto fail_platform_device1; |
| 491 | + } |
| 492 | + |
| 493 | + ret = platform_device_add(cros_platform_device); |
| 494 | + if (ret) |
| 495 | + goto fail_platform_device2; |
| 496 | + |
| 390 | 497 | return 0; |
| 498 | + |
| 499 | +fail_platform_device2: |
| 500 | + platform_device_put(cros_platform_device); |
| 501 | +fail_platform_device1: |
| 502 | + platform_driver_unregister(&cros_platform_driver); |
| 503 | + return ret; |
| 391 | 504 | } |
| 392 | 505 | |
| 393 | 506 | static void __exit chromeos_laptop_exit(void) |
| @@ -398,6 +511,9 @@ static void __exit chromeos_laptop_exit(void) · 4 unmodified lines |
| 398 | 511 | i2c_unregister_device(tp); |
| 399 | 512 | if (ts) |
| 400 | 513 | i2c_unregister_device(ts); |
| 514 | + |
| 515 | + platform_device_unregister(cros_platform_device); |
| 516 | + platform_driver_unregister(&cros_platform_driver); |
| 401 | 517 | } |
| 402 | 518 | |
| 403 | 519 | module_init(chromeos_laptop_init); |