Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp521519rwb; Fri, 4 Aug 2023 17:28:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB1GEWwne0a+hXvhk703PdZd2Jlwac/T19LCuG1pbdosK8AUKjcNMkmEdsSjk0+9pKGpxC X-Received: by 2002:a17:906:74da:b0:99b:efd3:3dcc with SMTP id z26-20020a17090674da00b0099befd33dccmr2415063ejl.62.1691195298105; Fri, 04 Aug 2023 17:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691195298; cv=none; d=google.com; s=arc-20160816; b=GY3iw+xs60tXktLANMfjkLe/Ko9QIGlIEcnvcTHCS+4ga86X2urh4aLhpuIzlY7L0M /XwAdZY2RBFjUmb4hvmGrEEvA7p9woW80B66IStt4xe45nvT3hKYV5VLmrFDugy7L03s I5IY3KCqEGC3bMxYAqEtVcaFuxCKPsl5I+f4A3MQeDH2L7FYL5v8Y3HsO+gm7CGCdsih PcXuyJnVvfFdnbstCA5RBL2QAhMEf8DJd6hKDaZEIb9LTF20ZMvL6fhAaqziH4+lUixQ CiFgBTtiGiOeYJy1xnbCDFH8GA5oWUbQtBUurzLAjuVCvt1DdLMSdrSXCw5D8RnOCEY3 eJ0w== 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=Xf+Tz2fFyyXSDGq4CfflRMSve1lco14CCrpTl97xtkk=; fh=BC5mzH7WYMNtnXIpJuxGlMILQBWZskNjPpt7nnWi2/E=; b=MMcvO4DisZWhKQLFxaeZ6pQQYSDeJ99hkDJ8+NaSEOxOg2Is/WYd/PNNaROUjLQjc/ dHaUVvtN7fd2fZmevvqPlorrNsLV9aBLnu2URHrHnrPN+rZgu6tWxZmHAf97oFMgUUgp 2zdgegdZcOiIfVpuRrAyWkmb1tBqCGHfSl3Ro77r6R+IS66f+zsqkXc0JUJyU2h+NjPF sA1D+i2Gd2yUSdhlkIs84Gv4brdzDeP4nE+41ZChUn3CbFBwcvLFNtxrNSU7+l/78ZeX zhO56jV1w2AIKaQ0hhrDVJVdocq/Ofhuw9kG0Mu693ypfTSUtu+oxsUKIsl0KWLVtojg H03Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pmY7MD90; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a170906180a00b009924c43105csi2232528eje.94.2023.08.04.17.27.52; Fri, 04 Aug 2023 17:28:18 -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=@kernel.org header.s=k20201202 header.b=pmY7MD90; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjHDXp7 (ORCPT + 99 others); Fri, 4 Aug 2023 19:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjHDXp6 (ORCPT ); Fri, 4 Aug 2023 19:45:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32AA23AAF; Fri, 4 Aug 2023 16:45:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B35186217A; Fri, 4 Aug 2023 23:45:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9282BC433C8; Fri, 4 Aug 2023 23:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691192756; bh=dMBsnf7UVFGyJspGf+fmvKXjCVkmWyeAS8rDN2tPz/E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pmY7MD90OJcgP5sniA1hTm7IbuLT54Ol4h94HMC4LBIr1ZpdVPwxB9g7omT0er3p4 UxyDAknlzxLaOFHqUSE1vyBQW8YgS3M72WNbprkGHZWqIYz1AxNZJew64vNMktqJdX XAD7c6rSLvW0tzLREevadkAfHaldgnbuxzQxMN6Io8gblPbVL1kfIL6bhb66E7UNag jDGT1trq+xSPnLWqFQwr9wLZPl0mYmANficejs3+FwpiFsq3mDW3ow6cbUkgAldtXf JkiSEY8n+x+8koeemZxXJHkPbEzAinL5bKrXUz9LVB8KJ6q1RM6lzPqr1jlYwt9Tq4 aq+F4/GBeBeHg== Date: Sat, 5 Aug 2023 01:45:53 +0200 From: Andi Shyti To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= 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: <20230804234553.3egec5i5tyfyg4hz@intel.intel> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 Tue, Aug 01, 2023 at 01:01:43AM +0200, Michał Mirosław wrote: > On Mon, Jul 31, 2023 at 12:11:47AM +0200, Michał Mirosław wrote: > > 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. > > Maybe the function's name is misleading? We could find a better one. > Activation/deactivation in this driver means "initialize/shutdown the > hotplugged bus" and is done in response to an edge (triggering an > interrupt) of the hotplug-detect signal. So that algo_data is randomly chosen as a boolean value given the fact that this particular driver doesn't have its own algorithms but it's using the ones from the parent. Right? If so, can we have a different and more meaningful boolean value for this? And... thinking aloud... are there race conditions here? I mean... you can't attach two docking stations, but are there other scenarios? Thanks, Andi