Re: [PATCH RFC] usb: gadget: Add xilinx axi usb2 device support

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

 



On Fri, Feb 21, 2014 at 04:51:07PM +0100, Michal Simek wrote:
> On 02/21/2014 04:42 PM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Feb 21, 2014 at 02:41:03PM +0100, Michal Simek wrote:
> >>>>> +	/* Map the registers */
> >>>>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >>>>> +	udc->base_address = devm_ioremap_nocache(&pdev->dev, res->start,
> >>>>> +						 resource_size(res));
> >>>>
> >>>> use devm_ioremap_resource() instead.
> >>>
> >>> Also, res might be NULL. You should check that before dereferencing it.
> >>
> >> yes it is necessary for both cases with devm_ioremap_nocache
> >> or with devm_ioremap_resource.
> > 
> > read the source Luke:
> > 
> > | void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
> > | {
> > | 	resource_size_t size;
> > | 	const char *name;
> > | 	void __iomem *dest_ptr;
> > | 
> > | 	BUG_ON(!dev);
> > | 
> > | 	if (!res || resource_type(res) != IORESOURCE_MEM) {
> >             ^^^^
> > 	    already done for you
> > 
> > | 		dev_err(dev, "invalid resource\n");
> > | 		return ERR_PTR(-EINVAL);
> > | 	}
> > | 
> > | 	size = resource_size(res);
> > | 	name = res->name ?: dev_name(dev);
> > | 
> > | 	if (!devm_request_mem_region(dev, res->start, size, name)) {
> > | 		dev_err(dev, "can't request region for resource %pR\n", res);
> > | 		return ERR_PTR(-EBUSY);
> > | 	}
> > | 
> > | 	if (res->flags & IORESOURCE_CACHEABLE)
> > | 		dest_ptr = devm_ioremap(dev, res->start, size);
> > | 	else
> > | 		dest_ptr = devm_ioremap_nocache(dev, res->start, size);
> 
> I have read it just not sure if IORESOURCE_CACHEABLE is setup by default
> or not.
> If yes, then you have to setup res->flags in your driver and have to
> check it.

you don't need IORESOURCe_CACHEABLE. It's fine the way it is, just use
the helper function ;-).

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux