Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp299650pxu; Fri, 4 Dec 2020 03:43:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtzDQ9jhhKhObF2CIRKbOBgFrMJKo40rOpHqXgDd2Bk74LiwuF1fqQU/IDutBtwYhkn/vW X-Received: by 2002:a17:906:31d2:: with SMTP id f18mr6614880ejf.407.1607082181477; Fri, 04 Dec 2020 03:43:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607082181; cv=none; d=google.com; s=arc-20160816; b=tZbyOw8mf/ArnM+k5W8bayXIwqZxRbSw5LHdTHf2dUfFwQO/HDm6LEnzOacCnMX6fF fTy/eQx/if3H+oHKpjFivjuZJYpXEFO1QSuUpnuIdutjzPD1yFQ/cT5fwtdnBMsx0boF ol0s9iE1vUNe3lIxCgavUaX5xHT0giQD2hf6+AW0rUkO4rHxu4FGPQib0wxgmnDeTFyl uEEpuQIeZpj5J266/QwZvMsnkR73Q2TDTlQbPTlATONbXm+yZykKTZrxGsb7IR+DsN2D oV6H8S8Sr02+HhoU5htTNgKE2tTCpMRbiSUjxGc1sghmWoImJ8pJihsj3k0oWsaDiui7 MDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=exBJ0wxCFC+DAjgSdRFNf2bexKp0XAhBBcRQ54IRjMU=; b=dEOPvJnYKGhN47zlcOcWPpJZ+ermjSUyxzT9tYwh3c5dOcAoYx4qKJgbRf0W5Yz9Es OOO2U3StMThSVhCsyutpQAIWVgUrtR3wAR2Vl72cFIMCo0Zb8aIlNXnB2lnCJN67susy 7mXzvgZ1DQfq4+CMKUkn4HZhGg/MPso/usMC4GpEtbmcUCCQd5msyJKOkzX6PiNtosO6 uOA5jUjh/vR3zmd/SJm4Onn2i/wWI7tXLaws4S71fqvvEMa/HsVJHmb2kCN8q1JifHGs 1hH5IrHYj05AHcss20xUSkPpEamvWnmhcil99AmBI3m1AoUbOFi4Lxd7VQqtkPos/KKW mnxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mess.org header.s=2020 header.b=k91fdar8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c23si2725691edt.456.2020.12.04.03.42.38; Fri, 04 Dec 2020 03:43:01 -0800 (PST) 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; dkim=fail header.i=@mess.org header.s=2020 header.b=k91fdar8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387769AbgLDLlT (ORCPT + 99 others); Fri, 4 Dec 2020 06:41:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbgLDLlS (ORCPT ); Fri, 4 Dec 2020 06:41:18 -0500 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87151C0613D1; Fri, 4 Dec 2020 03:40:38 -0800 (PST) Received: by gofer.mess.org (Postfix, from userid 1000) id 74F6CC63B3; Fri, 4 Dec 2020 11:40:36 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1607082036; bh=X9lIo10egin06IAG613mKzLT1qTrqN6EI08M7P8iL14=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k91fdar8ih3LWqV4ABQ52GXceFOVNux9RtwLETtUZmOZgEWGLQvZHbooqWzFb2OHS vh/AORxGLnyumsBW+lAHt/ywhyogH+0jHnb91N1YJQmsxzVoM5g9+v6biDdm9BAdX3 sU0HthYz+/tj0JOwowyva6yjEaB+7AyhSfovWiP1MQn/e4cpcn6IDg2gafsUdQRz4x RO6ALNaTcx1WaMuN60+de9FFKYm0v2e8SuoRPDBWUxfTvJ1ecvCXLy8HBGMgy+34fl nmTDz9EbdCwuqqorzgFGbxndfsOXL7ht3MLwkmPweRe2I1EyWDzQMrMvlgvY96Tfq3 V9QuXxJzIgNig== Date: Fri, 4 Dec 2020 11:40:36 +0000 From: Sean Young To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Lino Sanfilippo , thierry.reding@gmail.com, lee.jones@linaro.org, nsaenzjulienne@suse.de, f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration Message-ID: <20201204114036.GB6547@gofer.mess.org> References: <202011281128.54eLfMWr-lkp@intel.com> <1606564926-19555-1-git-send-email-LinoSanfilippo@gmx.de> <20201129181050.p6rkif5vjoumvafm@pengutronix.de> <4683237c-7b40-11ab-b3c0-f94a5dd39b4d@gmx.de> <20201204112115.wopx5p5elgte7gad@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201204112115.wopx5p5elgte7gad@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 04, 2020 at 12:21:15PM +0100, Uwe Kleine-K?nig wrote: > Hello Lino, > > On Fri, Dec 04, 2020 at 12:42:15AM +0100, Lino Sanfilippo wrote: > > On 29.11.20 at 19:10, Uwe Kleine-K?nig wrote: > > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > > > you are sure that this won't discard relevant bits, please explain > > > this in a comment for the cursory reader. > > > > What about an extra check then to make sure that the period has not been truncated, > > e.g: > > > > value = DIV_ROUND_CLOSEST_ULL(state->period, scaler); > > > > /* dont accept a period that is too small or has been truncated */ > > if ((value < PERIOD_MIN) || > > (value != DIV_ROUND_CLOSEST_ULL(state->period, scaler))) > > return -EINVAL; > > I'd make value an unsigned long long and check for > 0xffffffff instead > of repeating the (expensive) division. (Hmm, maybe the compiler is smart > enough to not actually repeat it, but still.) I wonder where you got that idea from. Sean