forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/misc/eeprom/at25.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * at25.c -- support most SPI EEPROMs, such as Atmel AT25 models
34 *
45 * Copyright (C) 2006 David Brownell
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/kernel.h>
....@@ -94,10 +90,10 @@
9490 switch (at25->addrlen) {
9591 default: /* case 3 */
9692 *cp++ = offset >> 16;
97
- /* fall through */
93
+ fallthrough;
9894 case 2:
9995 *cp++ = offset >> 8;
100
- /* fall through */
96
+ fallthrough;
10197 case 1:
10298 case 0: /* can't happen: for better codegen */
10399 *cp++ = offset >> 0;
....@@ -182,10 +178,10 @@
182178 switch (at25->addrlen) {
183179 default: /* case 3 */
184180 *cp++ = offset >> 16;
185
- /* fall through */
181
+ fallthrough;
186182 case 2:
187183 *cp++ = offset >> 8;
188
- /* fall through */
184
+ fallthrough;
189185 case 1:
190186 case 0: /* can't happen: for better codegen */
191187 *cp++ = offset >> 0;
....@@ -265,7 +261,7 @@
265261
266262 if (device_property_read_u32(dev, "pagesize", &val) == 0 ||
267263 device_property_read_u32(dev, "at25,page-size", &val) == 0) {
268
- chip->page_size = (u16)val;
264
+ chip->page_size = val;
269265 } else {
270266 dev_err(dev, "Error: missing \"pagesize\" property\n");
271267 return -ENODEV;
....@@ -282,7 +278,7 @@
282278 switch (val) {
283279 case 9:
284280 chip->flags |= EE_INSTR_BIT3_IS_ADDR;
285
- /* fall through */
281
+ fallthrough;
286282 case 8:
287283 chip->flags |= EE_ADDR1;
288284 break;
....@@ -352,6 +348,7 @@
352348 spi_set_drvdata(spi, at25);
353349 at25->addrlen = addrlen;
354350
351
+ at25->nvmem_config.type = NVMEM_TYPE_EEPROM;
355352 at25->nvmem_config.name = dev_name(&spi->dev);
356353 at25->nvmem_config.dev = &spi->dev;
357354 at25->nvmem_config.read_only = chip.flags & EE_READONLY;
....@@ -366,7 +363,7 @@
366363 at25->nvmem_config.word_size = 1;
367364 at25->nvmem_config.size = chip.byte_len;
368365
369
- at25->nvmem = nvmem_register(&at25->nvmem_config);
366
+ at25->nvmem = devm_nvmem_register(&spi->dev, &at25->nvmem_config);
370367 if (IS_ERR(at25->nvmem))
371368 return PTR_ERR(at25->nvmem);
372369
....@@ -376,16 +373,6 @@
376373 at25->chip.name,
377374 (chip.flags & EE_READONLY) ? " (readonly)" : "",
378375 at25->chip.page_size);
379
- return 0;
380
-}
381
-
382
-static int at25_remove(struct spi_device *spi)
383
-{
384
- struct at25_data *at25;
385
-
386
- at25 = spi_get_drvdata(spi);
387
- nvmem_unregister(at25->nvmem);
388
-
389376 return 0;
390377 }
391378
....@@ -403,7 +390,6 @@
403390 .of_match_table = at25_of_match,
404391 },
405392 .probe = at25_probe,
406
- .remove = at25_remove,
407393 };
408394
409395 module_spi_driver(at25_driver);