diff options
Diffstat (limited to 'drivers/rtc/rtc-fm3130.c')
| -rw-r--r-- | drivers/rtc/rtc-fm3130.c | 68 | 
1 files changed, 11 insertions, 57 deletions
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index 4cf2e70c507..83c3b3029fa 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c @@ -47,7 +47,7 @@  struct fm3130 {  	u8			reg_addr_time; -	u8 			reg_addr_alarm; +	u8			reg_addr_alarm;  	u8			regs[15];  	struct i2c_msg		msg[4];  	struct i2c_client	*client; @@ -116,17 +116,7 @@ static int fm3130_get_time(struct device *dev, struct rtc_time *t)  	fm3130_rtc_mode(dev, FM3130_MODE_NORMAL); -	dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x" -			"%02x %02x %02x %02x %02x %02x %02x\n", -			"read", -			fm3130->regs[0], fm3130->regs[1], -			fm3130->regs[2], fm3130->regs[3], -			fm3130->regs[4], fm3130->regs[5], -			fm3130->regs[6], fm3130->regs[7], -			fm3130->regs[8], fm3130->regs[9], -			fm3130->regs[0xa], fm3130->regs[0xb], -			fm3130->regs[0xc], fm3130->regs[0xd], -			fm3130->regs[0xe]); +	dev_dbg(dev, "%s: %15ph\n", "read", fm3130->regs);  	t->tm_sec = bcd2bin(fm3130->regs[FM3130_RTC_SECONDS] & 0x7f);  	t->tm_min = bcd2bin(fm3130->regs[FM3130_RTC_MINUTES] & 0x7f); @@ -175,12 +165,7 @@ static int fm3130_set_time(struct device *dev, struct rtc_time *t)  	tmp = t->tm_year - 100;  	buf[FM3130_RTC_YEARS] = bin2bcd(tmp); -	dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x" -		"%02x %02x %02x %02x %02x %02x %02x %02x\n", -		"write", buf[0], buf[1], buf[2], buf[3], -		buf[4], buf[5], buf[6], buf[7], -		buf[8], buf[9], buf[0xa], buf[0xb], -		buf[0xc], buf[0xd], buf[0xe]); +	dev_dbg(dev, "%s: %15ph\n", "write", buf);  	fm3130_rtc_mode(dev, FM3130_MODE_WRITE); @@ -361,8 +346,8 @@ static const struct rtc_class_ops fm3130_rtc_ops = {  static struct i2c_driver fm3130_driver; -static int __devinit fm3130_probe(struct i2c_client *client, -				  const struct i2c_device_id *id) +static int fm3130_probe(struct i2c_client *client, +			const struct i2c_device_id *id)  {  	struct fm3130		*fm3130;  	int			err = -ENODEV; @@ -373,7 +358,7 @@ static int __devinit fm3130_probe(struct i2c_client *client,  			I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))  		return -EIO; -	fm3130 = kzalloc(sizeof(struct fm3130), GFP_KERNEL); +	fm3130 = devm_kzalloc(&client->dev, sizeof(struct fm3130), GFP_KERNEL);  	if (!fm3130)  		return -ENOMEM; @@ -410,7 +395,7 @@ static int __devinit fm3130_probe(struct i2c_client *client,  	tmp = i2c_transfer(adapter, fm3130->msg, 4);  	if (tmp != 4) { -		pr_debug("read error %d\n", tmp); +		dev_dbg(&client->dev, "read error %d\n", tmp);  		err = -EIO;  		goto exit_free;  	} @@ -517,22 +502,12 @@ bad_alarm:  bad_clock:  	if (!fm3130->data_valid || !fm3130->alarm_valid) -		dev_dbg(&client->dev, -				"%s: %02x %02x %02x %02x %02x %02x %02x %02x" -				"%02x %02x %02x %02x %02x %02x %02x\n", -			"bogus registers", -			fm3130->regs[0], fm3130->regs[1], -			fm3130->regs[2], fm3130->regs[3], -			fm3130->regs[4], fm3130->regs[5], -			fm3130->regs[6], fm3130->regs[7], -			fm3130->regs[8], fm3130->regs[9], -			fm3130->regs[0xa], fm3130->regs[0xb], -			fm3130->regs[0xc], fm3130->regs[0xd], -			fm3130->regs[0xe]); +		dev_dbg(&client->dev, "%s: %15ph\n", "bogus registers", +			fm3130->regs);  	/* We won't bail out here because we just got invalid data.  	   Time setting from u-boot doesn't work anyway */ -	fm3130->rtc = rtc_device_register(client->name, &client->dev, +	fm3130->rtc = devm_rtc_device_register(&client->dev, client->name,  				&fm3130_rtc_ops, THIS_MODULE);  	if (IS_ERR(fm3130->rtc)) {  		err = PTR_ERR(fm3130->rtc); @@ -542,40 +517,19 @@ bad_clock:  	}  	return 0;  exit_free: -	kfree(fm3130);  	return err;  } -static int __devexit fm3130_remove(struct i2c_client *client) -{ -	struct fm3130 *fm3130 = i2c_get_clientdata(client); - -	rtc_device_unregister(fm3130->rtc); -	kfree(fm3130); -	return 0; -} -  static struct i2c_driver fm3130_driver = {  	.driver = {  		.name	= "rtc-fm3130",  		.owner	= THIS_MODULE,  	},  	.probe		= fm3130_probe, -	.remove		= __devexit_p(fm3130_remove),  	.id_table	= fm3130_id,  }; -static int __init fm3130_init(void) -{ -	return i2c_add_driver(&fm3130_driver); -} -module_init(fm3130_init); - -static void __exit fm3130_exit(void) -{ -	i2c_del_driver(&fm3130_driver); -} -module_exit(fm3130_exit); +module_i2c_driver(fm3130_driver);  MODULE_DESCRIPTION("RTC driver for FM3130");  MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>");  | 
