pic32-dmt.c (0898782247ae533d1f4e47a06bc5d4870931b284) pic32-dmt.c (e0912ea8714deb598c7763ec60c9ba83b157acf7)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * PIC32 deadman timer driver
4 *
5 * Purna Chandra Mandal <purna.mandal@microchip.com>
6 * Copyright (c) 2016, Microchip Technology Inc.
7 */
8#include <linux/clk.h>

--- 150 unchanged lines hidden (view full) ---

159 .identity = "PIC32 Deadman Timer",
160};
161
162static struct watchdog_device pic32_dmt_wdd = {
163 .info = &pic32_dmt_ident,
164 .ops = &pic32_dmt_fops,
165};
166
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * PIC32 deadman timer driver
4 *
5 * Purna Chandra Mandal <purna.mandal@microchip.com>
6 * Copyright (c) 2016, Microchip Technology Inc.
7 */
8#include <linux/clk.h>

--- 150 unchanged lines hidden (view full) ---

159 .identity = "PIC32 Deadman Timer",
160};
161
162static struct watchdog_device pic32_dmt_wdd = {
163 .info = &pic32_dmt_ident,
164 .ops = &pic32_dmt_fops,
165};
166
167static void pic32_clk_disable_unprepare(void *data)
168{
169 clk_disable_unprepare(data);
170}
171
172static int pic32_dmt_probe(struct platform_device *pdev)
173{
174 struct device *dev = &pdev->dev;
175 int ret;
176 struct pic32_dmt *dmt;
177 struct watchdog_device *wdd = &pic32_dmt_wdd;
178
179 dmt = devm_kzalloc(dev, sizeof(*dmt), GFP_KERNEL);
180 if (!dmt)
181 return -ENOMEM;
182
183 dmt->regs = devm_platform_ioremap_resource(pdev, 0);
184 if (IS_ERR(dmt->regs))
185 return PTR_ERR(dmt->regs);
186
167static int pic32_dmt_probe(struct platform_device *pdev)
168{
169 struct device *dev = &pdev->dev;
170 int ret;
171 struct pic32_dmt *dmt;
172 struct watchdog_device *wdd = &pic32_dmt_wdd;
173
174 dmt = devm_kzalloc(dev, sizeof(*dmt), GFP_KERNEL);
175 if (!dmt)
176 return -ENOMEM;
177
178 dmt->regs = devm_platform_ioremap_resource(pdev, 0);
179 if (IS_ERR(dmt->regs))
180 return PTR_ERR(dmt->regs);
181
187 dmt->clk = devm_clk_get(dev, NULL);
182 dmt->clk = devm_clk_get_enabled(dev, NULL);
188 if (IS_ERR(dmt->clk)) {
189 dev_err(dev, "clk not found\n");
190 return PTR_ERR(dmt->clk);
191 }
192
183 if (IS_ERR(dmt->clk)) {
184 dev_err(dev, "clk not found\n");
185 return PTR_ERR(dmt->clk);
186 }
187
193 ret = clk_prepare_enable(dmt->clk);
194 if (ret)
195 return ret;
196 ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare,
197 dmt->clk);
198 if (ret)
199 return ret;
200
201 wdd->timeout = pic32_dmt_get_timeout_secs(dmt);
202 if (!wdd->timeout) {
203 dev_err(dev, "failed to read watchdog register timeout\n");
204 return -EINVAL;
205 }
206
207 dev_info(dev, "timeout %d\n", wdd->timeout);
208

--- 32 unchanged lines hidden ---
188 wdd->timeout = pic32_dmt_get_timeout_secs(dmt);
189 if (!wdd->timeout) {
190 dev_err(dev, "failed to read watchdog register timeout\n");
191 return -EINVAL;
192 }
193
194 dev_info(dev, "timeout %d\n", wdd->timeout);
195

--- 32 unchanged lines hidden ---