libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010, 2011, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at 00009 * your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/errno.h> 00021 #include <libexplain/ac/linux/scc.h> 00022 00023 #include <libexplain/buffer/dac.h> 00024 #include <libexplain/buffer/efault.h> 00025 #include <libexplain/buffer/einval.h> 00026 #include <libexplain/buffer/scc_hw_config.h> 00027 #include <libexplain/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/siocscccfg.h> 00029 #include <libexplain/is_efault.h> 00030 00031 #ifdef HAVE_LINUX_SCC_H 00032 00033 00034 static void 00035 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00036 int errnum, int fildes, int request, const void *data) 00037 { 00038 (void)p; 00039 (void)errnum; 00040 (void)fildes; 00041 (void)request; 00042 explain_buffer_scc_hw_config(sb, data); 00043 } 00044 00045 00046 static void 00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00048 int errnum, int fildes, int request, const void *data) 00049 { 00050 switch (errnum) 00051 { 00052 case EPERM: 00053 explain_buffer_dac_sys_rawio(sb); 00054 break; 00055 00056 case EINVAL: 00057 if (explain_is_efault_pointer(data, sizeof(struct scc_hw_config))) 00058 goto efault; 00059 00060 /* 00061 * There are many causes of this result: 00062 * 00063 * + too many devices (Nchips >= SCC_MAXCHIPS) 00064 * No way to test, have no access to Nchips or SCC_MAXCHIPS 00065 * + stupid IRQ (hwcfg.irq < 0) 00066 * Finally, something we can check 00067 * + stupid IRQ (hwcfg.irq >= nr_irqs) 00068 * No way to test, no access to nr_irqs 00069 * + driver already initialised 00070 * No way to test, no access to Ivec[] 00071 */ 00072 explain_buffer_einval_vague(sb, "data"); 00073 break; 00074 00075 case EFAULT: 00076 efault: 00077 explain_buffer_efault(sb, "data"); 00078 break; 00079 00080 default: 00081 explain_iocontrol_generic_print_explanation 00082 ( 00083 p, 00084 sb, 00085 errnum, 00086 fildes, 00087 request, 00088 data 00089 ); 00090 break; 00091 } 00092 } 00093 00094 00095 const explain_iocontrol_t explain_iocontrol_siocscccfg = 00096 { 00097 "SIOCSCCCFG", /* name */ 00098 SIOCSCCCFG, /* value */ 00099 explain_iocontrol_disambiguate_scc, 00100 0, /* print_name */ 00101 print_data, 00102 print_explanation, 00103 0, /* print_data_returned */ 00104 sizeof(struct scc_hw_config), /* data_size */ 00105 "struct scc_hw_config *", /* data_type */ 00106 IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */ 00107 __FILE__, 00108 __LINE__, 00109 }; 00110 00111 #else /* ndef SIOCSCCCFG */ 00112 00113 const explain_iocontrol_t explain_iocontrol_siocscccfg = 00114 { 00115 0, /* name */ 00116 0, /* value */ 00117 0, /* disambiguate */ 00118 0, /* print_name */ 00119 0, /* print_data */ 00120 0, /* print_explanation */ 00121 0, /* print_data_returned */ 00122 0, /* data_size */ 00123 0, /* data_type */ 00124 0, /* flags */ 00125 __FILE__, 00126 __LINE__, 00127 }; 00128 00129 #endif /* SIOCSCCCFG */ 00130 00131 00132 /* vim: set ts=8 sw=4 et : */