On 05/20/2015 01:18 AM, Izumi, Taku wrote: > > This patch adds implementation of platform_device driver > to FUJITSU Extended Socket Network Device driver. > > When "PNP0C02" is found and ACPI resource can be retrieved > successfuly, this driver creates platform_device. > platform_driver.probe and .remove routine are mock code. > > Signed-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx> This can probably be rolled into the 2nd patch as well. It seems like this is mostly just putting in infrastructure and that kind of stuff is usually best done as just one patch if you are going to do it. > --- > drivers/platform/x86/fjes/fjes_main.c | 47 +++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/platform/x86/fjes/fjes_main.c b/drivers/platform/x86/fjes/fjes_main.c > index 3454098..87057b8 100644 > --- a/drivers/platform/x86/fjes/fjes_main.c > +++ b/drivers/platform/x86/fjes/fjes_main.c > @@ -22,6 +22,7 @@ > #include <linux/module.h> > #include <linux/types.h> > #include <linux/nls.h> > +#include <linux/platform_device.h> > > #include "fjes.h" > > @@ -47,6 +48,9 @@ static int fjes_acpi_add(struct acpi_device *); > static int fjes_acpi_remove(struct acpi_device *); > static acpi_status fjes_get_acpi_resource(struct acpi_resource *, void*); > > +static int fjes_probe(struct platform_device *); > +static int fjes_remove(struct platform_device *); > + > > static const struct acpi_device_id fjes_acpi_ids[] = { > {"PNP0C02", 0}, > @@ -65,6 +69,15 @@ static struct acpi_driver fjes_acpi_driver = { > }, > }; > > +static struct platform_driver fjes_driver = { > + .driver = { > + .name = DRV_NAME, > + .owner = THIS_MODULE, > + }, > + .probe = fjes_probe, > + .remove = fjes_remove, > +}; > + > static struct resource fjes_resource[] = { > { > .flags = IORESOURCE_MEM, > @@ -93,6 +106,10 @@ static int __init fjes_init_module(void) > fjes_driver_string, fjes_driver_version); > pr_info("%s\n", fjes_copyright); > > + result = platform_driver_register(&fjes_driver); > + if (result < 0) > + return result; > + > result = acpi_bus_register_driver(&fjes_acpi_driver); > if (result < 0) > goto fail_acpi_driver; > @@ -100,6 +117,7 @@ static int __init fjes_init_module(void) > return 0; > > fail_acpi_driver: > + platform_driver_unregister(&fjes_driver); > return result; > } > > @@ -114,6 +132,7 @@ module_init(fjes_init_module); > static void __exit fjes_exit_module(void) > { > acpi_bus_unregister_driver(&fjes_acpi_driver); > + platform_driver_unregister(&fjes_driver); > } > > module_exit(fjes_exit_module); > @@ -126,6 +145,7 @@ static int fjes_acpi_add(struct acpi_device *device) > union acpi_object *str; > char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; > int result; > + struct platform_device *plat_dev; > > status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); > if (ACPI_FAILURE(status)) > @@ -148,11 +168,21 @@ static int fjes_acpi_add(struct acpi_device *device) > if (ACPI_FAILURE(status)) > return -ENODEV; > > + /* create platform_device */ > + plat_dev = platform_device_register_simple(DRV_NAME, 0, > + fjes_resource, ARRAY_SIZE(fjes_resource)); > + device->driver_data = plat_dev; > + > return 0; > } > > static int fjes_acpi_remove(struct acpi_device *device) > { > + struct platform_device *plat_dev; > + > + plat_dev = (struct platform_device *)acpi_driver_data(device); > + platform_device_unregister(plat_dev); > + > return 0; > } > > @@ -186,5 +216,22 @@ static acpi_status fjes_get_acpi_resource(struct acpi_resource *acpi_res, > return AE_OK; > } > > +/* > + * fjes_probe - Device Initialization Routine > + * > + * Returns 0 on success, negative on failure > + */ > +static int fjes_probe(struct platform_device *plat_dev) > +{ > + return 0; > +} > + > +/* > + * fjes_remove - Device Removal Routine > + */ > +static int fjes_remove(struct platform_device *plat_dev) > +{ > + return 0; > +} > > > -- To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html