hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-pcf8523.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * 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.
74 */
85
96 #include <linux/bcd.h>
....@@ -37,10 +34,6 @@
3734
3835 #define REG_OFFSET 0x0e
3936 #define REG_OFFSET_MODE BIT(7)
40
-
41
-struct pcf8523 {
42
- struct rtc_device *rtc;
43
-};
4437
4538 static int pcf8523_read(struct i2c_client *client, u8 reg, u8 *valuep)
4639 {
....@@ -115,7 +108,7 @@
115108 default:
116109 dev_warn(&client->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 12500",
117110 load);
118
- /* fall through */
111
+ fallthrough;
119112 case 12500:
120113 value |= REG_CONTROL1_CAP_SEL;
121114 break;
....@@ -289,11 +282,11 @@
289282 ret = pcf8523_voltage_low(client);
290283 if (ret < 0)
291284 return ret;
285
+ if (ret)
286
+ ret = RTC_VL_BACKUP_LOW;
292287
293
- if (copy_to_user((void __user *)arg, &ret, sizeof(int)))
294
- return -EFAULT;
288
+ return put_user(ret, (unsigned int __user *)arg);
295289
296
- return 0;
297290 default:
298291 return -ENOIOCTLCMD;
299292 }
....@@ -348,15 +341,11 @@
348341 static int pcf8523_probe(struct i2c_client *client,
349342 const struct i2c_device_id *id)
350343 {
351
- struct pcf8523 *pcf;
344
+ struct rtc_device *rtc;
352345 int err;
353346
354347 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
355348 return -ENODEV;
356
-
357
- pcf = devm_kzalloc(&client->dev, sizeof(*pcf), GFP_KERNEL);
358
- if (!pcf)
359
- return -ENOMEM;
360349
361350 err = pcf8523_load_capacitance(client);
362351 if (err < 0)
....@@ -367,12 +356,10 @@
367356 if (err < 0)
368357 return err;
369358
370
- pcf->rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
359
+ rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
371360 &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);
376363
377364 return 0;
378365 }
....@@ -386,6 +373,7 @@
386373 #ifdef CONFIG_OF
387374 static const struct of_device_id pcf8523_of_match[] = {
388375 { .compatible = "nxp,pcf8523" },
376
+ { .compatible = "microcrystal,rv8523" },
389377 { }
390378 };
391379 MODULE_DEVICE_TABLE(of, pcf8523_of_match);