diff options
Diffstat (limited to 'drivers/input/serio/xilinx_ps2.c')
| -rw-r--r-- | drivers/input/serio/xilinx_ps2.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c index 6615c02a08fd..01433f0b48f1 100644 --- a/drivers/input/serio/xilinx_ps2.c +++ b/drivers/input/serio/xilinx_ps2.c @@ -1,17 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Xilinx XPS PS/2 device driver * * (c) 2005 MontaVista Software, Inc. * (c) 2008 Xilinx, Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. */ @@ -22,10 +14,10 @@ #include <linux/slab.h> #include <linux/list.h> #include <linux/io.h> +#include <linux/mod_devicetable.h> #include <linux/of_address.h> -#include <linux/of_device.h> #include <linux/of_irq.h> -#include <linux/of_platform.h> +#include <linux/platform_device.h> #define DRIVER_NAME "xilinx_ps2" @@ -163,22 +155,17 @@ static irqreturn_t xps2_interrupt(int irq, void *dev_id) static int sxps2_write(struct serio *pserio, unsigned char c) { struct xps2data *drvdata = pserio->port_data; - unsigned long flags; u32 sr; - int status = -1; - spin_lock_irqsave(&drvdata->lock, flags); + guard(spinlock_irqsave)(&drvdata->lock); /* If the PS/2 transmitter is empty send a byte of data */ sr = in_be32(drvdata->base_address + XPS2_STATUS_OFFSET); - if (!(sr & XPS2_STATUS_TX_FULL)) { - out_be32(drvdata->base_address + XPS2_TX_DATA_OFFSET, c); - status = 0; - } - - spin_unlock_irqrestore(&drvdata->lock, flags); + if (sr & XPS2_STATUS_TX_FULL) + return -EAGAIN; - return status; + out_be32(drvdata->base_address + XPS2_TX_DATA_OFFSET, c); + return 0; } /** @@ -227,8 +214,7 @@ static void sxps2_close(struct serio *pserio) /** * xps2_of_probe - probe method for the PS/2 device. - * @of_dev: pointer to OF device structure - * @match: pointer to the structure used for matching a device + * @ofdev: pointer to OF device structure * * This function probes the PS/2 device in the device tree. * It initializes the driver data structure and the hardware. @@ -261,8 +247,8 @@ static int xps2_of_probe(struct platform_device *ofdev) return -ENODEV; } - drvdata = kzalloc(sizeof(struct xps2data), GFP_KERNEL); - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); + serio = kzalloc(sizeof(*serio), GFP_KERNEL); if (!drvdata || !serio) { error = -ENOMEM; goto failed1; @@ -337,7 +323,7 @@ failed1: * if the driver module is being unloaded. It frees any resources allocated to * the device. */ -static int xps2_of_remove(struct platform_device *of_dev) +static void xps2_of_remove(struct platform_device *of_dev) { struct xps2data *drvdata = platform_get_drvdata(of_dev); struct resource r_mem; /* IO mem resources */ @@ -352,8 +338,6 @@ static int xps2_of_remove(struct platform_device *of_dev) release_mem_region(r_mem.start, resource_size(&r_mem)); kfree(drvdata); - - return 0; } /* Match table for of_platform binding */ |
