Skip to content

Commit 2e5a7bd

Browse files
David Brownellgregkh
authored andcommitted
[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>
1 parent 0c86846 commit 2e5a7bd

2 files changed

Lines changed: 43 additions & 43 deletions

File tree

‎drivers/input/touchscreen/ads7846.c‎

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,15 @@ static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)
345345

346346
/*--------------------------------------------------------------------------*/
347347

348-
/* non-empty "extra" is needed before 2.6.14-git5 or so */
349-
#define EXTRA // , u32 level
350-
#define EXTRA2 // , 0
351-
352348
static int
353-
ads7846_suspend(struct device *dev, pm_message_t message EXTRA)
349+
ads7846_suspend(struct spi_device *spi, pm_message_t message)
354350
{
355-
struct ads7846 *ts = dev_get_drvdata(dev);
351+
struct ads7846 *ts = dev_get_drvdata(&spi->dev);
356352
unsigned long flags;
357353

358354
spin_lock_irqsave(&ts->lock, flags);
359355

360-
ts->spi->dev.power.power_state = message;
356+
spi->dev.power.power_state = message;
361357

362358
/* are we waiting for IRQ, or polling? */
363359
if (!ts->pendown) {
@@ -387,36 +383,35 @@ ads7846_suspend(struct device *dev, pm_message_t message EXTRA)
387383
return 0;
388384
}
389385

390-
static int ads7846_resume(struct device *dev EXTRA)
386+
static int ads7846_resume(struct spi_device *spi)
391387
{
392-
struct ads7846 *ts = dev_get_drvdata(dev);
388+
struct ads7846 *ts = dev_get_drvdata(&spi->dev);
393389

394390
ts->irq_disabled = 0;
395391
enable_irq(ts->spi->irq);
396-
dev->power.power_state = PMSG_ON;
392+
spi->dev.power.power_state = PMSG_ON;
397393
return 0;
398394
}
399395

400-
static int __init ads7846_probe(struct device *dev)
396+
static int __devinit ads7846_probe(struct spi_device *spi)
401397
{
402-
struct spi_device *spi = to_spi_device(dev);
403398
struct ads7846 *ts;
404-
struct ads7846_platform_data *pdata = dev->platform_data;
399+
struct ads7846_platform_data *pdata = spi->dev.platform_data;
405400
struct spi_transfer *x;
406401

407402
if (!spi->irq) {
408-
dev_dbg(dev, "no IRQ?\n");
403+
dev_dbg(&spi->dev, "no IRQ?\n");
409404
return -ENODEV;
410405
}
411406

412407
if (!pdata) {
413-
dev_dbg(dev, "no platform data?\n");
408+
dev_dbg(&spi->dev, "no platform data?\n");
414409
return -ENODEV;
415410
}
416411

417412
/* don't exceed max specified sample rate */
418413
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",
420415
(spi->max_speed_hz/16)/1000);
421416
return -EINVAL;
422417
}
@@ -430,7 +425,7 @@ static int __init ads7846_probe(struct device *dev)
430425
if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL)))
431426
return -ENOMEM;
432427

433-
dev_set_drvdata(dev, ts);
428+
dev_set_drvdata(&spi->dev, ts);
434429

435430
ts->spi = spi;
436431
spi->dev.power.power_state = PMSG_ON;
@@ -445,9 +440,9 @@ static int __init ads7846_probe(struct device *dev)
445440

446441
init_input_dev(&ts->input);
447442

448-
ts->input.dev = dev;
443+
ts->input.dev = &spi->dev;
449444
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);
451446
ts->input.phys = ts->phys;
452447

453448
ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
@@ -511,65 +506,68 @@ static int __init ads7846_probe(struct device *dev)
511506
ts->msg.context = ts;
512507

513508
if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM,
514-
dev->bus_id, ts)) {
515-
dev_dbg(dev, "irq %d busy?\n", spi->irq);
509+
spi->dev.bus_id, ts)) {
510+
dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
516511
input_unregister_device(&ts->input);
517512
kfree(ts);
518513
return -EBUSY;
519514
}
520515
set_irq_type(spi->irq, IRQT_FALLING);
521516

522-
dev_info(dev, "touchscreen, irq %d\n", spi->irq);
517+
dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
523518

524519
/* take a first sample, leaving nPENIRQ active; avoid
525520
* the touchscreen, in case it's not connected.
526521
*/
527-
(void) ads7846_read12_ser(dev,
522+
(void) ads7846_read12_ser(&spi->dev,
528523
READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
529524

530525
/* ads7843/7845 don't have temperature sensors, and
531526
* use the other sensors a bit differently too
532527
*/
533528
if (ts->model == 7846) {
534-
device_create_file(dev, &dev_attr_temp0);
535-
device_create_file(dev, &dev_attr_temp1);
529+
device_create_file(&spi->dev, &dev_attr_temp0);
530+
device_create_file(&spi->dev, &dev_attr_temp1);
536531
}
537532
if (ts->model != 7845)
538-
device_create_file(dev, &dev_attr_vbatt);
539-
device_create_file(dev, &dev_attr_vaux);
533+
device_create_file(&spi->dev, &dev_attr_vbatt);
534+
device_create_file(&spi->dev, &dev_attr_vaux);
540535

541536
return 0;
542537
}
543538

544-
static int __exit ads7846_remove(struct device *dev)
539+
static int __devexit ads7846_remove(struct spi_device *spi)
545540
{
546-
struct ads7846 *ts = dev_get_drvdata(dev);
541+
struct ads7846 *ts = dev_get_drvdata(&spi->dev);
547542

548-
ads7846_suspend(dev, PMSG_SUSPEND EXTRA2);
543+
ads7846_suspend(spi, PMSG_SUSPEND);
549544
free_irq(ts->spi->irq, ts);
550545
if (ts->irq_disabled)
551546
enable_irq(ts->spi->irq);
552547

553548
if (ts->model == 7846) {
554-
device_remove_file(dev, &dev_attr_temp0);
555-
device_remove_file(dev, &dev_attr_temp1);
549+
device_remove_file(&spi->dev, &dev_attr_temp0);
550+
device_remove_file(&spi->dev, &dev_attr_temp1);
556551
}
557552
if (ts->model != 7845)
558-
device_remove_file(dev, &dev_attr_vbatt);
559-
device_remove_file(dev, &dev_attr_vaux);
553+
device_remove_file(&spi->dev, &dev_attr_vbatt);
554+
device_remove_file(&spi->dev, &dev_attr_vaux);
560555

561556
input_unregister_device(&ts->input);
562557
kfree(ts);
563558

564-
dev_dbg(dev, "unregistered touchscreen\n");
559+
dev_dbg(&spi->dev, "unregistered touchscreen\n");
565560
return 0;
566561
}
567562

568-
static struct device_driver ads7846_driver = {
569-
.name = "ads7846",
570-
.bus = &spi_bus_type,
563+
static struct spi_driver ads7846_driver = {
564+
.driver = {
565+
.name = "ads7846",
566+
.bus = &spi_bus_type,
567+
.owner = THIS_MODULE,
568+
},
571569
.probe = ads7846_probe,
572-
.remove = __exit_p(ads7846_remove),
570+
.remove = __devexit_p(ads7846_remove),
573571
.suspend = ads7846_suspend,
574572
.resume = ads7846_resume,
575573
};
@@ -594,18 +592,20 @@ static int __init ads7846_init(void)
594592
// PXA:
595593
// also Dell Axim X50
596594
// also HP iPaq H191x/H192x/H415x/H435x
597-
// also Intel Lubbock (alternate to UCB1400)
595+
// also Intel Lubbock (additional to UCB1400; as temperature sensor)
598596
// also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
599597

598+
// Atmel at91sam9261-EK uses ads7843
599+
600600
// also various AMD Au1x00 devel boards
601601

602-
return driver_register(&ads7846_driver);
602+
return spi_register_driver(&ads7846_driver);
603603
}
604604
module_init(ads7846_init);
605605

606606
static void __exit ads7846_exit(void)
607607
{
608-
driver_unregister(&ads7846_driver);
608+
spi_unregister_driver(&ads7846_driver);
609609

610610
#ifdef CONFIG_ARCH_OMAP
611611
if (machine_is_omap_osk()) {

‎include/linux/spi/ads7846.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* linux/spi/ads7846.h */
22

33
/* 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.
55
*
66
* It's OK if the min/max values are zero.
77
*/

0 commit comments

Comments
 (0)