static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) { struct smsc47b397_data *data = dev_get_drvdata(dev); int i; mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { dev_dbg(dev, "starting device update...\n"); /* 4 temperature inputs, 4 fan inputs */ for (i = 0; i < 4; i++) { data->temp[i] = smsc47b397_read_value(data, SMSC47B397_REG_TEMP(i)); /* must read LSB first */ data->fan[i] = smsc47b397_read_value(data, SMSC47B397_REG_FAN_LSB(i)); data->fan[i] |= smsc47b397_read_value(data, SMSC47B397_REG_FAN_MSB(i)) << 8; } data->last_updated = jiffies; data->valid = 1; dev_dbg(dev, "... device update complete\n"); } mutex_unlock(&data->update_lock); return data; }
static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct smsc47b397_data *data = i2c_get_clientdata(client); int i; down(&data->update_lock); if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { dev_dbg(&client->dev, "starting device update...\n"); /* 4 temperature inputs, 4 fan inputs */ for (i = 0; i < 4; i++) { data->temp[i] = smsc47b397_read_value(client, SMSC47B397_REG_TEMP(i)); /* must read LSB first */ data->fan[i] = smsc47b397_read_value(client, SMSC47B397_REG_FAN_LSB(i)); data->fan[i] |= smsc47b397_read_value(client, SMSC47B397_REG_FAN_MSB(i)) << 8; } data->last_updated = jiffies; data->valid = 1; dev_dbg(&client->dev, "... device update complete\n"); } up(&data->update_lock); return data; }