From patchwork Tue Nov 12 15:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872442 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AC4A2038A2; Tue, 12 Nov 2024 15:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427112; cv=none; b=baXwR7oOToObOKTTdFzFn9gqhPiGhlM7gcHKVQSkjSiqwW9YmJiXVjjSPA2sA7F2XZjNJKPRT4Aqivrab9JQb6VGgNEEFu4/nVv5Wb6PxXiNfzHBmkdH53SfLLUkJ5Y29o0ahPnuGpJvOwbxeOmGPLURW/vfHYnatoZp6lCeD5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427112; c=relaxed/simple; bh=wC9mZ39C44jdIYeQTKZVxRinkEPaPJNuk0gKXTbFhyY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oHm0Kd18K2RIJSvuuj8XnilNW0GaiXNF01hAD8M7C0EJ4h3GSBUZEN0A3SuX5u8jOtUVcGaMDPWIF7FcR5vs+t3sYmRbSBop5brmFmiXufPVaDXZ8fBwJQYuHjO33kPes6nU8eUI1uu4josAk0fab1OpbTGQ12ggyVUT9ExANnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b0PmKXXL; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b0PmKXXL" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-37d4821e6b4so4133922f8f.3; Tue, 12 Nov 2024 07:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427108; x=1732031908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VLrKR8h0hMM7F++0PtBceneF9LUpCKVWB9g0O0i5f7A=; b=b0PmKXXLreUICb/X96rLy2D7GXUgtGUFO34MOtv7FRbxbX/6aGBkO8dcttHD9a/ijM +0vrpFuaDelUgGcHTKpm6nK4U8XFjfuARcQAQam1tdFRI0NFLwSeD0jiadboPKv7p9sK ADJ2JwDOJzBZOoMnd6vbwryKnChABT32lSI4owEYvPfyCqJUzLBO9keF1F4KcXk6Nwwm caZoVWWLZUodKK9+U49g/mlzORVU6ivZ6Z/Lx9CnTlhIQkJ8v6yEx+ldNrBjL0MihXn1 VsIyjXUiUBTVzJR5HAjG0iUwh8Nvxf26h/bZY6FklwJqDINpNyeV5Xl57oysfGNskc7k /9xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427108; x=1732031908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VLrKR8h0hMM7F++0PtBceneF9LUpCKVWB9g0O0i5f7A=; b=JcO8JdXqzfV2QJxSoEKzz0kZVWG61TZ9b0KOAgrMLFeTvIF9eRgPZLr/TLq7aPUu42 s/H0wBU4U3/BZx5ZY1oGdgRQMEHjuDJO20mlrBNest0AUmhayNFqlB2sCNaXJ6y7JDQ3 SwdwSvMCi+PODaV3AGsm5x4VWPsjMn3jG54JwN+x+sIBZUYBAWaHgwI/YwJ68yhgRsWS nNzOI6oZD7QWRGrS8AshQHT6oMYyIKWdrIft7waMt+oIUe0Uhb7Ne+y+Hwer1+QDGJkl IcRNG/ly1Jj7rqCtDX5BZx5GUAAxwiMhvXzerPqmkCfclAbTUvSOGYY2LQzrxeZZ1AW+ Nj0g== X-Forwarded-Encrypted: i=1; AJvYcCVxHUAVULLFOJqlINQvEAUjoPfu3RpI7sT081XimUwBBbKS0Qs9wg/qNViZ33mQc2BkzvEu66GiPNM=@vger.kernel.org X-Gm-Message-State: AOJu0YyoR0nEo81RKtnc9MvZQdDrFfxSIqhsKXHpXNVGwiEtMTt/s/nk pH7fqSXBw0CV3ZXIxhjty9FZ/GYLG1HZShSCD3bG5iLQ33ui44zU X-Google-Smtp-Source: AGHT+IF3sw83754J0k0uX9EzFSvgiWJVjoGFNkxu6Hq3hSCgGmn6YnA7dLKZdiABcowBY9Z5P5qLlA== X-Received: by 2002:a05:6000:1849:b0:37d:4fab:c198 with SMTP id ffacd0b85a97d-381f1872412mr13268838f8f.26.1731427108114; Tue, 12 Nov 2024 07:58:28 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:27 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 1/8] drivers/usb/gadget: refactor min with min_t Date: Tue, 12 Nov 2024 20:58:10 +0500 Message-Id: <20241112155817.3512577-2-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t() instead of casted min(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/gadget/composite.c | 12 ++++++------ drivers/usb/gadget/configfs.c | 2 +- drivers/usb/gadget/function/f_fs.c | 6 +++--- drivers/usb/gadget/function/f_mass_storage.c | 8 ++++---- drivers/usb/gadget/function/uvc_video.c | 4 ++-- drivers/usb/gadget/legacy/raw_gadget.c | 4 ++-- drivers/usb/gadget/udc/omap_udc.c | 4 ++-- drivers/usb/gadget/usbstring.c | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index f25dd2cb5d03..8e8c3baa9d7e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1844,7 +1844,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) cdev->desc.bcdUSB = cpu_to_le16(0x0200); } - value = min(w_length, (u16) sizeof cdev->desc); + value = min_t(u16, w_length, sizeof(cdev->desc)); memcpy(req->buf, &cdev->desc, value); break; case USB_DT_DEVICE_QUALIFIER: @@ -1863,19 +1863,19 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) case USB_DT_CONFIG: value = config_desc(cdev, w_value); if (value >= 0) - value = min(w_length, (u16) value); + value = min_t(u16, w_length, value); break; case USB_DT_STRING: value = get_string(cdev, req->buf, w_index, w_value & 0xff); if (value >= 0) - value = min(w_length, (u16) value); + value = min_t(u16, w_length, value); break; case USB_DT_BOS: if (gadget_is_superspeed(gadget) || gadget->lpm_capable || cdev->use_webusb) { value = bos_desc(cdev); - value = min(w_length, (u16) value); + value = min_t(u16, w_length, value); } break; case USB_DT_OTG: @@ -1930,7 +1930,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) *(u8 *)req->buf = cdev->config->bConfigurationValue; else *(u8 *)req->buf = 0; - value = min(w_length, (u16) 1); + value = min_t(u16, w_length, 1); break; /* function drivers must handle get/set altsetting */ @@ -1976,7 +1976,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) if (value < 0) break; *((u8 *)req->buf) = value; - value = min(w_length, (u16) 1); + value = min_t(u16, w_length, 1); break; case USB_REQ_GET_STATUS: if (gadget_is_otg(gadget) && gadget->hnp_polling_support && diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index c82a6a0fba93..6499a88d346c 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1184,7 +1184,7 @@ static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page, struct gadget_info *gi = os_desc_item_to_gadget_info(item); int res, l; - l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1); + l = min_t(int, len, OS_STRING_QW_SIGN_LEN >> 1); if (page[l - 1] == '\n') --l; diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 2920f8000bbd..2ccf7f4e4db1 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -456,7 +456,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, } /* FFS_SETUP_PENDING and not stall */ - len = min(len, (size_t)le16_to_cpu(ffs->ev.setup.wLength)); + len = min_t(size_t, len, le16_to_cpu(ffs->ev.setup.wLength)); spin_unlock_irq(&ffs->ev.waitq.lock); @@ -590,7 +590,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf, /* unlocks spinlock */ return __ffs_ep0_read_events(ffs, buf, - min(n, (size_t)ffs->ev.count)); + min_t(size_t, n, ffs->ev.count)); case FFS_SETUP_PENDING: if (ffs->ev.setup.bRequestType & USB_DIR_IN) { @@ -599,7 +599,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf, goto done_mutex; } - len = min(len, (size_t)le16_to_cpu(ffs->ev.setup.wLength)); + len = min_t(size_t, len, le16_to_cpu(ffs->ev.setup.wLength)); spin_unlock_irq(&ffs->ev.waitq.lock); diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 08e0d1c511e8..2eae8fc2e0db 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -500,7 +500,7 @@ static int fsg_setup(struct usb_function *f, *(u8 *)req->buf = _fsg_common_get_max_lun(fsg->common); /* Respond with data/status */ - req->length = min((u16)1, w_length); + req->length = min_t(u16, 1, w_length); return ep0_queue(fsg->common); } @@ -655,7 +655,7 @@ static int do_read(struct fsg_common *common) * And don't try to read past the end of the file. */ amount = min(amount_left, FSG_BUFLEN); - amount = min((loff_t)amount, + amount = min_t(loff_t, amount, curlun->file_length - file_offset); /* Wait for the next buffer to become available */ @@ -1005,7 +1005,7 @@ static int do_verify(struct fsg_common *common) * And don't try to read past the end of the file. */ amount = min(amount_left, FSG_BUFLEN); - amount = min((loff_t)amount, + amount = min_t(loff_t, amount, curlun->file_length - file_offset); if (amount == 0) { curlun->sense_data = @@ -2167,7 +2167,7 @@ static int do_scsi_command(struct fsg_common *common) if (reply == -EINVAL) reply = 0; /* Error reply length */ if (reply >= 0 && common->data_dir == DATA_DIR_TO_HOST) { - reply = min((u32)reply, common->data_size_from_cmnd); + reply = min_t(u32, reply, common->data_size_from_cmnd); bh->inreq->length = reply; bh->state = BUF_STATE_FULL; common->residue -= reply; diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index 57a851151225..23064626ddb7 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -78,7 +78,7 @@ uvc_video_encode_data(struct uvc_video *video, struct uvc_buffer *buf, /* Copy video data to the USB buffer. */ mem = buf->mem + queue->buf_used; - nbytes = min((unsigned int)len, buf->bytesused - queue->buf_used); + nbytes = min_t(unsigned int, len, buf->bytesused - queue->buf_used); memcpy(data, mem, nbytes); queue->buf_used += nbytes; @@ -104,7 +104,7 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video, } /* Process video data. */ - len = min((int)(video->max_payload_size - video->payload_size), len); + len = min_t(int, video->max_payload_size - video->payload_size, len); ret = uvc_video_encode_data(video, buf, mem, len); video->payload_size += ret; diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c index 112fd18d8c99..20165e1582d9 100644 --- a/drivers/usb/gadget/legacy/raw_gadget.c +++ b/drivers/usb/gadget/legacy/raw_gadget.c @@ -782,7 +782,7 @@ static int raw_ioctl_ep0_read(struct raw_dev *dev, unsigned long value) if (ret < 0) goto free; - length = min(io.length, (unsigned int)ret); + length = min_t(unsigned int, io.length, ret); if (copy_to_user((void __user *)(value + sizeof(io)), data, length)) ret = -EFAULT; else @@ -1168,7 +1168,7 @@ static int raw_ioctl_ep_read(struct raw_dev *dev, unsigned long value) if (ret < 0) goto free; - length = min(io.length, (unsigned int)ret); + length = min_t(unsigned int, io.length, ret); if (copy_to_user((void __user *)(value + sizeof(io)), data, length)) ret = -EFAULT; else diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index 61a45e4657d5..38b1d90d026f 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -576,13 +576,13 @@ static void finish_in_dma(struct omap_ep *ep, struct omap_req *req, int status) static void next_out_dma(struct omap_ep *ep, struct omap_req *req) { - unsigned packets = req->req.length - req->req.actual; + unsigned int packets = req->req.length - req->req.actual; int dma_trigger = 0; u16 w; /* set up this DMA transfer, enable the fifo, start */ packets /= ep->ep.maxpacket; - packets = min(packets, (unsigned)UDC_RXN_TC + 1); + packets = min_t(unsigned int, packets, UDC_RXN_TC + 1); req->dma_bytes = packets * ep->ep.maxpacket; omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, ep->ep.maxpacket >> 1, packets, diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 75f6f99f8173..37a2f1b61cba 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -55,7 +55,7 @@ usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf) return -EINVAL; /* string descriptors have length, tag, then UTF16-LE text */ - len = min((size_t)USB_MAX_STRING_LEN, strlen(s->s)); + len = min_t(size_t, USB_MAX_STRING_LEN, strlen(s->s)); len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN, (wchar_t *) &buf[2], USB_MAX_STRING_LEN); if (len < 0) From patchwork Tue Nov 12 15:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872443 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BB7D20400C; Tue, 12 Nov 2024 15:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427114; cv=none; b=Oun0EbCYZRDCoBgfv3OR76xwUcr/DgyH8MRi3IElF71EyArmg/UtTiSlVA2F+Mmf7kwd0bw4oZka6X7ePaa7+bCiSSLIpM5nyTshwmHyaRplSU8KXz+zbHWz5fz3BYtpkkPsCXfzi3cHo9uGfs0eUyMDAbLue11FnsjnVu0kypg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427114; c=relaxed/simple; bh=uSU/VtQn1QUlbG4Wl5WZNMTR0aFBqiE+k0MLbiJaaKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dfF5HrGt8iMOrasVyUx9MXsqK6MgMyxuf20pySq8IpUgiYoYALGAgFvjomCZkf9CabCXPPF1GQQzUOqv2Bqu237wRI0SCWEkdeT34CQnjINjCmTHHjoBErj+HnncxdwfgVohYsmEYs52KNVk9355BYoG0CDSRB8yVhbWTdMFkMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cphwKQ9m; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cphwKQ9m" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-381ee2e10dfso3420349f8f.0; Tue, 12 Nov 2024 07:58:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427111; x=1732031911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DGw6mWqyKGhSGEz0pcciGxD/rSjc8N2yFhLNVJVJUYM=; b=cphwKQ9mAQz5vqIY9GruKjMwl/0OimzX7MBAsCPyRjl7XlvgbdiQ5yTDg4a+vDrXyI X4FJWGAaS/IckpZlmaUb61kkLJtRzLQHk3XcQ3hOntzsx6fZ7UtQGFObv/VVsfgOz2jX TtYnKbMqN9qrzTU2FE2DJrl+7k9K8a+b+4xSnpSQZEyWBAEYSV/YH09lTjMpbooM9FD+ FCQtiaE6mXdbGhUUpJRtAxIlhQaLUg7v2M728FgLuPSaaig5bQ1ADCj+CXFaZpWA/988 WE5ySrrHmH4dJGFNSRazVzpuj1GynV+UoQu6X9ZkiNBOJxRo3QxR/o/YZlDhulRzXXrF 7QOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427111; x=1732031911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DGw6mWqyKGhSGEz0pcciGxD/rSjc8N2yFhLNVJVJUYM=; b=h4+wUyFUdhWYMQnaqZ0IT0gBZovwI5vhT61FdbphCyjb8w8LpWY/cYLdYPZo4iECf+ x3tKiFqx1HHkIovcLXB7escPvPQL9NmFPeqkPqRbDj+K4n3N+dBq3M6OfAkegcnlCYNo TbmuAzROhhMIU+3NiWvw+3gr7hunVRaUcp6bJVfSfE1XdnqD/f7wR8aRD08RidiBv24Q P6LkUXcVCyxvuF/eUYQDU0KGnYSdcciC/Uv4GVF0ibb4pXRpI8L5B795mQKG/BvILy93 nNyw5q260q3xQatiq3jXOzsY+96obofJSF8tQNtsHkDvlPrgqovY0HDKWwvXeWtDYLVd 0lig== X-Forwarded-Encrypted: i=1; AJvYcCVoR0hXbBWkwTkTadeyd34m86WtChSPrfXgyPBZRBqmhzjzsz+AqZcG3qSdyJIaGc5XKswTs7c1FBY=@vger.kernel.org X-Gm-Message-State: AOJu0YxKYJ8mi85YEjfue+dN/i4lRYvg5i03YcMDUNA4muVVVDitEjdo ZkEF/c6A0xh14Ar/zi1RazGOS78HPACnZaLyYEGOtHHadVeoRxaKgBneKCThOuA= X-Google-Smtp-Source: AGHT+IEbyNeqX/7SF/IGuqdiiAfXFJz/3cccPl3GxFMxGzcm+w5FZmI77IrTrDi6ZFwOa2K4uuRVLA== X-Received: by 2002:a05:6000:2a2:b0:37d:5257:41bd with SMTP id ffacd0b85a97d-381f1862d93mr14320340f8f.3.1731427111188; Tue, 12 Nov 2024 07:58:31 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:30 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 2/8] drivers/usb/core: refactor max with max_t Date: Tue, 12 Nov 2024 20:58:11 +0500 Message-Id: <20241112155817.3512577-3-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using max_t() instead of max(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/core/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 880d52c0949d..25a00f974934 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -924,7 +924,7 @@ int usb_get_configuration(struct usb_device *dev) result = -EINVAL; goto err; } - length = max((int) le16_to_cpu(desc->wTotalLength), + length = max_t(int, le16_to_cpu(desc->wTotalLength), USB_DT_CONFIG_SIZE); /* Now that we know the length, get the whole thing */ From patchwork Tue Nov 12 15:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872444 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14CA9206E6E; Tue, 12 Nov 2024 15:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427117; cv=none; b=KhrVvOSR4a/7Q9S4Q1SDpof4k3ry5lZzqEcOtIpN33PgTmkzMYO7O+5TtlFi8zfUExonu6ZTzfN0WbfWS6q5vjOWQo90+NPud4YrD/3tEDvbVyrNJCgtkmmPKD9st0/2rNKKZ3yayxI51V2cSBMeLHnsvTtXUyi2r8qbBp6X1MQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427117; c=relaxed/simple; bh=kx9RV/7hh8OxwyU6O/CqIX9Yzgup8/L0Sqd2aGul450=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W5Ja3ZBv0Xq+R6E/xbhSp6PoTR9VaPMm0YJmMD56uPgtgpNld6iHicgCLMsGSYuv+joZEuQEXYxouNWME1ZQQdjdyrpEn7+/PnwTsJQP/9b4hDAMWzSitoi2R9HBvxqO26dVHNBFMZMfOjxaxJIRyzAP5KW1i71imvcpgb7rBlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DhODKlZ3; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DhODKlZ3" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4315c1c7392so51784405e9.1; Tue, 12 Nov 2024 07:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427114; x=1732031914; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jKbcoc75O9Cb98zpsIShjH5Q68sP76O0sTpNDdmUgyw=; b=DhODKlZ3B+oSCMcRT7Iy8x+r1xllM4m1xtrqb5GCG/LVmfrxkpeyXh1XU95+jmNwt7 aPXZ7l0SDhXSbGKLILVBwUKahCyphbW9sUBKTaYSMwgfzTzUv+4DGsRnl5Dumk6bjdjk dfFU7HmQ2adbC5FWBxYCNObD3Gfzpfg2u6HXXH2cvbAUMjJqKul1pEWcLdjhdT9lE3sC Ysr7kgz24D7lglyMT3XFrRz7oahnRZBlCzUrmZnr3cvyBhB7fY1matZ68F5PMIEAQ5Fg 6wCZPHn4hbKce62/vbzsyYCXINeOP8eX7vcr9VXyEYs+cPn6HGVKSOikn7hjB+rrvPRz Ehsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427114; x=1732031914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jKbcoc75O9Cb98zpsIShjH5Q68sP76O0sTpNDdmUgyw=; b=RSlEWcqPrn+MPtR0N7B08C/S8OqBfzY1DABZpOPpLb3oDrsdw67qJSkjywSYlmVQBH BKz3OEUlVU7Cd5nv3GEFUjD5UMJD8N87d5K+7OnMityl/W/69navb7MqnakFz/wjisdg DV1FiI3Sy3dRO9dyuCp3sEEnXrODnV37AKATVExyrUWxa60na4WoC189OTv+pFxyMGEi dmnC9DZaX9EcP46oX3Rg8PkHpgdpcx9wdfZ+5ZwfwB2/IHnSD5vLBgAuEIfoIpw/KFqo IIgwzmQFNthnr5R5DuO/mPvolORuRKvm02W7U6fhYjCfJSmCXos4v0abbhCmfBgZjx1w KJuQ== X-Forwarded-Encrypted: i=1; AJvYcCXWTzuPShf/FRqVBa1uv8XGR4eIuTh3dQ5DyiDFmo+TXDZe+nyCOic367mLfmMhAnpFED8k9UBKXlc=@vger.kernel.org X-Gm-Message-State: AOJu0YyLrFTm6Cva9ci8ykSJWVy4+SlvgdIU+0uXbXqBevIAXxYgiq1j 0e/ji0TB9pmB4e+aVb/pLCq+0PguRgPcGplUMB0/YcS6zlhBMVWX X-Google-Smtp-Source: AGHT+IHFM0NmW34275yJbQeBGl/55ILfHlCyt7SGKx4KH7xPXJmZehxAQekfXV7mMWXzQaSI1omRNw== X-Received: by 2002:a05:6000:402a:b0:37d:5103:8894 with SMTP id ffacd0b85a97d-381f1881319mr13351957f8f.42.1731427114129; Tue, 12 Nov 2024 07:58:34 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:33 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 3/8] drivers/usb/host: refactor min/max with min_t/max_t Date: Tue, 12 Nov 2024 20:58:12 +0500 Message-Id: <20241112155817.3512577-4-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t/max_t instead of casted min/max. Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index cbc0b86fcc36..6de79ac5e6a4 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -547,7 +547,7 @@ static int ehci_init(struct usb_hcd *hcd) * make problems: throughput reduction (!), data errors... */ if (park) { - park = min(park, (unsigned) 3); + park = min_t(unsigned int, park, 3); temp |= CMD_PARK; temp |= park << 8; } diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index ca3859463ba1..eaa34ee0a535 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -902,7 +902,7 @@ static int oxu_buf_alloc(struct oxu_hcd *oxu, struct ehci_qtd *qtd, int len) /* Find a suitable available data buffer */ for (i = 0; i < BUFFER_NUM; - i += max(a_blocks, (int)oxu->db_used[i])) { + i += max_t(int, a_blocks, oxu->db_used[i])) { /* Check all the required blocks are available */ for (j = 0; j < a_blocks; j++) @@ -3040,7 +3040,7 @@ static int oxu_hcd_init(struct usb_hcd *hcd) * make problems: throughput reduction (!), data errors... */ if (park) { - park = min(park, (unsigned) 3); + park = min_t(unsigned int, park, 3); temp |= CMD_PARK; temp |= park << 8; } diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 6576515a29cd..d693fdfaa542 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -1336,7 +1336,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) buf = (void *)urb->transfer_buffer + urb->actual_length; urb_len = urb->transfer_buffer_length - urb->actual_length; } - bufsize = min(urb_len, (int) td->maxpacket); + bufsize = min_t(int, urb_len, td->maxpacket); if (rcv_len <= bufsize) { size = rcv_len; } else { From patchwork Tue Nov 12 15:58:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872445 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96009206E9B; Tue, 12 Nov 2024 15:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427120; cv=none; b=XYplMtBWuOEzseh9EG3iH+vXaihXAOX6BQ4IwMS9C5hWtyw+oIAFQ9LcBlHO2Tzu2bcsOzdZ9RY0GBhChUzB/28Ff8JbY6wuGtPBvCPJSv8hhEnyt26nwKxIWVe4q1JjNifgXshEf1SpEClnzf+RONWdSxlrsyGHKWnLZxMqdEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427120; c=relaxed/simple; bh=O4AvFer74LkEoJ32uQUsWCZt7z9HiKEdzSP0dkJ7rZc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nnoPCu1OS/B+pi56IIhRp/DeGZiyqUp4A947FS/qMXYtCM3I9XrJUHOScWXcLsB1dNEoW3qGe3btjdEF5isCm4bOpNkf3C4n73t1WbDIaaKwuwAF3QeU/EdOhgaQnmk7FW2Uel8idvjBfN3MJwUiwq2g6mZ4E2vjUXvtpz4S7r8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mhQUZYXV; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mhQUZYXV" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-37d4ba20075so3930943f8f.0; Tue, 12 Nov 2024 07:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427117; x=1732031917; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YdY3Vsmu+IF4zfDZEiWUDqDaXm10hp+1m/IbDQWsUjk=; b=mhQUZYXVz6NXeOfHKXlobY2zySWtMvCgUQVKzf/obSf+d0ZMWEisp7YCl6Hbc+dlO4 2tHPJ2sxxu9f3GR4wek5+ZgJbDTr1VX6FbJ6kdj89gFi0fDBlfCxesPfrIkAQacAwTKP P3C1TSfghcsLcK8gJDTRR1YH3sHhQ3FXzY+/21hotWiityb9c7Dl7BhPI7RdcmDkhLZ9 iNIuqVyCbfGOf7se9JV8iiBwPHKL/sOTXfXgSDawdPfpT3FQ7w1VrlTQNZ5GEdp6G8Fj +fetrOe9Hvoh0P9JTmUqUxRTAfkKJJAKQZJvlTzNCpcAAWtnch87ICfXYQY+HbKdhPwg MvFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427117; x=1732031917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YdY3Vsmu+IF4zfDZEiWUDqDaXm10hp+1m/IbDQWsUjk=; b=f7YK4vRUfieO+IE5ePv7+xJLR7hSFfKDnJiY8deim8Ur37iJ6Gjor0rhX0JeKAx1QO b/diiRrk0FzlgYRCupg9m+RAzhmaReopotqtxbJ8QzJKorLXC3CCxguXTqqzKHHKpz4L BywLrtagtM02bT35U2ygBQI9+o0MUutuqb11Qi7+AzA+IJLixKVvAamu/zGq517Z5GNU Fwteup/iHPjEp86Kzx9vtMlnnh1nTGQaXkwfo1Q1MAtyd9HQ+T9sr2Li7y3/beNVjbrI Eyh8FrrUo4jH1F5YQGe4xQrfGWj3fU3wTum6Pd77wK/xsZRH9aVFyP4afEXpFelJFIZa eykg== X-Forwarded-Encrypted: i=1; AJvYcCVKXFHwN2ZgfCYM31ZhW2IxiBmasHD2ey5KEKWvKnY5EDdKm+1krbgSt1g/+QvdPtW/G6j6gAy8mqw=@vger.kernel.org X-Gm-Message-State: AOJu0YxsJK2sl2JgMptkOCs79eNgOhd0IjcDHN0K6chfcdt7zr9pxzaM zFOa3wvnmKuPQGlrIeixb3/thKW/ECfwPW3RXd567YuTkcibEZf8 X-Google-Smtp-Source: AGHT+IEk5cRyDkDwbtRzoRMZemPPxSCgDgj1ja1/Qas1wY9h9mscgWXEcczgtTnkR7b7cd4xSSzqtw== X-Received: by 2002:a05:6000:4009:b0:382:424:94ff with SMTP id ffacd0b85a97d-38204249572mr4094085f8f.18.1731427116898; Tue, 12 Nov 2024 07:58:36 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:36 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 4/8] drivers/usb/misc: refactor min with min_t Date: Tue, 12 Nov 2024 20:58:13 +0500 Message-Id: <20241112155817.3512577-5-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t() instead of min(). Also add the explicit `unsigned int` as scripts/checkpatch.pl warns about: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/misc/usbtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index caf65f8294db..8d379ae835bc 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -2021,7 +2021,8 @@ static struct urb *iso_alloc_urb( for (i = 0; i < packets; i++) { /* here, only the last packet will be short */ - urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp); + urb->iso_frame_desc[i].length = min_t(unsigned int, + bytes, maxp); bytes -= urb->iso_frame_desc[i].length; urb->iso_frame_desc[i].offset = maxp * i; From patchwork Tue Nov 12 15:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872446 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23A8620720E; Tue, 12 Nov 2024 15:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427122; cv=none; b=E7NSMQQXtG2g5Mr2tXuggAyewLA/aaRQs1dBIAUJ3Flkb5GrUP1Ip0po7qRsixOHy8DlJ4F+4CZf/OLC6tdGWJTCEsAEnfqh6xfFDdsjCP9fnRMZPlpwx6P8s3zmzpQRn53qsAM3DpJzxZpAv2Y4UN6UC0ARc6NJjJDI+PiK6J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427122; c=relaxed/simple; bh=WzQuvL1qaXh0RlfWv8D0x8WAvSbMA0OdN3Q2Ejhekms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i4GZ20WD0/yHWCFvJoyhdxbvD163WnsKFcGebNP35oGAVDyOon4llPSHIM+IHXHNfRAwao7pvWnyFJVzFVNqVNtu/AAdbCaRsBh/Q4pVP/gkvsazFaGCsS7UTQhev6yvQ35iFcjgwerZ6EbXdqFZcClJfxApoaHFI2W/k/8rSug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XDey1Oft; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XDey1Oft" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so49136885e9.0; Tue, 12 Nov 2024 07:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427119; x=1732031919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/a3ScA4GKVwMKEp5bNwzhgLvy/jMX4sk0gqCJ9bcam4=; b=XDey1OftcG3JqSn+PdZ4QJueC5CatfC6Wk2YoifNsqrtjru9sdf7jmRsHEWBSSi+89 fGqMl4q8PlHKwb8Ri3fV6L9fWw3OQYhecwqCx6yqGFveY/98q65vRwJIyNbcmlHz+aHh v7HLdVABCmh2DWDCnK5g5b0bZBRFKB8icKBAMw18r4aKRSFpmjhpoNEZoXYzEmo5GPXT Idd8fIkIcg2DfLANCUXrhgunPnTvxBaTJ/pGMu8l9V1J+4OjUgX6pTKWcaTCDO4NNBhy sUm18PknimbkSTUPmMnBhXbkfv4DDLrqADF5Tnfr4CcwhgESY5avVa5FBRFnu7mOOjKR v+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427119; x=1732031919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/a3ScA4GKVwMKEp5bNwzhgLvy/jMX4sk0gqCJ9bcam4=; b=HU+Un16dzMmfD7Z4vplZt6O3QhPDge4IwLU5w0ELt/+w7rJM63b2lwzcuyTiRYoqLz xgu/JZE4Aje09gYTiANX4Z0a/8ZPcGkrjZHva4EcOms3fF0Rd9iQlQexkx+V6XVzeqJx Hd058PLx+HdeFzchiaIV8TRo7rqSCcN7NtEN1AJ84zma61GNvNQlh9eFTwJUwGNqyRmf 0kef9mMk8GXpiF3Qvf21aBKN9mq6pSqbFl9P/fhJwQRLGkqErn7vKNgn/6CTbE5F5EOE zJSn2pLxi5+PZ+c70Qd0MCQoRd9gPBO4BmXBqKT5Bjl7bWAIDvgmReumMfkaABrlr+jo 3o6A== X-Forwarded-Encrypted: i=1; AJvYcCVoG+J+fNIBb1vuNDs2NJP+HeIN5P0XxRyQVoeDd8+6XNDv89E411D50EuWpr/yujQR4Nv8duXpQxE=@vger.kernel.org X-Gm-Message-State: AOJu0YwDMg+MCf182BQuSc0wR8g+q3YvBytI27njgz1ZSi8fzMt7UNY+ biAGc3Ups8NBahKfQhnkvF7NR8FWbHjAsR5x+tKhrH4L3FFkHbTZ X-Google-Smtp-Source: AGHT+IGKhg0idjgcZB7nZV/8fQC70huh7z1KhT3us97vMBFd4YuUTyplBPiFYDRAuAdW3/aRHr0ETQ== X-Received: by 2002:a05:6000:2a1:b0:381:cffc:d419 with SMTP id ffacd0b85a97d-381f183f682mr14837750f8f.36.1731427119405; Tue, 12 Nov 2024 07:58:39 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:39 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 5/8] drivers/usb/mon: refactor min with min_t Date: Tue, 12 Nov 2024 20:58:14 +0500 Message-Id: <20241112155817.3512577-6-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t() instead of casted min(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/mon/mon_bin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index afb71c18415d..c93b43f5bc46 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -823,7 +823,7 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf, ep = MON_OFF2HDR(rp, rp->b_out); if (rp->b_read < hdrbytes) { - step_len = min(nbytes, (size_t)(hdrbytes - rp->b_read)); + step_len = min_t(size_t, nbytes, hdrbytes - rp->b_read); ptr = ((char *)ep) + rp->b_read; if (step_len && copy_to_user(buf, ptr, step_len)) { mutex_unlock(&rp->fetch_lock); From patchwork Tue Nov 12 15:58:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872447 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88FC22076BC; Tue, 12 Nov 2024 15:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427125; cv=none; b=dII9gbDq8/di/coZnjMULhZLc1a0sve4GeTcSsQKxnm/EgP+NcaTTB7ZpBL8gcpeAckjKXJ5mj5+TWBk7tCS8g3wdE2uNSgCbe394ZSWBN20YPVfYjHM5D6pV+DpQ+mnSJUC7oX/s/fYhcXJ0qBvOyWCqJTLQkGsxefiIjroeDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427125; c=relaxed/simple; bh=xYrNNORV/XYxgedcM6FRYBpcFd78+3NGOiIjPUINCKo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tm8tmnEn5gBjkm+nGNz1dLMxbMSHdZwgBbPXZwgogyYg3mPmQxCGHodhmXmxr6WywpTms0EDPTWrd34LbUMYOuh0l8nzr5DD8r7xb7BHNK3fUNCRUF14Bjwxmvk1PW8XcoFkKDZnL2e+N8rpZXt7tsbjCjZIbPMAd8R3B+x2LWM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L6vvqgMJ; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L6vvqgMJ" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37d808ae924so3625044f8f.0; Tue, 12 Nov 2024 07:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427122; x=1732031922; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/MKCUUUxJD/2v5EQc5z8RrUear+TyL1L5ShZEVqt3HE=; b=L6vvqgMJ7Y4N3MhvjDcweBGvWBPNO3Kn6PstDX2SenbaOq+c/a3Ojla/O8wYt06vRn u6ad3O0l+W0AOby1dkLfW/0vnKXkhxGNL32LaaEVuK53wXjyeEVvrTrcxPsZs1vMGpOY SyDhrfD/OI1KYlSLBP6ZpVzVHz3F8dTZXVi7gTqCEBaGc/QMYW+394rtiTUKjkzjduW3 S5YsIofz5UieJDF3Zueron3IOZAJypN2am7C/o2ApelqrWOC6U5+tNexB3WXUtoqiaWH WPQ3TCUfLkMtgL+2GsJI8i+TzLI619EOufiqvo836Xf/mAHp5DR5UFhKupCheJE1J2vO SbXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427122; x=1732031922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/MKCUUUxJD/2v5EQc5z8RrUear+TyL1L5ShZEVqt3HE=; b=jQwaaS0sIvANgNlmkuT85aXUEaENDuYR/0bHF0xnOKLN/D9azZl7CizuVOqNqa6lLH bfxJweGMoK7wxGs3a8UVILvFJ0TQk+5y0ruEheQJck4hgqUWxfipy67VBXX68ftRjfKw 0SA++1Xn32mTj0euLOFDBXFsyGm3a4/WJ65LBhT+y/03EBhSBo7bRg4uS5MDNnaGuw4Y vWlEIz5rTCQY9Hml71wrEKCnfMQOZa761b3lLkomJ4UgJlZxe/cQGMW5JNVttOnUKr2w e1UIJ/YKDTSlG4p4+b3ljteNTrB6cMmsW5sNFtLx93/VHZqJ7UlXID6gbwBZ3au5NyLm 4KYA== X-Forwarded-Encrypted: i=1; AJvYcCW5/5O3iklo0YycxsqGeCARZg3LTnkp/cOt/5QmV7a6VThXrz/pGgOj6wQ6yCla0NHSHKQtkNgy5zM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7dRRKB4EZZ/ctDLmMKTXqYIJb0ps7ozOXC8C0nCHeOs7Zxtxo D5XRkIOQZ6dlSx7/wcL3wTysgdH3tQXZudLEfTaGREmff8CsBPp/bjRwoexdKpI= X-Google-Smtp-Source: AGHT+IEajO2qYrPwbD2tIZK1Vgen3l8STSY7cu7vIlq85YMMKzVkH1SjjAa0k8mT+T5zrhdk31a1gQ== X-Received: by 2002:a5d:64c5:0:b0:37d:52e3:e3f0 with SMTP id ffacd0b85a97d-381f1883da1mr14716985f8f.44.1731427121902; Tue, 12 Nov 2024 07:58:41 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:41 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 6/8] drivers/usb/musb: refactor min/max with min_t/max_t Date: Tue, 12 Nov 2024 20:58:15 +0500 Message-Id: <20241112155817.3512577-7-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t()/max_t() instead of casted min()/max(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/musb/musb_core.c | 2 +- drivers/usb/musb/musb_gadget_ep0.c | 2 +- drivers/usb/musb/musb_host.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index b24adb5b399f..61f3aee7b72e 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1387,7 +1387,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, /* expect hw_ep has already been zero-initialized */ - size = ffs(max(maxpacket, (u16) 8)) - 1; + size = ffs(max_t(u16, maxpacket, 8)) - 1; maxpacket = 1 << size; c_size = size - 3; diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 6d7336727388..f0786f8fbb25 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -533,7 +533,7 @@ static void ep0_txstate(struct musb *musb) /* load the data */ fifo_src = (u8 *) request->buf + request->actual; - fifo_count = min((unsigned) MUSB_EP0_FIFOSIZE, + fifo_count = min_t(unsigned, MUSB_EP0_FIFOSIZE, request->length - request->actual); musb_write_fifo(&musb->endpoints[0], fifo_count, fifo_src); request->actual += fifo_count; diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index bc4507781167..732ba981e607 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -798,10 +798,9 @@ static void musb_ep_program(struct musb *musb, u8 epnum, } if (can_bulk_split(musb, qh->type)) - load_count = min((u32) hw_ep->max_packet_sz_tx, - len); + load_count = min_t(u32, hw_ep->max_packet_sz_tx, len); else - load_count = min((u32) packet_sz, len); + load_count = min_t(u32, packet_sz, len); if (dma_channel && musb_tx_dma_program(dma_controller, hw_ep, qh, urb, offset, len)) From patchwork Tue Nov 12 15:58:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872448 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16650204923; Tue, 12 Nov 2024 15:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427127; cv=none; b=WDSy/JVBge12Wfs61fjXcyyUdKd4Q03crnYV9xzynT5Vw55KOTbgljuHw9iEaV0X9oNp0WY2xZMhPGLIRosuz8M4pyiVeOluKO6M9+YzTMCSFAXBCfb1xyYXsEJoJMjjGhOJuPfQ/GLDr8Ma74WYr9wBLgjW5v8TvWmsewq52UU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427127; c=relaxed/simple; bh=C0mc3QtPKj7pyUeJbmesl6Jpo/WFOyAGxSSnADDScRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D2h+rvPFG0ZQ5s+FH39GoPhJFC8xWazsi+hwX15KQszBr90ln+jk6Ay43MTJgi03+tVVOXrICmWudbkd4jWsjaZMEUowgDonsaGdorghTmMWYeUpwfXiNa05g1RZURkAvvE1fQWzTmFb+X0nGqn8kVEOcF/2m1LY4VXH3aqM3FQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q86UTpPb; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q86UTpPb" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-381ee2e10dfso3420553f8f.0; Tue, 12 Nov 2024 07:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427124; x=1732031924; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hL4i3B/UuK7CLhkZCi41Y+0eVdaffsWKjLCivALdDZE=; b=Q86UTpPbknkYM+yeEpJpH2CSiFEf0KWPQoj58QtILQR0b7sLp7Vs0z66OS5fbmKN6G II8Z8l+QYu9y742PpphRQQhrlOPivuWOmI5hMiKpfx2oew0Ndgx4JuB5rRw5lmoIIv9y xTYWlGH6I/fSHLk/BXbIASXK2ZUkSjXZ7o83CIN2IZBYc6Bct1hN1eb8jc0ElL3MKIvi ZBLPEGM0SUhoAN2z0BmaZe7wsGcriVvoUmrDr+x00Xdc4QqxzfperHPlR7OXgqtwZ9Qh HX2/hS1zL434S/ZXmWtonIAcY2riXLlKm8HolXIQmfz7RC86HjjHB29clXtUiWO6xqWS Moog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427124; x=1732031924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hL4i3B/UuK7CLhkZCi41Y+0eVdaffsWKjLCivALdDZE=; b=EWBcm+pYiainhRa+8+yHd67MUK12+begjkTsHOlV+NxFSvb8oZ4k12sEG+7cxgszlI dYA3QX3CTyYz/J9XgEHYeiO/NClUOJz0F4xiS6RHDZoF32cjPL2Ul+LQgd6C0gwBQWll Vf9HyOB04sRpbuRcULMFHwLQo082qhRW9rF5Cuce15dPEr59BsnhI6bpRic3lNFnexRF pJGqyQQ/qZmPMPhWhunUGdscUlTxOxWSKfQnbXIPKx6PCnxzq1TTKCtERjNSezYZtiAL 5XFYftp2lgDc2co669Ph8GuaU8gyhCzV1KM8R0P73XkimVvSAg70UbDof2cAHZ0+Xrq8 06kw== X-Forwarded-Encrypted: i=1; AJvYcCWqV+sGKpsvW8xn7jU9OptCzupntmIAtjICiVSHE5EG3/Z9PmfVF4QqB0AEVU8pxJurT635GKiy/SI=@vger.kernel.org X-Gm-Message-State: AOJu0YxI0DMnnRspAc1scZ58QgmJmLkaS7fx3vuu75MaigyDt899d+mb k43UOOEuOUvFhYRNOKNav+SmS60+iB/5iwSiaXUacI8AC0A9258G X-Google-Smtp-Source: AGHT+IHTWrYa9MUCV9W4cVrxu0hAjA7rgOc+21HiHjz0mEh1o4esTS1xlbC5/MSRQ1zQr7aypigC3g== X-Received: by 2002:a05:6000:1f87:b0:37c:d20d:447c with SMTP id ffacd0b85a97d-381f186cbc9mr14886375f8f.29.1731427124479; Tue, 12 Nov 2024 07:58:44 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:44 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 7/8] drivers/usb/serial: refactor min with min_t Date: Tue, 12 Nov 2024 20:58:16 +0500 Message-Id: <20241112155817.3512577-8-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t() instead of casted min(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/serial/io_edgeport.c | 2 +- drivers/usb/serial/sierra.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 28c71d99e857..1fffda7647f9 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1129,7 +1129,7 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, spin_lock_irqsave(&edge_port->ep_lock, flags); /* calculate number of bytes to put in fifo */ - copySize = min((unsigned int)count, + copySize = min_t(unsigned int, count, (edge_port->txCredits - fifo->count)); dev_dbg(&port->dev, "%s of %d byte(s) Fifo room %d -- will copy %d bytes\n", diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 64a2e0bb5723..741e68e46139 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -421,7 +421,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, unsigned long flags; unsigned char *buffer; struct urb *urb; - size_t writesize = min((size_t)count, (size_t)MAX_TRANSFER); + size_t writesize = min_t(size_t, count, MAX_TRANSFER); int retval = 0; /* verify that we actually have some data to write */ From patchwork Tue Nov 12 15:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13872449 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8AAD20CCEF; Tue, 12 Nov 2024 15:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427130; cv=none; b=dfxdd7PxMChRRok1Dfalbgp2mLYzA08EISRFRqsbYwnXRUI1+GNvTxTpUcrwSxl/TYG4/J8evAqnODh0+b4jwQ/63lTxd8hwPawNIdtFcZPl8j6g3TuBG/pE4Nn5cBJEhzvPC3eOGL1WS3gs4M5oiYK/7vxII67hddE5IJEwtKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731427130; c=relaxed/simple; bh=BS+W4NLNitc/rh658uxhSObPTer0s+SXmyx9+eClOOU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b0Cv3uJIjPe7yiAR/SPslOPl2SCkvaDcHrxevb0lAHm/NC71rDeP5932gDm2W7yXe+IiMlk3HF7Nikb0sOH/Wv4cQQ+0HUNficb85MzQXE7ZgHE1rIedNX8iSp/HPlcDJW48JbrNeGqqCintdMW47iMy823RDlEGl0WFhlg+z5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NkDuRESP; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NkDuRESP" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37d495d217bso5321322f8f.0; Tue, 12 Nov 2024 07:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731427127; x=1732031927; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DPqm3+0wFCwqO/jzcOFah7stBZqw75yUdyOGq2gHnGA=; b=NkDuRESPY9x71FUm22u5rIDSH3CnTX04iuRRgQkCizoPM22h4g+ctrlPbyzdFTKXph 73BQ3Up0867piPZ/ufmSRHfbkbZXHRzT1wN5xzjQzL/MFqIy4JhFnyjtP+dNK8FDIuoo SmzdVANkpmEDA2KRMGNm8/5x/f8KZ7HQExt0qLyNyW1yEU5DUQ4bTw/dM0DkLPKSVV5J MRMroDUdZ3G7zOh7233R4IkrH67QMylyRLCePy4uekUH/z8HcLGtaRKFW/9jx5K729hC XhgS/YKqPbcOb6PP3lKxWJQMYPPIDdXtziYYNl5A+9udPlbGOMO7nq8rDLMaZwXarxyK 4JPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731427127; x=1732031927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DPqm3+0wFCwqO/jzcOFah7stBZqw75yUdyOGq2gHnGA=; b=YcZb6jO+9isep5qgZ91fex5oGQHOt8CsdOwWRt6QBn0ycFR4KYIHCKDtqypzcUXCKz BtP8244N42Jg3vSMECrSUmKXsDUSpRPT48gDnjzNpVYBuSj2uQyW+5upOcZC2+82h+t4 P+51uQPceD4kywfuzYJl762WZ5mTAtYsEPS0ozDxZlyrraSdAPDWdAjbv3JLrKpwcsuE FeiL9rzAd5Q1Krw0uLYMM4IVEWcb3ke7aUJhttpkDXsl0GXpv6INr+FbqVFentBLOxbT qnYeA1kwoMa72f4swYG7ycedDhwMVrx9mSlJYqH1T2BYJ5OwSwd827QZONPvHvKJwE/B WsNg== X-Forwarded-Encrypted: i=1; AJvYcCUhVZY3MKqz6ir6pBbfSAi30Ttc4o12d3d9BmYH2swZ50KqzoN19bIfZV2HxNTmJaiF0DnSHE39c8Y=@vger.kernel.org X-Gm-Message-State: AOJu0YytYb7pOF5R3wfVduC4cL5wXQDI92jaF8A6pZh8OKqIJi5efsNn kZzekzJDI4HR8ZANVqQ45FhN/J6ycDnV9bqGRUTaqq4frXTWHRI3 X-Google-Smtp-Source: AGHT+IGF1oY4L6RmN+BZPkWQctTMCBFmLlST8MkZ1QDOGfGAvINLvwrekWN3unxTDcmS+thQ/mgwCA== X-Received: by 2002:a05:6000:1564:b0:37d:4376:6e1d with SMTP id ffacd0b85a97d-381f1884855mr18317807f8f.41.1731427127167; Tue, 12 Nov 2024 07:58:47 -0800 (PST) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381edc1104asm15991136f8f.88.2024.11.12.07.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 07:58:46 -0800 (PST) From: Sabyrzhan Tasbolatov To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com, johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net Subject: [PATCH v2 8/8] drivers/usb/storage: refactor min with min_t Date: Tue, 12 Nov 2024 20:58:17 +0500 Message-Id: <20241112155817.3512577-9-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com> References: <2024111251-spill-hatchback-72da@gregkh> <20241112155817.3512577-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ensure type safety by using min_t() instead of casted min(). Signed-off-by: Sabyrzhan Tasbolatov --- drivers/usb/storage/sddr09.c | 4 ++-- drivers/usb/storage/sddr55.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 03d1b9c69ea1..30ee76cfef05 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -752,7 +752,7 @@ sddr09_read_data(struct us_data *us, // a bounce buffer and move the data a piece at a time between the // bounce buffer and the actual transfer buffer. - len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; + len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize; buffer = kmalloc(len, GFP_NOIO); if (!buffer) return -ENOMEM; @@ -997,7 +997,7 @@ sddr09_write_data(struct us_data *us, * at a time between the bounce buffer and the actual transfer buffer. */ - len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; + len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize; buffer = kmalloc(len, GFP_NOIO); if (!buffer) { kfree(blockbuffer); diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index b8227478a7ad..a37fc505c57f 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -206,7 +206,7 @@ static int sddr55_read_data(struct us_data *us, // a bounce buffer and move the data a piece at a time between the // bounce buffer and the actual transfer buffer. - len = min((unsigned int) sectors, (unsigned int) info->blocksize >> + len = min_t(unsigned int, sectors, info->blocksize >> info->smallpageshift) * PAGESIZE; buffer = kmalloc(len, GFP_NOIO); if (buffer == NULL) @@ -224,7 +224,7 @@ static int sddr55_read_data(struct us_data *us, // Read as many sectors as possible in this block - pages = min((unsigned int) sectors << info->smallpageshift, + pages = min_t(unsigned int, sectors << info->smallpageshift, info->blocksize - page); len = pages << info->pageshift; @@ -333,7 +333,7 @@ static int sddr55_write_data(struct us_data *us, // a bounce buffer and move the data a piece at a time between the // bounce buffer and the actual transfer buffer. - len = min((unsigned int) sectors, (unsigned int) info->blocksize >> + len = min_t(unsigned int, sectors, info->blocksize >> info->smallpageshift) * PAGESIZE; buffer = kmalloc(len, GFP_NOIO); if (buffer == NULL) @@ -351,7 +351,7 @@ static int sddr55_write_data(struct us_data *us, // Write as many sectors as possible in this block - pages = min((unsigned int) sectors << info->smallpageshift, + pages = min_t(unsigned int, sectors << info->smallpageshift, info->blocksize - page); len = pages << info->pageshift;