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

« back to all changes in this revision

Viewing changes to drivers/staging/iio/adc/ad799x_ring.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:
73
73
{
74
74
        struct iio_ring_buffer *ring = indio_dev->ring;
75
75
        struct ad799x_state *st = indio_dev->dev_data;
76
 
        size_t d_size;
77
 
        unsigned long numvals;
78
76
 
79
77
        /*
80
78
         * Need to figure out the current mode based upon the requested
84
82
        if (st->id == ad7997 || st->id == ad7998)
85
83
                ad799x_set_scan_mode(st, ring->scan_mask);
86
84
 
87
 
        numvals = ring->scan_count;
88
 
 
89
 
        if (ring->access.set_bytes_per_datum) {
90
 
                d_size = numvals*2 + sizeof(s64);
91
 
                if (d_size % 8)
92
 
                        d_size += 8 - (d_size % 8);
93
 
                ring->access.set_bytes_per_datum(ring, d_size);
 
85
        st->d_size = ring->scan_count * 2;
 
86
 
 
87
        if (ring->scan_timestamp) {
 
88
                st->d_size += sizeof(s64);
 
89
 
 
90
                if (st->d_size % sizeof(s64))
 
91
                        st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
94
92
        }
95
93
 
 
94
        if (indio_dev->ring->access.set_bytes_per_datum)
 
95
                indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring,
 
96
                                                            st->d_size);
 
97
 
96
98
        return 0;
97
99
}
98
100
 
99
101
/**
100
102
 * ad799x_poll_func_th() th of trigger launched polling to ring buffer
101
103
 *
102
 
 * As sampling only occurs on i2c comms occuring, leave timestamping until
 
104
 * As sampling only occurs on i2c comms occurring, leave timestamping until
103
105
 * then.  Some triggers will generate their own time stamp.  Currently
104
106
 * there is no way of notifying them when no one cares.
105
107
 **/
130
132
        s64 time_ns;
131
133
        __u8 *rxbuf;
132
134
        int b_sent;
133
 
        size_t d_size;
134
135
        u8 cmd;
135
136
 
136
 
        unsigned long numvals = ring->scan_count;
137
 
 
138
 
        /* Ensure the timestamp is 8 byte aligned */
139
 
        d_size = numvals*2 + sizeof(s64);
140
 
 
141
 
        if (d_size % sizeof(s64))
142
 
                d_size += sizeof(s64) - (d_size % sizeof(s64));
143
 
 
144
137
        /* Ensure only one copy of this function running at a time */
145
138
        if (atomic_inc_return(&st->protect_ring) > 1)
146
139
                return;
147
140
 
148
 
        /* Monitor mode prevents reading. Whilst not currently implemented
149
 
         * might as well have this test in here in the meantime as it does
150
 
         * no harm.
151
 
         */
152
 
        if (numvals == 0)
153
 
                return;
154
 
 
155
 
        rxbuf = kmalloc(d_size, GFP_KERNEL);
 
141
        rxbuf = kmalloc(st->d_size, GFP_KERNEL);
156
142
        if (rxbuf == NULL)
157
143
                return;
158
144
 
177
163
        }
178
164
 
179
165
        b_sent = i2c_smbus_read_i2c_block_data(st->client,
180
 
                        cmd, numvals*2, rxbuf);
 
166
                        cmd, ring->scan_count * 2, rxbuf);
181
167
        if (b_sent < 0)
182
168
                goto done;
183
169
 
184
170
        time_ns = iio_get_time_ns();
185
171
 
186
 
        memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
 
172
        if (ring->scan_timestamp)
 
173
                memcpy(rxbuf + st->d_size - sizeof(s64),
 
174
                        &time_ns, sizeof(time_ns));
187
175
 
188
176
        ring->access.store_to(&ring_sw->buf, rxbuf, time_ns);
189
177
done:
213
201
        indio_dev->ring->preenable = &ad799x_ring_preenable;
214
202
        indio_dev->ring->postenable = &iio_triggered_ring_postenable;
215
203
        indio_dev->ring->predisable = &iio_triggered_ring_predisable;
 
204
        indio_dev->ring->scan_timestamp = true;
216
205
 
217
206
        INIT_WORK(&st->poll_work, &ad799x_poll_bh_to_ring);
218
207