| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2012 Avionic Design GmbH |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 6 | | - * published by the Free Software Foundation. |
|---|
| 7 | 4 | */ |
|---|
| 8 | 5 | |
|---|
| 9 | 6 | #include <linux/bcd.h> |
|---|
| .. | .. |
|---|
| 37 | 34 | |
|---|
| 38 | 35 | #define REG_OFFSET 0x0e |
|---|
| 39 | 36 | #define REG_OFFSET_MODE BIT(7) |
|---|
| 40 | | - |
|---|
| 41 | | -struct pcf8523 { |
|---|
| 42 | | - struct rtc_device *rtc; |
|---|
| 43 | | -}; |
|---|
| 44 | 37 | |
|---|
| 45 | 38 | static int pcf8523_read(struct i2c_client *client, u8 reg, u8 *valuep) |
|---|
| 46 | 39 | { |
|---|
| .. | .. |
|---|
| 115 | 108 | default: |
|---|
| 116 | 109 | dev_warn(&client->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 12500", |
|---|
| 117 | 110 | load); |
|---|
| 118 | | - /* fall through */ |
|---|
| 111 | + fallthrough; |
|---|
| 119 | 112 | case 12500: |
|---|
| 120 | 113 | value |= REG_CONTROL1_CAP_SEL; |
|---|
| 121 | 114 | break; |
|---|
| .. | .. |
|---|
| 289 | 282 | ret = pcf8523_voltage_low(client); |
|---|
| 290 | 283 | if (ret < 0) |
|---|
| 291 | 284 | return ret; |
|---|
| 285 | + if (ret) |
|---|
| 286 | + ret = RTC_VL_BACKUP_LOW; |
|---|
| 292 | 287 | |
|---|
| 293 | | - if (copy_to_user((void __user *)arg, &ret, sizeof(int))) |
|---|
| 294 | | - return -EFAULT; |
|---|
| 288 | + return put_user(ret, (unsigned int __user *)arg); |
|---|
| 295 | 289 | |
|---|
| 296 | | - return 0; |
|---|
| 297 | 290 | default: |
|---|
| 298 | 291 | return -ENOIOCTLCMD; |
|---|
| 299 | 292 | } |
|---|
| .. | .. |
|---|
| 348 | 341 | static int pcf8523_probe(struct i2c_client *client, |
|---|
| 349 | 342 | const struct i2c_device_id *id) |
|---|
| 350 | 343 | { |
|---|
| 351 | | - struct pcf8523 *pcf; |
|---|
| 344 | + struct rtc_device *rtc; |
|---|
| 352 | 345 | int err; |
|---|
| 353 | 346 | |
|---|
| 354 | 347 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
|---|
| 355 | 348 | return -ENODEV; |
|---|
| 356 | | - |
|---|
| 357 | | - pcf = devm_kzalloc(&client->dev, sizeof(*pcf), GFP_KERNEL); |
|---|
| 358 | | - if (!pcf) |
|---|
| 359 | | - return -ENOMEM; |
|---|
| 360 | 349 | |
|---|
| 361 | 350 | err = pcf8523_load_capacitance(client); |
|---|
| 362 | 351 | if (err < 0) |
|---|
| .. | .. |
|---|
| 367 | 356 | if (err < 0) |
|---|
| 368 | 357 | return err; |
|---|
| 369 | 358 | |
|---|
| 370 | | - pcf->rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME, |
|---|
| 359 | + rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME, |
|---|
| 371 | 360 | &pcf8523_rtc_ops, THIS_MODULE); |
|---|
| 372 | | - if (IS_ERR(pcf->rtc)) |
|---|
| 373 | | - return PTR_ERR(pcf->rtc); |
|---|
| 374 | | - |
|---|
| 375 | | - i2c_set_clientdata(client, pcf); |
|---|
| 361 | + if (IS_ERR(rtc)) |
|---|
| 362 | + return PTR_ERR(rtc); |
|---|
| 376 | 363 | |
|---|
| 377 | 364 | return 0; |
|---|
| 378 | 365 | } |
|---|
| .. | .. |
|---|
| 386 | 373 | #ifdef CONFIG_OF |
|---|
| 387 | 374 | static const struct of_device_id pcf8523_of_match[] = { |
|---|
| 388 | 375 | { .compatible = "nxp,pcf8523" }, |
|---|
| 376 | + { .compatible = "microcrystal,rv8523" }, |
|---|
| 389 | 377 | { } |
|---|
| 390 | 378 | }; |
|---|
| 391 | 379 | MODULE_DEVICE_TABLE(of, pcf8523_of_match); |
|---|