static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { int r; mutex_lock(&lasat_info_mutex); r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); if (r < 0) { mutex_unlock(&lasat_info_mutex); return r; } if (newval && newlen) { if (name && *name == LASAT_PRID) lasat_board_info.li_eeprom_info.prid = *(int*)newval; lasat_write_eeprom_info(); lasat_init_board_info(); } mutex_unlock(&lasat_info_mutex); return 0; }
int proc_lasat_ip(ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { unsigned int ip; char *p, c; int len; char ipbuf[32]; if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) { *lenp = 0; return 0; } if (write) { len = 0; p = buffer; while (len < *lenp) { if (get_user(c, p++)) return -EFAULT; if (c == 0 || c == '\n') break; len++; } if (len >= sizeof(ipbuf)-1) len = sizeof(ipbuf) - 1; if (copy_from_user(ipbuf, buffer, len)) return -EFAULT; ipbuf[len] = 0; *ppos += *lenp; /* Now see if we can convert it to a valid IP */ ip = in_aton(ipbuf); *(unsigned int *)(table->data) = ip; lasat_write_eeprom_info(); } else { ip = *(unsigned int *)(table->data); sprintf(ipbuf, "%d.%d.%d.%d", (ip) & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff); len = strlen(ipbuf); if (len > *lenp) len = *lenp; if (len) if (copy_to_user(buffer, ipbuf, len)) return -EFAULT; if (len < *lenp) { if (put_user('\n', ((char *) buffer) + len)) return -EFAULT; len++; } *lenp = len; *ppos += len; } return 0; }
/* proc function to write EEPROM after changing int entry */ int proc_dolasatint(ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int r; r = proc_dointvec(table, write, buffer, lenp, ppos); if ((!write) || r) return r; lasat_write_eeprom_info(); return 0; }
/* And the same for proc */ int proc_dolasatstring(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp, loff_t *ppos) { int r; r = proc_dostring(table, write, filp, buffer, lenp, ppos); if ((!write) || r) return r; lasat_write_eeprom_info(); return 0; }
/* proc function to write EEPROM after changing int entry */ int proc_dolasatint(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp, loff_t *ppos) { int r; mutex_lock(&lasat_info_mutex); r = proc_dointvec(table, write, filp, buffer, lenp, ppos); if ( (!write) || r) { mutex_unlock(&lasat_info_mutex); return r; } lasat_write_eeprom_info(); mutex_unlock(&lasat_info_mutex); return 0; }
/* Sysctl for setting the IP addresses */ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { int r; r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); if (r < 0) return r; if (newval && newlen) lasat_write_eeprom_info(); return 0; }
int proc_lasat_prid(ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int r; r = proc_dointvec(table, write, buffer, lenp, ppos); if (r < 0) return r; if (write) { lasat_board_info.li_eeprom_info.prid = lasat_board_info.li_prid; lasat_write_eeprom_info(); lasat_init_board_info(); } return 0; }
static int sysctl_lasat_prid(ctl_table *table, int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { int r; r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); if (r < 0) return r; if (newval && newlen) { lasat_board_info.li_eeprom_info.prid = *(int *)newval; lasat_write_eeprom_info(); lasat_init_board_info(); } return 0; }
/* Sysctl for setting the IP addresses */ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { int r; mutex_lock(&lasat_info_mutex); r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); if (r < 0) { mutex_unlock(&lasat_info_mutex); return r; } if (newval && newlen) { lasat_write_eeprom_info(); } mutex_unlock(&lasat_info_mutex); return 1; }
int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp, loff_t *ppos) { int r; mutex_lock(&lasat_info_mutex); r = proc_dointvec(table, write, filp, buffer, lenp, ppos); if ( (!write) || r) { mutex_unlock(&lasat_info_mutex); return r; } if (filp && filp->f_path.dentry) { if (!strcmp(filp->f_path.dentry->d_name.name, "prid")) lasat_board_info.li_eeprom_info.prid = lasat_board_info.li_prid; if (!strcmp(filp->f_path.dentry->d_name.name, "debugaccess")) lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess; } lasat_write_eeprom_info(); mutex_unlock(&lasat_info_mutex); return 0; }