hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/input/serio/olpc_apsp.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * OLPC serio driver for multiplexed input from Marvell MMP security processor
34 *
45 * Copyright (C) 2011-2013 One Laptop Per Child
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167
178 #include <linux/module.h>
....@@ -145,8 +136,15 @@
145136 {
146137 struct olpc_apsp *priv = port->port_data;
147138 unsigned int tmp;
139
+ unsigned long l;
148140
149141 if (priv->open_count++ == 0) {
142
+ l = readl(priv->base + COMMAND_FIFO_STATUS);
143
+ if (!(l & CMD_STS_MASK)) {
144
+ dev_err(priv->dev, "SP cannot accept commands.\n");
145
+ return -EIO;
146
+ }
147
+
150148 /* Enable interrupt 0 by clearing its bit */
151149 tmp = readl(priv->base + PJ_INTERRUPT_MASK);
152150 writel(tmp & ~INT_0, priv->base + PJ_INTERRUPT_MASK);
....@@ -172,15 +170,14 @@
172170 struct serio *kb_serio, *pad_serio;
173171 struct olpc_apsp *priv;
174172 struct resource *res;
175
- struct device_node *np;
176
- unsigned long l;
177173 int error;
178174
179175 priv = devm_kzalloc(&pdev->dev, sizeof(struct olpc_apsp), GFP_KERNEL);
180176 if (!priv)
181177 return -ENOMEM;
182178
183
- np = pdev->dev.of_node;
179
+ priv->dev = &pdev->dev;
180
+
184181 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
185182 priv->base = devm_ioremap_resource(&pdev->dev, res);
186183 if (IS_ERR(priv->base)) {
....@@ -191,12 +188,6 @@
191188 priv->irq = platform_get_irq(pdev, 0);
192189 if (priv->irq < 0)
193190 return priv->irq;
194
-
195
- l = readl(priv->base + COMMAND_FIFO_STATUS);
196
- if (!(l & CMD_STS_MASK)) {
197
- dev_err(&pdev->dev, "SP cannot accept commands.\n");
198
- return -EIO;
199
- }
200191
201192 /* KEYBOARD */
202193 kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
....@@ -236,7 +227,6 @@
236227 goto err_irq;
237228 }
238229
239
- priv->dev = &pdev->dev;
240230 device_init_wakeup(priv->dev, 1);
241231 platform_set_drvdata(pdev, priv);
242232