From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287E0C77B75 for ; Fri, 12 May 2023 08:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240276AbjELI6q (ORCPT ); Fri, 12 May 2023 04:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240273AbjELI6h (ORCPT ); Fri, 12 May 2023 04:58:37 -0400 Received: from smtpbgbr1.qq.com (smtpbgbr1.qq.com [54.207.19.206]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D454D10E67; Fri, 12 May 2023 01:58:32 -0700 (PDT) X-QQ-mid: Yeas3t1683881853t174t45976 Received: from 3DB253DBDE8942B29385B9DFB0B7E889 (jiawenwu@trustnetic.com [125.119.253.217]) X-QQ-SSF: 00400000000000F0FNF000000000000 From: =?utf-8?b?Smlhd2VuIFd1?= X-BIZMAIL-ID: 2705097927430388980 To: Cc: , , , , , , , , , , , References: <20230509022734.148970-1-jiawenwu@trustnetic.com> <20230509022734.148970-7-jiawenwu@trustnetic.com> In-Reply-To: Subject: RE: [PATCH net-next v7 6/9] net: txgbe: Support GPIO to SFP socket Date: Fri, 12 May 2023 16:57:32 +0800 Message-ID: <000001d984af$c9bc89e0$5d359da0$@trustnetic.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AQJdw4zS3rpHMobUlf9gBLGLbLpYXQGeWQPmAYIr88uuNK3a0A== X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org > > +static int txgbe_gpio_direction_out(struct gpio_chip *chip, unsigned int offset, > > + int val) > > +{ > > + struct wx *wx = gpiochip_get_data(chip); > > + u32 mask; > > + > > + mask = BIT(offset) | BIT(offset - 1); > > + if (val) > > + wr32m(wx, WX_GPIO_DR, mask, mask); > > + else > > + wr32m(wx, WX_GPIO_DR, mask, 0); > > + > > + wr32m(wx, WX_GPIO_DDR, BIT(offset), BIT(offset)); > > Can you explain, what prevents to have this flow to be interleaved by other API > calls, like ->direction_in()? Didn't you missed proper locking schema? It's true, I should add spinlock for writing GPIO registers. > > > + return 0; > > +} > > ... > > > + switch (type) { > > + case IRQ_TYPE_EDGE_BOTH: > > + level |= BIT(hwirq); > > + break; > > + case IRQ_TYPE_EDGE_RISING: > > + level |= BIT(hwirq); > > + polarity |= BIT(hwirq); > > + break; > > + case IRQ_TYPE_EDGE_FALLING: > > + level |= BIT(hwirq); > > > + polarity &= ~BIT(hwirq); > > This... > > > + break; > > + case IRQ_TYPE_LEVEL_HIGH: > > + level &= ~BIT(hwirq); > > ...and this can be done outside of the switch-case. Then you simply set certain > bits where it's needed. > > > + polarity |= BIT(hwirq); > > + break; > > + case IRQ_TYPE_LEVEL_LOW: > > + level &= ~BIT(hwirq); > > + polarity &= ~BIT(hwirq); > > + break; > > default? Do you mean that treat IRQ_TYPE_LEVEL_LOW as default case, clear level and polarity firstly, then set the bits in other needed case?