mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	i2c: core: Allocate temp client on the stack in i2c_detect
The temp client is used only in scope of this function, so there's no benefit in dynamic allocation. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
This commit is contained in:
		
							parent
							
								
									7fd9d28d1a
								
							
						
					
					
						commit
						735668f8e5
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -2461,7 +2461,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 | 
			
		|||
static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned short *address_list;
 | 
			
		||||
	struct i2c_client *temp_client;
 | 
			
		||||
	struct i2c_client temp_client;
 | 
			
		||||
	int i, err = 0;
 | 
			
		||||
 | 
			
		||||
	address_list = driver->address_list;
 | 
			
		||||
| 
						 | 
				
			
			@ -2482,22 +2482,19 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
 | 
			
		|||
		return 0;
 | 
			
		||||
 | 
			
		||||
	/* Set up a temporary client to help detect callback */
 | 
			
		||||
	temp_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
 | 
			
		||||
	if (!temp_client)
 | 
			
		||||
		return -ENOMEM;
 | 
			
		||||
	temp_client->adapter = adapter;
 | 
			
		||||
	memset(&temp_client, 0, sizeof(temp_client));
 | 
			
		||||
	temp_client.adapter = adapter;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
 | 
			
		||||
		dev_dbg(&adapter->dev,
 | 
			
		||||
			"found normal entry for adapter %d, addr 0x%02x\n",
 | 
			
		||||
			i2c_adapter_id(adapter), address_list[i]);
 | 
			
		||||
		temp_client->addr = address_list[i];
 | 
			
		||||
		err = i2c_detect_address(temp_client, driver);
 | 
			
		||||
		temp_client.addr = address_list[i];
 | 
			
		||||
		err = i2c_detect_address(&temp_client, driver);
 | 
			
		||||
		if (unlikely(err))
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	kfree(temp_client);
 | 
			
		||||
	return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue