Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1354114pxb; Wed, 2 Feb 2022 03:05:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJytab6ut1SOnMv043s7TH29fMIZHu7H5ukkzXHav0cM15E2J8NNfe5m1P0ITgO82vTsXrFE X-Received: by 2002:a63:2a86:: with SMTP id q128mr24729053pgq.552.1643799947417; Wed, 02 Feb 2022 03:05:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643799947; cv=none; d=google.com; s=arc-20160816; b=VZ/LI6Q1gkZQP30IB/4oYQ2ggyeV6wNQv5/F2FXGXybNxGIEu0Gzi9s79KPOgmQxsK ZR8RWKB1N1ged1DQiNpDhbT7wSlJ9I0N9fEVk4Zl3CayL6n51W1q/JBCB0tOG6VfZuUK 8I6Ko1NOS0eGrsw6PYZiSxCI3PPB+FN2YEayFUdIgSasRbHJTI5Gozmf3iAbuTGzgAQo C8QqpyRovNUBQWVgs1CAWhWd74QwPhyLbJw8UQs7vIaHJfqqNeZ0QqtseWVexojJ8sCl 5hz/yFXdRemvKLk3WnqEZFtu8/gzycYzZxLtp9Cjclh5e+YWa/AuwLQJUgrSE/IRbAif JGdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=9hzPMVYA6JSyF04scFOLCtVol/sa3kyshLCHF8CeYoQ=; b=yJ0nf0PA31yMLtga9C0AUDaEetbbWzFMjAe52AIfG0PPbzt8aAwBZq3rl2FUyCRZjo Lf0zff+YrAq97PX+bbYWzERVT+QwfutipLraXohwDxnJHgfGeqarQsrBja0pyVc0plrw SuPcD9wD1wk4sa0d/VLVPHP/SsI65j2ObQMRZyF8Mwkq1qalUkMX+dkV11Ds9FqYviHO 1ac3O18cI7FwyEP5PUWTZWumsko4JBQjbvPz+F809XEZWnQbP/HRs7V1Qvazgahr7opd T4X7cwK6xtMSjgioD93o7ON+yOwARnZ1jcVB8jXfXDO37akEekkiu7UBrm9ook+iPY/p pZPw== ARC-Authentication-Results: i=1; mx.google.com; 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 d69si19865488pgc.244.2022.02.02.03.05.34; Wed, 02 Feb 2022 03:05:47 -0800 (PST) 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; 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 S235745AbiBAUyW (ORCPT + 99 others); Tue, 1 Feb 2022 15:54:22 -0500 Received: from mail-ua1-f48.google.com ([209.85.222.48]:43775 "EHLO mail-ua1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbiBAUyL (ORCPT ); Tue, 1 Feb 2022 15:54:11 -0500 Received: by mail-ua1-f48.google.com with SMTP id a24so1728102uat.10; Tue, 01 Feb 2022 12:54:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9hzPMVYA6JSyF04scFOLCtVol/sa3kyshLCHF8CeYoQ=; b=vDWXg2Z/zopD6by1ebOQFuBOjdV31StMoRlJLvF6XWDPnfHA/EcmhuA7aAS0hjX9et ge6/1ThY0oZnowVnkPTbExwDno7RijKM+EHMZ02/I/WgQEoRyTFaQ4vMYcuPG96Y6mbt GSoJS3znki2HBpYkSKYJuSwbC9WjIulTznxp1YqV5OZ3Bsve7ucXwj+izoX+nMPZS+eG HzY/s108Uy1j+WFRLngTjtN/7ifQZsgpNYS44Z/+mpLcT6+Ljl2B1K4N3AjteaVruj2b 0JNlAIP7X32iyUy9vW/hS2giCen+St7Nb+kW8g481uVvQt+Hwcc5tzM83/5ccffr+sho AySA== X-Gm-Message-State: AOAM530zi66qOlTaVVQUWq7pYqStKQFMpqxN2jaw9vrv8/FsKuhns62p KxAErxz2Ax2FHtPIZfqXEemHH/aQ2HGQFQ== X-Received: by 2002:a05:6102:2922:: with SMTP id cz34mr10596276vsb.55.1643748850537; Tue, 01 Feb 2022 12:54:10 -0800 (PST) Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com. [209.85.222.46]) by smtp.gmail.com with ESMTPSA id t190sm74705vst.16.2022.02.01.12.54.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Feb 2022 12:54:10 -0800 (PST) Received: by mail-ua1-f46.google.com with SMTP id b37so15394511uad.12; Tue, 01 Feb 2022 12:54:09 -0800 (PST) X-Received: by 2002:a67:c198:: with SMTP id h24mr11140054vsj.5.1643748849729; Tue, 01 Feb 2022 12:54:09 -0800 (PST) MIME-Version: 1.0 References: <6a62a531227cd4f20d77d50cdde60c7a18b9f052.1643625325.git.geert+renesas@glider.be> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 1 Feb 2022 21:53:58 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] gpio: aggregator: Fix calling into sleeping GPIO controllers To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , =?UTF-8?Q?Mikko_Salom=C3=A4ki?= , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On Tue, Feb 1, 2022 at 9:35 PM Andy Shevchenko wrote: > On Tue, Feb 1, 2022 at 10:09 PM Geert Uytterhoeven > wrote: > > If the parent GPIO controller is a sleeping controller (e.g. a GPIO > > controller connected to I2C), getting or setting a GPIO triggers a > > might_sleep() warning. This happens because the GPIO Aggregator takes > > the can_sleep flag into account only for its internal locking, not for > > calling into the parent GPIO controller. > > > > Fix this by using the gpiod_[gs]et*_cansleep() APIs when calling into a > > sleeping GPIO controller. > > Reviewed-by: Andy Shevchenko Thanks! > > +++ b/drivers/gpio/gpio-aggregator.c > > @@ -278,7 +278,8 @@ static int gpio_fwd_get(struct gpio_chip *chip, unsigned int offset) > > { > > struct gpiochip_fwd *fwd = gpiochip_get_data(chip); > > > > - return gpiod_get_value(fwd->descs[offset]); > > > + return chip->can_sleep ? gpiod_get_value_cansleep(fwd->descs[offset]) > > + : gpiod_get_value(fwd->descs[offset]); > > This indentation kills the perfectionist in me :-) Why? The above is aligned perfectly ("?" just above ":")? > What about: > > return chip->can_sleep ? > gpiod_get_value_cansleep(fwd->descs[offset]) : > gpiod_get_value(fwd->descs[offset]); > > ? > > Or as variant > > struct gpio_desc *desc = fwd->descs[offset]; > > return chip->can_sleep ? gpiod_get_value_cansleep(desc) : > gpiod_get_value(desc); > > ? IMHO, those are ugly as hell ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds