aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-01-08 16:34:25 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-13 19:29:55 -0500
commit2e5a7bd978bf4118a0c8edf2e6ff81d0a72fee47 (patch)
treeee5b09d090c7a4a6cbf19ddf9f252d315b46eda1 /drivers/input/touchscreen
parent0c868461fcb8413cb9f691d68e5b99b0fd3c0737 (diff)
[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>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/ads7846.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 24ff6c5a4021..c741776ef3bf 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -345,19 +345,15 @@ static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)
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
352static int 348static int
353ads7846_suspend(struct device *dev, pm_message_t message EXTRA) 349ads7846_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 unsigned long flags; 352 unsigned long flags;
357 353
358 spin_lock_irqsave(&ts->lock, flags); 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 /* are we waiting for IRQ, or polling? */ 358 /* are we waiting for IRQ, or polling? */
363 if (!ts->pendown) { 359 if (!ts->pendown) {
@@ -387,36 +383,35 @@ ads7846_suspend(struct device *dev, pm_message_t message EXTRA)
387 return 0; 383 return 0;
388} 384}
389 385
390static int ads7846_resume(struct device *dev EXTRA) 386static int ads7846_resume(struct spi_device *spi)
391{ 387{
392 struct ads7846 *ts = dev_get_drvdata(dev); 388 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
393 389
394 ts->irq_disabled = 0; 390 ts->irq_disabled = 0;
395 enable_irq(ts->spi->irq); 391 enable_irq(ts->spi->irq);
396 dev->power.power_state = PMSG_ON; 392 spi->dev.power.power_state = PMSG_ON;
397 return 0; 393 return 0;
398} 394}
399 395
400static int __init ads7846_probe(struct device *dev) 396static int __devinit ads7846_probe(struct spi_device *spi)
401{ 397{
402 struct spi_device *spi = to_spi_device(dev);
403 struct ads7846 *ts; 398 struct ads7846 *ts;
404 struct ads7846_platform_data *pdata = dev->platform_data; 399 struct ads7846_platform_data *pdata = spi->dev.platform_data;
405 struct spi_transfer *x; 400 struct spi_transfer *x;
406 401
407 if (!spi->irq) { 402 if (!spi->irq) {
408 dev_dbg(dev, "no IRQ?\n"); 403 dev_dbg(&spi->dev, "no IRQ?\n");
409 return -ENODEV; 404 return -ENODEV;
410 } 405 }
411 406
412 if (!pdata) { 407 if (!pdata) {
413 dev_dbg(dev, "no platform data?\n"); 408 dev_dbg(&spi->dev, "no platform data?\n");
414 return -ENODEV; 409 return -ENODEV;
415 } 410 }
416 411
417 /* don't exceed max specified sample rate */ 412 /* don't exceed max specified sample rate */
418 if (spi->max_speed_hz > (125000 * 16)) { 413 if (spi->max_speed_hz > (125000 * 16)) {
419 dev_dbg(dev, "f(sample) %d KHz?\n", 414 dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
420 (spi->max_speed_hz/16)/1000); 415 (spi->max_speed_hz/16)/1000);
421 return -EINVAL; 416 return -EINVAL;
422 } 417 }
@@ -430,7 +425,7 @@ static int __init ads7846_probe(struct device *dev)
430 if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL))) 425 if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL)))
431 return -ENOMEM; 426 return -ENOMEM;
432 427
433 dev_set_drvdata(dev, ts); 428 dev_set_drvdata(&spi->dev, ts);
434 429
435 ts->spi = spi; 430 ts->spi = spi;
436 spi->dev.power.power_state = PMSG_ON; 431 spi->dev.power.power_state = PMSG_ON;
@@ -445,9 +440,9 @@ static int __init ads7846_probe(struct device *dev)
445 440
446 init_input_dev(&ts->input); 441 init_input_dev(&ts->input);
447 442
448 ts->input.dev = dev; 443 ts->input.dev = &spi->dev;
449 ts->input.name = "ADS784x Touchscreen"; 444 ts->input.name = "ADS784x Touchscreen";
450 snprintf(ts->phys, sizeof ts->phys, "%s/input0", dev->bus_id); 445 snprintf(ts->phys, sizeof ts->phys, "%s/input0", spi->dev.bus_id);
451 ts->input.phys = ts->phys; 446 ts->input.phys = ts->phys;
452 447
453 ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 448 ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
@@ -511,65 +506,68 @@ static int __init ads7846_probe(struct device *dev)
511 ts->msg.context = ts; 506 ts->msg.context = ts;
512 507
513 if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM, 508 if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM,
514 dev->bus_id, ts)) { 509 spi->dev.bus_id, ts)) {
515 dev_dbg(dev, "irq %d busy?\n", spi->irq); 510 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
516 input_unregister_device(&ts->input); 511 input_unregister_device(&ts->input);
517 kfree(ts); 512 kfree(ts);
518 return -EBUSY; 513 return -EBUSY;
519 } 514 }
520 set_irq_type(spi->irq, IRQT_FALLING); 515 set_irq_type(spi->irq, IRQT_FALLING);
521 516
522 dev_info(dev, "touchscreen, irq %d\n", spi->irq); 517 dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
523 518
524 /* take a first sample, leaving nPENIRQ active; avoid 519 /* take a first sample, leaving nPENIRQ active; avoid
525 * the touchscreen, in case it's not connected. 520 * the touchscreen, in case it's not connected.
526 */ 521 */
527 (void) ads7846_read12_ser(dev, 522 (void) ads7846_read12_ser(&spi->dev,
528 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); 523 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
529 524
530 /* ads7843/7845 don't have temperature sensors, and 525 /* ads7843/7845 don't have temperature sensors, and
531 * use the other sensors a bit differently too 526 * use the other sensors a bit differently too
532 */ 527 */
533 if (ts->model == 7846) { 528 if (ts->model == 7846) {
534 device_create_file(dev, &dev_attr_temp0); 529 device_create_file(&spi->dev, &dev_attr_temp0);
535 device_create_file(dev, &dev_attr_temp1); 530 device_create_file(&spi->dev, &dev_attr_temp1);
536 } 531 }
537 if (ts->model != 7845) 532 if (ts->model != 7845)
538 device_create_file(dev, &dev_attr_vbatt); 533 device_create_file(&spi->dev, &dev_attr_vbatt);
539 device_create_file(dev, &dev_attr_vaux); 534 device_create_file(&spi->dev, &dev_attr_vaux);
540 535
541 return 0; 536 return 0;
542} 537}
543 538
544static int __exit ads7846_remove(struct device *dev) 539static int __devexit ads7846_remove(struct spi_device *spi)
545{ 540{
546 struct ads7846 *ts = dev_get_drvdata(dev); 541 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
547 542
548 ads7846_suspend(dev, PMSG_SUSPEND EXTRA2); 543 ads7846_suspend(spi, PMSG_SUSPEND);
549 free_irq(ts->spi->irq, ts); 544 free_irq(ts->spi->irq, ts);
550 if (ts->irq_disabled) 545 if (ts->irq_disabled)
551 enable_irq(ts->spi->irq); 546 enable_irq(ts->spi->irq);
552 547
553 if (ts->model == 7846) { 548 if (ts->model == 7846) {
554 device_remove_file(dev, &dev_attr_temp0); 549 device_remove_file(&spi->dev, &dev_attr_temp0);
555 device_remove_file(dev, &dev_attr_temp1); 550 device_remove_file(&spi->dev, &dev_attr_temp1);
556 } 551 }
557 if (ts->model != 7845) 552 if (ts->model != 7845)
558 device_remove_file(dev, &dev_attr_vbatt); 553 device_remove_file(&spi->dev, &dev_attr_vbatt);
559 device_remove_file(dev, &dev_attr_vaux); 554 device_remove_file(&spi->dev, &dev_attr_vaux);
560 555
561 input_unregister_device(&ts->input); 556 input_unregister_device(&ts->input);
562 kfree(ts); 557 kfree(ts);
563 558
564 dev_dbg(dev, "unregistered touchscreen\n"); 559 dev_dbg(&spi->dev, "unregistered touchscreen\n");
565 return 0; 560 return 0;
566} 561}
567 562
568static struct device_driver ads7846_driver = { 563static struct spi_driver ads7846_driver = {
569 .name = "ads7846", 564 .driver = {
570 .bus = &spi_bus_type, 565 .name = "ads7846",
566 .bus = &spi_bus_type,
567 .owner = THIS_MODULE,
568 },
571 .probe = ads7846_probe, 569 .probe = ads7846_probe,
572 .remove = __exit_p(ads7846_remove), 570 .remove = __devexit_p(ads7846_remove),
573 .suspend = ads7846_suspend, 571 .suspend = ads7846_suspend,
574 .resume = ads7846_resume, 572 .resume = ads7846_resume,
575}; 573};
@@ -594,18 +592,20 @@ static int __init ads7846_init(void)
594 // PXA: 592 // PXA:
595 // also Dell Axim X50 593 // also Dell Axim X50
596 // also HP iPaq H191x/H192x/H415x/H435x 594 // also HP iPaq H191x/H192x/H415x/H435x
597 // also Intel Lubbock (alternate to UCB1400) 595 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
598 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky) 596 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
599 597
598 // Atmel at91sam9261-EK uses ads7843
599
600 // also various AMD Au1x00 devel boards 600 // also various AMD Au1x00 devel boards
601 601
602 return driver_register(&ads7846_driver); 602 return spi_register_driver(&ads7846_driver);
603} 603}
604module_init(ads7846_init); 604module_init(ads7846_init);
605 605
606static void __exit ads7846_exit(void) 606static void __exit ads7846_exit(void)
607{ 607{
608 driver_unregister(&ads7846_driver); 608 spi_unregister_driver(&ads7846_driver);
609 609
610#ifdef CONFIG_ARCH_OMAP 610#ifdef CONFIG_ARCH_OMAP
611 if (machine_is_omap_osk()) { 611 if (machine_is_omap_osk()) {