Exemple #1
0
static int ftape_read_proc(char *page, char **start, off_t off,
			   int count, int *eof, void *data)
{
	char *ptr = page;
	size_t len;
	
	ptr += sprintf(ptr, "Kernel Driver\n\n");
	ptr += get_driver_info(ptr);
	ptr += sprintf(ptr, "\nTape Drive\n\n");
	ptr += get_tapedrive_info(ptr);
	ptr += sprintf(ptr, "\nFDC Controller\n\n");
	ptr += get_controller_info(ptr);
	ptr += sprintf(ptr, "\nTape Cartridge\n\n");
	ptr += get_cartridge_info(ptr);
	ptr += sprintf(ptr, "\nHistory Record\n\n");
	ptr += get_history_info(ptr);

	len = strlen(page);
	*start = NULL;
	if (off+count >= len) {
		*eof = 1;
	} else {
		*eof = 0;
	}
	return len;
}
Exemple #2
0
int is_driver_loaded()
{
    if (!get_driver_info()) {
        property_set(DRIVER_PROP_NAME,"unloaded");
        //property_set(WLAN_DRIVER,"");
        return 0;
    } else {
        property_set(DRIVER_PROP_NAME,"ok");
        return 1;
    }
}
int wifi_load_driver()
{
#ifdef WIFI_DRIVER_MODULE_PATH
    char driver_status[PROPERTY_VALUE_MAX];
    char modname[PROPERTY_VALUE_MAX];
    char modpath[SYSFS_PATH_MAX];
    int count = 100; /* wait at most 20 seconds for completion */

    if (is_wifi_driver_loaded()) {
        return 0;
    }

    if (!property_get(DRIVER_PATH_PROP, modpath, NULL)) {
        property_get(DRIVER_NAME_PROP, modname, NULL);
        strcat(modname, ".ko");
        if (!get_driver_path(modname, MODULE_DEFAULT_DIR, modpath))
            strcpy(modpath, WIFI_DRIVER_MODULE_PATH);
    }

    ALOGI("got module path %s", modpath);
    if (insmod(modpath, DRIVER_MODULE_ARG) < 0)
        return -1;

    if (strcmp(FIRMWARE_LOADER,"") == 0) {
        /* usleep(WIFI_DRIVER_LOADER_DELAY); */
        property_set(DRIVER_PROP_NAME, "ok");
    }
    else {
        property_set("ctl.start", FIRMWARE_LOADER);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0) {
                get_driver_info(modname);
                return 0;
            } else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
                wifi_unload_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "timeout");
    wifi_unload_driver();
    return -1;
#else
    property_set(DRIVER_PROP_NAME, "ok");
    return 0;
#endif
}
int is_wifi_driver_loaded() {
#ifdef WIFI_DRIVER_MODULE_PATH
    char modname[PROPERTY_VALUE_MAX];
    char line[PROPERTY_VALUE_MAX];
    FILE *proc;
    int cnt = property_get(DRIVER_NAME_PROP, modname, NULL);

    if (!cnt) {
        if (get_driver_info(modname))
            cnt = strlen(modname);
        else if (property_get("wlan.interface", line, NULL))
            return 1; // found an interface without modname, assume built-in
        else
            goto unloaded;
    }
    modname[cnt++] = ' ';

    /*
     * If the property says the driver is loaded, check to
     * make sure that the property setting isn't just left
     * over from a previous manual shutdown or a runtime
     * crash.
     */
    if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
        ALOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
        goto unloaded;
    }

    while ((fgets(line, sizeof(line), proc)) != NULL) {
        if (strncmp(line, modname, cnt) == 0) {
            fclose(proc);
            return 1;
        }
    }
    fclose(proc);

unloaded:
    property_set(DRIVER_PROP_NAME, "unloaded");
    return 0;
#else
    return 1;
#endif
}
Exemple #5
0
static void
#ifndef CONFIG_USB_COMPOSITE
stop_activity(struct usb_gadget *gadget, struct usb_gadget_driver *driver)
{
#else
stop_activity(struct usb_gadget *gadget, struct gadget_driver_info *p_info)
{
	struct usb_gadget_driver *driver=NULL;
#endif

	DMSG("Trace path 1\n");
	driver = (struct usb_gadget_driver *)stop_udc(driver);

	/* report disconnect; the driver is already quiesced */
#ifndef CONFIG_USB_COMPOSITE
	if (driver)
		driver->disconnect(gadget);
#else
	if (!p_info->stopped)
		p_info->driver->disconnect(gadget);
	p_info->stopped = 1;
#endif

	/* re-init driver-visible data structures */
	udc_reinit();
}

#ifdef CONFIG_USB_COMPOSITE
struct gadget_driver_info *get_driver_info(struct pxa3xx_comp *dev,
					   struct usb_gadget_driver *driver)
{
	struct gadget_driver_info *p_info = dev->first_gadget;

	while (p_info && (p_info->driver != driver)) p_info = p_info->next;

	return p_info;
}
#endif

int comp_check_driver(struct pxa3xx_comp *dev,
		      struct usb_gadget_driver *slf_drver,
		      struct usb_gadget_driver *driver)
{
	struct gadget_driver_info *p_info = get_driver_info(dev, driver);
#ifdef CONFIG_USB_OTG
	if (dev->transceiver && dev->transceiver->default_a) {
		printk(KERN_ERR "Mini-A connected!  "
		       "This operation may cause unexpected error!!!\n");
	}
#endif

#ifdef CONFIG_USB_COMPOSITE

	if (!driver || NULL == p_info) {
		printk(KERN_ERR "%s, can't find driver!\n", __FUNCTION__);
		return 0;
	}
	return 1;
#else
	if (!driver || driver != slf_drver) {
		printk(KERN_ERR "%s, can't find driver!\n", __FUNCTION__);
		return 0;
	}
	return 1;
#endif
}

int comp_is_dev_busy(struct pxa3xx_comp *dev, struct usb_gadget_driver *driver)
{
#ifndef CONFIG_USB_COMPOSITE
	if (driver)
		return 1;
#else
	/* FIXME remove all modules before insert again */
	if ((dev->rm_flag) && dev->first_gadget) {
		printk(KERN_ERR "left modules may not work!  "
		       "please remove all and insert again!!!\n");
		return 1;
	}
#ifdef CONFIG_USB_OTG
	if(dev->transceiver && dev->transceiver->default_a) {
		printk(KERN_ERR "Mini-A connected!  "
		       "please unplug it and insert module again!!!\n");
		return 1;
	}
#endif
#endif
	return 0;
}

int stop_cur_gadget(struct pxa3xx_comp *dev, struct usb_gadget *gadget,
		    struct usb_gadget_driver *driver)
{
#ifdef CONFIG_USB_COMPOSITE
	struct gadget_driver_info *p_info = get_driver_info(dev, driver);

	set_gadget_data(gadget, p_info->driver_data);
	stop_activity(gadget, p_info);
	return 0;
#else
	stop_activity(gadget, driver);
	return 0;
#endif
}
void comp_register_driver(struct pxa3xx_comp *dev, struct usb_gadget *gadget,
			    struct usb_gadget_driver *driver)
{
#ifdef CONFIG_USB_COMPOSITE
	/* allocate gadget_driver_info and attach it to controller */
	gadget_info_init(dev, gadget, driver);
	dev->active_gadget->driver_data = get_gadget_data(gadget);
#ifdef MULTI_P3
	gadget_get_device_desc(dev, gadget, driver);
#endif /* MULTI_P3 */
#endif
	/* After driver is bound, send a fake get configuration command to
	 * gadget driver to get the configuration information */
	gadget_get_config_desc(dev, gadget, driver);
#if defined(CONFIG_USB_COMPOSITE) && (defined(CONFIG_USB_PXA3XX_U2D) \
	|| defined(CONFIG_USB_PXA_U2O))
	gadget_get_config_desc_hs(dev, gadget, driver);
#endif
}