sysfs_remove_group(&dev->kobj, &axp20x_attribute_group);
}
-static int axp20x_pek_probe(struct platform_device *pdev)
+static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
+ struct platform_device *pdev)
{
- struct axp20x_pek *axp20x_pek;
- struct axp20x_dev *axp20x;
+ struct axp20x_dev *axp20x = axp20x_pek->axp20x;
struct input_dev *idev;
int error;
- axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
- GFP_KERNEL);
- if (!axp20x_pek)
- return -ENOMEM;
-
- axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
- axp20x = axp20x_pek->axp20x;
-
axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
if (axp20x_pek->irq_dbr < 0) {
dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
return error;
}
+ error = input_register_device(idev);
+ if (error) {
+ dev_err(&pdev->dev, "Can't register input device: %d\n",
+ error);
+ return error;
+ }
+
+ return 0;
+}
+
+static int axp20x_pek_probe(struct platform_device *pdev)
+{
+ struct axp20x_pek *axp20x_pek;
+ int error;
+
+ axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
+ GFP_KERNEL);
+ if (!axp20x_pek)
+ return -ENOMEM;
+
+ axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+
+ error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
+ if (error)
+ return error;
+
error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group);
if (error) {
dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n",
return error;
}
- error = input_register_device(idev);
- if (error) {
- dev_err(&pdev->dev, "Can't register input device: %d\n",
- error);
- return error;
- }
-
platform_set_drvdata(pdev, axp20x_pek);
return 0;