Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6007970rwd; Mon, 5 Jun 2023 11:31:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yzGy4HGXgwwpx7+AZfg+/sC36HmphLnja/9aTDbnSwdJ0F029zHhhIqZ/kBK0NgrVLzuz X-Received: by 2002:a17:90a:24e:b0:250:c4c1:882 with SMTP id t14-20020a17090a024e00b00250c4c10882mr4049207pje.30.1685989878034; Mon, 05 Jun 2023 11:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685989878; cv=none; d=google.com; s=arc-20160816; b=QrRe7aOFCeL22YeyzXB+Fk+R3AffLAmS81SHefKwRZg3WIjx6znVdOWSXwOsEYcMOu Kse4XctAOp4yV4fqeSTH4WIdm4Ze3cN0sgouil7HV4EmaMyj/QPOwDdaCkXexo8XajfC 8DKBwWWlBqa22/Pk/PZfFaRTJfvUR0Sc9J6twGtLuVVtq5qJN7LTMWeBcgEQjNLckAZE wx9PvUgQZi9boLLQqA0RAy0ATGRywM6dr6kvYx/YWFd9KWVO2nBUMbs3oNO76hzLzHjB 0cxpCf7MQHK4afcdjpXcaBdOsXtafMRWC/KlERC2QQlPYb77GuDgTQn6ykgRpfA0a9yA OKkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=cVsuCfqC328oMH5P7QiDL9VIp18ZMkyI/Asduj73yQk=; b=NGfoOtCf87hnV9xEsCvJBT9uz4S/QT1StyY69bw+tI3svi98xSsbxKinl+RBEUx+dY 7qDn6rK7UWlYyV+kZOzTrOFlBDruKQV/Ktw8o6kKyhzNfpreGm+PR14GpOqSz6Wl1817 yCr9ZuWRIqUgYG4co4HqBGWwcmTdv7AtIJZ6d2JBvYGtOUhPfJwwByh3iRVLlR0XiaLj xr+gLc77ITVR9ac6HVpt4Z9upUbJFur1sCcCu8GGRxE4YgihpXXyMrtoGekWz5Ihx5IE u374a1VWZV2xyQK7PKZajOvOlK3wm9riHFvKOTi7JOtrGIba+WvQ7HKzS/jOHOs6EWVj BsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=NI+cWrOZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a63ea05000000b005303c1de315si5670330pgi.853.2023.06.05.11.30.59; Mon, 05 Jun 2023 11:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=NI+cWrOZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232280AbjFER5p (ORCPT + 99 others); Mon, 5 Jun 2023 13:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231747AbjFER5o (ORCPT ); Mon, 5 Jun 2023 13:57:44 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73CF7C7; Mon, 5 Jun 2023 10:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:Content-Type:Mime-Version: References:In-Reply-To:Message-Id:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cVsuCfqC328oMH5P7QiDL9VIp18ZMkyI/Asduj73yQk=; b=NI+cWrOZPRfjHDb5xVaM2Nknyv hYDPhBnh/UnnvcHlfe0cLuKWDGGbRpbOSva/wC7PuIf4av1CXrxHq6QkOSPi2zIxRKYw2Jof36FO9 N8BB/DUqoECfE1ka07zWf+hW4NZXODnJ9YUrZydN/MjV1tpBWhzm8iaXj1HJ/2kYz1mc=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:50380 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1q6ESV-0001nl-3e; Mon, 05 Jun 2023 13:57:36 -0400 Date: Mon, 5 Jun 2023 13:57:34 -0400 From: Hugo Villeneuve To: Hugo Villeneuve Cc: Greg KH , robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com, linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, Andy Shevchenko Message-Id: <20230605135734.1b66d32f39e7e4d32d5978a8@hugovil.com> In-Reply-To: <20230604191613.ea95fa9a1bc508525fe3bbd5@hugovil.com> References: <20230602152626.284324-1-hugo@hugovil.com> <20230602152626.284324-6-hugo@hugovil.com> <2023060454-cotton-paramount-e33e@gregkh> <20230604134344.73dc3cbb57d335d4a0b4b33a@hugovil.com> <2023060406-scarcity-clear-cc56@gregkh> <20230604191613.ea95fa9a1bc508525fe3bbd5@hugovil.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: [PATCH v7 5/9] serial: sc16is7xx: fix regression with GPIO configuration X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 4 Jun 2023 19:16:13 -0400 Hugo Villeneuve wrote: > On Sun, 4 Jun 2023 20:29:58 +0200 > Greg KH wrote: > > > On Sun, Jun 04, 2023 at 01:43:44PM -0400, Hugo Villeneuve wrote: > > > Here is what I suggest to silence the warning: > > > > > > mctrl_mask = sc16is7xx_setup_mctrl_ports(dev); > > > > > > #ifdef CONFIG_GPIOLIB > > > ret = sc16is7xx_setup_gpio_chip(dev, mctrl_mask); > > > if (ret) > > > goto out_thread; > > > #else > > > (void) mctrl_mask; > > > #endif > > > > Eeek, no, please no... > > > > First off, please don't put #ifdef in .c files if at all possible. > > Hi Greg, > Andy also made a similar comment, but couldn't suggest a valid > alternative when I asked him what to do about that. > > Just as a sidenote, I didn't add those #ifdef, they were already > present in the driver in multiple places. > > What would be your suggestion to get rid of those #ifdef, simply delete > them all? > > If you suggest me what to do, I will be happy to submit a > future patch after this series is finalized to clean that aspect. > > > > Secondly, that (void) craziness is just that. Rework this to not be an > > issue some other way please. > > > > > I could also store (define new variable) mctrl_mask directly inside struct sc16is7xx_port... > > > > Sure, that sounds best. > > Ok, I will do that. > > > > > > And you have a real port here, no need to pass in a "raw" struct device, > > > > right? > > > > > > The function operates globally on both ports (or nr_uart), not just a single port. That is why I pass the "raw" struct device, in order to extract the > > > struct sc16is7xx_port from it: > > > > > > struct sc16is7xx_port *s = dev_get_drvdata(dev); > > > > > > Inside the function, I also need the "raw" struc device. If we pass a struct sc16is7xx_port to the function, then I can get the "raw" struc device with this: > > > > > > static u8 sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s) > > > { > > > struct device *dev = &s->p[0].port.dev; > > > > > > But I find this more obfuscated and hard to understand than to simply pass a "raw" struct device... > > > > You should never need a "raw" struct device for stuff (if so, something > > is really odd). Except for error messages, but that's not really a big > > deal, right? > > > Don't pass around struct device in a driver, use the real types as you > > know you have it and it saves odd casting around and it just doesn't > > look safe at all to do so. > > If you look at the patch, you will see that I need "struct device *dev" > at two places in the sc16is7xx_setup_mctrl_ports() function to read the > device properties: > > ... > +static u8 sc16is7xx_setup_mctrl_ports(struct device *dev) > ... > + count = device_property_count_u32(dev,... > ... > + ret = device_property_read_u32_array(dev, > ... > > I do not understand why this is odd? Hi Greg, I finally added a "struct device" member inside "struct sc16is7xx_port" and now I simply pass "struct sc16is7xx_port *s as the sole argument to sc16is7xx_setup_mctrl_ports(). That should take care of your concern I hope, and I will submit a V8 soon with all these changes. Hugo. > > And if you have that crazy s->p.... stuff in multiple places, the > > perhaps you might want to rethink the structure somehow? Or at the very > > least, write an inline function to get it when needed. > > I am not sure what you mean by that, since again that "crazy" stuff is > already used everywhere in this driver? > > > > Also, meta comment, you might want to use some \n characters in your > > emails, your lines are really long :) > > Strange, I use sylpheed as a mail client, and the option "Wrap lines at > 72 characters" is enabled by default, but somehow you must also check > the box "Wrap on input" for it to work, not very intuitive :) Thanks for > pointing that to me. > > Hugo.