mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	hwmon: (nct6775-i2c) Use i2c_get_match_data()
Use preferred i2c_get_match_data() instead of of_match_device() and i2c_match_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Adjust the 'kinds' enum to not use 0, so that no match data can be distinguished from a valid enum value. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231115205703.3730448-2-robh@kernel.org [groeck: Use double cast for i2c_get_match_data() to make clang happy] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
		
							parent
							
								
									5cfc392cc9
								
							
						
					
					
						commit
						10a0575ea0
					
				
					 2 changed files with 3 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
#include <linux/hwmon.h>
 | 
			
		||||
#include <linux/hwmon-sysfs.h>
 | 
			
		||||
#include <linux/err.h>
 | 
			
		||||
#include <linux/of_device.h>
 | 
			
		||||
#include <linux/of.h>
 | 
			
		||||
#include <linux/regmap.h>
 | 
			
		||||
#include "nct6775.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -155,23 +155,13 @@ static const struct regmap_config nct6775_i2c_regmap_config = {
 | 
			
		|||
static int nct6775_i2c_probe(struct i2c_client *client)
 | 
			
		||||
{
 | 
			
		||||
	struct nct6775_data *data;
 | 
			
		||||
	const struct of_device_id *of_id;
 | 
			
		||||
	const struct i2c_device_id *i2c_id;
 | 
			
		||||
	struct device *dev = &client->dev;
 | 
			
		||||
 | 
			
		||||
	of_id = of_match_device(nct6775_i2c_of_match, dev);
 | 
			
		||||
	i2c_id = i2c_match_id(nct6775_i2c_id, client);
 | 
			
		||||
 | 
			
		||||
	if (of_id && (unsigned long)of_id->data != i2c_id->driver_data)
 | 
			
		||||
		dev_notice(dev, "Device mismatch: %s in device tree, %s detected\n",
 | 
			
		||||
			   of_id->name, i2c_id->name);
 | 
			
		||||
 | 
			
		||||
	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
 | 
			
		||||
	if (!data)
 | 
			
		||||
		return -ENOMEM;
 | 
			
		||||
 | 
			
		||||
	data->kind = i2c_id->driver_data;
 | 
			
		||||
 | 
			
		||||
	data->kind = (enum kinds)(uintptr_t)i2c_get_match_data(client);
 | 
			
		||||
	data->read_only = true;
 | 
			
		||||
	data->driver_data = client;
 | 
			
		||||
	data->driver_init = nct6775_i2c_probe_init;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
 | 
			
		||||
#include <linux/types.h>
 | 
			
		||||
 | 
			
		||||
enum kinds { nct6106, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792,
 | 
			
		||||
enum kinds { nct6106 = 1, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792,
 | 
			
		||||
	     nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 };
 | 
			
		||||
enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue