Skip to contentSkip to conversation

power: bq24190: Remove gratuitous dummy function

PATCH New Thierry Reding 1 participant 2 messages Mar 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 power: bq24190: Remove gratuitous dummy function

From: Thierry Reding <[email protected]>

Check for OF support using IS_ENABLED(CONFIG_OF). This will enable the compiler to eliminate dead code if OF support is disabled. With that in place, the dummy implementation of bq24190_setup_dt() for non-DT setups can be removed as the compiler will automatically discard the function when appropriate.

---
 drivers/power/bq24190_charger.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/power/bq24190_charger.c +1 -8
index ad3ff8fbfbbb..f5b21c0d0ba3 100644
@@ -1312,7 +1312,6 @@ out:
 	return ret;
 }
 
-#ifdef CONFIG_OF
 static int bq24190_setup_dt(struct bq24190_dev_info *bdi)
 {
 	bdi->irq = irq_of_parse_and_map(bdi->dev->of_node, 0);
@@ -1321,12 +1320,6 @@ static int bq24190_setup_dt(struct bq24190_dev_info *bdi)
 
 	return 0;
 }
-#else
-static int bq24190_setup_dt(struct bq24190_dev_info *bdi)
-{
-	return -1;
-}
-#endif
 
 static int bq24190_setup_pdata(struct bq24190_dev_info *bdi,
 		struct bq24190_platform_data *pdata)
@@ -1388,7 +1381,7 @@ static int bq24190_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, bdi);
 
-	if (dev->of_node)
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
 		ret = bq24190_setup_dt(bdi);
 	else
 		ret = bq24190_setup_pdata(bdi, pdata);
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 2/2 power: bq24190: Remove empty OF device table

From: Thierry Reding <[email protected]>

The driver already uses the of_match_ptr() macro that evaluates to NULL when DT is disabled, so defining an empty device table is unnecessary.

---
 drivers/power/bq24190_charger.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/power/bq24190_charger.c +0 -4
index f5b21c0d0ba3..04403ce801c0 100644
@@ -1517,10 +1517,6 @@ static const struct of_device_id bq24190_of_match[] = {
 	{ },
 };
 MODULE_DEVICE_TABLE(of, bq24190_of_match);
-#else
-static const struct of_device_id bq24190_of_match[] = {
-	{ },
-};
 #endif
 
 static struct i2c_driver bq24190_driver = {
Signature · 1 line
1.8.4.2