From patchwork Tue Jul 9 10:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13727605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9005C2BD09 for ; Tue, 9 Jul 2024 10:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9BOw9dsOWGZoOiBoP3N0sxoT3vbz+H/cGBx1h+V5mL8=; b=DotDeIpobuQBMGX+JWu4w1R2eG nPBVGd1mXBBu0An0mVyUsXFfr4HeeOAKMAJhk9CZOzBe6Aduq0QJe9Gv8UA9sABqMOLdmdACI8I+h TjE4+kQlSUcBdYa0LZz5hnHnHQRwI8NRFQ/xzBBL6/dzzHEb8RWTFpQzhPEQI52AfyHlLoegPVxwh YUABSCjNR4jD2m+gM5GAbowhwqCI2J9m4fZhlGACdO+360l2H5oXtRnjsQfRpWUocIxaldHkCBmS1 TJFfQsp2RpVsBUcr7pgaBo7KuKBnWXysZkfTwUhXpDOvBGrY0X2SdTEtnpOOoho8y1FTObtyDUapx 9bacrprw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR7w3-00000006mv7-18B3; Tue, 09 Jul 2024 10:18:59 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR7va-00000006mqX-0cM1 for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 10:18:31 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a77e7a6cfa7so254605266b.1 for ; Tue, 09 Jul 2024 03:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1720520308; x=1721125108; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9BOw9dsOWGZoOiBoP3N0sxoT3vbz+H/cGBx1h+V5mL8=; b=VYDbFGHFpyI4/W0oDG9nmJvoJqr9or+fdD0D9PtQCYkpnoy0VAfNb7GBIYJ57KM0sd V0KW0jGTCvQ9Sso3hV5uC+IqZNbl69QnVwzf7QTs50VEinmgEGcHSa4+GOiWx/V1Og1F gO4hVE2t6W1jBrVL+iTyKRjpVWTCtYeo9dcHKcHZsRtVu7pDF5KneNcJmHgntVmAhAes Vcsuhiyg/XesWdevX7vr0eeXXiKHUOoz6XCR7HnV3SycmA0PdoTYJRL5uglwEPMGdYtW 8wUPP+GY4HUjEc2e7cPFwj8wK64W5dDNtkR8Ls/EXyhLJQN4AvU4Z669sXbPUXKuKHr9 hekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720520308; x=1721125108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BOw9dsOWGZoOiBoP3N0sxoT3vbz+H/cGBx1h+V5mL8=; b=PfpyhYEgmeeCs1WQMXXGwheFWshkZDC63fUouGwlELCn0Tw95xoG9RLHbCUZWYmnKq r1QNfX/EQL8MBIGvuWCdGlviZbVFynENmjreUt+ZABoqyLqVMCxaJZpIkIDkkW+OXpCY nI42X+qhIqa4qJJFwX38kGA95xHbuxjeSb5WoHC4QuWoTgBrOz2fkSKXZKhdr3jbW/yp dyzseT6Zz3fXFq3euaJWQjvpZY+PBIGhJiEiYmLMUSFKU45l8pBlCIdUsQbxC8H/58nJ NNuJPVOIElWVjtsxd1kXPzktHsGeddQL8nXhpTE6qqATStewTHigLFPcR0BHH/eN7JMO sXHg== X-Forwarded-Encrypted: i=1; AJvYcCXzlFe6hDPr78Q/WN33jA+NrVveAKFnDQGW/Zzi6ne83qTZMVuN6H/akLuuhUn7Lyn1868Y2Z6vTkslKSg84XGAGUVVccfA+CTvsywLF5/mBZkiGPo= X-Gm-Message-State: AOJu0YyvgMsDYWIak6lPH9XOMDo16sWDuwOA6IO4MaE+YsAx1TJxlTr9 uQP3qxNvlUUXnk/iVGxeyOOukyKqJiMPrKA7P81AVQOTuUzNTKSnQTKneY7zWNk= X-Google-Smtp-Source: AGHT+IGVVa5D8a6/0GBs6EWCyvWixTX/bOy31j64hArHSZ7WV+Fy/H469dRiEtMa86fDs5rPgvYElw== X-Received: by 2002:a17:906:1388:b0:a72:428f:cd66 with SMTP id a640c23a62f3a-a780b705222mr124173666b.39.1720520308461; Tue, 09 Jul 2024 03:18:28 -0700 (PDT) Received: from localhost (p50915e7b.dip0.t-ipconnect.de. [80.145.94.123]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a856251sm64827766b.185.2024.07.09.03.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:18:28 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] pwm: atmel-tcb: Simplify checking the companion output Date: Tue, 9 Jul 2024 12:18:06 +0200 Message-ID: <20240709101806.52394-4-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240709101806.52394-3-u.kleine-koenig@baylibre.com> References: <20240709101806.52394-3-u.kleine-koenig@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2086; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=HRECQNJEoiWSJM96Y5TzsskbT2xf7RBPRMnhjuAtAsE=; b=owGbwMvMwMXY3/A7olbonx/jabUkhrRevqSy5Kdeaf8YDzhvTgr8arve/sze15a/IuW5KyedO GS6JJapk9GYhYGRi0FWTJHFvnFNplWVXGTn2n+XYQaxMoFMYeDiFICJ8Fiy/6/L9c8+86cyPyBR RiPL93Z31+1DoSu4Xx2xqo6pCuoXydvdaMNx48LJg43LhFSv7Dhldv3dMa52BtmH64ocuILaLN5 pr5P3Pm0RXGlRmxTV1eOW02wcpKsUVO2ld7D21v+Ku6ZXtcIaoi9/+1k/5eaGxlJ1lkUHjPw8PG effBOxjnNTjrupfZh3qKLeqaUXW1KVDfrnKh1mSk2oL5/1ZAr/d+uNk5kzPJaYTr1ddutS+S8pV o1H1od39K7TirJknRKSJjnh3rZL0VtXNMbq6wZF3Ekqe8XJt3b/7/pk1XdO0Xc6ShmXbsvS/5pj Jr/vY7bA1E0rLtVP2fq6/q7JBE222DeH15i66AYFCX8DAA== X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_031830_207958_89016807 X-CRM114-Status: GOOD ( 17.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The two outputs provided by the supported hardware share some settings, so access to the other PWM is required when one of them is configured. Instead of an explicit if to deterimine the other PWM just use hwpwm ^ 1. Further atcbpwm is never NULL, so drop the corresponding check. Signed-off-by: Uwe Kleine-König Acked-by: Nicolas Ferre --- drivers/pwm/pwm-atmel-tcb.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index aca11493239a..2feee3744b50 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -260,7 +260,8 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, { struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm]; - struct atmel_tcb_pwm_device *atcbpwm = NULL; + /* companion PWM sharing register values period and div */ + struct atmel_tcb_pwm_device *atcbpwm = &tcbpwmc->pwms[pwm->hwpwm ^ 1]; int i = 0; int slowclk = 0; unsigned period; @@ -305,11 +306,6 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, duty = div_u64(duty_ns, min); period = div_u64(period_ns, min); - if (pwm->hwpwm == 0) - atcbpwm = &tcbpwmc->pwms[1]; - else - atcbpwm = &tcbpwmc->pwms[0]; - /* * PWM devices provided by the TCB driver are grouped by 2. * PWM devices in a given group must be configured with the @@ -318,8 +314,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, * We're checking the period value of the second PWM device * in this group before applying the new config. */ - if ((atcbpwm && atcbpwm->duty > 0 && - atcbpwm->duty != atcbpwm->period) && + if ((atcbpwm->duty > 0 && atcbpwm->duty != atcbpwm->period) && (atcbpwm->div != i || atcbpwm->period != period)) { dev_err(pwmchip_parent(chip), "failed to configure period_ns: PWM group already configured with a different value\n");