Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1896528rbb; Tue, 27 Feb 2024 04:58:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWv7Qn7E6RAPJ3I9g016qWs5jy04QEAVJF7zFFH6d+kW58elKt4nr32zxmP2/ou6y8erlHKmW7kl+1TO2Qkg/SYmdrKa20itjD2dXuYOw== X-Google-Smtp-Source: AGHT+IEB2B6yQiG1VaTyDX/cp512dtWbrtTn/g6biZSxMtNxy8so+LOv0TEVEUhJsEJigjltc+LH X-Received: by 2002:a25:a24a:0:b0:dc6:dd45:bd1c with SMTP id b68-20020a25a24a000000b00dc6dd45bd1cmr1940739ybi.52.1709038683409; Tue, 27 Feb 2024 04:58:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709038683; cv=pass; d=google.com; s=arc-20160816; b=AgJ8GocSfBwNzVacB5z5/SnuMo6SRlfes4vWukFltmAFLzPmeJG36XmuKst0xoJlUy yG2JfzNfuKXQvwiJvstBQHKOQD6VYOGMYzBLjtWe1gEjcX5120Dffe+TJmaoMrPs3wPe XxaONqRrG8mczI0+eYGPgJLA0uGjl+J9uNfSk1AaLdTYeHknUjfgBDKg47/XcD0upM6U ML0ZJ9aM8Spq95SwntaqwIinCTY5Wn51eDPt1FwWw+c+dEjf3ZwwH0h8iLBfu/VwNUmQ 3OFkbPsvvS7WYOVVPmtzQd2EIVbleZW1Mxd3SXfcTUFydmOLftL7610GpZCLYmoqFElV DrWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=YeT2rPCyhTWBBjp7LhR2heyPVPdkgjfjdUkU51rViJU=; fh=6h4UlClfhOiMnP0kI+jpjRUx1mCqU5Tubh29rld0kZk=; b=FwWwFaH6x+AY/1oli984CXbkMwZtgHwSJgS8T2skLeqOQehWJ1pjrhD6zpjDEMuwp6 d+1Aa6toTqhY5U/qZ3fsi2to5ebdDFEr1qDiSTRXqQKCg3+gAD3QY/Km2bhaqcYbe0IT +glmYopC8u+M+ZRgAcfG3tUrEsC6UEjnQOtckl3qaeBi2lDf1ibwuueGqtzgdZIvl7KA +kGhI+U9B14m0D662yW8eNojULi5iVhzEroicP7sjzPuZxbX9dl93kYOXQjNDhiGLc0G glmOY3UPqFYGVhfaQtEayr6pZGjyVg5GFA4DK08BUpNTSoYXUpcgWkdaYEwz2dtC4tem iETA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-83271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83271-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g12-20020ac8480c000000b0042e7b1eb6a4si5634839qtq.643.2024.02.27.04.58.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 04:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-83271-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83271-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 11F131C21858 for ; Tue, 27 Feb 2024 12:58:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B27A713AA20; Tue, 27 Feb 2024 12:57:47 +0000 (UTC) Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 294E0135A5C for ; Tue, 27 Feb 2024 12:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709038667; cv=none; b=Fwnu8AdyW9CHJePQOS8uYdzUbgSVS5RWzDMca472WKuhUmGaKIKF4k58tsog3l5w0Q5fjnyRVyyqZ7dKM32N66CWmibJnjlU+4K9l+1MWXQ8QHdD+WEXukAlR/N26NBhoXW+0OFs6WFAjk5PoO9wGGM0IbUljuxnjyCz6px1CWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709038667; c=relaxed/simple; bh=rLuWRYY4nrBUkzXuyIyoCtcyMvzxxNjHaMWHuiSTGqo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R84fzr3nZRt/1ZqfLq6ljmcc7+4mZKdBqZUk+ZRNDhTNMNLJU1Pk2v9+HidOZ+xwFxXyqz6Kaq+YZtgr12FsQ0bAKzdvq/7xrxkZcwnYDATru2rFLPVnQ1bxOPyz3SbzCuk+Y1Fi2dgiiiW6jmVnjPPG+lMTxMwe8CD8GcB1LP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1rex1I-0004YG-2F; Tue, 27 Feb 2024 12:57:16 +0000 Date: Tue, 27 Feb 2024 12:57:07 +0000 From: Daniel Golle To: Zhihao Cheng Cc: Richard Weinberger , Miquel Raynal , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Message-ID: References: <186fa96ae25f7033ff8b6f0f7fcfb1e602f556fc.1708971705.git.daniel@makrotopia.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Feb 27, 2024 at 10:23:17AM +0800, Zhihao Cheng wrote: > 在 2024/2/27 2:23, Daniel Golle 写道: > > A compiler warning related to sizeof(int) != 8 when calling do_div() > > is triggered when building on 32-bit platforms. > > Address this by using integer types having a well-defined size where > > appropriate. > > > > Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes") > > Signed-off-by: Daniel Golle > > --- > > drivers/mtd/ubi/nvmem.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c > > index b7a93c495d172..5820a170d2512 100644 > > --- a/drivers/mtd/ubi/nvmem.c > > +++ b/drivers/mtd/ubi/nvmem.c > > @@ -23,14 +23,17 @@ struct ubi_nvmem { > > static int ubi_nvmem_reg_read(void *priv, unsigned int from, > > void *val, size_t bytes) > > { > > - int err = 0, lnum = from, offs, bytes_left = bytes, to_read; > > + uint32_t bytes_left, offs, to_read; > > struct ubi_nvmem *unv = priv; > > struct ubi_volume_desc *desc; > > + uint64_t lnum = from; > > + int err = 0; > > desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY); > > if (IS_ERR(desc)) > > return PTR_ERR(desc); > > + bytes_left = bytes; > The 'bytes' is a size_t type, which has 64 bits on 64-bit platforms. This > assignment will lead a type truncation, so should we add a explicit type > conversion here to avoid compiler warning? Oh right. I reckon the best is to declare 'bytes' as 'size_t' type as well then. I will send v2 with that change shortly. > > offs = do_div(lnum, unv->usable_leb_size); > > while (bytes_left) { > > to_read = unv->usable_leb_size - offs; > > > > > ______________________________________________________ > Linux MTD discussion mailing list > http://lists.infradead.org/mailman/listinfo/linux-mtd/