diff options
author | Udi Atar <udia@siano-ms.com> | 2009-06-28 03:22:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-08-31 01:24:53 -0400 |
commit | ef2d12ce12117bb97fa35bbcf677c28e14667efa (patch) | |
tree | d6d9ed6d31ab706683d240a9d089fc1c6b278037 | |
parent | f2e26ae7c8c077d001c77b330130f98e42ccad70 (diff) |
V4L/DVB (12450): Siano: Fixed SDIO compilation bugs
Fixed SDIO compilation bugs
Also fixed a memory overrun issue in buffer management.
Signed-off-by: Udi Atar <udia@siano-ms.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/siano/smssdio.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/media/dvb/siano/smssdio.c b/drivers/media/dvb/siano/smssdio.c index dfaa49a53f32..d1d652e7f890 100644 --- a/drivers/media/dvb/siano/smssdio.c +++ b/drivers/media/dvb/siano/smssdio.c | |||
@@ -46,6 +46,7 @@ | |||
46 | 46 | ||
47 | #define SMSSDIO_DATA 0x00 | 47 | #define SMSSDIO_DATA 0x00 |
48 | #define SMSSDIO_INT 0x04 | 48 | #define SMSSDIO_INT 0x04 |
49 | #define SMSSDIO_BLOCK_SIZE 128 | ||
49 | 50 | ||
50 | static const struct sdio_device_id smssdio_ids[] = { | 51 | static const struct sdio_device_id smssdio_ids[] = { |
51 | {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR), | 52 | {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR), |
@@ -85,7 +86,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size) | |||
85 | sdio_claim_host(smsdev->func); | 86 | sdio_claim_host(smsdev->func); |
86 | 87 | ||
87 | while (size >= smsdev->func->cur_blksize) { | 88 | while (size >= smsdev->func->cur_blksize) { |
88 | ret = sdio_write_blocks(smsdev->func, SMSSDIO_DATA, buffer, 1); | 89 | ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA, |
90 | buffer, smsdev->func->cur_blksize); | ||
89 | if (ret) | 91 | if (ret) |
90 | goto out; | 92 | goto out; |
91 | 93 | ||
@@ -94,8 +96,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size) | |||
94 | } | 96 | } |
95 | 97 | ||
96 | if (size) { | 98 | if (size) { |
97 | ret = sdio_write_bytes(smsdev->func, SMSSDIO_DATA, | 99 | ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA, |
98 | buffer, size); | 100 | buffer, size); |
99 | } | 101 | } |
100 | 102 | ||
101 | out: | 103 | out: |
@@ -125,23 +127,23 @@ static void smssdio_interrupt(struct sdio_func *func) | |||
125 | */ | 127 | */ |
126 | isr = sdio_readb(func, SMSSDIO_INT, &ret); | 128 | isr = sdio_readb(func, SMSSDIO_INT, &ret); |
127 | if (ret) { | 129 | if (ret) { |
128 | dev_err(&smsdev->func->dev, | 130 | sms_err("Unable to read interrupt register!\n"); |
129 | "Unable to read interrupt register!\n"); | ||
130 | return; | 131 | return; |
131 | } | 132 | } |
132 | 133 | ||
133 | if (smsdev->split_cb == NULL) { | 134 | if (smsdev->split_cb == NULL) { |
134 | cb = smscore_getbuffer(smsdev->coredev); | 135 | cb = smscore_getbuffer(smsdev->coredev); |
135 | if (!cb) { | 136 | if (!cb) { |
136 | dev_err(&smsdev->func->dev, | 137 | sms_err("Unable to allocate data buffer!\n"); |
137 | "Unable to allocate data buffer!\n"); | ||
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | 140 | ||
141 | ret = sdio_read_blocks(smsdev->func, cb->p, SMSSDIO_DATA, 1); | 141 | ret = sdio_memcpy_fromio(smsdev->func, |
142 | cb->p, | ||
143 | SMSSDIO_DATA, | ||
144 | SMSSDIO_BLOCK_SIZE); | ||
142 | if (ret) { | 145 | if (ret) { |
143 | dev_err(&smsdev->func->dev, | 146 | sms_err("Error %d reading initial block!\n", ret); |
144 | "Error %d reading initial block!\n", ret); | ||
145 | return; | 147 | return; |
146 | } | 148 | } |
147 | 149 | ||
@@ -152,7 +154,10 @@ static void smssdio_interrupt(struct sdio_func *func) | |||
152 | return; | 154 | return; |
153 | } | 155 | } |
154 | 156 | ||
155 | size = hdr->msgLength - smsdev->func->cur_blksize; | 157 | if (hdr->msgLength > smsdev->func->cur_blksize) |
158 | size = hdr->msgLength - smsdev->func->cur_blksize; | ||
159 | else | ||
160 | size = 0; | ||
156 | } else { | 161 | } else { |
157 | cb = smsdev->split_cb; | 162 | cb = smsdev->split_cb; |
158 | hdr = cb->p; | 163 | hdr = cb->p; |
@@ -162,23 +167,24 @@ static void smssdio_interrupt(struct sdio_func *func) | |||
162 | smsdev->split_cb = NULL; | 167 | smsdev->split_cb = NULL; |
163 | } | 168 | } |
164 | 169 | ||
165 | if (hdr->msgLength > smsdev->func->cur_blksize) { | 170 | if (size) { |
166 | void *buffer; | 171 | void *buffer; |
167 | 172 | ||
168 | size = ALIGN(size, 128); | 173 | buffer = cb->p + (hdr->msgLength - size); |
169 | buffer = cb->p + hdr->msgLength; | 174 | size = ALIGN(size, SMSSDIO_BLOCK_SIZE); |
170 | 175 | ||
171 | BUG_ON(smsdev->func->cur_blksize != 128); | 176 | BUG_ON(smsdev->func->cur_blksize != SMSSDIO_BLOCK_SIZE); |
172 | 177 | ||
173 | /* | 178 | /* |
174 | * First attempt to transfer all of it in one go... | 179 | * First attempt to transfer all of it in one go... |
175 | */ | 180 | */ |
176 | ret = sdio_read_blocks(smsdev->func, buffer, | 181 | ret = sdio_memcpy_fromio(smsdev->func, |
177 | SMSSDIO_DATA, size / 128); | 182 | buffer, |
183 | SMSSDIO_DATA, | ||
184 | size); | ||
178 | if (ret && ret != -EINVAL) { | 185 | if (ret && ret != -EINVAL) { |
179 | smscore_putbuffer(smsdev->coredev, cb); | 186 | smscore_putbuffer(smsdev->coredev, cb); |
180 | dev_err(&smsdev->func->dev, | 187 | sms_err("Error %d reading data from card!\n", ret); |
181 | "Error %d reading data from card!\n", ret); | ||
182 | return; | 188 | return; |
183 | } | 189 | } |
184 | 190 | ||
@@ -191,12 +197,12 @@ static void smssdio_interrupt(struct sdio_func *func) | |||
191 | */ | 197 | */ |
192 | if (ret == -EINVAL) { | 198 | if (ret == -EINVAL) { |
193 | while (size) { | 199 | while (size) { |
194 | ret = sdio_read_blocks(smsdev->func, | 200 | ret = sdio_memcpy_fromio(smsdev->func, |
195 | buffer, SMSSDIO_DATA, 1); | 201 | buffer, SMSSDIO_DATA, |
202 | smsdev->func->cur_blksize); | ||
196 | if (ret) { | 203 | if (ret) { |
197 | smscore_putbuffer(smsdev->coredev, cb); | 204 | smscore_putbuffer(smsdev->coredev, cb); |
198 | dev_err(&smsdev->func->dev, | 205 | sms_err("Error %d reading " |
199 | "Error %d reading " | ||
200 | "data from card!\n", ret); | 206 | "data from card!\n", ret); |
201 | return; | 207 | return; |
202 | } | 208 | } |
@@ -269,7 +275,7 @@ static int smssdio_probe(struct sdio_func *func, | |||
269 | if (ret) | 275 | if (ret) |
270 | goto release; | 276 | goto release; |
271 | 277 | ||
272 | ret = sdio_set_block_size(func, 128); | 278 | ret = sdio_set_block_size(func, SMSSDIO_BLOCK_SIZE); |
273 | if (ret) | 279 | if (ret) |
274 | goto disable; | 280 | goto disable; |
275 | 281 | ||