Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2162974rdg; Sun, 15 Oct 2023 14:25:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjMJMJj8iIMMgbhzNDa5X9kG7qt9lPf78Ezhz66hLw3uIIBHab3jDeHf8JScfqYyOao3tN X-Received: by 2002:a05:6358:7241:b0:14c:4f02:f3e with SMTP id i1-20020a056358724100b0014c4f020f3emr40321648rwa.21.1697405144277; Sun, 15 Oct 2023 14:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697405144; cv=none; d=google.com; s=arc-20160816; b=SDSsDVhj+esF91DkEVMs5pfJLlg6p+6+DL4TAi7mSXsP8Mtj/rxy0a97ngcaIEwzPT zZztCz/sYuOh4OcgS51nGVXt9dWTY+J5Qr9FaE+K8/IwywFRG5DiQDipSPNlPvGyIBGC 5wsz+jst3/Gwh2Aa9CaKaxoKe92g7xauWe2FvfIJGfay5VWdYqZFxwOpZouVrX8xrDZY GItV/fNX1uUWzGOjZKEvhRbqvLByHkAJkYOLfMuVwxH0ObZ3wcCdTMje4XTZ0DzKObuf KGu9dy+co2vrzsd+w2MX07TgJrM5AiS9p3fXzneXkAEcHOz5dfx47oBM2TPE80pS3zV5 hjyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RHauOd3TImA1K5cVPQnH5nN8pBawRG4Ef1Xjg7YbEYI=; fh=+iZeY/+JCgmvE5UfJUpxjPbWOmbG8lb6xxDVvmYxRD0=; b=oJiFHFswQ4pR+tWXjKjK/97ymGqglU88MbgPhXWKHixxzQppfW/GzK925gChcEVqHs B/O0g2PeQN2f9LJcB1hQA/XUt9+UWob0bO9VNnW90MeTlEz31JkXO9gX52h18y7Zz8Rh 9yT/pGwCBBl/wy2RgBls31WCc43FCdmr0glkY6Swx5KHb23QBb/msn+eIwU0gOSa8cPI dLpEgmzHZm2A/MnQANnceX0ufI+u3dQBub6AFIXjuS62I5JjNGuWz3s8HX3jV4M4zuYM /Q6DI8wyMqjLUYhs5Q/LOq0YXJbuUP6hTg+5gQHCpcQinmt6TgwtMx7UmSx0dzajNFcE Zskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Hj4tjheV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k184-20020a6384c1000000b005ac958aa98esi5600425pgd.797.2023.10.15.14.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 14:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Hj4tjheV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 83494809E8B1; Sun, 15 Oct 2023 14:25:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbjJOVZL (ORCPT + 99 others); Sun, 15 Oct 2023 17:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjJOVZK (ORCPT ); Sun, 15 Oct 2023 17:25:10 -0400 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A389AA1; Sun, 15 Oct 2023 14:25:08 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id 7DEEE10006C; Sun, 15 Oct 2023 22:25:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1697405106; bh=bEsPWlV0d3DdW9md1Bi6AvCyqdcvpm/SuqajVVIis+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hj4tjheVmnfxVhyB40FmH5NWLbFdlcIrn2T8zehCWhlaCBdb+1qAfgIfhv45qpU5E he6Lui8HAUtblU0BWLY1sl6tKbKYts9ma9ubHI+ubhW/Xwfaf4i9qokGv00TG+yV0e qkBDtGQSg+HehEdZsqdjbE8q8oLftMtAiCB+K9KQ/sqvY18LRqneZtnv9O/GivRZvH HDH/d2YTVmDYMrTpIdHsS87vj+X1Ovh+Rv4PAP5aXx0NizkphXb4Tqc7pcE9UDbRil eefjUHepOevTV87Plz83rHwU5J1W4Vlf7LUbIpFk8fG6lvJ9nV7x1Zya7vU3LLb+7V +L0YxHOatcRIw== Date: Sun, 15 Oct 2023 22:25:06 +0100 From: Sean Young To: Ivaylo Dimitrov Cc: linux-media@vger.kernel.org, Mauro Carvalho Chehab , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: Re: [PATCH v2 3/3] media: pwm-ir-tx: trigger edges from hrtimer interrupt context Message-ID: References: <1560b474f7d426bc77100665c14c3a29c3af3e75.1697193646.git.sean@mess.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 15 Oct 2023 14:25:29 -0700 (PDT) On Sun, Oct 15, 2023 at 09:31:34AM +0300, Ivaylo Dimitrov wrote: > On 13.10.23 г. 13:46 ч., Sean Young wrote: > > This makes the driver much more precise. > > > > Signed-off-by: Sean Young > > --- > > drivers/media/rc/pwm-ir-tx.c | 79 ++++++++++++++++++++++++++++++++++-- > > 1 file changed, 76 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c > > index c5f37c03af9c..3e801fa8ee2c 100644 > > --- a/drivers/media/rc/pwm-ir-tx.c > > +++ b/drivers/media/rc/pwm-ir-tx.c > > @@ -10,6 +10,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > #include > > #define DRIVER_NAME "pwm-ir-tx" > > @@ -17,8 +19,14 @@ > > struct pwm_ir { > > struct pwm_device *pwm; > > - unsigned int carrier; > > - unsigned int duty_cycle; > > + struct hrtimer timer; > > + struct completion completion; > > what about 'struct completion tx_done'? Agreed, that's much better. > > + struct pwm_state *state; > > + uint carrier; > > + uint duty_cycle; > > With my c++ developer hat on, I think either 'u32' or 'unsigned int' is more > proper type for carrier and duty_cycle. Both s_tx_duty_cycle and > s_tx_carrier are declared with second parameter of type u32, maybe that's > what have to be used all over the place if you are to change from 'unsigned > int'. But better leave as it is, pwm_set_relative_duty_cycle() takes > 'unsigned int' anyway. I much prefer the rust way of u64/u32/u16/u8/usize and simply no int/short/long types at all. int is useful when your compiler needs to work on weird architectures with non-power-of-two register sizes like the pdp-9 (18 bits anyone?), but on contemporary cpus there is really no need for int: int is always a 32 bit value. So I'm all for banishing int in every form, but for now the kernel uses unsigned int and u32 interchangably, so it's hard to be consistent with this. > > + uint *txbuf; > > + uint txbuf_len; > > + uint txbuf_index; > > OTOH, it is (*tx_ir)(struct rc_dev *dev, unsigned *txbuf, unsigned n), so > maybe you should use 'unsigned' or 'unsigned int' for those. > > I know at the end all those will be compiled to same type, but still :) Maybe it's time for tx_ir to be defined with u32 types and do away with this madness. However, as it stands I agree with your points. I guess it's best to be consistent with the apis this driver implements/uses. Thanks, Sean