From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 217B5C433F5 for ; Thu, 17 Mar 2022 14:47:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE1ED833ED; Thu, 17 Mar 2022 15:47:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="tnjycEE4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B5EE83ADC; Thu, 17 Mar 2022 15:47:16 +0100 (CET) Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 85D11833ED for ; Thu, 17 Mar 2022 15:47:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 3C4E02223A; Thu, 17 Mar 2022 15:47:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1647528432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yXHLf4A3auXxLRyf1B9FJ/yblrJPFxeIA61V1Pt748A=; b=tnjycEE4zo3kVnPjn1CUp/lkAgX7nyuWVwVsiUl4YZ4IKYfP7Su+f6rOVVfFwCbGbdWNW/ JkpilVJ91+qdEUY8Ydygzd4PL7ztjwU7q4oGv0BrmYY6LD867AUDYw3+DJEC1lEqqYC4IV hLbo8jz98O/g0KhWFNvmrC1gn0s7snc= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 17 Mar 2022 15:47:11 +0100 From: Michael Walle To: Sean Anderson Cc: Heiko Thiery , u-boot@lists.denx.de, Marek Vasut , Angus Ainslie , Angus Ainslie , lukma@denx.de, sbabic@denx.de, festevam@gmail.com, uboot-imx@nxp.com, peng.fan@nxp.com Subject: Re: [RFC] serial: mxc: get the clock frequency from the used clock for the device In-Reply-To: <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> References: <20220317124127.1783768-1-heiko.thiery@gmail.com> <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <25046b02eb285f3f281cd003961e4900@walle.cc> X-Sender: michael@walle.cc X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean >> + struct clk clk; >> + if(!clk_get_by_name(dev, "ipg", &clk)) >> + rate = clk_get_rate(&clk); >> + } >> + >> + /* as fallback we try to get the clk rate that way */ >> + if (rate == 0) > > !rate || IS_ERR_VALUE(rate) This looked so weird I had to actually look at clk_get_rate() in u-boot. /** * clk_get_rate() - Get current clock rate. * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). * * Return: clock rate in Hz on success, 0 for invalid clock, or -ve error code * for other errors. */ ulong clk_get_rate(struct clk *clk); How can an ulong return a negative error value? What if the clock speed happens to be the same as -errno? -michael