Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715AbbBERqS (ORCPT ); Thu, 5 Feb 2015 12:46:18 -0500 Received: from mail-ob0-f181.google.com ([209.85.214.181]:59923 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750891AbbBERqQ convert rfc822-to-8bit (ORCPT ); Thu, 5 Feb 2015 12:46:16 -0500 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Laurent Pinchart , "Sergei Shtylyov" From: Mike Turquette In-Reply-To: <4034374.lq5RZGeRAm@avalon> Cc: "Wolfram Sang" , "Geert Uytterhoeven" , "Stephen Boyd" , "Ulrich Hecht" , "Wolfram Sang" , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org References: <1423052841-15194-1-git-send-email-geert+renesas@glider.be> <54D29760.4010009@cogentembedded.com> <54D299D6.7060809@cogentembedded.com> <4034374.lq5RZGeRAm@avalon> Message-ID: <20150205174610.421.31308@quantum> User-Agent: alot/0.3.5 Subject: Re: [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate() Date: Thu, 05 Feb 2015 09:46:10 -0800 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2099 Lines: 56 Quoting Laurent Pinchart (2015-02-05 09:19:14) > 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 ? Yes, I think we should support passing a zero rate for two reasons: 1) it's crazy to not sanitize a value that is passed into a function and used as a divisor. This is not really a shortcoming of the framework. 2) during the fractional divider discussion there was the idea of making unsigned long rate into something like millihertz. E.g. rate = 1000 is 1Hz. If we start cheating by passing a rate of 1 into .round_rate, then we've just created a bug for ourselves if we ever move to millihertz. Regards, Mike > > -- > Regards, > > Laurent Pinchart > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/