From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A54232E2F03 for ; Wed, 26 Nov 2025 09:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764148998; cv=none; b=SFerFnl/d4VpfvyLmfoChwQs7NwmbR1+M1a9pm382A5+mZAh7Dh45hrx1M8fwf+qg6wfwA0o5AmAFpnyPjXwCnc9epiVZeQZBzrl9fGMGyuCfIjaH32mWHCux8oG8issOJ0K2HZIFECFIJn2A02BDW7gr0e2QV71IASZMpE0Deo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764148998; c=relaxed/simple; bh=wixrgdMWvektAfki4LUuIuIMAc6wkVwerFO7SvnDyfg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GWwT/8AuDDrJF61nBAnLVkNwhZLVhilC+JA62ykbtbPyRGcJVe+OT9yArwzYYRXTPfX96BOB50vdUNYN4jY2qJjtPGVtY27SEzYIqfmF91WuwaR3MkaTulW6E/MQio6xQx+wP3SImozzKSmCg9NxnSmnNfbjYdrRtiw3d6UcfdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=runbox.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=ppmCTh9m; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=runbox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="ppmCTh9m" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vOBk2-008q5Z-0x; Wed, 26 Nov 2025 10:23:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date; bh=X7mv+EDXWUYP656BAyXTbXpNq08vOgz9UAI+XYQ2FOo=; b=ppmCTh9m6vlJvqJpoKUsFkw4BB 6CAlfmZ8tqjNpfd9DRduyfzVhfVAA87Fw+KAoQqM2n034UoVO1H26HYUW00ONFwcuaq5I8oWHBJYp R9il0+Xw6nE7ijwwN75chYVKEPejDE9xItYmhi32ZcckeZGmbOgWEayJRTfN9iAaaa70zB/GEy8xu YLn05HhtcysOFoBjZG+zkaBXisCs2W0sVmWSj9G0mZUAWokm2C2xeBfpZmnOChLv3Vp4D0jPGAL1o BIuGKLdmSbJX8bQk8NrbiXQFEBMFHj+7SJjLxhI+y0hpGV9Re2ewAWBjbTbZBhh31MBOqeaHTW9Ar yLMUZvOg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vOBk1-0001o0-FJ; Wed, 26 Nov 2025 10:23:13 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vOBjs-00DGBa-IJ; Wed, 26 Nov 2025 10:23:04 +0100 Date: Wed, 26 Nov 2025 09:22:58 +0000 From: david laight To: Andy Shevchenko Cc: Prajna Rajendra Kumar , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown Subject: Re: [PATCH v2 1/6] spi: microchip-core: use min() instead of min_t() Message-ID: <20251126092258.3bc4d92e@pumpkin> In-Reply-To: <20251126075558.2035012-2-andriy.shevchenko@linux.intel.com> References: <20251126075558.2035012-1-andriy.shevchenko@linux.intel.com> <20251126075558.2035012-2-andriy.shevchenko@linux.intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 26 Nov 2025 08:54:39 +0100 Andy Shevchenko wrote: > min_t(int, a, b) casts an 'unsigned int' to 'int'. This might lead > to the cases when big number is wrongly chosen. On the other hand, > the SPI transfer length is unsigned and driver uses signed type for > an unknown reason. Change the type of the transfer length to be > unsigned and convert use min() instead of min_t(). > > Signed-off-by: Andy Shevchenko Reviewed-by: David Laight > --- > drivers/spi/spi-microchip-core-spi.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/spi/spi-microchip-core-spi.c b/drivers/spi/spi-microchip-core-spi.c > index 16e0885474a0..08ccdc5f0cc9 100644 > --- a/drivers/spi/spi-microchip-core-spi.c > +++ b/drivers/spi/spi-microchip-core-spi.c > @@ -74,8 +74,8 @@ struct mchp_corespi { > u8 *rx_buf; > u32 clk_gen; > int irq; > - int tx_len; > - int rx_len; > + unsigned int tx_len; > + unsigned int rx_len; > u32 fifo_depth; > }; > > @@ -214,7 +214,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) > spi->regs + MCHP_CORESPI_REG_INTCLEAR); > finalise = true; > dev_err(&host->dev, > - "RX OVERFLOW: rxlen: %d, txlen: %d\n", > + "RX OVERFLOW: rxlen: %u, txlen: %u\n", > spi->rx_len, spi->tx_len); > } > > @@ -223,7 +223,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) > spi->regs + MCHP_CORESPI_REG_INTCLEAR); > finalise = true; > dev_err(&host->dev, > - "TX UNDERFLOW: rxlen: %d, txlen: %d\n", > + "TX UNDERFLOW: rxlen: %u, txlen: %u\n", > spi->rx_len, spi->tx_len); > } > > @@ -283,7 +283,7 @@ static int mchp_corespi_transfer_one(struct spi_controller *host, > spi->rx_len = xfer->len; > > while (spi->tx_len) { > - int fifo_max = min_t(int, spi->tx_len, spi->fifo_depth); > + unsigned int fifo_max = min(spi->tx_len, spi->fifo_depth); > > mchp_corespi_write_fifo(spi, fifo_max); > mchp_corespi_read_fifo(spi, fifo_max);