linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Dmitry Osipenko <digetx@gmail.com>, Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com,
	Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCHv1 2/2] power: supply: smb347-charger: Use generic property framework
Date: Wed, 26 Aug 2020 16:41:59 +0200	[thread overview]
Message-ID: <20200826144159.353837-3-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20200826144159.353837-1-sebastian.reichel@collabora.com>

Simplify the driver and remove the DT specific code by
using the generic device property framework.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/smb347-charger.c | 40 +++++++++++++--------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c
index b182727dfc90..d3bf35ed12ce 100644
--- a/drivers/power/supply/smb347-charger.c
+++ b/drivers/power/supply/smb347-charger.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/power_supply.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 
 #include <dt-bindings/power/summit,smb347-charger.h>
@@ -1176,7 +1177,7 @@ static bool smb347_readable_reg(struct device *dev, unsigned int reg)
 
 static void smb347_dt_parse_dev_info(struct smb347_charger *smb)
 {
-	struct device_node *np = smb->dev->of_node;
+	struct device *dev = smb->dev;
 
 	smb->soft_temp_limit_compensation =
 					SMB3XX_SOFT_TEMP_COMPENSATE_DEFAULT;
@@ -1190,32 +1191,29 @@ static void smb347_dt_parse_dev_info(struct smb347_charger *smb)
 	smb->hard_hot_temp_limit  = SMB3XX_TEMP_USE_DEFAULT;
 
 	/* Charging constraints */
-	of_property_read_u32(np, "summit,fast-voltage-threshold-microvolt",
-			     &smb->pre_to_fast_voltage);
-	of_property_read_u32(np, "summit,mains-current-limit-microamp",
-			     &smb->mains_current_limit);
-	of_property_read_u32(np, "summit,usb-current-limit-microamp",
-			     &smb->usb_hc_current_limit);
+	device_property_read_u32(dev, "summit,fast-voltage-threshold-microvolt",
+				 &smb->pre_to_fast_voltage);
+	device_property_read_u32(dev, "summit,mains-current-limit-microamp",
+				 &smb->mains_current_limit);
+	device_property_read_u32(dev, "summit,usb-current-limit-microamp",
+				 &smb->usb_hc_current_limit);
 
 	/* For thermometer monitoring */
-	of_property_read_u32(np, "summit,chip-temperature-threshold-celsius",
-			     &smb->chip_temp_threshold);
-	of_property_read_u32(np, "summit,soft-compensation-method",
-			     &smb->soft_temp_limit_compensation);
-	of_property_read_u32(np, "summit,charge-current-compensation-microamp",
-			     &smb->charge_current_compensation);
+	device_property_read_u32(dev, "summit,chip-temperature-threshold-celsius",
+				 &smb->chip_temp_threshold);
+	device_property_read_u32(dev, "summit,soft-compensation-method",
+				 &smb->soft_temp_limit_compensation);
+	device_property_read_u32(dev, "summit,charge-current-compensation-microamp",
+				 &smb->charge_current_compensation);
 
 	/* Supported charging mode */
-	smb->use_mains =
-		of_property_read_bool(np, "summit,enable-mains-charging");
-	smb->use_usb =
-		of_property_read_bool(np, "summit,enable-usb-charging");
-	smb->use_usb_otg =
-		of_property_read_bool(np, "summit,enable-otg-charging");
+	smb->use_mains = device_property_read_bool(dev, "summit,enable-mains-charging");
+	smb->use_usb = device_property_read_bool(dev, "summit,enable-usb-charging");
+	smb->use_usb_otg = device_property_read_bool(dev, "summit,enable-otg-charging");
 
 	/* Select charging control */
-	of_property_read_u32(np, "summit,enable-charge-control",
-			     &smb->enable_control);
+	device_property_read_u32(dev, "summit,enable-charge-control",
+				 &smb->enable_control);
 }
 
 static int smb347_get_battery_info(struct smb347_charger *smb)
-- 
2.28.0


  parent reply	other threads:[~2020-08-26 14:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 14:41 [PATCHv1 0/2] power: supply: smb347-charger: Cleanups Sebastian Reichel
2020-08-26 14:41 ` [PATCHv1 1/2] power: supply: smb347-charger: Drop pdata support Sebastian Reichel
2020-08-28  7:47   ` Dmitry Osipenko
2020-08-26 14:41 ` Sebastian Reichel [this message]
2020-08-28  7:47   ` [PATCHv1 2/2] power: supply: smb347-charger: Use generic property framework Dmitry Osipenko
2020-08-28  7:47 ` [PATCHv1 0/2] power: supply: smb347-charger: Cleanups Dmitry Osipenko
2020-08-28 15:06   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200826144159.353837-3-sebastian.reichel@collabora.com \
    --to=sebastian.reichel@collabora.com \
    --cc=digetx@gmail.com \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).