~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to drivers/staging/iio/kfifo_buf.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#include "kfifo_buf.h"
10
10
 
 
11
#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring)
 
12
 
11
13
static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
12
14
                                int bytes_per_datum, int length)
13
15
{
18
20
        return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL);
19
21
}
20
22
 
21
 
int iio_request_update_kfifo(struct iio_ring_buffer *r)
 
23
static int iio_request_update_kfifo(struct iio_ring_buffer *r)
22
24
{
23
25
        int ret = 0;
24
26
        struct iio_kfifo *buf = iio_to_kfifo(r);
37
39
        mutex_unlock(&buf->use_lock);
38
40
        return ret;
39
41
}
40
 
EXPORT_SYMBOL(iio_request_update_kfifo);
41
42
 
42
 
void iio_mark_kfifo_in_use(struct iio_ring_buffer *r)
 
43
static void iio_mark_kfifo_in_use(struct iio_ring_buffer *r)
43
44
{
44
45
        struct iio_kfifo *buf = iio_to_kfifo(r);
45
46
        mutex_lock(&buf->use_lock);
46
47
        buf->use_count++;
47
48
        mutex_unlock(&buf->use_lock);
48
49
}
49
 
EXPORT_SYMBOL(iio_mark_kfifo_in_use);
50
50
 
51
 
void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r)
 
51
static void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r)
52
52
{
53
53
        struct iio_kfifo *buf = iio_to_kfifo(r);
54
54
        mutex_lock(&buf->use_lock);
55
55
        buf->use_count--;
56
56
        mutex_unlock(&buf->use_lock);
57
57
}
58
 
EXPORT_SYMBOL(iio_unmark_kfifo_in_use);
59
58
 
60
 
int iio_get_length_kfifo(struct iio_ring_buffer *r)
 
59
static int iio_get_length_kfifo(struct iio_ring_buffer *r)
61
60
{
62
61
        return r->length;
63
62
}
64
 
EXPORT_SYMBOL(iio_get_length_kfifo);
65
63
 
66
64
static inline void __iio_init_kfifo(struct iio_kfifo *kf)
67
65
{
108
106
        kf = kzalloc(sizeof *kf, GFP_KERNEL);
109
107
        if (!kf)
110
108
                return NULL;
 
109
        kf->update_needed = true;
111
110
        iio_ring_buffer_init(&kf->ring, indio_dev);
112
111
        __iio_init_kfifo(kf);
113
112
        kf->ring.dev.type = &iio_kfifo_type;
120
119
}
121
120
EXPORT_SYMBOL(iio_kfifo_allocate);
122
121
 
123
 
int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r)
 
122
static int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r)
124
123
{
125
124
        return r->bytes_per_datum;
126
125
}
127
 
EXPORT_SYMBOL(iio_get_bytes_per_datum_kfifo);
128
126
 
129
 
int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd)
 
127
static int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd)
130
128
{
131
129
        if (r->bytes_per_datum != bpd) {
132
130
                r->bytes_per_datum = bpd;
133
 
                if (r->access.mark_param_change)
134
 
                        r->access.mark_param_change(r);
 
131
                if (r->access->mark_param_change)
 
132
                        r->access->mark_param_change(r);
135
133
        }
136
134
        return 0;
137
135
}
138
 
EXPORT_SYMBOL(iio_set_bytes_per_datum_kfifo);
139
136
 
140
 
int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r)
 
137
static int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r)
141
138
{
142
139
        struct iio_kfifo *kf = iio_to_kfifo(r);
143
140
        kf->update_needed = true;
144
141
        return 0;
145
142
}
146
 
EXPORT_SYMBOL(iio_mark_update_needed_kfifo);
147
143
 
148
 
int iio_set_length_kfifo(struct iio_ring_buffer *r, int length)
 
144
static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length)
149
145
{
150
146
        if (r->length != length) {
151
147
                r->length = length;
152
 
                if (r->access.mark_param_change)
153
 
                        r->access.mark_param_change(r);
 
148
                if (r->access->mark_param_change)
 
149
                        r->access->mark_param_change(r);
154
150
        }
155
151
        return 0;
156
152
}
157
 
EXPORT_SYMBOL(iio_set_length_kfifo);
158
153
 
159
154
void iio_kfifo_free(struct iio_ring_buffer *r)
160
155
{
163
158
}
164
159
EXPORT_SYMBOL(iio_kfifo_free);
165
160
 
166
 
int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp)
 
161
static int iio_store_to_kfifo(struct iio_ring_buffer *r,
 
162
                              u8 *data,
 
163
                              s64 timestamp)
167
164
{
168
165
        int ret;
169
166
        struct iio_kfifo *kf = iio_to_kfifo(r);
179
176
        kfree(datal);
180
177
        return 0;
181
178
}
182
 
EXPORT_SYMBOL(iio_store_to_kfifo);
183
179
 
184
 
int iio_rip_kfifo(struct iio_ring_buffer *r,
185
 
                size_t count, char __user *buf, int *deadoffset)
 
180
static int iio_read_first_n_kfifo(struct iio_ring_buffer *r,
 
181
                           size_t n, char __user *buf)
186
182
{
187
183
        int ret, copied;
188
184
        struct iio_kfifo *kf = iio_to_kfifo(r);
189
185
 
190
 
        *deadoffset = 0;
191
 
        ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*count, &copied);
 
186
        ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*n, &copied);
192
187
 
193
188
        return copied;
194
189
}
195
 
EXPORT_SYMBOL(iio_rip_kfifo);
 
190
 
 
191
const struct iio_ring_access_funcs kfifo_access_funcs = {
 
192
        .mark_in_use = &iio_mark_kfifo_in_use,
 
193
        .unmark_in_use = &iio_unmark_kfifo_in_use,
 
194
        .store_to = &iio_store_to_kfifo,
 
195
        .read_first_n = &iio_read_first_n_kfifo,
 
196
        .mark_param_change = &iio_mark_update_needed_kfifo,
 
197
        .request_update = &iio_request_update_kfifo,
 
198
        .get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo,
 
199
        .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
 
200
        .get_length = &iio_get_length_kfifo,
 
201
        .set_length = &iio_set_length_kfifo,
 
202
};
 
203
EXPORT_SYMBOL(kfifo_access_funcs);
 
204
 
196
205
MODULE_LICENSE("GPL");