Skip to content

Commit

Permalink
[PATCH] pktcdvd: cleanup
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
Cc: Peter Osterlund <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sboxnet authored and Linus Torvalds committed Feb 11, 2007
1 parent b035b6d commit 83f3aa3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Documentation/ABI/testing/debugfs-pktcdvd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
What: /debug/pktcdvd/pktcdvd[0-7]
Date: Oct. 2006
KernelVersion: 2.6.19
KernelVersion: 2.6.20
Contact: Thomas Maier <[email protected]>
Description:

Expand All @@ -11,8 +11,7 @@ The pktcdvd module (packet writing driver) creates
these files in debugfs:

/debug/pktcdvd/pktcdvd[0-7]/
info (0444) Lots of human readable driver
statistics and infos. Multiple lines!
info (0444) Lots of driver statistics and infos.

Example:
-------
Expand Down
2 changes: 1 addition & 1 deletion Documentation/ABI/testing/sysfs-class-pktcdvd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
What: /sys/class/pktcdvd/
Date: Oct. 2006
KernelVersion: 2.6.19
KernelVersion: 2.6.20
Contact: Thomas Maier <[email protected]>
Description:

Expand Down
2 changes: 1 addition & 1 deletion Documentation/cdrom/packet-writing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Notes
Using the pktcdvd sysfs interface
---------------------------------

Since Linux 2.6.19, the pktcdvd module has a sysfs interface
Since Linux 2.6.20, the pktcdvd module has a sysfs interface
and can be controlled by it. For example the "pktcdvd" tool uses
this interface. (see http://people.freenet.de/BalaGi#pktcdvd )

Expand Down
26 changes: 7 additions & 19 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ static struct attribute *kobj_pkt_attrs_wqueue[] = {
NULL
};

/* declares a char buffer[64] _dbuf, copies data from
* _b with length _l into it and ensures that _dbuf ends
* with a \0 character.
*/
#define DECLARE_BUF_AS_STRING(_dbuf, _b, _l) \
char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0

static ssize_t kobj_pkt_show(struct kobject *kobj,
struct attribute *attr, char *data)
{
Expand Down Expand Up @@ -264,25 +255,24 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
{
struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
int val;
DECLARE_BUF_AS_STRING(dbuf, data, len); /* ensure sscanf scans a string */

if (strcmp(attr->name, "reset") == 0 && dlen > 0) {
if (strcmp(attr->name, "reset") == 0 && len > 0) {
pd->stats.pkt_started = 0;
pd->stats.pkt_ended = 0;
pd->stats.secs_w = 0;
pd->stats.secs_rg = 0;
pd->stats.secs_r = 0;

} else if (strcmp(attr->name, "congestion_off") == 0
&& sscanf(dbuf, "%d", &val) == 1) {
&& sscanf(data, "%d", &val) == 1) {
spin_lock(&pd->lock);
pd->write_congestion_off = val;
init_write_congestion_marks(&pd->write_congestion_off,
&pd->write_congestion_on);
spin_unlock(&pd->lock);

} else if (strcmp(attr->name, "congestion_on") == 0
&& sscanf(dbuf, "%d", &val) == 1) {
&& sscanf(data, "%d", &val) == 1) {
spin_lock(&pd->lock);
pd->write_congestion_on = val;
init_write_congestion_marks(&pd->write_congestion_off,
Expand Down Expand Up @@ -369,8 +359,7 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
size_t count)
{
unsigned int major, minor;
DECLARE_BUF_AS_STRING(dbuf, buf, count);
if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
pkt_setup_dev(MKDEV(major, minor), NULL);
return count;
}
Expand All @@ -381,8 +370,7 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
size_t count)
{
unsigned int major, minor;
DECLARE_BUF_AS_STRING(dbuf, buf, count);
if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
pkt_remove_dev(MKDEV(major, minor));
return count;
}
Expand Down Expand Up @@ -1377,7 +1365,7 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
&& pd->bio_queue_size <= pd->write_congestion_off);
spin_unlock(&pd->lock);
if (wakeup)
blk_clear_queue_congested(pd->disk->queue, WRITE);
clear_bdi_congested(&pd->disk->queue->backing_dev_info, WRITE);

pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
pkt_set_state(pkt, PACKET_WAITING_STATE);
Expand Down Expand Up @@ -2598,7 +2586,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
spin_lock(&pd->lock);
if (pd->write_congestion_on > 0
&& pd->bio_queue_size >= pd->write_congestion_on) {
blk_set_queue_congested(q, WRITE);
set_bdi_congested(&q->backing_dev_info, WRITE);
do {
spin_unlock(&pd->lock);
congestion_wait(WRITE, HZ);
Expand Down

0 comments on commit 83f3aa3

Please sign in to comment.