/* This function is called if a device is physically removed from the system or if the driver module is being unloaded. It frees any resources allocated to the device.  */
static int __devexit xps2_of_remove(struct of_device *of_dev)
/* This function is called if a device is physically removed from the system or if the driver module is being unloaded. It frees any resources allocated to the device.  */
static int __devexit xps2_of_remove(struct of_device *of_dev)
{
	struct device *dev = &of_dev->dev;
	struct xps2data *drvdata = dev_get_drvdata(dev);
	struct resource r_mem;
	serio_unregister_port(&drvdata->serio);
	iounmap(drvdata->base_address);
	if (of_address_to_resource(of_dev->node, 0, &r_mem))
		dev_err(dev, "invalid address\n");
	else
		release_mem_region(r_mem.start, r_mem.end - r_mem.start + 1);
	kfree(drvdata);
	dev_set_drvdata(dev, NULL);
	return 0;
}