diff mbox series

[v4,5/7] gpio: vf610: simplify code by adding of_device_id data for vf610

Message ID 20230926-vf610-gpio-v4-5-b57b7f6e8368@nxp.com
State New
Headers show
Series [v4,1/7] dt-bindings: gpio: vf610: update gpio-ranges | expand

Commit Message

Peng Fan (OSS) Sept. 26, 2023, 3:33 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

Add of_device_id data for devices compatible with fsl,vf610-gpio,
then no need to check port->sdata is NULL or not. So code simplified
a bit.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/gpio/gpio-vf610.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index 49867d5db642..c48a3bdfb942 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -64,6 +64,10 @@  struct vf610_gpio_port {
 #define IMX8ULP_GPIO_BASE_OFF	0x40
 #define IMX8ULP_BASE_OFF	0x80
 
+static const struct fsl_gpio_soc_data vf610_data = {
+	.have_dual_base = true,
+};
+
 static const struct fsl_gpio_soc_data imx_data = {
 	.have_paddr = true,
 	.have_dual_base = true,
@@ -74,7 +78,7 @@  static const struct fsl_gpio_soc_data imx8ulp_data = {
 };
 
 static const struct of_device_id vf610_gpio_dt_ids[] = {
-	{ .compatible = "fsl,vf610-gpio",	.data = NULL, },
+	{ .compatible = "fsl,vf610-gpio",	.data = &vf610_data },
 	{ .compatible = "fsl,imx7ulp-gpio",	.data = &imx_data, },
 	{ .compatible = "fsl,imx8ulp-gpio",	.data = &imx8ulp_data, },
 	{ /* sentinel */ }
@@ -96,7 +100,7 @@  static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 	unsigned long mask = BIT(gpio);
 	unsigned long offset = GPIO_PDIR;
 
-	if (port->sdata && port->sdata->have_paddr) {
+	if (port->sdata->have_paddr) {
 		mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR);
 		if (mask)
 			offset = GPIO_PDOR;
@@ -120,7 +124,7 @@  static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
 	unsigned long mask = BIT(gpio);
 	u32 val;
 
-	if (port->sdata && port->sdata->have_paddr) {
+	if (port->sdata->have_paddr) {
 		val = vf610_gpio_readl(port->gpio_base + GPIO_PDDR);
 		val &= ~mask;
 		vf610_gpio_writel(val, port->gpio_base + GPIO_PDDR);
@@ -136,7 +140,7 @@  static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
 	unsigned long mask = BIT(gpio);
 	u32 val;
 
-	if (port->sdata && port->sdata->have_paddr) {
+	if (port->sdata->have_paddr) {
 		val = vf610_gpio_readl(port->gpio_base + GPIO_PDDR);
 		val |= mask;
 		vf610_gpio_writel(val, port->gpio_base + GPIO_PDDR);
@@ -287,7 +291,7 @@  static int vf610_gpio_probe(struct platform_device *pdev)
 	    (device_is_compatible(dev, "fsl,imx8ulp-gpio"))))
 		dual_base = true;
 
-	if ((port->sdata && port->sdata->have_dual_base) || dual_base) {
+	if (port->sdata->have_dual_base || dual_base) {
 		port->base = devm_platform_ioremap_resource(pdev, 0);
 		if (IS_ERR(port->base))
 			return PTR_ERR(port->base);