From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 4DD902597 for ; Fri, 12 May 2023 08:59:47 +0000 (UTC) Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D6211FFF for ; Fri, 12 May 2023 01:59:44 -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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FROM_EXCESS_BASE64, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net > > +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?