hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-efm32.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2014 Uwe Kleine-Koenig for Pengutronix
3
- *
4
- * This program is free software; you can redistribute it and/or modify it under
5
- * the terms of the GNU General Public License version 2 as published by the
6
- * Free Software Foundation.
74 */
85 #include <linux/module.h>
96 #include <linux/platform_device.h>
....@@ -315,9 +312,6 @@
315312 int ret;
316313 u32 clkdiv;
317314
318
- if (!np)
319
- return -EINVAL;
320
-
321315 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
322316 if (!ddata)
323317 return -ENOMEM;
....@@ -338,24 +332,17 @@
338332 return ret;
339333 }
340334
341
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
342
- if (!res) {
343
- dev_err(&pdev->dev, "failed to determine base address\n");
344
- return -ENODEV;
345
- }
335
+ ddata->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
336
+ if (IS_ERR(ddata->base))
337
+ return PTR_ERR(ddata->base);
346338
347339 if (resource_size(res) < 0x42) {
348340 dev_err(&pdev->dev, "memory resource too small\n");
349341 return -EINVAL;
350342 }
351343
352
- ddata->base = devm_ioremap_resource(&pdev->dev, res);
353
- if (IS_ERR(ddata->base))
354
- return PTR_ERR(ddata->base);
355
-
356344 ret = platform_get_irq(pdev, 0);
357345 if (ret <= 0) {
358
- dev_err(&pdev->dev, "failed to get irq (%d)\n", ret);
359346 if (!ret)
360347 ret = -EINVAL;
361348 return ret;
....@@ -391,7 +378,7 @@
391378 if (!ret) {
392379 dev_dbg(&pdev->dev, "using frequency %u\n", frequency);
393380 } else {
394
- frequency = 100000;
381
+ frequency = I2C_MAX_STANDARD_MODE_FREQ;
395382 dev_info(&pdev->dev, "defaulting to 100 kHz\n");
396383 }
397384 ddata->frequency = frequency;