Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp513744rwb; Thu, 22 Sep 2022 02:51:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Xp23W2WJ3vSj8ABZveJtPKt6EjWyW6ONM/jRB7KbK826Whl2sH/1nv5sEUg6D8uaUSFCd X-Received: by 2002:a05:6402:284:b0:454:3e53:feae with SMTP id l4-20020a056402028400b004543e53feaemr2370898edv.280.1663840289651; Thu, 22 Sep 2022 02:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663840289; cv=none; d=google.com; s=arc-20160816; b=m6BH+8bwvQBLt+KIAIfntOIY9EQgX1wSinoU8oE9tmxgaFeSvpBusuj1FAagusZUTN d8swDqjIQ/j60FDFcnzdjwsaJ9GzmoovWUkZuv0EnfG/oYuhjIxdpBxWuTuVFP6cwd61 D0PFamYdkGZXtQX8Cq4spqKO3i+K1FO6Gf2LpW2vTv3hOZvoupzanWoHVr3XnDQvUKjD 0nrz1Xq/uMT2gG+oHeKiWfA7tbFjO+IvTNkzyMzLRDo54qCJBw9QQK+D2slSKTQlIwfu ukK1RXnN05J0bxIs3cUmcKMJzRHR1Pt+lCjdc9JjL5+xzUrsOV72FUR0EDG4x8G/DgMD cS1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6q4YGDHLzVxZZA0z/19qhpYPv+00FVkwJ71bEFIBV9E=; b=WjpMDfgFoW85QQQlP1iwAK5MhflaxtkxlvxZRyeoxeGXy3AWljzKQqjjQMNUZKYTjq cIu2XLY++HGet+VWesxlA5wBSTPH4bW0hVxrmH+nZYG4Ts6lw3jnboMxq0XXr7uhvTSy oUmVZdIJ1C8HeRWGcolbQwtsFmztNcwQ7ELH6RHmvwzpYnT7ACdz51mT7dVtNkPcWE61 /rjQSNeOjH8D8jhDyzry+9xnuYWjHofVU03Ww03wrFyZxx8Fw8LRj8lrXe1njbTBDpNw gBIkl6A4gdAh6d7jBXuV2eWuud91YmZEXysNU6rL9zS4nzlrovsYT3lrZvoJsFD4PuFk Lqyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kcdJsDiL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm10-20020a170907948a00b007800b181a0csi5300679ejc.300.2022.09.22.02.51.03; Thu, 22 Sep 2022 02:51:29 -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=pass header.i=@intel.com header.s=Intel header.b=kcdJsDiL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbiIVJoW (ORCPT + 99 others); Thu, 22 Sep 2022 05:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiIVJoV (ORCPT ); Thu, 22 Sep 2022 05:44:21 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41BDD4A9C; Thu, 22 Sep 2022 02:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663839859; x=1695375859; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=zGNnp1SHc0bPd8aNRkbUAnaA+Tc26kl+IYTmTGgGBeA=; b=kcdJsDiLStrd1eoU56E3C+1XQqg1LdjAdH5KBFpj/Ifxj4Bt4axjMSO+ 7+MLDiZbqH+6PgkvDN+NQulhXM1lWVSX4kKuf13zCy0UYgqucMS8Dzsg7 bAx4DwCzLAi3vVCjaDtHsCZsawD868vczoiDxRHbzl6S4YKNB76Vzz3wv /ifuT/St7IbgFqhjsZ08fvvKcpqff8DW71IT//0qEyaCqYdu2VO5WGdvN M6P1kd9q/ZWEpgA1i8PKPdeF/f84x8D6zbduplGMfpSscVBx1oElT5pUk h7t7kXV8VOwBZM4kmMgnuku+dGRnrSro8R3R+/WsT2jSdcWMaQ0I6XKh9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="280622755" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="280622755" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 02:44:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="652900936" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga001.jf.intel.com with ESMTP; 22 Sep 2022 02:44:15 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1obIke-005wpi-2D; Thu, 22 Sep 2022 12:44:12 +0300 Date: Thu, 22 Sep 2022 12:44:12 +0300 From: Andy Shevchenko To: Raul Rangel Cc: Linux ACPI , linux-input , Tim Van Patten , Hans de Goede , "Rafael J. Wysocki" , "Limonciello, Mario" , "jingle.wu" , Mika Westerberg , Dmitry Torokhov , Linus Walleij , Wolfram Sang , "open list:I2C SUBSYSTEM HOST DRIVERS" , linux-kernel Subject: Re: [PATCH v4 07/13] i2c: acpi: Use ACPI wake capability bit to set wake_irq Message-ID: References: <20220919155916.1044219-1-rrangel@chromium.org> <20220919095504.v4.7.I8af4282adc72eb9f247adcd03676a43893a020a6@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 21, 2022 at 09:18:34AM -0600, Raul Rangel wrote: > On Tue, Sep 20, 2022 at 6:32 AM Andy Shevchenko > wrote: > > On Mon, Sep 19, 2022 at 09:59:09AM -0600, Raul E Rangel wrote: ... > > > + if (irq_ctx.irq == -ENOENT) > > > + irq_ctx.irq = acpi_dev_gpio_irq_wake_get(adev, 0, &irq_ctx.wake_capable); > > > > I just realized, that there is an inconsistency on how we fill the wake_capable > > parameter. In some cases we check for IRQ for an error condition (IRQ not found) > > and in some the wake_capable still be filled. > > > > Here the best approach I believe is to add > > > > if (irq_ctx.irq < 0) > > return irq_ctx.irq; > > > > I.o.w. we apply the rule "do not fill the output parameters when it's known > > to be an error condition". > > > > > + if (wake_capable) > > > + *wake_capable = irq_ctx.wake_capable; > > > > > + return irq_ctx.irq; > > > > I applied the following: > diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c > index ba64e505183595..1618f5619d5ed9 100644 > --- a/drivers/i2c/i2c-core-acpi.c > +++ b/drivers/i2c/i2c-core-acpi.c > @@ -220,7 +220,7 @@ int i2c_acpi_get_irq(struct i2c_client *client, > bool *wake_capable) > if (irq_ctx.irq == -ENOENT) > irq_ctx.irq = acpi_dev_gpio_irq_wake_get(adev, 0, > &irq_ctx.wake_capable); > > - if (wake_capable) > + if (irq_ctx.irq > 0 && wake_capable) > *wake_capable = irq_ctx.wake_capable; > > return irq_ctx.irq; While it's working solution it is not so flexible since basically any addition of a new code will require if (irq > 0), that's why I'm in favour of my proposal rather than yours approach. -- With Best Regards, Andy Shevchenko