| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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. |
|---|
| 7 | 4 | */ |
|---|
| 8 | 5 | #include <linux/module.h> |
|---|
| 9 | 6 | #include <linux/platform_device.h> |
|---|
| .. | .. |
|---|
| 315 | 312 | int ret; |
|---|
| 316 | 313 | u32 clkdiv; |
|---|
| 317 | 314 | |
|---|
| 318 | | - if (!np) |
|---|
| 319 | | - return -EINVAL; |
|---|
| 320 | | - |
|---|
| 321 | 315 | ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); |
|---|
| 322 | 316 | if (!ddata) |
|---|
| 323 | 317 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 338 | 332 | return ret; |
|---|
| 339 | 333 | } |
|---|
| 340 | 334 | |
|---|
| 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); |
|---|
| 346 | 338 | |
|---|
| 347 | 339 | if (resource_size(res) < 0x42) { |
|---|
| 348 | 340 | dev_err(&pdev->dev, "memory resource too small\n"); |
|---|
| 349 | 341 | return -EINVAL; |
|---|
| 350 | 342 | } |
|---|
| 351 | 343 | |
|---|
| 352 | | - ddata->base = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 353 | | - if (IS_ERR(ddata->base)) |
|---|
| 354 | | - return PTR_ERR(ddata->base); |
|---|
| 355 | | - |
|---|
| 356 | 344 | ret = platform_get_irq(pdev, 0); |
|---|
| 357 | 345 | if (ret <= 0) { |
|---|
| 358 | | - dev_err(&pdev->dev, "failed to get irq (%d)\n", ret); |
|---|
| 359 | 346 | if (!ret) |
|---|
| 360 | 347 | ret = -EINVAL; |
|---|
| 361 | 348 | return ret; |
|---|
| .. | .. |
|---|
| 391 | 378 | if (!ret) { |
|---|
| 392 | 379 | dev_dbg(&pdev->dev, "using frequency %u\n", frequency); |
|---|
| 393 | 380 | } else { |
|---|
| 394 | | - frequency = 100000; |
|---|
| 381 | + frequency = I2C_MAX_STANDARD_MODE_FREQ; |
|---|
| 395 | 382 | dev_info(&pdev->dev, "defaulting to 100 kHz\n"); |
|---|
| 396 | 383 | } |
|---|
| 397 | 384 | ddata->frequency = frequency; |
|---|