From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guido Kiener <guido@kiener-muenchen.de>
Cc: linux-usb@vger.kernel.org, guido.kiener@rohde-schwarz.com,
steve_bayless@keysight.com, dpenkler@gmail.com
Subject: [v3,02/23] usb: usbtmc: Add ioctl for generic requests on control
Date: Tue, 24 Jul 2018 13:43:28 +0200 [thread overview]
Message-ID: <20180724114328.GA16735@kroah.com> (raw)
On Tue, Jul 24, 2018 at 11:05:29AM +0200, Guido Kiener wrote:
> Add USBTMC_IOCTL_CTRL_REQUEST to send arbitrary requests on the
> control pipe. Used by specific applications of IVI Foundation,
> Inc. to implement VISA API functions: viUsbControlIn/Out.
>
> The maximum length of control request is set to 4k.
>
> Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
> Reviewed-by: Steve Bayless <steve_bayless@keysight.com>
> ---
> drivers/usb/class/usbtmc.c | 84 ++++++++++++++++++++++++++++++++++++
> include/uapi/linux/usb/tmc.h | 15 +++++++
> 2 files changed, 99 insertions(+)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 83ffa5a14c3d..3b3b4284d04e 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
> * Copyright (C) 2008 Novell, Inc.
> * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
> + * Copyright (C) 2018 IVI Foundation, Inc.
> */
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> @@ -36,6 +37,9 @@
> /* Default USB timeout (in milliseconds) */
> #define USBTMC_TIMEOUT 5000
>
> +/* I/O buffer size used in generic read/write functions */
> +#define USBTMC_BUFSIZE (4096)
> +
> /*
> * Maximum number of read cycles to empty bulk in endpoint during CLEAR and
> * ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short
> @@ -129,6 +133,21 @@ struct usbtmc_file_data {
> /* Forward declarations */
> static struct usb_driver usbtmc_driver;
>
> +#ifdef CONFIG_COMPAT
> +static void __user *u64_to_uptr(u64 value)
> +{
> + if (in_compat_syscall())
> + return compat_ptr(value);
> + else
> + return (void __user *)(unsigned long)value;
> +}
> +#else
> +static inline void __user *u64_to_uptr(u64 value)
> +{
> + return (void __user *)(unsigned long)value;
> +}
> +#endif /* CONFIG_COMPAT */
For Linux, if there are functions/operations that are always needed by
all drivers (or even some), then those functions are provided in the
core kernel with header files or in the library. So if you are writing
a single driver, and find you need to create something that looks very
"generic", either you are doing something that no other driver has ever
needed before in the history of Linux, or you are doing something wrong.
Which do you think it is here? :)
Please fix this up and do it properly. Your driver should only have 1
#ifdef CONFIG_COMPAT line, and that was in patch 1 for this series.
Nothing else should be needed if you create your structures correctly.
thanks,
greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2018-07-24 11:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 11:43 Greg Kroah-Hartman [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-07-24 12:33 [v3,02/23] usb: usbtmc: Add ioctl for generic requests on control Guido Kiener
2018-07-24 12:24 Guido Kiener
2018-07-24 11:47 Greg Kroah-Hartman
2018-07-24 9:05 Guido Kiener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180724114328.GA16735@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=dpenkler@gmail.com \
--cc=guido.kiener@rohde-schwarz.com \
--cc=guido@kiener-muenchen.de \
--cc=linux-usb@vger.kernel.org \
--cc=steve_bayless@keysight.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.