- }
-
- err = ret = 0;
-
- if (cmd & IOC_IN) __copy_from_user((char *)&buf, (char *)arg, size);
-
- switch (cmd) {
- case DS_ADJUST_RESOURCE_INFO:
- ret = pcmcia_adjust_resource_info(s->handle, &buf.adjust);
- break;
- case DS_GET_CARD_SERVICES_INFO:
- ret = pcmcia_get_card_services_info(&buf.servinfo);
- break;
- case DS_GET_CONFIGURATION_INFO:
- ret = pcmcia_get_configuration_info(s->handle, &buf.config);
- break;
- case DS_GET_FIRST_TUPLE:
- ret = pcmcia_get_first_tuple(s->handle, &buf.tuple);
- break;
- case DS_GET_NEXT_TUPLE:
- ret = pcmcia_get_next_tuple(s->handle, &buf.tuple);
- break;
- case DS_GET_TUPLE_DATA:
- buf.tuple.TupleData = buf.tuple_parse.data;
- buf.tuple.TupleDataMax = sizeof(buf.tuple_parse.data);
- ret = pcmcia_get_tuple_data(s->handle, &buf.tuple);
- break;
- case DS_PARSE_TUPLE:
- buf.tuple.TupleData = buf.tuple_parse.data;
- ret = pcmcia_parse_tuple(s->handle, &buf.tuple, &buf.tuple_parse.parse);
- break;
- case DS_RESET_CARD:
- ret = pcmcia_reset_card(s->handle, NULL);
- break;
- case DS_GET_STATUS:
- ret = pcmcia_get_status(s->handle, &buf.status);
- break;
- case DS_VALIDATE_CIS:
- ret = pcmcia_validate_cis(s->handle, &buf.cisinfo);
- break;
- case DS_SUSPEND_CARD:
- ret = pcmcia_suspend_card(s->parent);
- break;
- case DS_RESUME_CARD:
- ret = pcmcia_resume_card(s->parent);
- break;
- case DS_EJECT_CARD:
- ret = pcmcia_eject_card(s->parent);
- break;
- case DS_INSERT_CARD:
- ret = pcmcia_insert_card(s->parent);
- break;
- case DS_ACCESS_CONFIGURATION_REGISTER:
- if ((buf.conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN))
- return -EPERM;
- ret = pcmcia_access_configuration_register(s->handle, &buf.conf_reg);
- break;
- case DS_GET_FIRST_REGION:
- ret = pcmcia_get_first_region(s->handle, &buf.region);
- break;
- case DS_GET_NEXT_REGION:
- ret = pcmcia_get_next_region(s->handle, &buf.region);
- break;
- case DS_GET_FIRST_WINDOW:
- buf.win_info.handle = (window_handle_t)s->handle;
- ret = pcmcia_get_first_window(&buf.win_info.handle, &buf.win_info.window);
- break;
- case DS_GET_NEXT_WINDOW:
- ret = pcmcia_get_next_window(&buf.win_info.handle, &buf.win_info.window);
- break;
- case DS_GET_MEM_PAGE:
- ret = pcmcia_get_mem_page(buf.win_info.handle,
- &buf.win_info.map);
- break;
- case DS_REPLACE_CIS:
- ret = pcmcia_replace_cis(s->handle, &buf.cisdump);
- break;
- case DS_BIND_REQUEST:
- if (!capable(CAP_SYS_ADMIN)) return -EPERM;
- err = bind_request(s, &buf.bind_info);
- break;
- case DS_GET_DEVICE_INFO:
- err = get_device_info(s, &buf.bind_info, 1);
- break;
- case DS_GET_NEXT_DEVICE:
- err = get_device_info(s, &buf.bind_info, 0);
- break;
- case DS_UNBIND_REQUEST:
- err = unbind_request(s, &buf.bind_info);
- break;
- case DS_BIND_MTD:
- if (!capable(CAP_SYS_ADMIN)) return -EPERM;
- err = bind_mtd(s, &buf.mtd_info);
- break;
- default:
- err = -EINVAL;
- }