Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2470421pxj; Mon, 31 May 2021 03:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyunBDiYQfw5IGwd46o7l/F5np8zPTrmRn6YvZAYhqyXyYq2R6ZoP8Ws282aRRBwF82SAZi X-Received: by 2002:a02:5289:: with SMTP id d131mr20279210jab.121.1622455459258; Mon, 31 May 2021 03:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622455459; cv=none; d=google.com; s=arc-20160816; b=TlwT6GRqOgLvKaetb2CtZELBSeEGA1FvUFvZQhk0OgoMAN6sIUO8ArpQyFrsXy6tU1 xM4ABlWVJr7AR1Zy3Q0p6t5AdW/2dQk1WrR3g+w1GfpqWD/zy6UiqFo7Dci9KTJqimG2 vQp4t73w2E6VGf/WzNidnEo4tBDgvdVhWBHHm/vhflxPRlQA3Qhud1Msaau5otUYszBw LS53u7AnG/KtE97AXsUPz8INIc7svVya4ghuxEgSk5H5gS6q2EzOaAEyQlzIOf6VqkDO ufvFZMa0v6tmsCnpg9J8dalcZ/QMA3oIJ6uyOrxTlW6/zQRDjuYeDVgPXD/CSUAUJXQq 047g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=M8ypIbGCojMKHG/PDBsOfcrNR9gbQaGmeLY8YETAt9w=; b=qH+5zb/nvW5EE/SEXbgQZd84vv/kYQLEuYN3EAtTPvJq2Yz3+s2gjL5JH2wZuw0SUp GVyRl+JBuSnTiobhlHUaoEFRudpYY8eddhuSkvV1jmjZNTgGiInBBQ/YEgt2BJ7d/oIA byvV1RUJPlkqaMAYPYy5HKCH5XvztzwmTBpBHDYxpKrBAaEBz2l8gh0tY05W5SqWzDk5 cLptCkkDjwavMhyewf7XdT4qQBuMD0C2fUGY8EoNcwcCj9tIjrzQfomKJ0VvblgBa4PK x/RD3fj+wRmWQCSs18iE2gX58ZFCixGOQL4DF8YaQXl3CqJZ5ZrJDS8eHecsjzqSiYrt SXGw== 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 k2si15756316iow.30.2021.05.31.03.04.05; Mon, 31 May 2021 03:04:19 -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 S231211AbhEaKE7 (ORCPT + 99 others); Mon, 31 May 2021 06:04:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:3574 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbhEaKE4 (ORCPT ); Mon, 31 May 2021 06:04:56 -0400 IronPort-SDR: qJDjOufhdBRywiJM2WMUKgSRaCmk5yIztGsTT4+DtzH2IsXJxIK0h1jx8zpcr25x2X+87XXit3 L5YBEDR/yOBQ== X-IronPort-AV: E=McAfee;i="6200,9189,10000"; a="264523616" X-IronPort-AV: E=Sophos;i="5.83,236,1616482800"; d="scan'208";a="264523616" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2021 03:03:17 -0700 IronPort-SDR: R7TmoirUKoi5vXYZAGmOoI85Ey9fXqwPm7EYyUmaa7ResZBLfCTlzJULqeTZC0imwG27GsS7fw 22ixxb1exIzg== X-IronPort-AV: E=Sophos;i="5.83,236,1616482800"; d="scan'208";a="398924173" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2021 03:03:14 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lnelL-00G47N-El; Mon, 31 May 2021 13:03:11 +0300 Date: Mon, 31 May 2021 13:03:11 +0300 From: Andy Shevchenko To: Marc Kleine-Budde Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Thomas Kopp , Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski Subject: Re: [PATCH v2 1/2] can: mcp251xfd: Try to get crystal clock rate from property Message-ID: References: <20210526193327.70468-1-andriy.shevchenko@linux.intel.com> <20210531084720.6xql2r4uhp6ruzl6@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 31, 2021 at 12:58:29PM +0300, Andy Shevchenko wrote: > On Mon, May 31, 2021 at 10:47:20AM +0200, Marc Kleine-Budde wrote: > > On 26.05.2021 22:33:26, Andy Shevchenko wrote: > > > In some configurations, mainly ACPI-based, the clock frequency of the device > > > is supplied by very well established 'clock-frequency' property. Hence, try > > > to get it from the property at last if no other providers are available. > > > > return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver), > > > "Failed to get Transceiver regulator!\n"); > > > > > > - clk = devm_clk_get(&spi->dev, NULL); > > > + /* Always ask for fixed clock rate from a property. */ > > > + device_property_read_u32(&spi->dev, "clock-frequency", &rate); > > > > what about error handling....? > > Not needed, but rate should be assigned to 0, which is missed. > > > > + clk = devm_clk_get_optional(&spi->dev, NULL); > > > if (IS_ERR(clk)) > > > return dev_err_probe(&spi->dev, PTR_ERR(clk), > > > "Failed to get Oscillator (clock)!\n"); > > > freq = clk_get_rate(clk); > > > + if (freq == 0) > > > + freq = rate; > > > > ... this means we don't fail if there is neither a clk nor a > > clock-frequency property. > > The following will check for it (which is already in the code) > > if (freq <= MCP251XFD_SYSCLOCK_HZ_MAX / MCP251XFD_OSC_PLL_MULTIPLIER) { Even before, actually, /* Sanity check */ if (freq < MCP251XFD_SYSCLOCK_HZ_MIN || freq > MCP251XFD_SYSCLOCK_HZ_MAX) { > > I've send a v3 to fix this. > > You mean I have to send v3? > Sure! So, I am going to send a v3 with amended commit message and assigning rate to 0. -- With Best Regards, Andy Shevchenko