Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: intel-mid_wdt: Convert to use new SCU IPC API

This converts the Intel MID watchdog driver over the new SCU IPC API
where the SCU IPC instance is passed to the functions.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Mika Westerberg and committed by
Lee Jones
80ae679b 595694bd

+37 -16
+37 -16
drivers/watchdog/intel-mid_wdt.c
··· 33 33 SCU_WATCHDOG_KEEPALIVE, 34 34 }; 35 35 36 - static inline int wdt_command(int sub, u32 *in, int inlen) 36 + struct mid_wdt { 37 + struct watchdog_device wd; 38 + struct device *dev; 39 + struct intel_scu_ipc_dev *scu; 40 + }; 41 + 42 + static inline int 43 + wdt_command(struct mid_wdt *mid, int sub, const void *in, size_t inlen, size_t size) 37 44 { 38 - return intel_scu_ipc_command(IPC_WATCHDOG, sub, in, inlen, NULL, 0); 45 + struct intel_scu_ipc_dev *scu = mid->scu; 46 + 47 + return intel_scu_ipc_dev_command_with_size(scu, IPC_WATCHDOG, sub, in, 48 + inlen, size, NULL, 0); 39 49 } 40 50 41 51 static int wdt_start(struct watchdog_device *wd) 42 52 { 43 - struct device *dev = watchdog_get_drvdata(wd); 53 + struct mid_wdt *mid = watchdog_get_drvdata(wd); 44 54 int ret, in_size; 45 55 int timeout = wd->timeout; 46 56 struct ipc_wd_start { ··· 59 49 } ipc_wd_start = { timeout - MID_WDT_PRETIMEOUT, timeout }; 60 50 61 51 /* 62 - * SCU expects the input size for watchdog IPC to 63 - * be based on 4 bytes 52 + * SCU expects the input size for watchdog IPC to be 2 which is the 53 + * size of the structure in dwords. SCU IPC normally takes bytes 54 + * but this is a special case where we specify size to be different 55 + * than inlen. 64 56 */ 65 57 in_size = DIV_ROUND_UP(sizeof(ipc_wd_start), 4); 66 58 67 - ret = wdt_command(SCU_WATCHDOG_START, (u32 *)&ipc_wd_start, in_size); 59 + ret = wdt_command(mid, SCU_WATCHDOG_START, &ipc_wd_start, 60 + sizeof(ipc_wd_start), in_size); 68 61 if (ret) 69 - dev_crit(dev, "error starting watchdog: %d\n", ret); 62 + dev_crit(mid->dev, "error starting watchdog: %d\n", ret); 70 63 71 64 return ret; 72 65 } 73 66 74 67 static int wdt_ping(struct watchdog_device *wd) 75 68 { 76 - struct device *dev = watchdog_get_drvdata(wd); 69 + struct mid_wdt *mid = watchdog_get_drvdata(wd); 77 70 int ret; 78 71 79 - ret = wdt_command(SCU_WATCHDOG_KEEPALIVE, NULL, 0); 72 + ret = wdt_command(mid, SCU_WATCHDOG_KEEPALIVE, NULL, 0, 0); 80 73 if (ret) 81 - dev_crit(dev, "Error executing keepalive: %d\n", ret); 74 + dev_crit(mid->dev, "Error executing keepalive: %d\n", ret); 82 75 83 76 return ret; 84 77 } 85 78 86 79 static int wdt_stop(struct watchdog_device *wd) 87 80 { 88 - struct device *dev = watchdog_get_drvdata(wd); 81 + struct mid_wdt *mid = watchdog_get_drvdata(wd); 89 82 int ret; 90 83 91 - ret = wdt_command(SCU_WATCHDOG_STOP, NULL, 0); 84 + ret = wdt_command(mid, SCU_WATCHDOG_STOP, NULL, 0, 0); 92 85 if (ret) 93 - dev_crit(dev, "Error stopping watchdog: %d\n", ret); 86 + dev_crit(mid->dev, "Error stopping watchdog: %d\n", ret); 94 87 95 88 return ret; 96 89 } ··· 123 110 struct device *dev = &pdev->dev; 124 111 struct watchdog_device *wdt_dev; 125 112 struct intel_mid_wdt_pdata *pdata = dev->platform_data; 113 + struct mid_wdt *mid; 126 114 int ret; 127 115 128 116 if (!pdata) { ··· 137 123 return ret; 138 124 } 139 125 140 - wdt_dev = devm_kzalloc(dev, sizeof(*wdt_dev), GFP_KERNEL); 141 - if (!wdt_dev) 126 + mid = devm_kzalloc(dev, sizeof(*mid), GFP_KERNEL); 127 + if (!mid) 142 128 return -ENOMEM; 129 + 130 + mid->dev = dev; 131 + wdt_dev = &mid->wd; 143 132 144 133 wdt_dev->info = &mid_wdt_info; 145 134 wdt_dev->ops = &mid_wdt_ops; ··· 152 135 wdt_dev->parent = dev; 153 136 154 137 watchdog_set_nowayout(wdt_dev, WATCHDOG_NOWAYOUT); 155 - watchdog_set_drvdata(wdt_dev, dev); 138 + watchdog_set_drvdata(wdt_dev, mid); 156 139 157 140 ret = devm_request_irq(dev, pdata->irq, mid_wdt_irq, 158 141 IRQF_SHARED | IRQF_NO_SUSPEND, "watchdog", ··· 161 144 dev_err(dev, "error requesting warning irq %d\n", pdata->irq); 162 145 return ret; 163 146 } 147 + 148 + mid->scu = devm_intel_scu_ipc_dev_get(dev); 149 + if (!mid->scu) 150 + return -EPROBE_DEFER; 164 151 165 152 /* 166 153 * The firmware followed by U-Boot leaves the watchdog running