static struct platform_device *xxx_platform_device;

static int __init xxx_init(void)
{
  ...
  xxx_platform_device = platform_device_register_simple("xxx", 0, 0, 0);

  driver_register(&xxx_drv);
  ...
  return 0;
}

static void __exit xxx_exit(void)
{
  platform_device_unregister(xxx_platform_device);
  driver_unregister(&xxx_drv);
  ...
}
module_init(xxx_init);
module_exit(xxx_exit);