Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp863522pxf; Wed, 7 Apr 2021 13:35:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc67Ys0OAIgqZ4KRtoD77Gjn/xAjI7l2QvVCUYSOQrjEoY/+mt+vuNJd3aI4cBUbXYX+c6 X-Received: by 2002:a17:906:c0c1:: with SMTP id bn1mr5805133ejb.406.1617827723919; Wed, 07 Apr 2021 13:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617827723; cv=none; d=google.com; s=arc-20160816; b=feIpFDln5Xzl0Rh29tX6yfCAdPeCcgX1TnuZ/PxpoK2RbS+sRMx/F0rJ3h9sdQbWo/ +itZfKV0kjF14NmmFVq/wdUrS6ia4yNsJgh3BM9dHaPgZTxkpSluUxeoR7X+/GOrmyn/ mzAHdtfcvaImkMvFyBzbzYibqJYjzzQjQY1Vs5ZZeTNQzfmKsBcXudtj1QFlL2/LJbd/ hl4OX6yp/WiSxeZhrCeAb0HKhflR32q+M4EwvvhPeK2up6lZ2T3svqJgCgz7Ua36p70H uaUFgEnSjxsVgYucjl2TLl6aIxpEkHkok1tIpeWAR6VmqRFUcZN9xyvNh//AXphwSXKc q94Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=GCGwsX/ANMfF1r15YgaPl8CstyM0sdFXn03M4CSDOT8=; b=lwqin1GNqhFXzBG3rUkGIcXscKagxhQLCqyVbc6BuKcB44iVs7tISnU1aQjM0Yh++q 9Twf17HQOYgaoFDXVUDBCmtwQJ0FLF1t0jRDnlfjQIcQHqUnsofulU1CkNchrrJqQ3LH gDbWqEJ7e25P91fsKkrQHURsehduPGwQSPWmRJx6oMA9lGCH1x/qFcHKhjJT6e5VybTV pEYp3LUc3AOlE2ZCB8zRH69m/arUYoawdfy1lMuqawlda3ckwhooEN9x7HCWP/LGrvQL rpl13NYy9MyhigdQqTTwlBfRWUszIrfu8BnHwie8PxnrwOjjnAC1rJUaydoWseZByBoL DEGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si19439683ejj.290.2021.04.07.13.35.00; Wed, 07 Apr 2021 13:35:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242891AbhDGIck (ORCPT + 99 others); Wed, 7 Apr 2021 04:32:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:49711 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244949AbhDGIci (ORCPT ); Wed, 7 Apr 2021 04:32:38 -0400 IronPort-SDR: 26woun6F62rJtDQ9RnOjQHC7NiO+3jFNPeansRZ/F80Cu0DN4NvPn++cyr/sqyPIbfObQiu1cp Y8yieMcWQpLg== X-IronPort-AV: E=McAfee;i="6000,8403,9946"; a="213648064" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="213648064" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 01:32:14 -0700 IronPort-SDR: NbSLsRqgo5vTWbDeh7/ht5zJtyo1Nt8F8KOD6rhNicoY4gaYZuKIwDKuvV1SYo3ukSTb2yGDeV +4LIOjHKeavQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="421598177" Received: from mylly.fi.intel.com (HELO [10.237.72.57]) ([10.237.72.57]) by orsmga008.jf.intel.com with ESMTP; 07 Apr 2021 01:32:11 -0700 Subject: Re: [PATCH v6 3/5] i2c: add support for HiSilicon I2C controller To: Yicong Yang , wsa@kernel.org, andriy.shevchenko@linux.intel.com, linux-i2c@vger.kernel.org, Sergey.Semin@baikalelectronics.ru, linux-kernel@vger.kernel.org Cc: digetx@gmail.com, treding@nvidia.com, rmk+kernel@armlinux.org.uk, song.bao.hua@hisilicon.com, john.garry@huawei.com, mika.westerberg@linux.intel.com, prime.zeng@huawei.com, linuxarm@huawei.com References: <1617197790-30627-1-git-send-email-yangyicong@hisilicon.com> <1617197790-30627-4-git-send-email-yangyicong@hisilicon.com> From: Jarkko Nikula Message-ID: Date: Wed, 7 Apr 2021 11:32:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1617197790-30627-4-git-send-email-yangyicong@hisilicon.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 3/31/21 4:36 PM, Yicong Yang wrote: > + ret = device_property_read_u64(dev, "clk_rate", &ctlr->clk_rate_khz); > + if (ret) { > + dev_err(dev, "failed to get clock frequency, ret = %d\n", ret); > + return ret; > + } > + > + ctlr->clk_rate_khz = DIV_ROUND_UP_ULL(ctlr->clk_rate_khz, HZ_PER_KHZ); > + I'd use a temp variable here for reading the "clk_rate" property in Hertz and calculating the derived kHz value from it. As a bonus allow to use u32 for clk_rate_khz instead of u64. u32 will still provide plenty of headroom :-) Reason for temp variable is for me it's confusing to see statement like "rate_khz = rate_khz / 1000". Jarkko