From patchwork Thu May 20 14:09:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 444926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6726AC43470 for ; Thu, 20 May 2021 14:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E6EF61353 for ; Thu, 20 May 2021 14:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243715AbhETONS (ORCPT ); Thu, 20 May 2021 10:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240757AbhETOMb (ORCPT ); Thu, 20 May 2021 10:12:31 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E71C06135D; Thu, 20 May 2021 07:09:45 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id f6-20020a1c1f060000b0290175ca89f698so5506283wmf.5; Thu, 20 May 2021 07:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DScPvwKQ0WIISqQGprqYEDaZlRL+0SsZpAZEoDfBM6E=; b=epZ4NBGpKpmvR3LAKLC/jkyQMGltnEBa5H02wagxkhhCHKquMX5fi2bDZLjGNwu4ii AcG2OthR4bi5RozEMLbjtxLPMOqj7bkO7idvRGHIcVJTtMB0spUIgYXFttxBkP68J41U Y5AljqNAZgkzpseQnkEQeqBKToJ+pnfz8hnSnvlITOF9XNaRiMCH4n6g55JzTPUSkYFA bC6G22Z0ry+PIpccTR1tdVlMUFI2uha6MmIipdRd60VSOZvg+klYLb5KaiAC9DaoW+7+ tVvUr7MgXuYWcbrkH6iTl4QakQOmYIliszriFQyJjoXkf9HztBcJ3fMJOIWBDYWVyTdq PrzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DScPvwKQ0WIISqQGprqYEDaZlRL+0SsZpAZEoDfBM6E=; b=U/yMIotYKlM+nqrBevJneKzT5nUj5n3y1pBxxMB8i9dyXsKBDucodHRi5wcFy9Y3ST p1qZQ7sck20TGwKLHgdX+LYvTW81ItNdxZpeCy21wX5RR/K20tAAiaNHgidEOytkFMuJ NJbBOsO2GKTjvlQZWQiuhbqfGqujo7jHhpv6ddEL1RjZPq/0+fBlsjgnEVCKl8o20jhO /KcBd45lGUgl+fRLaYkkRcrk4lu5cKk9XtCTTZ67rSeP7/eIbghAWNVKUkK0pl2eVdBu U+aUYG8tHgcysVACgr5vh6hJs8VIUrkU3YXdKuC/+F8tiiNAHBnx6l3K/V+wen7RaQeu ydfA== X-Gm-Message-State: AOAM530U9PRvfSkge4ELzefCthepBaLCmNZSlWzKGDvoWpNkhk9qY9PV Zoq53yfd4TjZoBNUwy/Nqxw= X-Google-Smtp-Source: ABdhPJysq0wOJR0dRUN8yQ2vkDAD3ldi//g2fuhWbfYRM4Z4Si/r62BsMPieVqlNTKe/TG0oXyeQgQ== X-Received: by 2002:a7b:cd04:: with SMTP id f4mr4024898wmj.84.1621519784115; Thu, 20 May 2021 07:09:44 -0700 (PDT) Received: from valhalla.home ([91.110.20.117]) by smtp.gmail.com with ESMTPSA id m6sm8411974wml.3.2021.05.20.07.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 07:09:43 -0700 (PDT) From: Daniel Scally To: "Rafael J . Wysocki" , Andy Shevchenko , Daniel Scally , Wolfram Sang , Lee Jones , Hans de Goede , Maximilian Luz , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org Cc: Len Brown , Mika Westerberg , Russell King , Linus Walleij , Bartosz Golaszewski , Mark Gross , Robert Moore , Erik Kaneda , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, Sakari Ailus Subject: [PATCH v4 3/8] i2c: core: Add a format macro for I2C device names Date: Thu, 20 May 2021 15:09:23 +0100 Message-Id: <20210520140928.3252671-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210520140928.3252671-1-djrscally@gmail.com> References: <20210520140928.3252671-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some places in the kernel allow users to map resources to a device using device name (for example, in the struct gpiod_lookup_table). Currently this involves waiting for the I2C client to have been registered so we can use dev_name(&client->dev). We want to add a function to allow users to refer to an I2C device by name before it has been instantiated, so create a macro for the format that's accessible outside the I2C layer and use it in i2c_dev_set_name(). Acked-by: Wolfram Sang Suggested-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Reviewed-by: Sakari Ailus Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes since v3: - None drivers/i2c/i2c-core-base.c | 4 ++-- include/linux/i2c.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 5a97e4a02fa2..2ca50a6f5514 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -852,12 +852,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, struct acpi_device *adev = ACPI_COMPANION(&client->dev); if (info && info->dev_name) { - dev_set_name(&client->dev, "i2c-%s", info->dev_name); + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); return; } if (adev) { - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); return; } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index e8f2ac8c9c3d..d9f433617a8d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -39,6 +39,9 @@ enum i2c_slave_event; typedef int (*i2c_slave_cb_t)(struct i2c_client *client, enum i2c_slave_event event, u8 *val); +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ +#define I2C_DEV_NAME_FORMAT "i2c-%s" + /* I2C Frequency Modes */ #define I2C_MAX_STANDARD_MODE_FREQ 100000 #define I2C_MAX_FAST_MODE_FREQ 400000