[PATCH] spi: ads7836 uses spi_driver

This updates the ads7864 driver to use the new "spi_driver" struct, and
includes some minor unrelated cleanup.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by David Brownell and committed by Greg Kroah-Hartman 2e5a7bd9 0c868461

+43 -43
+42 -42
drivers/input/touchscreen/ads7846.c
··· 345 345 346 346 /*--------------------------------------------------------------------------*/ 347 347 348 - /* non-empty "extra" is needed before 2.6.14-git5 or so */ 349 - #define EXTRA // , u32 level 350 - #define EXTRA2 // , 0 351 - 352 348 static int 353 - ads7846_suspend(struct device *dev, pm_message_t message EXTRA) 349 + ads7846_suspend(struct spi_device *spi, pm_message_t message) 354 350 { 355 - struct ads7846 *ts = dev_get_drvdata(dev); 351 + struct ads7846 *ts = dev_get_drvdata(&spi->dev); 356 352 unsigned long flags; 357 353 358 354 spin_lock_irqsave(&ts->lock, flags); 359 355 360 - ts->spi->dev.power.power_state = message; 356 + spi->dev.power.power_state = message; 361 357 362 358 /* are we waiting for IRQ, or polling? */ 363 359 if (!ts->pendown) { ··· 383 387 return 0; 384 388 } 385 389 386 - static int ads7846_resume(struct device *dev EXTRA) 390 + static int ads7846_resume(struct spi_device *spi) 387 391 { 388 - struct ads7846 *ts = dev_get_drvdata(dev); 392 + struct ads7846 *ts = dev_get_drvdata(&spi->dev); 389 393 390 394 ts->irq_disabled = 0; 391 395 enable_irq(ts->spi->irq); 392 - dev->power.power_state = PMSG_ON; 396 + spi->dev.power.power_state = PMSG_ON; 393 397 return 0; 394 398 } 395 399 396 - static int __init ads7846_probe(struct device *dev) 400 + static int __devinit ads7846_probe(struct spi_device *spi) 397 401 { 398 - struct spi_device *spi = to_spi_device(dev); 399 402 struct ads7846 *ts; 400 - struct ads7846_platform_data *pdata = dev->platform_data; 403 + struct ads7846_platform_data *pdata = spi->dev.platform_data; 401 404 struct spi_transfer *x; 402 405 403 406 if (!spi->irq) { 404 - dev_dbg(dev, "no IRQ?\n"); 407 + dev_dbg(&spi->dev, "no IRQ?\n"); 405 408 return -ENODEV; 406 409 } 407 410 408 411 if (!pdata) { 409 - dev_dbg(dev, "no platform data?\n"); 412 + dev_dbg(&spi->dev, "no platform data?\n"); 410 413 return -ENODEV; 411 414 } 412 415 413 416 /* don't exceed max specified sample rate */ 414 417 if (spi->max_speed_hz > (125000 * 16)) { 415 - dev_dbg(dev, "f(sample) %d KHz?\n", 418 + dev_dbg(&spi->dev, "f(sample) %d KHz?\n", 416 419 (spi->max_speed_hz/16)/1000); 417 420 return -EINVAL; 418 421 } ··· 425 430 if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL))) 426 431 return -ENOMEM; 427 432 428 - dev_set_drvdata(dev, ts); 433 + dev_set_drvdata(&spi->dev, ts); 429 434 430 435 ts->spi = spi; 431 436 spi->dev.power.power_state = PMSG_ON; ··· 440 445 441 446 init_input_dev(&ts->input); 442 447 443 - ts->input.dev = dev; 448 + ts->input.dev = &spi->dev; 444 449 ts->input.name = "ADS784x Touchscreen"; 445 - snprintf(ts->phys, sizeof ts->phys, "%s/input0", dev->bus_id); 450 + snprintf(ts->phys, sizeof ts->phys, "%s/input0", spi->dev.bus_id); 446 451 ts->input.phys = ts->phys; 447 452 448 453 ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); ··· 506 511 ts->msg.context = ts; 507 512 508 513 if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM, 509 - dev->bus_id, ts)) { 510 - dev_dbg(dev, "irq %d busy?\n", spi->irq); 514 + spi->dev.bus_id, ts)) { 515 + dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 511 516 input_unregister_device(&ts->input); 512 517 kfree(ts); 513 518 return -EBUSY; 514 519 } 515 520 set_irq_type(spi->irq, IRQT_FALLING); 516 521 517 - dev_info(dev, "touchscreen, irq %d\n", spi->irq); 522 + dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); 518 523 519 524 /* take a first sample, leaving nPENIRQ active; avoid 520 525 * the touchscreen, in case it's not connected. 521 526 */ 522 - (void) ads7846_read12_ser(dev, 527 + (void) ads7846_read12_ser(&spi->dev, 523 528 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); 524 529 525 530 /* ads7843/7845 don't have temperature sensors, and 526 531 * use the other sensors a bit differently too 527 532 */ 528 533 if (ts->model == 7846) { 529 - device_create_file(dev, &dev_attr_temp0); 530 - device_create_file(dev, &dev_attr_temp1); 534 + device_create_file(&spi->dev, &dev_attr_temp0); 535 + device_create_file(&spi->dev, &dev_attr_temp1); 531 536 } 532 537 if (ts->model != 7845) 533 - device_create_file(dev, &dev_attr_vbatt); 534 - device_create_file(dev, &dev_attr_vaux); 538 + device_create_file(&spi->dev, &dev_attr_vbatt); 539 + device_create_file(&spi->dev, &dev_attr_vaux); 535 540 536 541 return 0; 537 542 } 538 543 539 - static int __exit ads7846_remove(struct device *dev) 544 + static int __devexit ads7846_remove(struct spi_device *spi) 540 545 { 541 - struct ads7846 *ts = dev_get_drvdata(dev); 546 + struct ads7846 *ts = dev_get_drvdata(&spi->dev); 542 547 543 - ads7846_suspend(dev, PMSG_SUSPEND EXTRA2); 548 + ads7846_suspend(spi, PMSG_SUSPEND); 544 549 free_irq(ts->spi->irq, ts); 545 550 if (ts->irq_disabled) 546 551 enable_irq(ts->spi->irq); 547 552 548 553 if (ts->model == 7846) { 549 - device_remove_file(dev, &dev_attr_temp0); 550 - device_remove_file(dev, &dev_attr_temp1); 554 + device_remove_file(&spi->dev, &dev_attr_temp0); 555 + device_remove_file(&spi->dev, &dev_attr_temp1); 551 556 } 552 557 if (ts->model != 7845) 553 - device_remove_file(dev, &dev_attr_vbatt); 554 - device_remove_file(dev, &dev_attr_vaux); 558 + device_remove_file(&spi->dev, &dev_attr_vbatt); 559 + device_remove_file(&spi->dev, &dev_attr_vaux); 555 560 556 561 input_unregister_device(&ts->input); 557 562 kfree(ts); 558 563 559 - dev_dbg(dev, "unregistered touchscreen\n"); 564 + dev_dbg(&spi->dev, "unregistered touchscreen\n"); 560 565 return 0; 561 566 } 562 567 563 - static struct device_driver ads7846_driver = { 564 - .name = "ads7846", 565 - .bus = &spi_bus_type, 568 + static struct spi_driver ads7846_driver = { 569 + .driver = { 570 + .name = "ads7846", 571 + .bus = &spi_bus_type, 572 + .owner = THIS_MODULE, 573 + }, 566 574 .probe = ads7846_probe, 567 - .remove = __exit_p(ads7846_remove), 575 + .remove = __devexit_p(ads7846_remove), 568 576 .suspend = ads7846_suspend, 569 577 .resume = ads7846_resume, 570 578 }; ··· 592 594 // PXA: 593 595 // also Dell Axim X50 594 596 // also HP iPaq H191x/H192x/H415x/H435x 595 - // also Intel Lubbock (alternate to UCB1400) 597 + // also Intel Lubbock (additional to UCB1400; as temperature sensor) 596 598 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky) 599 + 600 + // Atmel at91sam9261-EK uses ads7843 597 601 598 602 // also various AMD Au1x00 devel boards 599 603 600 - return driver_register(&ads7846_driver); 604 + return spi_register_driver(&ads7846_driver); 601 605 } 602 606 module_init(ads7846_init); 603 607 604 608 static void __exit ads7846_exit(void) 605 609 { 606 - driver_unregister(&ads7846_driver); 610 + spi_unregister_driver(&ads7846_driver); 607 611 608 612 #ifdef CONFIG_ARCH_OMAP 609 613 if (machine_is_omap_osk()) {
+1 -1
include/linux/spi/ads7846.h
··· 1 1 /* linux/spi/ads7846.h */ 2 2 3 3 /* Touchscreen characteristics vary between boards and models. The 4 - * platform_data for the device's "struct device" holts this information. 4 + * platform_data for the device's "struct device" holds this information. 5 5 * 6 6 * It's OK if the min/max values are zero. 7 7 */