Skip to contentSkip to conversation

can: tcan4x5x: various cleanups

PATCH In review Marc Kleine-Budde 2 participants 8 messages Nov 30, 2020

Subsystems (2)
lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

cover can: tcan4x5x: various cleanups

Hello,

this is a small series of various cleanups for the tcan4x5x and m_can driver.

regards,
Marc

author maintainer
#1 lore raw

PATCH 1/6 can: tcan4x5x: remove mram_start and reg_offset from struct tcan4x5x_priv

Both struct tcan4x5x_priv::mram_start and struct tcan4x5x_priv::reg_offset are only assigned once with a constant and then always used read-only. This patch changes the driver to use the constant directly instead.

---
 drivers/net/can/m_can/tcan4x5x.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/can/m_can/tcan4x5x.c +4 -10
index a2144bbcd486..04bb392f60fa 100644
@@ -123,10 +123,6 @@ struct tcan4x5x_priv {
 	struct gpio_desc *device_wake_gpio;
 	struct gpio_desc *device_state_gpio;
 	struct regulator *power;
-
-	/* Register based ip */
-	int mram_start;
-	int reg_offset;
 };
 
 static struct can_bittiming_const tcan4x5x_bittiming_const = {
@@ -260,7 +256,7 @@ static u32 tcan4x5x_read_reg(struct m_can_classdev *cdev, int reg)
 	struct tcan4x5x_priv *priv = cdev->device_data;
 	u32 val;
 
-	regmap_read(priv->regmap, priv->reg_offset + reg, &val);
+	regmap_read(priv->regmap, TCAN4X5X_MCAN_OFFSET + reg, &val);
 
 	return val;
 }
@@ -270,7 +266,7 @@ static u32 tcan4x5x_read_fifo(struct m_can_classdev *cdev, int addr_offset)
 	struct tcan4x5x_priv *priv = cdev->device_data;
 	u32 val;
 
-	regmap_read(priv->regmap, priv->mram_start + addr_offset, &val);
+	regmap_read(priv->regmap, TCAN4X5X_MRAM_START + addr_offset, &val);
 
 	return val;
 }
@@ -279,7 +275,7 @@ static int tcan4x5x_write_reg(struct m_can_classdev *cdev, int reg, int val)
 {
 	struct tcan4x5x_priv *priv = cdev->device_data;
 
-	return regmap_write(priv->regmap, priv->reg_offset + reg, val);
+	return regmap_write(priv->regmap, TCAN4X5X_MCAN_OFFSET + reg, val);
 }
 
 static int tcan4x5x_write_fifo(struct m_can_classdev *cdev,
@@ -287,7 +283,7 @@ static int tcan4x5x_write_fifo(struct m_can_classdev *cdev,
 {
 	struct tcan4x5x_priv *priv = cdev->device_data;
 
-	return regmap_write(priv->regmap, priv->mram_start + addr_offset, val);
+	return regmap_write(priv->regmap, TCAN4X5X_MRAM_START + addr_offset, val);
 }
 
 static int tcan4x5x_power_enable(struct regulator *reg, int enable)
@@ -465,8 +461,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 		goto out_m_can_class_free_dev;
 	}
 
-	priv->reg_offset = TCAN4X5X_MCAN_OFFSET;
-	priv->mram_start = TCAN4X5X_MRAM_START;
 	priv->spi = spi;
 	priv->mcan_dev = mcan_class;
 
Signature · 1 line
2.29.2
author maintainer
#2 lore raw

PATCH 2/6 can: tcan4x5x: tcan4x5x_can_probe(): remove probe failed error message

In reply to Marc Kleine-Budde

The driver core already emits a probe failed error message, so remove this one from the driver.

---
 drivers/net/can/m_can/tcan4x5x.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/can/m_can/tcan4x5x.c +0 -2
index 04bb392f60fa..483a78dca17e 100644
@@ -516,8 +516,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 	}
  out_m_can_class_free_dev:
 	m_can_class_free_dev(mcan_class->net);
-	dev_err(&spi->dev, "Probe failed, err=%d\n", ret);
-
 	return ret;
 }
 
Signature · 1 line
2.29.2
author maintainer
#3 lore raw

PATCH 3/6 can: m_can: Kconfig: convert the into menu

In reply to Marc Kleine-Budde

Since there is more than one base driver for the m_can core, let's convert this into a menu.

---
 drivers/net/can/m_can/Kconfig | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/can/m_can/Kconfig +5 -3
index 5f9f8192dd0b..e3eb69b76cf5 100644
@@ -1,21 +1,21 @@
 # SPDX-License-Identifier: GPL-2.0-only
-config CAN_M_CAN
+menuconfig CAN_M_CAN
 	tristate "Bosch M_CAN support"
 	help
 	  Say Y here if you want support for Bosch M_CAN controller framework.
 	  This is common support for devices that embed the Bosch M_CAN IP.
 
+if CAN_M_CAN
+
 config CAN_M_CAN_PLATFORM
 	tristate "Bosch M_CAN support for io-mapped devices"
 	depends on HAS_IOMEM
-	depends on CAN_M_CAN
 	help
 	  Say Y here if you want support for IO Mapped Bosch M_CAN controller.
 	  This support is for devices that have the Bosch M_CAN controller
 	  IP embedded into the device and the IP is IO Mapped to the processor.
 
 config CAN_M_CAN_TCAN4X5X
-	depends on CAN_M_CAN
 	depends on SPI
 	select REGMAP_SPI
 	tristate "TCAN4X5X M_CAN device"
@@ -23,3 +23,5 @@ config CAN_M_CAN_TCAN4X5X
 	  Say Y here if you want support for Texas Instruments TCAN4x5x
 	  M_CAN controller.  This device is a peripheral device that uses the
 	  SPI bus for communication.
+
+endif
Signature · 1 line
2.29.2
author maintainer
#4 lore raw

PATCH 4/6 can: m_can: remove not used variable struct m_can_classdev::freq

In reply to Marc Kleine-Budde

This patch removes the unused variable freq from the struct m_can_classdev.

---
 drivers/net/can/m_can/m_can.h | 1 -
 1 file changed, 1 deletion(-)
drivers/net/can/m_can/m_can.h +0 -1
index b2699a7c9997..f8a692596e59 100644
@@ -89,7 +89,6 @@ struct m_can_classdev {
 	void *device_data;
 
 	int version;
-	int freq;
 	u32 irqstatus;
 
 	int pm_clock_support;
Signature · 1 line
2.29.2
author maintainer
#5 lore raw

PATCH 5/6 can: m_can: m_can_plat_remove(): remove unneeded platform_set_drvdata()

In reply to Marc Kleine-Budde

There's no need to unset the drvdata on remove, so remove the unneeded call to platform_set_drvdata() in m_can_plat_remove().

---
 drivers/net/can/m_can/m_can_platform.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/can/m_can/m_can_platform.c +0 -2
index 161cb9be018c..c45a889a1afd 100644
@@ -141,8 +141,6 @@ static int m_can_plat_remove(struct platform_device *pdev)
 
 	m_can_class_free_dev(mcan_class->net);
 
-	platform_set_drvdata(pdev, NULL);
-
 	return 0;
 }
 
Signature · 1 line
2.29.2
author maintainer
#6 lore raw

PATCH 6/6 can: m_can: m_can_class_unregister(): move right after m_can_class_register()

In reply to Marc Kleine-Budde

This patch moves the function m_can_class_unregister() directly after the m_can_class_register() function.

---
 drivers/net/can/m_can/m_can.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/can/m_can/m_can.c +8 -8
index 553ff39199aa..05c978d1c53d 100644
@@ -1869,6 +1869,14 @@ int m_can_class_register(struct m_can_classdev *m_can_dev)
 }
 EXPORT_SYMBOL_GPL(m_can_class_register);
 
+void m_can_class_unregister(struct m_can_classdev *m_can_dev)
+{
+	unregister_candev(m_can_dev->net);
+
+	m_can_clk_stop(m_can_dev);
+}
+EXPORT_SYMBOL_GPL(m_can_class_unregister);
+
 int m_can_class_suspend(struct device *dev)
 {
 	struct net_device *ndev = dev_get_drvdata(dev);
@@ -1915,14 +1923,6 @@ int m_can_class_resume(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(m_can_class_resume);
 
-void m_can_class_unregister(struct m_can_classdev *m_can_dev)
-{
-	unregister_candev(m_can_dev->net);
-
-	m_can_clk_stop(m_can_dev);
-}
-EXPORT_SYMBOL_GPL(m_can_class_unregister);
-
 MODULE_AUTHOR("Dong Aisheng <[email protected]>");
 MODULE_AUTHOR("Dan Murphy <[email protected]>");
 MODULE_LICENSE("GPL v2");
Signature · 1 line
2.29.2