Skip to content

Commit

Permalink
usb: gadget: s3c: use platform resources
Browse files Browse the repository at this point in the history
The resources are correctly initialized, so just use them
instead of relying on hardcoded data from platform headers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Felipe Balbi <balbi@kernel.org>
Link: https://lore.kernel.org/r/20200806182059.2431-8-krzk@kernel.org
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
  • Loading branch information
arndb authored and krzk committed Aug 19, 2020
1 parent 98c2922 commit 188db44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
31 changes: 11 additions & 20 deletions drivers/usb/gadget/udc/s3c2410_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@
#include <asm/byteorder.h>
#include <asm/irq.h>
#include <asm/unaligned.h>
#include <mach/irqs.h>

#include <mach/hardware.h>

#include <plat/regs-udc.h>
#include <linux/platform_data/usb-s3c2410_udc.h>


#include "s3c2410_udc.h"
#include "s3c2410_udc_regs.h"

#define DRIVER_DESC "S3C2410 USB Device Controller Gadget"
#define DRIVER_AUTHOR "Herbert Pötzl <herbert@13thfloor.at>, " \
Expand All @@ -57,6 +53,7 @@ static struct s3c2410_udc *the_controller;
static struct clk *udc_clock;
static struct clk *usb_bus_clock;
static void __iomem *base_addr;
static int irq_usbd;
static u64 rsrc_start;
static u64 rsrc_len;
static struct dentry *s3c2410_udc_debugfs_root;
Expand Down Expand Up @@ -835,8 +832,6 @@ static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep)
}
}

#include <mach/regs-irq.h>

/*
* s3c2410_udc_irq - interrupt handler
*/
Expand Down Expand Up @@ -977,7 +972,7 @@ static irqreturn_t s3c2410_udc_irq(int dummy, void *_dev)
}
}

dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", IRQ_USBD);
dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", irq_usbd);

/* Restore old index */
udc_write(idx, S3C2410_UDC_INDEX_REG);
Expand Down Expand Up @@ -1780,13 +1775,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
spin_lock_init(&udc->lock);
udc_info = dev_get_platdata(&pdev->dev);

rsrc_start = S3C2410_PA_USBDEV;
rsrc_len = S3C24XX_SZ_USBDEV;

if (!request_mem_region(rsrc_start, rsrc_len, gadget_name))
return -EBUSY;

base_addr = ioremap(rsrc_start, rsrc_len);
base_addr = devm_platform_ioremap_resource(pdev, 0);
if (!base_addr) {
retval = -ENOMEM;
goto err_mem;
Expand All @@ -1798,17 +1787,19 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
s3c2410_udc_disable(udc);
s3c2410_udc_reinit(udc);

irq_usbd = platform_get_irq(pdev, 0);

/* irq setup after old hardware state is cleaned up */
retval = request_irq(IRQ_USBD, s3c2410_udc_irq,
retval = request_irq(irq_usbd, s3c2410_udc_irq,
0, gadget_name, udc);

if (retval != 0) {
dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval);
dev_err(dev, "cannot get irq %i, err %d\n", irq_usbd, retval);
retval = -EBUSY;
goto err_map;
}

dev_dbg(dev, "got irq %i\n", IRQ_USBD);
dev_dbg(dev, "got irq %i\n", irq_usbd);

if (udc_info && udc_info->vbus_pin > 0) {
retval = gpio_request(udc_info->vbus_pin, "udc vbus");
Expand Down Expand Up @@ -1875,7 +1866,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
if (udc_info && udc_info->vbus_pin > 0)
gpio_free(udc_info->vbus_pin);
err_int:
free_irq(IRQ_USBD, udc);
free_irq(irq_usbd, udc);
err_map:
iounmap(base_addr);
err_mem:
Expand Down Expand Up @@ -1909,7 +1900,7 @@ static int s3c2410_udc_remove(struct platform_device *pdev)
free_irq(irq, udc);
}

free_irq(IRQ_USBD, udc);
free_irq(irq_usbd, udc);

iounmap(base_addr);
release_mem_region(rsrc_start, rsrc_len);
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/gadget/udc/s3c2410_udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct s3c2410_udc {
unsigned req_pending : 1;
u8 vbus;
struct dentry *regs_info;
int irq;
};
#define to_s3c2410(g) (container_of((g), struct s3c2410_udc, gadget))

Expand Down
File renamed without changes.

0 comments on commit 188db44

Please sign in to comment.