From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161368AbbBERSd (ORCPT ); Thu, 5 Feb 2015 12:18:33 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:58713 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754196AbbBERSc (ORCPT ); Thu, 5 Feb 2015 12:18:32 -0500 From: Laurent Pinchart To: Sergei Shtylyov Cc: Mike Turquette , Wolfram Sang , Geert Uytterhoeven , Stephen Boyd , Ulrich Hecht , Wolfram Sang , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate() Date: Thu, 05 Feb 2015 19:19:14 +0200 Message-ID: <4034374.lq5RZGeRAm@avalon> User-Agent: KMail/4.14.3 (Linux/3.17.7-gentoo; KDE/4.14.3; x86_64; ; ) In-Reply-To: <54D299D6.7060809@cogentembedded.com> References: <1423052841-15194-1-git-send-email-geert+renesas@glider.be> <54D29760.4010009@cogentembedded.com> <54D299D6.7060809@cogentembedded.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sergei, On Thursday 05 February 2015 01:14:46 Sergei Shtylyov wrote: > On 02/05/2015 01:04 AM, Sergei Shtylyov wrote: > >>>>> Anyone may call clk_round_rate() with a zero rate value, so we have to > >>>>> protect against that. > >>>>> > >>>>> Signed-off-by: Geert Uytterhoeven > >>>> > >>>> Acked-by: Wolfram Sang > >>>> > >>>> I agree that this should not be fixed in the core because the fixup is > >>>> really driver dependant. > >>>> > >>> Dunno, zero frequency seems generally insane to me. > >> > >> It is useful to find the lowest frequency a clock can support. Basically > >> it is a search for the floor frequency. > >> > > Why not just use 1? Or are you assuming that some hardware could actually > > support 0 Hz? > > Replying to myself: yes, this has happened to me, when I forgot to override > the EXTAL frequency in the board .dts file (default was 0). So it was a good thing that the driver crashed, it let you find a bug ;-) Jokes aside, a zero frequency is the usual way to find the lowest frequency, but I agree that there aren't many integers between 0 and 1. Mike, do you have an opinion ? -- Regards, Laurent Pinchart