aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pcmcia_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r--drivers/pcmcia/pcmcia_resource.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 4884a18cf9e6..9f054bc847f2 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -909,3 +909,65 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) {
909 pcmcia_release_window(p_dev->win); 909 pcmcia_release_window(p_dev->win);
910} 910}
911EXPORT_SYMBOL(pcmcia_disable_device); 911EXPORT_SYMBOL(pcmcia_disable_device);
912
913
914struct pcmcia_cfg_mem {
915 tuple_t tuple;
916 cisparse_t parse;
917 u8 buf[256];
918};
919
920/**
921 * pcmcia_loop_config() - loop over configuration options
922 * @p_dev: the struct pcmcia_device which we need to loop for.
923 * @conf_check: function to call for each configuration option.
924 * It gets passed the struct pcmcia_device, the CIS data
925 * describing the configuration option, and private data
926 * being passed to pcmcia_loop_config()
927 * @priv_data: private data to be passed to the conf_check function.
928 *
929 * pcmcia_loop_config() loops over all configuration options, and calls
930 * the driver-specific conf_check() for each one, checking whether
931 * it is a valid one.
932 */
933int pcmcia_loop_config(struct pcmcia_device *p_dev,
934 int (*conf_check) (struct pcmcia_device *p_dev,
935 cistpl_cftable_entry_t *cfg,
936 void *priv_data),
937 void *priv_data)
938{
939 struct pcmcia_cfg_mem *cfg_mem;
940 tuple_t *tuple;
941 int ret = -ENODEV;
942
943 cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL);
944 if (cfg_mem == NULL)
945 return -ENOMEM;
946
947 tuple = &cfg_mem->tuple;
948 tuple->TupleData = cfg_mem->buf;
949 tuple->TupleDataMax = 255;
950 tuple->TupleOffset = 0;
951 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
952 tuple->Attributes = 0;
953
954 ret = pcmcia_get_first_tuple(p_dev, tuple);
955 while (!ret) {
956 if (pcmcia_get_tuple_data(p_dev, tuple))
957 goto next_entry;
958
959 if (pcmcia_parse_tuple(p_dev, tuple, &cfg_mem->parse))
960 goto next_entry;
961
962 ret = conf_check(p_dev, &cfg_mem->parse.cftable_entry,
963 priv_data);
964 if (!ret)
965 break;
966
967next_entry:
968 ret = pcmcia_get_next_tuple(p_dev, tuple);
969 }
970
971 return ret;
972}
973EXPORT_SYMBOL(pcmcia_loop_config);