hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/hsi/controllers/omap_ssi_core.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* OMAP SSI driver.
23 *
34 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
45 * Copyright (C) 2014 Sebastian Reichel <sre@kernel.org>
56 *
67 * Contact: Carlos Chinea <carlos.chinea@nokia.com>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * version 2 as published by the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope that it will be useful, but
13
- * WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
- * 02110-1301 USA
218 */
229
2310 #include <linux/compiler.h>
....@@ -48,7 +35,7 @@
4835 static DEFINE_IDA(platform_omap_ssi_ida);
4936
5037 #ifdef CONFIG_DEBUG_FS
51
-static int ssi_debug_show(struct seq_file *m, void *p __maybe_unused)
38
+static int ssi_regs_show(struct seq_file *m, void *p __maybe_unused)
5239 {
5340 struct hsi_controller *ssi = m->private;
5441 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
....@@ -63,7 +50,7 @@
6350 return 0;
6451 }
6552
66
-static int ssi_debug_gdd_show(struct seq_file *m, void *p __maybe_unused)
53
+static int ssi_gdd_regs_show(struct seq_file *m, void *p __maybe_unused)
6754 {
6855 struct hsi_controller *ssi = m->private;
6956 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
....@@ -117,29 +104,8 @@
117104 return 0;
118105 }
119106
120
-static int ssi_regs_open(struct inode *inode, struct file *file)
121
-{
122
- return single_open(file, ssi_debug_show, inode->i_private);
123
-}
124
-
125
-static int ssi_gdd_regs_open(struct inode *inode, struct file *file)
126
-{
127
- return single_open(file, ssi_debug_gdd_show, inode->i_private);
128
-}
129
-
130
-static const struct file_operations ssi_regs_fops = {
131
- .open = ssi_regs_open,
132
- .read = seq_read,
133
- .llseek = seq_lseek,
134
- .release = single_release,
135
-};
136
-
137
-static const struct file_operations ssi_gdd_regs_fops = {
138
- .open = ssi_gdd_regs_open,
139
- .read = seq_read,
140
- .llseek = seq_lseek,
141
- .release = single_release,
142
-};
107
+DEFINE_SHOW_ATTRIBUTE(ssi_regs);
108
+DEFINE_SHOW_ATTRIBUTE(ssi_gdd_regs);
143109
144110 static int ssi_debug_add_ctrl(struct hsi_controller *ssi)
145111 {
....@@ -330,7 +296,7 @@
330296 break;
331297 case ABORT_RATE_CHANGE:
332298 dev_dbg(&ssi->device, "abort rate change\n");
333
- /* Fall through */
299
+ fallthrough;
334300 case POST_RATE_CHANGE:
335301 dev_dbg(&ssi->device, "post rate change (%lu -> %lu)\n",
336302 clk_data->old_rate, clk_data->new_rate);
....@@ -404,10 +370,8 @@
404370 if (err < 0)
405371 goto out_err;
406372 err = platform_get_irq_byname(pd, "gdd_mpu");
407
- if (err < 0) {
408
- dev_err(&pd->dev, "GDD IRQ resource missing\n");
373
+ if (err < 0)
409374 goto out_err;
410
- }
411375 omap_ssi->gdd_irq = err;
412376 tasklet_init(&omap_ssi->gdd_tasklet, ssi_gdd_tasklet,
413377 (unsigned long)ssi);
....@@ -460,7 +424,7 @@
460424 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
461425 int err;
462426
463
- err = pm_runtime_get_sync(ssi->device.parent);
427
+ err = pm_runtime_resume_and_get(ssi->device.parent);
464428 if (err < 0) {
465429 dev_err(&ssi->device, "runtime PM failed %d\n", err);
466430 return err;
....@@ -538,8 +502,10 @@
538502 platform_set_drvdata(pd, ssi);
539503
540504 err = ssi_add_controller(ssi, pd);
541
- if (err < 0)
505
+ if (err < 0) {
506
+ hsi_put_controller(ssi);
542507 goto out1;
508
+ }
543509
544510 pm_runtime_enable(&pd->dev);
545511
....@@ -560,6 +526,7 @@
560526 if (!childpdev) {
561527 err = -ENODEV;
562528 dev_err(&pd->dev, "failed to create ssi controller port\n");
529
+ of_node_put(child);
563530 goto out3;
564531 }
565532 }
....@@ -571,9 +538,9 @@
571538 device_for_each_child(&pd->dev, NULL, ssi_remove_ports);
572539 out2:
573540 ssi_remove_controller(ssi);
541
+ pm_runtime_disable(&pd->dev);
574542 out1:
575543 platform_set_drvdata(pd, NULL);
576
- pm_runtime_disable(&pd->dev);
577544
578545 return err;
579546 }
....@@ -664,7 +631,13 @@
664631 if (ret)
665632 return ret;
666633
667
- return platform_driver_register(&ssi_port_pdriver);
634
+ ret = platform_driver_register(&ssi_port_pdriver);
635
+ if (ret) {
636
+ platform_driver_unregister(&ssi_pdriver);
637
+ return ret;
638
+ }
639
+
640
+ return 0;
668641 }
669642 module_init(ssi_init);
670643