Merge 4.9.197 into android-4.9-q
Changes in 4.9.197
KVM: s390: Test for bad access register and size at the start of S390_MEM_OP
s390/topology: avoid firing events before kobjs are created
s390/cio: avoid calling strlen on null pointer
s390/cio: exclude subchannels with no parent from pseudo check
KVM: nVMX: handle page fault in vmread fix
ASoC: Define a set of DAPM pre/post-up events
powerpc/powernv: Restrict OPAL symbol map to only be readable by root
can: mcp251x: mcp251x_hw_reset(): allow more time after a reset
crypto: qat - Silence smp_processor_id() warning
usercopy: Avoid HIGHMEM pfn warning
timer: Read jiffies once when forwarding base clk
watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout
ieee802154: atusb: fix use-after-free at disconnect
cfg80211: initialize on-stack chandefs
ima: always return negative code for error
fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
9p: avoid attaching writeback_fid on mmap with type PRIVATE
xen/pci: reserve MCFG areas earlier
ceph: fix directories inode i_blkbits initialization
ceph: reconnect connection if session hang in opening state
drm/amdgpu: Check for valid number of registers to read
thermal: Fix use-after-free when unregistering thermal zone device
fuse: fix memleak in cuse_channel_open
sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr()
kernel/elfcore.c: include proper prototypes
tools lib traceevent: Do not free tep->cmdlines in add_new_comm() on failure
perf tools: Fix segfault in cpu_cache_level__read()
perf stat: Fix a segmentation fault when using repeat forever
perf stat: Reset previous counts on repeat with interval
crypto: caam - fix concurrency issue in givencrypt descriptor
coresight: etm4x: Use explicit barriers on enable/disable
cfg80211: add and use strongly typed element iteration macros
cfg80211: Use const more consistently in for_each_element macros
nl80211: validate beacon head
ASoC: sgtl5000: Improve VAG power and mute control
panic: ensure preemption is disabled during panic()
USB: rio500: Remove Rio 500 kernel driver
USB: yurex: Don't retry on unexpected errors
USB: yurex: fix NULL-derefs on disconnect
USB: usb-skeleton: fix runtime PM after driver unbind
USB: usb-skeleton: fix NULL-deref on disconnect
xhci: Fix false warning message about wrong bounce buffer write length
xhci: Prevent device initiated U1/U2 link pm if exit latency is too long
xhci: Check all endpoints for LPM timeout
usb: xhci: wait for CNR controller not ready bit in xhci resume
xhci: Increase STS_SAVE timeout in xhci_suspend()
USB: adutux: remove redundant variable minor
USB: adutux: fix use-after-free on disconnect
USB: adutux: fix NULL-derefs on disconnect
USB: adutux: fix use-after-free on release
USB: iowarrior: fix use-after-free on disconnect
USB: iowarrior: fix use-after-free on release
USB: iowarrior: fix use-after-free after driver unbind
USB: usblp: fix runtime PM after driver unbind
USB: chaoskey: fix use-after-free on release
USB: ldusb: fix NULL-derefs on driver unbind
serial: uartlite: fix exit path null pointer
USB: serial: keyspan: fix NULL-derefs on open() and write()
USB: serial: ftdi_sio: add device IDs for Sienna and Echelon PL-20
USB: serial: option: add Telit FN980 compositions
USB: serial: option: add support for Cinterion CLS8 devices
USB: serial: fix runtime PM after driver unbind
USB: usblcd: fix I/O after disconnect
USB: microtek: fix info-leak at probe
USB: dummy-hcd: fix power budget for SuperSpeed mode
usb: renesas_usbhs: gadget: Do not discard queues in usb_ep_set_{halt,wedge}()
usb: renesas_usbhs: gadget: Fix usb_ep_set_{halt,wedge}() behavior
USB: legousbtower: fix slab info leak at probe
USB: legousbtower: fix deadlock on disconnect
USB: legousbtower: fix potential NULL-deref on disconnect
USB: legousbtower: fix open after failed reset request
USB: legousbtower: fix use-after-free on release
staging: vt6655: Fix memory leak in vt6655_probe
iio: adc: ad799x: fix probe error handling
iio: light: opt3001: fix mutex unlock race
efivar/ssdt: Don't iterate over EFI vars if no SSDT override was specified
perf llvm: Don't access out-of-scope array
perf inject jit: Fix JIT_CODE_MOVE filename
CIFS: Gracefully handle QueryInfo errors during open
CIFS: Force revalidate inode when dentry is stale
CIFS: Force reval dentry if LOOKUP_REVAL flag is set
kernel/sysctl.c: do not override max_threads provided by userspace
staging: fbtft: Stop using BL_CORE_DRIVER1
Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
MIPS: Disable Loongson MMI instructions for kernel build
Fix the locking in dcache_readdir() and friends
media: stkwebcam: fix runtime PM after driver unbind
tracing/hwlat: Report total time spent in all NMIs during the sample
tracing/hwlat: Don't ignore outer-loop duration when calculating max_latency
tracing: Get trace_array reference for available_tracers files
x86/asm: Fix MWAITX C-state hint value
xfs: clear sb->s_fs_info on mount failure
Linux 4.9.197
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -1,138 +0,0 @@
|
||||
Copyright (C) 1999, 2000 Bruce Tenison
|
||||
Portions Copyright (C) 1999, 2000 David Nelson
|
||||
Thanks to David Nelson for guidance and the usage of the scanner.txt
|
||||
and scanner.c files to model our driver and this informative file.
|
||||
|
||||
Mar. 2, 2000
|
||||
|
||||
CHANGES
|
||||
|
||||
- Initial Revision
|
||||
|
||||
|
||||
OVERVIEW
|
||||
|
||||
This README will address issues regarding how to configure the kernel
|
||||
to access a RIO 500 mp3 player.
|
||||
Before I explain how to use this to access the Rio500 please be warned:
|
||||
|
||||
W A R N I N G:
|
||||
--------------
|
||||
|
||||
Please note that this software is still under development. The authors
|
||||
are in no way responsible for any damage that may occur, no matter how
|
||||
inconsequential.
|
||||
|
||||
It seems that the Rio has a problem when sending .mp3 with low batteries.
|
||||
I suggest when the batteries are low and you want to transfer stuff that you
|
||||
replace it with a fresh one. In my case, what happened is I lost two 16kb
|
||||
blocks (they are no longer usable to store information to it). But I don't
|
||||
know if that's normal or not; it could simply be a problem with the flash
|
||||
memory.
|
||||
|
||||
In an extreme case, I left my Rio playing overnight and the batteries wore
|
||||
down to nothing and appear to have corrupted the flash memory. My RIO
|
||||
needed to be replaced as a result. Diamond tech support is aware of the
|
||||
problem. Do NOT allow your batteries to wear down to nothing before
|
||||
changing them. It appears RIO 500 firmware does not handle low battery
|
||||
power well at all.
|
||||
|
||||
On systems with OHCI controllers, the kernel OHCI code appears to have
|
||||
power on problems with some chipsets. If you are having problems
|
||||
connecting to your RIO 500, try turning it on first and then plugging it
|
||||
into the USB cable.
|
||||
|
||||
Contact information:
|
||||
--------------------
|
||||
|
||||
The main page for the project is hosted at sourceforge.net in the following
|
||||
URL: <http://rio500.sourceforge.net>. You can also go to the project's
|
||||
sourceforge home page at: <http://sourceforge.net/projects/rio500/>.
|
||||
There is also a mailing list: rio500-users@lists.sourceforge.net
|
||||
|
||||
Authors:
|
||||
-------
|
||||
|
||||
Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith
|
||||
Clayton <kclayton@jps.net> is incharge of the PPC port and making sure
|
||||
things work there. Bruce Tenison <btenison@dibbs.net> is adding support
|
||||
for .fon files and also does testing. The program will mostly sure be
|
||||
re-written and Pete Ikusz along with the rest will re-design it. I would
|
||||
also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use
|
||||
with some important information regarding the communication with the Rio.
|
||||
|
||||
ADDITIONAL INFORMATION and Userspace tools
|
||||
|
||||
http://rio500.sourceforge.net/
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
|
||||
A host with a USB port. Ideally, either a UHCI (Intel) or OHCI
|
||||
(Compaq and others) hardware port should work.
|
||||
|
||||
A Linux development kernel (2.3.x) with USB support enabled or a
|
||||
backported version to linux-2.2.x. See http://www.linux-usb.org for
|
||||
more information on accomplishing this.
|
||||
|
||||
A Linux kernel with RIO 500 support enabled.
|
||||
|
||||
'lspci' which is only needed to determine the type of USB hardware
|
||||
available in your machine.
|
||||
|
||||
CONFIGURATION
|
||||
|
||||
Using `lspci -v`, determine the type of USB hardware available.
|
||||
|
||||
If you see something like:
|
||||
|
||||
USB Controller: ......
|
||||
Flags: .....
|
||||
I/O ports at ....
|
||||
|
||||
Then you have a UHCI based controller.
|
||||
|
||||
If you see something like:
|
||||
|
||||
USB Controller: .....
|
||||
Flags: ....
|
||||
Memory at .....
|
||||
|
||||
Then you have a OHCI based controller.
|
||||
|
||||
Using `make menuconfig` or your preferred method for configuring the
|
||||
kernel, select 'Support for USB', 'OHCI/UHCI' depending on your
|
||||
hardware (determined from the steps above), 'USB Diamond Rio500 support', and
|
||||
'Preliminary USB device filesystem'. Compile and install the modules
|
||||
(you may need to execute `depmod -a` to update the module
|
||||
dependencies).
|
||||
|
||||
Add a device for the USB rio500:
|
||||
`mknod /dev/usb/rio500 c 180 64`
|
||||
|
||||
Set appropriate permissions for /dev/usb/rio500 (don't forget about
|
||||
group and world permissions). Both read and write permissions are
|
||||
required for proper operation.
|
||||
|
||||
Load the appropriate modules (if compiled as modules):
|
||||
|
||||
OHCI:
|
||||
modprobe usbcore
|
||||
modprobe usb-ohci
|
||||
modprobe rio500
|
||||
|
||||
UHCI:
|
||||
modprobe usbcore
|
||||
modprobe usb-uhci (or uhci)
|
||||
modprobe rio500
|
||||
|
||||
That's it. The Rio500 Utils at: http://rio500.sourceforge.net should
|
||||
be able to access the rio500.
|
||||
|
||||
BUGS
|
||||
|
||||
If you encounter any problems feel free to drop me an email.
|
||||
|
||||
Bruce Tenison
|
||||
btenison@dibbs.net
|
||||
|
||||
@@ -12486,13 +12486,6 @@ W: http://www.linux-usb.org/usbnet
|
||||
S: Maintained
|
||||
F: drivers/net/usb/dm9601.c
|
||||
|
||||
USB DIAMOND RIO500 DRIVER
|
||||
M: Cesar Miquel <miquel@df.uba.ar>
|
||||
L: rio500-users@lists.sourceforge.net
|
||||
W: http://rio500.sourceforge.net
|
||||
S: Maintained
|
||||
F: drivers/usb/misc/rio500*
|
||||
|
||||
USB EHCI DRIVER
|
||||
M: Alan Stern <stern@rowland.harvard.edu>
|
||||
L: linux-usb@vger.kernel.org
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
VERSION = 4
|
||||
PATCHLEVEL = 9
|
||||
SUBLEVEL = 196
|
||||
SUBLEVEL = 197
|
||||
EXTRAVERSION =
|
||||
NAME = Roaring Lionus
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ CONFIG_USB_SERIAL_PL2303=m
|
||||
CONFIG_USB_SERIAL_CYBERJACK=m
|
||||
CONFIG_USB_SERIAL_XIRCOM=m
|
||||
CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_EXT2_FS=m
|
||||
CONFIG_EXT3_FS=m
|
||||
CONFIG_MSDOS_FS=y
|
||||
|
||||
@@ -207,7 +207,6 @@ CONFIG_USB_SERIAL_XIRCOM=m
|
||||
CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_EMI62=m
|
||||
CONFIG_USB_EMI26=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -591,7 +591,6 @@ CONFIG_USB_SERIAL_XIRCOM=m
|
||||
CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_EMI62=m
|
||||
CONFIG_USB_EMI26=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -354,7 +354,6 @@ CONFIG_USB_EMI62=m
|
||||
CONFIG_USB_EMI26=m
|
||||
CONFIG_USB_ADUTUX=m
|
||||
CONFIG_USB_SEVSEG=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -202,7 +202,6 @@ CONFIG_USB_SERIAL_XIRCOM=m
|
||||
CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_EMI62=m
|
||||
CONFIG_USB_EMI26=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -637,7 +637,6 @@ CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_EMI62=m
|
||||
CONFIG_USB_EMI26=m
|
||||
CONFIG_USB_ADUTUX=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -350,7 +350,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y
|
||||
CONFIG_USB_SERIAL_CYBERJACK=m
|
||||
CONFIG_USB_SERIAL_XIRCOM=m
|
||||
CONFIG_USB_SERIAL_OMNINET=m
|
||||
CONFIG_USB_RIO500=m
|
||||
CONFIG_USB_LEGOTOWER=m
|
||||
CONFIG_USB_LCD=m
|
||||
CONFIG_USB_LED=m
|
||||
|
||||
@@ -43,6 +43,10 @@ else
|
||||
$(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)
|
||||
endif
|
||||
|
||||
# Some -march= flags enable MMI instructions, and GCC complains about that
|
||||
# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
|
||||
cflags-y += $(call cc-option,-mno-loongson-mmi)
|
||||
|
||||
#
|
||||
# Loongson Machines' Support
|
||||
#
|
||||
|
||||
@@ -8,6 +8,7 @@ ccflags-vdso := \
|
||||
$(filter -mmicromips,$(KBUILD_CFLAGS)) \
|
||||
$(filter -march=%,$(KBUILD_CFLAGS)) \
|
||||
$(filter -m%-float,$(KBUILD_CFLAGS)) \
|
||||
$(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \
|
||||
-D__VDSO__
|
||||
cflags-vdso := $(ccflags-vdso) \
|
||||
$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
|
||||
|
||||
@@ -579,7 +579,10 @@ static ssize_t symbol_map_read(struct file *fp, struct kobject *kobj,
|
||||
bin_attr->size);
|
||||
}
|
||||
|
||||
static BIN_ATTR_RO(symbol_map, 0);
|
||||
static struct bin_attribute symbol_map_attr = {
|
||||
.attr = {.name = "symbol_map", .mode = 0400},
|
||||
.read = symbol_map_read
|
||||
};
|
||||
|
||||
static void opal_export_symmap(void)
|
||||
{
|
||||
@@ -596,10 +599,10 @@ static void opal_export_symmap(void)
|
||||
return;
|
||||
|
||||
/* Setup attributes */
|
||||
bin_attr_symbol_map.private = __va(be64_to_cpu(syms[0]));
|
||||
bin_attr_symbol_map.size = be64_to_cpu(syms[1]);
|
||||
symbol_map_attr.private = __va(be64_to_cpu(syms[0]));
|
||||
symbol_map_attr.size = be64_to_cpu(syms[1]);
|
||||
|
||||
rc = sysfs_create_bin_file(opal_kobj, &bin_attr_symbol_map);
|
||||
rc = sysfs_create_bin_file(opal_kobj, &symbol_map_attr);
|
||||
if (rc)
|
||||
pr_warn("Error %d creating OPAL symbols file\n", rc);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,8 @@ int arch_update_cpu_topology(void)
|
||||
topology_update_polarization_simple();
|
||||
for_each_online_cpu(cpu) {
|
||||
dev = get_cpu_device(cpu);
|
||||
kobject_uevent(&dev->kobj, KOBJ_CHANGE);
|
||||
if (dev)
|
||||
kobject_uevent(&dev->kobj, KOBJ_CHANGE);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3033,7 +3033,7 @@ static long kvm_s390_guest_mem_op(struct kvm_vcpu *vcpu,
|
||||
const u64 supported_flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION
|
||||
| KVM_S390_MEMOP_F_CHECK_ONLY;
|
||||
|
||||
if (mop->flags & ~supported_flags)
|
||||
if (mop->flags & ~supported_flags || mop->ar >= NUM_ACRS || !mop->size)
|
||||
return -EINVAL;
|
||||
|
||||
if (mop->size > MEM_OP_MAX_SIZE)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define MWAIT_ECX_INTERRUPT_BREAK 0x1
|
||||
#define MWAITX_ECX_TIMER_ENABLE BIT(1)
|
||||
#define MWAITX_MAX_LOOPS ((u32)-1)
|
||||
#define MWAITX_DISABLE_CSTATES 0xf
|
||||
#define MWAITX_DISABLE_CSTATES 0xf0
|
||||
|
||||
static inline void __monitor(const void *eax, unsigned long ecx,
|
||||
unsigned long edx)
|
||||
|
||||
@@ -7668,7 +7668,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
|
||||
/* _system ok, as nested_vmx_check_permission verified cpl=0 */
|
||||
if (kvm_write_guest_virt_system(vcpu, gva, &field_value,
|
||||
(is_long_mode(vcpu) ? 8 : 4),
|
||||
NULL))
|
||||
&e))
|
||||
kvm_inject_page_fault(vcpu, &e);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ static void delay_mwaitx(unsigned long __loops)
|
||||
__monitorx(raw_cpu_ptr(&cpu_tss), 0, 0);
|
||||
|
||||
/*
|
||||
* AMD, like Intel, supports the EAX hint and EAX=0xf
|
||||
* means, do not enter any deep C-state and we use it
|
||||
* AMD, like Intel's MWAIT version, supports the EAX hint and
|
||||
* EAX=0xf0 means, do not enter any deep C-state and we use it
|
||||
* here in delay() to minimize wakeup latency.
|
||||
*/
|
||||
__mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE);
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
#define DESC_AEAD_BASE (4 * CAAM_CMD_SZ)
|
||||
#define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 11 * CAAM_CMD_SZ)
|
||||
#define DESC_AEAD_DEC_LEN (DESC_AEAD_BASE + 15 * CAAM_CMD_SZ)
|
||||
#define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 9 * CAAM_CMD_SZ)
|
||||
#define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 10 * CAAM_CMD_SZ)
|
||||
|
||||
/* Note: Nonce is counted in enckeylen */
|
||||
#define DESC_AEAD_CTR_RFC3686_LEN (4 * CAAM_CMD_SZ)
|
||||
@@ -474,6 +474,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
|
||||
u32 geniv, moveiv;
|
||||
u32 ctx1_iv_off = 0;
|
||||
u32 *desc;
|
||||
u32 *wait_cmd;
|
||||
const bool ctr_mode = ((ctx->class1_alg_type & OP_ALG_AAI_MASK) ==
|
||||
OP_ALG_AAI_CTR_MOD128);
|
||||
const bool is_rfc3686 = alg->caam.rfc3686;
|
||||
@@ -736,6 +737,14 @@ copy_iv:
|
||||
|
||||
/* Will read cryptlen */
|
||||
append_math_add(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
|
||||
|
||||
/*
|
||||
* Wait for IV transfer (ofifo -> class2) to finish before starting
|
||||
* ciphertext transfer (ofifo -> external memory).
|
||||
*/
|
||||
wait_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | JUMP_COND_NIFP);
|
||||
set_jump_tgt_here(desc, wait_cmd);
|
||||
|
||||
append_seq_fifo_load(desc, 0, FIFOLD_CLASS_BOTH | KEY_VLF |
|
||||
FIFOLD_TYPE_MSG1OUT2 | FIFOLD_TYPE_LASTBOTH);
|
||||
append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | KEY_VLF);
|
||||
|
||||
@@ -95,7 +95,7 @@ struct service_hndl {
|
||||
|
||||
static inline int get_current_node(void)
|
||||
{
|
||||
return topology_physical_package_id(smp_processor_id());
|
||||
return topology_physical_package_id(raw_smp_processor_id());
|
||||
}
|
||||
|
||||
int adf_service_register(struct service_hndl *service);
|
||||
|
||||
@@ -243,6 +243,9 @@ static __init int efivar_ssdt_load(void)
|
||||
void *data;
|
||||
int ret;
|
||||
|
||||
if (!efivar_ssdt[0])
|
||||
return 0;
|
||||
|
||||
ret = efivar_init(efivar_ssdt_iter, &entries, true, &entries);
|
||||
|
||||
list_for_each_entry_safe(entry, aux, &entries, list) {
|
||||
|
||||
@@ -430,6 +430,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
|
||||
if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
|
||||
sh_num = 0xffffffff;
|
||||
|
||||
if (info->read_mmr_reg.count > 128)
|
||||
return -EINVAL;
|
||||
|
||||
regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL);
|
||||
if (!regs)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -181,6 +181,12 @@ static void etm4_enable_hw(void *info)
|
||||
if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0))
|
||||
dev_err(drvdata->dev,
|
||||
"timeout while waiting for Idle Trace Status\n");
|
||||
/*
|
||||
* As recommended by section 4.3.7 ("Synchronization when using the
|
||||
* memory-mapped interface") of ARM IHI 0064D
|
||||
*/
|
||||
dsb(sy);
|
||||
isb();
|
||||
|
||||
CS_LOCK(drvdata->base);
|
||||
|
||||
@@ -323,8 +329,12 @@ static void etm4_disable_hw(void *info)
|
||||
/* EN, bit[0] Trace unit enable bit */
|
||||
control &= ~0x1;
|
||||
|
||||
/* make sure everything completes before disabling */
|
||||
mb();
|
||||
/*
|
||||
* Make sure everything completes before disabling, as recommended
|
||||
* by section 7.3.77 ("TRCVICTLR, ViewInst Main Control Register,
|
||||
* SSTATUS") of ARM IHI 0064D
|
||||
*/
|
||||
dsb(sy);
|
||||
isb();
|
||||
writel_relaxed(control, drvdata->base + TRCPRGCTLR);
|
||||
|
||||
|
||||
@@ -817,10 +817,10 @@ static int ad799x_probe(struct i2c_client *client,
|
||||
|
||||
ret = ad799x_write_config(st, st->chip_config->default_config);
|
||||
if (ret < 0)
|
||||
goto error_disable_reg;
|
||||
goto error_disable_vref;
|
||||
ret = ad799x_read_config(st);
|
||||
if (ret < 0)
|
||||
goto error_disable_reg;
|
||||
goto error_disable_vref;
|
||||
st->config = ret;
|
||||
|
||||
ret = iio_triggered_buffer_setup(indio_dev, NULL,
|
||||
|
||||
@@ -695,6 +695,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)
|
||||
struct iio_dev *iio = _iio;
|
||||
struct opt3001 *opt = iio_priv(iio);
|
||||
int ret;
|
||||
bool wake_result_ready_queue = false;
|
||||
|
||||
if (!opt->ok_to_ignore_lock)
|
||||
mutex_lock(&opt->lock);
|
||||
@@ -729,13 +730,16 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)
|
||||
}
|
||||
opt->result = ret;
|
||||
opt->result_ready = true;
|
||||
wake_up(&opt->result_ready_queue);
|
||||
wake_result_ready_queue = true;
|
||||
}
|
||||
|
||||
out:
|
||||
if (!opt->ok_to_ignore_lock)
|
||||
mutex_unlock(&opt->lock);
|
||||
|
||||
if (wake_result_ready_queue)
|
||||
wake_up(&opt->result_ready_queue);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -647,8 +647,7 @@ static int v4l_stk_release(struct file *fp)
|
||||
dev->owner = NULL;
|
||||
}
|
||||
|
||||
if (is_present(dev))
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
mutex_unlock(&dev->lock);
|
||||
return v4l2_fh_release(fp);
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv,
|
||||
static int mcp251x_hw_reset(struct spi_device *spi)
|
||||
{
|
||||
struct mcp251x_priv *priv = spi_get_drvdata(spi);
|
||||
u8 reg;
|
||||
unsigned long timeout;
|
||||
int ret;
|
||||
|
||||
/* Wait for oscillator startup timer after power up */
|
||||
@@ -641,10 +641,19 @@ static int mcp251x_hw_reset(struct spi_device *spi)
|
||||
/* Wait for oscillator startup timer after reset */
|
||||
mdelay(MCP251X_OST_DELAY_MS);
|
||||
|
||||
reg = mcp251x_read_reg(spi, CANSTAT);
|
||||
if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
|
||||
return -ENODEV;
|
||||
/* Wait for reset to finish */
|
||||
timeout = jiffies + HZ;
|
||||
while ((mcp251x_read_reg(spi, CANSTAT) & CANCTRL_REQOP_MASK) !=
|
||||
CANCTRL_REQOP_CONF) {
|
||||
usleep_range(MCP251X_OST_DELAY_MS * 1000,
|
||||
MCP251X_OST_DELAY_MS * 1000 * 2);
|
||||
|
||||
if (time_after(jiffies, timeout)) {
|
||||
dev_err(&spi->dev,
|
||||
"MCP251x didn't enter in conf mode after reset\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -838,10 +838,11 @@ static void atusb_disconnect(struct usb_interface *interface)
|
||||
|
||||
ieee802154_unregister_hw(atusb->hw);
|
||||
|
||||
usb_put_dev(atusb->usb_dev);
|
||||
|
||||
ieee802154_free_hw(atusb->hw);
|
||||
|
||||
usb_set_intfdata(interface, NULL);
|
||||
usb_put_dev(atusb->usb_dev);
|
||||
|
||||
pr_debug("atusb_disconnect done\n");
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
|
||||
goto error;
|
||||
}
|
||||
/* Check for trailing stuff. */
|
||||
if (i == num_devices && strlen(buf) > 0) {
|
||||
if (i == num_devices && buf && strlen(buf) > 0) {
|
||||
rc = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1120,6 +1120,8 @@ device_initcall(cio_settle_init);
|
||||
|
||||
int sch_is_pseudo_sch(struct subchannel *sch)
|
||||
{
|
||||
if (!sch->dev.parent)
|
||||
return 0;
|
||||
return sch == to_css(sch->dev.parent)->pseudo_subchannel;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ static int fbtft_request_gpios_dt(struct fbtft_par *par)
|
||||
static int fbtft_backlight_update_status(struct backlight_device *bd)
|
||||
{
|
||||
struct fbtft_par *par = bl_get_data(bd);
|
||||
bool polarity = !!(bd->props.state & BL_CORE_DRIVER1);
|
||||
bool polarity = par->polarity;
|
||||
|
||||
fbtft_par_dbg(DEBUG_BACKLIGHT, par,
|
||||
"%s: polarity=%d, power=%d, fb_blank=%d\n",
|
||||
@@ -296,7 +296,7 @@ void fbtft_register_backlight(struct fbtft_par *par)
|
||||
/* Assume backlight is off, get polarity from current state of pin */
|
||||
bl_props.power = FB_BLANK_POWERDOWN;
|
||||
if (!gpio_get_value(par->gpio.led[0]))
|
||||
bl_props.state |= BL_CORE_DRIVER1;
|
||||
par->polarity = true;
|
||||
|
||||
bd = backlight_device_register(dev_driver_string(par->info->device),
|
||||
par->info->device, par, &fbtft_bl_ops, &bl_props);
|
||||
@@ -814,7 +814,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
if (par->gamma.curves && gamma) {
|
||||
if (fbtft_gamma_parse_str(par,
|
||||
par->gamma.curves, gamma, strlen(gamma)))
|
||||
goto alloc_fail;
|
||||
goto release_framebuf;
|
||||
}
|
||||
|
||||
/* Transmit buffer */
|
||||
@@ -839,7 +839,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
|
||||
}
|
||||
if (!txbuf)
|
||||
goto alloc_fail;
|
||||
goto release_framebuf;
|
||||
par->txbuf.buf = txbuf;
|
||||
par->txbuf.len = txbuflen;
|
||||
}
|
||||
@@ -875,6 +875,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
|
||||
return info;
|
||||
|
||||
release_framebuf:
|
||||
framebuffer_release(info);
|
||||
|
||||
alloc_fail:
|
||||
vfree(vmem);
|
||||
|
||||
|
||||
@@ -241,6 +241,7 @@ struct fbtft_par {
|
||||
ktime_t update_time;
|
||||
bool bgr;
|
||||
void *extra;
|
||||
bool polarity;
|
||||
};
|
||||
|
||||
#define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int))
|
||||
|
||||
@@ -1673,8 +1673,10 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
|
||||
|
||||
priv->hw->max_signal = 100;
|
||||
|
||||
if (vnt_init(priv))
|
||||
if (vnt_init(priv)) {
|
||||
device_free_info(priv);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
device_print_info(priv);
|
||||
pci_set_drvdata(pcid, priv);
|
||||
|
||||
@@ -402,7 +402,7 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
|
||||
mod_delayed_work(system_freezable_wq, &tz->poll_queue,
|
||||
msecs_to_jiffies(delay));
|
||||
else
|
||||
cancel_delayed_work(&tz->poll_queue);
|
||||
cancel_delayed_work_sync(&tz->poll_queue);
|
||||
}
|
||||
|
||||
static void monitor_thermal_zone(struct thermal_zone_device *tz)
|
||||
|
||||
@@ -746,7 +746,8 @@ err_uart:
|
||||
static void __exit ulite_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&ulite_platform_driver);
|
||||
uart_unregister_driver(&ulite_uart_driver);
|
||||
if (ulite_uart_driver.state)
|
||||
uart_unregister_driver(&ulite_uart_driver);
|
||||
}
|
||||
|
||||
module_init(ulite_init);
|
||||
|
||||
@@ -474,10 +474,12 @@ static int usblp_release(struct inode *inode, struct file *file)
|
||||
|
||||
mutex_lock(&usblp_mutex);
|
||||
usblp->used = 0;
|
||||
if (usblp->present) {
|
||||
if (usblp->present)
|
||||
usblp_unlink_urbs(usblp);
|
||||
usb_autopm_put_interface(usblp->intf);
|
||||
} else /* finish cleanup from disconnect */
|
||||
|
||||
usb_autopm_put_interface(usblp->intf);
|
||||
|
||||
if (!usblp->present) /* finish cleanup from disconnect */
|
||||
usblp_cleanup(usblp);
|
||||
mutex_unlock(&usblp_mutex);
|
||||
return 0;
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#define DRIVER_VERSION "02 May 2005"
|
||||
|
||||
#define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */
|
||||
#define POWER_BUDGET_3 900 /* in mA */
|
||||
|
||||
static const char driver_name[] = "dummy_hcd";
|
||||
static const char driver_desc[] = "USB Host+Gadget Emulator";
|
||||
@@ -2433,7 +2434,7 @@ static int dummy_start_ss(struct dummy_hcd *dum_hcd)
|
||||
dum_hcd->rh_state = DUMMY_RH_RUNNING;
|
||||
dum_hcd->stream_en_ep = 0;
|
||||
INIT_LIST_HEAD(&dum_hcd->urbp_list);
|
||||
dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET;
|
||||
dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET_3;
|
||||
dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING;
|
||||
dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1;
|
||||
#ifdef CONFIG_USB_OTG
|
||||
|
||||
@@ -3200,10 +3200,10 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
|
||||
if (usb_urb_dir_out(urb)) {
|
||||
len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
|
||||
seg->bounce_buf, new_buff_len, enqd_len);
|
||||
if (len != seg->bounce_len)
|
||||
if (len != new_buff_len)
|
||||
xhci_warn(xhci,
|
||||
"WARN Wrong bounce buffer write length: %zu != %d\n",
|
||||
len, seg->bounce_len);
|
||||
len, new_buff_len);
|
||||
seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,
|
||||
max_pkt, DMA_TO_DEVICE);
|
||||
} else {
|
||||
|
||||
@@ -985,7 +985,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
|
||||
command |= CMD_CSS;
|
||||
writel(command, &xhci->op_regs->command);
|
||||
if (xhci_handshake(&xhci->op_regs->status,
|
||||
STS_SAVE, 0, 10 * 1000)) {
|
||||
STS_SAVE, 0, 20 * 1000)) {
|
||||
xhci_warn(xhci, "WARN: xHC save state timeout\n");
|
||||
spin_unlock_irq(&xhci->lock);
|
||||
return -ETIMEDOUT;
|
||||
@@ -1045,6 +1045,18 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
|
||||
hibernated = true;
|
||||
|
||||
if (!hibernated) {
|
||||
/*
|
||||
* Some controllers might lose power during suspend, so wait
|
||||
* for controller not ready bit to clear, just as in xHC init.
|
||||
*/
|
||||
retval = xhci_handshake(&xhci->op_regs->status,
|
||||
STS_CNR, 0, 10 * 1000 * 1000);
|
||||
if (retval) {
|
||||
xhci_warn(xhci, "Controller not ready at resume %d\n",
|
||||
retval);
|
||||
spin_unlock_irq(&xhci->lock);
|
||||
return retval;
|
||||
}
|
||||
/* step 1: restore register */
|
||||
xhci_restore_registers(xhci);
|
||||
/* step 2: initialize command ring buffer */
|
||||
@@ -4510,12 +4522,12 @@ static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci,
|
||||
alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
|
||||
desc, state, timeout);
|
||||
|
||||
/* If we found we can't enable hub-initiated LPM, or
|
||||
/* If we found we can't enable hub-initiated LPM, and
|
||||
* the U1 or U2 exit latency was too high to allow
|
||||
* device-initiated LPM as well, just stop searching.
|
||||
* device-initiated LPM as well, then we will disable LPM
|
||||
* for this device, so stop searching any further.
|
||||
*/
|
||||
if (alt_timeout == USB3_LPM_DISABLED ||
|
||||
alt_timeout == USB3_LPM_DEVICE_INITIATED) {
|
||||
if (alt_timeout == USB3_LPM_DISABLED) {
|
||||
*timeout = alt_timeout;
|
||||
return -E2BIG;
|
||||
}
|
||||
@@ -4626,10 +4638,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd,
|
||||
if (intf->dev.driver) {
|
||||
driver = to_usb_driver(intf->dev.driver);
|
||||
if (driver && driver->disable_hub_initiated_lpm) {
|
||||
dev_dbg(&udev->dev, "Hub-initiated %s disabled "
|
||||
"at request of driver %s\n",
|
||||
state_name, driver->name);
|
||||
return xhci_get_timeout_no_hub_lpm(udev, state);
|
||||
dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
|
||||
state_name, driver->name);
|
||||
timeout = xhci_get_timeout_no_hub_lpm(udev,
|
||||
state);
|
||||
if (timeout == USB3_LPM_DISABLED)
|
||||
return timeout;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -724,6 +724,10 @@ static int mts_usb_probe(struct usb_interface *intf,
|
||||
|
||||
}
|
||||
|
||||
if (ep_in_current != &ep_in_set[2]) {
|
||||
MTS_WARNING("couldn't find two input bulk endpoints. Bailing out.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if ( ep_out == -1 ) {
|
||||
MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );
|
||||
|
||||
@@ -46,16 +46,6 @@ config USB_SEVSEG
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called usbsevseg.
|
||||
|
||||
config USB_RIO500
|
||||
tristate "USB Diamond Rio500 support"
|
||||
help
|
||||
Say Y here if you want to connect a USB Rio500 mp3 player to your
|
||||
computer's USB port. Please read <file:Documentation/usb/rio.txt>
|
||||
for more information.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called rio500.
|
||||
|
||||
config USB_LEGOTOWER
|
||||
tristate "USB Lego Infrared Tower support"
|
||||
help
|
||||
|
||||
@@ -16,7 +16,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
|
||||
obj-$(CONFIG_USB_LCD) += usblcd.o
|
||||
obj-$(CONFIG_USB_LD) += ldusb.o
|
||||
obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
|
||||
obj-$(CONFIG_USB_RIO500) += rio500.o
|
||||
obj-$(CONFIG_USB_TEST) += usbtest.o
|
||||
obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o
|
||||
obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
|
||||
|
||||
@@ -80,6 +80,7 @@ struct adu_device {
|
||||
char serial_number[8];
|
||||
|
||||
int open_count; /* number of times this port has been opened */
|
||||
unsigned long disconnected:1;
|
||||
|
||||
char *read_buffer_primary;
|
||||
int read_buffer_length;
|
||||
@@ -121,7 +122,7 @@ static void adu_abort_transfers(struct adu_device *dev)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
if (dev->udev == NULL)
|
||||
if (dev->disconnected)
|
||||
return;
|
||||
|
||||
/* shutdown transfer */
|
||||
@@ -151,6 +152,7 @@ static void adu_delete(struct adu_device *dev)
|
||||
kfree(dev->read_buffer_secondary);
|
||||
kfree(dev->interrupt_in_buffer);
|
||||
kfree(dev->interrupt_out_buffer);
|
||||
usb_put_dev(dev->udev);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
@@ -244,7 +246,7 @@ static int adu_open(struct inode *inode, struct file *file)
|
||||
}
|
||||
|
||||
dev = usb_get_intfdata(interface);
|
||||
if (!dev || !dev->udev) {
|
||||
if (!dev) {
|
||||
retval = -ENODEV;
|
||||
goto exit_no_device;
|
||||
}
|
||||
@@ -327,7 +329,7 @@ static int adu_release(struct inode *inode, struct file *file)
|
||||
}
|
||||
|
||||
adu_release_internal(dev);
|
||||
if (dev->udev == NULL) {
|
||||
if (dev->disconnected) {
|
||||
/* the device was unplugged before the file was released */
|
||||
if (!dev->open_count) /* ... and we're the last user */
|
||||
adu_delete(dev);
|
||||
@@ -356,7 +358,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
|
||||
return -ERESTARTSYS;
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->udev == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
pr_err("No device or device unplugged %d\n", retval);
|
||||
goto exit;
|
||||
@@ -525,7 +527,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
|
||||
goto exit_nolock;
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->udev == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
pr_err("No device or device unplugged %d\n", retval);
|
||||
goto exit;
|
||||
@@ -679,7 +681,7 @@ static int adu_probe(struct usb_interface *interface,
|
||||
|
||||
mutex_init(&dev->mtx);
|
||||
spin_lock_init(&dev->buflock);
|
||||
dev->udev = udev;
|
||||
dev->udev = usb_get_dev(udev);
|
||||
init_waitqueue_head(&dev->read_wait);
|
||||
init_waitqueue_head(&dev->write_wait);
|
||||
|
||||
@@ -789,19 +791,21 @@ error:
|
||||
static void adu_disconnect(struct usb_interface *interface)
|
||||
{
|
||||
struct adu_device *dev;
|
||||
int minor;
|
||||
|
||||
dev = usb_get_intfdata(interface);
|
||||
|
||||
mutex_lock(&dev->mtx); /* not interruptible */
|
||||
dev->udev = NULL; /* poison */
|
||||
minor = dev->minor;
|
||||
usb_deregister_dev(interface, &adu_class);
|
||||
mutex_unlock(&dev->mtx);
|
||||
|
||||
usb_poison_urb(dev->interrupt_in_urb);
|
||||
usb_poison_urb(dev->interrupt_out_urb);
|
||||
|
||||
mutex_lock(&adutux_mutex);
|
||||
usb_set_intfdata(interface, NULL);
|
||||
|
||||
mutex_lock(&dev->mtx); /* not interruptible */
|
||||
dev->disconnected = 1;
|
||||
mutex_unlock(&dev->mtx);
|
||||
|
||||
/* if the device is not opened, then we clean up right now */
|
||||
if (!dev->open_count)
|
||||
adu_delete(dev);
|
||||
|
||||
@@ -108,6 +108,7 @@ static void chaoskey_free(struct chaoskey *dev)
|
||||
usb_free_urb(dev->urb);
|
||||
kfree(dev->name);
|
||||
kfree(dev->buf);
|
||||
usb_put_intf(dev->interface);
|
||||
kfree(dev);
|
||||
}
|
||||
}
|
||||
@@ -157,6 +158,8 @@ static int chaoskey_probe(struct usb_interface *interface,
|
||||
if (dev == NULL)
|
||||
goto out;
|
||||
|
||||
dev->interface = usb_get_intf(interface);
|
||||
|
||||
dev->buf = kmalloc(size, GFP_KERNEL);
|
||||
|
||||
if (dev->buf == NULL)
|
||||
@@ -190,8 +193,6 @@ static int chaoskey_probe(struct usb_interface *interface,
|
||||
strcat(dev->name, udev->serial);
|
||||
}
|
||||
|
||||
dev->interface = interface;
|
||||
|
||||
dev->in_ep = in_ep;
|
||||
|
||||
if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID)
|
||||
|
||||
@@ -89,6 +89,7 @@ struct iowarrior {
|
||||
char chip_serial[9]; /* the serial number string of the chip connected */
|
||||
int report_size; /* number of bytes in a report */
|
||||
u16 product_id;
|
||||
struct usb_anchor submitted;
|
||||
};
|
||||
|
||||
/*--------------*/
|
||||
@@ -248,6 +249,7 @@ static inline void iowarrior_delete(struct iowarrior *dev)
|
||||
kfree(dev->int_in_buffer);
|
||||
usb_free_urb(dev->int_in_urb);
|
||||
kfree(dev->read_queue);
|
||||
usb_put_intf(dev->interface);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
@@ -434,11 +436,13 @@ static ssize_t iowarrior_write(struct file *file,
|
||||
retval = -EFAULT;
|
||||
goto error;
|
||||
}
|
||||
usb_anchor_urb(int_out_urb, &dev->submitted);
|
||||
retval = usb_submit_urb(int_out_urb, GFP_KERNEL);
|
||||
if (retval) {
|
||||
dev_dbg(&dev->interface->dev,
|
||||
"submit error %d for urb nr.%d\n",
|
||||
retval, atomic_read(&dev->write_busy));
|
||||
usb_unanchor_urb(int_out_urb);
|
||||
goto error;
|
||||
}
|
||||
/* submit was ok */
|
||||
@@ -776,11 +780,13 @@ static int iowarrior_probe(struct usb_interface *interface,
|
||||
init_waitqueue_head(&dev->write_wait);
|
||||
|
||||
dev->udev = udev;
|
||||
dev->interface = interface;
|
||||
dev->interface = usb_get_intf(interface);
|
||||
|
||||
iface_desc = interface->cur_altsetting;
|
||||
dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
|
||||
|
||||
init_usb_anchor(&dev->submitted);
|
||||
|
||||
/* set up the endpoint information */
|
||||
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
|
||||
endpoint = &iface_desc->endpoint[i].desc;
|
||||
@@ -886,8 +892,6 @@ static void iowarrior_disconnect(struct usb_interface *interface)
|
||||
dev = usb_get_intfdata(interface);
|
||||
mutex_lock(&iowarrior_open_disc_lock);
|
||||
usb_set_intfdata(interface, NULL);
|
||||
/* prevent device read, write and ioctl */
|
||||
dev->present = 0;
|
||||
|
||||
minor = dev->minor;
|
||||
mutex_unlock(&iowarrior_open_disc_lock);
|
||||
@@ -898,8 +902,7 @@ static void iowarrior_disconnect(struct usb_interface *interface)
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
/* prevent device read, write and ioctl */
|
||||
|
||||
mutex_unlock(&dev->mutex);
|
||||
dev->present = 0;
|
||||
|
||||
if (dev->opened) {
|
||||
/* There is a process that holds a filedescriptor to the device ,
|
||||
@@ -907,10 +910,13 @@ static void iowarrior_disconnect(struct usb_interface *interface)
|
||||
Deleting the device is postponed until close() was called.
|
||||
*/
|
||||
usb_kill_urb(dev->int_in_urb);
|
||||
usb_kill_anchored_urbs(&dev->submitted);
|
||||
wake_up_interruptible(&dev->read_wait);
|
||||
wake_up_interruptible(&dev->write_wait);
|
||||
mutex_unlock(&dev->mutex);
|
||||
} else {
|
||||
/* no process is using the device, cleanup now */
|
||||
mutex_unlock(&dev->mutex);
|
||||
iowarrior_delete(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in
|
||||
struct ld_usb {
|
||||
struct mutex mutex; /* locks this structure */
|
||||
struct usb_interface* intf; /* save off the usb interface pointer */
|
||||
unsigned long disconnected:1;
|
||||
|
||||
int open_count; /* number of times this port has been opened */
|
||||
|
||||
@@ -197,12 +198,10 @@ static void ld_usb_abort_transfers(struct ld_usb *dev)
|
||||
/* shutdown transfer */
|
||||
if (dev->interrupt_in_running) {
|
||||
dev->interrupt_in_running = 0;
|
||||
if (dev->intf)
|
||||
usb_kill_urb(dev->interrupt_in_urb);
|
||||
usb_kill_urb(dev->interrupt_in_urb);
|
||||
}
|
||||
if (dev->interrupt_out_busy)
|
||||
if (dev->intf)
|
||||
usb_kill_urb(dev->interrupt_out_urb);
|
||||
usb_kill_urb(dev->interrupt_out_urb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,8 +209,6 @@ static void ld_usb_abort_transfers(struct ld_usb *dev)
|
||||
*/
|
||||
static void ld_usb_delete(struct ld_usb *dev)
|
||||
{
|
||||
ld_usb_abort_transfers(dev);
|
||||
|
||||
/* free data structures */
|
||||
usb_free_urb(dev->interrupt_in_urb);
|
||||
usb_free_urb(dev->interrupt_out_urb);
|
||||
@@ -267,7 +264,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb)
|
||||
|
||||
resubmit:
|
||||
/* resubmit if we're still running */
|
||||
if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) {
|
||||
if (dev->interrupt_in_running && !dev->buffer_overflow) {
|
||||
retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
|
||||
if (retval) {
|
||||
dev_err(&dev->intf->dev,
|
||||
@@ -396,7 +393,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
|
||||
retval = -ENODEV;
|
||||
goto unlock_exit;
|
||||
}
|
||||
if (dev->intf == NULL) {
|
||||
if (dev->disconnected) {
|
||||
/* the device was unplugged before the file was released */
|
||||
mutex_unlock(&dev->mutex);
|
||||
/* unlock here as ld_usb_delete frees dev */
|
||||
@@ -427,7 +424,7 @@ static unsigned int ld_usb_poll(struct file *file, poll_table *wait)
|
||||
|
||||
dev = file->private_data;
|
||||
|
||||
if (!dev->intf)
|
||||
if (dev->disconnected)
|
||||
return POLLERR | POLLHUP;
|
||||
|
||||
poll_wait(file, &dev->read_wait, wait);
|
||||
@@ -466,7 +463,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
|
||||
}
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->intf == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
|
||||
goto unlock_exit;
|
||||
@@ -546,7 +543,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
|
||||
}
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->intf == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
|
||||
goto unlock_exit;
|
||||
@@ -768,6 +765,9 @@ static void ld_usb_disconnect(struct usb_interface *intf)
|
||||
/* give back our minor */
|
||||
usb_deregister_dev(intf, &ld_usb_class);
|
||||
|
||||
usb_poison_urb(dev->interrupt_in_urb);
|
||||
usb_poison_urb(dev->interrupt_out_urb);
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
/* if the device is not opened, then we clean up right now */
|
||||
@@ -775,7 +775,7 @@ static void ld_usb_disconnect(struct usb_interface *intf)
|
||||
mutex_unlock(&dev->mutex);
|
||||
ld_usb_delete(dev);
|
||||
} else {
|
||||
dev->intf = NULL;
|
||||
dev->disconnected = 1;
|
||||
/* wake up pollers */
|
||||
wake_up_interruptible_all(&dev->read_wait);
|
||||
wake_up_interruptible_all(&dev->write_wait);
|
||||
|
||||
@@ -185,7 +185,6 @@ static const struct usb_device_id tower_table[] = {
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE (usb, tower_table);
|
||||
static DEFINE_MUTEX(open_disc_mutex);
|
||||
|
||||
#define LEGO_USB_TOWER_MINOR_BASE 160
|
||||
|
||||
@@ -197,6 +196,7 @@ struct lego_usb_tower {
|
||||
unsigned char minor; /* the starting minor number for this device */
|
||||
|
||||
int open_count; /* number of times this port has been opened */
|
||||
unsigned long disconnected:1;
|
||||
|
||||
char* read_buffer;
|
||||
size_t read_buffer_length; /* this much came in */
|
||||
@@ -296,14 +296,13 @@ static inline void lego_usb_tower_debug_data(struct device *dev,
|
||||
*/
|
||||
static inline void tower_delete (struct lego_usb_tower *dev)
|
||||
{
|
||||
tower_abort_transfers (dev);
|
||||
|
||||
/* free data structures */
|
||||
usb_free_urb(dev->interrupt_in_urb);
|
||||
usb_free_urb(dev->interrupt_out_urb);
|
||||
kfree (dev->read_buffer);
|
||||
kfree (dev->interrupt_in_buffer);
|
||||
kfree (dev->interrupt_out_buffer);
|
||||
usb_put_dev(dev->udev);
|
||||
kfree (dev);
|
||||
}
|
||||
|
||||
@@ -338,18 +337,14 @@ static int tower_open (struct inode *inode, struct file *file)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mutex_lock(&open_disc_mutex);
|
||||
dev = usb_get_intfdata(interface);
|
||||
|
||||
if (!dev) {
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
retval = -ENODEV;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* lock this device */
|
||||
if (mutex_lock_interruptible(&dev->lock)) {
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
retval = -ERESTARTSYS;
|
||||
goto exit;
|
||||
}
|
||||
@@ -357,12 +352,9 @@ static int tower_open (struct inode *inode, struct file *file)
|
||||
|
||||
/* allow opening only once */
|
||||
if (dev->open_count) {
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
retval = -EBUSY;
|
||||
goto unlock_exit;
|
||||
}
|
||||
dev->open_count = 1;
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
|
||||
/* reset the tower */
|
||||
result = usb_control_msg (dev->udev,
|
||||
@@ -402,13 +394,14 @@ static int tower_open (struct inode *inode, struct file *file)
|
||||
dev_err(&dev->udev->dev,
|
||||
"Couldn't submit interrupt_in_urb %d\n", retval);
|
||||
dev->interrupt_in_running = 0;
|
||||
dev->open_count = 0;
|
||||
goto unlock_exit;
|
||||
}
|
||||
|
||||
/* save device in the file's private structure */
|
||||
file->private_data = dev;
|
||||
|
||||
dev->open_count = 1;
|
||||
|
||||
unlock_exit:
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
@@ -429,10 +422,9 @@ static int tower_release (struct inode *inode, struct file *file)
|
||||
|
||||
if (dev == NULL) {
|
||||
retval = -ENODEV;
|
||||
goto exit_nolock;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mutex_lock(&open_disc_mutex);
|
||||
if (mutex_lock_interruptible(&dev->lock)) {
|
||||
retval = -ERESTARTSYS;
|
||||
goto exit;
|
||||
@@ -444,7 +436,8 @@ static int tower_release (struct inode *inode, struct file *file)
|
||||
retval = -ENODEV;
|
||||
goto unlock_exit;
|
||||
}
|
||||
if (dev->udev == NULL) {
|
||||
|
||||
if (dev->disconnected) {
|
||||
/* the device was unplugged before the file was released */
|
||||
|
||||
/* unlock here as tower_delete frees dev */
|
||||
@@ -462,10 +455,7 @@ static int tower_release (struct inode *inode, struct file *file)
|
||||
|
||||
unlock_exit:
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
exit:
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
exit_nolock:
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -483,10 +473,9 @@ static void tower_abort_transfers (struct lego_usb_tower *dev)
|
||||
if (dev->interrupt_in_running) {
|
||||
dev->interrupt_in_running = 0;
|
||||
mb();
|
||||
if (dev->udev)
|
||||
usb_kill_urb (dev->interrupt_in_urb);
|
||||
usb_kill_urb(dev->interrupt_in_urb);
|
||||
}
|
||||
if (dev->interrupt_out_busy && dev->udev)
|
||||
if (dev->interrupt_out_busy)
|
||||
usb_kill_urb(dev->interrupt_out_urb);
|
||||
}
|
||||
|
||||
@@ -522,7 +511,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait)
|
||||
|
||||
dev = file->private_data;
|
||||
|
||||
if (!dev->udev)
|
||||
if (dev->disconnected)
|
||||
return POLLERR | POLLHUP;
|
||||
|
||||
poll_wait(file, &dev->read_wait, wait);
|
||||
@@ -569,7 +558,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count,
|
||||
}
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->udev == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
pr_err("No device or device unplugged %d\n", retval);
|
||||
goto unlock_exit;
|
||||
@@ -655,7 +644,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
|
||||
}
|
||||
|
||||
/* verify that the device wasn't unplugged */
|
||||
if (dev->udev == NULL) {
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
pr_err("No device or device unplugged %d\n", retval);
|
||||
goto unlock_exit;
|
||||
@@ -764,7 +753,7 @@ static void tower_interrupt_in_callback (struct urb *urb)
|
||||
|
||||
resubmit:
|
||||
/* resubmit if we're still running */
|
||||
if (dev->interrupt_in_running && dev->udev) {
|
||||
if (dev->interrupt_in_running) {
|
||||
retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC);
|
||||
if (retval)
|
||||
dev_err(&dev->udev->dev,
|
||||
@@ -830,8 +819,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
|
||||
|
||||
mutex_init(&dev->lock);
|
||||
|
||||
dev->udev = udev;
|
||||
dev->udev = usb_get_dev(udev);
|
||||
dev->open_count = 0;
|
||||
dev->disconnected = 0;
|
||||
|
||||
dev->read_buffer = NULL;
|
||||
dev->read_buffer_length = 0;
|
||||
@@ -911,8 +901,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
|
||||
get_version_reply,
|
||||
sizeof(*get_version_reply),
|
||||
1000);
|
||||
if (result < 0) {
|
||||
dev_err(idev, "LEGO USB Tower get version control request failed\n");
|
||||
if (result < sizeof(*get_version_reply)) {
|
||||
if (result >= 0)
|
||||
result = -EIO;
|
||||
dev_err(idev, "get version request failed: %d\n", result);
|
||||
retval = result;
|
||||
goto error;
|
||||
}
|
||||
@@ -930,7 +922,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
|
||||
if (retval) {
|
||||
/* something prevented us from registering this driver */
|
||||
dev_err(idev, "Not able to get a minor for this device.\n");
|
||||
usb_set_intfdata (interface, NULL);
|
||||
goto error;
|
||||
}
|
||||
dev->minor = interface->minor;
|
||||
@@ -962,23 +953,24 @@ static void tower_disconnect (struct usb_interface *interface)
|
||||
int minor;
|
||||
|
||||
dev = usb_get_intfdata (interface);
|
||||
mutex_lock(&open_disc_mutex);
|
||||
usb_set_intfdata (interface, NULL);
|
||||
|
||||
minor = dev->minor;
|
||||
|
||||
/* give back our minor */
|
||||
/* give back our minor and prevent further open() */
|
||||
usb_deregister_dev (interface, &tower_class);
|
||||
|
||||
/* stop I/O */
|
||||
usb_poison_urb(dev->interrupt_in_urb);
|
||||
usb_poison_urb(dev->interrupt_out_urb);
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
mutex_unlock(&open_disc_mutex);
|
||||
|
||||
/* if the device is not opened, then we clean up right now */
|
||||
if (!dev->open_count) {
|
||||
mutex_unlock(&dev->lock);
|
||||
tower_delete (dev);
|
||||
} else {
|
||||
dev->udev = NULL;
|
||||
dev->disconnected = 1;
|
||||
/* wake up pollers */
|
||||
wake_up_interruptible_all(&dev->read_wait);
|
||||
wake_up_interruptible_all(&dev->write_wait);
|
||||
|
||||
@@ -1,578 +0,0 @@
|
||||
/* -*- linux-c -*- */
|
||||
|
||||
/*
|
||||
* Driver for USB Rio 500
|
||||
*
|
||||
* Cesar Miquel (miquel@df.uba.ar)
|
||||
*
|
||||
* based on hp_scanner.c by David E. Nelson (dnelson@jump.net)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee).
|
||||
*
|
||||
* Changelog:
|
||||
* 30/05/2003 replaced lock/unlock kernel with up/down
|
||||
* Daniele Bellucci bellucda@tiscali.it
|
||||
* */
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/signal.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include "rio500_usb.h"
|
||||
|
||||
/*
|
||||
* Version Information
|
||||
*/
|
||||
#define DRIVER_VERSION "v1.1"
|
||||
#define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>"
|
||||
#define DRIVER_DESC "USB Rio 500 driver"
|
||||
|
||||
#define RIO_MINOR 64
|
||||
|
||||
/* stall/wait timeout for rio */
|
||||
#define NAK_TIMEOUT (HZ)
|
||||
|
||||
#define IBUF_SIZE 0x1000
|
||||
|
||||
/* Size of the rio buffer */
|
||||
#define OBUF_SIZE 0x10000
|
||||
|
||||
struct rio_usb_data {
|
||||
struct usb_device *rio_dev; /* init: probe_rio */
|
||||
unsigned int ifnum; /* Interface number of the USB device */
|
||||
int isopen; /* nz if open */
|
||||
int present; /* Device is present on the bus */
|
||||
char *obuf, *ibuf; /* transfer buffers */
|
||||
char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */
|
||||
wait_queue_head_t wait_q; /* for timeouts */
|
||||
struct mutex lock; /* general race avoidance */
|
||||
};
|
||||
|
||||
static DEFINE_MUTEX(rio500_mutex);
|
||||
static struct rio_usb_data rio_instance;
|
||||
|
||||
static int open_rio(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
|
||||
/* against disconnect() */
|
||||
mutex_lock(&rio500_mutex);
|
||||
mutex_lock(&(rio->lock));
|
||||
|
||||
if (rio->isopen || !rio->present) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
mutex_unlock(&rio500_mutex);
|
||||
return -EBUSY;
|
||||
}
|
||||
rio->isopen = 1;
|
||||
|
||||
init_waitqueue_head(&rio->wait_q);
|
||||
|
||||
mutex_unlock(&(rio->lock));
|
||||
|
||||
dev_info(&rio->rio_dev->dev, "Rio opened.\n");
|
||||
mutex_unlock(&rio500_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int close_rio(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
|
||||
/* against disconnect() */
|
||||
mutex_lock(&rio500_mutex);
|
||||
mutex_lock(&(rio->lock));
|
||||
|
||||
rio->isopen = 0;
|
||||
if (!rio->present) {
|
||||
/* cleanup has been delayed */
|
||||
kfree(rio->ibuf);
|
||||
kfree(rio->obuf);
|
||||
rio->ibuf = NULL;
|
||||
rio->obuf = NULL;
|
||||
} else {
|
||||
dev_info(&rio->rio_dev->dev, "Rio closed.\n");
|
||||
}
|
||||
mutex_unlock(&(rio->lock));
|
||||
mutex_unlock(&rio500_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct RioCommand rio_cmd;
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
void __user *data;
|
||||
unsigned char *buffer;
|
||||
int result, requesttype;
|
||||
int retries;
|
||||
int retval=0;
|
||||
|
||||
mutex_lock(&(rio->lock));
|
||||
/* Sanity check to make sure rio is connected, powered, etc */
|
||||
if (rio->present == 0 || rio->rio_dev == NULL) {
|
||||
retval = -ENODEV;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case RIO_RECV_COMMAND:
|
||||
data = (void __user *) arg;
|
||||
if (data == NULL)
|
||||
break;
|
||||
if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) {
|
||||
retval = -EFAULT;
|
||||
goto err_out;
|
||||
}
|
||||
if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) {
|
||||
retval = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
|
||||
if (buffer == NULL) {
|
||||
retval = -ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) {
|
||||
retval = -EFAULT;
|
||||
free_page((unsigned long) buffer);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
requesttype = rio_cmd.requesttype | USB_DIR_IN |
|
||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE;
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n",
|
||||
requesttype, rio_cmd.request, rio_cmd.value,
|
||||
rio_cmd.index, rio_cmd.length);
|
||||
/* Send rio control message */
|
||||
retries = 3;
|
||||
while (retries) {
|
||||
result = usb_control_msg(rio->rio_dev,
|
||||
usb_rcvctrlpipe(rio-> rio_dev, 0),
|
||||
rio_cmd.request,
|
||||
requesttype,
|
||||
rio_cmd.value,
|
||||
rio_cmd.index, buffer,
|
||||
rio_cmd.length,
|
||||
jiffies_to_msecs(rio_cmd.timeout));
|
||||
if (result == -ETIMEDOUT)
|
||||
retries--;
|
||||
else if (result < 0) {
|
||||
dev_err(&rio->rio_dev->dev,
|
||||
"Error executing ioctrl. code = %d\n",
|
||||
result);
|
||||
retries = 0;
|
||||
} else {
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"Executed ioctl. Result = %d (data=%02x)\n",
|
||||
result, buffer[0]);
|
||||
if (copy_to_user(rio_cmd.buffer, buffer,
|
||||
rio_cmd.length)) {
|
||||
free_page((unsigned long) buffer);
|
||||
retval = -EFAULT;
|
||||
goto err_out;
|
||||
}
|
||||
retries = 0;
|
||||
}
|
||||
|
||||
/* rio_cmd.buffer contains a raw stream of single byte
|
||||
data which has been returned from rio. Data is
|
||||
interpreted at application level. For data that
|
||||
will be cast to data types longer than 1 byte, data
|
||||
will be little_endian and will potentially need to
|
||||
be swapped at the app level */
|
||||
|
||||
}
|
||||
free_page((unsigned long) buffer);
|
||||
break;
|
||||
|
||||
case RIO_SEND_COMMAND:
|
||||
data = (void __user *) arg;
|
||||
if (data == NULL)
|
||||
break;
|
||||
if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) {
|
||||
retval = -EFAULT;
|
||||
goto err_out;
|
||||
}
|
||||
if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) {
|
||||
retval = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
|
||||
if (buffer == NULL) {
|
||||
retval = -ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) {
|
||||
free_page((unsigned long)buffer);
|
||||
retval = -EFAULT;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
requesttype = rio_cmd.requesttype | USB_DIR_OUT |
|
||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE;
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n",
|
||||
requesttype, rio_cmd.request, rio_cmd.value,
|
||||
rio_cmd.index, rio_cmd.length);
|
||||
/* Send rio control message */
|
||||
retries = 3;
|
||||
while (retries) {
|
||||
result = usb_control_msg(rio->rio_dev,
|
||||
usb_sndctrlpipe(rio-> rio_dev, 0),
|
||||
rio_cmd.request,
|
||||
requesttype,
|
||||
rio_cmd.value,
|
||||
rio_cmd.index, buffer,
|
||||
rio_cmd.length,
|
||||
jiffies_to_msecs(rio_cmd.timeout));
|
||||
if (result == -ETIMEDOUT)
|
||||
retries--;
|
||||
else if (result < 0) {
|
||||
dev_err(&rio->rio_dev->dev,
|
||||
"Error executing ioctrl. code = %d\n",
|
||||
result);
|
||||
retries = 0;
|
||||
} else {
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"Executed ioctl. Result = %d\n", result);
|
||||
retries = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
free_page((unsigned long) buffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
err_out:
|
||||
mutex_unlock(&(rio->lock));
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
write_rio(struct file *file, const char __user *buffer,
|
||||
size_t count, loff_t * ppos)
|
||||
{
|
||||
DEFINE_WAIT(wait);
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
|
||||
unsigned long copy_size;
|
||||
unsigned long bytes_written = 0;
|
||||
unsigned int partial;
|
||||
|
||||
int result = 0;
|
||||
int maxretry;
|
||||
int errn = 0;
|
||||
int intr;
|
||||
|
||||
intr = mutex_lock_interruptible(&(rio->lock));
|
||||
if (intr)
|
||||
return -EINTR;
|
||||
/* Sanity check to make sure rio is connected, powered, etc */
|
||||
if (rio->present == 0 || rio->rio_dev == NULL) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
do {
|
||||
unsigned long thistime;
|
||||
char *obuf = rio->obuf;
|
||||
|
||||
thistime = copy_size =
|
||||
(count >= OBUF_SIZE) ? OBUF_SIZE : count;
|
||||
if (copy_from_user(rio->obuf, buffer, copy_size)) {
|
||||
errn = -EFAULT;
|
||||
goto error;
|
||||
}
|
||||
maxretry = 5;
|
||||
while (thistime) {
|
||||
if (!rio->rio_dev) {
|
||||
errn = -ENODEV;
|
||||
goto error;
|
||||
}
|
||||
if (signal_pending(current)) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return bytes_written ? bytes_written : -EINTR;
|
||||
}
|
||||
|
||||
result = usb_bulk_msg(rio->rio_dev,
|
||||
usb_sndbulkpipe(rio->rio_dev, 2),
|
||||
obuf, thistime, &partial, 5000);
|
||||
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"write stats: result:%d thistime:%lu partial:%u\n",
|
||||
result, thistime, partial);
|
||||
|
||||
if (result == -ETIMEDOUT) { /* NAK - so hold for a while */
|
||||
if (!maxretry--) {
|
||||
errn = -ETIME;
|
||||
goto error;
|
||||
}
|
||||
prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(NAK_TIMEOUT);
|
||||
finish_wait(&rio->wait_q, &wait);
|
||||
continue;
|
||||
} else if (!result && partial) {
|
||||
obuf += partial;
|
||||
thistime -= partial;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (result) {
|
||||
dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n",
|
||||
result);
|
||||
errn = -EIO;
|
||||
goto error;
|
||||
}
|
||||
bytes_written += copy_size;
|
||||
count -= copy_size;
|
||||
buffer += copy_size;
|
||||
} while (count > 0);
|
||||
|
||||
mutex_unlock(&(rio->lock));
|
||||
|
||||
return bytes_written ? bytes_written : -EIO;
|
||||
|
||||
error:
|
||||
mutex_unlock(&(rio->lock));
|
||||
return errn;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
|
||||
{
|
||||
DEFINE_WAIT(wait);
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
ssize_t read_count;
|
||||
unsigned int partial;
|
||||
int this_read;
|
||||
int result;
|
||||
int maxretry = 10;
|
||||
char *ibuf;
|
||||
int intr;
|
||||
|
||||
intr = mutex_lock_interruptible(&(rio->lock));
|
||||
if (intr)
|
||||
return -EINTR;
|
||||
/* Sanity check to make sure rio is connected, powered, etc */
|
||||
if (rio->present == 0 || rio->rio_dev == NULL) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ibuf = rio->ibuf;
|
||||
|
||||
read_count = 0;
|
||||
|
||||
|
||||
while (count > 0) {
|
||||
if (signal_pending(current)) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return read_count ? read_count : -EINTR;
|
||||
}
|
||||
if (!rio->rio_dev) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return -ENODEV;
|
||||
}
|
||||
this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count;
|
||||
|
||||
result = usb_bulk_msg(rio->rio_dev,
|
||||
usb_rcvbulkpipe(rio->rio_dev, 1),
|
||||
ibuf, this_read, &partial,
|
||||
8000);
|
||||
|
||||
dev_dbg(&rio->rio_dev->dev,
|
||||
"read stats: result:%d this_read:%u partial:%u\n",
|
||||
result, this_read, partial);
|
||||
|
||||
if (partial) {
|
||||
count = this_read = partial;
|
||||
} else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */
|
||||
if (!maxretry--) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
dev_err(&rio->rio_dev->dev,
|
||||
"read_rio: maxretry timeout\n");
|
||||
return -ETIME;
|
||||
}
|
||||
prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(NAK_TIMEOUT);
|
||||
finish_wait(&rio->wait_q, &wait);
|
||||
continue;
|
||||
} else if (result != -EREMOTEIO) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
dev_err(&rio->rio_dev->dev,
|
||||
"Read Whoops - result:%u partial:%u this_read:%u\n",
|
||||
result, partial, this_read);
|
||||
return -EIO;
|
||||
} else {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (this_read) {
|
||||
if (copy_to_user(buffer, ibuf, this_read)) {
|
||||
mutex_unlock(&(rio->lock));
|
||||
return -EFAULT;
|
||||
}
|
||||
count -= this_read;
|
||||
read_count += this_read;
|
||||
buffer += this_read;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&(rio->lock));
|
||||
return read_count;
|
||||
}
|
||||
|
||||
static const struct file_operations usb_rio_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = read_rio,
|
||||
.write = write_rio,
|
||||
.unlocked_ioctl = ioctl_rio,
|
||||
.open = open_rio,
|
||||
.release = close_rio,
|
||||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
static struct usb_class_driver usb_rio_class = {
|
||||
.name = "rio500%d",
|
||||
.fops = &usb_rio_fops,
|
||||
.minor_base = RIO_MINOR,
|
||||
};
|
||||
|
||||
static int probe_rio(struct usb_interface *intf,
|
||||
const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_device *dev = interface_to_usbdev(intf);
|
||||
struct rio_usb_data *rio = &rio_instance;
|
||||
int retval = 0;
|
||||
|
||||
mutex_lock(&rio500_mutex);
|
||||
if (rio->present) {
|
||||
dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum);
|
||||
retval = -EBUSY;
|
||||
goto bail_out;
|
||||
} else {
|
||||
dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum);
|
||||
}
|
||||
|
||||
retval = usb_register_dev(intf, &usb_rio_class);
|
||||
if (retval) {
|
||||
dev_err(&dev->dev,
|
||||
"Not able to get a minor for this device.\n");
|
||||
retval = -ENOMEM;
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
rio->rio_dev = dev;
|
||||
|
||||
if (!(rio->obuf = kmalloc(OBUF_SIZE, GFP_KERNEL))) {
|
||||
dev_err(&dev->dev,
|
||||
"probe_rio: Not enough memory for the output buffer\n");
|
||||
usb_deregister_dev(intf, &usb_rio_class);
|
||||
retval = -ENOMEM;
|
||||
goto bail_out;
|
||||
}
|
||||
dev_dbg(&intf->dev, "obuf address:%p\n", rio->obuf);
|
||||
|
||||
if (!(rio->ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL))) {
|
||||
dev_err(&dev->dev,
|
||||
"probe_rio: Not enough memory for the input buffer\n");
|
||||
usb_deregister_dev(intf, &usb_rio_class);
|
||||
kfree(rio->obuf);
|
||||
retval = -ENOMEM;
|
||||
goto bail_out;
|
||||
}
|
||||
dev_dbg(&intf->dev, "ibuf address:%p\n", rio->ibuf);
|
||||
|
||||
mutex_init(&(rio->lock));
|
||||
|
||||
usb_set_intfdata (intf, rio);
|
||||
rio->present = 1;
|
||||
bail_out:
|
||||
mutex_unlock(&rio500_mutex);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void disconnect_rio(struct usb_interface *intf)
|
||||
{
|
||||
struct rio_usb_data *rio = usb_get_intfdata (intf);
|
||||
|
||||
usb_set_intfdata (intf, NULL);
|
||||
mutex_lock(&rio500_mutex);
|
||||
if (rio) {
|
||||
usb_deregister_dev(intf, &usb_rio_class);
|
||||
|
||||
mutex_lock(&(rio->lock));
|
||||
if (rio->isopen) {
|
||||
rio->isopen = 0;
|
||||
/* better let it finish - the release will do whats needed */
|
||||
rio->rio_dev = NULL;
|
||||
mutex_unlock(&(rio->lock));
|
||||
mutex_unlock(&rio500_mutex);
|
||||
return;
|
||||
}
|
||||
kfree(rio->ibuf);
|
||||
kfree(rio->obuf);
|
||||
|
||||
dev_info(&intf->dev, "USB Rio disconnected.\n");
|
||||
|
||||
rio->present = 0;
|
||||
mutex_unlock(&(rio->lock));
|
||||
}
|
||||
mutex_unlock(&rio500_mutex);
|
||||
}
|
||||
|
||||
static const struct usb_device_id rio_table[] = {
|
||||
{ USB_DEVICE(0x0841, 1) }, /* Rio 500 */
|
||||
{ } /* Terminating entry */
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE (usb, rio_table);
|
||||
|
||||
static struct usb_driver rio_driver = {
|
||||
.name = "rio500",
|
||||
.probe = probe_rio,
|
||||
.disconnect = disconnect_rio,
|
||||
.id_table = rio_table,
|
||||
};
|
||||
|
||||
module_usb_driver(rio_driver);
|
||||
|
||||
MODULE_AUTHOR( DRIVER_AUTHOR );
|
||||
MODULE_DESCRIPTION( DRIVER_DESC );
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
#define RIO_SEND_COMMAND 0x1
|
||||
#define RIO_RECV_COMMAND 0x2
|
||||
|
||||
#define RIO_DIR_OUT 0x0
|
||||
#define RIO_DIR_IN 0x1
|
||||
|
||||
struct RioCommand {
|
||||
short length;
|
||||
int request;
|
||||
int requesttype;
|
||||
int value;
|
||||
int index;
|
||||
void __user *buffer;
|
||||
int timeout;
|
||||
};
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/usb.h>
|
||||
|
||||
@@ -56,6 +57,8 @@ struct usb_lcd {
|
||||
using up all RAM */
|
||||
struct usb_anchor submitted; /* URBs to wait for
|
||||
before suspend */
|
||||
struct rw_semaphore io_rwsem;
|
||||
unsigned long disconnected:1;
|
||||
};
|
||||
#define to_lcd_dev(d) container_of(d, struct usb_lcd, kref)
|
||||
|
||||
@@ -141,6 +144,13 @@ static ssize_t lcd_read(struct file *file, char __user * buffer,
|
||||
|
||||
dev = file->private_data;
|
||||
|
||||
down_read(&dev->io_rwsem);
|
||||
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
goto out_up_io;
|
||||
}
|
||||
|
||||
/* do a blocking bulk read to get data from the device */
|
||||
retval = usb_bulk_msg(dev->udev,
|
||||
usb_rcvbulkpipe(dev->udev,
|
||||
@@ -157,6 +167,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer,
|
||||
retval = bytes_read;
|
||||
}
|
||||
|
||||
out_up_io:
|
||||
up_read(&dev->io_rwsem);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -236,11 +249,18 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer,
|
||||
if (r < 0)
|
||||
return -EINTR;
|
||||
|
||||
down_read(&dev->io_rwsem);
|
||||
|
||||
if (dev->disconnected) {
|
||||
retval = -ENODEV;
|
||||
goto err_up_io;
|
||||
}
|
||||
|
||||
/* create a urb, and a buffer for it, and copy the data to the urb */
|
||||
urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if (!urb) {
|
||||
retval = -ENOMEM;
|
||||
goto err_no_buf;
|
||||
goto err_up_io;
|
||||
}
|
||||
|
||||
buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL,
|
||||
@@ -277,6 +297,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer,
|
||||
the USB core will eventually free it entirely */
|
||||
usb_free_urb(urb);
|
||||
|
||||
up_read(&dev->io_rwsem);
|
||||
exit:
|
||||
return count;
|
||||
error_unanchor:
|
||||
@@ -284,7 +305,8 @@ error_unanchor:
|
||||
error:
|
||||
usb_free_coherent(dev->udev, count, buf, urb->transfer_dma);
|
||||
usb_free_urb(urb);
|
||||
err_no_buf:
|
||||
err_up_io:
|
||||
up_read(&dev->io_rwsem);
|
||||
up(&dev->limit_sem);
|
||||
return retval;
|
||||
}
|
||||
@@ -325,6 +347,7 @@ static int lcd_probe(struct usb_interface *interface,
|
||||
goto error;
|
||||
kref_init(&dev->kref);
|
||||
sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);
|
||||
init_rwsem(&dev->io_rwsem);
|
||||
init_usb_anchor(&dev->submitted);
|
||||
|
||||
dev->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
@@ -432,6 +455,12 @@ static void lcd_disconnect(struct usb_interface *interface)
|
||||
/* give back our minor */
|
||||
usb_deregister_dev(interface, &lcd_class);
|
||||
|
||||
down_write(&dev->io_rwsem);
|
||||
dev->disconnected = 1;
|
||||
up_write(&dev->io_rwsem);
|
||||
|
||||
usb_kill_anchored_urbs(&dev->submitted);
|
||||
|
||||
/* decrement our usage count */
|
||||
kref_put(&dev->kref, lcd_delete);
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ struct usb_yurex {
|
||||
|
||||
struct kref kref;
|
||||
struct mutex io_mutex;
|
||||
unsigned long disconnected:1;
|
||||
struct fasync_struct *async_queue;
|
||||
wait_queue_head_t waitq;
|
||||
|
||||
@@ -111,6 +112,7 @@ static void yurex_delete(struct kref *kref)
|
||||
dev->int_buffer, dev->urb->transfer_dma);
|
||||
usb_free_urb(dev->urb);
|
||||
}
|
||||
usb_put_intf(dev->interface);
|
||||
usb_put_dev(dev->udev);
|
||||
kfree(dev);
|
||||
}
|
||||
@@ -136,6 +138,7 @@ static void yurex_interrupt(struct urb *urb)
|
||||
switch (status) {
|
||||
case 0: /*success*/
|
||||
break;
|
||||
/* The device is terminated or messed up, give up */
|
||||
case -EOVERFLOW:
|
||||
dev_err(&dev->interface->dev,
|
||||
"%s - overflow with length %d, actual length is %d\n",
|
||||
@@ -144,12 +147,13 @@ static void yurex_interrupt(struct urb *urb)
|
||||
case -ENOENT:
|
||||
case -ESHUTDOWN:
|
||||
case -EILSEQ:
|
||||
/* The device is terminated, clean up */
|
||||
case -EPROTO:
|
||||
case -ETIME:
|
||||
return;
|
||||
default:
|
||||
dev_err(&dev->interface->dev,
|
||||
"%s - unknown status received: %d\n", __func__, status);
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
|
||||
/* handle received message */
|
||||
@@ -181,7 +185,6 @@ static void yurex_interrupt(struct urb *urb)
|
||||
break;
|
||||
}
|
||||
|
||||
exit:
|
||||
retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
|
||||
if (retval) {
|
||||
dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n",
|
||||
@@ -208,7 +211,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
|
||||
init_waitqueue_head(&dev->waitq);
|
||||
|
||||
dev->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
dev->interface = interface;
|
||||
dev->interface = usb_get_intf(interface);
|
||||
|
||||
/* set up the endpoint information */
|
||||
iface_desc = interface->cur_altsetting;
|
||||
@@ -325,8 +328,9 @@ static void yurex_disconnect(struct usb_interface *interface)
|
||||
|
||||
/* prevent more I/O from starting */
|
||||
usb_poison_urb(dev->urb);
|
||||
usb_poison_urb(dev->cntl_urb);
|
||||
mutex_lock(&dev->io_mutex);
|
||||
dev->interface = NULL;
|
||||
dev->disconnected = 1;
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
|
||||
/* wakeup waiters */
|
||||
@@ -414,7 +418,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
|
||||
dev = file->private_data;
|
||||
|
||||
mutex_lock(&dev->io_mutex);
|
||||
if (!dev->interface) { /* already disconnected */
|
||||
if (dev->disconnected) { /* already disconnected */
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
return -ENODEV;
|
||||
}
|
||||
@@ -449,7 +453,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
|
||||
goto error;
|
||||
|
||||
mutex_lock(&dev->io_mutex);
|
||||
if (!dev->interface) { /* already disconnected */
|
||||
if (dev->disconnected) { /* already disconnected */
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
retval = -ENODEV;
|
||||
goto error;
|
||||
|
||||
@@ -213,6 +213,7 @@ struct usbhs_priv;
|
||||
/* DCPCTR */
|
||||
#define BSTS (1 << 15) /* Buffer Status */
|
||||
#define SUREQ (1 << 14) /* Sending SETUP Token */
|
||||
#define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */
|
||||
#define CSSTS (1 << 12) /* CSSTS Status */
|
||||
#define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */
|
||||
#define SQCLR (1 << 8) /* Toggle Bit Clear */
|
||||
|
||||
@@ -98,7 +98,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt)
|
||||
list_del_init(&pkt->node);
|
||||
}
|
||||
|
||||
static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
|
||||
struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
|
||||
{
|
||||
if (list_empty(&pipe->list))
|
||||
return NULL;
|
||||
|
||||
@@ -106,5 +106,6 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
|
||||
void *buf, int len, int zero, int sequence);
|
||||
struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
|
||||
void usbhs_pkt_start(struct usbhs_pipe *pipe);
|
||||
struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe);
|
||||
|
||||
#endif /* RENESAS_USB_FIFO_H */
|
||||
|
||||
@@ -729,8 +729,7 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge)
|
||||
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
|
||||
struct device *dev = usbhsg_gpriv_to_dev(gpriv);
|
||||
unsigned long flags;
|
||||
|
||||
usbhsg_pipe_disable(uep);
|
||||
int ret = 0;
|
||||
|
||||
dev_dbg(dev, "set halt %d (pipe %d)\n",
|
||||
halt, usbhs_pipe_number(pipe));
|
||||
@@ -738,6 +737,18 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge)
|
||||
/******************** spin lock ********************/
|
||||
usbhs_lock(priv, flags);
|
||||
|
||||
/*
|
||||
* According to usb_ep_set_halt()'s description, this function should
|
||||
* return -EAGAIN if the IN endpoint has any queue or data. Note
|
||||
* that the usbhs_pipe_is_dir_in() returns false if the pipe is an
|
||||
* IN endpoint in the gadget mode.
|
||||
*/
|
||||
if (!usbhs_pipe_is_dir_in(pipe) && (__usbhsf_pkt_get(pipe) ||
|
||||
usbhs_pipe_contains_transmittable_data(pipe))) {
|
||||
ret = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (halt)
|
||||
usbhs_pipe_stall(pipe);
|
||||
else
|
||||
@@ -748,10 +759,11 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge)
|
||||
else
|
||||
usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE);
|
||||
|
||||
out:
|
||||
usbhs_unlock(priv, flags);
|
||||
/******************** spin unlock ******************/
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usbhsg_ep_set_halt(struct usb_ep *ep, int value)
|
||||
|
||||
@@ -286,6 +286,21 @@ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
/* Do not support for DCP pipe */
|
||||
if (usbhs_pipe_is_dcp(pipe))
|
||||
return false;
|
||||
|
||||
val = usbhsp_pipectrl_get(pipe);
|
||||
if (val & INBUFM)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* PID ctrl
|
||||
*/
|
||||
|
||||
@@ -90,6 +90,7 @@ void usbhs_pipe_init(struct usbhs_priv *priv,
|
||||
int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
|
||||
void usbhs_pipe_clear(struct usbhs_pipe *pipe);
|
||||
int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe);
|
||||
bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe);
|
||||
void usbhs_pipe_enable(struct usbhs_pipe *pipe);
|
||||
void usbhs_pipe_disable(struct usbhs_pipe *pipe);
|
||||
void usbhs_pipe_stall(struct usbhs_pipe *pipe);
|
||||
|
||||
@@ -1025,6 +1025,9 @@ static const struct usb_device_id id_table_combined[] = {
|
||||
/* EZPrototypes devices */
|
||||
{ USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },
|
||||
{ USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) },
|
||||
/* Sienna devices */
|
||||
{ USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) },
|
||||
{ USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) },
|
||||
{ } /* Terminating entry */
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
|
||||
#define FTDI_LUMEL_PD12_PID 0x6002
|
||||
|
||||
/* Sienna Serial Interface by Secyourit GmbH */
|
||||
#define FTDI_SIENNA_PID 0x8348
|
||||
|
||||
/* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */
|
||||
#define CYBER_CORTEX_AV_PID 0x8698
|
||||
|
||||
@@ -687,6 +690,12 @@
|
||||
#define BANDB_TTL3USB9M_PID 0xAC50
|
||||
#define BANDB_ZZ_PROG1_USB_PID 0xBA02
|
||||
|
||||
/*
|
||||
* Echelon USB Serial Interface
|
||||
*/
|
||||
#define ECHELON_VID 0x0920
|
||||
#define ECHELON_U20_PID 0x7500
|
||||
|
||||
/*
|
||||
* Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
|
||||
*/
|
||||
|
||||
@@ -1250,8 +1250,8 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
|
||||
|
||||
ep_desc = find_ep(serial, endpoint);
|
||||
if (!ep_desc) {
|
||||
/* leak the urb, something's wrong and the callers don't care */
|
||||
return urb;
|
||||
usb_free_urb(urb);
|
||||
return NULL;
|
||||
}
|
||||
if (usb_endpoint_xfer_int(ep_desc)) {
|
||||
ep_type_name = "INT";
|
||||
|
||||
@@ -421,6 +421,7 @@ static void option_instat_callback(struct urb *urb);
|
||||
#define CINTERION_PRODUCT_PH8_AUDIO 0x0083
|
||||
#define CINTERION_PRODUCT_AHXX_2RMNET 0x0084
|
||||
#define CINTERION_PRODUCT_AHXX_AUDIO 0x0085
|
||||
#define CINTERION_PRODUCT_CLS8 0x00b0
|
||||
|
||||
/* Olivetti products */
|
||||
#define OLIVETTI_VENDOR_ID 0x0b3c
|
||||
@@ -1149,6 +1150,14 @@ static const struct usb_device_id option_ids[] = {
|
||||
.driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),
|
||||
.driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1050, 0xff), /* Telit FN980 (rmnet) */
|
||||
.driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1051, 0xff), /* Telit FN980 (MBIM) */
|
||||
.driver_info = NCTRL(0) | RSVD(1) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1052, 0xff), /* Telit FN980 (RNDIS) */
|
||||
.driver_info = NCTRL(2) | RSVD(3) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */
|
||||
.driver_info = NCTRL(0) | RSVD(1) },
|
||||
{ USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
|
||||
.driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
|
||||
{ USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
|
||||
@@ -1842,6 +1851,8 @@ static const struct usb_device_id option_ids[] = {
|
||||
.driver_info = RSVD(4) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) },
|
||||
{ USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_CLS8, 0xff),
|
||||
.driver_info = RSVD(0) | RSVD(4) },
|
||||
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
|
||||
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
|
||||
{ USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
|
||||
|
||||
@@ -315,10 +315,7 @@ static void serial_cleanup(struct tty_struct *tty)
|
||||
serial = port->serial;
|
||||
owner = serial->type->driver.owner;
|
||||
|
||||
mutex_lock(&serial->disc_mutex);
|
||||
if (!serial->disconnected)
|
||||
usb_autopm_put_interface(serial->interface);
|
||||
mutex_unlock(&serial->disc_mutex);
|
||||
usb_autopm_put_interface(serial->interface);
|
||||
|
||||
usb_serial_put(serial);
|
||||
module_put(owner);
|
||||
|
||||
@@ -63,6 +63,7 @@ struct usb_skel {
|
||||
spinlock_t err_lock; /* lock for errors */
|
||||
struct kref kref;
|
||||
struct mutex io_mutex; /* synchronize I/O with disconnect */
|
||||
unsigned long disconnected:1;
|
||||
wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */
|
||||
};
|
||||
#define to_skel_dev(d) container_of(d, struct usb_skel, kref)
|
||||
@@ -75,6 +76,7 @@ static void skel_delete(struct kref *kref)
|
||||
struct usb_skel *dev = to_skel_dev(kref);
|
||||
|
||||
usb_free_urb(dev->bulk_in_urb);
|
||||
usb_put_intf(dev->interface);
|
||||
usb_put_dev(dev->udev);
|
||||
kfree(dev->bulk_in_buffer);
|
||||
kfree(dev);
|
||||
@@ -126,10 +128,7 @@ static int skel_release(struct inode *inode, struct file *file)
|
||||
return -ENODEV;
|
||||
|
||||
/* allow the device to be autosuspended */
|
||||
mutex_lock(&dev->io_mutex);
|
||||
if (dev->interface)
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
|
||||
/* decrement the count on our device */
|
||||
kref_put(&dev->kref, skel_delete);
|
||||
@@ -241,7 +240,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count,
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
if (!dev->interface) { /* disconnect() was called */
|
||||
if (dev->disconnected) { /* disconnect() was called */
|
||||
rv = -ENODEV;
|
||||
goto exit;
|
||||
}
|
||||
@@ -422,7 +421,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer,
|
||||
|
||||
/* this lock makes sure we don't submit URBs to gone devices */
|
||||
mutex_lock(&dev->io_mutex);
|
||||
if (!dev->interface) { /* disconnect() was called */
|
||||
if (dev->disconnected) { /* disconnect() was called */
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
retval = -ENODEV;
|
||||
goto error;
|
||||
@@ -509,7 +508,7 @@ static int skel_probe(struct usb_interface *interface,
|
||||
init_waitqueue_head(&dev->bulk_in_wait);
|
||||
|
||||
dev->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
dev->interface = interface;
|
||||
dev->interface = usb_get_intf(interface);
|
||||
|
||||
/* set up the endpoint information */
|
||||
/* use only the first bulk-in and bulk-out endpoints */
|
||||
@@ -582,7 +581,7 @@ static void skel_disconnect(struct usb_interface *interface)
|
||||
|
||||
/* prevent more I/O from starting */
|
||||
mutex_lock(&dev->io_mutex);
|
||||
dev->interface = NULL;
|
||||
dev->disconnected = 1;
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
|
||||
usb_kill_anchored_urbs(&dev->submitted);
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
#define IMX2_WDT_WMCR 0x08 /* Misc Register */
|
||||
|
||||
#define IMX2_WDT_MAX_TIME 128
|
||||
#define IMX2_WDT_MAX_TIME 128U
|
||||
#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */
|
||||
|
||||
#define WDOG_SEC_TO_COUNT(s) ((s * 2 - 1) << 8)
|
||||
@@ -183,7 +183,7 @@ static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
|
||||
{
|
||||
unsigned int actual;
|
||||
|
||||
actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
|
||||
actual = min(new_timeout, IMX2_WDT_MAX_TIME);
|
||||
__imx2_wdt_set_timeout(wdog, actual);
|
||||
wdog->timeout = new_timeout;
|
||||
return 0;
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "../pci/pci.h"
|
||||
#ifdef CONFIG_PCI_MMCONFIG
|
||||
#include <asm/pci_x86.h>
|
||||
|
||||
static int xen_mcfg_late(void);
|
||||
#endif
|
||||
|
||||
static bool __read_mostly pci_seg_supported = true;
|
||||
@@ -40,7 +42,18 @@ static int xen_add_device(struct device *dev)
|
||||
#ifdef CONFIG_PCI_IOV
|
||||
struct pci_dev *physfn = pci_dev->physfn;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI_MMCONFIG
|
||||
static bool pci_mcfg_reserved = false;
|
||||
/*
|
||||
* Reserve MCFG areas in Xen on first invocation due to this being
|
||||
* potentially called from inside of acpi_init immediately after
|
||||
* MCFG table has been finally parsed.
|
||||
*/
|
||||
if (!pci_mcfg_reserved) {
|
||||
xen_mcfg_late();
|
||||
pci_mcfg_reserved = true;
|
||||
}
|
||||
#endif
|
||||
if (pci_seg_supported) {
|
||||
struct {
|
||||
struct physdev_pci_device_add add;
|
||||
@@ -213,7 +226,7 @@ static int __init register_xen_pci_notifier(void)
|
||||
arch_initcall(register_xen_pci_notifier);
|
||||
|
||||
#ifdef CONFIG_PCI_MMCONFIG
|
||||
static int __init xen_mcfg_late(void)
|
||||
static int xen_mcfg_late(void)
|
||||
{
|
||||
struct pci_mmcfg_region *cfg;
|
||||
int rc;
|
||||
@@ -252,8 +265,4 @@ static int __init xen_mcfg_late(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Needs to be done after acpi_init which are subsys_initcall.
|
||||
*/
|
||||
subsys_initcall_sync(xen_mcfg_late);
|
||||
#endif
|
||||
|
||||
@@ -528,6 +528,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
v9inode = V9FS_I(inode);
|
||||
mutex_lock(&v9inode->v_mutex);
|
||||
if (!v9inode->writeback_fid &&
|
||||
(vma->vm_flags & VM_SHARED) &&
|
||||
(vma->vm_flags & VM_WRITE)) {
|
||||
/*
|
||||
* clone a fid and add it to writeback_fid
|
||||
@@ -629,6 +630,8 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
|
||||
(vma->vm_end - vma->vm_start - 1),
|
||||
};
|
||||
|
||||
if (!(vma->vm_flags & VM_SHARED))
|
||||
return;
|
||||
|
||||
p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
|
||||
|
||||
|
||||
@@ -800,7 +800,12 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
|
||||
ci->i_version = le64_to_cpu(info->version);
|
||||
inode->i_version++;
|
||||
inode->i_rdev = le32_to_cpu(info->rdev);
|
||||
inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
|
||||
/* directories have fl_stripe_unit set to zero */
|
||||
if (le32_to_cpu(info->layout.fl_stripe_unit))
|
||||
inode->i_blkbits =
|
||||
fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
|
||||
else
|
||||
inode->i_blkbits = CEPH_BLOCK_SHIFT;
|
||||
|
||||
if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) &&
|
||||
(issued & CEPH_CAP_AUTH_EXCL) == 0) {
|
||||
|
||||
@@ -3410,7 +3410,9 @@ static void delayed_work(struct work_struct *work)
|
||||
pr_info("mds%d hung\n", s->s_mds);
|
||||
}
|
||||
}
|
||||
if (s->s_state < CEPH_MDS_SESSION_OPEN) {
|
||||
if (s->s_state == CEPH_MDS_SESSION_NEW ||
|
||||
s->s_state == CEPH_MDS_SESSION_RESTARTING ||
|
||||
s->s_state == CEPH_MDS_SESSION_REJECTED) {
|
||||
/* this mds is failed or recovering, just wait */
|
||||
ceph_put_mds_session(s);
|
||||
continue;
|
||||
|
||||
@@ -830,10 +830,16 @@ lookup_out:
|
||||
static int
|
||||
cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
|
||||
{
|
||||
struct inode *inode;
|
||||
|
||||
if (flags & LOOKUP_RCU)
|
||||
return -ECHILD;
|
||||
|
||||
if (d_really_is_positive(direntry)) {
|
||||
inode = d_inode(direntry);
|
||||
if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
|
||||
CIFS_I(inode)->time = 0; /* force reval */
|
||||
|
||||
if (cifs_revalidate_dentry(direntry))
|
||||
return 0;
|
||||
else {
|
||||
@@ -844,7 +850,7 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
|
||||
* attributes will have been updated by
|
||||
* cifs_revalidate_dentry().
|
||||
*/
|
||||
if (IS_AUTOMOUNT(d_inode(direntry)) &&
|
||||
if (IS_AUTOMOUNT(inode) &&
|
||||
!(direntry->d_flags & DCACHE_NEED_AUTOMOUNT)) {
|
||||
spin_lock(&direntry->d_lock);
|
||||
direntry->d_flags |= DCACHE_NEED_AUTOMOUNT;
|
||||
|
||||
@@ -252,6 +252,12 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
|
||||
rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
|
||||
xid, fid);
|
||||
|
||||
if (rc) {
|
||||
server->ops->close(xid, tcon, fid);
|
||||
if (rc == -ESTALE)
|
||||
rc = -EOPENSTALE;
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(buf);
|
||||
return rc;
|
||||
|
||||
@@ -405,6 +405,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
|
||||
/* if uniqueid is different, return error */
|
||||
if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
|
||||
CIFS_I(*pinode)->uniqueid != fattr.cf_uniqueid)) {
|
||||
CIFS_I(*pinode)->time = 0; /* force reval */
|
||||
rc = -ESTALE;
|
||||
goto cgiiu_exit;
|
||||
}
|
||||
@@ -412,6 +413,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
|
||||
/* if filetype is different, return error */
|
||||
if (unlikely(((*pinode)->i_mode & S_IFMT) !=
|
||||
(fattr.cf_mode & S_IFMT))) {
|
||||
CIFS_I(*pinode)->time = 0; /* force reval */
|
||||
rc = -ESTALE;
|
||||
goto cgiiu_exit;
|
||||
}
|
||||
@@ -917,6 +919,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
|
||||
/* if uniqueid is different, return error */
|
||||
if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
|
||||
CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) {
|
||||
CIFS_I(*inode)->time = 0; /* force reval */
|
||||
rc = -ESTALE;
|
||||
goto cgii_exit;
|
||||
}
|
||||
@@ -924,6 +927,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
|
||||
/* if filetype is different, return error */
|
||||
if (unlikely(((*inode)->i_mode & S_IFMT) !=
|
||||
(fattr.cf_mode & S_IFMT))) {
|
||||
CIFS_I(*inode)->time = 0; /* force reval */
|
||||
rc = -ESTALE;
|
||||
goto cgii_exit;
|
||||
}
|
||||
|
||||
@@ -513,6 +513,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
|
||||
rc = cuse_send_init(cc);
|
||||
if (rc) {
|
||||
fuse_dev_free(fud);
|
||||
fuse_conn_put(&cc->fc);
|
||||
return rc;
|
||||
}
|
||||
file->private_data = fud;
|
||||
|
||||
134
fs/libfs.c
134
fs/libfs.c
@@ -85,58 +85,47 @@ int dcache_dir_close(struct inode *inode, struct file *file)
|
||||
EXPORT_SYMBOL(dcache_dir_close);
|
||||
|
||||
/* parent is locked at least shared */
|
||||
static struct dentry *next_positive(struct dentry *parent,
|
||||
struct list_head *from,
|
||||
int count)
|
||||
/*
|
||||
* Returns an element of siblings' list.
|
||||
* We are looking for <count>th positive after <p>; if
|
||||
* found, dentry is grabbed and passed to caller via *<res>.
|
||||
* If no such element exists, the anchor of list is returned
|
||||
* and *<res> is set to NULL.
|
||||
*/
|
||||
static struct list_head *scan_positives(struct dentry *cursor,
|
||||
struct list_head *p,
|
||||
loff_t count,
|
||||
struct dentry **res)
|
||||
{
|
||||
unsigned *seq = &parent->d_inode->i_dir_seq, n;
|
||||
struct dentry *res;
|
||||
struct list_head *p;
|
||||
bool skipped;
|
||||
int i;
|
||||
struct dentry *dentry = cursor->d_parent, *found = NULL;
|
||||
|
||||
retry:
|
||||
i = count;
|
||||
skipped = false;
|
||||
n = smp_load_acquire(seq) & ~1;
|
||||
res = NULL;
|
||||
rcu_read_lock();
|
||||
for (p = from->next; p != &parent->d_subdirs; p = p->next) {
|
||||
spin_lock(&dentry->d_lock);
|
||||
while ((p = p->next) != &dentry->d_subdirs) {
|
||||
struct dentry *d = list_entry(p, struct dentry, d_child);
|
||||
if (!simple_positive(d)) {
|
||||
skipped = true;
|
||||
} else if (!--i) {
|
||||
res = d;
|
||||
break;
|
||||
// we must at least skip cursors, to avoid livelocks
|
||||
if (d->d_flags & DCACHE_DENTRY_CURSOR)
|
||||
continue;
|
||||
if (simple_positive(d) && !--count) {
|
||||
spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
|
||||
if (simple_positive(d))
|
||||
found = dget_dlock(d);
|
||||
spin_unlock(&d->d_lock);
|
||||
if (likely(found))
|
||||
break;
|
||||
count = 1;
|
||||
}
|
||||
if (need_resched()) {
|
||||
list_move(&cursor->d_child, p);
|
||||
p = &cursor->d_child;
|
||||
spin_unlock(&dentry->d_lock);
|
||||
cond_resched();
|
||||
spin_lock(&dentry->d_lock);
|
||||
}
|
||||
}
|
||||
rcu_read_unlock();
|
||||
if (skipped) {
|
||||
smp_rmb();
|
||||
if (unlikely(*seq != n))
|
||||
goto retry;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void move_cursor(struct dentry *cursor, struct list_head *after)
|
||||
{
|
||||
struct dentry *parent = cursor->d_parent;
|
||||
unsigned n, *seq = &parent->d_inode->i_dir_seq;
|
||||
spin_lock(&parent->d_lock);
|
||||
for (;;) {
|
||||
n = *seq;
|
||||
if (!(n & 1) && cmpxchg(seq, n, n + 1) == n)
|
||||
break;
|
||||
cpu_relax();
|
||||
}
|
||||
__list_del(cursor->d_child.prev, cursor->d_child.next);
|
||||
if (after)
|
||||
list_add(&cursor->d_child, after);
|
||||
else
|
||||
list_add_tail(&cursor->d_child, &parent->d_subdirs);
|
||||
smp_store_release(seq, n + 2);
|
||||
spin_unlock(&parent->d_lock);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
dput(*res);
|
||||
*res = found;
|
||||
return p;
|
||||
}
|
||||
|
||||
loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
|
||||
@@ -152,17 +141,28 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
|
||||
return -EINVAL;
|
||||
}
|
||||
if (offset != file->f_pos) {
|
||||
file->f_pos = offset;
|
||||
if (file->f_pos >= 2) {
|
||||
struct dentry *cursor = file->private_data;
|
||||
struct dentry *to;
|
||||
loff_t n = file->f_pos - 2;
|
||||
struct dentry *cursor = file->private_data;
|
||||
struct dentry *to = NULL;
|
||||
struct list_head *p;
|
||||
|
||||
inode_lock_shared(dentry->d_inode);
|
||||
to = next_positive(dentry, &dentry->d_subdirs, n);
|
||||
move_cursor(cursor, to ? &to->d_child : NULL);
|
||||
inode_unlock_shared(dentry->d_inode);
|
||||
file->f_pos = offset;
|
||||
inode_lock_shared(dentry->d_inode);
|
||||
|
||||
if (file->f_pos > 2) {
|
||||
p = scan_positives(cursor, &dentry->d_subdirs,
|
||||
file->f_pos - 2, &to);
|
||||
spin_lock(&dentry->d_lock);
|
||||
list_move(&cursor->d_child, p);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
} else {
|
||||
spin_lock(&dentry->d_lock);
|
||||
list_del_init(&cursor->d_child);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
}
|
||||
|
||||
dput(to);
|
||||
|
||||
inode_unlock_shared(dentry->d_inode);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
@@ -184,25 +184,29 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
|
||||
{
|
||||
struct dentry *dentry = file->f_path.dentry;
|
||||
struct dentry *cursor = file->private_data;
|
||||
struct list_head *p = &cursor->d_child;
|
||||
struct dentry *next;
|
||||
bool moved = false;
|
||||
struct list_head *anchor = &dentry->d_subdirs;
|
||||
struct dentry *next = NULL;
|
||||
struct list_head *p;
|
||||
|
||||
if (!dir_emit_dots(file, ctx))
|
||||
return 0;
|
||||
|
||||
if (ctx->pos == 2)
|
||||
p = &dentry->d_subdirs;
|
||||
while ((next = next_positive(dentry, p, 1)) != NULL) {
|
||||
p = anchor;
|
||||
else
|
||||
p = &cursor->d_child;
|
||||
|
||||
while ((p = scan_positives(cursor, p, 1, &next)) != anchor) {
|
||||
if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
|
||||
d_inode(next)->i_ino, dt_type(d_inode(next))))
|
||||
break;
|
||||
moved = true;
|
||||
p = &next->d_child;
|
||||
ctx->pos++;
|
||||
}
|
||||
if (moved)
|
||||
move_cursor(cursor, p);
|
||||
spin_lock(&dentry->d_lock);
|
||||
list_move_tail(&cursor->d_child, p);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
dput(next);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(dcache_readdir);
|
||||
|
||||
@@ -1123,7 +1123,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
|
||||
} else
|
||||
*p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
|
||||
}
|
||||
if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) {
|
||||
if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) {
|
||||
*p++ = cpu_to_be32(label->lfs);
|
||||
*p++ = cpu_to_be32(label->pi);
|
||||
*p++ = cpu_to_be32(label->len);
|
||||
|
||||
@@ -1674,6 +1674,7 @@ xfs_fs_fill_super(
|
||||
out_close_devices:
|
||||
xfs_close_devices(mp);
|
||||
out_free_fsname:
|
||||
sb->s_fs_info = NULL;
|
||||
xfs_free_fsname(mp);
|
||||
kfree(mp);
|
||||
out:
|
||||
@@ -1691,6 +1692,10 @@ xfs_fs_put_super(
|
||||
{
|
||||
struct xfs_mount *mp = XFS_M(sb);
|
||||
|
||||
/* if ->fill_super failed, we have no mount to tear down */
|
||||
if (!sb->s_fs_info)
|
||||
return;
|
||||
|
||||
xfs_notice(mp, "Unmounting Filesystem");
|
||||
xfs_filestream_unmount(mp);
|
||||
xfs_unmountfs(mp);
|
||||
@@ -1700,6 +1705,8 @@ xfs_fs_put_super(
|
||||
xfs_destroy_percpu_counters(mp);
|
||||
xfs_destroy_mount_workqueues(mp);
|
||||
xfs_close_devices(mp);
|
||||
|
||||
sb->s_fs_info = NULL;
|
||||
xfs_free_fsname(mp);
|
||||
kfree(mp);
|
||||
}
|
||||
@@ -1719,6 +1726,9 @@ xfs_fs_nr_cached_objects(
|
||||
struct super_block *sb,
|
||||
struct shrink_control *sc)
|
||||
{
|
||||
/* Paranoia: catch incorrect calls during mount setup or teardown */
|
||||
if (WARN_ON_ONCE(!sb->s_fs_info))
|
||||
return 0;
|
||||
return xfs_reclaim_inodes_count(XFS_M(sb));
|
||||
}
|
||||
|
||||
|
||||
@@ -2630,4 +2630,57 @@ static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb)
|
||||
return true;
|
||||
}
|
||||
|
||||
struct element {
|
||||
u8 id;
|
||||
u8 datalen;
|
||||
u8 data[];
|
||||
} __packed;
|
||||
|
||||
/* element iteration helpers */
|
||||
#define for_each_element(_elem, _data, _datalen) \
|
||||
for (_elem = (const struct element *)(_data); \
|
||||
(const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
|
||||
(int)sizeof(*_elem) && \
|
||||
(const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
|
||||
(int)sizeof(*_elem) + _elem->datalen; \
|
||||
_elem = (const struct element *)(_elem->data + _elem->datalen))
|
||||
|
||||
#define for_each_element_id(element, _id, data, datalen) \
|
||||
for_each_element(element, data, datalen) \
|
||||
if (element->id == (_id))
|
||||
|
||||
#define for_each_element_extid(element, extid, data, datalen) \
|
||||
for_each_element(element, data, datalen) \
|
||||
if (element->id == WLAN_EID_EXTENSION && \
|
||||
element->datalen > 0 && \
|
||||
element->data[0] == (extid))
|
||||
|
||||
#define for_each_subelement(sub, element) \
|
||||
for_each_element(sub, (element)->data, (element)->datalen)
|
||||
|
||||
#define for_each_subelement_id(sub, id, element) \
|
||||
for_each_element_id(sub, id, (element)->data, (element)->datalen)
|
||||
|
||||
#define for_each_subelement_extid(sub, extid, element) \
|
||||
for_each_element_extid(sub, extid, (element)->data, (element)->datalen)
|
||||
|
||||
/**
|
||||
* for_each_element_completed - determine if element parsing consumed all data
|
||||
* @element: element pointer after for_each_element() or friends
|
||||
* @data: same data pointer as passed to for_each_element() or friends
|
||||
* @datalen: same data length as passed to for_each_element() or friends
|
||||
*
|
||||
* This function returns %true if all the data was parsed or considered
|
||||
* while walking the elements. Only use this if your for_each_element()
|
||||
* loop cannot be broken out of, otherwise it always returns %false.
|
||||
*
|
||||
* If some data was malformed, this returns %false since the last parsed
|
||||
* element will not fill the whole remaining data.
|
||||
*/
|
||||
static inline bool for_each_element_completed(const struct element *element,
|
||||
const void *data, size_t datalen)
|
||||
{
|
||||
return (const u8 *)element == (const u8 *)data + datalen;
|
||||
}
|
||||
|
||||
#endif /* LINUX_IEEE80211_H */
|
||||
|
||||
@@ -339,6 +339,8 @@ struct device;
|
||||
#define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */
|
||||
#define SND_SOC_DAPM_PRE_POST_PMD \
|
||||
(SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)
|
||||
#define SND_SOC_DAPM_PRE_POST_PMU \
|
||||
(SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)
|
||||
|
||||
/* convenience event type detection */
|
||||
#define SND_SOC_DAPM_EVENT_ON(e) \
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <linux/fs.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/binfmts.h>
|
||||
#include <linux/elfcore.h>
|
||||
|
||||
Elf_Half __weak elf_core_extra_phdrs(void)
|
||||
{
|
||||
|
||||
@@ -2493,7 +2493,7 @@ int sysctl_max_threads(struct ctl_table *table, int write,
|
||||
struct ctl_table t;
|
||||
int ret;
|
||||
int threads = max_threads;
|
||||
int min = MIN_THREADS;
|
||||
int min = 1;
|
||||
int max = MAX_THREADS;
|
||||
|
||||
t = *table;
|
||||
@@ -2505,7 +2505,7 @@ int sysctl_max_threads(struct ctl_table *table, int write,
|
||||
if (ret || !write)
|
||||
return ret;
|
||||
|
||||
set_max_threads(threads);
|
||||
max_threads = threads;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ void panic(const char *fmt, ...)
|
||||
* after setting panic_cpu) from invoking panic() again.
|
||||
*/
|
||||
local_irq_disable();
|
||||
preempt_disable_notrace();
|
||||
|
||||
/*
|
||||
* It's possible to come here directly from a panic-assertion and
|
||||
|
||||
@@ -1169,7 +1169,8 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
|
||||
if (cpumask_equal(&p->cpus_allowed, new_mask))
|
||||
goto out;
|
||||
|
||||
if (!cpumask_intersects(new_mask, cpu_valid_mask)) {
|
||||
dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
|
||||
if (dest_cpu >= nr_cpu_ids) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -1190,7 +1191,6 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
|
||||
if (cpumask_test_cpu(task_cpu(p), new_mask))
|
||||
goto out;
|
||||
|
||||
dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
|
||||
if (task_running(rq, p) || p->state == TASK_WAKING) {
|
||||
struct migration_arg arg = { p, dest_cpu };
|
||||
/* Need help from migration thread: drop lock and wait. */
|
||||
|
||||
@@ -1586,21 +1586,23 @@ void timer_clear_idle(void)
|
||||
static int collect_expired_timers(struct timer_base *base,
|
||||
struct hlist_head *heads)
|
||||
{
|
||||
unsigned long now = READ_ONCE(jiffies);
|
||||
|
||||
/*
|
||||
* NOHZ optimization. After a long idle sleep we need to forward the
|
||||
* base to current jiffies. Avoid a loop by searching the bitfield for
|
||||
* the next expiring timer.
|
||||
*/
|
||||
if ((long)(jiffies - base->clk) > 2) {
|
||||
if ((long)(now - base->clk) > 2) {
|
||||
unsigned long next = __next_timer_interrupt(base);
|
||||
|
||||
/*
|
||||
* If the next timer is ahead of time forward to current
|
||||
* jiffies, otherwise forward to the next expiry time:
|
||||
*/
|
||||
if (time_after(next, jiffies)) {
|
||||
if (time_after(next, now)) {
|
||||
/* The call site will increment clock! */
|
||||
base->clk = jiffies - 1;
|
||||
base->clk = now - 1;
|
||||
return 0;
|
||||
}
|
||||
base->clk = next;
|
||||
|
||||
@@ -3771,9 +3771,14 @@ static int show_traces_open(struct inode *inode, struct file *file)
|
||||
if (tracing_disabled)
|
||||
return -ENODEV;
|
||||
|
||||
if (trace_array_get(tr) < 0)
|
||||
return -ENODEV;
|
||||
|
||||
ret = seq_open(file, &show_traces_seq_ops);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
trace_array_put(tr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
m = file->private_data;
|
||||
m->private = tr;
|
||||
@@ -3781,6 +3786,14 @@ static int show_traces_open(struct inode *inode, struct file *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int show_traces_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct trace_array *tr = inode->i_private;
|
||||
|
||||
trace_array_put(tr);
|
||||
return seq_release(inode, file);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
tracing_write_stub(struct file *filp, const char __user *ubuf,
|
||||
size_t count, loff_t *ppos)
|
||||
@@ -3811,8 +3824,8 @@ static const struct file_operations tracing_fops = {
|
||||
static const struct file_operations show_traces_fops = {
|
||||
.open = show_traces_open,
|
||||
.read = seq_read,
|
||||
.release = seq_release,
|
||||
.llseek = seq_lseek,
|
||||
.release = show_traces_release,
|
||||
};
|
||||
|
||||
static ssize_t
|
||||
|
||||
@@ -151,7 +151,7 @@ void trace_hwlat_callback(bool enter)
|
||||
if (enter)
|
||||
nmi_ts_start = time_get();
|
||||
else
|
||||
nmi_total_ts = time_get() - nmi_ts_start;
|
||||
nmi_total_ts += time_get() - nmi_ts_start;
|
||||
}
|
||||
|
||||
if (enter)
|
||||
@@ -257,6 +257,8 @@ static int get_sample(void)
|
||||
/* Keep a running maximum ever recorded hardware latency */
|
||||
if (sample > tr->max_latency)
|
||||
tr->max_latency = sample;
|
||||
if (outer_sample > tr->max_latency)
|
||||
tr->max_latency = outer_sample;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/sections.h>
|
||||
|
||||
@@ -216,7 +217,12 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
|
||||
if (!virt_addr_valid(ptr))
|
||||
return NULL;
|
||||
|
||||
page = virt_to_head_page(ptr);
|
||||
/*
|
||||
* When CONFIG_HIGHMEM=y, kmap_to_page() will give either the
|
||||
* highmem page or fallback to virt_to_page(). The following
|
||||
* is effectively a highmem-aware virt_to_head_page().
|
||||
*/
|
||||
page = compound_head(kmap_to_page((void *)ptr));
|
||||
|
||||
/* Check slab allocator for flags and size. */
|
||||
if (PageSlab(page))
|
||||
|
||||
@@ -213,6 +213,36 @@ cfg80211_get_dev_from_info(struct net *netns, struct genl_info *info)
|
||||
return __cfg80211_rdev_from_attrs(netns, info->attrs);
|
||||
}
|
||||
|
||||
static int validate_beacon_head(const struct nlattr *attr)
|
||||
{
|
||||
const u8 *data = nla_data(attr);
|
||||
unsigned int len = nla_len(attr);
|
||||
const struct element *elem;
|
||||
const struct ieee80211_mgmt *mgmt = (void *)data;
|
||||
unsigned int fixedlen = offsetof(struct ieee80211_mgmt,
|
||||
u.beacon.variable);
|
||||
|
||||
if (len < fixedlen)
|
||||
goto err;
|
||||
|
||||
if (ieee80211_hdrlen(mgmt->frame_control) !=
|
||||
offsetof(struct ieee80211_mgmt, u.beacon))
|
||||
goto err;
|
||||
|
||||
data += fixedlen;
|
||||
len -= fixedlen;
|
||||
|
||||
for_each_element(elem, data, len) {
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
if (for_each_element_completed(elem, data, len))
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* policy for the attributes */
|
||||
static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
|
||||
[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
|
||||
@@ -2069,6 +2099,8 @@ static int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
|
||||
|
||||
control_freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
|
||||
|
||||
memset(chandef, 0, sizeof(*chandef));
|
||||
|
||||
chandef->chan = ieee80211_get_channel(&rdev->wiphy, control_freq);
|
||||
chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
|
||||
chandef->center_freq1 = control_freq;
|
||||
@@ -2538,7 +2570,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
|
||||
|
||||
if (rdev->ops->get_channel) {
|
||||
int ret;
|
||||
struct cfg80211_chan_def chandef;
|
||||
struct cfg80211_chan_def chandef = {};
|
||||
|
||||
ret = rdev_get_channel(rdev, wdev, &chandef);
|
||||
if (ret == 0) {
|
||||
@@ -3678,6 +3710,11 @@ static int nl80211_parse_beacon(struct nlattr *attrs[],
|
||||
memset(bcn, 0, sizeof(*bcn));
|
||||
|
||||
if (attrs[NL80211_ATTR_BEACON_HEAD]) {
|
||||
int ret = validate_beacon_head(attrs[NL80211_ATTR_BEACON_HEAD]);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
bcn->head = nla_data(attrs[NL80211_ATTR_BEACON_HEAD]);
|
||||
bcn->head_len = nla_len(attrs[NL80211_ATTR_BEACON_HEAD]);
|
||||
if (!bcn->head_len)
|
||||
|
||||
@@ -1564,7 +1564,7 @@ static void reg_call_notifier(struct wiphy *wiphy,
|
||||
|
||||
static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
|
||||
{
|
||||
struct cfg80211_chan_def chandef;
|
||||
struct cfg80211_chan_def chandef = {};
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
enum nl80211_iftype iftype;
|
||||
|
||||
|
||||
@@ -407,6 +407,8 @@ const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
|
||||
const u8 *match, int match_len,
|
||||
int match_offset)
|
||||
{
|
||||
const struct element *elem;
|
||||
|
||||
/* match_offset can't be smaller than 2, unless match_len is
|
||||
* zero, in which case match_offset must be zero as well.
|
||||
*/
|
||||
@@ -414,14 +416,10 @@ const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
|
||||
(!match_len && match_offset)))
|
||||
return NULL;
|
||||
|
||||
while (len >= 2 && len >= ies[1] + 2) {
|
||||
if ((ies[0] == eid) &&
|
||||
(ies[1] + 2 >= match_offset + match_len) &&
|
||||
!memcmp(ies + match_offset, match, match_len))
|
||||
return ies;
|
||||
|
||||
len -= ies[1] + 2;
|
||||
ies += ies[1] + 2;
|
||||
for_each_element_id(elem, eid, ies, len) {
|
||||
if (elem->datalen >= match_offset - 2 + match_len &&
|
||||
!memcmp(elem->data + match_offset - 2, match, match_len))
|
||||
return (void *)elem;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -799,7 +799,7 @@ static int cfg80211_wext_giwfreq(struct net_device *dev,
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
struct cfg80211_chan_def chandef;
|
||||
struct cfg80211_chan_def chandef = {};
|
||||
int ret;
|
||||
|
||||
switch (wdev->iftype) {
|
||||
|
||||
@@ -298,8 +298,11 @@ static int ima_calc_file_hash_atfm(struct file *file,
|
||||
rbuf_len = min_t(loff_t, i_size - offset, rbuf_size[active]);
|
||||
rc = integrity_kernel_read(file, offset, rbuf[active],
|
||||
rbuf_len);
|
||||
if (rc != rbuf_len)
|
||||
if (rc != rbuf_len) {
|
||||
if (rc >= 0)
|
||||
rc = -EINVAL;
|
||||
goto out3;
|
||||
}
|
||||
|
||||
if (rbuf[1] && offset) {
|
||||
/* Using two buffers, and it is not the first
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
#define SGTL5000_DAP_REG_OFFSET 0x0100
|
||||
#define SGTL5000_MAX_REG_OFFSET 0x013A
|
||||
|
||||
/* Delay for the VAG ramp up */
|
||||
#define SGTL5000_VAG_POWERUP_DELAY 500 /* ms */
|
||||
/* Delay for the VAG ramp down */
|
||||
#define SGTL5000_VAG_POWERDOWN_DELAY 500 /* ms */
|
||||
|
||||
#define SGTL5000_OUTPUTS_MUTE (SGTL5000_HP_MUTE | SGTL5000_LINE_OUT_MUTE)
|
||||
|
||||
/* default value of sgtl5000 registers */
|
||||
static const struct reg_default sgtl5000_reg_defaults[] = {
|
||||
{ SGTL5000_CHIP_DIG_POWER, 0x0000 },
|
||||
@@ -99,6 +106,13 @@ enum sgtl5000_micbias_resistor {
|
||||
SGTL5000_MICBIAS_8K = 8,
|
||||
};
|
||||
|
||||
enum {
|
||||
HP_POWER_EVENT,
|
||||
DAC_POWER_EVENT,
|
||||
ADC_POWER_EVENT,
|
||||
LAST_POWER_EVENT = ADC_POWER_EVENT
|
||||
};
|
||||
|
||||
/* sgtl5000 private structure in codec */
|
||||
struct sgtl5000_priv {
|
||||
int sysclk; /* sysclk rate */
|
||||
@@ -111,8 +125,117 @@ struct sgtl5000_priv {
|
||||
int revision;
|
||||
u8 micbias_resistor;
|
||||
u8 micbias_voltage;
|
||||
u16 mute_state[LAST_POWER_EVENT + 1];
|
||||
};
|
||||
|
||||
static inline int hp_sel_input(struct snd_soc_component *component)
|
||||
{
|
||||
unsigned int ana_reg = 0;
|
||||
|
||||
snd_soc_component_read(component, SGTL5000_CHIP_ANA_CTRL, &ana_reg);
|
||||
|
||||
return (ana_reg & SGTL5000_HP_SEL_MASK) >> SGTL5000_HP_SEL_SHIFT;
|
||||
}
|
||||
|
||||
static inline u16 mute_output(struct snd_soc_component *component,
|
||||
u16 mute_mask)
|
||||
{
|
||||
unsigned int mute_reg = 0;
|
||||
|
||||
snd_soc_component_read(component, SGTL5000_CHIP_ANA_CTRL, &mute_reg);
|
||||
|
||||
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
|
||||
mute_mask, mute_mask);
|
||||
return mute_reg;
|
||||
}
|
||||
|
||||
static inline void restore_output(struct snd_soc_component *component,
|
||||
u16 mute_mask, u16 mute_reg)
|
||||
{
|
||||
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
|
||||
mute_mask, mute_reg);
|
||||
}
|
||||
|
||||
static void vag_power_on(struct snd_soc_component *component, u32 source)
|
||||
{
|
||||
unsigned int ana_reg = 0;
|
||||
|
||||
snd_soc_component_read(component, SGTL5000_CHIP_ANA_POWER, &ana_reg);
|
||||
|
||||
if (ana_reg & SGTL5000_VAG_POWERUP)
|
||||
return;
|
||||
|
||||
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
|
||||
SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
|
||||
|
||||
/* When VAG powering on to get local loop from Line-In, the sleep
|
||||
* is required to avoid loud pop.
|
||||
*/
|
||||
if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN &&
|
||||
source == HP_POWER_EVENT)
|
||||
msleep(SGTL5000_VAG_POWERUP_DELAY);
|
||||
}
|
||||
|
||||
static int vag_power_consumers(struct snd_soc_component *component,
|
||||
u16 ana_pwr_reg, u32 source)
|
||||
{
|
||||
int consumers = 0;
|
||||
|
||||
/* count dac/adc consumers unconditional */
|
||||
if (ana_pwr_reg & SGTL5000_DAC_POWERUP)
|
||||
consumers++;
|
||||
if (ana_pwr_reg & SGTL5000_ADC_POWERUP)
|
||||
consumers++;
|
||||
|
||||
/*
|
||||
* If the event comes from HP and Line-In is selected,
|
||||
* current action is 'DAC to be powered down'.
|
||||
* As HP_POWERUP is not set when HP muxed to line-in,
|
||||
* we need to keep VAG power ON.
|
||||
*/
|
||||
if (source == HP_POWER_EVENT) {
|
||||
if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN)
|
||||
consumers++;
|
||||
} else {
|
||||
if (ana_pwr_reg & SGTL5000_HP_POWERUP)
|
||||
consumers++;
|
||||
}
|
||||
|
||||
return consumers;
|
||||
}
|
||||
|
||||
static void vag_power_off(struct snd_soc_component *component, u32 source)
|
||||
{
|
||||
unsigned int ana_pwr = SGTL5000_VAG_POWERUP;
|
||||
|
||||
snd_soc_component_read(component, SGTL5000_CHIP_ANA_POWER, &ana_pwr);
|
||||
|
||||
if (!(ana_pwr & SGTL5000_VAG_POWERUP))
|
||||
return;
|
||||
|
||||
/*
|
||||
* This function calls when any of VAG power consumers is disappearing.
|
||||
* Thus, if there is more than one consumer at the moment, as minimum
|
||||
* one consumer will definitely stay after the end of the current
|
||||
* event.
|
||||
* Don't clear VAG_POWERUP if 2 or more consumers of VAG present:
|
||||
* - LINE_IN (for HP events) / HP (for DAC/ADC events)
|
||||
* - DAC
|
||||
* - ADC
|
||||
* (the current consumer is disappearing right now)
|
||||
*/
|
||||
if (vag_power_consumers(component, ana_pwr, source) >= 2)
|
||||
return;
|
||||
|
||||
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
|
||||
SGTL5000_VAG_POWERUP, 0);
|
||||
/* In power down case, we need wait 400-1000 ms
|
||||
* when VAG fully ramped down.
|
||||
* As longer we wait, as smaller pop we've got.
|
||||
*/
|
||||
msleep(SGTL5000_VAG_POWERDOWN_DELAY);
|
||||
}
|
||||
|
||||
/*
|
||||
* mic_bias power on/off share the same register bits with
|
||||
* output impedance of mic bias, when power on mic bias, we
|
||||
@@ -144,36 +267,46 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* As manual described, ADC/DAC only works when VAG powerup,
|
||||
* So enabled VAG before ADC/DAC up.
|
||||
* In power down case, we need wait 400ms when vag fully ramped down.
|
||||
*/
|
||||
static int power_vag_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
static int vag_and_mute_control(struct snd_soc_component *component,
|
||||
int event, int event_source)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
|
||||
static const u16 mute_mask[] = {
|
||||
/*
|
||||
* Mask for HP_POWER_EVENT.
|
||||
* Muxing Headphones have to be wrapped with mute/unmute
|
||||
* headphones only.
|
||||
*/
|
||||
SGTL5000_HP_MUTE,
|
||||
/*
|
||||
* Masks for DAC_POWER_EVENT/ADC_POWER_EVENT.
|
||||
* Muxing DAC or ADC block have to be wrapped with mute/unmute
|
||||
* both headphones and line-out.
|
||||
*/
|
||||
SGTL5000_OUTPUTS_MUTE,
|
||||
SGTL5000_OUTPUTS_MUTE
|
||||
};
|
||||
|
||||
struct sgtl5000_priv *sgtl5000 =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
|
||||
SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
|
||||
msleep(400);
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
sgtl5000->mute_state[event_source] =
|
||||
mute_output(component, mute_mask[event_source]);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
vag_power_on(component, event_source);
|
||||
restore_output(component, mute_mask[event_source],
|
||||
sgtl5000->mute_state[event_source]);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
/*
|
||||
* Don't clear VAG_POWERUP, when both DAC and ADC are
|
||||
* operational to prevent inadvertently starving the
|
||||
* other one of them.
|
||||
*/
|
||||
if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) &
|
||||
mask) != mask) {
|
||||
snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
|
||||
SGTL5000_VAG_POWERUP, 0);
|
||||
msleep(400);
|
||||
}
|
||||
sgtl5000->mute_state[event_source] =
|
||||
mute_output(component, mute_mask[event_source]);
|
||||
vag_power_off(component, event_source);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
restore_output(component, mute_mask[event_source],
|
||||
sgtl5000->mute_state[event_source]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -182,6 +315,41 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mute Headphone when power it up/down.
|
||||
* Control VAG power on HP power path.
|
||||
*/
|
||||
static int headphone_pga_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
return vag_and_mute_control(component, event, HP_POWER_EVENT);
|
||||
}
|
||||
|
||||
/* As manual describes, ADC/DAC powering up/down requires
|
||||
* to mute outputs to avoid pops.
|
||||
* Control VAG power on ADC/DAC power path.
|
||||
*/
|
||||
static int adc_updown_depop(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
return vag_and_mute_control(component, event, ADC_POWER_EVENT);
|
||||
}
|
||||
|
||||
static int dac_updown_depop(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
return vag_and_mute_control(component, event, DAC_POWER_EVENT);
|
||||
}
|
||||
|
||||
/* input sources for ADC */
|
||||
static const char *adc_mux_text[] = {
|
||||
"MIC_IN", "LINE_IN"
|
||||
@@ -217,7 +385,10 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
|
||||
mic_bias_event,
|
||||
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
|
||||
|
||||
SND_SOC_DAPM_PGA("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0),
|
||||
SND_SOC_DAPM_PGA_E("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0,
|
||||
headphone_pga_event,
|
||||
SND_SOC_DAPM_PRE_POST_PMU |
|
||||
SND_SOC_DAPM_PRE_POST_PMD),
|
||||
SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),
|
||||
|
||||
SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux),
|
||||
@@ -233,11 +404,12 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
|
||||
0, SGTL5000_CHIP_DIG_POWER,
|
||||
1, 0),
|
||||
|
||||
SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0),
|
||||
SND_SOC_DAPM_DAC("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0),
|
||||
|
||||
SND_SOC_DAPM_PRE("VAG_POWER_PRE", power_vag_event),
|
||||
SND_SOC_DAPM_POST("VAG_POWER_POST", power_vag_event),
|
||||
SND_SOC_DAPM_ADC_E("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0,
|
||||
adc_updown_depop, SND_SOC_DAPM_PRE_POST_PMU |
|
||||
SND_SOC_DAPM_PRE_POST_PMD),
|
||||
SND_SOC_DAPM_DAC_E("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0,
|
||||
dac_updown_depop, SND_SOC_DAPM_PRE_POST_PMU |
|
||||
SND_SOC_DAPM_PRE_POST_PMD),
|
||||
};
|
||||
|
||||
/* routes for sgtl5000 */
|
||||
|
||||
@@ -267,10 +267,10 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
pevent->cmdlines = cmdlines;
|
||||
|
||||
cmdlines[pevent->cmdline_count].comm = strdup(comm);
|
||||
if (!cmdlines[pevent->cmdline_count].comm) {
|
||||
free(cmdlines);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@@ -281,7 +281,6 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
|
||||
pevent->cmdline_count++;
|
||||
|
||||
qsort(cmdlines, pevent->cmdline_count, sizeof(*cmdlines), cmdline_cmp);
|
||||
pevent->cmdlines = cmdlines;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2564,8 +2564,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||
fprintf(output, "[ perf stat: executing run #%d ... ]\n",
|
||||
run_idx + 1);
|
||||
|
||||
if (run_idx != 0)
|
||||
perf_evlist__reset_prev_raw_counts(evsel_list);
|
||||
|
||||
status = run_perf_stat(argc, argv);
|
||||
if (forever && status != -1) {
|
||||
if (forever && status != -1 && !interval) {
|
||||
print_counters(NULL, argc, argv);
|
||||
perf_stat__reset_stats();
|
||||
}
|
||||
|
||||
@@ -949,7 +949,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
|
||||
|
||||
scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path);
|
||||
if (sysfs__read_str(file, &cache->map, &len)) {
|
||||
free(cache->map);
|
||||
free(cache->size);
|
||||
free(cache->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
|
||||
size_t size;
|
||||
u16 idr_size;
|
||||
const char *sym;
|
||||
uint32_t count;
|
||||
uint64_t count;
|
||||
int ret, csize;
|
||||
pid_t pid, tid;
|
||||
struct {
|
||||
@@ -391,7 +391,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
|
||||
return -1;
|
||||
|
||||
filename = event->mmap2.filename;
|
||||
size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%u.so",
|
||||
size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so",
|
||||
jd->dir,
|
||||
pid,
|
||||
count);
|
||||
@@ -493,7 +493,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)
|
||||
return -1;
|
||||
|
||||
filename = event->mmap2.filename;
|
||||
size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%"PRIu64,
|
||||
size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so",
|
||||
jd->dir,
|
||||
pid,
|
||||
jr->move.code_index);
|
||||
|
||||
@@ -220,14 +220,14 @@ static int detect_kbuild_dir(char **kbuild_dir)
|
||||
const char *prefix_dir = "";
|
||||
const char *suffix_dir = "";
|
||||
|
||||
/* _UTSNAME_LENGTH is 65 */
|
||||
char release[128];
|
||||
|
||||
char *autoconf_path;
|
||||
|
||||
int err;
|
||||
|
||||
if (!test_dir) {
|
||||
/* _UTSNAME_LENGTH is 65 */
|
||||
char release[128];
|
||||
|
||||
err = fetch_kernel_version(NULL, release,
|
||||
sizeof(release));
|
||||
if (err)
|
||||
|
||||
@@ -145,6 +145,15 @@ static void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
|
||||
evsel->prev_raw_counts = NULL;
|
||||
}
|
||||
|
||||
static void perf_evsel__reset_prev_raw_counts(struct perf_evsel *evsel)
|
||||
{
|
||||
if (evsel->prev_raw_counts) {
|
||||
evsel->prev_raw_counts->aggr.val = 0;
|
||||
evsel->prev_raw_counts->aggr.ena = 0;
|
||||
evsel->prev_raw_counts->aggr.run = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw)
|
||||
{
|
||||
int ncpus = perf_evsel__nr_cpus(evsel);
|
||||
@@ -195,6 +204,14 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist)
|
||||
}
|
||||
}
|
||||
|
||||
void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist)
|
||||
{
|
||||
struct perf_evsel *evsel;
|
||||
|
||||
evlist__for_each_entry(evlist, evsel)
|
||||
perf_evsel__reset_prev_raw_counts(evsel);
|
||||
}
|
||||
|
||||
static void zero_per_pkg(struct perf_evsel *counter)
|
||||
{
|
||||
if (counter->per_pkg_mask)
|
||||
|
||||
@@ -94,6 +94,7 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
|
||||
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
|
||||
void perf_evlist__free_stats(struct perf_evlist *evlist);
|
||||
void perf_evlist__reset_stats(struct perf_evlist *evlist);
|
||||
void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist);
|
||||
|
||||
int perf_stat_process_counter(struct perf_stat_config *config,
|
||||
struct perf_evsel *counter);
|
||||
|
||||
Reference in New Issue
Block a user