usb: gadget: g_ffs: Allow to set bmAttributes of configuration
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / misc / sim_slot.c
1 /*
2
3  * Copyright (c) 2010-2015 Samsung Electronics Co., Ltd.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8
9
10 */
11 #include "sim_slot.h"
12
13 #ifndef SIM_SLOT_PIN
14         #error SIM_SLOT_PIN should be have a value. but not defined.
15 #endif
16
17 static int check_simslot_count(struct seq_file *m, void *v)
18 {
19
20 #ifdef CONFIG_MACH_Z3
21         int support_number_of_simslot;
22         support_number_of_simslot = DUAL_SIM;
23         pr_info("SIM_SLOT_COUNT = %d\n", support_number_of_simslot);
24 #else
25         int retval, support_number_of_simslot;
26         retval = gpio_request(SIM_SLOT_PIN, "SIM_SLOT_PIN");
27         if (retval) {
28                         pr_err("%s:Failed to reqeust GPIO, code = %d.\n",
29                                 __func__, retval);
30                         support_number_of_simslot = retval;
31         } else {
32                 retval = gpio_direction_input(SIM_SLOT_PIN);
33
34                 if (retval) {
35                         pr_err("%s:Failed to set direction of GPIO, code = %d.\n",
36                                 __func__, retval);
37                         support_number_of_simslot = retval;
38                 } else {
39                         retval = gpio_get_value(SIM_SLOT_PIN);
40
41                         /* This codes are implemented assumption that count
42                         of GPIO about simslot is only one on H/W schematic.
43                         You may change this codes if count of GPIO about
44                         simslot has change */
45                         switch (retval) {
46                         case SINGLE_SIM_VALUE:
47                                 support_number_of_simslot = SINGLE_SIM;
48                                 pr_info("\n SIM_SLOT_PIN gpio %d : Single Sim mode \n", SIM_SLOT_PIN);
49                                 break;
50                         case DUAL_SIM_VALUE:
51                                 support_number_of_simslot = DUAL_SIM;
52                                 pr_info("\n SIM_SLOT_PIN gpio %d : Dual Sim mode \n", SIM_SLOT_PIN);
53                                 break;
54                         default:
55                                 support_number_of_simslot = -1;
56                                 break;
57                         }
58                 }
59                 gpio_free(SIM_SLOT_PIN);
60         }
61 #endif
62         if (support_number_of_simslot < 0) {
63                 pr_err("******* Make a forced kernel panic because can't check simslot count******\n");
64                 panic("kernel panic");
65         }
66
67         seq_printf(m, "%u\n", support_number_of_simslot);
68
69         return 0;
70
71 }
72
73 static int check_simslot_count_open(struct inode *inode, struct file *file)
74 {
75         return single_open(file, check_simslot_count, NULL);
76 }
77
78 static const struct file_operations check_simslot_count_fops = {
79         .open   = check_simslot_count_open,
80         .read   = seq_read,
81         .write  = seq_lseek,
82         .release = single_release,
83 };
84
85 static int __init simslot_count_init(void)
86 {
87
88         if (!proc_create("simslot_count", 0, NULL, &check_simslot_count_fops)) {
89                 pr_err("***** Make a forced kernel panic because can't make a simslot_count file node ******\n");
90                 panic("kernel panic");
91                 return -ENOMEM;
92         } else
93                 return 0;
94 }
95
96 late_initcall(simslot_count_init);
97