mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 03:43:03 +00:00
4a36e44c45
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVoAOcAAoJEDjbvchgkmk+UhcP/1EOwnsJDcZ/sZkkclNgRmrJ yLBCW65caLAI2E3SmIdKvHQwIx7lHzX5gmWRBrvx+fIl4KhaNKEQ0NCOf1ATaVuQ MkYMdkicXWpLiFNdKokezryevGS8T1RME+2QlPFv3++Rby1Gy90YD5tu7YlIrEn7 sPRJQHEPCzVAQ7Lqhd66yHICM6/QvdefXj4pjh7vV8IMb2YwnY4vqYt7RxnJCUfP tqljxrT274kzpA2awzALNh+o3B3/Y4W9ROmlDWviw3JBc9gEqFXYwbDf8KDwA5c0 sp9GPGed/dV5DFuqRcAHksJenFnE3E4gZjo/R5hluHQU27peBuRfXev2hZyBfZqG 796eUOky8fb0OiyxHfT2vhfGeD7CHI/asvIAORjDBVUqzJy9nkkby3XJ0U4tW+pz VkcilD2oHw1uRIFH3JoBWTJ9W6CYSNFG1qxw+brgfKT5otJG/dBiI8kBABx+aTq7 V+A2cvf11oVwDEb93dnVypMGsfCywqzJUwEIRli9fTFjK7Fg9CBSGX38nwVGUaRv M2/NeloTyWqUQE41Nd11gCu+hKQRtUU77nxpZcSeKn1XsbpO9/7dHTwcELRuKnTD 9XDksqPznXmC9KXGj7XMcRkLyWyB//JHjay0FCS6b4S6v7R5nrEIRjcpdB+H1WLd zMOXRH4ZlcOAS/Yt2QMd =8AB3 -----END PGP SIGNATURE----- Merge upstream tag 'v3.10.84' into LA.BR.1.3.3 This merge brings us up-to-date as of upstream tag v3.10.84 * tag 'v3.10.84' (317 commits): Linux 3.10.84 fs: Fix S_NOSEC handling KVM: x86: make vapics_in_nmi_mode atomic MIPS: Fix KVM guest fixmap address x86/PCI: Use host bridge _CRS info on Foxconn K8M890-8237A powerpc/perf: Fix book3s kernel to userspace backtraces arm: KVM: force execution of HCPTR access on VM exit Revert "crypto: talitos - convert to use be16_add_cpu()" crypto: talitos - avoid memleak in talitos_alg_alloc() sctp: Fix race between OOTB responce and route removal packet: avoid out of bounds read in round robin fanout packet: read num_members once in packet_rcv_fanout() bridge: fix br_stp_set_bridge_priority race conditions bridge: fix multicast router rlist endless loop sparc: Use GFP_ATOMIC in ldc_alloc_exp_dring() as it can be called in softirq context Linux 3.10.83 bus: mvebu: pass the coherency availability information at init time KVM: nSVM: Check for NRIPS support before updating control field ARM: clk-imx6q: refine sata's parent d_walk() might skip too much ipv6: update ip6_rt_last_gc every time GC is run ipv6: prevent fib6_run_gc() contention xfrm: Increase the garbage collector threshold Btrfs: make xattr replace operations atomic x86/microcode/intel: Guard against stack overflow in the loader fs: take i_mutex during prepare_binprm for set[ug]id executables hpsa: add missing pci_set_master in kdump path hpsa: refine the pci enable/disable handling sb_edac: Fix erroneous bytes->gigabytes conversion ACPICA: Utilities: Cleanup to remove useless ACPI_PRINTF/FORMAT_xxx helpers. ACPICA: Utilities: Cleanup to convert physical address printing formats. __ptrace_may_access() should not deny sub-threads include/linux/sched.h: don't use task->pid/tgid in same_thread_group/has_group_leader_pid netfilter: Zero the tuple in nfnl_cthelper_parse_tuple() netfilter: nfnetlink_cthelper: Remove 'const' and '&' to avoid warnings config: Enable NEED_DMA_MAP_STATE by default when SWIOTLB is selected get rid of s_files and files_lock fput: turn "list_head delayed_fput_list" into llist_head Linux 3.10.82 lpfc: Add iotag memory barrier pipe: iovec: Fix memory corruption when retrying atomic copy as non-atomic drm/mgag200: Reject non-character-cell-aligned mode widths tracing: Have filter check for balanced ops crypto: caam - fix RNG buffer cache alignment Linux 3.10.81 btrfs: cleanup orphans while looking up default subvolume btrfs: incorrect handling for fiemap_fill_next_extent return cfg80211: wext: clear sinfo struct before calling driver mm/memory_hotplug.c: set zone->wait_table to null after freeing it drm/i915: Fix DDC probe for passive adapters pata_octeon_cf: fix broken build ozwpan: unchecked signed subtraction leads to DoS ozwpan: divide-by-zero leading to panic ozwpan: Use proper check to prevent heap overflow MIPS: Fix enabling of DEBUG_STACKOVERFLOW ring-buffer-benchmark: Fix the wrong sched_priority of producer USB: serial: ftdi_sio: Add support for a Motion Tracker Development Board USB: cp210x: add ID for HubZ dual ZigBee and Z-Wave dongle block: fix ext_dev_lock lockdep report Input: elantech - fix detection of touchpads where the revision matches a known rate ALSA: usb-audio: add MAYA44 USB+ mixer control names ALSA: usb-audio: Add mic volume fix quirk for Logitech Quickcam Fusion ALSA: hda/realtek - Add a fixup for another Acer Aspire 9420 iio: adis16400: Compute the scan mask from channel indices iio: adis16400: Use != channel indices for the two voltage channels iio: adis16400: Report pressure channel scale xen: netback: read hotplug script once at start of day. udp: fix behavior of wrong checksums net_sched: invoke ->attach() after setting dev->qdisc unix/caif: sk_socket can disappear when state is unlocked net: dp83640: fix broken calibration routine. bridge: fix parsing of MLDv2 reports ipv4: Avoid crashing in ip_error net: phy: Allow EEE for all RGMII variants Linux 3.10.80 fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings vfs: read file_handle only once in handle_to_path ACPI / init: Fix the ordering of acpi_reserve_resources() Input: elantech - fix semi-mt protocol for v3 HW rtlwifi: rtl8192cu: Fix kernel deadlock md/raid5: don't record new size if resize_stripes fails. svcrpc: fix potential GSSX_ACCEPT_SEC_CONTEXT decoding failures ARM: fix missing syscall trace exit ARM: dts: imx27: only map 4 Kbyte for fec registers crypto: s390/ghash - Fix incorrect ghash icv buffer handling. rt2x00: add new rt2800usb device DWA 130 libata: Ignore spurious PHY event on LPM policy change libata: Add helper to determine when PHY events should be ignored ext4: check for zero length extent explicitly ext4: convert write_begin methods to stable_page_writes semantics mmc: atmel-mci: fix bad variable type for clkdiv powerpc: Align TOC to 256 bytes usb: gadget: configfs: Fix interfaces array NULL-termination usb-storage: Add NO_WP_DETECT quirk for Lacie 059f:0651 devices USB: cp210x: add ID for KCF Technologies PRN device USB: pl2303: Remove support for Samsung I330 USB: visor: Match I330 phone more precisely xhci: gracefully handle xhci_irq dead device xhci: Solve full event ring by increasing TRBS_PER_SEGMENT to 256 xhci: fix isoc endpoint dequeue from advancing too far on transaction error target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST ASoC: wm8994: correct BCLK DIV 348 to 384 ASoC: wm8960: fix "RINPUT3" audio route error ASoC: mc13783: Fix wrong mask value used in mc13xxx_reg_rmw() calls ALSA: hda - Add headphone quirk for Lifebook E752 ALSA: hda - Add Conexant codecs CX20721, CX20722, CX20723 and CX20724 d_walk() might skip too much lib: Fix strnlen_user() to not touch memory after specified maximum hwmon: (ntc_thermistor) Ensure iio channel is of type IIO_VOLTAGE libceph: request a new osdmap if lingering request maps to no osd lguest: fix out-by-one error in address checking. fs, omfs: add NULL terminator in the end up the token list KVM: MMU: fix CR4.SMEP=1, CR0.WP=0 with shadow pages net: socket: Fix the wrong returns for recvmsg and sendmsg kernel: use the gnu89 standard explicitly staging, rtl8192e, LLVMLinux: Remove unused inline prototype staging: rtl8712, rtl8712: avoid lots of build warnings staging, rtl8192e, LLVMLinux: Change extern inline to static inline drm/i915: Fix declaration of intel_gmbus_{is_forced_bit/is_port_falid} staging: wlags49_h2: fix extern inline functions Linux 3.10.79 ACPICA: Utilities: Cleanup to enforce ACPI_PHYSADDR_TO_PTR()/ACPI_PTR_TO_PHYSADDR(). ACPICA: Tables: Change acpi_find_root_pointer() to use acpi_physical_address. revert "softirq: Add support for triggering softirq work on softirqs" sound/oss: fix deadlock in sequencer_ioctl(SNDCTL_SEQ_OUTOFBAND) mmc: card: Don't access RPMB partitions for normal read/write pinctrl: Don't just pretend to protect pinctrl_maps, do it for real drm/i915: Add missing MacBook Pro models with dual channel LVDS ARM: mvebu: armada-xp-openblocks-ax3-4: Disable internal RTC ARM: dts: imx23-olinuxino: Fix dr_mode of usb0 ARM: dts: imx28: Fix AUART4 TX-DMA interrupt name ARM: dts: imx25: Add #pwm-cells to pwm4 gpio: sysfs: fix memory leaks and device hotplug gpio: unregister gpiochip device before removing it xen/console: Update console event channel on resume mm/memory-failure: call shake_page() when error hits thp tail page nilfs2: fix sanity check of btree level in nilfs_btree_root_broken() ocfs2: dlm: fix race between purge and get lock resource Linux 3.10.78 ARC: signal handling robustify UBI: fix soft lockup in ubi_check_volume() Drivers: hv: vmbus: Don't wait after requesting offers ARM: dts: dove: Fix uart[23] reg property staging: panel: fix lcd type usb: gadget: printer: enqueue printer's response for setup request usb: host: oxu210hp: use new USB_RESUME_TIMEOUT 3w-sas: fix command completion race 3w-9xxx: fix command completion race 3w-xxxx: fix command completion race ext4: fix data corruption caused by unwritten and delayed extents rbd: end I/O the entire obj_request on error serial: of-serial: Remove device_type = "serial" registration ALSA: hda - Fix mute-LED fixed mode ALSA: emu10k1: Emu10k2 32 bit DMA mode ALSA: emu10k1: Fix card shortname string buffer overflow ALSA: emux: Fix mutex deadlock in OSS emulation ALSA: emux: Fix mutex deadlock at unloading ipv4: Missing sk_nulls_node_init() in ping_unhash(). Linux 3.10.77 s390: Fix build error nosave: consolidate __nosave_{begin,end} in <asm/sections.h> memstick: mspro_block: add missing curly braces C6x: time: Ensure consistency in __init wl18xx: show rx_frames_per_rates as an array as it really is lib: memzero_explicit: use barrier instead of OPTIMIZER_HIDE_VAR e1000: add dummy allocator to fix race condition between mtu change and netpoll ksoftirqd: Enable IRQs and call cond_resched() before poking RCU RCU pathwalk breakage when running into a symlink overmounting something drm/i915: cope with large i2c transfers drm/radeon: fix doublescan modes (v2) i2c: core: Export bus recovery functions IB/mlx4: Fix WQE LSO segment calculation IB/core: don't disallow registering region starting at 0x0 IB/core: disallow registering 0-sized memory region stk1160: Make sure current buffer is released mvsas: fix panic on expander attached SATA devices Drivers: hv: vmbus: Fix a bug in the error path in vmbus_open() xtensa: provide __NR_sync_file_range2 instead of __NR_sync_file_range xtensa: xtfpga: fix hardware lockup caused by LCD driver ACPICA: Utilities: split IO address types from data type models. drivers: parport: Kconfig: exclude arm64 for PARPORT_PC scsi: storvsc: Fix a bug in copy_from_bounce_buffer() UBI: fix check for "too many bytes" UBI: initialize LEB number variable UBI: fix out of bounds write UBI: account for bitflips in both the VID header and data tools/power turbostat: Use $(CURDIR) instead of $(PWD) and add support for O= option in Makefile powerpc/perf: Cap 64bit userspace backtraces to PERF_MAX_STACK_DEPTH ext4: make fsync to sync parent dir in no-journal for real this time arm64: kernel: compiling issue, need delete read_current_timer() video: vgacon: Don't build on arm64 console: Disable VGA text console support on cris drivers: parport: Kconfig: exclude h8300 for PARPORT_PC parport: disable PC-style parallel port support on cris rtlwifi: rtl8192cu: Add new device ID rtlwifi: rtl8192cu: Add new USB ID ptrace: fix race between ptrace_resume() and wait_task_stopped() fs/binfmt_elf.c: fix bug in loading of PIE binaries Input: elantech - fix absolute mode setting on some ASUS laptops ALSA: emu10k1: don't deadlock in proc-functions usb: core: hub: use new USB_RESUME_TIMEOUT usb: host: sl811: use new USB_RESUME_TIMEOUT usb: host: xhci: use new USB_RESUME_TIMEOUT usb: host: isp116x: use new USB_RESUME_TIMEOUT usb: host: r8a66597: use new USB_RESUME_TIMEOUT usb: define a generic USB_RESUME_TIMEOUT macro usb: phy: Find the right match in devm_usb_phy_match ARM: S3C64XX: Use fixed IRQ bases to avoid conflicts on Cragganmore ARM: 8320/1: fix integer overflow in ELF_ET_DYN_BASE power_supply: lp8788-charger: Fix leaked power supply on probe fail ring-buffer: Replace this_cpu_*() with __this_cpu_*() spi: spidev: fix possible arithmetic overflow for multi-transfer message cdc-wdm: fix endianness bug in debug statements MIPS: Hibernate: flush TLB entries earlier KVM: use slowpath for cross page cached accesses s390/hibernate: fix save and restore of kernel text section KVM: s390: Zero out current VMDB of STSI before including level3 data. usb: gadget: composite: enable BESL support Btrfs: fix inode eviction infinite loop after cloning into it Btrfs: fix log tree corruption when fs mounted with -o discard tcp: avoid looping in tcp_send_fin() tcp: fix possible deadlock in tcp_send_fin() ip_forward: Drop frames with attached skb->sk Linux 3.10.76 dcache: Fix locking bugs in backported "deal with deadlock in d_walk()" arc: mm: Fix build failure sb_edac: avoid INTERNAL ERROR message in EDAC with unspecified channel x86: mm: move mmap_sem unlock from mm_fault_error() to caller vm: make stack guard page errors return VM_FAULT_SIGSEGV rather than SIGBUS vm: add VM_FAULT_SIGSEGV handling support deal with deadlock in d_walk() move d_rcu from overlapping d_child to overlapping d_alias kconfig: Fix warning "‘jump’ may be used uninitialized" KVM: x86: SYSENTER emulation is broken netfilter: conntrack: disable generic tracking for known protocols Bluetooth: Ignore isochronous endpoints for Intel USB bootloader Bluetooth: Add support for Intel bootloader devices Bluetooth: btusb: Add IMC Networks (Broadcom based) Bluetooth: Add firmware update for Atheros 0cf3:311f Bluetooth: Enable Atheros 0cf3:311e for firmware upload mm: Fix NULL pointer dereference in madvise(MADV_WILLNEED) support splice: Apply generic position and size checks to each write jfs: fix readdir regression serial: 8250_dw: Fix deadlock in LCR workaround benet: Call dev_kfree_skby_any instead of kfree_skb. ixgb: Call dev_kfree_skby_any instead of dev_kfree_skb. tg3: Call dev_kfree_skby_any instead of dev_kfree_skb. bnx2: Call dev_kfree_skby_any instead of dev_kfree_skb. r8169: Call dev_kfree_skby_any instead of dev_kfree_skb. 8139too: Call dev_kfree_skby_any instead of dev_kfree_skb. 8139cp: Call dev_kfree_skby_any instead of kfree_skb. tcp: tcp_make_synack() should clear skb->tstamp tcp: fix FRTO undo on cumulative ACK of SACKed range ipv6: Don't reduce hop limit for an interface tcp: prevent fetching dst twice in early demux code remove extra definitions of U32_MAX conditionally define U32_MAX Linux 3.10.75 pagemap: do not leak physical addresses to non-privileged userspace console: Fix console name size mismatch IB/mlx4: Saturate RoCE port PMA counters in case of overflow kernel.h: define u8, s8, u32, etc. limits net: llc: use correct size for sysctl timeout entries net: rds: use correct size for max unacked packets and bytes ipc: fix compat msgrcv with negative msgtyp core, nfqueue, openvswitch: fix compilation warning media: s5p-mfc: fix mmap support for 64bit arch iscsi target: fix oops when adding reject pdu ocfs2: _really_ sync the right range be2iscsi: Fix kernel panic when device initialization fails cifs: fix use-after-free bug in find_writable_file usb: xhci: apply XHCI_AVOID_BEI quirk to all Intel xHCI controllers cpuidle: ACPI: do not overwrite name and description of C0 dmaengine: omap-dma: Fix memory leak when terminating running transfer iio: imu: Use iio_trigger_get for indio_dev->trig assignment iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo Defer processing of REQ_PREEMPT requests for blocked devices USB: ftdi_sio: Use jtag quirk for SNAP Connect E10 USB: ftdi_sio: Added custom PID for Synapse Wireless product radeon: Do not directly dereference pointers to BIOS area. writeback: fix possible underflow in write bandwidth calculation writeback: add missing INITIAL_JIFFIES init in global_update_bandwidth() mm/memory hotplug: postpone the reset of obsolete pgdat nbd: fix possible memory leak iwlwifi: dvm: run INIT firmware again upon .start() IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic IB/core: Avoid leakage from kernel to user space tcp: Fix crash in TCP Fast Open selinux: fix sel_write_enforce broken return value ALSA: hda - Fix headphone pin config for Lifebook T731 ALSA: usb - Creative USB X-Fi Pro SB1095 volume knob support ALSA: hda - Add one more node in the EAPD supporting candidate list Linux 3.10.74 net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3, 5} powerpc/mpc85xx: Add ranges to etsec2 nodes hfsplus: fix B-tree corruption after insertion at position 0 dm: hold suspend_lock while suspending device during device deletion vt6655: RFbSetPower fix missing rate RATE_12M perf: Fix irq_work 'tail' recursion Revert "iwlwifi: mvm: fix failure path when power_update fails in add_interface" mac80211: drop unencrypted frames in mesh fwding mac80211: disable u-APSD queues by default nl80211: ignore HT/VHT capabilities without QoS/WMM tcm_qla2xxx: Fix incorrect use of __transport_register_session tcm_fc: missing curly braces in ft_invl_hw_context() ASoC: wm8955: Fix wrong value references for boolean kctl ASoC: adav80x: Fix wrong value references for boolean kctl ASoC: ak4641: Fix wrong value references for boolean kctl ASoC: wm8904: Fix wrong value references for boolean kctl ASoC: wm8903: Fix wrong value references for boolean kctl ASoC: wm2000: Fix wrong value references for boolean kctl ASoC: wm8731: Fix wrong value references for boolean kctl ASoC: tas5086: Fix wrong value references for boolean kctl ASoC: wm8960: Fix wrong value references for boolean kctl ASoC: cs4271: Fix wrong value references for boolean kctl ASoC: sgtl5000: remove useless register write clearing CHRGPUMP_POWERUP Change-Id: Ib7976ee2c7224e39074157e28db4158db40b00db Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
790 lines
20 KiB
C
790 lines
20 KiB
C
/*
|
|
* Simple synchronous userspace interface to SPI devices
|
|
*
|
|
* Copyright (C) 2006 SWAPP
|
|
* Andrea Paterniani <a.paterniani@swapp-eng.it>
|
|
* Copyright (C) 2007 David Brownell (simplification, cleanup)
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/ioctl.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/device.h>
|
|
#include <linux/err.h>
|
|
#include <linux/list.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/compat.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/spi/spidev.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
/*
|
|
* This supports access to SPI devices using normal userspace I/O calls.
|
|
* Note that while traditional UNIX/POSIX I/O semantics are half duplex,
|
|
* and often mask message boundaries, full SPI support requires full duplex
|
|
* transfers. There are several kinds of internal message boundaries to
|
|
* handle chipselect management and other protocol options.
|
|
*
|
|
* SPI has a character major number assigned. We allocate minor numbers
|
|
* dynamically using a bitmask. You must use hotplug tools, such as udev
|
|
* (or mdev with busybox) to create and destroy the /dev/spidevB.C device
|
|
* nodes, since there is no fixed association of minor numbers with any
|
|
* particular SPI bus or device.
|
|
*/
|
|
#define SPIDEV_MAJOR 153 /* assigned */
|
|
#define N_SPI_MINORS 32 /* ... up to 256 */
|
|
|
|
static DECLARE_BITMAP(minors, N_SPI_MINORS);
|
|
|
|
|
|
/* Bit masks for spi_device.mode management. Note that incorrect
|
|
* settings for some settings can cause *lots* of trouble for other
|
|
* devices on a shared bus:
|
|
*
|
|
* - CS_HIGH ... this device will be active when it shouldn't be
|
|
* - 3WIRE ... when active, it won't behave as it should
|
|
* - NO_CS ... there will be no explicit message boundaries; this
|
|
* is completely incompatible with the shared bus model
|
|
* - READY ... transfers may proceed when they shouldn't.
|
|
*
|
|
* REVISIT should changing those flags be privileged?
|
|
*/
|
|
#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \
|
|
| SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP \
|
|
| SPI_NO_CS | SPI_READY)
|
|
|
|
struct spidev_data {
|
|
dev_t devt;
|
|
spinlock_t spi_lock;
|
|
struct spi_device *spi;
|
|
struct list_head device_entry;
|
|
|
|
/* buffer is NULL unless this device is open (users > 0) */
|
|
struct mutex buf_lock;
|
|
unsigned users;
|
|
u8 *buffer;
|
|
u8 *bufferrx;
|
|
};
|
|
|
|
static LIST_HEAD(device_list);
|
|
static DEFINE_MUTEX(device_list_lock);
|
|
|
|
static unsigned bufsiz = 4096;
|
|
module_param(bufsiz, uint, S_IRUGO);
|
|
MODULE_PARM_DESC(bufsiz, "data bytes in biggest supported SPI message");
|
|
|
|
/*
|
|
* This can be used for testing the controller, given the busnum and the
|
|
* cs required to use. If those parameters are used, spidev is
|
|
* dynamically added as device on the busnum, and messages can be sent
|
|
* via this interface.
|
|
*/
|
|
static int busnum = -1;
|
|
module_param(busnum, int, S_IRUGO);
|
|
MODULE_PARM_DESC(busnum, "bus num of the controller");
|
|
|
|
static int chipselect = -1;
|
|
module_param(chipselect, int, S_IRUGO);
|
|
MODULE_PARM_DESC(chipselect, "chip select of the desired device");
|
|
|
|
static int maxspeed = 10000000;
|
|
module_param(maxspeed, int, S_IRUGO);
|
|
MODULE_PARM_DESC(maxspeed, "max_speed of the desired device");
|
|
|
|
static int spimode = SPI_MODE_3;
|
|
module_param(spimode, int, S_IRUGO);
|
|
MODULE_PARM_DESC(spimode, "mode of the desired device");
|
|
|
|
static struct spi_device *spi;
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/*
|
|
* We can't use the standard synchronous wrappers for file I/O; we
|
|
* need to protect against async removal of the underlying spi_device.
|
|
*/
|
|
static void spidev_complete(void *arg)
|
|
{
|
|
complete(arg);
|
|
}
|
|
|
|
static ssize_t
|
|
spidev_sync(struct spidev_data *spidev, struct spi_message *message)
|
|
{
|
|
DECLARE_COMPLETION_ONSTACK(done);
|
|
int status;
|
|
|
|
message->complete = spidev_complete;
|
|
message->context = &done;
|
|
|
|
spin_lock_irq(&spidev->spi_lock);
|
|
if (spidev->spi == NULL)
|
|
status = -ESHUTDOWN;
|
|
else
|
|
status = spi_async(spidev->spi, message);
|
|
spin_unlock_irq(&spidev->spi_lock);
|
|
|
|
if (status == 0) {
|
|
wait_for_completion(&done);
|
|
status = message->status;
|
|
if (status == 0)
|
|
status = message->actual_length;
|
|
}
|
|
return status;
|
|
}
|
|
|
|
static inline ssize_t
|
|
spidev_sync_write(struct spidev_data *spidev, size_t len)
|
|
{
|
|
struct spi_transfer t = {
|
|
.tx_buf = spidev->buffer,
|
|
.len = len,
|
|
};
|
|
struct spi_message m;
|
|
|
|
spi_message_init(&m);
|
|
spi_message_add_tail(&t, &m);
|
|
return spidev_sync(spidev, &m);
|
|
}
|
|
|
|
static inline ssize_t
|
|
spidev_sync_read(struct spidev_data *spidev, size_t len)
|
|
{
|
|
struct spi_transfer t = {
|
|
.rx_buf = spidev->buffer,
|
|
.len = len,
|
|
};
|
|
struct spi_message m;
|
|
|
|
spi_message_init(&m);
|
|
spi_message_add_tail(&t, &m);
|
|
return spidev_sync(spidev, &m);
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Read-only message with current device setup */
|
|
static ssize_t
|
|
spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
|
|
{
|
|
struct spidev_data *spidev;
|
|
ssize_t status = 0;
|
|
|
|
/* chipselect only toggles at start or end of operation */
|
|
if (count > bufsiz)
|
|
return -EMSGSIZE;
|
|
|
|
spidev = filp->private_data;
|
|
|
|
mutex_lock(&spidev->buf_lock);
|
|
status = spidev_sync_read(spidev, count);
|
|
if (status > 0) {
|
|
unsigned long missing;
|
|
|
|
missing = copy_to_user(buf, spidev->buffer, status);
|
|
if (missing == status)
|
|
status = -EFAULT;
|
|
else
|
|
status = status - missing;
|
|
}
|
|
mutex_unlock(&spidev->buf_lock);
|
|
|
|
return status;
|
|
}
|
|
|
|
/* Write-only message with current device setup */
|
|
static ssize_t
|
|
spidev_write(struct file *filp, const char __user *buf,
|
|
size_t count, loff_t *f_pos)
|
|
{
|
|
struct spidev_data *spidev;
|
|
ssize_t status = 0;
|
|
unsigned long missing;
|
|
|
|
/* chipselect only toggles at start or end of operation */
|
|
if (count > bufsiz)
|
|
return -EMSGSIZE;
|
|
|
|
spidev = filp->private_data;
|
|
|
|
mutex_lock(&spidev->buf_lock);
|
|
missing = copy_from_user(spidev->buffer, buf, count);
|
|
if (missing == 0) {
|
|
status = spidev_sync_write(spidev, count);
|
|
} else
|
|
status = -EFAULT;
|
|
mutex_unlock(&spidev->buf_lock);
|
|
|
|
return status;
|
|
}
|
|
|
|
static int spidev_message(struct spidev_data *spidev,
|
|
struct spi_ioc_transfer *u_xfers, unsigned n_xfers)
|
|
{
|
|
struct spi_message msg;
|
|
struct spi_transfer *k_xfers;
|
|
struct spi_transfer *k_tmp;
|
|
struct spi_ioc_transfer *u_tmp;
|
|
unsigned n, total;
|
|
u8 *buf, *bufrx;
|
|
int status = -EFAULT;
|
|
|
|
spi_message_init(&msg);
|
|
k_xfers = kcalloc(n_xfers, sizeof(*k_tmp), GFP_KERNEL);
|
|
if (k_xfers == NULL)
|
|
return -ENOMEM;
|
|
|
|
/* Construct spi_message, copying any tx data to bounce buffer.
|
|
* We walk the array of user-provided transfers, using each one
|
|
* to initialize a kernel version of the same transfer.
|
|
*/
|
|
buf = spidev->buffer;
|
|
bufrx = spidev->bufferrx;
|
|
total = 0;
|
|
for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
|
|
n;
|
|
n--, k_tmp++, u_tmp++) {
|
|
k_tmp->len = u_tmp->len;
|
|
|
|
total += k_tmp->len;
|
|
/* Check total length of transfers. Also check each
|
|
* transfer length to avoid arithmetic overflow.
|
|
*/
|
|
if (total > bufsiz || k_tmp->len > bufsiz) {
|
|
status = -EMSGSIZE;
|
|
goto done;
|
|
}
|
|
|
|
if (u_tmp->rx_buf) {
|
|
k_tmp->rx_buf = bufrx;
|
|
if (!access_ok(VERIFY_WRITE, (u8 __user *)
|
|
(uintptr_t) u_tmp->rx_buf,
|
|
u_tmp->len))
|
|
goto done;
|
|
}
|
|
if (u_tmp->tx_buf) {
|
|
k_tmp->tx_buf = buf;
|
|
if (copy_from_user(buf, (const u8 __user *)
|
|
(uintptr_t) u_tmp->tx_buf,
|
|
u_tmp->len))
|
|
goto done;
|
|
}
|
|
buf += k_tmp->len;
|
|
bufrx += k_tmp->len;
|
|
|
|
k_tmp->cs_change = !!u_tmp->cs_change;
|
|
k_tmp->bits_per_word = u_tmp->bits_per_word;
|
|
k_tmp->delay_usecs = u_tmp->delay_usecs;
|
|
k_tmp->speed_hz = u_tmp->speed_hz;
|
|
#ifdef VERBOSE
|
|
dev_dbg(&spidev->spi->dev,
|
|
" xfer len %zd %s%s%s%dbits %u usec %uHz\n",
|
|
u_tmp->len,
|
|
u_tmp->rx_buf ? "rx " : "",
|
|
u_tmp->tx_buf ? "tx " : "",
|
|
u_tmp->cs_change ? "cs " : "",
|
|
u_tmp->bits_per_word ? : spidev->spi->bits_per_word,
|
|
u_tmp->delay_usecs,
|
|
u_tmp->speed_hz ? : spidev->spi->max_speed_hz);
|
|
#endif
|
|
spi_message_add_tail(k_tmp, &msg);
|
|
}
|
|
|
|
status = spidev_sync(spidev, &msg);
|
|
if (status < 0)
|
|
goto done;
|
|
|
|
/* copy any rx data out of bounce buffer */
|
|
buf = spidev->bufferrx;
|
|
for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
|
|
if (u_tmp->rx_buf) {
|
|
if (__copy_to_user((u8 __user *)
|
|
(uintptr_t) u_tmp->rx_buf, buf,
|
|
u_tmp->len)) {
|
|
status = -EFAULT;
|
|
goto done;
|
|
}
|
|
}
|
|
buf += u_tmp->len;
|
|
}
|
|
status = total;
|
|
|
|
done:
|
|
kfree(k_xfers);
|
|
return status;
|
|
}
|
|
|
|
static long
|
|
spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|
{
|
|
int err = 0;
|
|
int retval = 0;
|
|
struct spidev_data *spidev;
|
|
struct spi_device *spi;
|
|
u32 tmp;
|
|
unsigned n_ioc;
|
|
struct spi_ioc_transfer *ioc;
|
|
|
|
/* Check type and command number */
|
|
if (_IOC_TYPE(cmd) != SPI_IOC_MAGIC)
|
|
return -ENOTTY;
|
|
|
|
/* Check access direction once here; don't repeat below.
|
|
* IOC_DIR is from the user perspective, while access_ok is
|
|
* from the kernel perspective; so they look reversed.
|
|
*/
|
|
if (_IOC_DIR(cmd) & _IOC_READ)
|
|
err = !access_ok(VERIFY_WRITE,
|
|
(void __user *)arg, _IOC_SIZE(cmd));
|
|
if (err == 0 && _IOC_DIR(cmd) & _IOC_WRITE)
|
|
err = !access_ok(VERIFY_READ,
|
|
(void __user *)arg, _IOC_SIZE(cmd));
|
|
if (err)
|
|
return -EFAULT;
|
|
|
|
/* guard against device removal before, or while,
|
|
* we issue this ioctl.
|
|
*/
|
|
spidev = filp->private_data;
|
|
spin_lock_irq(&spidev->spi_lock);
|
|
spi = spi_dev_get(spidev->spi);
|
|
spin_unlock_irq(&spidev->spi_lock);
|
|
|
|
if (spi == NULL)
|
|
return -ESHUTDOWN;
|
|
|
|
/* use the buffer lock here for triple duty:
|
|
* - prevent I/O (from us) so calling spi_setup() is safe;
|
|
* - prevent concurrent SPI_IOC_WR_* from morphing
|
|
* data fields while SPI_IOC_RD_* reads them;
|
|
* - SPI_IOC_MESSAGE needs the buffer locked "normally".
|
|
*/
|
|
mutex_lock(&spidev->buf_lock);
|
|
|
|
switch (cmd) {
|
|
/* read requests */
|
|
case SPI_IOC_RD_MODE:
|
|
retval = __put_user(spi->mode & SPI_MODE_MASK,
|
|
(__u8 __user *)arg);
|
|
break;
|
|
case SPI_IOC_RD_LSB_FIRST:
|
|
retval = __put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
|
|
(__u8 __user *)arg);
|
|
break;
|
|
case SPI_IOC_RD_BITS_PER_WORD:
|
|
retval = __put_user(spi->bits_per_word, (__u8 __user *)arg);
|
|
break;
|
|
case SPI_IOC_RD_MAX_SPEED_HZ:
|
|
retval = __put_user(spi->max_speed_hz, (__u32 __user *)arg);
|
|
break;
|
|
|
|
/* write requests */
|
|
case SPI_IOC_WR_MODE:
|
|
retval = __get_user(tmp, (u8 __user *)arg);
|
|
if (retval == 0) {
|
|
u8 save = spi->mode;
|
|
|
|
if (tmp & ~SPI_MODE_MASK) {
|
|
retval = -EINVAL;
|
|
break;
|
|
}
|
|
|
|
tmp |= spi->mode & ~SPI_MODE_MASK;
|
|
spi->mode = (u8)tmp;
|
|
retval = spi_setup(spi);
|
|
if (retval < 0)
|
|
spi->mode = save;
|
|
else
|
|
dev_dbg(&spi->dev, "spi mode %02x\n", tmp);
|
|
}
|
|
break;
|
|
case SPI_IOC_WR_LSB_FIRST:
|
|
retval = __get_user(tmp, (__u8 __user *)arg);
|
|
if (retval == 0) {
|
|
u8 save = spi->mode;
|
|
|
|
if (tmp)
|
|
spi->mode |= SPI_LSB_FIRST;
|
|
else
|
|
spi->mode &= ~SPI_LSB_FIRST;
|
|
retval = spi_setup(spi);
|
|
if (retval < 0)
|
|
spi->mode = save;
|
|
else
|
|
dev_dbg(&spi->dev, "%csb first\n",
|
|
tmp ? 'l' : 'm');
|
|
}
|
|
break;
|
|
case SPI_IOC_WR_BITS_PER_WORD:
|
|
retval = __get_user(tmp, (__u8 __user *)arg);
|
|
if (retval == 0) {
|
|
u8 save = spi->bits_per_word;
|
|
|
|
spi->bits_per_word = tmp;
|
|
retval = spi_setup(spi);
|
|
if (retval < 0)
|
|
spi->bits_per_word = save;
|
|
else
|
|
dev_dbg(&spi->dev, "%d bits per word\n", tmp);
|
|
}
|
|
break;
|
|
case SPI_IOC_WR_MAX_SPEED_HZ:
|
|
retval = __get_user(tmp, (__u32 __user *)arg);
|
|
if (retval == 0) {
|
|
u32 save = spi->max_speed_hz;
|
|
|
|
spi->max_speed_hz = tmp;
|
|
retval = spi_setup(spi);
|
|
if (retval < 0)
|
|
spi->max_speed_hz = save;
|
|
else
|
|
dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
/* segmented and/or full-duplex I/O request */
|
|
if (_IOC_NR(cmd) != _IOC_NR(SPI_IOC_MESSAGE(0))
|
|
|| _IOC_DIR(cmd) != _IOC_WRITE) {
|
|
retval = -ENOTTY;
|
|
break;
|
|
}
|
|
|
|
tmp = _IOC_SIZE(cmd);
|
|
if ((tmp % sizeof(struct spi_ioc_transfer)) != 0) {
|
|
retval = -EINVAL;
|
|
break;
|
|
}
|
|
n_ioc = tmp / sizeof(struct spi_ioc_transfer);
|
|
if (n_ioc == 0)
|
|
break;
|
|
|
|
/* copy into scratch area */
|
|
ioc = kmalloc(tmp, GFP_KERNEL);
|
|
if (!ioc) {
|
|
retval = -ENOMEM;
|
|
break;
|
|
}
|
|
if (__copy_from_user(ioc, (void __user *)arg, tmp)) {
|
|
kfree(ioc);
|
|
retval = -EFAULT;
|
|
break;
|
|
}
|
|
|
|
/* translate to spi_message, execute */
|
|
retval = spidev_message(spidev, ioc, n_ioc);
|
|
kfree(ioc);
|
|
break;
|
|
}
|
|
|
|
mutex_unlock(&spidev->buf_lock);
|
|
spi_dev_put(spi);
|
|
return retval;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
static long
|
|
spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|
{
|
|
return spidev_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
|
|
}
|
|
#else
|
|
#define spidev_compat_ioctl NULL
|
|
#endif /* CONFIG_COMPAT */
|
|
|
|
static int spidev_open(struct inode *inode, struct file *filp)
|
|
{
|
|
struct spidev_data *spidev;
|
|
int status = -ENXIO;
|
|
|
|
mutex_lock(&device_list_lock);
|
|
|
|
list_for_each_entry(spidev, &device_list, device_entry) {
|
|
if (spidev->devt == inode->i_rdev) {
|
|
status = 0;
|
|
break;
|
|
}
|
|
}
|
|
if (status == 0) {
|
|
if (!spidev->buffer) {
|
|
spidev->buffer = kmalloc(bufsiz, GFP_KERNEL);
|
|
if (!spidev->buffer) {
|
|
dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
|
|
status = -ENOMEM;
|
|
}
|
|
}
|
|
if (!spidev->bufferrx) {
|
|
spidev->bufferrx = kmalloc(bufsiz, GFP_KERNEL);
|
|
if (!spidev->bufferrx) {
|
|
dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
|
|
kfree(spidev->buffer);
|
|
spidev->buffer = NULL;
|
|
status = -ENOMEM;
|
|
}
|
|
}
|
|
if (status == 0) {
|
|
spidev->users++;
|
|
filp->private_data = spidev;
|
|
nonseekable_open(inode, filp);
|
|
}
|
|
} else
|
|
pr_debug("spidev: nothing for minor %d\n", iminor(inode));
|
|
|
|
mutex_unlock(&device_list_lock);
|
|
return status;
|
|
}
|
|
|
|
static int spidev_release(struct inode *inode, struct file *filp)
|
|
{
|
|
struct spidev_data *spidev;
|
|
int status = 0;
|
|
|
|
mutex_lock(&device_list_lock);
|
|
spidev = filp->private_data;
|
|
filp->private_data = NULL;
|
|
|
|
/* last close? */
|
|
spidev->users--;
|
|
if (!spidev->users) {
|
|
int dofree;
|
|
|
|
kfree(spidev->buffer);
|
|
spidev->buffer = NULL;
|
|
kfree(spidev->bufferrx);
|
|
spidev->bufferrx = NULL;
|
|
|
|
/* ... after we unbound from the underlying device? */
|
|
spin_lock_irq(&spidev->spi_lock);
|
|
dofree = (spidev->spi == NULL);
|
|
spin_unlock_irq(&spidev->spi_lock);
|
|
|
|
if (dofree)
|
|
kfree(spidev);
|
|
}
|
|
mutex_unlock(&device_list_lock);
|
|
|
|
return status;
|
|
}
|
|
|
|
static const struct file_operations spidev_fops = {
|
|
.owner = THIS_MODULE,
|
|
/* REVISIT switch to aio primitives, so that userspace
|
|
* gets more complete API coverage. It'll simplify things
|
|
* too, except for the locking.
|
|
*/
|
|
.write = spidev_write,
|
|
.read = spidev_read,
|
|
.unlocked_ioctl = spidev_ioctl,
|
|
.compat_ioctl = spidev_compat_ioctl,
|
|
.open = spidev_open,
|
|
.release = spidev_release,
|
|
.llseek = no_llseek,
|
|
};
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* The main reason to have this class is to make mdev/udev create the
|
|
* /dev/spidevB.C character device nodes exposing our userspace API.
|
|
* It also simplifies memory management.
|
|
*/
|
|
|
|
static struct class *spidev_class;
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
static int spidev_probe(struct spi_device *spi)
|
|
{
|
|
struct spidev_data *spidev;
|
|
int status;
|
|
unsigned long minor;
|
|
|
|
/* Allocate driver data */
|
|
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
|
|
if (!spidev)
|
|
return -ENOMEM;
|
|
|
|
/* Initialize the driver data */
|
|
spidev->spi = spi;
|
|
spin_lock_init(&spidev->spi_lock);
|
|
mutex_init(&spidev->buf_lock);
|
|
|
|
INIT_LIST_HEAD(&spidev->device_entry);
|
|
|
|
/* If we can allocate a minor number, hook up this device.
|
|
* Reusing minors is fine so long as udev or mdev is working.
|
|
*/
|
|
mutex_lock(&device_list_lock);
|
|
minor = find_first_zero_bit(minors, N_SPI_MINORS);
|
|
if (minor < N_SPI_MINORS) {
|
|
struct device *dev;
|
|
|
|
spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
|
|
dev = device_create(spidev_class, &spi->dev, spidev->devt,
|
|
spidev, "spidev%d.%d",
|
|
spi->master->bus_num, spi->chip_select);
|
|
status = PTR_RET(dev);
|
|
} else {
|
|
dev_dbg(&spi->dev, "no minor number available!\n");
|
|
status = -ENODEV;
|
|
}
|
|
if (status == 0) {
|
|
set_bit(minor, minors);
|
|
list_add(&spidev->device_entry, &device_list);
|
|
}
|
|
mutex_unlock(&device_list_lock);
|
|
|
|
if (status == 0)
|
|
spi_set_drvdata(spi, spidev);
|
|
else
|
|
kfree(spidev);
|
|
|
|
return status;
|
|
}
|
|
|
|
static int spidev_remove(struct spi_device *spi)
|
|
{
|
|
struct spidev_data *spidev = spi_get_drvdata(spi);
|
|
|
|
/* make sure ops on existing fds can abort cleanly */
|
|
spin_lock_irq(&spidev->spi_lock);
|
|
spidev->spi = NULL;
|
|
spi_set_drvdata(spi, NULL);
|
|
spin_unlock_irq(&spidev->spi_lock);
|
|
|
|
/* prevent new opens */
|
|
mutex_lock(&device_list_lock);
|
|
list_del(&spidev->device_entry);
|
|
device_destroy(spidev_class, spidev->devt);
|
|
clear_bit(MINOR(spidev->devt), minors);
|
|
if (spidev->users == 0)
|
|
kfree(spidev);
|
|
mutex_unlock(&device_list_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id spidev_dt_ids[] = {
|
|
{ .compatible = "rohm,dh2228fv" },
|
|
{},
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
|
|
|
|
static struct spi_driver spidev_spi_driver = {
|
|
.driver = {
|
|
.name = "spidev",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = of_match_ptr(spidev_dt_ids),
|
|
},
|
|
.probe = spidev_probe,
|
|
.remove = spidev_remove,
|
|
|
|
/* NOTE: suspend/resume methods are not necessary here.
|
|
* We don't do anything except pass the requests to/from
|
|
* the underlying controller. The refrigerator handles
|
|
* most issues; the controller driver handles the rest.
|
|
*/
|
|
};
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
static int __init spidev_init(void)
|
|
{
|
|
int status;
|
|
|
|
/* Claim our 256 reserved device numbers. Then register a class
|
|
* that will key udev/mdev to add/remove /dev nodes. Last, register
|
|
* the driver which manages those device numbers.
|
|
*/
|
|
BUILD_BUG_ON(N_SPI_MINORS > 256);
|
|
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
|
|
if (status < 0)
|
|
return status;
|
|
|
|
spidev_class = class_create(THIS_MODULE, "spidev");
|
|
if (IS_ERR(spidev_class)) {
|
|
status = PTR_ERR(spidev_class);
|
|
goto error_class;
|
|
}
|
|
|
|
status = spi_register_driver(&spidev_spi_driver);
|
|
if (status < 0)
|
|
goto error_register;
|
|
|
|
if (busnum != -1 && chipselect != -1) {
|
|
struct spi_board_info chip = {
|
|
.modalias = "spidev",
|
|
.mode = spimode,
|
|
.bus_num = busnum,
|
|
.chip_select = chipselect,
|
|
.max_speed_hz = maxspeed,
|
|
};
|
|
|
|
struct spi_master *master;
|
|
|
|
master = spi_busnum_to_master(busnum);
|
|
if (!master) {
|
|
status = -ENODEV;
|
|
goto error_busnum;
|
|
}
|
|
|
|
/* We create a virtual device that will sit on the bus */
|
|
spi = spi_new_device(master, &chip);
|
|
if (!spi) {
|
|
status = -EBUSY;
|
|
goto error_mem;
|
|
}
|
|
dev_dbg(&spi->dev, "busnum=%d cs=%d bufsiz=%d maxspeed=%d",
|
|
busnum, chipselect, bufsiz, maxspeed);
|
|
}
|
|
return 0;
|
|
error_mem:
|
|
error_busnum:
|
|
spi_unregister_driver(&spidev_spi_driver);
|
|
error_register:
|
|
class_destroy(spidev_class);
|
|
error_class:
|
|
unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
|
|
return status;
|
|
}
|
|
module_init(spidev_init);
|
|
|
|
static void __exit spidev_exit(void)
|
|
{
|
|
if (spi) {
|
|
spi_unregister_device(spi);
|
|
spi = NULL;
|
|
}
|
|
spi_unregister_driver(&spidev_spi_driver);
|
|
class_destroy(spidev_class);
|
|
unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
|
|
}
|
|
module_exit(spidev_exit);
|
|
|
|
MODULE_AUTHOR("Andrea Paterniani, <a.paterniani@swapp-eng.it>");
|
|
MODULE_DESCRIPTION("User mode SPI device interface");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("spi:spidev");
|