From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 97BB531A56D for ; Mon, 23 Feb 2026 17:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771866549; cv=none; b=tEEsF9w7XGel8/bhsw+eomenJnBnzc6690n0AWCHuloCtbi3CL252AaMzubhxD4cX+g1yfF2afvqhIoTj3ZzV9jq4fC+fatpV9CbUta4NS3TL2NzFAzbHcLzHtRDJmCcPvslDL2TowJauuZmIzBAKptFcY6rIHJR1kOuuo5cVms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771866549; c=relaxed/simple; bh=HOE1BWvTdGm81sVi4uOGNfO5U+qY0bIwnNqnBLA/63s=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XF13XrDEifBNSIV9ffmPQstusXhxGqXZ5suJWCaLt2UncocKNVMkvXnXRThtvTFU0nKxjbbdQblWldCRsC0C2+tO56wtaPHWD2mCaPs8gwZvm8FQES2QbpCj3IxnKiWWiLP3dcvvoTTZNwjNtT7+InQOa8IplFN5dgxZfNwGqFU= 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=CilFVtTu; arc=none smtp.client-ip=209.85.128.48 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="CilFVtTu" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-48069a48629so47331995e9.0 for ; Mon, 23 Feb 2026 09:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771866545; x=1772471345; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=PSoWMk7UM/e+NtDYxH8dhGcwAl8yWcJJT9+skqKp56I=; b=CilFVtTu9JhMh3nuePDuylRFaDulTSnXzR4rXmfSh5DzSDuqNKW0VUmvvHAu+XqdQs addqIcDICFac6v0N2ImJ6ITCRQVgL7jWUJGVcPehSTk1QwKDI3QeitCHrrZV1gl8erRy JdMFuOaXdAFH2MIpGRZxqL7e6bGTroOyY6WsduyUyN7w1JMWHOLSQEOp/I3Ty8bid3+M JFi2lWC99B7eFI5uWeqthTlTX5yd0CoTiPdFFqTOErSOMTcmaVmZc2eGzBecuTYVAulJ UQDUxkb5ECLxhOy/wv+IwIczB/4isQjdD1iZYt+670kenTiPxqMxnuKfzYz900r8agKJ ELiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866545; x=1772471345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PSoWMk7UM/e+NtDYxH8dhGcwAl8yWcJJT9+skqKp56I=; b=LA/AL57n44SaYqnwxWMha27jFUbMN8VJegL62fiURhbFeWuV9FhBl3B5JuHkj6GcRE TASx8FzcyaoOmObUC2ob0n8xuH4GCRft/eR0JVVoxmVa3B7QlqIGCWW+ggSQRjgepvN5 wO5UYxISJ316RGBM7GF/52Dqhzi8bKRZ6nLFXdglERsZwYOZ3tBT9BZDdzPQf+weAg8P RW9CrD4ecNfHGOhCPVJk8hlSkHDhUT5MgjMU8FCKVXvovjbICB2L6duOrcvys6qQQatx CDHF+4QDd1zCX2eJRR2wu12dA1jBmcl6gaay5+n9inzTsVZ7kzMzACqeDgbOEUBVpVge J8kw== X-Forwarded-Encrypted: i=1; AJvYcCVuS7vP+CKJG8CHYDKccOehWew28lnQ7N/f7zMrppOT3C1V6uu+DFnVjA45UhvcQrp0VdmMDYrA2vxaOpg=@vger.kernel.org X-Gm-Message-State: AOJu0YwhszrrVjtm+K/3R5AbVRcYvdGK5Yn86iVdnfivHaiPxN9YuyiC vGe8HVC2X3ohPY13DKPlvZ5689O+TDrPa1yBk5O0Vi+18J1bNqfFTud3 X-Gm-Gg: AZuq6aL2LSHrHVoVrmW8bsqKVhZ+WHo/AYn1mQgymM31OqqekrZQ+1smSBGsreXmm9o 7k/AKSsnRZlt+cjSeccRRcGMEe6wuBVh317KSpXFSbmLfy2YmSrZcZqSVK1YpoQFqRLyO7mFsMt Sa9Z7Ytn+Mf8qdtwSBDUa3jfBj2WziWk5ckkEgpotxKr5kaJMRojpJrahIA2BthYniqG4C6Hqnn yYnSr7HW4CUX73bRkBubTy9+PPQeTTf2MgHQAyAAKgqlwPc/16sUg4kb0ZVO/s4ayzd31GI6HSW kE2Xcmr5+BVVvohtE2IQysFDDBniN+3gb2fRlsCxNhGEZvkKDQLurM+czqjniOaSx9NCb6p416Y 6xfh0f+YvIbSS0Qk2Iumkh5avLYwJhbkDjcUz4J7gFoMkzg5mo0L3JPYwZtYWJcVu6HClt2XoMy BLKdHoc5i/XGzbAIsS20q0C837pY/IUmU602nhvaom1/3Q+Wzmf5XUcaCV76OHJSlavYDDwReav fg= X-Received: by 2002:a05:600c:8716:b0:471:1717:411 with SMTP id 5b1f17b1804b1-483a95e9a7fmr160559565e9.24.1771866544616; Mon, 23 Feb 2026 09:09:04 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b75e51sm207415805e9.5.2026.02.23.09.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:09:04 -0800 (PST) Date: Mon, 23 Feb 2026 17:09:03 +0000 From: David Laight To: Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown Subject: Re: [PATCH v2 1/1] spi: pxa2xx: use min() instead of min_t() Message-ID: <20260223170903.5f3379b4@pumpkin> In-Reply-To: <20260223153117.2838840-1-andriy.shevchenko@linux.intel.com> References: <20260223153117.2838840-1-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 Mon, 23 Feb 2026 16:30:54 +0100 Andy Shevchenko wrote: > min_t(int, a, b) casts an 'u32' to 'int'. This might lead to > the cases when big number is wrongly chosen. On the other hand, > the SPI transfer speed rate is unsigned and driver uses signed type > for an unknown reason. Change the type of the SPI transfer speed > to be unsigned and convert to use min() instead of min_t(). > Reviewed-by: David Laight (but see below...) > Signed-off-by: Andy Shevchenko > --- > > v2: used u32 instead of unsigned long (David) > > drivers/spi/spi-pxa2xx.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c > index f7881a31e4cc..6291d7c2e06f 100644 > --- a/drivers/spi/spi-pxa2xx.c > +++ b/drivers/spi/spi-pxa2xx.c > @@ -796,7 +796,7 @@ static irqreturn_t ssp_int(int irq, void *dev_id) > * The function calculates parameters for all cases and chooses the one closest > * to the asked baud rate. > */ > -static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) > +static unsigned int quark_x1000_get_clk_div(u32 rate, u32 *dds) > { > unsigned long xtal = 200000000; > unsigned long fref = xtal / 2; /* mandatory division by 2, I've looked at the file... I think all the 'long' in that function can be 32bit. Especially if the code actually works on 32bit. There is also the stunning: do_div(fssp, 1 << 24); in the only bit that that does need u64. David > @@ -885,12 +885,12 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) > return q - 1; > } > > -static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) > +static unsigned int ssp_get_clk_div(struct driver_data *drv_data, u32 rate) > { > - unsigned long ssp_clk = drv_data->controller->max_speed_hz; > + u32 ssp_clk = drv_data->controller->max_speed_hz; > const struct ssp_device *ssp = drv_data->ssp; > > - rate = min_t(int, ssp_clk, rate); > + rate = min(ssp_clk, rate); > > /* > * Calculate the divisor for the SCR (Serial Clock Rate), avoiding > @@ -902,8 +902,7 @@ static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) > return (DIV_ROUND_UP(ssp_clk, rate) - 1) & 0xfff; > } > > -static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, > - int rate) > +static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, u32 rate) > { > struct chip_data *chip = > spi_get_ctldata(drv_data->controller->cur_msg->spi);