Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 181877
b: refs/heads/master
c: 33a470f
h: refs/heads/master
i:
  181875: 0db5f85
v: v3
  • Loading branch information
Jean Delvare authored and Benjamin Herrenschmidt committed Feb 3, 2010
1 parent dfe3dd9 commit e40f840
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 119ea10947cc1402abbf9d6200815b0606536906
refs/heads/master: 33a470f6d5e1879c26f16f6b34dc09f82d44f6e9
34 changes: 24 additions & 10 deletions trunk/drivers/macintosh/therm_adt746x.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ static struct task_struct *thread_therm = NULL;

static void write_both_fan_speed(struct thermostat *th, int speed);
static void write_fan_speed(struct thermostat *th, int speed, int fan);
static void thermostat_create_files(void);
static void thermostat_remove_files(void);

static int
write_reg(struct thermostat* th, int reg, u8 data)
Expand Down Expand Up @@ -161,6 +163,8 @@ remove_thermostat(struct i2c_client *client)
struct thermostat *th = i2c_get_clientdata(client);
int i;

thermostat_remove_files();

if (thread_therm != NULL) {
kthread_stop(thread_therm);
}
Expand Down Expand Up @@ -449,6 +453,8 @@ static int probe_thermostat(struct i2c_client *client,
return -ENOMEM;
}

thermostat_create_files();

return 0;
}

Expand Down Expand Up @@ -566,7 +572,6 @@ thermostat_init(void)
struct device_node* np;
const u32 *prop;
int i = 0, offset = 0;
int err;

np = of_find_node_by_name(NULL, "fan");
if (!np)
Expand Down Expand Up @@ -633,6 +638,17 @@ thermostat_init(void)
return -ENODEV;
}

#ifndef CONFIG_I2C_POWERMAC
request_module("i2c-powermac");
#endif

return i2c_add_driver(&thermostat_driver);
}

static void thermostat_create_files(void)
{
int err;

err = device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
Expand All @@ -647,16 +663,9 @@ thermostat_init(void)
if (err)
printk(KERN_WARNING
"Failed to create tempertaure attribute file(s).\n");

#ifndef CONFIG_I2C_POWERMAC
request_module("i2c-powermac");
#endif

return i2c_add_driver(&thermostat_driver);
}

static void __exit
thermostat_exit(void)
static void thermostat_remove_files(void)
{
if (of_dev) {
device_remove_file(&of_dev->dev, &dev_attr_sensor1_temperature);
Expand All @@ -673,9 +682,14 @@ thermostat_exit(void)
device_remove_file(&of_dev->dev,
&dev_attr_sensor2_fan_speed);

of_device_unregister(of_dev);
}
}

static void __exit
thermostat_exit(void)
{
i2c_del_driver(&thermostat_driver);
of_device_unregister(of_dev);
}

module_init(thermostat_init);
Expand Down

0 comments on commit e40f840

Please sign in to comment.