struct i2c_client *client;
struct nct1008_platform_data plat_data;
struct mutex mutex;
- struct dentry *dent;
u8 config;
enum nct1008_chip chip;
struct regulator *nct_reg;
return snprintf(buf, MAX_STR_PRINT, "Error read ext temperature\n");
}
+static ssize_t pr_reg(struct nct1008_data *nct, char *buf, int max_s,
+ const char *reg_name, int offset)
+{
+ int ret, sz = 0;
+
+ ret = nct1008_read_reg(nct->client, offset);
+ if (ret >= 0)
+ sz += snprintf(buf + sz, PAGE_SIZE - sz,
+ "%20s 0x%02x 0x%02x 0x%02x\n",
+ reg_name, nct->client->addr, offset, ret);
+ else
+ sz += snprintf(buf + sz, PAGE_SIZE - sz,
+ "%s: line=%d, i2c ** read error=%d **\n",
+ __func__, __LINE__, ret);
+ return sz;
+}
+
+static ssize_t nct1008_show_regs(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct nct1008_data *nct = i2c_get_clientdata(client);
+ char *name = nct->chip == NCT72 ? "nct72" : "nct1008";
+ int sz = 0;
+
+ sz += snprintf(buf + sz, PAGE_SIZE - sz, "%s Registers\n", name);
+ sz += snprintf(buf + sz, PAGE_SIZE - sz,
+ "---------------------------------------\n");
+ sz += snprintf(buf + sz, PAGE_SIZE - sz, "%20s %4s %4s %s\n",
+ "Register Name ", "Addr", "Reg", "Value");
+ sz += snprintf(buf + sz, PAGE_SIZE - sz, "%20s %4s %4s %s\n",
+ "--------------------", "----", "----", "-----");
+
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Local Temp Value ", 0x00);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Value Hi ", 0x01);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Status ", 0x02);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Configuration ", 0x03);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Conversion Rate ", 0x04);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Local Temp Hi Limit ", 0x05);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Local Temp Lo Limit ", 0x06);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Hi Limit Hi", 0x07);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Hi Limit Lo", 0x13);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Lo Limit Hi", 0x08);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Lo Limit Lo", 0x14);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Value Lo ", 0x10);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Offset Hi ", 0x11);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext Temp Offset Lo ", 0x12);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Ext THERM Limit ", 0x19);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Local THERM Limit ", 0x20);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "THERM Hysteresis ", 0x21);
+ sz += pr_reg(nct, buf+sz, PAGE_SIZE-sz, "Consecutive ALERT ", 0x22);
+ return sz;
+}
+
static DEVICE_ATTR(temperature, S_IRUGO, nct1008_show_temp, NULL);
static DEVICE_ATTR(temperature_overheat, (S_IRUGO | (S_IWUSR | S_IWGRP)),
nct1008_show_temp_overheat, nct1008_set_temp_overheat);
static DEVICE_ATTR(temperature_alert, (S_IRUGO | (S_IWUSR | S_IWGRP)),
nct1008_show_temp_alert, nct1008_set_temp_alert);
static DEVICE_ATTR(ext_temperature, S_IRUGO, nct1008_show_ext_temp, NULL);
+static DEVICE_ATTR(registers, S_IRUGO, nct1008_show_regs, NULL);
static struct attribute *nct1008_attributes[] = {
&dev_attr_temperature.attr,
&dev_attr_temperature_overheat.attr,
&dev_attr_temperature_alert.attr,
&dev_attr_ext_temperature.attr,
+ &dev_attr_registers.attr,
NULL
};
}
#endif /* CONFIG_THERMAL */
-#ifdef CONFIG_DEBUG_FS
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
-static void print_reg(const char *reg_name, struct seq_file *s,
- int offset)
-{
- struct nct1008_data *nct_data = s->private;
- int ret;
-
- ret = nct1008_read_reg(nct_data->client, offset);
- if (ret >= 0)
- seq_printf(s, "Reg %s Addr = 0x%02x Reg 0x%02x "
- "Value 0x%02x\n", reg_name,
- nct_data->client->addr,
- offset, ret);
- else
- seq_printf(s, "%s: line=%d, i2c read error=%d\n",
- __func__, __LINE__, ret);
-}
-
-static int dbg_nct1008_show(struct seq_file *s, void *unused)
-{
- seq_printf(s, "nct1008 nct72 Registers\n");
- seq_printf(s, "------------------\n");
- print_reg("Local Temp Value ", s, 0x00);
- print_reg("Ext Temp Value Hi ", s, 0x01);
- print_reg("Status ", s, 0x02);
- print_reg("Configuration ", s, 0x03);
- print_reg("Conversion Rate ", s, 0x04);
- print_reg("Local Temp Hi Limit ", s, 0x05);
- print_reg("Local Temp Lo Limit ", s, 0x06);
- print_reg("Ext Temp Hi Limit Hi", s, 0x07);
- print_reg("Ext Temp Hi Limit Lo", s, 0x13);
- print_reg("Ext Temp Lo Limit Hi", s, 0x08);
- print_reg("Ext Temp Lo Limit Lo", s, 0x14);
- print_reg("Ext Temp Value Lo ", s, 0x10);
- print_reg("Ext Temp Offset Hi ", s, 0x11);
- print_reg("Ext Temp Offset Lo ", s, 0x12);
- print_reg("Ext THERM Limit ", s, 0x19);
- print_reg("Local THERM Limit ", s, 0x20);
- print_reg("THERM Hysteresis ", s, 0x21);
- print_reg("Consecutive ALERT ", s, 0x22);
- return 0;
-}
-
-static int dbg_nct1008_open(struct inode *inode, struct file *file)
-{
- return single_open(file, dbg_nct1008_show, inode->i_private);
-}
-
-static const struct file_operations debug_fops = {
- .open = dbg_nct1008_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static int nct1008_debuginit(struct nct1008_data *nct)
-{
- int err = 0;
- struct dentry *d;
- if (nct->chip == NCT72)
- d = debugfs_create_file("nct72", S_IRUGO, NULL,
- (void *)nct, &debug_fops);
- else
- d = debugfs_create_file("nct1008", S_IRUGO, NULL,
- (void *)nct, &debug_fops);
- if ((!d) || IS_ERR(d)) {
- dev_err(&nct->client->dev, "Error: %s debugfs_create_file"
- " returned an error\n", __func__);
- err = -ENOENT;
- goto end;
- }
- if (d == ERR_PTR(-ENODEV)) {
- dev_err(&nct->client->dev, "Error: %s debugfs not supported "
- "error=-ENODEV\n", __func__);
- err = -ENODEV;
- } else {
- nct->dent = d;
- }
-end:
- return err;
-}
-#else
-static int nct1008_debuginit(struct nct1008_data *nct)
-{
- return 0;
-}
-#endif /* CONFIG_DEBUG_FS */
-
static int nct1008_enable(struct i2c_client *client)
{
struct nct1008_data *data = i2c_get_clientdata(client);
goto error;
}
- err = nct1008_debuginit(data);
- if (err < 0)
- err = 0; /* without debugfs we may continue */
-
#ifdef CONFIG_THERMAL
for (i = 0; i < data->plat_data.num_trips; i++)
if (strcmp(data->plat_data.trips[i].cdev_type,
{
struct nct1008_data *data = i2c_get_clientdata(client);
- if (data->dent)
- debugfs_remove(data->dent);
-
mutex_lock(&data->mutex);
data->stop_workqueue = 1;
mutex_unlock(&data->mutex);