From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6F73B646; Thu, 10 Oct 2024 15:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728573641; cv=none; b=r2wGOPdi3hmQWBR0AhwdVURRvLyj6P9cLtifZXE+diRVyWX67018CnRbp4nfRbF5jfFEcX+k3AmfWYBKLcSpBqxx9pERd0F9P8yzKM1SLypgwSyaNq4umWRaU/Rr7hebb/TVu+rp+RbBwmt1aPf1gElkGwIrLX61vwuAA5dLJ3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728573641; c=relaxed/simple; bh=FMOKQmRnRuG0u6SCHuk/rSndbZsClfTEYhslQL/e4Ss=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SnaL6pqJ4dpwrJfeahfMKD++CPfbavR1IqWvK9uaMq8tJRMr8HTHI9pxG3nhjdxqtnD9xgOBpiT6YVYhY9f/LPWD4lcIfvsGt7I/5RKyOHM3eWmNttHYDxJi1q3L8KLJ+e1CHJAtUkijSpXFCoEliltnHmy927IG8+XdKkefOMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Z0lpxxZS; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z0lpxxZS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728573640; x=1760109640; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FMOKQmRnRuG0u6SCHuk/rSndbZsClfTEYhslQL/e4Ss=; b=Z0lpxxZSVK9zbaYNzoqGUBV29/foJEJf7mVF3GY8IWsSbnU0Qg0W3q0Y 58EZ6HUZswo1Z2M8utA7g9z7qUSdQkONfXHS2TliWtCw5oMkQ7FolWJpg 2Ls217S+PrhlJ5I0tVZzAGZMcfLUrUHmAFMvFLDpmLm4Q4eJwblg+Abxy auyvLob1gN9vJ0lwjp5nh/NKgmsvm8iy2Ip+D1NAM8korusUGqnMRq3CO 6wLxOW0ltXsEc1887z8xx5ChoQaGRBr7TwYN/inChRG/3mu7Z02HVhD1e +VSjQYq4TZ6Q/uEp+nCnWSpGvB+XrOoN1xM+/oB2oedecnrIgw55qnOTl A==; X-CSE-ConnectionGUID: W35/HYwmSrqEun/momCJJA== X-CSE-MsgGUID: JqyMZV81RTu2+bLrf40CkA== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="45417083" X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="45417083" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 08:20:39 -0700 X-CSE-ConnectionGUID: uFuqKWFpRUGoCWa1ZSzSlg== X-CSE-MsgGUID: HFVp1nsLSFi0YkYM0dHCyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="76532971" Received: from smile.fi.intel.com ([10.237.72.154]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 08:20:35 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1syuxr-00000001ZlS-3lMj; Thu, 10 Oct 2024 18:20:31 +0300 Date: Thu, 10 Oct 2024 18:20:31 +0300 From: Andy Shevchenko To: Chen-Yu Tsai Cc: Rob Herring , Saravana Kannan , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , Jiri Kosina , linux-i2c@vger.kernel.org Subject: Re: [PATCH v8 6/8] i2c: of-prober: Add GPIO support to simple helpers Message-ID: References: <20241008073430.3992087-1-wenst@chromium.org> <20241008073430.3992087-7-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241008073430.3992087-7-wenst@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Tue, Oct 08, 2024 at 03:34:25PM +0800, Chen-Yu Tsai wrote: > Add GPIO support to the simple helpers for the I2C OF component prober. > Components that the prober intends to probe likely require their > regulator supplies be enabled, and GPIOs be toggled to enable them or > bring them out of reset before they will respond to probe attempts. > Regulator supplies were handled in the previous patch. > > The assumption is that the same class of components to be probed are > always connected in the same fashion with the same regulator supply > and GPIO. The names may vary due to binding differences, but the > physical layout does not change. > > This supports at most one GPIO pin. The user must specify the GPIO name, > the polarity, and the amount of time to wait after the GPIO is toggled. > Devices with more than one GPIO pin likely require specific power > sequencing beyond what generic code can easily support. ... > +static int i2c_of_probe_simple_get_gpiod(struct device *dev, struct device_node *node, > + struct i2c_of_probe_simple_ctx *ctx) > +{ > + struct fwnode_handle *fwnode = of_fwnode_handle(node); > + struct gpio_desc *gpiod; > + const char *con_id; > + > + /* NULL signals no GPIO needed */ > + if (!ctx->opts->gpio_name) > + return 0; > + > + /* An empty string signals an unnamed GPIO */ > + if (!ctx->opts->gpio_name[0]) > + con_id = NULL; > + else > + con_id = ctx->opts->gpio_name; Can it use positive conditional? if (ctx->opts->gpio_name[0]) con_id = ctx->opts->gpio_name; else con_id = NULL; > + gpiod = fwnode_gpiod_get_index(fwnode, con_id, 0, GPIOD_ASIS, "i2c-of-prober"); > + if (IS_ERR(gpiod)) > + return PTR_ERR(gpiod); > + > + ctx->gpiod = gpiod; > + > + return 0; > +} ... > +static void i2c_of_probe_simple_disable_gpio(struct device *dev, struct i2c_of_probe_simple_ctx *ctx) > +{ > + if (!ctx->gpiod) > + return; Do you need this check for the future patches? > + /* Ignore error if GPIO is not in output direction */ > + gpiod_set_value(ctx->gpiod, !ctx->opts->gpio_assert_to_enable); > +} ... > struct regulator; > +struct gpio_desc; Ordered? -- With Best Regards, Andy Shevchenko