From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17E511DA32 for ; Fri, 20 Oct 2023 14:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GRIir2VB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65A3C433C8; Fri, 20 Oct 2023 14:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1697812314; bh=WEpjgFcPeQJKLQYrLLB7W0sYAU1Nex9t/YsX/jHg8kg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GRIir2VB2uCvTMinb4tslLmOW2YakhXGfBsVmKz1btlcpi6XXOs0oQ6pRNg4+5Yzs lEETxsx3SqDEBRcRGqaRiK6Aq4JQo6hSk8Fyxusgj15xBTEFpmLDiX4gdquo5UhhqA dObczVTLNytqnwe4LJn92N1lxwORHsmVM9ibEVxA= Date: Fri, 20 Oct 2023 16:31:50 +0200 From: Greg Kroah-Hartman To: "Balas, Eliza" Cc: "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann Subject: Re: [PATCH v3 2/2] drivers: misc: adi-axi-tdd: Add TDD engine Message-ID: <2023102030-resort-glance-57ef@gregkh> References: <20231019125646.14236-1-eliza.balas@analog.com> <20231019125646.14236-3-eliza.balas@analog.com> <2023101917-cork-numeric-dab8@gregkh> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Oct 20, 2023 at 11:18:44AM +0000, Balas, Eliza wrote: > > > +static int adi_axi_tdd_parse_ms(struct adi_axi_tdd_state *st, > > > + const char *buf, > > > + u64 *res) > > > +{ > > > + u64 clk_rate = READ_ONCE(st->clk.rate); > > > + char *orig_str, *modf_str, *int_part, frac_part[7]; > > > + long ival, frac; > > > + int ret; > > > + > > > + orig_str = kstrdup(buf, GFP_KERNEL); > > > + int_part = strsep(&orig_str, "."); > > > > Why are we parsing floating point in the kernel? Please just keep the > > api simple so that we don't have to try to do any type of parsing other > > than turning a single text number into a value. > > > > The adi_axi_tdd_parse_ms function does almost the same thing as the > iio_str_to_fixpoint() function which already exists in kernel. That does not mean that this is a valid api for your device as you are not an iio driver (why aren't you an iio driver?) > It parses a fixed-point number from a string. And as such, you shouldn't duplicate existing logic. > The __iio_str_to_fixpoint is used in a similar way, as I intend to use adi_axi_tdd_parse_ms. > It writes to a channel the corresponding scale (micro,nano) for a value. Why not just have the api accept values in nanoseconds and then no parsing is needed? > Since the device is not an iio device, using an iio function would be confusing. Why isn't this an iio device? thanks, greg k-h