hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/drivers/macintosh/smu.c
....@@ -1,10 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * PowerMac G5 SMU driver
34 *
45 * Copyright 2004 J. Mayer <l_indien@magic.fr>
56 * Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
6
- *
7
- * Released under the term of the GNU GPL v2.
87 */
98
109 /*
....@@ -23,7 +22,7 @@
2322 #include <linux/kernel.h>
2423 #include <linux/device.h>
2524 #include <linux/dmapool.h>
26
-#include <linux/bootmem.h>
25
+#include <linux/memblock.h>
2726 #include <linux/vmalloc.h>
2827 #include <linux/highmem.h>
2928 #include <linux/jiffies.h>
....@@ -38,7 +37,6 @@
3837 #include <linux/of_irq.h>
3938 #include <linux/of_platform.h>
4039 #include <linux/slab.h>
41
-#include <linux/memblock.h>
4240 #include <linux/sched/signal.h>
4341
4442 #include <asm/byteorder.h>
....@@ -134,7 +132,7 @@
134132 /* Flush command and data to RAM */
135133 faddr = (unsigned long)smu->cmd_buf;
136134 fend = faddr + smu->cmd_buf->length + 2;
137
- flush_inval_dcache_range(faddr, fend);
135
+ flush_dcache_range(faddr, fend);
138136
139137
140138 /* We also disable NAP mode for the duration of the command
....@@ -196,7 +194,7 @@
196194 * reply length (it's only 2 cache lines anyway)
197195 */
198196 faddr = (unsigned long)smu->cmd_buf;
199
- flush_inval_dcache_range(faddr, faddr + 256);
197
+ flush_dcache_range(faddr, faddr + 256);
200198
201199 /* Now check ack */
202200 ack = (~cmd->cmd) & 0xff;
....@@ -486,14 +484,17 @@
486484 * SMU based G5s need some memory below 2Gb. Thankfully this is
487485 * called at a time where memblock is still available.
488486 */
489
- smu_cmdbuf_abs = memblock_alloc_base(4096, 4096, 0x80000000UL);
487
+ smu_cmdbuf_abs = memblock_phys_alloc_range(4096, 4096, 0, 0x80000000UL);
490488 if (smu_cmdbuf_abs == 0) {
491489 printk(KERN_ERR "SMU: Command buffer allocation failed !\n");
492490 ret = -EINVAL;
493491 goto fail_np;
494492 }
495493
496
- smu = alloc_bootmem(sizeof(struct smu_device));
494
+ smu = memblock_alloc(sizeof(struct smu_device), SMP_CACHE_BYTES);
495
+ if (!smu)
496
+ panic("%s: Failed to allocate %zu bytes\n", __func__,
497
+ sizeof(struct smu_device));
497498
498499 spin_lock_init(&smu->lock);
499500 INIT_LIST_HEAD(&smu->cmd_list);
....@@ -569,7 +570,7 @@
569570 fail_db_node:
570571 of_node_put(smu->db_node);
571572 fail_bootmem:
572
- free_bootmem(__pa(smu), sizeof(struct smu_device));
573
+ memblock_free(__pa(smu), sizeof(struct smu_device));
573574 smu = NULL;
574575 fail_np:
575576 of_node_put(np);
....@@ -637,7 +638,7 @@
637638 {
638639 struct device_node *np;
639640
640
- for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
641
+ for_each_child_of_node(smu->of_node, np)
641642 if (of_device_is_compatible(np, "smu-sensors"))
642643 of_platform_device_create(np, "smu-sensors",
643644 &smu->of_dev->dev);
....@@ -851,6 +852,7 @@
851852 break;
852853 case SMU_I2C_TRANSFER_COMBINED:
853854 cmd->info.devaddr &= 0xfe;
855
+ fallthrough;
854856 case SMU_I2C_TRANSFER_STDSUB:
855857 if (cmd->info.sublen > 3)
856858 return -EINVAL;
....@@ -1013,7 +1015,7 @@
10131015 /* Note: Only allowed to return error code in pointers (using ERR_PTR)
10141016 * when interruptible is 1
10151017 */
1016
-const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
1018
+static const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
10171019 unsigned int *size, int interruptible)
10181020 {
10191021 char pname[32];