salinfo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * salinfo.c
  3. *
  4. * Creates entries in /proc/sal for various system features.
  5. *
  6. * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
  7. * Copyright (c) 2003 Hewlett-Packard Co
  8. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  9. *
  10. * 10/30/2001 jbarnes@sgi.com copied much of Stephane's palinfo
  11. * code to create this file
  12. * Oct 23 2003 kaos@sgi.com
  13. * Replace IPI with set_cpus_allowed() to read a record from the required cpu.
  14. * Redesign salinfo log processing to separate interrupt and user space
  15. * contexts.
  16. * Cache the record across multi-block reads from user space.
  17. * Support > 64 cpus.
  18. * Delete module_exit and MOD_INC/DEC_COUNT, salinfo cannot be a module.
  19. *
  20. * Jan 28 2004 kaos@sgi.com
  21. * Periodically check for outstanding MCA or INIT records.
  22. *
  23. * Dec 5 2004 kaos@sgi.com
  24. * Standardize which records are cleared automatically.
  25. *
  26. * Aug 18 2005 kaos@sgi.com
  27. * mca.c may not pass a buffer, a NULL buffer just indicates that a new
  28. * record is available in SAL.
  29. * Replace some NR_CPUS by cpus_online, for hotplug cpu.
  30. */
  31. #include <linux/types.h>
  32. #include <linux/proc_fs.h>
  33. #include <linux/module.h>
  34. #include <linux/smp.h>
  35. #include <linux/smp_lock.h>
  36. #include <linux/timer.h>
  37. #include <linux/vmalloc.h>
  38. #include <asm/semaphore.h>
  39. #include <asm/sal.h>
  40. #include <asm/uaccess.h>
  41. MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
  42. MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
  43. MODULE_LICENSE("GPL");
  44. static int salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data);
  45. typedef struct {
  46. const char *name; /* name of the proc entry */
  47. unsigned long feature; /* feature bit */
  48. struct proc_dir_entry *entry; /* registered entry (removal) */
  49. } salinfo_entry_t;
  50. /*
  51. * List {name,feature} pairs for every entry in /proc/sal/<feature>
  52. * that this module exports
  53. */
  54. static salinfo_entry_t salinfo_entries[]={
  55. { "bus_lock", IA64_SAL_PLATFORM_FEATURE_BUS_LOCK, },
  56. { "irq_redirection", IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT, },
  57. { "ipi_redirection", IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT, },
  58. { "itc_drift", IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT, },
  59. };
  60. #define NR_SALINFO_ENTRIES ARRAY_SIZE(salinfo_entries)
  61. static char *salinfo_log_name[] = {
  62. "mca",
  63. "init",
  64. "cmc",
  65. "cpe",
  66. };
  67. static struct proc_dir_entry *salinfo_proc_entries[
  68. ARRAY_SIZE(salinfo_entries) + /* /proc/sal/bus_lock */
  69. ARRAY_SIZE(salinfo_log_name) + /* /proc/sal/{mca,...} */
  70. (2 * ARRAY_SIZE(salinfo_log_name)) + /* /proc/sal/mca/{event,data} */
  71. 1]; /* /proc/sal */
  72. /* Some records we get ourselves, some are accessed as saved data in buffers
  73. * that are owned by mca.c.
  74. */
  75. struct salinfo_data_saved {
  76. u8* buffer;
  77. u64 size;
  78. u64 id;
  79. int cpu;
  80. };
  81. /* State transitions. Actions are :-
  82. * Write "read <cpunum>" to the data file.
  83. * Write "clear <cpunum>" to the data file.
  84. * Write "oemdata <cpunum> <offset> to the data file.
  85. * Read from the data file.
  86. * Close the data file.
  87. *
  88. * Start state is NO_DATA.
  89. *
  90. * NO_DATA
  91. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  92. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  93. * write "oemdata <cpunum> <offset> -> return -EINVAL.
  94. * read data -> return EOF.
  95. * close -> unchanged. Free record areas.
  96. *
  97. * LOG_RECORD
  98. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  99. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  100. * write "oemdata <cpunum> <offset> -> format the oem data, goto OEMDATA.
  101. * read data -> return the INIT/MCA/CMC/CPE record.
  102. * close -> unchanged. Keep record areas.
  103. *
  104. * OEMDATA
  105. * write "read <cpunum>" -> NO_DATA or LOG_RECORD.
  106. * write "clear <cpunum>" -> NO_DATA or LOG_RECORD.
  107. * write "oemdata <cpunum> <offset> -> format the oem data, goto OEMDATA.
  108. * read data -> return the formatted oemdata.
  109. * close -> unchanged. Keep record areas.
  110. *
  111. * Closing the data file does not change the state. This allows shell scripts
  112. * to manipulate salinfo data, each shell redirection opens the file, does one
  113. * action then closes it again. The record areas are only freed at close when
  114. * the state is NO_DATA.
  115. */
  116. enum salinfo_state {
  117. STATE_NO_DATA,
  118. STATE_LOG_RECORD,
  119. STATE_OEMDATA,
  120. };
  121. struct salinfo_data {
  122. volatile cpumask_t cpu_event; /* which cpus have outstanding events */
  123. struct semaphore sem; /* count of cpus with outstanding events (bits set in cpu_event) */
  124. u8 *log_buffer;
  125. u64 log_size;
  126. u8 *oemdata; /* decoded oem data */
  127. u64 oemdata_size;
  128. int open; /* single-open to prevent races */
  129. u8 type;
  130. u8 saved_num; /* using a saved record? */
  131. enum salinfo_state state :8; /* processing state */
  132. u8 padding;
  133. int cpu_check; /* next CPU to check */
  134. struct salinfo_data_saved data_saved[5];/* save last 5 records from mca.c, must be < 255 */
  135. };
  136. static struct salinfo_data salinfo_data[ARRAY_SIZE(salinfo_log_name)];
  137. static DEFINE_SPINLOCK(data_lock);
  138. static DEFINE_SPINLOCK(data_saved_lock);
  139. /** salinfo_platform_oemdata - optional callback to decode oemdata from an error
  140. * record.
  141. * @sect_header: pointer to the start of the section to decode.
  142. * @oemdata: returns vmalloc area containing the decded output.
  143. * @oemdata_size: returns length of decoded output (strlen).
  144. *
  145. * Description: If user space asks for oem data to be decoded by the kernel
  146. * and/or prom and the platform has set salinfo_platform_oemdata to the address
  147. * of a platform specific routine then call that routine. salinfo_platform_oemdata
  148. * vmalloc's and formats its output area, returning the address of the text
  149. * and its strlen. Returns 0 for success, -ve for error. The callback is
  150. * invoked on the cpu that generated the error record.
  151. */
  152. int (*salinfo_platform_oemdata)(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size);
  153. struct salinfo_platform_oemdata_parms {
  154. const u8 *efi_guid;
  155. u8 **oemdata;
  156. u64 *oemdata_size;
  157. int ret;
  158. };
  159. static void
  160. salinfo_platform_oemdata_cpu(void *context)
  161. {
  162. struct salinfo_platform_oemdata_parms *parms = context;
  163. parms->ret = salinfo_platform_oemdata(parms->efi_guid, parms->oemdata, parms->oemdata_size);
  164. }
  165. static void
  166. shift1_data_saved (struct salinfo_data *data, int shift)
  167. {
  168. memcpy(data->data_saved+shift, data->data_saved+shift+1,
  169. (ARRAY_SIZE(data->data_saved) - (shift+1)) * sizeof(data->data_saved[0]));
  170. memset(data->data_saved + ARRAY_SIZE(data->data_saved) - 1, 0,
  171. sizeof(data->data_saved[0]));
  172. }
  173. /* This routine is invoked in interrupt context. Note: mca.c enables
  174. * interrupts before calling this code for CMC/CPE. MCA and INIT events are
  175. * not irq safe, do not call any routines that use spinlocks, they may deadlock.
  176. * MCA and INIT records are recorded, a timer event will look for any
  177. * outstanding events and wake up the user space code.
  178. *
  179. * The buffer passed from mca.c points to the output from ia64_log_get. This is
  180. * a persistent buffer but its contents can change between the interrupt and
  181. * when user space processes the record. Save the record id to identify
  182. * changes. If the buffer is NULL then just update the bitmap.
  183. */
  184. void
  185. salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe)
  186. {
  187. struct salinfo_data *data = salinfo_data + type;
  188. struct salinfo_data_saved *data_saved;
  189. unsigned long flags = 0;
  190. int i;
  191. int saved_size = ARRAY_SIZE(data->data_saved);
  192. BUG_ON(type >= ARRAY_SIZE(salinfo_log_name));
  193. if (buffer) {
  194. if (irqsafe)
  195. spin_lock_irqsave(&data_saved_lock, flags);
  196. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  197. if (!data_saved->buffer)
  198. break;
  199. }
  200. if (i == saved_size) {
  201. if (!data->saved_num) {
  202. shift1_data_saved(data, 0);
  203. data_saved = data->data_saved + saved_size - 1;
  204. } else
  205. data_saved = NULL;
  206. }
  207. if (data_saved) {
  208. data_saved->cpu = smp_processor_id();
  209. data_saved->id = ((sal_log_record_header_t *)buffer)->id;
  210. data_saved->size = size;
  211. data_saved->buffer = buffer;
  212. }
  213. if (irqsafe)
  214. spin_unlock_irqrestore(&data_saved_lock, flags);
  215. }
  216. if (!test_and_set_bit(smp_processor_id(), &data->cpu_event)) {
  217. if (irqsafe)
  218. up(&data->sem);
  219. }
  220. }
  221. /* Check for outstanding MCA/INIT records every minute (arbitrary) */
  222. #define SALINFO_TIMER_DELAY (60*HZ)
  223. static struct timer_list salinfo_timer;
  224. static void
  225. salinfo_timeout_check(struct salinfo_data *data)
  226. {
  227. int i;
  228. if (!data->open)
  229. return;
  230. for_each_online_cpu(i) {
  231. if (test_bit(i, &data->cpu_event)) {
  232. /* double up() is not a problem, user space will see no
  233. * records for the additional "events".
  234. */
  235. up(&data->sem);
  236. }
  237. }
  238. }
  239. static void
  240. salinfo_timeout (unsigned long arg)
  241. {
  242. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA);
  243. salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_INIT);
  244. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  245. add_timer(&salinfo_timer);
  246. }
  247. static int
  248. salinfo_event_open(struct inode *inode, struct file *file)
  249. {
  250. if (!capable(CAP_SYS_ADMIN))
  251. return -EPERM;
  252. return 0;
  253. }
  254. static ssize_t
  255. salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  256. {
  257. struct inode *inode = file->f_dentry->d_inode;
  258. struct proc_dir_entry *entry = PDE(inode);
  259. struct salinfo_data *data = entry->data;
  260. char cmd[32];
  261. size_t size;
  262. int i, n, cpu = -1;
  263. retry:
  264. if (down_trylock(&data->sem)) {
  265. if (file->f_flags & O_NONBLOCK)
  266. return -EAGAIN;
  267. if (down_interruptible(&data->sem))
  268. return -ERESTARTSYS;
  269. }
  270. n = data->cpu_check;
  271. for (i = 0; i < NR_CPUS; i++) {
  272. if (test_bit(n, &data->cpu_event) && cpu_online(n)) {
  273. cpu = n;
  274. break;
  275. }
  276. if (++n == NR_CPUS)
  277. n = 0;
  278. }
  279. if (cpu == -1)
  280. goto retry;
  281. /* events are sticky until the user says "clear" */
  282. up(&data->sem);
  283. /* for next read, start checking at next CPU */
  284. data->cpu_check = cpu;
  285. if (++data->cpu_check == NR_CPUS)
  286. data->cpu_check = 0;
  287. snprintf(cmd, sizeof(cmd), "read %d\n", cpu);
  288. size = strlen(cmd);
  289. if (size > count)
  290. size = count;
  291. if (copy_to_user(buffer, cmd, size))
  292. return -EFAULT;
  293. return size;
  294. }
  295. static struct file_operations salinfo_event_fops = {
  296. .open = salinfo_event_open,
  297. .read = salinfo_event_read,
  298. };
  299. static int
  300. salinfo_log_open(struct inode *inode, struct file *file)
  301. {
  302. struct proc_dir_entry *entry = PDE(inode);
  303. struct salinfo_data *data = entry->data;
  304. if (!capable(CAP_SYS_ADMIN))
  305. return -EPERM;
  306. spin_lock(&data_lock);
  307. if (data->open) {
  308. spin_unlock(&data_lock);
  309. return -EBUSY;
  310. }
  311. data->open = 1;
  312. spin_unlock(&data_lock);
  313. if (data->state == STATE_NO_DATA &&
  314. !(data->log_buffer = vmalloc(ia64_sal_get_state_info_size(data->type)))) {
  315. data->open = 0;
  316. return -ENOMEM;
  317. }
  318. return 0;
  319. }
  320. static int
  321. salinfo_log_release(struct inode *inode, struct file *file)
  322. {
  323. struct proc_dir_entry *entry = PDE(inode);
  324. struct salinfo_data *data = entry->data;
  325. if (data->state == STATE_NO_DATA) {
  326. vfree(data->log_buffer);
  327. vfree(data->oemdata);
  328. data->log_buffer = NULL;
  329. data->oemdata = NULL;
  330. }
  331. spin_lock(&data_lock);
  332. data->open = 0;
  333. spin_unlock(&data_lock);
  334. return 0;
  335. }
  336. static void
  337. call_on_cpu(int cpu, void (*fn)(void *), void *arg)
  338. {
  339. cpumask_t save_cpus_allowed, new_cpus_allowed;
  340. memcpy(&save_cpus_allowed, &current->cpus_allowed, sizeof(save_cpus_allowed));
  341. memset(&new_cpus_allowed, 0, sizeof(new_cpus_allowed));
  342. set_bit(cpu, &new_cpus_allowed);
  343. set_cpus_allowed(current, new_cpus_allowed);
  344. (*fn)(arg);
  345. set_cpus_allowed(current, save_cpus_allowed);
  346. }
  347. static void
  348. salinfo_log_read_cpu(void *context)
  349. {
  350. struct salinfo_data *data = context;
  351. sal_log_record_header_t *rh;
  352. data->log_size = ia64_sal_get_state_info(data->type, (u64 *) data->log_buffer);
  353. rh = (sal_log_record_header_t *)(data->log_buffer);
  354. /* Clear corrected errors as they are read from SAL */
  355. if (rh->severity == sal_log_severity_corrected)
  356. ia64_sal_clear_state_info(data->type);
  357. }
  358. static void
  359. salinfo_log_new_read(int cpu, struct salinfo_data *data)
  360. {
  361. struct salinfo_data_saved *data_saved;
  362. unsigned long flags;
  363. int i;
  364. int saved_size = ARRAY_SIZE(data->data_saved);
  365. data->saved_num = 0;
  366. spin_lock_irqsave(&data_saved_lock, flags);
  367. retry:
  368. for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) {
  369. if (data_saved->buffer && data_saved->cpu == cpu) {
  370. sal_log_record_header_t *rh = (sal_log_record_header_t *)(data_saved->buffer);
  371. data->log_size = data_saved->size;
  372. memcpy(data->log_buffer, rh, data->log_size);
  373. barrier(); /* id check must not be moved */
  374. if (rh->id == data_saved->id) {
  375. data->saved_num = i+1;
  376. break;
  377. }
  378. /* saved record changed by mca.c since interrupt, discard it */
  379. shift1_data_saved(data, i);
  380. goto retry;
  381. }
  382. }
  383. spin_unlock_irqrestore(&data_saved_lock, flags);
  384. if (!data->saved_num)
  385. call_on_cpu(cpu, salinfo_log_read_cpu, data);
  386. if (!data->log_size) {
  387. data->state = STATE_NO_DATA;
  388. clear_bit(cpu, &data->cpu_event);
  389. } else {
  390. data->state = STATE_LOG_RECORD;
  391. }
  392. }
  393. static ssize_t
  394. salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
  395. {
  396. struct inode *inode = file->f_dentry->d_inode;
  397. struct proc_dir_entry *entry = PDE(inode);
  398. struct salinfo_data *data = entry->data;
  399. u8 *buf;
  400. u64 bufsize;
  401. if (data->state == STATE_LOG_RECORD) {
  402. buf = data->log_buffer;
  403. bufsize = data->log_size;
  404. } else if (data->state == STATE_OEMDATA) {
  405. buf = data->oemdata;
  406. bufsize = data->oemdata_size;
  407. } else {
  408. buf = NULL;
  409. bufsize = 0;
  410. }
  411. return simple_read_from_buffer(buffer, count, ppos, buf, bufsize);
  412. }
  413. static void
  414. salinfo_log_clear_cpu(void *context)
  415. {
  416. struct salinfo_data *data = context;
  417. ia64_sal_clear_state_info(data->type);
  418. }
  419. static int
  420. salinfo_log_clear(struct salinfo_data *data, int cpu)
  421. {
  422. sal_log_record_header_t *rh;
  423. data->state = STATE_NO_DATA;
  424. if (!test_bit(cpu, &data->cpu_event))
  425. return 0;
  426. down(&data->sem);
  427. clear_bit(cpu, &data->cpu_event);
  428. if (data->saved_num) {
  429. unsigned long flags;
  430. spin_lock_irqsave(&data_saved_lock, flags);
  431. shift1_data_saved(data, data->saved_num - 1 );
  432. data->saved_num = 0;
  433. spin_unlock_irqrestore(&data_saved_lock, flags);
  434. }
  435. rh = (sal_log_record_header_t *)(data->log_buffer);
  436. /* Corrected errors have already been cleared from SAL */
  437. if (rh->severity != sal_log_severity_corrected)
  438. call_on_cpu(cpu, salinfo_log_clear_cpu, data);
  439. /* clearing a record may make a new record visible */
  440. salinfo_log_new_read(cpu, data);
  441. if (data->state == STATE_LOG_RECORD &&
  442. !test_and_set_bit(cpu, &data->cpu_event))
  443. up(&data->sem);
  444. return 0;
  445. }
  446. static ssize_t
  447. salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
  448. {
  449. struct inode *inode = file->f_dentry->d_inode;
  450. struct proc_dir_entry *entry = PDE(inode);
  451. struct salinfo_data *data = entry->data;
  452. char cmd[32];
  453. size_t size;
  454. u32 offset;
  455. int cpu;
  456. size = sizeof(cmd);
  457. if (count < size)
  458. size = count;
  459. if (copy_from_user(cmd, buffer, size))
  460. return -EFAULT;
  461. if (sscanf(cmd, "read %d", &cpu) == 1) {
  462. salinfo_log_new_read(cpu, data);
  463. } else if (sscanf(cmd, "clear %d", &cpu) == 1) {
  464. int ret;
  465. if ((ret = salinfo_log_clear(data, cpu)))
  466. count = ret;
  467. } else if (sscanf(cmd, "oemdata %d %d", &cpu, &offset) == 2) {
  468. if (data->state != STATE_LOG_RECORD && data->state != STATE_OEMDATA)
  469. return -EINVAL;
  470. if (offset > data->log_size - sizeof(efi_guid_t))
  471. return -EINVAL;
  472. data->state = STATE_OEMDATA;
  473. if (salinfo_platform_oemdata) {
  474. struct salinfo_platform_oemdata_parms parms = {
  475. .efi_guid = data->log_buffer + offset,
  476. .oemdata = &data->oemdata,
  477. .oemdata_size = &data->oemdata_size
  478. };
  479. call_on_cpu(cpu, salinfo_platform_oemdata_cpu, &parms);
  480. if (parms.ret)
  481. count = parms.ret;
  482. } else
  483. data->oemdata_size = 0;
  484. } else
  485. return -EINVAL;
  486. return count;
  487. }
  488. static struct file_operations salinfo_data_fops = {
  489. .open = salinfo_log_open,
  490. .release = salinfo_log_release,
  491. .read = salinfo_log_read,
  492. .write = salinfo_log_write,
  493. };
  494. static int __init
  495. salinfo_init(void)
  496. {
  497. struct proc_dir_entry *salinfo_dir; /* /proc/sal dir entry */
  498. struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */
  499. struct proc_dir_entry *dir, *entry;
  500. struct salinfo_data *data;
  501. int i, j, online;
  502. salinfo_dir = proc_mkdir("sal", NULL);
  503. if (!salinfo_dir)
  504. return 0;
  505. for (i=0; i < NR_SALINFO_ENTRIES; i++) {
  506. /* pass the feature bit in question as misc data */
  507. *sdir++ = create_proc_read_entry (salinfo_entries[i].name, 0, salinfo_dir,
  508. salinfo_read, (void *)salinfo_entries[i].feature);
  509. }
  510. for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
  511. data = salinfo_data + i;
  512. data->type = i;
  513. sema_init(&data->sem, 0);
  514. dir = proc_mkdir(salinfo_log_name[i], salinfo_dir);
  515. if (!dir)
  516. continue;
  517. entry = create_proc_entry("event", S_IRUSR, dir);
  518. if (!entry)
  519. continue;
  520. entry->data = data;
  521. entry->proc_fops = &salinfo_event_fops;
  522. *sdir++ = entry;
  523. entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir);
  524. if (!entry)
  525. continue;
  526. entry->data = data;
  527. entry->proc_fops = &salinfo_data_fops;
  528. *sdir++ = entry;
  529. /* we missed any events before now */
  530. online = 0;
  531. for_each_online_cpu(j) {
  532. set_bit(j, &data->cpu_event);
  533. ++online;
  534. }
  535. sema_init(&data->sem, online);
  536. *sdir++ = dir;
  537. }
  538. *sdir++ = salinfo_dir;
  539. init_timer(&salinfo_timer);
  540. salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
  541. salinfo_timer.function = &salinfo_timeout;
  542. add_timer(&salinfo_timer);
  543. return 0;
  544. }
  545. /*
  546. * 'data' contains an integer that corresponds to the feature we're
  547. * testing
  548. */
  549. static int
  550. salinfo_read(char *page, char **start, off_t off, int count, int *eof, void *data)
  551. {
  552. int len = 0;
  553. len = sprintf(page, (sal_platform_features & (unsigned long)data) ? "1\n" : "0\n");
  554. if (len <= off+count) *eof = 1;
  555. *start = page + off;
  556. len -= off;
  557. if (len>count) len = count;
  558. if (len<0) len = 0;
  559. return len;
  560. }
  561. module_init(salinfo_init);