#include <linux/module.h>
#include <linux/hwmon-sysfs.h>
static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
0x4d, 0x4e, I2C_CLIENT_END };
#define LM73_REG_INPUT 0x00
#define LM73_REG_CONF 0x01
#define LM73_REG_MAX 0x02
#define LM73_REG_MIN 0x03
#define LM73_REG_CTRL 0x04
#define LM73_TEMP_MIN (-256000 / 250)
#define LM73_TEMP_MAX (255750 / 250)
#define LM73_CTRL_RES_SHIFT 5
#define LM73_CTRL_RES_MASK (BIT(5) | BIT(6))
#define LM73_CTRL_TO_MASK BIT(7)
#define LM73_CTRL_HI_SHIFT 2
#define LM73_CTRL_LO_SHIFT 1
static const unsigned short lm73_convrates[] = {
struct i2c_client *client;
static ssize_t temp_store(struct device *dev, struct device_attribute *da,
const char *buf, size_t count)
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct lm73_data *data = dev_get_drvdata(dev);
int status = kstrtol(buf, 10, &temp);
value = clamp_val(temp / 250, LM73_TEMP_MIN, LM73_TEMP_MAX) << 5;
err = i2c_smbus_write_word_swapped(data->client, attr->index, value);
return (err < 0) ? err : count;
static ssize_t temp_show(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct lm73_data *data = dev_get_drvdata(dev);
s32 err = i2c_smbus_read_word_swapped(data->client, attr->index);