static ssize_t usbrh_proc_temp_read(struct file *file, char *buf, size_t count, loff_t *off) { struct usbrh *dev; struct usbrh_sensor_value value; int len; if (*off != 0) { return 0; } len = 0; dev = (struct usbrh *)PDE_DATA(file_inode(file)); if (usbrh_read_sensor(dev, &value)) { len += snprintf(buf, count, "Failed to get temperature\n"); *off += len; return len; } len += usbrh_snprint_value(buf, count-len, usbrh_calc_temp(&value)); len += snprintf(buf+len, count-len, "\n"); *off += len; return len; }
static int usbrh_proc_temp_read(char *buffer, char **start, off_t offset, int count, int *peof, void *dat) { struct usbrh *dev; struct usbrh_sensor_value value; int len; dev = (struct usbrh *)dat; *peof = 1; if (usbrh_read_sensor(dev, &value)) { return sprintf(buffer, "Failed to get temperature\n"); } len = usbrh_sprint_value(buffer, usbrh_calc_temp(&value)); len += sprintf(buffer+len, "\n"); return len; }