Re: [PATCH] Add platform device support for the ISP1760 USB chip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 10, 2009 at 12:51:13PM +0000, Catalin Marinas wrote:
> Currently, the driver only supports PCI and PPC_OF but there are
> boards like ARM RealView where this is a platform device. The patch adds
> the isp1760-plat.c file responsible for the driver registration and
> modifies the corresponding Makefile and Kconfig to be able to use this
> driver even if PCI and PPC_OF are not enabled.

> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> index f163571..54a9d81 100644
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -6,7 +6,9 @@ ifeq ($(CONFIG_USB_DEBUG),y)
>  	EXTRA_CFLAGS		+= -DDEBUG
>  endif
>  
> -isp1760-objs := isp1760-hcd.o isp1760-if.o
> +isp1760-$(CONFIG_PPC_OF)	+= isp1760-if.o
> +isp1760-$(CONFIG_PCI)		+= isp1760-if.o
> +isp1760-objs := isp1760-hcd.o isp1760-plat.o $(sort $(isp1760-y))

This is over complex - there's no need to mix -objs and -y together.

#  Composite objects are specified in kbuild makefile as follows:
#    <composite-object>-objs := <list of .o files>
#  or
#    <composite-object>-y    := <list of .o files>

so:

isp1760-y			:= isp1760-hcd.o isp1760-plat.o
isp1760-$(CONFIG_PPC_OF)	+= isp1760-if.o
isp1760-$(CONFIG_PCI)		+= isp1760-if.o

does just as well.

> +static int __devinit isp1760_drv_probe(struct platform_device *pdev)
> +{
> +	int ret = 0;
> +	struct usb_hcd *hcd;
> +	struct resource *mem_res;
> +	struct resource *irq_res;
> +	size_t mem_size;
> +
> +	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!mem_res) {
> +		pr_warning("isp1760: Memory resource not available\n");
> +		ret = -ENODEV;
> +		goto out;
> +	}
> +	mem_size = mem_res->end - mem_res->start + 1;

resource_size(mem_res) ?

> +	if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
> +		pr_warning("isp1760: Cannot reserve the memory resource\n");
> +		ret = -EBUSY;
> +		goto out;
> +	}
> +
> +	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (!irq_res) {
> +		pr_warning("isp1760: IRQ resource not available\n");
> +		return -ENODEV;
> +	}
> +
> +	hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
> +			       IRQF_SHARED | IRQF_DISABLED, &pdev->dev,
> +			       dev_name(&pdev->dev), 0);

Might want to pass the trigger flags as well?

> +	if (IS_ERR(hcd)) {
> +		pr_warning("isp1760: Failed to register the HCD device\n");
> +		ret = -ENODEV;
> +		goto cleanup;
> +	}
> +
> +	pr_info("ISP1760 USB device initialised\n");
> +	return ret;
> +
> +cleanup:
> +	release_mem_region(mem_res->start, mem_size);
> +out:
> +	return ret;
> +}
> +
> +static int __devexit isp1760_drv_remove(struct platform_device *pdev)
> +{
> +	struct resource *mem_res;
> +	size_t mem_size;
> +
> +	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	mem_size = mem_res->end - mem_res->start + 1;

resource_size(mem_res) ?

> +	release_mem_region(mem_res->start, mem_size);

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux