From 8f976ab0226e7e0275fa5908715ff46638da4c4c Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 18 Sep 2023 16:57:28 +0100 Subject: [PATCH] net: can: mttcan: Drop unnecessary version checks GPIO descriptor support has been supported in the Linux kernel since v3.16. Therefore, simplify the MTTCAN driver by removing the legacy GPIO support and only use GPIO descriptors. Bug 4119327 Bug 4228080 Change-Id: Ib1c50d17c514dee6a5c69145a8f5d3e07b5b3855 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2981396 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- .../net/can/mttcan/include/m_ttcan_linux.h | 4 -- drivers/net/can/mttcan/native/m_ttcan_linux.c | 55 +------------------ 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/drivers/net/can/mttcan/include/m_ttcan_linux.h b/drivers/net/can/mttcan/include/m_ttcan_linux.h index 8571de47..fef729a6 100644 --- a/drivers/net/can/mttcan/include/m_ttcan_linux.h +++ b/drivers/net/can/mttcan/include/m_ttcan_linux.h @@ -76,11 +76,7 @@ struct tegra_mttcan_soc_info { }; struct can_gpio { -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) - int gpio; -#else struct gpio_desc *gpio; -#endif int active_low; }; diff --git a/drivers/net/can/mttcan/native/m_ttcan_linux.c b/drivers/net/can/mttcan/native/m_ttcan_linux.c index 9742c205..5e7cce30 100644 --- a/drivers/net/can/mttcan/native/m_ttcan_linux.c +++ b/drivers/net/can/mttcan/native/m_ttcan_linux.c @@ -1251,17 +1251,6 @@ static int mttcan_power_up(struct mttcan_priv *priv) int level; mttcan_pm_runtime_get_sync(priv); -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) - if (gpio_is_valid(priv->gpio_can_stb.gpio)) { - level = !priv->gpio_can_stb.active_low; - gpio_direction_output(priv->gpio_can_stb.gpio, level); - } - - if (gpio_is_valid(priv->gpio_can_en.gpio)) { - level = !priv->gpio_can_en.active_low; - gpio_direction_output(priv->gpio_can_en.gpio, level); - } -#else if (priv->gpio_can_stb.gpio) { level = !priv->gpio_can_stb.active_low; gpiod_direction_output(priv->gpio_can_stb.gpio, level); @@ -1271,7 +1260,7 @@ static int mttcan_power_up(struct mttcan_priv *priv) level = !priv->gpio_can_en.active_low; gpiod_direction_output(priv->gpio_can_en.gpio, level); } -#endif + return ttcan_set_power(priv->ttcan, 1); } @@ -1283,17 +1272,6 @@ static int mttcan_power_down(struct net_device *dev) if (ttcan_set_power(priv->ttcan, 0)) return -ETIMEDOUT; -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) - if (gpio_is_valid(priv->gpio_can_stb.gpio)) { - level = priv->gpio_can_stb.active_low; - gpio_direction_output(priv->gpio_can_stb.gpio, level); - } - - if (gpio_is_valid(priv->gpio_can_en.gpio)) { - level = priv->gpio_can_en.active_low; - gpio_direction_output(priv->gpio_can_en.gpio, level); - } -#else if (priv->gpio_can_stb.gpio) { level = priv->gpio_can_stb.active_low; gpiod_direction_output(priv->gpio_can_stb.gpio, level); @@ -1303,7 +1281,6 @@ static int mttcan_power_down(struct net_device *dev) level = priv->gpio_can_en.active_low; gpiod_direction_output(priv->gpio_can_en.gpio, level); } -#endif mttcan_pm_runtime_put_sync(priv); @@ -1729,9 +1706,6 @@ static int mttcan_probe(struct platform_device *pdev) { int ret = 0; int irq = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) - enum of_gpio_flags flags; -#endif void __iomem *regs = NULL, *xregs = NULL; void __iomem *mram_addr = NULL; struct net_device *dev; @@ -1812,21 +1786,12 @@ static int mttcan_probe(struct platform_device *pdev) goto exit_free_device; /* set device-tree properties */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) priv->gpio_can_en.gpio = devm_gpiod_get_optional(&pdev->dev, "gpio_can_en", 0); priv->gpio_can_en.active_low = GPIOD_OUT_LOW; priv->gpio_can_stb.gpio = devm_gpiod_get_optional(&pdev->dev, "gpio_can_stb", 0); priv->gpio_can_stb.active_low = GPIOD_OUT_LOW; -#else - priv->gpio_can_en.gpio = of_get_named_gpio_flags(np, - "gpio_can_en", 0, &flags); - priv->gpio_can_en.active_low = flags & OF_GPIO_ACTIVE_LOW; - priv->gpio_can_stb.gpio = of_get_named_gpio_flags(np, - "gpio_can_stb", 0, &flags); - priv->gpio_can_stb.active_low = flags & OF_GPIO_ACTIVE_LOW; -#endif priv->instance = of_alias_get_id(np, "mttcan"); priv->poll = of_property_read_bool(np, "use-polling"); @@ -1850,24 +1815,6 @@ static int mttcan_probe(struct platform_device *pdev) goto exit_free_device; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) - if (gpio_is_valid(priv->gpio_can_stb.gpio)) { - if (devm_gpio_request(priv->device, priv->gpio_can_stb.gpio, - "gpio_can_stb") < 0) { - dev_err(priv->device, "stb gpio request failed\n"); - goto exit_free_device; - } - } - if (gpio_is_valid(priv->gpio_can_en.gpio)) { - if (devm_gpio_request(priv->device, priv->gpio_can_en.gpio, - "gpio_can_en") < 0) { - dev_err(priv->device, "stb gpio request failed\n"); - goto exit_free_device; - } - } -#endif - - /* allocate controller struct memory and set fields */ priv->ttcan = devm_kzalloc(priv->device, sizeof(struct ttcan_controller),