Skip to content

Commit 8bd4da0

Browse files
committed
pstore/ram: Move internal definitions out of kernel-wide include
Most of the details of the ram backend are entirely internal to the backend itself. Leave only what is needed to instantiate a ram backend in the kernel-wide header. Cc: Anton Vorontsov <[email protected]> Cc: Colin Cross <[email protected]> Cc: Tony Luck <[email protected]> Signed-off-by: Kees Cook <[email protected]> Reviewed-and-tested-by: Guilherme G. Piccoli <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6daf4e8 commit 8bd4da0

File tree

4 files changed

+102
-101
lines changed

4 files changed

+102
-101
lines changed

fs/pstore/ram.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
#include <linux/platform_device.h>
1919
#include <linux/slab.h>
2020
#include <linux/compiler.h>
21-
#include <linux/pstore_ram.h>
2221
#include <linux/of.h>
2322
#include <linux/of_address.h>
23+
2424
#include "internal.h"
25+
#include "ram_internal.h"
2526

2627
#define RAMOOPS_KERNMSG_HDR "===="
2728
#define MIN_MEM_SIZE 4096UL

fs/pstore/ram_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
#include <linux/kernel.h>
1414
#include <linux/list.h>
1515
#include <linux/memblock.h>
16-
#include <linux/pstore_ram.h>
1716
#include <linux/rslib.h>
1817
#include <linux/slab.h>
1918
#include <linux/uaccess.h>
2019
#include <linux/vmalloc.h>
2120
#include <asm/page.h>
2221

22+
#include "ram_internal.h"
23+
2324
/**
2425
* struct persistent_ram_buffer - persistent circular RAM buffer
2526
*

fs/pstore/ram_internal.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2010 Marco Stornelli <[email protected]>
4+
* Copyright (C) 2011 Kees Cook <[email protected]>
5+
* Copyright (C) 2011 Google, Inc.
6+
*/
7+
8+
#include <linux/pstore_ram.h>
9+
10+
/*
11+
* Choose whether access to the RAM zone requires locking or not. If a zone
12+
* can be written to from different CPUs like with ftrace for example, then
13+
* PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
14+
*/
15+
#define PRZ_FLAG_NO_LOCK BIT(0)
16+
/*
17+
* If a PRZ should only have a single-boot lifetime, this marks it as
18+
* getting wiped after its contents get copied out after boot.
19+
*/
20+
#define PRZ_FLAG_ZAP_OLD BIT(1)
21+
22+
/**
23+
* struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
24+
* used as a pstore backend
25+
*
26+
* @paddr: physical address of the mapped RAM area
27+
* @size: size of mapping
28+
* @label: unique name of this PRZ
29+
* @type: frontend type for this PRZ
30+
* @flags: holds PRZ_FLAGS_* bits
31+
*
32+
* @buffer_lock:
33+
* locks access to @buffer "size" bytes and "start" offset
34+
* @buffer:
35+
* pointer to actual RAM area managed by this PRZ
36+
* @buffer_size:
37+
* bytes in @buffer->data (not including any trailing ECC bytes)
38+
*
39+
* @par_buffer:
40+
* pointer into @buffer->data containing ECC bytes for @buffer->data
41+
* @par_header:
42+
* pointer into @buffer->data containing ECC bytes for @buffer header
43+
* (i.e. all fields up to @data)
44+
* @rs_decoder:
45+
* RSLIB instance for doing ECC calculations
46+
* @corrected_bytes:
47+
* ECC corrected bytes accounting since boot
48+
* @bad_blocks:
49+
* ECC uncorrectable bytes accounting since boot
50+
* @ecc_info:
51+
* ECC configuration details
52+
*
53+
* @old_log:
54+
* saved copy of @buffer->data prior to most recent wipe
55+
* @old_log_size:
56+
* bytes contained in @old_log
57+
*
58+
*/
59+
struct persistent_ram_zone {
60+
phys_addr_t paddr;
61+
size_t size;
62+
void *vaddr;
63+
char *label;
64+
enum pstore_type_id type;
65+
u32 flags;
66+
67+
raw_spinlock_t buffer_lock;
68+
struct persistent_ram_buffer *buffer;
69+
size_t buffer_size;
70+
71+
char *par_buffer;
72+
char *par_header;
73+
struct rs_control *rs_decoder;
74+
int corrected_bytes;
75+
int bad_blocks;
76+
struct persistent_ram_ecc_info ecc_info;
77+
78+
char *old_log;
79+
size_t old_log_size;
80+
};
81+
82+
struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
83+
u32 sig, struct persistent_ram_ecc_info *ecc_info,
84+
unsigned int memtype, u32 flags, char *label);
85+
void persistent_ram_free(struct persistent_ram_zone *prz);
86+
void persistent_ram_zap(struct persistent_ram_zone *prz);
87+
88+
int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
89+
unsigned int count);
90+
int persistent_ram_write_user(struct persistent_ram_zone *prz,
91+
const void __user *s, unsigned int count);
92+
93+
void persistent_ram_save_old(struct persistent_ram_zone *prz);
94+
size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
95+
void *persistent_ram_old(struct persistent_ram_zone *prz);
96+
void persistent_ram_free_old(struct persistent_ram_zone *prz);
97+
ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
98+
char *str, size_t len);

include/linux/pstore_ram.h

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,7 @@
88
#ifndef __LINUX_PSTORE_RAM_H__
99
#define __LINUX_PSTORE_RAM_H__
1010

11-
#include <linux/compiler.h>
12-
#include <linux/device.h>
13-
#include <linux/init.h>
14-
#include <linux/kernel.h>
15-
#include <linux/list.h>
1611
#include <linux/pstore.h>
17-
#include <linux/types.h>
18-
19-
/*
20-
* Choose whether access to the RAM zone requires locking or not. If a zone
21-
* can be written to from different CPUs like with ftrace for example, then
22-
* PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
23-
*/
24-
#define PRZ_FLAG_NO_LOCK BIT(0)
25-
/*
26-
* If a PRZ should only have a single-boot lifetime, this marks it as
27-
* getting wiped after its contents get copied out after boot.
28-
*/
29-
#define PRZ_FLAG_ZAP_OLD BIT(1)
30-
31-
struct persistent_ram_buffer;
32-
struct rs_control;
3312

3413
struct persistent_ram_ecc_info {
3514
int block_size;
@@ -39,84 +18,6 @@ struct persistent_ram_ecc_info {
3918
uint16_t *par;
4019
};
4120

42-
/**
43-
* struct persistent_ram_zone - Details of a persistent RAM zone (PRZ)
44-
* used as a pstore backend
45-
*
46-
* @paddr: physical address of the mapped RAM area
47-
* @size: size of mapping
48-
* @label: unique name of this PRZ
49-
* @type: frontend type for this PRZ
50-
* @flags: holds PRZ_FLAGS_* bits
51-
*
52-
* @buffer_lock:
53-
* locks access to @buffer "size" bytes and "start" offset
54-
* @buffer:
55-
* pointer to actual RAM area managed by this PRZ
56-
* @buffer_size:
57-
* bytes in @buffer->data (not including any trailing ECC bytes)
58-
*
59-
* @par_buffer:
60-
* pointer into @buffer->data containing ECC bytes for @buffer->data
61-
* @par_header:
62-
* pointer into @buffer->data containing ECC bytes for @buffer header
63-
* (i.e. all fields up to @data)
64-
* @rs_decoder:
65-
* RSLIB instance for doing ECC calculations
66-
* @corrected_bytes:
67-
* ECC corrected bytes accounting since boot
68-
* @bad_blocks:
69-
* ECC uncorrectable bytes accounting since boot
70-
* @ecc_info:
71-
* ECC configuration details
72-
*
73-
* @old_log:
74-
* saved copy of @buffer->data prior to most recent wipe
75-
* @old_log_size:
76-
* bytes contained in @old_log
77-
*
78-
*/
79-
struct persistent_ram_zone {
80-
phys_addr_t paddr;
81-
size_t size;
82-
void *vaddr;
83-
char *label;
84-
enum pstore_type_id type;
85-
u32 flags;
86-
87-
raw_spinlock_t buffer_lock;
88-
struct persistent_ram_buffer *buffer;
89-
size_t buffer_size;
90-
91-
char *par_buffer;
92-
char *par_header;
93-
struct rs_control *rs_decoder;
94-
int corrected_bytes;
95-
int bad_blocks;
96-
struct persistent_ram_ecc_info ecc_info;
97-
98-
char *old_log;
99-
size_t old_log_size;
100-
};
101-
102-
struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
103-
u32 sig, struct persistent_ram_ecc_info *ecc_info,
104-
unsigned int memtype, u32 flags, char *label);
105-
void persistent_ram_free(struct persistent_ram_zone *prz);
106-
void persistent_ram_zap(struct persistent_ram_zone *prz);
107-
108-
int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
109-
unsigned int count);
110-
int persistent_ram_write_user(struct persistent_ram_zone *prz,
111-
const void __user *s, unsigned int count);
112-
113-
void persistent_ram_save_old(struct persistent_ram_zone *prz);
114-
size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
115-
void *persistent_ram_old(struct persistent_ram_zone *prz);
116-
void persistent_ram_free_old(struct persistent_ram_zone *prz);
117-
ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
118-
char *str, size_t len);
119-
12021
/*
12122
* Ramoops platform data
12223
* @mem_size memory size for ramoops

0 commit comments

Comments
 (0)