From patchwork Thu Feb 15 16:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 201648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp531878dyb; Thu, 15 Feb 2024 08:55:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUP8IxEL/OyhwTZ4NQJEGgjRy+iNYOcLNLBa0f3gMuJ3JKJ2erDJdyNvwcJxpavYFLYUQBznuWoV92ZNhJdp6AlsWfnoA== X-Google-Smtp-Source: AGHT+IFWWL3WcdyfewjvLl7nTXlu7svfpau93BewGgY4yKSp2mChkBCZ92V1I7T9tUa9sv+UJVw2 X-Received: by 2002:a05:6a20:c706:b0:19e:c9e8:f2af with SMTP id hi6-20020a056a20c70600b0019ec9e8f2afmr2771752pzb.8.1708016136865; Thu, 15 Feb 2024 08:55:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708016136; cv=pass; d=google.com; s=arc-20160816; b=nNm5hjNO4dUi4bqH+XmGrrCLZm2iubV1k37lUvA9cLRrbCG7jCkKHCHrdbiiH0t+8W mrpoPj6gAmM2OdHEKZoB0xfvOh7DROr8DFDgrzml78RNcnP+Sxe8zn0oDYvywE41BmWX tXWVo4rtsRtepPIJ5kJb2VfTd9eTzGaSVsqjdIkxiWA1Cr3qMirafwdDU1ebafrH52eo B2LXMd01c1qoaSvWFSOREiWGY8RRSCtqtc9iCa9uANz2c8lyke9bC+moI9dwZeG2tbmW NQ9+87TQXI/rMIadvcKX3jLaaJvY2PTrKvXbf6RupjxrGMxYS66OnbZDf71HZfgzID+I TUDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=hHgj/sUog/rIQGKTCVoK5NCE+i8l4ZPuQCIx37ekvXk=; fh=5JSnMO1qLgeVtLVJilSQcFnAcZn2MWLSM3RnsAdOnEU=; b=mG5bcMbEnInBlHnm+T2qk7X90u/8dYA4zCJRP1N2J4rme+pBwuzykvXEKc2U+ojZbC pqsp32XALxgT9HH9nL15NsDgHdp8N59t6I4BLduAZWzn9ahcHAIug27kDKGzWM1m21jo xmSNavt40w/gQVpCV80FZLvR38FdyfybvUX9fCbFl6uycssIUztlgJ65OOa46T/DAVTj A0sMvnRbaUhSx+GeDt9ATk4mmMfeKax3+w1uvWnja4BBiKMYSoJGGERYOleowIbRmKII ileAOJrOPQnzzw6lzfWWBcMHrdL/tyiqt5xwYANNg7Ix6tH7+D3LnkJGlyPN8kUK8vam ETaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dU6jtuPy; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67337-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67337-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b71-20020a63344a000000b005dc351748dfsi1345262pga.121.2024.02.15.08.55.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67337-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dU6jtuPy; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67337-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67337-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C97E62813F3 for ; Thu, 15 Feb 2024 16:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 174FE139599; Thu, 15 Feb 2024 16:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dU6jtuPy" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2EFD136644; Thu, 15 Feb 2024 16:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015961; cv=none; b=P42UrXSoe0LpViqIt+IfUsTbwLMdP0Mp9p6bt8bHYnrMcvmlOXs47gSHJmCpy0hjyYLcvr/e9rzwp4jI8x5cxqpvQXdEKqX2QdRU62otovdHQvM6pRK9f4HRQi58iJ1/SRZDxfzXN4s9yX0Rw87nOe57ss4KHG6bGK/BqTMJxf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015961; c=relaxed/simple; bh=p4+YmJ//W4/C2NnX+iwxmBA71H8qzZZas5Ie+2nLBMM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nK/SwP6T0VPh8ZRoH9bcMkuDlFgM+ICKbpNZYsLe272LPZzjG6pSvk/tMjo0MuUKitqyDVOgYUgoQ/ahMYeSsB7Dd9Lv6psOMSNHr4zNpIMm/lBj9Id4O+L4o6RbrEqxVQk8fD3hFfqzBxH0h0fZL9VVOSO7yZsdE0OscS51PQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dU6jtuPy; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 4674AE001D; Thu, 15 Feb 2024 16:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708015956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hHgj/sUog/rIQGKTCVoK5NCE+i8l4ZPuQCIx37ekvXk=; b=dU6jtuPytIjrJ86JqQdnSkLy2orKj5Tn7kipaiTwv24WiH+am/zNL+XZ4M6MHWelu0N/iS Er9NbbIoONbESW4ObrKYr+kqMSy1gyK3dD5NMkBmprxyFB5Wf+uUyyG2H9yrDhSH078GPR NpOBGpN0wVmDdH0BdoCmj/FuYizDiyIEn1ZtupEGOSpirqPuD6tFqWEn/mAHTcAG8L2XKk WDSxOH0LGZWSl/aJG/vZTRbm+8ImntQv419T6ZuGT6B6w1wwau4fWUKpfIPMnaUCauNTst 2givAYmLI/XDKDRpy6K9XQECSrbF1QcSiwwzHkw/njAID0Y9MLAbe3LRe9FWyQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 15 Feb 2024 17:52:12 +0100 Subject: [PATCH 05/13] i2c: nomadik: simplify IRQ masking logic Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240215-mbly-i2c-v1-5-19a336e91dca@bootlin.com> References: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> In-Reply-To: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Gregory Clement , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790984729035970301 X-GMAIL-MSGID: 1790984729035970301 IRQ_MASK and I2C_CLEAR_ALL_INTS are redundant. One masks the top three bits off as reserved, the other one masks the reserved IRQs inside the u32. Get rid of IRQ_MASK and only use the most restrictive mask. Signed-off-by: Théo Lebrun Reviewed-by: Linus Walleij --- drivers/i2c/busses/i2c-nomadik.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index cd511c884f99..80bdf7e42613 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -94,9 +94,6 @@ /* some bits in ICR are reserved */ #define I2C_CLEAR_ALL_INTS 0x131f007f -/* first three msb bits are reserved */ -#define IRQ_MASK(mask) (mask & 0x1fffffff) - /* maximum threshold value */ #define MAX_I2C_FIFO_THRESHOLD 15 @@ -249,8 +246,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *priv) */ static void disable_all_interrupts(struct nmk_i2c_dev *priv) { - u32 mask = IRQ_MASK(0); - writel(mask, priv->virtbase + I2C_IMSCR); + writel(0, priv->virtbase + I2C_IMSCR); } /** @@ -259,9 +255,7 @@ static void disable_all_interrupts(struct nmk_i2c_dev *priv) */ static void clear_all_interrupts(struct nmk_i2c_dev *priv) { - u32 mask; - mask = IRQ_MASK(I2C_CLEAR_ALL_INTS); - writel(mask, priv->virtbase + I2C_ICR); + writel(I2C_CLEAR_ALL_INTS, priv->virtbase + I2C_ICR); } /** @@ -468,7 +462,7 @@ static int read_i2c(struct nmk_i2c_dev *priv, u16 flags) else irq_mask |= I2C_IT_MTDWS; - irq_mask = I2C_CLEAR_ALL_INTS & IRQ_MASK(irq_mask); + irq_mask &= I2C_CLEAR_ALL_INTS; writel(readl(priv->virtbase + I2C_IMSCR) | irq_mask, priv->virtbase + I2C_IMSCR); @@ -547,7 +541,7 @@ static int write_i2c(struct nmk_i2c_dev *priv, u16 flags) else irq_mask |= I2C_IT_MTDWS; - irq_mask = I2C_CLEAR_ALL_INTS & IRQ_MASK(irq_mask); + irq_mask &= I2C_CLEAR_ALL_INTS; writel(readl(priv->virtbase + I2C_IMSCR) | irq_mask, priv->virtbase + I2C_IMSCR); @@ -703,8 +697,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, */ static int disable_interrupts(struct nmk_i2c_dev *priv, u32 irq) { - irq = IRQ_MASK(irq); - writel(readl(priv->virtbase + I2C_IMSCR) & ~(I2C_CLEAR_ALL_INTS & irq), + irq &= I2C_CLEAR_ALL_INTS; + writel(readl(priv->virtbase + I2C_IMSCR) & ~irq, priv->virtbase + I2C_IMSCR); return 0; }