1 // SPDX-License-Identifier: GPL-2.0-only
3 * Thomas Horsten <thh@lasat.com>
4 * Copyright (C) 2000 LASAT Networks A/S.
6 * Routines specific to the LASAT boards
8 #include <linux/types.h>
9 #include <asm/lasat/lasat.h>
11 #include <linux/sysctl.h>
12 #include <linux/stddef.h>
13 #include <linux/init.h>
15 #include <linux/ctype.h>
16 #include <linux/string.h>
17 #include <linux/net.h>
18 #include <linux/inet.h>
19 #include <linux/uaccess.h>
28 /* And the same for proc */
29 int proc_dolasatstring(struct ctl_table
*table
, int write
,
30 void *buffer
, size_t *lenp
, loff_t
*ppos
)
34 r
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
38 lasat_write_eeprom_info();
46 /* proc function to read/write RealTime Clock */
47 int proc_dolasatrtc(struct ctl_table
*table
, int write
,
48 void *buffer
, size_t *lenp
, loff_t
*ppos
)
54 read_persistent_clock64(&ts
);
56 /* check for time < 0 and set to 0 */
60 r
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
66 * Due to the RTC hardware limitation, we can not actually
67 * use the full 64-bit range here.
72 update_persistent_clock64(ts
);
80 int proc_lasat_ip(struct ctl_table
*table
, int write
,
81 void *buffer
, size_t *lenp
, loff_t
*ppos
)
88 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
100 if (c
== 0 || c
== '\n')
104 if (len
>= sizeof(ipbuf
)-1)
105 len
= sizeof(ipbuf
) - 1;
106 if (copy_from_user(ipbuf
, buffer
, len
))
110 /* Now see if we can convert it to a valid IP */
112 *(unsigned int *)(table
->data
) = ip
;
113 lasat_write_eeprom_info();
115 ip
= *(unsigned int *)(table
->data
);
116 sprintf(ipbuf
, "%d.%d.%d.%d",
125 if (copy_to_user(buffer
, ipbuf
, len
))
128 if (put_user('\n', ((char *) buffer
) + len
))
140 int proc_lasat_prid(struct ctl_table
*table
, int write
,
141 void *buffer
, size_t *lenp
, loff_t
*ppos
)
145 r
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
149 lasat_board_info
.li_eeprom_info
.prid
=
150 lasat_board_info
.li_prid
;
151 lasat_write_eeprom_info();
152 lasat_init_board_info();
157 extern int lasat_boot_to_service
;
159 static struct ctl_table lasat_table
[] = {
161 .procname
= "cpu-hz",
162 .data
= &lasat_board_info
.li_cpu_hz
,
163 .maxlen
= sizeof(int),
165 .proc_handler
= proc_dointvec
,
168 .procname
= "bus-hz",
169 .data
= &lasat_board_info
.li_bus_hz
,
170 .maxlen
= sizeof(int),
172 .proc_handler
= proc_dointvec
,
176 .data
= &lasat_board_info
.li_bmid
,
177 .maxlen
= sizeof(int),
179 .proc_handler
= proc_dointvec
,
183 .data
= &lasat_board_info
.li_prid
,
184 .maxlen
= sizeof(int),
186 .proc_handler
= proc_lasat_prid
,
190 .procname
= "ipaddr",
191 .data
= &lasat_board_info
.li_eeprom_info
.ipaddr
,
192 .maxlen
= sizeof(int),
194 .proc_handler
= proc_lasat_ip
,
197 .procname
= "netmask",
198 .data
= &lasat_board_info
.li_eeprom_info
.netmask
,
199 .maxlen
= sizeof(int),
201 .proc_handler
= proc_lasat_ip
,
205 .procname
= "passwd_hash",
206 .data
= &lasat_board_info
.li_eeprom_info
.passwd_hash
,
208 sizeof(lasat_board_info
.li_eeprom_info
.passwd_hash
),
210 .proc_handler
= proc_dolasatstring
,
213 .procname
= "boot-service",
214 .data
= &lasat_boot_to_service
,
215 .maxlen
= sizeof(int),
217 .proc_handler
= proc_dointvec
,
223 .maxlen
= sizeof(int),
225 .proc_handler
= proc_dolasatrtc
,
229 .procname
= "namestr",
230 .data
= &lasat_board_info
.li_namestr
,
231 .maxlen
= sizeof(lasat_board_info
.li_namestr
),
233 .proc_handler
= proc_dostring
,
236 .procname
= "typestr",
237 .data
= &lasat_board_info
.li_typestr
,
238 .maxlen
= sizeof(lasat_board_info
.li_typestr
),
240 .proc_handler
= proc_dostring
,
245 static struct ctl_table lasat_root_table
[] = {
254 static int __init
lasat_register_sysctl(void)
256 struct ctl_table_header
*lasat_table_header
;
259 register_sysctl_table(lasat_root_table
);
260 if (!lasat_table_header
) {
261 printk(KERN_ERR
"Unable to register LASAT sysctl\n");
268 arch_initcall(lasat_register_sysctl
);