.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * at25.c -- support most SPI EEPROMs, such as Atmel AT25 models |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/kernel.h> |
---|
.. | .. |
---|
94 | 90 | switch (at25->addrlen) { |
---|
95 | 91 | default: /* case 3 */ |
---|
96 | 92 | *cp++ = offset >> 16; |
---|
97 | | - /* fall through */ |
---|
| 93 | + fallthrough; |
---|
98 | 94 | case 2: |
---|
99 | 95 | *cp++ = offset >> 8; |
---|
100 | | - /* fall through */ |
---|
| 96 | + fallthrough; |
---|
101 | 97 | case 1: |
---|
102 | 98 | case 0: /* can't happen: for better codegen */ |
---|
103 | 99 | *cp++ = offset >> 0; |
---|
.. | .. |
---|
182 | 178 | switch (at25->addrlen) { |
---|
183 | 179 | default: /* case 3 */ |
---|
184 | 180 | *cp++ = offset >> 16; |
---|
185 | | - /* fall through */ |
---|
| 181 | + fallthrough; |
---|
186 | 182 | case 2: |
---|
187 | 183 | *cp++ = offset >> 8; |
---|
188 | | - /* fall through */ |
---|
| 184 | + fallthrough; |
---|
189 | 185 | case 1: |
---|
190 | 186 | case 0: /* can't happen: for better codegen */ |
---|
191 | 187 | *cp++ = offset >> 0; |
---|
.. | .. |
---|
265 | 261 | |
---|
266 | 262 | if (device_property_read_u32(dev, "pagesize", &val) == 0 || |
---|
267 | 263 | device_property_read_u32(dev, "at25,page-size", &val) == 0) { |
---|
268 | | - chip->page_size = (u16)val; |
---|
| 264 | + chip->page_size = val; |
---|
269 | 265 | } else { |
---|
270 | 266 | dev_err(dev, "Error: missing \"pagesize\" property\n"); |
---|
271 | 267 | return -ENODEV; |
---|
.. | .. |
---|
282 | 278 | switch (val) { |
---|
283 | 279 | case 9: |
---|
284 | 280 | chip->flags |= EE_INSTR_BIT3_IS_ADDR; |
---|
285 | | - /* fall through */ |
---|
| 281 | + fallthrough; |
---|
286 | 282 | case 8: |
---|
287 | 283 | chip->flags |= EE_ADDR1; |
---|
288 | 284 | break; |
---|
.. | .. |
---|
352 | 348 | spi_set_drvdata(spi, at25); |
---|
353 | 349 | at25->addrlen = addrlen; |
---|
354 | 350 | |
---|
| 351 | + at25->nvmem_config.type = NVMEM_TYPE_EEPROM; |
---|
355 | 352 | at25->nvmem_config.name = dev_name(&spi->dev); |
---|
356 | 353 | at25->nvmem_config.dev = &spi->dev; |
---|
357 | 354 | at25->nvmem_config.read_only = chip.flags & EE_READONLY; |
---|
.. | .. |
---|
366 | 363 | at25->nvmem_config.word_size = 1; |
---|
367 | 364 | at25->nvmem_config.size = chip.byte_len; |
---|
368 | 365 | |
---|
369 | | - at25->nvmem = nvmem_register(&at25->nvmem_config); |
---|
| 366 | + at25->nvmem = devm_nvmem_register(&spi->dev, &at25->nvmem_config); |
---|
370 | 367 | if (IS_ERR(at25->nvmem)) |
---|
371 | 368 | return PTR_ERR(at25->nvmem); |
---|
372 | 369 | |
---|
.. | .. |
---|
376 | 373 | at25->chip.name, |
---|
377 | 374 | (chip.flags & EE_READONLY) ? " (readonly)" : "", |
---|
378 | 375 | 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 | | - |
---|
389 | 376 | return 0; |
---|
390 | 377 | } |
---|
391 | 378 | |
---|
.. | .. |
---|
403 | 390 | .of_match_table = at25_of_match, |
---|
404 | 391 | }, |
---|
405 | 392 | .probe = at25_probe, |
---|
406 | | - .remove = at25_remove, |
---|
407 | 393 | }; |
---|
408 | 394 | |
---|
409 | 395 | module_spi_driver(at25_driver); |
---|