|
@@ -141,7 +141,8 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
- rdc321x_gpio_dev = kzalloc(sizeof(struct rdc321x_gpio), GFP_KERNEL);
|
|
|
|
|
|
+ rdc321x_gpio_dev = devm_kzalloc(&pdev->dev, sizeof(struct rdc321x_gpio),
|
|
|
|
+ GFP_KERNEL);
|
|
if (!rdc321x_gpio_dev) {
|
|
if (!rdc321x_gpio_dev) {
|
|
dev_err(&pdev->dev, "failed to allocate private data\n");
|
|
dev_err(&pdev->dev, "failed to allocate private data\n");
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
@@ -150,8 +151,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
|
|
r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg1");
|
|
r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg1");
|
|
if (!r) {
|
|
if (!r) {
|
|
dev_err(&pdev->dev, "failed to get gpio-reg1 resource\n");
|
|
dev_err(&pdev->dev, "failed to get gpio-reg1 resource\n");
|
|
- err = -ENODEV;
|
|
|
|
- goto out_free;
|
|
|
|
|
|
+ return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
spin_lock_init(&rdc321x_gpio_dev->lock);
|
|
spin_lock_init(&rdc321x_gpio_dev->lock);
|
|
@@ -162,8 +162,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
|
|
r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg2");
|
|
r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg2");
|
|
if (!r) {
|
|
if (!r) {
|
|
dev_err(&pdev->dev, "failed to get gpio-reg2 resource\n");
|
|
dev_err(&pdev->dev, "failed to get gpio-reg2 resource\n");
|
|
- err = -ENODEV;
|
|
|
|
- goto out_free;
|
|
|
|
|
|
+ return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
rdc321x_gpio_dev->reg2_ctrl_base = r->start;
|
|
rdc321x_gpio_dev->reg2_ctrl_base = r->start;
|
|
@@ -187,21 +186,17 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
|
|
rdc321x_gpio_dev->reg1_data_base,
|
|
rdc321x_gpio_dev->reg1_data_base,
|
|
&rdc321x_gpio_dev->data_reg[0]);
|
|
&rdc321x_gpio_dev->data_reg[0]);
|
|
if (err)
|
|
if (err)
|
|
- goto out_free;
|
|
|
|
|
|
+ return err;
|
|
|
|
|
|
err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev,
|
|
err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev,
|
|
rdc321x_gpio_dev->reg2_data_base,
|
|
rdc321x_gpio_dev->reg2_data_base,
|
|
&rdc321x_gpio_dev->data_reg[1]);
|
|
&rdc321x_gpio_dev->data_reg[1]);
|
|
if (err)
|
|
if (err)
|
|
- goto out_free;
|
|
|
|
|
|
+ return err;
|
|
|
|
|
|
dev_info(&pdev->dev, "registering %d GPIOs\n",
|
|
dev_info(&pdev->dev, "registering %d GPIOs\n",
|
|
rdc321x_gpio_dev->chip.ngpio);
|
|
rdc321x_gpio_dev->chip.ngpio);
|
|
return gpiochip_add(&rdc321x_gpio_dev->chip);
|
|
return gpiochip_add(&rdc321x_gpio_dev->chip);
|
|
-
|
|
|
|
-out_free:
|
|
|
|
- kfree(rdc321x_gpio_dev);
|
|
|
|
- return err;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static int rdc321x_gpio_remove(struct platform_device *pdev)
|
|
static int rdc321x_gpio_remove(struct platform_device *pdev)
|
|
@@ -213,8 +208,6 @@ static int rdc321x_gpio_remove(struct platform_device *pdev)
|
|
if (ret)
|
|
if (ret)
|
|
dev_err(&pdev->dev, "failed to unregister chip\n");
|
|
dev_err(&pdev->dev, "failed to unregister chip\n");
|
|
|
|
|
|
- kfree(rdc321x_gpio_dev);
|
|
|
|
-
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|