Skip to contentSkip to conversation

rtc: max77686: use module_platform_driver()

PATCH New Jingoo Han 1 participant 5 messages Feb 27, 2013

Subsystems (2)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/5 rtc: max77686: use module_platform_driver()

This patch uses module_platform_driver() macro which makes the code smaller and simpler.

---
 drivers/rtc/rtc-max77686.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)
drivers/rtc/rtc-max77686.c +1 -11
index 6b1337f..a8e31fc 100644
@@ -624,17 +624,7 @@ static struct platform_driver max77686_rtc_driver = {
 	.id_table	= rtc_id,
 };
 
-static int __init max77686_rtc_init(void)
-{
-	return platform_driver_register(&max77686_rtc_driver);
-}
-module_init(max77686_rtc_init);
-
-static void __exit max77686_rtc_exit(void)
-{
-	platform_driver_unregister(&max77686_rtc_driver);
-}
-module_exit(max77686_rtc_exit);
+module_platform_driver(max77686_rtc_driver);
 
 MODULE_DESCRIPTION("Maxim MAX77686 RTC driver");
 MODULE_AUTHOR("<[email protected]>");
Signature · 1 line
1.7.2.5
author
#1 lore raw

PATCH 2/5 rtc: max77686: add missing module author name

This patch adds missing module author name to MODULE_AUTHOR macro.

---
 drivers/rtc/rtc-max77686.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-max77686.c +1 -1
index a8e31fc..4da2a55 100644
@@ -627,5 +627,5 @@ static struct platform_driver max77686_rtc_driver = {
 module_platform_driver(max77686_rtc_driver);
 
 MODULE_DESCRIPTION("Maxim MAX77686 RTC driver");
-MODULE_AUTHOR("<[email protected]>");
+MODULE_AUTHOR("Chiwoong Byun <[email protected]>");
 MODULE_LICENSE("GPL");
Signature · 1 line
1.7.2.5
author
#2 lore raw

PATCH 3/5 rtc: max77686: use devm_kzalloc()

In reply to Jingoo Han

Use devm_kzalloc() to make cleanup paths more simple.

---
 drivers/rtc/rtc-max77686.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/rtc/rtc-max77686.c +2 -7
index 4da2a55..36b1f5c 100644
@@ -505,7 +505,8 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	dev_info(&pdev->dev, "%s\n", __func__);
 
-	info = kzalloc(sizeof(struct max77686_rtc_info), GFP_KERNEL);
+	info = devm_kzalloc(&pdev->dev, sizeof(struct max77686_rtc_info),
+				GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -519,7 +520,6 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 		ret = PTR_ERR(info->max77686->rtc_regmap);
 		dev_err(info->max77686->dev, "Failed to allocate register map: %d\n",
 				ret);
-		kfree(info);
 		return ret;
 	}
 	platform_set_drvdata(pdev, info);
@@ -563,11 +563,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 		goto err_rtc;
 	}
 
-	goto out;
 err_rtc:
-	kfree(info);
-	return ret;
-out:
 	return ret;
 }
 
@@ -578,7 +574,6 @@ static int max77686_rtc_remove(struct platform_device *pdev)
 	if (info) {
 		free_irq(info->virq, info);
 		rtc_device_unregister(info->rtc_dev);
-		kfree(info);
 	}
 
 	return 0;
Signature · 1 line
1.7.2.5
author
#3 lore raw

PATCH 4/5 rtc: max77686: fix indentation of bit definitions

In reply to Jingoo Han

This patch fixes indentation of bit definitions to enhance the readability.

---
 drivers/rtc/rtc-max77686.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/rtc/rtc-max77686.c +5 -5
index 36b1f5c..9de93e7 100644
@@ -24,7 +24,7 @@
 
 /* RTC Control Register */
 #define BCD_EN_SHIFT			0
-#define BCD_EN_MASK				(1 << BCD_EN_SHIFT)
+#define BCD_EN_MASK			(1 << BCD_EN_SHIFT)
 #define MODEL24_SHIFT			1
 #define MODEL24_MASK			(1 << MODEL24_SHIFT)
 /* RTC Update Register1 */
@@ -33,12 +33,12 @@
 #define RTC_RBUDR_SHIFT			4
 #define RTC_RBUDR_MASK			(1 << RTC_RBUDR_SHIFT)
 /* WTSR and SMPL Register */
-#define WTSRT_SHIFT				0
-#define SMPLT_SHIFT				2
+#define WTSRT_SHIFT			0
+#define SMPLT_SHIFT			2
 #define WTSR_EN_SHIFT			6
 #define SMPL_EN_SHIFT			7
-#define WTSRT_MASK				(3 << WTSRT_SHIFT)
-#define SMPLT_MASK				(3 << SMPLT_SHIFT)
+#define WTSRT_MASK			(3 << WTSRT_SHIFT)
+#define SMPLT_MASK			(3 << SMPLT_SHIFT)
 #define WTSR_EN_MASK			(1 << WTSR_EN_SHIFT)
 #define SMPL_EN_MASK			(1 << SMPL_EN_SHIFT)
 /* RTC Hour register */
Signature · 1 line
1.7.2.5
author
#4 lore raw

PATCH 5/5 rtc: max77686: use dev_info()/dev_emerg() instead of pr_info()/pr_emerg()

In reply to Jingoo Han

dev_info()/dev_emerg() are more preferred than pr_info()/pr_emerg().

---
 drivers/rtc/rtc-max77686.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
drivers/rtc/rtc-max77686.c +9 -6
index 9de93e7..df66bab 100644
@@ -466,7 +466,7 @@ static void max77686_rtc_enable_smpl(struct max77686_rtc_info *info, bool enable
 
 	val = 0;
 	regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val);
-	pr_info("%s: WTSR_SMPL(0x%02x)\n", __func__, val);
+	dev_info(info->dev, "%s: WTSR_SMPL(0x%02x)\n", __func__, val);
 }
 #endif /* MAX77686_RTC_WTSR_SMPL */
 
@@ -589,11 +589,14 @@ static void max77686_rtc_shutdown(struct platform_device *pdev)
 	for (i = 0; i < 3; i++) {
 		max77686_rtc_enable_wtsr(info, false);
 		regmap_read(info->max77686->rtc_regmap, MAX77686_WTSR_SMPL_CNTL, &val);
-		pr_info("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val);
-		if (val & WTSR_EN_MASK)
-			pr_emerg("%s: fail to disable WTSR\n", __func__);
-		else {
-			pr_info("%s: success to disable WTSR\n", __func__);
+		dev_info(info->dev, "%s: WTSR_SMPL reg(0x%02x)\n", __func__,
+				val);
+		if (val & WTSR_EN_MASK) {
+			dev_emerg(info->dev, "%s: fail to disable WTSR\n",
+					__func__);
+		} else {
+			dev_info(info->dev, "%s: success to disable WTSR\n",
+					__func__);
 			break;
 		}
 	}
Signature · 1 line
1.7.2.5