linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c: Replace lists of special clients with flagging of such clients
@ 2024-08-21 20:46 Heiner Kallweit
  2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Heiner Kallweit @ 2024-08-21 20:46 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c@vger.kernel.org

So far lists are used to track special clients, i.e. auto-detected and
userspace-created clients. The same functionality can be achieved much
simpler by flagging such clients.

Heiner Kallweit (3):
  i2c: Replace list-based mechanism for handling auto-detected clients
  i2c: Replace list-based mechanism for handling userspace-created
    clients
  i2c: core: Remove obsolete members of i2c_adapter and i2c_client

 drivers/i2c/i2c-core-base.c | 108 +++++++++++-------------------------
 include/linux/i2c.h         |  10 +---
 2 files changed, 35 insertions(+), 83 deletions(-)

-- 
2.46.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients
  2024-08-21 20:46 [PATCH 0/3] i2c: Replace lists of special clients with flagging of such clients Heiner Kallweit
@ 2024-08-21 20:46 ` Heiner Kallweit
  2024-08-22 15:37   ` kernel test robot
  2024-08-22 17:31   ` kernel test robot
  2024-08-21 20:47 ` [PATCH 2/3] i2c: Replace list-based mechanism for handling userspace-created clients Heiner Kallweit
  2024-08-21 20:48 ` [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client Heiner Kallweit
  2 siblings, 2 replies; 7+ messages in thread
From: Heiner Kallweit @ 2024-08-21 20:46 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c@vger.kernel.org

So far a list is used to track auto-detected clients per driver.
The same functionality can be achieved much simpler by flagging
auto-detected clients.

Two notes regarding the usage of driver_for_each_device:
In our case it can't fail, however the function is annotated __must_check.
So a little workaround is needed to avoid a compiler warning.
Then we may remove nodes from the list over which we iterate.
This is safe, see the explanation at the beginning of lib/klist.c.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/i2c/i2c-core-base.c | 48 ++++++++++---------------------------
 include/linux/i2c.h         |  3 +--
 2 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 79292bb33..549bb76b7 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1662,23 +1662,6 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap)
 }
 EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter);
 
-static void i2c_do_del_adapter(struct i2c_driver *driver,
-			      struct i2c_adapter *adapter)
-{
-	struct i2c_client *client, *_n;
-
-	/* Remove the devices we created ourselves as the result of hardware
-	 * probing (using a driver's detect method) */
-	list_for_each_entry_safe(client, _n, &driver->clients, detected) {
-		if (client->adapter == adapter) {
-			dev_dbg(&adapter->dev, "Removing %s at 0x%x\n",
-				client->name, client->addr);
-			list_del(&client->detected);
-			i2c_unregister_device(client);
-		}
-	}
-}
-
 static int __unregister_client(struct device *dev, void *dummy)
 {
 	struct i2c_client *client = i2c_verify_client(dev);
@@ -1694,12 +1677,6 @@ static int __unregister_dummy(struct device *dev, void *dummy)
 	return 0;
 }
 
-static int __process_removed_adapter(struct device_driver *d, void *data)
-{
-	i2c_do_del_adapter(to_i2c_driver(d), data);
-	return 0;
-}
-
 /**
  * i2c_del_adapter - unregister I2C adapter
  * @adap: the adapter being unregistered
@@ -1723,11 +1700,6 @@ void i2c_del_adapter(struct i2c_adapter *adap)
 	}
 
 	i2c_acpi_remove_space_handler(adap);
-	/* Tell drivers about this removal */
-	mutex_lock(&core_lock);
-	bus_for_each_drv(&i2c_bus_type, NULL, adap,
-			       __process_removed_adapter);
-	mutex_unlock(&core_lock);
 
 	/* Remove devices instantiated from sysfs */
 	mutex_lock_nested(&adap->userspace_clients_lock,
@@ -1967,7 +1939,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 	/* add the driver to the list of i2c drivers in the driver core */
 	driver->driver.owner = owner;
 	driver->driver.bus = &i2c_bus_type;
-	INIT_LIST_HEAD(&driver->clients);
 
 	/* When registration returns, the driver core
 	 * will have called probe() for all matching-but-unbound devices.
@@ -1985,10 +1956,13 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 }
 EXPORT_SYMBOL(i2c_register_driver);
 
-static int __process_removed_driver(struct device *dev, void *data)
+static int __i2c_unregister_detected_client(struct device *dev, void *argp)
 {
-	if (dev->type == &i2c_adapter_type)
-		i2c_do_del_adapter(data, to_i2c_adapter(dev));
+	struct i2c_client *client = i2c_verify_client(dev);
+
+	if (client && client->flags & I2C_CLIENT_AUTO)
+		i2c_unregister_device(client);
+
 	return 0;
 }
 
@@ -1999,7 +1973,10 @@ static int __process_removed_driver(struct device *dev, void *data)
  */
 void i2c_del_driver(struct i2c_driver *driver)
 {
-	i2c_for_each_dev(driver, __process_removed_driver);
+	/* Satisfy __must_check, function can't fail */
+	if (driver_for_each_device(&driver->driver, NULL, NULL,
+				   __i2c_unregister_detected_client)) {
+	}
 
 	driver_unregister(&driver->driver);
 	pr_debug("driver [%s] unregistered\n", driver->driver.name);
@@ -2426,6 +2403,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 	/* Finally call the custom detection function */
 	memset(&info, 0, sizeof(struct i2c_board_info));
 	info.addr = addr;
+	info.flags = I2C_CLIENT_AUTO;
 	err = driver->detect(temp_client, &info);
 	if (err) {
 		/* -ENODEV is returned if the detection fails. We catch it
@@ -2452,9 +2430,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 		dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n",
 			info.type, info.addr);
 		client = i2c_new_client_device(adapter, &info);
-		if (!IS_ERR(client))
-			list_add_tail(&client->detected, &driver->clients);
-		else
+		if (IS_ERR(client))
 			dev_err(&adapter->dev, "Failed creating %s at 0x%02x\n",
 				info.type, info.addr);
 	}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 377def497..910a9b259 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -244,7 +244,6 @@ enum i2c_driver_flags {
  * @id_table: List of I2C devices supported by this driver
  * @detect: Callback for device detection
  * @address_list: The I2C addresses to probe (for detect)
- * @clients: List of detected clients we created (for i2c-core use only)
  * @flags: A bitmask of flags defined in &enum i2c_driver_flags
  *
  * The driver.owner field should be set to the module owner of this driver.
@@ -299,7 +298,6 @@ struct i2c_driver {
 	/* Device detection callback for automatic device creation */
 	int (*detect)(struct i2c_client *client, struct i2c_board_info *info);
 	const unsigned short *address_list;
-	struct list_head clients;
 
 	u32 flags;
 };
@@ -334,6 +332,7 @@ struct i2c_client {
 #define I2C_CLIENT_SLAVE	0x20	/* we are the slave */
 #define I2C_CLIENT_HOST_NOTIFY	0x40	/* We want to use I2C host notify */
 #define I2C_CLIENT_WAKE		0x80	/* for board_info; true iff can wake */
+#define I2C_CLIENT_AUTO		0x100	/* for board_info; auto-detected */
 #define I2C_CLIENT_SCCB		0x9000	/* Use Omnivision SCCB protocol */
 					/* Must match I2C_M_STOP|IGNORE_NAK */
 
-- 
2.46.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] i2c: Replace list-based mechanism for handling userspace-created clients
  2024-08-21 20:46 [PATCH 0/3] i2c: Replace lists of special clients with flagging of such clients Heiner Kallweit
  2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
@ 2024-08-21 20:47 ` Heiner Kallweit
  2024-08-21 20:48 ` [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client Heiner Kallweit
  2 siblings, 0 replies; 7+ messages in thread
From: Heiner Kallweit @ 2024-08-21 20:47 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c@vger.kernel.org

Similarly to the list of auto-detected clients, we can also replace the
list of userspace-created clients with flagging such client devices.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/i2c/i2c-core-base.c | 58 ++++++++++++++-----------------------
 include/linux/i2c.h         |  1 +
 2 files changed, 22 insertions(+), 37 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 549bb76b7..b9f1b1a1b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1265,14 +1265,12 @@ new_device_store(struct device *dev, struct device_attribute *attr,
 		info.flags |= I2C_CLIENT_SLAVE;
 	}
 
+	info.flags |= I2C_CLIENT_USER;
+
 	client = i2c_new_client_device(adap, &info);
 	if (IS_ERR(client))
 		return PTR_ERR(client);
 
-	/* Keep track of the added device */
-	mutex_lock(&adap->userspace_clients_lock);
-	list_add_tail(&client->detected, &adap->userspace_clients);
-	mutex_unlock(&adap->userspace_clients_lock);
 	dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device",
 		 info.type, info.addr);
 
@@ -1280,6 +1278,15 @@ new_device_store(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_WO(new_device);
 
+static int __i2c_find_user_addr(struct device *dev, void *addrp)
+{
+	struct i2c_client *client = i2c_verify_client(dev);
+	unsigned short addr = *(unsigned short *)addrp;
+
+	return client && client->flags & I2C_CLIENT_USER &&
+	       i2c_encode_flags_to_addr(client) == addr;
+}
+
 /*
  * And of course let the users delete the devices they instantiated, if
  * they got it wrong. This interface can only be used to delete devices
@@ -1294,7 +1301,8 @@ delete_device_store(struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
 	struct i2c_adapter *adap = to_i2c_adapter(dev);
-	struct i2c_client *client, *next;
+	struct i2c_client *client;
+	struct device *child_dev;
 	unsigned short addr;
 	char end;
 	int res;
@@ -1311,27 +1319,16 @@ delete_device_store(struct device *dev, struct device_attribute *attr,
 	}
 
 	/* Make sure the device was added through sysfs */
-	res = -ENOENT;
-	mutex_lock_nested(&adap->userspace_clients_lock,
-			  i2c_adapter_depth(adap));
-	list_for_each_entry_safe(client, next, &adap->userspace_clients,
-				 detected) {
-		if (i2c_encode_flags_to_addr(client) == addr) {
-			dev_info(dev, "%s: Deleting device %s at 0x%02hx\n",
-				 "delete_device", client->name, client->addr);
-
-			list_del(&client->detected);
-			i2c_unregister_device(client);
-			res = count;
-			break;
-		}
+	child_dev = device_find_child(&adap->dev, &addr, __i2c_find_user_addr);
+	if (!child_dev) {
+		dev_err(dev, "Can't find userspace-created device at %#x\n", addr);
+		return -ENOENT;
 	}
-	mutex_unlock(&adap->userspace_clients_lock);
+	client = i2c_verify_client(child_dev);
+	i2c_unregister_device(client);
+	put_device(child_dev);
 
-	if (res < 0)
-		dev_err(dev, "%s: Can't find device in list\n",
-			"delete_device");
-	return res;
+	return count;
 }
 static DEVICE_ATTR_IGNORE_LOCKDEP(delete_device, S_IWUSR, NULL,
 				  delete_device_store);
@@ -1688,7 +1685,6 @@ static int __unregister_dummy(struct device *dev, void *dummy)
 void i2c_del_adapter(struct i2c_adapter *adap)
 {
 	struct i2c_adapter *found;
-	struct i2c_client *client, *next;
 
 	/* First make sure that this adapter was ever added */
 	mutex_lock(&core_lock);
@@ -1701,18 +1697,6 @@ void i2c_del_adapter(struct i2c_adapter *adap)
 
 	i2c_acpi_remove_space_handler(adap);
 
-	/* Remove devices instantiated from sysfs */
-	mutex_lock_nested(&adap->userspace_clients_lock,
-			  i2c_adapter_depth(adap));
-	list_for_each_entry_safe(client, next, &adap->userspace_clients,
-				 detected) {
-		dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name,
-			client->addr);
-		list_del(&client->detected);
-		i2c_unregister_device(client);
-	}
-	mutex_unlock(&adap->userspace_clients_lock);
-
 	/* Detach any active clients. This can't fail, thus we do not
 	 * check the returned value. This is a two-pass process, because
 	 * we can't remove the dummy devices during the first pass: they
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 910a9b259..ba2564fe4 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -333,6 +333,7 @@ struct i2c_client {
 #define I2C_CLIENT_HOST_NOTIFY	0x40	/* We want to use I2C host notify */
 #define I2C_CLIENT_WAKE		0x80	/* for board_info; true iff can wake */
 #define I2C_CLIENT_AUTO		0x100	/* for board_info; auto-detected */
+#define I2C_CLIENT_USER		0x200	/* for board_info; userspace-created */
 #define I2C_CLIENT_SCCB		0x9000	/* Use Omnivision SCCB protocol */
 					/* Must match I2C_M_STOP|IGNORE_NAK */
 
-- 
2.46.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client
  2024-08-21 20:46 [PATCH 0/3] i2c: Replace lists of special clients with flagging of such clients Heiner Kallweit
  2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
  2024-08-21 20:47 ` [PATCH 2/3] i2c: Replace list-based mechanism for handling userspace-created clients Heiner Kallweit
@ 2024-08-21 20:48 ` Heiner Kallweit
  2024-08-22 17:31   ` kernel test robot
  2 siblings, 1 reply; 7+ messages in thread
From: Heiner Kallweit @ 2024-08-21 20:48 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c@vger.kernel.org

After the lists of auto-detected and userspace-created clients have been
removed, we can remove now unused struct members.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/i2c/i2c-core-base.c | 2 --
 include/linux/i2c.h         | 6 ------
 2 files changed, 8 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index b9f1b1a1b..4224ba6b1 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1499,8 +1499,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
 	adap->locked_flags = 0;
 	rt_mutex_init(&adap->bus_lock);
 	rt_mutex_init(&adap->mux_lock);
-	mutex_init(&adap->userspace_clients_lock);
-	INIT_LIST_HEAD(&adap->userspace_clients);
 
 	/* Set default timeout to 1 second if not already set */
 	if (adap->timeout == 0)
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index ba2564fe4..ada90df88 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -313,8 +313,6 @@ struct i2c_driver {
  * @dev: Driver model device node for the slave.
  * @init_irq: IRQ that was set at initialization
  * @irq: indicates the IRQ generated by this device (if any)
- * @detected: member of an i2c_driver.clients list or i2c-core's
- *	userspace_devices list
  * @slave_cb: Callback when I2C slave mode of an adapter is used. The adapter
  *	calls it to pass on slave events to the slave driver.
  * @devres_group_id: id of the devres group that will be created for resources
@@ -345,7 +343,6 @@ struct i2c_client {
 	struct device dev;		/* the device structure		*/
 	int init_irq;			/* irq set at initialization	*/
 	int irq;			/* irq issued by device		*/
-	struct list_head detected;
 #if IS_ENABLED(CONFIG_I2C_SLAVE)
 	i2c_slave_cb_t slave_cb;	/* callback for slave mode	*/
 #endif
@@ -751,9 +748,6 @@ struct i2c_adapter {
 	char name[48];
 	struct completion dev_released;
 
-	struct mutex userspace_clients_lock;
-	struct list_head userspace_clients;
-
 	struct i2c_bus_recovery_info *bus_recovery_info;
 	const struct i2c_adapter_quirks *quirks;
 
-- 
2.46.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients
  2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
@ 2024-08-22 15:37   ` kernel test robot
  2024-08-22 17:31   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-08-22 15:37 UTC (permalink / raw)
  To: Heiner Kallweit, Wolfram Sang; +Cc: oe-kbuild-all, linux-i2c@vger.kernel.org

Hi Heiner,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.11-rc4 next-20240822]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/i2c-Replace-list-based-mechanism-for-handling-auto-detected-clients/20240822-044950
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/9eb8879b-f975-41fc-a098-0ad189cc583d%40gmail.com
patch subject: [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240822/202408222315.iGb5Ttng-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240822/202408222315.iGb5Ttng-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408222315.iGb5Ttng-lkp@intel.com/

All errors (new ones prefixed by >>):

   sound/ppc/keywest.c: In function 'keywest_attach_adapter':
>> sound/ppc/keywest.c:69:70: error: 'struct i2c_driver' has no member named 'clients'
      69 |                       &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
         |                                                                      ^~


vim +69 sound/ppc/keywest.c

5de4155bb3760f Jean Delvare       2009-04-20  28  
5de4155bb3760f Jean Delvare       2009-04-20  29  /*
5de4155bb3760f Jean Delvare       2009-04-20  30   * This is kind of a hack, best would be to turn powermac to fixed i2c
5de4155bb3760f Jean Delvare       2009-04-20  31   * bus numbers and declare the sound device as part of platform
5de4155bb3760f Jean Delvare       2009-04-20  32   * initialization
5de4155bb3760f Jean Delvare       2009-04-20  33   */
^1da177e4c3f41 Linus Torvalds     2005-04-16  34  static int keywest_attach_adapter(struct i2c_adapter *adapter)
^1da177e4c3f41 Linus Torvalds     2005-04-16  35  {
5de4155bb3760f Jean Delvare       2009-04-20  36  	struct i2c_board_info info;
04a9af2e038423 Wolfram Sang       2020-03-26  37  	struct i2c_client *client;
^1da177e4c3f41 Linus Torvalds     2005-04-16  38  
^1da177e4c3f41 Linus Torvalds     2005-04-16  39  	if (! keywest_ctx)
^1da177e4c3f41 Linus Torvalds     2005-04-16  40  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds     2005-04-16  41  
903dba1eae4927 Jean Delvare       2009-05-14  42  	if (strncmp(adapter->name, "mac-io", 6))
ac397c80de8950 Wolfram Sang       2015-05-09  43  		return -EINVAL; /* ignored */
^1da177e4c3f41 Linus Torvalds     2005-04-16  44  
5de4155bb3760f Jean Delvare       2009-04-20  45  	memset(&info, 0, sizeof(struct i2c_board_info));
75b1a8f9d62e50 Joe Perches        2021-01-04  46  	strscpy(info.type, "keywest", I2C_NAME_SIZE);
5de4155bb3760f Jean Delvare       2009-04-20  47  	info.addr = keywest_ctx->addr;
04a9af2e038423 Wolfram Sang       2020-03-26  48  	client = i2c_new_client_device(adapter, &info);
04a9af2e038423 Wolfram Sang       2020-03-26  49  	if (IS_ERR(client))
04a9af2e038423 Wolfram Sang       2020-03-26  50  		return PTR_ERR(client);
04a9af2e038423 Wolfram Sang       2020-03-26  51  	keywest_ctx->client = client;
04a9af2e038423 Wolfram Sang       2020-03-26  52  
18c4078489fe06 Takashi Iwai       2009-10-01  53  	/*
18c4078489fe06 Takashi Iwai       2009-10-01  54  	 * We know the driver is already loaded, so the device should be
18c4078489fe06 Takashi Iwai       2009-10-01  55  	 * already bound. If not it means binding failed, and then there
18c4078489fe06 Takashi Iwai       2009-10-01  56  	 * is no point in keeping the device instantiated.
18c4078489fe06 Takashi Iwai       2009-10-01  57  	 */
a7cde6d25c494e Lars-Peter Clausen 2013-09-29  58  	if (!keywest_ctx->client->dev.driver) {
18c4078489fe06 Takashi Iwai       2009-10-01  59  		i2c_unregister_device(keywest_ctx->client);
18c4078489fe06 Takashi Iwai       2009-10-01  60  		keywest_ctx->client = NULL;
18c4078489fe06 Takashi Iwai       2009-10-01  61  		return -ENODEV;
18c4078489fe06 Takashi Iwai       2009-10-01  62  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  63  	
5de4155bb3760f Jean Delvare       2009-04-20  64  	/*
5de4155bb3760f Jean Delvare       2009-04-20  65  	 * Let i2c-core delete that device on driver removal.
5de4155bb3760f Jean Delvare       2009-04-20  66  	 * This is safe because i2c-core holds the core_lock mutex for us.
5de4155bb3760f Jean Delvare       2009-04-20  67  	 */
5de4155bb3760f Jean Delvare       2009-04-20  68  	list_add_tail(&keywest_ctx->client->detected,
a7cde6d25c494e Lars-Peter Clausen 2013-09-29 @69  		      &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
^1da177e4c3f41 Linus Torvalds     2005-04-16  70  	return 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  71  }
^1da177e4c3f41 Linus Torvalds     2005-04-16  72  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients
  2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
  2024-08-22 15:37   ` kernel test robot
@ 2024-08-22 17:31   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-08-22 17:31 UTC (permalink / raw)
  To: Heiner Kallweit, Wolfram Sang
  Cc: llvm, oe-kbuild-all, linux-i2c@vger.kernel.org

Hi Heiner,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.11-rc4 next-20240822]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/i2c-Replace-list-based-mechanism-for-handling-auto-detected-clients/20240822-044950
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/9eb8879b-f975-41fc-a098-0ad189cc583d%40gmail.com
patch subject: [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240823/202408230125.uTXoWaqi-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 26670e7fa4f032a019d23d56c6a02926e854e8af)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240823/202408230125.uTXoWaqi-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408230125.uTXoWaqi-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from sound/ppc/keywest.c:10:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:25:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/powerpc/include/asm/io.h:24:
   In file included from include/linux/mm.h:2228:
   include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     500 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     501 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     507 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     508 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     519 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     520 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:528:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     528 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     529 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> sound/ppc/keywest.c:69:58: error: no member named 'clients' in 'struct i2c_driver'
      69 |                       &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
         |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
   5 warnings and 1 error generated.


vim +69 sound/ppc/keywest.c

5de4155bb3760f Jean Delvare       2009-04-20  28  
5de4155bb3760f Jean Delvare       2009-04-20  29  /*
5de4155bb3760f Jean Delvare       2009-04-20  30   * This is kind of a hack, best would be to turn powermac to fixed i2c
5de4155bb3760f Jean Delvare       2009-04-20  31   * bus numbers and declare the sound device as part of platform
5de4155bb3760f Jean Delvare       2009-04-20  32   * initialization
5de4155bb3760f Jean Delvare       2009-04-20  33   */
^1da177e4c3f41 Linus Torvalds     2005-04-16  34  static int keywest_attach_adapter(struct i2c_adapter *adapter)
^1da177e4c3f41 Linus Torvalds     2005-04-16  35  {
5de4155bb3760f Jean Delvare       2009-04-20  36  	struct i2c_board_info info;
04a9af2e038423 Wolfram Sang       2020-03-26  37  	struct i2c_client *client;
^1da177e4c3f41 Linus Torvalds     2005-04-16  38  
^1da177e4c3f41 Linus Torvalds     2005-04-16  39  	if (! keywest_ctx)
^1da177e4c3f41 Linus Torvalds     2005-04-16  40  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds     2005-04-16  41  
903dba1eae4927 Jean Delvare       2009-05-14  42  	if (strncmp(adapter->name, "mac-io", 6))
ac397c80de8950 Wolfram Sang       2015-05-09  43  		return -EINVAL; /* ignored */
^1da177e4c3f41 Linus Torvalds     2005-04-16  44  
5de4155bb3760f Jean Delvare       2009-04-20  45  	memset(&info, 0, sizeof(struct i2c_board_info));
75b1a8f9d62e50 Joe Perches        2021-01-04  46  	strscpy(info.type, "keywest", I2C_NAME_SIZE);
5de4155bb3760f Jean Delvare       2009-04-20  47  	info.addr = keywest_ctx->addr;
04a9af2e038423 Wolfram Sang       2020-03-26  48  	client = i2c_new_client_device(adapter, &info);
04a9af2e038423 Wolfram Sang       2020-03-26  49  	if (IS_ERR(client))
04a9af2e038423 Wolfram Sang       2020-03-26  50  		return PTR_ERR(client);
04a9af2e038423 Wolfram Sang       2020-03-26  51  	keywest_ctx->client = client;
04a9af2e038423 Wolfram Sang       2020-03-26  52  
18c4078489fe06 Takashi Iwai       2009-10-01  53  	/*
18c4078489fe06 Takashi Iwai       2009-10-01  54  	 * We know the driver is already loaded, so the device should be
18c4078489fe06 Takashi Iwai       2009-10-01  55  	 * already bound. If not it means binding failed, and then there
18c4078489fe06 Takashi Iwai       2009-10-01  56  	 * is no point in keeping the device instantiated.
18c4078489fe06 Takashi Iwai       2009-10-01  57  	 */
a7cde6d25c494e Lars-Peter Clausen 2013-09-29  58  	if (!keywest_ctx->client->dev.driver) {
18c4078489fe06 Takashi Iwai       2009-10-01  59  		i2c_unregister_device(keywest_ctx->client);
18c4078489fe06 Takashi Iwai       2009-10-01  60  		keywest_ctx->client = NULL;
18c4078489fe06 Takashi Iwai       2009-10-01  61  		return -ENODEV;
18c4078489fe06 Takashi Iwai       2009-10-01  62  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  63  	
5de4155bb3760f Jean Delvare       2009-04-20  64  	/*
5de4155bb3760f Jean Delvare       2009-04-20  65  	 * Let i2c-core delete that device on driver removal.
5de4155bb3760f Jean Delvare       2009-04-20  66  	 * This is safe because i2c-core holds the core_lock mutex for us.
5de4155bb3760f Jean Delvare       2009-04-20  67  	 */
5de4155bb3760f Jean Delvare       2009-04-20  68  	list_add_tail(&keywest_ctx->client->detected,
a7cde6d25c494e Lars-Peter Clausen 2013-09-29 @69  		      &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
^1da177e4c3f41 Linus Torvalds     2005-04-16  70  	return 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  71  }
^1da177e4c3f41 Linus Torvalds     2005-04-16  72  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client
  2024-08-21 20:48 ` [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client Heiner Kallweit
@ 2024-08-22 17:31   ` kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-08-22 17:31 UTC (permalink / raw)
  To: Heiner Kallweit, Wolfram Sang; +Cc: oe-kbuild-all, linux-i2c@vger.kernel.org

Hi Heiner,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.11-rc4 next-20240822]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/i2c-Replace-list-based-mechanism-for-handling-auto-detected-clients/20240822-044950
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/01cef629-5650-4ef2-93db-9a16893ff5a0%40gmail.com
patch subject: [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240823/202408230156.SZSDmCCc-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240823/202408230156.SZSDmCCc-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408230156.SZSDmCCc-lkp@intel.com/

All errors (new ones prefixed by >>):

   sound/ppc/keywest.c: In function 'keywest_attach_adapter':
>> sound/ppc/keywest.c:68:43: error: 'struct i2c_client' has no member named 'detected'
      68 |         list_add_tail(&keywest_ctx->client->detected,
         |                                           ^~
   sound/ppc/keywest.c:69:70: error: 'struct i2c_driver' has no member named 'clients'
      69 |                       &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
         |                                                                      ^~


vim +68 sound/ppc/keywest.c

5de4155bb3760fc Jean Delvare       2009-04-20  28  
5de4155bb3760fc Jean Delvare       2009-04-20  29  /*
5de4155bb3760fc Jean Delvare       2009-04-20  30   * This is kind of a hack, best would be to turn powermac to fixed i2c
5de4155bb3760fc Jean Delvare       2009-04-20  31   * bus numbers and declare the sound device as part of platform
5de4155bb3760fc Jean Delvare       2009-04-20  32   * initialization
5de4155bb3760fc Jean Delvare       2009-04-20  33   */
^1da177e4c3f415 Linus Torvalds     2005-04-16  34  static int keywest_attach_adapter(struct i2c_adapter *adapter)
^1da177e4c3f415 Linus Torvalds     2005-04-16  35  {
5de4155bb3760fc Jean Delvare       2009-04-20  36  	struct i2c_board_info info;
04a9af2e0384234 Wolfram Sang       2020-03-26  37  	struct i2c_client *client;
^1da177e4c3f415 Linus Torvalds     2005-04-16  38  
^1da177e4c3f415 Linus Torvalds     2005-04-16  39  	if (! keywest_ctx)
^1da177e4c3f415 Linus Torvalds     2005-04-16  40  		return -EINVAL;
^1da177e4c3f415 Linus Torvalds     2005-04-16  41  
903dba1eae49270 Jean Delvare       2009-05-14  42  	if (strncmp(adapter->name, "mac-io", 6))
ac397c80de89509 Wolfram Sang       2015-05-09  43  		return -EINVAL; /* ignored */
^1da177e4c3f415 Linus Torvalds     2005-04-16  44  
5de4155bb3760fc Jean Delvare       2009-04-20  45  	memset(&info, 0, sizeof(struct i2c_board_info));
75b1a8f9d62e50f Joe Perches        2021-01-04  46  	strscpy(info.type, "keywest", I2C_NAME_SIZE);
5de4155bb3760fc Jean Delvare       2009-04-20  47  	info.addr = keywest_ctx->addr;
04a9af2e0384234 Wolfram Sang       2020-03-26  48  	client = i2c_new_client_device(adapter, &info);
04a9af2e0384234 Wolfram Sang       2020-03-26  49  	if (IS_ERR(client))
04a9af2e0384234 Wolfram Sang       2020-03-26  50  		return PTR_ERR(client);
04a9af2e0384234 Wolfram Sang       2020-03-26  51  	keywest_ctx->client = client;
04a9af2e0384234 Wolfram Sang       2020-03-26  52  
18c4078489fe064 Takashi Iwai       2009-10-01  53  	/*
18c4078489fe064 Takashi Iwai       2009-10-01  54  	 * We know the driver is already loaded, so the device should be
18c4078489fe064 Takashi Iwai       2009-10-01  55  	 * already bound. If not it means binding failed, and then there
18c4078489fe064 Takashi Iwai       2009-10-01  56  	 * is no point in keeping the device instantiated.
18c4078489fe064 Takashi Iwai       2009-10-01  57  	 */
a7cde6d25c494e1 Lars-Peter Clausen 2013-09-29  58  	if (!keywest_ctx->client->dev.driver) {
18c4078489fe064 Takashi Iwai       2009-10-01  59  		i2c_unregister_device(keywest_ctx->client);
18c4078489fe064 Takashi Iwai       2009-10-01  60  		keywest_ctx->client = NULL;
18c4078489fe064 Takashi Iwai       2009-10-01  61  		return -ENODEV;
18c4078489fe064 Takashi Iwai       2009-10-01  62  	}
^1da177e4c3f415 Linus Torvalds     2005-04-16  63  	
5de4155bb3760fc Jean Delvare       2009-04-20  64  	/*
5de4155bb3760fc Jean Delvare       2009-04-20  65  	 * Let i2c-core delete that device on driver removal.
5de4155bb3760fc Jean Delvare       2009-04-20  66  	 * This is safe because i2c-core holds the core_lock mutex for us.
5de4155bb3760fc Jean Delvare       2009-04-20  67  	 */
5de4155bb3760fc Jean Delvare       2009-04-20 @68  	list_add_tail(&keywest_ctx->client->detected,
a7cde6d25c494e1 Lars-Peter Clausen 2013-09-29  69  		      &to_i2c_driver(keywest_ctx->client->dev.driver)->clients);
^1da177e4c3f415 Linus Torvalds     2005-04-16  70  	return 0;
^1da177e4c3f415 Linus Torvalds     2005-04-16  71  }
^1da177e4c3f415 Linus Torvalds     2005-04-16  72  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-22 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 20:46 [PATCH 0/3] i2c: Replace lists of special clients with flagging of such clients Heiner Kallweit
2024-08-21 20:46 ` [PATCH 1/3] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
2024-08-22 15:37   ` kernel test robot
2024-08-22 17:31   ` kernel test robot
2024-08-21 20:47 ` [PATCH 2/3] i2c: Replace list-based mechanism for handling userspace-created clients Heiner Kallweit
2024-08-21 20:48 ` [PATCH 3/3] i2c: Remove obsolete members of i2c_adapter and i2c_client Heiner Kallweit
2024-08-22 17:31   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).