Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: gdth: reuse dma coherent allocation in gdth_show_info

gdth_show_info currently allocs and frees a dma buffer four times which
isn't very efficient. Reuse a single allocation instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Christoph Hellwig and committed by
Martin K. Petersen
8d22022c 9f475ebf

+5 -15
+5 -15
drivers/scsi/gdth_proc.c
··· 226 226 #endif 227 227 228 228 if (ha->more_proc) { 229 + size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str)); 230 + 229 231 /* more information: 2. about physical devices */ 230 232 seq_puts(m, "\nPhysical Devices:"); 231 233 flag = FALSE; 232 234 233 - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 235 + buf = gdth_ioctl_alloc(ha, size, FALSE, &paddr); 234 236 if (!buf) 235 237 goto stop_output; 236 238 for (i = 0; i < ha->bus_cnt; ++i) { ··· 325 323 } 326 324 } 327 325 } 328 - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 329 326 330 327 if (!flag) 331 328 seq_puts(m, "\n --\n"); ··· 333 332 seq_puts(m, "\nLogical Drives:"); 334 333 flag = FALSE; 335 334 336 - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 337 - if (!buf) 338 - goto stop_output; 339 335 for (i = 0; i < MAX_LDRIVES; ++i) { 340 336 if (!ha->hdr[i].is_logdrv) 341 337 continue; ··· 406 408 seq_printf(m, 407 409 " To Array Drv.:\t%s\n", hrec); 408 410 } 409 - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 410 411 411 412 if (!flag) 412 413 seq_puts(m, "\n --\n"); ··· 414 417 seq_puts(m, "\nArray Drives:"); 415 418 flag = FALSE; 416 419 417 - buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); 418 - if (!buf) 419 - goto stop_output; 420 420 for (i = 0; i < MAX_LDRIVES; ++i) { 421 421 if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master)) 422 422 continue; ··· 462 468 hrec); 463 469 } 464 470 } 465 - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); 466 - 471 + 467 472 if (!flag) 468 473 seq_puts(m, "\n --\n"); 469 474 ··· 470 477 seq_puts(m, "\nHost Drives:"); 471 478 flag = FALSE; 472 479 473 - buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); 474 - if (!buf) 475 - goto stop_output; 476 480 for (i = 0; i < MAX_LDRIVES; ++i) { 477 481 if (!ha->hdr[i].is_logdrv || 478 482 (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master)) ··· 500 510 } 501 511 } 502 512 } 503 - gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr); 513 + gdth_ioctl_free(ha, size, buf, paddr); 504 514 505 515 for (i = 0; i < MAX_HDRIVES; ++i) { 506 516 if (!(ha->hdr[i].present))