Re: [PATCH] drivers/usb/gadget: beautify code, delete unused code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



于 2013年03月11日 18:21, Felipe Balbi 写道:
> in case of net2272.c and net2280.c, they call stop_activity() also from
> disconnect and reset interrupt handlers, in that case the gadget driver
> needs to know about the disconnect.

  I guess your meaning is:
    for net2272.c and net2280.c, we still need driver->disconnect. although for others do not need.

  if it is correct:
    I will try to find another members which have relative HW to help us to test it.
      e.g. communicate with the relative company to help test their own product.
      e.g. find another relative members with net22??.c which have HW and can help us.

    if I can not find other members to help us, I will try to find another ways.
      if so, maybe I need more time to do it.
      if so, I am sorry to have to delay the time point (2013-3-15)
        and I guess the new time point is within a month (before 2013-4-15)

  all together: I beleive "ways is always more than issues".


BTW:
  I also add comments for your test program, please check whether it is ok, thanks.

--------------------------------------------------------------------------------------

/**
 * device-reset.c - Reset a USB device multiple times
 *
 * Copyright (C) 2013 Felipe Balbi <balbi@xxxxxx>
 *
 * This file is part of the USB Verification Tools Project
 *
 * USB Tools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public Liicense as published by
 * the Free Software Foundation, either version 3 of the license, or
 * (at your option) any later version.
 *
 * USB Tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with USB Tools. If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * compiling:
 *   $(CROSS_COMPILE)gcc -Wall -O2 -g -lusb-1.0 -o device-reset device-reset.c
 *     this file name is device-reset.c
 *     it needs libusb.h (for fedora, package name is libusb1-devel)
 *
 * usage:
 *   [root@gchenlinux tmp]# ./device-reset -h
 *   ./device-reset -D VID:PID
 *   [root@gchenlinux tmp]# lsusb
 *   ...
 *   Bus 002 Device 003: ID 05e3:0718 Genesys Logic, Inc. IDE/SATA Adapter
 *   ...
 *   [root@gchenlinux tmp]# ./device-reset -D 05e3:0718
 *
 * result:
 *   it will run 10000 times.
 *   all printing lines should content PASSED, and should not content FAILED.
 */

#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>

#include <libusb-1.0/libusb.h>

#define OPTION(n, h, v)			\
{					\
	.name		= #n,		\
	.has_arg	= h,		\
	.val		= v,		\
}

static struct option device_reset_opts[] = {
	OPTION("help",		0, 'h'),
	OPTION("device",	1, 'D'),
	{  }	/* Terminating entry */
};

static void usage(char *cmd)
{
	fprintf(stdout, "%s -D VID:PID\n", cmd);
}

int main(int argc, char *argv[])
{
	libusb_context		*context;
	libusb_device_handle	*udevh;

	unsigned		vid = 0;
	unsigned		pid = 0;

	int			ret = 0;
	int			i;

	while (1) {
		int		optidx;
		int		opt;

		char		*token;

		opt = getopt_long(argc, argv, "D:h", device_reset_opts, &optidx);
		if (opt == -1)
			break;

		switch (opt) {
		case 'D':
			token = strtok(optarg, ":");
			vid = strtoul(token, NULL, 16);
			token = strtok(NULL, ":");
			pid = strtoul(token, NULL, 16);
			break;
		case 'h': /* FALLTHROUGH */
		default:
			usage(argv[0]);
			exit(-1);
		}
	}

	libusb_init(&context);

	udevh = libusb_open_device_with_vid_pid(context, vid, pid);
	if (!udevh) {
		perror("open");
		ret = -ENODEV;
		goto out0;
	}

	for (i = 0; i < 10000; i++) {
		ret = libusb_reset_device(udevh);
		printf("Reset #%d: ", i + 1);

		if (ret < 0) {
			printf("FAILED\n");
			break;
		} else {
			printf("PASSED\n");
		}
	}

	libusb_close(udevh);

out0:
	libusb_exit(context);

	return ret;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux