aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorThomas Maier <balagi@justmail.de>2007-02-10 04:45:11 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:28 -0500
commit83f3aa3dc5a5014cb4dc344e503b082344d8fe1e (patch)
tree02e2b60930f17adc1b8015aa5d1d07ca12de3891 /drivers
parentb035b6de24932ffd4a2b1c6619a2f5711da6920f (diff)
[PATCH] pktcdvd: cleanup
- update documentation - use clear_bdi_congested/set_bdi_congested functions directly instead of old wrappers - removed DECLARE_BUF_AS_STRING macro Signed-off-by: Thomas Maier <balagi@justmail.de> Cc: Peter Osterlund <petero2@telia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/pktcdvd.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 62462190e07e..c0e89490e3d5 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -190,15 +190,6 @@ static struct attribute *kobj_pkt_attrs_wqueue[] = {
190 NULL 190 NULL
191}; 191};
192 192
193/* declares a char buffer[64] _dbuf, copies data from
194 * _b with length _l into it and ensures that _dbuf ends
195 * with a \0 character.
196 */
197#define DECLARE_BUF_AS_STRING(_dbuf, _b, _l) \
198 char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
199 if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
200 memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0
201
202static ssize_t kobj_pkt_show(struct kobject *kobj, 193static ssize_t kobj_pkt_show(struct kobject *kobj,
203 struct attribute *attr, char *data) 194 struct attribute *attr, char *data)
204{ 195{
@@ -264,9 +255,8 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
264{ 255{
265 struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd; 256 struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
266 int val; 257 int val;
267 DECLARE_BUF_AS_STRING(dbuf, data, len); /* ensure sscanf scans a string */
268 258
269 if (strcmp(attr->name, "reset") == 0 && dlen > 0) { 259 if (strcmp(attr->name, "reset") == 0 && len > 0) {
270 pd->stats.pkt_started = 0; 260 pd->stats.pkt_started = 0;
271 pd->stats.pkt_ended = 0; 261 pd->stats.pkt_ended = 0;
272 pd->stats.secs_w = 0; 262 pd->stats.secs_w = 0;
@@ -274,7 +264,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
274 pd->stats.secs_r = 0; 264 pd->stats.secs_r = 0;
275 265
276 } else if (strcmp(attr->name, "congestion_off") == 0 266 } else if (strcmp(attr->name, "congestion_off") == 0
277 && sscanf(dbuf, "%d", &val) == 1) { 267 && sscanf(data, "%d", &val) == 1) {
278 spin_lock(&pd->lock); 268 spin_lock(&pd->lock);
279 pd->write_congestion_off = val; 269 pd->write_congestion_off = val;
280 init_write_congestion_marks(&pd->write_congestion_off, 270 init_write_congestion_marks(&pd->write_congestion_off,
@@ -282,7 +272,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
282 spin_unlock(&pd->lock); 272 spin_unlock(&pd->lock);
283 273
284 } else if (strcmp(attr->name, "congestion_on") == 0 274 } else if (strcmp(attr->name, "congestion_on") == 0
285 && sscanf(dbuf, "%d", &val) == 1) { 275 && sscanf(data, "%d", &val) == 1) {
286 spin_lock(&pd->lock); 276 spin_lock(&pd->lock);
287 pd->write_congestion_on = val; 277 pd->write_congestion_on = val;
288 init_write_congestion_marks(&pd->write_congestion_off, 278 init_write_congestion_marks(&pd->write_congestion_off,
@@ -369,8 +359,7 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
369 size_t count) 359 size_t count)
370{ 360{
371 unsigned int major, minor; 361 unsigned int major, minor;
372 DECLARE_BUF_AS_STRING(dbuf, buf, count); 362 if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
373 if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
374 pkt_setup_dev(MKDEV(major, minor), NULL); 363 pkt_setup_dev(MKDEV(major, minor), NULL);
375 return count; 364 return count;
376 } 365 }
@@ -381,8 +370,7 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
381 size_t count) 370 size_t count)
382{ 371{
383 unsigned int major, minor; 372 unsigned int major, minor;
384 DECLARE_BUF_AS_STRING(dbuf, buf, count); 373 if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
385 if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
386 pkt_remove_dev(MKDEV(major, minor)); 374 pkt_remove_dev(MKDEV(major, minor));
387 return count; 375 return count;
388 } 376 }
@@ -1377,7 +1365,7 @@ try_next_bio:
1377 && pd->bio_queue_size <= pd->write_congestion_off); 1365 && pd->bio_queue_size <= pd->write_congestion_off);
1378 spin_unlock(&pd->lock); 1366 spin_unlock(&pd->lock);
1379 if (wakeup) 1367 if (wakeup)
1380 blk_clear_queue_congested(pd->disk->queue, WRITE); 1368 clear_bdi_congested(&pd->disk->queue->backing_dev_info, WRITE);
1381 1369
1382 pkt->sleep_time = max(PACKET_WAIT_TIME, 1); 1370 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
1383 pkt_set_state(pkt, PACKET_WAITING_STATE); 1371 pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2598,7 +2586,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
2598 spin_lock(&pd->lock); 2586 spin_lock(&pd->lock);
2599 if (pd->write_congestion_on > 0 2587 if (pd->write_congestion_on > 0
2600 && pd->bio_queue_size >= pd->write_congestion_on) { 2588 && pd->bio_queue_size >= pd->write_congestion_on) {
2601 blk_set_queue_congested(q, WRITE); 2589 set_bdi_congested(&q->backing_dev_info, WRITE);
2602 do { 2590 do {
2603 spin_unlock(&pd->lock); 2591 spin_unlock(&pd->lock);
2604 congestion_wait(WRITE, HZ); 2592 congestion_wait(WRITE, HZ);