Commit 91046a8a authored by Jeff Garzik's avatar Jeff Garzik Committed by Linus Torvalds

[PATCH] RTC: handle sysfs errors

Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bfc7ee20
...@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind) ...@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
/* read control register */ /* read control register */
err = ds1672_get_control(client, &control); err = ds1672_get_control(client, &control);
if (err) if (err)
goto exit_detach; goto exit_devreg;
if (control & DS1672_REG_CONTROL_EOSC) if (control & DS1672_REG_CONTROL_EOSC)
dev_warn(&client->dev, "Oscillator not enabled. " dev_warn(&client->dev, "Oscillator not enabled. "
"Set time to enable.\n"); "Set time to enable.\n");
/* Register sysfs hooks */ /* Register sysfs hooks */
device_create_file(&client->dev, &dev_attr_control); err = device_create_file(&client->dev, &dev_attr_control);
if (err)
goto exit_devreg;
return 0; return 0;
exit_devreg:
rtc_device_unregister(rtc);
exit_detach: exit_detach:
i2c_detach_client(client); i2c_detach_client(client);
......
...@@ -238,11 +238,19 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind) ...@@ -238,11 +238,19 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
i2c_set_clientdata(client, rtc); i2c_set_clientdata(client, rtc);
device_create_file(&client->dev, &dev_attr_trim); err = device_create_file(&client->dev, &dev_attr_trim);
device_create_file(&client->dev, &dev_attr_osc); if (err) goto exit_devreg;
err = device_create_file(&client->dev, &dev_attr_osc);
if (err) goto exit_trim;
return 0; return 0;
exit_trim:
device_remove_file(&client->dev, &dev_attr_trim);
exit_devreg:
rtc_device_unregister(rtc);
exit_detach: exit_detach:
i2c_detach_client(client); i2c_detach_client(client);
......
...@@ -123,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev) ...@@ -123,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
err = PTR_ERR(rtc); err = PTR_ERR(rtc);
return err; return err;
} }
device_create_file(&plat_dev->dev, &dev_attr_irq);
err = device_create_file(&plat_dev->dev, &dev_attr_irq);
if (err)
goto err;
platform_set_drvdata(plat_dev, rtc); platform_set_drvdata(plat_dev, rtc);
return 0; return 0;
err:
rtc_device_unregister(rtc);
return err;
} }
static int __devexit test_remove(struct platform_device *plat_dev) static int __devexit test_remove(struct platform_device *plat_dev)
......
...@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) ...@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
else else
dev_err(&client->dev, "couldn't read status\n"); dev_err(&client->dev, "couldn't read status\n");
device_create_file(&client->dev, &dev_attr_atrim); err = device_create_file(&client->dev, &dev_attr_atrim);
device_create_file(&client->dev, &dev_attr_dtrim); if (err) goto exit_devreg;
err = device_create_file(&client->dev, &dev_attr_dtrim);
if (err) goto exit_atrim;
return 0; return 0;
exit_atrim:
device_remove_file(&client->dev, &dev_attr_atrim);
exit_devreg:
rtc_device_unregister(rtc);
exit_detach: exit_detach:
i2c_detach_client(client); i2c_detach_client(client);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment