From: "Randy.Dunlap" From: Michael Veeck Remove unnecessary min/max macros and change calls to use kernel.h macros instead. --- 25-akpm/drivers/message/fusion/mptbase.c | 14 +++++++------- 25-akpm/drivers/message/fusion/mptbase.h | 7 ------- 25-akpm/drivers/message/fusion/mptctl.c | 14 +++++++------- 25-akpm/drivers/message/fusion/mptscsih.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 30 deletions(-) diff -puN drivers/message/fusion/mptbase.c~fusion-use-min-max drivers/message/fusion/mptbase.c --- 25/drivers/message/fusion/mptbase.c~fusion-use-min-max Thu Feb 26 13:51:13 2004 +++ 25-akpm/drivers/message/fusion/mptbase.c Thu Feb 26 13:51:13 2004 @@ -2509,10 +2509,10 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepF * Set values for this IOC's request & reply frame sizes, * and request & reply queue depths... */ - ioc->req_sz = MIN(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4); - ioc->req_depth = MIN(MPT_MAX_REQ_DEPTH, facts->GlobalCredits); + ioc->req_sz = min(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4); + ioc->req_depth = min_t(int, MPT_MAX_REQ_DEPTH, facts->GlobalCredits); ioc->reply_sz = ioc->req_sz; - ioc->reply_depth = MIN(MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); + ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); dprintk((MYIOC_s_INFO_FMT "reply_sz=%3d, reply_depth=%4d\n", ioc->name, ioc->reply_sz, ioc->reply_depth)); @@ -3993,7 +3993,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER /* * Copy out the cached reply... */ - for (ii=0; ii < MIN(replyBytes/2,mptReply->MsgLength*2); ii++) + for (ii=0; ii < min(replyBytes/2, mptReply->MsgLength*2); ii++) u16reply[ii] = ioc->hs_reply[ii]; } else { return -99; @@ -4240,7 +4240,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc) if ((rc = mpt_config(ioc, &cfg)) == 0) { /* save the data */ - copy_sz = MIN(sizeof(LANPage0_t), data_sz); + copy_sz = min_t(int, sizeof(LANPage0_t), data_sz); memcpy(&ioc->lan_cnfg_page0, ppage0_alloc, copy_sz); } @@ -4285,7 +4285,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc) if ((rc = mpt_config(ioc, &cfg)) == 0) { /* save the data */ - copy_sz = MIN(sizeof(LANPage1_t), data_sz); + copy_sz = min_t(int, sizeof(LANPage1_t), data_sz); memcpy(&ioc->lan_cnfg_page1, ppage1_alloc, copy_sz); } @@ -4354,7 +4354,7 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int por if ((rc = mpt_config(ioc, &cfg)) == 0) { /* save the data */ pp0dest = &ioc->fc_port_page0[portnum]; - copy_sz = MIN(sizeof(FCPortPage0_t), data_sz); + copy_sz = min_t(int, sizeof(FCPortPage0_t), data_sz); memcpy(pp0dest, ppage0_alloc, copy_sz); /* diff -puN drivers/message/fusion/mptbase.h~fusion-use-min-max drivers/message/fusion/mptbase.h --- 25/drivers/message/fusion/mptbase.h~fusion-use-min-max Thu Feb 26 13:51:13 2004 +++ 25-akpm/drivers/message/fusion/mptbase.h Thu Feb 26 13:51:13 2004 @@ -1057,13 +1057,6 @@ extern int mpt_ASCQ_TableSz; /* * More (public) macros... */ -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - #ifndef offsetof #define offsetof(t, m) ((size_t) (&((t *)0)->m)) #endif diff -puN drivers/message/fusion/mptctl.c~fusion-use-min-max drivers/message/fusion/mptctl.c --- 25/drivers/message/fusion/mptctl.c~fusion-use-min-max Thu Feb 26 13:51:13 2004 +++ 25-akpm/drivers/message/fusion/mptctl.c Thu Feb 26 13:51:13 2004 @@ -283,7 +283,7 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME dctlprintk((MYIOC_s_INFO_FMT ": Copying Reply Frame @%p to IOC!\n", ioc->name, reply)); memcpy(ioc->ioctl->ReplyFrame, reply, - MIN(ioc->reply_sz, 4*reply->u.reply.MsgLength)); + min(ioc->reply_sz, 4*reply->u.reply.MsgLength)); ioc->ioctl->status |= MPT_IOCTL_STATUS_RF_VALID; /* Set the command status to GOOD if IOC Status is GOOD @@ -334,7 +334,7 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME // NOTE: Expects/requires non-Turbo reply! dctlprintk((MYIOC_s_INFO_FMT ":Caching MPI_FUNCTION_FW_DOWNLOAD reply!\n", ioc->name)); - memcpy(fwReplyBuffer, reply, MIN(sizeof(fwReplyBuffer), 4*reply->u.reply.MsgLength)); + memcpy(fwReplyBuffer, reply, min_t(int, sizeof(fwReplyBuffer), 4*reply->u.reply.MsgLength)); ReplyMsg = (pMPIDefaultReply_t) fwReplyBuffer; } } @@ -992,7 +992,7 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i MptSge_t *sgl; int numfrags = 0; int fragcnt = 0; - int alloc_sz = MIN(bytes,MAX_KMALLOC_SZ); // avoid kernel warning msg! + int alloc_sz = min(bytes, MAX_KMALLOC_SZ); // avoid kernel warning msg! int bytes_allocd = 0; int this_alloc; dma_addr_t pa; // phys addr @@ -1037,7 +1037,7 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i sgl = sglbuf; sg_spill = ((ioc->req_sz - sge_offset)/(sizeof(dma_addr_t) + sizeof(u32))) - 1; while (bytes_allocd < bytes) { - this_alloc = MIN(alloc_sz, bytes-bytes_allocd); + this_alloc = min(alloc_sz, bytes-bytes_allocd); buflist[buflist_ent].len = this_alloc; buflist[buflist_ent].kptr = pci_alloc_consistent(ioc->pcidev, this_alloc, @@ -2280,9 +2280,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_ */ if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) { if (karg.maxReplyBytes < ioc->reply_sz) { - sz = MIN(karg.maxReplyBytes, 4*ioc->ioctl->ReplyFrame[2]); + sz = min(karg.maxReplyBytes, 4*ioc->ioctl->ReplyFrame[2]); } else { - sz = MIN(ioc->reply_sz, 4*ioc->ioctl->ReplyFrame[2]); + sz = min(ioc->reply_sz, 4*ioc->ioctl->ReplyFrame[2]); } if (sz > 0) { @@ -2301,7 +2301,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_ /* If valid sense data, copy to user. */ if (ioc->ioctl->status & MPT_IOCTL_STATUS_SENSE_VALID) { - sz = MIN(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); + sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); if (sz > 0) { if (copy_to_user((char *)karg.senseDataPtr, ioc->ioctl->sense, sz)) { printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " diff -puN drivers/message/fusion/mptscsih.c~fusion-use-min-max drivers/message/fusion/mptscsih.c --- 25/drivers/message/fusion/mptscsih.c~fusion-use-min-max Thu Feb 26 13:51:13 2004 +++ 25-akpm/drivers/message/fusion/mptscsih.c Thu Feb 26 13:51:13 2004 @@ -3658,7 +3658,7 @@ mptscsih_target_settings(MPT_SCSI_HOST * if (nfactor < pspi_data->minSyncFactor ) nfactor = pspi_data->minSyncFactor; - factor = MAX (factor, nfactor); + factor = max(factor, nfactor); if (factor == MPT_ASYNC) offset = 0; } else { @@ -4716,7 +4716,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, in maxid = ioc->sh->max_id - 1; } else if (ioc->sh) { id = target_id; - maxid = MIN(id, ioc->sh->max_id - 1); + maxid = min_t(int, id, ioc->sh->max_id - 1); } for (; id <= maxid; id++) { @@ -5049,7 +5049,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *io sense_data = ((u8 *)hd->ioc->sense_buf_pool + (req_idx * MPT_SENSE_BUFFER_ALLOC)); - sz = MIN (pReq->SenseBufferLength, + sz = min_t(int, pReq->SenseBufferLength, SCSI_STD_SENSE_BYTES); memcpy(hd->pLocal->sense, sense_data, sz); @@ -5698,7 +5698,7 @@ mptscsih_domainValidation(void *arg) ioc->spi_data.forceDv &= ~MPT_SCSICFG_RELOAD_IOC_PG3; } - maxid = MIN (ioc->sh->max_id, MPT_MAX_SCSI_DEVICES); + maxid = min_t(int, ioc->sh->max_id, MPT_MAX_SCSI_DEVICES); for (id = 0; id < maxid; id++) { spin_lock_irqsave(&dvtaskQ_lock, flags); @@ -6374,7 +6374,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int por if (echoBufSize > 0) { iocmd.flags |= MPT_ICFLAG_ECHO; if (dataBufSize > 0) - bufsize = MIN(echoBufSize, dataBufSize); + bufsize = min(echoBufSize, dataBufSize); else bufsize = echoBufSize; } else if (dataBufSize == 0) @@ -6385,7 +6385,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int por /* Data buffers for write-read-compare test max 1K. */ - sz = MIN(bufsize, 1024); + sz = min(bufsize, 1024); /* --- loop ---- * On first pass, always issue a reserve. @@ -6740,9 +6740,9 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP } /* limit by adapter capabilities */ - width = MIN(width, hd->ioc->spi_data.maxBusWidth); - offset = MIN(offset, hd->ioc->spi_data.maxSyncOffset); - factor = MAX(factor, hd->ioc->spi_data.minSyncFactor); + width = min(width, hd->ioc->spi_data.maxBusWidth); + offset = min(offset, hd->ioc->spi_data.maxSyncOffset); + factor = max(factor, hd->ioc->spi_data.minSyncFactor); /* Check Consistency */ if (offset && (factor < MPT_ULTRA2) && !width) _