Skip to contentSkip to conversation

st: cleanup new_tape_buffer

PATCH In review Christoph Hellwig 2 participants 2 messages Jan 30, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 st: cleanup new_tape_buffer

- remove superflous forward prototype
- remove whitespace before function name
- update header comment
- remove from_initialization parametes. It was always 1, but should always be 0 because all callers can sleep
- use kzalloc
- remove variable 'got', it was always 0

drivers/scsi/st.c +5 -14
Index: scsi-misc-2.6/drivers/scsi/st.c
===================================================================
@@ -180,7 +180,6 @@
 
 static int modes_defined;
 
-static struct st_buffer *new_tape_buffer(int, int, int);
 static int enlarge_buffer(struct st_buffer *, int, int);
 static void normalize_buffer(struct st_buffer *);
 static int append_to_buffer(const char __user *, struct st_buffer *, int);
@@ -3574,35 +3573,27 @@
 
 
 
 
-/* Try to allocate a new tape buffer. Calling function must not hold
-   dev_arr_lock. */
+/* Allocate a new tape buffer. */
 static struct st_buffer *
- new_tape_buffer(int from_initialization, int need_dma, int max_sg)
+new_tape_buffer(int need_dma, int max_sg)
 {
-	int i, got = 0;
-	gfp_t priority;
+	int i;
 	struct st_buffer *tb;
 
-	if (from_initialization)
-		priority = GFP_ATOMIC;
-	else
-		priority = GFP_KERNEL;
-
 	i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
 		max_sg * sizeof(struct st_buf_fragment);
-	tb = kmalloc(i, priority);
+	tb = kzalloc(i, GFP_KERNEL);
 	if (!tb) {
 		printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n");
 		return NULL;
 	}
-	memset(tb, 0, i);
 	tb->frp_segs = tb->orig_frp_segs = 0;
 	tb->use_sg = max_sg;
 	tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
 
 	tb->in_use = 1;
 	tb->dma = need_dma;
-	tb->buffer_size = got;
+	tb->buffer_size = 0;
 
 	return tb;

}
@@ -3896,7 +3887,7 @@
SDp->request_queue->max_phys_segments);
if (st_max_sg_segs < i)
i = st_max_sg_segs;
- buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);
+ buffer = new_tape_buffer(SDp->host->unchecked_isa_dma, i);
if (buffer == NULL) {
printk(KERN_ERR
"st: Can't allocate new tape buffer. Device not attached.\n");

Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christoph Hellwig

- remove superflous forward prototype
- remove whitespace before function name
- update header comment
- remove from_initialization parametes. It was always 1, but should always be 0 because all callers can sleep

True in 2.6. The other allocations in the only caller (st_probe) could also be changed to use GFP_KERNEL.

Quoted 19 lines

- use kzalloc
- remove variable 'got', it was always 0

Index: scsi-misc-2.6/drivers/scsi/st.c
===================================================================

drivers/scsi/st.c +0 -1
@@ -180,7 +180,6 @@
 
 static int modes_defined;
 
-static struct st_buffer *new_tape_buffer(int, int, int);
 static int enlarge_buffer(struct st_buffer *, int, int);
 static void normalize_buffer(struct st_buffer *);
 static int append_to_buffer(const char __user *, struct st_buffer *, int);

drivers/scsi/st.c line 3579

Quoted 10 lines
drivers/scsi/st.c +2 -3
@@ -3574,35 +3573,27 @@
 
 
 
 
-/* Try to allocate a new tape buffer. Calling function must not hold
-   dev_arr_lock. */
+/* Allocate a new tape buffer. */
 static struct st_buffer *
- new_tape_buffer(int from_initialization, int need_dma, int max_sg)
+new_tape_buffer(int need_dma, int max_sg)

You could remove the newline instead of the blank to put the function type and rest of declaration to the same line.

Thanks for the cleanup.

Signature · 1 line
Kai