From 950cf957fe34d40d63dfa3bf3968210430b6491e Mon Sep 17 00:00:00 2001 From: Hangyu Hua Date: Mon, 18 Apr 2022 16:57:58 +0800 Subject: misc: ocxl: fix possible double free in ocxl_file_register_afu info_release() will be called in device_unregister() when info->dev's reference count is 0. So there is no need to call ocxl_afu_put() and kfree() again. Fix this by adding free_minor() and return to err_unregister error path. Fixes: 75ca758adbaf ("ocxl: Create a clear delineation between ocxl backend & frontend") Signed-off-by: Hangyu Hua Acked-by: Frederic Barrat Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220418085758.38145-1-hbh25y@gmail.com --- drivers/misc/ocxl/file.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index d881f5e40ad9..6777c419a8da 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -556,7 +556,9 @@ int ocxl_file_register_afu(struct ocxl_afu *afu) err_unregister: ocxl_sysfs_unregister_afu(info); // safe to call even if register failed + free_minor(info); device_unregister(&info->dev); + return rc; err_put: ocxl_afu_put(afu); free_minor(info); -- cgit v1.2.3 From 7641c1bafacdfcf0cb5e7da59238fbc501da92d6 Mon Sep 17 00:00:00 2001 From: Fuqian Huang Date: Thu, 4 Jul 2019 00:28:21 +0800 Subject: macintosh: Use kmemdup rather than duplicating its implementation kmemdup is introduced to duplicate a region of memory in a neat way. Rather than kmalloc/kzalloc + memcpy, which the programmer needs to write the size twice (sometimes lead to mistakes), kmemdup improves readability, leads to smaller code and also reduce the chances of mistakes. Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy. Signed-off-by: Fuqian Huang [chleroy: Fixed parenthesis alignment] Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190703162821.32322-1-huangfq.daxian@gmail.com --- drivers/macintosh/adbhid.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index 994ba5cb3678..1d355aa9a1dd 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c @@ -789,7 +789,8 @@ adbhid_input_register(int id, int default_id, int original_handler_id, switch (default_id) { case ADB_KEYBOARD: - hid->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL); + hid->keycode = kmemdup(adb_to_linux_keycodes, + sizeof(adb_to_linux_keycodes), GFP_KERNEL); if (!hid->keycode) { err = -ENOMEM; goto fail; @@ -797,8 +798,6 @@ adbhid_input_register(int id, int default_id, int original_handler_id, sprintf(hid->name, "ADB keyboard"); - memcpy(hid->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes)); - switch (original_handler_id) { default: keyboard_type = ""; -- cgit v1.2.3 From d5f14dcf0016e8c86c424d1fd839b1e9ab000279 Mon Sep 17 00:00:00 2001 From: Ye Bin Date: Fri, 9 Apr 2021 17:51:45 +0800 Subject: macintosh/via-pmu: Use DEFINE_SPINLOCK() for spinlock spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init(). Reported-by: Hulk Robot Signed-off-by: Ye Bin Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210409095145.2294210-1-yebin10@huawei.com --- drivers/macintosh/via-pmu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 4b98bc26a94b..facd21e2d1d6 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -161,7 +161,7 @@ static unsigned char __iomem *gpio_reg; static int gpio_irq = 0; static int gpio_irq_enabled = -1; static volatile int pmu_suspended; -static spinlock_t pmu_lock; +static DEFINE_SPINLOCK(pmu_lock); static u8 pmu_intr_mask; static int pmu_version; static int drop_interrupts; @@ -305,8 +305,6 @@ int __init find_via_pmu(void) goto fail; } - spin_lock_init(&pmu_lock); - pmu_has_adb = 1; pmu_intr_mask = PMU_INT_PCEJECT | @@ -388,8 +386,6 @@ int __init find_via_pmu(void) pmu_kind = PMU_UNKNOWN; - spin_lock_init(&pmu_lock); - pmu_has_adb = 1; pmu_intr_mask = PMU_INT_PCEJECT | -- cgit v1.2.3 From 8cd1d2e9d08654b66c17432eccd404de9137ac08 Mon Sep 17 00:00:00 2001 From: Jing Yangyang Date: Tue, 24 Aug 2021 23:18:38 -0700 Subject: macintosh/smu: Fix warning comparing pointer to 0 Fix the following coccicheck warning: ./drivers/macintosh/smu.c:1089: 11-12: WARNING comparing pointer to 0, suggest !E ./drivers/macintosh/smu.c:1256:11-12: WARNING comparing pointer to 0 Reported-by: Zeal Robot Signed-off-by: Jing Yangyang Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210825061838.69746-1-deng.changcheng@zte.com.cn --- drivers/macintosh/smu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index a4fbc3fc713d..d72d073d81fd 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -1087,7 +1087,7 @@ static int smu_open(struct inode *inode, struct file *file) unsigned long flags; pp = kzalloc(sizeof(struct smu_private), GFP_KERNEL); - if (pp == 0) + if (!pp) return -ENOMEM; spin_lock_init(&pp->lock); pp->mode = smu_file_commands; @@ -1254,7 +1254,7 @@ static __poll_t smu_fpoll(struct file *file, poll_table *wait) __poll_t mask = 0; unsigned long flags; - if (pp == 0) + if (!pp) return 0; if (pp->mode == smu_file_commands) { @@ -1277,7 +1277,7 @@ static int smu_release(struct inode *inode, struct file *file) unsigned long flags; unsigned int busy; - if (pp == 0) + if (!pp) return 0; file->private_data = NULL; -- cgit v1.2.3 From cc4639989e93f5be6445e1466937e0a455f9bd88 Mon Sep 17 00:00:00 2001 From: Qing Wang Date: Thu, 14 Oct 2021 23:49:04 -0700 Subject: macintosh/ams: Replace snprintf in show functions with sysfs_emit show() must not use snprintf() when formatting the value to be returned to user space. Fix the following coccicheck warning: drivers/macintosh/ams/ams-core.c:53: WARNING: use scnprintf or sprintf. Use sysfs_emit instead of scnprintf or sprintf makes more sense. Signed-off-by: Qing Wang Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/1634280544-4581-1-git-send-email-wangqing@vivo.com --- drivers/macintosh/ams/ams-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/macintosh/ams/ams-core.c b/drivers/macintosh/ams/ams-core.c index 01eeb2336d1a..877e8cb23128 100644 --- a/drivers/macintosh/ams/ams-core.c +++ b/drivers/macintosh/ams/ams-core.c @@ -50,7 +50,7 @@ static ssize_t ams_show_current(struct device *dev, ams_sensors(&x, &y, &z); mutex_unlock(&ams_info.lock); - return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z); + return sysfs_emit(buf, "%d %d %d\n", x, y, z); } static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL); -- cgit v1.2.3 From 6130ed79decc38b873deb582678ac81caefd5555 Mon Sep 17 00:00:00 2001 From: Yang Guang Date: Thu, 4 Nov 2021 09:14:56 +0800 Subject: macintosh/adb: Use swap() to make code cleaner Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid opencoding it. Reported-by: Zeal Robot Signed-off-by: Yang Guang Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20211104011456.1027830-1-yang.guang5@zte.com.cn --- drivers/macintosh/adbhid.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index 1d355aa9a1dd..b2fe7a3dc471 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c @@ -816,9 +816,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id, case 0xC4: case 0xC7: keyboard_type = "ISO, swapping keys"; input_dev->id.version = ADB_KEYBOARD_ISO; - i = hid->keycode[10]; - hid->keycode[10] = hid->keycode[50]; - hid->keycode[50] = i; + swap(hid->keycode[10], hid->keycode[50]); break; case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A: -- cgit v1.2.3 From e9bb94cde12d14e460b954f468af1200856564cf Mon Sep 17 00:00:00 2001 From: Minghao Chi Date: Tue, 18 Jan 2022 07:52:52 +0000 Subject: macintosh/ams: Remove unneeded result variable Return the value from i2c_add_driver() directly instead of storing it in another redundant variable. Reported-by: Zeal Robot Signed-off-by: Minghao Chi Signed-off-by: CGEL ZTE Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220118075252.925616-1-chi.minghao@zte.com.cn --- drivers/macintosh/ams/ams-i2c.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/ams/ams-i2c.c b/drivers/macintosh/ams/ams-i2c.c index 21271b2e9259..d2f0cde6f9c7 100644 --- a/drivers/macintosh/ams/ams-i2c.c +++ b/drivers/macintosh/ams/ams-i2c.c @@ -256,8 +256,6 @@ static void ams_i2c_exit(void) int __init ams_i2c_init(struct device_node *np) { - int result; - /* Set implementation stuff */ ams_info.of_node = np; ams_info.exit = ams_i2c_exit; @@ -266,7 +264,5 @@ int __init ams_i2c_init(struct device_node *np) ams_info.clear_irq = ams_i2c_clear_irq; ams_info.bustype = BUS_I2C; - result = i2c_add_driver(&ams_i2c_driver); - - return result; + return i2c_add_driver(&ams_i2c_driver); } -- cgit v1.2.3 From 928b39645ec4985ea02dc3e3b45720d1456e190b Mon Sep 17 00:00:00 2001 From: Yang Li Date: Mon, 14 Feb 2022 09:05:58 +0800 Subject: macintosh: Fix warning comparing pointer to 0 Fix the following coccicheck warnings: ./drivers/macintosh/via-cuda.c:240:16-17: WARNING comparing pointer to 0 ./drivers/macintosh/via-cuda.c:243:16-17: WARNING comparing pointer to 0, suggest !E ./drivers/macintosh/via-cuda.c:521:23-24: WARNING comparing pointer to 0 Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220214010558.130201-1-yang.lee@linux.alibaba.com --- drivers/macintosh/via-cuda.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index 3d0d0b9d471d..a9feb7d5a068 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c @@ -237,10 +237,10 @@ int __init find_via_cuda(void) const u32 *reg; int err; - if (vias != 0) + if (vias) return 1; vias = of_find_node_by_name(NULL, "via-cuda"); - if (vias == 0) + if (!vias) return 0; reg = of_get_property(vias, "reg", NULL); @@ -518,7 +518,7 @@ cuda_write(struct adb_request *req) req->reply_len = 0; spin_lock_irqsave(&cuda_lock, flags); - if (current_req != 0) { + if (current_req) { last_req->next = req; last_req = req; } else { -- cgit v1.2.3 From 6c1e5600b7c305fe2b7c4967c14c4d0cc5a13fae Mon Sep 17 00:00:00 2001 From: Zou Wei Date: Mon, 7 Jun 2021 11:01:48 +0800 Subject: macintosh: Use for_each_child_of_node() macro Use for_each_child_of_node() macro instead of open coding it. Reported-by: Hulk Robot Signed-off-by: Zou Wei Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/1623034908-30525-1-git-send-email-zou_wei@huawei.com --- drivers/macintosh/macio_asic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 1943a007e2d5..6b025c8c7e57 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -472,7 +472,7 @@ static void macio_pci_add_devices(struct macio_chip *chip) root_res = &rdev->resource[0]; /* First scan 1st level */ - for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) { + for_each_child_of_node(pnode, np) { if (macio_skip_device(np)) continue; of_node_get(np); @@ -489,7 +489,7 @@ static void macio_pci_add_devices(struct macio_chip *chip) /* Add media bay devices if any */ if (mbdev) { pnode = mbdev->ofdev.dev.of_node; - for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) { + for_each_child_of_node(pnode, np) { if (macio_skip_device(np)) continue; of_node_get(np); @@ -502,7 +502,7 @@ static void macio_pci_add_devices(struct macio_chip *chip) /* Add serial ports if any */ if (sdev) { pnode = sdev->ofdev.dev.of_node; - for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) { + for_each_child_of_node(pnode, np) { if (macio_skip_device(np)) continue; of_node_get(np); -- cgit v1.2.3 From a486e512d1f3fb93b0406ab125f35777d22b47ba Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Fri, 1 Apr 2022 19:15:53 +0200 Subject: macintosh: Prepare cleanup of powerpc's asm/prom.h powerpc's asm/prom.h brings some headers that it doesn't need itself. In order to clean it up, first add missing headers in users of asm/prom.h Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/04961364547fe4556e30cb302b0e20a939b83426.1648833027.git.christophe.leroy@csgroup.eu --- drivers/macintosh/adb.c | 2 +- drivers/macintosh/ans-lcd.c | 2 +- drivers/macintosh/macio-adb.c | 5 ++++- drivers/macintosh/macio_asic.c | 3 ++- drivers/macintosh/macio_sysfs.c | 2 ++ drivers/macintosh/mediabay.c | 2 +- drivers/macintosh/rack-meter.c | 1 - drivers/macintosh/smu.c | 1 - drivers/macintosh/therm_adt746x.c | 1 - drivers/macintosh/therm_windtunnel.c | 1 - drivers/macintosh/via-cuda.c | 4 +++- drivers/macintosh/via-pmu-backlight.c | 1 - drivers/macintosh/via-pmu-led.c | 2 +- drivers/macintosh/via-pmu.c | 1 - drivers/macintosh/windfarm_ad7417_sensor.c | 2 +- drivers/macintosh/windfarm_core.c | 2 -- drivers/macintosh/windfarm_cpufreq_clamp.c | 2 -- drivers/macintosh/windfarm_fcu_controls.c | 2 +- drivers/macintosh/windfarm_lm75_sensor.c | 1 - drivers/macintosh/windfarm_lm87_sensor.c | 2 +- drivers/macintosh/windfarm_max6690_sensor.c | 2 +- drivers/macintosh/windfarm_mpu.h | 2 ++ drivers/macintosh/windfarm_pm112.c | 4 +++- drivers/macintosh/windfarm_pm121.c | 3 ++- drivers/macintosh/windfarm_pm72.c | 2 +- drivers/macintosh/windfarm_pm81.c | 3 ++- drivers/macintosh/windfarm_pm91.c | 3 ++- drivers/macintosh/windfarm_rm31.c | 2 +- drivers/macintosh/windfarm_smu_controls.c | 3 ++- drivers/macintosh/windfarm_smu_sat.c | 2 +- drivers/macintosh/windfarm_smu_sensors.c | 3 ++- 31 files changed, 37 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 73b396189039..439fab4eaa85 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -38,10 +38,10 @@ #include #include #include +#include #include #ifdef CONFIG_PPC -#include #include #endif diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c index b4821c751d04..fa904b24a600 100644 --- a/drivers/macintosh/ans-lcd.c +++ b/drivers/macintosh/ans-lcd.c @@ -11,10 +11,10 @@ #include #include #include +#include #include #include -#include #include #include "ans-lcd.h" diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c index dc634c2932fd..9b63bd2551c6 100644 --- a/drivers/macintosh/macio-adb.c +++ b/drivers/macintosh/macio-adb.c @@ -9,8 +9,11 @@ #include #include #include -#include +#include +#include +#include #include + #include #include #include diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 6b025c8c7e57..1ec1e5984563 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -20,13 +20,14 @@ #include #include #include +#include #include +#include #include #include #include #include -#include #undef DEBUG diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index 27f5eefc508f..2bbe359b26d9 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include +#include #include #include diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index b17660c022eb..36070c6586d1 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c @@ -17,7 +17,7 @@ #include #include #include -#include + #include #include #include diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c index 60311e8d6240..c28893e41a8b 100644 --- a/drivers/macintosh/rack-meter.c +++ b/drivers/macintosh/rack-meter.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index d72d073d81fd..b495bfa77896 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -41,7 +41,6 @@ #include #include -#include #include #include #include diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 7e218437730c..e604cbc91763 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index f55f6adf5e5f..9226b74fa08f 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -38,7 +38,6 @@ #include #include -#include #include #include #include diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index a9feb7d5a068..5071289063f0 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c @@ -18,8 +18,10 @@ #include #include #include +#include +#include + #ifdef CONFIG_PPC -#include #include #include #else diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c index 50ada02ae75d..2194016122d2 100644 --- a/drivers/macintosh/via-pmu-backlight.c +++ b/drivers/macintosh/via-pmu-backlight.c @@ -12,7 +12,6 @@ #include #include #include -#include #define MAX_PMU_LEVEL 0xFF diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c index ae067ab2373d..a4fb16d7db3c 100644 --- a/drivers/macintosh/via-pmu-led.c +++ b/drivers/macintosh/via-pmu-led.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include static spinlock_t pmu_blink_lock; static struct adb_request pmu_blink_req; diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index facd21e2d1d6..308fcce6ad67 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/macintosh/windfarm_ad7417_sensor.c b/drivers/macintosh/windfarm_ad7417_sensor.c index e7dec328c7cf..6ad6441abcbc 100644 --- a/drivers/macintosh/windfarm_ad7417_sensor.c +++ b/drivers/macintosh/windfarm_ad7417_sensor.c @@ -13,7 +13,7 @@ #include #include #include -#include + #include #include #include diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c index 07f91ec1f960..5307b1e34261 100644 --- a/drivers/macintosh/windfarm_core.c +++ b/drivers/macintosh/windfarm_core.c @@ -35,8 +35,6 @@ #include #include -#include - #include "windfarm.h" #define VERSION "0.2" diff --git a/drivers/macintosh/windfarm_cpufreq_clamp.c b/drivers/macintosh/windfarm_cpufreq_clamp.c index 7b726f00f183..28d18ef22bbb 100644 --- a/drivers/macintosh/windfarm_cpufreq_clamp.c +++ b/drivers/macintosh/windfarm_cpufreq_clamp.c @@ -10,8 +10,6 @@ #include #include -#include - #include "windfarm.h" #define VERSION "0.3" diff --git a/drivers/macintosh/windfarm_fcu_controls.c b/drivers/macintosh/windfarm_fcu_controls.c index 2470e5a725c8..82e7b2005ae7 100644 --- a/drivers/macintosh/windfarm_fcu_controls.c +++ b/drivers/macintosh/windfarm_fcu_controls.c @@ -14,7 +14,7 @@ #include #include #include -#include + #include #include #include diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index 29f48c2028b6..eb7e7f0bd219 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/macintosh/windfarm_lm87_sensor.c b/drivers/macintosh/windfarm_lm87_sensor.c index 9fab0b47cd3d..807efdde86bc 100644 --- a/drivers/macintosh/windfarm_lm87_sensor.c +++ b/drivers/macintosh/windfarm_lm87_sensor.c @@ -13,7 +13,7 @@ #include #include #include -#include + #include #include #include diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c index 1e7b03d44ad9..55ee417fb878 100644 --- a/drivers/macintosh/windfarm_max6690_sensor.c +++ b/drivers/macintosh/windfarm_max6690_sensor.c @@ -10,7 +10,7 @@ #include #include #include -#include + #include #include "windfarm.h" diff --git a/drivers/macintosh/windfarm_mpu.h b/drivers/macintosh/windfarm_mpu.h index 157ce6e3f32e..b5ce347d12d4 100644 --- a/drivers/macintosh/windfarm_mpu.h +++ b/drivers/macintosh/windfarm_mpu.h @@ -8,6 +8,8 @@ #ifndef __WINDFARM_MPU_H #define __WINDFARM_MPU_H +#include + typedef unsigned short fu16; typedef int fs32; typedef short fs16; diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c index e8377ce0a95a..d1dec314ae30 100644 --- a/drivers/macintosh/windfarm_pm112.c +++ b/drivers/macintosh/windfarm_pm112.c @@ -12,7 +12,9 @@ #include #include #include -#include +#include +#include + #include #include "windfarm.h" diff --git a/drivers/macintosh/windfarm_pm121.c b/drivers/macintosh/windfarm_pm121.c index ba1ec6fc11d2..36312f163aac 100644 --- a/drivers/macintosh/windfarm_pm121.c +++ b/drivers/macintosh/windfarm_pm121.c @@ -201,7 +201,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/drivers/macintosh/windfarm_pm72.c b/drivers/macintosh/windfarm_pm72.c index e81746b87cff..e21f973551cc 100644 --- a/drivers/macintosh/windfarm_pm72.c +++ b/drivers/macintosh/windfarm_pm72.c @@ -11,7 +11,7 @@ #include #include #include -#include + #include #include "windfarm.h" diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c index 82c67a4ee5f7..e0f4743f21cc 100644 --- a/drivers/macintosh/windfarm_pm81.c +++ b/drivers/macintosh/windfarm_pm81.c @@ -102,7 +102,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c index 3f346af9e3f7..c8535855360d 100644 --- a/drivers/macintosh/windfarm_pm91.c +++ b/drivers/macintosh/windfarm_pm91.c @@ -37,7 +37,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/drivers/macintosh/windfarm_rm31.c b/drivers/macintosh/windfarm_rm31.c index 7acd1684c451..e9eb7fdde48c 100644 --- a/drivers/macintosh/windfarm_rm31.c +++ b/drivers/macintosh/windfarm_rm31.c @@ -11,7 +11,7 @@ #include #include #include -#include + #include #include "windfarm.h" diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c index 75966052819a..e9957ad49a2a 100644 --- a/drivers/macintosh/windfarm_smu_controls.c +++ b/drivers/macintosh/windfarm_smu_controls.c @@ -14,7 +14,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c index e46e1153a0b4..5ade627eaa78 100644 --- a/drivers/macintosh/windfarm_smu_sat.c +++ b/drivers/macintosh/windfarm_smu_sat.c @@ -13,7 +13,7 @@ #include #include #include -#include + #include #include diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c index c8706cfb83fd..00c6fe25fcba 100644 --- a/drivers/macintosh/windfarm_smu_sensors.c +++ b/drivers/macintosh/windfarm_smu_sensors.c @@ -14,7 +14,8 @@ #include #include #include -#include +#include + #include #include #include -- cgit v1.2.3 From d8d2af70b98109418bb16ff6638d7c1c4336f7fe Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Sat, 2 Apr 2022 11:52:33 +0200 Subject: cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h powerpc's asm/prom.h brings some headers that it doesn't need itself. In order to clean it up, first add missing headers in users of asm/prom.h Signed-off-by: Christophe Leroy Acked-by: Frederic Barrat Acked-by: Andrew Donnellan Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/a2bae89b280e7a7cb87889635d9911d6a245e780.1648833388.git.christophe.leroy@csgroup.eu --- drivers/misc/cxl/api.c | 1 + drivers/misc/cxl/cxl.h | 2 ++ drivers/misc/cxl/cxllib.c | 1 + drivers/misc/cxl/flash.c | 1 + drivers/misc/cxl/guest.c | 2 ++ drivers/misc/cxl/irq.c | 1 + drivers/misc/cxl/main.c | 1 + drivers/misc/cxl/native.c | 1 + drivers/misc/ocxl/afu_irq.c | 1 + drivers/misc/ocxl/link.c | 1 + 10 files changed, 12 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index b493de962153..d85c56530863 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "cxl.h" diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 5dc0f6093f9d..7a6dd91987fd 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -25,6 +25,8 @@ extern uint cxl_verbose; +struct property; + #define CXL_TIMEOUT 5 /* diff --git a/drivers/misc/cxl/cxllib.c b/drivers/misc/cxl/cxllib.c index 53b919856426..e5fe0a171472 100644 --- a/drivers/misc/cxl/cxllib.c +++ b/drivers/misc/cxl/cxllib.c @@ -5,6 +5,7 @@ #include #include +#include #include #include diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c index 5b93ff51d82a..eee9decc121e 100644 --- a/drivers/misc/cxl/flash.c +++ b/drivers/misc/cxl/flash.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "cxl.h" diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c index 9d485c9e3fff..3321c014913c 100644 --- a/drivers/misc/cxl/guest.c +++ b/drivers/misc/cxl/guest.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "cxl.h" #include "hcalls.h" diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 4cb829d5d873..5f0e2dcebb34 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c index 43b312d06e3e..c1fbf6f588f7 100644 --- a/drivers/misc/cxl/main.c +++ b/drivers/misc/cxl/main.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 1a7f22836041..50b0c44bb8d7 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c index ecdcfae025b7..a06920b7e049 100644 --- a/drivers/misc/ocxl/afu_irq.c +++ b/drivers/misc/ocxl/afu_irq.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ // Copyright 2017 IBM Corp. #include +#include #include #include #include "ocxl_internal.h" diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c index 9670d02c927f..4cf4c55a5f00 100644 --- a/drivers/misc/ocxl/link.c +++ b/drivers/misc/ocxl/link.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From c127d130f6d59fa81701f6b04023cf7cd1972fb3 Mon Sep 17 00:00:00 2001 From: Haren Myneni Date: Sat, 9 Apr 2022 01:44:16 -0700 Subject: powerpc/powernv/vas: Assign real address to rx_fifo in vas_rx_win_attr In init_winctx_regs(), __pa() is called on winctx->rx_fifo and this function is called to initialize registers for receive and fault windows. But the real address is passed in winctx->rx_fifo for receive windows and the virtual address for fault windows which causes errors with DEBUG_VIRTUAL enabled. Fixes this issue by assigning only real address to rx_fifo in vas_rx_win_attr struct for both receive and fault windows. Reported-by: Michael Ellerman Signed-off-by: Haren Myneni Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/338e958c7ab8f3b266fa794a1f80f99b9671829e.camel@linux.ibm.com --- arch/powerpc/include/asm/vas.h | 2 +- arch/powerpc/platforms/powernv/vas-fault.c | 2 +- arch/powerpc/platforms/powernv/vas-window.c | 4 ++-- arch/powerpc/platforms/powernv/vas.h | 2 +- drivers/crypto/nx/nx-common-powernv.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h index 83afcb6c194b..c36f71e01c0f 100644 --- a/arch/powerpc/include/asm/vas.h +++ b/arch/powerpc/include/asm/vas.h @@ -126,7 +126,7 @@ static inline void vas_user_win_add_mm_context(struct vas_user_win_ref *ref) * Receive window attributes specified by the (in-kernel) owner of window. */ struct vas_rx_win_attr { - void *rx_fifo; + u64 rx_fifo; int rx_fifo_size; int wcreds_max; diff --git a/arch/powerpc/platforms/powernv/vas-fault.c b/arch/powerpc/platforms/powernv/vas-fault.c index a7aabc18039e..c1bfad56447d 100644 --- a/arch/powerpc/platforms/powernv/vas-fault.c +++ b/arch/powerpc/platforms/powernv/vas-fault.c @@ -216,7 +216,7 @@ int vas_setup_fault_window(struct vas_instance *vinst) vas_init_rx_win_attr(&attr, VAS_COP_TYPE_FAULT); attr.rx_fifo_size = vinst->fault_fifo_size; - attr.rx_fifo = vinst->fault_fifo; + attr.rx_fifo = __pa(vinst->fault_fifo); /* * Max creds is based on number of CRBs can fit in the FIFO. diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c index 0f8d39fbf2b2..0072682531d8 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -404,7 +404,7 @@ static void init_winctx_regs(struct pnv_vas_window *window, * * See also: Design note in function header. */ - val = __pa(winctx->rx_fifo); + val = winctx->rx_fifo; val = SET_FIELD(VAS_PAGE_MIGRATION_SELECT, val, 0); write_hvwc_reg(window, VREG(LFIFO_BAR), val); @@ -739,7 +739,7 @@ static void init_winctx_for_rxwin(struct pnv_vas_window *rxwin, */ winctx->fifo_disable = true; winctx->intr_disable = true; - winctx->rx_fifo = NULL; + winctx->rx_fifo = 0; } winctx->lnotify_lpid = rxattr->lnotify_lpid; diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h index 8bb08e395de0..08d9d3d5a22b 100644 --- a/arch/powerpc/platforms/powernv/vas.h +++ b/arch/powerpc/platforms/powernv/vas.h @@ -376,7 +376,7 @@ struct pnv_vas_window { * is a container for the register fields in the window context. */ struct vas_winctx { - void *rx_fifo; + u64 rx_fifo; int rx_fifo_size; int wcreds_max; int rsvd_txbuf_count; diff --git a/drivers/crypto/nx/nx-common-powernv.c b/drivers/crypto/nx/nx-common-powernv.c index 32a036ada5d0..f418817c0f43 100644 --- a/drivers/crypto/nx/nx-common-powernv.c +++ b/drivers/crypto/nx/nx-common-powernv.c @@ -827,7 +827,7 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id, goto err_out; vas_init_rx_win_attr(&rxattr, coproc->ct); - rxattr.rx_fifo = (void *)rx_fifo; + rxattr.rx_fifo = rx_fifo; rxattr.rx_fifo_size = fifo_size; rxattr.lnotify_lpid = lpid; rxattr.lnotify_pid = pid; -- cgit v1.2.3 From 86ce436e30d86327c9f5260f718104ae7b21f506 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Thu, 7 Apr 2022 20:11:32 +1000 Subject: macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled drivers/macintosh/via-pmu-event.o: In function `via_pmu_event': via-pmu-event.c:(.text+0x44): undefined reference to `input_event' via-pmu-event.c:(.text+0x68): undefined reference to `input_event' via-pmu-event.c:(.text+0x94): undefined reference to `input_event' via-pmu-event.c:(.text+0xb8): undefined reference to `input_event' drivers/macintosh/via-pmu-event.o: In function `via_pmu_event_init': via-pmu-event.c:(.init.text+0x20): undefined reference to `input_allocate_device' via-pmu-event.c:(.init.text+0xc4): undefined reference to `input_register_device' via-pmu-event.c:(.init.text+0xd4): undefined reference to `input_free_device' make[1]: *** [Makefile:1155: vmlinux] Error 1 make: *** [Makefile:350: __build_one_by_one] Error 2 Don't call into the input subsystem unless CONFIG_INPUT is built-in. Reported-by: kernel test robot Signed-off-by: Finn Thain Tested-by: Randy Dunlap Reviewed-by: Christophe Leroy Acked-by: Randy Dunlap Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/5edbe76ce68227f71e09af4614cc4c1bd61c7ec8.1649326292.git.fthain@linux-m68k.org --- drivers/macintosh/Kconfig | 4 ++++ drivers/macintosh/Makefile | 3 ++- drivers/macintosh/via-pmu.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index 5cdc361da37c..3942db15a2b8 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig @@ -67,6 +67,10 @@ config ADB_PMU this device; you should do so if your machine is one of those mentioned above. +config ADB_PMU_EVENT + def_bool y + depends on ADB_PMU && INPUT=y + config ADB_PMU_LED bool "Support for the Power/iBook front LED" depends on PPC_PMAC && ADB_PMU diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile index 49819b1b6f20..712edcb3e0b0 100644 --- a/drivers/macintosh/Makefile +++ b/drivers/macintosh/Makefile @@ -12,7 +12,8 @@ obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o obj-$(CONFIG_INPUT_ADBHID) += adbhid.o obj-$(CONFIG_ANSLCD) += ans-lcd.o -obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o +obj-$(CONFIG_ADB_PMU) += via-pmu.o +obj-$(CONFIG_ADB_PMU_EVENT) += via-pmu-event.o obj-$(CONFIG_ADB_PMU_LED) += via-pmu-led.o obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o obj-$(CONFIG_ADB_CUDA) += via-cuda.o diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 308fcce6ad67..49657962d892 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -1454,7 +1454,7 @@ next: pmu_pass_intr(data, len); /* len == 6 is probably a bad check. But how do I * know what PMU versions send what events here? */ - if (len == 6) { + if (IS_ENABLED(CONFIG_ADB_PMU_EVENT) && len == 6) { via_pmu_event(PMU_EVT_POWER, !!(data[1]&8)); via_pmu_event(PMU_EVT_LID, data[1]&1); } -- cgit v1.2.3 From 9a9c5ff5fff87eb1a43db0d899473554e408fd7b Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 10 Apr 2022 09:10:35 -0700 Subject: macintosh: via-pmu and via-cuda need RTC_LIB Fix build when RTC_LIB is not set/enabled. Eliminates these build errors: m68k-linux-ld: drivers/macintosh/via-pmu.o: in function `pmu_set_rtc_time': drivers/macintosh/via-pmu.c:1769: undefined reference to `rtc_tm_to_time64' m68k-linux-ld: drivers/macintosh/via-cuda.o: in function `cuda_set_rtc_time': drivers/macintosh/via-cuda.c:797: undefined reference to `rtc_tm_to_time64' Fixes: 0792a2c8e0bb ("macintosh: Use common code to access RTC") Reported-by: kernel test robot Suggested-by: Christophe Leroy Signed-off-by: Randy Dunlap Acked-by: Arnd Bergmann Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220410161035.592-1-rdunlap@infradead.org --- drivers/macintosh/Kconfig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index 3942db15a2b8..539a2ed4e13d 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig @@ -44,6 +44,7 @@ config ADB_IOP config ADB_CUDA bool "Support for Cuda/Egret based Macs and PowerMacs" depends on (ADB || PPC_PMAC) && !PPC_PMAC64 + select RTC_LIB help This provides support for Cuda/Egret based Macintosh and Power Macintosh systems. This includes most m68k based Macs, @@ -57,6 +58,7 @@ config ADB_CUDA config ADB_PMU bool "Support for PMU based PowerMacs and PowerBooks" depends on PPC_PMAC || MAC + select RTC_LIB help On PowerBooks, iBooks, and recent iMacs and Power Macintoshes, the PMU is an embedded microprocessor whose primary function is to -- cgit v1.2.3