kernel: backport NVMEM changes queued for v6.8
[openwrt/staging/stintel.git] / target / linux / generic / backport-5.15 / 834-v6.8-0002-nvmem-Create-a-header-for-internal-sharing.patch
1 From ec9c08a1cb8dc5e8e003f95f5f62de41dde235bb Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Fri, 15 Dec 2023 11:15:29 +0000
4 Subject: [PATCH] nvmem: Create a header for internal sharing
5
6 Before adding all the NVMEM layout bus infrastructure to the core, let's
7 move the main nvmem_device structure in an internal header, only
8 available to the core. This way all the additional code can be added in
9 a dedicated file in order to keep the current core file tidy.
10
11 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
12 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
13 Link: https://lore.kernel.org/r/20231215111536.316972-4-srinivas.kandagatla@linaro.org
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 ---
16 drivers/nvmem/core.c | 24 +-----------------------
17 drivers/nvmem/internals.h | 35 +++++++++++++++++++++++++++++++++++
18 2 files changed, 36 insertions(+), 23 deletions(-)
19 create mode 100644 drivers/nvmem/internals.h
20
21 --- a/drivers/nvmem/core.c
22 +++ b/drivers/nvmem/core.c
23 @@ -20,29 +20,7 @@
24 #include <linux/of_device.h>
25 #include <linux/slab.h>
26
27 -struct nvmem_device {
28 - struct module *owner;
29 - struct device dev;
30 - int stride;
31 - int word_size;
32 - int id;
33 - struct kref refcnt;
34 - size_t size;
35 - bool read_only;
36 - bool root_only;
37 - int flags;
38 - enum nvmem_type type;
39 - struct bin_attribute eeprom;
40 - struct device *base_dev;
41 - struct list_head cells;
42 - const struct nvmem_keepout *keepout;
43 - unsigned int nkeepout;
44 - nvmem_reg_read_t reg_read;
45 - nvmem_reg_write_t reg_write;
46 - struct gpio_desc *wp_gpio;
47 - struct nvmem_layout *layout;
48 - void *priv;
49 -};
50 +#include "internals.h"
51
52 #define to_nvmem_device(d) container_of(d, struct nvmem_device, dev)
53
54 --- /dev/null
55 +++ b/drivers/nvmem/internals.h
56 @@ -0,0 +1,35 @@
57 +/* SPDX-License-Identifier: GPL-2.0 */
58 +
59 +#ifndef _LINUX_NVMEM_INTERNALS_H
60 +#define _LINUX_NVMEM_INTERNALS_H
61 +
62 +#include <linux/device.h>
63 +#include <linux/nvmem-consumer.h>
64 +#include <linux/nvmem-provider.h>
65 +
66 +struct nvmem_device {
67 + struct module *owner;
68 + struct device dev;
69 + struct list_head node;
70 + int stride;
71 + int word_size;
72 + int id;
73 + struct kref refcnt;
74 + size_t size;
75 + bool read_only;
76 + bool root_only;
77 + int flags;
78 + enum nvmem_type type;
79 + struct bin_attribute eeprom;
80 + struct device *base_dev;
81 + struct list_head cells;
82 + const struct nvmem_keepout *keepout;
83 + unsigned int nkeepout;
84 + nvmem_reg_read_t reg_read;
85 + nvmem_reg_write_t reg_write;
86 + struct gpio_desc *wp_gpio;
87 + struct nvmem_layout *layout;
88 + void *priv;
89 +};
90 +
91 +#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */