Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2000812pxb; Mon, 18 Jan 2021 05:51:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFGQArDpbLDW2wGQgbgzFGQntnrCHPxYejh3dvVESxoZUQ6O06q+eUB2PLyRGpzAvXjvaW X-Received: by 2002:a05:6402:17f9:: with SMTP id t25mr4908957edy.386.1610977901021; Mon, 18 Jan 2021 05:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610977901; cv=none; d=google.com; s=arc-20160816; b=Vl2ACBY6tGNB2QY2gi13GlXhfmoOkh0j+01gwxH2/p7Zlm7iWiPT6CBhRFc6O+0t48 Ceo3cdkt9uCdFJoTEWF/INFC5pvJMGefA4OQ4NiqD2MlNV+/Uld7sdbpQ6cOueMMJOgq mcqK3bGYH+vn56azDgJly7iJHxe3DgqsSa+B2gCoV7W0ykQimQWCsOFQZco84gsAbkoU o9YV9vWwajX7/R0MxHw00iKffronygTz7UCMJ9azal5foWJSzlFSjfZg9tlqpjtlMiDL K5NqizmjGI0l2wh47p+GVGT1GvWwhmF82oatcoSwwN2L+0DZMSN3YouEvNGbnG2yU7Wn bN7w== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=23UTvdRKd23ZMA0mwj8QBDBFLMhZi98EPyb+uf4ixP4=; b=xkn3NdNm0bK1TjzdktfJBx9gbY4aPMR94NxBVBeaJOaVvCMbFfQ2MQYlZPrnH3mRt5 XZrb2CuGkFzLPAtHTUqvrdOfKm9afzyF3xkA5+2rL8cSIx8e52YmoZMjzkIv0nYTyOBw iIDclTp77K6iM06vjTVfbL2XKY+sOUzcEJF7V4rpVQQuJEMaoIfX9r/RoxoTwF6Zxvwt 2aTmMAhyTKBt3c2iGTzkT+YfpJAT57Icu/m9zL8Z50x4kLYN/+9A73tdcr95FxZDfxWP mBZiYkXtuqGjuk8nEp4LhpfZjEItBfAh8xnrw9A4rUeQW6OSp9H6AZsewB8+U9rqCKZ7 vu7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn6si6518902edb.580.2021.01.18.05.51.14; Mon, 18 Jan 2021 05:51:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404741AbhARNnB (ORCPT + 99 others); Mon, 18 Jan 2021 08:43:01 -0500 Received: from mga14.intel.com ([192.55.52.115]:20331 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404694AbhARNk4 (ORCPT ); Mon, 18 Jan 2021 08:40:56 -0500 IronPort-SDR: MyOVt8vuN2Z1r5s11nFmV9zQ6GQe0/IbQTXUcSYZgqZii5voPRJxSs7rBDV94nNNpmVqI0B67B L8lJUo4cFGUA== X-IronPort-AV: E=McAfee;i="6000,8403,9867"; a="178025104" X-IronPort-AV: E=Sophos;i="5.79,356,1602572400"; d="scan'208";a="178025104" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 05:38:45 -0800 IronPort-SDR: /Q+2HufiZGX3oBzf+0ER74lIk7mRRaoLxsaFsyb3FRbFv7qF1XOG6KEqn4EG99M8X4ATPlvp43 de7X5IwY9YjA== X-IronPort-AV: E=Sophos;i="5.79,356,1602572400"; d="scan'208";a="402050586" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 05:38:40 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l1Ukw-002BZm-Lq; Mon, 18 Jan 2021 15:39:42 +0200 Date: Mon, 18 Jan 2021 15:39:42 +0200 From: Andy Shevchenko To: Daniel Scally Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org, rjw@rjwysocki.net, lenb@kernel.org, andy@kernel.org, mika.westerberg@linux.intel.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, wsa@kernel.org, lee.jones@linaro.org, hdegoede@redhat.com, mgross@linux.intel.com, robert.moore@intel.com, erik.kaneda@intel.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: Re: [PATCH v2 4/7] i2c: i2c-core-acpi: Add i2c_acpi_dev_name() Message-ID: <20210118133942.GI4077@smile.fi.intel.com> References: <20210118003428.568892-1-djrscally@gmail.com> <20210118003428.568892-5-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210118003428.568892-5-djrscally@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 18, 2021 at 12:34:25AM +0000, Daniel Scally wrote: > We want to refer to an i2c device by name before it has been I?C > created by the kernel; add a function that constructs the name > from the acpi device instead. acpi -> ACPI Prefix: "i2c: core: " With above Reviewed-by: Andy Shevchenko > Signed-off-by: Daniel Scally > --- > Changes in v2: > > - Stopped using devm_kasprintf() > > drivers/i2c/i2c-core-acpi.c | 16 ++++++++++++++++ > include/linux/i2c.h | 5 +++++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c > index 37c510d9347a..98c3ba9a2350 100644 > --- a/drivers/i2c/i2c-core-acpi.c > +++ b/drivers/i2c/i2c-core-acpi.c > @@ -497,6 +497,22 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, > } > EXPORT_SYMBOL_GPL(i2c_acpi_new_device); > > +/** > + * i2c_acpi_dev_name - Construct i2c device name for devs sourced from ACPI > + * @adev: ACPI device to construct the name for > + * > + * Constructs the name of an i2c device matching the format used by > + * i2c_dev_set_name() to allow users to refer to an i2c device by name even > + * before they have been instantiated. > + * > + * The caller is responsible for freeing the returned pointer. > + */ > +char *i2c_acpi_dev_name(struct acpi_device *adev) > +{ > + return kasprintf(GFP_KERNEL, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); > +} > +EXPORT_SYMBOL_GPL(i2c_acpi_dev_name); > + > #ifdef CONFIG_ACPI_I2C_OPREGION > static int acpi_gsb_i2c_read_bytes(struct i2c_client *client, > u8 cmd, u8 *data, u8 data_len) > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index 4d40a4b46810..b82aac05b17f 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -998,6 +998,7 @@ bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, > u32 i2c_acpi_find_bus_speed(struct device *dev); > struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, > struct i2c_board_info *info); > +char *i2c_acpi_dev_name(struct acpi_device *adev); > struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle); > #else > static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, > @@ -1014,6 +1015,10 @@ static inline struct i2c_client *i2c_acpi_new_device(struct device *dev, > { > return ERR_PTR(-ENODEV); > } > +static inline char *i2c_acpi_dev_name(struct acpi_device *adev) > +{ > + return NULL; > +} > static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) > { > return NULL; > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko