From patchwork Tue Oct 17 14:04:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13425208 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 858E7CDB474 for ; Tue, 17 Oct 2023 14:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Zwa5w1x8Kv0dcmtBD9VgZ85y44c8o2O0BNt+QiYim7k=; b=Gz4dowWUorWoLK vaLmVuxqoGYoQvl4R+mYg+on9NPoO/3z3oQlqb+t51n7X+KiRviV3HCKfdR0yt49lSeqFJl81VYZa 7eZmXK3vhIugJgo5QLMkNrHdkYSts7m5qjUVVearv4pjaxK7Kh6eBQvHu+g5H5qjDKE5d6jJOUWRn BxBuLf/Zt9SMHt9v0ohs0k8ONn6GnvWaMFCpNkxmCrmg7HvqCncwg3Qx2zSrHfVoXuRSCeiFXlE8D 30hTN5u8QQy6B96xvCL4kbhiOnnHfYug5Ncgf/sha97A1UIWWSp8vsuLTyQLHpzqYB3LBqZoFlJRM q0IzLPAVdssNg/XNFwmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qskgF-00CURr-1g; Tue, 17 Oct 2023 14:04:19 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qskgC-00CUPf-20 for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 14:04:18 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so72302521fa.2 for ; Tue, 17 Oct 2023 07:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697551454; x=1698156254; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=TsrDGDEum/5uA7iQIpJCzRkScaB2QGiVp3IoiHcOdaw=; b=IzmIoyZcQ6m3ulLD/nZImhVoy/K9ceShJ6jaPe7bpQ8ibrGQqEwAvgS4nz7lY7K2Xs vb/GQnR4cdZil1KScuHt0/bYlw6cp6Qy31XgLKswrKLwfa7Ue6Uzewz3/mmmNxu/rtr5 Kd+cyLlo2KvFNIxAqTG2ys5g8MhYncnHrux+U+3GVnqFB7xzqZdJS3vl1BvFPddMVNdp 7Q5vxkffFFqM61sFkLblirS3psd4K7AEP550yKmb7KBNUN4/DJVwBp4c/ACA4nN4iKzu +riIPuoE62lWKPnwv3HL8J9OnZiyIXKWXPeSn2BJh/Hq5Dli5+kXC2fIZ+dD7Gx/ncM1 33ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697551454; x=1698156254; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TsrDGDEum/5uA7iQIpJCzRkScaB2QGiVp3IoiHcOdaw=; b=PgevWiNtiADMez/vjATvU9BaidCebe6ZPdcWqQGSFE4iK8dXPgBm0CocHj62yodjcA cQ34JFGhrgqtc6B5G8DWYz91DWlcv9GxLF7o8dJz+nlQE7e5ao8tJq0bV0UmUFfoelnh nytEvspQZ52zLCBziBhzeI/VroH9s1/On2f6pkeQGeLDppsYflxNxcpZ9yNszcks8VWo 5ZfR/wzC6yS4Ka+qJmG91ZAEEA+b0BOLn0vlxqhCQoZV0Pjgj5Z6Rz7BnIAfxp4oY5bH 46/GbNtUl97dIehPgLBzcrFwYGLFG5SK9EhhyhqSNl0n9c2ab/IQc1pYC2K6/VywRiTx q8WA== X-Gm-Message-State: AOJu0YxEJoLi/hcWmoSRmx6xFiWw4pVkIkuKZTRFzQz87eVuwxZBnxCo HKjmUB2N4CP4jYedkF+nK6GZoA== X-Google-Smtp-Source: AGHT+IG3knXmy/5vJWYi5wyeUzPAbczRcRkMPFoeND1u5tpRwFY2sHAcBNusoVs8ClImAyYJzR9CHA== X-Received: by 2002:a05:651c:1a0f:b0:2c5:16c0:6239 with SMTP id by15-20020a05651c1a0f00b002c516c06239mr2087490ljb.51.1697551454222; Tue, 17 Oct 2023 07:04:14 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c234300b0040813e14b49sm1390701wmq.30.2023.10.17.07.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:04:13 -0700 (PDT) Date: Tue, 17 Oct 2023 17:04:08 +0300 From: Dan Carpenter To: Uwe =?iso-8859-1?q?Kleine-K=F6nig?= Cc: Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pwm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] pwm: samsung: Fix a bit test Message-ID: <917e3890-7895-4b1c-bcee-4eecb3b7fe09@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_070416_662899_D06C50C3 X-CRM114-Status: GOOD ( 15.27 ) 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 This code has two problems. First, it passes the wrong bit parameter to test_bit(). Second, it mixes using PWMF_REQUESTED in test_bit() and in open coded bit tests. The test_bit() function takes a bit number. In other words, "if (test_bit(0, &flags))" is the equivalent of "if (flags & (1 << 0))". Passing (1 << 0) to test_bit() is like writing BIT(BIT(0)). It's a double shift bug. In pwm_samsung_resume() these issues mean that the flag is never set and the function is essentially a no-op. Fixes: 4c9548d24c0d ("pwm: samsung: Put per-channel data into driver data") Signed-off-by: Dan Carpenter --- From static analysis and not tested. drivers/pwm/pwm-samsung.c | 2 +- include/linux/pwm.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 10fe2c13cd80..acf4a0d8d990 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -630,7 +630,7 @@ static int pwm_samsung_resume(struct device *dev) struct pwm_device *pwm = &chip->pwms[i]; struct samsung_pwm_channel *chan = &our_chip->channel[i]; - if (!(pwm->flags & PWMF_REQUESTED)) + if (!test_bit(PWMF_REQUESTED, &pwm->flags)) continue; if (our_chip->variant.output_mask & BIT(i)) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index e3b437587b32..3eee5bf367fb 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -41,8 +41,8 @@ struct pwm_args { }; enum { - PWMF_REQUESTED = 1 << 0, - PWMF_EXPORTED = 1 << 1, + PWMF_REQUESTED = 0, + PWMF_EXPORTED = 1, }; /*