Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b38a66e authored by Axel Lin's avatar Axel Lin Committed by Guenter Roeck
Browse files

hwmon: (thmc50) Avoid forward declaration



Reorder functions to avoid forward declaration.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 30485776
Loading
Loading
Loading
Loading
+76 −84
Original line number Original line Diff line number Diff line
@@ -85,32 +85,47 @@ struct thmc50_data {
	u8 alarms;
	u8 alarms;
};
};


static int thmc50_detect(struct i2c_client *client,
static struct thmc50_data *thmc50_update_device(struct device *dev)
			 struct i2c_board_info *info);
{
static int thmc50_probe(struct i2c_client *client,
	struct i2c_client *client = to_i2c_client(dev);
			const struct i2c_device_id *id);
	struct thmc50_data *data = i2c_get_clientdata(client);
static int thmc50_remove(struct i2c_client *client);
	int timeout = HZ / 5 + (data->type == thmc50 ? HZ : 0);
static void thmc50_init_client(struct i2c_client *client);
static struct thmc50_data *thmc50_update_device(struct device *dev);


static const struct i2c_device_id thmc50_id[] = {
	mutex_lock(&data->update_lock);
	{ "adm1022", adm1022 },
	{ "thmc50", thmc50 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, thmc50_id);


static struct i2c_driver thmc50_driver = {
	if (time_after(jiffies, data->last_updated + timeout)
	.class = I2C_CLASS_HWMON,
	    || !data->valid) {
	.driver = {

		.name = "thmc50",
		int temps = data->has_temp3 ? 3 : 2;
	},
		int i;
	.probe = thmc50_probe,
		int prog = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
	.remove = thmc50_remove,

	.id_table = thmc50_id,
		prog &= THMC50_REG_CONF_PROGRAMMED;
	.detect = thmc50_detect,

	.address_list = normal_i2c,
		for (i = 0; i < temps; i++) {
};
			data->temp_input[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP[i]);
			data->temp_max[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP_MAX[i]);
			data->temp_min[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP_MIN[i]);
			data->temp_critical[i] =
				i2c_smbus_read_byte_data(client,
					prog ? THMC50_REG_TEMP_CRITICAL[i]
					     : THMC50_REG_TEMP_DEFAULT[i]);
		}
		data->analog_out =
		    i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT);
		data->alarms =
		    i2c_smbus_read_byte_data(client, THMC50_REG_INTR);
		data->last_updated = jiffies;
		data->valid = 1;
	}

	mutex_unlock(&data->update_lock);

	return data;
}


static ssize_t show_analog_out(struct device *dev,
static ssize_t show_analog_out(struct device *dev,
			       struct device_attribute *attr, char *buf)
			       struct device_attribute *attr, char *buf)
@@ -355,6 +370,26 @@ static int thmc50_detect(struct i2c_client *client,
	return 0;
	return 0;
}
}


static void thmc50_init_client(struct i2c_client *client)
{
	struct thmc50_data *data = i2c_get_clientdata(client);
	int config;

	data->analog_out = i2c_smbus_read_byte_data(client,
						    THMC50_REG_ANALOG_OUT);
	/* set up to at least 1 */
	if (data->analog_out == 0) {
		data->analog_out = 1;
		i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT,
					  data->analog_out);
	}
	config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
	config |= 0x1;	/* start the chip if it is in standby mode */
	if (data->type == adm1022 && (config & (1 << 7)))
		data->has_temp3 = 1;
	i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config);
}

static int thmc50_probe(struct i2c_client *client,
static int thmc50_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
			const struct i2c_device_id *id)
{
{
@@ -413,67 +448,24 @@ static int thmc50_remove(struct i2c_client *client)
	return 0;
	return 0;
}
}


static void thmc50_init_client(struct i2c_client *client)
static const struct i2c_device_id thmc50_id[] = {
{
	{ "adm1022", adm1022 },
	struct thmc50_data *data = i2c_get_clientdata(client);
	{ "thmc50", thmc50 },
	int config;
	{ }

};
	data->analog_out = i2c_smbus_read_byte_data(client,
MODULE_DEVICE_TABLE(i2c, thmc50_id);
						    THMC50_REG_ANALOG_OUT);
	/* set up to at least 1 */
	if (data->analog_out == 0) {
		data->analog_out = 1;
		i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT,
					  data->analog_out);
	}
	config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
	config |= 0x1;	/* start the chip if it is in standby mode */
	if (data->type == adm1022 && (config & (1 << 7)))
		data->has_temp3 = 1;
	i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config);
}

static struct thmc50_data *thmc50_update_device(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct thmc50_data *data = i2c_get_clientdata(client);
	int timeout = HZ / 5 + (data->type == thmc50 ? HZ : 0);

	mutex_lock(&data->update_lock);

	if (time_after(jiffies, data->last_updated + timeout)
	    || !data->valid) {

		int temps = data->has_temp3 ? 3 : 2;
		int i;
		int prog = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);

		prog &= THMC50_REG_CONF_PROGRAMMED;

		for (i = 0; i < temps; i++) {
			data->temp_input[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP[i]);
			data->temp_max[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP_MAX[i]);
			data->temp_min[i] = i2c_smbus_read_byte_data(client,
						THMC50_REG_TEMP_MIN[i]);
			data->temp_critical[i] =
				i2c_smbus_read_byte_data(client,
					prog ? THMC50_REG_TEMP_CRITICAL[i]
					     : THMC50_REG_TEMP_DEFAULT[i]);
		}
		data->analog_out =
		    i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT);
		data->alarms =
		    i2c_smbus_read_byte_data(client, THMC50_REG_INTR);
		data->last_updated = jiffies;
		data->valid = 1;
	}

	mutex_unlock(&data->update_lock);


	return data;
static struct i2c_driver thmc50_driver = {
}
	.class = I2C_CLASS_HWMON,
	.driver = {
		.name = "thmc50",
	},
	.probe = thmc50_probe,
	.remove = thmc50_remove,
	.id_table = thmc50_id,
	.detect = thmc50_detect,
	.address_list = normal_i2c,
};


module_i2c_driver(thmc50_driver);
module_i2c_driver(thmc50_driver);