summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_mass_storage.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: gadget: f_mass_storage: call try_to_freeze only when its safeGeorge Cherian2013-11-251-11/+12
| | | | | | | | | | | | | | | | Call try_to_freeze() in sleep_thread() only when it's safe to sleep. do_read() and do_write() calls sleep_thread with lock held. Make sure these won't call try_to_freeze() by passing can_freeze flag to sleep_thread. Calling try_to_freeze() with a lock hold was done since day one in f_mass_storage but since commit 0f9548ca1 ("lockdep: check that no locks held at freeze time") lockdep complains about it. Signed-off-by: George Cherian <george.cherian@ti.com> Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: storage: fix sparse warningFelipe Balbi2013-11-251-1/+1
| | | | | | | | | | | | | | fsg_common_set_inquiry_string() expects pointers as second and third argument. Let's fix that by passing NULL instead of plain 0 just so we silence sparse's: drivers/usb/gadget/f_mass_storage.c:3114:60: warning: \ Using plain integer as NULL pointer drivers/usb/gadget/f_mass_storage.c:3114:63: warning: \ Using plain integer as NULL pointer Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: mass storage: fix return of delayed statusPratyush Anand2013-11-251-1/+1
| | | | | | | | | | | | | | | | Mass storage gadget returns DELAYED_STATUS in stead of USB_GADGET_DELAYED_STATUS while handling bulk reset request. Since peripheral driver uses USB_GADGET_DELAYED_STATUS for delayed status handling, therefore replace DELAYED_STATUS by USB_GADGET_DELAYED_STATUS in mass storage driver. Since, DELAYED_STATUS and hence EP0_BUFSIZE will no longer be used now, so remove them. Signed-off-by: Pratyush Anand <pratyush.anand@st.com> Cc: Paul Zimmerman <Paul.Zimmerman@synopsys.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb/gadget: f_mass_storage: use string literal as format in dev_set_nameAndrzej Pietrasiewicz2013-10-251-1/+1
| | | | | | | | | | | | Fix commit b27c08c953e994f792a03d9b7cbc5cf3f9844135 where dev_set_name() is used without a string literal as format. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Cc: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: gadget: f_mass_storage: style corrections, cleanup & simplificationAndrzej Pietrasiewicz2013-10-171-19/+18
| | | | | | | | | | Fix spacing, improve error code returned, remove unused #define, use strtobool() instead of kstrtou8(). Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: storage_common: pass filesem to fsg_store_cdromAndrzej Pietrasiewicz2013-10-151-1/+6
| | | | | | | | | | If cdrom flag is set ro flag is implied. Try setting the ro first, and only if it succeeds set the cdrom flag. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: remove compatibility layerAndrzej Pietrasiewicz2013-10-101-131/+19
| | | | | | | | There are no more old interface users left. Remove it. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: add configfs supportAndrzej Pietrasiewicz2013-10-101-0/+360
| | | | | | | | From this commit on f_mass_storage is available through configfs. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: storage_common: make attribute operations more genericAndrzej Pietrasiewicz2013-10-101-6/+21
| | | | | | | | | | Show/store methods for sysfs attributes contain code which can be used also by configfs. Make them abstract the source the lun and rw_semaphore are taken from. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: mass_storage: convert to new interface of f_mass_storageAndrzej Pietrasiewicz2013-10-101-0/+7
| | | | | | | | | | | | Convert old mass_storage gadget to use the new interface of f_mass_storage so that later the compatibility layer in f_mass_storage can be removed. struct fsg_common is not known to mass_storage.c, so a setter method is added to f_mass_storage. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: convert to new function interface with backward ↵Andrzej Pietrasiewicz2013-10-101-22/+156
| | | | | | | | | | | | | | | | compatibility Converting mass storage to the new function interface requires converting the USB mass storage's function code and its users. This patch converts the f_mass_storage.c to the new function interface. The file is now compiled into a separate usb_f_mass_storage.ko module. The old function interface is provided by means of a preprocessor conditional directives. After all users are converted, the old interface can be removed. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create fsg_common_run_thread for use in ↵Andrzej Pietrasiewicz2013-10-101-11/+21
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create fsg_common_set_inquiry_string for use in ↵Andrzej Pietrasiewicz2013-10-101-10/+19
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create lun creation helpers for use in ↵Andrzej Pietrasiewicz2013-10-101-91/+147
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor portions of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create fsg_common_set_cdev for use in ↵Andrzej Pietrasiewicz2013-10-101-21/+29
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create lun handling helpers for use in ↵Andrzej Pietrasiewicz2013-10-101-17/+63
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor portions of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create fsg_common_set_num_buffers for use in ↵Andrzej Pietrasiewicz2013-10-101-26/+46
| | | | | | | | | | | fsg_common_init fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create fsg_common_setup for use in fsg_common_initAndrzej Pietrasiewicz2013-10-101-16/+24
| | | | | | | | | fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: make sysfs interface optionalAndrzej Pietrasiewicz2013-10-101-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | When configfs is in place, the luns will not be represented in sysfs, so there will be no struct device associated with a lun. In order to maintain compatibility and allow configfs adoption sysfs is made optional in this patch. As a consequence some debug macros need to be adjusted. Two new fields are added to struct fsg_lun: name and name_pfx. The "name" is for storing a string which is presented to the user instead of the dev_name. The "name_pfx", if non-NULL, is prepended to the "name" at printing time. The name_pfx is for a future lun.0, which will be a default group in mass_storage.<name>. By design at USB function configfs group's creation time its name is not known (but instead set a bit later in drivers/usb/gadget/configfs.c:function_make) and it is this name that serves the purpose of the said name prefix. So instead of copying a yet-unknown string a pointer to it is stored in struct fsg_lun. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: create _fsg_common_free_buffersAndrzej Pietrasiewicz2013-10-101-9/+13
| | | | | | | | | | When configfs is in place, gadgets will have to be able to free fsg buffers. Add a helper function. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: use usb_gstrings_attachAndrzej Pietrasiewicz2013-10-011-13/+12
| | | | | | | | Prepare for handling with configfs. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: add a level of indirection for luns storageAndrzej Pietrasiewicz2013-10-011-19/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needed to prepare for configfs integration. So far the luns have been allocated during gadget's initialization, based on the nluns module parameter's value; the exact number is known when the gadget is initialized and that number of luns is allocated in one go; they all will be used. When configfs is in place, the luns will be created one-by-one by the user. Once the user is satisfied with the number of luns, they activate the gadget. The number of luns must be <= FSG_MAX_LUN (currently 8), but other than that it is not known up front and the user need not use contiguous numbering (apart from the default lun #0). On the other hand, the function code uses lun numbers to identify them and the number needs to be used as an index into an array. Given the above, an array needs to be allocated, but it might happen that 7 out of its 8 elements will not be used. On my machine sizeof(struct fsg_lun) == 462, so > 3k of memory is allocated but not used in the worst case. By adding another level of indirection (allocating an array of pointers to struct fsg_lun and then allocating individual luns instead of an array of struct fsg_luns) at most 7 pointers are wasted, which is much less. This patch also changes some for/while loops to cope with the fact that in the luns array some entries are potentially empty. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: factor out a header fileAndrzej Pietrasiewicz2013-10-011-110/+7
| | | | | | | | | | | In order to prepare for the new function interface the f_mass_storage.c needs to be compiled as a module, and so a header file will be required. This patch factors out some code to a new f_mass_storage.h. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: create a utility module for mass_storageAndrzej Pietrasiewicz2013-10-011-15/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | Converting to configfs requires making the f_mass_storage.c a module. But first we need to get rid of "#include "storage_common.c". This patch makes storage_common.c a separately compiled file, which is built as a utility module named u_ms.ko. After all mass storage users are converted to the new function interface this module can be eliminated by merging it with the mass storage function's module. USB descriptors are exported so that they can be accessed from f_mass_storage. FSG_VENDOR_ID and FSG_PRODUCT_ID are moved to their only user. Handling of CONFIG_USB_GADGET_DEBUG_FILES is moved to f_mass_storage.c. The fsg_num_buffers static is moved to FSG_MODULE_PARAMETER users, so instead of using a global variable the f_mass_storage introduces fsg_num_buffers member in fsg_common (and fsg_config). fsg_strings and fsg_stringtab are moved to f_mass_storage.c. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: reset endpoint driver data when disabledPeter Oh2013-09-171-0/+2
| | | | | | | | | | | | | | | Gadgets endpoint driver data is a criteria to judge that whether the endpoints are in use or not. When gadget gets assigned an endpoint from endpoint list, they check its driver data if the driver data is NULL. If the driver data is not NULL then they regard it as in use. Therefore all of gadgets should reset their endpoints driver data to NULL as they are disabled. Otherwise it causes a leak of endpoint resource. Signed-off-by: Peter Oh <poh@broadcom.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* USB: gadget: audit sysfs attribute permissionsGreg Kroah-Hartman2013-08-271-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | Convert all USB gadget sysfs attributes to use the _RO or _RW variants, to make them easier to audit and ensure that the permissions are correct. Note, two are left using the DEVICE_ATTR() macro, as there is no DEVICE_ATTR_WO() in Linus's tree, that will happen after 3.12-rc1 is out, a follow-on patch will be sent then. Reviewed-by: Felipe Balbi <balbi@ti.com> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -- drivers/usb/gadget/composite.c | 8 +++----- drivers/usb/gadget/dummy_hcd.c | 8 ++++---- drivers/usb/gadget/f_mass_storage.c | 14 ++++++-------- drivers/usb/gadget/net2272.c | 4 ++-- drivers/usb/gadget/net2280.c | 18 +++++++++--------- drivers/usb/gadget/storage_common.c | 25 ++++++++++++------------- drivers/usb/gadget/udc-core.c | 14 +++++++------- 7 files changed, 43 insertions(+), 48 deletions(-)
* usb: gadget: f_mass_storage: use NULL instead of 0Jingoo Han2013-08-091-3/+3
| | | | | | | | | | | | | The local variables such as 'filename', 'vendor_name', and 'product_name' are pointers; thus, use NULL instead of 0 to fix the following sparse warnings drivers/usb/gadget/f_mass_storage.c:3046:27: warning: Using plain integer as NULL pointer drivers/usb/gadget/f_mass_storage.c:3050:28: warning: Using plain integer as NULL pointer drivers/usb/gadget/f_mass_storage.c:3051:29: warning: Using plain integer as NULL pointer Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: fix default product nameAndrzej Pietrasiewicz2013-06-121-2/+2
| | | | | | | | | | | | If cfg->product name is not set, a default name is chosen depending on the common->luns->cdrom flag. If the flag is set the name should be "File-CD Gadget", and if the flag is not set the name should be "File-Stor Gadget". Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: add missing memory barrier for thread_wakeup_neededUCHINO Satoshi2013-06-101-0/+2
| | | | | | | | | | | | | | | | | | | Without this memory barrier, the file-storage thread may fail to escape from the following while loop, because it may observe new common->thread_wakeup_needed and old bh->state which are updated by the callback functions. /* Wait for the CBW to arrive */ while (bh->state != BUF_STATE_FULL) { rc = sleep_thread(common); if (rc) return rc; } Cc: stable@vger.kernel.org Signed-off-by: UCHINO Satoshi <satoshi.uchino@toshiba.co.jp> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge branch 'for-linus' of ↵Linus Torvalds2013-02-261-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull vfs pile (part one) from Al Viro: "Assorted stuff - cleaning namei.c up a bit, fixing ->d_name/->d_parent locking violations, etc. The most visible changes here are death of FS_REVAL_DOT (replaced with "has ->d_weak_revalidate()") and a new helper getting from struct file to inode. Some bits of preparation to xattr method interface changes. Misc patches by various people sent this cycle *and* ocfs2 fixes from several cycles ago that should've been upstream right then. PS: the next vfs pile will be xattr stuff." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits) saner proc_get_inode() calling conventions proc: avoid extra pde_put() in proc_fill_super() fs: change return values from -EACCES to -EPERM fs/exec.c: make bprm_mm_init() static ocfs2/dlm: use GFP_ATOMIC inside a spin_lock ocfs2: fix possible use-after-free with AIO ocfs2: Fix oops in ocfs2_fast_symlink_readpage() code path get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero target: writev() on single-element vector is pointless export kernel_write(), convert open-coded instances fs: encode_fh: return FILEID_INVALID if invalid fid_type kill f_vfsmnt vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op nfsd: handle vfs_getattr errors in acl protocol switch vfs_getattr() to struct path default SET_PERSONALITY() in linux/elf.h ceph: prepopulate inodes only when request is aborted d_hash_and_lookup(): export, switch open-coded instances 9p: switch v9fs_set_create_acl() to inode+fid, do it before d_instantiate() 9p: split dropping the acls from v9fs_set_create_acl() ...
| * new helper: file_inode(file)Al Viro2013-02-221-1/+1
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | usb: gadget: mass_storage: remove >= 0 check for unsigned typeSebastian Andrzej Siewior2013-01-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In file included from drivers/usb/gadget/acm_ms.c:43: | f_mass_storage.c:2199:18: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] | if (common->lun >= 0 && common->lun < common->nluns) | ~~~~~~~~~~~ ^ ~ common->lun is defined as "unsigned int" so its value is always >= 0. It is assigned via cbw->Lun which is defined as u8 so it is also not abused as -1. [ mina86@mina86.com : make lun unsigned int and use %u in DBG() macro for it ] Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_mass_storage: remove unused operationsAndrzej Pietrasiewicz2013-01-101-28/+1
|/ | | | | | | | | pre_eject and post_eject are not used by anyone. Removing them. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: storage_common: Drop #ifdefs used for the sake of FSG.Michal Nazarewicz2012-11-081-4/+0
| | | | | | | | | | | | storage_common.c has been used by both file_storage.c and f_mass_storage.c which had some different requirements in a few places. To accomodate for that, storage_common.c provided configuratian macros which were to be defined (or not) prior to the file #inclusion. Because now file_storage.c is no longer with us, we can remove support for those macros and thus simplify the code slightly. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: always update HS/SS descriptors and create a copy of themSebastian Andrzej Siewior2012-10-311-39/+20
| | | | | | | | | | | | | | | | | | | | | | | | HS and SS descriptors are staticaly created. They are updated during the bind process with the endpoint address, string id or interface numbers. After that, the descriptor chain is linked to struct usb_function which is used by composite in order to serve the GET_DESCRIPTOR requests, number of available configs and so on. There is no need to assign the HS descriptor only if the UDC supports HS speed because composite won't report those to the host if HS support has not been reached. The same reasoning is valid for SS. This patch makes sure each function updates HS/SS descriptors unconditionally and uses the newly introduced helper function to create a copy the descriptors for the speed which is supported by the UDC. While at that, also rename f->descriptors to f->fs_descriptors in order to make it more explicit what that means. Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: remove usb_gadget_controller_number()Sebastian Andrzej Siewior2012-09-101-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bcdDevice field is defined as |Device release number in binary-coded decimal in the USB 2.0 specification. We use this field to distinguish the UDCs from each other. In theory this could be used on the host side to apply certain quirks if the "special" UDC in combination with this gadget is used. This hasn't been done as far as I am aware. In practice it would be better to fix the UDC driver before shipping since a later release might not need this quirk anymore. There are some driver in tree (on the host side) which use the bcdDevice field to figure out special workarounds for a given firmware revision. This seems to make sense. Therefore this patch converts all gadgets (except a few) to use the kernel version instead a random 2 or 3 plus the UDC number. The few that don't report kernel's version are: - webcam This one reports always a version 0x10 so allow it to do so in future. - nokia This one reports always 0x211. The comment says that this gadget works only if the UDC supports altsettings so I added a check for this. - serial This one reports 0x2400 + UDC number. Since the gadget version is 2.4 this could make sense. Therefore bcdDevice is 0x2400 here. I also remove various gadget_is_<name> macros which are unused. The remaining few macros should be moved to feature / bug bitfield. Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: Provide a default implementation of default manufacturer stringSebastian Andrzej Siewior2012-09-101-1/+0
| | | | | | | | | | | | | | | | | Some gadgets provide custom entry here. Some may override it with an etntry that is also created by composite if there was no value sumbitted at all. This patch removes all "custom manufacturer" strings which are the same as these which are created by composite. Then it moves the creation of the default manufacturer string to usb_composite_overwrite_options() in case no command line argument has been used and the entry is still an empty string. By doing this we get rid of the global variable "composite_manufacturer" in composite. Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: mass_storage: make "file" and "ro" read only in some casesMichal Nazarewicz2012-07-021-5/+21
| | | | | | | | | | | | | | | | | The “file” sysfs entry for LUNs was writable even for non-removable LUNs and the fsg_store_file() function did not check whether LUN is removable or not. This made it possible to change or even close LUN's backing file. The same is true for “ro” sysfs entry and LUNs simulating CD-ROM. For those LUNs, the file should not be writable. This commit introduces two new device_attribute structures for those two special cases so that the file/ro sysfs entries are made non-writable when not desired. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: mass_storage: add documentationMichal Nazarewicz2012-06-151-62/+7
| | | | | | | | | | | This commit adds Documentation/usb/mass-storage.txt file. It contains description of how to use the mass storage gadget from user space. It elaborates on madule parameters and sysfs interface more then it was written in the comments in the source code. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: mass_storage: remove unused optionsMichal Nazarewicz2012-06-151-40/+10
| | | | | | | | | This commit removes thread_name and lun_name_format fields from the fsg_config structure. Those fields are not used by any in-tree code and their usefulness is rather theoretical. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: f_mass_storage: change default value of the removable parameterMichal Nazarewicz2012-06-041-4/+2
| | | | | | | | | This commit changes the default value of the removable module parameter from “y” to “n”. This comes with line with file_storag's default and seems to be a better default. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge tag 'gadget-for-v3.5' of ↵Greg Kroah-Hartman2012-05-071-7/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next usb: gadget: patches for v3.5 This pull request is quite big, but mainly because there's a giant rework of the s3c_hsotg.c driver to make it friendlier for other users. Samsung Exynos platforms use the DesignWare Core USB2 IP from Synopsys so it's a bit unfair to have the driver work for Samsung platforms only. In short, the big rework is in preparation to make the driver more reusable. Another big rework in this pull request came from Ido, where he's removing the redundant pointer for the endpoint descriptor from the controller driver's own endpoint representation. The same pointer is available through the generic struct usb_ep structure. Also on this pull request is the conversion of a few extra controller drivers to the new style registration, which allows multiple controllers to be available on the same platform and helps remove global pointers from those drivers. Together with those big changes, there's the usual fixes and cleanups to gadget drivers. Nothing major.
| * usb: gadget: f_mass_storage: remove deprecated fsg_add()Michal Nazarewicz2012-05-041-7/+0
| | | | | | | | | | | | | | | | | | There are no in-tree fsg_add() users and it has been deprecated since 2.6.35 [1dc90985d1: fsg_add() renamed to fsg_bind_config()] so out-of-tree users had more then enough time to convert. Removing. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | USB: gadget: storage gadgets send wrong error code for unknown commandsAlan Stern2012-04-121-1/+1
|/ | | | | | | | | | | | | | | | This patch (as1539) fixes a minor bug in the mass-storage gadget drivers. When an unknown command is received, the error code sent back is "Invalid Field in CDB" rather than "Invalid Command". This is because the bitmask of CDB bytes allowed to be nonzero is incorrect. When handling an unknown command, we don't care which command bytes are nonzero. All the bits in the mask should be set, not just eight of them. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: <Michal Nazarewicz <mina86@mina86.com> CC: <stable@vger.kernel.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge tag 'gadget-for-v3.4' of ↵Greg Kroah-Hartman2012-03-011-2/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next USB: Gadget: changes for 3.4 This merge is rather big. Here's what it contains: For am5536udc we have just simple coding style fixes. Nothing that has any potential to cause any issues going forward. With mv_udc, there's only one single change removing an unneeded NULL check. at91_udc also only saw a single change this merge window, and that's only removing a duplicated header. The Renesas controller has a few more involved changes. Support for SUDMAC was added, there's now a special handling of IRQ resources for when the IRQ line is shared between Renesas controller and SUDMAC, we also had a bug fix where Renesas controller would sleep in atomic context while doing DMA transfers from a tasklet. There were also a set of minor cleanups. The FSL UDC also had a scheduling in atomic context bug fix, but that's all. Thanks to Sebastian, the dummy_hcd now works better than ever with support for scatterlists and streams. Sebastian also added SuperSpeed descriptors to the serial gadgets. The highlight on this merge is the addition of a generic API for mapping and unmapping usb_requests. This will avoid code duplication on all UDC controllers and also kills all the defines for DMA_ADDR_INVALID which UDC controllers sprinkled around. A few of the UDC controllers were already converted to use this new API. Conflicts: drivers/usb/dwc3/gadget.c
| * usb: gadget: f_mass_storage: remove one FSG_NO_INTR_EPSebastian Andrzej Siewior2012-01-241-1/+0
| | | | | | | | | | | | | | | | Remove one define of FSG_NO_INTR_EP and we still have that we can use. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * usb: gadget: update Michal Nazarewicz's email addressMichal Nazarewicz2012-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | The m.nazarewicz@samsung.com email address is no longer valid, so this commit replaces it with mina86@mina86.com which is employer-agnostic and thus should be valid for foreseeable feature. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb/gadget: use common defines within the storage gadgetSebastian Andrzej Siewior2012-02-281-12/+12
| | | | | | | | | | | | | | | | | | | | This replaces the remaining defines which are available in "public" include/ directory and are re-defined by the storage gadget. This is patch is basicaly search & replace followed by the removal of the defines. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb/storage: a couple defines from drivers/usb/storage/transport.h to ↵Sebastian Andrzej Siewior2012-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | include/linux/usb/storage.h This moves the BOT data structures for CBW and CSW from drivers internal header file to global include able file in include/. The storage gadget is using the same name for CSW but a different for CBW so I fix it up properly. The same goes for the ub driver and keucr driver in staging. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | usb: gadget: f_mass_storage: Use "bool" instead of "int" in ↵Fabio Estevam2012-01-241-5/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fsg_module_parameters Fix the following build warnings: CC [M] drivers/usb/gadget/acm_ms.o drivers/usb/gadget/acm_ms.c: In function ‘__check_ro’: drivers/usb/gadget/acm_ms.c:119: warning: return from incompatible pointer type drivers/usb/gadget/acm_ms.c: In function ‘__check_removable’: drivers/usb/gadget/acm_ms.c:119: warning: return from incompatible pointer type drivers/usb/gadget/acm_ms.c: In function ‘__check_cdrom’: drivers/usb/gadget/acm_ms.c:119: warning: return from incompatible pointer type drivers/usb/gadget/acm_ms.c: In function ‘__check_nofua’: drivers/usb/gadget/acm_ms.c:119: warning: return from incompatible pointer type drivers/usb/gadget/acm_ms.c: In function ‘__check_stall’: drivers/usb/gadget/acm_ms.c:119: warning: return from incompatible pointer type CC [M] drivers/usb/gadget/mass_storage.o drivers/usb/gadget/mass_storage.c: In function ‘__check_ro’: drivers/usb/gadget/mass_storage.c:94: warning: return from incompatible pointer type drivers/usb/gadget/mass_storage.c: In function ‘__check_removable’: drivers/usb/gadget/mass_storage.c:94: warning: return from incompatible pointer type drivers/usb/gadget/mass_storage.c: In function ‘__check_cdrom’: drivers/usb/gadget/mass_storage.c:94: warning: return from incompatible pointer type drivers/usb/gadget/mass_storage.c: In function ‘__check_nofua’: drivers/usb/gadget/mass_storage.c:94: warning: return from incompatible pointer type drivers/usb/gadget/mass_storage.c: In function ‘__check_stall’: drivers/usb/gadget/mass_storage.c:94: warning: return from incompatible pointer type Declare the fsg_module_parameters fields as "bool" so that they can match the types passed in FSG_MODULE_PARAM_ARRAY macro. Since commit 493c90ef (module_param: check that bool parameters really are bool.), moduleparam.h was changed in a way that the "bool" parameter type now really requires "bool" type and no longer allows "unsigned int". Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
OpenPOWER on IntegriCloud