diff options
Diffstat (limited to 'drivers/fsi/fsi-occ.c')
| -rw-r--r-- | drivers/fsi/fsi-occ.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c index abdd37d5507f..e41ef12fa095 100644 --- a/drivers/fsi/fsi-occ.c +++ b/drivers/fsi/fsi-occ.c @@ -15,16 +15,16 @@ #include <linux/mutex.h> #include <linux/fsi-occ.h> #include <linux/of.h> -#include <linux/of_device.h> +#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/unaligned.h> +#include <linux/unaligned.h> -#define OCC_SRAM_BYTES 4096 -#define OCC_CMD_DATA_BYTES 4090 -#define OCC_RESP_DATA_BYTES 4089 +#define OCC_SRAM_BYTES 8192 +#define OCC_CMD_DATA_BYTES 8186 +#define OCC_RESP_DATA_BYTES 8185 #define OCC_P9_SRAM_CMD_ADDR 0xFFFBE000 #define OCC_P9_SRAM_RSP_ADDR 0xFFFBF000 @@ -86,7 +86,7 @@ static int occ_open(struct inode *inode, struct file *file) if (!client) return -ENOMEM; - client->buffer = (u8 *)__get_free_page(GFP_KERNEL); + client->buffer = kvmalloc(OCC_SRAM_BYTES, GFP_KERNEL); if (!client->buffer) { kfree(client); return -ENOMEM; @@ -97,10 +97,6 @@ static int occ_open(struct inode *inode, struct file *file) file->private_data = client; get_device(occ->dev); - /* We allocate a 1-page buffer, make sure it all fits */ - BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE); - BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE); - return 0; } @@ -176,7 +172,7 @@ static ssize_t occ_write(struct file *file, const char __user *buf, } /* Submit command; 4 bytes before the data and 2 bytes after */ - rlen = PAGE_SIZE; + rlen = OCC_SRAM_BYTES; rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd, &rlen); if (rc) @@ -200,7 +196,7 @@ static int occ_release(struct inode *inode, struct file *file) struct occ_client *client = file->private_data; put_device(client->occ->dev); - free_page((unsigned long)client->buffer); + kvfree(client->buffer); kfree(client); return 0; @@ -656,17 +652,16 @@ static int occ_probe(struct platform_device *pdev) rc = of_property_read_u32(dev->of_node, "reg", ®); if (!rc) { /* make sure we don't have a duplicate from dts */ - occ->idx = ida_simple_get(&occ_ida, reg, reg + 1, - GFP_KERNEL); + occ->idx = ida_alloc_range(&occ_ida, reg, reg, + GFP_KERNEL); if (occ->idx < 0) - occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, - GFP_KERNEL); + occ->idx = ida_alloc_min(&occ_ida, 1, + GFP_KERNEL); } else { - occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, - GFP_KERNEL); + occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL); } } else { - occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL); + occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL); } platform_set_drvdata(pdev, occ); @@ -680,7 +675,7 @@ static int occ_probe(struct platform_device *pdev) rc = misc_register(&occ->mdev); if (rc) { dev_err(dev, "failed to register miscdevice: %d\n", rc); - ida_simple_remove(&occ_ida, occ->idx); + ida_free(&occ_ida, occ->idx); kvfree(occ->buffer); return rc; } @@ -703,7 +698,7 @@ static int occ_probe(struct platform_device *pdev) return 0; } -static int occ_remove(struct platform_device *pdev) +static void occ_remove(struct platform_device *pdev) { struct occ *occ = platform_get_drvdata(pdev); @@ -719,9 +714,7 @@ static int occ_remove(struct platform_device *pdev) else device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child); - ida_simple_remove(&occ_ida, occ->idx); - - return 0; + ida_free(&occ_ida, occ->idx); } static const struct of_device_id occ_match[] = { |
