Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3764640rwb; Sun, 30 Jul 2023 15:51:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFC7z5Xz4XRSoHhkkGbFaWbBLdhy9rOh7o7CKifLKS2DlT5A2OiRKq43XlvromXd0m3KBpH X-Received: by 2002:a17:906:5a6a:b0:99b:e04d:3079 with SMTP id my42-20020a1709065a6a00b0099be04d3079mr5071141ejc.19.1690757511337; Sun, 30 Jul 2023 15:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690757511; cv=none; d=google.com; s=arc-20160816; b=xNAyHwD5Q+wGUWff6mgctsBDCiT0XzeEsnaTwHFkJ/64GQjH9UCTaaWNodiYUsiy1K eMM6BcuOt8GmGxgXLzlIDyaMpLCOhVCM3vXlA2/XFZJcrjFwWmF2tAZlQAVw8PlLXvui GOM/0zBvWFG5eG279VsJXrao15/kKMKentkwfum4GiCl4/sdJAZzlGApoYsEpXM4jz3/ hqAow2PbuE/DS6+IVtZvJqHQJtvsaHx4CDZe+Qrh2co4Mtsu6UPpEXzDZ/oR31G8wkBg xpCQclQJ5ebqO+tsJpi2EhnYs1pm9paxXM8m477KHOIRBQRAqt7D/cYKMy1bnp2yGjQs n6/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wC88/4iWok7/3jLKdUMvkHUh+FeMdPdD1ZMqzjeUF30=; fh=+FwucPOArikJpiDbqXrEU7OSfEXASHAKzenyb0IVefs=; b=At7zCm6GlQtVmc0RD8ExrQqh/4lPSI0fvS01mvcHiLmit46ZOM/uVwwjmFkP52NxZL to2Nhu7uOs0JFDuVsR7elhGPV7IOH6zEStlnzvewI1GqXcQGigY2YyjIiJFGajSXJ9Az q/sjXPLtVFaJNMes4qq0ufEGIMXdDZd+Hlo7rVr7XXmLdrAfB1T0Ehv3kzmloWQB8f6+ L4SGYUVA0NYFhIJA18nu2c17d2s6Nv08vkDuI3TDVZ83GaTkQS6ekFukHJMndmyWqUbp QyjU0nS9Z6hC6/d9TySa3FEYyHN3ohHOyXv07J88zybPLOXEiOl2FwOki2S9pgug58yK P81Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=PRu1PhNx; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jx23-20020a170906ca5700b0098e4aef078esi5874713ejb.778.2023.07.30.15.51.27; Sun, 30 Jul 2023 15:51:51 -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=@rere.qmqm.pl header.s=1 header.b=PRu1PhNx; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbjG3WLy (ORCPT + 99 others); Sun, 30 Jul 2023 18:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjG3WLx (ORCPT ); Sun, 30 Jul 2023 18:11:53 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D60A510D5; Sun, 30 Jul 2023 15:11:48 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4RDbFH2dQpzBg; Mon, 31 Jul 2023 00:11:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1690755107; bh=XeiZSisA1teraNfcUk/a3LOgtrVOqBrf3jTR2Qc7bJ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PRu1PhNxXlz0lKRxHQBH57tTm9vhI1meIw/X/0z9+rwMa/1Itt2sVuWyqJwKMk6xJ 7deONlOh/QN5k9fQyaEKNY7MUQVacCRyAsGF2a64xcAngC1CcPn3LGP4dH7d9up7Gu lN5HFn4UzK4bTkTksfhnUyUeYym1jmyYGqgzCDhhom7BrdE4iQZAsMUQb6MghG6GK4 laFh4svpIJJ/N9aUd6wZTprliZpbKa9JrsheelzhQvwHs2n0ScQwhFtxGeSvhqSyqL 5VvadZjCWu2WBSjANsJMyJOVrV7s235+w6d4Aa0OfS9iM3oIUhuQR9L/UO8BmwQpQF PIctLvor/LDew== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Mon, 31 Jul 2023 00:11:46 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Andi Shyti Cc: Svyatoslav Ryhel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wolfram Sang , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] i2c: Add GPIO-based hotplug gate Message-ID: References: <20230729160857.6332-1-clamor95@gmail.com> <20230729160857.6332-3-clamor95@gmail.com> <20230730202507.ojwinyjsx7ygyavp@intel.intel> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230730202507.ojwinyjsx7ygyavp@intel.intel> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Sun, Jul 30, 2023 at 10:25:07PM +0200, Andi Shyti wrote: > On Sat, Jul 29, 2023 at 07:08:57PM +0300, Svyatoslav Ryhel wrote: > > +static int i2c_hotplug_activate(struct i2c_hotplug_priv *priv) [...] > > +{ > > + int ret; > > + > > + if (priv->adap.algo_data) > > + return 0; [...] > > + ret = i2c_add_adapter(&priv->adap); > > + if (!ret) > > + priv->adap.algo_data = (void *)1; > > You want to set algo_data to "1" in order to keep the > activate/deactivate ordering. > > But if we fail to add the adapter, what's the point to keep it > active? The code above does "if we added the adapter, remember we did so". IOW, if we failed to add the adapter we don't set the mark so that the next interrupt edge can trigger another try. Also we prevent trying to remove an adapter we didn't successfully add. > > +static irqreturn_t i2c_hotplug_interrupt(int irq, void *dev_id) > > +{ > > + struct i2c_hotplug_priv *priv = dev_id; > > + > > + /* debounce */ > > + msleep(20); > can you explain this waiting and why 20ms? It's an arbitrary time long enough to avoid having to handle multiple on/off events that could happen when the dock is being inserted (ringing) and short enough to not have to worry about the user getting impatient. Best Regards Micha? Miros?aw