Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp474161rdb; Sat, 19 Aug 2023 09:05:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsNh+xnnrVIZj/cRPTz+opTO7h0E3+F+wI7eDYS0UnFzSDhTWgsRqMwrUNEnrDZMUQEo9e X-Received: by 2002:a05:6a00:1d04:b0:679:a1f1:a5f8 with SMTP id a4-20020a056a001d0400b00679a1f1a5f8mr2617085pfx.3.1692461106935; Sat, 19 Aug 2023 09:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692461106; cv=none; d=google.com; s=arc-20160816; b=aIQrBqNshgDnYYbxmJvfb1F0+1dG8PkVy0R7PTKaeOFKgVrLbxolHgLU/9C95dFa4Q IUlf8XWr4HKufqYbtm8cS4g1dwomPj0JBHyUxMMItVD4nvczQHZbH6NNtYd4XwY8bzBH lRntTcckIzkUzcaCuiD3vmHiFqf9GSYzEUMcuzmTFvb7ZU9ulY5f41rWH+IhbnoYiJ6J OcLqohGembmaTAeeD0s1wgS+A7VLly4MynHzV324pVoSJmsdyYhqtwSo+jXJ9138uQmJ 7N2v4UIa0DQbXFD/0b1mp5knAlFt5sQy+fHFOgnH7kteoVJ5Zg+jePEuW6W51obmgQ2f USyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ErgZTsUwfqdgH6PT40mXFD/nQxIBR8WLnzNxCoXWjK4=; fh=9ZZrhYN0+7AJTzaUmYlwZ5g6HTzJ8S+YAwl6zEJDY5k=; b=NbcG2z+hRPRqZVbRA+KWXyx+ajYYSns169WvoGwYMewic/l8LfwYnzKvtgf4SX0ztD Mdov9lBmH1BChjpGKmZYIuJLJhyd+09klQfpk1mvbBP0Yd+RKFfMxzbvOGzNsb+9P8XO ynYKiBfGxxPXZkN1hPm3I/yN2Uy0ow/LmxHabDPWDQQdaIwi5qDTOvAP/DrM5wOVVWtN lp52rGnqu+vnINdOuIWYIRcRB0RMk75dtPLPEYdoTNkbMvJ1FSvJzJP+mGn9kYLAITvA TNH7eFDq7oUFmCUhghdbG6lD37F8BSN3gbSGdvdTtZJc2PDQTs2TjA+nrr8UptN0ZPqb wdTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RJdNvY1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bu30-20020a63295e000000b0055b731aa9adsi3732113pgb.562.2023.08.19.09.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 09:05:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RJdNvY1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14623FE29F; Sat, 19 Aug 2023 01:49:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233032AbjHNVxn (ORCPT + 99 others); Mon, 14 Aug 2023 17:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbjHNVxM (ORCPT ); Mon, 14 Aug 2023 17:53:12 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C107E110; Mon, 14 Aug 2023 14:52:59 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bc0d39b52cso29423805ad.2; Mon, 14 Aug 2023 14:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692049979; x=1692654779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ErgZTsUwfqdgH6PT40mXFD/nQxIBR8WLnzNxCoXWjK4=; b=RJdNvY1f9I1BtI8sV0sMl4Eb42DKVZPFjPf9Cr9/YoNUN7PCQ3aOV9W1ALK4celB43 +8dZM7EvQVBExS1Kz5vFQOtY+OmOfc5FL3Kodm6WouLcaGqE9aQQyjbCDMKjjPuKuHY3 /335eAsXcheUkGoB3WOcEEWKqmNaxdECa4LYNhstlWJBXUsgENQyY4wLX4ICuQckx2Ed Fr3uV/ygcN1z3PfmV/BelQTkEWlVsxz3O7RQiFVpPTW9mnlLwHXkQ3MNk8pY1nhuV3VW iI2HscxZ036zWX0AR3wW9LUiblkpZ55utxA5poaOc8pNyqbkKQ1dWZ3p870xERXeAOPT mVaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692049979; x=1692654779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ErgZTsUwfqdgH6PT40mXFD/nQxIBR8WLnzNxCoXWjK4=; b=TyNJwJRyKDU1KJ7hw4enNVQTmSkjdXLN9wZsGNhtHiOpv7jhLpYWb2rQxejkCkZbTy iskKoy+2UIyS+hWhHVSOsU0CNu5AxPGx5p+4lpMy+33+Khwx8iXn2Rd2CHWT/1KXQggl 3xX7hutbvqIIlPN/rnoVxy3/fKPUCPnKCHJ0xCphvUatQntT9+HBzqGCUhoEQNOsXixp OHRgpvgPW5PxNF66gJYv4TSQ4IK4nzJtCSXFQIVSWgS7Ft/5CAHX7uiWovOvaKVIfSjl xy13+yCcKv18nf5jPp7UTup1S8VOVdo5zL6p6r6GppklDYJTO+YU8jOXOWOLynRUWcQG O8JA== X-Gm-Message-State: AOJu0Yy8TniN43CTKYWkQ/GGUAEeTqMn1lj6M+Asp49Fb9mRdIwcaWCf 5RfM5cKywgiHujcKoUQzYm7LV65qp2E= X-Received: by 2002:a17:902:d481:b0:1bc:69d0:a024 with SMTP id c1-20020a170902d48100b001bc69d0a024mr12124180plg.33.1692049978951; Mon, 14 Aug 2023 14:52:58 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:6c34:7c96:4b56:4eca]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b001b02bd00c61sm10056065plb.237.2023.08.14.14.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 14:52:58 -0700 (PDT) From: Dmitry Torokhov To: Wolfram Sang , Andy Shevchenko , Andi Shyti , Biju Das , Jonathan Cameron , Michael Hennerich , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 1/4] i2c: start migrating to a pointer in i2c_device_id Date: Mon, 14 Aug 2023 14:52:49 -0700 Message-ID: <20230814-i2c-id-rework-v1-1-3e5bc71c49ee@gmail.com> X-Mailer: git-send-email 2.41.0.694.ge786442a9b-goog In-Reply-To: <20230814-i2c-id-rework-v1-0-3e5bc71c49ee@gmail.com> References: <20230814-i2c-id-rework-v1-0-3e5bc71c49ee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13-dev-099c9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 The of_device_id structure uses a void pointer to associate additional driver-private data with device id, most commonly used to refer to a structure containing additional characteristics of a particular chip. However i2c_device_id uses an unsigned long. While it can easily be converted to a pointer, several drivers use it to store a scalar (and it is possible to use a pointer in of_device_id to store a scalar value as well). The worst case comes when OF part of a driver uses pointers, while legacy part is using scalars, causing constructs like: data = device_get_match_data(...); if (!data) data = &some_array[i2c_match_id(...)->data]; ... To avoid this introduce a const void "data" pointer to i2c_device_id as well, so that we can convert drivers one by one, and drop driver_data member in the end. The end goal is to clean up all helpers and make device_get_match_data() work universally for all ACPI, DT, and legacy variants. Signed-off-by: Dmitry Torokhov --- drivers/i2c/i2c-core-base.c | 2 +- include/linux/mod_devicetable.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 60746652fd52..75d12d79d8f1 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -126,7 +126,7 @@ const void *i2c_get_match_data(const struct i2c_client *client) if (!match) return NULL; - data = (const void *)match->driver_data; + data = match->data ?: (const void *)match->driver_data; } return data; diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index b0678b093cb2..21ac2a96e828 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -477,7 +477,8 @@ struct rpmsg_device_id { struct i2c_device_id { char name[I2C_NAME_SIZE]; - kernel_ulong_t driver_data; /* Data private to the driver */ + kernel_ulong_t driver_data; /* This field is obsolete */ + const void *data; /* Data private to the driver */ }; /* pci_epf */ -- 2.41.0.694.ge786442a9b-goog