Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp748603pxu; Fri, 4 Dec 2020 14:50:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAwmPVSir9GmMakuekIJWJzK7VCoONPNo0KHV1226LFMKWSgmQdl5/JZJu5WHmjLfYPYCp X-Received: by 2002:a05:6402:143a:: with SMTP id c26mr9412205edx.131.1607122206957; Fri, 04 Dec 2020 14:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607122206; cv=none; d=google.com; s=arc-20160816; b=UVKkOcuewYUNXlpHc0p02Xbds59JZrT1Afo5I0uh3CVI74rhzYfOI11gijqaX1C/yD glgu+FyoBytCBdgzqNFnkLQGYsUoiQSQbl2TrlrZVqBBHF9YUz0Hnf4NIi5ArkfrlKXn 0yPfuofDnAeH7rIip7vhbl7l1AujVzc+eKqIJuFwfME3ozcitG7nmjDcRRJ/c3AkZHqg vFUpUN9dtYi74lIaZLMlVpl1yeHXKGGx9gjOHUoyGOrILO8+VnPw62v5cvGG9uvxekOT BVNqslFESq1/8lVwg0teneWRFZibeU74usX+AE5PkTY+cu/1+SB4pv3+71xkylgfwfBR Efhg== 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=+DNsDHT3DwT56dQtsoKVfGznB3B9G7Vsheomt8RjaIs=; b=M27qTHNX0l+3Jakjck0SSvLDzsHeYxYQYTwTK8+C2n2pg+8Up84OUsX3gpSjvS9FPE DdaQwFu/UGKZTQFQJSAvNUpMQlb5jbC+7C38prlsQlkRk5FapIdi4sT1FoJnkyjWhimY 7Jlf5SWst8sSlnG3Y3dgPJFhDaAzgYVpMPAaGnF2I2X+UfjiJjaAKRNusxA6r2KVwp9h ftwo1fzGlJkkjJE3t4XP5+ckGxqfYcH5BmXvJu60y3stLO7kjOchzXoxYhTm08fz2EvH CyoxQ7jhD0LBthw7j2h1OPgtQ5xKHoMwM/+U7RVJzoU0YkRqzblIgPyfdOZ1Ca5Rfqkb lC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mess.org header.s=2020 header.b=SOU4hQfI; 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 a89si4130544ede.326.2020.12.04.14.49.44; Fri, 04 Dec 2020 14:50:06 -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=SOU4hQfI; 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 S1730843AbgLDWpm (ORCPT + 99 others); Fri, 4 Dec 2020 17:45:42 -0500 Received: from gofer.mess.org ([88.97.38.141]:41021 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgLDWpl (ORCPT ); Fri, 4 Dec 2020 17:45:41 -0500 X-Greylist: delayed 50438 seconds by postgrey-1.27 at vger.kernel.org; Fri, 04 Dec 2020 17:45:40 EST Received: by gofer.mess.org (Postfix, from userid 1000) id 8F2F8C63F3; Fri, 4 Dec 2020 22:44:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1607121898; bh=PYH8ww1xg7JJTR9yV5V04QIPlPtwuoeubNCoR6ffAlo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SOU4hQfIGHnzuYrHWcRjab1uQ0fVMy/3s/r8IjYVXz2h02cPZUmubrdovi8MbRDlE bHb7/3pxfeh7AFUthUsi95Zd9+m5K2YM6qS0cU+b5zQ1oYERTt8r7XZ6GgbZs3ItPS M8dM7uJqtyF/XPm2Bcwiz7hvizQTfWFIaOo0osQGKeq3PjntFVXqOpwQXtzwelGpB/ cS/LvisM55v9yKB4spqMwd7cIdq4EXQg0u5IxnF3rzFfKvLsav9hpY/gLcgcnncPye EAQFBXdQVe/da5YPSLpHvavRDJZ/gt42IysVJMORk5tuMWDn6/EMraYCh3YOEZhs9Q a2eYr9/zZJ28g== Date: Fri, 4 Dec 2020 22:44:58 +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: <20201204224458.GA15986@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> <20201204114036.GB6547@gofer.mess.org> <20201204215525.uvjxlebth457aoj5@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201204215525.uvjxlebth457aoj5@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe, On Fri, Dec 04, 2020 at 10:55:25PM +0100, Uwe Kleine-K?nig wrote: > On Fri, Dec 04, 2020 at 11:40:36AM +0000, Sean Young wrote: > > On Fri, Dec 04, 2020 at 12:21:15PM +0100, Uwe Kleine-K?nig wrote: > > > 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. > > I don't know how to honestly answer your question. > Which idea do you mean? That divisions are expensive? Or that compilers > might be smart? And do you consider it a good idea? Or do you disagree? I had already made this exact suggestion -- and you had replied to my email making that suggestion -- before you emailed this. Granted, I said u64 and U32_MAX rather than unsigned long long and 0xffffffff. However, I should not have sent that snotty email. It's irrelevant. My apologies. Sean