~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/staging/iio/adc/ad7606_spi.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * AD7606 SPI ADC driver
 
3
 *
 
4
 * Copyright 2011 Analog Devices Inc.
 
5
 *
 
6
 * Licensed under the GPL-2.
 
7
 */
 
8
 
 
9
#include <linux/module.h>
 
10
#include <linux/spi/spi.h>
 
11
#include <linux/types.h>
 
12
#include <linux/err.h>
 
13
#include "ad7606.h"
 
14
 
 
15
#define MAX_SPI_FREQ_HZ         23500000        /* VDRIVE above 4.75 V */
 
16
 
 
17
static int ad7606_spi_read_block(struct device *dev,
 
18
                                 int count, void *buf)
 
19
{
 
20
        struct spi_device *spi = to_spi_device(dev);
 
21
        int i, ret;
 
22
        unsigned short *data = buf;
 
23
 
 
24
        ret = spi_read(spi, (u8 *)buf, count * 2);
 
25
        if (ret < 0) {
 
26
                dev_err(&spi->dev, "SPI read error\n");
 
27
                return ret;
 
28
        }
 
29
 
 
30
        for (i = 0; i < count; i++)
 
31
                data[i] = be16_to_cpu(data[i]);
 
32
 
 
33
        return 0;
 
34
}
 
35
 
 
36
static const struct ad7606_bus_ops ad7606_spi_bops = {
 
37
        .read_block     = ad7606_spi_read_block,
 
38
};
 
39
 
 
40
static int __devinit ad7606_spi_probe(struct spi_device *spi)
 
41
{
 
42
        struct ad7606_state *st;
 
43
 
 
44
        st = ad7606_probe(&spi->dev, spi->irq, NULL,
 
45
                           spi_get_device_id(spi)->driver_data,
 
46
                           &ad7606_spi_bops);
 
47
 
 
48
        if (IS_ERR(st))
 
49
                return PTR_ERR(st);
 
50
 
 
51
        spi_set_drvdata(spi, st);
 
52
 
 
53
        return 0;
 
54
}
 
55
 
 
56
static int __devexit ad7606_spi_remove(struct spi_device *spi)
 
57
{
 
58
        struct ad7606_state *st = dev_get_drvdata(&spi->dev);
 
59
 
 
60
        return ad7606_remove(st);
 
61
}
 
62
 
 
63
#ifdef CONFIG_PM
 
64
static int ad7606_spi_suspend(struct device *dev)
 
65
{
 
66
        struct ad7606_state *st = dev_get_drvdata(dev);
 
67
 
 
68
        ad7606_suspend(st);
 
69
 
 
70
        return 0;
 
71
}
 
72
 
 
73
static int ad7606_spi_resume(struct device *dev)
 
74
{
 
75
        struct ad7606_state *st = dev_get_drvdata(dev);
 
76
 
 
77
        ad7606_resume(st);
 
78
 
 
79
        return 0;
 
80
}
 
81
 
 
82
static const struct dev_pm_ops ad7606_pm_ops = {
 
83
        .suspend = ad7606_spi_suspend,
 
84
        .resume  = ad7606_spi_resume,
 
85
};
 
86
#define AD7606_SPI_PM_OPS (&ad7606_pm_ops)
 
87
 
 
88
#else
 
89
#define AD7606_SPI_PM_OPS NULL
 
90
#endif
 
91
 
 
92
static const struct spi_device_id ad7606_id[] = {
 
93
        {"ad7606-8", ID_AD7606_8},
 
94
        {"ad7606-6", ID_AD7606_6},
 
95
        {"ad7606-4", ID_AD7606_4},
 
96
        {}
 
97
};
 
98
 
 
99
static struct spi_driver ad7606_driver = {
 
100
        .driver = {
 
101
                .name = "ad7606",
 
102
                .bus = &spi_bus_type,
 
103
                .owner = THIS_MODULE,
 
104
                .pm    = AD7606_SPI_PM_OPS,
 
105
        },
 
106
        .probe = ad7606_spi_probe,
 
107
        .remove = __devexit_p(ad7606_spi_remove),
 
108
        .id_table = ad7606_id,
 
109
};
 
110
 
 
111
static int __init ad7606_spi_init(void)
 
112
{
 
113
        return spi_register_driver(&ad7606_driver);
 
114
}
 
115
module_init(ad7606_spi_init);
 
116
 
 
117
static void __exit ad7606_spi_exit(void)
 
118
{
 
119
        spi_unregister_driver(&ad7606_driver);
 
120
}
 
121
module_exit(ad7606_spi_exit);
 
122
 
 
123
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
 
124
MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
 
125
MODULE_LICENSE("GPL v2");
 
126
MODULE_ALIAS("spi:ad7606_spi");