diff options
Diffstat (limited to 'drivers/staging')
524 files changed, 19602 insertions, 29852 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 329bdb4..3a7965d 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -74,8 +74,6 @@ source "drivers/staging/iio/Kconfig" source "drivers/staging/zram/Kconfig" -source "drivers/staging/zcache/Kconfig" - source "drivers/staging/zsmalloc/Kconfig" source "drivers/staging/wlags49_h2/Kconfig" @@ -128,8 +126,6 @@ source "drivers/staging/csr/Kconfig" source "drivers/staging/omap-thermal/Kconfig" -source "drivers/staging/ramster/Kconfig" - source "drivers/staging/silicom/Kconfig" source "drivers/staging/ced1401/Kconfig" @@ -142,4 +138,8 @@ source "drivers/staging/sb105x/Kconfig" source "drivers/staging/fwserial/Kconfig" +source "drivers/staging/zcache/Kconfig" + +source "drivers/staging/goldfish/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index c7ec486..5971865 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -31,7 +31,6 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_ZRAM) += zram/ -obj-$(CONFIG_ZCACHE) += zcache/ obj-$(CONFIG_ZSMALLOC) += zsmalloc/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ @@ -56,10 +55,11 @@ obj-$(CONFIG_USB_G_CCG) += ccg/ obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ obj-$(CONFIG_CSR_WIFI) += csr/ obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal/ -obj-$(CONFIG_ZCACHE2) += ramster/ obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/ obj-$(CONFIG_CED1401) += ced1401/ obj-$(CONFIG_DRM_IMX) += imx-drm/ obj-$(CONFIG_DGRP) += dgrp/ obj-$(CONFIG_SB105X) += sb105x/ obj-$(CONFIG_FIREWIRE_SERIAL) += fwserial/ +obj-$(CONFIG_ZCACHE) += zcache/ +obj-$(CONFIG_GOLDFISH) += goldfish/ diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 0ce50d1..465a28c 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -11,19 +11,42 @@ if ANDROID config ANDROID_BINDER_IPC bool "Android Binder IPC Driver" default n + ---help--- + Binder is used in Android for both communication between processes, + and remote method invocation. + + This means one Android process can call a method/routine in another + Android process, using Binder to identify, invoke and pass arguments + between said processes. config ASHMEM bool "Enable the Anonymous Shared Memory Subsystem" default n depends on SHMEM || TINY_SHMEM - help + ---help--- The ashmem subsystem is a new shared memory allocator, similar to POSIX SHM but with different behavior and sporting a simpler file-based API. + It is, in theory, a good memory allocator for low-memory devices, + because it can discard shared memory units when under memory pressure. + config ANDROID_LOGGER tristate "Android log driver" default n + ---help--- + This adds support for system-wide logging using four log buffers. + + These are: + + 1: main + 2: events + 3: radio + 4: system + + Log reading and writing is performed via normal Linux reads and + optimized writes. This optimization avoids logging having too + much overhead in the system. config ANDROID_TIMED_OUTPUT bool "Timed output class driver" @@ -38,13 +61,13 @@ config ANDROID_LOW_MEMORY_KILLER bool "Android Low Memory Killer" default N ---help--- - Register processes to be killed when memory is low + Registers processes to be killed when memory is low config ANDROID_INTF_ALARM_DEV bool "Android alarm driver" depends on RTC_CLASS default n - help + ---help--- Provides non-wakeup and rtc backed wakeup alarms based on rtc or elapsed realtime, and a non-wakeup alarm on the monotonic clock. Also exports the alarm interface to user-space. diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c index a9b293f..ceb1c64 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -42,10 +42,6 @@ do { \ ANDROID_ALARM_RTC_WAKEUP_MASK | \ ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK) -/* support old userspace code */ -#define ANDROID_ALARM_SET_OLD _IOW('a', 2, time_t) /* set alarm */ -#define ANDROID_ALARM_SET_AND_WAIT_OLD _IOW('a', 3, time_t) - static int alarm_opened; static DEFINE_SPINLOCK(alarm_slock); static struct wakeup_source alarm_wake_lock; @@ -96,18 +92,116 @@ static void devalarm_cancel(struct devalarm *alrm) hrtimer_cancel(&alrm->u.hrt); } +static void alarm_clear(enum android_alarm_type alarm_type) +{ + uint32_t alarm_type_mask = 1U << alarm_type; + unsigned long flags; -static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + spin_lock_irqsave(&alarm_slock, flags); + alarm_dbg(IO, "alarm %d clear\n", alarm_type); + devalarm_try_to_cancel(&alarms[alarm_type]); + if (alarm_pending) { + alarm_pending &= ~alarm_type_mask; + if (!alarm_pending && !wait_pending) + __pm_relax(&alarm_wake_lock); + } + alarm_enabled &= ~alarm_type_mask; + spin_unlock_irqrestore(&alarm_slock, flags); + +} + +static void alarm_set(enum android_alarm_type alarm_type, + struct timespec *ts) { - int rv = 0; + uint32_t alarm_type_mask = 1U << alarm_type; unsigned long flags; - struct timespec new_alarm_time; - struct timespec new_rtc_time; - struct timespec tmp_time; + + spin_lock_irqsave(&alarm_slock, flags); + alarm_dbg(IO, "alarm %d set %ld.%09ld\n", + alarm_type, ts->tv_sec, ts->tv_nsec); + alarm_enabled |= alarm_type_mask; + devalarm_start(&alarms[alarm_type], timespec_to_ktime(*ts)); + spin_unlock_irqrestore(&alarm_slock, flags); +} + +static int alarm_wait(void) +{ + unsigned long flags; + int rv = 0; + + spin_lock_irqsave(&alarm_slock, flags); + alarm_dbg(IO, "alarm wait\n"); + if (!alarm_pending && wait_pending) { + __pm_relax(&alarm_wake_lock); + wait_pending = 0; + } + spin_unlock_irqrestore(&alarm_slock, flags); + + rv = wait_event_interruptible(alarm_wait_queue, alarm_pending); + if (rv) + return rv; + + spin_lock_irqsave(&alarm_slock, flags); + rv = alarm_pending; + wait_pending = 1; + alarm_pending = 0; + spin_unlock_irqrestore(&alarm_slock, flags); + + return rv; +} + +static int alarm_set_rtc(struct timespec *ts) +{ struct rtc_time new_rtc_tm; struct rtc_device *rtc_dev; + unsigned long flags; + int rv = 0; + + rtc_time_to_tm(ts->tv_sec, &new_rtc_tm); + rtc_dev = alarmtimer_get_rtcdev(); + rv = do_settimeofday(ts); + if (rv < 0) + return rv; + if (rtc_dev) + rv = rtc_set_time(rtc_dev, &new_rtc_tm); + + spin_lock_irqsave(&alarm_slock, flags); + alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK; + wake_up(&alarm_wait_queue); + spin_unlock_irqrestore(&alarm_slock, flags); + + return rv; +} + +static int alarm_get_time(enum android_alarm_type alarm_type, + struct timespec *ts) +{ + int rv = 0; + + switch (alarm_type) { + case ANDROID_ALARM_RTC_WAKEUP: + case ANDROID_ALARM_RTC: + getnstimeofday(ts); + break; + case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP: + case ANDROID_ALARM_ELAPSED_REALTIME: + get_monotonic_boottime(ts); + break; + case ANDROID_ALARM_SYSTEMTIME: + ktime_get_ts(ts); + break; + default: + rv = -EINVAL; + } + return rv; +} + +static long alarm_do_ioctl(struct file *file, unsigned int cmd, + struct timespec *ts) +{ + int rv = 0; + unsigned long flags; enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd); - uint32_t alarm_type_mask = 1U << alarm_type; if (alarm_type >= ANDROID_ALARM_TYPE_COUNT) return -EINVAL; @@ -130,115 +224,89 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch (ANDROID_ALARM_BASE_CMD(cmd)) { case ANDROID_ALARM_CLEAR(0): - spin_lock_irqsave(&alarm_slock, flags); - alarm_dbg(IO, "alarm %d clear\n", alarm_type); - devalarm_try_to_cancel(&alarms[alarm_type]); - if (alarm_pending) { - alarm_pending &= ~alarm_type_mask; - if (!alarm_pending && !wait_pending) - __pm_relax(&alarm_wake_lock); - } - alarm_enabled &= ~alarm_type_mask; - spin_unlock_irqrestore(&alarm_slock, flags); + alarm_clear(alarm_type); break; - - case ANDROID_ALARM_SET_OLD: - case ANDROID_ALARM_SET_AND_WAIT_OLD: - if (get_user(new_alarm_time.tv_sec, (int __user *)arg)) { - rv = -EFAULT; - goto err1; - } - new_alarm_time.tv_nsec = 0; - goto from_old_alarm_set; - - case ANDROID_ALARM_SET_AND_WAIT(0): case ANDROID_ALARM_SET(0): - if (copy_from_user(&new_alarm_time, (void __user *)arg, - sizeof(new_alarm_time))) { - rv = -EFAULT; - goto err1; - } -from_old_alarm_set: - spin_lock_irqsave(&alarm_slock, flags); - alarm_dbg(IO, "alarm %d set %ld.%09ld\n", - alarm_type, - new_alarm_time.tv_sec, new_alarm_time.tv_nsec); - alarm_enabled |= alarm_type_mask; - devalarm_start(&alarms[alarm_type], - timespec_to_ktime(new_alarm_time)); - spin_unlock_irqrestore(&alarm_slock, flags); - if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_SET_AND_WAIT(0) - && cmd != ANDROID_ALARM_SET_AND_WAIT_OLD) - break; + alarm_set(alarm_type, ts); + break; + case ANDROID_ALARM_SET_AND_WAIT(0): + alarm_set(alarm_type, ts); /* fall though */ case ANDROID_ALARM_WAIT: - spin_lock_irqsave(&alarm_slock, flags); - alarm_dbg(IO, "alarm wait\n"); - if (!alarm_pending && wait_pending) { - __pm_relax(&alarm_wake_lock); - wait_pending = 0; - } - spin_unlock_irqrestore(&alarm_slock, flags); - rv = wait_event_interruptible(alarm_wait_queue, alarm_pending); - if (rv) - goto err1; - spin_lock_irqsave(&alarm_slock, flags); - rv = alarm_pending; - wait_pending = 1; - alarm_pending = 0; - spin_unlock_irqrestore(&alarm_slock, flags); + rv = alarm_wait(); break; case ANDROID_ALARM_SET_RTC: - if (copy_from_user(&new_rtc_time, (void __user *)arg, - sizeof(new_rtc_time))) { - rv = -EFAULT; - goto err1; - } - rtc_time_to_tm(new_rtc_time.tv_sec, &new_rtc_tm); - rtc_dev = alarmtimer_get_rtcdev(); - rv = do_settimeofday(&new_rtc_time); - if (rv < 0) - goto err1; - if (rtc_dev) - rv = rtc_set_time(rtc_dev, &new_rtc_tm); - spin_lock_irqsave(&alarm_slock, flags); - alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK; - wake_up(&alarm_wait_queue); - spin_unlock_irqrestore(&alarm_slock, flags); - if (rv < 0) - goto err1; + rv = alarm_set_rtc(ts); break; case ANDROID_ALARM_GET_TIME(0): - switch (alarm_type) { - case ANDROID_ALARM_RTC_WAKEUP: - case ANDROID_ALARM_RTC: - getnstimeofday(&tmp_time); - break; - case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP: - case ANDROID_ALARM_ELAPSED_REALTIME: - get_monotonic_boottime(&tmp_time); - break; - case ANDROID_ALARM_SYSTEMTIME: - ktime_get_ts(&tmp_time); - break; - default: - rv = -EINVAL; - goto err1; - } - if (copy_to_user((void __user *)arg, &tmp_time, - sizeof(tmp_time))) { - rv = -EFAULT; - goto err1; - } + rv = alarm_get_time(alarm_type, ts); break; default: rv = -EINVAL; } -err1: return rv; } +static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + + struct timespec ts; + int rv; + + switch (ANDROID_ALARM_BASE_CMD(cmd)) { + case ANDROID_ALARM_SET_AND_WAIT(0): + case ANDROID_ALARM_SET(0): + case ANDROID_ALARM_SET_RTC: + if (copy_from_user(&ts, (void __user *)arg, sizeof(ts))) + return -EFAULT; + break; + } + + rv = alarm_do_ioctl(file, cmd, &ts); + + switch (ANDROID_ALARM_BASE_CMD(cmd)) { + case ANDROID_ALARM_GET_TIME(0): + if (copy_to_user((void __user *)arg, &ts, sizeof(ts))) + return -EFAULT; + break; + } + + return rv; +} +#ifdef CONFIG_COMPAT +static long alarm_compat_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + + struct timespec ts; + int rv; + + switch (ANDROID_ALARM_BASE_CMD(cmd)) { + case ANDROID_ALARM_SET_AND_WAIT_COMPAT(0): + case ANDROID_ALARM_SET_COMPAT(0): + case ANDROID_ALARM_SET_RTC_COMPAT: + if (compat_get_timespec(&ts, (void __user *)arg)) + return -EFAULT; + /* fall through */ + case ANDROID_ALARM_GET_TIME_COMPAT(0): + cmd = ANDROID_ALARM_COMPAT_TO_NORM(cmd); + break; + } + + rv = alarm_do_ioctl(file, cmd, &ts); + + switch (ANDROID_ALARM_BASE_CMD(cmd)) { + case ANDROID_ALARM_GET_TIME(0): /* NOTE: we modified cmd above */ + if (compat_put_timespec(&ts, (void __user *)arg)) + return -EFAULT; + break; + } + + return rv; +} +#endif + static int alarm_open(struct inode *inode, struct file *file) { file->private_data = NULL; @@ -319,6 +387,9 @@ static const struct file_operations alarm_fops = { .unlocked_ioctl = alarm_ioctl, .open = alarm_open, .release = alarm_release, +#ifdef CONFIG_COMPAT + .compat_ioctl = alarm_compat_ioctl, +#endif }; static struct miscdevice alarm_device = { diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h index d0cafd6..4fd32f3 100644 --- a/drivers/staging/android/android_alarm.h +++ b/drivers/staging/android/android_alarm.h @@ -18,6 +18,7 @@ #include <linux/ioctl.h> #include <linux/time.h> +#include <linux/compat.h> enum android_alarm_type { /* return code bit numbers or set alarm arg */ @@ -59,4 +60,22 @@ enum android_alarm_return_flags { #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) + +#ifdef CONFIG_COMPAT +#define ANDROID_ALARM_SET_COMPAT(type) ALARM_IOW(2, type, \ + struct compat_timespec) +#define ANDROID_ALARM_SET_AND_WAIT_COMPAT(type) ALARM_IOW(3, type, \ + struct compat_timespec) +#define ANDROID_ALARM_GET_TIME_COMPAT(type) ALARM_IOW(4, type, \ + struct compat_timespec) +#define ANDROID_ALARM_SET_RTC_COMPAT _IOW('a', 5, \ + struct compat_timespec) +#define ANDROID_ALARM_IOCTL_NR(cmd) (_IOC_NR(cmd) & ((1<<4)-1)) +#define ANDROID_ALARM_COMPAT_TO_NORM(cmd) \ + ALARM_IOW(ANDROID_ALARM_IOCTL_NR(cmd), \ + ANDROID_ALARM_IOCTL_TO_TYPE(cmd), \ + struct timespec) + +#endif + #endif diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 2d12e8a..538ebe2 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -3227,7 +3227,7 @@ static void print_binder_proc(struct seq_file *m, m->count = start_pos; } -static const char *binder_return_strings[] = { +static const char * const binder_return_strings[] = { "BR_ERROR", "BR_OK", "BR_TRANSACTION", @@ -3248,7 +3248,7 @@ static const char *binder_return_strings[] = { "BR_FAILED_REPLY" }; -static const char *binder_command_strings[] = { +static const char * const binder_command_strings[] = { "BC_TRANSACTION", "BC_REPLY", "BC_ACQUIRE_RESULT", @@ -3268,7 +3268,7 @@ static const char *binder_command_strings[] = { "BC_DEAD_BINDER_DONE" }; -static const char *binder_objstat_strings[] = { +static const char * const binder_objstat_strings[] = { "proc", "thread", "node", diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index 2f7d195..76ead8d 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -163,7 +163,7 @@ struct binder_pri_ptr_cookie { void *cookie; }; -enum BinderDriverReturnProtocol { +enum binder_driver_return_protocol { BR_ERROR = _IOR('r', 0, int), /* * int: error code @@ -251,7 +251,7 @@ enum BinderDriverReturnProtocol { */ }; -enum BinderDriverCommandProtocol { +enum binder_driver_command_protocol { BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), BC_REPLY = _IOW('c', 1, struct binder_transaction_data), /* diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c index 0018547..d0a5a28 100644 --- a/drivers/staging/asus_oled/asus_oled.c +++ b/drivers/staging/asus_oled/asus_oled.c @@ -164,11 +164,8 @@ static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl) struct asus_oled_packet *packet; packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); - - if (!packet) { - dev_err(&odev->udev->dev, "out of memory\n"); + if (!packet) return; - } setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00); @@ -323,11 +320,8 @@ static void send_data(struct asus_oled_dev *odev) struct asus_oled_packet *packet; packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); - - if (!packet) { - dev_err(&odev->udev->dev, "out of memory\n"); + if (!packet) return; - } if (odev->pack_mode == PACK_MODE_G1) { /* When sending roll-mode data the display updated only @@ -665,11 +659,8 @@ static int asus_oled_probe(struct usb_interface *interface, } odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL); - - if (odev == NULL) { - dev_err(&interface->dev, "Out of memory\n"); + if (odev == NULL) return -ENOMEM; - } odev->udev = usb_get_dev(udev); odev->pic_mode = ASUS_OLED_STATIC; diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h index f577948..1d8bf08 100644 --- a/drivers/staging/bcm/Adapter.h +++ b/drivers/staging/bcm/Adapter.h @@ -95,7 +95,7 @@ struct bcm_classifier_rule { UCHAR ucDirection; BOOLEAN bIpv6Protocol; UINT32 u32PHSRuleID; - S_PHS_RULE sPhsRule; + struct bcm_phs_rule sPhsRule; UCHAR u8AssociatedPHSI; /* Classification fields for ETH CS */ @@ -288,7 +288,7 @@ struct bcm_mini_adapter { wait_queue_head_t ioctl_fw_dnld_wait_queue; BOOLEAN waiting_to_fw_download_done; pid_t fw_download_process_pid; - PSTARGETPARAMS pstargetparams; + struct bcm_target_params *pstargetparams; BOOLEAN device_removed; BOOLEAN DeviceAccess; BOOLEAN bIsAutoCorrectEnabled; @@ -303,10 +303,10 @@ struct bcm_mini_adapter { struct task_struct *transmit_packet_thread; /* LED Related Structures */ - LED_INFO_STRUCT LEDInfo; + struct bcm_led_info LEDInfo; /* Driver State for LED Blinking */ - LedEventInfo_t DriverState; + enum bcm_led_events DriverState; /* Interface Specific */ PVOID pvInterfaceAdapter; int (*bcm_file_download)(PVOID, @@ -333,7 +333,7 @@ struct bcm_mini_adapter { /* BOOLEAN bTriedToWakeUpFromShutdown; */ BOOLEAN bLinkDownRequested; int downloadDDR; - PHS_DEVICE_EXTENSION stBCMPhsContext; + struct bcm_phs_extension stBCMPhsContext; struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo; uint8_t ucaPHSPktRestoreBuf[2048]; uint8_t bPHSEnabled; @@ -345,7 +345,7 @@ struct bcm_mini_adapter { struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES]; atomic_t uiMBupdate; UINT32 PmuMode; - NVM_TYPE eNVMType; + enum bcm_nvm_type eNVMType; UINT uiSectorSize; UINT uiSectorSizeInCFG; BOOLEAN bSectorSizeOverride; @@ -366,9 +366,9 @@ struct bcm_mini_adapter { struct device *pstCreatedClassDevice; /* BOOLEAN InterfaceUpStatus; */ - PFLASH2X_CS_INFO psFlash2xCSInfo; - PFLASH_CS_INFO psFlashCSInfo; - PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo; + struct bcm_flash2x_cs_info *psFlash2xCSInfo; + struct bcm_flash_cs_info *psFlashCSInfo; + struct bcm_flash2x_vendor_info *psFlash2xVendorInfo; UINT uiFlashBaseAdd; /* Flash start address */ UINT uiActiveISOOffset; /* Active ISO offset chosen before f/w download */ enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */ @@ -392,7 +392,7 @@ struct bcm_mini_adapter { struct semaphore LowPowerModeSync; ULONG liDrainCalculated; UINT gpioBitMap; - S_BCM_DEBUG_STATE stDebugState; + struct bcm_debug_state stDebugState; }; #define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index efad33e..491e2bf 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1013,7 +1013,7 @@ cntrlEnd: } case IOCTL_BCM_GET_CURRENT_STATUS: { - LINK_STATE link_state; + struct bcm_link_state link_state; /* Copy Ioctl Buffer structure */ if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { @@ -1229,13 +1229,13 @@ cntrlEnd: case IOCTL_BCM_SET_DEBUG: #ifdef DEBUG { - USER_BCM_DBG_STATE sUserDebugState; + struct bcm_user_debug_state sUserDebugState; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n"); if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) return -EFAULT; - if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE))) + if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state))) return -EFAULT; BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", @@ -1783,16 +1783,16 @@ cntrlEnd: } if (IsFlash2x(Adapter) == TRUE) { - if (IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO)) + if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info)) return -EINVAL; - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO))) + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(struct bcm_flash2x_cs_info))) return -EFAULT; } else { - if (IoBuffer.OutputLength < sizeof(FLASH_CS_INFO)) + if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) return -EINVAL; - if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO))) + if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(struct bcm_flash_cs_info))) return -EFAULT; } } diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 23ddc3d..97651450 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -113,7 +113,7 @@ static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIn static inline VOID CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc, - BOOLEAN bIpVersion6, E_IPADDR_CONTEXT eIpAddrContext) + BOOLEAN bIpVersion6, enum bcm_ipaddr_context eIpAddrContext) { int i = 0; UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS; @@ -440,7 +440,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer B_UINT16 u16PacketClassificationRuleIndex = 0; int i; struct bcm_convergence_types *psfCSType = NULL; - S_PHS_RULE sPhsRule; + struct bcm_phs_rule sPhsRule; USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; UINT UGIValue = 0; @@ -703,7 +703,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer /* Update PHS Rule For the Classifier */ if (sPhsRule.u8PHSI) { Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; - memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(S_PHS_RULE)); + memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(struct bcm_phs_rule)); } } } diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h index eecad8d..4ddfc3d4 100644 --- a/drivers/staging/bcm/CmHost.h +++ b/drivers/staging/bcm/CmHost.h @@ -27,32 +27,28 @@ struct bcm_add_indication_alt { u8 u8Type; u8 u8Direction; u16 u16TID; - /* brief 16bitCID */ u16 u16CID; - /* brief 16bitVCID */ u16 u16VCID; struct bcm_connect_mgr_params sfAuthorizedSet; struct bcm_connect_mgr_params sfAdmittedSet; struct bcm_connect_mgr_params sfActiveSet; u8 u8CC; /* < Confirmation Code */ - u8 u8Padd; /* < 8-bit Padding */ - u16 u16Padd; /* < 16 bit Padding */ + u8 u8Padd; + u16 u16Padd; }; struct bcm_change_indication { u8 u8Type; u8 u8Direction; u16 u16TID; - /* brief 16bitCID */ u16 u16CID; - /* brief 16bitVCID */ u16 u16VCID; struct bcm_connect_mgr_params sfAuthorizedSet; struct bcm_connect_mgr_params sfAdmittedSet; struct bcm_connect_mgr_params sfActiveSet; u8 u8CC; /* < Confirmation Code */ - u8 u8Padd; /* < 8-bit Padding */ - u16 u16Padd; /* < 16 bit */ + u8 u8Padd; + u16 u16Padd; }; unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer, unsigned int *puBufferLength); diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h index 8018a18..7b33121 100644 --- a/drivers/staging/bcm/Debug.h +++ b/drivers/staging/bcm/Debug.h @@ -9,142 +9,129 @@ #include <linux/string.h> #define NONE 0xFFFF - -//-------------------------------------------------------------------------------- - /* TYPE and SUBTYPE * Define valid TYPE (or category or code-path, however you like to think of it) * and SUBTYPE s. * Type and SubType are treated as bitmasks. */ -/*-----------------BEGIN TYPEs------------------------------------------*/ -#define DBG_TYPE_INITEXIT (1 << 0) // 1 -#define DBG_TYPE_TX (1 << 1) // 2 -#define DBG_TYPE_RX (1 << 2) // 4 -#define DBG_TYPE_OTHERS (1 << 3) // 8 -/*-----------------END TYPEs------------------------------------------*/ -#define NUMTYPES 4 // careful! - -/*-----------------BEGIN SUBTYPEs---------------------------------------*/ - -/*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// - Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c - total 17 macros */ -// Transmit.c -#define TX 1 -#define MP_SEND (TX<<0) -#define NEXT_SEND (TX<<1) -#define TX_FIFO (TX<<2) -#define TX_CONTROL (TX<<3) - -// Arp.c -#define IP_ADDR (TX<<4) -#define ARP_REQ (TX<<5) -#define ARP_RESP (TX<<6) - -// Leakybucket.c -#define TOKEN_COUNTS (TX<<8) -#define CHECK_TOKENS (TX<<9) -#define TX_PACKETS (TX<<10) -#define TIMER (TX<<11) - -// Qos.c -#define QOS TX -#define QUEUE_INDEX (QOS<<12) -#define IPV4_DBG (QOS<<13) -#define IPV6_DBG (QOS<<14) -#define PRUNE_QUEUE (QOS<<15) -#define SEND_QUEUE (QOS<<16) - -//TX_Misc -#define TX_OSAL_DBG (TX<<17) - - -//--SUBTYPEs for ------INIT & EXIT--------------------- -/*------------ TYPE is DBG_TYPE_INITEXIT -----// -DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ -#define MP 1 -#define DRV_ENTRY (MP<<0) -#define MP_INIT (MP<<1) -#define READ_REG (MP<<3) -#define DISPATCH (MP<<2) -#define CLAIM_ADAP (MP<<4) -#define REG_IO_PORT (MP<<5) -#define INIT_DISP (MP<<6) -#define RX_INIT (MP<<7) - - -//-SUBTYPEs for --RX---------------------------------- -//------------RX : TYPE is DBG_TYPE_RX -----// -// Receive.c -#define RX 1 -#define RX_DPC (RX<<0) -#define RX_CTRL (RX<<3) -#define RX_DATA (RX<<4) -#define MP_RETURN (RX<<1) -#define LINK_MSG (RX<<2) - - -//-SUBTYPEs for ----OTHER ROUTINES------------------ -//------------OTHERS : TYPE is DBG_TYPE_OTHER -----// -// HaltnReset,CheckForHang,PnP,Misc,CmHost -// total 12 macros -#define OTHERS 1 -// ??ISR.C - -#define ISR OTHERS -#define MP_DPC (ISR<<0) - -// HaltnReset.c -#define HALT OTHERS -#define MP_HALT (HALT<<1) -#define CHECK_HANG (HALT<<2) -#define MP_RESET (HALT<<3) -#define MP_SHUTDOWN (HALT<<4) - -// pnp.c -#define PNP OTHERS -#define MP_PNP (PNP<<5) - -// Misc.c -#define MISC OTHERS -#define DUMP_INFO (MISC<<6) -#define CLASSIFY (MISC<<7) -#define LINK_UP_MSG (MISC<<8) -#define CP_CTRL_PKT (MISC<<9) -#define DUMP_CONTROL (MISC<<10) -#define LED_DUMP_INFO (MISC<<11) - -// CmHost.c -#define CMHOST OTHERS - - -#define SERIAL (OTHERS<<12) -#define IDLE_MODE (OTHERS<<13) - -#define WRM (OTHERS<<14) -#define RDM (OTHERS<<15) - -// TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? -#define PHS_SEND (OTHERS<<16) -#define PHS_RECEIVE (OTHERS<<17) -#define PHS_MODULE (OTHERS<<18) - -#define INTF_INIT (OTHERS<<19) -#define INTF_ERR (OTHERS<<20) -#define INTF_WARN (OTHERS<<21) -#define INTF_NORM (OTHERS<<22) - -#define IRP_COMPLETION (OTHERS<<23) -#define SF_DESCRIPTOR_CNTS (OTHERS<<24) -#define PHS_DISPATCH (OTHERS << 25) -#define OSAL_DBG (OTHERS << 26) -#define NVM_RW (OTHERS << 27) - -#define HOST_MIBS (OTHERS << 28) -#define CONN_MSG (CMHOST << 29) -/*-----------------END SUBTYPEs------------------------------------------*/ - +#define DBG_TYPE_INITEXIT (1 << 0) /* 1 */ +#define DBG_TYPE_TX (1 << 1) /* 2 */ +#define DBG_TYPE_RX (1 << 2) /* 4 */ +#define DBG_TYPE_OTHERS (1 << 3) /* 8 */ +#define NUMTYPES 4 + +/* -SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// + * Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c + * total 17 macros + */ +/* Transmit.c */ +#define TX 1 +#define MP_SEND (TX << 0) +#define NEXT_SEND (TX << 1) +#define TX_FIFO (TX << 2) +#define TX_CONTROL (TX << 3) + +/* Arp.c */ +#define IP_ADDR (TX << 4) +#define ARP_REQ (TX << 5) +#define ARP_RESP (TX << 6) + +/* Leakybucket.c */ +#define TOKEN_COUNTS (TX << 8) +#define CHECK_TOKENS (TX << 9) +#define TX_PACKETS (TX << 10) +#define TIMER (TX << 11) + +/* Qos.c */ +#define QOS TX +#define QUEUE_INDEX (QOS << 12) +#define IPV4_DBG (QOS << 13) +#define IPV6_DBG (QOS << 14) +#define PRUNE_QUEUE (QOS << 15) +#define SEND_QUEUE (QOS << 16) + +/* TX_Misc */ +#define TX_OSAL_DBG (TX << 17) + +/* --SUBTYPEs for ------INIT & EXIT--------------------- + * ------------ TYPE is DBG_TYPE_INITEXIT -----// + * DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c + */ +#define MP 1 +#define DRV_ENTRY (MP << 0) +#define MP_INIT (MP << 1) +#define READ_REG (MP << 3) +#define DISPATCH (MP << 2) +#define CLAIM_ADAP (MP << 4) +#define REG_IO_PORT (MP << 5) +#define INIT_DISP (MP << 6) +#define RX_INIT (MP << 7) + +/* -SUBTYPEs for --RX---------------------------------- + * ------------RX : TYPE is DBG_TYPE_RX -----// + * Receive.c + */ +#define RX 1 +#define RX_DPC (RX << 0) +#define RX_CTRL (RX << 3) +#define RX_DATA (RX << 4) +#define MP_RETURN (RX << 1) +#define LINK_MSG (RX << 2) + +/* -SUBTYPEs for ----OTHER ROUTINES------------------ + * ------------OTHERS : TYPE is DBG_TYPE_OTHER -----// + * HaltnReset,CheckForHang,PnP,Misc,CmHost + * total 12 macros + */ +#define OTHERS 1 +#define ISR OTHERS +#define MP_DPC (ISR << 0) + +/* HaltnReset.c */ +#define HALT OTHERS +#define MP_HALT (HALT << 1) +#define CHECK_HANG (HALT << 2) +#define MP_RESET (HALT << 3) +#define MP_SHUTDOWN (HALT << 4) + +/* pnp.c */ +#define PNP OTHERS +#define MP_PNP (PNP << 5) + +/* Misc.c */ +#define MISC OTHERS +#define DUMP_INFO (MISC << 6) +#define CLASSIFY (MISC << 7) +#define LINK_UP_MSG (MISC << 8) +#define CP_CTRL_PKT (MISC << 9) +#define DUMP_CONTROL (MISC << 10) +#define LED_DUMP_INFO (MISC << 11) + +/* CmHost.c */ +#define CMHOST OTHERS +#define SERIAL (OTHERS << 12) +#define IDLE_MODE (OTHERS << 13) +#define WRM (OTHERS << 14) +#define RDM (OTHERS << 15) + +/* TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? */ +#define PHS_SEND (OTHERS << 16) +#define PHS_RECEIVE (OTHERS << 17) +#define PHS_MODULE (OTHERS << 18) + +#define INTF_INIT (OTHERS << 19) +#define INTF_ERR (OTHERS << 20) +#define INTF_WARN (OTHERS << 21) +#define INTF_NORM (OTHERS << 22) + +#define IRP_COMPLETION (OTHERS << 23) +#define SF_DESCRIPTOR_CNTS (OTHERS << 24) +#define PHS_DISPATCH (OTHERS << 25) +#define OSAL_DBG (OTHERS << 26) +#define NVM_RW (OTHERS << 27) + +#define HOST_MIBS (OTHERS << 28) +#define CONN_MSG (CMHOST << 29) /* Debug level * We have 8 debug levels, in (numerical) increasing order of verbosity. @@ -157,57 +144,58 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ * You can compile-time change that to any of the below, if you wish to. However, as of now, there's * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion. */ -#define BCM_ALL 7 -#define BCM_LOW 6 -#define BCM_PRINT 5 -#define BCM_NORMAL 4 -#define BCM_MEDIUM 3 -#define BCM_SCREAM 2 -#define BCM_ERR 1 +#define BCM_ALL 7 +#define BCM_LOW 6 +#define BCM_PRINT 5 +#define BCM_NORMAL 4 +#define BCM_MEDIUM 3 +#define BCM_SCREAM 2 +#define BCM_ERR 1 /* Not meant for developer in debug prints. - * To be used to disable all prints by setting the DBG_LVL_CURR to this value */ -#define BCM_NONE 0 + * To be used to disable all prints by setting the DBG_LVL_CURR to this value + */ +#define BCM_NONE 0 /* The current driver logging level. * Everything at this level and (numerically) lower (meaning higher prio) * is logged. -* Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. + * Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. * For eg. to set the logging level to 'errors only' use: * #define DBG_LVL_CURR (BCM_ERR) */ #define DBG_LVL_CURR (BCM_ALL) -#define DBG_LVL_ALL BCM_ALL +#define DBG_LVL_ALL BCM_ALL -/*---Userspace mapping of Debug State. +/* ---Userspace mapping of Debug State. * Delibrately matches that of the Windows driver.. * The TestApp's ioctl passes this struct to us. */ -typedef struct -{ +struct bcm_user_debug_state { unsigned int Subtype, Type; unsigned int OnOff; -// unsigned int debug_level; /* future expansion */ -} __attribute__((packed)) USER_BCM_DBG_STATE; +/* unsigned int debug_level; future expansion */ +} __packed; -//---Kernel-space mapping of Debug State -typedef struct _S_BCM_DEBUG_STATE { - UINT type; +/* ---Kernel-space mapping of Debug State */ +struct bcm_debug_state { + unsigned int type; /* A bitmap of 32 bits for Subtype per Type. * Valid indexes in 'subtype' array are *only* 1,2,4 and 8, * corresponding to valid Type values. Hence we use the 'Type' field * as the index value, ignoring the array entries 0,3,5,6,7 ! */ - UINT subtype[(NUMTYPES*2)+1]; - UINT debug_level; -} S_BCM_DEBUG_STATE; -/* Instantiated in the Adapter structure */ -/* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not - * we want the function's name printed. */ -#define DBG_NO_FUNC_PRINT 1 << 31 + unsigned int subtype[(NUMTYPES*2)+1]; + unsigned int debug_level; +}; +/* Instantiated in the Adapter structure + * We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not + * we want the function's name printed. + */ +#define DBG_NO_FUNC_PRINT (1 << 31) #define DBG_LVL_BITMASK 0xFF -//--- Only for direct printk's; "hidden" to API. +/* --- Only for direct printk's; "hidden" to API. */ #define DBG_TYPE_PRINTK 3 #define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \ @@ -215,40 +203,40 @@ typedef struct _S_BCM_DEBUG_STATE { if (DBG_TYPE_PRINTK == Type) \ pr_info("%s:" string, __func__, ##args); \ else if (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type])) { \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type])) { \ if (dbg_level & DBG_NO_FUNC_PRINT) \ - printk(KERN_DEBUG string, ##args); \ + pr_debug("%s:\n", string); \ else \ - printk(KERN_DEBUG "%s:" string, __func__, ##args); \ + pr_debug("%s:\n" string, __func__, ##args); \ } \ } while (0) -#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ - if (DBG_TYPE_PRINTK == Type || \ - (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type]))) { \ - printk(KERN_DEBUG "%s:\n", __func__); \ - print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ - 16, 1, buffer, bufferlen, false); \ - } \ -} while(0) - - -#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ - int i; \ - for (i=0; i<(NUMTYPES*2)+1; i++) { \ +#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) \ + do { \ + if (DBG_TYPE_PRINTK == Type || \ + (Adapter && \ + (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ + (Type & Adapter->stDebugState.type) && \ + (SubType & Adapter->stDebugState.subtype[Type]))) { \ + pr_debug("%s:\n", __func__); \ + print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ + 16, 1, buffer, bufferlen, false); \ + } \ + } while (0) + +#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ + int i; \ + for (i = 0; i < (NUMTYPES * 2) + 1; i++) { \ if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \ - /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ - Adapter->stDebugState.subtype[i] = 0xffffffff; */ \ - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ - i, Adapter->stDebugState.subtype[i]); \ + /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ + * Adapter->stDebugState.subtype[i] = 0xffffffff; \ + */ \ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ + i, Adapter->stDebugState.subtype[i]); \ } \ } \ } while (0) #endif - diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c index 4745ddd..6d803e7 100644 --- a/drivers/staging/bcm/IPv6Protocol.c +++ b/drivers/staging/bcm/IPv6Protocol.c @@ -1,10 +1,10 @@ #include "headers.h" static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header); + struct bcm_ipv6_hdr *pstIpv6Header); static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header); -static VOID DumpIpv6Header(IPV6Header *pstIpv6Header); + struct bcm_ipv6_hdr *pstIpv6Header); +static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header); static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, UCHAR *pucNextHeader, BOOLEAN *bParseDone, USHORT *pusPayloadLength) @@ -38,17 +38,17 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 HopByHop Header"); - usNextHeaderOffset += sizeof(IPV6HopByHopOptionsHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_options_hdr); } break; case IPV6HDR_TYPE_ROUTING: { - IPV6RoutingHeader *pstIpv6RoutingHeader; + struct bcm_ipv6_routing_hdr *pstIpv6RoutingHeader; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Routing Header"); - pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr; - usNextHeaderOffset += sizeof(IPV6RoutingHeader); + pstIpv6RoutingHeader = (struct bcm_ipv6_routing_hdr *)pucPayloadPtr; + usNextHeaderOffset += sizeof(struct bcm_ipv6_routing_hdr); usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES; } @@ -58,25 +58,25 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Fragmentation Header"); - usNextHeaderOffset += sizeof(IPV6FragmentHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_fragment_hdr); } break; case IPV6HDR_TYPE_DESTOPTS: { - IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr; + struct bcm_ipv6_dest_options_hdr *pstIpv6DestOptsHdr = (struct bcm_ipv6_dest_options_hdr *)pucPayloadPtr; int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 DestOpts Header Header"); - usNextHeaderOffset += sizeof(IPV6DestOptionsHeader); + usNextHeaderOffset += sizeof(struct bcm_ipv6_dest_options_hdr); usNextHeaderOffset += nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ; } break; case IPV6HDR_TYPE_AUTHENTICATION: { - IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr; + struct bcm_ipv6_authentication_hdr *pstIpv6AuthHdr = (struct bcm_ipv6_authentication_hdr *)pucPayloadPtr; int nHdrLen = pstIpv6AuthHdr->ucLength; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, @@ -186,13 +186,13 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, USHORT ushDestPort = 0; USHORT ushSrcPort = 0; UCHAR ucNextProtocolAboveIP = 0; - IPV6Header *pstIpv6Header = NULL; + struct bcm_ipv6_hdr *pstIpv6Header = NULL; BOOLEAN bClassificationSucceed = FALSE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "IpVersion6 ==========>\n"); - pstIpv6Header = (IPV6Header *)pcIpHeader; + pstIpv6Header = (struct bcm_ipv6_hdr *)pcIpHeader; DumpIpv6Header(pstIpv6Header); @@ -200,7 +200,7 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, * Try to get the next higher layer protocol * and the Ports Nos if TCP or UDP */ - ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)), + ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(struct bcm_ipv6_hdr)), &ushSrcPort, &ushDestPort, pstIpv6Header->usPayloadLength, @@ -289,7 +289,7 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header) + struct bcm_ipv6_hdr *pstIpv6Header) { UINT uiLoopIndex = 0; UINT uiIpv6AddIndex = 0; @@ -345,7 +345,7 @@ static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule } static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - IPV6Header *pstIpv6Header) + struct bcm_ipv6_hdr *pstIpv6Header) { UINT uiLoopIndex = 0; UINT uiIpv6AddIndex = 0; @@ -414,7 +414,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address) } -static VOID DumpIpv6Header(IPV6Header *pstIpv6Header) +static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header) { UCHAR ucVersion; UCHAR ucPrio; diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h index 8ba88a5..96b36a5 100644 --- a/drivers/staging/bcm/IPv6ProtocolHdr.h +++ b/drivers/staging/bcm/IPv6ProtocolHdr.h @@ -1,7 +1,6 @@ #ifndef _IPV6_PROTOCOL_DEFINES_ #define _IPV6_PROTOCOL_DEFINES_ - #define IPV6HDR_TYPE_HOPBYHOP 0x0 #define IPV6HDR_TYPE_ROUTING 0x2B #define IPV6HDR_TYPE_FRAGMENTATION 0x2C @@ -10,107 +9,77 @@ #define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34 #define MASK_IPV6_CS_SPEC 0x2 - -#define TCP_HEADER_TYPE 0x6 -#define UDP_HEADER_TYPE 0x11 +#define TCP_HEADER_TYPE 0x6 +#define UDP_HEADER_TYPE 0x11 #define IPV6_ICMP_HDR_TYPE 0x2 #define IPV6_FLOWLABEL_BITOFFSET 9 #define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64 /* -// Size of Dest Options field of Destinations Options Header -// in bytes. -*/ + * Size of Dest Options field of Destinations Options Header + * in bytes. + */ #define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8 -//typedef unsigned char UCHAR; -//typedef unsigned short USHORT; -//typedef unsigned long int ULONG; - -typedef struct IPV6HeaderFormatTag -{ - UCHAR ucVersionPrio; - UCHAR aucFlowLabel[3]; - USHORT usPayloadLength; - UCHAR ucNextHeader; - UCHAR ucHopLimit; - ULONG ulSrcIpAddress[4]; - ULONG ulDestIpAddress[4]; -}IPV6Header; - -typedef struct IPV6RoutingHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucRoutingType; - UCHAR ucNumAddresses; - UCHAR ucNextAddress; - ULONG ulReserved; - //UCHAR aucAddressList[0]; - -}IPV6RoutingHeader; - -typedef struct IPV6FragmentHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucReserved; - USHORT usFragmentOffset; - ULONG ulIdentification; -}IPV6FragmentHeader; - -typedef struct IPV6DestOptionsHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucHdrExtLen; - UCHAR ucDestOptions[6]; - //UCHAR udExtDestOptions[0]; -}IPV6DestOptionsHeader; - -typedef struct IPV6HopByHopOptionsHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucMisc[3]; - ULONG ulJumboPayloadLen; -}IPV6HopByHopOptionsHeader; - -typedef struct IPV6AuthenticationHeaderFormatTag -{ - UCHAR ucNextHeader; - UCHAR ucLength; - USHORT usReserved; - ULONG ulSecurityParametersIndex; - //UCHAR ucAuthenticationData[0]; - -}IPV6AuthenticationHeader; - -typedef struct IPV6IcmpHeaderFormatTag -{ - UCHAR ucType; - UCHAR ucCode; - USHORT usChecksum; - //UCHAR ucIcmpMsg[0]; - -}IPV6IcmpHeader; - -typedef enum _E_IPADDR_CONTEXT -{ +struct bcm_ipv6_hdr { + unsigned char ucVersionPrio; + unsigned char aucFlowLabel[3]; + unsigned short usPayloadLength; + unsigned char ucNextHeader; + unsigned char ucHopLimit; + unsigned long ulSrcIpAddress[4]; + unsigned long ulDestIpAddress[4]; +}; + +struct bcm_ipv6_routing_hdr { + unsigned char ucNextHeader; + unsigned char ucRoutingType; + unsigned char ucNumAddresses; + unsigned char ucNextAddress; + unsigned long ulReserved; +}; + +struct bcm_ipv6_fragment_hdr { + unsigned char ucNextHeader; + unsigned char ucReserved; + unsigned short usFragmentOffset; + unsigned long ulIdentification; +}; + +struct bcm_ipv6_dest_options_hdr { + unsigned char ucNextHeader; + unsigned char ucHdrExtLen; + unsigned char ucDestOptions[6]; +}; + +struct bcm_ipv6_options_hdr { + unsigned char ucNextHeader; + unsigned char ucMisc[3]; + unsigned long ulJumboPayloadLen; +}; + +struct bcm_ipv6_authentication_hdr { + unsigned char ucNextHeader; + unsigned char ucLength; + unsigned short usReserved; + unsigned long ulSecurityParametersIndex; +}; + +enum bcm_ipaddr_context { eSrcIpAddress, eDestIpAddress +}; -}E_IPADDR_CONTEXT; - - - -//Function Prototypes - -USHORT IpVersion6(struct bcm_mini_adapter *Adapter, /**< Pointer to the driver control structure */ - PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/ - struct bcm_classifier_rule *pstClassifierRule ); +/* Function Prototypes */ -VOID DumpIpv6Address(ULONG *puIpv6Address); +unsigned short IpVersion6(struct bcm_mini_adapter *Adapter, /* < Pointer to the driver control structure */ + void *pcIpHeader, /* <Pointer to the IP Hdr of the packet */ + struct bcm_classifier_rule *pstClassifierRule); -extern BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -extern BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -extern BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); +void DumpIpv6Address(unsigned long *puIpv6Address); +extern bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort); +extern bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, unsigned short ushSrcPort); +extern bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, unsigned char ucProtocol); #endif diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 87117a7..64ea6ed 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -138,12 +138,12 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm B_UINT32 value = 0; if (Adapter->pstargetparams == NULL) { - Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); if (Adapter->pstargetparams == NULL) return -ENOMEM; } - if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS)) + if (psFwInfo->u32FirmwareLength != sizeof(struct bcm_target_params)) return -EIO; retval = copy_from_user(Adapter->pstargetparams, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); @@ -195,7 +195,7 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm } } - retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(STARGETPARAMS), CONFIG_BEGIN_ADDR); + retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR); if (retval) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly"); diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index eb246430..79058ce 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -190,9 +190,9 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi } /* Allocate interface adapter structure */ - psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), GFP_KERNEL); + psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), + GFP_KERNEL); if (psIntfAdapter == NULL) { - dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n"); AdapterFree(psAdapter); return -ENOMEM; } @@ -564,11 +564,8 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; psIntfAdapter->sIntrIn.int_in_buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!psIntfAdapter->sIntrIn.int_in_buffer) { - dev_err(&psIntfAdapter->udev->dev, - "could not allocate interrupt_in_buffer\n"); + if (!psIntfAdapter->sIntrIn.int_in_buffer) return -EINVAL; - } } if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) { @@ -587,11 +584,8 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!psIntfAdapter->sIntrOut.int_out_buffer) { - dev_err(&psIntfAdapter->udev->dev, - "could not allocate interrupt_out_buffer\n"); + if (!psIntfAdapter->sIntrOut.int_out_buffer) return -EINVAL; - } } } } diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h index 8c70af9..e253c08 100644 --- a/drivers/staging/bcm/Ioctl.h +++ b/drivers/staging/bcm/Ioctl.h @@ -108,7 +108,7 @@ enum bcm_interface_type { }; struct bcm_driver_info { - NVM_TYPE u32NVMType; + enum bcm_nvm_type u32NVMType; unsigned int MaxRDMBufferSize; enum bcm_interface_type u32InterfaceType; unsigned int u32DSDStartOffset; @@ -202,8 +202,8 @@ struct bcm_flash2x_bitmap { }; struct bcm_time_elapsed { - unsigned long long ul64TimeElapsedSinceNetEntry; - u32 uiReserved[4]; + u64 ul64TimeElapsedSinceNetEntry; + u32 uiReserved[4]; }; enum { diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h index 46f5f0f..dc01e30 100644 --- a/drivers/staging/bcm/Macros.h +++ b/drivers/staging/bcm/Macros.h @@ -162,13 +162,11 @@ #define GPIO_MODE_REGISTER 0x0F000034 #define GPIO_PIN_STATE_REGISTER 0x0F000038 - -typedef struct _LINK_STATE { - UCHAR ucLinkStatus; - UCHAR bIdleMode; - UCHAR bShutdownMode; -} LINK_STATE, *PLINK_STATE; - +struct bcm_link_state { + unsigned char ucLinkStatus; + unsigned char bIdleMode; + unsigned char bShutdownMode; +}; enum enLinkStatus { WAIT_FOR_SYNC = 1, @@ -182,13 +180,12 @@ enum enLinkStatus { COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9 }; -typedef enum _E_PHS_DSC_ACTION { +enum bcm_phs_dsc_action { eAddPHSRule = 0, eSetPHSRule, eDeletePHSRule, eDeleteAllPHSRules -} E_PHS_DSC_ACTION; - +}; #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 /* Host to Mac */ #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */ @@ -324,18 +321,18 @@ typedef enum _E_PHS_DSC_ACTION { #define HPM_CONFIG_MSW 0x0F000D58 #define T3B 0xbece0310 -typedef enum eNVM_TYPE { +enum bcm_nvm_type { NVM_AUTODETECT = 0, NVM_EEPROM, NVM_FLASH, NVM_UNKNOWN -} NVM_TYPE; +}; -typedef enum ePMU_MODES { +enum bcm_pmu_modes { HYBRID_MODE_7C = 0, INTERNAL_MODE_6 = 1, HYBRID_MODE_6 = 2 -} PMU_MODE; +}; #define MAX_RDM_WRM_RETIRES 1 diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index c92078e..b5c2c4c 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -956,7 +956,7 @@ int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) /* Download cfg file */ status = buffDnldVerify(ps_adapter, (PUCHAR)ps_adapter->pstargetparams, - sizeof(STARGETPARAMS), + sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR); if (status) { BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); @@ -1053,7 +1053,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) if (!buff) return -ENOMEM; - Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL); + Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); if (Adapter->pstargetparams == NULL) { kfree(buff); return -ENOMEM; @@ -1070,7 +1070,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) len = kernel_read(flp, 0, buff, BUFFER_1K); filp_close(flp, NULL); - if (len != sizeof(STARGETPARAMS)) { + if (len != sizeof(struct bcm_target_params)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); kfree(buff); kfree(Adapter->pstargetparams); @@ -1082,7 +1082,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) /* * Values in Adapter->pstargetparams are in network byte order */ - memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS)); + memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params)); kfree(buff); beceem_parse_target_struct(Adapter); return STATUS_SUCCESS; @@ -1134,7 +1134,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n", uiEEPROMFlag); - Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3); + Adapter->eNVMType = (enum bcm_nvm_type)((uiEEPROMFlag>>4)&0x3); Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h index 6016fc5..cd78ee4 100644 --- a/drivers/staging/bcm/PHSDefines.h +++ b/drivers/staging/bcm/PHSDefines.h @@ -1,124 +1,94 @@ #ifndef BCM_PHS_DEFINES_H #define BCM_PHS_DEFINES_H -#define PHS_INVALID_TABLE_INDEX 0xffffffff - -/************************* MACROS **********************************************/ +#define PHS_INVALID_TABLE_INDEX 0xffffffff #define PHS_MEM_TAG "_SHP" - - -//PHS Defines -#define STATUS_PHS_COMPRESSED 0xa1 -#define STATUS_PHS_NOCOMPRESSION 0xa2 -#define APPLY_PHS 1 -#define MAX_NO_BIT 7 -#define ZERO_PHSI 0 -#define VERIFY 0 -#define SIZE_MULTIPLE_32 4 -#define UNCOMPRESSED_PACKET 0 -#define DYNAMIC 0 -#define SUPPRESS 0x80 -#define NO_CLASSIFIER_MATCH 0 -#define SEND_PACKET_UNCOMPRESSED 0 -#define PHSI_IS_ZERO 0 -#define PHSI_LEN 1 -#define ERROR_LEN 0 -#define PHS_BUFFER_SIZE 1532 - - -#define MAX_PHSRULE_PER_SF 20 -#define MAX_SERVICEFLOWS 17 - -//PHS Error Defines -#define PHS_SUCCESS 0 -#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 -#define ERR_PHS_INVALID_PHS_RULE 0x801 -#define ERR_PHS_RULE_ALREADY_EXISTS 0x802 -#define ERR_SF_MATCH_FAIL 0x803 -#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 -#define ERR_SFTABLE_FULL 0x805 -#define ERR_CLSASSIFIER_TABLE_FULL 0x806 -#define ERR_PHSRULE_MEMALLOC_FAIL 0x807 -#define ERR_CLSID_MATCH_FAIL 0x808 -#define ERR_PHSRULE_MATCH_FAIL 0x809 - -typedef struct _S_PHS_RULE -{ - /// brief 8bit PHSI Of The Service Flow - B_UINT8 u8PHSI; - /// brief PHSF Of The Service Flow - B_UINT8 u8PHSFLength; - B_UINT8 u8PHSF[MAX_PHS_LENGTHS]; - /// brief PHSM Of The Service Flow - B_UINT8 u8PHSMLength; - B_UINT8 u8PHSM[MAX_PHS_LENGTHS]; - /// brief 8bit PHSS Of The Service Flow - B_UINT8 u8PHSS; - /// brief 8bit PHSV Of The Service Flow - B_UINT8 u8PHSV; - //Reference Count for this PHS Rule - B_UINT8 u8RefCnt; - //Flag to Store Unclassified PHS rules only in DL - B_UINT8 bUnclassifiedPHSRule; - - B_UINT8 u8Reserved[3]; - - LONG PHSModifiedBytes; - ULONG PHSModifiedNumPackets; - ULONG PHSErrorNumPackets; -}S_PHS_RULE; - - -typedef enum _E_CLASSIFIER_ENTRY_CONTEXT -{ +/* PHS Defines */ +#define STATUS_PHS_COMPRESSED 0xa1 +#define STATUS_PHS_NOCOMPRESSION 0xa2 +#define APPLY_PHS 1 +#define MAX_NO_BIT 7 +#define ZERO_PHSI 0 +#define VERIFY 0 +#define SIZE_MULTIPLE_32 4 +#define UNCOMPRESSED_PACKET 0 +#define DYNAMIC 0 +#define SUPPRESS 0x80 +#define NO_CLASSIFIER_MATCH 0 +#define SEND_PACKET_UNCOMPRESSED 0 +#define PHSI_IS_ZERO 0 +#define PHSI_LEN 1 +#define ERROR_LEN 0 +#define PHS_BUFFER_SIZE 1532 +#define MAX_PHSRULE_PER_SF 20 +#define MAX_SERVICEFLOWS 17 + +/* PHS Error Defines */ +#define PHS_SUCCESS 0 +#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 +#define ERR_PHS_INVALID_PHS_RULE 0x801 +#define ERR_PHS_RULE_ALREADY_EXISTS 0x802 +#define ERR_SF_MATCH_FAIL 0x803 +#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 +#define ERR_SFTABLE_FULL 0x805 +#define ERR_CLSASSIFIER_TABLE_FULL 0x806 +#define ERR_PHSRULE_MEMALLOC_FAIL 0x807 +#define ERR_CLSID_MATCH_FAIL 0x808 +#define ERR_PHSRULE_MATCH_FAIL 0x809 + +struct bcm_phs_rule { + u8 u8PHSI; + u8 u8PHSFLength; + u8 u8PHSF[MAX_PHS_LENGTHS]; + u8 u8PHSMLength; + u8 u8PHSM[MAX_PHS_LENGTHS]; + u8 u8PHSS; + u8 u8PHSV; + u8 u8RefCnt; + u8 bUnclassifiedPHSRule; + u8 u8Reserved[3]; + long PHSModifiedBytes; + unsigned long PHSModifiedNumPackets; + unsigned long PHSErrorNumPackets; +}; + +enum bcm_phs_classifier_context { eActiveClassifierRuleContext, eOldClassifierRuleContext -}E_CLASSIFIER_ENTRY_CONTEXT; - -typedef struct _S_CLASSIFIER_ENTRY -{ - B_UINT8 bUsed; - B_UINT16 uiClassifierRuleId; - B_UINT8 u8PHSI; - S_PHS_RULE *pstPhsRule; - B_UINT8 bUnclassifiedPHSRule; - -}S_CLASSIFIER_ENTRY; - - -typedef struct _S_CLASSIFIER_TABLE -{ - B_UINT16 uiTotalClassifiers; - S_CLASSIFIER_ENTRY stActivePhsRulesList[MAX_PHSRULE_PER_SF]; - S_CLASSIFIER_ENTRY stOldPhsRulesList[MAX_PHSRULE_PER_SF]; - B_UINT16 uiOldestPhsRuleIndex; - -}S_CLASSIFIER_TABLE; - - -typedef struct _S_SERVICEFLOW_ENTRY -{ - B_UINT8 bUsed; - B_UINT16 uiVcid; - S_CLASSIFIER_TABLE *pstClassifierTable; -}S_SERVICEFLOW_ENTRY; - -typedef struct _S_SERVICEFLOW_TABLE -{ - B_UINT16 uiTotalServiceFlows; - S_SERVICEFLOW_ENTRY stSFList[MAX_SERVICEFLOWS]; - -}S_SERVICEFLOW_TABLE; - - -typedef struct _PHS_DEVICE_EXTENSION -{ - /* PHS Specific data*/ - S_SERVICEFLOW_TABLE *pstServiceFlowPhsRulesTable; - void *CompressedTxBuffer; - void *UnCompressedRxBuffer; -}PHS_DEVICE_EXTENSION,*PPHS_DEVICE_EXTENSION; - +}; + +struct bcm_phs_classifier_entry { + u8 bUsed; + u16 uiClassifierRuleId; + u8 u8PHSI; + struct bcm_phs_rule *pstPhsRule; + u8 bUnclassifiedPHSRule; +}; + +struct bcm_phs_classifier_table { + u16 uiTotalClassifiers; + struct bcm_phs_classifier_entry stActivePhsRulesList[MAX_PHSRULE_PER_SF]; + struct bcm_phs_classifier_entry stOldPhsRulesList[MAX_PHSRULE_PER_SF]; + u16 uiOldestPhsRuleIndex; +}; + +struct bcm_phs_entry { + u8 bUsed; + u16 uiVcid; + struct bcm_phs_classifier_table *pstClassifierTable; +}; + +struct bcm_phs_table { + u16 uiTotalServiceFlows; + struct bcm_phs_entry stSFList[MAX_SERVICEFLOWS]; +}; + +struct bcm_phs_extension { + /* PHS Specific data */ + struct bcm_phs_table *pstServiceFlowPhsRulesTable; + void *CompressedTxBuffer; + void *UnCompressedRxBuffer; +}; #endif diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index 6dc0bbc..7028bc9 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -1,24 +1,24 @@ #include "headers.h" -static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId, struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId, struct bcm_phs_entry *pstServiceFlowEntry, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI); +static UINT CreateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, enum bcm_phs_classifier_context eClsContext,B_UINT8 u8AssociatedPHSI); -static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI); +static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_entry *pstClassifierEntry, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); -static BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule); +static BOOLEAN ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule); -static BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule); +static BOOLEAN DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule); -static UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry); +static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable,B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_classifier_entry **ppstClassifierEntry); -static UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule); +static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable,B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_rule **ppstPhsRule); -static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable); +static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable); -static int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf, +static int phs_compress(struct bcm_phs_rule *phs_members, unsigned char *in_buf, unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size ); @@ -26,7 +26,7 @@ static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buff unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size ); static int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\ - S_PHS_RULE *phs_rules,UINT *header_size); + struct bcm_phs_rule *phs_rules, UINT *header_size); static ULONG PhsCompress(void* pvContext, @@ -291,17 +291,17 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen) // TRUE(1) -If allocation of memory was success full. // FALSE -If allocation of memory fails. //----------------------------------------------------------------------------- -int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter *Adapter) +int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adapter *Adapter) { int i; - S_SERVICEFLOW_TABLE *pstServiceFlowTable; + struct bcm_phs_table *pstServiceFlowTable; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function "); if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable) return -EINVAL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = - kzalloc(sizeof(S_SERVICEFLOW_TABLE), GFP_KERNEL); + kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL); if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { @@ -312,8 +312,8 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; for(i=0;i<MAX_SERVICEFLOWS;i++) { - S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i]; - sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL); + struct bcm_phs_entry sServiceFlow = pstServiceFlowTable->stSFList[i]; + sServiceFlow.pstClassifierTable = kzalloc(sizeof(struct bcm_phs_classifier_table), GFP_KERNEL); if(!sServiceFlow.pstClassifierTable) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); @@ -351,7 +351,7 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter } -int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt) +int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt) { if(pPHSDeviceExt->pstServiceFlowPhsRulesTable) { @@ -381,7 +381,7 @@ Arguments: IN void* pvContext - PHS Driver Specific Context IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. - IN S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. + IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. Return Value: @@ -392,17 +392,17 @@ Return Value: ULONG PhsUpdateClassifierRule(IN void* pvContext, IN B_UINT16 uiVcid , IN B_UINT16 uiClsId , - IN S_PHS_RULE *psPhsRule, + IN struct bcm_phs_rule *psPhsRule, IN B_UINT8 u8AssociatedPHSI) { ULONG lStatus =0; UINT nSFIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS With Corr2 Changes \n"); @@ -460,12 +460,12 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) { ULONG lStatus =0; UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n"); @@ -495,7 +495,7 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI) if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, - sizeof(S_CLASSIFIER_ENTRY)); + sizeof(struct bcm_phs_classifier_entry)); } } } @@ -526,10 +526,10 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 { ULONG lStatus =0; UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext; if(pDeviceExtension) { @@ -554,7 +554,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 kfree(pstClassifierEntry->pstPhsRule); } - memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, @@ -563,7 +563,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { kfree(pstClassifierEntry->pstPhsRule); - memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } } return lStatus; @@ -590,10 +590,10 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) ULONG lStatus =0; UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n"); if(pDeviceExtension) @@ -624,7 +624,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex] .pstPhsRule = NULL; } - memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) { if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] @@ -638,7 +638,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid) pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex] .pstPhsRule = NULL; } - memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY)); + memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); } } pstServiceFlowEntry->bUsed = FALSE; @@ -680,15 +680,15 @@ ULONG PhsCompress(IN void* pvContext, OUT UINT *pNewHeaderSize ) { UINT nSFIndex =0, nClsidIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; + struct bcm_phs_rule *pstPhsRule = NULL; ULONG lStatus =0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext; if(pDeviceExtension == NULL) @@ -775,12 +775,12 @@ ULONG PhsDeCompress(IN void* pvContext, OUT UINT *pOutHeaderSize ) { UINT nSFIndex =0, nPhsRuleIndex =0 ; - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_rule *pstPhsRule = NULL; UINT phsi; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - PPHS_DEVICE_EXTENSION pDeviceExtension= - (PPHS_DEVICE_EXTENSION)pvContext; + struct bcm_phs_extension *pDeviceExtension= + (struct bcm_phs_extension *)pvContext; *pInHeaderSize = 0; @@ -844,7 +844,7 @@ ULONG PhsDeCompress(IN void* pvContext, // Does not return any value. //----------------------------------------------------------------------------- -static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable) +static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable) { int i,j; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -854,9 +854,9 @@ static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTa { for(i=0;i<MAX_SERVICEFLOWS;i++) { - S_SERVICEFLOW_ENTRY stServiceFlowEntry = + struct bcm_phs_entry stServiceFlowEntry = psServiceFlowRulesTable->stSFList[i]; - S_CLASSIFIER_TABLE *pstClassifierRulesTable = + struct bcm_phs_classifier_table *pstClassifierRulesTable = stServiceFlowEntry.pstClassifierTable; if(pstClassifierRulesTable) @@ -898,7 +898,7 @@ static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTa -static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) +static BOOLEAN ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule) { if(psPhsRule) { @@ -927,8 +927,8 @@ static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule) } } -UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable, - IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry) +UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, + IN B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry) { int i; for(i=0;i<MAX_SERVICEFLOWS;i++) @@ -948,12 +948,12 @@ UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable, } -UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, - IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, - OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry) +UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, + IN B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, + OUT struct bcm_phs_classifier_entry **ppstClassifierEntry) { int i; - S_CLASSIFIER_ENTRY *psClassifierRules = NULL; + struct bcm_phs_classifier_entry *psClassifierRules = NULL; for(i=0;i<MAX_PHSRULE_PER_SF;i++) { @@ -981,12 +981,12 @@ UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, return PHS_INVALID_TABLE_INDEX; } -static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, - IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, - OUT S_PHS_RULE **ppstPhsRule) +static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, + IN B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, + OUT struct bcm_phs_rule **ppstPhsRule) { int i; - S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; + struct bcm_phs_classifier_entry *pstClassifierRule = NULL; for(i=0;i<MAX_PHSRULE_PER_SF;i++) { if(eClsContext == eActiveClassifierRuleContext) @@ -1013,11 +1013,11 @@ static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable, } UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId, - IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule, + IN struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI) { - S_CLASSIFIER_TABLE *psaClassifiertable = NULL; + struct bcm_phs_classifier_table *psaClassifiertable = NULL; UINT uiStatus = 0; int iSfIndex; BOOLEAN bFreeEntryFound =FALSE; @@ -1050,13 +1050,13 @@ UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId, } UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry, - S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI) + IN B_UINT16 uiClsId,IN struct bcm_phs_entry *pstServiceFlowEntry, + struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI) { - S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL; + struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; UINT uiStatus =PHS_SUCCESS; UINT nClassifierIndex = 0; - S_CLASSIFIER_TABLE *psaClassifiertable = NULL; + struct bcm_phs_classifier_table *psaClassifiertable = NULL; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; @@ -1141,12 +1141,12 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, } static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, - S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, - E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI) + struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, + enum bcm_phs_classifier_context eClsContext,B_UINT8 u8AssociatedPHSI) { UINT iClassifierIndex = 0; BOOLEAN bFreeEntryFound = FALSE; - S_CLASSIFIER_ENTRY *psClassifierRules = NULL; + struct bcm_phs_classifier_entry *psClassifierRules = NULL; UINT nStatus = PHS_SUCCESS; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule"); @@ -1227,7 +1227,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, { if(psClassifierRules->pstPhsRule == NULL) { - psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL); + psClassifierRules->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule),GFP_KERNEL); if(NULL == psClassifierRules->pstPhsRule) return ERR_PHSRULE_MEMALLOC_FAIL; @@ -1240,7 +1240,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, /* Update The PHS rule */ memcpy(psClassifierRules->pstPhsRule, - psPhsRule, sizeof(S_PHS_RULE)); + psPhsRule, sizeof(struct bcm_phs_rule)); } else { @@ -1252,11 +1252,11 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, - IN S_CLASSIFIER_ENTRY *pstClassifierEntry, - S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule, + IN struct bcm_phs_classifier_entry *pstClassifierEntry, + struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI) { - S_PHS_RULE *pstAddPhsRule = NULL; + struct bcm_phs_rule *pstAddPhsRule = NULL; UINT nPhsRuleIndex = 0; BOOLEAN bPHSRuleOrphaned = FALSE; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -1281,13 +1281,13 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId if(FALSE == bPHSRuleOrphaned) { - pstClassifierEntry->pstPhsRule = kmalloc(sizeof(S_PHS_RULE), GFP_KERNEL); + pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL); if(NULL == pstClassifierEntry->pstPhsRule) { return ERR_PHSRULE_MEMALLOC_FAIL; } } - memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE)); + memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule)); } else @@ -1312,7 +1312,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, } -static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule) +static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule) { if(pstPhsRule==NULL) return FALSE; @@ -1331,14 +1331,14 @@ static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifi } } -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) { int i,j,k,l; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n"); for(i=0;i<MAX_SERVICEFLOWS;i++) { - S_SERVICEFLOW_ENTRY stServFlowEntry = + struct bcm_phs_entry stServFlowEntry = pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; if(stServFlowEntry.bUsed) { @@ -1346,7 +1346,7 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) { for(l=0;l<2;l++) { - S_CLASSIFIER_ENTRY stClsEntry; + struct bcm_phs_classifier_entry stClsEntry; if(l==0) { stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j]; @@ -1408,10 +1408,10 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension) //----------------------------------------------------------------------------- int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, - S_PHS_RULE *decomp_phs_rules,UINT *header_size) + struct bcm_phs_rule *decomp_phs_rules, UINT *header_size) { int phss,size=0; - S_PHS_RULE *tmp_memb; + struct bcm_phs_rule *tmp_memb; int bit,i=0; unsigned char *phsf,*phsm; int in_buf_len = *header_size-1; @@ -1490,7 +1490,7 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf, // size-The number of bytes copied into the output buffer i.e dynamic fields // 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails. //----------------------------------------------------------------------------- -static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf +static int phs_compress(struct bcm_phs_rule *phs_rule, unsigned char *in_buf ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size) { unsigned char *old_addr = out_buf; diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h index b5f2115..82d8682 100644 --- a/drivers/staging/bcm/PHSModule.h +++ b/drivers/staging/bcm/PHSModule.h @@ -22,15 +22,15 @@ void DumpDataPacketHeader(PUCHAR pPkt); void DumpFullPacket(UCHAR *pBuf,UINT nPktLen); -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); -int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,struct bcm_mini_adapter *Adapter); +int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,struct bcm_mini_adapter *Adapter); -int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt); +int PhsCleanup(struct bcm_phs_extension *pPHSDeviceExt); //Utility Functions -ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI ); +ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId, struct bcm_phs_rule *psPhsRule,B_UINT8 u8AssociatedPHSI ); ULONG PhsDeletePHSRule(void* pvContext,B_UINT16 uiVcid,B_UINT8 u8PHSI); @@ -39,12 +39,12 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsI ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ; -BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule); +BOOLEAN ValidatePHSRule(struct bcm_phs_rule *psPhsRule); -UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry); +UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable,B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry); -void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension); +void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); #endif diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h index 562d4dd..9818128 100644 --- a/drivers/staging/bcm/Protocol.h +++ b/drivers/staging/bcm/Protocol.h @@ -1,98 +1,83 @@ /************************************ -* Protocol.h +* Protocol.h *************************************/ #ifndef __PROTOCOL_H__ #define __PROTOCOL_H__ - -#define IPV4 4 -#define IPV6 6 - +#define IPV4 4 +#define IPV6 6 struct ArpHeader { - struct arphdr arp; - unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ - unsigned char ar_sip[4]; /* sender IP address */ - unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ - unsigned char ar_tip[4]; /* target IP address */ -}/*__attribute__((packed))*/; - - -struct TransportHeaderT -{ - union - { + struct arphdr arp; + unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ + unsigned char ar_sip[4]; /* sender IP address */ + unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ + unsigned char ar_tip[4]; /* target IP address */ +}; + +struct bcm_transport_header { + union { struct udphdr uhdr; struct tcphdr thdr; }; -} __attribute__((packed)); -typedef struct TransportHeaderT xporthdr; - +} __packed; -typedef enum _E_NWPKT_IPFRAME_TYPE -{ +enum bcm_ip_frame_type { eNonIPPacket, eIPv4Packet, eIPv6Packet -}E_NWPKT_IPFRAME_TYPE; +}; -typedef enum _E_NWPKT_ETHFRAME_TYPE -{ +enum bcm_eth_frame_type { eEthUnsupportedFrame, eEth802LLCFrame, eEth802LLCSNAPFrame, eEth802QVLANFrame, eEthOtherFrame -} E_NWPKT_ETHFRAME_TYPE; - -typedef struct _S_ETHCS_PKT_INFO -{ - E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType; - E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType; - USHORT usEtherType; - UCHAR ucDSAP; -}S_ETHCS_PKT_INFO,*PS_ETHCS_PKT_INFO; - -typedef struct _ETH_CS_802_Q_FRAME -{ +}; + +struct bcm_eth_packet_info { + enum bcm_ip_frame_type eNwpktIPFrameType; + enum bcm_eth_frame_type eNwpktEthFrameType; + unsigned short usEtherType; + unsigned char ucDSAP; +}; + +struct bcm_eth_q_frame { struct bcm_eth_header EThHdr; - USHORT UserPriority:3; - USHORT CFI:1; - USHORT VLANID:12; - USHORT EthType; -} __attribute__((packed)) ETH_CS_802_Q_FRAME; - -typedef struct _ETH_CS_802_LLC_FRAME -{ + unsigned short UserPriority:3; + unsigned short CFI:1; + unsigned short VLANID:12; + unsigned short EthType; +} __packed; + +struct bcm_eth_llc_frame { struct bcm_eth_header EThHdr; unsigned char DSAP; unsigned char SSAP; unsigned char Control; -}__attribute__((packed)) ETH_CS_802_LLC_FRAME; +} __packed; -typedef struct _ETH_CS_802_LLC_SNAP_FRAME -{ +struct bcm_eth_llc_snap_frame { struct bcm_eth_header EThHdr; unsigned char DSAP; unsigned char SSAP; unsigned char Control; unsigned char OUI[3]; unsigned short usEtherType; -} __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME; +} __packed; -typedef struct _ETH_CS_ETH2_FRAME -{ +struct bcm_ethernet2_frame { struct bcm_eth_header EThHdr; -} __attribute__((packed)) ETH_CS_ETH2_FRAME; +} __packed; #define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) -#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) -#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) +#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) +#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) -//Per SF CS Specification Encodings -typedef enum _E_SERVICEFLOW_CS_SPEC_ -{ - eCSSpecUnspecified =0, +/* Per SF CS Specification Encodings */ +enum bcm_spec_encoding { + eCSSpecUnspecified = 0, eCSPacketIPV4, eCSPacketIPV6, eCS802_3PacketEthernet, @@ -102,50 +87,42 @@ typedef enum _E_SERVICEFLOW_CS_SPEC_ eCSPacketIPV4Over802_1QVLAN, eCSPacketIPV6Over802_1QVLAN, eCSPacketUnsupported -}E_SERVICEFLOW_CS_SPEC; - - -#define IP6_HEADER_LEN 40 - -#define IP_VERSION(byte) (((byte&0xF0)>>4)) - +}; +#define IP6_HEADER_LEN 40 +#define IP_VERSION(byte) (((byte&0xF0)>>4)) #define MAC_ADDRESS_SIZE 6 -#define ETH_AND_IP_HEADER_LEN 14 + 20 -#define L4_SRC_PORT_LEN 2 -#define L4_DEST_PORT_LEN 2 - - - -#define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN - -#define ETH_ARP_FRAME 0x806 -#define ETH_IPV4_FRAME 0x800 -#define ETH_IPV6_FRAME 0x86DD -#define UDP 0x11 -#define TCP 0x06 - -#define ARP_OP_REQUEST 0x01 -#define ARP_OP_REPLY 0x02 -#define ARP_PKT_SIZE 60 - -// This is the format for the TCP packet header -typedef struct _TCP_HEADER -{ - USHORT usSrcPort; - USHORT usDestPort; - ULONG ulSeqNumber; - ULONG ulAckNumber; - UCHAR HeaderLength; - UCHAR ucFlags; - USHORT usWindowsSize; - USHORT usChkSum; - USHORT usUrgetPtr; -} TCP_HEADER,*PTCP_HEADER; -#define TCP_HEADER_LEN sizeof(TCP_HEADER) -#define TCP_ACK 0x10 //Bit 4 in tcpflags field. +#define ETH_AND_IP_HEADER_LEN (14 + 20) +#define L4_SRC_PORT_LEN 2 +#define L4_DEST_PORT_LEN 2 +#define CTRL_PKT_LEN (8 + ETH_AND_IP_HEADER_LEN) + +#define ETH_ARP_FRAME 0x806 +#define ETH_IPV4_FRAME 0x800 +#define ETH_IPV6_FRAME 0x86DD +#define UDP 0x11 +#define TCP 0x06 + +#define ARP_OP_REQUEST 0x01 +#define ARP_OP_REPLY 0x02 +#define ARP_PKT_SIZE 60 + +/* This is the format for the TCP packet header */ +struct bcm_tcp_header { + unsigned short usSrcPort; + unsigned short usDestPort; + unsigned long ulSeqNumber; + unsigned long ulAckNumber; + unsigned char HeaderLength; + unsigned char ucFlags; + unsigned short usWindowsSize; + unsigned short usChkSum; + unsigned short usUrgetPtr; +}; + +#define TCP_HEADER_LEN sizeof(struct bcm_tcp_header) +#define TCP_ACK 0x10 /* Bit 4 in tcpflags field. */ #define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4) - -#endif //__PROTOCOL_H__ +#endif /* __PROTOCOL_H__ */ diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h index 90dbe0f..2a673b1 100644 --- a/drivers/staging/bcm/Prototypes.h +++ b/drivers/staging/bcm/Prototypes.h @@ -33,9 +33,9 @@ INT SearchSfid(struct bcm_mini_adapter *Adapter,UINT uiSfid); USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb); -BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); -BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); +bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); +bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort); +bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol); INT SetupNextSend(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/ diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 1b857bd..8d142a5 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,8 +4,8 @@ This file contains the routines related to Quality of Service. */ #include "headers.h" -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo); -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); +static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, struct bcm_classifier_rule *pstClassifierRule ); @@ -117,7 +117,7 @@ BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfSer * * Returns - TRUE(If address matches) else FAIL. ****************************************************************************/ -BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol) +bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol) { UCHAR ucLoopIndex=0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -146,7 +146,7 @@ BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProt * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort) +bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort) { UCHAR ucLoopIndex=0; @@ -178,7 +178,7 @@ BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrc * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort) +bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort) { UCHAR ucLoopIndex=0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); @@ -208,12 +208,12 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, struct bcm_classifier_rule *pstClassifierRule) { - xporthdr *xprt_hdr=NULL; + struct bcm_transport_header *xprt_hdr = NULL; BOOLEAN bClassificationSucceed=FALSE; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); - xprt_hdr=(xporthdr *)((PUCHAR)iphd + sizeof(struct iphdr)); + xprt_hdr=(struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr)); do { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", @@ -446,7 +446,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) { INT uiLoopIndex=0; struct bcm_classifier_rule *pstClassifierRule = NULL; - S_ETHCS_PKT_INFO stEthCsPktInfo; + struct bcm_eth_packet_info stEthCsPktInfo; PVOID pvEThPayload = NULL; struct iphdr *pIpHeader = NULL; INT uiSfIndex=0; @@ -454,7 +454,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) BOOLEAN bFragmentedPkt=FALSE,bClassificationSucceed=FALSE; USHORT usCurrFragment =0; - PTCP_HEADER pTcpHeader; + struct bcm_tcp_header *pTcpHeader; UCHAR IpHeaderLength; UCHAR TcpHeaderLength; @@ -467,32 +467,32 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) case eEth802LLCFrame: { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n"); - pIpHeader = pvEThPayload + sizeof(ETH_CS_802_LLC_FRAME); + pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame); break; } case eEth802LLCSNAPFrame: { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n"); - pIpHeader = pvEThPayload + sizeof(ETH_CS_802_LLC_SNAP_FRAME); + pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame); break; } case eEth802QVLANFrame: { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n"); - pIpHeader = pvEThPayload + sizeof(ETH_CS_802_Q_FRAME); + pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame); break; } case eEthOtherFrame: { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n"); - pIpHeader = pvEThPayload + sizeof(ETH_CS_ETH2_FRAME); + pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; } default: { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n"); - pIpHeader = pvEThPayload + sizeof(ETH_CS_ETH2_FRAME); + pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; } } @@ -614,7 +614,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) if((TCP == pIpHeader->protocol ) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len) ) { IpHeaderLength = pIpHeader->ihl; - pTcpHeader = (PTCP_HEADER)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); + pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); if((pTcpHeader->ucFlags & TCP_ACK) && @@ -683,7 +683,7 @@ static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifie return TRUE; } -static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if((pstClassifierRule->ucEtherTypeLen==0)|| @@ -718,7 +718,7 @@ static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRul } -static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo) +static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { BOOLEAN bClassificationSucceed = FALSE; USHORT usVLANID; @@ -769,7 +769,7 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb, - PS_ETHCS_PKT_INFO pstEthCsPktInfo, + struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport) { @@ -802,7 +802,7 @@ static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* } static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, - PS_ETHCS_PKT_INFO pstEthCsPktInfo) + struct bcm_eth_packet_info *pstEthCsPktInfo) { USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype); @@ -815,7 +815,7 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, { //802.1Q VLAN Header pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; - u16Etype = ((ETH_CS_802_Q_FRAME*)pvEthPayload)->EthType; + u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType; //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority } else @@ -830,12 +830,12 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, //802.2 LLC BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame \n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; - pstEthCsPktInfo->ucDSAP = ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->DSAP; - if(pstEthCsPktInfo->ucDSAP == 0xAA && ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->SSAP == 0xAA) + pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; + if(pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; - u16Etype = ((ETH_CS_802_LLC_SNAP_FRAME*)pvEthPayload)->usEtherType; + u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; } } if(u16Etype == ETHERNET_FRAMETYPE_IPV4) diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index 3c5f4a5..f55300d 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -11,11 +11,11 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs) { - S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL; - S_PHS_RULE *pstPhsRule = NULL; - S_CLASSIFIER_TABLE *pstClassifierTable = NULL; - S_CLASSIFIER_ENTRY *pstClassifierRule = NULL; - PPHS_DEVICE_EXTENSION pDeviceExtension = (PPHS_DEVICE_EXTENSION) &Adapter->stBCMPhsContext; + struct bcm_phs_entry *pstServiceFlowEntry = NULL; + struct bcm_phs_rule *pstPhsRule = NULL; + struct bcm_phs_classifier_table *pstClassifierTable = NULL; + struct bcm_phs_classifier_entry *pstClassifierRule = NULL; + struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext; UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; @@ -70,7 +70,7 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m memcpy(&pstHostMibs-> astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, sizeof(S_PHS_RULE)); + &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule)); nPhsTableIndex++; } diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c index 252a1b3..05a948a 100644 --- a/drivers/staging/bcm/led_control.c +++ b/drivers/staging/bcm/led_control.c @@ -24,7 +24,7 @@ BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios) } static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex, - ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate) + ULONG timeout, INT num_of_time, enum bcm_led_events currdriverstate) { int Status = STATUS_SUCCESS; BOOLEAN bInfinite = FALSE; @@ -97,7 +97,7 @@ static INT ScaleRateofTransfer(ULONG rate) static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx, UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex, - LedEventInfo_t currdriverstate) + enum bcm_led_events currdriverstate) { /* Initial values of TX and RX packets */ ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0; @@ -607,7 +607,7 @@ static VOID LedGpioInit(struct bcm_mini_adapter *Adapter) static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx, UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex, - LedEventInfo_t currdriverstate) + enum bcm_led_events currdriverstate) { UINT uiIndex = 0; @@ -651,7 +651,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) UCHAR GPIO_num = 0; UCHAR uiLedIndex = 0; UINT uiResetValue = 0; - LedEventInfo_t currdriverstate = 0; + enum bcm_led_events currdriverstate = 0; ulong timeout = 0; INT Status = 0; diff --git a/drivers/staging/bcm/led_control.h b/drivers/staging/bcm/led_control.h index ed8fbc0..bae40e2 100644 --- a/drivers/staging/bcm/led_control.h +++ b/drivers/staging/bcm/led_control.h @@ -1,102 +1,84 @@ #ifndef _LED_CONTROL_H #define _LED_CONTROL_H -/*************************TYPE DEF**********************/ -#define NUM_OF_LEDS 4 - +#define NUM_OF_LEDS 4 #define DSD_START_OFFSET 0x0200 #define EEPROM_VERSION_OFFSET 0x020E #define EEPROM_HW_PARAM_POINTER_ADDRESS 0x0218 #define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5 0x0220 #define GPIO_SECTION_START_OFFSET 0x03 - -#define COMPATIBILITY_SECTION_LENGTH 42 -#define COMPATIBILITY_SECTION_LENGTH_MAP5 84 - - -#define EEPROM_MAP5_MAJORVERSION 5 -#define EEPROM_MAP5_MINORVERSION 0 - - +#define COMPATIBILITY_SECTION_LENGTH 42 +#define COMPATIBILITY_SECTION_LENGTH_MAP5 84 +#define EEPROM_MAP5_MAJORVERSION 5 +#define EEPROM_MAP5_MINORVERSION 0 #define MAX_NUM_OF_BLINKS 10 #define NUM_OF_GPIO_PINS 16 - #define DISABLE_GPIO_NUM 0xFF #define EVENT_SIGNALED 1 - #define MAX_FILE_NAME_BUFFER_SIZE 100 -#define TURN_ON_LED(GPIO, index) do { \ - UINT gpio_val = GPIO; \ - (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0); - -#define TURN_OFF_LED(GPIO, index) do { \ - UINT gpio_val = GPIO; \ - (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0); - -#define B_ULONG32 unsigned long - -/*******************************************************/ - - -typedef enum _LEDColors{ - RED_LED = 1, - BLUE_LED = 2, - YELLOW_LED = 3, - GREEN_LED = 4 -} LEDColors; /*Enumerated values of different LED types*/ - -typedef enum LedEvents { - SHUTDOWN_EXIT = 0x00, - DRIVER_INIT = 0x1, - FW_DOWNLOAD = 0x2, - FW_DOWNLOAD_DONE = 0x4, - NO_NETWORK_ENTRY = 0x8, - NORMAL_OPERATION = 0x10, - LOWPOWER_MODE_ENTER = 0x20, - IDLEMODE_CONTINUE = 0x40, - IDLEMODE_EXIT = 0x80, - LED_THREAD_INACTIVE = 0x100, /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */ - LED_THREAD_ACTIVE = 0x200, /* Makes the LED Thread Active back. */ - DRIVER_HALT = 0xff -} LedEventInfo_t; /* Enumerated values of different driver states */ +#define TURN_ON_LED(GPIO, index) do { \ + unsigned int gpio_val = GPIO; \ + (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ + } while (0) + +#define TURN_OFF_LED(GPIO, index) do { \ + unsigned int gpio_val = GPIO; \ + (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \ + wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \ + } while (0) + +enum bcm_led_colors { + RED_LED = 1, + BLUE_LED = 2, + YELLOW_LED = 3, + GREEN_LED = 4 +}; + +enum bcm_led_events { + SHUTDOWN_EXIT = 0x00, + DRIVER_INIT = 0x1, + FW_DOWNLOAD = 0x2, + FW_DOWNLOAD_DONE = 0x4, + NO_NETWORK_ENTRY = 0x8, + NORMAL_OPERATION = 0x10, + LOWPOWER_MODE_ENTER = 0x20, + IDLEMODE_CONTINUE = 0x40, + IDLEMODE_EXIT = 0x80, + LED_THREAD_INACTIVE = 0x100, /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */ + LED_THREAD_ACTIVE = 0x200, /* Makes the LED Thread Active back. */ + DRIVER_HALT = 0xff +}; /* Enumerated values of different driver states */ /* * Structure which stores the information of different LED types * and corresponding LED state information of driver states */ -typedef struct LedStateInfo_t { - UCHAR LED_Type; /* specify GPIO number - use 0xFF if not used */ - UCHAR LED_On_State; /* Bits set or reset for different states */ - UCHAR LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ - UCHAR GPIO_Num; - UCHAR BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */ -} LEDStateInfo, *pLEDStateInfo; - - -typedef struct _LED_INFO_STRUCT { - LEDStateInfo LEDState[NUM_OF_LEDS]; - BOOLEAN bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target*/ - BOOLEAN bIdle_led_off; - wait_queue_head_t notify_led_event; +struct bcm_led_state_info { + unsigned char LED_Type; /* specify GPIO number - use 0xFF if not used */ + unsigned char LED_On_State; /* Bits set or reset for different states */ + unsigned char LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ + unsigned char GPIO_Num; + unsigned char BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */ +}; + +struct bcm_led_info { + struct bcm_led_state_info LEDState[NUM_OF_LEDS]; + bool bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target */ + bool bIdle_led_off; + wait_queue_head_t notify_led_event; wait_queue_head_t idleModeSyncEvent; - struct task_struct *led_cntrl_threadid; - int led_thread_running; - BOOLEAN bLedInitDone; + struct task_struct *led_cntrl_threadid; + int led_thread_running; + bool bLedInitDone; +}; -} LED_INFO_STRUCT, *PLED_INFO_STRUCT; /* LED Thread state. */ -#define BCM_LED_THREAD_DISABLED 0 /* LED Thread is not running. */ -#define BCM_LED_THREAD_RUNNING_ACTIVELY 1 /* LED thread is running. */ -#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /*LED thread has been put on hold*/ - - +#define BCM_LED_THREAD_DISABLED 0 /* LED Thread is not running. */ +#define BCM_LED_THREAD_RUNNING_ACTIVELY 1 /* LED thread is running. */ +#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /* LED thread has been put on hold */ #endif - diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index eab676f..e6152f4 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -12,7 +12,7 @@ static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsi static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter); static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter); static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter); -static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter); +static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter); static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal); @@ -472,7 +472,7 @@ static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter, static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter) { if (IsFlash2x(Adapter)) - return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER); + return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); else return 32 * 1024; } @@ -1978,7 +1978,7 @@ int BeceemNVMWrite(struct bcm_mini_adapter *Adapter, int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize) { int Status = -1; - FLASH_CS_INFO sFlashCsInfo = {0}; + struct bcm_flash_cs_info sFlashCsInfo = {0}; unsigned int uiTemp = 0; unsigned int uiSectorSig = 0; unsigned int uiCurrentSectorSize = 0; @@ -2228,20 +2228,20 @@ int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL"); return -EINVAL; } - psAdapter->psFlashCSInfo = (PFLASH_CS_INFO)kzalloc(sizeof(FLASH_CS_INFO), GFP_KERNEL); + psAdapter->psFlashCSInfo = (struct bcm_flash_cs_info *)kzalloc(sizeof(struct bcm_flash_cs_info), GFP_KERNEL); if (psAdapter->psFlashCSInfo == NULL) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 1.x"); return -ENOMEM; } - psAdapter->psFlash2xCSInfo = (PFLASH2X_CS_INFO)kzalloc(sizeof(FLASH2X_CS_INFO), GFP_KERNEL); + psAdapter->psFlash2xCSInfo = (struct bcm_flash2x_cs_info *)kzalloc(sizeof(struct bcm_flash2x_cs_info), GFP_KERNEL); if (!psAdapter->psFlash2xCSInfo) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 2.x"); kfree(psAdapter->psFlashCSInfo); return -ENOMEM; } - psAdapter->psFlash2xVendorInfo = (PFLASH2X_VENDORSPECIFIC_INFO)kzalloc(sizeof(FLASH2X_VENDORSPECIFIC_INFO), GFP_KERNEL); + psAdapter->psFlash2xVendorInfo = (struct bcm_flash2x_vendor_info *)kzalloc(sizeof(struct bcm_flash2x_vendor_info), GFP_KERNEL); if (!psAdapter->psFlash2xVendorInfo) { BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate Vendor Info Memory for Flash 2.x"); kfree(psAdapter->psFlashCSInfo); @@ -2264,7 +2264,7 @@ int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) return STATUS_SUCCESS; } -static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bcm_mini_adapter *Adapter) +static int BcmDumpFlash2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo, struct bcm_mini_adapter *Adapter) { unsigned int Index = 0; @@ -2324,7 +2324,7 @@ static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bc return STATUS_SUCCESS; } -static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo) +static int ConvertEndianOf2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo) { unsigned int Index = 0; @@ -2381,7 +2381,7 @@ static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo) return STATUS_SUCCESS; } -static int ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo) +static int ConvertEndianOfCSStructure(struct bcm_flash_cs_info *psFlashCSInfo) { /* unsigned int Index = 0; */ psFlashCSInfo->MagicNumber = ntohl(psFlashCSInfo->MagicNumber); @@ -2446,7 +2446,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) switch (i) { case DSD0: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS; else @@ -2454,7 +2454,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) break; case DSD1: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS; else @@ -2462,7 +2462,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) break; case DSD2: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) && + if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS; else @@ -2509,7 +2509,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) { - /* FLASH_CS_INFO sFlashCsInfo = {0}; */ + /* struct bcm_flash_cs_info sFlashCsInfo = {0}; */ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) unsigned int value; @@ -2522,8 +2522,8 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) Adapter->uiFlashBaseAdd = 0; Adapter->ulFlashCalStart = 0; - memset(Adapter->psFlashCSInfo, 0 , sizeof(FLASH_CS_INFO)); - memset(Adapter->psFlash2xCSInfo, 0 , sizeof(FLASH2X_CS_INFO)); + memset(Adapter->psFlashCSInfo, 0 , sizeof(struct bcm_flash_cs_info)); + memset(Adapter->psFlash2xCSInfo, 0 , sizeof(struct bcm_flash2x_cs_info)); if (!Adapter->bDDRInitDone) { value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; @@ -2551,7 +2551,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion); if (uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) { - BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(FLASH_CS_INFO)); + BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash_cs_info)); ConvertEndianOfCSStructure(Adapter->psFlashCSInfo); Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart); @@ -2576,7 +2576,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF; } else { if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL, - Adapter->ulFlashControlSectionStart, sizeof(FLASH2X_CS_INFO))) { + Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash2x_cs_info))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure\n"); return STATUS_FAILURE; } @@ -2629,7 +2629,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) * */ -static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter) +static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter) { unsigned int uiData = 0; @@ -2810,6 +2810,7 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x case CONTROL_SECTION: /* Not Clear So Putting failure. confirm and fix it. */ SectEndOffset = STATUS_FAILURE; + break; case ISO_IMAGE1_PART2: if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End != UNINIT_PTR_IN_CS) SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End); @@ -3101,7 +3102,7 @@ static int BcmDumpFlash2xSectionBitMap(struct bcm_flash2x_bitmap *psFlash2xBitMa int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap) { - PFLASH2X_CS_INFO psFlash2xCSInfo = Adapter->psFlash2xCSInfo; + struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo; enum bcm_flash2x_section_val uiHighestPriDSD = 0; enum bcm_flash2x_section_val uiHighestPriISO = 0; BOOLEAN SetActiveDSDDone = FALSE; @@ -3354,8 +3355,8 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti unsigned int SectImagePriority = 0; int Status = STATUS_SUCCESS; - /* DSD_HEADER sDSD = {0}; - * ISO_HEADER sISO = {0}; + /* struct bcm_dsd_header sDSD = {0}; + * struct bcm_iso_header sISO = {0}; */ int HighestPriDSD = 0 ; int HighestPriISO = 0; @@ -3391,7 +3392,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriISO, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3416,7 +3417,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, eFlash2xSectVal, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3452,7 +3453,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3472,7 +3473,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3492,7 +3493,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti Status = BcmFlash2xBulkWrite(Adapter, &SectImagePriority, eFlash2xSectVal, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), SIGNATURE_SIZE, TRUE); if (Status) { @@ -3550,7 +3551,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section Status = BcmFlash2xBulkRead(Adapter, &ISOLength, sCopySectStrut.SrcSection, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageSize), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize), 4); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n"); @@ -3561,7 +3562,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section if (ISOLength % Adapter->uiSectorSize) ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize); - sigOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber); + sigOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL); @@ -3846,7 +3847,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio unsigned int uiSignature = 0; unsigned int uiOffset = 0; - /* DSD_HEADER dsdHeader = {0}; */ + /* struct bcm_dsd_header dsdHeader = {0}; */ if (Adapter->bSigCorrupted == FALSE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is not corrupted by driver, hence not restoring\n"); return STATUS_SUCCESS; @@ -3863,7 +3864,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER); uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader; - uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber); + uiOffset += FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber); if ((ReadDSDSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Corrupted Pattern is not there. Hence won't write sig"); @@ -3872,7 +3873,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) { uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER); /* uiOffset = 0; */ - uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber); + uiOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); if ((ReadISOSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Currupted Pattern is not there. Hence won't write sig"); return STATUS_FAILURE; @@ -4141,14 +4142,14 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) { /* offset from the sector boundary having the header map */ offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize; - HeaderSizeToProtect = sizeof(DSD_HEADER); + HeaderSizeToProtect = sizeof(struct bcm_dsd_header); bHasHeader = TRUE; } if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) || uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) { offsetToProtect = 0; - HeaderSizeToProtect = sizeof(ISO_HEADER); + HeaderSizeToProtect = sizeof(struct bcm_iso_header); bHasHeader = TRUE; } /* If Header is present overwrite passed buffer with this */ @@ -4167,7 +4168,7 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned kfree(pTempBuff); } if (bHasHeader && Adapter->bSigCorrupted) { - sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber))); + sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))); sig = ntohl(sig); if ((sig & 0xFF000000) != CORRUPTED_PATTERN) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Desired pattern is not at sig offset. Hence won't restore"); @@ -4175,7 +4176,7 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned return STATUS_SUCCESS; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Corrupted sig is :%X", sig); - *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER); + *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature in Header Write only"); Adapter->bSigCorrupted = FALSE; } @@ -4268,7 +4269,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ { unsigned int uiDSDsig = 0; /* unsigned int sigoffsetInMap = 0; - * DSD_HEADER dsdHeader = {0}; + * struct bcm_dsd_header dsdHeader = {0}; */ /* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */ @@ -4280,7 +4281,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ BcmFlash2xBulkRead(Adapter, &uiDSDsig, dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber), SIGNATURE_SIZE); uiDSDsig = ntohl(uiDSDsig); @@ -4293,7 +4294,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v { /* unsigned int priOffsetInMap = 0 ; */ unsigned int uiDSDPri = STATUS_FAILURE; - /* DSD_HEADER dsdHeader = {0}; + /* struct bcm_dsd_header dsdHeader = {0}; * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader; */ if (IsSectionWritable(Adapter, dsd)) { @@ -4301,7 +4302,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v BcmFlash2xBulkRead(Adapter, &uiDSDPri, dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority), + Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), 4); uiDSDPri = ntohl(uiDSDPri); @@ -4348,7 +4349,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ { unsigned int uiISOsig = 0; /* unsigned int sigoffsetInMap = 0; - * ISO_HEADER ISOHeader = {0}; + * struct bcm_iso_header ISOHeader = {0}; * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader; */ if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) { @@ -4358,7 +4359,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_ BcmFlash2xBulkRead(Adapter, &uiISOsig, iso, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber), SIGNATURE_SIZE); uiISOsig = ntohl(uiISOsig); @@ -4375,7 +4376,7 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v BcmFlash2xBulkRead(Adapter, &ISOPri, iso, - 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority), + 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), 4); ISOPri = ntohl(ISOPri); @@ -4568,7 +4569,7 @@ static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sect return -ENOMEM; } - uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER); + uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); uiOffset -= MAX_RW_SIZE; BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE); diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h index 651b5a4..e765cca 100644 --- a/drivers/staging/bcm/nvm.h +++ b/drivers/staging/bcm/nvm.h @@ -1,409 +1,286 @@ /*************************************************************************************** -// -// Copyright (c) Beceem Communications Inc. -// -// Module Name: -// NVM.h -// -// Abstract: -// This file has the prototypes,preprocessors and definitions various NVM libraries. -// -// -// Revision History: -// Who When What -// -------- -------- ---------------------------------------------- -// Name Date Created/reviewed/modified -// -// Notes: -// -****************************************************************************************/ - + * + * Copyright (c) Beceem Communications Inc. + * + * Module Name: + * NVM.h + * + * Abstract: + * This file has the prototypes,preprocessors and definitions various NVM libraries. + * + * + * Revision History: + * Who When What + * -------- -------- ---------------------------------------------- + * Name Date Created/reviewed/modified + * + * Notes: + * + ****************************************************************************************/ #ifndef _NVM_H_ #define _NVM_H_ -typedef struct _FLASH_SECTOR_INFO -{ - UINT uiSectorSig; - UINT uiSectorSize; - -}FLASH_SECTOR_INFO,*PFLASH_SECTOR_INFO; - -typedef struct _FLASH_CS_INFO -{ - B_UINT32 MagicNumber; -// let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" - - B_UINT32 FlashLayoutVersion ; - - // ISO Image/Format/BuildTool versioning - B_UINT32 ISOImageVersion; - - // SCSI/Flash BootLoader versioning - B_UINT32 SCSIFirmwareVersion; - - - B_UINT32 OffsetFromZeroForPart1ISOImage; -// typically 0 - - B_UINT32 OffsetFromZeroForScsiFirmware; -//typically at 12MB - - B_UINT32 SizeOfScsiFirmware ; -//size of the firmware - depends on binary size - - B_UINT32 OffsetFromZeroForPart2ISOImage; -// typically at first Word Aligned offset 12MB + sizeOfScsiFirmware. - - B_UINT32 OffsetFromZeroForCalibrationStart; -// typically at 15MB - - B_UINT32 OffsetFromZeroForCalibrationEnd; - -// VSA0 offsets - B_UINT32 OffsetFromZeroForVSAStart; - B_UINT32 OffsetFromZeroForVSAEnd; - -// Control Section offsets - B_UINT32 OffsetFromZeroForControlSectionStart; - B_UINT32 OffsetFromZeroForControlSectionData; - -// NO Data Activity timeout to switch from MSC to NW Mode - B_UINT32 CDLessInactivityTimeout; - -// New ISO Image Signature - B_UINT32 NewImageSignature; - -// Signature to validate the sector size. - B_UINT32 FlashSectorSizeSig; - -// Sector Size - B_UINT32 FlashSectorSize; - -// Write Size Support - B_UINT32 FlashWriteSupportSize; - -// Total Flash Size - B_UINT32 TotalFlashSize; - -// Flash Base Address for offset specified - B_UINT32 FlashBaseAddr; - -// Flash Part Max Size - B_UINT32 FlashPartMaxSize; - -// Is CDLess or Flash Bootloader - B_UINT32 IsCDLessDeviceBootSig; - -// MSC Timeout after reset to switch from MSC to NW Mode - B_UINT32 MassStorageTimeout; - - -}FLASH_CS_INFO,*PFLASH_CS_INFO; - -#define FLASH2X_TOTAL_SIZE (64*1024*1024) -#define DEFAULT_SECTOR_SIZE (64*1024) - -typedef struct _FLASH_2X_CS_INFO -{ - - // magic number as 0xBECE-F1A5 - F1A5 for "flas-h" - B_UINT32 MagicNumber; - - B_UINT32 FlashLayoutVersion ; - - // ISO Image/Format/BuildTool versioning - B_UINT32 ISOImageVersion; - - // SCSI/Flash BootLoader versioning - B_UINT32 SCSIFirmwareVersion; - - // ISO Image1 Part1/SCSI Firmware/Flash Bootloader Start offset, size - B_UINT32 OffsetFromZeroForPart1ISOImage; - B_UINT32 OffsetFromZeroForScsiFirmware; - B_UINT32 SizeOfScsiFirmware ; - - // ISO Image1 Part2 start offset - B_UINT32 OffsetFromZeroForPart2ISOImage; - - - // DSD0 offset - B_UINT32 OffsetFromZeroForDSDStart; - B_UINT32 OffsetFromZeroForDSDEnd; - - // VSA0 offset - B_UINT32 OffsetFromZeroForVSAStart; - B_UINT32 OffsetFromZeroForVSAEnd; - - // Control Section offset - B_UINT32 OffsetFromZeroForControlSectionStart; - B_UINT32 OffsetFromZeroForControlSectionData; - - // NO Data Activity timeout to switch from MSC to NW Mode - B_UINT32 CDLessInactivityTimeout; - - // New ISO Image Signature - B_UINT32 NewImageSignature; - - B_UINT32 FlashSectorSizeSig; // Sector Size Signature - B_UINT32 FlashSectorSize; // Sector Size - B_UINT32 FlashWriteSupportSize; // Write Size Support - - B_UINT32 TotalFlashSize; // Total Flash Size - - // Flash Base Address for offset specified - B_UINT32 FlashBaseAddr; - B_UINT32 FlashPartMaxSize; // Flash Part Max Size - - // Is CDLess or Flash Bootloader - B_UINT32 IsCDLessDeviceBootSig; - - // MSC Timeout after reset to switch from MSC to NW Mode - B_UINT32 MassStorageTimeout; - +struct bcm_flash_cs_info { + u32 MagicNumber; + /* let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" */ + u32 FlashLayoutVersion; + u32 ISOImageVersion; + u32 SCSIFirmwareVersion; + u32 OffsetFromZeroForPart1ISOImage; + u32 OffsetFromZeroForScsiFirmware; + u32 SizeOfScsiFirmware; + u32 OffsetFromZeroForPart2ISOImage; + u32 OffsetFromZeroForCalibrationStart; + u32 OffsetFromZeroForCalibrationEnd; + u32 OffsetFromZeroForVSAStart; + u32 OffsetFromZeroForVSAEnd; + u32 OffsetFromZeroForControlSectionStart; + u32 OffsetFromZeroForControlSectionData; + u32 CDLessInactivityTimeout; + u32 NewImageSignature; + u32 FlashSectorSizeSig; + u32 FlashSectorSize; + u32 FlashWriteSupportSize; + u32 TotalFlashSize; + u32 FlashBaseAddr; + u32 FlashPartMaxSize; + u32 IsCDLessDeviceBootSig; + /* MSC Timeout after reset to switch from MSC to NW Mode */ + u32 MassStorageTimeout; +}; + +#define FLASH2X_TOTAL_SIZE (64 * 1024 * 1024) +#define DEFAULT_SECTOR_SIZE (64 * 1024) + +struct bcm_flash2x_cs_info { + /* magic number as 0xBECE-F1A5 - F1A5 for "flas-h" */ + u32 MagicNumber; + u32 FlashLayoutVersion; + u32 ISOImageVersion; + u32 SCSIFirmwareVersion; + u32 OffsetFromZeroForPart1ISOImage; + u32 OffsetFromZeroForScsiFirmware; + u32 SizeOfScsiFirmware; + u32 OffsetFromZeroForPart2ISOImage; + u32 OffsetFromZeroForDSDStart; + u32 OffsetFromZeroForDSDEnd; + u32 OffsetFromZeroForVSAStart; + u32 OffsetFromZeroForVSAEnd; + u32 OffsetFromZeroForControlSectionStart; + u32 OffsetFromZeroForControlSectionData; + /* NO Data Activity timeout to switch from MSC to NW Mode */ + u32 CDLessInactivityTimeout; + u32 NewImageSignature; + u32 FlashSectorSizeSig; + u32 FlashSectorSize; + u32 FlashWriteSupportSize; + u32 TotalFlashSize; + u32 FlashBaseAddr; + u32 FlashPartMaxSize; + u32 IsCDLessDeviceBootSig; + /* MSC Timeout after reset to switch from MSC to NW Mode */ + u32 MassStorageTimeout; /* Flash Map 2.0 Field */ - B_UINT32 OffsetISOImage1Part1Start; // ISO Image1 Part1 offset - B_UINT32 OffsetISOImage1Part1End; - B_UINT32 OffsetISOImage1Part2Start; // ISO Image1 Part2 offset - B_UINT32 OffsetISOImage1Part2End; - B_UINT32 OffsetISOImage1Part3Start; // ISO Image1 Part3 offset - B_UINT32 OffsetISOImage1Part3End; - - B_UINT32 OffsetISOImage2Part1Start; // ISO Image2 Part1 offset - B_UINT32 OffsetISOImage2Part1End; - B_UINT32 OffsetISOImage2Part2Start; // ISO Image2 Part2 offset - B_UINT32 OffsetISOImage2Part2End; - B_UINT32 OffsetISOImage2Part3Start; // ISO Image2 Part3 offset - B_UINT32 OffsetISOImage2Part3End; - - - // DSD Header offset from start of DSD - B_UINT32 OffsetFromDSDStartForDSDHeader; - B_UINT32 OffsetFromZeroForDSD1Start; // DSD 1 offset - B_UINT32 OffsetFromZeroForDSD1End; - B_UINT32 OffsetFromZeroForDSD2Start; // DSD 2 offset - B_UINT32 OffsetFromZeroForDSD2End; - - B_UINT32 OffsetFromZeroForVSA1Start; // VSA 1 offset - B_UINT32 OffsetFromZeroForVSA1End; - B_UINT32 OffsetFromZeroForVSA2Start; // VSA 2 offset - B_UINT32 OffsetFromZeroForVSA2End; - + u32 OffsetISOImage1Part1Start; + u32 OffsetISOImage1Part1End; + u32 OffsetISOImage1Part2Start; + u32 OffsetISOImage1Part2End; + u32 OffsetISOImage1Part3Start; + u32 OffsetISOImage1Part3End; + u32 OffsetISOImage2Part1Start; + u32 OffsetISOImage2Part1End; + u32 OffsetISOImage2Part2Start; + u32 OffsetISOImage2Part2End; + u32 OffsetISOImage2Part3Start; + u32 OffsetISOImage2Part3End; + /* DSD Header offset from start of DSD */ + u32 OffsetFromDSDStartForDSDHeader; + u32 OffsetFromZeroForDSD1Start; + u32 OffsetFromZeroForDSD1End; + u32 OffsetFromZeroForDSD2Start; + u32 OffsetFromZeroForDSD2End; + u32 OffsetFromZeroForVSA1Start; + u32 OffsetFromZeroForVSA1End; + u32 OffsetFromZeroForVSA2Start; + u32 OffsetFromZeroForVSA2End; /* -* ACCESS_BITS_PER_SECTOR 2 -* ACCESS_RW 0 -* ACCESS_RO 1 -* ACCESS_RESVD 2 -* ACCESS_RESVD 3 -* */ - B_UINT32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)]; - -// All expansions to the control data structure should add here - -}FLASH2X_CS_INFO,*PFLASH2X_CS_INFO; - -typedef struct _VENDOR_SECTION_INFO -{ - B_UINT32 OffsetFromZeroForSectionStart; - B_UINT32 OffsetFromZeroForSectionEnd; - B_UINT32 AccessFlags; - B_UINT32 Reserved[16]; - -} VENDOR_SECTION_INFO, *PVENDOR_SECTION_INFO; - -typedef struct _FLASH2X_VENDORSPECIFIC_INFO -{ - VENDOR_SECTION_INFO VendorSection[TOTAL_SECTIONS]; - B_UINT32 Reserved[16]; - -} FLASH2X_VENDORSPECIFIC_INFO, *PFLASH2X_VENDORSPECIFIC_INFO; - -typedef struct _DSD_HEADER -{ - B_UINT32 DSDImageSize; - B_UINT32 DSDImageCRC; - B_UINT32 DSDImagePriority; - //We should not consider right now. Reading reserve is worthless. - B_UINT32 Reserved[252]; // Resvd for DSD Header - B_UINT32 DSDImageMagicNumber; - -}DSD_HEADER, *PDSD_HEADER; - -typedef struct _ISO_HEADER -{ - B_UINT32 ISOImageMagicNumber; - B_UINT32 ISOImageSize; - B_UINT32 ISOImageCRC; - B_UINT32 ISOImagePriority; - //We should not consider right now. Reading reserve is worthless. - B_UINT32 Reserved[60]; //Resvd for ISO Header extension - -}ISO_HEADER, *PISO_HEADER; - -#define EEPROM_BEGIN_CIS (0) -#define EEPROM_BEGIN_NON_CIS (0x200) -#define EEPROM_END (0x2000) - -#define INIT_PARAMS_SIGNATURE (0x95a7a597) - -#define MAX_INIT_PARAMS_LENGTH (2048) - - -#define MAC_ADDRESS_OFFSET 0x200 - - -#define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS -#define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) -#define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) -#define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) - -#define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS+2048+16) -#define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+16) -#define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+8) -#define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS+4) - -#define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 -#define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 -#define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C - -#define EEPROM_SPI_Q_STATUS_REG 0x0F003008 -#define EEPROM_CMDQ_SPI_REG 0x0F003018 -#define EEPROM_WRITE_DATAQ_REG 0x0F00301C -#define EEPROM_READ_DATAQ_REG 0x0F003020 -#define SPI_FLUSH_REG 0x0F00304C - -#define EEPROM_WRITE_ENABLE 0x06000000 -#define EEPROM_READ_STATUS_REGISTER 0x05000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 -#define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 -#define EEPROM_WRITE_QUEUE_FULL 0x00004000 -#define EEPROM_16_BYTE_PAGE_READ 0xFB000000 -#define EEPROM_4_BYTE_PAGE_READ 0x3B000000 - -#define EEPROM_CMD_QUEUE_FLUSH 0x00000001 -#define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 -#define EEPROM_READ_QUEUE_FLUSH 0x00000004 -#define EEPROM_ETH_QUEUE_FLUSH 0x00000008 -#define EEPROM_ALL_QUEUE_FLUSH 0x0000000f -#define EEPROM_READ_ENABLE 0x06000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_READ_DATA_FULL 0x00000010 -#define EEPROM_READ_DATA_AVAIL 0x00000020 -#define EEPROM_READ_QUEUE_EMPTY 0x00000002 -#define EEPROM_CMD_QUEUE_EMPTY 0x00000100 -#define EEPROM_CMD_QUEUE_AVAIL 0x00000200 -#define EEPROM_CMD_QUEUE_FULL 0x00000400 + * ACCESS_BITS_PER_SECTOR 2 + * ACCESS_RW 0 + * ACCESS_RO 1 + * ACCESS_RESVD 2 + * ACCESS_RESVD 3 + */ + u32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)]; + /* All expansions to the control data structure should add here */ +}; + +struct bcm_vendor_section_info { + u32 OffsetFromZeroForSectionStart; + u32 OffsetFromZeroForSectionEnd; + u32 AccessFlags; + u32 Reserved[16]; +}; + +struct bcm_flash2x_vendor_info { + struct bcm_vendor_section_info VendorSection[TOTAL_SECTIONS]; + u32 Reserved[16]; +}; + +struct bcm_dsd_header { + u32 DSDImageSize; + u32 DSDImageCRC; + u32 DSDImagePriority; + /* We should not consider right now. Reading reserve is worthless. */ + u32 Reserved[252]; /* Resvd for DSD Header */ + u32 DSDImageMagicNumber; +}; + +struct bcm_iso_header { + u32 ISOImageMagicNumber; + u32 ISOImageSize; + u32 ISOImageCRC; + u32 ISOImagePriority; + /* We should not consider right now. Reading reserve is worthless. */ + u32 Reserved[60]; /* Resvd for ISO Header extension */ +}; + +#define EEPROM_BEGIN_CIS (0) +#define EEPROM_BEGIN_NON_CIS (0x200) +#define EEPROM_END (0x2000) +#define INIT_PARAMS_SIGNATURE (0x95a7a597) +#define MAX_INIT_PARAMS_LENGTH (2048) +#define MAC_ADDRESS_OFFSET 0x200 + +#define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS +#define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) +#define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) +#define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) + +#define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS + 2048 + 16) +#define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 16) +#define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 8) +#define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 4) + +#define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 +#define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 +#define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C + +#define EEPROM_SPI_Q_STATUS_REG 0x0F003008 +#define EEPROM_CMDQ_SPI_REG 0x0F003018 +#define EEPROM_WRITE_DATAQ_REG 0x0F00301C +#define EEPROM_READ_DATAQ_REG 0x0F003020 +#define SPI_FLUSH_REG 0x0F00304C + +#define EEPROM_WRITE_ENABLE 0x06000000 +#define EEPROM_READ_STATUS_REGISTER 0x05000000 +#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 +#define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 +#define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 +#define EEPROM_WRITE_QUEUE_FULL 0x00004000 +#define EEPROM_16_BYTE_PAGE_READ 0xFB000000 +#define EEPROM_4_BYTE_PAGE_READ 0x3B000000 + +#define EEPROM_CMD_QUEUE_FLUSH 0x00000001 +#define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 +#define EEPROM_READ_QUEUE_FLUSH 0x00000004 +#define EEPROM_ETH_QUEUE_FLUSH 0x00000008 +#define EEPROM_ALL_QUEUE_FLUSH 0x0000000f +#define EEPROM_READ_ENABLE 0x06000000 +#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 +#define EEPROM_READ_DATA_FULL 0x00000010 +#define EEPROM_READ_DATA_AVAIL 0x00000020 +#define EEPROM_READ_QUEUE_EMPTY 0x00000002 +#define EEPROM_CMD_QUEUE_EMPTY 0x00000100 +#define EEPROM_CMD_QUEUE_AVAIL 0x00000200 +#define EEPROM_CMD_QUEUE_FULL 0x00000400 /* Most EEPROM status register bit 0 indicates if the EEPROM is busy * with a write if set 1. See the details of the EEPROM Status Register - * in the EEPROM data sheet. */ -#define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 - -// We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES -// This will give us 80 mSec minimum of delay = 80mSecs -#define MAX_EEPROM_RETRIES 80 -#define RETRIES_PER_DELAY 64 - - -#define MAX_RW_SIZE 0x10 -#define MAX_READ_SIZE 0x10 -#define MAX_SECTOR_SIZE (512*1024) -#define MIN_SECTOR_SIZE (1024) -#define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC -#define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 -#define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE -#define FLASH_CS_INFO_START_ADDR 0xFF0000 -#define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 -#define SCSI_FIRMWARE_MAJOR_VERSION 0x1 -#define SCSI_FIRMWARE_MINOR_VERSION 0x5 -#define BYTE_WRITE_SUPPORT 0x1 - -#define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 - - - - -#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 -#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 - -#define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 -#define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF - - - -#define FLASH_SIZE_ADDR 0xFFFFEC - -#define FLASH_SPI_CMDQ_REG 0xAF003040 -#define FLASH_SPI_WRITEQ_REG 0xAF003044 -#define FLASH_SPI_READQ_REG 0xAF003048 -#define FLASH_CONFIG_REG 0xAF003050 -#define FLASH_GPIO_CONFIG_REG 0xAF000030 - -#define FLASH_CMD_WRITE_ENABLE 0x06 -#define FLASH_CMD_READ_ENABLE 0x03 -#define FLASH_CMD_RESET_WRITE_ENABLE 0x04 -#define FLASH_CMD_STATUS_REG_READ 0x05 -#define FLASH_CMD_STATUS_REG_WRITE 0x01 -#define FLASH_CMD_READ_ID 0x9F - -#define PAD_SELECT_REGISTER 0xAF000410 - -#define FLASH_PART_SST25VF080B 0xBF258E - -#define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 - -#define EEPROM_CALPARAM_START 0x200 -#define EEPROM_SIZE_OFFSET 524 - -//As Read/Write time vaires from 1.5 to 3.0 ms. -//so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), -//here time calculated meets the worst case delay, 3.0 ms -#define MAX_FLASH_RETRIES 4 -#define FLASH_PER_RETRIES_DELAY 16 - - -#define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 - - - -#define BECM ntohl(0x4245434d) - -#define FLASH_2X_MAJOR_NUMBER 0x2 -#define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D -#define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 -#define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 -#define MINOR_VERSION(x) ((x >>16) & 0xFFFF) + * in the EEPROM data sheet. + */ +#define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 + +/* We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES + * This will give us 80 mSec minimum of delay = 80mSecs + */ +#define MAX_EEPROM_RETRIES 80 +#define RETRIES_PER_DELAY 64 +#define MAX_RW_SIZE 0x10 +#define MAX_READ_SIZE 0x10 +#define MAX_SECTOR_SIZE (512 * 1024) +#define MIN_SECTOR_SIZE (1024) +#define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC +#define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 +#define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE +#define FLASH_CS_INFO_START_ADDR 0xFF0000 +#define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 +#define SCSI_FIRMWARE_MAJOR_VERSION 0x1 +#define SCSI_FIRMWARE_MINOR_VERSION 0x5 +#define BYTE_WRITE_SUPPORT 0x1 +#define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 +#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 +#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 +#define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 +#define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF +#define FLASH_SIZE_ADDR 0xFFFFEC +#define FLASH_SPI_CMDQ_REG 0xAF003040 +#define FLASH_SPI_WRITEQ_REG 0xAF003044 +#define FLASH_SPI_READQ_REG 0xAF003048 +#define FLASH_CONFIG_REG 0xAF003050 +#define FLASH_GPIO_CONFIG_REG 0xAF000030 +#define FLASH_CMD_WRITE_ENABLE 0x06 +#define FLASH_CMD_READ_ENABLE 0x03 +#define FLASH_CMD_RESET_WRITE_ENABLE 0x04 +#define FLASH_CMD_STATUS_REG_READ 0x05 +#define FLASH_CMD_STATUS_REG_WRITE 0x01 +#define FLASH_CMD_READ_ID 0x9F +#define PAD_SELECT_REGISTER 0xAF000410 +#define FLASH_PART_SST25VF080B 0xBF258E +#define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 +#define EEPROM_CALPARAM_START 0x200 +#define EEPROM_SIZE_OFFSET 524 + +/* As Read/Write time vaires from 1.5 to 3.0 ms. + * so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), + * here time calculated meets the worst case delay, 3.0 ms + */ +#define MAX_FLASH_RETRIES 4 +#define FLASH_PER_RETRIES_DELAY 16 +#define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 +#define BECM ntohl(0x4245434d) +#define FLASH_2X_MAJOR_NUMBER 0x2 +#define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D +#define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 +#define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 + +#define MINOR_VERSION(x) ((x >> 16) & 0xFFFF) #define MAJOR_VERSION(x) (x & 0xFFFF) -#define CORRUPTED_PATTERN 0x0 -#define UNINIT_PTR_IN_CS 0xBBBBDDDD - -#define VENDOR_PTR_IN_CS 0xAAAACCCC - - -#define FLASH2X_SECTION_PRESENT 1<<0 -#define FLASH2X_SECTION_VALID 1<<1 -#define FLASH2X_SECTION_RO 1<<2 -#define FLASH2X_SECTION_ACT 1<<3 -#define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE -#define INVALID_OFFSET STATUS_FAILURE -#define INVALID_SECTION STATUS_FAILURE -#define SECTOR_1K 1024 -#define SECTOR_64K (64 *SECTOR_1K) -#define SECTOR_128K (2 * SECTOR_64K) -#define SECTOR_256k (2 * SECTOR_128K) -#define SECTOR_512K (2 * SECTOR_256k) -#define FLASH_PART_SIZE (16 * 1024 * 1024) -#define RESET_CHIP_SELECT -1 -#define CHIP_SELECT_BIT12 12 - -#define SECTOR_READWRITE_PERMISSION 0 -#define SECTOR_READONLY 1 -#define SIGNATURE_SIZE 4 -#define DEFAULT_BUFF_SIZE 0x10000 - -#define FIELD_OFFSET_IN_HEADER(HeaderPointer,Field) ((PUCHAR)&((HeaderPointer)(NULL))->Field - (PUCHAR)(NULL)) +#define CORRUPTED_PATTERN 0x0 +#define UNINIT_PTR_IN_CS 0xBBBBDDDD +#define VENDOR_PTR_IN_CS 0xAAAACCCC +#define FLASH2X_SECTION_PRESENT (1 << 0) +#define FLASH2X_SECTION_VALID (1 << 1) +#define FLASH2X_SECTION_RO (1 << 2) +#define FLASH2X_SECTION_ACT (1 << 3) +#define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE +#define INVALID_OFFSET STATUS_FAILURE +#define INVALID_SECTION STATUS_FAILURE +#define SECTOR_1K 1024 +#define SECTOR_64K (64 * SECTOR_1K) +#define SECTOR_128K (2 * SECTOR_64K) +#define SECTOR_256k (2 * SECTOR_128K) +#define SECTOR_512K (2 * SECTOR_256k) +#define FLASH_PART_SIZE (16 * 1024 * 1024) +#define RESET_CHIP_SELECT -1 +#define CHIP_SELECT_BIT12 12 +#define SECTOR_READWRITE_PERMISSION 0 +#define SECTOR_READONLY 1 +#define SIGNATURE_SIZE 4 +#define DEFAULT_BUFF_SIZE 0x10000 + +#define FIELD_OFFSET_IN_HEADER(HeaderPointer, Field) ((u8 *)&((HeaderPointer)(NULL))->Field - (u8 *)(NULL)) #endif diff --git a/drivers/staging/bcm/target_params.h b/drivers/staging/bcm/target_params.h index ad7ec00..dc45f9a 100644 --- a/drivers/staging/bcm/target_params.h +++ b/drivers/staging/bcm/target_params.h @@ -1,81 +1,57 @@ #ifndef TARGET_PARAMS_H #define TARGET_PARAMS_H -typedef struct _TARGET_PARAMS -{ - B_UINT32 m_u32CfgVersion; - - // Scanning Related Params - B_UINT32 m_u32CenterFrequency; - B_UINT32 m_u32BandAScan; - B_UINT32 m_u32BandBScan; - B_UINT32 m_u32BandCScan; - - - // QoS Params - B_UINT32 m_u32ErtpsOptions; - - B_UINT32 m_u32PHSEnable; - - - // HO Params - B_UINT32 m_u32HoEnable; - - B_UINT32 m_u32HoReserved1; - B_UINT32 m_u32HoReserved2; - // Power Control Params - - B_UINT32 m_u32MimoEnable; - - B_UINT32 m_u32SecurityEnable; - - B_UINT32 m_u32PowerSavingModesEnable; //bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable - /* PowerSaving Mode Options: - bit 0 = 1: CPE mode - to keep pcmcia if alive; - bit 1 = 1: CINR reporting in Idlemode Msg - bit 2 = 1: Default PSC Enable in sleepmode*/ - B_UINT32 m_u32PowerSavingModeOptions; - - B_UINT32 m_u32ArqEnable; - - // From Version #3, the HARQ section renamed as general - B_UINT32 m_u32HarqEnable; - // EEPROM Param Location - B_UINT32 m_u32EEPROMFlag; - // BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte - // Unused - LSByte - B_UINT32 m_u32Customize; - B_UINT32 m_u32ConfigBW; /* In Hz */ - B_UINT32 m_u32ShutDownInitThresholdTimer; - - B_UINT32 m_u32RadioParameter; - B_UINT32 m_u32PhyParameter1; - B_UINT32 m_u32PhyParameter2; - B_UINT32 m_u32PhyParameter3; - - B_UINT32 m_u32TestOptions; // in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack - - B_UINT32 m_u32MaxMACDataperDLFrame; - B_UINT32 m_u32MaxMACDataperULFrame; - - B_UINT32 m_u32Corr2MacFlags; - - //adding driver params. - B_UINT32 HostDrvrConfig1; - B_UINT32 HostDrvrConfig2; - B_UINT32 HostDrvrConfig3; - B_UINT32 HostDrvrConfig4; - B_UINT32 HostDrvrConfig5; - B_UINT32 HostDrvrConfig6; - B_UINT32 m_u32SegmentedPUSCenable; - - // removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. - - //BAMC Related Parameters - //Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 – Enable Band AMC signaling. - //bit 16-31 Band AMC Data configuration: Bit 16 = 1 – Band AMC 2x3 support. - B_UINT32 m_u32BandAMCEnable; - -} stTargetParams,TARGET_PARAMS,*PTARGET_PARAMS, STARGETPARAMS, *PSTARGETPARAMS; +struct bcm_target_params { + u32 m_u32CfgVersion; + u32 m_u32CenterFrequency; + u32 m_u32BandAScan; + u32 m_u32BandBScan; + u32 m_u32BandCScan; + u32 m_u32ErtpsOptions; + u32 m_u32PHSEnable; + u32 m_u32HoEnable; + u32 m_u32HoReserved1; + u32 m_u32HoReserved2; + u32 m_u32MimoEnable; + u32 m_u32SecurityEnable; + u32 m_u32PowerSavingModesEnable; /* bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable */ + /* PowerSaving Mode Options: + * bit 0 = 1: CPE mode - to keep pcmcia if alive; + * bit 1 = 1: CINR reporting in Idlemode Msg + * bit 2 = 1: Default PSC Enable in sleepmode + */ + u32 m_u32PowerSavingModeOptions; + u32 m_u32ArqEnable; + /* From Version #3, the HARQ section renamed as general */ + u32 m_u32HarqEnable; + u32 m_u32EEPROMFlag; + /* BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte + * Unused - LSByte + */ + u32 m_u32Customize; + u32 m_u32ConfigBW; /* In Hz */ + u32 m_u32ShutDownInitThresholdTimer; + u32 m_u32RadioParameter; + u32 m_u32PhyParameter1; + u32 m_u32PhyParameter2; + u32 m_u32PhyParameter3; + u32 m_u32TestOptions; /* in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack */ + u32 m_u32MaxMACDataperDLFrame; + u32 m_u32MaxMACDataperULFrame; + u32 m_u32Corr2MacFlags; + u32 HostDrvrConfig1; + u32 HostDrvrConfig2; + u32 HostDrvrConfig3; + u32 HostDrvrConfig4; + u32 HostDrvrConfig5; + u32 HostDrvrConfig6; + u32 m_u32SegmentedPUSCenable; + /* removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. + * BAMC Related Parameters + * Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 – Enable Band AMC signaling. + * bit 16-31 Band AMC Data configuration: Bit 16 = 1 – Band AMC 2x3 support. + */ + u32 m_u32BandAMCEnable; +}; #endif diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c index 40be60a..be1f91d 100644 --- a/drivers/staging/bcm/vendorspecificextn.c +++ b/drivers/staging/bcm/vendorspecificextn.c @@ -11,7 +11,7 @@ // STATUS_SUCCESS/STATUS_FAILURE // //----------------------------------------------------------------------------- -INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo) +INT vendorextnGetSectionInfo(PVOID pContext, struct bcm_flash2x_vendor_info *pVendorInfo) { return STATUS_FAILURE; } diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h index 834410e..52890d21 100644 --- a/drivers/staging/bcm/vendorspecificextn.h +++ b/drivers/staging/bcm/vendorspecificextn.h @@ -4,7 +4,7 @@ #define CONTINUE_COMMON_PATH 0xFFFF -INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo); +INT vendorextnGetSectionInfo(PVOID pContext, struct bcm_flash2x_vendor_info *pVendorInfo); INT vendorextnExit(struct bcm_mini_adapter *Adapter); INT vendorextnInit(struct bcm_mini_adapter *Adapter); INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg); diff --git a/drivers/staging/ced1401/ced_ioc.c b/drivers/staging/ced1401/ced_ioc.c index d043471..82a333f 100644 --- a/drivers/staging/ced1401/ced_ioc.c +++ b/drivers/staging/ced1401/ced_ioc.c @@ -123,7 +123,7 @@ int SendString(DEVICE_EXTENSION * pdx, const char __user * pData, iReturn = PutChars(pdx, buffer, n); } - Allowi(pdx, false); // make sure we have input int + Allowi(pdx); // make sure we have input int mutex_unlock(&pdx->io_mutex); return iReturn; @@ -140,7 +140,7 @@ int SendChar(DEVICE_EXTENSION * pdx, char c) mutex_lock(&pdx->io_mutex); // Protect disconnect from new i/o iReturn = PutChars(pdx, &c, 1); dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)", c, c); - Allowi(pdx, false); // Make sure char reads are running + Allowi(pdx); // Make sure char reads are running mutex_unlock(&pdx->io_mutex); return iReturn; } @@ -433,8 +433,8 @@ int GetChar(DEVICE_EXTENSION * pdx) dev_dbg(&pdx->interface->dev, "GetChar"); - Allowi(pdx, false); // Make sure char reads are running - SendChars(pdx); // and send any buffered chars + Allowi(pdx); // Make sure char reads are running + SendChars(pdx); // and send any buffered chars spin_lock_irq(&pdx->charInLock); if (pdx->dwNumInput > 0) // worth looking @@ -447,7 +447,7 @@ int GetChar(DEVICE_EXTENSION * pdx) iReturn = U14ERR_NOIN; // no input data to read spin_unlock_irq(&pdx->charInLock); - Allowi(pdx, false); // Make sure char reads are running + Allowi(pdx); // Make sure char reads are running mutex_unlock(&pdx->io_mutex); // Protect disconnect from new i/o return iReturn; @@ -472,7 +472,7 @@ int GetString(DEVICE_EXTENSION * pdx, char __user * pUser, int n) return -ENOMEM; mutex_lock(&pdx->io_mutex); // Protect disconnect from new i/o - Allowi(pdx, false); // Make sure char reads are running + Allowi(pdx); // Make sure char reads are running SendChars(pdx); // and send any buffered chars spin_lock_irq(&pdx->charInLock); @@ -518,7 +518,7 @@ int GetString(DEVICE_EXTENSION * pdx, char __user * pUser, int n) } else spin_unlock_irq(&pdx->charInLock); - Allowi(pdx, false); // Make sure char reads are running + Allowi(pdx); // Make sure char reads are running mutex_unlock(&pdx->io_mutex); // Protect disconnect from new i/o return iReturn; @@ -531,7 +531,7 @@ int Stat1401(DEVICE_EXTENSION * pdx) { int iReturn; mutex_lock(&pdx->io_mutex); // Protect disconnect from new i/o - Allowi(pdx, false); // make sure we allow pending chars + Allowi(pdx); // make sure we allow pending chars SendChars(pdx); // in both directions iReturn = pdx->dwNumInput; // no lock as single read mutex_unlock(&pdx->io_mutex); // Protect disconnect from new i/o @@ -550,7 +550,7 @@ int LineCount(DEVICE_EXTENSION * pdx) int iReturn = 0; // will be count of line ends mutex_lock(&pdx->io_mutex); // Protect disconnect from new i/o - Allowi(pdx, false); // Make sure char reads are running + Allowi(pdx); // Make sure char reads are running SendChars(pdx); // and send any buffered chars spin_lock_irq(&pdx->charInLock); // Get protection diff --git a/drivers/staging/ced1401/usb1401.c b/drivers/staging/ced1401/usb1401.c index a27043a..254131d 100644 --- a/drivers/staging/ced1401/usb1401.c +++ b/drivers/staging/ced1401/usb1401.c @@ -697,7 +697,7 @@ static void staged_callback(struct urb *pUrb) // in Allowi as if it were protected by the char lock. In any case, most systems will // not be upset by char input during DMA... sigh. Needs sorting out. if (bRestartCharInput) // may be out of date, but... - Allowi(pdx, true); // ...Allowi tests a lock too. + Allowi(pdx); // ...Allowi tests a lock too. dev_dbg(&pdx->interface->dev, "%s done", __func__); } @@ -1172,7 +1172,7 @@ static void ced_readchar_callback(struct urb *pUrb) pdx->bReadCharsPending = false; // No longer have a pending read spin_unlock(&pdx->charInLock); // already at irq level - Allowi(pdx, true); // see if we can do the next one + Allowi(pdx); // see if we can do the next one } /**************************************************************************** @@ -1182,7 +1182,7 @@ static void ced_readchar_callback(struct urb *pUrb) ** we can pick up any inward transfers. This can be called in multiple contexts ** so we use the irqsave version of the spinlock. ****************************************************************************/ -int Allowi(DEVICE_EXTENSION * pdx, bool bInCallback) +int Allowi(DEVICE_EXTENSION * pdx) { int iReturn = U14ERR_NOERROR; unsigned long flags; @@ -1211,9 +1211,7 @@ int Allowi(DEVICE_EXTENSION * pdx, bool bInCallback) pdx, pdx->bInterval); pdx->pUrbCharIn->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; // short xfers are OK by default usb_anchor_urb(pdx->pUrbCharIn, &pdx->submitted); // in case we need to kill it - iReturn = - usb_submit_urb(pdx->pUrbCharIn, - bInCallback ? GFP_ATOMIC : GFP_KERNEL); + iReturn = usb_submit_urb(pdx->pUrbCharIn, GFP_ATOMIC); if (iReturn) { usb_unanchor_urb(pdx->pUrbCharIn); // remove from list of active Urbs pdx->bPipeError[nPipe] = 1; // Flag an error to be handled later @@ -1393,10 +1391,8 @@ static int ced_probe(struct usb_interface *interface, // allocate memory for our device extension and initialize it pdx = kzalloc(sizeof(*pdx), GFP_KERNEL); - if (!pdx) { - dev_err(&interface->dev, "Out of memory\n"); + if (!pdx) goto error; - } for (i = 0; i < MAX_TRANSAREAS; ++i) // Initialise the wait queues { diff --git a/drivers/staging/ced1401/usb1401.h b/drivers/staging/ced1401/usb1401.h index adb5fa4..8fc6958 100644 --- a/drivers/staging/ced1401/usb1401.h +++ b/drivers/staging/ced1401/usb1401.h @@ -204,7 +204,7 @@ typedef struct _DEVICE_EXTENSION /// Definitions of routimes used between compilation object files // in usb1401.c -extern int Allowi(DEVICE_EXTENSION* pdx, bool bInCallback); +extern int Allowi(DEVICE_EXTENSION* pdx); extern int SendChars(DEVICE_EXTENSION* pdx); extern void ced_draw_down(DEVICE_EXTENSION *pdx); extern int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent, diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 36eec32..1967852 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1,7 +1,6 @@ config COMEDI tristate "Data acquisition support (comedi)" depends on m - depends on BROKEN || FRV || M32R || MN10300 || SUPERH || TILE || X86 ---help--- Enable support a wide range of data acquisition devices for Linux. @@ -165,7 +164,7 @@ config COMEDI_PCL730 config COMEDI_PCL812 tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216" - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API ---help--- Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA, @@ -176,7 +175,7 @@ config COMEDI_PCL812 config COMEDI_PCL816 tristate "Advantech PCL-814 and PCL-816 ISA card support" - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API ---help--- Enable support for Advantech PCL-814 and PCL-816 ISA cards @@ -185,7 +184,7 @@ config COMEDI_PCL816 config COMEDI_PCL818 tristate "Advantech PCL-718 and PCL-818 ISA card support" - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API ---help--- Enable support for Advantech PCL-818 ISA cards PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718 @@ -275,10 +274,11 @@ config COMEDI_DAS08_ISA DAS08/JR-16-AO, PC104-DAS08, DAS08/JR/16. To compile this driver as a module, choose M here: the module will be - called das08. + called das08_isa. config COMEDI_DAS16 tristate "DAS-16 compatible ISA and PC/104 card support" + depends on ISA_DMA_API select COMEDI_8255 select COMEDI_FC ---help--- @@ -308,7 +308,7 @@ config COMEDI_DAS800 config COMEDI_DAS1800 tristate "DAS1800 and compatible ISA card support" - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API select COMEDI_FC ---help--- Enable support for DAS1800 and compatible ISA cards @@ -373,7 +373,7 @@ config COMEDI_DT2817 config COMEDI_DT282X tristate "Data Translation DT2821 series and DT-EZ ISA card support" select COMEDI_FC - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API ---help--- Enable support for Data Translation DT2821 series including DT-EZ DT2821, DT2821-F-16SE, DT2821-F-8DI, DT2821-G-16SE, DT2821-G-8DI, @@ -445,7 +445,7 @@ config COMEDI_ADQ12B config COMEDI_NI_AT_A2150 tristate "NI AT-A2150 ISA card support" select COMEDI_FC - depends on VIRT_TO_BUS + depends on VIRT_TO_BUS && ISA_DMA_API ---help--- Enable support for National Instruments AT-A2150 cards @@ -542,11 +542,7 @@ menuconfig COMEDI_PCI_DRIVERS bool "Comedi PCI drivers" depends on PCI ---help--- - Enable comedi PCI drivers to be built - - Note that the answer to this question won't directly affect the - kernel: saying N will just cause the configurator to skip all - the questions about PCI comedi drivers. + Enable support for comedi PCI drivers. if COMEDI_PCI_DRIVERS @@ -567,6 +563,13 @@ config COMEDI_8255_PCI To compile this driver as a module, choose M here: the module will be called 8255_pci. +config COMEDI_ADDI_WATCHDOG + tristate + ---help--- + Provides support for the watchdog subdevice found on many ADDI-DATA + boards. This module will be automatically selected when needed. The + module will be called addi_watchdog. + config COMEDI_ADDI_APCI_035 tristate "ADDI-DATA APCI_035 support" ---help--- @@ -593,6 +596,7 @@ config COMEDI_ADDI_APCI_1500 config COMEDI_ADDI_APCI_1516 tristate "ADDI-DATA APCI-1016/1516/2016 support" + select COMEDI_ADDI_WATCHDOG ---help--- Enable support for ADDI-DATA APCI-1016, APCI-1516 and APCI-2016 boards. These are 16 channel, optically isolated, digital I/O boards. The 1516 @@ -619,6 +623,7 @@ config COMEDI_ADDI_APCI_16XX config COMEDI_ADDI_APCI_2032 tristate "ADDI-DATA APCI_2032 support" + select COMEDI_ADDI_WATCHDOG ---help--- Enable support for ADDI-DATA APCI_2032 cards @@ -627,6 +632,7 @@ config COMEDI_ADDI_APCI_2032 config COMEDI_ADDI_APCI_2200 tristate "ADDI-DATA APCI_2200 support" + select COMEDI_ADDI_WATCHDOG ---help--- Enable support for ADDI-DATA APCI_2200 cards @@ -796,7 +802,7 @@ config COMEDI_DAS08_PCI Enable support for PCI DAS-08 cards. To compile this driver as a module, choose M here: the module will be - called das08. + called das08_pci. config COMEDI_DT3000 tristate "Data Translation DT3000 series support" @@ -1084,11 +1090,7 @@ menuconfig COMEDI_PCMCIA_DRIVERS bool "Comedi PCMCIA drivers" depends on PCMCIA ---help--- - Enable comedi PCMCIA and PCCARD drivers to be built - - Note that the answer to this question won't directly affect the - kernel: saying N will just cause the configurator to skip all - the questions about PCMCIA comedi drivers. + Enable support for comedi PCMCIA drivers. if COMEDI_PCMCIA_DRIVERS @@ -1165,11 +1167,7 @@ menuconfig COMEDI_USB_DRIVERS bool "Comedi USB drivers" depends on USB ---help--- - Enable comedi USB drivers to be built - - Note that the answer to this question won't directly affect the - kernel: saying N will just cause the configurator to skip all - the questions about USB comedi drivers. + Enable support for comedi USB drivers. if COMEDI_USB_DRIVERS diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index 8dbd306..e6dfc98f 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -1,11 +1,12 @@ -obj-$(CONFIG_COMEDI) += comedi.o +comedi-y := comedi_fops.o range.o drivers.o \ + comedi_buf.o +comedi-$(CONFIG_COMEDI_PCI_DRIVERS) += comedi_pci.o +comedi-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += comedi_pcmcia.o +comedi-$(CONFIG_COMEDI_USB_DRIVERS) += comedi_usb.o +comedi-$(CONFIG_PROC_FS) += proc.o +comedi-$(CONFIG_COMPAT) += comedi_compat32.o -obj-$(CONFIG_COMEDI) += kcomedilib/ -obj-$(CONFIG_COMEDI) += drivers/ +obj-$(CONFIG_COMEDI) += comedi.o -comedi-y := \ - comedi_fops.o \ - proc.o \ - range.o \ - drivers.o \ - comedi_compat32.o \ +obj-$(CONFIG_COMEDI) += kcomedilib/ +obj-$(CONFIG_COMEDI) += drivers/ diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index c8a8ca1..4233605 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -41,7 +41,17 @@ /* number of config options in the config structure */ #define COMEDI_NDEVCONFOPTS 32 -/*length of nth chunk of firmware data*/ + +/* + * NOTE: 'comedi_config --init-data' is deprecated + * + * The following indexes in the config options were used by + * comedi_config to pass firmware blobs from user space to the + * comedi drivers. The request_firmware() hotplug interface is + * now used by all comedi drivers instead. + */ + +/* length of nth chunk of firmware data -*/ #define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25 #define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26 #define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27 diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c new file mode 100644 index 0000000..9b997ae --- /dev/null +++ b/drivers/staging/comedi/comedi_buf.c @@ -0,0 +1,415 @@ +/* + * comedi_buf.c + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> + * + * 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 "comedidev.h" +#include "comedi_internal.h" + +#ifdef PAGE_KERNEL_NOCACHE +#define COMEDI_PAGE_PROTECTION PAGE_KERNEL_NOCACHE +#else +#define COMEDI_PAGE_PROTECTION PAGE_KERNEL +#endif + +static void __comedi_buf_free(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned n_pages) +{ + struct comedi_async *async = s->async; + struct comedi_buf_page *buf; + unsigned i; + + if (async->prealloc_buf) { + vunmap(async->prealloc_buf); + async->prealloc_buf = NULL; + async->prealloc_bufsz = 0; + } + + if (!async->buf_page_list) + return; + + for (i = 0; i < n_pages; ++i) { + buf = &async->buf_page_list[i]; + if (buf->virt_addr) { + clear_bit(PG_reserved, + &(virt_to_page(buf->virt_addr)->flags)); + if (s->async_dma_dir != DMA_NONE) { + dma_free_coherent(dev->hw_dev, + PAGE_SIZE, + buf->virt_addr, + buf->dma_addr); + } else { + free_page((unsigned long)buf->virt_addr); + } + } + } + vfree(async->buf_page_list); + async->buf_page_list = NULL; + async->n_buf_pages = 0; +} + +static void __comedi_buf_alloc(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned n_pages) +{ + struct comedi_async *async = s->async; + struct page **pages = NULL; + struct comedi_buf_page *buf; + unsigned i; + + async->buf_page_list = vzalloc(sizeof(*buf) * n_pages); + if (async->buf_page_list) + pages = vmalloc(sizeof(struct page *) * n_pages); + + if (!pages) + return; + + for (i = 0; i < n_pages; i++) { + buf = &async->buf_page_list[i]; + if (s->async_dma_dir != DMA_NONE) + buf->virt_addr = dma_alloc_coherent(dev->hw_dev, + PAGE_SIZE, + &buf->dma_addr, + GFP_KERNEL | + __GFP_COMP); + else + buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL); + if (!buf->virt_addr) + break; + + set_bit(PG_reserved, &(virt_to_page(buf->virt_addr)->flags)); + + pages[i] = virt_to_page(buf->virt_addr); + } + + /* vmap the prealloc_buf if all the pages were allocated */ + if (i == n_pages) + async->prealloc_buf = vmap(pages, n_pages, VM_MAP, + COMEDI_PAGE_PROTECTION); + + vfree(pages); +} + +int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, + unsigned long new_size) +{ + struct comedi_async *async = s->async; + + /* Round up new_size to multiple of PAGE_SIZE */ + new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK; + + /* if no change is required, do nothing */ + if (async->prealloc_buf && async->prealloc_bufsz == new_size) + return 0; + + /* deallocate old buffer */ + __comedi_buf_free(dev, s, async->n_buf_pages); + + /* allocate new buffer */ + if (new_size) { + unsigned n_pages = new_size >> PAGE_SHIFT; + + __comedi_buf_alloc(dev, s, n_pages); + + if (!async->prealloc_buf) { + /* allocation failed */ + __comedi_buf_free(dev, s, n_pages); + return -ENOMEM; + } + async->n_buf_pages = n_pages; + } + async->prealloc_bufsz = new_size; + + return 0; +} + +void comedi_buf_reset(struct comedi_async *async) +{ + async->buf_write_alloc_count = 0; + async->buf_write_count = 0; + async->buf_read_alloc_count = 0; + async->buf_read_count = 0; + + async->buf_write_ptr = 0; + async->buf_read_ptr = 0; + + async->cur_chan = 0; + async->scan_progress = 0; + async->munge_chan = 0; + async->munge_count = 0; + async->munge_ptr = 0; + + async->events = 0; +} + +static unsigned int comedi_buf_write_n_available(struct comedi_async *async) +{ + unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; + + return free_end - async->buf_write_alloc_count; +} + +static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, + unsigned int nbytes, + int strict) +{ + unsigned int available = comedi_buf_write_n_available(async); + + if (nbytes > available) + nbytes = strict ? 0 : available; + + async->buf_write_alloc_count += nbytes; + + /* + * ensure the async buffer 'counts' are read and updated + * before we write data to the write-alloc'ed buffer space + */ + smp_mb(); + + return nbytes; +} + +/* allocates chunk for the writer from free buffer space */ +unsigned int comedi_buf_write_alloc(struct comedi_async *async, + unsigned int nbytes) +{ + return __comedi_buf_write_alloc(async, nbytes, 0); +} +EXPORT_SYMBOL(comedi_buf_write_alloc); + +/* + * munging is applied to data by core as it passes between user + * and kernel space + */ +static unsigned int comedi_buf_munge(struct comedi_async *async, + unsigned int num_bytes) +{ + struct comedi_subdevice *s = async->subdevice; + unsigned int count = 0; + const unsigned num_sample_bytes = bytes_per_sample(s); + + if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) { + async->munge_count += num_bytes; + count = num_bytes; + } else { + /* don't munge partial samples */ + num_bytes -= num_bytes % num_sample_bytes; + while (count < num_bytes) { + int block_size = num_bytes - count; + unsigned int buf_end; + + buf_end = async->prealloc_bufsz - async->munge_ptr; + if (block_size > buf_end) + block_size = buf_end; + + s->munge(s->device, s, + async->prealloc_buf + async->munge_ptr, + block_size, async->munge_chan); + + /* + * ensure data is munged in buffer before the + * async buffer munge_count is incremented + */ + smp_wmb(); + + async->munge_chan += block_size / num_sample_bytes; + async->munge_chan %= async->cmd.chanlist_len; + async->munge_count += block_size; + async->munge_ptr += block_size; + async->munge_ptr %= async->prealloc_bufsz; + count += block_size; + } + } + + return count; +} + +unsigned int comedi_buf_write_n_allocated(struct comedi_async *async) +{ + return async->buf_write_alloc_count - async->buf_write_count; +} + +/* transfers a chunk from writer to filled buffer space */ +unsigned int comedi_buf_write_free(struct comedi_async *async, + unsigned int nbytes) +{ + unsigned int allocated = comedi_buf_write_n_allocated(async); + + if (nbytes > allocated) + nbytes = allocated; + + async->buf_write_count += nbytes; + async->buf_write_ptr += nbytes; + comedi_buf_munge(async, async->buf_write_count - async->munge_count); + if (async->buf_write_ptr >= async->prealloc_bufsz) + async->buf_write_ptr %= async->prealloc_bufsz; + + return nbytes; +} +EXPORT_SYMBOL(comedi_buf_write_free); + +unsigned int comedi_buf_read_n_available(struct comedi_async *async) +{ + unsigned num_bytes; + + if (!async) + return 0; + + num_bytes = async->munge_count - async->buf_read_count; + + /* + * ensure the async buffer 'counts' are read before we + * attempt to read data from the buffer + */ + smp_rmb(); + + return num_bytes; +} +EXPORT_SYMBOL(comedi_buf_read_n_available); + +/* allocates a chunk for the reader from filled (and munged) buffer space */ +unsigned int comedi_buf_read_alloc(struct comedi_async *async, + unsigned int nbytes) +{ + unsigned int available; + + available = async->munge_count - async->buf_read_alloc_count; + if (nbytes > available) + nbytes = available; + + async->buf_read_alloc_count += nbytes; + + /* + * ensure the async buffer 'counts' are read before we + * attempt to read data from the read-alloc'ed buffer space + */ + smp_rmb(); + + return nbytes; +} +EXPORT_SYMBOL(comedi_buf_read_alloc); + +static unsigned int comedi_buf_read_n_allocated(struct comedi_async *async) +{ + return async->buf_read_alloc_count - async->buf_read_count; +} + +/* transfers control of a chunk from reader to free buffer space */ +unsigned int comedi_buf_read_free(struct comedi_async *async, + unsigned int nbytes) +{ + unsigned int allocated; + + /* + * ensure data has been read out of buffer before + * the async read count is incremented + */ + smp_mb(); + + allocated = comedi_buf_read_n_allocated(async); + if (nbytes > allocated) + nbytes = allocated; + + async->buf_read_count += nbytes; + async->buf_read_ptr += nbytes; + async->buf_read_ptr %= async->prealloc_bufsz; + return nbytes; +} +EXPORT_SYMBOL(comedi_buf_read_free); + +int comedi_buf_put(struct comedi_async *async, short x) +{ + unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1); + + if (n < sizeof(short)) { + async->events |= COMEDI_CB_ERROR; + return 0; + } + *(short *)(async->prealloc_buf + async->buf_write_ptr) = x; + comedi_buf_write_free(async, sizeof(short)); + return 1; +} +EXPORT_SYMBOL(comedi_buf_put); + +int comedi_buf_get(struct comedi_async *async, short *x) +{ + unsigned int n = comedi_buf_read_n_available(async); + + if (n < sizeof(short)) + return 0; + comedi_buf_read_alloc(async, sizeof(short)); + *x = *(short *)(async->prealloc_buf + async->buf_read_ptr); + comedi_buf_read_free(async, sizeof(short)); + return 1; +} +EXPORT_SYMBOL(comedi_buf_get); + +void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, + const void *data, unsigned int num_bytes) +{ + unsigned int write_ptr = async->buf_write_ptr + offset; + + if (write_ptr >= async->prealloc_bufsz) + write_ptr %= async->prealloc_bufsz; + + while (num_bytes) { + unsigned int block_size; + + if (write_ptr + num_bytes > async->prealloc_bufsz) + block_size = async->prealloc_bufsz - write_ptr; + else + block_size = num_bytes; + + memcpy(async->prealloc_buf + write_ptr, data, block_size); + + data += block_size; + num_bytes -= block_size; + + write_ptr = 0; + } +} +EXPORT_SYMBOL(comedi_buf_memcpy_to); + +void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, + void *dest, unsigned int nbytes) +{ + void *src; + unsigned int read_ptr = async->buf_read_ptr + offset; + + if (read_ptr >= async->prealloc_bufsz) + read_ptr %= async->prealloc_bufsz; + + while (nbytes) { + unsigned int block_size; + + src = async->prealloc_buf + read_ptr; + + if (nbytes >= async->prealloc_bufsz - read_ptr) + block_size = async->prealloc_bufsz - read_ptr; + else + block_size = nbytes; + + memcpy(dest, src, block_size); + nbytes -= block_size; + dest += block_size; + read_ptr = 0; + } +} +EXPORT_SYMBOL(comedi_buf_memcpy_from); diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c index 4b7cbfa..ad208cd 100644 --- a/drivers/staging/comedi/comedi_compat32.c +++ b/drivers/staging/comedi/comedi_compat32.c @@ -30,8 +30,6 @@ #include "comedi.h" #include "comedi_compat32.h" -#ifdef CONFIG_COMPAT - #define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct) #define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct) /* N.B. COMEDI32_CMD and COMEDI_CMD ought to use _IOWR, not _IOR. @@ -460,5 +458,3 @@ long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { return raw_ioctl(file, cmd, arg); } - -#endif /* CONFIG_COMPAT */ diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 9b038e4..195d56d 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -49,10 +49,6 @@ #include "comedi_internal.h" -MODULE_AUTHOR("http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi core module"); -MODULE_LICENSE("GPL"); - #ifdef CONFIG_COMEDI_DEBUG int comedi_debug; EXPORT_SYMBOL(comedi_debug); @@ -62,11 +58,6 @@ MODULE_PARM_DESC(comedi_debug, ); #endif -bool comedi_autoconfig = 1; -module_param(comedi_autoconfig, bool, S_IRUGO); -MODULE_PARM_DESC(comedi_autoconfig, - "enable drivers to auto-configure comedi devices (default 1)"); - static int comedi_num_legacy_minors; module_param(comedi_num_legacy_minors, int, S_IRUGO); MODULE_PARM_DESC(comedi_num_legacy_minors, @@ -86,17 +77,58 @@ MODULE_PARM_DESC(comedi_default_buf_maxsize_kb, "default maximum size of asynchronous buffer in KiB (default " __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")"); +struct comedi_file_info { + struct comedi_device *device; + struct comedi_subdevice *read_subdevice; + struct comedi_subdevice *write_subdevice; + struct device *hardware_device; +}; + static DEFINE_SPINLOCK(comedi_file_info_table_lock); -static struct comedi_device_file_info -*comedi_file_info_table[COMEDI_NUM_MINORS]; +static struct comedi_file_info *comedi_file_info_table[COMEDI_NUM_MINORS]; -static void do_become_nonbusy(struct comedi_device *dev, - struct comedi_subdevice *s); -static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static struct comedi_file_info *comedi_file_info_from_minor(unsigned minor) +{ + struct comedi_file_info *info; + + BUG_ON(minor >= COMEDI_NUM_MINORS); + spin_lock(&comedi_file_info_table_lock); + info = comedi_file_info_table[minor]; + spin_unlock(&comedi_file_info_table_lock); + return info; +} + +static struct comedi_device * +comedi_dev_from_file_info(struct comedi_file_info *info) +{ + return info ? info->device : NULL; +} + +struct comedi_device *comedi_dev_from_minor(unsigned minor) +{ + return comedi_dev_from_file_info(comedi_file_info_from_minor(minor)); +} +EXPORT_SYMBOL_GPL(comedi_dev_from_minor); -static int comedi_fasync(int fd, struct file *file, int on); +static struct comedi_subdevice * +comedi_read_subdevice(const struct comedi_file_info *info) +{ + if (info->read_subdevice) + return info->read_subdevice; + if (info->device) + return info->device->read_subdev; + return NULL; +} -static int is_device_busy(struct comedi_device *dev); +static struct comedi_subdevice * +comedi_write_subdevice(const struct comedi_file_info *info) +{ + if (info->write_subdevice) + return info->write_subdevice; + if (info->device) + return info->device->write_subdev; + return NULL; +} static int resize_async_buffer(struct comedi_device *dev, struct comedi_subdevice *s, @@ -134,7 +166,7 @@ static int resize_async_buffer(struct comedi_device *dev, } DPRINTK("comedi%i subd %d buffer resized to %i bytes\n", - dev->minor, (int)(s - dev->subdevices), async->prealloc_bufsz); + dev->minor, s->index, async->prealloc_bufsz); return 0; } @@ -143,8 +175,8 @@ static int resize_async_buffer(struct comedi_device *dev, static ssize_t show_max_read_buffer_kb(struct device *dev, struct device_attribute *attr, char *buf) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_read_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_read_subdevice(info); unsigned int size = 0; mutex_lock(&info->device->mutex); @@ -159,8 +191,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_read_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_read_subdevice(info); unsigned int size; int err; @@ -184,8 +216,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev, static ssize_t show_read_buffer_kb(struct device *dev, struct device_attribute *attr, char *buf) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_read_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_read_subdevice(info); unsigned int size = 0; mutex_lock(&info->device->mutex); @@ -200,8 +232,8 @@ static ssize_t store_read_buffer_kb(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_read_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_read_subdevice(info); unsigned int size; int err; @@ -226,8 +258,8 @@ static ssize_t show_max_write_buffer_kb(struct device *dev, struct device_attribute *attr, char *buf) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_write_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_write_subdevice(info); unsigned int size = 0; mutex_lock(&info->device->mutex); @@ -242,8 +274,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_write_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_write_subdevice(info); unsigned int size; int err; @@ -267,8 +299,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev, static ssize_t show_write_buffer_kb(struct device *dev, struct device_attribute *attr, char *buf) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_write_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_write_subdevice(info); unsigned int size = 0; mutex_lock(&info->device->mutex); @@ -283,8 +315,8 @@ static ssize_t store_write_buffer_kb(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct comedi_device_file_info *info = dev_get_drvdata(dev); - struct comedi_subdevice *s = comedi_get_write_subdevice(info); + struct comedi_file_info *info = dev_get_drvdata(dev); + struct comedi_subdevice *s = comedi_write_subdevice(info); unsigned int size; int err; @@ -317,6 +349,103 @@ static struct device_attribute comedi_dev_attrs[] = { __ATTR_NULL }; +static void comedi_set_subdevice_runflags(struct comedi_subdevice *s, + unsigned mask, unsigned bits) +{ + unsigned long flags; + + spin_lock_irqsave(&s->spin_lock, flags); + s->runflags &= ~mask; + s->runflags |= (bits & mask); + spin_unlock_irqrestore(&s->spin_lock, flags); +} + +static unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) +{ + unsigned long flags; + unsigned runflags; + + spin_lock_irqsave(&s->spin_lock, flags); + runflags = s->runflags; + spin_unlock_irqrestore(&s->spin_lock, flags); + return runflags; +} + +bool comedi_is_subdevice_running(struct comedi_subdevice *s) +{ + unsigned runflags = comedi_get_subdevice_runflags(s); + + return (runflags & SRF_RUNNING) ? true : false; +} +EXPORT_SYMBOL_GPL(comedi_is_subdevice_running); + +static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s) +{ + unsigned runflags = comedi_get_subdevice_runflags(s); + + return (runflags & SRF_ERROR) ? true : false; +} + +static bool comedi_is_subdevice_idle(struct comedi_subdevice *s) +{ + unsigned runflags = comedi_get_subdevice_runflags(s); + + return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true; +} + +/* + This function restores a subdevice to an idle state. + */ +static void do_become_nonbusy(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct comedi_async *async = s->async; + + comedi_set_subdevice_runflags(s, SRF_RUNNING, 0); + if (async) { + comedi_buf_reset(async); + async->inttrig = NULL; + kfree(async->cmd.chanlist); + async->cmd.chanlist = NULL; + } else { + dev_err(dev->class_dev, + "BUG: (?) do_become_nonbusy called with async=NULL\n"); + } + + s->busy = NULL; +} + +static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +{ + int ret = 0; + + if (comedi_is_subdevice_running(s) && s->cancel) + ret = s->cancel(dev, s); + + do_become_nonbusy(dev, s); + + return ret; +} + +static int is_device_busy(struct comedi_device *dev) +{ + struct comedi_subdevice *s; + int i; + + if (!dev->attached) + return 0; + + for (i = 0; i < dev->n_subdevices; i++) { + s = &dev->subdevices[i]; + if (s->busy) + return 1; + if (s->async && s->async->mmap_count) + return 1; + } + + return 0; +} + /* COMEDI_DEVCONFIG device config ioctl @@ -335,8 +464,6 @@ static int do_devconfig_ioctl(struct comedi_device *dev, { struct comedi_devconfig it; int ret; - unsigned char *aux_data = NULL; - int aux_len; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -352,36 +479,15 @@ static int do_devconfig_ioctl(struct comedi_device *dev, return 0; } - if (copy_from_user(&it, arg, sizeof(struct comedi_devconfig))) + if (copy_from_user(&it, arg, sizeof(it))) return -EFAULT; it.board_name[COMEDI_NAMELEN - 1] = 0; - if (comedi_aux_data(it.options, 0) && - it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { - int bit_shift; - aux_len = it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]; - if (aux_len < 0) - return -EFAULT; - - aux_data = vmalloc(aux_len); - if (!aux_data) - return -ENOMEM; - - if (copy_from_user(aux_data, - (unsigned char __user * - )comedi_aux_data(it.options, 0), aux_len)) { - vfree(aux_data); - return -EFAULT; - } - it.options[COMEDI_DEVCONF_AUX_DATA_LO] = - (unsigned long)aux_data; - if (sizeof(void *) > sizeof(int)) { - bit_shift = sizeof(int) * 8; - it.options[COMEDI_DEVCONF_AUX_DATA_HI] = - ((unsigned long)aux_data) >> bit_shift; - } else - it.options[COMEDI_DEVCONF_AUX_DATA_HI] = 0; + if (it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) { + dev_warn(dev->class_dev, + "comedi_config --init_data is deprecated\n"); + return -EINVAL; } ret = comedi_device_attach(dev, &it); @@ -392,9 +498,6 @@ static int do_devconfig_ioctl(struct comedi_device *dev, } } - if (aux_data) - vfree(aux_data); - return ret; } @@ -420,7 +523,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, struct comedi_subdevice *s; int retval = 0; - if (copy_from_user(&bc, arg, sizeof(struct comedi_bufconfig))) + if (copy_from_user(&bc, arg, sizeof(bc))) return -EFAULT; if (bc.subdevice >= dev->n_subdevices || bc.subdevice < 0) @@ -453,7 +556,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, bc.maximum_size = async->max_bufsize; copyback: - if (copy_to_user(arg, &bc, sizeof(struct comedi_bufconfig))) + if (copy_to_user(arg, &bc, sizeof(bc))) return -EFAULT; return 0; @@ -477,14 +580,10 @@ static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo __user *arg, struct file *file) { - struct comedi_devinfo devinfo; const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_device_file_info *dev_file_info = - comedi_get_device_file_info(minor); - struct comedi_subdevice *read_subdev = - comedi_get_read_subdevice(dev_file_info); - struct comedi_subdevice *write_subdev = - comedi_get_write_subdevice(dev_file_info); + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_subdevice *s; + struct comedi_devinfo devinfo; memset(&devinfo, 0, sizeof(devinfo)); @@ -494,17 +593,19 @@ static int do_devinfo_ioctl(struct comedi_device *dev, strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN); strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN); - if (read_subdev) - devinfo.read_subdevice = read_subdev - dev->subdevices; + s = comedi_read_subdevice(info); + if (s) + devinfo.read_subdevice = s->index; else devinfo.read_subdevice = -1; - if (write_subdev) - devinfo.write_subdevice = write_subdev - dev->subdevices; + s = comedi_write_subdevice(info); + if (s) + devinfo.write_subdevice = s->index; else devinfo.write_subdevice = -1; - if (copy_to_user(arg, &devinfo, sizeof(struct comedi_devinfo))) + if (copy_to_user(arg, &devinfo, sizeof(devinfo))) return -EFAULT; return 0; @@ -531,9 +632,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *tmp, *us; struct comedi_subdevice *s; - tmp = - kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo), - GFP_KERNEL); + tmp = kcalloc(dev->n_subdevices, sizeof(*tmp), GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -545,7 +644,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, us->type = s->type; us->n_chan = s->n_chan; us->subd_flags = s->subdev_flags; - if (comedi_get_subdevice_runflags(s) & SRF_RUNNING) + if (comedi_is_subdevice_running(s)) us->subd_flags |= SDF_RUNNING; #define TIMER_nanosec 5 /* backwards compatibility */ us->timer_type = TIMER_nanosec; @@ -584,8 +683,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, us->settling_time_0 = s->settling_time_0; } - ret = copy_to_user(arg, tmp, - dev->n_subdevices * sizeof(struct comedi_subdinfo)); + ret = copy_to_user(arg, tmp, dev->n_subdevices * sizeof(*tmp)); kfree(tmp); @@ -612,7 +710,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_subdevice *s; struct comedi_chaninfo it; - if (copy_from_user(&it, arg, sizeof(struct comedi_chaninfo))) + if (copy_from_user(&it, arg, sizeof(it))) return -EFAULT; if (it.subdev >= dev->n_subdevices) @@ -679,7 +777,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, struct comedi_subdevice *s; struct comedi_async *async; - if (copy_from_user(&bi, arg, sizeof(struct comedi_bufinfo))) + if (copy_from_user(&bi, arg, sizeof(bi))) return -EFAULT; if (bi.subdevice >= dev->n_subdevices || bi.subdevice < 0) @@ -714,9 +812,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read); comedi_buf_read_free(async, bi.bytes_read); - if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR | - SRF_RUNNING)) - && async->buf_write_count == async->buf_read_count) { + if (comedi_is_subdevice_idle(s) && + async->buf_write_count == async->buf_read_count) { do_become_nonbusy(dev, s); } } @@ -734,103 +831,12 @@ copyback_position: bi.buf_read_ptr = async->buf_read_ptr; copyback: - if (copy_to_user(arg, &bi, sizeof(struct comedi_bufinfo))) + if (copy_to_user(arg, &bi, sizeof(bi))) return -EFAULT; return 0; } -static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, - unsigned int *data, void *file); -/* - * COMEDI_INSNLIST - * synchronous instructions - * - * arg: - * pointer to sync cmd structure - * - * reads: - * sync cmd struct at arg - * instruction list - * data (for writes) - * - * writes: - * data (for reads) - */ -/* arbitrary limits */ -#define MAX_SAMPLES 256 -static int do_insnlist_ioctl(struct comedi_device *dev, - struct comedi_insnlist __user *arg, void *file) -{ - struct comedi_insnlist insnlist; - struct comedi_insn *insns = NULL; - unsigned int *data = NULL; - int i = 0; - int ret = 0; - - if (copy_from_user(&insnlist, arg, sizeof(struct comedi_insnlist))) - return -EFAULT; - - data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL); - if (!data) { - DPRINTK("kmalloc failed\n"); - ret = -ENOMEM; - goto error; - } - - insns = - kcalloc(insnlist.n_insns, sizeof(struct comedi_insn), GFP_KERNEL); - if (!insns) { - DPRINTK("kmalloc failed\n"); - ret = -ENOMEM; - goto error; - } - - if (copy_from_user(insns, insnlist.insns, - sizeof(struct comedi_insn) * insnlist.n_insns)) { - DPRINTK("copy_from_user failed\n"); - ret = -EFAULT; - goto error; - } - - for (i = 0; i < insnlist.n_insns; i++) { - if (insns[i].n > MAX_SAMPLES) { - DPRINTK("number of samples too large\n"); - ret = -EINVAL; - goto error; - } - if (insns[i].insn & INSN_MASK_WRITE) { - if (copy_from_user(data, insns[i].data, - insns[i].n * sizeof(unsigned int))) { - DPRINTK("copy_from_user failed\n"); - ret = -EFAULT; - goto error; - } - } - ret = parse_insn(dev, insns + i, data, file); - if (ret < 0) - goto error; - if (insns[i].insn & INSN_MASK_READ) { - if (copy_to_user(insns[i].data, data, - insns[i].n * sizeof(unsigned int))) { - DPRINTK("copy_to_user failed\n"); - ret = -EFAULT; - goto error; - } - } - if (need_resched()) - schedule(); - } - -error: - kfree(insns); - kfree(data); - - if (ret < 0) - return ret; - return i; -} - static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data) { @@ -1062,6 +1068,94 @@ out: } /* + * COMEDI_INSNLIST + * synchronous instructions + * + * arg: + * pointer to sync cmd structure + * + * reads: + * sync cmd struct at arg + * instruction list + * data (for writes) + * + * writes: + * data (for reads) + */ +/* arbitrary limits */ +#define MAX_SAMPLES 256 +static int do_insnlist_ioctl(struct comedi_device *dev, + struct comedi_insnlist __user *arg, void *file) +{ + struct comedi_insnlist insnlist; + struct comedi_insn *insns = NULL; + unsigned int *data = NULL; + int i = 0; + int ret = 0; + + if (copy_from_user(&insnlist, arg, sizeof(insnlist))) + return -EFAULT; + + data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL); + if (!data) { + DPRINTK("kmalloc failed\n"); + ret = -ENOMEM; + goto error; + } + + insns = kcalloc(insnlist.n_insns, sizeof(*insns), GFP_KERNEL); + if (!insns) { + DPRINTK("kmalloc failed\n"); + ret = -ENOMEM; + goto error; + } + + if (copy_from_user(insns, insnlist.insns, + sizeof(*insns) * insnlist.n_insns)) { + DPRINTK("copy_from_user failed\n"); + ret = -EFAULT; + goto error; + } + + for (i = 0; i < insnlist.n_insns; i++) { + if (insns[i].n > MAX_SAMPLES) { + DPRINTK("number of samples too large\n"); + ret = -EINVAL; + goto error; + } + if (insns[i].insn & INSN_MASK_WRITE) { + if (copy_from_user(data, insns[i].data, + insns[i].n * sizeof(unsigned int))) { + DPRINTK("copy_from_user failed\n"); + ret = -EFAULT; + goto error; + } + } + ret = parse_insn(dev, insns + i, data, file); + if (ret < 0) + goto error; + if (insns[i].insn & INSN_MASK_READ) { + if (copy_to_user(insns[i].data, data, + insns[i].n * sizeof(unsigned int))) { + DPRINTK("copy_to_user failed\n"); + ret = -EFAULT; + goto error; + } + } + if (need_resched()) + schedule(); + } + +error: + kfree(insns); + kfree(data); + + if (ret < 0) + return ret; + return i; +} + +/* * COMEDI_INSN * synchronous instructions * @@ -1088,7 +1182,7 @@ static int do_insn_ioctl(struct comedi_device *dev, goto error; } - if (copy_from_user(&insn, arg, sizeof(struct comedi_insn))) { + if (copy_from_user(&insn, arg, sizeof(insn))) { ret = -EFAULT; goto error; } @@ -1123,17 +1217,6 @@ error: return ret; } -static void comedi_set_subdevice_runflags(struct comedi_subdevice *s, - unsigned mask, unsigned bits) -{ - unsigned long flags; - - spin_lock_irqsave(&s->spin_lock, flags); - s->runflags &= ~mask; - s->runflags |= (bits & mask); - spin_unlock_irqrestore(&s->spin_lock, flags); -} - static int do_cmd_ioctl(struct comedi_device *dev, struct comedi_cmd __user *arg, void *file) { @@ -1143,7 +1226,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, int ret = 0; unsigned int __user *user_chanlist; - if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) { + if (copy_from_user(&cmd, arg, sizeof(cmd))) { DPRINTK("bad cmd address\n"); return -EFAULT; } @@ -1233,7 +1316,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, /* restore chanlist pointer before copying back */ cmd.chanlist = (unsigned int __force *)user_chanlist; cmd.data = NULL; - if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) { + if (copy_to_user(arg, &cmd, sizeof(cmd))) { DPRINTK("fault writing cmd\n"); ret = -EFAULT; goto cleanup; @@ -1248,7 +1331,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, goto cleanup; } - comedi_reset_async_buf(async); + comedi_buf_reset(async); async->cb_mask = COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR | @@ -1292,7 +1375,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, unsigned int *chanlist = NULL; unsigned int __user *user_chanlist; - if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) { + if (copy_from_user(&cmd, arg, sizeof(cmd))) { DPRINTK("bad cmd address\n"); return -EFAULT; } @@ -1356,7 +1439,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, /* restore chanlist pointer before copying back */ cmd.chanlist = (unsigned int __force *)user_chanlist; - if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) { + if (copy_to_user(arg, &cmd, sizeof(cmd))) { DPRINTK("bad cmd address\n"); ret = -EFAULT; goto cleanup; @@ -1533,25 +1616,28 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_device_file_info *dev_file_info = - comedi_get_device_file_info(minor); - struct comedi_device *dev; + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_file_info(info); int rc; - if (dev_file_info == NULL || dev_file_info->device == NULL) + if (!dev) return -ENODEV; - dev = dev_file_info->device; mutex_lock(&dev->mutex); /* Device config is special, because it must work on * an unconfigured device. */ if (cmd == COMEDI_DEVCONFIG) { + if (minor >= COMEDI_NUM_BOARD_MINORS) { + /* Device config not appropriate on non-board minors. */ + rc = -ENOTTY; + goto done; + } rc = do_devconfig_ioctl(dev, (struct comedi_devconfig __user *)arg); if (rc == 0) /* Evade comedi_auto_unconfig(). */ - dev_file_info->hardware_device = NULL; + info->hardware_device = NULL; goto done; } @@ -1624,19 +1710,6 @@ done: return rc; } -static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s) -{ - int ret = 0; - - if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) && s->cancel) - ret = s->cancel(dev, s); - - do_become_nonbusy(dev, s); - - return ret; -} - - static void comedi_vm_open(struct vm_area_struct *area) { struct comedi_async *async; @@ -1671,40 +1744,38 @@ static struct vm_operations_struct comedi_vm_ops = { static int comedi_mmap(struct file *file, struct vm_area_struct *vma) { const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_async *async = NULL; + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_file_info(info); + struct comedi_subdevice *s; + struct comedi_async *async; unsigned long start = vma->vm_start; unsigned long size; int n_pages; int i; int retval; - struct comedi_subdevice *s; - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) + if (!dev) return -ENODEV; mutex_lock(&dev->mutex); + if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); retval = -ENODEV; goto done; } + if (vma->vm_flags & VM_WRITE) - s = comedi_get_write_subdevice(dev_file_info); + s = comedi_write_subdevice(info); else - s = comedi_get_read_subdevice(dev_file_info); - - if (s == NULL) { + s = comedi_read_subdevice(info); + if (!s) { retval = -EINVAL; goto done; } + async = s->async; - if (async == NULL) { + if (!async) { retval = -EINVAL; goto done; } @@ -1727,11 +1798,11 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) n_pages = size >> PAGE_SHIFT; for (i = 0; i < n_pages; ++i) { + struct comedi_buf_page *buf = &async->buf_page_list[i]; + if (remap_pfn_range(vma, start, - page_to_pfn(virt_to_page - (async->buf_page_list - [i].virt_addr)), PAGE_SIZE, - PAGE_SHARED)) { + page_to_pfn(virt_to_page(buf->virt_addr)), + PAGE_SIZE, PAGE_SHARED)) { retval = -EAGAIN; goto done; } @@ -1753,50 +1824,40 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_subdevice *read_subdev; - struct comedi_subdevice *write_subdev; - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_file_info(info); + struct comedi_subdevice *s; - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) + if (!dev) return -ENODEV; mutex_lock(&dev->mutex); + if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); - mutex_unlock(&dev->mutex); - return 0; + goto done; } - mask = 0; - read_subdev = comedi_get_read_subdevice(dev_file_info); - if (read_subdev) { - poll_wait(file, &read_subdev->async->wait_head, wait); - if (!read_subdev->busy - || comedi_buf_read_n_available(read_subdev->async) > 0 - || !(comedi_get_subdevice_runflags(read_subdev) & - SRF_RUNNING)) { + s = comedi_read_subdevice(info); + if (s && s->async) { + poll_wait(file, &s->async->wait_head, wait); + if (!s->busy || !comedi_is_subdevice_running(s) || + comedi_buf_read_n_available(s->async) > 0) mask |= POLLIN | POLLRDNORM; - } } - write_subdev = comedi_get_write_subdevice(dev_file_info); - if (write_subdev) { - poll_wait(file, &write_subdev->async->wait_head, wait); - comedi_buf_write_alloc(write_subdev->async, - write_subdev->async->prealloc_bufsz); - if (!write_subdev->busy - || !(comedi_get_subdevice_runflags(write_subdev) & - SRF_RUNNING) - || comedi_buf_write_n_allocated(write_subdev->async) >= - bytes_per_sample(write_subdev->async->subdevice)) { + + s = comedi_write_subdevice(info); + if (s && s->async) { + unsigned int bps = bytes_per_sample(s->async->subdevice); + + poll_wait(file, &s->async->wait_head, wait); + comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + if (!s->busy || !comedi_is_subdevice_running(s) || + comedi_buf_write_n_allocated(s->async) >= bps) mask |= POLLOUT | POLLWRNORM; - } } +done: mutex_unlock(&dev->mutex); return mask; } @@ -1809,53 +1870,38 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, int n, m, count = 0, retval = 0; DECLARE_WAITQUEUE(wait, current); const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_file_info(info); - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) + if (!dev) return -ENODEV; if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); - retval = -ENODEV; - goto done; + return -ENODEV; } - s = comedi_get_write_subdevice(dev_file_info); - if (s == NULL) { - retval = -EIO; - goto done; - } + s = comedi_write_subdevice(info); + if (!s || !s->async) + return -EIO; + async = s->async; - if (!nbytes) { - retval = 0; - goto done; - } - if (!s->busy) { - retval = 0; - goto done; - } - if (s->busy != file) { - retval = -EACCES; - goto done; - } + if (!s->busy || !nbytes) + return 0; + if (s->busy != file) + return -EACCES; + add_wait_queue(&async->wait_head, &wait); while (nbytes > 0 && !retval) { set_current_state(TASK_INTERRUPTIBLE); - if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) { + if (!comedi_is_subdevice_running(s)) { if (count == 0) { - if (comedi_get_subdevice_runflags(s) & - SRF_ERROR) { + if (comedi_is_subdevice_in_error(s)) retval = -EPIPE; - } else { + else retval = 0; - } do_become_nonbusy(dev, s); } break; @@ -1908,7 +1954,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, set_current_state(TASK_RUNNING); remove_wait_queue(&async->wait_head, &wait); -done: return count ? count : retval; } @@ -1920,40 +1965,26 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, int n, m, count = 0, retval = 0; DECLARE_WAITQUEUE(wait, current); const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_file_info(info); - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) + if (!dev) return -ENODEV; if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); - retval = -ENODEV; - goto done; + return -ENODEV; } - s = comedi_get_read_subdevice(dev_file_info); - if (s == NULL) { - retval = -EIO; - goto done; - } + s = comedi_read_subdevice(info); + if (!s || !s->async) + return -EIO; + async = s->async; - if (!nbytes) { - retval = 0; - goto done; - } - if (!s->busy) { - retval = 0; - goto done; - } - if (s->busy != file) { - retval = -EACCES; - goto done; - } + if (!s->busy || !nbytes) + return 0; + if (s->busy != file) + return -EACCES; add_wait_queue(&async->wait_head, &wait); while (nbytes > 0 && !retval) { @@ -1970,14 +2001,12 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, n = m; if (n == 0) { - if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) { + if (!comedi_is_subdevice_running(s)) { do_become_nonbusy(dev, s); - if (comedi_get_subdevice_runflags(s) & - SRF_ERROR) { + if (comedi_is_subdevice_in_error(s)) retval = -EPIPE; - } else { + else retval = 0; - } break; } if (file->f_flags & O_NONBLOCK) { @@ -2015,48 +2044,22 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, buf += n; break; /* makes device work like a pipe */ } - if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR | SRF_RUNNING)) && + if (comedi_is_subdevice_idle(s) && async->buf_read_count - async->buf_write_count == 0) { do_become_nonbusy(dev, s); } set_current_state(TASK_RUNNING); remove_wait_queue(&async->wait_head, &wait); -done: return count ? count : retval; } -/* - This function restores a subdevice to an idle state. - */ -static void do_become_nonbusy(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct comedi_async *async = s->async; - - comedi_set_subdevice_runflags(s, SRF_RUNNING, 0); - if (async) { - comedi_reset_async_buf(async); - async->inttrig = NULL; - kfree(async->cmd.chanlist); - async->cmd.chanlist = NULL; - } else { - dev_err(dev->class_dev, - "BUG: (?) do_become_nonbusy called with async=NULL\n"); - } - - s->busy = NULL; -} - static int comedi_open(struct inode *inode, struct file *file) { const unsigned minor = iminor(inode); - struct comedi_device_file_info *dev_file_info = - comedi_get_device_file_info(minor); - struct comedi_device *dev = - dev_file_info ? dev_file_info->device : NULL; + struct comedi_device *dev = comedi_dev_from_minor(minor); - if (dev == NULL) { + if (!dev) { DPRINTK("invalid minor number\n"); return -ENODEV; } @@ -2128,19 +2131,25 @@ ok: return 0; } +static int comedi_fasync(int fd, struct file *file, int on) +{ + const unsigned minor = iminor(file->f_dentry->d_inode); + struct comedi_device *dev = comedi_dev_from_minor(minor); + + if (!dev) + return -ENODEV; + + return fasync_helper(fd, file, on, &dev->async_queue); +} + static int comedi_close(struct inode *inode, struct file *file) { const unsigned minor = iminor(inode); + struct comedi_device *dev = comedi_dev_from_minor(minor); struct comedi_subdevice *s = NULL; int i; - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) + if (!dev) return -ENODEV; mutex_lock(&dev->mutex); @@ -2172,22 +2181,6 @@ static int comedi_close(struct inode *inode, struct file *file) return 0; } -static int comedi_fasync(int fd, struct file *file, int on) -{ - const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_device_file_info *dev_file_info; - struct comedi_device *dev; - dev_file_info = comedi_get_device_file_info(minor); - - if (dev_file_info == NULL) - return -ENODEV; - dev = dev_file_info->device; - if (dev == NULL) - return -ENODEV; - - return fasync_helper(fd, file, on, &dev->async_queue); -} - static const struct file_operations comedi_fops = { .owner = THIS_MODULE, .unlocked_ioctl = comedi_unlocked_ioctl, @@ -2205,99 +2198,6 @@ static const struct file_operations comedi_fops = { static struct class *comedi_class; static struct cdev comedi_cdev; -static void comedi_cleanup_legacy_minors(void) -{ - unsigned i; - - for (i = 0; i < comedi_num_legacy_minors; i++) - comedi_free_board_minor(i); -} - -static int __init comedi_init(void) -{ - int i; - int retval; - - pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n"); - - if (comedi_num_legacy_minors < 0 || - comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) { - pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\". Valid values are 0 through %i.\n", - COMEDI_NUM_BOARD_MINORS); - return -EINVAL; - } - - /* - * comedi is unusable if both comedi_autoconfig and - * comedi_num_legacy_minors are zero, so we might as well adjust the - * defaults in that case - */ - if (comedi_autoconfig == 0 && comedi_num_legacy_minors == 0) - comedi_num_legacy_minors = 16; - - memset(comedi_file_info_table, 0, - sizeof(struct comedi_device_file_info *) * COMEDI_NUM_MINORS); - - retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0), - COMEDI_NUM_MINORS, "comedi"); - if (retval) - return -EIO; - cdev_init(&comedi_cdev, &comedi_fops); - comedi_cdev.owner = THIS_MODULE; - kobject_set_name(&comedi_cdev.kobj, "comedi"); - if (cdev_add(&comedi_cdev, MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS)) { - unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), - COMEDI_NUM_MINORS); - return -EIO; - } - comedi_class = class_create(THIS_MODULE, "comedi"); - if (IS_ERR(comedi_class)) { - pr_err("comedi: failed to create class\n"); - cdev_del(&comedi_cdev); - unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), - COMEDI_NUM_MINORS); - return PTR_ERR(comedi_class); - } - - comedi_class->dev_attrs = comedi_dev_attrs; - - /* XXX requires /proc interface */ - comedi_proc_init(); - - /* create devices files for legacy/manual use */ - for (i = 0; i < comedi_num_legacy_minors; i++) { - int minor; - minor = comedi_alloc_board_minor(NULL); - if (minor < 0) { - comedi_cleanup_legacy_minors(); - cdev_del(&comedi_cdev); - unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), - COMEDI_NUM_MINORS); - return minor; - } - } - - return 0; -} - -static void __exit comedi_cleanup(void) -{ - int i; - - comedi_cleanup_legacy_minors(); - for (i = 0; i < COMEDI_NUM_MINORS; ++i) - BUG_ON(comedi_file_info_table[i]); - - class_destroy(comedi_class); - cdev_del(&comedi_cdev); - unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); - - comedi_proc_cleanup(); -} - -module_init(comedi_init); -module_exit(comedi_cleanup); - void comedi_error(const struct comedi_device *dev, const char *s) { dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s); @@ -2312,7 +2212,7 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) /* DPRINTK("comedi_event 0x%x\n",mask); */ - if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0) + if (!comedi_is_subdevice_running(s)) return; if (s-> @@ -2347,40 +2247,9 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) } EXPORT_SYMBOL(comedi_event); -unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) -{ - unsigned long flags; - unsigned runflags; - - spin_lock_irqsave(&s->spin_lock, flags); - runflags = s->runflags; - spin_unlock_irqrestore(&s->spin_lock, flags); - return runflags; -} -EXPORT_SYMBOL(comedi_get_subdevice_runflags); - -static int is_device_busy(struct comedi_device *dev) -{ - struct comedi_subdevice *s; - int i; - - if (!dev->attached) - return 0; - - for (i = 0; i < dev->n_subdevices; i++) { - s = &dev->subdevices[i]; - if (s->busy) - return 1; - if (s->async && s->async->mmap_count) - return 1; - } - - return 0; -} - static void comedi_device_init(struct comedi_device *dev) { - memset(dev, 0, sizeof(struct comedi_device)); + memset(dev, 0, sizeof(*dev)); spin_lock_init(&dev->spinlock); mutex_init(&dev->mutex); dev->minor = -1; @@ -2398,11 +2267,11 @@ static void comedi_device_cleanup(struct comedi_device *dev) int comedi_alloc_board_minor(struct device *hardware_device) { - struct comedi_device_file_info *info; + struct comedi_file_info *info; struct device *csdev; unsigned i; - info = kzalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; info->device = kzalloc(sizeof(struct comedi_device), GFP_KERNEL); @@ -2439,7 +2308,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) void comedi_free_board_minor(unsigned minor) { - struct comedi_device_file_info *info; + struct comedi_file_info *info; BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS); spin_lock(&comedi_file_info_table_lock); @@ -2464,7 +2333,7 @@ void comedi_free_board_minor(unsigned minor) int comedi_find_board_minor(struct device *hardware_device) { int minor; - struct comedi_device_file_info *info; + struct comedi_file_info *info; for (minor = 0; minor < COMEDI_NUM_BOARD_MINORS; minor++) { spin_lock(&comedi_file_info_table_lock); @@ -2478,19 +2347,21 @@ int comedi_find_board_minor(struct device *hardware_device) return -ENODEV; } -int comedi_alloc_subdevice_minor(struct comedi_device *dev, - struct comedi_subdevice *s) +int comedi_alloc_subdevice_minor(struct comedi_subdevice *s) { - struct comedi_device_file_info *info; + struct comedi_device *dev = s->device; + struct comedi_file_info *info; struct device *csdev; unsigned i; - info = kmalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL); - if (info == NULL) + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) return -ENOMEM; info->device = dev; - info->read_subdevice = s; - info->write_subdevice = s; + if (s->subdev_flags & SDF_CMD_READ) + info->read_subdevice = s; + if (s->subdev_flags & SDF_CMD_WRITE) + info->write_subdevice = s; spin_lock(&comedi_file_info_table_lock); for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) { if (comedi_file_info_table[i] == NULL) { @@ -2501,23 +2372,23 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, spin_unlock(&comedi_file_info_table_lock); if (i == COMEDI_NUM_MINORS) { kfree(info); - pr_err("comedi: error: ran out of minor numbers for board device files.\n"); + pr_err("comedi: error: ran out of minor numbers for subdevice files.\n"); return -EBUSY; } s->minor = i; csdev = device_create(comedi_class, dev->class_dev, MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i_subd%i", - dev->minor, (int)(s - dev->subdevices)); + dev->minor, s->index); if (!IS_ERR(csdev)) s->class_dev = csdev; dev_set_drvdata(csdev, info); - return i; + return 0; } void comedi_free_subdevice_minor(struct comedi_subdevice *s) { - struct comedi_device_file_info *info; + struct comedi_file_info *info; if (s == NULL) return; @@ -2539,14 +2410,90 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s) kfree(info); } -struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor) +static void comedi_cleanup_board_minors(void) { - struct comedi_device_file_info *info; + unsigned i; - BUG_ON(minor >= COMEDI_NUM_MINORS); - spin_lock(&comedi_file_info_table_lock); - info = comedi_file_info_table[minor]; - spin_unlock(&comedi_file_info_table_lock); - return info; + for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) + comedi_free_board_minor(i); +} + +static int __init comedi_init(void) +{ + int i; + int retval; + + pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n"); + + if (comedi_num_legacy_minors < 0 || + comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) { + pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\". Valid values are 0 through %i.\n", + COMEDI_NUM_BOARD_MINORS); + return -EINVAL; + } + + memset(comedi_file_info_table, 0, + sizeof(struct comedi_file_info *) * COMEDI_NUM_MINORS); + + retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0), + COMEDI_NUM_MINORS, "comedi"); + if (retval) + return -EIO; + cdev_init(&comedi_cdev, &comedi_fops); + comedi_cdev.owner = THIS_MODULE; + kobject_set_name(&comedi_cdev.kobj, "comedi"); + if (cdev_add(&comedi_cdev, MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS)) { + unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), + COMEDI_NUM_MINORS); + return -EIO; + } + comedi_class = class_create(THIS_MODULE, "comedi"); + if (IS_ERR(comedi_class)) { + pr_err("comedi: failed to create class\n"); + cdev_del(&comedi_cdev); + unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), + COMEDI_NUM_MINORS); + return PTR_ERR(comedi_class); + } + + comedi_class->dev_attrs = comedi_dev_attrs; + + /* XXX requires /proc interface */ + comedi_proc_init(); + + /* create devices files for legacy/manual use */ + for (i = 0; i < comedi_num_legacy_minors; i++) { + int minor; + minor = comedi_alloc_board_minor(NULL); + if (minor < 0) { + comedi_cleanup_board_minors(); + cdev_del(&comedi_cdev); + unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), + COMEDI_NUM_MINORS); + return minor; + } + } + + return 0; } -EXPORT_SYMBOL_GPL(comedi_get_device_file_info); +module_init(comedi_init); + +static void __exit comedi_cleanup(void) +{ + int i; + + comedi_cleanup_board_minors(); + for (i = 0; i < COMEDI_NUM_MINORS; ++i) + BUG_ON(comedi_file_info_table[i]); + + class_destroy(comedi_class); + cdev_del(&comedi_cdev); + unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); + + comedi_proc_cleanup(); +} +module_exit(comedi_cleanup); + +MODULE_AUTHOR("http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi core module"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index e70ef051..b374313 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -8,18 +8,43 @@ */ int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo __user *arg); -int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); int comedi_alloc_board_minor(struct device *hardware_device); void comedi_free_board_minor(unsigned minor); int comedi_find_board_minor(struct device *hardware_device); -void comedi_reset_async_buf(struct comedi_async *async); +int comedi_alloc_subdevice_minor(struct comedi_subdevice *s); +void comedi_free_subdevice_minor(struct comedi_subdevice *s); + int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); +void comedi_buf_reset(struct comedi_async *async); +unsigned int comedi_buf_write_n_allocated(struct comedi_async *async); extern unsigned int comedi_default_buf_size_kb; extern unsigned int comedi_default_buf_maxsize_kb; -extern bool comedi_autoconfig; + +/* drivers.c */ + extern struct comedi_driver *comedi_drivers; +int insn_inval(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *); + +void comedi_device_detach(struct comedi_device *); +int comedi_device_attach(struct comedi_device *, struct comedi_devconfig *); + +#ifdef CONFIG_PROC_FS + +/* proc.c */ + +void comedi_proc_init(void); +void comedi_proc_cleanup(void); +#else +static inline void comedi_proc_init(void) +{ +} +static inline void comedi_proc_cleanup(void) +{ +} +#endif + #endif /* _COMEDI_INTERNAL_H */ diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c new file mode 100644 index 0000000..37d2e46 --- /dev/null +++ b/drivers/staging/comedi/comedi_pci.c @@ -0,0 +1,140 @@ +/* + * comedi_pci.c + * Comedi PCI driver specific functions. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> + * + * 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/pci.h> + +#include "comedidev.h" + +/** + * comedi_to_pci_dev() - comedi_device pointer to pci_dev pointer. + * @dev: comedi_device struct + */ +struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) +{ + return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL; +} +EXPORT_SYMBOL_GPL(comedi_to_pci_dev); + +/** + * comedi_pci_enable() - Enable the PCI device and request the regions. + * @pcidev: pci_dev struct + * @res_name: name for the requested reqource + */ +int comedi_pci_enable(struct pci_dev *pcidev, const char *res_name) +{ + int rc; + + rc = pci_enable_device(pcidev); + if (rc < 0) + return rc; + + rc = pci_request_regions(pcidev, res_name); + if (rc < 0) + pci_disable_device(pcidev); + + return rc; +} +EXPORT_SYMBOL_GPL(comedi_pci_enable); + +/** + * comedi_pci_disable() - Release the regions and disable the PCI device. + * @pcidev: pci_dev struct + * + * This must be matched with a previous successful call to comedi_pci_enable(). + */ +void comedi_pci_disable(struct pci_dev *pcidev) +{ + pci_release_regions(pcidev); + pci_disable_device(pcidev); +} +EXPORT_SYMBOL_GPL(comedi_pci_disable); + +/** + * comedi_pci_auto_config() - Configure/probe a comedi PCI driver. + * @pcidev: pci_dev struct + * @driver: comedi_driver struct + * + * Typically called from the pci_driver (*probe) function. + */ +int comedi_pci_auto_config(struct pci_dev *pcidev, + struct comedi_driver *driver) +{ + return comedi_auto_config(&pcidev->dev, driver, 0); +} +EXPORT_SYMBOL_GPL(comedi_pci_auto_config); + +/** + * comedi_pci_auto_unconfig() - Unconfigure/remove a comedi PCI driver. + * @pcidev: pci_dev struct + * + * Typically called from the pci_driver (*remove) function. + */ +void comedi_pci_auto_unconfig(struct pci_dev *pcidev) +{ + comedi_auto_unconfig(&pcidev->dev); +} +EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig); + +/** + * comedi_pci_driver_register() - Register a comedi PCI driver. + * @comedi_driver: comedi_driver struct + * @pci_driver: pci_driver struct + * + * This function is used for the module_init() of comedi PCI drivers. + * Do not call it directly, use the module_comedi_pci_driver() helper + * macro instead. + */ +int comedi_pci_driver_register(struct comedi_driver *comedi_driver, + struct pci_driver *pci_driver) +{ + int ret; + + ret = comedi_driver_register(comedi_driver); + if (ret < 0) + return ret; + + ret = pci_register_driver(pci_driver); + if (ret < 0) { + comedi_driver_unregister(comedi_driver); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_pci_driver_register); + +/** + * comedi_pci_driver_unregister() - Unregister a comedi PCI driver. + * @comedi_driver: comedi_driver struct + * @pci_driver: pci_driver struct + * + * This function is used for the module_exit() of comedi PCI drivers. + * Do not call it directly, use the module_comedi_pci_driver() helper + * macro instead. + */ +void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver, + struct pci_driver *pci_driver) +{ + pci_unregister_driver(pci_driver); + comedi_driver_unregister(comedi_driver); +} +EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister); diff --git a/drivers/staging/comedi/comedi_pcmcia.c b/drivers/staging/comedi/comedi_pcmcia.c new file mode 100644 index 0000000..453ff3b --- /dev/null +++ b/drivers/staging/comedi/comedi_pcmcia.c @@ -0,0 +1,160 @@ +/* + * comedi_pcmcia.c + * Comedi PCMCIA driver specific functions. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> + * + * 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/kernel.h> + +#include <pcmcia/cistpl.h> +#include <pcmcia/ds.h> + +#include "comedidev.h" + +/** + * comedi_to_pcmcia_dev() - comedi_device pointer to pcmcia_device pointer. + * @dev: comedi_device struct + */ +struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *dev) +{ + return dev->hw_dev ? to_pcmcia_dev(dev->hw_dev) : NULL; +} +EXPORT_SYMBOL_GPL(comedi_to_pcmcia_dev); + +static int comedi_pcmcia_conf_check(struct pcmcia_device *link, + void *priv_data) +{ + if (link->config_index == 0) + return -EINVAL; + + return pcmcia_request_io(link); +} + +/** + * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device. + * @dev: comedi_device struct + * @conf_check: optional callback to check the pcmcia_device configuration + * + * The comedi PCMCIA driver needs to set the link->config_flags, as + * appropriate for that driver, before calling this function in order + * to allow pcmcia_loop_config() to do its internal autoconfiguration. + */ +int comedi_pcmcia_enable(struct comedi_device *dev, + int (*conf_check)(struct pcmcia_device *, void *)) +{ + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); + int ret; + + if (!link) + return -ENODEV; + + if (!conf_check) + conf_check = comedi_pcmcia_conf_check; + + ret = pcmcia_loop_config(link, conf_check, NULL); + if (ret) + return ret; + + return pcmcia_enable_device(link); +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_enable); + +/** + * comedi_pcmcia_disable() - Disable the PCMCIA device and release the regions. + * @dev: comedi_device struct + */ +void comedi_pcmcia_disable(struct comedi_device *dev) +{ + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); + + if (link) + pcmcia_disable_device(link); +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_disable); + +/** + * comedi_pcmcia_auto_config() - Configure/probe a comedi PCMCIA driver. + * @link: pcmcia_device struct + * @driver: comedi_driver struct + * + * Typically called from the pcmcia_driver (*probe) function. + */ +int comedi_pcmcia_auto_config(struct pcmcia_device *link, + struct comedi_driver *driver) +{ + return comedi_auto_config(&link->dev, driver, 0); +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_config); + +/** + * comedi_pcmcia_auto_unconfig() - Unconfigure/remove a comedi PCMCIA driver. + * @link: pcmcia_device struct + * + * Typically called from the pcmcia_driver (*remove) function. + */ +void comedi_pcmcia_auto_unconfig(struct pcmcia_device *link) +{ + comedi_auto_unconfig(&link->dev); +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_unconfig); + +/** + * comedi_pcmcia_driver_register() - Register a comedi PCMCIA driver. + * @comedi_driver: comedi_driver struct + * @pcmcia_driver: pcmcia_driver struct + * + * This function is used for the module_init() of comedi USB drivers. + * Do not call it directly, use the module_comedi_pcmcia_driver() helper + * macro instead. + */ +int comedi_pcmcia_driver_register(struct comedi_driver *comedi_driver, + struct pcmcia_driver *pcmcia_driver) +{ + int ret; + + ret = comedi_driver_register(comedi_driver); + if (ret < 0) + return ret; + + ret = pcmcia_register_driver(pcmcia_driver); + if (ret < 0) { + comedi_driver_unregister(comedi_driver); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register); + +/** + * comedi_pcmcia_driver_unregister() - Unregister a comedi PCMCIA driver. + * @comedi_driver: comedi_driver struct + * @pcmcia_driver: pcmcia_driver struct + * + * This function is used for the module_exit() of comedi PCMCIA drivers. + * Do not call it directly, use the module_comedi_pcmcia_driver() helper + * macro instead. + */ +void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver, + struct pcmcia_driver *pcmcia_driver) +{ + pcmcia_unregister_driver(pcmcia_driver); + comedi_driver_unregister(comedi_driver); +} +EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister); diff --git a/drivers/staging/comedi/comedi_usb.c b/drivers/staging/comedi/comedi_usb.c new file mode 100644 index 0000000..9d9716a --- /dev/null +++ b/drivers/staging/comedi/comedi_usb.c @@ -0,0 +1,108 @@ +/* + * comedi_usb.c + * Comedi USB driver specific functions. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> + * + * 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/usb.h> + +#include "comedidev.h" + +/** + * comedi_to_usb_interface() - comedi_device pointer to usb_interface pointer. + * @dev: comedi_device struct + */ +struct usb_interface *comedi_to_usb_interface(struct comedi_device *dev) +{ + return dev->hw_dev ? to_usb_interface(dev->hw_dev) : NULL; +} +EXPORT_SYMBOL_GPL(comedi_to_usb_interface); + +/** + * comedi_usb_auto_config() - Configure/probe a comedi USB driver. + * @intf: usb_interface struct + * @driver: comedi_driver struct + * @context: driver specific data, passed to comedi_auto_config() + * + * Typically called from the usb_driver (*probe) function. + */ +int comedi_usb_auto_config(struct usb_interface *intf, + struct comedi_driver *driver, + unsigned long context) +{ + return comedi_auto_config(&intf->dev, driver, context); +} +EXPORT_SYMBOL_GPL(comedi_usb_auto_config); + +/** + * comedi_pci_auto_unconfig() - Unconfigure/disconnect a comedi USB driver. + * @intf: usb_interface struct + * + * Typically called from the usb_driver (*disconnect) function. + */ +void comedi_usb_auto_unconfig(struct usb_interface *intf) +{ + comedi_auto_unconfig(&intf->dev); +} +EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig); + +/** + * comedi_usb_driver_register() - Register a comedi USB driver. + * @comedi_driver: comedi_driver struct + * @usb_driver: usb_driver struct + * + * This function is used for the module_init() of comedi USB drivers. + * Do not call it directly, use the module_comedi_usb_driver() helper + * macro instead. + */ +int comedi_usb_driver_register(struct comedi_driver *comedi_driver, + struct usb_driver *usb_driver) +{ + int ret; + + ret = comedi_driver_register(comedi_driver); + if (ret < 0) + return ret; + + ret = usb_register(usb_driver); + if (ret < 0) { + comedi_driver_unregister(comedi_driver); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_usb_driver_register); + +/** + * comedi_usb_driver_unregister() - Unregister a comedi USB driver. + * @comedi_driver: comedi_driver struct + * @usb_driver: usb_driver struct + * + * This function is used for the module_exit() of comedi USB drivers. + * Do not call it directly, use the module_comedi_usb_driver() helper + * macro instead. + */ +void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver, + struct usb_driver *usb_driver) +{ + usb_deregister(usb_driver); + comedi_driver_unregister(comedi_driver); +} +EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 692e1e6..f3a990b 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -40,8 +40,6 @@ #include <linux/uaccess.h> #include <linux/io.h> #include <linux/timer.h> -#include <linux/pci.h> -#include <linux/usb.h> #include "comedi.h" @@ -55,28 +53,13 @@ COMEDI_MINORVERSION, COMEDI_MICROVERSION) #define COMEDI_RELEASE VERSION -/* - * PCI Vendor IDs not in <linux/pci_ids.h> - */ -#define PCI_VENDOR_ID_KOLTER 0x1001 -#define PCI_VENDOR_ID_ICP 0x104c -#define PCI_VENDOR_ID_AMCC 0x10e8 -#define PCI_VENDOR_ID_DT 0x1116 -#define PCI_VENDOR_ID_IOTECH 0x1616 -#define PCI_VENDOR_ID_CONTEC 0x1221 -#define PCI_VENDOR_ID_CB 0x1307 /* Measurement Computing */ -#define PCI_VENDOR_ID_ADVANTECH 0x13fe -#define PCI_VENDOR_ID_MEILHAUS 0x1402 -#define PCI_VENDOR_ID_RTD 0x1435 -#define PCI_VENDOR_ID_ADLINK 0x144a -#define PCI_VENDOR_ID_AMPLICON 0x14dc - #define COMEDI_NUM_MINORS 0x100 #define COMEDI_NUM_BOARD_MINORS 0x30 #define COMEDI_FIRST_SUBDEVICE_MINOR COMEDI_NUM_BOARD_MINORS struct comedi_subdevice { struct comedi_device *device; + int index; int type; int n_chan; int subdev_flags; @@ -250,13 +233,6 @@ static inline const void *comedi_board(const struct comedi_device *dev) return dev->board_ptr; } -struct comedi_device_file_info { - struct comedi_device *device; - struct comedi_subdevice *read_subdevice; - struct comedi_subdevice *write_subdevice; - struct device *hardware_device; -}; - #ifdef CONFIG_COMEDI_DEBUG extern int comedi_debug; #else @@ -280,105 +256,13 @@ enum comedi_minor_bits { static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4; static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1; -struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor); - -static inline struct comedi_subdevice *comedi_get_read_subdevice( - const struct comedi_device_file_info *info) -{ - if (info->read_subdevice) - return info->read_subdevice; - if (info->device == NULL) - return NULL; - return info->device->read_subdev; -} - -static inline struct comedi_subdevice *comedi_get_write_subdevice( - const struct comedi_device_file_info *info) -{ - if (info->write_subdevice) - return info->write_subdevice; - if (info->device == NULL) - return NULL; - return info->device->write_subdev; -} - -int comedi_alloc_subdevices(struct comedi_device *, int); - -void comedi_device_detach(struct comedi_device *dev); -int comedi_device_attach(struct comedi_device *dev, - struct comedi_devconfig *it); -int comedi_driver_register(struct comedi_driver *); -int comedi_driver_unregister(struct comedi_driver *); - -/** - * module_comedi_driver() - Helper macro for registering a comedi driver - * @__comedi_driver: comedi_driver struct - * - * Helper macro for comedi drivers which do not do anything special in module - * init/exit. This eliminates a lot of boilerplate. Each module may only use - * this macro once, and calling it replaces module_init() and module_exit(). - */ -#define module_comedi_driver(__comedi_driver) \ - module_driver(__comedi_driver, comedi_driver_register, \ - comedi_driver_unregister) - -int comedi_pci_enable(struct pci_dev *, const char *); -void comedi_pci_disable(struct pci_dev *); - -int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *); -void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); - -/** - * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver - * @__comedi_driver: comedi_driver struct - * @__pci_driver: pci_driver struct - * - * Helper macro for comedi PCI drivers which do not do anything special - * in module init/exit. This eliminates a lot of boilerplate. Each - * module may only use this macro once, and calling it replaces - * module_init() and module_exit() - */ -#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \ - module_driver(__comedi_driver, comedi_pci_driver_register, \ - comedi_pci_driver_unregister, &(__pci_driver)) - -struct usb_driver; - -int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *); -void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *); - -/** - * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver - * @__comedi_driver: comedi_driver struct - * @__usb_driver: usb_driver struct - * - * Helper macro for comedi USB drivers which do not do anything special - * in module init/exit. This eliminates a lot of boilerplate. Each - * module may only use this macro once, and calling it replaces - * module_init() and module_exit() - */ -#define module_comedi_usb_driver(__comedi_driver, __usb_driver) \ - module_driver(__comedi_driver, comedi_usb_driver_register, \ - comedi_usb_driver_unregister, &(__usb_driver)) +struct comedi_device *comedi_dev_from_minor(unsigned minor); void init_polling(void); void cleanup_polling(void); void start_polling(struct comedi_device *); void stop_polling(struct comedi_device *); -#ifdef CONFIG_PROC_FS -void comedi_proc_init(void); -void comedi_proc_cleanup(void); -#else -static inline void comedi_proc_init(void) -{ -} - -static inline void comedi_proc_cleanup(void) -{ -} -#endif - /* subdevice runflags */ enum subdevice_runflags { SRF_USER = 0x00000001, @@ -389,10 +273,11 @@ enum subdevice_runflags { SRF_RUNNING = 0x08000000 }; +bool comedi_is_subdevice_running(struct comedi_subdevice *s); + int comedi_check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist); -unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s); /* range stuff */ @@ -433,111 +318,186 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) return sizeof(short); } -/* must be used in attach to set dev->hw_dev if you wish to dma directly -into comedi's buffer */ -static inline void comedi_set_hw_dev(struct comedi_device *dev, - struct device *hw_dev) -{ - if (dev->hw_dev == hw_dev) - return; - if (dev->hw_dev) - put_device(dev->hw_dev); - dev->hw_dev = hw_dev; - if (dev->hw_dev) { - dev->hw_dev = get_device(dev->hw_dev); - BUG_ON(dev->hw_dev == NULL); - } -} +/* + * Must set dev->hw_dev if you wish to dma directly into comedi's buffer. + * Also useful for retrieving a previously configured hardware device of + * known bus type. Set automatically for auto-configured devices. + * Automatically set to NULL when detaching hardware device. + */ +int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); -static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) -{ - return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL; -} +unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int); +unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int); -static inline struct usb_interface * -comedi_to_usb_interface(struct comedi_device *dev) -{ - return dev->hw_dev ? to_usb_interface(dev->hw_dev) : NULL; -} +unsigned int comedi_buf_read_n_available(struct comedi_async *); +unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); +unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); + +int comedi_buf_put(struct comedi_async *, short); +int comedi_buf_get(struct comedi_async *, short *); -int comedi_buf_put(struct comedi_async *async, short x); -int comedi_buf_get(struct comedi_async *async, short *x); - -unsigned int comedi_buf_write_n_available(struct comedi_async *async); -unsigned int comedi_buf_write_alloc(struct comedi_async *async, - unsigned int nbytes); -unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async, - unsigned int nbytes); -unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes); -unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes); -unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes); -unsigned int comedi_buf_read_n_available(struct comedi_async *async); void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, const void *source, unsigned int num_bytes); void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, void *destination, unsigned int num_bytes); -static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async) -{ - return async->buf_write_alloc_count - async->buf_write_count; -} -static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async) -{ - return async->buf_read_alloc_count - async->buf_read_count; -} +/* drivers.c - general comedi driver functions */ -static inline void *comedi_aux_data(int options[], int n) -{ - unsigned long address; - unsigned long addressLow; - int bit_shift; - if (sizeof(int) >= sizeof(void *)) - address = options[COMEDI_DEVCONF_AUX_DATA_LO]; - else { - address = options[COMEDI_DEVCONF_AUX_DATA_HI]; - bit_shift = sizeof(int) * 8; - address <<= bit_shift; - addressLow = options[COMEDI_DEVCONF_AUX_DATA_LO]; - addressLow &= (1UL << bit_shift) - 1; - address |= addressLow; - } - if (n >= 1) - address += options[COMEDI_DEVCONF_AUX_DATA0_LENGTH]; - if (n >= 2) - address += options[COMEDI_DEVCONF_AUX_DATA1_LENGTH]; - if (n >= 3) - address += options[COMEDI_DEVCONF_AUX_DATA2_LENGTH]; - BUG_ON(n > 3); - return (void *)address; -} +int comedi_alloc_subdevices(struct comedi_device *, int); -int comedi_alloc_subdevice_minor(struct comedi_device *dev, - struct comedi_subdevice *s); -void comedi_free_subdevice_minor(struct comedi_subdevice *s); -int comedi_auto_config(struct device *hardware_device, - struct comedi_driver *driver, unsigned long context); -void comedi_auto_unconfig(struct device *hardware_device); +int comedi_auto_config(struct device *, struct comedi_driver *, + unsigned long context); +void comedi_auto_unconfig(struct device *); -static inline int comedi_pci_auto_config(struct pci_dev *pcidev, - struct comedi_driver *driver) -{ - return comedi_auto_config(&pcidev->dev, driver, 0); -} +int comedi_driver_register(struct comedi_driver *); +int comedi_driver_unregister(struct comedi_driver *); + +/** + * module_comedi_driver() - Helper macro for registering a comedi driver + * @__comedi_driver: comedi_driver struct + * + * Helper macro for comedi drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only use + * this macro once, and calling it replaces module_init() and module_exit(). + */ +#define module_comedi_driver(__comedi_driver) \ + module_driver(__comedi_driver, comedi_driver_register, \ + comedi_driver_unregister) + +#ifdef CONFIG_COMEDI_PCI_DRIVERS + +/* comedi_pci.c - comedi PCI driver specific functions */ + +/* + * PCI Vendor IDs not in <linux/pci_ids.h> + */ +#define PCI_VENDOR_ID_KOLTER 0x1001 +#define PCI_VENDOR_ID_ICP 0x104c +#define PCI_VENDOR_ID_AMCC 0x10e8 +#define PCI_VENDOR_ID_DT 0x1116 +#define PCI_VENDOR_ID_IOTECH 0x1616 +#define PCI_VENDOR_ID_CONTEC 0x1221 +#define PCI_VENDOR_ID_RTD 0x1435 + +struct pci_dev; +struct pci_driver; + +struct pci_dev *comedi_to_pci_dev(struct comedi_device *); + +int comedi_pci_enable(struct pci_dev *, const char *); +void comedi_pci_disable(struct pci_dev *); + +int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *); +void comedi_pci_auto_unconfig(struct pci_dev *); + +int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *); +void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); + +/** + * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver + * @__comedi_driver: comedi_driver struct + * @__pci_driver: pci_driver struct + * + * Helper macro for comedi PCI drivers which do not do anything special + * in module init/exit. This eliminates a lot of boilerplate. Each + * module may only use this macro once, and calling it replaces + * module_init() and module_exit() + */ +#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \ + module_driver(__comedi_driver, comedi_pci_driver_register, \ + comedi_pci_driver_unregister, &(__pci_driver)) -static inline void comedi_pci_auto_unconfig(struct pci_dev *pcidev) +#else + +/* + * Some of the comedi mixed ISA/PCI drivers call the PCI specific + * functions. Provide some dummy functions if CONFIG_COMEDI_PCI_DRIVERS + * is not enabled. + */ + +static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) { - comedi_auto_unconfig(&pcidev->dev); + return NULL; } -static inline int comedi_usb_auto_config(struct usb_interface *intf, - struct comedi_driver *driver) +static inline int comedi_pci_enable(struct pci_dev *dev, const char *name) { - return comedi_auto_config(&intf->dev, driver, 0); + return -ENOSYS; } -static inline void comedi_usb_auto_unconfig(struct usb_interface *intf) +static inline void comedi_pci_disable(struct pci_dev *dev) { - comedi_auto_unconfig(&intf->dev); } +#endif /* CONFIG_COMEDI_PCI_DRIVERS */ + +#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS + +/* comedi_pcmcia.c - comedi PCMCIA driver specific functions */ + +struct pcmcia_driver; +struct pcmcia_device; + +struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *); + +int comedi_pcmcia_enable(struct comedi_device *, + int (*conf_check)(struct pcmcia_device *, void *)); +void comedi_pcmcia_disable(struct comedi_device *); + +int comedi_pcmcia_auto_config(struct pcmcia_device *, struct comedi_driver *); +void comedi_pcmcia_auto_unconfig(struct pcmcia_device *); + +int comedi_pcmcia_driver_register(struct comedi_driver *, + struct pcmcia_driver *); +void comedi_pcmcia_driver_unregister(struct comedi_driver *, + struct pcmcia_driver *); + +/** + * module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver + * @__comedi_driver: comedi_driver struct + * @__pcmcia_driver: pcmcia_driver struct + * + * Helper macro for comedi PCMCIA drivers which do not do anything special + * in module init/exit. This eliminates a lot of boilerplate. Each + * module may only use this macro once, and calling it replaces + * module_init() and module_exit() + */ +#define module_comedi_pcmcia_driver(__comedi_driver, __pcmcia_driver) \ + module_driver(__comedi_driver, comedi_pcmcia_driver_register, \ + comedi_pcmcia_driver_unregister, &(__pcmcia_driver)) + +#endif /* CONFIG_COMEDI_PCMCIA_DRIVERS */ + +#ifdef CONFIG_COMEDI_USB_DRIVERS + +/* comedi_usb.c - comedi USB driver specific functions */ + +struct usb_driver; +struct usb_interface; + +struct usb_interface *comedi_to_usb_interface(struct comedi_device *); + +int comedi_usb_auto_config(struct usb_interface *, struct comedi_driver *, + unsigned long context); +void comedi_usb_auto_unconfig(struct usb_interface *); + +int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *); +void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *); + +/** + * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver + * @__comedi_driver: comedi_driver struct + * @__usb_driver: usb_driver struct + * + * Helper macro for comedi USB drivers which do not do anything special + * in module init/exit. This eliminates a lot of boilerplate. Each + * module may only use this macro once, and calling it replaces + * module_init() and module_exit() + */ +#define module_comedi_usb_driver(__comedi_driver, __usb_driver) \ + module_driver(__comedi_driver, comedi_usb_driver_register, \ + comedi_usb_driver_unregister, &(__usb_driver)) + +#endif /* CONFIG_COMEDI_USB_DRIVERS */ + #endif /* _COMEDIDEV_H */ diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 50cf498..64be7c5 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -23,8 +23,6 @@ #include <linux/device.h> #include <linux/module.h> -#include <linux/pci.h> -#include <linux/usb.h> #include <linux/errno.h> #include <linux/kconfig.h> #include <linux/kernel.h> @@ -43,16 +41,25 @@ #include "comedidev.h" #include "comedi_internal.h" -static int postconfig(struct comedi_device *dev); -static int insn_rw_emulate_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static void *comedi_recognize(struct comedi_driver *driv, const char *name); -static void comedi_report_boards(struct comedi_driver *driv); -static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s); - struct comedi_driver *comedi_drivers; +int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev) +{ + if (hw_dev == dev->hw_dev) + return 0; + if (dev->hw_dev != NULL) + return -EEXIST; + dev->hw_dev = get_device(hw_dev); + return 0; +} +EXPORT_SYMBOL_GPL(comedi_set_hw_dev); + +static void comedi_clear_hw_dev(struct comedi_device *dev) +{ + put_device(dev->hw_dev); + dev->hw_dev = NULL; +} + int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) { struct comedi_subdevice *s; @@ -70,6 +77,7 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) for (i = 0; i < num_subdevices; ++i) { s = &dev->subdevices[i]; s->device = dev; + s->index = i; s->async_dma_dir = DMA_NONE; spin_lock_init(&s->spin_lock); s->minor = -1; @@ -107,7 +115,7 @@ static void cleanup_device(struct comedi_device *dev) dev->write_subdev = NULL; dev->open = NULL; dev->close = NULL; - comedi_set_hw_dev(dev, NULL); + comedi_clear_hw_dev(dev); } static void __comedi_device_detach(struct comedi_device *dev) @@ -128,131 +136,105 @@ void comedi_device_detach(struct comedi_device *dev) __comedi_device_detach(dev); } -/* do a little post-config cleanup */ -/* called with module refcount incremented, decrements it */ -static int comedi_device_postconfig(struct comedi_device *dev) +static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) { - int ret = postconfig(dev); - module_put(dev->driver->module); - if (ret < 0) { - __comedi_device_detach(dev); - return ret; - } - if (!dev->board_name) { - dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n"); - dev->board_name = "BUG"; - } - smp_wmb(); - dev->attached = 1; - return 0; + return -EINVAL; } -int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) +int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - struct comedi_driver *driv; + return -EINVAL; +} + +static int insn_rw_emulate_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct comedi_insn new_insn; int ret; + static const unsigned channels_per_bitfield = 32; - if (dev->attached) - return -EBUSY; + unsigned chan = CR_CHAN(insn->chanspec); + const unsigned base_bitfield_channel = + (chan < channels_per_bitfield) ? 0 : chan; + unsigned int new_data[2]; + memset(new_data, 0, sizeof(new_data)); + memset(&new_insn, 0, sizeof(new_insn)); + new_insn.insn = INSN_BITS; + new_insn.chanspec = base_bitfield_channel; + new_insn.n = 2; + new_insn.subdev = insn->subdev; - for (driv = comedi_drivers; driv; driv = driv->next) { - if (!try_module_get(driv->module)) - continue; - if (driv->num_names) { - dev->board_ptr = comedi_recognize(driv, it->board_name); - if (dev->board_ptr) - break; - } else if (strcmp(driv->driver_name, it->board_name) == 0) - break; - module_put(driv->module); - } - if (driv == NULL) { - /* recognize has failed if we get here */ - /* report valid board names before returning error */ - for (driv = comedi_drivers; driv; driv = driv->next) { - if (!try_module_get(driv->module)) - continue; - comedi_report_boards(driv); - module_put(driv->module); - } - return -EIO; - } - if (driv->attach == NULL) { - /* driver does not support manual configuration */ - dev_warn(dev->class_dev, - "driver '%s' does not support attach using comedi_config\n", - driv->driver_name); - module_put(driv->module); - return -ENOSYS; + if (insn->insn == INSN_WRITE) { + if (!(s->subdev_flags & SDF_WRITABLE)) + return -EINVAL; + new_data[0] = 1 << (chan - base_bitfield_channel); /* mask */ + new_data[1] = data[0] ? (1 << (chan - base_bitfield_channel)) + : 0; /* bits */ } - /* initialize dev->driver here so - * comedi_error() can be called from attach */ - dev->driver = driv; - ret = driv->attach(dev, it); - if (ret < 0) { - module_put(dev->driver->module); - __comedi_device_detach(dev); + + ret = s->insn_bits(dev, s, &new_insn, new_data); + if (ret < 0) return ret; - } - return comedi_device_postconfig(dev); -} -int comedi_driver_register(struct comedi_driver *driver) -{ - driver->next = comedi_drivers; - comedi_drivers = driver; + if (insn->insn == INSN_READ) + data[0] = (new_data[1] >> (chan - base_bitfield_channel)) & 1; - return 0; + return 1; } -EXPORT_SYMBOL(comedi_driver_register); -int comedi_driver_unregister(struct comedi_driver *driver) +static int __comedi_device_postconfig_async(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct comedi_driver *prev; - int i; + struct comedi_async *async; + unsigned int buf_size; + int ret; - /* check for devices using this driver */ - for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { - struct comedi_device_file_info *dev_file_info = - comedi_get_device_file_info(i); - struct comedi_device *dev; + if ((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0) { + dev_warn(dev->class_dev, + "async subdevices must support SDF_CMD_READ or SDF_CMD_WRITE\n"); + return -EINVAL; + } + if (!s->do_cmdtest) { + dev_warn(dev->class_dev, + "async subdevices must have a do_cmdtest() function\n"); + return -EINVAL; + } - if (dev_file_info == NULL) - continue; - dev = dev_file_info->device; + async = kzalloc(sizeof(*async), GFP_KERNEL); + if (!async) + return -ENOMEM; - mutex_lock(&dev->mutex); - if (dev->attached && dev->driver == driver) { - if (dev->use_count) - dev_warn(dev->class_dev, - "BUG! detaching device with use_count=%d\n", - dev->use_count); - comedi_device_detach(dev); - } - mutex_unlock(&dev->mutex); - } + init_waitqueue_head(&async->wait_head); + async->subdevice = s; + s->async = async; - if (comedi_drivers == driver) { - comedi_drivers = driver->next; - return 0; - } + async->max_bufsize = comedi_default_buf_maxsize_kb * 1024; + buf_size = comedi_default_buf_size_kb * 1024; + if (buf_size > async->max_bufsize) + buf_size = async->max_bufsize; - for (prev = comedi_drivers; prev->next; prev = prev->next) { - if (prev->next == driver) { - prev->next = driver->next; - return 0; - } + if (comedi_buf_alloc(dev, s, buf_size) < 0) { + dev_warn(dev->class_dev, "Buffer allocation failed\n"); + return -ENOMEM; } - return -EINVAL; + if (s->buf_change) { + ret = s->buf_change(dev, s, buf_size); + if (ret < 0) + return ret; + } + + comedi_alloc_subdevice_minor(s); + + return 0; } -EXPORT_SYMBOL(comedi_driver_unregister); -static int postconfig(struct comedi_device *dev) +static int __comedi_device_postconfig(struct comedi_device *dev) { - int i; struct comedi_subdevice *s; - struct comedi_async *async = NULL; int ret; + int i; for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; @@ -264,42 +246,9 @@ static int postconfig(struct comedi_device *dev) s->len_chanlist = 1; if (s->do_cmd) { - unsigned int buf_size; - - BUG_ON((s->subdev_flags & (SDF_CMD_READ | - SDF_CMD_WRITE)) == 0); - BUG_ON(!s->do_cmdtest); - - async = - kzalloc(sizeof(struct comedi_async), GFP_KERNEL); - if (async == NULL) { - dev_warn(dev->class_dev, - "failed to allocate async struct\n"); - return -ENOMEM; - } - init_waitqueue_head(&async->wait_head); - async->subdevice = s; - s->async = async; - - async->max_bufsize = - comedi_default_buf_maxsize_kb * 1024; - buf_size = comedi_default_buf_size_kb * 1024; - if (buf_size > async->max_bufsize) - buf_size = async->max_bufsize; - - async->prealloc_buf = NULL; - async->prealloc_bufsz = 0; - if (comedi_buf_alloc(dev, s, buf_size) < 0) { - dev_warn(dev->class_dev, - "Buffer allocation failed\n"); - return -ENOMEM; - } - if (s->buf_change) { - ret = s->buf_change(dev, s, buf_size); - if (ret < 0) - return ret; - } - comedi_alloc_subdevice_minor(dev, s); + ret = __comedi_device_postconfig_async(dev, s); + if (ret) + return ret; } if (!s->range_table && !s->range_table_list) @@ -326,6 +275,25 @@ static int postconfig(struct comedi_device *dev) return 0; } +/* do a little post-config cleanup */ +/* called with module refcount incremented, decrements it */ +static int comedi_device_postconfig(struct comedi_device *dev) +{ + int ret = __comedi_device_postconfig(dev); + module_put(dev->driver->module); + if (ret < 0) { + __comedi_device_detach(dev); + return ret; + } + if (!dev->board_name) { + dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n"); + dev->board_name = "BUG"; + } + smp_wmb(); + dev->attached = 1; + return 0; +} + /* * Generic recognize function for drivers that register their supported * board names. @@ -384,463 +352,63 @@ static void comedi_report_boards(struct comedi_driver *driv) pr_info(" %s\n", driv->driver_name); } -static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) -{ - return -EINVAL; -} - -int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - return -EINVAL; -} - -static int insn_rw_emulate_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - struct comedi_insn new_insn; + struct comedi_driver *driv; int ret; - static const unsigned channels_per_bitfield = 32; - - unsigned chan = CR_CHAN(insn->chanspec); - const unsigned base_bitfield_channel = - (chan < channels_per_bitfield) ? 0 : chan; - unsigned int new_data[2]; - memset(new_data, 0, sizeof(new_data)); - memset(&new_insn, 0, sizeof(new_insn)); - new_insn.insn = INSN_BITS; - new_insn.chanspec = base_bitfield_channel; - new_insn.n = 2; - new_insn.subdev = insn->subdev; - if (insn->insn == INSN_WRITE) { - if (!(s->subdev_flags & SDF_WRITABLE)) - return -EINVAL; - new_data[0] = 1 << (chan - base_bitfield_channel); /* mask */ - new_data[1] = data[0] ? (1 << (chan - base_bitfield_channel)) - : 0; /* bits */ - } - - ret = s->insn_bits(dev, s, &new_insn, new_data); - if (ret < 0) - return ret; - - if (insn->insn == INSN_READ) - data[0] = (new_data[1] >> (chan - base_bitfield_channel)) & 1; - - return 1; -} - -int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned long new_size) -{ - struct comedi_async *async = s->async; - - /* Round up new_size to multiple of PAGE_SIZE */ - new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK; - - /* if no change is required, do nothing */ - if (async->prealloc_buf && async->prealloc_bufsz == new_size) - return 0; - - /* deallocate old buffer */ - if (async->prealloc_buf) { - vunmap(async->prealloc_buf); - async->prealloc_buf = NULL; - async->prealloc_bufsz = 0; - } - if (async->buf_page_list) { - unsigned i; - for (i = 0; i < async->n_buf_pages; ++i) { - if (async->buf_page_list[i].virt_addr) { - clear_bit(PG_reserved, - &(virt_to_page(async->buf_page_list[i]. - virt_addr)->flags)); - if (s->async_dma_dir != DMA_NONE) { - dma_free_coherent(dev->hw_dev, - PAGE_SIZE, - async-> - buf_page_list - [i].virt_addr, - async-> - buf_page_list - [i].dma_addr); - } else { - free_page((unsigned long) - async->buf_page_list[i]. - virt_addr); - } - } - } - vfree(async->buf_page_list); - async->buf_page_list = NULL; - async->n_buf_pages = 0; - } - /* allocate new buffer */ - if (new_size) { - unsigned i = 0; - unsigned n_pages = new_size >> PAGE_SHIFT; - struct page **pages = NULL; - - async->buf_page_list = - vzalloc(sizeof(struct comedi_buf_page) * n_pages); - if (async->buf_page_list) - pages = vmalloc(sizeof(struct page *) * n_pages); - - if (pages) { - for (i = 0; i < n_pages; i++) { - if (s->async_dma_dir != DMA_NONE) { - async->buf_page_list[i].virt_addr = - dma_alloc_coherent(dev->hw_dev, - PAGE_SIZE, - &async-> - buf_page_list - [i].dma_addr, - GFP_KERNEL | - __GFP_COMP); - } else { - async->buf_page_list[i].virt_addr = - (void *) - get_zeroed_page(GFP_KERNEL); - } - if (async->buf_page_list[i].virt_addr == NULL) - break; - - set_bit(PG_reserved, - &(virt_to_page(async->buf_page_list[i]. - virt_addr)->flags)); - pages[i] = virt_to_page(async->buf_page_list[i]. - virt_addr); - } - } - if (i == n_pages) { - async->prealloc_buf = -#ifdef PAGE_KERNEL_NOCACHE - vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE); -#else - vmap(pages, n_pages, VM_MAP, PAGE_KERNEL); -#endif - } - vfree(pages); - - if (async->prealloc_buf == NULL) { - /* Some allocation failed above. */ - if (async->buf_page_list) { - for (i = 0; i < n_pages; i++) { - if (async->buf_page_list[i].virt_addr == - NULL) { - break; - } - clear_bit(PG_reserved, - &(virt_to_page(async-> - buf_page_list[i]. - virt_addr)->flags)); - if (s->async_dma_dir != DMA_NONE) { - dma_free_coherent(dev->hw_dev, - PAGE_SIZE, - async-> - buf_page_list - [i].virt_addr, - async-> - buf_page_list - [i].dma_addr); - } else { - free_page((unsigned long) - async->buf_page_list - [i].virt_addr); - } - } - vfree(async->buf_page_list); - async->buf_page_list = NULL; - } - return -ENOMEM; - } - async->n_buf_pages = n_pages; - } - async->prealloc_bufsz = new_size; - - return 0; -} + if (dev->attached) + return -EBUSY; -/* munging is applied to data by core as it passes between user - * and kernel space */ -static unsigned int comedi_buf_munge(struct comedi_async *async, - unsigned int num_bytes) -{ - struct comedi_subdevice *s = async->subdevice; - unsigned int count = 0; - const unsigned num_sample_bytes = bytes_per_sample(s); - - if (s->munge == NULL || (async->cmd.flags & CMDF_RAWDATA)) { - async->munge_count += num_bytes; - BUG_ON((int)(async->munge_count - async->buf_write_count) > 0); - return num_bytes; - } - /* don't munge partial samples */ - num_bytes -= num_bytes % num_sample_bytes; - while (count < num_bytes) { - int block_size; - - block_size = num_bytes - count; - if (block_size < 0) { - dev_warn(s->device->class_dev, - "%s: %s: bug! block_size is negative\n", - __FILE__, __func__); + for (driv = comedi_drivers; driv; driv = driv->next) { + if (!try_module_get(driv->module)) + continue; + if (driv->num_names) { + dev->board_ptr = comedi_recognize(driv, it->board_name); + if (dev->board_ptr) + break; + } else if (strcmp(driv->driver_name, it->board_name) == 0) break; - } - if ((int)(async->munge_ptr + block_size - - async->prealloc_bufsz) > 0) - block_size = async->prealloc_bufsz - async->munge_ptr; - - s->munge(s->device, s, async->prealloc_buf + async->munge_ptr, - block_size, async->munge_chan); - - smp_wmb(); /* barrier insures data is munged in buffer - * before munge_count is incremented */ - - async->munge_chan += block_size / num_sample_bytes; - async->munge_chan %= async->cmd.chanlist_len; - async->munge_count += block_size; - async->munge_ptr += block_size; - async->munge_ptr %= async->prealloc_bufsz; - count += block_size; - } - BUG_ON((int)(async->munge_count - async->buf_write_count) > 0); - return count; -} - -unsigned int comedi_buf_write_n_available(struct comedi_async *async) -{ - unsigned int free_end; - unsigned int nbytes; - - if (async == NULL) - return 0; - - free_end = async->buf_read_count + async->prealloc_bufsz; - nbytes = free_end - async->buf_write_alloc_count; - nbytes -= nbytes % bytes_per_sample(async->subdevice); - /* barrier insures the read of buf_read_count in this - query occurs before any following writes to the buffer which - might be based on the return value from this query. - */ - smp_mb(); - return nbytes; -} - -/* allocates chunk for the writer from free buffer space */ -unsigned int comedi_buf_write_alloc(struct comedi_async *async, - unsigned int nbytes) -{ - unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; - - if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0) - nbytes = free_end - async->buf_write_alloc_count; - - async->buf_write_alloc_count += nbytes; - /* barrier insures the read of buf_read_count above occurs before - we write data to the write-alloc'ed buffer space */ - smp_mb(); - return nbytes; -} -EXPORT_SYMBOL(comedi_buf_write_alloc); - -/* allocates nothing unless it can completely fulfill the request */ -unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async, - unsigned int nbytes) -{ - unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; - - if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0) - nbytes = 0; - - async->buf_write_alloc_count += nbytes; - /* barrier insures the read of buf_read_count above occurs before - we write data to the write-alloc'ed buffer space */ - smp_mb(); - return nbytes; -} - -/* transfers a chunk from writer to filled buffer space */ -unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) -{ - if ((int)(async->buf_write_count + nbytes - - async->buf_write_alloc_count) > 0) { - dev_info(async->subdevice->device->class_dev, - "attempted to write-free more bytes than have been write-allocated.\n"); - nbytes = async->buf_write_alloc_count - async->buf_write_count; - } - async->buf_write_count += nbytes; - async->buf_write_ptr += nbytes; - comedi_buf_munge(async, async->buf_write_count - async->munge_count); - if (async->buf_write_ptr >= async->prealloc_bufsz) - async->buf_write_ptr %= async->prealloc_bufsz; - - return nbytes; -} -EXPORT_SYMBOL(comedi_buf_write_free); - -/* allocates a chunk for the reader from filled (and munged) buffer space */ -unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes) -{ - if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) > - 0) { - nbytes = async->munge_count - async->buf_read_alloc_count; - } - async->buf_read_alloc_count += nbytes; - /* barrier insures read of munge_count occurs before we actually read - data out of buffer */ - smp_rmb(); - return nbytes; -} -EXPORT_SYMBOL(comedi_buf_read_alloc); - -/* transfers control of a chunk from reader to free buffer space */ -unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) -{ - /* barrier insures data has been read out of - * buffer before read count is incremented */ - smp_mb(); - if ((int)(async->buf_read_count + nbytes - - async->buf_read_alloc_count) > 0) { - dev_info(async->subdevice->device->class_dev, - "attempted to read-free more bytes than have been read-allocated.\n"); - nbytes = async->buf_read_alloc_count - async->buf_read_count; + module_put(driv->module); } - async->buf_read_count += nbytes; - async->buf_read_ptr += nbytes; - async->buf_read_ptr %= async->prealloc_bufsz; - return nbytes; -} -EXPORT_SYMBOL(comedi_buf_read_free); - -void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, - const void *data, unsigned int num_bytes) -{ - unsigned int write_ptr = async->buf_write_ptr + offset; - - if (write_ptr >= async->prealloc_bufsz) - write_ptr %= async->prealloc_bufsz; - - while (num_bytes) { - unsigned int block_size; - - if (write_ptr + num_bytes > async->prealloc_bufsz) - block_size = async->prealloc_bufsz - write_ptr; - else - block_size = num_bytes; - - memcpy(async->prealloc_buf + write_ptr, data, block_size); - - data += block_size; - num_bytes -= block_size; - - write_ptr = 0; + if (driv == NULL) { + /* recognize has failed if we get here */ + /* report valid board names before returning error */ + for (driv = comedi_drivers; driv; driv = driv->next) { + if (!try_module_get(driv->module)) + continue; + comedi_report_boards(driv); + module_put(driv->module); + } + return -EIO; } -} -EXPORT_SYMBOL(comedi_buf_memcpy_to); - -void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, - void *dest, unsigned int nbytes) -{ - void *src; - unsigned int read_ptr = async->buf_read_ptr + offset; - - if (read_ptr >= async->prealloc_bufsz) - read_ptr %= async->prealloc_bufsz; - - while (nbytes) { - unsigned int block_size; - - src = async->prealloc_buf + read_ptr; - - if (nbytes >= async->prealloc_bufsz - read_ptr) - block_size = async->prealloc_bufsz - read_ptr; - else - block_size = nbytes; - - memcpy(dest, src, block_size); - nbytes -= block_size; - dest += block_size; - read_ptr = 0; + if (driv->attach == NULL) { + /* driver does not support manual configuration */ + dev_warn(dev->class_dev, + "driver '%s' does not support attach using comedi_config\n", + driv->driver_name); + module_put(driv->module); + return -ENOSYS; } -} -EXPORT_SYMBOL(comedi_buf_memcpy_from); - -unsigned int comedi_buf_read_n_available(struct comedi_async *async) -{ - unsigned num_bytes; - - if (async == NULL) - return 0; - num_bytes = async->munge_count - async->buf_read_count; - /* barrier insures the read of munge_count in this - query occurs before any following reads of the buffer which - might be based on the return value from this query. - */ - smp_rmb(); - return num_bytes; -} -EXPORT_SYMBOL(comedi_buf_read_n_available); - -int comedi_buf_get(struct comedi_async *async, short *x) -{ - unsigned int n = comedi_buf_read_n_available(async); - - if (n < sizeof(short)) - return 0; - comedi_buf_read_alloc(async, sizeof(short)); - *x = *(short *)(async->prealloc_buf + async->buf_read_ptr); - comedi_buf_read_free(async, sizeof(short)); - return 1; -} -EXPORT_SYMBOL(comedi_buf_get); - -int comedi_buf_put(struct comedi_async *async, short x) -{ - unsigned int n = comedi_buf_write_alloc_strict(async, sizeof(short)); - - if (n < sizeof(short)) { - async->events |= COMEDI_CB_ERROR; - return 0; + /* initialize dev->driver here so + * comedi_error() can be called from attach */ + dev->driver = driv; + ret = driv->attach(dev, it); + if (ret < 0) { + module_put(dev->driver->module); + __comedi_device_detach(dev); + return ret; } - *(short *)(async->prealloc_buf + async->buf_write_ptr) = x; - comedi_buf_write_free(async, sizeof(short)); - return 1; -} -EXPORT_SYMBOL(comedi_buf_put); - -void comedi_reset_async_buf(struct comedi_async *async) -{ - async->buf_write_alloc_count = 0; - async->buf_write_count = 0; - async->buf_read_alloc_count = 0; - async->buf_read_count = 0; - - async->buf_write_ptr = 0; - async->buf_read_ptr = 0; - - async->cur_chan = 0; - async->scan_progress = 0; - async->munge_chan = 0; - async->munge_count = 0; - async->munge_ptr = 0; - - async->events = 0; + return comedi_device_postconfig(dev); } int comedi_auto_config(struct device *hardware_device, struct comedi_driver *driver, unsigned long context) { int minor; - struct comedi_device_file_info *dev_file_info; struct comedi_device *comedi_dev; int ret; - if (!comedi_autoconfig) - return 0; - if (!driver->auto_attach) { dev_warn(hardware_device, "BUG! comedi driver '%s' has no auto_attach handler\n", @@ -852,8 +420,7 @@ int comedi_auto_config(struct device *hardware_device, if (minor < 0) return minor; - dev_file_info = comedi_get_device_file_info(minor); - comedi_dev = dev_file_info->device; + comedi_dev = comedi_dev_from_minor(minor); mutex_lock(&comedi_dev->mutex); if (comedi_dev->attached) @@ -888,103 +455,53 @@ void comedi_auto_unconfig(struct device *hardware_device) minor = comedi_find_board_minor(hardware_device); if (minor < 0) return; - BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS); comedi_free_board_minor(minor); } EXPORT_SYMBOL_GPL(comedi_auto_unconfig); -/** - * comedi_pci_enable() - Enable the PCI device and request the regions. - * @pdev: pci_dev struct - * @res_name: name for the requested reqource - */ -int comedi_pci_enable(struct pci_dev *pdev, const char *res_name) -{ - int rc; - - rc = pci_enable_device(pdev); - if (rc < 0) - return rc; - - rc = pci_request_regions(pdev, res_name); - if (rc < 0) - pci_disable_device(pdev); - - return rc; -} -EXPORT_SYMBOL_GPL(comedi_pci_enable); - -/** - * comedi_pci_disable() - Release the regions and disable the PCI device. - * @pdev: pci_dev struct - * - * This must be matched with a previous successful call to comedi_pci_enable(). - */ -void comedi_pci_disable(struct pci_dev *pdev) -{ - pci_release_regions(pdev); - pci_disable_device(pdev); -} -EXPORT_SYMBOL_GPL(comedi_pci_disable); - -int comedi_pci_driver_register(struct comedi_driver *comedi_driver, - struct pci_driver *pci_driver) +int comedi_driver_register(struct comedi_driver *driver) { - int ret; - - ret = comedi_driver_register(comedi_driver); - if (ret < 0) - return ret; - - /* FIXME: Remove this test after auditing all comedi pci drivers */ - if (!pci_driver->name) - pci_driver->name = comedi_driver->driver_name; - - ret = pci_register_driver(pci_driver); - if (ret < 0) { - comedi_driver_unregister(comedi_driver); - return ret; - } + driver->next = comedi_drivers; + comedi_drivers = driver; return 0; } -EXPORT_SYMBOL_GPL(comedi_pci_driver_register); +EXPORT_SYMBOL(comedi_driver_register); -void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver, - struct pci_driver *pci_driver) +int comedi_driver_unregister(struct comedi_driver *driver) { - pci_unregister_driver(pci_driver); - comedi_driver_unregister(comedi_driver); -} -EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister); - -#if IS_ENABLED(CONFIG_USB) + struct comedi_driver *prev; + int i; -int comedi_usb_driver_register(struct comedi_driver *comedi_driver, - struct usb_driver *usb_driver) -{ - int ret; + /* check for devices using this driver */ + for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { + struct comedi_device *dev = comedi_dev_from_minor(i); - ret = comedi_driver_register(comedi_driver); - if (ret < 0) - return ret; + if (!dev) + continue; - ret = usb_register(usb_driver); - if (ret < 0) { - comedi_driver_unregister(comedi_driver); - return ret; + mutex_lock(&dev->mutex); + if (dev->attached && dev->driver == driver) { + if (dev->use_count) + dev_warn(dev->class_dev, + "BUG! detaching device with use_count=%d\n", + dev->use_count); + comedi_device_detach(dev); + } + mutex_unlock(&dev->mutex); } - return 0; -} -EXPORT_SYMBOL_GPL(comedi_usb_driver_register); + if (comedi_drivers == driver) { + comedi_drivers = driver->next; + return 0; + } -void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver, - struct usb_driver *usb_driver) -{ - usb_deregister(usb_driver); - comedi_driver_unregister(comedi_driver); + for (prev = comedi_drivers; prev->next; prev = prev->next) { + if (prev->next == driver) { + prev->next = driver->next; + return 0; + } + } + return -EINVAL; } -EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister); - -#endif +EXPORT_SYMBOL(comedi_driver_unregister); diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index e0a7952..0ae356a 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -54,6 +54,8 @@ Interrupt support for these boards is also not currently supported. Configuration Options: not applicable, uses PCI auto config */ +#include <linux/pci.h> + #include "../comedidev.h" #include "8255.h" @@ -314,11 +316,6 @@ static int pci_8255_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &pci_8255_driver); } -static void pci_8255_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(pci_8255_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_ADLINK_PCI7224) }, { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_ADLINK_PCI7248) }, @@ -342,7 +339,7 @@ static struct pci_driver pci_8255_pci_driver = { .name = "8255_pci", .id_table = pci_8255_pci_table, .probe = pci_8255_pci_probe, - .remove = pci_8255_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(pci_8255_driver, pci_8255_pci_driver); diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 0de4d2e..315e836 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -2,7 +2,6 @@ # # Comedi "helper" modules -obj-$(CONFIG_COMEDI) += pcm_common.o # Comedi misc drivers obj-$(CONFIG_COMEDI_BOND) += comedi_bond.o @@ -26,6 +25,7 @@ obj-$(CONFIG_COMEDI_PCM3730) += pcm3730.o obj-$(CONFIG_COMEDI_RTI800) += rti800.o obj-$(CONFIG_COMEDI_RTI802) += rti802.o obj-$(CONFIG_COMEDI_DAS16M1) += das16m1.o +obj-$(CONFIG_COMEDI_DAS08_ISA) += das08_isa.o obj-$(CONFIG_COMEDI_DAS16) += das16.o obj-$(CONFIG_COMEDI_DAS800) += das800.o obj-$(CONFIG_COMEDI_DAS1800) += das1800.o @@ -56,6 +56,7 @@ obj-$(CONFIG_COMEDI_POC) += poc.o # Comedi PCI drivers obj-$(CONFIG_COMEDI_8255_PCI) += 8255_pci.o +obj-$(CONFIG_COMEDI_ADDI_WATCHDOG) += addi_watchdog.o obj-$(CONFIG_COMEDI_ADDI_APCI_035) += addi_apci_035.o obj-$(CONFIG_COMEDI_ADDI_APCI_1032) += addi_apci_1032.o obj-$(CONFIG_COMEDI_ADDI_APCI_1500) += addi_apci_1500.o @@ -81,6 +82,7 @@ obj-$(CONFIG_COMEDI_AMPLC_PC263) += amplc_pc263.o obj-$(CONFIG_COMEDI_AMPLC_PCI224) += amplc_pci224.o obj-$(CONFIG_COMEDI_AMPLC_PCI230) += amplc_pci230.o obj-$(CONFIG_COMEDI_CONTEC_PCI_DIO) += contec_pci_dio.o +obj-$(CONFIG_COMEDI_DAS08_PCI) += das08_pci.o obj-$(CONFIG_COMEDI_DT3000) += dt3000.o obj-$(CONFIG_COMEDI_DYNA_PCI10XX) += dyna_pci10xx.o obj-$(CONFIG_COMEDI_UNIOXX5) += unioxx5.o diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 90cc432..1051fa5 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -11,13 +11,21 @@ Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. http://www.addi-data.com info@addi-data.com -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 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. +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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +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., +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -You should also find the complete GPL in the COPYING file accompanying this source code. +You should also find the complete GPL in the COPYING file accompanying this +source code. @endverbatim */ @@ -29,10 +37,10 @@ You should also find the complete GPL in the COPYING file accompanying this sour | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | +-----------------------------------------------------------------------+ - | Project : ADDI DATA | Compiler : GCC | + | Project : ADDI DATA | Compiler : GCC | | Modulname : addi_common.c | Version : 2.96 | +-------------------------------+---------------------------------------+ - | Author : | Date : | + | Author : | Date : | +-----------------------------------------------------------------------+ | Description : ADDI COMMON Main Module | +-----------------------------------------------------------------------+ @@ -167,11 +175,11 @@ static int addi_auto_attach(struct comedi_device *dev, if (this_board->i_PCIEeprom) { if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { /* Set 3 wait stait */ - if (!(strcmp(dev->board_name, "apci035"))) { + if (!(strcmp(dev->board_name, "apci035"))) outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - } else { + else outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - } + /* Enable the interrupt for the controller */ dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c deleted file mode 100644 index 5958a9c..0000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c +++ /dev/null @@ -1,807 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -You should also find the complete GPL in the COPYING file accompanying this source code. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1648 | Compiler : gcc | - | Module name : TTL.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: S. Weber | Date : 25/05/2005 | - +-----------------------------------------------------------------------+ - | Description : APCI-16XX TTL I/O module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - |25.05.2005| S.Weber | Creation | - | | | | - +-----------------------------------------------------------------------+ -*/ - -#ifndef COMEDI_SUBD_TTLIO -#define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */ -#endif - -#define APCI16XX_TTL_INIT 0 -#define APCI16XX_TTL_INITDIRECTION 1 -#define APCI16XX_TTL_OUTPUTMEMORY 2 - -#define APCI16XX_TTL_READCHANNEL 0 -#define APCI16XX_TTL_READPORT 1 - -#define APCI16XX_TTL_WRITECHANNEL_ON 0 -#define APCI16XX_TTL_WRITECHANNEL_OFF 1 -#define APCI16XX_TTL_WRITEPORT_ON 2 -#define APCI16XX_TTL_WRITEPORT_OFF 3 - -#define APCI16XX_TTL_READ_ALL_INPUTS 0 -#define APCI16XX_TTL_READ_ALL_OUTPUTS 1 - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI16XX_InsnConfigInitTTLIO | -| (struct comedi_device *dev, | -| struct comedi_subdevice *s, | -| struct comedi_insn *insn, | -| unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task APCI16XX_TTL_INIT (using defaults) : | -| Configure the TTL I/O operating mode from all ports | -| You must calling this function be | -| for you call any other function witch access of TTL. | -| APCI16XX_TTL_INITDIRECTION(user inputs for direction) | -+----------------------------------------------------------------------------+ -| Input Parameters : b_InitType = (unsigned char) data[0]; | -| b_Port0Mode = (unsigned char) data[1]; | -| b_Port1Mode = (unsigned char) data[2]; | -| b_Port2Mode = (unsigned char) data[3]; | -| b_Port3Mode = (unsigned char) data[4]; | -| ........ | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value :>0: No error | -| -1: Port 0 mode selection is wrong | -| -2: Port 1 mode selection is wrong | -| -3: Port 2 mode selection is wrong | -| -4: Port 3 mode selection is wrong | -| -X: Port X-1 mode selection is wrong | -| .... | -| -100 : Config command error | -| -101 : Data size error | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = comedi_board(dev); - struct addi_private *devpriv = dev->private; - int i_ReturnValue = insn->n; - unsigned char b_Command = 0; - unsigned char b_Cpt = 0; - unsigned char b_NumberOfPort = - (unsigned char) (this_board->i_NbrTTLChannel / 8); - - /************************/ - /* Test the buffer size */ - /************************/ - - if (insn->n >= 1) { - /*******************/ - /* Get the command */ - /* **************** */ - - b_Command = (unsigned char) data[0]; - - /********************/ - /* Test the command */ - /********************/ - - if ((b_Command == APCI16XX_TTL_INIT) || - (b_Command == APCI16XX_TTL_INITDIRECTION) || - (b_Command == APCI16XX_TTL_OUTPUTMEMORY)) { - /***************************************/ - /* Test the initialisation buffer size */ - /***************************************/ - - if ((b_Command == APCI16XX_TTL_INITDIRECTION) - && ((unsigned char) (insn->n - 1) != b_NumberOfPort)) { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - - if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY) - && ((unsigned char) (insn->n) != 2)) { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - } else { - /************************/ - /* Config command error */ - /************************/ - - printk("\nCommand selection error"); - i_ReturnValue = -100; - } - } else { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - - /**************************************************************************/ - /* Test if no error occur and APCI16XX_TTL_INITDIRECTION command selected */ - /**************************************************************************/ - - if ((i_ReturnValue >= 0) && (b_Command == APCI16XX_TTL_INITDIRECTION)) { - memset(devpriv->ul_TTLPortConfiguration, 0, - sizeof(devpriv->ul_TTLPortConfiguration)); - - /*************************************/ - /* Test the port direction selection */ - /*************************************/ - - for (b_Cpt = 1; - (b_Cpt <= b_NumberOfPort) && (i_ReturnValue >= 0); - b_Cpt++) { - /**********************/ - /* Test the direction */ - /**********************/ - - if ((data[b_Cpt] != 0) && (data[b_Cpt] != 0xFF)) { - /************************/ - /* Port direction error */ - /************************/ - - printk("\nPort %d direction selection error", - (int) b_Cpt); - i_ReturnValue = -(int) b_Cpt; - } - - /**************************/ - /* Save the configuration */ - /**************************/ - - devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] = - devpriv->ul_TTLPortConfiguration[(b_Cpt - - 1) / 4] | (data[b_Cpt] << (8 * ((b_Cpt - - 1) % 4))); - } - } - - /**************************/ - /* Test if no error occur */ - /**************************/ - - if (i_ReturnValue >= 0) { - /***********************************/ - /* Test if TTL port initilaisation */ - /***********************************/ - - if ((b_Command == APCI16XX_TTL_INIT) - || (b_Command == APCI16XX_TTL_INITDIRECTION)) { - /******************************/ - /* Set all port configuration */ - /******************************/ - - for (b_Cpt = 0; b_Cpt <= b_NumberOfPort; b_Cpt++) { - if ((b_Cpt % 4) == 0) { - /*************************/ - /* Set the configuration */ - /*************************/ - - outl(devpriv-> - ul_TTLPortConfiguration[b_Cpt / - 4], - devpriv->iobase + 32 + b_Cpt); - } - } - } - } - - /************************************************/ - /* Test if output memory initialisation command */ - /************************************************/ - - if (b_Command == APCI16XX_TTL_OUTPUTMEMORY) { - if (data[1]) { - devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE; - } else { - devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE; - } - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| INPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI16XX_InsnBitsReadTTLIO | -| (struct comedi_device *dev, | -| struct comedi_subdevice *s, | -| struct comedi_insn *insn, | -| unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read the status from selected TTL digital input | -| (b_InputChannel) | -+----------------------------------------------------------------------------+ -| Task : Read the status from digital input port | -| (b_SelectedPort) | -+----------------------------------------------------------------------------+ -| Input Parameters : | -| APCI16XX_TTL_READCHANNEL | -| b_SelectedPort= CR_RANGE(insn->chanspec); | -| b_InputChannel= CR_CHAN(insn->chanspec); | -| b_ReadType = (unsigned char) data[0]; | -| | -| APCI16XX_TTL_READPORT | -| b_SelectedPort= CR_RANGE(insn->chanspec); | -| b_ReadType = (unsigned char) data[0]; | -+----------------------------------------------------------------------------+ -| Output Parameters : data[0] 0 : Channle is not active | -| 1 : Channle is active | -+----------------------------------------------------------------------------+ -| Return Value : >0 : No error | -| -100 : Config command error | -| -101 : Data size error | -| -102 : The selected TTL input port is wrong | -| -103 : The selected TTL digital input is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = comedi_board(dev); - struct addi_private *devpriv = dev->private; - int i_ReturnValue = insn->n; - unsigned char b_Command = 0; - unsigned char b_NumberOfPort = - (unsigned char) (this_board->i_NbrTTLChannel / 8); - unsigned char b_SelectedPort = CR_RANGE(insn->chanspec); - unsigned char b_InputChannel = CR_CHAN(insn->chanspec); - unsigned char *pb_Status; - unsigned int dw_Status; - - /************************/ - /* Test the buffer size */ - /************************/ - - if (insn->n >= 1) { - /*******************/ - /* Get the command */ - /* **************** */ - - b_Command = (unsigned char) data[0]; - - /********************/ - /* Test the command */ - /********************/ - - if ((b_Command == APCI16XX_TTL_READCHANNEL) - || (b_Command == APCI16XX_TTL_READPORT)) { - /**************************/ - /* Test the selected port */ - /**************************/ - - if (b_SelectedPort < b_NumberOfPort) { - /**********************/ - /* Test if input port */ - /**********************/ - - if (((devpriv->ul_TTLPortConfiguration - [b_SelectedPort / - 4] >> (8 * - (b_SelectedPort - % - 4))) & - 0xFF) == 0) { - /***************************/ - /* Test the channel number */ - /***************************/ - - if ((b_Command == - APCI16XX_TTL_READCHANNEL) - && (b_InputChannel > 7)) { - /*******************************************/ - /* The selected TTL digital input is wrong */ - /*******************************************/ - - printk("\nChannel selection error"); - i_ReturnValue = -103; - } - } else { - /****************************************/ - /* The selected TTL input port is wrong */ - /****************************************/ - - printk("\nPort selection error"); - i_ReturnValue = -102; - } - } else { - /****************************************/ - /* The selected TTL input port is wrong */ - /****************************************/ - - printk("\nPort selection error"); - i_ReturnValue = -102; - } - } else { - /************************/ - /* Config command error */ - /************************/ - - printk("\nCommand selection error"); - i_ReturnValue = -100; - } - } else { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - - /**************************/ - /* Test if no error occur */ - /**************************/ - - if (i_ReturnValue >= 0) { - pb_Status = (unsigned char *) &data[0]; - - /*******************************/ - /* Get the digital inpu status */ - /*******************************/ - - dw_Status = - inl(devpriv->iobase + 8 + ((b_SelectedPort / 4) * 4)); - dw_Status = (dw_Status >> (8 * (b_SelectedPort % 4))) & 0xFF; - - /***********************/ - /* Save the port value */ - /***********************/ - - *pb_Status = (unsigned char) dw_Status; - - /***************************************/ - /* Test if read channel status command */ - /***************************************/ - - if (b_Command == APCI16XX_TTL_READCHANNEL) { - *pb_Status = (*pb_Status >> b_InputChannel) & 1; - } - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI16XX_InsnReadTTLIOAllPortValue | -| (struct comedi_device *dev, | -| struct comedi_subdevice *s, | -| struct comedi_insn *insn, | -| unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read the status from all digital input ports | -+----------------------------------------------------------------------------+ -| Input Parameters : - | -+----------------------------------------------------------------------------+ -| Output Parameters : data[0] : Port 0 to 3 data | -| data[1] : Port 4 to 7 data | -| .... | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -100 : Read command error | -| -101 : Data size error | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = comedi_board(dev); - struct addi_private *devpriv = dev->private; - unsigned char b_Command = (unsigned char) CR_AREF(insn->chanspec); - int i_ReturnValue = insn->n; - unsigned char b_Cpt = 0; - unsigned char b_NumberOfPort = 0; - unsigned int *pls_ReadData = data; - - /********************/ - /* Test the command */ - /********************/ - - if ((b_Command == APCI16XX_TTL_READ_ALL_INPUTS) - || (b_Command == APCI16XX_TTL_READ_ALL_OUTPUTS)) { - /**********************************/ - /* Get the number of 32-Bit ports */ - /**********************************/ - - b_NumberOfPort = - (unsigned char) (this_board->i_NbrTTLChannel / 32); - if ((b_NumberOfPort * 32) < - this_board->i_NbrTTLChannel) { - b_NumberOfPort = b_NumberOfPort + 1; - } - - /************************/ - /* Test the buffer size */ - /************************/ - - if (insn->n >= b_NumberOfPort) { - if (b_Command == APCI16XX_TTL_READ_ALL_INPUTS) { - /**************************/ - /* Read all digital input */ - /**************************/ - - for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt++) { - /************************/ - /* Read the 32-Bit port */ - /************************/ - - pls_ReadData[b_Cpt] = - inl(devpriv->iobase + 8 + - (b_Cpt * 4)); - - /**************************************/ - /* Mask all channels used als outputs */ - /**************************************/ - - pls_ReadData[b_Cpt] = - pls_ReadData[b_Cpt] & - (~devpriv-> - ul_TTLPortConfiguration[b_Cpt]); - } - } else { - /****************************/ - /* Read all digital outputs */ - /****************************/ - - for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt++) { - /************************/ - /* Read the 32-Bit port */ - /************************/ - - pls_ReadData[b_Cpt] = - inl(devpriv->iobase + 20 + - (b_Cpt * 4)); - - /**************************************/ - /* Mask all channels used als outputs */ - /**************************************/ - - pls_ReadData[b_Cpt] = - pls_ReadData[b_Cpt] & devpriv-> - ul_TTLPortConfiguration[b_Cpt]; - } - } - } else { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - } else { - /*****************/ - /* Command error */ - /*****************/ - - printk("\nCommand selection error"); - i_ReturnValue = -100; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| OUTPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI16XX_InsnBitsWriteTTLIO | -| (struct comedi_device *dev, | -| struct comedi_subdevice *s, | -| struct comedi_insn *insn, | -| unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Set the state from selected TTL digital output | -| (b_OutputChannel) | -+----------------------------------------------------------------------------+ -| Task : Set the state from digital output port | -| (b_SelectedPort) | -+----------------------------------------------------------------------------+ -| Input Parameters : | -| APCI16XX_TTL_WRITECHANNEL_ON | APCI16XX_TTL_WRITECHANNEL_OFF | -| b_SelectedPort = CR_RANGE(insn->chanspec); | -| b_OutputChannel= CR_CHAN(insn->chanspec); | -| b_Command = (unsigned char) data[0]; | -| | -| APCI16XX_TTL_WRITEPORT_ON | APCI16XX_TTL_WRITEPORT_OFF | -| b_SelectedPort = CR_RANGE(insn->chanspec); | -| b_Command = (unsigned char) data[0]; | -+----------------------------------------------------------------------------+ -| Output Parameters : data[0] : TTL output port 0 to 3 data | -| data[1] : TTL output port 4 to 7 data | -| .... | -+----------------------------------------------------------------------------+ -| Return Value : >0 : No error | -| -100 : Command error | -| -101 : Data size error | -| -102 : The selected TTL output port is wrong | -| -103 : The selected TTL digital output is wrong | -| -104 : Output memory disabled | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = comedi_board(dev); - struct addi_private *devpriv = dev->private; - int i_ReturnValue = insn->n; - unsigned char b_Command = 0; - unsigned char b_NumberOfPort = - (unsigned char) (this_board->i_NbrTTLChannel / 8); - unsigned char b_SelectedPort = CR_RANGE(insn->chanspec); - unsigned char b_OutputChannel = CR_CHAN(insn->chanspec); - unsigned int dw_Status = 0; - - /************************/ - /* Test the buffer size */ - /************************/ - - if (insn->n >= 1) { - /*******************/ - /* Get the command */ - /* **************** */ - - b_Command = (unsigned char) data[0]; - - /********************/ - /* Test the command */ - /********************/ - - if ((b_Command == APCI16XX_TTL_WRITECHANNEL_ON) || - (b_Command == APCI16XX_TTL_WRITEPORT_ON) || - (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) || - (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) { - /**************************/ - /* Test the selected port */ - /**************************/ - - if (b_SelectedPort < b_NumberOfPort) { - /***********************/ - /* Test if output port */ - /***********************/ - - if (((devpriv->ul_TTLPortConfiguration - [b_SelectedPort / - 4] >> (8 * - (b_SelectedPort - % - 4))) & - 0xFF) == 0xFF) { - /***************************/ - /* Test the channel number */ - /***************************/ - - if (((b_Command == APCI16XX_TTL_WRITECHANNEL_ON) || (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF)) && (b_OutputChannel > 7)) { - /********************************************/ - /* The selected TTL digital output is wrong */ - /********************************************/ - - printk("\nChannel selection error"); - i_ReturnValue = -103; - } - - if (((b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) || (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE)) { - /********************************************/ - /* The selected TTL digital output is wrong */ - /********************************************/ - - printk("\nOutput memory disabled"); - i_ReturnValue = -104; - } - - /************************/ - /* Test the buffer size */ - /************************/ - - if (((b_Command == APCI16XX_TTL_WRITEPORT_ON) || (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (insn->n < 2)) { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - } else { - /*****************************************/ - /* The selected TTL output port is wrong */ - /*****************************************/ - - printk("\nPort selection error %lX", - (unsigned long)devpriv-> - ul_TTLPortConfiguration[0]); - i_ReturnValue = -102; - } - } else { - /****************************************/ - /* The selected TTL output port is wrong */ - /****************************************/ - - printk("\nPort selection error %d %d", - b_SelectedPort, b_NumberOfPort); - i_ReturnValue = -102; - } - } else { - /************************/ - /* Config command error */ - /************************/ - - printk("\nCommand selection error"); - i_ReturnValue = -100; - } - } else { - /*******************/ - /* Data size error */ - /*******************/ - - printk("\nBuffer size error"); - i_ReturnValue = -101; - } - - /**************************/ - /* Test if no error occur */ - /**************************/ - - if (i_ReturnValue >= 0) { - /********************************/ - /* Get the digital output state */ - /********************************/ - - dw_Status = - inl(devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4)); - - /**********************************/ - /* Test if output memory not used */ - /**********************************/ - - if (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE) { - /*********************************/ - /* Clear the selected port value */ - /*********************************/ - - dw_Status = - dw_Status & (0xFFFFFFFFUL - - (0xFFUL << (8 * (b_SelectedPort % 4)))); - } - - /******************************/ - /* Test if setting channel ON */ - /******************************/ - - if (b_Command == APCI16XX_TTL_WRITECHANNEL_ON) { - dw_Status = - dw_Status | (1UL << ((8 * (b_SelectedPort % - 4)) + b_OutputChannel)); - } - - /***************************/ - /* Test if setting port ON */ - /***************************/ - - if (b_Command == APCI16XX_TTL_WRITEPORT_ON) { - dw_Status = - dw_Status | ((data[1] & 0xFF) << (8 * - (b_SelectedPort % 4))); - } - - /*******************************/ - /* Test if setting channel OFF */ - /*******************************/ - - if (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) { - dw_Status = - dw_Status & (0xFFFFFFFFUL - - (1UL << ((8 * (b_SelectedPort % 4)) + - b_OutputChannel))); - } - - /****************************/ - /* Test if setting port OFF */ - /****************************/ - - if (b_Command == APCI16XX_TTL_WRITEPORT_OFF) { - dw_Status = - dw_Status & (0xFFFFFFFFUL - - ((data[1] & 0xFF) << (8 * (b_SelectedPort % - 4)))); - } - - outl(dw_Status, - devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4)); - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI2200_Reset(struct comedi_device *dev) | +----------------------------------------------------------------------------+ -| Task :resets all the registers | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : - | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI16XX_Reset(struct comedi_device *dev) -{ - return 0; -} diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c deleted file mode 100644 index 9d4a117..0000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c +++ /dev/null @@ -1,263 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -You should also find the complete GPL in the COPYING file accompanying this source code. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-------------------------------+---------------------------------------+ - | Project : APCI-2200 | Compiler : GCC | - | Module name : hwdrv_apci2200.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-------------------------------+---------------------------------------+ - | Description : Hardware Layer Access For APCI-2200 | - +-----------------------------------------------------------------------+ - | UPDATES | - +----------+-----------+------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - | | | | - | | | | - +----------+-----------+------------------------------------------------+ -*/ - -/********* Definitions for APCI-2200 card *****/ - -/* Card Specific information */ -#define APCI2200_ADDRESS_RANGE 64 - -/* DIGITAL INPUT-OUTPUT DEFINE */ - -#define APCI2200_DIGITAL_OP 4 -#define APCI2200_DIGITAL_IP 0 - -/* TIMER COUNTER WATCHDOG DEFINES */ - -#define APCI2200_WATCHDOG 0x08 -#define APCI2200_WATCHDOG_ENABLEDISABLE 12 -#define APCI2200_WATCHDOG_RELOAD_VALUE 4 -#define APCI2200_WATCHDOG_STATUS 16 - -static int apci2200_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[1] = inw(devpriv->iobase + APCI2200_DIGITAL_IP); - - return insn->n; -} - -static int apci2200_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int mask = data[0]; - unsigned int bits = data[1]; - - s->state = inw(devpriv->iobase + APCI2200_DIGITAL_OP); - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); - - outw(s->state, devpriv->iobase + APCI2200_DIGITAL_OP); - } - - data[1] = s->state; - - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, -| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | -| | -+----------------------------------------------------------------------------+ -| Task : Configures The Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s, :pointer to subdevice structure -| struct comedi_insn *insn :pointer to insn structure | -| unsigned int *data : Data Pointer to read status | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - if (data[0] == 0) { - /* Disable the watchdog */ - outw(0x0, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_ENABLEDISABLE); - /* Loading the Reload value */ - outw(data[1], - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_RELOAD_VALUE); - data[1] = data[1] >> 16; - outw(data[1], - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_RELOAD_VALUE + 2); - } /* if(data[0]==0) */ - else { - printk("\nThe input parameters are wrong\n"); - return -EINVAL; - } /* elseif(data[0]==0) */ - - return insn->n; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : int i_APCI2200_StartStopWriteWatchdog | - | (struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data); | - +----------------------------------------------------------------------------+ - | Task : Start / Stop The Watchdog | - +----------------------------------------------------------------------------+ - | Input Parameters : struct comedi_device *dev : Driver handle | - | struct comedi_subdevice *s, :pointer to subdevice structure - struct comedi_insn *insn :pointer to insn structure | - | unsigned int *data : Data Pointer to read status | - +----------------------------------------------------------------------------+ - | Output Parameters : -- | - +----------------------------------------------------------------------------+ - | Return Value : TRUE : No error occur | - | : FALSE : Error occur. Return the error | - | | - +----------------------------------------------------------------------------+ - */ - -static int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - switch (data[0]) { - case 0: /* stop the watchdog */ - outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); /* disable the watchdog */ - break; - case 1: /* start the watchdog */ - outw(0x0001, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_ENABLEDISABLE); - break; - case 2: /* Software trigger */ - outw(0x0201, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_ENABLEDISABLE); - break; - default: - printk("\nSpecified functionality does not exist\n"); - return -EINVAL; - } /* switch(data[0]) */ - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI2200_ReadWatchdog | -| (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn, -| unsigned int *data); | -+----------------------------------------------------------------------------+ -| Task : Read The Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s, :pointer to subdevice structure -| struct comedi_insn *insn :pointer to insn structure | -| unsigned int *data : Data Pointer to read status | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI2200_ReadWatchdog(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[0] = - inw(devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_STATUS) & 0x1; - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI2200_Reset(struct comedi_device *dev) | | -+----------------------------------------------------------------------------+ -| Task :resets all the registers | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI2200_Reset(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - - outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP); /* RESETS THE DIGITAL OUTPUTS */ - outw(0x0, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_ENABLEDISABLE); - outw(0x0, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_RELOAD_VALUE); - outw(0x0, - devpriv->iobase + APCI2200_WATCHDOG + - APCI2200_WATCHDOG_RELOAD_VALUE + 2); - return 0; -} diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 829af18..c790873 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -633,7 +633,7 @@ static int apci3200_do_insn_bits(struct comedi_device *dev, s->state = inl(devpriv->i_IobaseAddon) & 0xf; if (mask) { s->state &= ~mask; - s->state |= (bits & mask) + s->state |= (bits & mask); outl(s->state, devpriv->i_IobaseAddon); } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c index 7a18ce7..ebc1534 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c @@ -1,274 +1,27 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -You should also find the complete GPL in the COPYING file accompanying this source code. - -@endverbatim -*/ -/*. - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-------------------------------+---------------------------------------+ - | Project : APCI-3501 | Compiler : GCC | - | Module name : hwdrv_apci3501.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-------------------------------+---------------------------------------+ - | Description : Hardware Layer Access For APCI-3501 | - +-----------------------------------------------------------------------+ - | UPDATES | - +----------+-----------+------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - | | | | - | | | | - +----------+-----------+------------------------------------------------+ -*/ - -/* Card Specific information */ -#define APCI3501_ADDRESS_RANGE 255 - -#define APCI3501_DIGITAL_IP 0x50 -#define APCI3501_DIGITAL_OP 0x40 -#define APCI3501_ANALOG_OUTPUT 0x00 - -/* Analog Output related Defines */ -#define APCI3501_AO_VOLT_MODE 0 -#define APCI3501_AO_PROG 4 -#define APCI3501_AO_TRIG_SCS 8 -#define UNIPOLAR 0 -#define BIPOLAR 1 -#define MODE0 0 -#define MODE1 1 - /* Watchdog Related Defines */ -#define APCI3501_WATCHDOG 0x20 -#define APCI3501_TCW_SYNC_ENABLEDISABLE 0 -#define APCI3501_TCW_RELOAD_VALUE 4 -#define APCI3501_TCW_TIMEBASE 8 -#define APCI3501_TCW_PROG 12 -#define APCI3501_TCW_TRIG_STATUS 16 -#define APCI3501_TCW_IRQ 20 -#define APCI3501_TCW_WARN_TIMEVAL 24 -#define APCI3501_TCW_WARN_TIMEBASE 28 #define ADDIDATA_TIMER 0 #define ADDIDATA_WATCHDOG 2 -/* ANALOG OUTPUT RANGE */ -static struct comedi_lrange range_apci3501_ao = { - 2, { - BIP_RANGE(10), - UNI_RANGE(10) - } -}; - -static int apci3501_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[1] = inl(devpriv->iobase + APCI3501_DIGITAL_IP) & 0x3; - - return insn->n; -} - -static int apci3501_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int mask = data[0]; - unsigned int bits = data[1]; - - s->state = inl(devpriv->iobase + APCI3501_DIGITAL_OP); - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); - - outl(s->state, devpriv->iobase + APCI3501_DIGITAL_OP); - } - - data[1] = s->state; - - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_ConfigAnalogOutput | -| (struct comedi_device *dev,struct comedi_subdevice *s, | -| struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Configures The Analog Output Subdevice | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s : Subdevice Pointer | -| struct comedi_insn *insn : Insn Structure Pointer | -| unsigned int *data : Data Pointer contains | -| configuration parameters as below | -| | -| data[0] : Voltage Mode | -| 0:Mode 0 | -| 1:Mode 1 | -| | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - outl(data[0], - devpriv->iobase + APCI3501_ANALOG_OUTPUT + - APCI3501_AO_VOLT_MODE); - - if (data[0]) { - devpriv->b_InterruptMode = MODE1; - } else { - devpriv->b_InterruptMode = MODE0; - } - return insn->n; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_WriteAnalogOutput | -| (struct comedi_device *dev,struct comedi_subdevice *s, | -| struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Writes To the Selected Anlog Output Channel | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| struct comedi_subdevice *s : Subdevice Pointer | -| struct comedi_insn *insn : Insn Structure Pointer | -| unsigned int *data : Data Pointer contains | -| configuration parameters as below | -| | -| | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0; - - ul_Channel_no = CR_CHAN(insn->chanspec); - - if (devpriv->b_InterruptMode == MODE1) { - ul_Polarity = 0x80000000; - if ((*data < 0) || (*data > 16384)) { - printk("\nIn WriteAnalogOutput :: Not Valid Data\n"); - } - - } /* end if(devpriv->b_InterruptMode==MODE1) */ - else { - ul_Polarity = 0; - if ((*data < 0) || (*data > 8192)) { - printk("\nIn WriteAnalogOutput :: Not Valid Data\n"); - } - - } /* end else */ - - if ((ul_Channel_no < 0) || (ul_Channel_no > 7)) { - printk("\nIn WriteAnalogOutput :: Not Valid Channel\n"); - } /* end if((ul_Channel_no<0)||(ul_Channel_no>7)) */ - - ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT); - - while (ul_DAC_Ready == 0) { - ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT); - ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1; - } - - if (ul_DAC_Ready) { -/* Output the Value on the output channels. */ - ul_Command1 = - (unsigned int) ((unsigned int) (ul_Channel_no & 0xFF) | - (unsigned int) ((*data << 0x8) & 0x7FFFFF00L) | - (unsigned int) (ul_Polarity)); - outl(ul_Command1, - devpriv->iobase + APCI3501_ANALOG_OUTPUT + - APCI3501_AO_PROG); - } - - return insn->n; -} - /* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_ConfigTimerCounterWatchdog | -| (struct comedi_device *dev,struct comedi_subdevice *s, | -| struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Configures The Timer , Counter or Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| unsigned int *data : Data Pointer contains | -| configuration parameters as below | -| | -| data[0] : 0 Configure As Timer | -| 1 Configure As Counter | -| 2 Configure As Watchdog | -| data[1] : 1 Enable Interrupt | -| 0 Disable Interrupt | -| data[2] : Time Unit | -| data[3] : Reload Value | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ + * (*insn_config) for the timer subdevice + * + * Configures The Timer, Counter or Watchdog + * Data Pointer contains configuration parameters as below + * data[0] : 0 Configure As Timer + * 1 Configure As Counter + * 2 Configure As Watchdog + * data[1] : 1 Enable Interrupt + * 0 Disable Interrupt + * data[2] : Time Unit + * data[3] : Reload Value + */ static int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3501_private *devpriv = dev->private; unsigned int ul_Command1 = 0; devpriv->tsk_Current = current; @@ -276,224 +29,146 @@ static int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev, devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG; /* Disable the watchdog */ - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Wa */ + outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG); if (data[1] == 1) { /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ - outl(0x02, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG); } else { - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */ + /* disable Timer interrupt */ + outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG); } - /* Loading the Timebase value */ - outl(data[2], - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TIMEBASE); + outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG); + outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG); - /* Loading the Reload value */ - outl(data[3], - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_RELOAD_VALUE); - /* Set the mode */ - ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL; /* e2->e0 */ - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); - } /* end if(data[0]==ADDIDATA_WATCHDOG) */ + /* Set the mode (e2->e0) */ + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG) | 0xFFF819E0UL; + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); + } else if (data[0] == ADDIDATA_TIMER) { /* First Stop The Timer */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* Stop The Timer */ + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); devpriv->b_TimerSelectMode = ADDIDATA_TIMER; if (data[1] == 1) { /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ - outl(0x02, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG); } else { - outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* disable Timer interrupt */ + /* disable Timer interrupt */ + outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG); } - /* Loading Timebase */ - outl(data[2], - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TIMEBASE); - - /* Loading the Reload value */ - outl(data[3], - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_RELOAD_VALUE); + outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG); + outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG); - /* printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG)); */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + /* mode 2 */ + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; - outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); /* mode 2 */ - - } /* end if(data[0]==ADDIDATA_TIMER) */ + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); + } return insn->n; } /* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_StartStopWriteTimerCounterWatchdog | -| (struct comedi_device *dev,struct comedi_subdevice *s, | -| struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Start / Stop The Selected Timer , Counter or Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| unsigned int *data : Data Pointer contains | -| configuration parameters as below | -| | -| data[0] : 0 Timer | -| 1 Counter | -| 2 Watchdog | | data[1] : 1 Start | -| 0 Stop | 2 Trigger | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - + * (*insn_write) for the timer subdevice + * + * Start / Stop The Selected Timer , Counter or Watchdog + * Data Pointer contains configuration parameters as below + * data[0] : 0 Timer + * 1 Counter + * 2 Watchdog + * data[1] : 1 Start + * 0 Stop + * 2 Trigger + */ static int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3501_private *devpriv = dev->private; unsigned int ul_Command1 = 0; int i_Temp; if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { if (data[1] == 1) { - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; /* Enable the Watchdog */ - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); } else if (data[1] == 0) /* Stop The Watchdog */ { /* Stop The Watchdog */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(0x0, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG); } else if (data[1] == 2) { - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x200UL; - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); - } /* if(data[1]==2) */ - } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); + } + } if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { if (data[1] == 1) { - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; /* Enable the Timer */ - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); } else if (data[1] == 0) { /* Stop The Timer */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); } else if (data[1] == 2) { /* Trigger the Timer */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x200UL; - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_PROG); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); } + } - } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ - i_Temp = inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TRIG_STATUS) & 0x1; + i_Temp = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1; return insn->n; } /* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_ReadTimerCounterWatchdog | -| (struct comedi_device *dev,struct comedi_subdevice *s, | -| struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read The Selected Timer , Counter or Watchdog | -+----------------------------------------------------------------------------+ -| Input Parameters : struct comedi_device *dev : Driver handle | -| unsigned int *data : Data Pointer contains | -| configuration parameters as below | -| | -| data[0] : 0 Timer | -| 1 Counter | -| 2 Watchdog | | data[1] : Timer Counter Watchdog Number | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ - + * (*insn_read) for the timer subdevice + * + * Read The Selected Timer, Counter or Watchdog + * Data Pointer contains configuration parameters as below + * data[0] : 0 Timer + * 1 Counter + * 2 Watchdog + * data[1] : Timer Counter Watchdog Number + */ static int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3501_private *devpriv = dev->private; if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) { - data[0] = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TRIG_STATUS) & 0x1; - data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG); - } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */ + data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1; + data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG); + } else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) { - data[0] = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TRIG_STATUS) & 0x1; - data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG); - } /* end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */ + data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1; + data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG); + } else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER) && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)) { @@ -501,111 +176,3 @@ static int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev, } return insn->n; } - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI3501_Reset(struct comedi_device *dev) | -| | -+----------------------------------------------------------------------------+ -| Task :Resets the registers of the card | -+----------------------------------------------------------------------------+ -| Input Parameters : | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : | -| | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI3501_Reset(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - int i_Count = 0, i_temp = 0; - unsigned int ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0; - - outl(0x0, devpriv->iobase + APCI3501_DIGITAL_OP); - outl(1, devpriv->iobase + APCI3501_ANALOG_OUTPUT + - APCI3501_AO_VOLT_MODE); - - ul_Polarity = 0x80000000; - - for (i_Count = 0; i_Count <= 7; i_Count++) { - ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT); - - while (ul_DAC_Ready == 0) { - ul_DAC_Ready = - inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT); - ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1; - } - - if (ul_DAC_Ready) { - /* Output the Value on the output channels. */ - ul_Command1 = - (unsigned int) ((unsigned int) (i_Count & 0xFF) | - (unsigned int) ((i_temp << 0x8) & 0x7FFFFF00L) | - (unsigned int) (ul_Polarity)); - outl(ul_Command1, - devpriv->iobase + APCI3501_ANALOG_OUTPUT + - APCI3501_AO_PROG); - } - } - - return 0; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : static void v_APCI3501_Interrupt | -| (int irq , void *d) | -+----------------------------------------------------------------------------+ -| Task : Interrupt processing Routine | -+----------------------------------------------------------------------------+ -| Input Parameters : int irq : irq number | -| void *d : void pointer | -+----------------------------------------------------------------------------+ -| Output Parameters : -- | -+----------------------------------------------------------------------------+ -| Return Value : TRUE : No error occur | -| : FALSE : Error occur. Return the error | -| | -+----------------------------------------------------------------------------+ -*/ -static void v_APCI3501_Interrupt(int irq, void *d) -{ - int i_temp; - struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; - unsigned int ui_Timer_AOWatchdog; - unsigned long ul_Command1; - - /* Disable Interrupt */ - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - - ul_Command1 = (ul_Command1 & 0xFFFFF9FDul); - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - - ui_Timer_AOWatchdog = - inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_IRQ) & 0x1; - - if ((!ui_Timer_AOWatchdog)) { - comedi_error(dev, "IRQ from unknown source"); - return; - } - -/* -* Enable Interrupt Send a signal to from kernel to user space -*/ - send_sig(SIGIO, devpriv->tsk_Current, 0); - ul_Command1 = - inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - ul_Command1 = ((ul_Command1 & 0xFFFFF9FDul) | 1 << 1); - outl(ul_Command1, - devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG); - i_temp = inl(devpriv->iobase + APCI3501_WATCHDOG + - APCI3501_TCW_TRIG_STATUS) & 0x1; - return; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index c981d4b..5a53e58 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -53,11 +55,6 @@ static int apci035_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci035_driver); } -static void apci035_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci035_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x0300) }, { 0 } @@ -68,7 +65,7 @@ static struct pci_driver apci035_pci_driver = { .name = "addi_apci_035", .id_table = apci035_pci_table, .probe = apci035_pci_probe, - .remove = apci035_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci035_driver, apci035_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 7f94242..c0d0429 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -29,6 +29,9 @@ * source code. */ +#include <linux/pci.h> +#include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -375,11 +378,6 @@ static int apci1032_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci1032_driver); } -static void apci1032_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci1032_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1003) }, { 0 } @@ -390,7 +388,7 @@ static struct pci_driver apci1032_pci_driver = { .name = "addi_apci_1032", .id_table = apci1032_pci_table, .probe = apci1032_pci_probe, - .remove = apci1032_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 8e686a9..9c2f8ee 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -53,11 +55,6 @@ static int apci1500_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci1500_driver); } -static void apci1500_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci1500_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x80fc) }, { 0 } @@ -68,7 +65,7 @@ static struct pci_driver apci1500_pci_driver = { .name = "addi_apci_1500", .id_table = apci1500_pci_table, .probe = apci1500_pci_probe, - .remove = apci1500_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index 8fef04b..69e39963 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -29,7 +29,10 @@ * this source code. */ +#include <linux/pci.h> + #include "../comedidev.h" +#include "addi_watchdog.h" #include "comedi_fc.h" /* @@ -49,13 +52,6 @@ * PCI bar 2 I/O Register map - Watchdog (APCI-1516 and APCI-2016) */ #define APCI1516_WDOG_REG 0x00 -#define APCI1516_WDOG_RELOAD_REG 0x04 -#define APCI1516_WDOG_CTRL_REG 0x0c -#define APCI1516_WDOG_CTRL_ENABLE (1 << 0) -#define APCI1516_WDOG_CTRL_SW_TRIG (1 << 9) -#define APCI1516_WDOG_STATUS_REG 0x10 -#define APCI1516_WDOG_STATUS_ENABLED (1 << 0) -#define APCI1516_WDOG_STATUS_SW_TRIG (1 << 1) struct apci1516_boardinfo { const char *name; @@ -86,7 +82,6 @@ static const struct apci1516_boardinfo apci1516_boardtypes[] = { struct apci1516_private { unsigned long wdog_iobase; - unsigned int ctrl; }; static int apci1516_di_insn_bits(struct comedi_device *dev, @@ -120,82 +115,6 @@ static int apci1516_do_insn_bits(struct comedi_device *dev, return insn->n; } -/* - * The watchdog subdevice is configured with two INSN_CONFIG instructions: - * - * Enable the watchdog and set the reload timeout: - * data[0] = INSN_CONFIG_ARM - * data[1] = timeout reload value - * - * Disable the watchdog: - * data[0] = INSN_CONFIG_DISARM - */ -static int apci1516_wdog_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - unsigned int reload; - - switch (data[0]) { - case INSN_CONFIG_ARM: - devpriv->ctrl = APCI1516_WDOG_CTRL_ENABLE; - reload = data[1] & s->maxdata; - outw(reload, devpriv->wdog_iobase + APCI1516_WDOG_RELOAD_REG); - - /* Time base is 20ms, let the user know the timeout */ - dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n", - 20 * reload + 20); - break; - case INSN_CONFIG_DISARM: - devpriv->ctrl = 0; - break; - default: - return -EINVAL; - } - - outw(devpriv->ctrl, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - - return insn->n; -} - -static int apci1516_wdog_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - int i; - - if (devpriv->ctrl == 0) { - dev_warn(dev->class_dev, "watchdog is disabled\n"); - return -EINVAL; - } - - /* "ping" the watchdog */ - for (i = 0; i < insn->n; i++) { - outw(devpriv->ctrl | APCI1516_WDOG_CTRL_SW_TRIG, - devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - } - - return insn->n; -} - -static int apci1516_wdog_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1516_private *devpriv = dev->private; - int i; - - for (i = 0; i < insn->n; i++) - data[i] = inw(devpriv->wdog_iobase + APCI1516_WDOG_STATUS_REG); - - return insn->n; -} - static int apci1516_reset(struct comedi_device *dev) { const struct apci1516_boardinfo *this_board = comedi_board(dev); @@ -205,8 +124,8 @@ static int apci1516_reset(struct comedi_device *dev) return 0; outw(0x0, dev->iobase + APCI1516_DO_REG); - outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG); - outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_RELOAD_REG); + + addi_watchdog_reset(devpriv->wdog_iobase); return 0; } @@ -285,13 +204,9 @@ static int apci1516_auto_attach(struct comedi_device *dev, /* Initialize the watchdog subdevice */ s = &dev->subdevices[2]; if (this_board->has_wdog) { - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE; - s->n_chan = 1; - s->maxdata = 0xff; - s->insn_write = apci1516_wdog_insn_write; - s->insn_read = apci1516_wdog_insn_read; - s->insn_config = apci1516_wdog_insn_config; + ret = addi_watchdog_init(s, devpriv->wdog_iobase); + if (ret) + return ret; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -304,10 +219,12 @@ static void apci1516_detach(struct comedi_device *dev) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (dev->iobase) { + if (dev->iobase) apci1516_reset(dev); + if (dev->subdevices) + addi_watchdog_cleanup(&dev->subdevices[2]); + if (dev->iobase) comedi_pci_disable(pcidev); - } } static struct comedi_driver apci1516_driver = { @@ -323,11 +240,6 @@ static int apci1516_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci1516_driver); } -static void apci1516_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1016) }, { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1516) }, @@ -340,7 +252,7 @@ static struct pci_driver apci1516_pci_driver = { .name = "addi_apci_1516", .id_table = apci1516_pci_table, .probe = apci1516_pci_probe, - .remove = apci1516_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci1516_driver, apci1516_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 513e536..ddea64d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -50,11 +52,6 @@ static int apci1564_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci1564_driver); } -static void apci1564_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci1564_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1006) }, { 0 } @@ -65,7 +62,7 @@ static struct pci_driver apci1564_pci_driver = { .name = "addi_apci_1564", .id_table = apci1564_pci_table, .probe = apci1564_pci_probe, - .remove = apci1564_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index ab9a96a..e51f800 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -1,49 +1,227 @@ +/* + * addi_apci_16xx.c + * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. + * Project manager: S. Weber + * + * ADDI-DATA GmbH + * Dieselstrasse 3 + * D-77833 Ottersweier + * Tel: +19(0)7223/9493-0 + * Fax: +49(0)7223/9493-92 + * http://www.addi-data.com + * info@addi-data.com + * + * 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * You should also find the complete GPL in the COPYING file accompanying + * this source code. + */ + +#include <linux/pci.h> + #include "../comedidev.h" -#include "comedi_fc.h" -#include "amcc_s5933.h" -#include "addi-data/addi_common.h" +/* + * PCI device ids supported by this driver + */ +#define PCI_DEVICE_ID_APCI1648 0x1009 +#define PCI_DEVICE_ID_APCI1696 0x100a -#include "addi-data/addi_eeprom.c" -#include "addi-data/hwdrv_apci16xx.c" -#include "addi-data/addi_common.c" +/* + * Register I/O map + */ +#define APCI16XX_IN_REG(x) (((x) * 4) + 0x08) +#define APCI16XX_OUT_REG(x) (((x) * 4) + 0x14) +#define APCI16XX_DIR_REG(x) (((x) * 4) + 0x20) -static const struct addi_board apci16xx_boardtypes[] = { +struct apci16xx_boardinfo { + const char *name; + unsigned short vendor; + unsigned short device; + int n_chan; +}; + +static const struct apci16xx_boardinfo apci16xx_boardtypes[] = { { - .pc_DriverName = "apci1648", - .i_VendorId = PCI_VENDOR_ID_ADDIDATA, - .i_DeviceId = 0x1009, - .i_IorangeBase0 = 128, - .i_PCIEeprom = ADDIDATA_NO_EEPROM, - .i_NbrTTLChannel = 48, - .reset = i_APCI16XX_Reset, - .ttl_config = i_APCI16XX_InsnConfigInitTTLIO, - .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO, - .ttl_read = i_APCI16XX_InsnReadTTLIOAllPortValue, - .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO, + .name = "apci1648", + .vendor = PCI_VENDOR_ID_ADDIDATA, + .device = PCI_DEVICE_ID_APCI1648, + .n_chan = 48, /* 2 subdevices */ }, { - .pc_DriverName = "apci1696", - .i_VendorId = PCI_VENDOR_ID_ADDIDATA, - .i_DeviceId = 0x100A, - .i_IorangeBase0 = 128, - .i_PCIEeprom = ADDIDATA_NO_EEPROM, - .i_NbrTTLChannel = 96, - .reset = i_APCI16XX_Reset, - .ttl_config = i_APCI16XX_InsnConfigInitTTLIO, - .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO, - .ttl_read = i_APCI16XX_InsnReadTTLIOAllPortValue, - .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO, + .name = "apci1696", + .vendor = PCI_VENDOR_ID_ADDIDATA, + .device = PCI_DEVICE_ID_APCI1696, + .n_chan = 96, /* 3 subdevices */ }, }; +static int apci16xx_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); + unsigned int bits; + + /* + * Each 8-bit "port" is configurable as either input or + * output. Changing the configuration of any channel in + * a port changes the entire port. + */ + if (chan_mask & 0x000000ff) + bits = 0x000000ff; + else if (chan_mask & 0x0000ff00) + bits = 0x0000ff00; + else if (chan_mask & 0x00ff0000) + bits = 0x00ff0000; + else + bits = 0xff000000; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_INPUT : COMEDI_OUTPUT; + return insn->n; + default: + return -EINVAL; + } + + outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(s->index)); + + return insn->n; +} + +static int apci16xx_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int mask = data[0]; + unsigned int bits = data[1]; + + /* Only update the channels configured as outputs */ + mask &= s->io_bits; + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outl(s->state, dev->iobase + APCI16XX_OUT_REG(s->index)); + } + + data[1] = inl(dev->iobase + APCI16XX_IN_REG(s->index)); + + return insn->n; +} + +static const void *apci16xx_find_boardinfo(struct comedi_device *dev, + struct pci_dev *pcidev) +{ + const struct apci16xx_boardinfo *board; + int i; + + for (i = 0; i < ARRAY_SIZE(apci16xx_boardtypes); i++) { + board = &apci16xx_boardtypes[i]; + if (board->vendor == pcidev->vendor && + board->device == pcidev->device) + return board; + } + return NULL; +} + +static int apci16xx_auto_attach(struct comedi_device *dev, + unsigned long context_unused) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + const struct apci16xx_boardinfo *board; + struct comedi_subdevice *s; + unsigned int n_subdevs; + unsigned int last; + int i; + int ret; + + board = apci16xx_find_boardinfo(dev, pcidev); + if (!board) + return -ENODEV; + dev->board_ptr = board; + dev->board_name = board->name; + + ret = comedi_pci_enable(pcidev, dev->board_name); + if (ret) + return ret; + + dev->iobase = pci_resource_start(pcidev, 0); + + /* + * Work out the nubmer of subdevices needed to support all the + * digital i/o channels on the board. Each subdevice supports + * up to 32 channels. + */ + n_subdevs = board->n_chan / 32; + if ((n_subdevs * 32) < board->n_chan) { + last = board->n_chan - (n_subdevs * 32); + n_subdevs++; + } else { + last = 0; + } + + ret = comedi_alloc_subdevices(dev, n_subdevs); + if (ret) + return ret; + + /* Initialize the TTL digital i/o subdevices */ + for (i = 0; i < n_subdevs; i++) { + s = &dev->subdevices[i]; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_WRITEABLE | SDF_READABLE; + s->n_chan = ((i * 32) < board->n_chan) ? 32 : last; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_config = apci16xx_insn_config; + s->insn_bits = apci16xx_dio_insn_bits; + + /* Default all channels to inputs */ + s->io_bits = 0; + outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(i)); + } + + return 0; +} + +static void apci16xx_detach(struct comedi_device *dev) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + } +} + static struct comedi_driver apci16xx_driver = { .driver_name = "addi_apci_16xx", .module = THIS_MODULE, - .auto_attach = addi_auto_attach, - .detach = i_ADDI_Detach, + .auto_attach = apci16xx_auto_attach, + .detach = apci16xx_detach, .num_names = ARRAY_SIZE(apci16xx_boardtypes), - .board_name = &apci16xx_boardtypes[0].pc_DriverName, - .offset = sizeof(struct addi_board), + .board_name = &apci16xx_boardtypes[0].name, + .offset = sizeof(struct apci16xx_boardinfo), }; static int apci16xx_pci_probe(struct pci_dev *dev, @@ -52,14 +230,9 @@ static int apci16xx_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci16xx_driver); } -static void apci16xx_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci16xx_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1009) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x100a) }, + { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1648) }, + { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1696) }, { 0 } }; MODULE_DEVICE_TABLE(pci, apci16xx_pci_table); @@ -68,10 +241,10 @@ static struct pci_driver apci16xx_pci_driver = { .name = "addi_apci_16xx", .id_table = apci16xx_pci_table, .probe = apci16xx_pci_probe, - .remove = apci16xx_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci16xx_driver, apci16xx_pci_driver); +MODULE_DESCRIPTION("ADDI-DATA APCI-1648/1696, TTL I/O boards"); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index 152e7ef..e83e829 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include <asm/i387.h> #include "../comedidev.h" @@ -128,11 +130,6 @@ static int apci1710_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci1710_driver); } -static void apci1710_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci1710_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, APCI1710_BOARD_DEVICE_ID) }, { 0 } @@ -143,7 +140,7 @@ static struct pci_driver apci1710_pci_driver = { .name = "addi_apci_1710", .id_table = apci1710_pci_table, .probe = apci1710_pci_probe, - .remove = apci1710_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci1710_driver, apci1710_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 8f8d3e9..9ce1d26 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -29,7 +29,11 @@ * this source code. */ +#include <linux/pci.h> +#include <linux/interrupt.h> + #include "../comedidev.h" +#include "addi_watchdog.h" #include "comedi_fc.h" /* @@ -45,17 +49,12 @@ #define APCI2032_STATUS_REG 0x0c #define APCI2032_STATUS_IRQ (1 << 0) #define APCI2032_WDOG_REG 0x10 -#define APCI2032_WDOG_RELOAD_REG 0x14 -#define APCI2032_WDOG_TIMEBASE 0x18 -#define APCI2032_WDOG_CTRL_REG 0x1c -#define APCI2032_WDOG_CTRL_ENABLE (1 << 0) -#define APCI2032_WDOG_CTRL_SW_TRIG (1 << 9) -#define APCI2032_WDOG_STATUS_REG 0x20 -#define APCI2032_WDOG_STATUS_ENABLED (1 << 0) -#define APCI2032_WDOG_STATUS_SW_TRIG (1 << 1) - -struct apci2032_private { - unsigned int wdog_ctrl; + +struct apci2032_int_private { + spinlock_t spinlock; + unsigned int stop_count; + bool active; + unsigned char enabled_isns; }; static int apci2032_do_insn_bits(struct comedi_device *dev, @@ -79,88 +78,47 @@ static int apci2032_do_insn_bits(struct comedi_device *dev, return insn->n; } -/* - * The watchdog subdevice is configured with two INSN_CONFIG instructions: - * - * Enable the watchdog and set the reload timeout: - * data[0] = INSN_CONFIG_ARM - * data[1] = timeout reload value - * - * Disable the watchdog: - * data[0] = INSN_CONFIG_DISARM - */ -static int apci2032_wdog_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int apci2032_int_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct apci2032_private *devpriv = dev->private; - unsigned int reload; - - switch (data[0]) { - case INSN_CONFIG_ARM: - devpriv->wdog_ctrl = APCI2032_WDOG_CTRL_ENABLE; - reload = data[1] & s->maxdata; - outw(reload, dev->iobase + APCI2032_WDOG_RELOAD_REG); - - /* Time base is 20ms, let the user know the timeout */ - dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n", - 20 * reload + 20); - break; - case INSN_CONFIG_DISARM: - devpriv->wdog_ctrl = 0; - break; - default: - return -EINVAL; - } - - outw(devpriv->wdog_ctrl, dev->iobase + APCI2032_WDOG_CTRL_REG); - + data[1] = inl(dev->iobase + APCI2032_INT_STATUS_REG) & 3; return insn->n; } -static int apci2032_wdog_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static void apci2032_int_stop(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct apci2032_private *devpriv = dev->private; - int i; - - if (devpriv->wdog_ctrl == 0) { - dev_warn(dev->class_dev, "watchdog is disabled\n"); - return -EINVAL; - } - - /* "ping" the watchdog */ - for (i = 0; i < insn->n; i++) { - outw(devpriv->wdog_ctrl | APCI2032_WDOG_CTRL_SW_TRIG, - dev->iobase + APCI2032_WDOG_CTRL_REG); - } + struct apci2032_int_private *subpriv = s->private; - return insn->n; + subpriv->active = false; + subpriv->enabled_isns = 0; + outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG); } -static int apci2032_wdog_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static bool apci2032_int_start(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned char enabled_isns) { - int i; - - for (i = 0; i < insn->n; i++) - data[i] = inl(dev->iobase + APCI2032_WDOG_STATUS_REG); - - return insn->n; -} + struct apci2032_int_private *subpriv = s->private; + struct comedi_cmd *cmd = &s->async->cmd; + bool do_event; + + subpriv->enabled_isns = enabled_isns; + subpriv->stop_count = cmd->stop_arg; + if (cmd->stop_src == TRIG_COUNT && subpriv->stop_count == 0) { + /* An empty acquisition! */ + s->async->events |= COMEDI_CB_EOA; + subpriv->active = false; + do_event = true; + } else { + subpriv->active = true; + outl(enabled_isns, dev->iobase + APCI2032_INT_CTRL_REG); + do_event = false; + } -static int apci2032_int_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - data[1] = s->state; - return insn->n; + return do_event; } static int apci2032_int_cmdtest(struct comedi_device *dev, @@ -172,15 +130,17 @@ static int apci2032_int_cmdtest(struct comedi_device *dev, /* Step 1 : check if triggers are trivially valid */ err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); - err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER); - err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE); + err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); if (err) return 1; /* Step 2a : make sure trigger sources are unique */ + err |= cfc_check_trigger_is_unique(cmd->stop_src); + /* Step 2b : and mutually compatible */ if (err) @@ -189,18 +149,11 @@ static int apci2032_int_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - - /* - * 0 == no trigger - * 1 == trigger on VCC interrupt - * 2 == trigger on CC interrupt - * 3 == trigger on either VCC or CC interrupt - */ - err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 3); - + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); - err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + if (cmd->stop_src == TRIG_NONE) + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) return 3; @@ -217,8 +170,22 @@ static int apci2032_int_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; + struct apci2032_int_private *subpriv = s->private; + unsigned char enabled_isns; + unsigned int n; + unsigned long flags; + bool do_event; + + enabled_isns = 0; + for (n = 0; n < cmd->chanlist_len; n++) + enabled_isns |= 1 << CR_CHAN(cmd->chanlist[n]); + + spin_lock_irqsave(&subpriv->spinlock, flags); + do_event = apci2032_int_start(dev, s, enabled_isns); + spin_unlock_irqrestore(&subpriv->spinlock, flags); - outl(cmd->scan_begin_arg, dev->iobase + APCI2032_INT_CTRL_REG); + if (do_event) + comedi_event(dev, s); return 0; } @@ -226,7 +193,13 @@ static int apci2032_int_cmd(struct comedi_device *dev, static int apci2032_int_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG); + struct apci2032_int_private *subpriv = s->private; + unsigned long flags; + + spin_lock_irqsave(&subpriv->spinlock, flags); + if (subpriv->active) + apci2032_int_stop(dev, s); + spin_unlock_irqrestore(&subpriv->spinlock, flags); return 0; } @@ -235,19 +208,64 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; + struct apci2032_int_private *subpriv; unsigned int val; + bool do_event = false; + + if (!dev->attached) + return IRQ_NONE; /* Check if VCC OR CC interrupt has occurred */ val = inl(dev->iobase + APCI2032_STATUS_REG) & APCI2032_STATUS_IRQ; if (!val) return IRQ_NONE; - s->state = inl(dev->iobase + APCI2032_INT_STATUS_REG); - outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG); + subpriv = s->private; + spin_lock(&subpriv->spinlock); + + val = inl(dev->iobase + APCI2032_INT_STATUS_REG) & 3; + /* Disable triggered interrupt sources. */ + outl(~val & 3, dev->iobase + APCI2032_INT_CTRL_REG); + /* + * Note: We don't reenable the triggered interrupt sources because they + * are level-sensitive, hardware error status interrupt sources and + * they'd keep triggering interrupts repeatedly. + */ - comedi_buf_put(s->async, s->state); - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(dev, s); + if (subpriv->active && (val & subpriv->enabled_isns) != 0) { + unsigned short bits; + unsigned int n, len; + unsigned int *chanlist; + + /* Bits in scan data correspond to indices in channel list. */ + bits = 0; + len = s->async->cmd.chanlist_len; + chanlist = &s->async->cmd.chanlist[0]; + for (n = 0; n < len; n++) + if ((val & (1U << CR_CHAN(chanlist[n]))) != 0) + bits |= 1U << n; + + if (comedi_buf_put(s->async, bits)) { + s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + if (s->async->cmd.stop_src == TRIG_COUNT && + subpriv->stop_count > 0) { + subpriv->stop_count--; + if (subpriv->stop_count == 0) { + /* end of acquisition */ + s->async->events |= COMEDI_CB_EOA; + apci2032_int_stop(dev, s); + } + } + } else { + apci2032_int_stop(dev, s); + s->async->events |= COMEDI_CB_OVERFLOW; + } + do_event = true; + } + + spin_unlock(&subpriv->spinlock); + if (do_event) + comedi_event(dev, s); return IRQ_HANDLED; } @@ -256,8 +274,8 @@ static int apci2032_reset(struct comedi_device *dev) { outl(0x0, dev->iobase + APCI2032_DO_REG); outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG); - outl(0x0, dev->iobase + APCI2032_WDOG_CTRL_REG); - outl(0x0, dev->iobase + APCI2032_WDOG_RELOAD_REG); + + addi_watchdog_reset(dev->iobase + APCI2032_WDOG_REG); return 0; } @@ -266,21 +284,16 @@ static int apci2032_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct apci2032_private *devpriv; struct comedi_subdevice *s; int ret; dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); - if (!devpriv) - return -ENOMEM; - dev->private = devpriv; - ret = comedi_pci_enable(pcidev, dev->board_name); if (ret) return ret; dev->iobase = pci_resource_start(pcidev, 1); + apci2032_reset(dev); if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci2032_interrupt, @@ -304,32 +317,34 @@ static int apci2032_auto_attach(struct comedi_device *dev, /* Initialize the watchdog subdevice */ s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE; - s->n_chan = 1; - s->maxdata = 0xff; - s->insn_write = apci2032_wdog_insn_write; - s->insn_read = apci2032_wdog_insn_read; - s->insn_config = apci2032_wdog_insn_config; + ret = addi_watchdog_init(s, dev->iobase + APCI2032_WDOG_REG); + if (ret) + return ret; /* Initialize the interrupt subdevice */ s = &dev->subdevices[2]; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 2; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci2032_int_insn_bits; if (dev->irq) { + struct apci2032_int_private *subpriv; + dev->read_subdev = s; - s->type = COMEDI_SUBD_DI | SDF_CMD_READ; - s->subdev_flags = SDF_READABLE; - s->n_chan = 1; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = apci2032_int_insn_bits; + subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); + if (!subpriv) + return -ENOMEM; + spin_lock_init(&subpriv->spinlock); + s->private = subpriv; + s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->len_chanlist = 2; s->do_cmdtest = apci2032_int_cmdtest; s->do_cmd = apci2032_int_cmd; s->cancel = apci2032_int_cancel; - } else { - s->type = COMEDI_SUBD_UNUSED; } - apci2032_reset(dev); return 0; } @@ -341,6 +356,10 @@ static void apci2032_detach(struct comedi_device *dev) apci2032_reset(dev); if (dev->irq) free_irq(dev->irq, dev); + if (dev->read_subdev) + kfree(dev->read_subdev->private); + if (dev->subdevices) + addi_watchdog_cleanup(&dev->subdevices[1]); if (pcidev) { if (dev->iobase) comedi_pci_disable(pcidev); @@ -360,11 +379,6 @@ static int apci2032_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci2032_driver); } -static void apci2032_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci2032_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1004) }, { 0 } @@ -375,7 +389,7 @@ static struct pci_driver apci2032_pci_driver = { .name = "addi_apci_2032", .id_table = apci2032_pci_table, .probe = apci2032_pci_probe, - .remove = apci2032_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index 7c2c5db..b1c4226 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -1,42 +1,152 @@ +/* + * addi_apci_2200.c + * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. + * Project manager: Eric Stolz + * + * ADDI-DATA GmbH + * Dieselstrasse 3 + * D-77833 Ottersweier + * Tel: +19(0)7223/9493-0 + * Fax: +49(0)7223/9493-92 + * http://www.addi-data.com + * info@addi-data.com + * + * 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * You should also find the complete GPL in the COPYING file accompanying + * this source code. + */ + +#include <linux/pci.h> + #include "../comedidev.h" -#include "comedi_fc.h" -#include "amcc_s5933.h" - -#include "addi-data/addi_common.h" - -#include "addi-data/addi_eeprom.c" -#include "addi-data/hwdrv_apci2200.c" -#include "addi-data/addi_common.c" - -static const struct addi_board apci2200_boardtypes[] = { - { - .pc_DriverName = "apci2200", - .i_VendorId = PCI_VENDOR_ID_ADDIDATA, - .i_DeviceId = 0x1005, - .i_IorangeBase0 = 4, - .i_IorangeBase1 = APCI2200_ADDRESS_RANGE, - .i_PCIEeprom = ADDIDATA_EEPROM, - .pc_EepromChip = ADDIDATA_93C76, - .i_NbrDiChannel = 8, - .i_NbrDoChannel = 16, - .i_Timer = 1, - .reset = i_APCI2200_Reset, - .di_bits = apci2200_di_insn_bits, - .do_bits = apci2200_do_insn_bits, - .timer_config = i_APCI2200_ConfigWatchdog, - .timer_write = i_APCI2200_StartStopWriteWatchdog, - .timer_read = i_APCI2200_ReadWatchdog, - }, -}; +#include "addi_watchdog.h" + +/* + * I/O Register Map + */ +#define APCI2200_DI_REG 0x00 +#define APCI2200_DO_REG 0x04 +#define APCI2200_WDOG_REG 0x08 + +static int apci2200_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + data[1] = inw(dev->iobase + APCI2200_DI_REG); + + return insn->n; +} + +static int apci2200_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int mask = data[0]; + unsigned int bits = data[1]; + + s->state = inw(dev->iobase + APCI2200_DO_REG); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outw(s->state, dev->iobase + APCI2200_DO_REG); + } + + data[1] = s->state; + + return insn->n; +} + +static int apci2200_reset(struct comedi_device *dev) +{ + outw(0x0, dev->iobase + APCI2200_DO_REG); + + addi_watchdog_reset(dev->iobase + APCI2200_WDOG_REG); + + return 0; +} + +static int apci2200_auto_attach(struct comedi_device *dev, + unsigned long context_unused) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + struct comedi_subdevice *s; + int ret; + + dev->board_name = dev->driver->driver_name; + + ret = comedi_pci_enable(pcidev, dev->board_name); + if (ret) + return ret; + + dev->iobase = pci_resource_start(pcidev, 1); + + ret = comedi_alloc_subdevices(dev, 3); + if (ret) + return ret; + + /* Initialize the digital input subdevice */ + s = &dev->subdevices[0]; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci2200_di_insn_bits; + + /* Initialize the digital output subdevice */ + s = &dev->subdevices[1]; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci2200_do_insn_bits; + + /* Initialize the watchdog subdevice */ + s = &dev->subdevices[2]; + ret = addi_watchdog_init(s, dev->iobase + APCI2200_WDOG_REG); + if (ret) + return ret; + + apci2200_reset(dev); + return 0; +} + +static void apci2200_detach(struct comedi_device *dev) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + + if (dev->iobase) + apci2200_reset(dev); + if (dev->subdevices) + addi_watchdog_cleanup(&dev->subdevices[2]); + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + } +} static struct comedi_driver apci2200_driver = { .driver_name = "addi_apci_2200", .module = THIS_MODULE, - .auto_attach = addi_auto_attach, - .detach = i_ADDI_Detach, - .num_names = ARRAY_SIZE(apci2200_boardtypes), - .board_name = &apci2200_boardtypes[0].pc_DriverName, - .offset = sizeof(struct addi_board), + .auto_attach = apci2200_auto_attach, + .detach = apci2200_detach, }; static int apci2200_pci_probe(struct pci_dev *dev, @@ -45,11 +155,6 @@ static int apci2200_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci2200_driver); } -static void apci2200_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci2200_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1005) }, { 0 } @@ -60,10 +165,10 @@ static struct pci_driver apci2200_pci_driver = { .name = "addi_apci_2200", .id_table = apci2200_pci_table, .probe = apci2200_pci_probe, - .remove = apci2200_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci2200_driver, apci2200_pci_driver); +MODULE_DESCRIPTION("ADDI-DATA APCI-2200 Relay board, optically isolated"); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index fec2962..917234d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -251,11 +253,6 @@ static int apci3120_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci3120_driver); } -static void apci3120_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci3120_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x818d) }, { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x828d) }, @@ -267,7 +264,7 @@ static struct pci_driver apci3120_pci_driver = { .name = "addi_apci_3120", .id_table = apci3120_pci_table, .probe = apci3120_pci_probe, - .remove = apci3120_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_3200.c b/drivers/staging/comedi/drivers/addi_apci_3200.c index 9085b77..90ee4f8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3200.c +++ b/drivers/staging/comedi/drivers/addi_apci_3200.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include <asm/i387.h> #include "../comedidev.h" @@ -106,15 +108,10 @@ static int apci3200_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci3200_driver); } -static void apci3200_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver apci3200_pci_driver = { .name = "addi_apci_3200", .id_table = apci3200_pci_table, .probe = apci3200_pci_probe, - .remove = apci3200_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci3200_driver, apci3200_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index ed297de..786fcaf 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -1,54 +1,445 @@ +/* + * addi_apci_3501.c + * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. + * Project manager: Eric Stolz + * + * ADDI-DATA GmbH + * Dieselstrasse 3 + * D-77833 Ottersweier + * Tel: +19(0)7223/9493-0 + * Fax: +49(0)7223/9493-92 + * http://www.addi-data.com + * info@addi-data.com + * + * 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * You should also find the complete GPL in the COPYING file accompanying + * this source code. + */ + +#include <linux/pci.h> +#include <linux/interrupt.h> +#include <linux/sched.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" -#include "addi-data/addi_common.h" +/* + * PCI bar 1 register I/O map + */ +#define APCI3501_AO_CTRL_STATUS_REG 0x00 +#define APCI3501_AO_CTRL_BIPOLAR (1 << 0) +#define APCI3501_AO_STATUS_READY (1 << 8) +#define APCI3501_AO_DATA_REG 0x04 +#define APCI3501_AO_DATA_CHAN(x) ((x) << 0) +#define APCI3501_AO_DATA_VAL(x) ((x) << 8) +#define APCI3501_AO_DATA_BIPOLAR (1 << 31) +#define APCI3501_AO_TRIG_SCS_REG 0x08 +#define APCI3501_TIMER_SYNC_REG 0x20 +#define APCI3501_TIMER_RELOAD_REG 0x24 +#define APCI3501_TIMER_TIMEBASE_REG 0x28 +#define APCI3501_TIMER_CTRL_REG 0x2c +#define APCI3501_TIMER_STATUS_REG 0x30 +#define APCI3501_TIMER_IRQ_REG 0x34 +#define APCI3501_TIMER_WARN_RELOAD_REG 0x38 +#define APCI3501_TIMER_WARN_TIMEBASE_REG 0x3c +#define APCI3501_DO_REG 0x40 +#define APCI3501_DI_REG 0x50 -#include "addi-data/addi_eeprom.c" -#include "addi-data/hwdrv_apci3501.c" -#include "addi-data/addi_common.c" - -static const struct addi_board apci3501_boardtypes[] = { - { - .pc_DriverName = "apci3501", - .i_VendorId = PCI_VENDOR_ID_ADDIDATA, - .i_DeviceId = 0x3001, - .i_IorangeBase0 = 64, - .i_IorangeBase1 = APCI3501_ADDRESS_RANGE, - .i_PCIEeprom = ADDIDATA_EEPROM, - .pc_EepromChip = ADDIDATA_S5933, - .i_AoMaxdata = 16383, - .pr_AoRangelist = &range_apci3501_ao, - .i_NbrDiChannel = 2, - .i_NbrDoChannel = 2, - .i_DoMaxdata = 0x3, - .i_Timer = 1, - .interrupt = v_APCI3501_Interrupt, - .reset = i_APCI3501_Reset, - .ao_config = i_APCI3501_ConfigAnalogOutput, - .ao_write = i_APCI3501_WriteAnalogOutput, - .di_bits = apci3501_di_insn_bits, - .do_bits = apci3501_do_insn_bits, - .timer_config = i_APCI3501_ConfigTimerCounterWatchdog, - .timer_write = i_APCI3501_StartStopWriteTimerCounterWatchdog, - .timer_read = i_APCI3501_ReadTimerCounterWatchdog, - }, +/* + * AMCC S5933 NVRAM + */ +#define NVRAM_USER_DATA_START 0x100 + +#define NVCMD_BEGIN_READ (0x7 << 5) +#define NVCMD_LOAD_LOW (0x4 << 5) +#define NVCMD_LOAD_HIGH (0x5 << 5) + +/* + * Function types stored in the eeprom + */ +#define EEPROM_DIGITALINPUT 0 +#define EEPROM_DIGITALOUTPUT 1 +#define EEPROM_ANALOGINPUT 2 +#define EEPROM_ANALOGOUTPUT 3 +#define EEPROM_TIMER 4 +#define EEPROM_WATCHDOG 5 +#define EEPROM_TIMER_WATCHDOG_COUNTER 10 + +struct apci3501_private { + int i_IobaseAmcc; + struct task_struct *tsk_Current; + unsigned char b_TimerSelectMode; }; -static DEFINE_PCI_DEVICE_TABLE(apci3501_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3001) }, - { 0 } +static struct comedi_lrange apci3501_ao_range = { + 2, { + BIP_RANGE(10), + UNI_RANGE(10) + } }; -MODULE_DEVICE_TABLE(pci, apci3501_pci_table); + +static int apci3501_wait_for_dac(struct comedi_device *dev) +{ + unsigned int status; + + do { + status = inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG); + } while (!(status & APCI3501_AO_STATUS_READY)); + + return 0; +} + +static int apci3501_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); + unsigned int val = 0; + int i; + int ret; + + /* + * All analog output channels have the same output range. + * 14-bit bipolar: 0-10V + * 13-bit unipolar: +/-10V + * Changing the range of one channel changes all of them! + */ + if (range) { + outl(0, dev->iobase + APCI3501_AO_CTRL_STATUS_REG); + } else { + val |= APCI3501_AO_DATA_BIPOLAR; + outl(APCI3501_AO_CTRL_BIPOLAR, + dev->iobase + APCI3501_AO_CTRL_STATUS_REG); + } + + val |= APCI3501_AO_DATA_CHAN(chan); + + for (i = 0; i < insn->n; i++) { + if (range == 1) { + if (data[i] > 0x1fff) { + dev_err(dev->class_dev, + "Unipolar resolution is only 13-bits\n"); + return -EINVAL; + } + } + + ret = apci3501_wait_for_dac(dev); + if (ret) + return ret; + + outl(val | APCI3501_AO_DATA_VAL(data[i]), + dev->iobase + APCI3501_AO_DATA_REG); + } + + return insn->n; +} + +#include "addi-data/hwdrv_apci3501.c" + +static int apci3501_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + data[1] = inl(dev->iobase + APCI3501_DI_REG) & 0x3; + + return insn->n; +} + +static int apci3501_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int mask = data[0]; + unsigned int bits = data[1]; + + s->state = inl(dev->iobase + APCI3501_DO_REG); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outl(s->state, dev->iobase + APCI3501_DO_REG); + } + + data[1] = s->state; + + return insn->n; +} + +static void apci3501_eeprom_wait(unsigned long iobase) +{ + unsigned char val; + + do { + val = inb(iobase + AMCC_OP_REG_MCSR_NVCMD); + } while (val & 0x80); +} + +static unsigned short apci3501_eeprom_readw(unsigned long iobase, + unsigned short addr) +{ + unsigned short val = 0; + unsigned char tmp; + unsigned char i; + + /* Add the offset to the start of the user data */ + addr += NVRAM_USER_DATA_START; + + for (i = 0; i < 2; i++) { + /* Load the low 8 bit address */ + outb(NVCMD_LOAD_LOW, iobase + AMCC_OP_REG_MCSR_NVCMD); + apci3501_eeprom_wait(iobase); + outb((addr + i) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA); + apci3501_eeprom_wait(iobase); + + /* Load the high 8 bit address */ + outb(NVCMD_LOAD_HIGH, iobase + AMCC_OP_REG_MCSR_NVCMD); + apci3501_eeprom_wait(iobase); + outb(((addr + i) >> 8) & 0xff, + iobase + AMCC_OP_REG_MCSR_NVDATA); + apci3501_eeprom_wait(iobase); + + /* Read the eeprom data byte */ + outb(NVCMD_BEGIN_READ, iobase + AMCC_OP_REG_MCSR_NVCMD); + apci3501_eeprom_wait(iobase); + tmp = inb(iobase + AMCC_OP_REG_MCSR_NVDATA); + apci3501_eeprom_wait(iobase); + + if (i == 0) + val |= tmp; + else + val |= (tmp << 8); + } + + return val; +} + +static int apci3501_eeprom_get_ao_n_chan(struct comedi_device *dev) +{ + struct apci3501_private *devpriv = dev->private; + unsigned long iobase = devpriv->i_IobaseAmcc; + unsigned char nfuncs; + int i; + + nfuncs = apci3501_eeprom_readw(iobase, 10) & 0xff; + + /* Read functionality details */ + for (i = 0; i < nfuncs; i++) { + unsigned short offset = i * 4; + unsigned short addr; + unsigned char func; + unsigned short val; + + func = apci3501_eeprom_readw(iobase, 12 + offset) & 0x3f; + addr = apci3501_eeprom_readw(iobase, 14 + offset); + + if (func == EEPROM_ANALOGOUTPUT) { + val = apci3501_eeprom_readw(iobase, addr + 10); + return (val >> 4) & 0x3ff; + } + } + return 0; +} + +static int apci3501_eeprom_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci3501_private *devpriv = dev->private; + unsigned short addr = CR_CHAN(insn->chanspec); + + data[0] = apci3501_eeprom_readw(devpriv->i_IobaseAmcc, 2 * addr); + + return insn->n; +} + +static irqreturn_t apci3501_interrupt(int irq, void *d) +{ + struct comedi_device *dev = d; + struct apci3501_private *devpriv = dev->private; + unsigned int ui_Timer_AOWatchdog; + unsigned long ul_Command1; + int i_temp; + + /* Disable Interrupt */ + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); + ul_Command1 = (ul_Command1 & 0xFFFFF9FDul); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); + + ui_Timer_AOWatchdog = inl(dev->iobase + APCI3501_TIMER_IRQ_REG) & 0x1; + if ((!ui_Timer_AOWatchdog)) { + comedi_error(dev, "IRQ from unknown source"); + return IRQ_NONE; + } + + /* Enable Interrupt Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_Current, 0); + ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); + ul_Command1 = ((ul_Command1 & 0xFFFFF9FDul) | 1 << 1); + outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); + i_temp = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1; + + return IRQ_HANDLED; +} + +static int apci3501_reset(struct comedi_device *dev) +{ + unsigned int val; + int chan; + int ret; + + /* Reset all digital outputs to "0" */ + outl(0x0, dev->iobase + APCI3501_DO_REG); + + /* Default all analog outputs to 0V (bipolar) */ + outl(APCI3501_AO_CTRL_BIPOLAR, + dev->iobase + APCI3501_AO_CTRL_STATUS_REG); + val = APCI3501_AO_DATA_BIPOLAR | APCI3501_AO_DATA_VAL(0); + + /* Set all analog output channels */ + for (chan = 0; chan < 8; chan++) { + ret = apci3501_wait_for_dac(dev); + if (ret) { + dev_warn(dev->class_dev, + "%s: DAC not-ready for channel %i\n", + __func__, chan); + } else { + outl(val | APCI3501_AO_DATA_CHAN(chan), + dev->iobase + APCI3501_AO_DATA_REG); + } + } + + return 0; +} + +static int apci3501_auto_attach(struct comedi_device *dev, + unsigned long context_unused) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + struct apci3501_private *devpriv; + struct comedi_subdevice *s; + int ao_n_chan; + int ret; + + dev->board_name = dev->driver->driver_name; + + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; + + ret = comedi_pci_enable(pcidev, dev->board_name); + if (ret) + return ret; + + dev->iobase = pci_resource_start(pcidev, 1); + devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + + ao_n_chan = apci3501_eeprom_get_ao_n_chan(dev); + + if (pcidev->irq > 0) { + ret = request_irq(pcidev->irq, apci3501_interrupt, IRQF_SHARED, + dev->board_name, dev); + if (ret == 0) + dev->irq = pcidev->irq; + } + + ret = comedi_alloc_subdevices(dev, 5); + if (ret) + return ret; + + /* Initialize the analog output subdevice */ + s = &dev->subdevices[0]; + if (ao_n_chan) { + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = ao_n_chan; + s->maxdata = 0x3fff; + s->range_table = &apci3501_ao_range; + s->insn_write = apci3501_ao_insn_write; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Initialize the digital input subdevice */ + s = &dev->subdevices[1]; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 2; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci3501_di_insn_bits; + + /* Initialize the digital output subdevice */ + s = &dev->subdevices[2]; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 2; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci3501_do_insn_bits; + + /* Initialize the timer/watchdog subdevice */ + s = &dev->subdevices[3]; + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + s->insn_write = i_APCI3501_StartStopWriteTimerCounterWatchdog; + s->insn_read = i_APCI3501_ReadTimerCounterWatchdog; + s->insn_config = i_APCI3501_ConfigTimerCounterWatchdog; + + /* Initialize the eeprom subdevice */ + s = &dev->subdevices[4]; + s->type = COMEDI_SUBD_MEMORY; + s->subdev_flags = SDF_READABLE | SDF_INTERNAL; + s->n_chan = 256; + s->maxdata = 0xffff; + s->insn_read = apci3501_eeprom_insn_read; + + apci3501_reset(dev); + return 0; +} + +static void apci3501_detach(struct comedi_device *dev) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + + if (dev->iobase) + apci3501_reset(dev); + if (dev->irq) + free_irq(dev->irq, dev); + if (pcidev) { + if (dev->iobase) + comedi_pci_disable(pcidev); + } +} static struct comedi_driver apci3501_driver = { .driver_name = "addi_apci_3501", .module = THIS_MODULE, - .auto_attach = addi_auto_attach, - .detach = i_ADDI_Detach, - .num_names = ARRAY_SIZE(apci3501_boardtypes), - .board_name = &apci3501_boardtypes[0].pc_DriverName, - .offset = sizeof(struct addi_board), + .auto_attach = apci3501_auto_attach, + .detach = apci3501_detach, }; static int apci3501_pci_probe(struct pci_dev *dev, @@ -57,19 +448,20 @@ static int apci3501_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci3501_driver); } -static void apci3501_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} +static DEFINE_PCI_DEVICE_TABLE(apci3501_pci_table) = { + { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3001) }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, apci3501_pci_table); static struct pci_driver apci3501_pci_driver = { .name = "addi_apci_3501", .id_table = apci3501_pci_table, .probe = apci3501_pci_probe, - .remove = apci3501_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci3501_driver, apci3501_pci_driver); +MODULE_DESCRIPTION("ADDI-DATA APCI-3501 Analog output board"); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 1562347..09d4b21 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -1,3 +1,5 @@ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" @@ -751,11 +753,6 @@ static int apci3xxx_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci3xxx_driver); } -static void apci3xxx_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(apci3xxx_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3010) }, { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300f) }, @@ -790,7 +787,7 @@ static struct pci_driver apci3xxx_pci_driver = { .name = "addi_apci_3xxx", .id_table = apci3xxx_pci_table, .probe = apci3xxx_pci_probe, - .remove = apci3xxx_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(apci3xxx_driver, apci3xxx_pci_driver); diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c new file mode 100644 index 0000000..375ab66 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_watchdog.c @@ -0,0 +1,172 @@ +/* + * COMEDI driver for the watchdog subdevice found on some addi-data boards + * Copyright (c) 2013 H Hartley Sweeten <hsweeten@visionengravers.com> + * + * Based on implementations in various addi-data COMEDI drivers. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998 David A. Schleef <ds@schleef.org> + * + * 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 "../comedidev.h" +#include "addi_watchdog.h" + +/* + * Register offsets/defines for the addi-data watchdog + */ +#define ADDI_WDOG_REG 0x00 +#define ADDI_WDOG_RELOAD_REG 0x04 +#define ADDI_WDOG_TIMEBASE 0x08 +#define ADDI_WDOG_CTRL_REG 0x0c +#define ADDI_WDOG_CTRL_ENABLE (1 << 0) +#define ADDI_WDOG_CTRL_SW_TRIG (1 << 9) +#define ADDI_WDOG_STATUS_REG 0x10 +#define ADDI_WDOG_STATUS_ENABLED (1 << 0) +#define ADDI_WDOG_STATUS_SW_TRIG (1 << 1) + +struct addi_watchdog_private { + unsigned long iobase; + unsigned int wdog_ctrl; +}; + +/* + * The watchdog subdevice is configured with two INSN_CONFIG instructions: + * + * Enable the watchdog and set the reload timeout: + * data[0] = INSN_CONFIG_ARM + * data[1] = timeout reload value + * + * Disable the watchdog: + * data[0] = INSN_CONFIG_DISARM + */ +static int addi_watchdog_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_watchdog_private *spriv = s->private; + unsigned int reload; + + switch (data[0]) { + case INSN_CONFIG_ARM: + spriv->wdog_ctrl = ADDI_WDOG_CTRL_ENABLE; + reload = data[1] & s->maxdata; + outl(reload, spriv->iobase + ADDI_WDOG_RELOAD_REG); + + /* Time base is 20ms, let the user know the timeout */ + dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n", + 20 * reload + 20); + break; + case INSN_CONFIG_DISARM: + spriv->wdog_ctrl = 0; + break; + default: + return -EINVAL; + } + + outl(spriv->wdog_ctrl, spriv->iobase + ADDI_WDOG_CTRL_REG); + + return insn->n; +} + +static int addi_watchdog_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_watchdog_private *spriv = s->private; + int i; + + for (i = 0; i < insn->n; i++) + data[i] = inl(spriv->iobase + ADDI_WDOG_STATUS_REG); + + return insn->n; +} + +static int addi_watchdog_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_watchdog_private *spriv = s->private; + int i; + + if (spriv->wdog_ctrl == 0) { + dev_warn(dev->class_dev, "watchdog is disabled\n"); + return -EINVAL; + } + + /* "ping" the watchdog */ + for (i = 0; i < insn->n; i++) { + outl(spriv->wdog_ctrl | ADDI_WDOG_CTRL_SW_TRIG, + spriv->iobase + ADDI_WDOG_CTRL_REG); + } + + return insn->n; +} + +void addi_watchdog_reset(unsigned long iobase) +{ + outl(0x0, iobase + ADDI_WDOG_CTRL_REG); + outl(0x0, iobase + ADDI_WDOG_RELOAD_REG); +} +EXPORT_SYMBOL_GPL(addi_watchdog_reset); + +int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase) +{ + struct addi_watchdog_private *spriv; + + spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); + if (!spriv) + return -ENOMEM; + + spriv->iobase = iobase; + + s->private = spriv; + + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 1; + s->maxdata = 0xff; + s->insn_config = addi_watchdog_insn_config; + s->insn_read = addi_watchdog_insn_read; + s->insn_write = addi_watchdog_insn_write; + + return 0; +} +EXPORT_SYMBOL_GPL(addi_watchdog_init); + +void addi_watchdog_cleanup(struct comedi_subdevice *s) +{ + kfree(s->private); +} +EXPORT_SYMBOL_GPL(addi_watchdog_cleanup); + +static int __init addi_watchdog_module_init(void) +{ + return 0; +} +module_init(addi_watchdog_module_init); + +static void __exit addi_watchdog_module_exit(void) +{ +} +module_exit(addi_watchdog_module_exit); + +MODULE_DESCRIPTION("ADDI-DATA Watchdog subdevice"); +MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_watchdog.h b/drivers/staging/comedi/drivers/addi_watchdog.h new file mode 100644 index 0000000..f374a7b --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_watchdog.h @@ -0,0 +1,10 @@ +#ifndef _ADDI_WATCHDOG_H +#define _ADDI_WATCHDOG_H + +#include "../comedidev.h" + +void addi_watchdog_reset(unsigned long iobase); +int addi_watchdog_init(struct comedi_subdevice *, unsigned long iobase); +void addi_watchdog_cleanup(struct comedi_subdevice *s); + +#endif diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 9a56eed..7b3e3316 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -42,6 +42,8 @@ References: - adl_pci9118.c */ +#include <linux/pci.h> + #include "../comedidev.h" /* @@ -270,11 +272,6 @@ static int adl_pci6208_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adl_pci6208_driver); } -static void adl_pci6208_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adl_pci6208_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI6208) }, { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI6216) }, @@ -286,7 +283,7 @@ static struct pci_driver adl_pci6208_pci_driver = { .name = "adl_pci6208", .id_table = adl_pci6208_pci_table, .probe = adl_pci6208_pci_probe, - .remove = adl_pci6208_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adl_pci6208_driver, adl_pci6208_pci_driver); diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/staging/comedi/drivers/adl_pci7x3x.c index 772edc0..f27f48e 100644 --- a/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -38,12 +38,6 @@ Author: H Hartley Sweeten <hsweeten@visionengravers.com> Updated: Thu, 02 Aug 2012 14:27:46 -0700 Status: untested -This driver only attaches using the PCI PnP auto config support -in the comedi core. The module parameter 'comedi_autoconfig' -must be 1 (default) to enable this feature. The COMEDI_DEVCONFIG -ioctl, used by the comedi_config utility, is not supported by -this driver. - The PCI-7230, PCI-7432 and PCI-7433 boards also support external interrupt signals on digital input channels 0 and 1. The PCI-7233 has dual-interrupt sources for change-of-state (COS) on any 16 @@ -51,9 +45,11 @@ digital input channels of LSB and for COS on any 16 digital input lines of MSB. Interrupts are not currently supported by this driver. -Configuration Options: not applicable +Configuration Options: not applicable, uses comedi PCI auto config */ +#include <linux/pci.h> + #include "../comedidev.h" /* @@ -302,11 +298,6 @@ static int adl_pci7x3x_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adl_pci7x3x_driver); } -static void adl_pci7x3x_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adl_pci7x3x_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) }, { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7233) }, @@ -322,7 +313,7 @@ static struct pci_driver adl_pci7x3x_pci_driver = { .name = "adl_pci7x3x", .id_table = adl_pci7x3x_pci_table, .probe = adl_pci7x3x_pci_probe, - .remove = adl_pci7x3x_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adl_pci7x3x_driver, adl_pci7x3x_pci_driver); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 4dd9d70..d06b83f 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -30,9 +30,11 @@ Updated: Mon, 14 Apr 2008 15:10:32 +0100 Configuration Options: not applicable, uses PCI auto config */ -#include "../comedidev.h" #include <linux/kernel.h> +#include <linux/pci.h> #include <linux/delay.h> + +#include "../comedidev.h" #include "comedi_fc.h" #include "8253.h" @@ -62,35 +64,35 @@ static void adl_pci8164_insn_read(struct comedi_device *dev, char *action, unsigned short offset) { int axis, axis_reg; - char *axisname; + char axisname; axis = CR_CHAN(insn->chanspec); switch (axis) { case 0: axis_reg = PCI8164_AXIS_X; - axisname = "X"; + axisname = 'X'; break; case 1: axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; + axisname = 'Y'; break; case 2: axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; + axisname = 'Z'; break; case 3: axis_reg = PCI8164_AXIS_U; - axisname = "U"; + axisname = 'U'; break; default: axis_reg = PCI8164_AXIS_X; - axisname = "X"; + axisname = 'X'; } data[0] = inw(dev->iobase + axis_reg + offset); dev_dbg(dev->class_dev, - "pci8164 %s read -> %04X:%04X on axis %s\n", + "pci8164 %s read -> %04X:%04X on axis %c\n", action, data[0], data[1], axisname); } @@ -142,36 +144,36 @@ static void adl_pci8164_insn_out(struct comedi_device *dev, { unsigned int axis, axis_reg; - char *axisname; + char axisname; axis = CR_CHAN(insn->chanspec); switch (axis) { case 0: axis_reg = PCI8164_AXIS_X; - axisname = "X"; + axisname = 'X'; break; case 1: axis_reg = PCI8164_AXIS_Y; - axisname = "Y"; + axisname = 'Y'; break; case 2: axis_reg = PCI8164_AXIS_Z; - axisname = "Z"; + axisname = 'Z'; break; case 3: axis_reg = PCI8164_AXIS_U; - axisname = "U"; + axisname = 'U'; break; default: axis_reg = PCI8164_AXIS_X; - axisname = "X"; + axisname = 'X'; } outw(data[0], dev->iobase + axis_reg + offset); dev_dbg(dev->class_dev, - "pci8164 %s write -> %04X:%04X on axis %s\n", + "pci8164 %s write -> %04X:%04X on axis %c\n", action, data[0], data[1], axisname); } @@ -298,11 +300,6 @@ static int adl_pci8164_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adl_pci8164_driver); } -static void adl_pci8164_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) }, {0} @@ -313,7 +310,7 @@ static struct pci_driver adl_pci8164_pci_driver = { .name = "adl_pci8164", .id_table = adl_pci8164_pci_table, .probe = adl_pci8164_pci_probe, - .remove = adl_pci8164_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adl_pci8164_driver, adl_pci8164_pci_driver); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index a339b9d..eeb10ec 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -68,11 +68,12 @@ TODO: */ -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include "../comedidev.h" + #include "8253.h" #include "comedi_fc.h" @@ -963,11 +964,6 @@ static int pci9111_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adl_pci9111_driver); } -static void pci9111_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) }, /* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */ @@ -979,7 +975,7 @@ static struct pci_driver adl_pci9111_pci_driver = { .name = "adl_pci9111", .id_table = pci9111_pci_table, .probe = pci9111_pci_probe, - .remove = pci9111_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adl_pci9111_driver, adl_pci9111_pci_driver); diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index b6dda80..4dbac74 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -76,13 +76,15 @@ Configuration options: * attachment if necessary, and possibly to set other options supported by * manual attachment. */ -#include "../comedidev.h" +#include <linux/pci.h> #include <linux/delay.h> #include <linux/gfp.h> #include <linux/interrupt.h> #include <linux/io.h> +#include "../comedidev.h" + #include "amcc_s5933.h" #include "8253.h" #include "comedi_fc.h" @@ -808,7 +810,7 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, *tim2 = *div1 * devpriv->i8254_osc_base; /* real convert timer */ - if (usessh & (chnsshfront == 0)) /* use BSSH signal */ + if (usessh && (chnsshfront == 0)) /* use BSSH signal */ if (*div2 < (chans + 2)) *div2 = chans + 2; @@ -2225,11 +2227,6 @@ static int adl_pci9118_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adl_pci9118_driver); } -static void adl_pci9118_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adl_pci9118_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80d9) }, { 0 } @@ -2240,7 +2237,7 @@ static struct pci_driver adl_pci9118_pci_driver = { .name = "adl_pci9118", .id_table = adl_pci9118_pci_table, .probe = adl_pci9118_pci_probe, - .remove = adl_pci9118_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adl_pci9118_driver, adl_pci9118_pci_driver); diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index a6fd8c2..3d788c7 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -41,6 +41,7 @@ Configuration options: device will be used. */ +#include <linux/pci.h> #include <linux/interrupt.h> #include "../comedidev.h" @@ -1402,11 +1403,6 @@ static int adv_pci1710_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adv_pci1710_driver); } -static void adv_pci1710_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adv_pci1710_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) }, { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) }, @@ -1421,7 +1417,7 @@ static struct pci_driver adv_pci1710_pci_driver = { .name = "adv_pci1710", .id_table = adv_pci1710_pci_table, .probe = adv_pci1710_pci_probe, - .remove = adv_pci1710_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver); diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 5af7314..02ce55a 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -48,6 +48,8 @@ TODO: 3. Implement calibration. */ +#include <linux/pci.h> + #include "../comedidev.h" /* all the registers for the pci1723 board */ @@ -327,11 +329,6 @@ static int adv_pci1723_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adv_pci1723_driver); } -static void adv_pci1723_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adv_pci1723_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1723) }, { 0 } @@ -342,7 +339,7 @@ static struct pci_driver adv_pci1723_pci_driver = { .name = "adv_pci1723", .id_table = adv_pci1723_pci_table, .probe = adv_pci1723_pci_probe, - .remove = adv_pci1723_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adv_pci1723_driver, adv_pci1723_pci_driver); diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 05a663e..338c43e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -29,10 +29,11 @@ Configuration options: */ -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> +#include "../comedidev.h" + #include "8255.h" #include "8253.h" @@ -1206,11 +1207,6 @@ static int adv_pci_dio_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &adv_pci_dio_driver); } -static void adv_pci_dio_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(adv_pci_dio_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1730) }, { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1733) }, @@ -1234,7 +1230,7 @@ static struct pci_driver adv_pci_dio_pci_driver = { .name = "adv_pci_dio", .id_table = adv_pci_dio_pci_table, .probe = adv_pci_dio_pci_probe, - .remove = adv_pci_dio_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(adv_pci_dio_driver, adv_pci_dio_pci_driver); diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 5f309ba..7c53dea 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -258,6 +258,7 @@ * order they appear in the channel list. */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/slab.h> @@ -1104,10 +1105,9 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, struct dio200_subdev_intr *subpriv; subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); - if (!subpriv) { - dev_err(dev->class_dev, "error! out of memory!\n"); + if (!subpriv) return -ENOMEM; - } + subpriv->ofs = offset; subpriv->valid_isns = valid_isns; spin_lock_init(&subpriv->spinlock); @@ -1443,10 +1443,8 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chan; subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); - if (!subpriv) { - dev_err(dev->class_dev, "error! out of memory!\n"); + if (!subpriv) return -ENOMEM; - } s->private = subpriv; s->type = COMEDI_SUBD_COUNTER; @@ -1977,8 +1975,7 @@ static int dio200_auto_attach(struct comedi_device *dev, devpriv->io.u.iobase = (unsigned long)base; devpriv->io.regtype = io_regtype; } - switch (thisboard->model) - { + switch (thisboard->model) { case pcie215_model: case pcie236_model: case pcie296_model: @@ -2079,16 +2076,11 @@ static int amplc_dio200_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &lc_dio200_driver); } -static void amplc_dio200_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver amplc_dio200_pci_driver = { .name = DIO200_DRIVER_NAME, .id_table = dio200_pci_table, .probe = &lc_dio200_pci_probe, - .remove = &lc_dio200_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(amplc_dio200_driver, amplc_dio200_pci_driver); #else diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 2898354..479e10f 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -52,6 +52,7 @@ the IRQ jumper. If no interrupt is connected, then subdevice 1 is unused. */ +#include <linux/pci.h> #include <linux/interrupt.h> #include "../comedidev.h" @@ -614,16 +615,11 @@ static int amplc_pc236_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &lc_pc236_driver); } -static void amplc_pc236_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver amplc_pc236_pci_driver = { .name = PC236_DRIVER_NAME, .id_table = pc236_pci_table, .probe = &lc_pc236_pci_probe, - .remove = &lc_pc236_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(amplc_pc236_driver, amplc_pc236_pci_driver); diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index dfbff77..11c1f47 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -44,6 +44,8 @@ connected to a reed-relay. Relay contacts are closed when output is 1. The state of the outputs can be read. */ +#include <linux/pci.h> + #include "../comedidev.h" #define PC263_DRIVER_NAME "amplc_pc263" @@ -372,16 +374,11 @@ static int amplc_pc263_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &lc_pc263_driver); } -static void amplc_pc263_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver amplc_pc263_pci_driver = { .name = PC263_DRIVER_NAME, .id_table = pc263_pci_table, .probe = &lc_pc263_pci_probe, - .remove = &lc_pc263_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(amplc_pc263_driver, amplc_pc263_pci_driver); #else diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 6e2566a..c9da4cd 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -103,6 +103,7 @@ Caveats: correctly. */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/slab.h> @@ -1512,11 +1513,6 @@ static int amplc_pci224_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &lc_pci224_driver); } -static void amplc_pci224_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(amplc_pci224_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224) }, { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234) }, @@ -1528,7 +1524,7 @@ static struct pci_driver amplc_pci224_pci_driver = { .name = "amplc_pci224", .id_table = amplc_pci224_pci_table, .probe = amplc_pci224_pci_probe, - .remove = amplc_pci224_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(amplc_pci224_driver, amplc_pci224_pci_driver); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 366c68b..e2244c6e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -188,11 +188,12 @@ Support for PCI230+/260+, more triggered scan functionality, and workarounds for (or detection of) various hardware problems added by Ian Abbott. */ -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include "../comedidev.h" + #include "comedi_fc.h" #include "8253.h" #include "8255.h" @@ -2863,11 +2864,6 @@ static int amplc_pci230_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &lc_pci230_driver); } -static void amplc_pci230_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(amplc_pci230_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230) }, { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260) }, @@ -2879,7 +2875,7 @@ static struct pci_driver amplc_pci230_pci_driver = { .name = "amplc_pci230", .id_table = amplc_pci230_pci_table, .probe = amplc_pci230_pci_probe, - .remove = amplc_pci230_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(amplc_pci230_driver, amplc_pci230_pci_driver); diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 93731de..f874fff 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -40,9 +40,10 @@ Status: experimental #include <linux/interrupt.h> #include <linux/slab.h> -#include "../comedidev.h" #include <linux/delay.h> +#include "../comedidev.h" + #include <pcmcia/cistpl.h> #include <pcmcia/ds.h> @@ -89,8 +90,6 @@ struct das16cs_private { unsigned short status2; }; -static struct pcmcia_device *cur_dev; - static const struct comedi_lrange das16cs_ai_range = { 4, { BIP_RANGE(10), @@ -383,46 +382,45 @@ static int das16cs_dio_insn_config(struct comedi_device *dev, return insn->n; } -static const struct das16cs_board *das16cs_probe(struct comedi_device *dev, - struct pcmcia_device *link) +static const void *das16cs_find_boardinfo(struct comedi_device *dev, + struct pcmcia_device *link) { + const struct das16cs_board *board; int i; for (i = 0; i < ARRAY_SIZE(das16cs_boards); i++) { - if (das16cs_boards[i].device_id == link->card_id) - return das16cs_boards + i; + board = &das16cs_boards[i]; + if (board->device_id == link->card_id) + return board; } - dev_dbg(dev->class_dev, "unknown board!\n"); - return NULL; } -static int das16cs_attach(struct comedi_device *dev, - struct comedi_devconfig *it) +static int das16cs_auto_attach(struct comedi_device *dev, + unsigned long context) { - const struct das16cs_board *thisboard; + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); + const struct das16cs_board *board; struct das16cs_private *devpriv; - struct pcmcia_device *link; struct comedi_subdevice *s; int ret; - link = cur_dev; /* XXX hack */ - if (!link) - return -EIO; - - dev->board_ptr = das16cs_probe(dev, link); - if (!dev->board_ptr) - return -EIO; - thisboard = comedi_board(dev); - - dev->board_name = thisboard->name; + board = das16cs_find_boardinfo(dev, link); + if (!board) + return -ENODEV; + dev->board_ptr = board; + dev->board_name = board->name; + link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; dev->iobase = link->resource[0]->start; - ret = request_irq(link->irq, das16cs_interrupt, - IRQF_SHARED, "cb_das16_cs", dev); - if (ret < 0) + link->priv = dev; + ret = pcmcia_request_irq(link, das16cs_interrupt); + if (ret) return ret; dev->irq = link->irq; @@ -450,10 +448,10 @@ static int das16cs_attach(struct comedi_device *dev, s = &dev->subdevices[1]; /* analog output subdevice */ - if (thisboard->n_ao_chans) { + if (board->n_ao_chans) { s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = thisboard->n_ao_chans; + s->n_chan = board->n_ao_chans; s->maxdata = 0xffff; s->range_table = &range_bipolar10; s->insn_write = &das16cs_ao_winsn; @@ -479,58 +477,16 @@ static int das16cs_attach(struct comedi_device *dev, return 0; } -static void das16cs_detach(struct comedi_device *dev) -{ - if (dev->irq) - free_irq(dev->irq, dev); -} - static struct comedi_driver driver_das16cs = { .driver_name = "cb_das16_cs", .module = THIS_MODULE, - .attach = das16cs_attach, - .detach = das16cs_detach, + .auto_attach = das16cs_auto_attach, + .detach = comedi_pcmcia_disable, }; -static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev, - void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - static int das16cs_pcmcia_attach(struct pcmcia_device *link) { - int ret; - - /* Do we need to allocate an interrupt? */ - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, das16cs_pcmcia_config_loop, NULL); - if (ret) - goto failed; - - if (!link->irq) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - cur_dev = link; - return 0; - -failed: - pcmcia_disable_device(link); - return ret; -} - -static void das16cs_pcmcia_detach(struct pcmcia_device *link) -{ - pcmcia_disable_device(link); - cur_dev = NULL; + return comedi_pcmcia_auto_config(link, &driver_das16cs); } static const struct pcmcia_device_id das16cs_id_table[] = { @@ -543,35 +499,11 @@ MODULE_DEVICE_TABLE(pcmcia, das16cs_id_table); static struct pcmcia_driver das16cs_driver = { .name = "cb_das16_cs", .owner = THIS_MODULE, - .probe = das16cs_pcmcia_attach, - .remove = das16cs_pcmcia_detach, .id_table = das16cs_id_table, + .probe = das16cs_pcmcia_attach, + .remove = comedi_pcmcia_auto_unconfig, }; - -static int __init das16cs_init(void) -{ - int ret; - - ret = comedi_driver_register(&driver_das16cs); - if (ret < 0) - return ret; - - ret = pcmcia_register_driver(&das16cs_driver); - if (ret < 0) { - comedi_driver_unregister(&driver_das16cs); - return ret; - } - - return 0; -} -module_init(das16cs_init); - -static void __exit das16cs_exit(void) -{ - pcmcia_unregister_driver(&das16cs_driver); - comedi_driver_unregister(&driver_das16cs); -} -module_exit(das16cs_exit); +module_comedi_pcmcia_driver(driver_das16cs, das16cs_driver); MODULE_AUTHOR("David A. Schleef <ds@schleef.org>"); MODULE_DESCRIPTION("Comedi driver for Computer Boards PC-CARD DAS16/16"); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index aed6863..79c7211 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -67,10 +67,12 @@ TODO: analog triggering on 1602 series */ -#include "../comedidev.h" +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include "../comedidev.h" + #include "8253.h" #include "8255.h" #include "amcc_s5933.h" @@ -1632,11 +1634,6 @@ static int cb_pcidas_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &cb_pcidas_driver); } -static void cb_pcidas_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) }, { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) }, @@ -1654,7 +1651,7 @@ static struct pci_driver cb_pcidas_pci_driver = { .name = "cb_pcidas", .id_table = cb_pcidas_pci_table, .probe = cb_pcidas_pci_probe, - .remove = cb_pcidas_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(cb_pcidas_driver, cb_pcidas_pci_driver); diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index d72b46c..9f3112c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -87,10 +87,12 @@ TODO: #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include "../comedidev.h" +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include "../comedidev.h" + #include "8253.h" #include "8255.h" #include "plx9080.h" @@ -3299,7 +3301,6 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) num_bytes = load_ao_dma_buffer(dev, cmd); if (num_bytes == 0) return -1; - if (num_bytes >= DMA_BUFFER_SIZE) ; load_ao_dma(dev, cmd); dma_start_sync(dev, 0); @@ -4220,11 +4221,6 @@ static int cb_pcidas64_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &cb_pcidas64_driver); } -static void cb_pcidas64_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(cb_pcidas64_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001d) }, { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001e) }, @@ -4253,7 +4249,7 @@ static struct pci_driver cb_pcidas64_pci_driver = { .name = "cb_pcidas64", .id_table = cb_pcidas64_pci_table, .probe = cb_pcidas64_pci_probe, - .remove = cb_pcidas64_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(cb_pcidas64_driver, cb_pcidas64_pci_driver); diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 7c6029a..e2cadc7 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -41,6 +41,8 @@ * Only simple analog output writing is supported. */ +#include <linux/pci.h> + #include "../comedidev.h" #include "comedi_fc.h" @@ -438,11 +440,6 @@ static int cb_pcidda_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &cb_pcidda_driver); } -static void cb_pcidda_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA02_12) }, { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA04_12) }, @@ -458,7 +455,7 @@ static struct pci_driver cb_pcidda_pci_driver = { .name = "cb_pcidda", .id_table = cb_pcidda_pci_table, .probe = cb_pcidda_pci_probe, - .remove = cb_pcidda_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(cb_pcidda_driver, cb_pcidda_pci_driver); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index b43a5f8..aae063c 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -40,11 +40,12 @@ No interrupts, multi channel or FIFO AI, although the card looks like it could s See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. */ -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include "../comedidev.h" + #include "plx9052.h" #include "8255.h" @@ -299,11 +300,6 @@ static int cb_pcimdas_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &cb_pcimdas_driver); } -static void cb_pcimdas_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) }, { 0 } @@ -314,7 +310,7 @@ static struct pci_driver cb_pcimdas_pci_driver = { .name = "cb_pcimdas", .id_table = cb_pcimdas_pci_table, .probe = cb_pcimdas_pci_probe, - .remove = cb_pcimdas_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver); diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 699b84f..63cfbaf 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -79,6 +79,8 @@ Configuration Options: not applicable, uses PCI auto config -Calin Culianu <calin@ajvar.org> */ +#include <linux/pci.h> + #include "../comedidev.h" #include "8255.h" @@ -222,11 +224,6 @@ static int cb_pcimdda_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &cb_pcimdda_driver); } -static void cb_pcimdda_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(cb_pcimdda_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_ID_PCIM_DDA06_16) }, { 0 } @@ -237,7 +234,7 @@ static struct pci_driver cb_pcimdda_driver_pci_driver = { .name = "cb_pcimdda", .id_table = cb_pcimdda_pci_table, .probe = cb_pcimdda_pci_probe, - .remove = cb_pcimdda_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(cb_pcimdda_driver, cb_pcimdda_driver_pci_driver); diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 3151599..1bb5381 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -245,10 +245,9 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) return 0; } bdev = kmalloc(sizeof(*bdev), GFP_KERNEL); - if (!bdev) { - dev_err(dev->class_dev, "Out of memory\n"); + if (!bdev) return 0; - } + bdev->dev = d; bdev->minor = minor; bdev->subdev = sdev; diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 01de996..270fea5 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -62,15 +62,14 @@ zero volts). /* Data unique to this driver */ struct waveform_private { struct timer_list timer; - struct timeval last; /* time at which last timer interrupt occurred */ + struct timeval last; /* time last timer interrupt occurred */ unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */ unsigned long usec_period; /* waveform period in microseconds */ - unsigned long usec_current; /* current time (modulo waveform period) */ - unsigned long usec_remainder; /* usec since last scan; */ - unsigned long ai_count; /* number of conversions remaining */ + unsigned long usec_current; /* current time (mod waveform period) */ + unsigned long usec_remainder; /* usec since last scan */ + unsigned long ai_count; /* number of conversions remaining */ unsigned int scan_period; /* scan period in usec */ unsigned int convert_period; /* conversion period in usec */ - unsigned timer_running:1; unsigned int ao_loopbacks[N_CHANS]; }; @@ -86,8 +85,9 @@ static const struct comedi_lrange waveform_ai_ranges = { } }; -static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index, - unsigned long current_time) +static unsigned short fake_sawtooth(struct comedi_device *dev, + unsigned int range_index, + unsigned long current_time) { struct waveform_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; @@ -110,9 +110,9 @@ static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index, return offset + value; } -static short fake_squarewave(struct comedi_device *dev, - unsigned int range_index, - unsigned long current_time) +static unsigned short fake_squarewave(struct comedi_device *dev, + unsigned int range_index, + unsigned long current_time) { struct waveform_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; @@ -132,15 +132,17 @@ static short fake_squarewave(struct comedi_device *dev, return offset + value; } -static short fake_flatline(struct comedi_device *dev, unsigned int range_index, - unsigned long current_time) +static unsigned short fake_flatline(struct comedi_device *dev, + unsigned int range_index, + unsigned long current_time) { return dev->read_subdev->maxdata / 2; } /* generates a different waveform depending on what channel is read */ -static short fake_waveform(struct comedi_device *dev, unsigned int channel, - unsigned int range, unsigned long current_time) +static unsigned short fake_waveform(struct comedi_device *dev, + unsigned int channel, unsigned int range, + unsigned long current_time) { enum { SAWTOOTH_CHAN, @@ -176,6 +178,7 @@ static void waveform_ai_interrupt(unsigned long arg) unsigned long elapsed_time; unsigned int num_scans; struct timeval now; + bool stopping = false; do_gettimeofday(&now); @@ -189,37 +192,35 @@ static void waveform_ai_interrupt(unsigned long arg) (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period; async->events = 0; + if (cmd->stop_src == TRIG_COUNT) { + unsigned int remaining = cmd->stop_arg - devpriv->ai_count; + if (num_scans >= remaining) { + /* about to finish */ + num_scans = remaining; + stopping = true; + } + } + for (i = 0; i < num_scans; i++) { for (j = 0; j < cmd->chanlist_len; j++) { - cfc_write_to_buffer(dev->read_subdev, - fake_waveform(dev, - CR_CHAN(cmd-> - chanlist[j]), - CR_RANGE(cmd-> - chanlist[j]), - devpriv-> - usec_current + - i * - devpriv->scan_period + - j * - devpriv-> - convert_period)); - } - devpriv->ai_count++; - if (cmd->stop_src == TRIG_COUNT - && devpriv->ai_count >= cmd->stop_arg) { - async->events |= COMEDI_CB_EOA; - break; + unsigned short sample; + sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]), + CR_RANGE(cmd->chanlist[j]), + devpriv->usec_current + + i * devpriv->scan_period + + j * devpriv->convert_period); + cfc_write_to_buffer(dev->read_subdev, sample); } } + devpriv->ai_count += i; devpriv->usec_current += elapsed_time; devpriv->usec_current %= devpriv->usec_period; - if ((async->events & COMEDI_CB_EOA) == 0 && devpriv->timer_running) - mod_timer(&devpriv->timer, jiffies + 1); + if (stopping) + async->events |= COMEDI_CB_EOA; else - del_timer(&devpriv->timer); + mod_timer(&devpriv->timer, jiffies + 1); comedi_event(dev, dev->read_subdev); } @@ -317,7 +318,6 @@ static int waveform_ai_cmd(struct comedi_device *dev, return -1; } - devpriv->timer_running = 1; devpriv->ai_count = 0; devpriv->scan_period = cmd->scan_begin_arg / nano_per_micro; @@ -344,7 +344,6 @@ static int waveform_ai_cancel(struct comedi_device *dev, { struct waveform_private *devpriv = dev->private; - devpriv->timer_running = 0; del_timer_sync(&devpriv->timer); return 0; } diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 1a18fa3..182dea6 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -30,6 +30,8 @@ Status: works Configuration Options: not applicable, uses comedi PCI auto config */ +#include <linux/pci.h> + #include "../comedidev.h" #define PCI_DEVICE_ID_PIO1616L 0x8172 @@ -130,11 +132,6 @@ static int contec_pci_dio_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &contec_pci_dio_driver); } -static void contec_pci_dio_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(contec_pci_dio_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L) }, { 0 } @@ -145,7 +142,7 @@ static struct pci_driver contec_pci_dio_pci_driver = { .name = "contec_pci_dio", .id_table = contec_pci_dio_pci_table, .probe = contec_pci_dio_pci_probe, - .remove = contec_pci_dio_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(contec_pci_dio_driver, contec_pci_dio_pci_driver); diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 992e557..50b450f 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -107,12 +107,13 @@ Configuration options: not applicable, uses PCI auto config */ -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/firmware.h> +#include "../comedidev.h" + #include "8255.h" #define DAQBOARD2000_FIRMWARE "daqboard2000_firmware.bin" @@ -485,7 +486,7 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev) writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c); udelay(10000); writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c); - udelay(10000); /* Not in the original code, but I like symmetry... */ + udelay(10000); /* Not in the original code, but I like symmetry... */ } static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) @@ -799,11 +800,6 @@ static int daqboard2000_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &daqboard2000_driver); } -static void daqboard2000_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_IOTECH, 0x0409) }, { 0 } @@ -814,7 +810,7 @@ static struct pci_driver daqboard2000_pci_driver = { .name = "daqboard2000", .id_table = daqboard2000_pci_table, .probe = daqboard2000_pci_probe, - .remove = daqboard2000_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(daqboard2000_driver, daqboard2000_pci_driver); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b15e058..9823aa0 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1,6 +1,6 @@ /* * comedi/drivers/das08.c - * DAS08 driver + * comedi driver for common DAS08 support (used by ISA/PCI/PCMCIA drivers) * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef <ds@schleef.org> @@ -27,57 +27,26 @@ /* * Driver: das08 * Description: DAS-08 compatible boards + * Devices: various, see das08_isa, das08_cs, and das08_pci drivers * Author: Warren Jasper, ds, Frank Hess - * Devices: [Keithley Metrabyte] DAS08 (isa-das08), - * [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm), - * DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh), - * DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao), - * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (pci-das08), - * PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16) * Updated: Fri, 31 Aug 2012 19:19:06 +0100 * Status: works * - * This is a rewrite of the das08 and das08jr drivers. + * This driver is used by the das08_isa, das08_cs, and das08_pci + * drivers to provide the common support for the DAS-08 hardware. * - * Options (for ISA cards): - * [0] - base io address - * - * Manual configuration of PCI cards is not supported; they are - * configured automatically. - * - * The das08 driver doesn't support asynchronous commands, since - * the cheap das08 hardware doesn't really support them. The - * comedi_rt_timer driver can be used to emulate commands for this - * driver. + * The driver doesn't support asynchronous commands, since the + * cheap das08 hardware doesn't really support them. */ -#include "../comedidev.h" - #include <linux/delay.h> +#include "../comedidev.h" + #include "8255.h" #include "8253.h" #include "das08.h" -#define DRV_NAME "das08" - -#define DO_ISA IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) -#define DO_PCI IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) -#define DO_COMEDI_DRIVER_REGISTER (DO_ISA || DO_PCI) - -#define PCI_DEVICE_ID_PCIDAS08 0x29 -#define PCIDAS08_SIZE 0x54 - -/* pci configuration registers */ -#define INTCSR 0x4c -#define INTR1_ENABLE 0x1 -#define INTR1_HIGH_POLARITY 0x2 -#define PCI_INTR_ENABLE 0x40 -#define INTR1_EDGE_TRIG 0x100 /* requires high polarity */ -#define CNTRL 0x50 -#define CNTRL_DIR 0x2 -#define CNTRL_INTR 0x4 - /* cio-das08.pdf @@ -235,16 +204,6 @@ static const int *const das08_gainlists[] = { das08_pgm_gainlist, }; -static inline bool is_isa_board(const struct das08_board_struct *board) -{ - return DO_ISA && board->bustype == isa; -} - -static inline bool is_pci_board(const struct das08_board_struct *board) -{ - return DO_PCI && board->bustype == pci; -} - #define TIMEOUT 100000 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, @@ -501,159 +460,6 @@ static int das08_counter_config(struct comedi_device *dev, return 2; } -#if DO_COMEDI_DRIVER_REGISTER -static const struct das08_board_struct das08_boards[] = { -#if DO_ISA - { - .name = "isa-das08", /* cio-das08.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pg_none, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8255_offset = 8, - .i8254_offset = 4, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-pgm", /* cio-das08pgx.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgm, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8255_offset = 0, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-pgh", /* cio-das08pgx.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgh, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-pgl", /* cio-das08pgx.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgl, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-aoh", /* cio-das08_aox.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgh, - .ai_encoding = das08_encode12, - .ao_nbits = 12, - .di_nchan = 3, - .do_nchan = 4, - .i8255_offset = 0x0c, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-aol", /* cio-das08_aox.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgl, - .ai_encoding = das08_encode12, - .ao_nbits = 12, - .di_nchan = 3, - .do_nchan = 4, - .i8255_offset = 0x0c, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08-aom", /* cio-das08_aox.pdf */ - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pgm, - .ai_encoding = das08_encode12, - .ao_nbits = 12, - .di_nchan = 3, - .do_nchan = 4, - .i8255_offset = 0x0c, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */ - .bustype = isa, - .is_jr = true, - .ai_nbits = 12, - .ai_pg = das08_pg_none, - .ai_encoding = das08_encode12, - .ao_nbits = 12, - .di_nchan = 8, - .do_nchan = 8, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */ - .bustype = isa, - .is_jr = true, - .ai_nbits = 16, - .ai_pg = das08_pg_none, - .ai_encoding = das08_encode16, - .ao_nbits = 16, - .di_nchan = 8, - .do_nchan = 8, - .i8254_offset = 0x04, - .iosize = 16, /* unchecked */ - }, - { - .name = "pc104-das08", - .bustype = isa, - .ai_nbits = 12, - .ai_pg = das08_pg_none, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8254_offset = 4, - .iosize = 16, /* unchecked */ - }, - { - .name = "das08jr/16", - .bustype = isa, - .is_jr = true, - .ai_nbits = 16, - .ai_pg = das08_pg_none, - .ai_encoding = das08_encode16, - .di_nchan = 8, - .do_nchan = 8, - .iosize = 16, /* unchecked */ - }, -#endif /* DO_ISA */ -#if DO_PCI - { - .name = "pci-das08", /* pci-das08 */ - .id = PCI_DEVICE_ID_PCIDAS08, - .bustype = pci, - .ai_nbits = 12, - .ai_pg = das08_bipolar5, - .ai_encoding = das08_encode12, - .di_nchan = 3, - .do_nchan = 4, - .i8254_offset = 4, - .iosize = 8, - }, -#endif /* DO_PCI */ -}; -#endif /* DO_COMEDI_DRIVER_REGISTER */ - int das08_common_attach(struct comedi_device *dev, unsigned long iobase) { const struct das08_board_struct *thisboard = comedi_board(dev); @@ -760,84 +566,6 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) } EXPORT_SYMBOL_GPL(das08_common_attach); -static const struct das08_board_struct * -das08_find_pci_board(struct pci_dev *pdev) -{ -#if DO_COMEDI_DRIVER_REGISTER - unsigned int i; - for (i = 0; i < ARRAY_SIZE(das08_boards); i++) - if (is_pci_board(&das08_boards[i]) && - pdev->device == das08_boards[i].id) - return &das08_boards[i]; -#endif - return NULL; -} - -/* only called in the PCI probe path, via comedi_pci_auto_config() */ -static int __maybe_unused -das08_auto_attach(struct comedi_device *dev, unsigned long context_unused) -{ - struct pci_dev *pdev; - struct das08_private_struct *devpriv; - unsigned long iobase; - - if (!DO_PCI) - return -EINVAL; - - pdev = comedi_to_pci_dev(dev); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); - if (!devpriv) - return -ENOMEM; - dev->private = devpriv; - - dev_info(dev->class_dev, "attach pci %s\n", pci_name(pdev)); - dev->board_ptr = das08_find_pci_board(pdev); - if (dev->board_ptr == NULL) { - dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); - return -EINVAL; - } - - /* enable PCI device and reserve I/O spaces */ - if (comedi_pci_enable(pdev, dev->driver->driver_name)) { - dev_err(dev->class_dev, - "Error enabling PCI device and requesting regions\n"); - return -EIO; - } - /* read base addresses */ - iobase = pci_resource_start(pdev, 2); - return das08_common_attach(dev, iobase); -} - -static int __maybe_unused -das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) -{ - const struct das08_board_struct *thisboard = comedi_board(dev); - struct das08_private_struct *devpriv; - unsigned long iobase; - - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); - if (!devpriv) - return -ENOMEM; - dev->private = devpriv; - - dev_info(dev->class_dev, "attach\n"); - if (is_pci_board(thisboard)) { - dev_err(dev->class_dev, - "Manual configuration of PCI board '%s' is not supported\n", - thisboard->name); - return -EIO; - } else if (is_isa_board(thisboard)) { - iobase = it->options[0]; - dev_info(dev->class_dev, "iobase 0x%lx\n", iobase); - if (!request_region(iobase, thisboard->iosize, DRV_NAME)) { - dev_err(dev->class_dev, "I/O port conflict\n"); - return -EIO; - } - return das08_common_attach(dev, iobase); - } else - return -EIO; -} - void das08_common_detach(struct comedi_device *dev) { if (dev->subdevices) @@ -845,84 +573,16 @@ void das08_common_detach(struct comedi_device *dev) } EXPORT_SYMBOL_GPL(das08_common_detach); -static void __maybe_unused das08_detach(struct comedi_device *dev) -{ - const struct das08_board_struct *thisboard = comedi_board(dev); - - if (!thisboard) - return; - das08_common_detach(dev); - if (is_isa_board(thisboard)) { - if (dev->iobase) - release_region(dev->iobase, thisboard->iosize); - } else if (is_pci_board(thisboard)) { - struct pci_dev *pdev = comedi_to_pci_dev(dev); - if (pdev) { - if (dev->iobase) - comedi_pci_disable(pdev); - } - } -} - -#if DO_COMEDI_DRIVER_REGISTER -static struct comedi_driver das08_driver = { - .driver_name = DRV_NAME, - .module = THIS_MODULE, - .attach = das08_attach, - .auto_attach = das08_auto_attach, - .detach = das08_detach, - .board_name = &das08_boards[0].name, - .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct), - .offset = sizeof(struct das08_board_struct), -}; -#endif - -#if DO_PCI -static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) }, - {0} -}; - -MODULE_DEVICE_TABLE(pci, das08_pci_table); - -static int das08_pci_probe(struct pci_dev *dev, - const struct pci_device_id *ent) -{ - return comedi_pci_auto_config(dev, &das08_driver); -} - -static void das08_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - -static struct pci_driver das08_pci_driver = { - .id_table = das08_pci_table, - .name = DRV_NAME, - .probe = &das08_pci_probe, - .remove = &das08_pci_remove -}; -#endif /* DO_PCI */ - -#if DO_COMEDI_DRIVER_REGISTER -#if DO_PCI -module_comedi_pci_driver(das08_driver, das08_pci_driver); -#else -module_comedi_driver(das08_driver); -#endif -#else /* DO_COMEDI_DRIVER_REGISTER */ static int __init das08_init(void) { return 0; } +module_init(das08_init); static void __exit das08_exit(void) { } - -module_init(das08_init); module_exit(das08_exit); -#endif /* DO_COMEDI_DRIVER_REGISTER */ MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 0314bae..b102ad4 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -24,7 +24,6 @@ #ifndef _DAS08_H #define _DAS08_H -enum das08_bustype { isa, pci, pcmcia }; /* different ways ai data is encoded in first two registers */ enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 }; enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, @@ -34,7 +33,6 @@ enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl, struct das08_board_struct { const char *name; unsigned int id; /* id for pci/pcmcia boards */ - enum das08_bustype bustype; bool is_jr; /* true for 'JR' boards */ unsigned int ai_nbits; enum das08_lrange ai_pg; diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 0242623..cfeebe4 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -46,125 +46,70 @@ Options (for pcm-das08): Command support does not exist, but could be added for this board. */ -#include "../comedidev.h" - #include <linux/delay.h> -#include <linux/pci.h> #include <linux/slab.h> -#include "das08.h" +#include "../comedidev.h" -/* pcmcia includes */ #include <pcmcia/cistpl.h> #include <pcmcia/ds.h> +#include "das08.h" + static const struct das08_board_struct das08_cs_boards[] = { { - .name = "pcm-das08", - .id = 0x0, /* XXX */ - .bustype = pcmcia, - .ai_nbits = 12, - .ai_pg = das08_bipolar5, - .ai_encoding = das08_pcm_encode12, - .di_nchan = 3, - .do_nchan = 3, - .iosize = 16, - }, - /* duplicate so driver name can be used also */ - { - .name = "das08_cs", - .id = 0x0, /* XXX */ - .bustype = pcmcia, - .ai_nbits = 12, - .ai_pg = das08_bipolar5, - .ai_encoding = das08_pcm_encode12, - .di_nchan = 3, - .do_nchan = 3, - .iosize = 16, + .name = "pcm-das08", + .id = 0x0, /* XXX */ + .ai_nbits = 12, + .ai_pg = das08_bipolar5, + .ai_encoding = das08_pcm_encode12, + .di_nchan = 3, + .do_nchan = 3, + .iosize = 16, }, }; -static struct pcmcia_device *cur_dev; - -static int das08_cs_attach(struct comedi_device *dev, - struct comedi_devconfig *it) +static int das08_cs_auto_attach(struct comedi_device *dev, + unsigned long context) { - const struct das08_board_struct *thisboard = comedi_board(dev); + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); struct das08_private_struct *devpriv; unsigned long iobase; - struct pcmcia_device *link = cur_dev; /* XXX hack */ + int ret; + + /* The das08 driver needs the board_ptr */ + dev->board_ptr = &das08_cs_boards[0]; + + link->config_flags |= CONF_AUTO_SET_IO; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; + iobase = link->resource[0]->start; devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; dev->private = devpriv; - dev_info(dev->class_dev, "das08_cs: attach\n"); - /* deal with a pci board */ - - if (thisboard->bustype == pcmcia) { - if (link == NULL) { - dev_err(dev->class_dev, "no pcmcia cards found\n"); - return -EIO; - } - iobase = link->resource[0]->start; - } else { - dev_err(dev->class_dev, - "bug! board does not have PCMCIA bustype\n"); - return -EINVAL; - } - return das08_common_attach(dev, iobase); } +static void das08_cs_detach(struct comedi_device *dev) +{ + das08_common_detach(dev); + comedi_pcmcia_disable(dev); +} + static struct comedi_driver driver_das08_cs = { .driver_name = "das08_cs", .module = THIS_MODULE, - .attach = das08_cs_attach, - .detach = das08_common_detach, - .board_name = &das08_cs_boards[0].name, - .num_names = ARRAY_SIZE(das08_cs_boards), - .offset = sizeof(struct das08_board_struct), + .auto_attach = das08_cs_auto_attach, + .detach = das08_cs_detach, }; -static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev, - void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - static int das08_pcmcia_attach(struct pcmcia_device *link) { - int ret; - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, das08_pcmcia_config_loop, NULL); - if (ret) - goto failed; - - if (!link->irq) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - cur_dev = link; - return 0; - -failed: - pcmcia_disable_device(link); - return ret; -} - -static void das08_pcmcia_detach(struct pcmcia_device *link) -{ - pcmcia_disable_device(link); - cur_dev = NULL; + return comedi_pcmcia_auto_config(link, &driver_das08_cs); } static const struct pcmcia_device_id das08_cs_id_table[] = { @@ -176,36 +121,11 @@ MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table); static struct pcmcia_driver das08_cs_driver = { .name = "pcm-das08", .owner = THIS_MODULE, - .probe = das08_pcmcia_attach, - .remove = das08_pcmcia_detach, .id_table = das08_cs_id_table, + .probe = das08_pcmcia_attach, + .remove = comedi_pcmcia_auto_unconfig, }; - -static int __init das08_cs_init_module(void) -{ - int ret; - - ret = comedi_driver_register(&driver_das08_cs); - if (ret < 0) - return ret; - - ret = pcmcia_register_driver(&das08_cs_driver); - if (ret < 0) { - comedi_driver_unregister(&driver_das08_cs); - return ret; - } - - return 0; - -} -module_init(das08_cs_init_module); - -static void __exit das08_cs_exit_module(void) -{ - pcmcia_unregister_driver(&das08_cs_driver); - comedi_driver_unregister(&driver_das08_cs); -} -module_exit(das08_cs_exit_module); +module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver); MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, " "Frank Mori Hess <fmhess@users.sourceforge.net>"); diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/staging/comedi/drivers/das08_isa.c new file mode 100644 index 0000000..f120782 --- /dev/null +++ b/drivers/staging/comedi/drivers/das08_isa.c @@ -0,0 +1,217 @@ +/* + * das08_isa.c + * comedi driver for DAS08 ISA/PC-104 boards + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef <ds@schleef.org> + * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> + * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> + * + * 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. + */ + +/* + * Driver: das08_isa + * Description: DAS-08 ISA/PC-104 compatible boards + * Devices: (Keithley Metrabyte) DAS08 [isa-das08], + * (ComputerBoards) DAS08 [isa-das08] + * (ComputerBoards) DAS08-PGM [das08-pgm] + * (ComputerBoards) DAS08-PGH [das08-pgh] + * (ComputerBoards) DAS08-PGL [das08-pgl] + * (ComputerBoards) DAS08-AOH [das08-aoh] + * (ComputerBoards) DAS08-AOL [das08-aol] + * (ComputerBoards) DAS08-AOM [das08-aom] + * (ComputerBoards) DAS08/JR-AO [das08/jr-ao] + * (ComputerBoards) DAS08/JR-16-AO [das08jr-16-ao] + * (ComputerBoards) PC104-DAS08 [pc104-das08] + * (ComputerBoards) DAS08/JR/16 [das08jr/16] + * Author: Warren Jasper, ds, Frank Hess + * Updated: Fri, 31 Aug 2012 19:19:06 +0100 + * Status: works + * + * This is the ISA/PC-104-specific support split off from the das08 driver. + * + * Configuration Options: + * [0] - base io address + */ + +#include "../comedidev.h" + +#include "das08.h" + +static const struct das08_board_struct das08_isa_boards[] = { + { + /* cio-das08.pdf */ + .name = "isa-das08", + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8255_offset = 8, + .i8254_offset = 4, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08pgx.pdf */ + .name = "das08-pgm", + .ai_nbits = 12, + .ai_pg = das08_pgm, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8255_offset = 0, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08pgx.pdf */ + .name = "das08-pgh", + .ai_nbits = 12, + .ai_pg = das08_pgh, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08pgx.pdf */ + .name = "das08-pgl", + .ai_nbits = 12, + .ai_pg = das08_pgl, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08_aox.pdf */ + .name = "das08-aoh", + .ai_nbits = 12, + .ai_pg = das08_pgh, + .ai_encoding = das08_encode12, + .ao_nbits = 12, + .di_nchan = 3, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08_aox.pdf */ + .name = "das08-aol", + .ai_nbits = 12, + .ai_pg = das08_pgl, + .ai_encoding = das08_encode12, + .ao_nbits = 12, + .di_nchan = 3, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08_aox.pdf */ + .name = "das08-aom", + .ai_nbits = 12, + .ai_pg = das08_pgm, + .ai_encoding = das08_encode12, + .ao_nbits = 12, + .di_nchan = 3, + .do_nchan = 4, + .i8255_offset = 0x0c, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08-jr-ao.pdf */ + .name = "das08/jr-ao", + .is_jr = true, + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .ao_nbits = 12, + .di_nchan = 8, + .do_nchan = 8, + .iosize = 16, /* unchecked */ + }, { + /* cio-das08jr-16-ao.pdf */ + .name = "das08jr-16-ao", + .is_jr = true, + .ai_nbits = 16, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode16, + .ao_nbits = 16, + .di_nchan = 8, + .do_nchan = 8, + .i8254_offset = 0x04, + .iosize = 16, /* unchecked */ + }, { + .name = "pc104-das08", + .ai_nbits = 12, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8254_offset = 4, + .iosize = 16, /* unchecked */ + }, { + .name = "das08jr/16", + .is_jr = true, + .ai_nbits = 16, + .ai_pg = das08_pg_none, + .ai_encoding = das08_encode16, + .di_nchan = 8, + .do_nchan = 8, + .iosize = 16, /* unchecked */ + }, +}; + +static int das08_isa_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + const struct das08_board_struct *thisboard = comedi_board(dev); + struct das08_private_struct *devpriv; + + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; + + if (!request_region(it->options[0], thisboard->iosize, + thisboard->name)) + return -EIO; + + return das08_common_attach(dev, it->options[0]); +} + +static void das08_isa_detach(struct comedi_device *dev) +{ + const struct das08_board_struct *thisboard = comedi_board(dev); + + das08_common_detach(dev); + if (dev->iobase) + release_region(dev->iobase, thisboard->iosize); +} + +static struct comedi_driver das08_isa_driver = { + .driver_name = "isa-das08", + .module = THIS_MODULE, + .attach = das08_isa_attach, + .detach = das08_isa_detach, + .board_name = &das08_isa_boards[0].name, + .num_names = ARRAY_SIZE(das08_isa_boards), + .offset = sizeof(das08_isa_boards[0]), +}; +module_comedi_driver(das08_isa_driver); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c new file mode 100644 index 0000000..c405876 --- /dev/null +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -0,0 +1,121 @@ +/* + * das08_pci.c + * comedi driver for DAS08 PCI boards + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef <ds@schleef.org> + * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> + * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> + * + * 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. + */ + +/* + * Driver: das08_pci + * Description: DAS-08 PCI compatible boards + * Devices: (ComputerBoards) PCI-DAS08 [pci-das08] + * Author: Warren Jasper, ds, Frank Hess + * Updated: Fri, 31 Aug 2012 19:19:06 +0100 + * Status: works + * + * This is the PCI-specific support split off from the das08 driver. + * + * Configuration Options: not applicable, uses PCI auto config + */ + +#include <linux/pci.h> + +#include "../comedidev.h" + +#include "das08.h" + +#define PCI_DEVICE_ID_PCIDAS08 0x0029 + +static const struct das08_board_struct das08_pci_boards[] = { + { + .name = "pci-das08", + .id = PCI_DEVICE_ID_PCIDAS08, + .ai_nbits = 12, + .ai_pg = das08_bipolar5, + .ai_encoding = das08_encode12, + .di_nchan = 3, + .do_nchan = 4, + .i8254_offset = 4, + .iosize = 8, + }, +}; + +static int das08_pci_auto_attach(struct comedi_device *dev, + unsigned long context_unused) +{ + struct pci_dev *pdev = comedi_to_pci_dev(dev); + struct das08_private_struct *devpriv; + int ret; + + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; + + /* The das08 driver needs the board_ptr */ + dev->board_ptr = &das08_pci_boards[0]; + + ret = comedi_pci_enable(pdev, dev->driver->driver_name); + if (ret) + return ret; + dev->iobase = pci_resource_start(pdev, 2); + + return das08_common_attach(dev, dev->iobase); +} + +static void das08_pci_detach(struct comedi_device *dev) +{ + struct pci_dev *pdev = comedi_to_pci_dev(dev); + + das08_common_detach(dev); + if (dev->iobase) + comedi_pci_disable(pdev); +} + +static struct comedi_driver das08_pci_comedi_driver = { + .driver_name = "pci-das08", + .module = THIS_MODULE, + .auto_attach = das08_pci_auto_attach, + .detach = das08_pci_detach, +}; + +static int das08_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, &das08_pci_comedi_driver); +} + +static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = { + { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, das08_pci_table); + +static struct pci_driver das08_pci_driver = { + .name = "pci-das08", + .id_table = das08_pci_table, + .probe = das08_pci_probe, + .remove = comedi_pci_auto_unconfig, +}; +module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index b159f44..f238a1f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -82,7 +82,9 @@ www.measurementcomputing.com #include <linux/pci.h> #include <linux/slab.h> #include <linux/interrupt.h> + #include <asm/dma.h> + #include "../comedidev.h" #include "8253.h" diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 960da8d..3ce499f 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -55,9 +55,11 @@ AO commands are not supported. #define DEBUG 1 +#include <linux/pci.h> +#include <linux/delay.h> #include <linux/interrupt.h> + #include "../comedidev.h" -#include <linux/delay.h> #include "comedi_fc.h" @@ -856,11 +858,6 @@ static int dt3000_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &dt3000_driver); } -static void dt3000_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(dt3000_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_DT, PCI_DEVICE_ID_DT3001) }, { PCI_DEVICE(PCI_VENDOR_ID_DT, PCI_DEVICE_ID_DT3001_PGL) }, @@ -877,7 +874,7 @@ static struct pci_driver dt3000_pci_driver = { .name = "dt3000", .id_table = dt3000_pci_table, .probe = dt3000_pci_probe, - .remove = dt3000_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(dt3000_driver, dt3000_pci_driver); diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 1767998..192cf08 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -702,10 +702,9 @@ static int dt9812_probe(struct usb_interface *interface, /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&interface->dev, "Out of memory\n"); + if (dev == NULL) goto error; - } + kref_init(&dev->kref); dev->udev = usb_get_dev(interface_to_usbdev(interface)); @@ -1133,7 +1132,7 @@ static struct comedi_driver dt9812_comedi_driver = { static int __init usb_dt9812_init(void) { - int result, i; + int i; /* Initialize all driver slots */ for (i = 0; i < DT9812_NUM_SLOTS; i++) { @@ -1144,30 +1143,13 @@ static int __init usb_dt9812_init(void) } dt9812[12].serial = 0x0; - /* register with the USB subsystem */ - result = usb_register(&dt9812_usb_driver); - if (result) { - pr_err("usb_register failed. Error number %d\n", result); - return result; - } - /* register with comedi */ - result = comedi_driver_register(&dt9812_comedi_driver); - if (result) { - usb_deregister(&dt9812_usb_driver); - pr_err("comedi_driver_register failed. Error number %d\n", - result); - } - - return result; + return comedi_usb_driver_register(&dt9812_comedi_driver, + &dt9812_usb_driver); } static void __exit usb_dt9812_exit(void) { - /* unregister with comedi */ - comedi_driver_unregister(&dt9812_comedi_driver); - - /* deregister this driver with the USB subsystem */ - usb_deregister(&dt9812_usb_driver); + comedi_usb_driver_unregister(&dt9812_comedi_driver, &dt9812_usb_driver); } module_init(usb_dt9812_init); diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 8497a36..decc17f 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -37,9 +37,11 @@ their cards in their manuals. */ -#include "../comedidev.h" +#include <linux/pci.h> #include <linux/mutex.h> +#include "../comedidev.h" + #define READ_TIMEOUT 50 static const struct comedi_lrange range_pci1050_ai = { 3, { @@ -276,11 +278,6 @@ static int dyna_pci10xx_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &dyna_pci10xx_driver); } -static void dyna_pci10xx_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(dyna_pci10xx_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_PLX, 0x1050) }, { 0 } @@ -291,7 +288,7 @@ static struct pci_driver dyna_pci10xx_pci_driver = { .name = "dyna_pci10xx", .id_table = dyna_pci10xx_pci_table, .probe = dyna_pci10xx_pci_probe, - .remove = dyna_pci10xx_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(dyna_pci10xx_driver, dyna_pci10xx_pci_driver); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 154598f..b60c975 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -47,9 +47,11 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include <linux/pci.h> +#include <linux/delay.h> #include <linux/interrupt.h> + #include "../comedidev.h" -#include <linux/delay.h> #include "plx9080.h" #include "comedi_fc.h" @@ -946,11 +948,6 @@ static int gsc_hpdi_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &gsc_hpdi_driver); } -static void gsc_hpdi_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(gsc_hpdi_pci_table) = { { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400, 0, 0, 0}, @@ -962,7 +959,7 @@ static struct pci_driver gsc_hpdi_pci_driver = { .name = "gsc_hpdi", .id_table = gsc_hpdi_pci_table, .probe = gsc_hpdi_pci_probe, - .remove = gsc_hpdi_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index a91a448..1e08f91 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -47,11 +47,11 @@ There are 4 x 12-bit Analogue Outputs. Ranges : 5V, 10V, +/-5V, +/-10V Configuration options: not applicable, uses PCI auto config */ +#include <linux/pci.h> +#include <linux/delay.h> #include <linux/interrupt.h> -#include "../comedidev.h" -#include <linux/delay.h> -#include <linux/pci.h> +#include "../comedidev.h" #define PCI_DEVICE_ID_ICP_MULTI 0x8000 @@ -623,11 +623,6 @@ static int icp_multi_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &icp_multi_driver); } -static void icp_multi_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(icp_multi_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_ICP, PCI_DEVICE_ID_ICP_MULTI) }, { 0 } @@ -638,7 +633,7 @@ static struct pci_driver icp_multi_pci_driver = { .name = "icp_multi", .id_table = icp_multi_pci_table, .probe = icp_multi_pci_probe, - .remove = icp_multi_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(icp_multi_driver, icp_multi_pci_driver); diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index c756a35..17ba75e 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -42,15 +42,17 @@ * comedi_nonfree_firmware tarball. The file is called "jr3pci.idm". */ -#include "../comedidev.h" - +#include <linux/kernel.h> +#include <linux/pci.h> #include <linux/delay.h> #include <linux/ctype.h> #include <linux/firmware.h> #include <linux/jiffies.h> #include <linux/slab.h> #include <linux/timer.h> -#include <linux/kernel.h> + +#include "../comedidev.h" + #include "jr3_pci.h" #define PCI_VENDOR_ID_JR3 0x1762 @@ -844,11 +846,6 @@ static int jr3_pci_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &jr3_pci_driver); } -static void jr3_pci_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL) }, { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL_NEW) }, @@ -863,7 +860,7 @@ static struct pci_driver jr3_pci_pci_driver = { .name = "jr3_pci", .id_table = jr3_pci_pci_table, .probe = jr3_pci_pci_probe, - .remove = jr3_pci_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(jr3_pci_driver, jr3_pci_pci_driver); diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 19c9428..8c09c02 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -34,6 +34,8 @@ This driver is a simple driver to read the counter values from Kolter Electronic PCI Counter Card. */ +#include <linux/pci.h> + #include "../comedidev.h" #define CNT_CARD_DEVICE_ID 0x0014 @@ -152,11 +154,6 @@ static int ke_counter_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ke_counter_driver); } -static void ke_counter_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(ke_counter_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID) }, { 0 } @@ -167,7 +164,7 @@ static struct pci_driver ke_counter_pci_driver = { .name = "ke_counter", .id_table = ke_counter_pci_table, .probe = ke_counter_pci_probe, - .remove = ke_counter_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ke_counter_driver, ke_counter_pci_driver); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 3c4b022..b766bb9 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -45,13 +45,14 @@ broken. */ -#include <linux/interrupt.h> -#include "../comedidev.h" - +#include <linux/pci.h> #include <linux/delay.h> +#include <linux/interrupt.h> #include <linux/list.h> #include <linux/spinlock.h> +#include "../comedidev.h" + #include "comedi_fc.h" #include "8253.h" @@ -1734,11 +1735,6 @@ static int me4000_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &me4000_driver); } -static void me4000_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = { {PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4650)}, {PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660)}, @@ -1761,7 +1757,7 @@ static struct pci_driver me4000_pci_driver = { .name = "me4000", .id_table = me4000_pci_table, .probe = me4000_pci_probe, - .remove = me4000_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(me4000_driver, me4000_pci_driver); diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index ce8e3d3..06490eb 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -34,9 +34,11 @@ * Analog Input, Analog Output, Digital I/O */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/firmware.h> + #include "../comedidev.h" #define ME2600_FIRMWARE "me2600_firmware.bin" @@ -619,11 +621,6 @@ static int me_daq_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &me_daq_driver); } -static void me_daq_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(me_daq_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID) }, { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID) }, @@ -635,7 +632,7 @@ static struct pci_driver me_daq_pci_driver = { .name = "me_daq", .id_table = me_daq_pci_table, .probe = me_daq_pci_probe, - .remove = me_daq_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(me_daq_driver, me_daq_pci_driver); diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index e27850f..be2c15f 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -51,11 +51,12 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include "mite.h" +#include <linux/pci.h> -#include "comedi_fc.h" #include "../comedidev.h" +#include "comedi_fc.h" +#include "mite.h" #define PCI_MITE_SIZE 4096 #define PCI_DAQ_SIZE 4096 diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 5196b460..bcd4df2 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -41,7 +41,9 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800 #define DEBUG 1 #define DEBUG_FLAGS +#include <linux/pci.h> #include <linux/interrupt.h> + #include "../comedidev.h" #include "comedi_fc.h" @@ -452,16 +454,11 @@ static int ni6527_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni6527_driver); } -static void ni6527_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver ni6527_pci_driver = { .name = DRIVER_NAME, .id_table = ni6527_pci_table, .probe = ni6527_pci_probe, - .remove = ni6527_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni6527_driver, ni6527_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 2fb4b77..bfa790e 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -50,8 +50,11 @@ except maybe the 6514. #define DEBUG 1 #define DEBUG_FLAGS + +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/slab.h> + #include "../comedidev.h" #include "comedi_fc.h" @@ -787,16 +790,11 @@ static int ni_65xx_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni_65xx_driver); } -static void ni_65xx_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver ni_65xx_pci_driver = { .name = "ni_65xx", .id_table = ni_65xx_pci_table, .probe = ni_65xx_pci_probe, - .remove = ni_65xx_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni_65xx_driver, ni_65xx_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 26baf9c..e46dd7a 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -40,8 +40,11 @@ DAQ 6601/6602 User Manual (NI 322137B-01) */ +#include <linux/pci.h> #include <linux/interrupt.h> + #include "../comedidev.h" + #include "mite.h" #include "ni_tio.h" @@ -1327,11 +1330,6 @@ static int ni_660x_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni_660x_driver); } -static void ni_660x_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = { {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c60)}, {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1310)}, @@ -1345,7 +1343,7 @@ static struct pci_driver ni_660x_pci_driver = { .name = "ni_660x", .id_table = ni_660x_pci_table, .probe = ni_660x_pci_probe, - .remove = ni_660x_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni_660x_driver, ni_660x_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 272caeb..2faf86c 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -41,8 +41,10 @@ Commands are not supported. */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/slab.h> + #include "../comedidev.h" #include "mite.h" @@ -309,11 +311,6 @@ static int ni_670x_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni_670x_driver); } -static void ni_670x_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c90) }, { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1920) }, @@ -325,7 +322,7 @@ static struct pci_driver ni_670x_pci_driver = { .name = "ni_670x", .id_table = ni_670x_pci_table, .probe = ni_670x_pci_probe, - .remove = ni_670x_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni_670x_driver, ni_670x_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 68d7c6a..9cc6092 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -50,22 +50,15 @@ Manuals: Register level: http://www.ni.com/pdf/manuals/340698.pdf User Manual: http://www.ni.com/pdf/manuals/320676d.pdf */ +#include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/slab.h> -#include "../comedidev.h" -#include <linux/ioport.h> +#include "../comedidev.h" #include <pcmcia/cistpl.h> -#include <pcmcia/cisreg.h> #include <pcmcia/ds.h> -static struct pcmcia_device *pcmcia_cur_dev; - -struct daq700_board { - const char *name; -}; - /* daqcard700 registers */ #define DIO_W 0x04 /* WO 8bit */ #define DIO_R 0x05 /* RO 8bit */ @@ -202,24 +195,20 @@ static void daq700_ai_config(struct comedi_device *dev, inw(iobase + ADFIFO_R); /* read 16bit junk from FIFO to clear */ } -static int daq700_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int daq700_auto_attach(struct comedi_device *dev, + unsigned long context) { - const struct daq700_board *thisboard = comedi_board(dev); + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); struct comedi_subdevice *s; - struct pcmcia_device *link; int ret; - link = pcmcia_cur_dev; /* XXX hack */ - if (!link) - return -EIO; + dev->board_name = dev->driver->driver_name; + link->config_flags |= CONF_AUTO_SET_IO; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; dev->iobase = link->resource[0]->start; - if (!dev->iobase) { - dev_err(dev->class_dev, "io base address is zero!\n"); - return -EINVAL; - } - - dev->board_name = thisboard->name; ret = comedi_alloc_subdevices(dev, 2); if (ret) @@ -256,68 +245,16 @@ static int daq700_attach(struct comedi_device *dev, struct comedi_devconfig *it) return 0; } -static void daq700_detach(struct comedi_device *dev) -{ - /* nothing to cleanup */ -} - -static const struct daq700_board daq700_boards[] = { - { - .name = "daqcard-700", - }, { - .name = "ni_daq_700", - }, -}; - static struct comedi_driver daq700_driver = { .driver_name = "ni_daq_700", .module = THIS_MODULE, - .attach = daq700_attach, - .detach = daq700_detach, - .board_name = &daq700_boards[0].name, - .num_names = ARRAY_SIZE(daq700_boards), - .offset = sizeof(struct daq700_board), + .auto_attach = daq700_auto_attach, + .detach = comedi_pcmcia_disable, }; -static int daq700_pcmcia_config_loop(struct pcmcia_device *p_dev, - void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - static int daq700_cs_attach(struct pcmcia_device *link) { - int ret; - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO | - CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, daq700_pcmcia_config_loop, NULL); - if (ret) - goto failed; - - if (!link->irq) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - pcmcia_cur_dev = link; - return 0; - -failed: - pcmcia_disable_device(link); - return ret; -} - -static void daq700_cs_detach(struct pcmcia_device *link) -{ - pcmcia_disable_device(link); - pcmcia_cur_dev = NULL; + return comedi_pcmcia_auto_config(link, &daq700_driver); } static const struct pcmcia_device_id daq700_cs_ids[] = { @@ -329,35 +266,11 @@ MODULE_DEVICE_TABLE(pcmcia, daq700_cs_ids); static struct pcmcia_driver daq700_cs_driver = { .name = "ni_daq_700", .owner = THIS_MODULE, - .probe = daq700_cs_attach, - .remove = daq700_cs_detach, .id_table = daq700_cs_ids, + .probe = daq700_cs_attach, + .remove = comedi_pcmcia_auto_unconfig, }; - -static int __init daq700_cs_init(void) -{ - int ret; - - ret = comedi_driver_register(&daq700_driver); - if (ret < 0) - return ret; - - ret = pcmcia_register_driver(&daq700_cs_driver); - if (ret < 0) { - comedi_driver_unregister(&daq700_driver); - return ret; - } - - return 0; -} -module_init(daq700_cs_init); - -static void __exit daq700_cs_exit(void) -{ - pcmcia_unregister_driver(&daq700_cs_driver); - comedi_driver_unregister(&daq700_driver); -} -module_exit(daq700_cs_exit); +module_comedi_pcmcia_driver(daq700_driver, daq700_cs_driver); MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>"); MODULE_DESCRIPTION( diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index 7b33335..e1cc9d0 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -37,127 +37,28 @@ This is just a wrapper around the 8255.o driver to properly handle the PCMCIA interface. */ - /* #define LABPC_DEBUG *//* enable debugging messages */ -#undef LABPC_DEBUG - -#include <linux/interrupt.h> -#include <linux/slab.h> #include "../comedidev.h" -#include <linux/ioport.h> - -#include "8255.h" - #include <pcmcia/cistpl.h> #include <pcmcia/cisreg.h> #include <pcmcia/ds.h> -static struct pcmcia_device *pcmcia_cur_dev; - -#define DIO24_SIZE 4 /* size of io region used by board */ - -static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it); -static void dio24_detach(struct comedi_device *dev); - -enum dio24_bustype { pcmcia_bustype }; - -struct dio24_board_struct { - const char *name; - int device_id; /* device id for pcmcia board */ - enum dio24_bustype bustype; /* PCMCIA */ - int have_dio; /* have 8255 chip */ - /* function pointers so we can use inb/outb or readb/writeb as appropriate */ - unsigned int (*read_byte) (unsigned int address); - void (*write_byte) (unsigned int byte, unsigned int address); -}; - -static const struct dio24_board_struct dio24_boards[] = { - { - .name = "daqcard-dio24", - .device_id = 0x475c, /* 0x10b is manufacturer id, 0x475c is device id */ - .bustype = pcmcia_bustype, - .have_dio = 1, - }, - { - .name = "ni_daq_dio24", - .device_id = 0x475c, /* 0x10b is manufacturer id, 0x475c is device id */ - .bustype = pcmcia_bustype, - .have_dio = 1, - }, -}; - -/* - * Useful for shorthand access to the particular board structure - */ -#define thisboard ((const struct dio24_board_struct *)dev->board_ptr) - -struct dio24_private { - - int data; /* number of data points left to be taken */ -}; - -static struct comedi_driver driver_dio24 = { - .driver_name = "ni_daq_dio24", - .module = THIS_MODULE, - .attach = dio24_attach, - .detach = dio24_detach, - .num_names = ARRAY_SIZE(dio24_boards), - .board_name = &dio24_boards[0].name, - .offset = sizeof(struct dio24_board_struct), -}; +#include "8255.h" -static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int dio24_auto_attach(struct comedi_device *dev, + unsigned long context) { - struct dio24_private *devpriv; + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); struct comedi_subdevice *s; - unsigned long iobase = 0; -#ifdef incomplete - unsigned int irq = 0; -#endif - struct pcmcia_device *link; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); - if (!devpriv) - return -ENOMEM; - dev->private = devpriv; - - /* get base address, irq etc. based on bustype */ - switch (thisboard->bustype) { - case pcmcia_bustype: - link = pcmcia_cur_dev; /* XXX hack */ - if (!link) - return -EIO; - iobase = link->resource[0]->start; -#ifdef incomplete - irq = link->irq; -#endif - break; - default: - pr_err("bug! couldn't determine board type\n"); - return -EINVAL; - break; - } - pr_debug("comedi%d: ni_daq_dio24: %s, io 0x%lx", dev->minor, - thisboard->name, iobase); -#ifdef incomplete - if (irq) - pr_debug("irq %u\n", irq); -#endif - - if (iobase == 0) { - pr_err("io base address is zero!\n"); - return -EINVAL; - } + dev->board_name = dev->driver->driver_name; - dev->iobase = iobase; - -#ifdef incomplete - /* grab our IRQ */ - dev->irq = irq; -#endif - - dev->board_name = thisboard->name; + link->config_flags |= CONF_AUTO_SET_IO; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; + dev->iobase = link->resource[0]->start; ret = comedi_alloc_subdevices(dev, 1); if (ret) @@ -165,184 +66,48 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* 8255 dio */ s = &dev->subdevices[0]; - subdev_8255_init(dev, s, NULL, dev->iobase); + ret = subdev_8255_init(dev, s, NULL, dev->iobase); + if (ret) + return ret; return 0; -}; +} static void dio24_detach(struct comedi_device *dev) { - struct comedi_subdevice *s; - - if (dev->subdevices) { - s = &dev->subdevices[0]; - subdev_8255_cleanup(dev, s); - } - if (thisboard->bustype != pcmcia_bustype && dev->iobase) - release_region(dev->iobase, DIO24_SIZE); - if (dev->irq) - free_irq(dev->irq, dev); -}; - -static void dio24_config(struct pcmcia_device *link); -static void dio24_release(struct pcmcia_device *link); -static int dio24_cs_suspend(struct pcmcia_device *p_dev); -static int dio24_cs_resume(struct pcmcia_device *p_dev); - -static int dio24_cs_attach(struct pcmcia_device *); -static void dio24_cs_detach(struct pcmcia_device *); + if (dev->subdevices) + subdev_8255_cleanup(dev, &dev->subdevices[0]); + comedi_pcmcia_disable(dev); +} -struct local_info_t { - struct pcmcia_device *link; - int stop; - struct bus_operations *bus; +static struct comedi_driver driver_dio24 = { + .driver_name = "ni_daq_dio24", + .module = THIS_MODULE, + .auto_attach = dio24_auto_attach, + .detach = dio24_detach, }; static int dio24_cs_attach(struct pcmcia_device *link) { - struct local_info_t *local; - - dev_info(&link->dev, "ni_daq_dio24: HOLA SOY YO - CS-attach!\n"); - - dev_dbg(&link->dev, "dio24_cs_attach()\n"); - - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL); - if (!local) - return -ENOMEM; - local->link = link; - link->priv = local; - - pcmcia_cur_dev = link; - - dio24_config(link); - - return 0; -} /* dio24_cs_attach */ - -static void dio24_cs_detach(struct pcmcia_device *link) -{ - ((struct local_info_t *)link->priv)->stop = 1; - dio24_release(link); - - /* This points to the parent local_info_t struct */ - kfree(link->priv); + return comedi_pcmcia_auto_config(link, &driver_dio24); } -static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev, - void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - -static void dio24_config(struct pcmcia_device *link) -{ - int ret; - - dev_info(&link->dev, "ni_daq_dio24: HOLA SOY YO! - config\n"); - - dev_dbg(&link->dev, "dio24_config\n"); - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO | - CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, dio24_pcmcia_config_loop, NULL); - if (ret) { - dev_warn(&link->dev, "no configuration found\n"); - goto failed; - } - - if (!link->irq) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - return; - -failed: - dev_info(&link->dev, "Fallo"); - dio24_release(link); - -} /* dio24_config */ - -static void dio24_release(struct pcmcia_device *link) -{ - dev_dbg(&link->dev, "dio24_release\n"); - - pcmcia_disable_device(link); -} /* dio24_release */ - -static int dio24_cs_suspend(struct pcmcia_device *link) -{ - struct local_info_t *local = link->priv; - - /* Mark the device as stopped, to block IO until later */ - local->stop = 1; - return 0; -} /* dio24_cs_suspend */ - -static int dio24_cs_resume(struct pcmcia_device *link) -{ - struct local_info_t *local = link->priv; - - local->stop = 0; - return 0; -} /* dio24_cs_resume */ - -/*====================================================================*/ - static const struct pcmcia_device_id dio24_cs_ids[] = { - /* N.B. These IDs should match those in dio24_boards */ PCMCIA_DEVICE_MANF_CARD(0x010b, 0x475c), /* daqcard-dio24 */ PCMCIA_DEVICE_NULL }; - MODULE_DEVICE_TABLE(pcmcia, dio24_cs_ids); -MODULE_AUTHOR("Daniel Vecino Castel <dvecino@able.es>"); -MODULE_DESCRIPTION("Comedi driver for National Instruments " - "PCMCIA DAQ-Card DIO-24"); -MODULE_LICENSE("GPL"); static struct pcmcia_driver dio24_cs_driver = { - .probe = dio24_cs_attach, - .remove = dio24_cs_detach, - .suspend = dio24_cs_suspend, - .resume = dio24_cs_resume, - .id_table = dio24_cs_ids, - .owner = THIS_MODULE, - .name = "ni_daq_dio24", + .name = "ni_daq_dio24", + .owner = THIS_MODULE, + .id_table = dio24_cs_ids, + .probe = dio24_cs_attach, + .remove = comedi_pcmcia_auto_unconfig, }; +module_comedi_pcmcia_driver(driver_dio24, dio24_cs_driver); -static int __init init_dio24_cs(void) -{ - printk("ni_daq_dio24: HOLA SOY YO!\n"); - pcmcia_register_driver(&dio24_cs_driver); - return 0; -} - -static void __exit exit_dio24_cs(void) -{ - pcmcia_unregister_driver(&dio24_cs_driver); -} - -int __init init_module(void) -{ - int ret; - - ret = init_dio24_cs(); - if (ret < 0) - return ret; - - return comedi_driver_register(&driver_dio24); -} - -void __exit cleanup_module(void) -{ - exit_dio24_cs(); - comedi_driver_unregister(&driver_dio24); -} +MODULE_AUTHOR("Daniel Vecino Castel <dvecino@able.es>"); +MODULE_DESCRIPTION( + "Comedi driver for National Instruments PCMCIA DAQ-Card DIO-24"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index d29c4d7..f957b88 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -73,12 +73,14 @@ NI manuals: */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/slab.h> #include <linux/io.h> +#include <linux/delay.h> + #include "../comedidev.h" -#include <linux/delay.h> #include <asm/dma.h> #include "8253.h" @@ -568,13 +570,11 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, return -EINVAL; } else if (dma_chan) { /* allocate dma buffer */ - devpriv->dma_buffer = - kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA); - if (devpriv->dma_buffer == NULL) { - dev_err(dev->class_dev, - "failed to allocate dma buffer\n"); + devpriv->dma_buffer = kmalloc(dma_buffer_size, + GFP_KERNEL | GFP_DMA); + if (devpriv->dma_buffer == NULL) return -ENOMEM; - } + if (request_dma(dma_chan, DRV_NAME)) { dev_err(dev->class_dev, "failed to allocate dma channel %u\n", @@ -1202,7 +1202,8 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) else channel = CR_CHAN(cmd->chanlist[0]); /* munge channel bits for differential / scan disabled mode */ - if (mode != MODE_SINGLE_CHAN && aref == AREF_DIFF) + if ((mode == MODE_SINGLE_CHAN || mode == MODE_SINGLE_CHAN_INTERVAL) && + aref == AREF_DIFF) channel *= 2; devpriv->command1_bits |= ADC_CHAN_BITS(channel); devpriv->command1_bits |= thisboard->ai_range_code[range]; @@ -1217,21 +1218,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG); } - /* setup any external triggering/pacing (command4 register) */ - devpriv->command4_bits = 0; - if (cmd->convert_src != TRIG_EXT) - devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT; - /* XXX should discard first scan when using interval scanning - * since manual says it is not synced with scan clock */ - if (labpc_use_continuous_mode(cmd, mode) == 0) { - devpriv->command4_bits |= INTERVAL_SCAN_EN_BIT; - if (cmd->scan_begin_src == TRIG_EXT) - devpriv->command4_bits |= EXT_SCAN_EN_BIT; - } - /* single-ended/differential */ - if (aref == AREF_DIFF) - devpriv->command4_bits |= ADC_DIFF_BIT; - devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG); devpriv->write_byte(cmd->chanlist_len, dev->iobase + INTERVAL_COUNT_REG); @@ -1311,6 +1297,22 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->command3_bits &= ~ADC_FNE_INTR_EN_BIT; devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); + /* setup any external triggering/pacing (command4 register) */ + devpriv->command4_bits = 0; + if (cmd->convert_src != TRIG_EXT) + devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT; + /* XXX should discard first scan when using interval scanning + * since manual says it is not synced with scan clock */ + if (labpc_use_continuous_mode(cmd, mode) == 0) { + devpriv->command4_bits |= INTERVAL_SCAN_EN_BIT; + if (cmd->scan_begin_src == TRIG_EXT) + devpriv->command4_bits |= EXT_SCAN_EN_BIT; + } + /* single-ended/differential */ + if (aref == AREF_DIFF) + devpriv->command4_bits |= ADC_DIFF_BIT; + devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG); + /* startup acquisition */ /* command2 reg */ @@ -2116,16 +2118,11 @@ static int labpc_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &labpc_driver); } -static void labpc_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver labpc_pci_driver = { .name = DRV_NAME, .id_table = labpc_pci_table, .probe = labpc_pci_probe, - .remove = labpc_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(labpc_driver, labpc_pci_driver); #else diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index bfe19fa..be7d141 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -59,8 +59,6 @@ NI manuals: */ -#undef LABPC_DEBUG /* debugging messages */ - #include "../comedidev.h" #include <linux/delay.h> @@ -75,240 +73,81 @@ NI manuals: #include <pcmcia/cisreg.h> #include <pcmcia/ds.h> -static struct pcmcia_device *pcmcia_cur_dev; - -static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it); - static const struct labpc_board_struct labpc_cs_boards[] = { { - .name = "daqcard-1200", - .device_id = 0x103, /* 0x10b is manufacturer id, - 0x103 is device id */ - .ai_speed = 10000, - .bustype = pcmcia_bustype, - .register_layout = labpc_1200_layout, - .has_ao = 1, - .ai_range_table = &range_labpc_1200_ai, - .ai_range_code = labpc_1200_ai_gain_bits, - .ai_range_is_unipolar = labpc_1200_is_unipolar, - .ai_scan_up = 0, - .memory_mapped_io = 0, - }, - /* duplicate entry, to support using alternate name */ - { - .name = "ni_labpc_cs", - .device_id = 0x103, - .ai_speed = 10000, - .bustype = pcmcia_bustype, - .register_layout = labpc_1200_layout, - .has_ao = 1, - .ai_range_table = &range_labpc_1200_ai, - .ai_range_code = labpc_1200_ai_gain_bits, - .ai_range_is_unipolar = labpc_1200_is_unipolar, - .ai_scan_up = 0, - .memory_mapped_io = 0, - }, + .name = "daqcard-1200", + .device_id = 0x103, + .ai_speed = 10000, + .bustype = pcmcia_bustype, + .register_layout = labpc_1200_layout, + .has_ao = 1, + .ai_range_table = &range_labpc_1200_ai, + .ai_range_code = labpc_1200_ai_gain_bits, + .ai_range_is_unipolar = labpc_1200_is_unipolar, + }, }; -/* - * Useful for shorthand access to the particular board structure - */ -#define thisboard ((const struct labpc_board_struct *)dev->board_ptr) - -static struct comedi_driver driver_labpc_cs = { - .driver_name = "ni_labpc_cs", - .module = THIS_MODULE, - .attach = &labpc_attach, - .detach = &labpc_common_detach, - .num_names = ARRAY_SIZE(labpc_cs_boards), - .board_name = &labpc_cs_boards[0].name, - .offset = sizeof(struct labpc_board_struct), -}; - -static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int labpc_auto_attach(struct comedi_device *dev, + unsigned long context) { + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); struct labpc_private *devpriv; - unsigned long iobase = 0; - unsigned int irq = 0; - struct pcmcia_device *link; + int ret; + + /* The ni_labpc driver needs the board_ptr */ + dev->board_ptr = &labpc_cs_boards[0]; + + link->config_flags |= CONF_AUTO_SET_IO | + CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; + dev->iobase = link->resource[0]->start; + + if (!link->irq) + return -EINVAL; devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; dev->private = devpriv; - /* get base address, irq etc. based on bustype */ - switch (thisboard->bustype) { - case pcmcia_bustype: - link = pcmcia_cur_dev; /* XXX hack */ - if (!link) - return -EIO; - iobase = link->resource[0]->start; - irq = link->irq; - break; - default: - pr_err("bug! couldn't determine board type\n"); - return -EINVAL; - break; - } - return labpc_common_attach(dev, iobase, irq, 0); + return labpc_common_attach(dev, dev->iobase, link->irq, 0); } -static void labpc_config(struct pcmcia_device *link); -static void labpc_release(struct pcmcia_device *link); -static int labpc_cs_suspend(struct pcmcia_device *p_dev); -static int labpc_cs_resume(struct pcmcia_device *p_dev); - -static int labpc_cs_attach(struct pcmcia_device *); -static void labpc_cs_detach(struct pcmcia_device *); +static void labpc_detach(struct comedi_device *dev) +{ + labpc_common_detach(dev); + comedi_pcmcia_disable(dev); +} -struct local_info_t { - struct pcmcia_device *link; - int stop; - struct bus_operations *bus; +static struct comedi_driver driver_labpc_cs = { + .driver_name = "ni_labpc_cs", + .module = THIS_MODULE, + .auto_attach = labpc_auto_attach, + .detach = labpc_detach, }; static int labpc_cs_attach(struct pcmcia_device *link) { - struct local_info_t *local; - - dev_dbg(&link->dev, "labpc_cs_attach()\n"); - - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL); - if (!local) - return -ENOMEM; - local->link = link; - link->priv = local; - - pcmcia_cur_dev = link; - - labpc_config(link); - - return 0; -} /* labpc_cs_attach */ - -static void labpc_cs_detach(struct pcmcia_device *link) -{ - ((struct local_info_t *)link->priv)->stop = 1; - labpc_release(link); - - /* This points to the parent local_info_t struct (may be null) */ - kfree(link->priv); - + return comedi_pcmcia_auto_config(link, &driver_labpc_cs); } -static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev, - void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - - -static void labpc_config(struct pcmcia_device *link) -{ - int ret; - - dev_dbg(&link->dev, "labpc_config\n"); - - link->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ | - CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, labpc_pcmcia_config_loop, NULL); - if (ret) { - dev_warn(&link->dev, "no configuration found\n"); - goto failed; - } - - if (!link->irq) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - return; - -failed: - labpc_release(link); - -} /* labpc_config */ - -static void labpc_release(struct pcmcia_device *link) -{ - dev_dbg(&link->dev, "labpc_release\n"); - - pcmcia_disable_device(link); -} /* labpc_release */ - -static int labpc_cs_suspend(struct pcmcia_device *link) -{ - struct local_info_t *local = link->priv; - - /* Mark the device as stopped, to block IO until later */ - local->stop = 1; - return 0; -} /* labpc_cs_suspend */ - -static int labpc_cs_resume(struct pcmcia_device *link) -{ - struct local_info_t *local = link->priv; - - local->stop = 0; - return 0; -} /* labpc_cs_resume */ - static const struct pcmcia_device_id labpc_cs_ids[] = { - /* N.B. These IDs should match those in labpc_cs_boards (ni_labpc.c) */ PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0103), /* daqcard-1200 */ PCMCIA_DEVICE_NULL }; - MODULE_DEVICE_TABLE(pcmcia, labpc_cs_ids); -MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>"); -MODULE_DESCRIPTION("Comedi driver for National Instruments Lab-PC"); -MODULE_LICENSE("GPL"); static struct pcmcia_driver labpc_cs_driver = { - .probe = labpc_cs_attach, - .remove = labpc_cs_detach, - .suspend = labpc_cs_suspend, - .resume = labpc_cs_resume, - .id_table = labpc_cs_ids, - .owner = THIS_MODULE, - .name = "daqcard-1200", + .name = "daqcard-1200", + .owner = THIS_MODULE, + .id_table = labpc_cs_ids, + .probe = labpc_cs_attach, + .remove = comedi_pcmcia_auto_unconfig, }; +module_comedi_pcmcia_driver(driver_labpc_cs, labpc_cs_driver); -static int __init init_labpc_cs(void) -{ - pcmcia_register_driver(&labpc_cs_driver); - return 0; -} - -static void __exit exit_labpc_cs(void) -{ - pcmcia_unregister_driver(&labpc_cs_driver); -} - -static int __init labpc_init_module(void) -{ - int ret; - - ret = init_labpc_cs(); - if (ret < 0) - return ret; - - return comedi_driver_register(&driver_labpc_cs); -} - -static void __exit labpc_exit_module(void) -{ - exit_labpc_cs(); - comedi_driver_unregister(&driver_labpc_cs); -} - -module_init(labpc_init_module); -module_exit(labpc_exit_module); +MODULE_DESCRIPTION("Comedi driver for National Instruments Lab-PC"); +MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 56dc599..b740359 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -986,7 +986,7 @@ static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s) if (s-> async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW | COMEDI_CB_EOA)) { - switch (s - dev->subdevices) { + switch (s->index) { case NI_AI_SUBDEV: ni_ai_reset(dev, s); break; @@ -1086,7 +1086,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, ("ni_mio_common: a_status=0xffff. Card removed?\n"); /* we probably aren't even running a command now, * so it's a good idea to be careful. */ - if (comedi_get_subdevice_runflags(s) & SRF_RUNNING) { + if (comedi_is_subdevice_running(s)) { s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; ni_event(dev, s); diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c index 76c6a13..888be7b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_cs.c +++ b/drivers/staging/comedi/drivers/ni_mio_cs.c @@ -65,112 +65,90 @@ See the notes in the ni_atmio.o driver. #define MAX_N_CALDACS 32 static const struct ni_board_struct ni_boards[] = { - {.device_id = 0x010d, - .name = "DAQCard-ai-16xe-50", - .n_adchan = 16, - .adbits = 16, - .ai_fifo_depth = 1024, - .alwaysdither = 0, - .gainlkup = ai_gain_8, - .ai_speed = 5000, - .n_aochan = 0, - .aobits = 0, - .ao_fifo_depth = 0, - .ao_unipolar = 0, - .num_p0_dio_channels = 8, - .has_8255 = 0, - .caldac = {dac8800, dac8043}, - }, - {.device_id = 0x010c, - .name = "DAQCard-ai-16e-4", - .n_adchan = 16, - .adbits = 12, - .ai_fifo_depth = 1024, - .alwaysdither = 0, - .gainlkup = ai_gain_16, - .ai_speed = 4000, - .n_aochan = 0, - .aobits = 0, - .ao_fifo_depth = 0, - .ao_unipolar = 0, - .num_p0_dio_channels = 8, - .has_8255 = 0, - .caldac = {mb88341}, /* verified */ - }, - {.device_id = 0x02c4, - .name = "DAQCard-6062E", - .n_adchan = 16, - .adbits = 12, - .ai_fifo_depth = 8192, - .alwaysdither = 0, - .gainlkup = ai_gain_16, - .ai_speed = 2000, - .n_aochan = 2, - .aobits = 12, - .ao_fifo_depth = 2048, - .ao_range_table = &range_bipolar10, - .ao_unipolar = 0, - .ao_speed = 1176, - .num_p0_dio_channels = 8, - .has_8255 = 0, - .caldac = {ad8804_debug}, /* verified */ - }, - {.device_id = 0x075e, - .name = "DAQCard-6024E", /* specs incorrect! */ - .n_adchan = 16, - .adbits = 12, - .ai_fifo_depth = 1024, - .alwaysdither = 0, - .gainlkup = ai_gain_4, - .ai_speed = 5000, - .n_aochan = 2, - .aobits = 12, - .ao_fifo_depth = 0, - .ao_range_table = &range_bipolar10, - .ao_unipolar = 0, - .ao_speed = 1000000, - .num_p0_dio_channels = 8, - .has_8255 = 0, - .caldac = {ad8804_debug}, - }, - {.device_id = 0x0245, - .name = "DAQCard-6036E", /* specs incorrect! */ - .n_adchan = 16, - .adbits = 16, - .ai_fifo_depth = 1024, - .alwaysdither = 1, - .gainlkup = ai_gain_4, - .ai_speed = 5000, - .n_aochan = 2, - .aobits = 16, - .ao_fifo_depth = 0, - .ao_range_table = &range_bipolar10, - .ao_unipolar = 0, - .ao_speed = 1000000, - .num_p0_dio_channels = 8, - .has_8255 = 0, - .caldac = {ad8804_debug}, + { + .device_id = 0x010d, + .name = "DAQCard-ai-16xe-50", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 1024, + .gainlkup = ai_gain_8, + .ai_speed = 5000, + .num_p0_dio_channels = 8, + .caldac = { dac8800, dac8043 }, + }, { + .device_id = 0x010c, + .name = "DAQCard-ai-16e-4", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 1024, + .gainlkup = ai_gain_16, + .ai_speed = 4000, + .num_p0_dio_channels = 8, + .caldac = { mb88341 }, /* verified */ + }, { + .device_id = 0x02c4, + .name = "DAQCard-6062E", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 8192, + .gainlkup = ai_gain_16, + .ai_speed = 2000, + .n_aochan = 2, + .aobits = 12, + .ao_fifo_depth = 2048, + .ao_range_table = &range_bipolar10, + .ao_speed = 1176, + .num_p0_dio_channels = 8, + .caldac = { ad8804_debug }, /* verified */ + }, { + /* specs incorrect! */ + .device_id = 0x075e, + .name = "DAQCard-6024E", + .n_adchan = 16, + .adbits = 12, + .ai_fifo_depth = 1024, + .gainlkup = ai_gain_4, + .ai_speed = 5000, + .n_aochan = 2, + .aobits = 12, + .ao_range_table = &range_bipolar10, + .ao_speed = 1000000, + .num_p0_dio_channels = 8, + .caldac = { ad8804_debug }, + }, { + /* specs incorrect! */ + .device_id = 0x0245, + .name = "DAQCard-6036E", + .n_adchan = 16, + .adbits = 16, + .ai_fifo_depth = 1024, + .alwaysdither = 1, + .gainlkup = ai_gain_4, + .ai_speed = 5000, + .n_aochan = 2, + .aobits = 16, + .ao_range_table = &range_bipolar10, + .ao_speed = 1000000, + .num_p0_dio_channels = 8, + .caldac = { ad8804_debug }, }, #if 0 - {.device_id = 0x0000, /* unknown */ - .name = "DAQCard-6715", - .n_adchan = 0, - .n_aochan = 8, - .aobits = 12, - .ao_671x = 8192, - .num_p0_dio_channels = 8, - .caldac = {mb88341, mb88341}, - }, + { + .device_id = 0x0000, /* unknown */ + .name = "DAQCard-6715", + .n_aochan = 8, + .aobits = 12, + .ao_671x = 8192, + .num_p0_dio_channels = 8, + .caldac = { mb88341, mb88341 }, + }, #endif - /* N.B. Update ni_mio_cs_ids[] when entries added above. */ }; #define interrupt_pin(a) 0 #define IRQ_POLARITY 1 -#define NI_E_IRQ_FLAGS IRQF_SHARED - struct ni_private { struct pcmcia_device *link; @@ -225,67 +203,22 @@ static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr) return ret; } -static int mio_cs_attach(struct comedi_device *dev, - struct comedi_devconfig *it); -static void mio_cs_detach(struct comedi_device *dev); -static struct comedi_driver driver_ni_mio_cs = { - .driver_name = "ni_mio_cs", - .module = THIS_MODULE, - .attach = mio_cs_attach, - .detach = mio_cs_detach, -}; - #include "ni_mio_common.c" -static int ni_getboardtype(struct comedi_device *dev, - struct pcmcia_device *link); - -static void mio_cs_detach(struct comedi_device *dev) -{ - mio_common_detach(dev); - if (dev->irq) - free_irq(dev->irq, dev); -} - -static void mio_cs_config(struct pcmcia_device *link); -static void cs_release(struct pcmcia_device *link); -static void cs_detach(struct pcmcia_device *); - -static struct pcmcia_device *cur_dev; - -static int cs_attach(struct pcmcia_device *link) +static const void *ni_getboardtype(struct comedi_device *dev, + struct pcmcia_device *link) { - cur_dev = link; - - mio_cs_config(link); - - return 0; -} - -static void cs_release(struct pcmcia_device *link) -{ - pcmcia_disable_device(link); -} - -static void cs_detach(struct pcmcia_device *link) -{ - cs_release(link); -} - -static int mio_cs_suspend(struct pcmcia_device *link) -{ - DPRINTK("pm suspend\n"); - - return 0; -} + static const struct ni_board_struct *board; + int i; -static int mio_cs_resume(struct pcmcia_device *link) -{ - DPRINTK("pm resume\n"); - return 0; + for (i = 0; i < ARRAY_SIZE(ni_boards); i++) { + board = &ni_boards[i]; + if (board->device_id == link->card_id) + return board; + } + return NULL; } - static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) { int base, ret; @@ -302,114 +235,63 @@ static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) return -ENODEV; } - -static void mio_cs_config(struct pcmcia_device *link) -{ - int ret; - - DPRINTK("mio_cs_config(link=%p)\n", link); - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL); - if (ret) { - dev_warn(&link->dev, "no configuration found\n"); - return; - } - - if (!link->irq) - dev_info(&link->dev, "no IRQ available\n"); - - ret = pcmcia_enable_device(link); -} - -static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) +static int mio_cs_auto_attach(struct comedi_device *dev, + unsigned long context) { + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); + static const struct ni_board_struct *board; struct ni_private *devpriv; - struct pcmcia_device *link; - unsigned int irq; int ret; - DPRINTK("mio_cs_attach(dev=%p,it=%p)\n", dev, it); - - link = cur_dev; /* XXX hack */ - if (!link) - return -EIO; + board = ni_getboardtype(dev, link); + if (!board) + return -ENODEV; + dev->board_ptr = board; + dev->board_name = board->name; - dev->driver = &driver_ni_mio_cs; + link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; + ret = comedi_pcmcia_enable(dev, mio_pcmcia_config_loop); + if (ret) + return ret; dev->iobase = link->resource[0]->start; - irq = link->irq; - - dev->board_ptr = ni_boards + ni_getboardtype(dev, link); - -#if 0 - { - int i; - - printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ", - dev->minor, dev->driver->driver_name, dev->iobase, irq); - - printk(" board fingerprint:"); - for (i = 0; i < 32; i += 2) { - printk(" %04x %02x", inw(dev->iobase + i), - inb(dev->iobase + i + 1)); - } - printk("\n"); - printk(" board fingerprint (windowed):"); - for (i = 0; i < 10; i++) - printk(" 0x%04x", win_in(i)); - printk("\n"); - - printk("boardtype.name: %s\n", boardtype.name); - } -#endif - - dev->board_name = boardtype.name; - - ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS, - "ni_mio_cs", dev); - if (ret < 0) { - dev_err(dev->class_dev, "irq not available\n"); - return -EINVAL; - } - dev->irq = irq; + link->priv = dev; + ret = pcmcia_request_irq(link, ni_E_interrupt); + if (ret) + return ret; + dev->irq = link->irq; ret = ni_alloc_private(dev); if (ret) return ret; - devpriv = dev->private; - - devpriv->stc_writew = &mio_cs_win_out; - devpriv->stc_readw = &mio_cs_win_in; - devpriv->stc_writel = &win_out2; - devpriv->stc_readl = &win_in2; - - ret = ni_E_init(dev); - if (ret < 0) - return ret; + devpriv = dev->private; + devpriv->stc_writew = mio_cs_win_out; + devpriv->stc_readw = mio_cs_win_in; + devpriv->stc_writel = win_out2; + devpriv->stc_readl = win_in2; - return 0; + return ni_E_init(dev); } -static int ni_getboardtype(struct comedi_device *dev, - struct pcmcia_device *link) +static void mio_cs_detach(struct comedi_device *dev) { - int i; - - for (i = 0; i < n_ni_boards; i++) { - if (ni_boards[i].device_id == link->card_id) - return i; - } + mio_common_detach(dev); + comedi_pcmcia_disable(dev); +} - dev_err(dev->class_dev, - "unknown board 0x%04x -- pretend it is a ", link->card_id); +static struct comedi_driver driver_ni_mio_cs = { + .driver_name = "ni_mio_cs", + .module = THIS_MODULE, + .auto_attach = mio_cs_auto_attach, + .detach = mio_cs_detach, +}; - return 0; +static int cs_attach(struct pcmcia_device *link) +{ + return comedi_pcmcia_auto_config(link, &driver_ni_mio_cs); } -#ifdef MODULE - static const struct pcmcia_device_id ni_mio_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */ PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c), /* DAQCard-ai-16e-4 */ @@ -418,36 +300,17 @@ static const struct pcmcia_device_id ni_mio_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0245), /* DAQCard-6036E */ PCMCIA_DEVICE_NULL }; - MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids); -MODULE_AUTHOR("David A. Schleef <ds@schleef.org>"); -MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series"); -MODULE_LICENSE("GPL"); static struct pcmcia_driver ni_mio_cs_driver = { - .probe = &cs_attach, - .remove = &cs_detach, - .suspend = &mio_cs_suspend, - .resume = &mio_cs_resume, - .id_table = ni_mio_cs_ids, - .owner = THIS_MODULE, - .name = "ni_mio_cs", + .name = "ni_mio_cs", + .owner = THIS_MODULE, + .id_table = ni_mio_cs_ids, + .probe = cs_attach, + .remove = comedi_pcmcia_auto_unconfig, }; +module_comedi_pcmcia_driver(driver_ni_mio_cs, ni_mio_cs_driver); -int init_module(void) -{ - pcmcia_register_driver(&ni_mio_cs_driver); - comedi_driver_register(&driver_ni_mio_cs); - return 0; -} - -void cleanup_module(void) -{ - pcmcia_unregister_driver(&ni_mio_cs_driver); -#if 0 - while (cur_dev != NULL) - cs_detach(cur_dev->handle); -#endif - comedi_driver_unregister(&driver_ni_mio_cs); -} -#endif +MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series"); +MODULE_AUTHOR("David A. Schleef <ds@schleef.org>"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 084ebea..0a00260 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -55,9 +55,11 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org /* #define DEBUG 1 */ /* #define DEBUG_FLAGS */ +#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/firmware.h> + #include "../comedidev.h" #include "comedi_fc.h" @@ -1224,11 +1226,6 @@ static int ni_pcidio_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni_pcidio_driver); } -static void ni_pcidio_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) }, { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) }, @@ -1241,7 +1238,7 @@ static struct pci_driver ni_pcidio_pci_driver = { .name = "ni_pcidio", .id_table = ni_pcidio_pci_table, .probe = ni_pcidio_pci_probe, - .remove = ni_pcidio_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni_pcidio_driver, ni_pcidio_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index fd1662b..98b43f2 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -110,10 +110,12 @@ Bugs: */ +#include <linux/delay.h> +#include <linux/delay.h> + #include "../comedidev.h" #include <asm/byteorder.h> -#include <linux/delay.h> #include "ni_stc.h" #include "mite.h" @@ -1791,11 +1793,6 @@ static int ni_pcimio_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &ni_pcimio_driver); } -static void ni_pcimio_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(ni_pcimio_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0162) }, { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1170) }, @@ -1858,7 +1855,7 @@ static struct pci_driver ni_pcimio_pci_driver = { .name = "ni_pcimio", .id_table = ni_pcimio_pci_table, .probe = ni_pcimio_pci_probe, - .remove = ni_pcimio_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(ni_pcimio_driver, ni_pcimio_pci_driver); diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 98f8789..2252877 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -276,7 +276,7 @@ static inline unsigned NI_660x_RTSI_Second_Gate_Select(unsigned n) } static const unsigned int counter_status_mask = - COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING; + COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING; static int __init ni_tio_init_module(void) { diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 0c991b9..13747f3 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -159,6 +159,7 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) async->inttrig = NULL; mite_dma_arm(counter->mite_chan); retval = ni_tio_arm(counter, 1, cmd->start_arg); + break; case TRIG_OTHER: async->inttrig = NULL; mite_dma_arm(counter->mite_chan); diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 06127a5..b5af22e 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -243,8 +243,8 @@ static const struct comedi_lrange range_pcl818l_h_ai = { 4, { }; static const struct comedi_lrange range718_bipolar1 = { 1, {BIP_RANGE(1),} }; -static const struct comedi_lrange range718_bipolar0_5 = - { 1, {BIP_RANGE(0.5),} }; +static const struct comedi_lrange range718_bipolar0_5 = { + 1, {BIP_RANGE(0.5),} }; static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} }; static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} }; @@ -1005,17 +1005,14 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, switch (devpriv->dma) { case 1: /* DMA */ case 3: - if (devpriv->dma_rtc == 0) { + if (devpriv->dma_rtc == 0) pcl818_ai_mode13dma_int(mode, dev, s); - } #ifdef unused - else { + else pcl818_ai_mode13dma_rtc(mode, dev, s); - } #else - else { + else return -EINVAL; - } #endif break; case 0: @@ -1069,7 +1066,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev, */ #ifdef PCL818_MODE13_AO static int pcl818_ao_mode13(int mode, struct comedi_device *dev, - struct comedi_subdevice *s, comedi_trig * it) + struct comedi_subdevice *s, comedi_trig *it) { struct pcl818_private *devpriv = dev->private; int divisor1 = 0, divisor2 = 0; @@ -1124,7 +1121,7 @@ static int pcl818_ao_mode13(int mode, struct comedi_device *dev, ANALOG OUTPUT MODE 1, 818 cards */ static int pcl818_ao_mode1(struct comedi_device *dev, - struct comedi_subdevice *s, comedi_trig * it) + struct comedi_subdevice *s, comedi_trig *it) { return pcl818_ao_mode13(1, dev, s, it); } @@ -1134,7 +1131,7 @@ static int pcl818_ao_mode1(struct comedi_device *dev, ANALOG OUTPUT MODE 3, 818 cards */ static int pcl818_ao_mode3(struct comedi_device *dev, - struct comedi_subdevice *s, comedi_trig * it) + struct comedi_subdevice *s, comedi_trig *it) { return pcl818_ao_mode13(3, dev, s, it); } diff --git a/drivers/staging/comedi/drivers/pcm_common.c b/drivers/staging/comedi/drivers/pcm_common.c deleted file mode 100644 index 8a718ae..0000000 --- a/drivers/staging/comedi/drivers/pcm_common.c +++ /dev/null @@ -1,63 +0,0 @@ -#include "../comedidev.h" - -#include "comedi_fc.h" -#include "pcm_common.h" - -int comedi_pcm_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_cmd *cmd) -{ - int err = 0; - - /* Step 1 : check if triggers are trivially valid */ - - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT); - err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT); - err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW); - err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); - - if (err) - return 1; - - /* Step 2a : make sure trigger sources are unique */ - - err |= cfc_check_trigger_is_unique(cmd->start_src); - err |= cfc_check_trigger_is_unique(cmd->stop_src); - - /* Step 2b : and mutually compatible */ - - if (err) - return 2; - - /* Step 3: check if arguments are trivially valid */ - - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); - - switch (cmd->stop_src) { - case TRIG_COUNT: - /* any count allowed */ - break; - case TRIG_NONE: - err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); - break; - default: - break; - } - - if (err) - return 3; - - /* step 4: fix up any arguments */ - - /* if (err) return 4; */ - - return 0; -} -EXPORT_SYMBOL(comedi_pcm_cmdtest); - -MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcm_common.h b/drivers/staging/comedi/drivers/pcm_common.h deleted file mode 100644 index cd4840c..0000000 --- a/drivers/staging/comedi/drivers/pcm_common.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _comedi_common_H -#define _comedi_common_H - -extern int comedi_pcm_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_cmd *cmd); - -#endif diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 0882daf..13f79f4 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -53,9 +53,6 @@ Configuration Options: #include "../comedidev.h" -#include <linux/pci.h> /* for PCI devices */ - -#define SDEV_NO ((int)(s - dev->subdevices)) #define CHANS 8 #define IOSIZE 16 #define LSB(x) ((unsigned char)((x) & 0xff)) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 7522bfb..5fa1fe0 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -78,9 +78,10 @@ Configuration Options: #include <linux/interrupt.h> #include <linux/slab.h> + #include "../comedidev.h" -#include "pcm_common.h" -#include <linux/pci.h> /* for PCI devices */ + +#include "comedi_fc.h" /* This stuff is all from pcmuio.c -- it refers to the DIO subdevices only */ #define CHANS_PER_PORT 8 @@ -93,7 +94,6 @@ Configuration Options: #define INTR_PORTS_PER_SUBDEV (INTR_CHANS_PER_ASIC/CHANS_PER_PORT) #define MAX_DIO_CHANS (PORTS_PER_ASIC*1*CHANS_PER_PORT) #define MAX_ASICS (MAX_DIO_CHANS/CHANS_PER_ASIC) -#define SDEV_NO ((int)(s - dev->subdevices)) #define CALC_N_DIO_SUBDEVS(nchans) ((nchans)/MAX_CHANS_PER_SUBDEV + (!!((nchans)%MAX_CHANS_PER_SUBDEV)) /*+ (nchans > INTR_CHANS_PER_ASIC ? 2 : 1)*/) /* IO Memory sizes */ #define ASIC_IOSIZE (0x0B) @@ -802,11 +802,59 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -static int -pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pcmmio_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { - return comedi_pcm_cmdtest(dev, s, cmd); + int err = 0; + + /* Step 1 : check if triggers are trivially valid */ + + err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW); + err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); + err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); + + if (err) + return 1; + + /* Step 2a : make sure trigger sources are unique */ + + err |= cfc_check_trigger_is_unique(cmd->start_src); + err |= cfc_check_trigger_is_unique(cmd->stop_src); + + /* Step 2b : and mutually compatible */ + + if (err) + return 2; + + /* Step 3: check if arguments are trivially valid */ + + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + + switch (cmd->stop_src) { + case TRIG_COUNT: + /* any count allowed */ + break; + case TRIG_NONE: + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); + break; + default: + break; + } + + if (err) + return 3; + + /* step 4: fix up any arguments */ + + /* if (err) return 4; */ + + return 0; } static int adc_wait_ready(unsigned long iobase) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 31ea20c..433270c 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -77,10 +77,10 @@ Configuration Options: #include <linux/interrupt.h> #include <linux/slab.h> + #include "../comedidev.h" -#include "pcm_common.h" -#include <linux/pci.h> /* for PCI devices */ +#include "comedi_fc.h" #define CHANS_PER_PORT 8 #define PORTS_PER_ASIC 6 @@ -92,7 +92,6 @@ Configuration Options: #define INTR_PORTS_PER_SUBDEV (INTR_CHANS_PER_ASIC/CHANS_PER_PORT) #define MAX_DIO_CHANS (PORTS_PER_ASIC*2*CHANS_PER_PORT) #define MAX_ASICS (MAX_DIO_CHANS/CHANS_PER_ASIC) -#define SDEV_NO ((int)(s - dev->subdevices)) #define CALC_N_SUBDEVS(nchans) ((nchans)/MAX_CHANS_PER_SUBDEV + (!!((nchans)%MAX_CHANS_PER_SUBDEV)) /*+ (nchans > INTR_CHANS_PER_ASIC ? 2 : 1)*/) /* IO Memory sizes */ #define ASIC_IOSIZE (0x10) @@ -740,11 +739,59 @@ static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -static int -pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_cmd *cmd) +static int pcmuio_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { - return comedi_pcm_cmdtest(dev, s, cmd); + int err = 0; + + /* Step 1 : check if triggers are trivially valid */ + + err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW); + err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); + err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); + + if (err) + return 1; + + /* Step 2a : make sure trigger sources are unique */ + + err |= cfc_check_trigger_is_unique(cmd->start_src); + err |= cfc_check_trigger_is_unique(cmd->stop_src); + + /* Step 2b : and mutually compatible */ + + if (err) + return 2; + + /* Step 3: check if arguments are trivially valid */ + + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + + switch (cmd->stop_src) { + case TRIG_COUNT: + /* any count allowed */ + break; + case TRIG_NONE: + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); + break; + default: + break; + } + + if (err) + return 3; + + /* step 4: fix up any arguments */ + + /* if (err) return 4; */ + + return 0; } static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) @@ -791,14 +838,11 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) chans_left = CHANS_PER_ASIC * board->num_asics; n_subdevs = CALC_N_SUBDEVS(chans_left); - devpriv->sprivs = - kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private), - GFP_KERNEL); - if (!devpriv->sprivs) { - dev_warn(dev->class_dev, - "cannot allocate subdevice private data structures\n"); + devpriv->sprivs = kcalloc(n_subdevs, + sizeof(struct pcmuio_subdev_private), + GFP_KERNEL); + if (!devpriv->sprivs) return -ENOMEM; - } ret = comedi_alloc_subdevices(dev, n_subdevs); if (ret) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index ef0cdaa..911eb6b 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -47,8 +47,6 @@ Status: works Devices: [Quatech] DAQP-208 (daqp), DAQP-308 */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "../comedidev.h" #include <linux/semaphore.h> @@ -60,28 +58,16 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308 #include "comedi_fc.h" -/* Maximum number of separate DAQP devices we'll allow */ -#define MAX_DEV 4 - -struct local_info_t { - struct pcmcia_device *link; +struct daqp_private { int stop; - int table_index; - char board_name[32]; enum { semaphore, buffer } interrupt_mode; struct completion eos; - struct comedi_device *dev; - struct comedi_subdevice *s; int count; }; -/* A list of "instances" of the device. */ - -static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ }; - /* The DAQP communicates with the system through a 16 byte I/O window. */ #define DAQP_FIFO_SIZE 4096 @@ -165,84 +151,38 @@ static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ }; #define DAQP_AUX_FIFO_NEARFULL 0x02 #define DAQP_AUX_FIFO_EMPTY 0x01 -/* These range structures tell COMEDI how the sample values map to - * voltages. The A/D converter has four .ranges = +/- 10V through - * +/- 1.25V, and the D/A converter has only .one = +/- 5V. - */ - -static const struct comedi_lrange range_daqp_ai = { 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25) - } -}; - -static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} }; - -/*====================================================================*/ - -/* comedi interface code */ - -static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it); -static void daqp_detach(struct comedi_device *dev); -static struct comedi_driver driver_daqp = { - .driver_name = "quatech_daqp_cs", - .module = THIS_MODULE, - .attach = daqp_attach, - .detach = daqp_detach, -}; - -#ifdef DAQP_DEBUG - -static void daqp_dump(struct comedi_device *dev) -{ - dev_info(dev->class_dev, "status %02x; aux status %02x\n", - inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX)); -} - -static void hex_dump(char *str, void *ptr, int len) -{ - unsigned char *cptr = ptr; - int i; - - printk(str); - - for (i = 0; i < len; i++) { - if (i % 16 == 0) - printk("\n%p:", cptr); - - printk(" %02x", *(cptr++)); +static const struct comedi_lrange range_daqp_ai = { + 4, { + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25) } - printk("\n"); -} - -#endif +}; /* Cancel a running acquisition */ static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct local_info_t *local = (struct local_info_t *)s->private; + struct daqp_private *devpriv = dev->private; - if (local->stop) + if (devpriv->stop) return -EIO; - outb(DAQP_COMMAND_STOP, dev->iobase + DAQP_COMMAND); /* flush any linguring data in FIFO - superfluous here */ /* outb(DAQP_COMMAND_RSTF, dev->iobase+DAQP_COMMAND); */ - local->interrupt_mode = semaphore; + devpriv->interrupt_mode = semaphore; return 0; } /* Interrupt handler * - * Operates in one of two modes. If local->interrupt_mode is - * 'semaphore', just signal the local->eos completion and return + * Operates in one of two modes. If devpriv->interrupt_mode is + * 'semaphore', just signal the devpriv->eos completion and return * (one-shot mode). Otherwise (continuous mode), read data in from * the card, transfer it to the buffer provided by the higher-level * comedi kernel module, and signal various comedi callback routines, @@ -250,48 +190,21 @@ static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) */ static enum irqreturn daqp_interrupt(int irq, void *dev_id) { - struct local_info_t *local = (struct local_info_t *)dev_id; - struct comedi_device *dev; - struct comedi_subdevice *s; + struct comedi_device *dev = dev_id; + struct daqp_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; int loop_limit = 10000; int status; - if (local == NULL) { - pr_warn("irq %d for unknown device.\n", irq); + if (!dev->attached) return IRQ_NONE; - } - - dev = local->dev; - if (dev == NULL) { - pr_warn("NULL comedi_device.\n"); - return IRQ_NONE; - } - - if (!dev->attached) { - pr_warn("struct comedi_device not yet attached.\n"); - return IRQ_NONE; - } - - s = local->s; - if (s == NULL) { - pr_warn("NULL comedi_subdevice.\n"); - return IRQ_NONE; - } - - if ((struct local_info_t *)s->private != local) { - pr_warn("invalid comedi_subdevice.\n"); - return IRQ_NONE; - } - - switch (local->interrupt_mode) { + switch (devpriv->interrupt_mode) { case semaphore: - - complete(&local->eos); + complete(&devpriv->eos); break; case buffer: - while (!((status = inb(dev->iobase + DAQP_STATUS)) & DAQP_STATUS_FIFO_EMPTY)) { @@ -315,9 +228,9 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) * and stop conversion if zero */ - if (local->count > 0) { - local->count--; - if (local->count == 0) { + if (devpriv->count > 0) { + devpriv->count--; + if (devpriv->count == 0) { daqp_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; break; @@ -342,21 +255,41 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static void daqp_ai_set_one_scanlist_entry(struct comedi_device *dev, + unsigned int chanspec, + int start) +{ + unsigned int chan = CR_CHAN(chanspec); + unsigned int range = CR_RANGE(chanspec); + unsigned int aref = CR_AREF(chanspec); + unsigned int val; + + val = DAQP_SCANLIST_CHANNEL(chan) | DAQP_SCANLIST_GAIN(range); + + if (aref == AREF_DIFF) + val |= DAQP_SCANLIST_DIFFERENTIAL; + + if (start) + val |= DAQP_SCANLIST_START; + + outb(val & 0xff, dev->iobase + DAQP_SCANLIST); + outb((val >> 8) & 0xff, dev->iobase + DAQP_SCANLIST); +} + /* One-shot analog data acquisition routine */ static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct local_info_t *local = (struct local_info_t *)s->private; + struct daqp_private *devpriv = dev->private; int i; int v; int counter = 10000; - if (local->stop) + if (devpriv->stop) return -EIO; - /* Stop any running conversion */ daqp_ai_cancel(dev, s); @@ -366,18 +299,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND); /* Program one scan list entry */ - - v = DAQP_SCANLIST_CHANNEL(CR_CHAN(insn->chanspec)) - | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec)); - - if (CR_AREF(insn->chanspec) == AREF_DIFF) - v |= DAQP_SCANLIST_DIFFERENTIAL; - - - v |= DAQP_SCANLIST_START; - - outb(v & 0xff, dev->iobase + DAQP_SCANLIST); - outb(v >> 8, dev->iobase + DAQP_SCANLIST); + daqp_ai_set_one_scanlist_entry(dev, insn->chanspec, 1); /* Reset data FIFO (see page 28 of DAQP User's Manual) */ @@ -403,10 +325,8 @@ static int daqp_ai_insn_read(struct comedi_device *dev, return -1; } - init_completion(&local->eos); - local->interrupt_mode = semaphore; - local->dev = dev; - local->s = s; + init_completion(&devpriv->eos); + devpriv->interrupt_mode = semaphore; for (i = 0; i < insn->n; i++) { @@ -416,7 +336,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, /* Wait for interrupt service routine to unblock completion */ /* Maybe could use a timeout here, but it's interruptible */ - if (wait_for_completion_interruptible(&local->eos)) + if (wait_for_completion_interruptible(&devpriv->eos)) return -EINTR; data[i] = inb(dev->iobase + DAQP_FIFO); @@ -541,7 +461,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct local_info_t *local = (struct local_info_t *)s->private; + struct daqp_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; int counter; int scanlist_start_on_every_entry; @@ -550,10 +470,9 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int i; int v; - if (local->stop) + if (devpriv->stop) return -EIO; - /* Stop any running conversion */ daqp_ai_cancel(dev, s); @@ -592,24 +511,10 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* Program scan list */ - for (i = 0; i < cmd->chanlist_len; i++) { + int start = (i == 0 || scanlist_start_on_every_entry); - int chanspec = cmd->chanlist[i]; - - /* Program one scan list entry */ - - v = DAQP_SCANLIST_CHANNEL(CR_CHAN(chanspec)) - | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec)); - - if (CR_AREF(chanspec) == AREF_DIFF) - v |= DAQP_SCANLIST_DIFFERENTIAL; - - if (i == 0 || scanlist_start_on_every_entry) - v |= DAQP_SCANLIST_START; - - outb(v & 0xff, dev->iobase + DAQP_SCANLIST); - outb(v >> 8, dev->iobase + DAQP_SCANLIST); + daqp_ai_set_one_scanlist_entry(dev, cmd->chanlist[i], start); } /* Now it's time to program the FIFO threshold, basically the @@ -675,16 +580,16 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* Save away the number of conversions we should perform, and * compute the FIFO threshold (in bytes, not samples - that's - * why we multiple local->count by 2 = sizeof(sample)) + * why we multiple devpriv->count by 2 = sizeof(sample)) */ if (cmd->stop_src == TRIG_COUNT) { - local->count = cmd->stop_arg * cmd->scan_end_arg; - threshold = 2 * local->count; + devpriv->count = cmd->stop_arg * cmd->scan_end_arg; + threshold = 2 * devpriv->count; while (threshold > DAQP_FIFO_SIZE * 3 / 4) threshold /= 2; } else { - local->count = -1; + devpriv->count = -1; threshold = DAQP_FIFO_SIZE / 2; } @@ -726,9 +631,7 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -1; } - local->interrupt_mode = buffer; - local->dev = dev; - local->s = s; + devpriv->interrupt_mode = buffer; /* Start conversion */ outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA, @@ -737,341 +640,193 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -/* Single-shot analog output routine */ - static int daqp_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct local_info_t *local = (struct local_info_t *)s->private; - int d; - unsigned int chan; + struct daqp_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val; + int i; - if (local->stop) + if (devpriv->stop) return -EIO; - chan = CR_CHAN(insn->chanspec); - d = data[0]; - d &= 0x0fff; - d ^= 0x0800; /* Flip the sign */ - d |= chan << 12; - /* Make sure D/A update mode is direct update */ outb(0, dev->iobase + DAQP_AUX); - outw(d, dev->iobase + DAQP_DA); + for (i = 0; i > insn->n; i++) { + val = data[0]; + val &= 0x0fff; + val ^= 0x0800; /* Flip the sign */ + val |= (chan << 12); - return 1; -} + outw(val, dev->iobase + DAQP_DA); + } -/* Digital input routine */ + return insn->n; +} -static int daqp_di_insn_read(struct comedi_device *dev, +static int daqp_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct local_info_t *local = (struct local_info_t *)s->private; + struct daqp_private *devpriv = dev->private; - if (local->stop) + if (devpriv->stop) return -EIO; data[0] = inb(dev->iobase + DAQP_DIGITAL_IO); - return 1; + return insn->n; } -/* Digital output routine */ - -static int daqp_do_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int daqp_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct local_info_t *local = (struct local_info_t *)s->private; + struct daqp_private *devpriv = dev->private; + unsigned int mask = data[0]; + unsigned int bits = data[1]; - if (local->stop) + if (devpriv->stop) return -EIO; - outw(data[0] & 0xf, dev->iobase + DAQP_DIGITAL_IO); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); - return 1; -} + outb(s->state, dev->iobase + DAQP_DIGITAL_IO); + } -/* daqp_attach is called via comedi_config to attach a comedi device - * to a /dev/comedi*. Note that this is different from daqp_cs_attach() - * which is called by the pcmcia subsystem to attach the PCMCIA card - * when it is inserted. - */ + data[1] = s->state; -static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it) + return insn->n; +} + +static int daqp_auto_attach(struct comedi_device *dev, + unsigned long context) { - int ret; - struct local_info_t *local = dev_table[it->options[0]]; + struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); + struct daqp_private *devpriv; struct comedi_subdevice *s; + int ret; - if (it->options[0] < 0 || it->options[0] >= MAX_DEV || !local) { - dev_err(dev->class_dev, "No such daqp device %d\n", - it->options[0]); - return -EIO; - } + dev->board_name = dev->driver->driver_name; - /* Typically brittle code that I don't completely understand, - * but "it works on my card". The intent is to pull the model - * number of the card out the PCMCIA CIS and stash it away as - * the COMEDI board_name. Looks like the third field in - * CISTPL_VERS_1 (offset 2) holds what we're looking for. If - * it doesn't work, who cares, just leave it as "DAQP". - */ + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) + return -ENOMEM; + dev->private = devpriv; - strcpy(local->board_name, "DAQP"); - dev->board_name = local->board_name; - if (local->link->prod_id[2]) { - if (strncmp(local->link->prod_id[2], "DAQP", 4) == 0) { - strncpy(local->board_name, local->link->prod_id[2], - sizeof(local->board_name)); - } - } + link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; + ret = comedi_pcmcia_enable(dev, NULL); + if (ret) + return ret; + dev->iobase = link->resource[0]->start; - dev->iobase = local->link->resource[0]->start; + link->priv = dev; + ret = pcmcia_request_irq(link, daqp_interrupt); + if (ret) + return ret; ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; - dev_info(dev->class_dev, "attaching daqp%d (io 0x%04lx)\n", - it->options[0], dev->iobase); - s = &dev->subdevices[0]; dev->read_subdev = s; - s->private = local; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ; - s->n_chan = 8; - s->len_chanlist = 2048; - s->maxdata = 0xffff; - s->range_table = &range_daqp_ai; - s->insn_read = daqp_ai_insn_read; - s->do_cmdtest = daqp_ai_cmdtest; - s->do_cmd = daqp_ai_cmd; - s->cancel = daqp_ai_cancel; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ; + s->n_chan = 8; + s->len_chanlist = 2048; + s->maxdata = 0xffff; + s->range_table = &range_daqp_ai; + s->insn_read = daqp_ai_insn_read; + s->do_cmdtest = daqp_ai_cmdtest; + s->do_cmd = daqp_ai_cmd; + s->cancel = daqp_ai_cancel; s = &dev->subdevices[1]; - dev->write_subdev = s; - s->private = local; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE; - s->n_chan = 2; - s->len_chanlist = 1; - s->maxdata = 0x0fff; - s->range_table = &range_daqp_ao; - s->insn_write = daqp_ao_insn_write; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 2; + s->maxdata = 0x0fff; + s->range_table = &range_bipolar5; + s->insn_write = daqp_ao_insn_write; s = &dev->subdevices[2]; - s->private = local; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 1; - s->len_chanlist = 1; - s->insn_read = daqp_di_insn_read; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 1; + s->maxdata = 1; + s->insn_bits = daqp_di_insn_bits; s = &dev->subdevices[3]; - s->private = local; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; - s->n_chan = 1; - s->len_chanlist = 1; - s->insn_write = daqp_do_insn_write; - - return 1; -} - -static void daqp_detach(struct comedi_device *dev) -{ - /* Nothing to cleanup */ -} - -/*==================================================================== - - PCMCIA interface code - - The rest of the code in this file is based on dummy_cs.c v1.24 - from the Linux pcmcia_cs distribution v3.1.8 and is subject - to the following license agreement. - - The remaining contents of this file are subject to the Mozilla Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The initial developer of the original code is David A. Hinds - <dhinds@pcmcia.sourceforge.org>. Portions created by David A. Hinds - are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - - Alternatively, the contents of this file may be used under the - terms of the GNU Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the - above. If you wish to allow the use of your version of this file - only under the terms of the GPL and not to allow others to use - your version of this file under the MPL, indicate your decision - by deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the MPL or the GPL. - -======================================================================*/ - -static void daqp_cs_config(struct pcmcia_device *link); -static void daqp_cs_release(struct pcmcia_device *link); -static int daqp_cs_suspend(struct pcmcia_device *p_dev); -static int daqp_cs_resume(struct pcmcia_device *p_dev); - -static int daqp_cs_attach(struct pcmcia_device *); -static void daqp_cs_detach(struct pcmcia_device *); - -static int daqp_cs_attach(struct pcmcia_device *link) -{ - struct local_info_t *local; - int i; - - dev_dbg(&link->dev, "daqp_cs_attach()\n"); - - for (i = 0; i < MAX_DEV; i++) - if (dev_table[i] == NULL) - break; - if (i == MAX_DEV) { - dev_notice(&link->dev, "no devices available\n"); - return -ENODEV; - } - - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL); - if (!local) - return -ENOMEM; - - local->table_index = i; - dev_table[i] = local; - local->link = link; - link->priv = local; - - daqp_cs_config(link); + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 1; + s->maxdata = 1; + s->insn_bits = daqp_do_insn_bits; return 0; -} /* daqp_cs_attach */ - -static void daqp_cs_detach(struct pcmcia_device *link) -{ - struct local_info_t *dev = link->priv; - - dev->stop = 1; - daqp_cs_release(link); - - /* Unlink device structure, and free it */ - dev_table[dev->table_index] = NULL; - kfree(dev); - } -static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) -{ - if (p_dev->config_index == 0) - return -EINVAL; - - return pcmcia_request_io(p_dev); -} - -static void daqp_cs_config(struct pcmcia_device *link) -{ - int ret; - - dev_dbg(&link->dev, "daqp_cs_config\n"); - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL); - if (ret) { - dev_warn(&link->dev, "no configuration found\n"); - goto failed; - } - - ret = pcmcia_request_irq(link, daqp_interrupt); - if (ret) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - return; - -failed: - daqp_cs_release(link); - -} /* daqp_cs_config */ - -static void daqp_cs_release(struct pcmcia_device *link) -{ - dev_dbg(&link->dev, "daqp_cs_release\n"); - - pcmcia_disable_device(link); -} /* daqp_cs_release */ +static struct comedi_driver driver_daqp = { + .driver_name = "quatech_daqp_cs", + .module = THIS_MODULE, + .auto_attach = daqp_auto_attach, + .detach = comedi_pcmcia_disable, +}; static int daqp_cs_suspend(struct pcmcia_device *link) { - struct local_info_t *local = link->priv; + struct comedi_device *dev = link->priv; + struct daqp_private *devpriv = dev ? dev->private : NULL; /* Mark the device as stopped, to block IO until later */ - local->stop = 1; + if (devpriv) + devpriv->stop = 1; + return 0; } static int daqp_cs_resume(struct pcmcia_device *link) { - struct local_info_t *local = link->priv; + struct comedi_device *dev = link->priv; + struct daqp_private *devpriv = dev ? dev->private : NULL; - local->stop = 0; + if (devpriv) + devpriv->stop = 0; return 0; } -/*====================================================================*/ - -#ifdef MODULE +static int daqp_cs_attach(struct pcmcia_device *link) +{ + return comedi_pcmcia_auto_config(link, &driver_daqp); +} static const struct pcmcia_device_id daqp_cs_id_table[] = { PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027), PCMCIA_DEVICE_NULL }; - MODULE_DEVICE_TABLE(pcmcia, daqp_cs_id_table); -MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>"); -MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards"); -MODULE_LICENSE("GPL"); static struct pcmcia_driver daqp_cs_driver = { - .probe = daqp_cs_attach, - .remove = daqp_cs_detach, - .suspend = daqp_cs_suspend, - .resume = daqp_cs_resume, - .id_table = daqp_cs_id_table, - .owner = THIS_MODULE, - .name = "quatech_daqp_cs", + .name = "quatech_daqp_cs", + .owner = THIS_MODULE, + .id_table = daqp_cs_id_table, + .probe = daqp_cs_attach, + .remove = comedi_pcmcia_auto_unconfig, + .suspend = daqp_cs_suspend, + .resume = daqp_cs_resume, }; +module_comedi_pcmcia_driver(driver_daqp, daqp_cs_driver); -int __init init_module(void) -{ - pcmcia_register_driver(&daqp_cs_driver); - comedi_driver_register(&driver_daqp); - return 0; -} - -void __exit cleanup_module(void) -{ - comedi_driver_unregister(&driver_daqp); - pcmcia_unregister_driver(&daqp_cs_driver); -} - -#endif +MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards"); +MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 8d7c948..6a5c914 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -101,8 +101,9 @@ Configuration options: */ -#include <linux/interrupt.h> +#include <linux/pci.h> #include <linux/delay.h> +#include <linux/interrupt.h> #include "../comedidev.h" @@ -1420,11 +1421,6 @@ static int rtd520_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &rtd520_driver); } -static void rtd520_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = { { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x7520) }, { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x4520) }, @@ -1436,7 +1432,7 @@ static struct pci_driver rtd520_pci_driver = { .name = "rtd520", .id_table = rtd520_pci_table, .probe = rtd520_pci_probe, - .remove = rtd520_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(rtd520_driver, rtd520_pci_driver); diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 6dc1d28..81a1fe6 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -64,6 +64,7 @@ INSN_CONFIG instructions: comedi_do_insn(cf,&insn); //executing configuration */ +#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/types.h> @@ -2836,11 +2837,6 @@ static int s626_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &s626_driver); } -static void s626_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - /* * For devices with vendor:device id == 0x1131:0x7146 you must specify * also subvendor:subdevice ids, because otherwise it will conflict with @@ -2857,7 +2853,7 @@ static struct pci_driver s626_pci_driver = { .name = "s626", .id_table = s626_pci_table, .probe = s626_pci_probe, - .remove = s626_pci_remove, + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(s626_driver, s626_pci_driver); diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index e2d7970..cb83f6a 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -72,9 +72,9 @@ Configuration Options: * options that are used with comedi_config. */ -#include "../comedidev.h" +#include <linux/pci.h> -#include <linux/pci.h> /* for PCI devices */ +#include "../comedidev.h" #include "comedi_fc.h" @@ -707,15 +707,11 @@ static int skel_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &skel_driver); } -static void skel_pci_remove(struct pci_dev *dev) -{ - comedi_pci_auto_unconfig(dev); -} - static struct pci_driver skel_pci_driver = { + .name = "dummy", .id_table = skel_pci_table, .probe = &skel_pci_probe, - .remove = &skel_pci_remove + .remove = comedi_pci_auto_unconfig, }; module_comedi_pci_driver(skel_driver, skel_pci_driver); #else diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index c9ded93..74b974b 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -380,12 +380,8 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, } usp = kzalloc(sizeof(*usp), GFP_KERNEL); - - if (usp == NULL) { - dev_err(subdev->class_dev, - "comedi%d: error! --> out of memory!\n", minor); + if (usp == NULL) return -1; - } usp->usp_iobase = subdev_iobase; dev_info(subdev->class_dev, "comedi%d: |", minor); diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 17b45eb..1a0062a 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2388,7 +2388,7 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw, "Could not upload firmware (err=%d)\n", ret); goto out; } - comedi_usb_auto_config(uinterf, &usbdux_driver); + comedi_usb_auto_config(uinterf, &usbdux_driver, 0); out: release_firmware(fw); } @@ -2445,8 +2445,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* create space for the commands of the DA converter */ usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); if (!usbduxsub[index].dac_commands) { - dev_err(dev, "comedi_: usbdux: " - "error alloc space for dac commands\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2454,8 +2452,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* create space for the commands going to the usb device */ usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); if (!usbduxsub[index].dux_commands) { - dev_err(dev, "comedi_: usbdux: " - "error alloc space for dux commands\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2463,8 +2459,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* create space for the in buffer and set it to zero */ usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!(usbduxsub[index].inBuffer)) { - dev_err(dev, "comedi_: usbdux: " - "could not alloc space for inBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2472,8 +2466,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* create space of the instruction buffer */ usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); if (!(usbduxsub[index].insnBuffer)) { - dev_err(dev, "comedi_: usbdux: " - "could not alloc space for insnBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2481,8 +2473,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* create space for the outbuffer */ usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!(usbduxsub[index].outBuffer)) { - dev_err(dev, "comedi_: usbdux: " - "could not alloc space for outBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2504,10 +2494,9 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL; usbduxsub[index].urbIn = - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers, - GFP_KERNEL); + kcalloc(usbduxsub[index].numOfInBuffers, sizeof(struct urb *), + GFP_KERNEL); if (!(usbduxsub[index].urbIn)) { - dev_err(dev, "comedi_: usbdux: Could not alloc. urbIn array\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2532,8 +2521,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbIn[i]->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) { - dev_err(dev, "comedi_: usbdux%d: " - "could not alloc. transb.\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2552,11 +2539,9 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL; usbduxsub[index].urbOut = - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers, - GFP_KERNEL); + kcalloc(usbduxsub[index].numOfOutBuffers, sizeof(struct urb *), + GFP_KERNEL); if (!(usbduxsub[index].urbOut)) { - dev_err(dev, "comedi_: usbdux: " - "Could not alloc. urbOut array\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2581,8 +2566,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbOut[i]->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) { - dev_err(dev, "comedi_: usbdux%d: " - "could not alloc. transb.\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2617,8 +2600,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbPwm->transfer_buffer = kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL); if (!(usbduxsub[index].urbPwm->transfer_buffer)) { - dev_err(dev, "comedi_: usbdux%d: " - "could not alloc. transb. for pwm\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 4e19f61..4bf5dd0 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -1490,7 +1490,7 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware goto out; } - comedi_usb_auto_config(uinterf, &usbduxfast_driver); + comedi_usb_auto_config(uinterf, &usbduxfast_driver, 0); out: release_firmware(fw); } @@ -1556,8 +1556,6 @@ static int usbduxfast_usb_probe(struct usb_interface *uinterf, usbduxfastsub[index].dux_commands = kmalloc(SIZEOFDUXBUFFER, GFP_KERNEL); if (!usbduxfastsub[index].dux_commands) { - dev_err(&uinterf->dev, - "error alloc space for dac commands\n"); tidy_up(&(usbduxfastsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -1565,8 +1563,6 @@ static int usbduxfast_usb_probe(struct usb_interface *uinterf, /* create space of the instruction buffer */ usbduxfastsub[index].insnBuffer = kmalloc(SIZEINSNBUF, GFP_KERNEL); if (!usbduxfastsub[index].insnBuffer) { - dev_err(&uinterf->dev, - "could not alloc space for insnBuffer\n"); tidy_up(&(usbduxfastsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -1592,8 +1588,6 @@ static int usbduxfast_usb_probe(struct usb_interface *uinterf, } usbduxfastsub[index].transfer_buffer = kmalloc(SIZEINBUF, GFP_KERNEL); if (!usbduxfastsub[index].transfer_buffer) { - dev_err(&uinterf->dev, - "usbduxfast%d: could not alloc. transb.\n", index); tidy_up(&(usbduxfastsub[index])); up(&start_stop_sem); return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index cdd279b..d066351 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -2374,7 +2374,7 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw, "Could not upload firmware (err=%d)\n", ret); goto out; } - comedi_usb_auto_config(uinterf, &usbduxsigma_driver); + comedi_usb_auto_config(uinterf, &usbduxsigma_driver, 0); out: release_firmware(fw); } @@ -2431,8 +2431,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, /* create space for the commands of the DA converter */ usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); if (!usbduxsub[index].dac_commands) { - dev_err(dev, "comedi_: usbduxsigma: " - "error alloc space for dac commands\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2440,8 +2438,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, /* create space for the commands going to the usb device */ usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); if (!usbduxsub[index].dux_commands) { - dev_err(dev, "comedi_: usbduxsigma: " - "error alloc space for dux commands\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2449,8 +2445,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, /* create space for the in buffer and set it to zero */ usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!(usbduxsub[index].inBuffer)) { - dev_err(dev, "comedi_: usbduxsigma: " - "could not alloc space for inBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2458,8 +2452,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, /* create space of the instruction buffer */ usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); if (!(usbduxsub[index].insnBuffer)) { - dev_err(dev, "comedi_: usbduxsigma: " - "could not alloc space for insnBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2467,8 +2459,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, /* create space for the outbuffer */ usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!(usbduxsub[index].outBuffer)) { - dev_err(dev, "comedi_: usbduxsigma: " - "could not alloc space for outBuffer\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2489,12 +2479,10 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, else usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL; - usbduxsub[index].urbIn = - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers, - GFP_KERNEL); + usbduxsub[index].urbIn = kcalloc(usbduxsub[index].numOfInBuffers, + sizeof(struct urb *), + GFP_KERNEL); if (!(usbduxsub[index].urbIn)) { - dev_err(dev, "comedi_: usbduxsigma: " - "Could not alloc. urbIn array\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2519,8 +2507,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbIn[i]->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) { - dev_err(dev, "comedi_: usbduxsigma%d: " - "could not alloc. transb.\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2539,12 +2525,9 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, else usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL; - usbduxsub[index].urbOut = - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers, - GFP_KERNEL); + usbduxsub[index].urbOut = kcalloc(usbduxsub[index].numOfOutBuffers, + sizeof(struct urb *), GFP_KERNEL); if (!(usbduxsub[index].urbOut)) { - dev_err(dev, "comedi_: usbduxsigma: " - "Could not alloc. urbOut array\n"); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2569,8 +2552,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbOut[i]->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) { - dev_err(dev, "comedi_: usbduxsigma%d: " - "could not alloc. transb.\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2606,8 +2587,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *uinterf, usbduxsub[index].urbPwm->transfer_buffer = kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL); if (!(usbduxsub[index].urbPwm->transfer_buffer)) { - dev_err(dev, "comedi_: usbduxsigma%d: " - "could not alloc. transb. for pwm\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index 609dc69..2be5087 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -38,19 +38,6 @@ Supports: - counter - pwm */ -/* -Changelog: - -0.8.81 -3- code completely rewritten (adjust driver logic) -0.8.81 -2- full support for K8061 -0.8.81 -1- fix some mistaken among others the number of - supported boards and I/O handling - -0.7.76 -4- renamed to vmk80xx -0.7.76 -3- detect K8061 (only theoretically supported) -0.7.76 -2- code completely rewritten (adjust driver logic) -0.7.76 -1- support for digital and counter subdevice -*/ #include <linux/kernel.h> #include <linux/module.h> @@ -113,30 +100,9 @@ enum { #define VMK8061_CMD_RD_AO 0x0f #define VMK8061_CMD_RD_PWM 0x10 -#define VMK80XX_MAX_BOARDS COMEDI_NUM_BOARD_MINORS - -#define TRANS_OUT_BUSY 1 -#define TRANS_IN_BUSY 2 -#define TRANS_IN_RUNNING 3 - #define IC3_VERSION (1 << 0) #define IC6_VERSION (1 << 1) -#define URB_RCV_FLAG (1 << 0) -#define URB_SND_FLAG (1 << 1) - -#ifdef CONFIG_COMEDI_DEBUG -static int dbgcm = 1; -#else -static int dbgcm; -#endif - -#define dbgcm(fmt, arg...) \ -do { \ - if (dbgcm) \ - printk(KERN_DEBUG fmt, ##arg); \ -} while (0) - enum vmk80xx_model { VMK8055_MODEL, VMK8061_MODEL @@ -147,130 +113,73 @@ struct firmware_version { unsigned char ic6_vers[32]; /* CPU */ }; -static const struct comedi_lrange vmk8055_range = { - 1, {UNI_RANGE(5)} -}; - static const struct comedi_lrange vmk8061_range = { - 2, {UNI_RANGE(5), UNI_RANGE(10)} + 2, { + UNI_RANGE(5), + UNI_RANGE(10) + } }; struct vmk80xx_board { const char *name; enum vmk80xx_model model; const struct comedi_lrange *range; - __u8 ai_chans; - __le16 ai_bits; - __u8 ao_chans; - __le16 ao_bits; - __u8 di_chans; - __le16 di_bits; - __u8 do_chans; - __le16 do_bits; - __u8 cnt_chans; - __le16 cnt_bits; - __u8 pwm_chans; - __le16 pwm_bits; + int ai_nchans; + unsigned int ai_maxdata; + int ao_nchans; + int di_nchans; + unsigned int cnt_maxdata; + int pwm_nchans; + unsigned int pwm_maxdata; }; -enum { - VMK80XX_SUBD_AI, - VMK80XX_SUBD_AO, - VMK80XX_SUBD_DI, - VMK80XX_SUBD_DO, - VMK80XX_SUBD_CNT, - VMK80XX_SUBD_PWM, +static const struct vmk80xx_board vmk80xx_boardinfo[] = { + [DEVICE_VMK8055] = { + .name = "K8055 (VM110)", + .model = VMK8055_MODEL, + .range = &range_unipolar5, + .ai_nchans = 2, + .ai_maxdata = 0x00ff, + .ao_nchans = 2, + .di_nchans = 6, + .cnt_maxdata = 0xffff, + }, + [DEVICE_VMK8061] = { + .name = "K8061 (VM140)", + .model = VMK8061_MODEL, + .range = &vmk8061_range, + .ai_nchans = 8, + .ai_maxdata = 0x03ff, + .ao_nchans = 8, + .di_nchans = 8, + .cnt_maxdata = 0, /* unknown, device is not writeable */ + .pwm_nchans = 1, + .pwm_maxdata = 0x03ff, + }, }; -struct vmk80xx_usb { - struct usb_device *udev; +struct vmk80xx_private { + struct usb_device *usb; struct usb_interface *intf; struct usb_endpoint_descriptor *ep_rx; struct usb_endpoint_descriptor *ep_tx; - struct usb_anchor rx_anchor; - struct usb_anchor tx_anchor; - struct vmk80xx_board board; struct firmware_version fw; struct semaphore limit_sem; - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; unsigned char *usb_rx_buf; unsigned char *usb_tx_buf; - unsigned long flags; - int probed; - int attached; - int count; + enum vmk80xx_model model; }; -static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS]; - -static DEFINE_MUTEX(glb_mutex); - -static void vmk80xx_tx_callback(struct urb *urb) -{ - struct vmk80xx_usb *dev = urb->context; - int stat = urb->status; - - if (stat && !(stat == -ENOENT - || stat == -ECONNRESET || stat == -ESHUTDOWN)) - dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n", - __func__, stat); - - if (!test_bit(TRANS_OUT_BUSY, &dev->flags)) - return; - - clear_bit(TRANS_OUT_BUSY, &dev->flags); - - wake_up_interruptible(&dev->write_wait); -} - -static void vmk80xx_rx_callback(struct urb *urb) -{ - struct vmk80xx_usb *dev = urb->context; - int stat = urb->status; - - switch (stat) { - case 0: - break; - case -ENOENT: - case -ECONNRESET: - case -ESHUTDOWN: - break; - default: - dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n", - __func__, stat); - goto resubmit; - } - - goto exit; -resubmit: - if (test_bit(TRANS_IN_RUNNING, &dev->flags) && dev->intf) { - usb_anchor_urb(urb, &dev->rx_anchor); - - if (!usb_submit_urb(urb, GFP_KERNEL)) - goto exit; - - dev_err(&urb->dev->dev, - "comedi#: vmk80xx: %s - submit urb failed\n", - __func__); - - usb_unanchor_urb(urb); - } -exit: - clear_bit(TRANS_IN_BUSY, &dev->flags); - - wake_up_interruptible(&dev->read_wait); -} - -static int vmk80xx_check_data_link(struct vmk80xx_usb *dev) +static int vmk80xx_check_data_link(struct vmk80xx_private *devpriv) { + struct usb_device *usb = devpriv->usb; unsigned int tx_pipe; unsigned int rx_pipe; unsigned char tx[1]; unsigned char rx[2]; - tx_pipe = usb_sndbulkpipe(dev->udev, 0x01); - rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81); + tx_pipe = usb_sndbulkpipe(usb, 0x01); + rx_pipe = usb_rcvbulkpipe(usb, 0x81); tx[0] = VMK8061_CMD_RD_PWR_STAT; @@ -279,22 +188,23 @@ static int vmk80xx_check_data_link(struct vmk80xx_usb *dev) * running and the data link between IC3 and * IC6 is working properly */ - usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, dev->ep_tx->bInterval); - usb_bulk_msg(dev->udev, rx_pipe, rx, 2, NULL, HZ * 10); + usb_bulk_msg(usb, tx_pipe, tx, 1, NULL, devpriv->ep_tx->bInterval); + usb_bulk_msg(usb, rx_pipe, rx, 2, NULL, HZ * 10); return (int)rx[1]; } -static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag) +static void vmk80xx_read_eeprom(struct vmk80xx_private *devpriv, int flag) { + struct usb_device *usb = devpriv->usb; unsigned int tx_pipe; unsigned int rx_pipe; unsigned char tx[1]; unsigned char rx[64]; int cnt; - tx_pipe = usb_sndbulkpipe(dev->udev, 0x01); - rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81); + tx_pipe = usb_sndbulkpipe(usb, 0x01); + rx_pipe = usb_rcvbulkpipe(usb, 0x81); tx[0] = VMK8061_CMD_RD_VERSION; @@ -302,243 +212,116 @@ static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag) * Read the firmware version info of IC3 and * IC6 from the internal EEPROM of the IC */ - usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, dev->ep_tx->bInterval); - usb_bulk_msg(dev->udev, rx_pipe, rx, 64, &cnt, HZ * 10); + usb_bulk_msg(usb, tx_pipe, tx, 1, NULL, devpriv->ep_tx->bInterval); + usb_bulk_msg(usb, rx_pipe, rx, 64, &cnt, HZ * 10); rx[cnt] = '\0'; if (flag & IC3_VERSION) - strncpy(dev->fw.ic3_vers, rx + 1, 24); + strncpy(devpriv->fw.ic3_vers, rx + 1, 24); else /* IC6_VERSION */ - strncpy(dev->fw.ic6_vers, rx + 25, 24); + strncpy(devpriv->fw.ic6_vers, rx + 25, 24); } -static int vmk80xx_reset_device(struct vmk80xx_usb *dev) -{ - struct urb *urb; - unsigned int tx_pipe; - int ival; - size_t size; - - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) - return -ENOMEM; - - tx_pipe = usb_sndintpipe(dev->udev, 0x01); - - ival = dev->ep_tx->bInterval; - size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); - - dev->usb_tx_buf[0] = VMK8055_CMD_RST; - dev->usb_tx_buf[1] = 0x00; - dev->usb_tx_buf[2] = 0x00; - dev->usb_tx_buf[3] = 0x00; - dev->usb_tx_buf[4] = 0x00; - dev->usb_tx_buf[5] = 0x00; - dev->usb_tx_buf[6] = 0x00; - dev->usb_tx_buf[7] = 0x00; - - usb_fill_int_urb(urb, dev->udev, tx_pipe, dev->usb_tx_buf, - size, vmk80xx_tx_callback, dev, ival); - - usb_anchor_urb(urb, &dev->tx_anchor); - - return usb_submit_urb(urb, GFP_KERNEL); -} - -static void vmk80xx_build_int_urb(struct urb *urb, int flag) -{ - struct vmk80xx_usb *dev = urb->context; - __u8 rx_addr; - __u8 tx_addr; - unsigned int pipe; - unsigned char *buf; - size_t size; - void (*callback) (struct urb *); - int ival; - - if (flag & URB_RCV_FLAG) { - rx_addr = dev->ep_rx->bEndpointAddress; - pipe = usb_rcvintpipe(dev->udev, rx_addr); - buf = dev->usb_rx_buf; - size = le16_to_cpu(dev->ep_rx->wMaxPacketSize); - callback = vmk80xx_rx_callback; - ival = dev->ep_rx->bInterval; - } else { /* URB_SND_FLAG */ - tx_addr = dev->ep_tx->bEndpointAddress; - pipe = usb_sndintpipe(dev->udev, tx_addr); - buf = dev->usb_tx_buf; - size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); - callback = vmk80xx_tx_callback; - ival = dev->ep_tx->bInterval; - } - - usb_fill_int_urb(urb, dev->udev, pipe, buf, size, callback, dev, ival); -} - -static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev) +static void vmk80xx_do_bulk_msg(struct vmk80xx_private *devpriv) { + struct usb_device *usb = devpriv->usb; __u8 tx_addr; __u8 rx_addr; unsigned int tx_pipe; unsigned int rx_pipe; size_t size; - set_bit(TRANS_IN_BUSY, &dev->flags); - set_bit(TRANS_OUT_BUSY, &dev->flags); - - tx_addr = dev->ep_tx->bEndpointAddress; - rx_addr = dev->ep_rx->bEndpointAddress; - tx_pipe = usb_sndbulkpipe(dev->udev, tx_addr); - rx_pipe = usb_rcvbulkpipe(dev->udev, rx_addr); + tx_addr = devpriv->ep_tx->bEndpointAddress; + rx_addr = devpriv->ep_rx->bEndpointAddress; + tx_pipe = usb_sndbulkpipe(usb, tx_addr); + rx_pipe = usb_rcvbulkpipe(usb, rx_addr); /* * The max packet size attributes of the K8061 * input/output endpoints are identical */ - size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); - - usb_bulk_msg(dev->udev, tx_pipe, dev->usb_tx_buf, - size, NULL, dev->ep_tx->bInterval); - usb_bulk_msg(dev->udev, rx_pipe, dev->usb_rx_buf, size, NULL, HZ * 10); + size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize); - clear_bit(TRANS_OUT_BUSY, &dev->flags); - clear_bit(TRANS_IN_BUSY, &dev->flags); + usb_bulk_msg(usb, tx_pipe, devpriv->usb_tx_buf, + size, NULL, devpriv->ep_tx->bInterval); + usb_bulk_msg(usb, rx_pipe, devpriv->usb_rx_buf, size, NULL, HZ * 10); } -static int vmk80xx_read_packet(struct vmk80xx_usb *dev) +static int vmk80xx_read_packet(struct vmk80xx_private *devpriv) { - struct urb *urb; - int retval; + struct usb_device *usb; + struct usb_endpoint_descriptor *ep; + unsigned int pipe; - if (!dev->intf) + if (!devpriv->intf) return -ENODEV; - /* Only useful for interrupt transfers */ - if (test_bit(TRANS_IN_BUSY, &dev->flags)) - if (wait_event_interruptible(dev->read_wait, - !test_bit(TRANS_IN_BUSY, - &dev->flags))) - return -ERESTART; - - if (dev->board.model == VMK8061_MODEL) { - vmk80xx_do_bulk_msg(dev); - + if (devpriv->model == VMK8061_MODEL) { + vmk80xx_do_bulk_msg(devpriv); return 0; } - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) - return -ENOMEM; - - urb->context = dev; - vmk80xx_build_int_urb(urb, URB_RCV_FLAG); - - set_bit(TRANS_IN_RUNNING, &dev->flags); - set_bit(TRANS_IN_BUSY, &dev->flags); - - usb_anchor_urb(urb, &dev->rx_anchor); - - retval = usb_submit_urb(urb, GFP_KERNEL); - if (!retval) - goto exit; - - clear_bit(TRANS_IN_RUNNING, &dev->flags); - usb_unanchor_urb(urb); - -exit: - usb_free_urb(urb); - - return retval; + usb = devpriv->usb; + ep = devpriv->ep_rx; + pipe = usb_rcvintpipe(usb, ep->bEndpointAddress); + return usb_interrupt_msg(usb, pipe, devpriv->usb_rx_buf, + le16_to_cpu(ep->wMaxPacketSize), NULL, + HZ * 10); } -static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd) +static int vmk80xx_write_packet(struct vmk80xx_private *devpriv, int cmd) { - struct urb *urb; - int retval; + struct usb_device *usb; + struct usb_endpoint_descriptor *ep; + unsigned int pipe; - if (!dev->intf) + if (!devpriv->intf) return -ENODEV; - if (test_bit(TRANS_OUT_BUSY, &dev->flags)) - if (wait_event_interruptible(dev->write_wait, - !test_bit(TRANS_OUT_BUSY, - &dev->flags))) - return -ERESTART; - - if (dev->board.model == VMK8061_MODEL) { - dev->usb_tx_buf[0] = cmd; - vmk80xx_do_bulk_msg(dev); + devpriv->usb_tx_buf[0] = cmd; + if (devpriv->model == VMK8061_MODEL) { + vmk80xx_do_bulk_msg(devpriv); return 0; } - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) - return -ENOMEM; - - urb->context = dev; - vmk80xx_build_int_urb(urb, URB_SND_FLAG); - - set_bit(TRANS_OUT_BUSY, &dev->flags); - - usb_anchor_urb(urb, &dev->tx_anchor); - - dev->usb_tx_buf[0] = cmd; - - retval = usb_submit_urb(urb, GFP_KERNEL); - if (!retval) - goto exit; - - clear_bit(TRANS_OUT_BUSY, &dev->flags); - usb_unanchor_urb(urb); - -exit: - usb_free_urb(urb); - - return retval; + usb = devpriv->usb; + ep = devpriv->ep_tx; + pipe = usb_sndintpipe(usb, ep->bEndpointAddress); + return usb_interrupt_msg(usb, pipe, devpriv->usb_tx_buf, + le16_to_cpu(ep->wMaxPacketSize), NULL, + HZ * 10); } -#define DIR_IN 1 -#define DIR_OUT 2 - -static int rudimentary_check(struct vmk80xx_usb *dev, int dir) +static int vmk80xx_reset_device(struct vmk80xx_private *devpriv) { - if (!dev) - return -EFAULT; - if (!dev->probed) - return -ENODEV; - if (!dev->attached) - return -ENODEV; - if (dir & DIR_IN) { - if (test_bit(TRANS_IN_BUSY, &dev->flags)) - return -EBUSY; - } - if (dir & DIR_OUT) { - if (test_bit(TRANS_OUT_BUSY, &dev->flags)) - return -EBUSY; - } + size_t size; + int retval; - return 0; + size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize); + memset(devpriv->usb_tx_buf, 0, size); + retval = vmk80xx_write_packet(devpriv, VMK8055_CMD_RST); + if (retval) + return retval; + /* set outputs to known state as we cannot read them */ + return vmk80xx_write_packet(devpriv, VMK8055_CMD_WRT_AD); } -static int vmk80xx_ai_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; int chan; int reg[2]; int n; - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); - switch (dev->board.model) { + switch (devpriv->model) { case VMK8055_MODEL: if (!chan) reg[0] = VMK8055_AI1_REG; @@ -549,48 +332,45 @@ static int vmk80xx_ai_rinsn(struct comedi_device *cdev, default: reg[0] = VMK8061_AI_REG1; reg[1] = VMK8061_AI_REG2; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_AI; - dev->usb_tx_buf[VMK8061_CH_REG] = chan; + devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_AI; + devpriv->usb_tx_buf[VMK8061_CH_REG] = chan; break; } for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) + if (vmk80xx_read_packet(devpriv)) break; - if (dev->board.model == VMK8055_MODEL) { - data[n] = dev->usb_rx_buf[reg[0]]; + if (devpriv->model == VMK8055_MODEL) { + data[n] = devpriv->usb_rx_buf[reg[0]]; continue; } /* VMK8061_MODEL */ - data[n] = dev->usb_rx_buf[reg[0]] + 256 * - dev->usb_rx_buf[reg[1]]; + data[n] = devpriv->usb_rx_buf[reg[0]] + 256 * + devpriv->usb_rx_buf[reg[1]]; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_ao_winsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; int chan; int cmd; int reg; int n; - n = rudimentary_check(dev, DIR_OUT); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); - switch (dev->board.model) { + switch (devpriv->model) { case VMK8055_MODEL: cmd = VMK8055_CMD_WRT_AD; if (!chan) @@ -601,82 +381,76 @@ static int vmk80xx_ao_winsn(struct comedi_device *cdev, default: /* NOTE: avoid compiler warnings */ cmd = VMK8061_CMD_SET_AO; reg = VMK8061_AO_REG; - dev->usb_tx_buf[VMK8061_CH_REG] = chan; + devpriv->usb_tx_buf[VMK8061_CH_REG] = chan; break; } for (n = 0; n < insn->n; n++) { - dev->usb_tx_buf[reg] = data[n]; + devpriv->usb_tx_buf[reg] = data[n]; - if (vmk80xx_write_packet(dev, cmd)) + if (vmk80xx_write_packet(devpriv, cmd)) break; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_ao_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_ao_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; int chan; int reg; int n; - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); reg = VMK8061_AO_REG - 1; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_AO; + devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_AO; for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) + if (vmk80xx_read_packet(devpriv)) break; - data[n] = dev->usb_rx_buf[reg + chan]; + data[n] = devpriv->usb_rx_buf[reg + chan]; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_di_bits(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; unsigned char *rx_buf; int reg; int retval; - retval = rudimentary_check(dev, DIR_IN); - if (retval) - return retval; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); - rx_buf = dev->usb_rx_buf; + rx_buf = devpriv->usb_rx_buf; - if (dev->board.model == VMK8061_MODEL) { + if (devpriv->model == VMK8061_MODEL) { reg = VMK8061_DI_REG; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI; + devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_DI; } else { reg = VMK8055_DI_REG; } - retval = vmk80xx_read_packet(dev); + retval = vmk80xx_read_packet(devpriv); if (!retval) { - if (dev->board.model == VMK8055_MODEL) + if (devpriv->model == VMK8055_MODEL) data[1] = (((rx_buf[reg] >> 4) & 0x03) | ((rx_buf[reg] << 2) & 0x04) | ((rx_buf[reg] >> 3) & 0x18)); @@ -686,185 +460,48 @@ static int vmk80xx_di_bits(struct comedi_device *cdev, retval = 2; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return retval; } -static int vmk80xx_di_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; - int chan; - unsigned char *rx_buf; - int reg; - int inp; - int n; - - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; - - down(&dev->limit_sem); - chan = CR_CHAN(insn->chanspec); - - rx_buf = dev->usb_rx_buf; - - if (dev->board.model == VMK8061_MODEL) { - reg = VMK8061_DI_REG; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI; - } else { - reg = VMK8055_DI_REG; - } - for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) - break; - - if (dev->board.model == VMK8055_MODEL) - inp = (((rx_buf[reg] >> 4) & 0x03) | - ((rx_buf[reg] << 2) & 0x04) | - ((rx_buf[reg] >> 3) & 0x18)); - else - inp = rx_buf[reg]; - - data[n] = (inp >> chan) & 1; - } - - up(&dev->limit_sem); - - return n; -} - -static int vmk80xx_do_winsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct vmk80xx_usb *dev = cdev->private; - int chan; - unsigned char *tx_buf; - int reg; - int cmd; - int n; - - n = rudimentary_check(dev, DIR_OUT); - if (n) - return n; - - down(&dev->limit_sem); - chan = CR_CHAN(insn->chanspec); - - tx_buf = dev->usb_tx_buf; - - for (n = 0; n < insn->n; n++) { - if (dev->board.model == VMK8055_MODEL) { - reg = VMK8055_DO_REG; - cmd = VMK8055_CMD_WRT_AD; - if (data[n] == 1) - tx_buf[reg] |= (1 << chan); - else - tx_buf[reg] ^= (1 << chan); - } else { /* VMK8061_MODEL */ - reg = VMK8061_DO_REG; - if (data[n] == 1) { - cmd = VMK8061_CMD_SET_DO; - tx_buf[reg] = 1 << chan; - } else { - cmd = VMK8061_CMD_CLR_DO; - tx_buf[reg] = 0xff - (1 << chan); - } - } - - if (vmk80xx_write_packet(dev, cmd)) - break; - } - - up(&dev->limit_sem); - - return n; -} - -static int vmk80xx_do_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct vmk80xx_usb *dev = cdev->private; - int chan; - int reg; - int n; - - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; - - down(&dev->limit_sem); - chan = CR_CHAN(insn->chanspec); - - reg = VMK8061_DO_REG; - - dev->usb_tx_buf[0] = VMK8061_CMD_RD_DO; - - for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) - break; - - data[n] = (dev->usb_rx_buf[reg] >> chan) & 1; - } - - up(&dev->limit_sem); - - return n; -} - -static int vmk80xx_do_bits(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; unsigned char *rx_buf, *tx_buf; - int dir, reg, cmd; + int reg, cmd; int retval; - dir = 0; - - if (data[0]) - dir |= DIR_OUT; - - if (dev->board.model == VMK8061_MODEL) - dir |= DIR_IN; - - retval = rudimentary_check(dev, dir); - if (retval) - return retval; + if (devpriv->model == VMK8061_MODEL) { + reg = VMK8061_DO_REG; + cmd = VMK8061_CMD_DO; + } else { /* VMK8055_MODEL */ + reg = VMK8055_DO_REG; + cmd = VMK8055_CMD_WRT_AD; + } - down(&dev->limit_sem); + down(&devpriv->limit_sem); - rx_buf = dev->usb_rx_buf; - tx_buf = dev->usb_tx_buf; + rx_buf = devpriv->usb_rx_buf; + tx_buf = devpriv->usb_tx_buf; if (data[0]) { - if (dev->board.model == VMK8055_MODEL) { - reg = VMK8055_DO_REG; - cmd = VMK8055_CMD_WRT_AD; - } else { /* VMK8061_MODEL */ - reg = VMK8061_DO_REG; - cmd = VMK8061_CMD_DO; - } - tx_buf[reg] &= ~data[0]; tx_buf[reg] |= (data[0] & data[1]); - retval = vmk80xx_write_packet(dev, cmd); + retval = vmk80xx_write_packet(devpriv, cmd); if (retval) goto out; } - if (dev->board.model == VMK8061_MODEL) { - reg = VMK8061_DO_REG; + if (devpriv->model == VMK8061_MODEL) { tx_buf[0] = VMK8061_CMD_RD_DO; - retval = vmk80xx_read_packet(dev); + retval = vmk80xx_read_packet(devpriv); if (!retval) { data[1] = rx_buf[reg]; @@ -876,28 +513,25 @@ static int vmk80xx_do_bits(struct comedi_device *cdev, } out: - up(&dev->limit_sem); + up(&devpriv->limit_sem); return retval; } -static int vmk80xx_cnt_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_cnt_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; int chan; int reg[2]; int n; - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); - switch (dev->board.model) { + switch (devpriv->model) { case VMK8055_MODEL: if (!chan) reg[0] = VMK8055_CNT1_REG; @@ -908,50 +542,47 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *cdev, default: reg[0] = VMK8061_CNT_REG; reg[1] = VMK8061_CNT_REG; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_CNT; + devpriv->usb_tx_buf[0] = VMK8061_CMD_RD_CNT; break; } for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) + if (vmk80xx_read_packet(devpriv)) break; - if (dev->board.model == VMK8055_MODEL) - data[n] = dev->usb_rx_buf[reg[0]]; + if (devpriv->model == VMK8055_MODEL) + data[n] = devpriv->usb_rx_buf[reg[0]]; else /* VMK8061_MODEL */ - data[n] = dev->usb_rx_buf[reg[0] * (chan + 1) + 1] - + 256 * dev->usb_rx_buf[reg[1] * 2 + 2]; + data[n] = devpriv->usb_rx_buf[reg[0] * (chan + 1) + 1] + + 256 * devpriv->usb_rx_buf[reg[1] * 2 + 2]; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_cnt_cinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_cnt_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; unsigned int insn_cmd; int chan; int cmd; int reg; int n; - n = rudimentary_check(dev, DIR_OUT); - if (n) - return n; - insn_cmd = data[0]; if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET) return -EINVAL; - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); - if (dev->board.model == VMK8055_MODEL) { + if (devpriv->model == VMK8055_MODEL) { if (!chan) { cmd = VMK8055_CMD_RST_CNT1; reg = VMK8055_CNT1_REG; @@ -960,36 +591,33 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *cdev, reg = VMK8055_CNT2_REG; } - dev->usb_tx_buf[reg] = 0x00; + devpriv->usb_tx_buf[reg] = 0x00; } else { cmd = VMK8061_CMD_RST_CNT; } for (n = 0; n < insn->n; n++) - if (vmk80xx_write_packet(dev, cmd)) + if (vmk80xx_write_packet(devpriv, cmd)) break; - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_cnt_winsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_cnt_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; unsigned long debtime; unsigned long val; int chan; int cmd; int n; - n = rudimentary_check(dev, DIR_OUT); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); chan = CR_CHAN(insn->chanspec); if (!chan) @@ -1010,65 +638,64 @@ static int vmk80xx_cnt_winsn(struct comedi_device *cdev, if (((val + 1) * val) < debtime * 1000 / 115) val += 1; - dev->usb_tx_buf[6 + chan] = val; + devpriv->usb_tx_buf[6 + chan] = val; - if (vmk80xx_write_packet(dev, cmd)) + if (vmk80xx_write_packet(devpriv, cmd)) break; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_pwm_rinsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_pwm_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; + unsigned char *tx_buf; + unsigned char *rx_buf; int reg[2]; int n; - n = rudimentary_check(dev, DIR_IN); - if (n) - return n; + down(&devpriv->limit_sem); - down(&dev->limit_sem); + tx_buf = devpriv->usb_tx_buf; + rx_buf = devpriv->usb_rx_buf; reg[0] = VMK8061_PWM_REG1; reg[1] = VMK8061_PWM_REG2; - dev->usb_tx_buf[0] = VMK8061_CMD_RD_PWM; + tx_buf[0] = VMK8061_CMD_RD_PWM; for (n = 0; n < insn->n; n++) { - if (vmk80xx_read_packet(dev)) + if (vmk80xx_read_packet(devpriv)) break; - data[n] = dev->usb_rx_buf[reg[0]] + 4 * dev->usb_rx_buf[reg[1]]; + data[n] = rx_buf[reg[0]] + 4 * rx_buf[reg[1]]; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_pwm_winsn(struct comedi_device *cdev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int vmk80xx_pwm_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct vmk80xx_usb *dev = cdev->private; + struct vmk80xx_private *devpriv = dev->private; unsigned char *tx_buf; int reg[2]; int cmd; int n; - n = rudimentary_check(dev, DIR_OUT); - if (n) - return n; - - down(&dev->limit_sem); + down(&devpriv->limit_sem); - tx_buf = dev->usb_tx_buf; + tx_buf = devpriv->usb_tx_buf; reg[0] = VMK8061_PWM_REG1; reg[1] = VMK8061_PWM_REG2; @@ -1092,341 +719,236 @@ static int vmk80xx_pwm_winsn(struct comedi_device *cdev, tx_buf[reg[0]] = (unsigned char)(data[n] & 0x03); tx_buf[reg[1]] = (unsigned char)(data[n] >> 2) & 0xff; - if (vmk80xx_write_packet(dev, cmd)) + if (vmk80xx_write_packet(devpriv, cmd)) break; } - up(&dev->limit_sem); + up(&devpriv->limit_sem); return n; } -static int vmk80xx_attach_common(struct comedi_device *cdev, - struct vmk80xx_usb *dev) +static int vmk80xx_find_usb_endpoints(struct comedi_device *dev) { - int n_subd; - struct comedi_subdevice *s; - int ret; + struct vmk80xx_private *devpriv = dev->private; + struct usb_interface *intf = devpriv->intf; + struct usb_host_interface *iface_desc = intf->cur_altsetting; + struct usb_endpoint_descriptor *ep_desc; + int i; - down(&dev->limit_sem); - cdev->board_name = dev->board.name; - cdev->private = dev; - if (dev->board.model == VMK8055_MODEL) - n_subd = 5; - else - n_subd = 6; - ret = comedi_alloc_subdevices(cdev, n_subd); - if (ret) { - up(&dev->limit_sem); - return ret; - } - /* Analog input subdevice */ - s = &cdev->subdevices[VMK80XX_SUBD_AI]; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = dev->board.ai_chans; - s->maxdata = (1 << dev->board.ai_bits) - 1; - s->range_table = dev->board.range; - s->insn_read = vmk80xx_ai_rinsn; - /* Analog output subdevice */ - s = &cdev->subdevices[VMK80XX_SUBD_AO]; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; - s->n_chan = dev->board.ao_chans; - s->maxdata = (1 << dev->board.ao_bits) - 1; - s->range_table = dev->board.range; - s->insn_write = vmk80xx_ao_winsn; - if (dev->board.model == VMK8061_MODEL) { - s->subdev_flags |= SDF_READABLE; - s->insn_read = vmk80xx_ao_rinsn; - } - /* Digital input subdevice */ - s = &cdev->subdevices[VMK80XX_SUBD_DI]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = dev->board.di_chans; - s->maxdata = 1; - s->insn_read = vmk80xx_di_rinsn; - s->insn_bits = vmk80xx_di_bits; - /* Digital output subdevice */ - s = &cdev->subdevices[VMK80XX_SUBD_DO]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; - s->n_chan = dev->board.do_chans; - s->maxdata = 1; - s->insn_write = vmk80xx_do_winsn; - s->insn_bits = vmk80xx_do_bits; - if (dev->board.model == VMK8061_MODEL) { - s->subdev_flags |= SDF_READABLE; - s->insn_read = vmk80xx_do_rinsn; - } - /* Counter subdevice */ - s = &cdev->subdevices[VMK80XX_SUBD_CNT]; - s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_READABLE; - s->n_chan = dev->board.cnt_chans; - s->insn_read = vmk80xx_cnt_rinsn; - s->insn_config = vmk80xx_cnt_cinsn; - if (dev->board.model == VMK8055_MODEL) { - s->subdev_flags |= SDF_WRITEABLE; - s->maxdata = (1 << dev->board.cnt_bits) - 1; - s->insn_write = vmk80xx_cnt_winsn; - } - /* PWM subdevice */ - if (dev->board.model == VMK8061_MODEL) { - s = &cdev->subdevices[VMK80XX_SUBD_PWM]; - s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; - s->n_chan = dev->board.pwm_chans; - s->maxdata = (1 << dev->board.pwm_bits) - 1; - s->insn_read = vmk80xx_pwm_rinsn; - s->insn_write = vmk80xx_pwm_winsn; - } - dev->attached = 1; - dev_info(cdev->class_dev, "vmk80xx: board #%d [%s] attached\n", - dev->count, dev->board.name); - up(&dev->limit_sem); - return 0; -} + if (iface_desc->desc.bNumEndpoints != 2) + return -ENODEV; -/* called for COMEDI_DEVCONFIG ioctl for board_name "vmk80xx" */ -static int vmk80xx_attach(struct comedi_device *cdev, - struct comedi_devconfig *it) -{ - int i; - int ret; + for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { + ep_desc = &iface_desc->endpoint[i].desc; - mutex_lock(&glb_mutex); - for (i = 0; i < VMK80XX_MAX_BOARDS; i++) - if (vmb[i].probed && !vmb[i].attached) - break; - if (i == VMK80XX_MAX_BOARDS) - ret = -ENODEV; - else - ret = vmk80xx_attach_common(cdev, &vmb[i]); - mutex_unlock(&glb_mutex); - return ret; -} + if (usb_endpoint_is_int_in(ep_desc) || + usb_endpoint_is_bulk_in(ep_desc)) { + if (!devpriv->ep_rx) + devpriv->ep_rx = ep_desc; + continue; + } -/* called via comedi_usb_auto_config() */ -static int vmk80xx_auto_attach(struct comedi_device *cdev, - unsigned long context_unused) -{ - struct usb_interface *intf = comedi_to_usb_interface(cdev); - int i; - int ret; + if (usb_endpoint_is_int_out(ep_desc) || + usb_endpoint_is_bulk_out(ep_desc)) { + if (!devpriv->ep_tx) + devpriv->ep_tx = ep_desc; + continue; + } + } - mutex_lock(&glb_mutex); - for (i = 0; i < VMK80XX_MAX_BOARDS; i++) - if (vmb[i].probed && vmb[i].intf == intf) - break; - if (i == VMK80XX_MAX_BOARDS) - ret = -ENODEV; - else if (vmb[i].attached) - ret = -EBUSY; - else - ret = vmk80xx_attach_common(cdev, &vmb[i]); - mutex_unlock(&glb_mutex); - return ret; + if (!devpriv->ep_rx || !devpriv->ep_tx) + return -ENODEV; + + return 0; } -static void vmk80xx_detach(struct comedi_device *dev) +static int vmk80xx_alloc_usb_buffers(struct comedi_device *dev) { - struct vmk80xx_usb *usb = dev->private; + struct vmk80xx_private *devpriv = dev->private; + size_t size; + + size = le16_to_cpu(devpriv->ep_rx->wMaxPacketSize); + devpriv->usb_rx_buf = kzalloc(size, GFP_KERNEL); + if (!devpriv->usb_rx_buf) + return -ENOMEM; - if (usb) { - down(&usb->limit_sem); - dev->private = NULL; - usb->attached = 0; - up(&usb->limit_sem); + size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize); + devpriv->usb_tx_buf = kzalloc(size, GFP_KERNEL); + if (!devpriv->usb_tx_buf) { + kfree(devpriv->usb_rx_buf); + return -ENOMEM; } -} -static struct comedi_driver vmk80xx_driver = { - .module = THIS_MODULE, - .driver_name = "vmk80xx", - .attach = vmk80xx_attach, - .detach = vmk80xx_detach, - .auto_attach = vmk80xx_auto_attach, -}; + return 0; +} -static int vmk80xx_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) +static int vmk80xx_init_subdevices(struct comedi_device *dev) { - int i; - struct vmk80xx_usb *dev; - struct usb_host_interface *iface_desc; - struct usb_endpoint_descriptor *ep_desc; - size_t size; - - mutex_lock(&glb_mutex); + const struct vmk80xx_board *boardinfo = comedi_board(dev); + struct vmk80xx_private *devpriv = dev->private; + struct comedi_subdevice *s; + int n_subd; + int ret; - for (i = 0; i < VMK80XX_MAX_BOARDS; i++) - if (!vmb[i].probed) - break; + down(&devpriv->limit_sem); - if (i == VMK80XX_MAX_BOARDS) { - mutex_unlock(&glb_mutex); - return -EMFILE; + if (devpriv->model == VMK8055_MODEL) + n_subd = 5; + else + n_subd = 6; + ret = comedi_alloc_subdevices(dev, n_subd); + if (ret) { + up(&devpriv->limit_sem); + return ret; } - dev = &vmb[i]; + /* Analog input subdevice */ + s = &dev->subdevices[0]; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND; + s->n_chan = boardinfo->ai_nchans; + s->maxdata = boardinfo->ai_maxdata; + s->range_table = boardinfo->range; + s->insn_read = vmk80xx_ai_insn_read; - memset(dev, 0x00, sizeof(struct vmk80xx_usb)); - dev->count = i; + /* Analog output subdevice */ + s = &dev->subdevices[1]; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; + s->n_chan = boardinfo->ao_nchans; + s->maxdata = 0x00ff; + s->range_table = boardinfo->range; + s->insn_write = vmk80xx_ao_insn_write; + if (devpriv->model == VMK8061_MODEL) { + s->subdev_flags |= SDF_READABLE; + s->insn_read = vmk80xx_ao_insn_read; + } - iface_desc = intf->cur_altsetting; - if (iface_desc->desc.bNumEndpoints != 2) - goto error; + /* Digital input subdevice */ + s = &dev->subdevices[2]; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = boardinfo->di_nchans; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = vmk80xx_di_insn_bits; - for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { - ep_desc = &iface_desc->endpoint[i].desc; + /* Digital output subdevice */ + s = &dev->subdevices[3]; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = vmk80xx_do_insn_bits; - if (usb_endpoint_is_int_in(ep_desc)) { - dev->ep_rx = ep_desc; - continue; - } + /* Counter subdevice */ + s = &dev->subdevices[4]; + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_READABLE; + s->n_chan = 2; + s->maxdata = boardinfo->cnt_maxdata; + s->insn_read = vmk80xx_cnt_insn_read; + s->insn_config = vmk80xx_cnt_insn_config; + if (devpriv->model == VMK8055_MODEL) { + s->subdev_flags |= SDF_WRITEABLE; + s->insn_write = vmk80xx_cnt_insn_write; + } - if (usb_endpoint_is_int_out(ep_desc)) { - dev->ep_tx = ep_desc; - continue; - } + /* PWM subdevice */ + if (devpriv->model == VMK8061_MODEL) { + s = &dev->subdevices[5]; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; + s->n_chan = boardinfo->pwm_nchans; + s->maxdata = boardinfo->pwm_maxdata; + s->insn_read = vmk80xx_pwm_insn_read; + s->insn_write = vmk80xx_pwm_insn_write; + } - if (usb_endpoint_is_bulk_in(ep_desc)) { - dev->ep_rx = ep_desc; - continue; - } + up(&devpriv->limit_sem); - if (usb_endpoint_is_bulk_out(ep_desc)) { - dev->ep_tx = ep_desc; - continue; - } - } + return 0; +} - if (!dev->ep_rx || !dev->ep_tx) - goto error; +static int vmk80xx_auto_attach(struct comedi_device *dev, + unsigned long context) +{ + struct usb_interface *intf = comedi_to_usb_interface(dev); + const struct vmk80xx_board *boardinfo; + struct vmk80xx_private *devpriv; + int ret; - size = le16_to_cpu(dev->ep_rx->wMaxPacketSize); - dev->usb_rx_buf = kmalloc(size, GFP_KERNEL); - if (!dev->usb_rx_buf) { - mutex_unlock(&glb_mutex); - return -ENOMEM; - } + boardinfo = &vmk80xx_boardinfo[context]; + dev->board_ptr = boardinfo; + dev->board_name = boardinfo->name; - size = le16_to_cpu(dev->ep_tx->wMaxPacketSize); - dev->usb_tx_buf = kmalloc(size, GFP_KERNEL); - if (!dev->usb_tx_buf) { - kfree(dev->usb_rx_buf); - mutex_unlock(&glb_mutex); + devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + if (!devpriv) return -ENOMEM; - } - - dev->udev = interface_to_usbdev(intf); - dev->intf = intf; - - sema_init(&dev->limit_sem, 8); - init_waitqueue_head(&dev->read_wait); - init_waitqueue_head(&dev->write_wait); - - init_usb_anchor(&dev->rx_anchor); - init_usb_anchor(&dev->tx_anchor); - - usb_set_intfdata(intf, dev); - - switch (id->driver_info) { - case DEVICE_VMK8055: - dev->board.name = "K8055 (VM110)"; - dev->board.model = VMK8055_MODEL; - dev->board.range = &vmk8055_range; - dev->board.ai_chans = 2; - dev->board.ai_bits = 8; - dev->board.ao_chans = 2; - dev->board.ao_bits = 8; - dev->board.di_chans = 5; - dev->board.di_bits = 1; - dev->board.do_chans = 8; - dev->board.do_bits = 1; - dev->board.cnt_chans = 2; - dev->board.cnt_bits = 16; - dev->board.pwm_chans = 0; - dev->board.pwm_bits = 0; - break; - case DEVICE_VMK8061: - dev->board.name = "K8061 (VM140)"; - dev->board.model = VMK8061_MODEL; - dev->board.range = &vmk8061_range; - dev->board.ai_chans = 8; - dev->board.ai_bits = 10; - dev->board.ao_chans = 8; - dev->board.ao_bits = 8; - dev->board.di_chans = 8; - dev->board.di_bits = 1; - dev->board.do_chans = 8; - dev->board.do_bits = 1; - dev->board.cnt_chans = 2; - dev->board.cnt_bits = 0; - dev->board.pwm_chans = 1; - dev->board.pwm_bits = 10; - break; - } + dev->private = devpriv; - if (dev->board.model == VMK8061_MODEL) { - vmk80xx_read_eeprom(dev, IC3_VERSION); - dev_info(&intf->dev, "%s\n", dev->fw.ic3_vers); + devpriv->usb = interface_to_usbdev(intf); + devpriv->intf = intf; + devpriv->model = boardinfo->model; - if (vmk80xx_check_data_link(dev)) { - vmk80xx_read_eeprom(dev, IC6_VERSION); - dev_info(&intf->dev, "%s\n", dev->fw.ic6_vers); - } else { - dbgcm("comedi#: vmk80xx: no conn. to CPU\n"); - } - } + ret = vmk80xx_find_usb_endpoints(dev); + if (ret) + return ret; - if (dev->board.model == VMK8055_MODEL) - vmk80xx_reset_device(dev); + ret = vmk80xx_alloc_usb_buffers(dev); + if (ret) + return ret; - dev->probed = 1; + sema_init(&devpriv->limit_sem, 8); - dev_info(&intf->dev, "board #%d [%s] now attached\n", - dev->count, dev->board.name); + usb_set_intfdata(intf, devpriv); - mutex_unlock(&glb_mutex); + if (devpriv->model == VMK8061_MODEL) { + vmk80xx_read_eeprom(devpriv, IC3_VERSION); + dev_info(&intf->dev, "%s\n", devpriv->fw.ic3_vers); - comedi_usb_auto_config(intf, &vmk80xx_driver); + if (vmk80xx_check_data_link(devpriv)) { + vmk80xx_read_eeprom(devpriv, IC6_VERSION); + dev_info(&intf->dev, "%s\n", devpriv->fw.ic6_vers); + } + } - return 0; -error: - mutex_unlock(&glb_mutex); + if (devpriv->model == VMK8055_MODEL) + vmk80xx_reset_device(devpriv); - return -ENODEV; + return vmk80xx_init_subdevices(dev); } -static void vmk80xx_usb_disconnect(struct usb_interface *intf) +static void vmk80xx_detach(struct comedi_device *dev) { - struct vmk80xx_usb *dev = usb_get_intfdata(intf); + struct vmk80xx_private *devpriv = dev->private; - if (!dev) + if (!devpriv) return; - comedi_usb_auto_unconfig(intf); - - mutex_lock(&glb_mutex); - down(&dev->limit_sem); + down(&devpriv->limit_sem); - dev->probed = 0; - usb_set_intfdata(dev->intf, NULL); + usb_set_intfdata(devpriv->intf, NULL); - usb_kill_anchored_urbs(&dev->rx_anchor); - usb_kill_anchored_urbs(&dev->tx_anchor); + kfree(devpriv->usb_rx_buf); + kfree(devpriv->usb_tx_buf); - kfree(dev->usb_rx_buf); - kfree(dev->usb_tx_buf); + up(&devpriv->limit_sem); +} - dev_info(&intf->dev, "board #%d [%s] now detached\n", - dev->count, dev->board.name); +static struct comedi_driver vmk80xx_driver = { + .module = THIS_MODULE, + .driver_name = "vmk80xx", + .auto_attach = vmk80xx_auto_attach, + .detach = vmk80xx_detach, +}; - up(&dev->limit_sem); - mutex_unlock(&glb_mutex); +static int vmk80xx_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + return comedi_usb_auto_config(intf, &vmk80xx_driver, id->driver_info); } static const struct usb_device_id vmk80xx_usb_id_table[] = { @@ -1446,13 +968,11 @@ static const struct usb_device_id vmk80xx_usb_id_table[] = { }; MODULE_DEVICE_TABLE(usb, vmk80xx_usb_id_table); -/* TODO: Add support for suspend, resume, pre_reset, - * post_reset and flush */ static struct usb_driver vmk80xx_usb_driver = { .name = "vmk80xx", - .probe = vmk80xx_usb_probe, - .disconnect = vmk80xx_usb_disconnect, .id_table = vmk80xx_usb_id_table, + .probe = vmk80xx_usb_probe, + .disconnect = comedi_usb_auto_unconfig, }; module_comedi_usb_driver(vmk80xx_driver, vmk80xx_usb_driver); diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index 4dc09a2..8932a51 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -42,7 +42,6 @@ MODULE_LICENSE("GPL"); struct comedi_device *comedi_open(const char *filename) { - struct comedi_device_file_info *dev_file_info; struct comedi_device *dev; unsigned int minor; @@ -54,12 +53,9 @@ struct comedi_device *comedi_open(const char *filename) if (minor >= COMEDI_NUM_BOARD_MINORS) return NULL; - dev_file_info = comedi_get_device_file_info(minor); - if (dev_file_info == NULL) - return NULL; - dev = dev_file_info->device; + dev = comedi_dev_from_minor(minor); - if (dev == NULL || !dev->attached) + if (!dev || !dev->attached) return NULL; if (!try_module_get(dev->driver->module)) diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index 01acbe9..362c214 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -33,7 +33,6 @@ #include <linux/proc_fs.h> #include <linux/string.h> -#ifdef CONFIG_PROC_FS static int comedi_read(char *buf, char **start, off_t offset, int len, int *eof, void *data) { @@ -49,13 +48,10 @@ static int comedi_read(char *buf, char **start, off_t offset, int len, "driver_name, board_name, n_subdevices"); for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { - struct comedi_device_file_info *dev_file_info = - comedi_get_device_file_info(i); - struct comedi_device *dev; + struct comedi_device *dev = comedi_dev_from_minor(i); - if (dev_file_info == NULL) + if (!dev) continue; - dev = dev_file_info->device; if (dev->attached) { devices_q = 1; @@ -95,4 +91,3 @@ void comedi_proc_cleanup(void) { remove_proc_entry("comedi", NULL); } -#endif diff --git a/drivers/staging/cptm1217/clearpad_tm1217.c b/drivers/staging/cptm1217/clearpad_tm1217.c index a49b0da..31fb5d3 100644 --- a/drivers/staging/cptm1217/clearpad_tm1217.c +++ b/drivers/staging/cptm1217/clearpad_tm1217.c @@ -421,11 +421,8 @@ static int cp_tm1217_probe(struct i2c_client *client, pdata = client->dev.platform_data; ts = kzalloc(sizeof(struct cp_tm1217_device), GFP_KERNEL); - if (!ts) { - dev_err(&client->dev, - "cp_tm1217: Private Device Struct alloc failed\n"); + if (!ts) return -ENOMEM; - } ts->client = client; ts->dev = &client->dev; diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c index 4780c32..3bd52fd 100644 --- a/drivers/staging/csr/drv.c +++ b/drivers/staging/csr/drv.c @@ -819,15 +819,15 @@ unifi_write(struct file *filp, const char *p, size_t len, loff_t *poff) unifi_trace(priv, UDBG2, "unifi_write: signal 0x%.4X len:%d\n", sig_id, signal_size); - /* Allocate a buffer for the signal */ - signal_buf = kmalloc(signal_size, GFP_KERNEL); + /* Allocate a buffer for the signal */ + signal_buf = kmemdup(bulkdata.d[0].os_data_ptr, signal_size, + GFP_KERNEL); if (!signal_buf) { unifi_net_data_free(priv, &bulkdata.d[0]); return -ENOMEM; } /* Get the signal from the os_data_ptr */ - memcpy(signal_buf, bulkdata.d[0].os_data_ptr, signal_size); signal_buf[5] = (pcli->sender_id >> 8) & 0xff; if (signal_size < len) { diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c index 2b06819..b1151a2 100644 --- a/drivers/staging/csr/sme_sys.c +++ b/drivers/staging/csr/sme_sys.c @@ -280,7 +280,7 @@ void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) CSR_SIGNAL *signal; u16 interfaceTag = 0; CSR_MA_PACKET_REQUEST *req; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; + netInterface_priv_t *interfacePriv; if (priv == NULL) { return; @@ -294,6 +294,8 @@ void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) return; } + interfacePriv = priv->interfacePriv[interfaceTag]; + /* Initialize bulkdata to avoid os_net_buf is garbage */ memset(&bulkdata, 0, sizeof(bulk_data_param_t)); @@ -1498,7 +1500,7 @@ void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) u8 *daddr, *saddr; u16 interfaceTag = mareq->interfaceTag & 0x00ff; int queue; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; + netInterface_priv_t *interfacePriv; if (!mareq->frame || !priv || !priv->smepriv) { @@ -1510,6 +1512,8 @@ void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n"); return; } + + interfacePriv = priv->interfacePriv[interfaceTag]; /* get a pointer to dest & source Mac address */ daddr = mareq->frame; saddr = (mareq->frame + ETH_ALEN); @@ -2056,9 +2060,9 @@ void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg; CsrResult status = CSR_RESULT_SUCCESS; unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; + netInterface_priv_t *interfacePriv; - unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler \n"); + unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler\n"); if (priv == NULL) { unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n"); @@ -2071,6 +2075,8 @@ void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) return; } + interfacePriv = priv->interfacePriv[req->interfaceTag]; + switch(interfacePriv->interfaceMode) { case CSR_WIFI_ROUTER_CTRL_MODE_AP: @@ -2471,7 +2477,7 @@ void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv,CsrWifiFsmEvent* msg) CsrResult status = CSR_RESULT_SUCCESS; unifi_priv_t *priv = (unifi_priv_t*)drvpriv; u32 handle = 0; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; + netInterface_priv_t *interfacePriv; unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n"); if (priv == NULL) @@ -2486,6 +2492,8 @@ void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv,CsrWifiFsmEvent* msg) return; } + interfacePriv = priv->interfacePriv[req->interfaceTag]; + switch(interfacePriv->interfaceMode) { case CSR_WIFI_ROUTER_CTRL_MODE_AP: @@ -3036,21 +3044,24 @@ void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) ul_client_t *client; CSR_SIGNAL signal; CSR_MA_PACKET_INDICATION *pkt_ind; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; + netInterface_priv_t *interfacePriv; + + if (priv == NULL) { + unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__); + return; + } + + if (priv->smepriv == NULL) { + unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__); + return; + } + + interfacePriv = priv->interfacePriv[req->interfaceTag]; if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n",__FUNCTION__); - return; - } - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n",__FUNCTION__); - return; - } if (req->dataLength == 0 || req->data == NULL) { unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n",__FUNCTION__); diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c index 49395da..7d19e63 100644 --- a/drivers/staging/csr/unifi_sme.c +++ b/drivers/staging/csr/unifi_sme.c @@ -1196,7 +1196,6 @@ void uf_send_pkt_to_encrypt(struct work_struct *work) if (pktBulkDataLength > 0) { pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL); - memset(pktBulkData, 0, pktBulkDataLength); } else { unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n"); return; diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 0ff2865..a829b62 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -773,7 +773,9 @@ do_del_chan (struct net_device * musycc_dev, void *data) if (copy_from_user (&cp, data, sizeof (struct sbecom_chan_param))) return -EFAULT; - sprintf (buf, CHANNAME "%d", cp.channum); + if (cp.channum > 999) + return -EINVAL; + snprintf (buf, sizeof(buf), CHANNAME "%d", cp.channum); if (!(dev = dev_get_by_name (&init_net, buf))) return -ENOENT; dev_put (dev); diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index c214078..13c7ccf 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -81,33 +81,34 @@ static struct dgrp_proc_entry dgrp_mon_table[]; static struct dgrp_proc_entry dgrp_ports_table[]; static struct dgrp_proc_entry dgrp_dpa_table[]; -static ssize_t config_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos); +static ssize_t dgrp_config_proc_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *pos); -static int nodeinfo_proc_open(struct inode *inode, struct file *file); -static int info_proc_open(struct inode *inode, struct file *file); -static int config_proc_open(struct inode *inode, struct file *file); +static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file); +static int dgrp_info_proc_open(struct inode *inode, struct file *file); +static int dgrp_config_proc_open(struct inode *inode, struct file *file); static struct file_operations config_proc_file_ops = { .owner = THIS_MODULE, - .open = config_proc_open, + .open = dgrp_config_proc_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .write = config_proc_write + .write = dgrp_config_proc_write, }; static struct file_operations info_proc_file_ops = { .owner = THIS_MODULE, - .open = info_proc_open, + .open = dgrp_info_proc_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = single_release, }; static struct file_operations nodeinfo_proc_file_ops = { .owner = THIS_MODULE, - .open = nodeinfo_proc_open, + .open = dgrp_nodeinfo_proc_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, @@ -181,13 +182,13 @@ static struct dgrp_proc_entry dgrp_dpa_table[] = { void dgrp_unregister_proc(void) { - unregister_proc_table(dgrp_table, dgrp_proc_dir_entry); net_entry_pointer = NULL; mon_entry_pointer = NULL; dpa_entry_pointer = NULL; ports_entry_pointer = NULL; if (dgrp_proc_dir_entry) { + unregister_proc_table(dgrp_table, dgrp_proc_dir_entry); remove_proc_entry(dgrp_proc_dir_entry->name, dgrp_proc_dir_entry->parent); dgrp_proc_dir_entry = NULL; @@ -231,6 +232,8 @@ static void register_proc_table(struct dgrp_proc_entry *table, if (table == NULL) return; + if (root == NULL) + return; for (; table->id; table++) { /* Can't do anything without a proc name. */ @@ -403,21 +406,21 @@ done: return 0; } -static void *config_proc_start(struct seq_file *m, loff_t *pos) +static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos) { return seq_list_start_head(&nd_struct_list, *pos); } -static void *config_proc_next(struct seq_file *p, void *v, loff_t *pos) +static void *dgrp_config_proc_next(struct seq_file *p, void *v, loff_t *pos) { return seq_list_next(v, &nd_struct_list, pos); } -static void config_proc_stop(struct seq_file *m, void *v) +static void dgrp_config_proc_stop(struct seq_file *m, void *v) { } -static int config_proc_show(struct seq_file *m, void *v) +static int dgrp_config_proc_show(struct seq_file *m, void *v) { struct nd_struct *nd; char tmp_id[4]; @@ -443,13 +446,13 @@ static int config_proc_show(struct seq_file *m, void *v) } static const struct seq_operations proc_config_ops = { - .start = config_proc_start, - .next = config_proc_next, - .stop = config_proc_stop, - .show = config_proc_show + .start = dgrp_config_proc_start, + .next = dgrp_config_proc_next, + .stop = dgrp_config_proc_stop, + .show = dgrp_config_proc_show, }; -static int config_proc_open(struct inode *inode, struct file *file) +static int dgrp_config_proc_open(struct inode *inode, struct file *file) { return seq_open(file, &proc_config_ops); } @@ -460,8 +463,9 @@ static int config_proc_open(struct inode *inode, struct file *file) * write) is treated as an independent request. See the "parse" * description for more details. */ -static ssize_t config_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) +static ssize_t dgrp_config_proc_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *pos) { ssize_t retval; char *inbuf, *sp; @@ -625,7 +629,7 @@ static int parse_write_config(char *buf) return retval; } -static int info_proc_show(struct seq_file *m, void *v) +static int dgrp_info_proc_show(struct seq_file *m, void *v) { seq_printf(m, "version: %s\n", DIGI_VERSION); seq_puts(m, "register_with_sysfs: 1\n"); @@ -635,27 +639,27 @@ static int info_proc_show(struct seq_file *m, void *v) return 0; } -static int info_proc_open(struct inode *inode, struct file *file) +static int dgrp_info_proc_open(struct inode *inode, struct file *file) { - return single_open(file, info_proc_show, NULL); + return single_open(file, dgrp_info_proc_show, NULL); } -static void *nodeinfo_start(struct seq_file *m, loff_t *pos) +static void *dgrp_nodeinfo_start(struct seq_file *m, loff_t *pos) { return seq_list_start_head(&nd_struct_list, *pos); } -static void *nodeinfo_next(struct seq_file *p, void *v, loff_t *pos) +static void *dgrp_nodeinfo_next(struct seq_file *p, void *v, loff_t *pos) { return seq_list_next(v, &nd_struct_list, pos); } -static void nodeinfo_stop(struct seq_file *m, void *v) +static void dgrp_nodeinfo_stop(struct seq_file *m, void *v) { } -static int nodeinfo_show(struct seq_file *m, void *v) +static int dgrp_nodeinfo_show(struct seq_file *m, void *v) { struct nd_struct *nd; char hwver[8]; @@ -697,13 +701,13 @@ static int nodeinfo_show(struct seq_file *m, void *v) static const struct seq_operations nodeinfo_ops = { - .start = nodeinfo_start, - .next = nodeinfo_next, - .stop = nodeinfo_stop, - .show = nodeinfo_show + .start = dgrp_nodeinfo_start, + .next = dgrp_nodeinfo_next, + .stop = dgrp_nodeinfo_stop, + .show = dgrp_nodeinfo_show, }; -static int nodeinfo_proc_open(struct inode *inode, struct file *file) +static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file) { return seq_open(file, &nodeinfo_ops); } @@ -773,14 +777,11 @@ static int dgrp_remove_nd(struct nd_struct *nd) dgrp_remove_node_class_sysfs_files(nd); } - if (nd->nd_mon_de) - unregister_dgrp_device(nd->nd_mon_de); + unregister_dgrp_device(nd->nd_mon_de); - if (nd->nd_ports_de) - unregister_dgrp_device(nd->nd_ports_de); + unregister_dgrp_device(nd->nd_ports_de); - if (nd->nd_dpa_de) - unregister_dgrp_device(nd->nd_dpa_de); + unregister_dgrp_device(nd->nd_dpa_de); dgrp_tty_uninit(nd); diff --git a/drivers/staging/echo/echo.c b/drivers/staging/echo/echo.c index ca87ce9..5882139 100644 --- a/drivers/staging/echo/echo.c +++ b/drivers/staging/echo/echo.c @@ -119,7 +119,6 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift) { int i; - int j; int offset1; int offset2; int factor; @@ -142,7 +141,7 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift) /* asm("st:"); */ n = ec->taps; - for (i = 0, j = offset2; i < n; i++, j++) { + for (i = 0; i < n; i++) { exp = *phist++ * factor; ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15); } @@ -230,6 +229,7 @@ struct oslec_state *oslec_create(int len, int adaption_mode) { struct oslec_state *ec; int i; + const int16_t *history; ec = kzalloc(sizeof(*ec), GFP_KERNEL); if (!ec) @@ -239,15 +239,22 @@ struct oslec_state *oslec_create(int len, int adaption_mode) ec->log2taps = top_bit(len); ec->curr_pos = ec->taps - 1; - for (i = 0; i < 2; i++) { - ec->fir_taps16[i] = - kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); - if (!ec->fir_taps16[i]) - goto error_oom; - } + ec->fir_taps16[0] = + kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); + if (!ec->fir_taps16[0]) + goto error_oom_0; + + ec->fir_taps16[1] = + kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); + if (!ec->fir_taps16[1]) + goto error_oom_1; - fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps); - fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps); + history = fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps); + if (!history) + goto error_state; + history = fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps); + if (!history) + goto error_state_bg; for (i = 0; i < 5; i++) ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0; @@ -257,7 +264,7 @@ struct oslec_state *oslec_create(int len, int adaption_mode) ec->snapshot = kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); if (!ec->snapshot) - goto error_oom; + goto error_snap; ec->cond_met = 0; ec->Pstates = 0; @@ -270,10 +277,15 @@ struct oslec_state *oslec_create(int len, int adaption_mode) return ec; -error_oom: - for (i = 0; i < 2; i++) - kfree(ec->fir_taps16[i]); - +error_snap: + fir16_free(&ec->fir_state_bg); +error_state_bg: + fir16_free(&ec->fir_state); +error_state: + kfree(ec->fir_taps16[1]); +error_oom_1: + kfree(ec->fir_taps16[0]); +error_oom_0: kfree(ec); return NULL; } diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 38537d4..05ad085 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -9,6 +9,10 @@ driver as they did not build properly at the time. TODO: - some rx packets have CRC/code/frame errors + - Look at reducing the number of spinlocks + - Simplify code in nic_rx_pkts(), when determining multicast_pkts_rcvd + - Implement NAPI support + - in et131x_tx(), don't return NETDEV_TX_BUSY, just drop the packet with kfree_skb(). Please send patches to: Greg Kroah-Hartman <gregkh@linuxfoundation.org> diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index a0a30b3..42ae5e8 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -1,5 +1,4 @@ -/* - * Agere Systems Inc. +/* Agere Systems Inc. * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. @@ -50,7 +49,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. - * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -102,8 +100,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere S #define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */ /* ISR defines */ -/* - * For interrupts, normal running is: +/* For interrupts, normal running is: * rxdma_xfr_done, phy_interrupt, mac_stat_interrupt, * watchdog_interrupt & txdma_xfer_done * @@ -139,19 +136,19 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere S #define NIC_SEND_HANG_THRESHOLD 0 /* MP_TCB flags */ -#define fMP_DEST_MULTI 0x00000001 -#define fMP_DEST_BROAD 0x00000002 +#define FMP_DEST_MULTI 0x00000001 +#define FMP_DEST_BROAD 0x00000002 /* MP_ADAPTER flags */ -#define fMP_ADAPTER_INTERRUPT_IN_USE 0x00000008 +#define FMP_ADAPTER_INTERRUPT_IN_USE 0x00000008 /* MP_SHARED flags */ -#define fMP_ADAPTER_LOWER_POWER 0x00200000 +#define FMP_ADAPTER_LOWER_POWER 0x00200000 -#define fMP_ADAPTER_NON_RECOVER_ERROR 0x00800000 -#define fMP_ADAPTER_HARDWARE_ERROR 0x04000000 +#define FMP_ADAPTER_NON_RECOVER_ERROR 0x00800000 +#define FMP_ADAPTER_HARDWARE_ERROR 0x04000000 -#define fMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000 +#define FMP_ADAPTER_FAIL_SEND_MASK 0x3ff00000 /* Some offsets in PCI config space that are actually used. */ #define ET1310_PCI_MAC_ADDRESS 0xA4 @@ -245,8 +242,7 @@ struct pkt_stat_desc { /* Typedefs for the RX DMA status word */ -/* - * rx status word 0 holds part of the status bits of the Rx DMA engine +/* rx status word 0 holds part of the status bits of the Rx DMA engine * that get copied out to memory by the ET-1310. Word 0 is a 32 bit word * which contains the Free Buffer ring 0 and 1 available offset. * @@ -256,8 +252,7 @@ struct pkt_stat_desc { * bit 26 Wrap flag for FBR0 */ -/* - * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine +/* RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine * that get copied out to memory by the ET-1310. Word 3 is a 32 bit word * which contains the Packet Status Ring available offset. * @@ -267,8 +262,7 @@ struct pkt_stat_desc { * bit 29-31 unused */ -/* - * struct rx_status_block is a structure representing the status of the Rx +/* struct rx_status_block is a structure representing the status of the Rx * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020 */ struct rx_status_block { @@ -276,8 +270,7 @@ struct rx_status_block { u32 word1; }; -/* - * Structure for look-up table holding free buffer ring pointers, addresses +/* Structure for look-up table holding free buffer ring pointers, addresses * and state. */ struct fbr_lookup { @@ -293,8 +286,7 @@ struct fbr_lookup { dma_addr_t buffsize; }; -/* - * struct rx_ring is the sructure representing the adaptor's local +/* struct rx_ring is the sructure representing the adaptor's local * reference(s) to the rings */ struct rx_ring { @@ -317,8 +309,7 @@ struct rx_ring { }; /* TX defines */ -/* - * word 2 of the control bits in the Tx Descriptor ring for the ET-1310 +/* word 2 of the control bits in the Tx Descriptor ring for the ET-1310 * * 0-15: length of packet * 16-27: VLAN tag @@ -344,6 +335,10 @@ struct rx_ring { * 14: UDP checksum assist */ +#define TXDESC_FLAG_LASTPKT 0x0001 +#define TXDESC_FLAG_FIRSTPKT 0x0002 +#define TXDESC_FLAG_INTPROC 0x0004 + /* struct tx_desc represents each descriptor on the ring */ struct tx_desc { u32 addr_hi; @@ -352,8 +347,7 @@ struct tx_desc { u32 flags; /* data (detailed above) */ }; -/* - * The status of the Tx DMA engine it sits in free memory, and is pointed to +/* The status of the Tx DMA engine it sits in free memory, and is pointed to * by 0x101c / 0x1020. This is a DMA10 type */ @@ -402,15 +396,13 @@ struct tx_ring { int since_irq; }; -/* - * Do not change these values: if changed, then change also in respective +/* Do not change these values: if changed, then change also in respective * TXdma and Rxdma engines */ #define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */ #define NUM_TCB 64 -/* - * These values are all superseded by registry entries to facilitate tuning. +/* These values are all superseded by registry entries to facilitate tuning. * Once the desired performance has been achieved, the optimal registry values * should be re-populated to these #defines: */ @@ -555,8 +547,7 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) u32 reg; int i; - /* - * 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and + /* 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and * bits 7,1:0 both equal to 1, at least once after reset. * Subsequent operations need only to check that bits 1:0 are equal * to 1 prior to starting a single byte read/write @@ -577,9 +568,7 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) return -ETIMEDOUT; } - -/** - * eeprom_write - Write a byte to the ET1310's EEPROM +/* eeprom_write - Write a byte to the ET1310's EEPROM * @adapter: pointer to our private adapter structure * @addr: the address to write * @data: the value to write @@ -597,8 +586,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) u32 status; u32 val = 0; - /* - * For an EEPROM, an I2C single byte write is defined as a START + /* For an EEPROM, an I2C single byte write is defined as a START * condition followed by the device address, EEPROM address, one byte * of data and a STOP condition. The STOP condition will trigger the * EEPROM's internally timed write cycle to the nonvolatile memory. @@ -610,12 +598,11 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) if (err) return err; - /* - * 2. Write to the LBCIF Control Register: bit 7=1, bit 6=1, bit 3=0, - * and bits 1:0 both =0. Bit 5 should be set according to the - * type of EEPROM being accessed (1=two byte addressing, 0=one - * byte addressing). - */ + /* 2. Write to the LBCIF Control Register: bit 7=1, bit 6=1, bit 3=0, + * and bits 1:0 both =0. Bit 5 should be set according to the + * type of EEPROM being accessed (1=two byte addressing, 0=one + * byte addressing). + */ if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE)) return -EIO; @@ -628,14 +615,12 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) /* Write the address to the LBCIF Address Register */ if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) break; - /* - * Write the data to the LBCIF Data Register (the I2C write + /* Write the data to the LBCIF Data Register (the I2C write * will begin). */ if (pci_write_config_byte(pdev, LBCIF_DATA_REGISTER, data)) break; - /* - * Monitor bit 1:0 of the LBCIF Status Register. When bits + /* Monitor bit 1:0 of the LBCIF Status Register. When bits * 1:0 are both equal to 1, the I2C write has completed and the * internal write cycle of the EEPROM is about to start. * (bits 1:0 = 01 is a legal state while waiting from both @@ -646,8 +631,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) if (err < 0) return 0; - /* - * Check bit 3 of the LBCIF Status Register. If equal to 1, + /* Check bit 3 of the LBCIF Status Register. If equal to 1, * an error has occurred.Don't break here if we are revision * 1, this is so we do a blind write for load bug. */ @@ -655,8 +639,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) && adapter->pdev->revision == 0) break; - /* - * Check bit 2 of the LBCIF Status Register. If equal to 1 an + /* Check bit 2 of the LBCIF Status Register. If equal to 1 an * ACK error has occurred on the address phase of the write. * This could be due to an actual hardware failure or the * EEPROM may still be in its internal write cycle from a @@ -664,8 +647,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) *repeated later. */ if (status & LBCIF_STATUS_ACK_ERROR) { - /* - * This could be due to an actual hardware failure + /* This could be due to an actual hardware failure * or the EEPROM may still be in its internal write * cycle from a previous write. This write operation * was ignored and must be repeated later. @@ -678,8 +660,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) break; } - /* - * Set bit 6 of the LBCIF Control Register = 0. + /* Set bit 6 of the LBCIF Control Register = 0. */ udelay(10); @@ -708,8 +689,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) return writeok ? 0 : -EIO; } -/** - * eeprom_read - Read a byte from the ET1310's EEPROM +/* eeprom_read - Read a byte from the ET1310's EEPROM * @adapter: pointer to our private adapter structure * @addr: the address from which to read * @pdata: a pointer to a byte in which to store the value of the read @@ -724,16 +704,14 @@ static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata) int err; u32 status; - /* - * A single byte read is similar to the single byte write, with the + /* A single byte read is similar to the single byte write, with the * exception of the data flow: */ err = eeprom_wait_ready(pdev, NULL); if (err) return err; - /* - * Write to the LBCIF Control Register: bit 7=1, bit 6=0, bit 3=0, + /* Write to the LBCIF Control Register: bit 7=1, bit 6=0, bit 3=0, * and bits 1:0 both =0. Bit 5 should be set according to the type * of EEPROM being accessed (1=two byte addressing, 0=one byte * addressing). @@ -741,27 +719,23 @@ static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata) if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER, LBCIF_CONTROL_LBCIF_ENABLE)) return -EIO; - /* - * Write the address to the LBCIF Address Register (I2C read will + /* Write the address to the LBCIF Address Register (I2C read will * begin). */ if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr)) return -EIO; - /* - * Monitor bit 0 of the LBCIF Status Register. When = 1, I2C read + /* Monitor bit 0 of the LBCIF Status Register. When = 1, I2C read * is complete. (if bit 1 =1 and bit 0 stays = 0, a hardware failure * has occurred). */ err = eeprom_wait_ready(pdev, &status); if (err < 0) return err; - /* - * Regardless of error status, read data byte from LBCIF Data + /* Regardless of error status, read data byte from LBCIF Data * Register. */ *pdata = err; - /* - * Check bit 2 of the LBCIF Status Register. If = 1, + /* Check bit 2 of the LBCIF Status Register. If = 1, * then an error has occurred. */ return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0; @@ -775,13 +749,12 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter) /* We first need to check the EEPROM Status code located at offset * 0xB2 of config space */ - pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, - &eestatus); + pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus); /* THIS IS A WORKAROUND: * I need to call this function twice to get my card in a * LG M1 Express Dual running. I tried also a msleep before this - * function, because I thought there could be some time condidions + * function, because I thought there could be some time conditions * but it didn't work. Call the whole function twice also work. */ if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) { @@ -836,36 +809,35 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter) return 0; } -/** - * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. +/* et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310. * @adapter: pointer to our adapter structure */ static void et131x_rx_dma_enable(struct et131x_adapter *adapter) { /* Setup the receive dma configuration register for normal operation */ - u32 csr = 0x2000; /* FBR1 enable */ + u32 csr = ET_RXDMA_CSR_FBR1_ENABLE; if (adapter->rx_ring.fbr[1]->buffsize == 4096) - csr |= 0x0800; + csr |= ET_RXDMA_CSR_FBR1_SIZE_LO; else if (adapter->rx_ring.fbr[1]->buffsize == 8192) - csr |= 0x1000; + csr |= ET_RXDMA_CSR_FBR1_SIZE_HI; else if (adapter->rx_ring.fbr[1]->buffsize == 16384) - csr |= 0x1800; + csr |= ET_RXDMA_CSR_FBR1_SIZE_LO | ET_RXDMA_CSR_FBR1_SIZE_HI; - csr |= 0x0400; /* FBR0 enable */ + csr |= ET_RXDMA_CSR_FBR0_ENABLE; if (adapter->rx_ring.fbr[0]->buffsize == 256) - csr |= 0x0100; + csr |= ET_RXDMA_CSR_FBR0_SIZE_LO; else if (adapter->rx_ring.fbr[0]->buffsize == 512) - csr |= 0x0200; + csr |= ET_RXDMA_CSR_FBR0_SIZE_HI; else if (adapter->rx_ring.fbr[0]->buffsize == 1024) - csr |= 0x0300; + csr |= ET_RXDMA_CSR_FBR0_SIZE_LO | ET_RXDMA_CSR_FBR0_SIZE_HI; writel(csr, &adapter->regs->rxdma.csr); csr = readl(&adapter->regs->rxdma.csr); - if (csr & 0x00020000) { + if (csr & ET_RXDMA_CSR_HALT_STATUS) { udelay(5); csr = readl(&adapter->regs->rxdma.csr); - if (csr & 0x00020000) { + if (csr & ET_RXDMA_CSR_HALT_STATUS) { dev_err(&adapter->pdev->dev, "RX Dma failed to exit halt state. CSR 0x%08x\n", csr); @@ -873,28 +845,27 @@ static void et131x_rx_dma_enable(struct et131x_adapter *adapter) } } -/** - * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 +/* et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310 * @adapter: pointer to our adapter structure */ static void et131x_rx_dma_disable(struct et131x_adapter *adapter) { u32 csr; /* Setup the receive dma configuration register */ - writel(0x00002001, &adapter->regs->rxdma.csr); + writel(ET_RXDMA_CSR_HALT | ET_RXDMA_CSR_FBR1_ENABLE, + &adapter->regs->rxdma.csr); csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) { /* Check halt status (bit 17) */ + if (!(csr & ET_RXDMA_CSR_HALT_STATUS)) { udelay(5); csr = readl(&adapter->regs->rxdma.csr); - if ((csr & 0x00020000) == 0) + if (!(csr & ET_RXDMA_CSR_HALT_STATUS)) dev_err(&adapter->pdev->dev, - "RX Dma failed to enter halt state. CSR 0x%08x\n", - csr); + "RX Dma failed to enter halt state. CSR 0x%08x\n", + csr); } } -/** - * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. +/* et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310. * @adapter: pointer to our adapter structure * * Mainly used after a return to the D0 (full-power) state from a lower state. @@ -918,8 +889,7 @@ static inline void add_12bit(u32 *v, int n) *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP); } -/** - * et1310_config_mac_regs1 - Initialize the first part of MAC regs +/* et1310_config_mac_regs1 - Initialize the first part of MAC regs * @adapter: pointer to our adapter structure */ static void et1310_config_mac_regs1(struct et131x_adapter *adapter) @@ -932,7 +902,10 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter) /* First we need to reset everything. Write to MAC configuration * register 1 to perform reset. */ - writel(0xC00F0000, ¯egs->cfg1); + writel(ET_MAC_CFG1_SOFT_RESET | ET_MAC_CFG1_SIM_RESET | + ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC | + ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC, + ¯egs->cfg1); /* Next lets configure the MAC Inter-packet gap register */ ipg = 0x38005860; /* IPG1 0x38 IPG2 0x58 B2B 0x60 */ @@ -947,7 +920,7 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter) writel(0, ¯egs->if_ctrl); /* Let's move on to setting up the mii management configuration */ - writel(0x07, ¯egs->mii_mgmt_cfg); /* Clock reset 0x7 */ + writel(ET_MAC_MIIMGMT_CLK_RST, ¯egs->mii_mgmt_cfg); /* Next lets configure the MAC Station Address register. These * values are read from the EEPROM during initialization and stored @@ -978,8 +951,7 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter) writel(0, ¯egs->cfg1); } -/** - * et1310_config_mac_regs2 - Initialize the second part of MAC regs +/* et1310_config_mac_regs2 - Initialize the second part of MAC regs * @adapter: pointer to our adapter structure */ static void et1310_config_mac_regs2(struct et131x_adapter *adapter) @@ -998,38 +970,44 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter) ifctrl = readl(&mac->if_ctrl); /* Set up the if mode bits */ - cfg2 &= ~0x300; + cfg2 &= ~ET_MAC_CFG2_IFMODE_MASK; if (phydev && phydev->speed == SPEED_1000) { - cfg2 |= 0x200; + cfg2 |= ET_MAC_CFG2_IFMODE_1000; /* Phy mode bit */ - ifctrl &= ~(1 << 24); + ifctrl &= ~ET_MAC_IFCTRL_PHYMODE; } else { - cfg2 |= 0x100; - ifctrl |= (1 << 24); + cfg2 |= ET_MAC_CFG2_IFMODE_100; + ifctrl |= ET_MAC_IFCTRL_PHYMODE; } /* We need to enable Rx/Tx */ - cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW; + cfg1 |= ET_MAC_CFG1_RX_ENABLE | ET_MAC_CFG1_TX_ENABLE | + ET_MAC_CFG1_TX_FLOW; /* Initialize loop back to off */ - cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW); + cfg1 &= ~(ET_MAC_CFG1_LOOPBACK | ET_MAC_CFG1_RX_FLOW); if (adapter->flowcontrol == FLOW_RXONLY || adapter->flowcontrol == FLOW_BOTH) - cfg1 |= CFG1_RX_FLOW; + cfg1 |= ET_MAC_CFG1_RX_FLOW; writel(cfg1, &mac->cfg1); /* Now we need to initialize the MAC Configuration 2 register */ /* preamble 7, check length, huge frame off, pad crc, crc enable - full duplex off */ - cfg2 |= 0x7016; - cfg2 &= ~0x0021; + * full duplex off + */ + cfg2 |= 0x7 << ET_MAC_CFG2_PREAMBLE_SHIFT; + cfg2 |= ET_MAC_CFG2_IFMODE_LEN_CHECK; + cfg2 |= ET_MAC_CFG2_IFMODE_PAD_CRC; + cfg2 |= ET_MAC_CFG2_IFMODE_CRC_ENABLE; + cfg2 &= ~ET_MAC_CFG2_IFMODE_HUGE_FRAME; + cfg2 &= ~ET_MAC_CFG2_IFMODE_FULL_DPLX; /* Turn on duplex if needed */ if (phydev && phydev->duplex == DUPLEX_FULL) - cfg2 |= 0x01; + cfg2 |= ET_MAC_CFG2_IFMODE_FULL_DPLX; - ifctrl &= ~(1 << 26); + ifctrl &= ~ET_MAC_IFCTRL_GHDMODE; if (phydev && phydev->duplex == DUPLEX_HALF) - ifctrl |= (1<<26); /* Enable ghd */ + ifctrl |= ET_MAC_IFCTRL_GHDMODE; writel(ifctrl, &mac->if_ctrl); writel(cfg2, &mac->cfg2); @@ -1038,7 +1016,7 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter) udelay(10); delay++; cfg1 = readl(&mac->cfg1); - } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100); + } while ((cfg1 & ET_MAC_CFG1_WAIT) != ET_MAC_CFG1_WAIT && delay < 100); if (delay == 100) { dev_warn(&adapter->pdev->dev, @@ -1047,18 +1025,17 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter) } /* Enable txmac */ - ctl |= 0x09; /* TX mac enable, FC disable */ + ctl |= ET_TX_CTRL_TXMAC_ENABLE | ET_TX_CTRL_FC_DISABLE; writel(ctl, &adapter->regs->txmac.ctl); /* Ready to start the RXDMA/TXDMA engine */ - if (adapter->flags & fMP_ADAPTER_LOWER_POWER) { + if (adapter->flags & FMP_ADAPTER_LOWER_POWER) { et131x_rx_dma_enable(adapter); et131x_tx_dma_enable(adapter); } } -/** - * et1310_in_phy_coma - check if the device is in phy coma +/* et1310_in_phy_coma - check if the device is in phy coma * @adapter: pointer to our adapter structure * * Returns 0 if the device is not in phy coma, 1 if it is in phy coma @@ -1139,19 +1116,19 @@ static void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the * MAC address for first address */ - uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) | - (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) | - (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) | + uni_pf3 = (adapter->addr[0] << ET_RX_UNI_PF_ADDR2_1_SHIFT) | + (adapter->addr[1] << ET_RX_UNI_PF_ADDR2_2_SHIFT) | + (adapter->addr[0] << ET_RX_UNI_PF_ADDR1_1_SHIFT) | adapter->addr[1]; - uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) | + uni_pf2 = (adapter->addr[2] << ET_RX_UNI_PF_ADDR2_3_SHIFT) | + (adapter->addr[3] << ET_RX_UNI_PF_ADDR2_4_SHIFT) | + (adapter->addr[4] << ET_RX_UNI_PF_ADDR2_5_SHIFT) | adapter->addr[5]; - uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) | - (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) | - (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) | + uni_pf1 = (adapter->addr[2] << ET_RX_UNI_PF_ADDR1_3_SHIFT) | + (adapter->addr[3] << ET_RX_UNI_PF_ADDR1_4_SHIFT) | + (adapter->addr[4] << ET_RX_UNI_PF_ADDR1_5_SHIFT) | adapter->addr[5]; pm_csr = readl(&adapter->regs->global.pm_csr); @@ -1208,13 +1185,13 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) writel(0, &rxmac->mask4_word3); /* Lets setup the WOL Source Address */ - sa_lo = (adapter->addr[2] << ET_WOL_LO_SA3_SHIFT) | - (adapter->addr[3] << ET_WOL_LO_SA4_SHIFT) | - (adapter->addr[4] << ET_WOL_LO_SA5_SHIFT) | + sa_lo = (adapter->addr[2] << ET_RX_WOL_LO_SA3_SHIFT) | + (adapter->addr[3] << ET_RX_WOL_LO_SA4_SHIFT) | + (adapter->addr[4] << ET_RX_WOL_LO_SA5_SHIFT) | adapter->addr[5]; writel(sa_lo, &rxmac->sa_lo); - sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) | + sa_hi = (u32) (adapter->addr[0] << ET_RX_WOL_HI_SA1_SHIFT) | adapter->addr[1]; writel(sa_hi, &rxmac->sa_hi); @@ -1224,7 +1201,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) /* Let's initialize the Unicast Packet filtering address */ if (adapter->packet_filter & ET131X_PACKET_TYPE_DIRECTED) { et1310_setup_device_for_unicast(adapter); - pf_ctrl |= 4; /* Unicast filter */ + pf_ctrl |= ET_RX_PFCTRL_UNICST_FILTER_ENABLE; } else { writel(0, &rxmac->uni_pf_addr1); writel(0, &rxmac->uni_pf_addr2); @@ -1233,13 +1210,13 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) /* Let's initialize the Multicast hash */ if (!(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) { - pf_ctrl |= 2; /* Multicast filter */ + pf_ctrl |= ET_RX_PFCTRL_MLTCST_FILTER_ENABLE; et1310_setup_device_for_multicast(adapter); } /* Runt packet filtering. Didn't work in version A silicon. */ - pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16; - pf_ctrl |= 8; /* Fragment filter */ + pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT; + pf_ctrl |= ET_RX_PFCTRL_FRAG_FILTER_ENABLE; if (adapter->registry_jumbo_packet > 8192) /* In order to transmit jumbo packets greater than 8k, the @@ -1290,7 +1267,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) * but we still leave the packet filter on. */ writel(pf_ctrl, &rxmac->pf_ctrl); - writel(0x9, &rxmac->ctrl); + writel(ET_RX_CTRL_RXMAC_ENABLE | ET_RX_CTRL_WOL_DISABLE, &rxmac->ctrl); } static void et1310_config_txmac_regs(struct et131x_adapter *adapter) @@ -1372,8 +1349,7 @@ static void et1310_config_macstat_regs(struct et131x_adapter *adapter) writel(0xFFFE7E8B, &macstat->carry_reg2_mask); } -/** - * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC +/* et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC * @adapter: pointer to our private adapter structure * @addr: the address of the transceiver * @reg: the register to read @@ -1401,7 +1377,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to read from on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + writel(ET_MAC_MII_ADDR(addr, reg), &mac->mii_mgmt_addr); writel(0x1, &mac->mii_mgmt_cmd); @@ -1409,7 +1385,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, udelay(50); delay++; mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_WAIT) && delay < 50); + } while ((mii_indicator & ET_MAC_MGMT_WAIT) && delay < 50); /* If we hit the max delay, we could not read the register */ if (delay == 50) { @@ -1422,8 +1398,9 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr, } /* If we hit here we were able to read the register and we need to - * return the value to the caller */ - *value = readl(&mac->mii_mgmt_stat) & 0xFFFF; + * return the value to the caller + */ + *value = readl(&mac->mii_mgmt_stat) & ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK; /* Stop the read operation */ writel(0, &mac->mii_mgmt_cmd); @@ -1447,8 +1424,7 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) return et131x_phy_mii_read(adapter, phydev->addr, reg, value); } -/** - * et131x_mii_write - Write to a PHY register through the MII interface of the MAC +/* et131x_mii_write - Write to a PHY reg through the MII interface of the MAC * @adapter: pointer to our private adapter structure * @reg: the register to read * @value: 16-bit value to write @@ -1483,7 +1459,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) writel(0, &mac->mii_mgmt_cmd); /* Set up the register we need to write to on the correct PHY */ - writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr); + writel(ET_MAC_MII_ADDR(addr, reg), &mac->mii_mgmt_addr); /* Add the value to write to the registers to the mac */ writel(value, &mac->mii_mgmt_ctrl); @@ -1492,7 +1468,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) udelay(50); delay++; mii_indicator = readl(&mac->mii_mgmt_indicator); - } while ((mii_indicator & MGMT_BUSY) && delay < 100); + } while ((mii_indicator & ET_MAC_MGMT_BUSY) && delay < 100); /* If we hit the max delay, we could not write the register */ if (delay == 100) { @@ -1512,8 +1488,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) /* Stop the write operation */ writel(0, &mac->mii_mgmt_cmd); - /* - * set the registers we touched back to the state at which we entered + /* set the registers we touched back to the state at which we entered * this function */ writel(mii_addr, &mac->mii_mgmt_addr); @@ -1528,7 +1503,7 @@ static void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u8 *value) { u16 reg; - u16 mask = 0x0001 << bitnum; + u16 mask = 1 << bitnum; /* Read the requested register */ et131x_mii_read(adapter, regnum, ®); @@ -1579,7 +1554,8 @@ static void et1310_config_flow_control(struct et131x_adapter *adapter) (remote_async_pause == TRUEPHY_BIT_CLEAR)) { adapter->flowcontrol = FLOW_NONE; } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT && - remote_async_pause == TRUEPHY_SET_BIT) */ + * remote_async_pause == TRUEPHY_SET_BIT) + */ if (adapter->wanted_flow == FLOW_BOTH) adapter->flowcontrol = FLOW_RXONLY; else @@ -1588,8 +1564,7 @@ static void et1310_config_flow_control(struct et131x_adapter *adapter) } } -/** - * et1310_update_macstat_host_counters - Update the local copy of the statistics +/* et1310_update_macstat_host_counters - Update the local copy of the statistics * @adapter: pointer to the adapter structure */ static void et1310_update_macstat_host_counters(struct et131x_adapter *adapter) @@ -1616,8 +1591,7 @@ static void et1310_update_macstat_host_counters(struct et131x_adapter *adapter) stats->rx_other_errs += readl(&macstat->rx_fragment_packets); } -/** - * et1310_handle_macstat_interrupt +/* et1310_handle_macstat_interrupt * @adapter: pointer to the adapter structure * * One of the MACSTAT counters has wrapped. Update the local copy of @@ -1708,8 +1682,7 @@ static int et131x_mdio_reset(struct mii_bus *bus) return 0; } -/** - * et1310_phy_power_down - PHY power control +/* et1310_phy_power_down - PHY power control * @adapter: device to control * @down: true for off/false for back on * @@ -1729,8 +1702,7 @@ static void et1310_phy_power_down(struct et131x_adapter *adapter, bool down) et131x_mii_write(adapter, MII_BMCR, data); } -/** - * et131x_xcvr_init - Init the phy if we are setting it into force mode +/* et131x_xcvr_init - Init the phy if we are setting it into force mode * @adapter: pointer to our private adapter structure * */ @@ -1761,8 +1733,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter) } } -/** - * et131x_configure_global_regs - configure JAGCore global regs +/* et131x_configure_global_regs - configure JAGCore global regs * @adapter: pointer to our adapter structure * * Used to configure the global registers on the JAGCore @@ -1808,8 +1779,7 @@ static void et131x_configure_global_regs(struct et131x_adapter *adapter) writel(0, ®s->watchdog_timer); } -/** - * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence +/* et131x_config_rx_dma_regs - Start of Rx_DMA init sequence * @adapter: pointer to our adapter structure */ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) @@ -1839,7 +1809,7 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des); writel(0, &rx_dma->psr_full_offset); - psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; + psr_num_des = readl(&rx_dma->psr_num_des) & ET_RXDMA_PSR_NUM_DES_MASK; writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, &rx_dma->psr_min_des); @@ -1849,11 +1819,11 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) rx_local->local_psr_full = 0; for (id = 0; id < NUM_FBRS; id++) { - u32 *num_des; - u32 *full_offset; - u32 *min_des; - u32 *base_hi; - u32 *base_lo; + u32 __iomem *num_des; + u32 __iomem *full_offset; + u32 __iomem *min_des; + u32 __iomem *base_hi; + u32 __iomem *base_lo; if (id == 0) { num_des = &rx_dma->fbr0_num_des; @@ -1916,8 +1886,7 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter) spin_unlock_irqrestore(&adapter->rcv_lock, flags); } -/** - * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. +/* et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore. * @adapter: pointer to our private adapter structure * * Configure the transmit engine with the ring buffers we have created @@ -1948,8 +1917,7 @@ static void et131x_config_tx_dma_regs(struct et131x_adapter *adapter) adapter->tx_ring.send_idx = 0; } -/** - * et131x_adapter_setup - Set the adapter up as per cassini+ documentation +/* et131x_adapter_setup - Set the adapter up as per cassini+ documentation * @adapter: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h) @@ -1977,23 +1945,29 @@ static void et131x_adapter_setup(struct et131x_adapter *adapter) et131x_xcvr_init(adapter); } -/** - * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 +/* et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 * @adapter: pointer to our private adapter structure */ static void et131x_soft_reset(struct et131x_adapter *adapter) { - /* Disable MAC Core */ - writel(0xc00f0000, &adapter->regs->mac.cfg1); + u32 reg; - /* Set everything to a reset value */ - writel(0x7F, &adapter->regs->global.sw_reset); - writel(0x000f0000, &adapter->regs->mac.cfg1); - writel(0x00000000, &adapter->regs->mac.cfg1); + /* Disable MAC Core */ + reg = ET_MAC_CFG1_SOFT_RESET | ET_MAC_CFG1_SIM_RESET | + ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC | + ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC; + writel(reg, &adapter->regs->mac.cfg1); + + reg = ET_RESET_ALL; + writel(reg, &adapter->regs->global.sw_reset); + + reg = ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC | + ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC; + writel(reg, &adapter->regs->mac.cfg1); + writel(0, &adapter->regs->mac.cfg1); } -/** - * et131x_enable_interrupts - enable interrupt +/* et131x_enable_interrupts - enable interrupt * @adapter: et131x device * * Enable the appropriate interrupts on the ET131x according to our @@ -2013,8 +1987,7 @@ static void et131x_enable_interrupts(struct et131x_adapter *adapter) writel(mask, &adapter->regs->global.int_mask); } -/** - * et131x_disable_interrupts - interrupt disable +/* et131x_disable_interrupts - interrupt disable * @adapter: et131x device * * Block all interrupts from the et131x device at the device itself @@ -2025,19 +1998,17 @@ static void et131x_disable_interrupts(struct et131x_adapter *adapter) writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask); } -/** - * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 +/* et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 * @adapter: pointer to our adapter structure */ static void et131x_tx_dma_disable(struct et131x_adapter *adapter) { /* Setup the tramsmit dma configuration register */ - writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT, + writel(ET_TXDMA_CSR_HALT | ET_TXDMA_SNGL_EPKT, &adapter->regs->txdma.csr); } -/** - * et131x_enable_txrx - Enable tx/rx queues +/* et131x_enable_txrx - Enable tx/rx queues * @netdev: device to be enabled */ static void et131x_enable_txrx(struct net_device *netdev) @@ -2049,15 +2020,14 @@ static void et131x_enable_txrx(struct net_device *netdev) et131x_tx_dma_enable(adapter); /* Enable device interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) + if (adapter->flags & FMP_ADAPTER_INTERRUPT_IN_USE) et131x_enable_interrupts(adapter); /* We're ready to move some data, so start the queue */ netif_start_queue(netdev); } -/** - * et131x_disable_txrx - Disable tx/rx queues +/* et131x_disable_txrx - Disable tx/rx queues * @netdev: device to be disabled */ static void et131x_disable_txrx(struct net_device *netdev) @@ -2075,8 +2045,7 @@ static void et131x_disable_txrx(struct net_device *netdev) et131x_disable_interrupts(adapter); } -/** - * et131x_init_send - Initialize send data structures +/* et131x_init_send - Initialize send data structures * @adapter: pointer to our private adapter structure */ static void et131x_init_send(struct et131x_adapter *adapter) @@ -2109,8 +2078,7 @@ static void et131x_init_send(struct et131x_adapter *adapter) tx_ring->send_tail = NULL; } -/** - * et1310_enable_phy_coma - called when network cable is unplugged +/* et1310_enable_phy_coma - called when network cable is unplugged * @adapter: pointer to our adapter structure * * driver receive an phy status change interrupt while in D0 and check that @@ -2139,8 +2107,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter) /* Save the GbE PHY speed and duplex modes. Need to restore this * when cable is plugged back in */ - /* - * TODO - when PM is re-enabled, check if we need to + /* TODO - when PM is re-enabled, check if we need to * perform a similar task as this - * adapter->pdown_speed = adapter->ai_force_speed; * adapter->pdown_duplex = adapter->ai_force_duplex; @@ -2148,7 +2115,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter) /* Stop sending packets. */ spin_lock_irqsave(&adapter->send_hw_lock, flags); - adapter->flags |= fMP_ADAPTER_LOWER_POWER; + adapter->flags |= FMP_ADAPTER_LOWER_POWER; spin_unlock_irqrestore(&adapter->send_hw_lock, flags); /* Wait for outstanding Receive packets */ @@ -2164,8 +2131,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter) writel(pmcsr, &adapter->regs->global.pm_csr); } -/** - * et1310_disable_phy_coma - Disable the Phy Coma Mode +/* et1310_disable_phy_coma - Disable the Phy Coma Mode * @adapter: pointer to our adapter structure */ static void et1310_disable_phy_coma(struct et131x_adapter *adapter) @@ -2201,7 +2167,7 @@ static void et1310_disable_phy_coma(struct et131x_adapter *adapter) et131x_adapter_setup(adapter); /* Allow Tx to restart */ - adapter->flags &= ~fMP_ADAPTER_LOWER_POWER; + adapter->flags &= ~FMP_ADAPTER_LOWER_POWER; et131x_enable_txrx(adapter->netdev); } @@ -2211,9 +2177,10 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) u32 tmp_free_buff_ring = *free_buff_ring; tmp_free_buff_ring++; /* This works for all cases where limit < 1024. The 1023 case - works because 1023++ is 1024 which means the if condition is not - taken but the carry of the bit into the wrap bit toggles the wrap - value correctly */ + * works because 1023++ is 1024 which means the if condition is not + * taken but the carry of the bit into the wrap bit toggles the wrap + * value correctly + */ if ((tmp_free_buff_ring & ET_DMA10_MASK) > limit) { tmp_free_buff_ring &= ~ET_DMA10_MASK; tmp_free_buff_ring ^= ET_DMA10_WRAP; @@ -2224,8 +2191,7 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) return tmp_free_buff_ring; } -/** - * et131x_rx_dma_memory_alloc +/* et131x_rx_dma_memory_alloc * @adapter: pointer to our private adapter structure * * Returns 0 on success and errno on failure (as defined in errno.h) @@ -2365,8 +2331,7 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) pr_info("Packet Status Ring %llx\n", (unsigned long long) rx_ring->ps_ring_physaddr); - /* - * NOTE : dma_alloc_coherent(), used above to alloc DMA regions, + /* NOTE : dma_alloc_coherent(), used above to alloc DMA regions, * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses * are ever returned, make sure the high part is retrieved here before * storing the adjusted address. @@ -2392,8 +2357,7 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) return 0; } -/** - * et131x_rx_dma_memory_free - Free all memory allocated within this module. +/* et131x_rx_dma_memory_free - Free all memory allocated within this module. * @adapter: pointer to our private adapter structure */ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) @@ -2480,8 +2444,7 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) rx_ring->num_ready_recv = 0; } -/** - * et131x_init_recv - Initialize receive data structures. +/* et131x_init_recv - Initialize receive data structures. * @adapter: pointer to our private adapter structure * * Returns 0 on success and errno on failure (as defined in errno.h) @@ -2499,11 +2462,8 @@ static int et131x_init_recv(struct et131x_adapter *adapter) /* Setup each RFD */ for (rfdct = 0; rfdct < rx_ring->num_rfd; rfdct++) { rfd = kzalloc(sizeof(struct rfd), GFP_ATOMIC | GFP_DMA); - - if (!rfd) { - dev_err(&adapter->pdev->dev, "Couldn't alloc RFD\n"); + if (!rfd) return -ENOMEM; - } rfd->skb = NULL; @@ -2518,8 +2478,7 @@ static int et131x_init_recv(struct et131x_adapter *adapter) return 0; } -/** - * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. +/* et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. * @adapter: pointer to our adapter structure */ static void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) @@ -2538,8 +2497,7 @@ static void et131x_set_rx_dma_timer(struct et131x_adapter *adapter) } } -/** - * NICReturnRFD - Recycle a RFD and put it back onto the receive list +/* NICReturnRFD - Recycle a RFD and put it back onto the receive list * @adapter: pointer to our adapter * @rfd: pointer to the RFD */ @@ -2555,7 +2513,7 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) * need to clean up OOB data */ if (buff_index < rx_local->fbr[ring_index]->num_entries) { - u32 *offset; + u32 __iomem *offset; struct fbr_desc *next; spin_lock_irqsave(&adapter->fbr_lock, flags); @@ -2599,8 +2557,7 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd) WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd); } -/** - * nic_rx_pkts - Checks the hardware for available packets +/* nic_rx_pkts - Checks the hardware for available packets * @adapter: pointer to our adapter * * Returns rfd, a pointer to our MPRFD. @@ -2773,7 +2730,6 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) rx_local->fbr[ring_index]->virt[buff_index], rfd->len); - skb->dev = adapter->netdev; skb->protocol = eth_type_trans(skb, adapter->netdev); skb->ip_summed = CHECKSUM_NONE; netif_rx_ni(skb); @@ -2783,8 +2739,7 @@ out: return rfd; } -/** - * et131x_handle_recv_interrupt - Interrupt handler for receive processing +/* et131x_handle_recv_interrupt - Interrupt handler for receive processing * @adapter: pointer to our adapter * * Assumption, Rcv spinlock has been acquired. @@ -2838,8 +2793,7 @@ static void et131x_handle_recv_interrupt(struct et131x_adapter *adapter) adapter->rx_ring.unfinished_receives = false; } -/** - * et131x_tx_dma_memory_alloc +/* et131x_tx_dma_memory_alloc * @adapter: pointer to our private adapter structure * * Returns 0 on success and errno on failure (as defined in errno.h). @@ -2856,12 +2810,10 @@ static int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) struct tx_ring *tx_ring = &adapter->tx_ring; /* Allocate memory for the TCB's (Transmit Control Block) */ - adapter->tx_ring.tcb_ring = - kcalloc(NUM_TCB, sizeof(struct tcb), GFP_ATOMIC | GFP_DMA); - if (!adapter->tx_ring.tcb_ring) { - dev_err(&adapter->pdev->dev, "Cannot alloc memory for TCBs\n"); + adapter->tx_ring.tcb_ring = kcalloc(NUM_TCB, sizeof(struct tcb), + GFP_ATOMIC | GFP_DMA); + if (!adapter->tx_ring.tcb_ring) return -ENOMEM; - } desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX); tx_ring->tx_desc_ring = @@ -2895,8 +2847,7 @@ static int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter) return 0; } -/** - * et131x_tx_dma_memory_free - Free all memory allocated within this module +/* et131x_tx_dma_memory_free - Free all memory allocated within this module * @adapter: pointer to our private adapter structure * * Returns 0 on success and errno on failure (as defined in errno.h). @@ -2928,8 +2879,7 @@ static void et131x_tx_dma_memory_free(struct et131x_adapter *adapter) kfree(adapter->tx_ring.tcb_ring); } -/** - * nic_send_packet - NIC specific send handler for version B silicon. +/* nic_send_packet - NIC specific send handler for version B silicon. * @adapter: pointer to our adapter * @tcb: pointer to struct tcb * @@ -2977,7 +2927,8 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) */ if (skb_headlen(skb) <= 1514) { /* Low 16bits are length, high is vlan and - unused currently so zero */ + * unused currently so zero + */ desc[frag].len_vlan = skb_headlen(skb); dma_addr = dma_map_single(&adapter->pdev->dev, skb->data, @@ -3022,23 +2973,24 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) if (phydev && phydev->speed == SPEED_1000) { if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) { /* Last element & Interrupt flag */ - desc[frag - 1].flags = 0x5; + desc[frag - 1].flags = + TXDESC_FLAG_INTPROC | TXDESC_FLAG_LASTPKT; adapter->tx_ring.since_irq = 0; } else { /* Last element */ - desc[frag - 1].flags = 0x1; + desc[frag - 1].flags = TXDESC_FLAG_LASTPKT; } } else - desc[frag - 1].flags = 0x5; + desc[frag - 1].flags = + TXDESC_FLAG_INTPROC | TXDESC_FLAG_LASTPKT; - desc[0].flags |= 2; /* First element flag */ + desc[0].flags |= TXDESC_FLAG_FIRSTPKT; tcb->index_start = adapter->tx_ring.send_idx; tcb->stale = 0; spin_lock_irqsave(&adapter->send_hw_lock, flags); - thiscopy = NUM_DESC_PER_RING_TX - - INDEX10(adapter->tx_ring.send_idx); + thiscopy = NUM_DESC_PER_RING_TX - INDEX10(adapter->tx_ring.send_idx); if (thiscopy >= frag) { remainder = 0; @@ -3106,8 +3058,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) return 0; } -/** - * send_packet - Do the work to send a packet +/* send_packet - Do the work to send a packet * @skb: the packet(s) to send * @adapter: a pointer to the device's private adapter structure * @@ -3150,9 +3101,9 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) if ((shbufva[0] == 0xffff) && (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) { - tcb->flags |= fMP_DEST_BROAD; + tcb->flags |= FMP_DEST_BROAD; } else if ((shbufva[0] & 0x3) == 0x0001) { - tcb->flags |= fMP_DEST_MULTI; + tcb->flags |= FMP_DEST_MULTI; } } @@ -3178,8 +3129,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter) return 0; } -/** - * et131x_send_packets - This function is called by the OS to send packets +/* et131x_send_packets - This function is called by the OS to send packets * @skb: the packet(s) to send * @netdev:device on which to TX the above packet(s) * @@ -3207,7 +3157,7 @@ static int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) /* We need to see if the link is up; if it's not, make the * netif layer think we're good and drop the packet */ - if ((adapter->flags & fMP_ADAPTER_FAIL_SEND_MASK) || + if ((adapter->flags & FMP_ADAPTER_FAIL_SEND_MASK) || !netif_carrier_ok(netdev)) { dev_kfree_skb_any(skb); skb = NULL; @@ -3228,8 +3178,7 @@ static int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev) return status; } -/** - * free_send_packet - Recycle a struct tcb +/* free_send_packet - Recycle a struct tcb * @adapter: pointer to our adapter * @tcb: pointer to struct tcb * @@ -3244,9 +3193,9 @@ static inline void free_send_packet(struct et131x_adapter *adapter, struct net_device_stats *stats = &adapter->net_stats; u64 dma_addr; - if (tcb->flags & fMP_DEST_BROAD) + if (tcb->flags & FMP_DEST_BROAD) atomic_inc(&adapter->stats.broadcast_pkts_xmtd); - else if (tcb->flags & fMP_DEST_MULTI) + else if (tcb->flags & FMP_DEST_MULTI) atomic_inc(&adapter->stats.multicast_pkts_xmtd); else atomic_inc(&adapter->stats.unicast_pkts_xmtd); @@ -3301,8 +3250,7 @@ static inline void free_send_packet(struct et131x_adapter *adapter, WARN_ON(adapter->tx_ring.used < 0); } -/** - * et131x_free_busy_send_packets - Free and complete the stopped active sends +/* et131x_free_busy_send_packets - Free and complete the stopped active sends * @adapter: pointer to our adapter * * Assumption - Send spinlock has been acquired @@ -3345,8 +3293,7 @@ static void et131x_free_busy_send_packets(struct et131x_adapter *adapter) adapter->tx_ring.used = 0; } -/** - * et131x_handle_send_interrupt - Interrupt handler for sending processing +/* et131x_handle_send_interrupt - Interrupt handler for sending processing * @adapter: pointer to our adapter * * Re-claim the send resources, complete sends and get more to send from @@ -3438,6 +3385,7 @@ static void et131x_get_regs(struct net_device *netdev, struct address_map __iomem *aregs = adapter->regs; u32 *regs_buff = regs_data; u32 num = 0; + u16 tmp; memset(regs_data, 0, et131x_get_regs_len(netdev)); @@ -3445,44 +3393,68 @@ static void et131x_get_regs(struct net_device *netdev, adapter->pdev->device; /* PHY regs */ - et131x_mii_read(adapter, MII_BMCR, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_BMSR, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_PHYSID1, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_PHYSID2, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_ADVERTISE, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_LPA, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_EXPANSION, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, MII_BMCR, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_BMSR, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_PHYSID1, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_PHYSID2, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_ADVERTISE, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_LPA, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_EXPANSION, &tmp); + regs_buff[num++] = tmp; /* Autoneg next page transmit reg */ - et131x_mii_read(adapter, 0x07, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, 0x07, &tmp); + regs_buff[num++] = tmp; /* Link partner next page reg */ - et131x_mii_read(adapter, 0x08, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_CTRL1000, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_STAT1000, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, 0x0b, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, 0x0c, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_MMD_CTRL, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_MMD_DATA, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, MII_ESTATUS, (u16 *)®s_buff[num++]); - - et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1, - (u16 *)®s_buff[num++]); - - et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_CONFIG, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_PHY_CONTROL, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_INTERRUPT_MASK, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, - (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_PHY_STATUS, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LED_1, (u16 *)®s_buff[num++]); - et131x_mii_read(adapter, PHY_LED_2, (u16 *)®s_buff[num++]); + et131x_mii_read(adapter, 0x08, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_CTRL1000, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_STAT1000, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, 0x0b, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, 0x0c, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_MMD_CTRL, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_MMD_DATA, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, MII_ESTATUS, &tmp); + regs_buff[num++] = tmp; + + et131x_mii_read(adapter, PHY_INDEX_REG, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_DATA_REG, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL + 1, &tmp); + regs_buff[num++] = tmp; + + et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_CONFIG, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_PHY_CONTROL, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_PHY_STATUS, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_LED_1, &tmp); + regs_buff[num++] = tmp; + et131x_mii_read(adapter, PHY_LED_2, &tmp); + regs_buff[num++] = tmp; /* Global regs */ regs_buff[num++] = readl(&aregs->global.txq_start_addr); @@ -3579,8 +3551,8 @@ static struct ethtool_ops et131x_ethtool_ops = { .get_regs = et131x_get_regs, .get_link = ethtool_op_get_link, }; -/** - * et131x_hwaddr_init - set up the MAC Address on the ET1310 + +/* et131x_hwaddr_init - set up the MAC Address on the ET1310 * @adapter: pointer to our private adapter structure */ static void et131x_hwaddr_init(struct et131x_adapter *adapter) @@ -3590,14 +3562,12 @@ static void et131x_hwaddr_init(struct et131x_adapter *adapter) * device */ if (is_zero_ether_addr(adapter->rom_addr)) { - /* - * We need to randomly generate the last octet so we + /* We need to randomly generate the last octet so we * decrease our chances of setting the mac address to * same as another one of our cards in the system */ get_random_bytes(&adapter->addr[5], 1); - /* - * We have the default value in the register we are + /* We have the default value in the register we are * working with so we need to copy the current * address into the permanent address */ @@ -3613,8 +3583,7 @@ static void et131x_hwaddr_init(struct et131x_adapter *adapter) } } -/** - * et131x_pci_init - initial PCI setup +/* et131x_pci_init - initial PCI setup * @adapter: pointer to our private adapter structure * @pdev: our PCI device * @@ -3706,8 +3675,7 @@ err_out: goto out; } -/** - * et131x_error_timer_handler +/* et131x_error_timer_handler * @data: timer-specific variable; here a pointer to our adapter structure * * The routine called when the error timer expires, to track the number of @@ -3721,7 +3689,8 @@ static void et131x_error_timer_handler(unsigned long data) if (et1310_in_phy_coma(adapter)) { /* Bring the device immediately out of coma, to * prevent it from sleeping indefinitely, this - * mechanism could be improved! */ + * mechanism could be improved! + */ et1310_disable_phy_coma(adapter); adapter->boot_coma = 20; } else { @@ -3747,8 +3716,7 @@ static void et131x_error_timer_handler(unsigned long data) mod_timer(&adapter->error_timer, jiffies + TX_ERROR_PERIOD * HZ / 1000); } -/** - * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx +/* et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx * @adapter: pointer to our private adapter structure */ static void et131x_adapter_memory_free(struct et131x_adapter *adapter) @@ -3758,8 +3726,7 @@ static void et131x_adapter_memory_free(struct et131x_adapter *adapter) et131x_rx_dma_memory_free(adapter); } -/** - * et131x_adapter_memory_alloc +/* et131x_adapter_memory_alloc * @adapter: pointer to our private adapter structure * * Returns 0 on success, errno on failure (as defined in errno.h). @@ -3801,60 +3768,54 @@ static void et131x_adjust_link(struct net_device *netdev) struct et131x_adapter *adapter = netdev_priv(netdev); struct phy_device *phydev = adapter->phydev; - if (netif_carrier_ok(netdev)) { - adapter->boot_coma = 20; - - if (phydev && phydev->speed == SPEED_10) { - /* - * NOTE - Is there a way to query this without - * TruePHY? - * && TRU_QueryCoreType(adapter->hTruePhy, 0)== - * EMI_TRUEPHY_A13O) { - */ - u16 register18; - - et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, - ®ister18); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18 | 0x4); - et131x_mii_write(adapter, PHY_INDEX_REG, - register18 | 0x8402); - et131x_mii_write(adapter, PHY_DATA_REG, - register18 | 511); - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, - register18); - } - - et1310_config_flow_control(adapter); - - if (phydev && phydev->speed == SPEED_1000 && - adapter->registry_jumbo_packet > 2048) { - u16 reg; - - et131x_mii_read(adapter, PHY_CONFIG, ®); - reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; - reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; - et131x_mii_write(adapter, PHY_CONFIG, reg); - } - - et131x_set_rx_dma_timer(adapter); - et1310_config_mac_regs2(adapter); - } - if (phydev && phydev->link != adapter->link) { - /* - * Check to see if we are in coma mode and if + /* Check to see if we are in coma mode and if * so, disable it because we will not be able * to read PHY values until we are out. */ if (et1310_in_phy_coma(adapter)) et1310_disable_phy_coma(adapter); + adapter->link = phydev->link; + phy_print_status(phydev); + if (phydev->link) { adapter->boot_coma = 20; + if (phydev && phydev->speed == SPEED_10) { + /* NOTE - Is there a way to query this without + * TruePHY? + * && TRU_QueryCoreType(adapter->hTruePhy, 0)== + * EMI_TRUEPHY_A13O) { + */ + u16 register18; + + et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, + ®ister18); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18 | 0x4); + et131x_mii_write(adapter, PHY_INDEX_REG, + register18 | 0x8402); + et131x_mii_write(adapter, PHY_DATA_REG, + register18 | 511); + et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, + register18); + } + + et1310_config_flow_control(adapter); + + if (phydev && phydev->speed == SPEED_1000 && + adapter->registry_jumbo_packet > 2048) { + u16 reg; + + et131x_mii_read(adapter, PHY_CONFIG, ®); + reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; + reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; + et131x_mii_write(adapter, PHY_CONFIG, reg); + } + + et131x_set_rx_dma_timer(adapter); + et1310_config_mac_regs2(adapter); } else { - dev_warn(&adapter->pdev->dev, - "Link down - cable problem ?\n"); adapter->boot_coma = 0; if (phydev->speed == SPEED_10) { @@ -3883,8 +3844,7 @@ static void et131x_adjust_link(struct net_device *netdev) /* Re-initialize the send structures */ et131x_init_send(adapter); - /* - * Bring the device back to the state it was during + /* Bring the device back to the state it was during * init prior to autonegotiation being complete. This * way, when we get the auto-neg complete interrupt, * we can complete init by calling config_mac_regs2. @@ -3899,9 +3859,6 @@ static void et131x_adjust_link(struct net_device *netdev) et131x_enable_txrx(netdev); } - adapter->link = phydev->link; - - phy_print_status(phydev); } } @@ -3944,8 +3901,7 @@ static int et131x_mii_probe(struct net_device *netdev) return 0; } -/** - * et131x_adapter_init +/* et131x_adapter_init * @adapter: pointer to the private adapter struct * @pdev: pointer to the PCI device * @@ -3982,8 +3938,7 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, return adapter; } -/** - * et131x_pci_remove +/* et131x_pci_remove * @pdev: a pointer to the device's pci_dev structure * * Registered in the pci_driver structure, this function is called when the @@ -4010,8 +3965,7 @@ static void et131x_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } -/** - * et131x_up - Bring up a device for use. +/* et131x_up - Bring up a device for use. * @netdev: device to be opened */ static void et131x_up(struct net_device *netdev) @@ -4022,8 +3976,7 @@ static void et131x_up(struct net_device *netdev) phy_start(adapter->phydev); } -/** - * et131x_down - Bring down the device +/* et131x_down - Bring down the device * @netdev: device to be brought down */ static void et131x_down(struct net_device *netdev) @@ -4072,14 +4025,13 @@ static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume); #define ET131X_PM_OPS NULL #endif -/** - * et131x_isr - The Interrupt Service Routine for the driver. +/* et131x_isr - The Interrupt Service Routine for the driver. * @irq: the IRQ on which the interrupt was received. * @dev_id: device-specific info (here a pointer to a net_device struct) * * Returns a value indicating if the interrupt was handled. */ -irqreturn_t et131x_isr(int irq, void *dev_id) +static irqreturn_t et131x_isr(int irq, void *dev_id) { bool handled = true; struct net_device *netdev = (struct net_device *)dev_id; @@ -4161,8 +4113,7 @@ out: return IRQ_RETVAL(handled); } -/** - * et131x_isr_handler - The ISR handler +/* et131x_isr_handler - The ISR handler * @p_adapter, a pointer to the device's private adapter structure * * scheduled to run in a deferred context by the ISR. This is where the ISR's @@ -4175,8 +4126,7 @@ static void et131x_isr_handler(struct work_struct *work) u32 status = adapter->stats.interrupt_status; struct address_map __iomem *iomem = adapter->regs; - /* - * These first two are by far the most common. Once handled, we clear + /* These first two are by far the most common. Once handled, we clear * their two bits in the status word. If the word is now zero, we * exit. */ @@ -4207,8 +4157,7 @@ static void et131x_isr_handler(struct work_struct *work) /* Handle Free Buffer Ring 0 and 1 Low interrupt */ if (status & (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) { - /* - * This indicates the number of unused buffers in RXDMA free + /* This indicates the number of unused buffers in RXDMA free * buffer ring 0 is <= the limit you programmed. Free buffer * resources need to be returned. Free buffers are consumed as * packets are passed from the network to the host. The host @@ -4220,16 +4169,14 @@ static void et131x_isr_handler(struct work_struct *work) * method of returning resources. */ - /* - * If the user has flow control on, then we will + /* If the user has flow control on, then we will * send a pause packet, otherwise just exit */ if (adapter->flowcontrol == FLOW_TXONLY || adapter->flowcontrol == FLOW_BOTH) { u32 pm_csr; - /* - * Tell the device to send a pause packet via the back + /* Tell the device to send a pause packet via the back * pressure register (bp req and bp xon/xoff) */ pm_csr = readl(&iomem->global.pm_csr); @@ -4240,8 +4187,7 @@ static void et131x_isr_handler(struct work_struct *work) /* Handle Packet Status Ring Low Interrupt */ if (status & ET_INTR_RXDMA_STAT_LOW) { - /* - * Same idea as with the two Free Buffer Rings. Packets going + /* Same idea as with the two Free Buffer Rings. Packets going * from the network to the host each consume a free buffer * resource and a packet status resource. These resoures are * passed to the OS. When the OS is done with the resources, @@ -4252,8 +4198,7 @@ static void et131x_isr_handler(struct work_struct *work) /* Handle RXDMA Error Interrupt */ if (status & ET_INTR_RXDMA_ERR) { - /* - * The rxdma_error interrupt is sent when a time-out on a + /* The rxdma_error interrupt is sent when a time-out on a * request issued by the JAGCore has occurred or a completion is * returned with an un-successful status. In both cases the * request is considered complete. The JAGCore will @@ -4276,8 +4221,7 @@ static void et131x_isr_handler(struct work_struct *work) /* Handle the Wake on LAN Event */ if (status & ET_INTR_WOL) { - /* - * This is a secondary interrupt for wake on LAN. The driver + /* This is a secondary interrupt for wake on LAN. The driver * should never see this, if it does, something serious is * wrong. We will TRAP the message when we are in DBG mode, * otherwise we will ignore it. @@ -4289,8 +4233,7 @@ static void et131x_isr_handler(struct work_struct *work) if (status & ET_INTR_TXMAC) { u32 err = readl(&iomem->txmac.err); - /* - * When any of the errors occur and TXMAC generates an + /* When any of the errors occur and TXMAC generates an * interrupt to report these errors, it usually means that * TXMAC has detected an error in the data stream retrieved * from the on-chip Tx Q. All of these errors are catastrophic @@ -4302,20 +4245,18 @@ static void et131x_isr_handler(struct work_struct *work) "TXMAC interrupt, error 0x%08x\n", err); - /* - * If we are debugging, we want to see this error, otherwise we + /* If we are debugging, we want to see this error, otherwise we * just want the device to be reset and continue */ } /* Handle RXMAC Interrupt */ if (status & ET_INTR_RXMAC) { - /* - * These interrupts are catastrophic to the device, what we need + /* These interrupts are catastrophic to the device, what we need * to do is disable the interrupts and set the flag to cause us * to reset so we can solve this issue. */ - /* MP_SET_FLAG( adapter, fMP_ADAPTER_HARDWARE_ERROR); */ + /* MP_SET_FLAG( adapter, FMP_ADAPTER_HARDWARE_ERROR); */ dev_warn(&adapter->pdev->dev, "RXMAC interrupt, error 0x%08x. Requesting reset\n", @@ -4326,16 +4267,14 @@ static void et131x_isr_handler(struct work_struct *work) readl(&iomem->rxmac.ctrl), readl(&iomem->rxmac.rxq_diag)); - /* - * If we are debugging, we want to see this error, otherwise we + /* If we are debugging, we want to see this error, otherwise we * just want the device to be reset and continue */ } /* Handle MAC_STAT Interrupt */ if (status & ET_INTR_MAC_STAT) { - /* - * This means at least one of the un-masked counters in the + /* This means at least one of the un-masked counters in the * MAC_STAT block has rolled over. Use this to maintain the top, * software managed bits of the counter(s). */ @@ -4344,8 +4283,7 @@ static void et131x_isr_handler(struct work_struct *work) /* Handle SLV Timeout Interrupt */ if (status & ET_INTR_SLV_TIMEOUT) { - /* - * This means a timeout has occurred on a read or write request + /* This means a timeout has occurred on a read or write request * to one of the JAGCore registers. The Global Resources block * has terminated the request and on a read request, returned a * "fake" value. The most likely reasons are: Bad Address or the @@ -4356,8 +4294,7 @@ out: et131x_enable_interrupts(adapter); } -/** - * et131x_stats - Return the current device statistics. +/* et131x_stats - Return the current device statistics. * @netdev: device whose stats are being queried * * Returns 0 on success, errno on failure (as defined in errno.h) @@ -4403,8 +4340,7 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev) return stats; } -/** - * et131x_open - Open the device for use. +/* et131x_open - Open the device for use. * @netdev: device to be opened * * Returns 0 on success, errno on failure (as defined in errno.h) @@ -4430,15 +4366,14 @@ static int et131x_open(struct net_device *netdev) return result; } - adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; + adapter->flags |= FMP_ADAPTER_INTERRUPT_IN_USE; et131x_up(netdev); return result; } -/** - * et131x_close - Close the device +/* et131x_close - Close the device * @netdev: device to be closed * * Returns 0 on success, errno on failure (as defined in errno.h) @@ -4449,15 +4384,14 @@ static int et131x_close(struct net_device *netdev) et131x_down(netdev); - adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; + adapter->flags &= ~FMP_ADAPTER_INTERRUPT_IN_USE; free_irq(adapter->pdev->irq, netdev); /* Stop the error timer */ return del_timer_sync(&adapter->error_timer); } -/** - * et131x_ioctl - The I/O Control handler for the driver +/* et131x_ioctl - The I/O Control handler for the driver * @netdev: device on which the control request is being made * @reqbuf: a pointer to the IOCTL request buffer * @cmd: the IOCTL command code @@ -4475,8 +4409,7 @@ static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, return phy_mii_ioctl(adapter->phydev, reqbuf, cmd); } -/** - * et131x_set_packet_filter - Configures the Rx Packet filtering on the device +/* et131x_set_packet_filter - Configures the Rx Packet filtering on the device * @adapter: pointer to our private adapter structure * * FIXME: lot of dups with MAC code @@ -4504,8 +4437,7 @@ static int et131x_set_packet_filter(struct et131x_adapter *adapter) if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0) pf_ctrl &= ~7; /* Clear filter bits */ else { - /* - * Set us up with Multicast packet filtering. Three cases are + /* Set us up with Multicast packet filtering. Three cases are * possible - (1) we have a multi-cast list, (2) we receive ALL * multicast entries or (3) we receive none. */ @@ -4541,8 +4473,7 @@ static int et131x_set_packet_filter(struct et131x_adapter *adapter) return status; } -/** - * et131x_multicast - The handler to configure multicasting on the interface +/* et131x_multicast - The handler to configure multicasting on the interface * @netdev: a pointer to a net_device struct representing the device */ static void et131x_multicast(struct net_device *netdev) @@ -4611,8 +4542,7 @@ static void et131x_multicast(struct net_device *netdev) spin_unlock_irqrestore(&adapter->lock, flags); } -/** - * et131x_tx - The handler to tx a packet on the device +/* et131x_tx - The handler to tx a packet on the device * @skb: data to be Tx'd * @netdev: device on which data is to be Tx'd * @@ -4644,8 +4574,7 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev) return status; } -/** - * et131x_tx_timeout - Timeout handler +/* et131x_tx_timeout - Timeout handler * @netdev: a pointer to a net_device struct representing the device * * The handler called when a Tx request times out. The timeout period is @@ -4659,17 +4588,17 @@ static void et131x_tx_timeout(struct net_device *netdev) unsigned long flags; /* If the device is closed, ignore the timeout */ - if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)) + if (~(adapter->flags & FMP_ADAPTER_INTERRUPT_IN_USE)) return; /* Any nonrecoverable hardware error? * Checks adapter->flags for any failure in phy reading */ - if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR) + if (adapter->flags & FMP_ADAPTER_NON_RECOVER_ERROR) return; /* Hardware failure? */ - if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) { + if (adapter->flags & FMP_ADAPTER_HARDWARE_ERROR) { dev_err(&adapter->pdev->dev, "hardware error - reset\n"); return; } @@ -4703,8 +4632,7 @@ static void et131x_tx_timeout(struct net_device *netdev) spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags); } -/** - * et131x_change_mtu - The handler called to change the MTU for the device +/* et131x_change_mtu - The handler called to change the MTU for the device * @netdev: device whose MTU is to be changed * @new_mtu: the desired MTU * @@ -4754,8 +4682,7 @@ static int et131x_change_mtu(struct net_device *netdev, int new_mtu) return result; } -/** - * et131x_set_mac_addr - handler to change the MAC address for the device +/* et131x_set_mac_addr - handler to change the MAC address for the device * @netdev: device whose MAC is to be changed * @new_mac: the desired MAC address * @@ -4828,8 +4755,7 @@ static const struct net_device_ops et131x_netdev_ops = { .ndo_do_ioctl = et131x_ioctl, }; -/** - * et131x_pci_setup - Perform device initialization +/* et131x_pci_setup - Perform device initialization * @pdev: a pointer to the device's pci_dev structure * @ent: this device's entry in the pci_device_id table * @@ -4963,11 +4889,10 @@ static int et131x_pci_setup(struct pci_dev *pdev, adapter->mii_bus->read = et131x_mdio_read; adapter->mii_bus->write = et131x_mdio_write; adapter->mii_bus->reset = et131x_mdio_reset; - adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); - if (!adapter->mii_bus->irq) { - dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); + adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), + GFP_KERNEL); + if (!adapter->mii_bus->irq) goto err_mdio_free; - } for (ii = 0; ii < PHY_MAX_ADDR; ii++) adapter->mii_bus->irq[ii] = PHY_POLL; diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index 347e63d..bbe78a7 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -145,6 +145,8 @@ *31: selfclr_disable */ +#define ET_RESET_ALL 0x007F; + /* * SLV Timer reg at address 0x002C (low 24 bits) */ @@ -317,6 +319,14 @@ struct txdma_regs { /* Location: */ * 18-31: unused */ +#define ET_RXDMA_CSR_HALT 0x0001 +#define ET_RXDMA_CSR_FBR0_SIZE_LO 0x0100 +#define ET_RXDMA_CSR_FBR0_SIZE_HI 0x0200 +#define ET_RXDMA_CSR_FBR0_ENABLE 0x0400 +#define ET_RXDMA_CSR_FBR1_SIZE_LO 0x0800 +#define ET_RXDMA_CSR_FBR1_SIZE_HI 0x1000 +#define ET_RXDMA_CSR_FBR1_ENABLE 0x2000 +#define ET_RXDMA_CSR_HALT_STATUS 0x00020000 /* * structure for dma writeback lo reg in rxdma address map @@ -384,6 +394,8 @@ struct txdma_regs { /* Location: */ * 11-0: psr ndes */ +#define ET_RXDMA_PSR_NUM_DES_MASK 0xFFF; + /* * structure for packet status ring available offset reg in rxdma address map * located at address 0x202C @@ -559,6 +571,9 @@ struct rxdma_regs { /* Location: */ * 0: txmac_en */ +#define ET_TX_CTRL_FC_DISABLE 0x0008 +#define ET_TX_CTRL_TXMAC_ENABLE 0x0001 + /* * structure for shadow pointer reg in txmac address map * located at address 0x3004 @@ -674,6 +689,9 @@ struct txmac_regs { /* Location: */ * 0: rxmac_en */ +#define ET_RX_CTRL_WOL_DISABLE 0x0008 +#define ET_RX_CTRL_RXMAC_ENABLE 0x0001 + /* * structure for Wake On Lan Control and CRC 0 reg in rxmac address map * located at address 0x4004 @@ -715,9 +733,9 @@ struct txmac_regs { /* Location: */ * 7-0: sa6 */ -#define ET_WOL_LO_SA3_SHIFT 24 -#define ET_WOL_LO_SA4_SHIFT 16 -#define ET_WOL_LO_SA5_SHIFT 8 +#define ET_RX_WOL_LO_SA3_SHIFT 24 +#define ET_RX_WOL_LO_SA4_SHIFT 16 +#define ET_RX_WOL_LO_SA5_SHIFT 8 /* * structure for Wake On Lan Source Address Hi reg in rxmac address map @@ -728,7 +746,7 @@ struct txmac_regs { /* Location: */ * 7-0: sa2 */ -#define ET_WOL_HI_SA1_SHIFT 8 +#define ET_RX_WOL_HI_SA1_SHIFT 8 /* * structure for Wake On Lan mask reg in rxmac address map @@ -746,9 +764,9 @@ struct txmac_regs { /* Location: */ * 7-0: addr1_6 */ -#define ET_UNI_PF_ADDR1_3_SHIFT 24 -#define ET_UNI_PF_ADDR1_4_SHIFT 16 -#define ET_UNI_PF_ADDR1_5_SHIFT 8 +#define ET_RX_UNI_PF_ADDR1_3_SHIFT 24 +#define ET_RX_UNI_PF_ADDR1_4_SHIFT 16 +#define ET_RX_UNI_PF_ADDR1_5_SHIFT 8 /* * structure for Unicast Paket Filter Address 2 reg in rxmac address map @@ -760,9 +778,9 @@ struct txmac_regs { /* Location: */ * 7-0: addr2_6 */ -#define ET_UNI_PF_ADDR2_3_SHIFT 24 -#define ET_UNI_PF_ADDR2_4_SHIFT 16 -#define ET_UNI_PF_ADDR2_5_SHIFT 8 +#define ET_RX_UNI_PF_ADDR2_3_SHIFT 24 +#define ET_RX_UNI_PF_ADDR2_4_SHIFT 16 +#define ET_RX_UNI_PF_ADDR2_5_SHIFT 8 /* * structure for Unicast Paket Filter Address 1 & 2 reg in rxmac address map @@ -774,10 +792,9 @@ struct txmac_regs { /* Location: */ * 7-0: addr1_2 */ -#define ET_UNI_PF_ADDR2_1_SHIFT 24 -#define ET_UNI_PF_ADDR2_2_SHIFT 16 -#define ET_UNI_PF_ADDR1_1_SHIFT 8 - +#define ET_RX_UNI_PF_ADDR2_1_SHIFT 24 +#define ET_RX_UNI_PF_ADDR2_2_SHIFT 16 +#define ET_RX_UNI_PF_ADDR1_1_SHIFT 8 /* * structure for Multicast Hash reg in rxmac address map @@ -798,6 +815,12 @@ struct txmac_regs { /* Location: */ * 0: filter_broad_en */ +#define ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT 16; +#define ET_RX_PFCTRL_FRAG_FILTER_ENABLE 0x0008; +#define ET_RX_PFCTRL_UNICST_FILTER_ENABLE 0x0004; +#define ET_RX_PFCTRL_MLTCST_FILTER_ENABLE 0x0002; +#define ET_RX_PFCTRL_BRDCST_FILTER_ENABLE 0x0001; + /* * structure for Memory Controller Interface Control Max Segment reg in rxmac * address map. Located at address 0x4088 @@ -808,6 +831,10 @@ struct txmac_regs { /* Location: */ * 0: seg_en */ +#define ET_RX_MCIF_CTRL_MAX_SEG_SIZE_SHIFT 2; +#define ET_RX_MCIF_CTRL_MAX_SEG_FC_ENABLE 0x0002; +#define ET_RX_MCIF_CTRL_MAX_SEG_ENABLE 0x0001; + /* * structure for Memory Controller Interface Water Mark reg in rxmac address * map. Located at address 0x408C @@ -907,7 +934,6 @@ struct rxmac_regs { /* Location: */ /* END OF RXMAC REGISTER ADDRESS MAP */ - /* START OF MAC REGISTER ADDRESS MAP */ /* @@ -932,12 +958,18 @@ struct rxmac_regs { /* Location: */ * 0: tx enable */ -#define CFG1_LOOPBACK 0x00000100 -#define CFG1_RX_FLOW 0x00000020 -#define CFG1_TX_FLOW 0x00000010 -#define CFG1_RX_ENABLE 0x00000004 -#define CFG1_TX_ENABLE 0x00000001 -#define CFG1_WAIT 0x0000000A /* RX & TX syncd */ +#define ET_MAC_CFG1_SOFT_RESET 0x80000000 +#define ET_MAC_CFG1_SIM_RESET 0x40000000 +#define ET_MAC_CFG1_RESET_RXMC 0x00080000 +#define ET_MAC_CFG1_RESET_TXMC 0x00040000 +#define ET_MAC_CFG1_RESET_RXFUNC 0x00020000 +#define ET_MAC_CFG1_RESET_TXFUNC 0x00010000 +#define ET_MAC_CFG1_LOOPBACK 0x00000100 +#define ET_MAC_CFG1_RX_FLOW 0x00000020 +#define ET_MAC_CFG1_TX_FLOW 0x00000010 +#define ET_MAC_CFG1_RX_ENABLE 0x00000004 +#define ET_MAC_CFG1_TX_ENABLE 0x00000001 +#define ET_MAC_CFG1_WAIT 0x0000000A /* RX & TX syncd */ /* * structure for configuration #2 reg in mac address map. @@ -955,6 +987,15 @@ struct rxmac_regs { /* Location: */ * 0: full duplex */ +#define ET_MAC_CFG2_PREAMBLE_SHIFT 12; +#define ET_MAC_CFG2_IFMODE_MASK 0x0300; +#define ET_MAC_CFG2_IFMODE_1000 0x0200; +#define ET_MAC_CFG2_IFMODE_100 0x0100; +#define ET_MAC_CFG2_IFMODE_HUGE_FRAME 0x0020; +#define ET_MAC_CFG2_IFMODE_LEN_CHECK 0x0010; +#define ET_MAC_CFG2_IFMODE_PAD_CRC 0x0004; +#define ET_MAC_CFG2_IFMODE_CRC_ENABLE 0x0002; +#define ET_MAC_CFG2_IFMODE_FULL_DPLX 0x0001; /* * structure for Interpacket gap reg in mac address map. @@ -1009,6 +1050,8 @@ struct rxmac_regs { /* Location: */ * 2-0: mgmt clock reset */ +#define ET_MAC_MIIMGMT_CLK_RST 0x0007 + /* * structure for MII Management Command reg in mac address map. * located at address 0x5024 @@ -1025,7 +1068,7 @@ struct rxmac_regs { /* Location: */ * 4-0: register */ -#define MII_ADDR(phy, reg) ((phy) << 8 | (reg)) +#define ET_MAC_MII_ADDR(phy, reg) ((phy) << 8 | (reg)) /* * structure for MII Management Control reg in mac address map. @@ -1041,6 +1084,8 @@ struct rxmac_regs { /* Location: */ * 15-0: phy control */ +#define ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK 0xFFFF; + /* * structure for MII Management Indicators reg in mac address map. * located at address 0x5034 @@ -1050,8 +1095,8 @@ struct rxmac_regs { /* Location: */ * 0: busy */ -#define MGMT_BUSY 0x00000001 /* busy */ -#define MGMT_WAIT 0x00000005 /* busy | not valid */ +#define ET_MAC_MGMT_BUSY 0x00000001 /* busy */ +#define ET_MAC_MGMT_WAIT 0x00000005 /* busy | not valid */ /* * structure for Interface Control reg in mac address map. @@ -1076,6 +1121,9 @@ struct rxmac_regs { /* Location: */ * 0: enable jabber protection */ +#define ET_MAC_IFCTRL_GHDMODE (1 << 26) +#define ET_MAC_IFCTRL_PHYMODE (1 << 24) + /* * structure for Interface Status reg in mac address map. * located at address 0x503C diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c index 33085782..ea9362d 100644 --- a/drivers/staging/frontier/alphatrack.c +++ b/drivers/staging/frontier/alphatrack.c @@ -678,10 +678,9 @@ static int usb_alphatrack_probe(struct usb_interface *intf, /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&intf->dev, "Out of memory\n"); + if (dev == NULL) goto exit; - } + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); @@ -721,28 +720,21 @@ static int usb_alphatrack_probe(struct usb_interface *intf, /* FIXME - there are more usb_alloc routines for dma correctness. Needed? */ - dev->ring_buffer = - kmalloc((true_size * sizeof(struct alphatrack_icmd)), GFP_KERNEL); - - if (!dev->ring_buffer) { - dev_err(&intf->dev, - "Couldn't allocate input ring_buffer of size %d\n", - true_size); + dev->ring_buffer = kmalloc_array(true_size, + sizeof(struct alphatrack_icmd), + GFP_KERNEL); + if (!dev->ring_buffer) goto error; - } - dev->interrupt_in_buffer = - kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - - if (!dev->interrupt_in_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); + dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, + GFP_KERNEL); + if (!dev->interrupt_in_buffer) goto error; - } + dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - if (!dev->oldi_buffer) { - dev_err(&intf->dev, "Couldn't allocate old buffer\n"); + if (!dev->oldi_buffer) goto error; - } + dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); @@ -764,20 +756,17 @@ static int usb_alphatrack_probe(struct usb_interface *intf, true_size = min(write_buffer_size, WRITE_BUFFER_SIZE); dev->interrupt_out_buffer = - kmalloc(true_size * dev->interrupt_out_endpoint_size, GFP_KERNEL); - - if (!dev->interrupt_out_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); + kmalloc_array(true_size, + dev->interrupt_out_endpoint_size, + GFP_KERNEL); + if (!dev->interrupt_out_buffer) goto error; - } - - dev->write_buffer = - kmalloc(true_size * sizeof(struct alphatrack_ocmd), GFP_KERNEL); - if (!dev->write_buffer) { - dev_err(&intf->dev, "Couldn't allocate write_buffer\n"); + dev->write_buffer = kmalloc_array(true_size, + sizeof(struct alphatrack_ocmd), + GFP_KERNEL); + if (!dev->write_buffer) goto error; - } dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 5196a4e..04b5e66d 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -803,10 +803,9 @@ static int usb_tranzport_probe(struct usb_interface *intf, /* allocate memory for our device state and initialize it */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&intf->dev, "Out of memory\n"); + if (dev == NULL) goto exit; - } + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); @@ -848,18 +847,14 @@ static int usb_tranzport_probe(struct usb_interface *intf, dev->ring_buffer = kmalloc((true_size * sizeof(struct tranzport_cmd)) + 8, GFP_KERNEL); - - if (!dev->ring_buffer) { - dev_err(&intf->dev, - "Couldn't allocate ring_buffer size %d\n", true_size); + if (!dev->ring_buffer) goto error; - } + dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - if (!dev->interrupt_in_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); + if (!dev->interrupt_in_buffer) goto error; - } + dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_in_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); @@ -875,12 +870,11 @@ static int usb_tranzport_probe(struct usb_interface *intf, "Interrupt out endpoint size is not 8!)\n"); dev->interrupt_out_buffer = - kmalloc(write_buffer_size * dev->interrupt_out_endpoint_size, - GFP_KERNEL); - if (!dev->interrupt_out_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); + kmalloc_array(write_buffer_size, + dev->interrupt_out_endpoint_size, GFP_KERNEL); + if (!dev->interrupt_out_buffer) goto error; - } + dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->interrupt_out_urb) { dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n"); diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h index adb436e..65f7ab6 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h @@ -31,41 +31,10 @@ #define SUCCESS 0x00 #define FAILURE 0x01 -struct ft1000_info { - struct net_device_stats stats; - u16 DrvErrNum; - u16 AsicID; +struct ft1000_pcmcia { int PktIntfErr; - int CardReady; - int registered; - int mediastate; u16 packetseqnum; - u8 squeseqnum; /* sequence number on slow queue */ - spinlock_t dpram_lock; - u16 fifo_cnt; - u8 DspVer[DSPVERSZ]; /* DSP version number */ - u8 HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ - u8 Sku[SKUSZ]; /* SKU */ - u8 eui64[EUISZ]; /* EUI64 */ - time_t ConTm; /* Connection Time */ - u16 LedStat; - u16 ConStat; - u16 ProgConStat; - u8 ProductMode[MODESZ]; - u8 RfCalVer[CALVERSZ]; - u8 RfCalDate[CALDATESZ]; - u16 DSP_TIME[4]; - struct list_head prov_list; - u16 DSPInfoBlklen; - int (*ft1000_reset)(void *); void *link; - u16 DSPInfoBlk[MAX_DSP_SESS_REC]; - union { - u16 Rec[MAX_DSP_SESS_REC]; - u32 MagRec[MAX_DSP_SESS_REC/2]; - } DSPSess; - struct proc_dir_entry *proc_ft1000; - char netdevname[IFNAMSIZ]; }; struct pcmcia_device; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 67ca5c9..29d0a72 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -328,11 +328,12 @@ static void ft1000_disable_interrupts(struct net_device *dev) static void ft1000_reset_asic(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); + struct ft1000_pcmcia *pcmcia = info->priv; u16 tempword; DEBUG(1, "ft1000_hw:ft1000_reset_asic called\n"); - (*info->ft1000_reset) (info->link); + (*info->ft1000_reset) (pcmcia->link); // Let's use the register provided by the Magnemite ASIC to reset the // ASIC and DSP. @@ -1397,12 +1398,13 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) { struct ft1000_info *info = netdev_priv(dev); + struct ft1000_pcmcia *pcmcia = info->priv; u16 i; u32 templong; u16 tempword; DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n"); - if (info->PktIntfErr > MAX_PH_ERR) { + if (pcmcia->PktIntfErr > MAX_PH_ERR) { if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -1491,7 +1493,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) FIFO_FLUSH_BADCNT; } else { // Let's assume that we really flush the FIFO - info->PktIntfErr++; + pcmcia->PktIntfErr++; return; } } else { @@ -1522,7 +1524,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword); } if (DrvErrNum) { - info->PktIntfErr++; + pcmcia->PktIntfErr++; } } } @@ -1731,6 +1733,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len) { struct ft1000_info *info = netdev_priv(dev); + struct ft1000_pcmcia *pcmcia = info->priv; union { struct pseudo_hdr blk; u16 buff[sizeof(struct pseudo_hdr) >> 1]; @@ -1780,7 +1783,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len) pseudo.blk.control = 0; pseudo.blk.rsvd1 = 0; pseudo.blk.seq_num = 0; - pseudo.blk.rsvd2 = info->packetseqnum++; + pseudo.blk.rsvd2 = pcmcia->packetseqnum++; pseudo.blk.qos_class = 0; /* Calculate pseudo header checksum */ pseudo.blk.checksum = pseudo.buff[0]; @@ -2058,6 +2061,8 @@ void stop_ft1000_card(struct net_device *dev) kfree(ptr); } + kfree(info->priv); + if (info->registered) { unregister_netdev(dev); info->registered = 0; @@ -2101,6 +2106,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, void *ft1000_reset) { struct ft1000_info *info; + struct ft1000_pcmcia *pcmcia; struct net_device *dev; static const struct net_device_ops ft1000ops = // Slavius 21.10.2009 due to kernel changes @@ -2142,10 +2148,13 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, memset(&info->stats, 0, sizeof(struct net_device_stats)); + info->priv = kzalloc(sizeof(struct ft1000_pcmcia), GFP_KERNEL); + pcmcia = info->priv; + pcmcia->link = link; + spin_lock_init(&info->dpram_lock); info->DrvErrNum = 0; info->registered = 1; - info->link = link; info->ft1000_reset = ft1000_reset; info->mediastate = 0; info->fifo_cnt = 0; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 72727c6..5337b41 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c @@ -175,8 +175,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, switch (event) { case NETDEV_CHANGENAME: - remove_proc_entry(info->netdevname, info->proc_ft1000); - create_proc_read_entry(dev->name, 0644, info->proc_ft1000, + remove_proc_entry(info->netdevname, info->ft1000_proc_dir); + create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, ft1000ReadProc, dev); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); break; @@ -194,8 +194,8 @@ void ft1000InitProc(struct net_device *dev) info = netdev_priv(dev); - info->proc_ft1000 = proc_mkdir(FT1000_PROC, init_net.proc_net); - create_proc_read_entry(dev->name, 0644, info->proc_ft1000, + info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net); + create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, ft1000ReadProc, dev); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); register_netdevice_notifier(&ft1000_netdev_notifier); @@ -207,7 +207,7 @@ void ft1000CleanupProc(struct net_device *dev) info = netdev_priv(dev); - remove_proc_entry(dev->name, info->proc_ft1000); + remove_proc_entry(dev->name, info->ft1000_proc_dir); remove_proc_entry(FT1000_PROC, init_net.proc_net); unregister_netdevice_notifier(&ft1000_netdev_notifier); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 6d911fd..297389e 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -137,29 +137,28 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist) // Notes: Only called by init_module(). // //--------------------------------------------------------------------------- -int ft1000_create_dev(struct ft1000_device *dev) +int ft1000_create_dev(struct ft1000_usb *dev) { - struct ft1000_info *info = netdev_priv(dev->net); int result; int i; struct dentry *dir, *file; struct ft1000_debug_dirs *tmp; // make a new device name - sprintf(info->DeviceName, "%s%d", "FT1000_", info->CardNumber); + sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); - DEBUG("DeviceCreated = %x\n", info->DeviceCreated); + DEBUG("DeviceCreated = %x\n", dev->DeviceCreated); - if (info->DeviceCreated) + if (dev->DeviceCreated) { - DEBUG("%s: \"%s\" already registered\n", __func__, info->DeviceName); + DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName); return -EIO; } // register the device - DEBUG("%s: \"%s\" debugfs device registration\n", __func__, info->DeviceName); + DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL); if (tmp == NULL) { @@ -167,7 +166,7 @@ int ft1000_create_dev(struct ft1000_device *dev) goto fail; } - dir = debugfs_create_dir(info->DeviceName, NULL); + dir = debugfs_create_dir(dev->DeviceName, NULL); if (IS_ERR(dir)) { result = PTR_ERR(dir); goto debug_dir_fail; @@ -182,27 +181,27 @@ int ft1000_create_dev(struct ft1000_device *dev) tmp->dent = dir; tmp->file = file; - tmp->int_number = info->CardNumber; - list_add(&(tmp->list), &(info->nodes.list)); + tmp->int_number = dev->CardNumber; + list_add(&(tmp->list), &(dev->nodes.list)); - DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, info->DeviceName); + DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); // initialize application information - info->appcnt = 0; + dev->appcnt = 0; for (i=0; i<MAX_NUM_APP; i++) { - info->app_info[i].nTxMsg = 0; - info->app_info[i].nRxMsg = 0; - info->app_info[i].nTxMsgReject = 0; - info->app_info[i].nRxMsgMiss = 0; - info->app_info[i].fileobject = NULL; - info->app_info[i].app_id = i+1; - info->app_info[i].DspBCMsgFlag = 0; - info->app_info[i].NumOfMsg = 0; - init_waitqueue_head(&info->app_info[i].wait_dpram_msg); - INIT_LIST_HEAD (&info->app_info[i].app_sqlist); + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; + dev->app_info[i].fileobject = NULL; + dev->app_info[i].app_id = i+1; + dev->app_info[i].DspBCMsgFlag = 0; + dev->app_info[i].NumOfMsg = 0; + init_waitqueue_head(&dev->app_info[i].wait_dpram_msg); + INIT_LIST_HEAD (&dev->app_info[i].app_sqlist); } - info->DeviceCreated = TRUE; + dev->DeviceCreated = TRUE; ft1000_flarion_cnt++; return 0; @@ -225,9 +224,10 @@ fail: // Notes: Only called by cleanup_module(). // //--------------------------------------------------------------------------- -void ft1000_destroy_dev(struct net_device *dev) +void ft1000_destroy_dev(struct net_device *netdev) { - struct ft1000_info *info = netdev_priv(dev); + struct ft1000_info *info = netdev_priv(netdev); + struct ft1000_usb *dev = info->priv; int i; struct dpram_blk *pdpram_blk; struct dpram_blk *ptr; @@ -238,12 +238,12 @@ void ft1000_destroy_dev(struct net_device *dev) - if (info->DeviceCreated) + if (dev->DeviceCreated) { ft1000_flarion_cnt--; - list_for_each_safe(pos, q, &info->nodes.list) { + list_for_each_safe(pos, q, &dev->nodes.list) { dir = list_entry(pos, struct ft1000_debug_dirs, list); - if (dir->int_number == info->CardNumber) { + if (dir->int_number == dev->CardNumber) { debugfs_remove(dir->file); debugfs_remove(dir->dent); list_del(pos); @@ -251,17 +251,17 @@ void ft1000_destroy_dev(struct net_device *dev) } } DEBUG("%s: unregistered device \"%s\"\n", __func__, - info->DeviceName); + dev->DeviceName); // Make sure we free any memory reserve for slow Queue for (i=0; i<MAX_NUM_APP; i++) { - while (list_empty(&info->app_info[i].app_sqlist) == 0) { - pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list); + while (list_empty(&dev->app_info[i].app_sqlist) == 0) { + pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list); list_del(&pdpram_blk->list); ft1000_free_buffer(pdpram_blk, &freercvpool); } - wake_up_interruptible(&info->app_info[i].wait_dpram_msg); + wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); } // Remove buffer allocated for receive command data @@ -273,7 +273,7 @@ void ft1000_destroy_dev(struct net_device *dev) kfree(ptr); } } - info->DeviceCreated = FALSE; + dev->DeviceCreated = FALSE; } @@ -292,7 +292,7 @@ void ft1000_destroy_dev(struct net_device *dev) static int ft1000_open (struct inode *inode, struct file *file) { struct ft1000_info *info; - struct ft1000_device *dev = (struct ft1000_device *)inode->i_private; + struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private; int i,num; DEBUG("%s called\n", __func__); @@ -301,17 +301,17 @@ static int ft1000_open (struct inode *inode, struct file *file) info = file->private_data = netdev_priv(dev->net); - DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), info->appcnt ); + DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt ); // Check if maximum number of application exceeded - if (info->appcnt > MAX_NUM_APP) { + if (dev->appcnt > MAX_NUM_APP) { DEBUG("Maximum number of application exceeded\n"); return -EACCES; } // Search for available application info block for (i=0; i<MAX_NUM_APP; i++) { - if ( (info->app_info[i].fileobject == NULL) ) { + if ( (dev->app_info[i].fileobject == NULL) ) { break; } } @@ -322,12 +322,12 @@ static int ft1000_open (struct inode *inode, struct file *file) return -EACCES; } - info->appcnt++; - info->app_info[i].fileobject = &file->f_owner; - info->app_info[i].nTxMsg = 0; - info->app_info[i].nRxMsg = 0; - info->app_info[i].nTxMsgReject = 0; - info->app_info[i].nRxMsgMiss = 0; + dev->appcnt++; + dev->app_info[i].fileobject = &file->f_owner; + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; nonseekable_open(inode, file); return 0; @@ -347,8 +347,9 @@ static int ft1000_open (struct inode *inode, struct file *file) static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) { - struct net_device *dev = file->private_data; - struct ft1000_info *info; + struct net_device *netdev = file->private_data; + struct ft1000_info *info = netdev_priv(netdev); + struct ft1000_usb *dev = info->priv; int i; //DEBUG("ft1000_poll_dev called\n"); @@ -357,12 +358,10 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) return (-EBADF); } - info = netdev_priv(dev); - // Search for matching file object for (i=0; i<MAX_NUM_APP; i++) { - if ( info->app_info[i].fileobject == &file->f_owner) { - //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id); + if ( dev->app_info[i].fileobject == &file->f_owner) { + //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); break; } } @@ -373,12 +372,12 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) return ( -EACCES ); } - if (list_empty(&info->app_info[i].app_sqlist) == 0) { + if (list_empty(&dev->app_info[i].app_sqlist) == 0) { DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n"); return(POLLIN | POLLRDNORM | POLLPRI); } - poll_wait (file, &info->app_info[i].wait_dpram_msg, wait); + poll_wait (file, &dev->app_info[i].wait_dpram_msg, wait); //DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); return (0); @@ -399,7 +398,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, { void __user *argp = (void __user *)argument; struct ft1000_info *info; - struct ft1000_device *ft1000dev; + struct ft1000_usb *ft1000dev; int result=0; int cmd; int i; @@ -428,7 +427,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, //DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); info = file->private_data; - ft1000dev = info->pFt1000Dev; + ft1000dev = info->priv; cmd = _IOC_NR(command); //DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); @@ -444,8 +443,8 @@ static long ft1000_ioctl (struct file *file, unsigned int command, if (tempword == DSPBCMSGID) { // Search for matching file object for (i=0; i<MAX_NUM_APP; i++) { - if ( info->app_info[i].fileobject == &file->f_owner) { - info->app_info[i].DspBCMsgFlag = 1; + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + ft1000dev->app_info[i].DspBCMsgFlag = 1; DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n"); break; } @@ -534,15 +533,15 @@ static long ft1000_ioctl (struct file *file, unsigned int command, return (-EBADF); } - if (info->DrvMsgPend) { + if (ft1000dev->DrvMsgPend) { return (-ENOTTY); } - if ( (info->DspAsicReset) || (info->fProvComplete == 0) ) { + if (ft1000dev->fProvComplete == 0) { return (-EACCES); } - info->fAppMsgPend = 1; + ft1000dev->fAppMsgPend = 1; if (info->CardReady) { @@ -571,7 +570,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, else { // Check if this message came from a registered application for (i=0; i<MAX_NUM_APP; i++) { - if ( info->app_info[i].fileobject == &file->f_owner) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { break; } } @@ -632,7 +631,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, // Insert slow queue sequence number ppseudo_hdr->seq_num = info->squeseqnum++; - ppseudo_hdr->portsrc = info->app_info[app_index].app_id; + ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; // Calculate new checksum ppseudo_hdr->checksum = *pmsg++; //DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); @@ -645,7 +644,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, card_send_command(ft1000dev,(unsigned short*)dpram_data,total_len+2); - info->app_info[app_index].nTxMsg++; + ft1000dev->app_info[app_index].nTxMsg++; } else { result = -EINVAL; @@ -675,8 +674,8 @@ static long ft1000_ioctl (struct file *file, unsigned int command, // Search for matching file object for (i=0; i<MAX_NUM_APP; i++) { - if ( info->app_info[i].fileobject == &file->f_owner) { - //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id); + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); break; } } @@ -690,13 +689,13 @@ static long ft1000_ioctl (struct file *file, unsigned int command, result = 0; pioctl_dpram = argp; - if (list_empty(&info->app_info[i].app_sqlist) == 0) { + if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { //DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); spin_lock_irqsave(&free_buff_lock, flags); - pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); list_del(&pdpram_blk->list); - info->app_info[i].NumOfMsg--; - //DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, info->app_info[i].NumOfMsg); + ft1000dev->app_info[i].NumOfMsg--; + //DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); spin_unlock_irqrestore(&free_buff_lock, flags); msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; result = get_user(msglen, &pioctl_dpram->total_len); @@ -723,7 +722,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, result = -ENOTTY; break; } - info->fAppMsgPend = 0; + ft1000dev->fAppMsgPend = 0; return result; } @@ -741,6 +740,7 @@ static int ft1000_release (struct inode *inode, struct file *file) { struct ft1000_info *info; struct net_device *dev; + struct ft1000_usb *ft1000dev; int i; struct dpram_blk *pdpram_blk; @@ -748,16 +748,17 @@ static int ft1000_release (struct inode *inode, struct file *file) dev = file->private_data; info = netdev_priv(dev); + ft1000dev = info->priv; if (ft1000_flarion_cnt == 0) { - info->appcnt--; + ft1000dev->appcnt--; return (-EBADF); } // Search for matching file object for (i=0; i<MAX_NUM_APP; i++) { - if ( info->app_info[i].fileobject == &file->f_owner) { - //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id); + if ( ft1000dev->app_info[i].fileobject == &file->f_owner) { + //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); break; } } @@ -765,17 +766,17 @@ static int ft1000_release (struct inode *inode, struct file *file) if (i==MAX_NUM_APP) return 0; - while (list_empty(&info->app_info[i].app_sqlist) == 0) { + while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { DEBUG("Remove and free memory queue up on slow queue\n"); - pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); list_del(&pdpram_blk->list); ft1000_free_buffer(pdpram_blk, &freercvpool); } // initialize application information - info->appcnt--; - DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, info->appcnt); - info->app_info[i].fileobject = NULL; + ft1000dev->appcnt--; + DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt); + ft1000dev->app_info[i].fileobject = NULL; return 0; } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 1972b72..5190c8a 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -114,7 +114,7 @@ struct dsp_image_info { //--------------------------------------------------------------------------- // Function: check_usb_db // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // // Returns: 0 - success // @@ -123,7 +123,7 @@ struct dsp_image_info { // Notes: // //--------------------------------------------------------------------------- -static u32 check_usb_db (struct ft1000_device *ft1000dev) +static u32 check_usb_db (struct ft1000_usb *ft1000dev) { int loopcnt; u16 temp; @@ -172,7 +172,7 @@ static u32 check_usb_db (struct ft1000_device *ft1000dev) //--------------------------------------------------------------------------- // Function: get_handshake // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // u16 expected_value - the handshake value expected // // Returns: handshakevalue - success @@ -183,12 +183,11 @@ static u32 check_usb_db (struct ft1000_device *ft1000dev) // Notes: // //--------------------------------------------------------------------------- -static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value) +static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) { u16 handshake; int loopcnt; u32 status = 0; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); loopcnt = 0; @@ -196,10 +195,10 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value) /* Need to clear downloader doorbell if Hartley ASIC */ status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_RX, FT1000_REG_DOORBELL); - if (pft1000info->fcodeldr) { + if (ft1000dev->fcodeldr) { DEBUG(" get_handshake: fcodeldr is %d\n", - pft1000info->fcodeldr); - pft1000info->fcodeldr = 0; + ft1000dev->fcodeldr); + ft1000dev->fcodeldr = 0; status = check_usb_db(ft1000dev); if (status != STATUS_SUCCESS) { DEBUG("get_handshake: check_usb_db failed\n"); @@ -233,7 +232,7 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value) //--------------------------------------------------------------------------- // Function: put_handshake // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // u16 handshake_value - handshake to be written // // Returns: none @@ -244,7 +243,7 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value) // Notes: // //--------------------------------------------------------------------------- -static void put_handshake(struct ft1000_device *ft1000dev,u16 handshake_value) +static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value) { u32 tempx; u16 tempword; @@ -263,36 +262,35 @@ static void put_handshake(struct ft1000_device *ft1000dev,u16 handshake_value) FT1000_REG_DOORBELL); } -static u16 get_handshake_usb(struct ft1000_device *ft1000dev, u16 expected_value) +static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) { u16 handshake; int loopcnt; u16 temp; u32 status = 0; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); loopcnt = 0; handshake = 0; while (loopcnt < 100) { - if (pft1000info->usbboot == 2) { + if (ft1000dev->usbboot == 2) { status = ft1000_read_dpram32(ft1000dev, 0, - (u8 *)&(pft1000info->tempbuf[0]), 64); + (u8 *)&(ft1000dev->tempbuf[0]), 64); for (temp = 0; temp < 16; temp++) { DEBUG("tempbuf %d = 0x%x\n", temp, - pft1000info->tempbuf[temp]); + ft1000dev->tempbuf[temp]); } status = ft1000_read_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); DEBUG("handshake from read_dpram16 = 0x%x\n", handshake); - if (pft1000info->dspalive == pft1000info->tempbuf[6]) { + if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) { handshake = 0; } else { - handshake = pft1000info->tempbuf[1]; - pft1000info->dspalive = - pft1000info->tempbuf[6]; + handshake = ft1000dev->tempbuf[1]; + ft1000dev->dspalive = + ft1000dev->tempbuf[6]; } } else { status = ft1000_read_dpram16(ft1000dev, @@ -311,7 +309,7 @@ static u16 get_handshake_usb(struct ft1000_device *ft1000dev, u16 expected_value return HANDSHAKE_TIMEOUT_VALUE; } -static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_value) +static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value) { int i; @@ -321,7 +319,7 @@ static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_valu //--------------------------------------------------------------------------- // Function: get_request_type // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // // Returns: request type - success // @@ -330,15 +328,14 @@ static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_valu // Notes: // //--------------------------------------------------------------------------- -static u16 get_request_type(struct ft1000_device *ft1000dev) +static u16 get_request_type(struct ft1000_usb *ft1000dev) { u16 request_type; u32 status; u16 tempword; u32 tempx; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); - if (pft1000info->bootmode == 1) { + if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); @@ -354,22 +351,21 @@ static u16 get_request_type(struct ft1000_device *ft1000dev) return request_type; } -static u16 get_request_type_usb(struct ft1000_device *ft1000dev) +static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) { u16 request_type; u32 status; u16 tempword; u32 tempx; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); - if (pft1000info->bootmode == 1) { + if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); } else { - if (pft1000info->usbboot == 2) { - tempx = pft1000info->tempbuf[2]; - tempword = pft1000info->tempbuf[3]; + if (ft1000dev->usbboot == 2) { + tempx = ft1000dev->tempbuf[2]; + tempword = ft1000dev->tempbuf[3]; } else { tempx = 0; status = ft1000_read_dpram16(ft1000dev, @@ -387,7 +383,7 @@ static u16 get_request_type_usb(struct ft1000_device *ft1000dev) //--------------------------------------------------------------------------- // Function: get_request_value // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // // Returns: request value - success // @@ -396,14 +392,13 @@ static u16 get_request_type_usb(struct ft1000_device *ft1000dev) // Notes: // //--------------------------------------------------------------------------- -static long get_request_value(struct ft1000_device *ft1000dev) +static long get_request_value(struct ft1000_usb *ft1000dev) { u32 value; u16 tempword; u32 status; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); - if (pft1000info->bootmode == 1) { + if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, DWNLD_MAG1_SIZE_LOC, (u8 *)&value); value = ntohl(value); @@ -424,7 +419,7 @@ static long get_request_value(struct ft1000_device *ft1000dev) //--------------------------------------------------------------------------- // Function: put_request_value // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // long lvalue - value to be put into DPRAM location DWNLD_MAG1_SIZE_LOC // // Returns: none @@ -434,7 +429,7 @@ static long get_request_value(struct ft1000_device *ft1000dev) // Notes: // //--------------------------------------------------------------------------- -static void put_request_value(struct ft1000_device *ft1000dev, long lvalue) +static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue) { u32 tempx; u32 status; @@ -485,7 +480,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) //--------------------------------------------------------------------------- // Function: write_blk // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // u16 **pUsFile - DSP image file pointer in u16 // u8 **pUcFile - DSP image file pointer in u8 // long word_length - length of the buffer to be written @@ -499,7 +494,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) // Notes: // //--------------------------------------------------------------------------- -static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) +static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { u32 Status = STATUS_SUCCESS; u16 dpram; @@ -507,7 +502,6 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi u16 tempword; u16 tempbuffer[64]; u16 resultbuffer[64]; - struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; @@ -548,7 +542,7 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi //DEBUG("write_blk: loopcnt is %d\n", loopcnt); //DEBUG("write_blk: bootmode = %d\n", bootmode); //DEBUG("write_blk: dpram = %x\n", dpram); - if (pft1000info->bootmode == 0) + if (ft1000dev->bootmode == 0) { if (dpram >= 0x3F4) Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 8); @@ -625,7 +619,7 @@ static void usb_dnld_complete (struct urb *urb) //--------------------------------------------------------------------------- // Function: write_blk_fifo // -// Parameters: struct ft1000_device - device structure +// Parameters: struct ft1000_usb - device structure // u16 **pUsFile - DSP image file pointer in u16 // u8 **pUcFile - DSP image file pointer in u8 // long word_length - length of the buffer to be written @@ -639,7 +633,7 @@ static void usb_dnld_complete (struct urb *urb) // Notes: // //--------------------------------------------------------------------------- -static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile, +static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { u32 Status = STATUS_SUCCESS; @@ -682,7 +676,7 @@ static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile, // Returns: status - return code //--------------------------------------------------------------------------- -u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, +u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, u32 FileLength) { u16 status = STATUS_SUCCESS; @@ -718,9 +712,9 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, DEBUG("Entered scram_dnldr...\n"); - pft1000info->fcodeldr = 0; - pft1000info->usbboot = 0; - pft1000info->dspalive = 0xffff; + ft1000dev->fcodeldr = 0; + ft1000dev->usbboot = 0; + ft1000dev->dspalive = 0xffff; // // Get version id of file, at first 4 bytes of file, for newer files. @@ -745,7 +739,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, switch (state) { case STATE_START_DWNLD: DEBUG("FT1000:STATE_START_DWNLD\n"); - if (pft1000info->usbboot) + if (ft1000dev->usbboot) handshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); @@ -771,7 +765,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, case STATE_BOOT_DWNLD: DEBUG("FT1000:STATE_BOOT_DWNLD\n"); - pft1000info->bootmode = 1; + ft1000dev->bootmode = 1; handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST); if (handshake == HANDSHAKE_REQUEST) { /* @@ -797,7 +791,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, //DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); //DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); state = STATE_CODE_DWNLD; - pft1000info->fcodeldr = 1; + ft1000dev->fcodeldr = 1; break; case REQUEST_CODE_SEGMENT: //DEBUG("FT1000:REQUEST_CODE_SEGMENT\n"); @@ -842,7 +836,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, status = STATUS_FAILURE; break; } - if (pft1000info->usbboot) + if (ft1000dev->usbboot) put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE); else @@ -858,8 +852,8 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, case STATE_CODE_DWNLD: //DEBUG("FT1000:STATE_CODE_DWNLD\n"); - pft1000info->bootmode = 0; - if (pft1000info->usbboot) + ft1000dev->bootmode = 0; + if (ft1000dev->usbboot) handshake = get_handshake_usb(ft1000dev, HANDSHAKE_REQUEST); @@ -870,7 +864,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, /* * Get type associated with the request. */ - if (pft1000info->usbboot) + if (ft1000dev->usbboot) request = get_request_type_usb(ft1000dev); else @@ -916,7 +910,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, } break; case REQUEST_DONE_CL: - pft1000info->usbboot = 3; + ft1000dev->usbboot = 3; /* Reposition ptrs to beginning of provisioning section */ s_file = (u16 *) (pFileStart + @@ -965,9 +959,9 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, write_blk_fifo(ft1000dev, &s_file, &c_file, word_length); - if (pft1000info->usbboot == 0) - pft1000info->usbboot++; - if (pft1000info->usbboot == 1) { + if (ft1000dev->usbboot == 0) + ft1000dev->usbboot++; + if (ft1000dev->usbboot == 1) { tempword = 0; ft1000_write_dpram16(ft1000dev, DWNLD_MAG1_PS_HDR_LOC, @@ -1117,7 +1111,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, status = STATUS_FAILURE; break; } - if (pft1000info->usbboot) + if (ft1000dev->usbboot) put_handshake_usb(ft1000dev, HANDSHAKE_RESPONSE); else diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 809fa48..9b8fed7 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -29,12 +29,12 @@ //#define JDEBUG -static int ft1000_reset(struct net_device *ft1000dev); +static int ft1000_reset(void *ft1000dev); static int ft1000_submit_rx_urb(struct ft1000_info *info); static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev); static int ft1000_open (struct net_device *dev); static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev); -static int ft1000_chkcard (struct ft1000_device *dev); +static int ft1000_chkcard (struct ft1000_usb *dev); static u8 tempbuffer[1600]; @@ -43,7 +43,7 @@ static u8 tempbuffer[1600]; //--------------------------------------------------------------------------- // Function: ft1000_control // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // pipe - usb control message pipe // request - control request // requesttype - control message request type @@ -61,7 +61,7 @@ static u8 tempbuffer[1600]; // Notes: // //--------------------------------------------------------------------------- -static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe, +static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe, u8 request, u8 requesttype, u16 value, u16 index, void *data, u16 size, int timeout) { @@ -84,7 +84,7 @@ static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe, //--------------------------------------------------------------------------- // Function: ft1000_read_register // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // Data - data buffer to hold the value read // nRegIndex - register index // @@ -97,7 +97,7 @@ static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe, // //--------------------------------------------------------------------------- -int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, +int ft1000_read_register(struct ft1000_usb *ft1000dev, u16* Data, u16 nRegIndx) { int ret = STATUS_SUCCESS; @@ -118,7 +118,7 @@ int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, //--------------------------------------------------------------------------- // Function: ft1000_write_register // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // value - value to write into a register // nRegIndex - register index // @@ -130,7 +130,7 @@ int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, // Notes: // //--------------------------------------------------------------------------- -int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value, +int ft1000_write_register(struct ft1000_usb *ft1000dev, u16 value, u16 nRegIndx) { int ret = STATUS_SUCCESS; @@ -151,7 +151,7 @@ int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value, //--------------------------------------------------------------------------- // Function: ft1000_read_dpram32 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to read // buffer - data buffer to hold the data read // cnt - number of byte read from DPRAM @@ -165,7 +165,7 @@ int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value, // //--------------------------------------------------------------------------- -int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, +int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u16 cnt) { int ret = STATUS_SUCCESS; @@ -186,7 +186,7 @@ int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, //--------------------------------------------------------------------------- // Function: ft1000_write_dpram32 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to write the data // buffer - data buffer to write into DPRAM // cnt - number of bytes to write @@ -199,7 +199,7 @@ int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, // Notes: // //--------------------------------------------------------------------------- -int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, +int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u16 cnt) { int ret = STATUS_SUCCESS; @@ -223,7 +223,7 @@ int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, //--------------------------------------------------------------------------- // Function: ft1000_read_dpram16 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to read // buffer - data buffer to hold the data read // hightlow - high or low 16 bit word @@ -236,7 +236,7 @@ int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, // Notes: // //--------------------------------------------------------------------------- -int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, +int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u8 highlow) { int ret = STATUS_SUCCESS; @@ -263,7 +263,7 @@ int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, //--------------------------------------------------------------------------- // Function: ft1000_write_dpram16 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to write the data // value - 16bits value to write // hightlow - high or low 16 bit word @@ -276,7 +276,7 @@ int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, // Notes: // //--------------------------------------------------------------------------- -int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u8 highlow) +int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, u8 highlow) { int ret = STATUS_SUCCESS; u8 request; @@ -302,7 +302,7 @@ int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u //--------------------------------------------------------------------------- // Function: fix_ft1000_read_dpram32 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to read // buffer - data buffer to hold the data read // @@ -315,7 +315,7 @@ int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u // Notes: // //--------------------------------------------------------------------------- -int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, +int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) { u8 buf[16]; @@ -346,7 +346,7 @@ int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, //--------------------------------------------------------------------------- // Function: fix_ft1000_write_dpram32 // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // indx - starting address to write // buffer - data buffer to write // @@ -359,7 +359,7 @@ int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, // Notes: // //--------------------------------------------------------------------------- -int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer) +int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) { u16 pos1; u16 pos2; @@ -426,7 +426,7 @@ int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buff // // Returns: None //----------------------------------------------------------------------- -static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value) +static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) { u16 status = STATUS_SUCCESS; u16 tempword; @@ -465,7 +465,7 @@ static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value) //--------------------------------------------------------------------------- // Function: card_send_command // -// Parameters: ft1000_device - device structure +// Parameters: ft1000_usb - device structure // ptempbuffer - command buffer // size - command buffer size // @@ -477,7 +477,7 @@ static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value) // Notes: // //--------------------------------------------------------------------------- -void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer, +void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, int size) { unsigned short temp; @@ -524,7 +524,7 @@ void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer, // // Returns: None //----------------------------------------------------------------------- -int dsp_reload(struct ft1000_device *ft1000dev) +int dsp_reload(struct ft1000_usb *ft1000dev) { u16 status; u16 tempword; @@ -588,7 +588,7 @@ int dsp_reload(struct ft1000_device *ft1000dev) static void ft1000_reset_asic(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); - struct ft1000_device *ft1000dev = info->pFt1000Dev; + struct ft1000_usb *ft1000dev = info->priv; u16 tempword; DEBUG("ft1000_hw:ft1000_reset_asic called\n"); @@ -627,15 +627,15 @@ static void ft1000_reset_asic(struct net_device *dev) static int ft1000_reset_card(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); - struct ft1000_device *ft1000dev = info->pFt1000Dev; + struct ft1000_usb *ft1000dev = info->priv; u16 tempword; struct prov_record *ptr; DEBUG("ft1000_hw:ft1000_reset_card called.....\n"); - info->fCondResetPend = 1; + ft1000dev->fCondResetPend = 1; info->CardReady = 0; - info->fProvComplete = 0; + ft1000dev->fProvComplete = 0; /* Make sure we free any memory reserve for provisioning */ while (list_empty(&info->prov_list) == 0) { @@ -666,7 +666,7 @@ static int ft1000_reset_card(struct net_device *dev) info->CardReady = 1; - info->fCondResetPend = 0; + ft1000dev->fCondResetPend = 0; return TRUE; } @@ -694,7 +694,7 @@ static const struct net_device_ops ftnet_ops = // Notes: // //--------------------------------------------------------------------------- -int init_ft1000_netdev(struct ft1000_device *ft1000dev) +int init_ft1000_netdev(struct ft1000_usb *ft1000dev) { struct net_device *netdev; struct ft1000_info *pInfo = NULL; @@ -702,7 +702,7 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev) int i, ret_val; struct list_head *cur, *tmp; char card_nr[2]; - unsigned long gCardIndex = 0; + u8 gCardIndex = 0; DEBUG("Enter init_ft1000_netdev...\n"); @@ -723,14 +723,14 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev) if (strncmp(netdev->name, "eth", 3) == 0) { card_nr[0] = netdev->name[3]; card_nr[1] = '\0'; - ret_val = strict_strtoul(card_nr, 10, &gCardIndex); + ret_val = kstrtou8(card_nr, 10, &gCardIndex); if (ret_val) { printk(KERN_ERR "Can't parse netdev\n"); goto err_net; } - pInfo->CardNumber = gCardIndex; - DEBUG("card number = %d\n", pInfo->CardNumber); + ft1000dev->CardNumber = gCardIndex; + DEBUG("card number = %d\n", ft1000dev->CardNumber); } else { printk(KERN_ERR "ft1000: Invalid device name\n"); ret_val = -ENXIO; @@ -740,27 +740,27 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev) memset(&pInfo->stats, 0, sizeof(struct net_device_stats)); spin_lock_init(&pInfo->dpram_lock); - pInfo->pFt1000Dev = ft1000dev; + pInfo->priv = ft1000dev; pInfo->DrvErrNum = 0; pInfo->registered = 1; pInfo->ft1000_reset = ft1000_reset; pInfo->mediastate = 0; pInfo->fifo_cnt = 0; - pInfo->DeviceCreated = FALSE; + ft1000dev->DeviceCreated = FALSE; pInfo->CardReady = 0; pInfo->DSP_TIME[0] = 0; pInfo->DSP_TIME[1] = 0; pInfo->DSP_TIME[2] = 0; pInfo->DSP_TIME[3] = 0; - pInfo->fAppMsgPend = 0; - pInfo->fCondResetPend = 0; - pInfo->usbboot = 0; - pInfo->dspalive = 0; - memset(&pInfo->tempbuf[0], 0, sizeof(pInfo->tempbuf)); + ft1000dev->fAppMsgPend = 0; + ft1000dev->fCondResetPend = 0; + ft1000dev->usbboot = 0; + ft1000dev->dspalive = 0; + memset(&ft1000dev->tempbuf[0], 0, sizeof(ft1000dev->tempbuf)); INIT_LIST_HEAD(&pInfo->prov_list); - INIT_LIST_HEAD(&pInfo->nodes.list); + INIT_LIST_HEAD(&ft1000dev->nodes.list); netdev->netdev_ops = &ftnet_ops; @@ -822,7 +822,7 @@ err_net: // Notes: // //--------------------------------------------------------------------------- -int reg_ft1000_netdev(struct ft1000_device *ft1000dev, +int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, struct usb_interface *intf) { struct net_device *netdev; @@ -854,7 +854,7 @@ int reg_ft1000_netdev(struct ft1000_device *ft1000dev, return 0; } -static int ft1000_reset(struct net_device *dev) +int ft1000_reset(void *dev) { ft1000_reset_card(dev); return 0; @@ -876,7 +876,7 @@ static int ft1000_reset(struct net_device *dev) static void ft1000_usb_transmit_complete(struct urb *urb) { - struct ft1000_device *ft1000dev = urb->context; + struct ft1000_usb *ft1000dev = urb->context; if (urb->status) pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status); @@ -902,7 +902,7 @@ static void ft1000_usb_transmit_complete(struct urb *urb) static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len) { struct ft1000_info *pInfo = netdev_priv(netdev); - struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev; + struct ft1000_usb *pFt1000Dev = pInfo->priv; int count, ret; u8 *t; @@ -981,7 +981,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len) static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ft1000_info *pInfo = netdev_priv(dev); - struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev; + struct ft1000_usb *pFt1000Dev = pInfo->priv; u8 *pdata; int maxlen, pipe; @@ -1039,7 +1039,7 @@ err: static int ft1000_copy_up_pkt(struct urb *urb) { struct ft1000_info *info = urb->context; - struct ft1000_device *ft1000dev = info->pFt1000Dev; + struct ft1000_usb *ft1000dev = info->priv; struct net_device *net = ft1000dev->net; u16 tempword; @@ -1134,7 +1134,7 @@ static int ft1000_copy_up_pkt(struct urb *urb) static int ft1000_submit_rx_urb(struct ft1000_info *info) { int result; - struct ft1000_device *pFt1000Dev = info->pFt1000Dev; + struct ft1000_usb *pFt1000Dev = info->priv; if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { DEBUG("network driver is closed, return\n"); @@ -1177,9 +1177,10 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) static int ft1000_open(struct net_device *dev) { struct ft1000_info *pInfo = netdev_priv(dev); + struct ft1000_usb *pFt1000Dev = pInfo->priv; struct timeval tv; - DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber); + DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); pInfo->stats.rx_bytes = 0; pInfo->stats.tx_bytes = 0; @@ -1213,7 +1214,7 @@ static int ft1000_open(struct net_device *dev) int ft1000_close(struct net_device *net) { struct ft1000_info *pInfo = netdev_priv(net); - struct ft1000_device *ft1000dev = pInfo->pFt1000Dev; + struct ft1000_usb *ft1000dev = pInfo->priv; ft1000dev->status |= FT1000_STATUS_CLOSING; @@ -1247,13 +1248,12 @@ static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev) // TRUE (device is present) // //--------------------------------------------------------------------------- -static int ft1000_chkcard(struct ft1000_device *dev) +static int ft1000_chkcard(struct ft1000_usb *dev) { u16 tempword; u16 status; - struct ft1000_info *info = netdev_priv(dev->net); - if (info->fCondResetPend) { + if (dev->fCondResetPend) { DEBUG ("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n"); return TRUE; @@ -1293,7 +1293,7 @@ static int ft1000_chkcard(struct ft1000_device *dev) // = 1 (successful) // //--------------------------------------------------------------------------- -static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer, +static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, int maxsz, u16 *pnxtph) { u16 size, ret; @@ -1360,7 +1360,7 @@ static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer, static int ft1000_dsp_prov(void *arg) { - struct ft1000_device *dev = (struct ft1000_device *)arg; + struct ft1000_usb *dev = (struct ft1000_usb *)arg; struct ft1000_info *info = netdev_priv(dev->net); u16 tempword; u16 len; @@ -1441,13 +1441,13 @@ static int ft1000_dsp_prov(void *arg) msleep(100); - info->fProvComplete = 1; + dev->fProvComplete = 1; info->CardReady = 1; return STATUS_SUCCESS; } -static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) +static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) { struct ft1000_info *info = netdev_priv(dev->net); u16 msgtype; @@ -1498,7 +1498,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) if (pmediamsg->state) { DEBUG("Media is up\n"); if (info->mediastate == 0) { - if (info->NetDevRegDone) { + if (dev->NetDevRegDone) { netif_wake_queue(dev-> net); } @@ -1508,7 +1508,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) DEBUG("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; - if (info->NetDevRegDone) { + if (dev->NetDevRegDone) { } info->ConTm = 0; } @@ -1567,12 +1567,12 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) * Send provisioning data to DSP */ if (list_empty(&info->prov_list) == 0) { - info->fProvComplete = 0; + dev->fProvComplete = 0; status = ft1000_dsp_prov(dev); if (status != STATUS_SUCCESS) goto out; } else { - info->fProvComplete = 1; + dev->fProvComplete = 1; status = ft1000_write_register(dev, FT1000_DB_HB, FT1000_REG_DOORBELL); @@ -1605,7 +1605,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) case DSP_GET_INFO:{ DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n"); /* copy dsp info block to dsp */ - info->DrvMsgPend = 1; + dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ mdelay(10); status = @@ -1667,7 +1667,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) status = ft1000_write_register(dev, FT1000_DB_DPRAM_TX, FT1000_REG_DOORBELL); - info->DrvMsgPend = 0; + dev->DrvMsgPend = 0; break; } @@ -1675,7 +1675,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) case GET_DRV_ERR_RPT_MSG:{ DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); /* copy driver error message to dsp */ - info->DrvMsgPend = 1; + dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ mdelay(10); status = @@ -1735,7 +1735,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size) (u16) (0x0012 + PSEUDOSZ)); info->DrvErrNum = 0; } - info->DrvMsgPend = 0; + dev->DrvMsgPend = 0; break; } @@ -1753,7 +1753,7 @@ out: int ft1000_poll(void* dev_id) { - struct ft1000_device *dev = (struct ft1000_device *)dev_id; + struct ft1000_usb *dev = (struct ft1000_usb *)dev_id; struct ft1000_info *info = netdev_priv(dev->net); u16 tempword; @@ -1804,8 +1804,8 @@ int ft1000_poll(void* dev_id) // Check which application has registered for dsp broadcast messages for (i=0; i<MAX_NUM_APP; i++) { - if ( (info->app_info[i].DspBCMsgFlag) && (info->app_info[i].fileobject) && - (info->app_info[i].NumOfMsg < MAX_MSG_LIMIT) ) + if ( (dev->app_info[i].DspBCMsgFlag) && (dev->app_info[i].fileobject) && + (dev->app_info[i].NumOfMsg < MAX_MSG_LIMIT) ) { nxtph = FT1000_DPRAM_RX_BASE + 2; pdpram_blk = ft1000_get_buffer (&freercvpool); @@ -1813,15 +1813,15 @@ int ft1000_poll(void* dev_id) if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) { ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer; // Put message into the appropriate application block - info->app_info[i].nRxMsg++; + dev->app_info[i].nRxMsg++; spin_lock_irqsave(&free_buff_lock, flags); - list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist); - info->app_info[i].NumOfMsg++; + list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist); + dev->app_info[i].NumOfMsg++; spin_unlock_irqrestore(&free_buff_lock, flags); - wake_up_interruptible(&info->app_info[i].wait_dpram_msg); + wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); } else { - info->app_info[i].nRxMsgMiss++; + dev->app_info[i].nRxMsgMiss++; // Put memory back to free pool ft1000_free_buffer(pdpram_blk, &freercvpool); DEBUG("pdpram_blk::ft1000_get_buffer NULL\n"); @@ -1829,7 +1829,7 @@ int ft1000_poll(void* dev_id) } else { DEBUG("Out of memory in free receive command pool\n"); - info->app_info[i].nRxMsgMiss++; + dev->app_info[i].nRxMsgMiss++; } } } @@ -1842,7 +1842,7 @@ int ft1000_poll(void* dev_id) ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer; // Search for correct application block for (i=0; i<MAX_NUM_APP; i++) { - if (info->app_info[i].app_id == ppseudo_hdr->portdest) { + if (dev->app_info[i].app_id == ppseudo_hdr->portdest) { break; } } @@ -1853,15 +1853,15 @@ int ft1000_poll(void* dev_id) ft1000_free_buffer(pdpram_blk, &freercvpool); } else { - if (info->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { + if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { // Put memory back to free pool ft1000_free_buffer(pdpram_blk, &freercvpool); } else { - info->app_info[i].nRxMsg++; + dev->app_info[i].nRxMsg++; // Put message into the appropriate application block - list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist); - info->app_info[i].NumOfMsg++; + list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist); + dev->app_info[i].NumOfMsg++; } } } @@ -1921,7 +1921,7 @@ int ft1000_poll(void* dev_id) else if (tempword & FT1000_DB_COND_RESET) { DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); - if (info->fAppMsgPend == 0) { + if (dev->fAppMsgPend == 0) { // Reset ASIC and DSP status = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX); @@ -1934,8 +1934,8 @@ int ft1000_poll(void* dev_id) info->ft1000_reset(dev->net); } else { - info->fProvComplete = 0; - info->fCondResetPend = 1; + dev->fProvComplete = 0; + dev->fCondResetPend = 1; } ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index 1edaddb..b996406 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c @@ -51,7 +51,7 @@ #define FTNET_PROC init_net.proc_net -int ft1000_read_dpram16 (struct ft1000_device *ft1000dev, u16 indx, +int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u8 highlow); @@ -94,11 +94,11 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof, if (info->ProgConStat != 0xFF) { - ft1000_read_dpram16(info->pFt1000Dev, FT1000_MAG_DSP_LED, + ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); info->LedStat = ntohs(ledStat); - ft1000_read_dpram16(info->pFt1000Dev, FT1000_MAG_DSP_CON_STATE, + ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); info->ConStat = ntohs(conStat); do_gettimeofday(&tv); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index b2ecd0e..614db55 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -63,16 +63,13 @@ static int ft1000_probe(struct usb_interface *interface, unsigned numaltsetting; int i, ret = 0, size; - struct ft1000_device *ft1000dev; + struct ft1000_usb *ft1000dev; struct ft1000_info *pft1000info = NULL; const struct firmware *dsp_fw; - ft1000dev = kzalloc(sizeof(struct ft1000_device), GFP_KERNEL); - - if (!ft1000dev) { - pr_err("out of memory allocating device structure\n"); + ft1000dev = kzalloc(sizeof(struct ft1000_usb), GFP_KERNEL); + if (!ft1000dev) return -ENOMEM; - } dev = interface_to_usbdev(interface); DEBUG("ft1000_probe: usb device descriptor info:\n"); @@ -171,11 +168,11 @@ static int ft1000_probe(struct usb_interface *interface, } gPollingfailed = FALSE; - pft1000info->pPollThread = + ft1000dev->pPollThread = kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); - if (IS_ERR(pft1000info->pPollThread)) { - ret = PTR_ERR(pft1000info->pPollThread); + if (IS_ERR(ft1000dev->pPollThread)) { + ret = PTR_ERR(ft1000dev->pPollThread); goto err_load; } @@ -200,7 +197,7 @@ static int ft1000_probe(struct usb_interface *interface, if (ret) goto err_proc; - pft1000info->NetDevRegDone = 1; + ft1000dev->NetDevRegDone = 1; return 0; @@ -208,7 +205,7 @@ err_proc: unregister_netdev(ft1000dev->net); free_netdev(ft1000dev->net); err_thread: - kthread_stop(pft1000info->pPollThread); + kthread_stop(ft1000dev->pPollThread); err_load: kfree(pFileStart); err_fw: @@ -219,6 +216,7 @@ err_fw: static void ft1000_disconnect(struct usb_interface *interface) { struct ft1000_info *pft1000info; + struct ft1000_usb *ft1000dev; DEBUG("ft1000_disconnect is called\n"); @@ -226,28 +224,29 @@ static void ft1000_disconnect(struct usb_interface *interface) DEBUG("In disconnect pft1000info=%p\n", pft1000info); if (pft1000info) { + ft1000dev = pft1000info->priv; ft1000_cleanup_proc(pft1000info); - if (pft1000info->pPollThread) - kthread_stop(pft1000info->pPollThread); + if (ft1000dev->pPollThread) + kthread_stop(ft1000dev->pPollThread); DEBUG("ft1000_disconnect: threads are terminated\n"); - if (pft1000info->pFt1000Dev->net) { + if (ft1000dev->net) { DEBUG("ft1000_disconnect: destroy char driver\n"); - ft1000_destroy_dev(pft1000info->pFt1000Dev->net); - unregister_netdev(pft1000info->pFt1000Dev->net); + ft1000_destroy_dev(ft1000dev->net); + unregister_netdev(ft1000dev->net); DEBUG ("ft1000_disconnect: network device unregistered\n"); - free_netdev(pft1000info->pFt1000Dev->net); + free_netdev(ft1000dev->net); } - usb_free_urb(pft1000info->pFt1000Dev->rx_urb); - usb_free_urb(pft1000info->pFt1000Dev->tx_urb); + usb_free_urb(ft1000dev->rx_urb); + usb_free_urb(ft1000dev->tx_urb); DEBUG("ft1000_disconnect: urb freed\n"); - kfree(pft1000info->pFt1000Dev); + kfree(ft1000dev); } kfree(pFileStart); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index 2aa6a1c..bd1da1f 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -55,7 +55,14 @@ struct app_info_block { #define MAX_BUF_SIZE 4096 -struct ft1000_device { +struct ft1000_debug_dirs { + struct list_head list; + struct dentry *dent; + struct dentry *file; + int int_number; +}; + +struct ft1000_usb { struct usb_device *dev; struct net_device *net; @@ -69,71 +76,26 @@ struct ft1000_device { u8 bulk_in_endpointAddr; u8 bulk_out_endpointAddr; -} __packed; - -struct ft1000_debug_dirs { - struct list_head list; - struct dentry *dent; - struct dentry *file; - int int_number; -}; - -struct ft1000_info { - struct ft1000_device *pFt1000Dev; - struct net_device_stats stats; struct task_struct *pPollThread; - unsigned char fcodeldr; unsigned char bootmode; unsigned char usbboot; unsigned short dspalive; - u16 ASIC_ID; bool fProvComplete; bool fCondResetPend; bool fAppMsgPend; - u16 DrvErrNum; - u16 AsicID; - int DspAsicReset; int DeviceCreated; - int CardReady; int NetDevRegDone; u8 CardNumber; u8 DeviceName[15]; struct ft1000_debug_dirs nodes; - int registered; - int mediastate; - u8 squeseqnum; /* sequence number on slow queue */ - spinlock_t dpram_lock; spinlock_t fifo_lock; - u16 fifo_cnt; - u8 DspVer[DSPVERSZ]; /* DSP version number */ - u8 HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ - u8 Sku[SKUSZ]; /* SKU */ - u8 eui64[EUISZ]; /* EUI64 */ - time_t ConTm; /* Connection Time */ - u8 ProductMode[MODESZ]; - u8 RfCalVer[CALVERSZ]; - u8 RfCalDate[CALDATESZ]; - u16 DSP_TIME[4]; - u16 LedStat; - u16 ConStat; - u16 ProgConStat; - struct list_head prov_list; int appcnt; struct app_info_block app_info[MAX_NUM_APP]; - u16 DSPInfoBlklen; u16 DrvMsgPend; - int (*ft1000_reset)(struct net_device *dev); - u16 DSPInfoBlk[MAX_DSP_SESS_REC]; - union { - u16 Rec[MAX_DSP_SESS_REC]; - u32 MagRec[MAX_DSP_SESS_REC/2]; - } DSPSess; unsigned short tempbuf[32]; - char netdevname[IFNAMSIZ]; - struct proc_dir_entry *ft1000_proc_dir; -}; +} __packed; struct dpram_blk { @@ -141,21 +103,21 @@ struct dpram_blk { u16 *pbuffer; } __packed; -int ft1000_read_register(struct ft1000_device *ft1000dev, +int ft1000_read_register(struct ft1000_usb *ft1000dev, u16 *Data, u16 nRegIndx); -int ft1000_write_register(struct ft1000_device *ft1000dev, +int ft1000_write_register(struct ft1000_usb *ft1000dev, u16 value, u16 nRegIndx); -int ft1000_read_dpram32(struct ft1000_device *ft1000dev, +int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u16 cnt); -int ft1000_write_dpram32(struct ft1000_device *ft1000dev, +int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u16 cnt); -int ft1000_read_dpram16(struct ft1000_device *ft1000dev, +int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u8 highlow); -int ft1000_write_dpram16(struct ft1000_device *ft1000dev, +int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, u8 highlow); -int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, +int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer); -int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, +int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer); extern void *pFileStart; @@ -163,25 +125,25 @@ extern size_t FileLength; extern int numofmsgbuf; int ft1000_close(struct net_device *dev); -u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, +u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, u32 FileLength); extern struct list_head freercvpool; extern spinlock_t free_buff_lock; /* lock to arbitrate free buffer list for receive command data */ -int ft1000_create_dev(struct ft1000_device *dev); +int ft1000_create_dev(struct ft1000_usb *dev); void ft1000_destroy_dev(struct net_device *dev); -extern void card_send_command(struct ft1000_device *ft1000dev, +extern void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, int size); struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist); void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist); -int dsp_reload(struct ft1000_device *ft1000dev); -int init_ft1000_netdev(struct ft1000_device *ft1000dev); +int dsp_reload(struct ft1000_usb *ft1000dev); +int init_ft1000_netdev(struct ft1000_usb *ft1000dev); struct usb_interface; -int reg_ft1000_netdev(struct ft1000_device *ft1000dev, +int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, struct usb_interface *intf); int ft1000_poll(void *dev_id); diff --git a/drivers/staging/ft1000/ft1000.h b/drivers/staging/ft1000/ft1000.h index 03baa57..175abfa 100644 --- a/drivers/staging/ft1000/ft1000.h +++ b/drivers/staging/ft1000/ft1000.h @@ -250,3 +250,38 @@ struct prov_record { struct list_head list; u8 *pprov_data; }; + +struct ft1000_info { + void *priv; + struct net_device_stats stats; + u16 DrvErrNum; + u16 AsicID; + int CardReady; + int registered; + int mediastate; + u8 squeseqnum; /* sequence number on slow queue */ + spinlock_t dpram_lock; + u16 fifo_cnt; + u8 DspVer[DSPVERSZ]; /* DSP version number */ + u8 HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ + u8 Sku[SKUSZ]; /* SKU */ + u8 eui64[EUISZ]; /* EUI64 */ + time_t ConTm; /* Connection Time */ + u8 ProductMode[MODESZ]; + u8 RfCalVer[CALVERSZ]; + u8 RfCalDate[CALDATESZ]; + u16 DSP_TIME[4]; + u16 LedStat; + u16 ConStat; + u16 ProgConStat; + struct list_head prov_list; + u16 DSPInfoBlklen; + int (*ft1000_reset)(void *); + u16 DSPInfoBlk[MAX_DSP_SESS_REC]; + union { + u16 Rec[MAX_DSP_SESS_REC]; + u32 MagRec[MAX_DSP_SESS_REC/2]; + } DSPSess; + struct proc_dir_entry *ft1000_proc_dir; + char netdevname[IFNAMSIZ]; +}; diff --git a/drivers/staging/fwserial/TODO b/drivers/staging/fwserial/TODO index 8dae8fb..382a795 100644 --- a/drivers/staging/fwserial/TODO +++ b/drivers/staging/fwserial/TODO @@ -12,18 +12,3 @@ TODOs prior to this driver moving out of staging 1. This driver uses the same unregistered vendor id that the firewire core does (0xd00d1e). Perhaps this could be exposed as a define in firewire.h? -3. Maybe device_max_receive() and link_speed_to_max_payload() should be - taken up by the firewire core? - --- Issues with TTY core -- - 1. Hack for alternate device name scheme - - because udev no longer allows device renaming, devices should have - their proper names on creation. This is an issue for creating the - fwloop<n> device with the fwtty<n> devices because although duplicating - roughly the same operations as tty_port_register_device() isn't difficult, - access to the tty_class & tty_fops is restricted in scope. - - This is currently being worked around in create_loop_device() by - extracting the tty_class ptr and tty_fops ptr from the previously created - tty devices. Perhaps an add'l api can be added -- eg., - tty_{port_}register_named_device(). diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index d03a7f5..8859c75 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -40,12 +40,10 @@ static int num_ttys = 4; /* # of std ttys to create per fw_card */ /* - doubles as loopback port index */ static bool auto_connect = true; /* try to VIRT_CABLE to every peer */ static bool create_loop_dev = true; /* create a loopback device for each card */ -bool limit_bw; /* limit async bandwidth to 20% of max */ module_param_named(ttys, num_ttys, int, S_IRUGO | S_IWUSR); module_param_named(auto, auto_connect, bool, S_IRUGO | S_IWUSR); module_param_named(loop, create_loop_dev, bool, S_IRUGO | S_IWUSR); -module_param(limit_bw, bool, S_IRUGO | S_IWUSR); /* * Threshold below which the tty is woken for writing @@ -74,12 +72,20 @@ static DEFINE_MUTEX(port_table_lock); static bool port_table_corrupt; #define FWTTY_INVALID_INDEX MAX_TOTAL_PORTS +#define loop_idx(port) (((port)->index) / num_ports) +#define table_idx(loop) ((loop) * num_ports + num_ttys) + /* total # of tty ports created per fw_card */ static int num_ports; /* slab used as pool for struct fwtty_transactions */ static struct kmem_cache *fwtty_txn_cache; +struct tty_driver *fwtty_driver; +static struct tty_driver *fwloop_driver; + +static struct dentry *fwserial_debugfs; + struct fwtty_transaction; typedef void (*fwtty_transaction_cb)(struct fw_card *card, int rcode, void *data, size_t length, @@ -176,10 +182,15 @@ static void dump_profile(struct seq_file *m, struct stats *stats) #define dump_profile(m, stats) #endif -/* Returns the max receive packet size for the given card */ +/* + * Returns the max receive packet size for the given node + * Devices which are OHCI v1.0/ v1.1/ v1.2-draft or RFC 2734 compliant + * are required by specification to support max_rec of 8 (512 bytes) or more. + */ static inline int device_max_receive(struct fw_device *fw_device) { - return 1 << (clamp_t(int, fw_device->max_rec, 8U, 11U) + 1); + /* see IEEE 1394-2008 table 8-8 */ + return min(2 << fw_device->max_rec, 4096); } static void fwtty_log_tx_error(struct fwtty_port *port, int rcode) @@ -566,8 +577,11 @@ static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) struct buffered_rx *buf; size_t size = (n + sizeof(struct buffered_rx) + 0xFF) & ~0xFF; - if (port->buffered + n > HIGH_WATERMARK) + if (port->buffered + n > HIGH_WATERMARK) { + fwtty_err_ratelimited(port, "overflowed rx buffer: buffered: %d new: %zu wtrmk: %d", + port->buffered, n, HIGH_WATERMARK); return 0; + } buf = kmalloc(size, GFP_ATOMIC); if (!buf) return 0; @@ -1160,6 +1174,19 @@ static int fwtty_install(struct tty_driver *driver, struct tty_struct *tty) return err; } +static int fwloop_install(struct tty_driver *driver, struct tty_struct *tty) +{ + struct fwtty_port *port = fwtty_port_get(table_idx(tty->index)); + int err; + + err = tty_standard_install(driver, tty); + if (!err) + tty->driver_data = port; + else + fwtty_port_put(port); + return err; +} + static int fwtty_write(struct tty_struct *tty, const unsigned char *buf, int c) { struct fwtty_port *port = tty->driver_data; @@ -1487,17 +1514,26 @@ static void fwtty_proc_show_port(struct seq_file *m, struct fwtty_port *port) if (port->port.console) (*port->fwcon_ops->stats)(&stats, port->con_data); - seq_printf(m, " tx:%d rx:%d", port->icount.tx + stats.xchars, - port->icount.rx); + seq_printf(m, " addr:%012llx tx:%d rx:%d", port->rx_handler.offset, + port->icount.tx + stats.xchars, port->icount.rx); seq_printf(m, " cts:%d dsr:%d rng:%d dcd:%d", port->icount.cts, port->icount.dsr, port->icount.rng, port->icount.dcd); seq_printf(m, " fe:%d oe:%d pe:%d brk:%d", port->icount.frame, port->icount.overrun, port->icount.parity, port->icount.brk); +} + +static void fwtty_debugfs_show_port(struct seq_file *m, struct fwtty_port *port) +{ + struct stats stats; + + memcpy(&stats, &port->stats, sizeof(stats)); + if (port->port.console) + (*port->fwcon_ops->stats)(&stats, port->con_data); + seq_printf(m, " dr:%d st:%d err:%d lost:%d", stats.dropped, stats.tx_stall, stats.fifo_errs, stats.lost); seq_printf(m, " pkts:%d thr:%d wtrmk:%d", stats.sent, stats.throttled, stats.watermark); - seq_printf(m, " addr:%012llx", port->rx_handler.offset); if (port->port.console) { seq_printf(m, "\n "); @@ -1507,7 +1543,7 @@ static void fwtty_proc_show_port(struct seq_file *m, struct fwtty_port *port) dump_profile(m, &port->stats); } -static void fwtty_proc_show_peer(struct seq_file *m, struct fwtty_peer *peer) +static void fwtty_debugfs_show_peer(struct seq_file *m, struct fwtty_peer *peer) { int generation = peer->generation; @@ -1516,21 +1552,14 @@ static void fwtty_proc_show_peer(struct seq_file *m, struct fwtty_peer *peer) seq_printf(m, " node:%04x gen:%d", peer->node_id, generation); seq_printf(m, " sp:%d max:%d guid:%016llx", peer->speed, peer->max_payload, (unsigned long long) peer->guid); - - if (capable(CAP_SYS_ADMIN)) { - seq_printf(m, " mgmt:%012llx", - (unsigned long long) peer->mgmt_addr); - seq_printf(m, " addr:%012llx", - (unsigned long long) peer->status_addr); - } + seq_printf(m, " mgmt:%012llx", (unsigned long long) peer->mgmt_addr); + seq_printf(m, " addr:%012llx", (unsigned long long) peer->status_addr); seq_putc(m, '\n'); } static int fwtty_proc_show(struct seq_file *m, void *v) { struct fwtty_port *port; - struct fw_serial *serial; - struct fwtty_peer *peer; int i; seq_puts(m, "fwserinfo: 1.0 driver: 1.0\n"); @@ -1541,16 +1570,39 @@ static int fwtty_proc_show(struct seq_file *m, void *v) fwtty_port_put(port); seq_printf(m, "\n"); } - seq_putc(m, '\n'); + return 0; +} - rcu_read_lock(); - list_for_each_entry_rcu(serial, &fwserial_list, list) { - seq_printf(m, "card: %s guid: %016llx\n", - dev_name(serial->card->device), - (unsigned long long) serial->card->guid); - list_for_each_entry_rcu(peer, &serial->peer_list, list) - fwtty_proc_show_peer(m, peer); +static int fwtty_debugfs_stats_show(struct seq_file *m, void *v) +{ + struct fw_serial *serial = m->private; + struct fwtty_port *port; + int i; + + for (i = 0; i < num_ports; ++i) { + port = fwtty_port_get(serial->ports[i]->index); + if (port) { + seq_printf(m, "%2d:", port->index); + fwtty_proc_show_port(m, port); + fwtty_debugfs_show_port(m, port); + fwtty_port_put(port); + seq_printf(m, "\n"); + } } + return 0; +} + +static int fwtty_debugfs_peers_show(struct seq_file *m, void *v) +{ + struct fw_serial *serial = m->private; + struct fwtty_peer *peer; + + rcu_read_lock(); + seq_printf(m, "card: %s guid: %016llx\n", + dev_name(serial->card->device), + (unsigned long long) serial->card->guid); + list_for_each_entry_rcu(peer, &serial->peer_list, list) + fwtty_debugfs_show_peer(m, peer); rcu_read_unlock(); return 0; } @@ -1560,6 +1612,32 @@ static int fwtty_proc_open(struct inode *inode, struct file *fp) return single_open(fp, fwtty_proc_show, NULL); } +static int fwtty_stats_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, fwtty_debugfs_stats_show, inode->i_private); +} + +static int fwtty_peers_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, fwtty_debugfs_peers_show, inode->i_private); +} + +static const struct file_operations fwtty_stats_fops = { + .owner = THIS_MODULE, + .open = fwtty_stats_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static const struct file_operations fwtty_peers_fops = { + .owner = THIS_MODULE, + .open = fwtty_peers_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static const struct file_operations fwtty_proc_fops = { .owner = THIS_MODULE, .open = fwtty_proc_open, @@ -1596,6 +1674,26 @@ static const struct tty_operations fwtty_ops = { .proc_fops = &fwtty_proc_fops, }; +static const struct tty_operations fwloop_ops = { + .open = fwtty_open, + .close = fwtty_close, + .hangup = fwtty_hangup, + .cleanup = fwtty_cleanup, + .install = fwloop_install, + .write = fwtty_write, + .write_room = fwtty_write_room, + .chars_in_buffer = fwtty_chars_in_buffer, + .send_xchar = fwtty_send_xchar, + .throttle = fwtty_throttle, + .unthrottle = fwtty_unthrottle, + .ioctl = fwtty_ioctl, + .set_termios = fwtty_set_termios, + .break_ctl = fwtty_break_ctl, + .tiocmget = fwtty_tiocmget, + .tiocmset = fwtty_tiocmset, + .get_icount = fwtty_get_icount, +}; + static inline int mgmt_pkt_expected_len(__be16 code) { static const struct fwserial_mgmt_pkt pkt; @@ -1685,8 +1783,7 @@ static void fwserial_virt_plug_complete(struct fwtty_peer *peer, /* reconfigure tx_fifo optimally for this peer */ spin_lock_bh(&port->lock); - port->max_payload = min3(peer->max_payload, peer->fifo_len, - MAX_ASYNC_PAYLOAD); + port->max_payload = min(peer->max_payload, peer->fifo_len); dma_fifo_change_tx_limit(&port->tx_fifo, port->max_payload); spin_unlock_bh(&peer->port->lock); @@ -1781,10 +1878,11 @@ static struct fwtty_port *fwserial_find_port(struct fwtty_peer *peer) return NULL; } -static void fwserial_release_port(struct fwtty_port *port) +static void fwserial_release_port(struct fwtty_port *port, bool reset) { /* drop carrier (and all other line status) */ - fwtty_update_port_status(port, 0); + if (reset) + fwtty_update_port_status(port, 0); spin_lock_bh(&port->lock); @@ -1814,7 +1912,7 @@ static void fwserial_plug_timeout(unsigned long data) spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, false); } /** @@ -1877,7 +1975,7 @@ cancel_timer: peer_revert_state(peer); release_port: spin_unlock_bh(&peer->lock); - fwserial_release_port(port); + fwserial_release_port(port, false); free_pkt: kfree(pkt); return err; @@ -1892,7 +1990,8 @@ free_pkt: * The port reference is put by fwtty_cleanup (if a reference was * ever taken). */ -static void fwserial_close_port(struct fwtty_port *port) +static void fwserial_close_port(struct tty_driver *driver, + struct fwtty_port *port) { struct tty_struct *tty; @@ -1904,7 +2003,10 @@ static void fwserial_close_port(struct fwtty_port *port) } mutex_unlock(&port->port.mutex); - tty_unregister_device(fwtty_driver, port->index); + if (driver == fwloop_driver) + tty_unregister_device(driver, loop_idx(port)); + else + tty_unregister_device(driver, port->index); } /** @@ -2155,85 +2257,13 @@ static void fwserial_remove_peer(struct fwtty_peer *peer) spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, true); synchronize_rcu(); kfree(peer); } /** - * create_loop_device - create a loopback tty device - * @tty_driver: tty_driver to own loopback device - * @prototype: ptr to already-assigned 'prototype' tty port - * @index: index to associate this device with the tty port - * @parent: device to child to - * - * HACK - this is basically tty_port_register_device() with an - * alternate naming scheme. Suggest tty_port_register_named_device() - * helper api. - * - * Creates a loopback tty device named 'fwloop<n>' which is attached to - * the local unit in fwserial_add_peer(). Note that <n> in the device - * name advances in increments of port allocation blocks, ie., for port - * indices 0..3, the device name will be 'fwloop0'; for 4..7, 'fwloop1', - * and so on. - * - * Only one loopback device should be created per fw_card. - */ -static void release_loop_device(struct device *dev) -{ - kfree(dev); -} - -static struct device *create_loop_device(struct tty_driver *driver, - struct fwtty_port *prototype, - struct fwtty_port *port, - struct device *parent) -{ - char name[64]; - int index = port->index; - dev_t devt = MKDEV(driver->major, driver->minor_start) + index; - struct device *dev = NULL; - int err; - - if (index >= fwtty_driver->num) - return ERR_PTR(-EINVAL); - - snprintf(name, 64, "%s%d", loop_dev_name, index / num_ports); - - tty_port_link_device(&port->port, driver, index); - - cdev_init(&driver->cdevs[index], driver->cdevs[prototype->index].ops); - driver->cdevs[index].owner = driver->owner; - err = cdev_add(&driver->cdevs[index], devt, 1); - if (err) - return ERR_PTR(err); - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - cdev_del(&driver->cdevs[index]); - return ERR_PTR(-ENOMEM); - } - - dev->devt = devt; - dev->class = prototype->device->class; - dev->parent = parent; - dev->release = release_loop_device; - dev_set_name(dev, "%s", name); - dev->groups = NULL; - dev_set_drvdata(dev, NULL); - - err = device_register(dev); - if (err) { - put_device(dev); - cdev_del(&driver->cdevs[index]); - return ERR_PTR(err); - } - - return dev; -} - -/** * fwserial_create - init everything to create TTYs for a specific fw_card * @unit: fw_unit for first 'serial' unit device probed for this fw_card * @@ -2331,17 +2361,28 @@ static int fwserial_create(struct fw_unit *unit) if (create_loop_dev) { struct device *loop_dev; - loop_dev = create_loop_device(fwtty_driver, - serial->ports[0], - serial->ports[num_ttys], - card->device); + loop_dev = tty_port_register_device(&serial->ports[j]->port, + fwloop_driver, + loop_idx(serial->ports[j]), + card->device); if (IS_ERR(loop_dev)) { err = PTR_ERR(loop_dev); fwtty_err(&unit, "create loop device failed (%d)", err); goto unregister_ttys; } - serial->ports[num_ttys]->device = loop_dev; - serial->ports[num_ttys]->loopback = true; + serial->ports[j]->device = loop_dev; + serial->ports[j]->loopback = true; + } + + if (!IS_ERR_OR_NULL(fwserial_debugfs)) { + serial->debugfs = debugfs_create_dir(dev_name(&unit->device), + fwserial_debugfs); + if (!IS_ERR_OR_NULL(serial->debugfs)) { + debugfs_create_file("peers", 0444, serial->debugfs, + serial, &fwtty_peers_fops); + debugfs_create_file("stats", 0444, serial->debugfs, + serial, &fwtty_stats_fops); + } } list_add_rcu(&serial->list, &fwserial_list); @@ -2356,7 +2397,11 @@ static int fwserial_create(struct fw_unit *unit) fwtty_err(&unit, "unable to add peer unit device (%d)", err); /* fall-through to error processing */ + debugfs_remove_recursive(serial->debugfs); + list_del_rcu(&serial->list); + if (create_loop_dev) + tty_unregister_device(fwloop_driver, loop_idx(serial->ports[j])); unregister_ttys: for (--j; j >= 0; --j) tty_unregister_device(fwtty_driver, serial->ports[j]->index); @@ -2445,8 +2490,12 @@ static int fwserial_remove(struct device *dev) /* unlink from the fwserial_list here */ list_del_rcu(&serial->list); - for (i = 0; i < num_ports; ++i) - fwserial_close_port(serial->ports[i]); + debugfs_remove_recursive(serial->debugfs); + + for (i = 0; i < num_ttys; ++i) + fwserial_close_port(fwtty_driver, serial->ports[i]); + if (create_loop_dev) + fwserial_close_port(fwloop_driver, serial->ports[i]); kref_put(&serial->kref, fwserial_destroy); } mutex_unlock(&fwserial_list_mutex); @@ -2510,26 +2559,25 @@ static struct fw_driver fwserial_driver = { /* XXX: config ROM definitons could be improved with semi-automated offset * and length calculation */ +#define FW_ROM_LEN(quads) ((quads) << 16) #define FW_ROM_DESCRIPTOR(ofs) (((CSR_LEAF | CSR_DESCRIPTOR) << 24) | (ofs)) struct fwserial_unit_directory_data { - u16 crc; - u16 len; + u32 len_crc; u32 unit_specifier; u32 unit_sw_version; u32 unit_addr_offset; u32 desc1_ofs; - u16 desc1_crc; - u16 desc1_len; + u32 desc1_len_crc; u32 desc1_data[5]; } __packed; static struct fwserial_unit_directory_data fwserial_unit_directory_data = { - .len = 4, + .len_crc = FW_ROM_LEN(4), .unit_specifier = FW_UNIT_SPECIFIER(LINUX_VENDOR_ID), .unit_sw_version = FW_UNIT_VERSION(FWSERIAL_VERSION), .desc1_ofs = FW_ROM_DESCRIPTOR(1), - .desc1_len = 5, + .desc1_len_crc = FW_ROM_LEN(5), .desc1_data = { 0x00000000, /* type = text */ 0x00000000, /* enc = ASCII, lang EN */ @@ -2549,7 +2597,7 @@ static struct fw_descriptor fwserial_unit_directory = { * The management address is in the unit space region but above other known * address users (to keep wild writes from causing havoc) */ -const struct fw_address_region fwserial_mgmt_addr_region = { +static const struct fw_address_region fwserial_mgmt_addr_region = { .start = CSR_REGISTER_BASE + 0x1e0000ULL, .end = 0x1000000000000ULL, }; @@ -2615,7 +2663,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, false); rcode = fwserial_send_mgmt_sync(peer, pkt); @@ -2637,7 +2685,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) cleanup: spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, false); kfree(pkt); return; } @@ -2681,15 +2729,14 @@ static void fwserial_handle_unplug_req(struct work_struct *work) spin_lock_bh(&peer->lock); if (peer->state == FWPS_UNPLUG_RESPONDING) { - if (rcode == RCODE_COMPLETE) - port = peer_revert_state(peer); - else + if (rcode != RCODE_COMPLETE) fwtty_err(&peer->unit, "UNPLUG_RSP error (%d)", rcode); + port = peer_revert_state(peer); } cleanup: spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, true); kfree(pkt); return; } @@ -2700,6 +2747,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, size_t len) { struct fwtty_port *port = NULL; + bool reset = false; int rcode; if (addr != fwserial_mgmt_addr_handler.offset || len < sizeof(pkt->hdr)) @@ -2775,6 +2823,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) fwtty_notice(&peer->unit, "NACK unplug?"); port = peer_revert_state(peer); + reset = true; } break; @@ -2786,7 +2835,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, spin_unlock_bh(&peer->lock); if (port) - fwserial_release_port(port); + fwserial_release_port(port, reset); return rcode; } @@ -2836,14 +2885,18 @@ static int __init fwserial_init(void) { int err, num_loops = !!(create_loop_dev); + /* XXX: placeholder for a "firewire" debugfs node */ + fwserial_debugfs = debugfs_create_dir(KBUILD_MODNAME, NULL); + /* num_ttys/num_ports must not be set above the static alloc avail */ if (num_ttys + num_loops > MAX_CARD_PORTS) num_ttys = MAX_CARD_PORTS - num_loops; num_ports = num_ttys + num_loops; - fwtty_driver = alloc_tty_driver(MAX_TOTAL_PORTS); - if (!fwtty_driver) { - err = -ENOMEM; + fwtty_driver = tty_alloc_driver(MAX_TOTAL_PORTS, TTY_DRIVER_REAL_RAW + | TTY_DRIVER_DYNAMIC_DEV); + if (IS_ERR(fwtty_driver)) { + err = PTR_ERR(fwtty_driver); return err; } @@ -2853,9 +2906,6 @@ static int __init fwserial_init(void) fwtty_driver->minor_start = 0; fwtty_driver->type = TTY_DRIVER_TYPE_SERIAL; fwtty_driver->subtype = SERIAL_TYPE_NORMAL; - fwtty_driver->flags = TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV; - fwtty_driver->init_termios = tty_std_termios; fwtty_driver->init_termios.c_cflag |= CLOCAL; tty_set_operations(fwtty_driver, &fwtty_ops); @@ -2866,12 +2916,38 @@ static int __init fwserial_init(void) goto put_tty; } + if (create_loop_dev) { + fwloop_driver = tty_alloc_driver(MAX_TOTAL_PORTS / num_ports, + TTY_DRIVER_REAL_RAW + | TTY_DRIVER_DYNAMIC_DEV); + if (IS_ERR(fwloop_driver)) { + err = PTR_ERR(fwloop_driver); + goto unregister_driver; + } + + fwloop_driver->driver_name = KBUILD_MODNAME "_loop"; + fwloop_driver->name = loop_dev_name; + fwloop_driver->major = 0; + fwloop_driver->minor_start = 0; + fwloop_driver->type = TTY_DRIVER_TYPE_SERIAL; + fwloop_driver->subtype = SERIAL_TYPE_NORMAL; + fwloop_driver->init_termios = tty_std_termios; + fwloop_driver->init_termios.c_cflag |= CLOCAL; + tty_set_operations(fwloop_driver, &fwloop_ops); + + err = tty_register_driver(fwloop_driver); + if (err) { + driver_err("register loop driver failed (%d)", err); + goto put_loop; + } + } + fwtty_txn_cache = kmem_cache_create("fwtty_txn_cache", sizeof(struct fwtty_transaction), 0, 0, fwtty_txn_constructor); if (!fwtty_txn_cache) { err = -ENOMEM; - goto unregister_driver; + goto unregister_loop; } /* @@ -2913,10 +2989,17 @@ remove_handler: fw_core_remove_address_handler(&fwserial_mgmt_addr_handler); destroy_cache: kmem_cache_destroy(fwtty_txn_cache); +unregister_loop: + if (create_loop_dev) + tty_unregister_driver(fwloop_driver); +put_loop: + if (create_loop_dev) + put_tty_driver(fwloop_driver); unregister_driver: tty_unregister_driver(fwtty_driver); put_tty: put_tty_driver(fwtty_driver); + debugfs_remove_recursive(fwserial_debugfs); return err; } @@ -2926,8 +3009,13 @@ static void __exit fwserial_exit(void) fw_core_remove_descriptor(&fwserial_unit_directory); fw_core_remove_address_handler(&fwserial_mgmt_addr_handler); kmem_cache_destroy(fwtty_txn_cache); + if (create_loop_dev) { + tty_unregister_driver(fwloop_driver); + put_tty_driver(fwloop_driver); + } tty_unregister_driver(fwtty_driver); put_tty_driver(fwtty_driver); + debugfs_remove_recursive(fwserial_debugfs); } module_init(fwserial_init); @@ -2940,4 +3028,3 @@ MODULE_DEVICE_TABLE(ieee1394, fwserial_id_table); MODULE_PARM_DESC(ttys, "Number of ttys to create for each local firewire node"); MODULE_PARM_DESC(auto, "Auto-connect a tty to each firewire node discovered"); MODULE_PARM_DESC(loop, "Create a loopback device, fwloop<n>, with ttys"); -MODULE_PARM_DESC(limit_bw, "Limit bandwidth utilization to 20%."); diff --git a/drivers/staging/fwserial/fwserial.h b/drivers/staging/fwserial/fwserial.h index caa1c1e..514f571 100644 --- a/drivers/staging/fwserial/fwserial.h +++ b/drivers/staging/fwserial/fwserial.h @@ -15,6 +15,7 @@ #include <linux/serial_reg.h> #include <linux/module.h> #include <linux/seq_file.h> +#include <linux/debugfs.h> #include "dma_fifo.h" @@ -193,7 +194,7 @@ struct buffered_rx { * @port: underlying tty_port * @device: tty device * @index: index into port_table for this particular port - * note: minor = index + FWSERIAL_TTY_START_MINOR + * note: minor = index + minor_start assigned by tty_alloc_driver() * @serial: back pointer to the containing fw_serial * @rx_handler: bus address handler for unique addr region used by remotes * to communicate with this port. Every port uses @@ -279,7 +280,7 @@ struct fwtty_port { loopback:1; unsigned long flags; - struct fwtty_peer *peer; + struct fwtty_peer __rcu *peer; struct async_icount icount; struct stats stats; @@ -338,6 +339,7 @@ struct fw_serial { struct fw_card *card; struct kref kref; + struct dentry *debugfs; struct fwtty_peer *self; struct list_head list; @@ -351,9 +353,8 @@ struct fw_serial { #define TTY_DEV_NAME "fwtty" /* ttyFW was taken */ static const char tty_dev_name[] = TTY_DEV_NAME; static const char loop_dev_name[] = "fwloop"; -extern bool limit_bw; -struct tty_driver *fwtty_driver; +extern struct tty_driver *fwtty_driver; #define driver_err(s, v...) pr_err(KBUILD_MODNAME ": " s, ##v) @@ -370,18 +371,16 @@ static inline void fwtty_bind_console(struct fwtty_port *port, /* * Returns the max send async payload size in bytes based on the unit device - * link speed - if set to limit bandwidth to max 20%, use lookup table + * link speed. Self-limiting asynchronous bandwidth (via reducing the payload) + * is not necessary and does not work, because + * 1) asynchronous traffic will absorb all available bandwidth (less that + * being used for isochronous traffic) + * 2) isochronous arbitration always wins. */ static inline int link_speed_to_max_payload(unsigned speed) { - static const int max_async[] = { 307, 614, 1229, 2458, }; - BUILD_BUG_ON(ARRAY_SIZE(max_async) - 1 != SCODE_800); - - speed = clamp(speed, (unsigned) SCODE_100, (unsigned) SCODE_800); - if (limit_bw) - return max_async[speed]; - else - return 1 << (speed + 9); + /* Max async payload is 4096 - see IEEE 1394-2008 tables 6-4, 16-18 */ + return min(512 << speed, 4096); } #endif /* _FIREWIRE_FWSERIAL_H */ diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index 8b8ed98..695762b 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -156,10 +156,8 @@ static int init_sdio(struct sdiowm_dev *sdev) spin_lock_init(&tx->lock); tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL); - if (tx->sdu_buf == NULL) { - dev_err(&sdev->func->dev, "Failed to allocate SDU tx buffer.\n"); + if (tx->sdu_buf == NULL) goto fail; - } for (i = 0; i < MAX_NR_SDU_BUF; i++) { t = alloc_tx_struct(tx); @@ -185,10 +183,8 @@ static int init_sdio(struct sdiowm_dev *sdev) } rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); - if (rx->rx_buf == NULL) { - dev_err(&sdev->func->dev, "Failed to allocate rx buffer.\n"); + if (rx->rx_buf == NULL) goto fail; - } return 0; diff --git a/drivers/staging/gdm72xx/sdio_boot.c b/drivers/staging/gdm72xx/sdio_boot.c index 6291829..93046dd 100644 --- a/drivers/staging/gdm72xx/sdio_boot.c +++ b/drivers/staging/gdm72xx/sdio_boot.c @@ -72,10 +72,8 @@ static int download_image(struct sdio_func *func, const char *img_name) } buf = kmalloc(DOWNLOAD_SIZE + TYPE_A_HEADER_SIZE, GFP_KERNEL); - if (buf == NULL) { - dev_err(&func->dev, "Error: kmalloc\n"); + if (buf == NULL) return -ENOMEM; - } img_len = firm->size; @@ -141,11 +139,8 @@ int sdio_boot(struct sdio_func *func) const char *rfs_name = FW_DIR FW_RFS; tx_buf = kmalloc(YMEM0_SIZE, GFP_KERNEL); - if (tx_buf == NULL) { - dev_err(&func->dev, "Error: kmalloc: %s %d\n", - __func__, __LINE__); + if (tx_buf == NULL) return -ENOMEM; - } ret = download_image(func, krn_name); if (ret) diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 3e2103a..0d45eb6 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -158,10 +158,8 @@ int usb_boot(struct usb_device *usbdev, u16 pid) } tx_buf = kmalloc(DOWNLOAD_SIZE, GFP_KERNEL); - if (tx_buf == NULL) { - dev_err(&usbdev->dev, "Error: kmalloc\n"); + if (tx_buf == NULL) return -ENOMEM; - } if (firm->size < sizeof(hdr)) { dev_err(&usbdev->dev, "Cannot read the image info.\n"); @@ -301,10 +299,8 @@ static int em_download_image(struct usb_device *usbdev, const char *img_name, } buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL); - if (buf == NULL) { - dev_err(&usbdev->dev, "Error: kmalloc\n"); + if (buf == NULL) return -ENOMEM; - } strcpy(buf+pad_size, type_string); ret = gdm_wibro_send(usbdev, buf, strlen(type_string)+pad_size); diff --git a/drivers/staging/goldfish/Kconfig b/drivers/staging/goldfish/Kconfig new file mode 100644 index 0000000..4e09460 --- /dev/null +++ b/drivers/staging/goldfish/Kconfig @@ -0,0 +1,13 @@ +config GOLDFISH_AUDIO + tristate "Goldfish AVD Audio Device" + depends on GOLDFISH + ---help--- + Emulated audio channel for the Goldfish Android Virtual Device + +config MTD_GOLDFISH_NAND + tristate "Goldfish NAND device" + depends on GOLDFISH + depends on MTD + help + Drives the emulated NAND flash device on the Google Goldfish + Android virtual device. diff --git a/drivers/staging/goldfish/Makefile b/drivers/staging/goldfish/Makefile new file mode 100644 index 0000000..dec34ad --- /dev/null +++ b/drivers/staging/goldfish/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for the Goldfish audio driver +# + +obj-$(CONFIG_GOLDFISH_AUDIO) += goldfish_audio.o +obj-$(CONFIG_MTD_GOLDFISH_NAND) += goldfish_nand.o diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README new file mode 100644 index 0000000..93d65b0 --- /dev/null +++ b/drivers/staging/goldfish/README @@ -0,0 +1,12 @@ +Audio +----- +- Move to using the ALSA framework not faking it +- Fix the wrong user page DMA (moving to ALSA may fix that too) + +NAND +---- +- Switch from spinlock to mutex +- Remove excess checking of parameters in calls +- Use dma coherent memory not kmalloc/__pa for the memory (this is just + a cleanliness issue not a correctness one) + diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c new file mode 100644 index 0000000..d3bed21f --- /dev/null +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -0,0 +1,363 @@ +/* drivers/misc/goldfish_audio.c + * + * Copyright (C) 2007 Google, Inc. + * Copyright (C) 2012 Intel, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include <linux/module.h> +#include <linux/miscdevice.h> +#include <linux/fs.h> +#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/pci.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/sched.h> +#include <linux/dma-mapping.h> +#include <linux/uaccess.h> + +MODULE_AUTHOR("Google, Inc."); +MODULE_DESCRIPTION("Android QEMU Audio Driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0"); + +struct goldfish_audio { + char __iomem *reg_base; + int irq; + spinlock_t lock; + wait_queue_head_t wait; + + char __iomem *buffer_virt; /* combined buffer virtual address */ + unsigned long buffer_phys; /* combined buffer physical address */ + + char __iomem *write_buffer1; /* write buffer 1 virtual address */ + char __iomem *write_buffer2; /* write buffer 2 virtual address */ + char __iomem *read_buffer; /* read buffer virtual address */ + int buffer_status; + int read_supported; /* true if we have audio input support */ +}; + +/* We will allocate two read buffers and two write buffers. + Having two read buffers facilitate stereo -> mono conversion. + Having two write buffers facilitate interleaved IO. +*/ +#define READ_BUFFER_SIZE 16384 +#define WRITE_BUFFER_SIZE 16384 +#define COMBINED_BUFFER_SIZE ((2 * READ_BUFFER_SIZE) + \ + (2 * WRITE_BUFFER_SIZE)) + +#define AUDIO_READ(data, addr) (readl(data->reg_base + addr)) +#define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr)) + +/* temporary variable used between goldfish_audio_probe() and + goldfish_audio_open() */ +static struct goldfish_audio *audio_data; + +enum { + /* audio status register */ + AUDIO_INT_STATUS = 0x00, + /* set this to enable IRQ */ + AUDIO_INT_ENABLE = 0x04, + /* set these to specify buffer addresses */ + AUDIO_SET_WRITE_BUFFER_1 = 0x08, + AUDIO_SET_WRITE_BUFFER_2 = 0x0C, + /* set number of bytes in buffer to write */ + AUDIO_WRITE_BUFFER_1 = 0x10, + AUDIO_WRITE_BUFFER_2 = 0x14, + + /* true if audio input is supported */ + AUDIO_READ_SUPPORTED = 0x18, + /* buffer to use for audio input */ + AUDIO_SET_READ_BUFFER = 0x1C, + + /* driver writes number of bytes to read */ + AUDIO_START_READ = 0x20, + + /* number of bytes available in read buffer */ + AUDIO_READ_BUFFER_AVAILABLE = 0x24, + + /* AUDIO_INT_STATUS bits */ + + /* this bit set when it is safe to write more bytes to the buffer */ + AUDIO_INT_WRITE_BUFFER_1_EMPTY = 1U << 0, + AUDIO_INT_WRITE_BUFFER_2_EMPTY = 1U << 1, + AUDIO_INT_READ_BUFFER_FULL = 1U << 2, + + AUDIO_INT_MASK = AUDIO_INT_WRITE_BUFFER_1_EMPTY | + AUDIO_INT_WRITE_BUFFER_2_EMPTY | + AUDIO_INT_READ_BUFFER_FULL, +}; + + +static atomic_t open_count = ATOMIC_INIT(0); + + +static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, + size_t count, loff_t *pos) +{ + struct goldfish_audio *data = fp->private_data; + int length; + int result = 0; + + if (!data->read_supported) + return -ENODEV; + + while (count > 0) { + length = (count > READ_BUFFER_SIZE ? READ_BUFFER_SIZE : count); + AUDIO_WRITE(data, AUDIO_START_READ, length); + + wait_event_interruptible(data->wait, + (data->buffer_status & AUDIO_INT_READ_BUFFER_FULL)); + + length = AUDIO_READ(data, + AUDIO_READ_BUFFER_AVAILABLE); + + /* copy data to user space */ + if (copy_to_user(buf, data->read_buffer, length)) + return -EFAULT; + + result += length; + buf += length; + count -= length; + } + return result; +} + +static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct goldfish_audio *data = fp->private_data; + unsigned long irq_flags; + ssize_t result = 0; + char __iomem *kbuf; + + while (count > 0) { + ssize_t copy = count; + if (copy > WRITE_BUFFER_SIZE) + copy = WRITE_BUFFER_SIZE; + wait_event_interruptible(data->wait, (data->buffer_status & + (AUDIO_INT_WRITE_BUFFER_1_EMPTY | + AUDIO_INT_WRITE_BUFFER_2_EMPTY))); + + if ((data->buffer_status & AUDIO_INT_WRITE_BUFFER_1_EMPTY) != 0) + kbuf = data->write_buffer1; + else + kbuf = data->write_buffer2; + + /* copy from user space to the appropriate buffer */ + if (copy_from_user(kbuf, buf, copy)) { + result = -EFAULT; + break; + } + + spin_lock_irqsave(&data->lock, irq_flags); + /* clear the buffer empty flag, and signal the emulator + * to start writing the buffer */ + if (kbuf == data->write_buffer1) { + data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_1_EMPTY; + AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_1, copy); + } else { + data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_2_EMPTY; + AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_2, copy); + } + spin_unlock_irqrestore(&data->lock, irq_flags); + + buf += copy; + result += copy; + count -= copy; + } + return result; +} + +static int goldfish_audio_open(struct inode *ip, struct file *fp) +{ + if (!audio_data) + return -ENODEV; + + if (atomic_inc_return(&open_count) == 1) { + fp->private_data = audio_data; + audio_data->buffer_status = (AUDIO_INT_WRITE_BUFFER_1_EMPTY | + AUDIO_INT_WRITE_BUFFER_2_EMPTY); + AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, AUDIO_INT_MASK); + return 0; + } else { + atomic_dec(&open_count); + return -EBUSY; + } +} + +static int goldfish_audio_release(struct inode *ip, struct file *fp) +{ + atomic_dec(&open_count); + /* FIXME: surely this is wrong for the multi-opened case */ + AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, 0); + return 0; +} + +static long goldfish_audio_ioctl(struct file *fp, unsigned int cmd, + unsigned long arg) +{ + /* temporary workaround, until we switch to the ALSA API */ + if (cmd == 315) + return -1; + else + return 0; +} + +static irqreturn_t goldfish_audio_interrupt(int irq, void *dev_id) +{ + unsigned long irq_flags; + struct goldfish_audio *data = dev_id; + u32 status; + + spin_lock_irqsave(&data->lock, irq_flags); + + /* read buffer status flags */ + status = AUDIO_READ(data, AUDIO_INT_STATUS); + status &= AUDIO_INT_MASK; + /* if buffers are newly empty, wake up blocked + goldfish_audio_write() call */ + if (status) { + data->buffer_status = status; + wake_up(&data->wait); + } + + spin_unlock_irqrestore(&data->lock, irq_flags); + return status ? IRQ_HANDLED : IRQ_NONE; +} + +/* file operations for /dev/eac */ +static const struct file_operations goldfish_audio_fops = { + .owner = THIS_MODULE, + .read = goldfish_audio_read, + .write = goldfish_audio_write, + .open = goldfish_audio_open, + .release = goldfish_audio_release, + .unlocked_ioctl = goldfish_audio_ioctl, +}; + +static struct miscdevice goldfish_audio_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "eac", + .fops = &goldfish_audio_fops, +}; + +static int goldfish_audio_probe(struct platform_device *pdev) +{ + int ret; + struct resource *r; + struct goldfish_audio *data; + dma_addr_t buf_addr; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (data == NULL) { + ret = -ENOMEM; + goto err_data_alloc_failed; + } + spin_lock_init(&data->lock); + init_waitqueue_head(&data->wait); + platform_set_drvdata(pdev, data); + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (r == NULL) { + dev_err(&pdev->dev, "platform_get_resource failed\n"); + ret = -ENODEV; + goto err_no_io_base; + } + data->reg_base = ioremap(r->start, PAGE_SIZE); + if (data->reg_base == NULL) { + ret = -ENOMEM; + goto err_no_io_base; + } + + data->irq = platform_get_irq(pdev, 0); + if (data->irq < 0) { + dev_err(&pdev->dev, "platform_get_irq failed\n"); + ret = -ENODEV; + goto err_no_irq; + } + data->buffer_virt = dma_alloc_coherent(&pdev->dev, + COMBINED_BUFFER_SIZE, &buf_addr, GFP_KERNEL); + if (data->buffer_virt == 0) { + ret = -ENOMEM; + dev_err(&pdev->dev, "allocate buffer failed\n"); + goto err_alloc_write_buffer_failed; + } + data->buffer_phys = buf_addr; + data->write_buffer1 = data->buffer_virt; + data->write_buffer2 = data->buffer_virt + WRITE_BUFFER_SIZE; + data->read_buffer = data->buffer_virt + 2 * WRITE_BUFFER_SIZE; + + ret = request_irq(data->irq, goldfish_audio_interrupt, + IRQF_SHARED, pdev->name, data); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); + goto err_request_irq_failed; + } + + ret = misc_register(&goldfish_audio_device); + if (ret) { + dev_err(&pdev->dev, + "misc_register returned %d in goldfish_audio_init\n", + ret); + goto err_misc_register_failed; + } + + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr); + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2, + buf_addr + WRITE_BUFFER_SIZE); + + data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED); + if (data->read_supported) + AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER, + buf_addr + 2 * WRITE_BUFFER_SIZE); + + audio_data = data; + return 0; + +err_misc_register_failed: +err_request_irq_failed: + dma_free_coherent(&pdev->dev, COMBINED_BUFFER_SIZE, + data->buffer_virt, data->buffer_phys); +err_alloc_write_buffer_failed: +err_no_irq: + iounmap(data->reg_base); +err_no_io_base: + kfree(data); +err_data_alloc_failed: + return ret; +} + +static int goldfish_audio_remove(struct platform_device *pdev) +{ + struct goldfish_audio *data = platform_get_drvdata(pdev); + + misc_deregister(&goldfish_audio_device); + free_irq(data->irq, data); + dma_free_coherent(&pdev->dev, COMBINED_BUFFER_SIZE, + data->buffer_virt, data->buffer_phys); + iounmap(data->reg_base); + kfree(data); + audio_data = NULL; + return 0; +} + +static struct platform_driver goldfish_audio_driver = { + .probe = goldfish_audio_probe, + .remove = goldfish_audio_remove, + .driver = { + .name = "goldfish_audio" + } +}; + +module_platform_driver(goldfish_audio_driver); diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c new file mode 100644 index 0000000..ab1f019 --- /dev/null +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -0,0 +1,444 @@ +/* + * drivers/mtd/devices/goldfish_nand.c + * + * Copyright (C) 2007 Google, Inc. + * Copyright (C) 2012 Intel, Inc. + * Copyright (C) 2013 Intel, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include <linux/io.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/ioport.h> +#include <linux/vmalloc.h> +#include <linux/init.h> +#include <linux/mtd/mtd.h> +#include <linux/platform_device.h> + +#include <asm/div64.h> + +#include "goldfish_nand_reg.h" + +struct goldfish_nand { + spinlock_t lock; + unsigned char __iomem *base; + struct cmd_params *cmd_params; + size_t mtd_count; + struct mtd_info mtd[0]; +}; + +static u32 goldfish_nand_cmd_with_params(struct mtd_info *mtd, + enum nand_cmd cmd, u64 addr, u32 len, + void *ptr, u32 *rv) +{ + u32 cmdp; + struct goldfish_nand *nand = mtd->priv; + struct cmd_params *cps = nand->cmd_params; + unsigned char __iomem *base = nand->base; + + if (cps == NULL) + return -1; + + switch (cmd) { + case NAND_CMD_ERASE: + cmdp = NAND_CMD_ERASE_WITH_PARAMS; + break; + case NAND_CMD_READ: + cmdp = NAND_CMD_READ_WITH_PARAMS; + break; + case NAND_CMD_WRITE: + cmdp = NAND_CMD_WRITE_WITH_PARAMS; + break; + default: + return -1; + } + cps->dev = mtd - nand->mtd; + cps->addr_high = (u32)(addr >> 32); + cps->addr_low = (u32)addr; + cps->transfer_size = len; + cps->data = (u32)ptr; + writel(cmdp, base + NAND_COMMAND); + *rv = cps->result; + return 0; +} + +static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, + u64 addr, u32 len, void *ptr) +{ + struct goldfish_nand *nand = mtd->priv; + u32 rv; + unsigned long irq_flags; + unsigned char __iomem *base = nand->base; + + spin_lock_irqsave(&nand->lock, irq_flags); + if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) { + writel(mtd - nand->mtd, base + NAND_DEV); + writel((u32)(addr >> 32), base + NAND_ADDR_HIGH); + writel((u32)addr, base + NAND_ADDR_LOW); + writel(len, base + NAND_TRANSFER_SIZE); + writel((u32)ptr, base + NAND_DATA); + writel(cmd, base + NAND_COMMAND); + rv = readl(base + NAND_RESULT); + } + spin_unlock_irqrestore(&nand->lock, irq_flags); + return rv; +} + +static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr) +{ + loff_t ofs = instr->addr; + u32 len = instr->len; + u32 rem; + + if (ofs + len > mtd->size) + goto invalid_arg; + rem = do_div(ofs, mtd->writesize); + if (rem) + goto invalid_arg; + ofs *= (mtd->writesize + mtd->oobsize); + + if (len % mtd->writesize) + goto invalid_arg; + len = len / mtd->writesize * (mtd->writesize + mtd->oobsize); + + if (goldfish_nand_cmd(mtd, NAND_CMD_ERASE, ofs, len, NULL) != len) { + pr_err("goldfish_nand_erase: erase failed, start %llx, len %x, dev_size %llx, erase_size %x\n", + ofs, len, mtd->size, mtd->erasesize); + return -EIO; + } + + instr->state = MTD_ERASE_DONE; + mtd_erase_callback(instr); + + return 0; + +invalid_arg: + pr_err("goldfish_nand_erase: invalid erase, start %llx, len %x, dev_size %llx, erase_size %x\n", + ofs, len, mtd->size, mtd->erasesize); + return -EINVAL; +} + +static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs, + struct mtd_oob_ops *ops) +{ + u32 rem; + + if (ofs + ops->len > mtd->size) + goto invalid_arg; + if (ops->datbuf && ops->len && ops->len != mtd->writesize) + goto invalid_arg; + if (ops->ooblen + ops->ooboffs > mtd->oobsize) + goto invalid_arg; + + rem = do_div(ofs, mtd->writesize); + if (rem) + goto invalid_arg; + ofs *= (mtd->writesize + mtd->oobsize); + + if (ops->datbuf) + ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs, + ops->len, ops->datbuf); + ofs += mtd->writesize + ops->ooboffs; + if (ops->oobbuf) + ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs, + ops->ooblen, ops->oobbuf); + return 0; + +invalid_arg: + pr_err("goldfish_nand_read_oob: invalid read, start %llx, len %zx, ooblen %zx, dev_size %llx, write_size %x\n", + ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs, + struct mtd_oob_ops *ops) +{ + u32 rem; + + if (ofs + ops->len > mtd->size) + goto invalid_arg; + if (ops->len && ops->len != mtd->writesize) + goto invalid_arg; + if (ops->ooblen + ops->ooboffs > mtd->oobsize) + goto invalid_arg; + + rem = do_div(ofs, mtd->writesize); + if (rem) + goto invalid_arg; + ofs *= (mtd->writesize + mtd->oobsize); + + if (ops->datbuf) + ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs, + ops->len, ops->datbuf); + ofs += mtd->writesize + ops->ooboffs; + if (ops->oobbuf) + ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs, + ops->ooblen, ops->oobbuf); + return 0; + +invalid_arg: + pr_err("goldfish_nand_write_oob: invalid write, start %llx, len %zx, ooblen %zx, dev_size %llx, write_size %x\n", + ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, u_char *buf) +{ + u32 rem; + + if (from + len > mtd->size) + goto invalid_arg; + if (len != mtd->writesize) + goto invalid_arg; + + rem = do_div(from, mtd->writesize); + if (rem) + goto invalid_arg; + from *= (mtd->writesize + mtd->oobsize); + + *retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, from, len, buf); + return 0; + +invalid_arg: + pr_err("goldfish_nand_read: invalid read, start %llx, len %zx, dev_size %llx, write_size %x\n", + from, len, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) +{ + u32 rem; + + if (to + len > mtd->size) + goto invalid_arg; + if (len != mtd->writesize) + goto invalid_arg; + + rem = do_div(to, mtd->writesize); + if (rem) + goto invalid_arg; + to *= (mtd->writesize + mtd->oobsize); + + *retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, to, len, (void *)buf); + return 0; + +invalid_arg: + pr_err("goldfish_nand_write: invalid write, start %llx, len %zx, dev_size %llx, write_size %x\n", + to, len, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) +{ + u32 rem; + + if (ofs >= mtd->size) + goto invalid_arg; + + rem = do_div(ofs, mtd->erasesize); + if (rem) + goto invalid_arg; + ofs *= mtd->erasesize / mtd->writesize; + ofs *= (mtd->writesize + mtd->oobsize); + + return goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_GET, ofs, 0, NULL); + +invalid_arg: + pr_err("goldfish_nand_block_isbad: invalid arg, ofs %llx, dev_size %llx, write_size %x\n", + ofs, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) +{ + u32 rem; + + if (ofs >= mtd->size) + goto invalid_arg; + + rem = do_div(ofs, mtd->erasesize); + if (rem) + goto invalid_arg; + ofs *= mtd->erasesize / mtd->writesize; + ofs *= (mtd->writesize + mtd->oobsize); + + if (goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_SET, ofs, 0, NULL) != 1) + return -EIO; + return 0; + +invalid_arg: + pr_err("goldfish_nand_block_markbad: invalid arg, ofs %llx, dev_size %llx, write_size %x\n", + ofs, mtd->size, mtd->writesize); + return -EINVAL; +} + +static int nand_setup_cmd_params(struct platform_device *pdev, + struct goldfish_nand *nand) +{ + u64 paddr; + unsigned char __iomem *base = nand->base; + + nand->cmd_params = devm_kzalloc(&pdev->dev, + sizeof(struct cmd_params), GFP_KERNEL); + if (!nand->cmd_params) + return -1; + + paddr = __pa(nand->cmd_params); + writel((u32)(paddr >> 32), base + NAND_CMD_PARAMS_ADDR_HIGH); + writel((u32)paddr, base + NAND_CMD_PARAMS_ADDR_LOW); + return 0; +} + +static int goldfish_nand_init_device(struct platform_device *pdev, + struct goldfish_nand *nand, int id) +{ + u32 name_len; + u32 result; + u32 flags; + unsigned long irq_flags; + unsigned char __iomem *base = nand->base; + struct mtd_info *mtd = &nand->mtd[id]; + char *name; + + spin_lock_irqsave(&nand->lock, irq_flags); + writel(id, base + NAND_DEV); + flags = readl(base + NAND_DEV_FLAGS); + name_len = readl(base + NAND_DEV_NAME_LEN); + mtd->writesize = readl(base + NAND_DEV_PAGE_SIZE); + mtd->size = readl(base + NAND_DEV_SIZE_LOW); + mtd->size |= (u64)readl(base + NAND_DEV_SIZE_HIGH) << 32; + mtd->oobsize = readl(base + NAND_DEV_EXTRA_SIZE); + mtd->oobavail = mtd->oobsize; + mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) / + (mtd->writesize + mtd->oobsize) * mtd->writesize; + do_div(mtd->size, mtd->writesize + mtd->oobsize); + mtd->size *= mtd->writesize; + dev_dbg(&pdev->dev, + "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n", + id, mtd->size, mtd->writesize, mtd->oobsize, mtd->erasesize); + spin_unlock_irqrestore(&nand->lock, irq_flags); + + mtd->priv = nand; + + mtd->name = name = devm_kzalloc(&pdev->dev, name_len + 1, GFP_KERNEL); + if (name == NULL) + return -ENOMEM; + + result = goldfish_nand_cmd(mtd, NAND_CMD_GET_DEV_NAME, 0, name_len, + name); + if (result != name_len) { + dev_err(&pdev->dev, + "goldfish_nand_init_device failed to get dev name %d != %d\n", + result, name_len); + return -ENODEV; + } + ((char *) mtd->name)[name_len] = '\0'; + + /* Setup the MTD structure */ + mtd->type = MTD_NANDFLASH; + mtd->flags = MTD_CAP_NANDFLASH; + if (flags & NAND_DEV_FLAG_READ_ONLY) + mtd->flags &= ~MTD_WRITEABLE; + if (flags & NAND_DEV_FLAG_CMD_PARAMS_CAP) + nand_setup_cmd_params(pdev, nand); + + mtd->owner = THIS_MODULE; + mtd->_erase = goldfish_nand_erase; + mtd->_read = goldfish_nand_read; + mtd->_write = goldfish_nand_write; + mtd->_read_oob = goldfish_nand_read_oob; + mtd->_write_oob = goldfish_nand_write_oob; + mtd->_block_isbad = goldfish_nand_block_isbad; + mtd->_block_markbad = goldfish_nand_block_markbad; + + if (mtd_device_register(mtd, NULL, 0)) + return -EIO; + + return 0; +} + +static int goldfish_nand_probe(struct platform_device *pdev) +{ + u32 num_dev; + int i; + int err; + u32 num_dev_working; + u32 version; + struct resource *r; + struct goldfish_nand *nand; + unsigned char __iomem *base; + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (r == NULL) + return -ENODEV; + + base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); + if (base == NULL) + return -ENOMEM; + + version = readl(base + NAND_VERSION); + if (version != NAND_VERSION_CURRENT) { + dev_err(&pdev->dev, + "goldfish_nand_init: version mismatch, got %d, expected %d\n", + version, NAND_VERSION_CURRENT); + return -ENODEV; + } + num_dev = readl(base + NAND_NUM_DEV); + if (num_dev == 0) + return -ENODEV; + + nand = devm_kzalloc(&pdev->dev, sizeof(*nand) + + sizeof(struct mtd_info) * num_dev, GFP_KERNEL); + if (nand == NULL) + return -ENOMEM; + + spin_lock_init(&nand->lock); + nand->base = base; + nand->mtd_count = num_dev; + platform_set_drvdata(pdev, nand); + + num_dev_working = 0; + for (i = 0; i < num_dev; i++) { + err = goldfish_nand_init_device(pdev, nand, i); + if (err == 0) + num_dev_working++; + } + if (num_dev_working == 0) + return -ENODEV; + return 0; +} + +static int goldfish_nand_remove(struct platform_device *pdev) +{ + struct goldfish_nand *nand = platform_get_drvdata(pdev); + int i; + for (i = 0; i < nand->mtd_count; i++) { + if (nand->mtd[i].name) + mtd_device_unregister(&nand->mtd[i]); + } + return 0; +} + +static struct platform_driver goldfish_nand_driver = { + .probe = goldfish_nand_probe, + .remove = goldfish_nand_remove, + .driver = { + .name = "goldfish_nand" + } +}; + +module_platform_driver(goldfish_nand_driver); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/goldfish/goldfish_nand_reg.h b/drivers/staging/goldfish/goldfish_nand_reg.h new file mode 100644 index 0000000..956c6c3 --- /dev/null +++ b/drivers/staging/goldfish/goldfish_nand_reg.h @@ -0,0 +1,72 @@ +/* drivers/mtd/devices/goldfish_nand_reg.h +** +** Copyright (C) 2007 Google, Inc. +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** 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. +** +*/ + +#ifndef GOLDFISH_NAND_REG_H +#define GOLDFISH_NAND_REG_H + +enum nand_cmd { + NAND_CMD_GET_DEV_NAME, /* Write device name for NAND_DEV to NAND_DATA (vaddr) */ + NAND_CMD_READ, + NAND_CMD_WRITE, + NAND_CMD_ERASE, + NAND_CMD_BLOCK_BAD_GET, /* NAND_RESULT is 1 if block is bad, 0 if it is not */ + NAND_CMD_BLOCK_BAD_SET, + NAND_CMD_READ_WITH_PARAMS, + NAND_CMD_WRITE_WITH_PARAMS, + NAND_CMD_ERASE_WITH_PARAMS +}; + +enum nand_dev_flags { + NAND_DEV_FLAG_READ_ONLY = 0x00000001, + NAND_DEV_FLAG_CMD_PARAMS_CAP = 0x00000002, +}; + +#define NAND_VERSION_CURRENT (1) + +enum nand_reg { + /* Global */ + NAND_VERSION = 0x000, + NAND_NUM_DEV = 0x004, + NAND_DEV = 0x008, + + /* Dev info */ + NAND_DEV_FLAGS = 0x010, + NAND_DEV_NAME_LEN = 0x014, + NAND_DEV_PAGE_SIZE = 0x018, + NAND_DEV_EXTRA_SIZE = 0x01c, + NAND_DEV_ERASE_SIZE = 0x020, + NAND_DEV_SIZE_LOW = 0x028, + NAND_DEV_SIZE_HIGH = 0x02c, + + /* Command */ + NAND_RESULT = 0x040, + NAND_COMMAND = 0x044, + NAND_DATA = 0x048, + NAND_TRANSFER_SIZE = 0x04c, + NAND_ADDR_LOW = 0x050, + NAND_ADDR_HIGH = 0x054, + NAND_CMD_PARAMS_ADDR_LOW = 0x058, + NAND_CMD_PARAMS_ADDR_HIGH = 0x05c, +}; + +struct cmd_params { + uint32_t dev; + uint32_t addr_low; + uint32_t addr_high; + uint32_t transfer_size; + uint32_t data; + uint32_t result; +}; +#endif diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig index ca56c75..dc26717 100644 --- a/drivers/staging/iio/Kconfig +++ b/drivers/staging/iio/Kconfig @@ -12,19 +12,6 @@ config IIO_ST_HWMON map allows IIO devices to provide basic hwmon functionality for those channels specified in the map. -if IIO_BUFFER - -config IIO_SW_RING - select IIO_TRIGGER - tristate "Industrial I/O lock free software ring" - help - Example software ring buffer implementation. The design aim - of this particular realization was to minimize write locking - with the intention that some devices would be able to write - in interrupt context. - -endif # IIO_BUFFER - source "drivers/staging/iio/accel/Kconfig" source "drivers/staging/iio/adc/Kconfig" source "drivers/staging/iio/addac/Kconfig" @@ -32,7 +19,6 @@ source "drivers/staging/iio/cdc/Kconfig" source "drivers/staging/iio/frequency/Kconfig" source "drivers/staging/iio/gyro/Kconfig" source "drivers/staging/iio/impedance-analyzer/Kconfig" -source "drivers/staging/iio/imu/Kconfig" source "drivers/staging/iio/light/Kconfig" source "drivers/staging/iio/magnetometer/Kconfig" source "drivers/staging/iio/meter/Kconfig" diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index fa6937d..158e0a0 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -2,8 +2,6 @@ # Makefile for the industrial I/O core. # -obj-$(CONFIG_IIO_SW_RING) += ring_sw.o - obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_dummy.o iio_dummy-y := iio_simple_dummy.o iio_dummy-$(CONFIG_IIO_SIMPLE_DUMMY_EVENTS) += iio_simple_dummy_events.o @@ -20,7 +18,6 @@ obj-y += cdc/ obj-y += frequency/ obj-y += gyro/ obj-y += impedance-analyzer/ -obj-y += imu/ obj-y += light/ obj-y += magnetometer/ obj-y += meter/ diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index 2b54430..e2e786d 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -56,45 +56,17 @@ config ADIS16240 Say yes here to build support for Analog Devices adis16240 programmable impact Sensor and recorder. -config KXSD9 - tristate "Kionix KXSD9 Accelerometer Driver" - depends on SPI - help - Say yes here to build support for the Kionix KXSD9 accelerometer. - Currently this only supports the device via an SPI interface. - config LIS3L02DQ tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver" depends on SPI select IIO_TRIGGER if IIO_BUFFER - depends on !IIO_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING + depends on !IIO_BUFFER || IIO_KFIFO_BUF depends on GENERIC_GPIO help Say yes here to build SPI support for the ST microelectronics accelerometer. The driver supplies direct access via sysfs files and an event interface via a character device. -choice - prompt "Buffer type" - depends on LIS3L02DQ && IIO_BUFFER - -config LIS3L02DQ_BUF_KFIFO - depends on IIO_KFIFO_BUF - bool "Simple FIFO" - help - Kfifo based FIFO. Does not provide any events so it is up - to userspace to ensure it reads often enough that data is not - lost. - -config LIS3L02DQ_BUF_RING_SW - depends on IIO_SW_RING - bool "IIO Software Ring" - help - Original IIO ring buffer implementation. Provides simple - buffer events, half full etc. - -endchoice - config SCA3000 depends on IIO_BUFFER depends on SPI diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile index 8e7ee03..1ed137f 100644 --- a/drivers/staging/iio/accel/Makefile +++ b/drivers/staging/iio/accel/Makefile @@ -20,8 +20,6 @@ obj-$(CONFIG_ADIS16220) += adis16220.o adis16240-y := adis16240_core.o obj-$(CONFIG_ADIS16240) += adis16240.o -obj-$(CONFIG_KXSD9) += kxsd9.o - lis3l02dq-y := lis3l02dq_core.o lis3l02dq-$(CONFIG_IIO_BUFFER) += lis3l02dq_ring.o obj-$(CONFIG_LIS3L02DQ) += lis3l02dq.o diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c deleted file mode 100644 index 318331f..0000000 --- a/drivers/staging/iio/accel/kxsd9.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * kxsd9.c simple support for the Kionix KXSD9 3D - * accelerometer. - * - * Copyright (c) 2008-2009 Jonathan Cameron <jic23@kernel.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * The i2c interface is very similar, so shouldn't be a problem once - * I have a suitable wire made up. - * - * TODO: Support the motion detector - * Uses register address incrementing so could have a - * heavily optimized ring buffer access function. - */ - -#include <linux/device.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/sysfs.h> -#include <linux/slab.h> -#include <linux/module.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> - -#define KXSD9_REG_X 0x00 -#define KXSD9_REG_Y 0x02 -#define KXSD9_REG_Z 0x04 -#define KXSD9_REG_AUX 0x06 -#define KXSD9_REG_RESET 0x0a -#define KXSD9_REG_CTRL_C 0x0c - -#define KXSD9_FS_MASK 0x03 - -#define KXSD9_REG_CTRL_B 0x0d -#define KXSD9_REG_CTRL_A 0x0e - -#define KXSD9_READ(a) (0x80 | (a)) -#define KXSD9_WRITE(a) (a) - -#define KXSD9_STATE_RX_SIZE 2 -#define KXSD9_STATE_TX_SIZE 2 -/** - * struct kxsd9_state - device related storage - * @buf_lock: protect the rx and tx buffers. - * @us: spi device - * @rx: single rx buffer storage - * @tx: single tx buffer storage - **/ -struct kxsd9_state { - struct mutex buf_lock; - struct spi_device *us; - u8 rx[KXSD9_STATE_RX_SIZE] ____cacheline_aligned; - u8 tx[KXSD9_STATE_TX_SIZE]; -}; - -#define KXSD9_SCALE_2G "0.011978" -#define KXSD9_SCALE_4G "0.023927" -#define KXSD9_SCALE_6G "0.035934" -#define KXSD9_SCALE_8G "0.047853" - -/* reverse order */ -static const int kxsd9_micro_scales[4] = { 47853, 35934, 23927, 11978 }; - -static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro) -{ - int ret, i; - struct kxsd9_state *st = iio_priv(indio_dev); - bool foundit = false; - - for (i = 0; i < 4; i++) - if (micro == kxsd9_micro_scales[i]) { - foundit = true; - break; - } - if (!foundit) - return -EINVAL; - - mutex_lock(&st->buf_lock); - ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); - if (ret) - goto error_ret; - st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C); - st->tx[1] = (ret & ~KXSD9_FS_MASK) | i; - - ret = spi_write(st->us, st->tx, 2); -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -static int kxsd9_read(struct iio_dev *indio_dev, u8 address) -{ - struct spi_message msg; - int ret; - struct kxsd9_state *st = iio_priv(indio_dev); - struct spi_transfer xfers[] = { - { - .bits_per_word = 8, - .len = 1, - .delay_usecs = 200, - .tx_buf = st->tx, - }, { - .bits_per_word = 8, - .len = 2, - .rx_buf = st->rx, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = KXSD9_READ(address); - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); - if (ret) - return ret; - return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); -} - -static IIO_CONST_ATTR(accel_scale_available, - KXSD9_SCALE_2G " " - KXSD9_SCALE_4G " " - KXSD9_SCALE_6G " " - KXSD9_SCALE_8G); - -static struct attribute *kxsd9_attributes[] = { - &iio_const_attr_accel_scale_available.dev_attr.attr, - NULL, -}; - -static int kxsd9_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) -{ - int ret = -EINVAL; - - if (mask == IIO_CHAN_INFO_SCALE) { - /* Check no integer component */ - if (val) - return -EINVAL; - ret = kxsd9_write_scale(indio_dev, val2); - } - - return ret; -} - -static int kxsd9_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) -{ - int ret = -EINVAL; - struct kxsd9_state *st = iio_priv(indio_dev); - - switch (mask) { - case IIO_CHAN_INFO_RAW: - ret = kxsd9_read(indio_dev, chan->address); - if (ret < 0) - goto error_ret; - *val = ret; - break; - case IIO_CHAN_INFO_SCALE: - ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); - if (ret) - goto error_ret; - *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; - ret = IIO_VAL_INT_PLUS_MICRO; - break; - } - -error_ret: - return ret; -}; -#define KXSD9_ACCEL_CHAN(axis) \ - { \ - .type = IIO_ACCEL, \ - .modified = 1, \ - .channel2 = IIO_MOD_##axis, \ - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ - IIO_CHAN_INFO_SCALE_SHARED_BIT, \ - .address = KXSD9_REG_##axis, \ - } - -static const struct iio_chan_spec kxsd9_channels[] = { - KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z), - { - .type = IIO_VOLTAGE, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, - .indexed = 1, - .address = KXSD9_REG_AUX, - } -}; - -static const struct attribute_group kxsd9_attribute_group = { - .attrs = kxsd9_attributes, -}; - -static int kxsd9_power_up(struct kxsd9_state *st) -{ - int ret; - - st->tx[0] = 0x0d; - st->tx[1] = 0x40; - ret = spi_write(st->us, st->tx, 2); - if (ret) - return ret; - - st->tx[0] = 0x0c; - st->tx[1] = 0x9b; - return spi_write(st->us, st->tx, 2); -}; - -static const struct iio_info kxsd9_info = { - .read_raw = &kxsd9_read_raw, - .write_raw = &kxsd9_write_raw, - .attrs = &kxsd9_attribute_group, - .driver_module = THIS_MODULE, -}; - -static int kxsd9_probe(struct spi_device *spi) -{ - struct iio_dev *indio_dev; - struct kxsd9_state *st; - int ret = 0; - - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); - - st->us = spi; - mutex_init(&st->buf_lock); - indio_dev->channels = kxsd9_channels; - indio_dev->num_channels = ARRAY_SIZE(kxsd9_channels); - indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &kxsd9_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - - spi->mode = SPI_MODE_0; - spi_setup(spi); - kxsd9_power_up(st); - - return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; -} - -static int kxsd9_remove(struct spi_device *spi) -{ - iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - - return 0; -} - -static const struct spi_device_id kxsd9_id[] = { - {"kxsd9", 0}, - { }, -}; -MODULE_DEVICE_TABLE(spi, kxsd9_id); - -static struct spi_driver kxsd9_driver = { - .driver = { - .name = "kxsd9", - .owner = THIS_MODULE, - }, - .probe = kxsd9_probe, - .remove = kxsd9_remove, - .id_table = kxsd9_id, -}; -module_spi_driver(kxsd9_driver); - -MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>"); -MODULE_DESCRIPTION("Kionix KXSD9 SPI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h index 2bac722..0a8ea82 100644 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ b/drivers/staging/iio/accel/lis3l02dq.h @@ -185,14 +185,6 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev); int lis3l02dq_configure_buffer(struct iio_dev *indio_dev); void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev); -#ifdef CONFIG_LIS3L02DQ_BUF_RING_SW -#define lis3l02dq_free_buf iio_sw_rb_free -#define lis3l02dq_alloc_buf iio_sw_rb_allocate -#endif -#ifdef CONFIG_LIS3L02DQ_BUF_KFIFO -#define lis3l02dq_free_buf iio_kfifo_free -#define lis3l02dq_alloc_buf iio_kfifo_allocate -#endif irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private); #define lis3l02dq_th lis3l02dq_data_rdy_trig_poll diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 37ed1b8..0e01930 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -53,7 +53,6 @@ int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, u8 reg_address, u8 *val) { struct lis3l02dq_state *st = iio_priv(indio_dev); - struct spi_message msg; int ret; struct spi_transfer xfer = { .tx_buf = st->tx, @@ -66,9 +65,7 @@ int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, st->tx[0] = LIS3L02DQ_READ_REG(reg_address); st->tx[1] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, &xfer, 1); *val = st->rx[1]; mutex_unlock(&st->buf_lock); @@ -109,7 +106,6 @@ static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev, s16 value) { int ret; - struct spi_message msg; struct lis3l02dq_state *st = iio_priv(indio_dev); struct spi_transfer xfers[] = { { .tx_buf = st->tx, @@ -129,10 +125,7 @@ static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev, st->tx[2] = LIS3L02DQ_WRITE_REG(lower_reg_address + 1); st->tx[3] = (value >> 8) & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); mutex_unlock(&st->buf_lock); return ret; @@ -143,8 +136,6 @@ static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev, int *val) { struct lis3l02dq_state *st = iio_priv(indio_dev); - - struct spi_message msg; int ret; s16 tempval; struct spi_transfer xfers[] = { { @@ -167,10 +158,7 @@ static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev, st->tx[2] = LIS3L02DQ_READ_REG(lower_reg_address + 1); st->tx[3] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 16 bit register"); goto error_ret; diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index bc38651..e676403 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -7,7 +7,6 @@ #include <linux/export.h> #include <linux/iio/iio.h> -#include "../ring_sw.h" #include <linux/iio/kfifo_buf.h> #include <linux/iio/trigger.h> #include <linux/iio/trigger_consumer.h> @@ -141,11 +140,8 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) char *data; data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (data == NULL) { - dev_err(indio_dev->dev.parent, - "memory alloc failed in buffer bh"); + if (data == NULL) goto done; - } if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) len = lis3l02dq_get_buffer_element(indio_dev, data); @@ -318,7 +314,7 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - lis3l02dq_free_buf(indio_dev->buffer); + iio_kfifo_free(indio_dev->buffer); } static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev) @@ -401,7 +397,7 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) int ret; struct iio_buffer *buffer; - buffer = lis3l02dq_alloc_buf(indio_dev); + buffer = iio_kfifo_allocate(indio_dev); if (!buffer) return -ENOMEM; @@ -427,6 +423,6 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) return 0; error_iio_sw_rb_free: - lis3l02dq_free_buf(indio_dev->buffer); + iio_kfifo_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 414d3ca..14683f5 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -90,7 +90,6 @@ int sca3000_read_data_short(struct sca3000_state *st, uint8_t reg_address_high, int len) { - struct spi_message msg; struct spi_transfer xfer[2] = { { .len = 1, @@ -101,11 +100,8 @@ int sca3000_read_data_short(struct sca3000_state *st, } }; st->tx[0] = SCA3000_READ_REG(reg_address_high); - spi_message_init(&msg); - spi_message_add_tail(&xfer[0], &msg); - spi_message_add_tail(&xfer[1], &msg); - return spi_sync(st->us, &msg); + return spi_sync_transfer(st->us, xfer, ARRAY_SIZE(xfer)); } /** @@ -133,7 +129,6 @@ static int sca3000_reg_lock_on(struct sca3000_state *st) **/ static int __sca3000_unlock_reg_lock(struct sca3000_state *st) { - struct spi_message msg; struct spi_transfer xfer[3] = { { .len = 2, @@ -154,12 +149,8 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st) st->tx[3] = 0x50; st->tx[4] = SCA3000_WRITE_REG(SCA3000_REG_ADDR_UNLOCK); st->tx[5] = 0xA0; - spi_message_init(&msg); - spi_message_add_tail(&xfer[0], &msg); - spi_message_add_tail(&xfer[1], &msg); - spi_message_add_tail(&xfer[2], &msg); - return spi_sync(st->us, &msg); + return spi_sync_transfer(st->us, xfer, ARRAY_SIZE(xfer)); } /** diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index cbec2f1..3e5e860 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -39,7 +39,6 @@ static int sca3000_read_data(struct sca3000_state *st, int len) { int ret; - struct spi_message msg; struct spi_transfer xfer[2] = { { .len = 1, @@ -55,10 +54,7 @@ static int sca3000_read_data(struct sca3000_state *st, } xfer[1].rx_buf = *rx_p; st->tx[0] = SCA3000_READ_REG(reg_address_high); - spi_message_init(&msg); - spi_message_add_tail(&xfer[0], &msg); - spi_message_add_tail(&xfer[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfer, ARRAY_SIZE(xfer)); if (ret) { dev_err(get_device(&st->us->dev), "problem reading register"); goto error_free_rx; diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index fb8c239..7b2a01d 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -119,12 +119,12 @@ config LPC32XX_ADC via sysfs. config MXS_LRADC - tristate "Freescale i.MX28 LRADC" + tristate "Freescale i.MX23/i.MX28 LRADC" depends on ARCH_MXS select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - Say yes here to build support for i.MX28 LRADC convertor + Say yes here to build support for i.MX23/i.MX28 LRADC convertor built into these chips. To compile this driver as a module, choose M here: the diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index fa81a49..1f190c1 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -199,12 +199,8 @@ static int __ad7280_read32(struct spi_device *spi, unsigned *val) .rx_buf = &rx_buf, .len = 4, }; - struct spi_message m; - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - ret = spi_sync(spi, &m); + ret = spi_sync_transfer(spi, &t, 1); if (ret) return ret; diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 3d562da..55a459b 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -33,6 +33,8 @@ #include <linux/stmp_device.h> #include <linux/bitops.h> #include <linux/completion.h> +#include <linux/delay.h> +#include <linux/input.h> #include <mach/mxs.h> #include <mach/common.h> @@ -60,7 +62,39 @@ #define LRADC_DELAY_TIMER_PER 200 #define LRADC_DELAY_TIMER_LOOP 5 -static const char * const mxs_lradc_irq_name[] = { +/* + * Once the pen touches the touchscreen, the touchscreen switches from + * IRQ-driven mode to polling mode to prevent interrupt storm. The polling + * is realized by worker thread, which is called every 20 or so milliseconds. + * This gives the touchscreen enough fluence and does not strain the system + * too much. + */ +#define LRADC_TS_SAMPLE_DELAY_MS 5 + +/* + * The LRADC reads the following amount of samples from each touchscreen + * channel and the driver then computes avarage of these. + */ +#define LRADC_TS_SAMPLE_AMOUNT 4 + +enum mxs_lradc_id { + IMX23_LRADC, + IMX28_LRADC, +}; + +static const char * const mx23_lradc_irq_names[] = { + "mxs-lradc-touchscreen", + "mxs-lradc-channel0", + "mxs-lradc-channel1", + "mxs-lradc-channel2", + "mxs-lradc-channel3", + "mxs-lradc-channel4", + "mxs-lradc-channel5", + "mxs-lradc-channel6", + "mxs-lradc-channel7", +}; + +static const char * const mx28_lradc_irq_names[] = { "mxs-lradc-touchscreen", "mxs-lradc-thresh0", "mxs-lradc-thresh1", @@ -76,9 +110,26 @@ static const char * const mxs_lradc_irq_name[] = { "mxs-lradc-button1", }; -struct mxs_lradc_chan { - uint8_t slot; - uint8_t flags; +struct mxs_lradc_of_config { + const int irq_count; + const char * const *irq_name; +}; + +static const struct mxs_lradc_of_config mxs_lradc_of_config[] = { + [IMX23_LRADC] = { + .irq_count = ARRAY_SIZE(mx23_lradc_irq_names), + .irq_name = mx23_lradc_irq_names, + }, + [IMX28_LRADC] = { + .irq_count = ARRAY_SIZE(mx28_lradc_irq_names), + .irq_name = mx28_lradc_irq_names, + }, +}; + +enum mxs_lradc_ts { + MXS_LRADC_TOUCHSCREEN_NONE = 0, + MXS_LRADC_TOUCHSCREEN_4WIRE, + MXS_LRADC_TOUCHSCREEN_5WIRE, }; struct mxs_lradc { @@ -91,24 +142,70 @@ struct mxs_lradc { struct mutex lock; - uint8_t enable; - struct completion completion; + + /* + * Touchscreen LRADC channels receives a private slot in the CTRL4 + * register, the slot #7. Therefore only 7 slots instead of 8 in the + * CTRL4 register can be mapped to LRADC channels when using the + * touchscreen. + * + * Furthermore, certain LRADC channels are shared between touchscreen + * and/or touch-buttons and generic LRADC block. Therefore when using + * either of these, these channels are not available for the regular + * sampling. The shared channels are as follows: + * + * CH0 -- Touch button #0 + * CH1 -- Touch button #1 + * CH2 -- Touch screen XPUL + * CH3 -- Touch screen YPLL + * CH4 -- Touch screen XNUL + * CH5 -- Touch screen YNLR + * CH6 -- Touch screen WIPER (5-wire only) + * + * The bitfields below represents which parts of the LRADC block are + * switched into special mode of operation. These channels can not + * be sampled as regular LRADC channels. The driver will refuse any + * attempt to sample these channels. + */ +#define CHAN_MASK_TOUCHBUTTON (0x3 << 0) +#define CHAN_MASK_TOUCHSCREEN_4WIRE (0xf << 2) +#define CHAN_MASK_TOUCHSCREEN_5WIRE (0x1f << 2) + enum mxs_lradc_ts use_touchscreen; + bool stop_touchscreen; + bool use_touchbutton; + + struct input_dev *ts_input; + struct work_struct ts_work; }; #define LRADC_CTRL0 0x00 -#define LRADC_CTRL0_TOUCH_DETECT_ENABLE (1 << 23) -#define LRADC_CTRL0_TOUCH_SCREEN_TYPE (1 << 22) +#define LRADC_CTRL0_TOUCH_DETECT_ENABLE (1 << 23) +#define LRADC_CTRL0_TOUCH_SCREEN_TYPE (1 << 22) +#define LRADC_CTRL0_YNNSW /* YM */ (1 << 21) +#define LRADC_CTRL0_YPNSW /* YP */ (1 << 20) +#define LRADC_CTRL0_YPPSW /* YP */ (1 << 19) +#define LRADC_CTRL0_XNNSW /* XM */ (1 << 18) +#define LRADC_CTRL0_XNPSW /* XM */ (1 << 17) +#define LRADC_CTRL0_XPPSW /* XP */ (1 << 16) +#define LRADC_CTRL0_PLATE_MASK (0x3f << 16) #define LRADC_CTRL1 0x10 -#define LRADC_CTRL1_LRADC_IRQ(n) (1 << (n)) -#define LRADC_CTRL1_LRADC_IRQ_MASK 0x1fff +#define LRADC_CTRL1_TOUCH_DETECT_IRQ_EN (1 << 24) #define LRADC_CTRL1_LRADC_IRQ_EN(n) (1 << ((n) + 16)) #define LRADC_CTRL1_LRADC_IRQ_EN_MASK (0x1fff << 16) +#define LRADC_CTRL1_LRADC_IRQ_EN_OFFSET 16 +#define LRADC_CTRL1_TOUCH_DETECT_IRQ (1 << 8) +#define LRADC_CTRL1_LRADC_IRQ(n) (1 << (n)) +#define LRADC_CTRL1_LRADC_IRQ_MASK 0x1fff +#define LRADC_CTRL1_LRADC_IRQ_OFFSET 0 #define LRADC_CTRL2 0x20 #define LRADC_CTRL2_TEMPSENSE_PWD (1 << 15) +#define LRADC_STATUS 0x40 +#define LRADC_STATUS_TOUCH_DETECT_RAW (1 << 0) + #define LRADC_CH(n) (0x50 + (0x10 * (n))) #define LRADC_CH_ACCUMULATE (1 << 29) #define LRADC_CH_NUM_SAMPLES_MASK (0x1f << 24) @@ -140,6 +237,7 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, { struct mxs_lradc *lradc = iio_priv(iio_dev); int ret; + unsigned long mask; if (m != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -148,6 +246,12 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, if (chan->channel > LRADC_MAX_TOTAL_CHANS) return -EINVAL; + /* Validate the channel if it doesn't intersect with reserved chans. */ + bitmap_set(&mask, chan->channel, 1); + ret = iio_validate_scan_mask_onehot(iio_dev, &mask); + if (ret) + return -EINVAL; + /* * See if there is no buffered operation in progess. If there is, simply * bail out. This can be improved to support both buffered and raw IO at @@ -169,7 +273,11 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); writel(0xff, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - writel(chan->channel, lradc->base + LRADC_CTRL4); + /* Clean the slot's previous content, then set new one. */ + writel(LRADC_CTRL4_LRADCSELECT_MASK(0), + lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_CLR); + writel(chan->channel, lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_SET); + writel(0, lradc->base + LRADC_CH(0)); /* Enable the IRQ and start sampling the channel. */ @@ -203,6 +311,269 @@ static const struct iio_info mxs_lradc_iio_info = { }; /* + * Touchscreen handling + */ +enum lradc_ts_plate { + LRADC_SAMPLE_X, + LRADC_SAMPLE_Y, + LRADC_SAMPLE_PRESSURE, +}; + +static int mxs_lradc_ts_touched(struct mxs_lradc *lradc) +{ + uint32_t reg; + + /* Enable touch detection. */ + writel(LRADC_CTRL0_PLATE_MASK, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); + writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); + + msleep(LRADC_TS_SAMPLE_DELAY_MS); + + reg = readl(lradc->base + LRADC_STATUS); + + return reg & LRADC_STATUS_TOUCH_DETECT_RAW; +} + +static int32_t mxs_lradc_ts_sample(struct mxs_lradc *lradc, + enum lradc_ts_plate plate, int change) +{ + unsigned long delay, jiff; + uint32_t reg, ctrl0 = 0, chan = 0; + /* The touchscreen always uses CTRL4 slot #7. */ + const uint8_t slot = 7; + uint32_t val; + + /* + * There are three correct configurations of the controller sampling + * the touchscreen, each of these configuration provides different + * information from the touchscreen. + * + * The following table describes the sampling configurations: + * +-------------+-------+-------+-------+ + * | Wire \ Axis | X | Y | Z | + * +---------------------+-------+-------+ + * | X+ (CH2) | HI | TS | TS | + * +-------------+-------+-------+-------+ + * | X- (CH4) | LO | SH | HI | + * +-------------+-------+-------+-------+ + * | Y+ (CH3) | SH | HI | HI | + * +-------------+-------+-------+-------+ + * | Y- (CH5) | TS | LO | SH | + * +-------------+-------+-------+-------+ + * + * HI ... strong '1' ; LO ... strong '0' + * SH ... sample here ; TS ... tri-state + * + * There are a few other ways of obtaining the Z coordinate + * (aka. pressure), but the one in the table seems to be the + * most reliable one. + */ + switch (plate) { + case LRADC_SAMPLE_X: + ctrl0 = LRADC_CTRL0_XPPSW | LRADC_CTRL0_XNNSW; + chan = 3; + break; + case LRADC_SAMPLE_Y: + ctrl0 = LRADC_CTRL0_YPPSW | LRADC_CTRL0_YNNSW; + chan = 4; + break; + case LRADC_SAMPLE_PRESSURE: + ctrl0 = LRADC_CTRL0_YPPSW | LRADC_CTRL0_XNNSW; + chan = 5; + break; + } + + if (change) { + writel(LRADC_CTRL0_PLATE_MASK, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); + writel(ctrl0, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); + + writel(LRADC_CTRL4_LRADCSELECT_MASK(slot), + lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_CLR); + writel(chan << LRADC_CTRL4_LRADCSELECT_OFFSET(slot), + lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_SET); + } + + writel(0xffffffff, lradc->base + LRADC_CH(slot) + STMP_OFFSET_REG_CLR); + writel(1 << slot, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); + + delay = jiffies + msecs_to_jiffies(LRADC_TS_SAMPLE_DELAY_MS); + do { + jiff = jiffies; + reg = readl_relaxed(lradc->base + LRADC_CTRL1); + if (reg & LRADC_CTRL1_LRADC_IRQ(slot)) + break; + } while (time_before(jiff, delay)); + + writel(LRADC_CTRL1_LRADC_IRQ(slot), + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); + + if (time_after_eq(jiff, delay)) + return -ETIMEDOUT; + + val = readl(lradc->base + LRADC_CH(slot)); + val &= LRADC_CH_VALUE_MASK; + + return val; +} + +static int32_t mxs_lradc_ts_sample_filter(struct mxs_lradc *lradc, + enum lradc_ts_plate plate) +{ + int32_t val, tot = 0; + int i; + + val = mxs_lradc_ts_sample(lradc, plate, 1); + + /* Delay a bit so the touchscreen is stable. */ + mdelay(2); + + for (i = 0; i < LRADC_TS_SAMPLE_AMOUNT; i++) { + val = mxs_lradc_ts_sample(lradc, plate, 0); + tot += val; + } + + return tot / LRADC_TS_SAMPLE_AMOUNT; +} + +static void mxs_lradc_ts_work(struct work_struct *ts_work) +{ + struct mxs_lradc *lradc = container_of(ts_work, + struct mxs_lradc, ts_work); + int val_x, val_y, val_p; + bool valid = false; + + while (mxs_lradc_ts_touched(lradc)) { + /* Disable touch detector so we can sample the touchscreen. */ + writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); + + if (likely(valid)) { + input_report_abs(lradc->ts_input, ABS_X, val_x); + input_report_abs(lradc->ts_input, ABS_Y, val_y); + input_report_abs(lradc->ts_input, ABS_PRESSURE, val_p); + input_report_key(lradc->ts_input, BTN_TOUCH, 1); + input_sync(lradc->ts_input); + } + + valid = false; + + val_x = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_X); + if (val_x < 0) + continue; + val_y = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_Y); + if (val_y < 0) + continue; + val_p = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_PRESSURE); + if (val_p < 0) + continue; + + valid = true; + } + + input_report_abs(lradc->ts_input, ABS_PRESSURE, 0); + input_report_key(lradc->ts_input, BTN_TOUCH, 0); + input_sync(lradc->ts_input); + + /* Do not restart the TS IRQ if the driver is shutting down. */ + if (lradc->stop_touchscreen) + return; + + /* Restart the touchscreen interrupts. */ + writel(LRADC_CTRL1_TOUCH_DETECT_IRQ, + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); + writel(LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_SET); +} + +static int mxs_lradc_ts_open(struct input_dev *dev) +{ + struct mxs_lradc *lradc = input_get_drvdata(dev); + + /* The touchscreen is starting. */ + lradc->stop_touchscreen = false; + + /* Enable the touch-detect circuitry. */ + writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); + + /* Enable the touch-detect IRQ. */ + writel(LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_SET); + + return 0; +} + +static void mxs_lradc_ts_close(struct input_dev *dev) +{ + struct mxs_lradc *lradc = input_get_drvdata(dev); + + /* Indicate the touchscreen is stopping. */ + lradc->stop_touchscreen = true; + mb(); + + /* Wait until touchscreen thread finishes any possible remnants. */ + cancel_work_sync(&lradc->ts_work); + + /* Disable touchscreen touch-detect IRQ. */ + writel(LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); + + /* Power-down touchscreen touch-detect circuitry. */ + writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); +} + +static int mxs_lradc_ts_register(struct mxs_lradc *lradc) +{ + struct input_dev *input; + struct device *dev = lradc->dev; + int ret; + + if (!lradc->use_touchscreen) + return 0; + + input = input_allocate_device(); + if (!input) { + dev_err(dev, "Failed to allocate TS device!\n"); + return -ENOMEM; + } + + input->name = DRIVER_NAME; + input->id.bustype = BUS_HOST; + input->dev.parent = dev; + input->open = mxs_lradc_ts_open; + input->close = mxs_lradc_ts_close; + + __set_bit(EV_ABS, input->evbit); + __set_bit(EV_KEY, input->evbit); + __set_bit(BTN_TOUCH, input->keybit); + input_set_abs_params(input, ABS_X, 0, LRADC_CH_VALUE_MASK, 0, 0); + input_set_abs_params(input, ABS_Y, 0, LRADC_CH_VALUE_MASK, 0, 0); + input_set_abs_params(input, ABS_PRESSURE, 0, LRADC_CH_VALUE_MASK, 0, 0); + + lradc->ts_input = input; + input_set_drvdata(input, lradc); + ret = input_register_device(input); + if (ret) + input_free_device(lradc->ts_input); + + return ret; +} + +static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc) +{ + if (!lradc->use_touchscreen) + return; + + cancel_work_sync(&lradc->ts_work); + + input_unregister_device(lradc->ts_input); +} + +/* * IRQ Handling */ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) @@ -210,14 +581,24 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) struct iio_dev *iio = data; struct mxs_lradc *lradc = iio_priv(iio); unsigned long reg = readl(lradc->base + LRADC_CTRL1); + const uint32_t ts_irq_mask = + LRADC_CTRL1_TOUCH_DETECT_IRQ_EN | + LRADC_CTRL1_TOUCH_DETECT_IRQ; if (!(reg & LRADC_CTRL1_LRADC_IRQ_MASK)) return IRQ_NONE; /* - * Touchscreen IRQ handling code shall probably have priority - * and therefore shall be placed here. + * Touchscreen IRQ handling code has priority and therefore + * is placed here. In case touchscreen IRQ arrives, disable + * it ASAP */ + if (reg & LRADC_CTRL1_TOUCH_DETECT_IRQ) { + writel(ts_irq_mask, + lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); + if (!lradc->stop_touchscreen) + schedule_work(&lradc->ts_work); + } if (iio_buffer_enabled(iio)) iio_trigger_poll(iio->trig, iio_get_time_ns()); @@ -313,8 +694,10 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) { struct mxs_lradc *lradc = iio_priv(iio); struct iio_buffer *buffer = iio->buffer; - int ret = 0, chan, ofs = 0, enable = 0; - uint32_t ctrl4 = 0; + int ret = 0, chan, ofs = 0; + unsigned long enable = 0; + uint32_t ctrl4_set = 0; + uint32_t ctrl4_clr = 0; uint32_t ctrl1_irq = 0; const uint32_t chan_value = LRADC_CH_ACCUMULATE | ((LRADC_DELAY_TIMER_LOOP - 1) << LRADC_CH_NUM_SAMPLES_OFFSET); @@ -346,17 +729,20 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) writel(0xff, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); for_each_set_bit(chan, buffer->scan_mask, LRADC_MAX_TOTAL_CHANS) { - ctrl4 |= chan << LRADC_CTRL4_LRADCSELECT_OFFSET(ofs); + ctrl4_set |= chan << LRADC_CTRL4_LRADCSELECT_OFFSET(ofs); + ctrl4_clr |= LRADC_CTRL4_LRADCSELECT_MASK(ofs); ctrl1_irq |= LRADC_CTRL1_LRADC_IRQ_EN(ofs); writel(chan_value, lradc->base + LRADC_CH(ofs)); - enable |= 1 << ofs; + bitmap_set(&enable, ofs, 1); ofs++; } writel(LRADC_DELAY_TRIGGER_LRADCS_MASK | LRADC_DELAY_KICK, lradc->base + LRADC_DELAY(0) + STMP_OFFSET_REG_CLR); - writel(ctrl4, lradc->base + LRADC_CTRL4); + writel(ctrl4_clr, lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_CLR); + writel(ctrl4_set, lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_SET); + writel(ctrl1_irq, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_SET); writel(enable << LRADC_DELAY_TRIGGER_LRADCS_OFFSET, @@ -391,9 +777,33 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio) static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, const unsigned long *mask) { - const int mw = bitmap_weight(mask, iio->masklength); - - return mw <= LRADC_MAX_MAPPED_CHANS; + struct mxs_lradc *lradc = iio_priv(iio); + const int len = iio->masklength; + const int map_chans = bitmap_weight(mask, len); + int rsvd_chans = 0; + unsigned long rsvd_mask = 0; + + if (lradc->use_touchbutton) + rsvd_mask |= CHAN_MASK_TOUCHBUTTON; + if (lradc->use_touchscreen == MXS_LRADC_TOUCHSCREEN_4WIRE) + rsvd_mask |= CHAN_MASK_TOUCHSCREEN_4WIRE; + if (lradc->use_touchscreen == MXS_LRADC_TOUCHSCREEN_5WIRE) + rsvd_mask |= CHAN_MASK_TOUCHSCREEN_5WIRE; + + if (lradc->use_touchbutton) + rsvd_chans++; + if (lradc->use_touchscreen) + rsvd_chans++; + + /* Test for attempts to map channels with special mode of operation. */ + if (bitmap_intersects(mask, &rsvd_mask, len)) + return false; + + /* Test for attempts to map more channels then available slots. */ + if (map_chans + rsvd_chans > LRADC_MAX_MAPPED_CHANS) + return false; + + return true; } static const struct iio_buffer_setup_ops mxs_lradc_buffer_ops = { @@ -442,15 +852,29 @@ static const struct iio_chan_spec mxs_lradc_chan_spec[] = { static void mxs_lradc_hw_init(struct mxs_lradc *lradc) { - int i; - const uint32_t cfg = + /* The ADC always uses DELAY CHANNEL 0. */ + const uint32_t adc_cfg = + (1 << (LRADC_DELAY_TRIGGER_DELAYS_OFFSET + 0)) | (LRADC_DELAY_TIMER_PER << LRADC_DELAY_DELAY_OFFSET); stmp_reset_block(lradc->base); - for (i = 0; i < LRADC_MAX_DELAY_CHANS; i++) - writel(cfg | (1 << (LRADC_DELAY_TRIGGER_DELAYS_OFFSET + i)), - lradc->base + LRADC_DELAY(i)); + /* Configure DELAY CHANNEL 0 for generic ADC sampling. */ + writel(adc_cfg, lradc->base + LRADC_DELAY(0)); + + /* Disable remaining DELAY CHANNELs */ + writel(0, lradc->base + LRADC_DELAY(1)); + writel(0, lradc->base + LRADC_DELAY(2)); + writel(0, lradc->base + LRADC_DELAY(3)); + + /* Configure the touchscreen type */ + writel(LRADC_CTRL0_TOUCH_SCREEN_TYPE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); + + if (lradc->use_touchscreen == MXS_LRADC_TOUCHSCREEN_5WIRE) { + writel(LRADC_CTRL0_TOUCH_SCREEN_TYPE, + lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); + } /* Start internal temperature sensing. */ writel(0, lradc->base + LRADC_CTRL2); @@ -467,12 +891,25 @@ static void mxs_lradc_hw_stop(struct mxs_lradc *lradc) writel(0, lradc->base + LRADC_DELAY(i)); } +static const struct of_device_id mxs_lradc_dt_ids[] = { + { .compatible = "fsl,imx23-lradc", .data = (void *)IMX23_LRADC, }, + { .compatible = "fsl,imx28-lradc", .data = (void *)IMX28_LRADC, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids); + static int mxs_lradc_probe(struct platform_device *pdev) { + const struct of_device_id *of_id = + of_match_device(mxs_lradc_dt_ids, &pdev->dev); + const struct mxs_lradc_of_config *of_cfg = + &mxs_lradc_of_config[(enum mxs_lradc_id)of_id->data]; struct device *dev = &pdev->dev; + struct device_node *node = dev->of_node; struct mxs_lradc *lradc; struct iio_dev *iio; struct resource *iores; + uint32_t ts_wires = 0; int ret = 0; int i; @@ -494,8 +931,23 @@ static int mxs_lradc_probe(struct platform_device *pdev) goto err_addr; } + INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work); + + /* Check if touchscreen is enabled in DT. */ + ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", + &ts_wires); + if (ret) + dev_info(dev, "Touchscreen not enabled.\n"); + else if (ts_wires == 4) + lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_4WIRE; + else if (ts_wires == 5) + lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_5WIRE; + else + dev_warn(dev, "Unsupported number of touchscreen wires (%d)\n", + ts_wires); + /* Grab all IRQ sources */ - for (i = 0; i < 13; i++) { + for (i = 0; i < of_cfg->irq_count; i++) { lradc->irq[i] = platform_get_irq(pdev, i); if (lradc->irq[i] < 0) { ret = -EINVAL; @@ -504,7 +956,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) ret = devm_request_irq(dev, lradc->irq[i], mxs_lradc_handle_irq, 0, - mxs_lradc_irq_name[i], iio); + of_cfg->irq_name[i], iio); if (ret) goto err_addr; } @@ -531,11 +983,16 @@ static int mxs_lradc_probe(struct platform_device *pdev) if (ret) goto err_trig; + /* Register the touchscreen input device. */ + ret = mxs_lradc_ts_register(lradc); + if (ret) + goto err_dev; + /* Register IIO device. */ ret = iio_device_register(iio); if (ret) { dev_err(dev, "Failed to register IIO device\n"); - goto err_dev; + goto err_ts; } /* Configure the hardware. */ @@ -543,6 +1000,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) return 0; +err_ts: + mxs_lradc_ts_unregister(lradc); err_dev: mxs_lradc_trigger_remove(iio); err_trig: @@ -557,6 +1016,8 @@ static int mxs_lradc_remove(struct platform_device *pdev) struct iio_dev *iio = platform_get_drvdata(pdev); struct mxs_lradc *lradc = iio_priv(iio); + mxs_lradc_ts_unregister(lradc); + mxs_lradc_hw_stop(lradc); iio_device_unregister(iio); @@ -567,12 +1028,6 @@ static int mxs_lradc_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id mxs_lradc_dt_ids[] = { - { .compatible = "fsl,imx28-lradc", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids); - static struct platform_driver mxs_lradc_driver = { .driver = { .name = DRIVER_NAME, diff --git a/drivers/staging/iio/frequency/ad5930.c b/drivers/staging/iio/frequency/ad5930.c index 23777be..69e90e9 100644 --- a/drivers/staging/iio/frequency/ad5930.c +++ b/drivers/staging/iio/frequency/ad5930.c @@ -44,7 +44,6 @@ static ssize_t ad5930_set_parameter(struct device *dev, const char *buf, size_t len) { - struct spi_message msg; struct spi_transfer xfer; int ret; struct ad5903_config *config = (struct ad5903_config *)buf; @@ -64,9 +63,7 @@ static ssize_t ad5930_set_parameter(struct device *dev, xfer.tx_buf = config; mutex_lock(&st->lock); - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->sdev, &msg); + ret = spi_sync_transfer(st->sdev, &xfer, 1); if (ret) goto error_ret; error_ret: diff --git a/drivers/staging/iio/frequency/ad9850.c b/drivers/staging/iio/frequency/ad9850.c index 104f7a4..01a8a93 100644 --- a/drivers/staging/iio/frequency/ad9850.c +++ b/drivers/staging/iio/frequency/ad9850.c @@ -39,7 +39,6 @@ static ssize_t ad9850_set_parameter(struct device *dev, const char *buf, size_t len) { - struct spi_message msg; struct spi_transfer xfer; int ret; struct ad9850_config *config = (struct ad9850_config *)buf; @@ -50,9 +49,7 @@ static ssize_t ad9850_set_parameter(struct device *dev, xfer.tx_buf = config; mutex_lock(&st->lock); - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->sdev, &msg); + ret = spi_sync_transfer(st->sdev, &xfer, 1); if (ret) goto error_ret; error_ret: diff --git a/drivers/staging/iio/frequency/ad9852.c b/drivers/staging/iio/frequency/ad9852.c index 17ac825..1344031 100644 --- a/drivers/staging/iio/frequency/ad9852.c +++ b/drivers/staging/iio/frequency/ad9852.c @@ -183,7 +183,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9852_set_parameter, 0); static void ad9852_init(struct ad9852_state *st) { - struct spi_message msg; struct spi_transfer xfer; int ret; u8 config[5]; @@ -199,9 +198,7 @@ static void ad9852_init(struct ad9852_state *st) xfer.len = 5; xfer.tx_buf = &config; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->sdev, &msg); + ret = spi_sync_transfer(st->sdev, &xfer, 1); if (ret) goto error_ret; diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index 87979a0..8360662 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -10,13 +10,6 @@ config ADIS16060 Say yes here to build support for Analog Devices adis16060 wide bandwidth yaw rate gyroscope with SPI. -config ADIS16080 - tristate "Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver" - depends on SPI - help - Say yes here to build support for Analog Devices adis16080/100 Yaw Rate - Gyroscope with SPI. - config ADIS16130 tristate "Analog Devices ADIS16130 High Precision Angular Rate Sensor driver" depends on SPI @@ -36,14 +29,4 @@ config ADIS16260 This driver can also be built as a module. If so, the module will be called adis16260. -config ADXRS450 - tristate "Analog Devices ADXRS450/3 Digital Output Gyroscope SPI driver" - depends on SPI - help - Say yes here to build support for Analog Devices ADXRS450 and ADXRS453 - programmable digital output gyroscope. - - This driver can also be built as a module. If so, the module - will be called adxrs450. - endmenu diff --git a/drivers/staging/iio/gyro/Makefile b/drivers/staging/iio/gyro/Makefile index 1303569..98e6500 100644 --- a/drivers/staging/iio/gyro/Makefile +++ b/drivers/staging/iio/gyro/Makefile @@ -5,17 +5,8 @@ adis16060-y := adis16060_core.o obj-$(CONFIG_ADIS16060) += adis16060.o -adis16080-y := adis16080_core.o -obj-$(CONFIG_ADIS16080) += adis16080.o - adis16130-y := adis16130_core.o obj-$(CONFIG_ADIS16130) += adis16130.o adis16260-y := adis16260_core.o obj-$(CONFIG_ADIS16260) += adis16260.o - -adis16251-y := adis16251_core.o -obj-$(CONFIG_ADIS16251) += adis16251.o - -adxrs450-y := adxrs450_core.o -obj-$(CONFIG_ADXRS450) += adxrs450.o diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c deleted file mode 100644 index 41d7350..0000000 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * ADIS16080/100 Yaw Rate Gyroscope with SPI driver - * - * Copyright 2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ -#include <linux/delay.h> -#include <linux/mutex.h> -#include <linux/device.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/sysfs.h> -#include <linux/module.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> - -#define ADIS16080_DIN_GYRO (0 << 10) /* Gyroscope output */ -#define ADIS16080_DIN_TEMP (1 << 10) /* Temperature output */ -#define ADIS16080_DIN_AIN1 (2 << 10) -#define ADIS16080_DIN_AIN2 (3 << 10) - -/* - * 1: Write contents on DIN to control register. - * 0: No changes to control register. - */ - -#define ADIS16080_DIN_WRITE (1 << 15) - -/** - * struct adis16080_state - device instance specific data - * @us: actual spi_device to write data - * @buf: transmit or receive buffer - * @buf_lock: mutex to protect tx and rx - **/ -struct adis16080_state { - struct spi_device *us; - struct mutex buf_lock; - - u8 buf[2] ____cacheline_aligned; -}; - -static int adis16080_spi_write(struct iio_dev *indio_dev, - u16 val) -{ - int ret; - struct adis16080_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - st->buf[0] = val >> 8; - st->buf[1] = val; - - ret = spi_write(st->us, st->buf, 2); - mutex_unlock(&st->buf_lock); - - return ret; -} - -static int adis16080_spi_read(struct iio_dev *indio_dev, - u16 *val) -{ - int ret; - struct adis16080_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - - ret = spi_read(st->us, st->buf, 2); - - if (ret == 0) - *val = sign_extend32(((st->buf[0] & 0xF) << 8) | st->buf[1], 11); - mutex_unlock(&st->buf_lock); - - return ret; -} - -static int adis16080_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) -{ - int ret = -EINVAL; - u16 ut = 0; - /* Take the iio_dev status lock */ - - mutex_lock(&indio_dev->mlock); - switch (mask) { - case IIO_CHAN_INFO_RAW: - ret = adis16080_spi_write(indio_dev, - chan->address | - ADIS16080_DIN_WRITE); - if (ret < 0) - break; - ret = adis16080_spi_read(indio_dev, &ut); - if (ret < 0) - break; - *val = ut; - ret = IIO_VAL_INT; - break; - } - mutex_unlock(&indio_dev->mlock); - - return ret; -} - -static const struct iio_chan_spec adis16080_channels[] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, - .address = ADIS16080_DIN_GYRO, - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, - .address = ADIS16080_DIN_AIN1, - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, - .address = ADIS16080_DIN_AIN2, - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, - .address = ADIS16080_DIN_TEMP, - } -}; - -static const struct iio_info adis16080_info = { - .read_raw = &adis16080_read_raw, - .driver_module = THIS_MODULE, -}; - -static int adis16080_probe(struct spi_device *spi) -{ - int ret; - struct adis16080_state *st; - struct iio_dev *indio_dev; - - /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - st = iio_priv(indio_dev); - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); - - /* Allocate the comms buffers */ - st->us = spi; - mutex_init(&st->buf_lock); - - indio_dev->name = spi->dev.driver->name; - indio_dev->channels = adis16080_channels; - indio_dev->num_channels = ARRAY_SIZE(adis16080_channels); - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &adis16080_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; -} - -/* fixme, confirm ordering in this function */ -static int adis16080_remove(struct spi_device *spi) -{ - iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - - return 0; -} - -static struct spi_driver adis16080_driver = { - .driver = { - .name = "adis16080", - .owner = THIS_MODULE, - }, - .probe = adis16080_probe, - .remove = adis16080_remove, -}; -module_spi_driver(adis16080_driver); - -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); -MODULE_DESCRIPTION("Analog Devices ADIS16080/100 Yaw Rate Gyroscope Driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:adis16080"); diff --git a/drivers/staging/iio/gyro/adxrs450.h b/drivers/staging/iio/gyro/adxrs450.h deleted file mode 100644 index f8cf21f..0000000 --- a/drivers/staging/iio/gyro/adxrs450.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef SPI_ADXRS450_H_ -#define SPI_ADXRS450_H_ - -#define ADXRS450_STARTUP_DELAY 50 /* ms */ - -/* The MSB for the spi commands */ -#define ADXRS450_SENSOR_DATA 0x20 -#define ADXRS450_WRITE_DATA 0x40 -#define ADXRS450_READ_DATA 0x80 - -#define ADXRS450_RATE1 0x00 /* Rate Registers */ -#define ADXRS450_TEMP1 0x02 /* Temperature Registers */ -#define ADXRS450_LOCST1 0x04 /* Low CST Memory Registers */ -#define ADXRS450_HICST1 0x06 /* High CST Memory Registers */ -#define ADXRS450_QUAD1 0x08 /* Quad Memory Registers */ -#define ADXRS450_FAULT1 0x0A /* Fault Registers */ -#define ADXRS450_PID1 0x0C /* Part ID Register 1 */ -#define ADXRS450_SNH 0x0E /* Serial Number Registers, 4 bytes */ -#define ADXRS450_SNL 0x10 -#define ADXRS450_DNC1 0x12 /* Dynamic Null Correction Registers */ -/* Check bits */ -#define ADXRS450_P 0x01 -#define ADXRS450_CHK 0x02 -#define ADXRS450_CST 0x04 -#define ADXRS450_PWR 0x08 -#define ADXRS450_POR 0x10 -#define ADXRS450_NVM 0x20 -#define ADXRS450_Q 0x40 -#define ADXRS450_PLL 0x80 -#define ADXRS450_UV 0x100 -#define ADXRS450_OV 0x200 -#define ADXRS450_AMP 0x400 -#define ADXRS450_FAIL 0x800 - -#define ADXRS450_WRERR_MASK (0x7 << 29) - -#define ADXRS450_MAX_RX 4 -#define ADXRS450_MAX_TX 4 - -#define ADXRS450_GET_ST(a) ((a >> 26) & 0x3) - -enum { - ID_ADXRS450, - ID_ADXRS453, -}; - -/** - * struct adxrs450_state - device instance specific data - * @us: actual spi_device - * @buf_lock: mutex to protect tx and rx - * @tx: transmit buffer - * @rx: receive buffer - **/ -struct adxrs450_state { - struct spi_device *us; - struct mutex buf_lock; - u8 tx[ADXRS450_MAX_RX] ____cacheline_aligned; - u8 rx[ADXRS450_MAX_TX]; - -}; - -#endif /* SPI_ADXRS450_H_ */ diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c deleted file mode 100644 index f0ce81d..0000000 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - * ADXRS450/ADXRS453 Digital Output Gyroscope Driver - * - * Copyright 2011 Analog Devices Inc. - * - * Licensed under the GPL-2. - */ - -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/delay.h> -#include <linux/mutex.h> -#include <linux/device.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/sysfs.h> -#include <linux/list.h> -#include <linux/module.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> - -#include "adxrs450.h" - -/** - * adxrs450_spi_read_reg_16() - read 2 bytes from a register pair - * @dev: device associated with child of actual iio_dev - * @reg_address: the address of the lower of the two registers,which should be an even address, - * Second register's address is reg_address + 1. - * @val: somewhere to pass back the value read - **/ -static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, - u8 reg_address, - u16 *val) -{ - struct adxrs450_state *st = iio_priv(indio_dev); - int ret; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7); - st->tx[1] = reg_address << 1; - st->tx[2] = 0; - st->tx[3] = 0; - - if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) - st->tx[3] |= ADXRS450_P; - - ret = spi_write(st->us, st->tx, 4); - if (ret) { - dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", - reg_address); - goto error_ret; - } - ret = spi_read(st->us, st->rx, 4); - if (ret) { - dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", - reg_address); - goto error_ret; - } - - *val = (be32_to_cpu(*(u32 *)st->rx) >> 5) & 0xFFFF; - -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -/** - * adxrs450_spi_write_reg_16() - write 2 bytes data to a register pair - * @dev: device associated with child of actual actual iio_dev - * @reg_address: the address of the lower of the two registers,which should be an even address, - * Second register's address is reg_address + 1. - * @val: value to be written. - **/ -static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, - u8 reg_address, - u16 val) -{ - struct adxrs450_state *st = iio_priv(indio_dev); - int ret; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADXRS450_WRITE_DATA | reg_address >> 7; - st->tx[1] = reg_address << 1 | val >> 15; - st->tx[2] = val >> 7; - st->tx[3] = val << 1; - - if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) - st->tx[3] |= ADXRS450_P; - - ret = spi_write(st->us, st->tx, 4); - if (ret) - dev_err(&st->us->dev, "problem while writing 16 bit register 0x%02x\n", - reg_address); - msleep(1); /* enforce sequential transfer delay 0.1ms */ - mutex_unlock(&st->buf_lock); - return ret; -} - -/** - * adxrs450_spi_sensor_data() - read 2 bytes sensor data - * @dev: device associated with child of actual iio_dev - * @val: somewhere to pass back the value read - **/ -static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) -{ - struct adxrs450_state *st = iio_priv(indio_dev); - int ret; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADXRS450_SENSOR_DATA; - st->tx[1] = 0; - st->tx[2] = 0; - st->tx[3] = 0; - - ret = spi_write(st->us, st->tx, 4); - if (ret) { - dev_err(&st->us->dev, "Problem while reading sensor data\n"); - goto error_ret; - } - - ret = spi_read(st->us, st->rx, 4); - if (ret) { - dev_err(&st->us->dev, "Problem while reading sensor data\n"); - goto error_ret; - } - - *val = (be32_to_cpu(*(u32 *)st->rx) >> 10) & 0xFFFF; - -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -/** - * adxrs450_spi_initial() - use for initializing procedure. - * @st: device instance specific data - * @val: somewhere to pass back the value read - **/ -static int adxrs450_spi_initial(struct adxrs450_state *st, - u32 *val, char chk) -{ - struct spi_message msg; - int ret; - struct spi_transfer xfers = { - .tx_buf = st->tx, - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 4, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADXRS450_SENSOR_DATA; - st->tx[1] = 0; - st->tx[2] = 0; - st->tx[3] = 0; - if (chk) - st->tx[3] |= (ADXRS450_CHK | ADXRS450_P); - spi_message_init(&msg); - spi_message_add_tail(&xfers, &msg); - ret = spi_sync(st->us, &msg); - if (ret) { - dev_err(&st->us->dev, "Problem while reading initializing data\n"); - goto error_ret; - } - - *val = be32_to_cpu(*(u32 *)st->rx); - -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -/* Recommended Startup Sequence by spec */ -static int adxrs450_initial_setup(struct iio_dev *indio_dev) -{ - u32 t; - u16 data; - int ret; - struct adxrs450_state *st = iio_priv(indio_dev); - - msleep(ADXRS450_STARTUP_DELAY*2); - ret = adxrs450_spi_initial(st, &t, 1); - if (ret) - return ret; - if (t != 0x01) - dev_warn(&st->us->dev, "The initial power on response " - "is not correct! Restart without reset?\n"); - - msleep(ADXRS450_STARTUP_DELAY); - ret = adxrs450_spi_initial(st, &t, 0); - if (ret) - return ret; - - msleep(ADXRS450_STARTUP_DELAY); - ret = adxrs450_spi_initial(st, &t, 0); - if (ret) - return ret; - if (((t & 0xff) | 0x01) != 0xff || ADXRS450_GET_ST(t) != 2) { - dev_err(&st->us->dev, "The second response is not correct!\n"); - return -EIO; - - } - ret = adxrs450_spi_initial(st, &t, 0); - if (ret) - return ret; - if (((t & 0xff) | 0x01) != 0xff || ADXRS450_GET_ST(t) != 2) { - dev_err(&st->us->dev, "The third response is not correct!\n"); - return -EIO; - - } - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_FAULT1, &data); - if (ret) - return ret; - if (data & 0x0fff) { - dev_err(&st->us->dev, "The device is not in normal status!\n"); - return -EINVAL; - } - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_PID1, &data); - if (ret) - return ret; - dev_info(&st->us->dev, "The Part ID is 0x%x\n", data); - - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_SNL, &data); - if (ret) - return ret; - t = data; - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_SNH, &data); - if (ret) - return ret; - t |= data << 16; - dev_info(&st->us->dev, "The Serial Number is 0x%x\n", t); - - return 0; -} - -static int adxrs450_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) -{ - int ret; - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: - ret = adxrs450_spi_write_reg_16(indio_dev, - ADXRS450_DNC1, - val & 0x3FF); - break; - default: - ret = -EINVAL; - break; - } - return ret; -} - -static int adxrs450_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) -{ - int ret; - s16 t; - - switch (mask) { - case IIO_CHAN_INFO_RAW: - switch (chan->type) { - case IIO_ANGL_VEL: - ret = adxrs450_spi_sensor_data(indio_dev, &t); - if (ret) - break; - *val = t; - ret = IIO_VAL_INT; - break; - case IIO_TEMP: - ret = adxrs450_spi_read_reg_16(indio_dev, - ADXRS450_TEMP1, &t); - if (ret) - break; - *val = (t >> 6) + 225; - ret = IIO_VAL_INT; - break; - default: - ret = -EINVAL; - break; - } - break; - case IIO_CHAN_INFO_SCALE: - switch (chan->type) { - case IIO_ANGL_VEL: - *val = 0; - *val2 = 218166; - return IIO_VAL_INT_PLUS_NANO; - case IIO_TEMP: - *val = 200; - *val2 = 0; - return IIO_VAL_INT; - default: - return -EINVAL; - } - break; - case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); - if (ret) - break; - *val = t; - ret = IIO_VAL_INT; - break; - case IIO_CHAN_INFO_CALIBBIAS: - ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_DNC1, &t); - if (ret) - break; - *val = t; - ret = IIO_VAL_INT; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static const struct iio_chan_spec adxrs450_channels[2][2] = { - [ID_ADXRS450] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - } - }, - [ID_ADXRS453] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT | - IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - } - }, -}; - -static const struct iio_info adxrs450_info = { - .driver_module = THIS_MODULE, - .read_raw = &adxrs450_read_raw, - .write_raw = &adxrs450_write_raw, -}; - -static int adxrs450_probe(struct spi_device *spi) -{ - int ret; - struct adxrs450_state *st; - struct iio_dev *indio_dev; - - /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - st = iio_priv(indio_dev); - st->us = spi; - mutex_init(&st->buf_lock); - /* This is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); - - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &adxrs450_info; - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = - adxrs450_channels[spi_get_device_id(spi)->driver_data]; - indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); - indio_dev->name = spi->dev.driver->name; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - - /* Get the device into a sane initial state */ - ret = adxrs450_initial_setup(indio_dev); - if (ret) - goto error_initial; - return 0; -error_initial: - iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); - -error_ret: - return ret; -} - -static int adxrs450_remove(struct spi_device *spi) -{ - iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - - return 0; -} - -static const struct spi_device_id adxrs450_id[] = { - {"adxrs450", ID_ADXRS450}, - {"adxrs453", ID_ADXRS453}, - {} -}; -MODULE_DEVICE_TABLE(spi, adxrs450_id); - -static struct spi_driver adxrs450_driver = { - .driver = { - .name = "adxrs450", - .owner = THIS_MODULE, - }, - .probe = adxrs450_probe, - .remove = adxrs450_remove, - .id_table = adxrs450_id, -}; -module_spi_driver(adxrs450_driver); - -MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>"); -MODULE_DESCRIPTION("Analog Devices ADXRS450/ADXRS453 Gyroscope SPI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c index c7a5f97..93af756 100644 --- a/drivers/staging/iio/iio_hwmon.c +++ b/drivers/staging/iio/iio_hwmon.c @@ -55,63 +55,58 @@ static ssize_t iio_hwmon_read_val(struct device *dev, return sprintf(buf, "%d\n", result); } -static void iio_hwmon_free_attrs(struct iio_hwmon_state *st) +static ssize_t show_name(struct device *dev, struct device_attribute *attr, + char *buf) { - int i; - struct sensor_device_attribute *a; - for (i = 0; i < st->num_channels; i++) - if (st->attrs[i]) { - a = to_sensor_dev_attr( - container_of(st->attrs[i], - struct device_attribute, - attr)); - kfree(a); - } + return sprintf(buf, "iio_hwmon\n"); } +static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); + static int iio_hwmon_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct iio_hwmon_state *st; struct sensor_device_attribute *a; int ret, i; int in_i = 1, temp_i = 1, curr_i = 1; enum iio_chan_type type; + struct iio_channel *channels; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { - ret = -ENOMEM; - goto error_ret; - } + channels = iio_channel_get_all(dev); + if (IS_ERR(channels)) + return PTR_ERR(channels); - st->channels = iio_channel_get_all(dev_name(&pdev->dev)); - if (IS_ERR(st->channels)) { - ret = PTR_ERR(st->channels); - goto error_free_state; - } + st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); + if (st == NULL) + return -ENOMEM; + + st->channels = channels; /* count how many attributes we have */ while (st->channels[st->num_channels].indio_dev) st->num_channels++; - st->attrs = kzalloc(sizeof(st->attrs) * (st->num_channels + 1), - GFP_KERNEL); + st->attrs = devm_kzalloc(dev, + sizeof(*st->attrs) * (st->num_channels + 2), + GFP_KERNEL); if (st->attrs == NULL) { ret = -ENOMEM; goto error_release_channels; } + for (i = 0; i < st->num_channels; i++) { - a = kzalloc(sizeof(*a), GFP_KERNEL); + a = devm_kzalloc(dev, sizeof(*a), GFP_KERNEL); if (a == NULL) { ret = -ENOMEM; - goto error_free_attrs; + goto error_release_channels; } sysfs_attr_init(&a->dev_attr.attr); ret = iio_get_channel_type(&st->channels[i], &type); - if (ret < 0) { - kfree(a); - goto error_free_attrs; - } + if (ret < 0) + goto error_release_channels; + switch (type) { case IIO_VOLTAGE: a->dev_attr.attr.name = kasprintf(GFP_KERNEL, @@ -130,27 +125,25 @@ static int iio_hwmon_probe(struct platform_device *pdev) break; default: ret = -EINVAL; - kfree(a); - goto error_free_attrs; + goto error_release_channels; } if (a->dev_attr.attr.name == NULL) { - kfree(a); ret = -ENOMEM; - goto error_free_attrs; + goto error_release_channels; } a->dev_attr.show = iio_hwmon_read_val; a->dev_attr.attr.mode = S_IRUGO; a->index = i; st->attrs[i] = &a->dev_attr.attr; } - + st->attrs[st->num_channels] = &dev_attr_name.attr; st->attr_group.attrs = st->attrs; platform_set_drvdata(pdev, st); - ret = sysfs_create_group(&pdev->dev.kobj, &st->attr_group); + ret = sysfs_create_group(&dev->kobj, &st->attr_group); if (ret < 0) - goto error_free_attrs; + goto error_release_channels; - st->hwmon_dev = hwmon_device_register(&pdev->dev); + st->hwmon_dev = hwmon_device_register(dev); if (IS_ERR(st->hwmon_dev)) { ret = PTR_ERR(st->hwmon_dev); goto error_remove_group; @@ -158,15 +151,9 @@ static int iio_hwmon_probe(struct platform_device *pdev) return 0; error_remove_group: - sysfs_remove_group(&pdev->dev.kobj, &st->attr_group); -error_free_attrs: - iio_hwmon_free_attrs(st); - kfree(st->attrs); + sysfs_remove_group(&dev->kobj, &st->attr_group); error_release_channels: iio_channel_release_all(st->channels); -error_free_state: - kfree(st); -error_ret: return ret; } @@ -176,17 +163,21 @@ static int iio_hwmon_remove(struct platform_device *pdev) hwmon_device_unregister(st->hwmon_dev); sysfs_remove_group(&pdev->dev.kobj, &st->attr_group); - iio_hwmon_free_attrs(st); - kfree(st->attrs); iio_channel_release_all(st->channels); return 0; } +static struct of_device_id iio_hwmon_of_match[] = { + { .compatible = "iio-hwmon", }, + { } +}; + static struct platform_driver __refdata iio_hwmon_driver = { .driver = { .name = "iio_hwmon", .owner = THIS_MODULE, + .of_match_table = iio_hwmon_of_match, }, .probe = iio_hwmon_probe, .remove = iio_hwmon_remove, diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c index a865adf..aee76c7 100644 --- a/drivers/staging/iio/iio_simple_dummy.c +++ b/drivers/staging/iio/iio_simple_dummy.c @@ -54,7 +54,7 @@ struct iio_dummy_accel_calibscale { static const struct iio_dummy_accel_calibscale dummy_scales[] = { { 0, 100, 0x8 }, /* 0.000100 */ { 0, 133, 0x7 }, /* 0.000133 */ - { 733, 13, 0x9 }, /* 733.00013 */ + { 733, 13, 0x9 }, /* 733.000013 */ }; /* @@ -284,7 +284,7 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, /** * iio_dummy_write_raw() - data write function. * @indio_dev: the struct iio_dev associated with this device instance - * @chan: the channel whose data is to be read + * @chan: the channel whose data is to be written * @val: first element of value to set (typically INT) * @val2: second element of value to set (typically MICRO) * @mask: what we actually want to write. 0 is the channel, everything else diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c index dee16f0..72f400c 100644 --- a/drivers/staging/iio/iio_simple_dummy_buffer.c +++ b/drivers/staging/iio/iio_simple_dummy_buffer.c @@ -155,7 +155,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev, * occurs, this function is run. Typically this grabs data * from the device. * - * NULL for the top half. This is normally implemented only if we + * NULL for the bottom half. This is normally implemented only if we * either want to ping a capture now pin (no sleeping) or grab * a timestamp as close as possible to a data ready trigger firing. * diff --git a/drivers/staging/iio/impedance-analyzer/Kconfig b/drivers/staging/iio/impedance-analyzer/Kconfig index ad0ff76..dd97b6b 100644 --- a/drivers/staging/iio/impedance-analyzer/Kconfig +++ b/drivers/staging/iio/impedance-analyzer/Kconfig @@ -7,7 +7,7 @@ config AD5933 tristate "Analog Devices AD5933, AD5934 driver" depends on I2C select IIO_BUFFER - select IIO_SW_RING + select IIO_KFIFO_BUF help Say yes here to build support for Analog Devices Impedance Converter, Network Analyzer, AD5933/4, provides direct access via sysfs. diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 779243d..440e226 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -22,7 +22,7 @@ #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> -#include "../ring_sw.h" +#include <linux/iio/kfifo_buf.h> #include "ad5933.h" @@ -630,7 +630,7 @@ static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) { - indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + indio_dev->buffer = iio_kfifo_allocate(indio_dev); if (!indio_dev->buffer) return -ENOMEM; @@ -774,7 +774,7 @@ static int ad5933_probe(struct i2c_client *client, error_uninitialize_ring: iio_buffer_unregister(indio_dev); error_unreg_ring: - iio_sw_rb_free(indio_dev->buffer); + iio_kfifo_free(indio_dev->buffer); error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); @@ -794,7 +794,7 @@ static int ad5933_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); - iio_sw_rb_free(indio_dev->buffer); + iio_kfifo_free(indio_dev->buffer); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig deleted file mode 100644 index 2c2f47d..0000000 --- a/drivers/staging/iio/imu/Kconfig +++ /dev/null @@ -1,17 +0,0 @@ -# -# IIO imu drivers configuration -# -menu "Inertial measurement units" - -config ADIS16400 - tristate "Analog Devices ADIS16400 and similar IMU SPI driver" - depends on SPI - select IIO_SW_RING if IIO_BUFFER - select IIO_TRIGGER if IIO_BUFFER - help - Say yes here to build support for Analog Devices adis16300, adis16344, - adis16350, adis16354, adis16355, adis16360, adis16362, adis16364, - adis16365, adis16400 and adis16405 triaxial inertial sensors - (adis16400 series also have magnetometers). - -endmenu diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile deleted file mode 100644 index 3400a13..0000000 --- a/drivers/staging/iio/imu/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -# Makefile for Inertial Measurement Units -# - -adis16400-y := adis16400_core.o -adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o adis16400_trigger.o -obj-$(CONFIG_ADIS16400) += adis16400.o diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h deleted file mode 100644 index 7a105e9..0000000 --- a/drivers/staging/iio/imu/adis16400.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * adis16400.h support Analog Devices ADIS16400 - * 3d 18g accelerometers, - * 3d gyroscopes, - * 3d 2.5gauss magnetometers via SPI - * - * Copyright (c) 2009 Manuel Stahl <manuel.stahl@iis.fraunhofer.de> - * Copyright (c) 2007 Jonathan Cameron <jic23@kernel.org> - * - * Loosely based upon lis3l02dq.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef SPI_ADIS16400_H_ -#define SPI_ADIS16400_H_ - -#define ADIS16400_STARTUP_DELAY 290 /* ms */ -#define ADIS16400_MTEST_DELAY 90 /* ms */ - -#define ADIS16400_READ_REG(a) a -#define ADIS16400_WRITE_REG(a) ((a) | 0x80) - -#define ADIS16400_FLASH_CNT 0x00 /* Flash memory write count */ -#define ADIS16400_SUPPLY_OUT 0x02 /* Power supply measurement */ -#define ADIS16400_XGYRO_OUT 0x04 /* X-axis gyroscope output */ -#define ADIS16400_YGYRO_OUT 0x06 /* Y-axis gyroscope output */ -#define ADIS16400_ZGYRO_OUT 0x08 /* Z-axis gyroscope output */ -#define ADIS16400_XACCL_OUT 0x0A /* X-axis accelerometer output */ -#define ADIS16400_YACCL_OUT 0x0C /* Y-axis accelerometer output */ -#define ADIS16400_ZACCL_OUT 0x0E /* Z-axis accelerometer output */ -#define ADIS16400_XMAGN_OUT 0x10 /* X-axis magnetometer measurement */ -#define ADIS16400_YMAGN_OUT 0x12 /* Y-axis magnetometer measurement */ -#define ADIS16400_ZMAGN_OUT 0x14 /* Z-axis magnetometer measurement */ -#define ADIS16400_TEMP_OUT 0x16 /* Temperature output */ -#define ADIS16400_AUX_ADC 0x18 /* Auxiliary ADC measurement */ - -#define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */ -#define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */ -#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */ - -#define ADIS16300_PITCH_OUT 0x12 /* X axis inclinometer output measurement */ -#define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */ -#define ADIS16300_AUX_ADC 0x16 /* Auxiliary ADC measurement */ - -/* Calibration parameters */ -#define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */ -#define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */ -#define ADIS16400_ZGYRO_OFF 0x1E /* Z-axis gyroscope bias offset factor */ -#define ADIS16400_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */ -#define ADIS16400_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */ -#define ADIS16400_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */ -#define ADIS16400_XMAGN_HIF 0x26 /* X-axis magnetometer, hard-iron factor */ -#define ADIS16400_YMAGN_HIF 0x28 /* Y-axis magnetometer, hard-iron factor */ -#define ADIS16400_ZMAGN_HIF 0x2A /* Z-axis magnetometer, hard-iron factor */ -#define ADIS16400_XMAGN_SIF 0x2C /* X-axis magnetometer, soft-iron factor */ -#define ADIS16400_YMAGN_SIF 0x2E /* Y-axis magnetometer, soft-iron factor */ -#define ADIS16400_ZMAGN_SIF 0x30 /* Z-axis magnetometer, soft-iron factor */ - -#define ADIS16400_GPIO_CTRL 0x32 /* Auxiliary digital input/output control */ -#define ADIS16400_MSC_CTRL 0x34 /* Miscellaneous control */ -#define ADIS16400_SMPL_PRD 0x36 /* Internal sample period (rate) control */ -#define ADIS16400_SENS_AVG 0x38 /* Dynamic range and digital filter control */ -#define ADIS16400_SLP_CNT 0x3A /* Sleep mode control */ -#define ADIS16400_DIAG_STAT 0x3C /* System status */ - -/* Alarm functions */ -#define ADIS16400_GLOB_CMD 0x3E /* System command */ -#define ADIS16400_ALM_MAG1 0x40 /* Alarm 1 amplitude threshold */ -#define ADIS16400_ALM_MAG2 0x42 /* Alarm 2 amplitude threshold */ -#define ADIS16400_ALM_SMPL1 0x44 /* Alarm 1 sample size */ -#define ADIS16400_ALM_SMPL2 0x46 /* Alarm 2 sample size */ -#define ADIS16400_ALM_CTRL 0x48 /* Alarm control */ -#define ADIS16400_AUX_DAC 0x4A /* Auxiliary DAC data */ - -#define ADIS16400_PRODUCT_ID 0x56 /* Product identifier */ - -#define ADIS16400_ERROR_ACTIVE (1<<14) -#define ADIS16400_NEW_DATA (1<<14) - -/* MSC_CTRL */ -#define ADIS16400_MSC_CTRL_MEM_TEST (1<<11) -#define ADIS16400_MSC_CTRL_INT_SELF_TEST (1<<10) -#define ADIS16400_MSC_CTRL_NEG_SELF_TEST (1<<9) -#define ADIS16400_MSC_CTRL_POS_SELF_TEST (1<<8) -#define ADIS16400_MSC_CTRL_GYRO_BIAS (1<<7) -#define ADIS16400_MSC_CTRL_ACCL_ALIGN (1<<6) -#define ADIS16400_MSC_CTRL_DATA_RDY_EN (1<<2) -#define ADIS16400_MSC_CTRL_DATA_RDY_POL_HIGH (1<<1) -#define ADIS16400_MSC_CTRL_DATA_RDY_DIO2 (1<<0) - -/* SMPL_PRD */ -#define ADIS16400_SMPL_PRD_TIME_BASE (1<<7) -#define ADIS16400_SMPL_PRD_DIV_MASK 0x7F - -/* DIAG_STAT */ -#define ADIS16400_DIAG_STAT_ZACCL_FAIL (1<<15) -#define ADIS16400_DIAG_STAT_YACCL_FAIL (1<<14) -#define ADIS16400_DIAG_STAT_XACCL_FAIL (1<<13) -#define ADIS16400_DIAG_STAT_XGYRO_FAIL (1<<12) -#define ADIS16400_DIAG_STAT_YGYRO_FAIL (1<<11) -#define ADIS16400_DIAG_STAT_ZGYRO_FAIL (1<<10) -#define ADIS16400_DIAG_STAT_ALARM2 (1<<9) -#define ADIS16400_DIAG_STAT_ALARM1 (1<<8) -#define ADIS16400_DIAG_STAT_FLASH_CHK (1<<6) -#define ADIS16400_DIAG_STAT_SELF_TEST (1<<5) -#define ADIS16400_DIAG_STAT_OVERFLOW (1<<4) -#define ADIS16400_DIAG_STAT_SPI_FAIL (1<<3) -#define ADIS16400_DIAG_STAT_FLASH_UPT (1<<2) -#define ADIS16400_DIAG_STAT_POWER_HIGH (1<<1) -#define ADIS16400_DIAG_STAT_POWER_LOW (1<<0) - -/* GLOB_CMD */ -#define ADIS16400_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16400_GLOB_CMD_P_AUTO_NULL (1<<4) -#define ADIS16400_GLOB_CMD_FLASH_UPD (1<<3) -#define ADIS16400_GLOB_CMD_DAC_LATCH (1<<2) -#define ADIS16400_GLOB_CMD_FAC_CALIB (1<<1) -#define ADIS16400_GLOB_CMD_AUTO_NULL (1<<0) - -/* SLP_CNT */ -#define ADIS16400_SLP_CNT_POWER_OFF (1<<8) - -#define ADIS16334_RATE_DIV_SHIFT 8 -#define ADIS16334_RATE_INT_CLK BIT(0) - -#define ADIS16400_MAX_TX 24 -#define ADIS16400_MAX_RX 24 - -#define ADIS16400_SPI_SLOW (u32)(300 * 1000) -#define ADIS16400_SPI_BURST (u32)(1000 * 1000) -#define ADIS16400_SPI_FAST (u32)(2000 * 1000) - -#define ADIS16400_HAS_PROD_ID BIT(0) -#define ADIS16400_NO_BURST BIT(1) -#define ADIS16400_HAS_SLOW_MODE BIT(2) - -struct adis16400_chip_info { - const struct iio_chan_spec *channels; - const int num_channels; - const long flags; - unsigned int gyro_scale_micro; - unsigned int accel_scale_micro; - int temp_scale_nano; - int temp_offset; - unsigned long default_scan_mask; - int (*set_freq)(struct iio_dev *indio_dev, unsigned int freq); - int (*get_freq)(struct iio_dev *indio_dev); -}; - -/** - * struct adis16400_state - device instance specific data - * @us: actual spi_device - * @trig: data ready trigger registered with iio - * @tx: transmit buffer - * @rx: receive buffer - * @buf_lock: mutex to protect tx and rx - * @filt_int: integer part of requested filter frequency - **/ -struct adis16400_state { - struct spi_device *us; - struct iio_trigger *trig; - struct mutex buf_lock; - struct adis16400_chip_info *variant; - int filt_int; - - u8 tx[ADIS16400_MAX_TX] ____cacheline_aligned; - u8 rx[ADIS16400_MAX_RX] ____cacheline_aligned; -}; - -int adis16400_set_irq(struct iio_dev *indio_dev, bool enable); - -/* At the moment triggers are only used for ring buffer - * filling. This may change! - */ - -#define ADIS16400_SCAN_SUPPLY 0 -#define ADIS16400_SCAN_GYRO_X 1 -#define ADIS16400_SCAN_GYRO_Y 2 -#define ADIS16400_SCAN_GYRO_Z 3 -#define ADIS16400_SCAN_ACC_X 4 -#define ADIS16400_SCAN_ACC_Y 5 -#define ADIS16400_SCAN_ACC_Z 6 -#define ADIS16400_SCAN_MAGN_X 7 -#define ADIS16350_SCAN_TEMP_X 7 -#define ADIS16400_SCAN_MAGN_Y 8 -#define ADIS16350_SCAN_TEMP_Y 8 -#define ADIS16400_SCAN_MAGN_Z 9 -#define ADIS16350_SCAN_TEMP_Z 9 -#define ADIS16400_SCAN_TEMP 10 -#define ADIS16350_SCAN_ADC_0 10 -#define ADIS16400_SCAN_ADC_0 11 -#define ADIS16300_SCAN_INCLI_X 12 -#define ADIS16300_SCAN_INCLI_Y 13 - -#ifdef CONFIG_IIO_BUFFER -void adis16400_remove_trigger(struct iio_dev *indio_dev); -int adis16400_probe_trigger(struct iio_dev *indio_dev); - -ssize_t adis16400_read_data_from_ring(struct device *dev, - struct device_attribute *attr, - char *buf); - - -int adis16400_configure_ring(struct iio_dev *indio_dev); -void adis16400_unconfigure_ring(struct iio_dev *indio_dev); - -#else /* CONFIG_IIO_BUFFER */ - -static inline void adis16400_remove_trigger(struct iio_dev *indio_dev) -{ -} - -static inline int adis16400_probe_trigger(struct iio_dev *indio_dev) -{ - return 0; -} - -static inline ssize_t -adis16400_read_data_from_ring(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return 0; -} - -static int adis16400_configure_ring(struct iio_dev *indio_dev) -{ - return 0; -} - -static inline void adis16400_unconfigure_ring(struct iio_dev *indio_dev) -{ -} - -#endif /* CONFIG_IIO_BUFFER */ -#endif /* SPI_ADIS16400_H_ */ diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c deleted file mode 100644 index 9c8f5ab..0000000 --- a/drivers/staging/iio/imu/adis16400_core.c +++ /dev/null @@ -1,1320 +0,0 @@ -/* - * adis16400.c support Analog Devices ADIS16400/5 - * 3d 2g Linear Accelerometers, - * 3d Gyroscopes, - * 3d Magnetometers via SPI - * - * Copyright (c) 2009 Manuel Stahl <manuel.stahl@iis.fraunhofer.de> - * Copyright (c) 2007 Jonathan Cameron <jic23@kernel.org> - * Copyright (c) 2011 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - */ - -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/delay.h> -#include <linux/mutex.h> -#include <linux/device.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/sysfs.h> -#include <linux/list.h> -#include <linux/module.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> -#include <linux/iio/buffer.h> -#include "adis16400.h" - -enum adis16400_chip_variant { - ADIS16300, - ADIS16334, - ADIS16350, - ADIS16360, - ADIS16362, - ADIS16364, - ADIS16400, -}; - -/** - * adis16400_spi_write_reg_8() - write single byte to a register - * @dev: device associated with child of actual device (iio_dev or iio_trig) - * @reg_address: the address of the register to be written - * @val: the value to write - */ -static int adis16400_spi_write_reg_8(struct iio_dev *indio_dev, - u8 reg_address, - u8 val) -{ - int ret; - struct adis16400_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16400_WRITE_REG(reg_address); - st->tx[1] = val; - - ret = spi_write(st->us, st->tx, 2); - mutex_unlock(&st->buf_lock); - - return ret; -} - -/** - * adis16400_spi_write_reg_16() - write 2 bytes to a pair of registers - * @dev: device associated with child of actual device (iio_dev or iio_trig) - * @reg_address: the address of the lower of the two registers. Second register - * is assumed to have address one greater. - * @val: value to be written - * - * At the moment the spi framework doesn't allow global setting of cs_change. - * This means that use cannot be made of spi_write. - */ -static int adis16400_spi_write_reg_16(struct iio_dev *indio_dev, - u8 lower_reg_address, - u16 value) -{ - int ret; - struct spi_message msg; - struct adis16400_state *st = iio_priv(indio_dev); - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - }, { - .tx_buf = st->tx + 2, - .bits_per_word = 8, - .len = 2, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16400_WRITE_REG(lower_reg_address); - st->tx[1] = value & 0xFF; - st->tx[2] = ADIS16400_WRITE_REG(lower_reg_address + 1); - st->tx[3] = (value >> 8) & 0xFF; - - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); - mutex_unlock(&st->buf_lock); - - return ret; -} - -/** - * adis16400_spi_read_reg_16() - read 2 bytes from a 16-bit register - * @indio_dev: iio device - * @reg_address: the address of the lower of the two registers. Second register - * is assumed to have address one greater. - * @val: somewhere to pass back the value read - * - * At the moment the spi framework doesn't allow global setting of cs_change. - * This means that use cannot be made of spi_read. - **/ -static int adis16400_spi_read_reg_16(struct iio_dev *indio_dev, - u8 lower_reg_address, - u16 *val) -{ - struct spi_message msg; - struct adis16400_state *st = iio_priv(indio_dev); - int ret; - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - }, { - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 2, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16400_READ_REG(lower_reg_address); - st->tx[1] = 0; - - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); - if (ret) { - dev_err(&st->us->dev, - "problem when reading 16 bit register 0x%02X", - lower_reg_address); - goto error_ret; - } - *val = (st->rx[0] << 8) | st->rx[1]; - -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -static int adis16334_get_freq(struct iio_dev *indio_dev) -{ - int ret; - u16 t; - - ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SMPL_PRD, &t); - if (ret < 0) - return ret; - - t >>= ADIS16334_RATE_DIV_SHIFT; - - return (8192 >> t) / 10; -} - -static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq) -{ - unsigned int t; - - t = ilog2(8192 / (freq * 10)); - - if (t > 0x31) - t = 0x31; - - t <<= ADIS16334_RATE_DIV_SHIFT; - t |= ADIS16334_RATE_INT_CLK; - - return adis16400_spi_write_reg_16(indio_dev, ADIS16400_SMPL_PRD, t); -} - -static int adis16400_get_freq(struct iio_dev *indio_dev) -{ - int sps, ret; - u16 t; - - ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SMPL_PRD, &t); - if (ret < 0) - return ret; - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638; - sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1; - - return sps; -} - -static int adis16400_set_freq(struct iio_dev *indio_dev, unsigned int freq) -{ - struct adis16400_state *st = iio_priv(indio_dev); - unsigned int t; - - t = 1638 / freq; - if (t > 0) - t--; - t &= ADIS16400_SMPL_PRD_DIV_MASK; - if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A) - st->us->max_speed_hz = ADIS16400_SPI_SLOW; - else - st->us->max_speed_hz = ADIS16400_SPI_FAST; - - return adis16400_spi_write_reg_8(indio_dev, - ADIS16400_SMPL_PRD, t); -} - -static ssize_t adis16400_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis16400_state *st = iio_priv(indio_dev); - int ret, len = 0; - - ret = st->variant->get_freq(indio_dev); - if (ret < 0) - return ret; - len = sprintf(buf, "%d SPS\n", ret); - return len; -} - -static const unsigned adis16400_3db_divisors[] = { - [0] = 2, /* Special case */ - [1] = 5, - [2] = 10, - [3] = 50, - [4] = 200, -}; - -static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val) -{ - int i, ret; - u16 val16; - for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 0; i--) - if (sps/adis16400_3db_divisors[i] > val) - break; - if (i == -1) - ret = -EINVAL; - else { - ret = adis16400_spi_read_reg_16(indio_dev, - ADIS16400_SENS_AVG, - &val16); - if (ret < 0) - goto error_ret; - - ret = adis16400_spi_write_reg_16(indio_dev, - ADIS16400_SENS_AVG, - (val16 & ~0x03) | i); - } -error_ret: - return ret; -} - -static ssize_t adis16400_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis16400_state *st = iio_priv(indio_dev); - long val; - int ret; - - ret = strict_strtol(buf, 10, &val); - if (ret) - return ret; - if (val == 0) - return -EINVAL; - - mutex_lock(&indio_dev->mlock); - - st->variant->set_freq(indio_dev, val); - - /* Also update the filter */ - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static int adis16400_reset(struct iio_dev *indio_dev) -{ - int ret; - ret = adis16400_spi_write_reg_8(indio_dev, - ADIS16400_GLOB_CMD, - ADIS16400_GLOB_CMD_SW_RESET); - if (ret) - dev_err(&indio_dev->dev, "problem resetting device"); - - return ret; -} - -int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) -{ - int ret; - u16 msc; - - ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_MSC_CTRL, &msc); - if (ret) - goto error_ret; - - msc |= ADIS16400_MSC_CTRL_DATA_RDY_POL_HIGH; - if (enable) - msc |= ADIS16400_MSC_CTRL_DATA_RDY_EN; - else - msc &= ~ADIS16400_MSC_CTRL_DATA_RDY_EN; - - ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_MSC_CTRL, msc); - if (ret) - goto error_ret; - -error_ret: - return ret; -} - -/* Power down the device */ -static int adis16400_stop_device(struct iio_dev *indio_dev) -{ - int ret; - u16 val = ADIS16400_SLP_CNT_POWER_OFF; - - ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_SLP_CNT, val); - if (ret) - dev_err(&indio_dev->dev, - "problem with turning device off: SLP_CNT"); - - return ret; -} - -static int adis16400_check_status(struct iio_dev *indio_dev) -{ - u16 status; - int ret; - struct device *dev = &indio_dev->dev; - - ret = adis16400_spi_read_reg_16(indio_dev, - ADIS16400_DIAG_STAT, &status); - - if (ret < 0) { - dev_err(dev, "Reading status failed\n"); - goto error_ret; - } - ret = status; - if (status & ADIS16400_DIAG_STAT_ZACCL_FAIL) - dev_err(dev, "Z-axis accelerometer self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_YACCL_FAIL) - dev_err(dev, "Y-axis accelerometer self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_XACCL_FAIL) - dev_err(dev, "X-axis accelerometer self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_XGYRO_FAIL) - dev_err(dev, "X-axis gyroscope self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_YGYRO_FAIL) - dev_err(dev, "Y-axis gyroscope self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_ZGYRO_FAIL) - dev_err(dev, "Z-axis gyroscope self-test failure\n"); - if (status & ADIS16400_DIAG_STAT_ALARM2) - dev_err(dev, "Alarm 2 active\n"); - if (status & ADIS16400_DIAG_STAT_ALARM1) - dev_err(dev, "Alarm 1 active\n"); - if (status & ADIS16400_DIAG_STAT_FLASH_CHK) - dev_err(dev, "Flash checksum error\n"); - if (status & ADIS16400_DIAG_STAT_SELF_TEST) - dev_err(dev, "Self test error\n"); - if (status & ADIS16400_DIAG_STAT_OVERFLOW) - dev_err(dev, "Sensor overrange\n"); - if (status & ADIS16400_DIAG_STAT_SPI_FAIL) - dev_err(dev, "SPI failure\n"); - if (status & ADIS16400_DIAG_STAT_FLASH_UPT) - dev_err(dev, "Flash update failed\n"); - if (status & ADIS16400_DIAG_STAT_POWER_HIGH) - dev_err(dev, "Power supply above 5.25V\n"); - if (status & ADIS16400_DIAG_STAT_POWER_LOW) - dev_err(dev, "Power supply below 4.75V\n"); - -error_ret: - return ret; -} - -static int adis16400_self_test(struct iio_dev *indio_dev) -{ - int ret; - ret = adis16400_spi_write_reg_16(indio_dev, - ADIS16400_MSC_CTRL, - ADIS16400_MSC_CTRL_MEM_TEST); - if (ret) { - dev_err(&indio_dev->dev, "problem starting self test"); - goto err_ret; - } - - msleep(ADIS16400_MTEST_DELAY); - adis16400_check_status(indio_dev); - -err_ret: - return ret; -} - -static int adis16400_initial_setup(struct iio_dev *indio_dev) -{ - int ret; - u16 prod_id, smp_prd; - unsigned int device_id; - struct adis16400_state *st = iio_priv(indio_dev); - - /* use low spi speed for init if the device has a slow mode */ - if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) - st->us->max_speed_hz = ADIS16400_SPI_SLOW; - else - st->us->max_speed_hz = ADIS16400_SPI_FAST; - st->us->mode = SPI_MODE_3; - spi_setup(st->us); - - ret = adis16400_set_irq(indio_dev, false); - if (ret) { - dev_err(&indio_dev->dev, "disable irq failed"); - goto err_ret; - } - - ret = adis16400_self_test(indio_dev); - if (ret) { - dev_err(&indio_dev->dev, "self test failure"); - goto err_ret; - } - - ret = adis16400_check_status(indio_dev); - if (ret) { - adis16400_reset(indio_dev); - dev_err(&indio_dev->dev, "device not playing ball -> reset"); - msleep(ADIS16400_STARTUP_DELAY); - ret = adis16400_check_status(indio_dev); - if (ret) { - dev_err(&indio_dev->dev, "giving up"); - goto err_ret; - } - } - if (st->variant->flags & ADIS16400_HAS_PROD_ID) { - ret = adis16400_spi_read_reg_16(indio_dev, - ADIS16400_PRODUCT_ID, &prod_id); - if (ret) - goto err_ret; - - sscanf(indio_dev->name, "adis%u\n", &device_id); - - if (prod_id != device_id) - dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.", - device_id, prod_id); - - dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n", - indio_dev->name, prod_id, - st->us->chip_select, st->us->irq); - } - /* use high spi speed if possible */ - if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) { - ret = adis16400_spi_read_reg_16(indio_dev, - ADIS16400_SMPL_PRD, &smp_prd); - if (ret) - goto err_ret; - - if ((smp_prd & ADIS16400_SMPL_PRD_DIV_MASK) < 0x0A) { - st->us->max_speed_hz = ADIS16400_SPI_FAST; - spi_setup(st->us); - } - } - -err_ret: - return ret; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - adis16400_read_frequency, - adis16400_write_frequency); - -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638"); - -enum adis16400_chan { - in_supply, - gyro_x, - gyro_y, - gyro_z, - accel_x, - accel_y, - accel_z, - magn_x, - magn_y, - magn_z, - temp, - temp0, temp1, temp2, - in1, - in2, - incli_x, - incli_y, -}; - -static u8 adis16400_addresses[18][2] = { - [in_supply] = { ADIS16400_SUPPLY_OUT }, - [gyro_x] = { ADIS16400_XGYRO_OUT, ADIS16400_XGYRO_OFF }, - [gyro_y] = { ADIS16400_YGYRO_OUT, ADIS16400_YGYRO_OFF }, - [gyro_z] = { ADIS16400_ZGYRO_OUT, ADIS16400_ZGYRO_OFF }, - [accel_x] = { ADIS16400_XACCL_OUT, ADIS16400_XACCL_OFF }, - [accel_y] = { ADIS16400_YACCL_OUT, ADIS16400_YACCL_OFF }, - [accel_z] = { ADIS16400_ZACCL_OUT, ADIS16400_ZACCL_OFF }, - [magn_x] = { ADIS16400_XMAGN_OUT }, - [magn_y] = { ADIS16400_YMAGN_OUT }, - [magn_z] = { ADIS16400_ZMAGN_OUT }, - [temp] = { ADIS16400_TEMP_OUT }, - [temp0] = { ADIS16350_XTEMP_OUT }, - [temp1] = { ADIS16350_YTEMP_OUT }, - [temp2] = { ADIS16350_ZTEMP_OUT }, - [in1] = { ADIS16300_AUX_ADC }, - [in2] = { ADIS16400_AUX_ADC }, - [incli_x] = { ADIS16300_PITCH_OUT }, - [incli_y] = { ADIS16300_ROLL_OUT } -}; - - -static int adis16400_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) -{ - struct adis16400_state *st = iio_priv(indio_dev); - int ret, sps; - - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: - mutex_lock(&indio_dev->mlock); - ret = adis16400_spi_write_reg_16(indio_dev, - adis16400_addresses[chan->address][1], - val); - mutex_unlock(&indio_dev->mlock); - return ret; - case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: - /* Need to cache values so we can update if the frequency - changes */ - mutex_lock(&indio_dev->mlock); - st->filt_int = val; - /* Work out update to current value */ - sps = st->variant->get_freq(indio_dev); - if (sps < 0) { - mutex_unlock(&indio_dev->mlock); - return sps; - } - - ret = adis16400_set_filter(indio_dev, sps, val); - mutex_unlock(&indio_dev->mlock); - return ret; - default: - return -EINVAL; - } -} - -static int adis16400_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) -{ - struct adis16400_state *st = iio_priv(indio_dev); - int ret, shift; - s16 val16; - - switch (mask) { - case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - ret = adis16400_spi_read_reg_16(indio_dev, - adis16400_addresses[chan->address][0], - &val16); - if (ret) { - mutex_unlock(&indio_dev->mlock); - return ret; - } - val16 &= (1 << chan->scan_type.realbits) - 1; - if (chan->scan_type.sign == 's') { - shift = 16 - chan->scan_type.realbits; - val16 = (s16)(val16 << shift) >> shift; - } - *val = val16; - mutex_unlock(&indio_dev->mlock); - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: - switch (chan->type) { - case IIO_ANGL_VEL: - *val = 0; - *val2 = st->variant->gyro_scale_micro; - return IIO_VAL_INT_PLUS_MICRO; - case IIO_VOLTAGE: - *val = 0; - if (chan->channel == 0) { - *val = 2; - *val2 = 418000; /* 2.418 mV */ - } else { - *val = 0; - *val2 = 805800; /* 805.8 uV */ - } - return IIO_VAL_INT_PLUS_MICRO; - case IIO_ACCEL: - *val = 0; - *val2 = st->variant->accel_scale_micro; - return IIO_VAL_INT_PLUS_MICRO; - case IIO_MAGN: - *val = 0; - *val2 = 500; /* 0.5 mgauss */ - return IIO_VAL_INT_PLUS_MICRO; - case IIO_TEMP: - *val = st->variant->temp_scale_nano / 1000000; - *val2 = (st->variant->temp_scale_nano % 1000000); - return IIO_VAL_INT_PLUS_MICRO; - default: - return -EINVAL; - } - case IIO_CHAN_INFO_CALIBBIAS: - mutex_lock(&indio_dev->mlock); - ret = adis16400_spi_read_reg_16(indio_dev, - adis16400_addresses[chan->address][1], - &val16); - mutex_unlock(&indio_dev->mlock); - if (ret) - return ret; - val16 = ((val16 & 0xFFF) << 4) >> 4; - *val = val16; - return IIO_VAL_INT; - case IIO_CHAN_INFO_OFFSET: - /* currently only temperature */ - *val = st->variant->temp_offset; - return IIO_VAL_INT; - case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: - mutex_lock(&indio_dev->mlock); - /* Need both the number of taps and the sampling frequency */ - ret = adis16400_spi_read_reg_16(indio_dev, - ADIS16400_SENS_AVG, - &val16); - if (ret < 0) { - mutex_unlock(&indio_dev->mlock); - return ret; - } - val16 = st->variant->get_freq(indio_dev); - if (ret > 0) - *val = ret/adis16400_3db_divisors[val16 & 0x03]; - *val2 = 0; - mutex_unlock(&indio_dev->mlock); - if (ret < 0) - return ret; - return IIO_VAL_INT_PLUS_MICRO; - default: - return -EINVAL; - } -} - -static const struct iio_chan_spec adis16400_channels[] = { - { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .extend_name = "supply", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in_supply, - .scan_index = ADIS16400_SCAN_SUPPLY, - .scan_type = IIO_ST('u', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_x, - .scan_index = ADIS16400_SCAN_GYRO_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_y, - .scan_index = ADIS16400_SCAN_GYRO_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_z, - .scan_index = ADIS16400_SCAN_GYRO_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_x, - .scan_index = ADIS16400_SCAN_ACC_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_y, - .scan_index = ADIS16400_SCAN_ACC_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_z, - .scan_index = ADIS16400_SCAN_ACC_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_MAGN, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = magn_x, - .scan_index = ADIS16400_SCAN_MAGN_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_MAGN, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = magn_y, - .scan_index = ADIS16400_SCAN_MAGN_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_MAGN, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = magn_z, - .scan_index = ADIS16400_SCAN_MAGN_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = temp, - .scan_index = ADIS16400_SCAN_TEMP, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in2, - .scan_index = ADIS16400_SCAN_ADC_0, - .scan_type = IIO_ST('s', 12, 16, 0), - }, - IIO_CHAN_SOFT_TIMESTAMP(12) -}; - -static const struct iio_chan_spec adis16350_channels[] = { - { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .extend_name = "supply", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in_supply, - .scan_index = ADIS16400_SCAN_SUPPLY, - .scan_type = IIO_ST('u', 12, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_x, - .scan_index = ADIS16400_SCAN_GYRO_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_y, - .scan_index = ADIS16400_SCAN_GYRO_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_z, - .scan_index = ADIS16400_SCAN_GYRO_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_x, - .scan_index = ADIS16400_SCAN_ACC_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_y, - .scan_index = ADIS16400_SCAN_ACC_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_z, - .scan_index = ADIS16400_SCAN_ACC_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .extend_name = "x", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = temp0, - .scan_index = ADIS16350_SCAN_TEMP_X, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 1, - .extend_name = "y", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = temp1, - .scan_index = ADIS16350_SCAN_TEMP_Y, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 2, - .extend_name = "z", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = temp2, - .scan_index = ADIS16350_SCAN_TEMP_Z, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in1, - .scan_index = ADIS16350_SCAN_ADC_0, - .scan_type = IIO_ST('s', 12, 16, 0), - }, - IIO_CHAN_SOFT_TIMESTAMP(11) -}; - -static const struct iio_chan_spec adis16300_channels[] = { - { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .extend_name = "supply", - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in_supply, - .scan_index = ADIS16400_SCAN_SUPPLY, - .scan_type = IIO_ST('u', 12, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_x, - .scan_index = ADIS16400_SCAN_GYRO_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_x, - .scan_index = ADIS16400_SCAN_ACC_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_y, - .scan_index = ADIS16400_SCAN_ACC_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_z, - .scan_index = ADIS16400_SCAN_ACC_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = temp0, - .scan_index = ADIS16400_SCAN_TEMP, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - .address = in1, - .scan_index = ADIS16350_SCAN_ADC_0, - .scan_type = IIO_ST('s', 12, 16, 0), - }, { - .type = IIO_INCLI, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT, - .address = incli_x, - .scan_index = ADIS16300_SCAN_INCLI_X, - .scan_type = IIO_ST('s', 13, 16, 0), - }, { - .type = IIO_INCLI, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT, - .address = incli_y, - .scan_index = ADIS16300_SCAN_INCLI_Y, - .scan_type = IIO_ST('s', 13, 16, 0), - }, - IIO_CHAN_SOFT_TIMESTAMP(14) -}; - -static const struct iio_chan_spec adis16334_channels[] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_x, - .scan_index = ADIS16400_SCAN_GYRO_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_y, - .scan_index = ADIS16400_SCAN_GYRO_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = gyro_z, - .scan_index = ADIS16400_SCAN_GYRO_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_X, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_x, - .scan_index = ADIS16400_SCAN_ACC_X, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Y, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_y, - .scan_index = ADIS16400_SCAN_ACC_Y, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_ACCEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT | - IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, - .address = accel_z, - .scan_index = ADIS16400_SCAN_ACC_Z, - .scan_type = IIO_ST('s', 14, 16, 0), - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SHARED_BIT, - .address = temp0, - .scan_index = ADIS16400_SCAN_TEMP, - .scan_type = IIO_ST('s', 14, 16, 0), - }, - IIO_CHAN_SOFT_TIMESTAMP(12) -}; - -static struct attribute *adis16400_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group adis16400_attribute_group = { - .attrs = adis16400_attributes, -}; - -static struct adis16400_chip_info adis16400_chips[] = { - [ADIS16300] = { - .channels = adis16300_channels, - .num_channels = ARRAY_SIZE(adis16300_channels), - .flags = ADIS16400_HAS_SLOW_MODE, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = 5884, - .temp_scale_nano = 140000000, /* 0.14 C */ - .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */ - .default_scan_mask = (1 << ADIS16400_SCAN_SUPPLY) | - (1 << ADIS16400_SCAN_GYRO_X) | (1 << ADIS16400_SCAN_ACC_X) | - (1 << ADIS16400_SCAN_ACC_Y) | (1 << ADIS16400_SCAN_ACC_Z) | - (1 << ADIS16400_SCAN_TEMP) | (1 << ADIS16400_SCAN_ADC_0) | - (1 << ADIS16300_SCAN_INCLI_X) | (1 << ADIS16300_SCAN_INCLI_Y) | - (1 << 14), - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - }, - [ADIS16334] = { - .channels = adis16334_channels, - .num_channels = ARRAY_SIZE(adis16334_channels), - .flags = ADIS16400_HAS_PROD_ID, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */ - .temp_scale_nano = 67850000, /* 0.06785 C */ - .temp_offset = 25000000 / 67850, /* 25 C = 0x00 */ - .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) | - (1 << ADIS16400_SCAN_GYRO_Y) | (1 << ADIS16400_SCAN_GYRO_Z) | - (1 << ADIS16400_SCAN_ACC_X) | (1 << ADIS16400_SCAN_ACC_Y) | - (1 << ADIS16400_SCAN_ACC_Z), - .set_freq = adis16334_set_freq, - .get_freq = adis16334_get_freq, - }, - [ADIS16350] = { - .channels = adis16350_channels, - .num_channels = ARRAY_SIZE(adis16350_channels), - .gyro_scale_micro = IIO_DEGREE_TO_RAD(73260), /* 0.07326 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(2522), /* 0.002522 g */ - .temp_scale_nano = 145300000, /* 0.1453 C */ - .temp_offset = 25000000 / 145300, /* 25 C = 0x00 */ - .default_scan_mask = 0x7FF, - .flags = ADIS16400_NO_BURST | ADIS16400_HAS_SLOW_MODE, - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - }, - [ADIS16360] = { - .channels = adis16350_channels, - .num_channels = ARRAY_SIZE(adis16350_channels), - .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */ - .temp_scale_nano = 136000000, /* 0.136 C */ - .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */ - .default_scan_mask = 0x7FF, - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - }, - [ADIS16362] = { - .channels = adis16350_channels, - .num_channels = ARRAY_SIZE(adis16350_channels), - .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(333), /* 0.333 mg */ - .temp_scale_nano = 136000000, /* 0.136 C */ - .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */ - .default_scan_mask = 0x7FF, - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - }, - [ADIS16364] = { - .channels = adis16350_channels, - .num_channels = ARRAY_SIZE(adis16350_channels), - .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */ - .temp_scale_nano = 136000000, /* 0.136 C */ - .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */ - .default_scan_mask = 0x7FF, - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - }, - [ADIS16400] = { - .channels = adis16400_channels, - .num_channels = ARRAY_SIZE(adis16400_channels), - .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE, - .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */ - .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */ - .default_scan_mask = 0xFFF, - .temp_scale_nano = 140000000, /* 0.14 C */ - .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */ - .set_freq = adis16400_set_freq, - .get_freq = adis16400_get_freq, - } -}; - -static const struct iio_info adis16400_info = { - .driver_module = THIS_MODULE, - .read_raw = &adis16400_read_raw, - .write_raw = &adis16400_write_raw, - .attrs = &adis16400_attribute_group, -}; - -static int adis16400_probe(struct spi_device *spi) -{ - int ret; - struct adis16400_state *st; - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - st = iio_priv(indio_dev); - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); - - st->us = spi; - mutex_init(&st->buf_lock); - - /* setup the industrialio driver allocated elements */ - st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; - indio_dev->dev.parent = &spi->dev; - indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->channels = st->variant->channels; - indio_dev->num_channels = st->variant->num_channels; - indio_dev->info = &adis16400_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - ret = adis16400_configure_ring(indio_dev); - if (ret) - goto error_free_dev; - - ret = iio_buffer_register(indio_dev, - st->variant->channels, - st->variant->num_channels); - if (ret) { - dev_err(&spi->dev, "failed to initialize the ring\n"); - goto error_unreg_ring_funcs; - } - - if (spi->irq) { - ret = adis16400_probe_trigger(indio_dev); - if (ret) - goto error_uninitialize_ring; - } - - /* Get the device into a sane initial state */ - ret = adis16400_initial_setup(indio_dev); - if (ret) - goto error_remove_trigger; - ret = iio_device_register(indio_dev); - if (ret) - goto error_remove_trigger; - - return 0; - -error_remove_trigger: - if (spi->irq) - adis16400_remove_trigger(indio_dev); -error_uninitialize_ring: - iio_buffer_unregister(indio_dev); -error_unreg_ring_funcs: - adis16400_unconfigure_ring(indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; -} - -/* fixme, confirm ordering in this function */ -static int adis16400_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); - adis16400_stop_device(indio_dev); - - adis16400_remove_trigger(indio_dev); - iio_buffer_unregister(indio_dev); - adis16400_unconfigure_ring(indio_dev); - iio_device_free(indio_dev); - - return 0; -} - -static const struct spi_device_id adis16400_id[] = { - {"adis16300", ADIS16300}, - {"adis16334", ADIS16334}, - {"adis16350", ADIS16350}, - {"adis16354", ADIS16350}, - {"adis16355", ADIS16350}, - {"adis16360", ADIS16360}, - {"adis16362", ADIS16362}, - {"adis16364", ADIS16364}, - {"adis16365", ADIS16360}, - {"adis16400", ADIS16400}, - {"adis16405", ADIS16400}, - {} -}; -MODULE_DEVICE_TABLE(spi, adis16400_id); - -static struct spi_driver adis16400_driver = { - .driver = { - .name = "adis16400", - .owner = THIS_MODULE, - }, - .id_table = adis16400_id, - .probe = adis16400_probe, - .remove = adis16400_remove, -}; -module_spi_driver(adis16400_driver); - -MODULE_AUTHOR("Manuel Stahl <manuel.stahl@iis.fraunhofer.de>"); -MODULE_DESCRIPTION("Analog Devices ADIS16400/5 IMU SPI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c deleted file mode 100644 index d46c1e3..0000000 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ /dev/null @@ -1,204 +0,0 @@ -#include <linux/interrupt.h> -#include <linux/mutex.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/slab.h> -#include <linux/bitops.h> -#include <linux/export.h> - -#include <linux/iio/iio.h> -#include "../ring_sw.h" -#include <linux/iio/trigger_consumer.h> -#include "adis16400.h" - -/** - * adis16400_spi_read_burst() - read all data registers - * @indio_dev: the IIO device - * @rx: somewhere to pass back the value read (min size is 24 bytes) - **/ -static int adis16400_spi_read_burst(struct iio_dev *indio_dev, u8 *rx) -{ - struct spi_message msg; - struct adis16400_state *st = iio_priv(indio_dev); - u32 old_speed_hz = st->us->max_speed_hz; - int ret; - - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - }, { - .rx_buf = rx, - .bits_per_word = 8, - .len = 24, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD); - st->tx[1] = 0; - - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - - st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz); - spi_setup(st->us); - - ret = spi_sync(st->us, &msg); - if (ret) - dev_err(&st->us->dev, "problem when burst reading"); - - st->us->max_speed_hz = old_speed_hz; - spi_setup(st->us); - mutex_unlock(&st->buf_lock); - return ret; -} - -static const u16 read_all_tx_array[] = { - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_SUPPLY_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XGYRO_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YGYRO_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZGYRO_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XACCL_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YACCL_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZACCL_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16350_XTEMP_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16350_YTEMP_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16350_ZTEMP_OUT)), - cpu_to_be16(ADIS16400_READ_REG(ADIS16400_AUX_ADC)), -}; - -static int adis16350_spi_read_all(struct iio_dev *indio_dev, u8 *rx) -{ - struct adis16400_state *st = iio_priv(indio_dev); - - struct spi_message msg; - int i, j = 0, ret; - struct spi_transfer *xfers; - int scan_count = bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); - - xfers = kzalloc(sizeof(*xfers)*(scan_count + 1), - GFP_KERNEL); - if (xfers == NULL) - return -ENOMEM; - - for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++) - if (test_bit(i, indio_dev->active_scan_mask)) { - xfers[j].tx_buf = &read_all_tx_array[i]; - xfers[j].bits_per_word = 16; - xfers[j].len = 2; - xfers[j + 1].rx_buf = rx + j*2; - j++; - } - xfers[j].bits_per_word = 16; - xfers[j].len = 2; - - spi_message_init(&msg); - for (j = 0; j < scan_count + 1; j++) - spi_message_add_tail(&xfers[j], &msg); - - ret = spi_sync(st->us, &msg); - kfree(xfers); - - return ret; -} - -/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device - * specific to be rolled into the core. - */ -static irqreturn_t adis16400_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct adis16400_state *st = iio_priv(indio_dev); - int i = 0, j, ret = 0; - s16 *data; - - /* Asumption that long is enough for maximum channels */ - unsigned long mask = *indio_dev->active_scan_mask; - int scan_count = bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); - data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (data == NULL) { - dev_err(&st->us->dev, "memory alloc failed in ring bh"); - goto done; - } - - if (scan_count) { - if (st->variant->flags & ADIS16400_NO_BURST) { - ret = adis16350_spi_read_all(indio_dev, st->rx); - if (ret < 0) - goto done; - for (; i < scan_count; i++) - data[i] = *(s16 *)(st->rx + i*2); - } else { - ret = adis16400_spi_read_burst(indio_dev, st->rx); - if (ret < 0) - goto done; - for (; i < scan_count; i++) { - j = __ffs(mask); - mask &= ~(1 << j); - data[i] = be16_to_cpup( - (__be16 *)&(st->rx[j*2])); - } - } - } - /* Guaranteed to be aligned with 8 byte boundary */ - if (indio_dev->scan_timestamp) - *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp; - iio_push_to_buffers(indio_dev, (u8 *) data); - -done: - kfree(data); - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} - -void adis16400_unconfigure_ring(struct iio_dev *indio_dev) -{ - iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->buffer); -} - -static const struct iio_buffer_setup_ops adis16400_ring_setup_ops = { - .preenable = &iio_sw_buffer_preenable, - .postenable = &iio_triggered_buffer_postenable, - .predisable = &iio_triggered_buffer_predisable, -}; - -int adis16400_configure_ring(struct iio_dev *indio_dev) -{ - int ret = 0; - struct iio_buffer *ring; - - ring = iio_sw_rb_allocate(indio_dev); - if (!ring) { - ret = -ENOMEM; - return ret; - } - indio_dev->buffer = ring; - ring->scan_timestamp = true; - indio_dev->setup_ops = &adis16400_ring_setup_ops; - - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, - &adis16400_trigger_handler, - IRQF_ONESHOT, - indio_dev, - "%s_consumer%d", - indio_dev->name, - indio_dev->id); - if (indio_dev->pollfunc == NULL) { - ret = -ENOMEM; - goto error_iio_sw_rb_free; - } - - indio_dev->modes |= INDIO_BUFFER_TRIGGERED; - return 0; -error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->buffer); - return ret; -} diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c deleted file mode 100644 index 42a678e..0000000 --- a/drivers/staging/iio/imu/adis16400_trigger.c +++ /dev/null @@ -1,74 +0,0 @@ -#include <linux/interrupt.h> -#include <linux/kernel.h> -#include <linux/spi/spi.h> -#include <linux/export.h> - -#include <linux/iio/iio.h> -#include <linux/iio/trigger.h> -#include "adis16400.h" - -/** - * adis16400_data_rdy_trigger_set_state() set datardy interrupt state - **/ -static int adis16400_data_rdy_trigger_set_state(struct iio_trigger *trig, - bool state) -{ - struct iio_dev *indio_dev = trig->private_data; - - dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state); - return adis16400_set_irq(indio_dev, state); -} - -static const struct iio_trigger_ops adis16400_trigger_ops = { - .owner = THIS_MODULE, - .set_trigger_state = &adis16400_data_rdy_trigger_set_state, -}; - -int adis16400_probe_trigger(struct iio_dev *indio_dev) -{ - int ret; - struct adis16400_state *st = iio_priv(indio_dev); - - st->trig = iio_trigger_alloc("%s-dev%d", - indio_dev->name, - indio_dev->id); - if (st->trig == NULL) { - ret = -ENOMEM; - goto error_ret; - } - - ret = request_irq(st->us->irq, - &iio_trigger_generic_data_rdy_poll, - IRQF_TRIGGER_RISING, - "adis16400", - st->trig); - if (ret) - goto error_free_trig; - st->trig->dev.parent = &st->us->dev; - st->trig->private_data = indio_dev; - st->trig->ops = &adis16400_trigger_ops; - ret = iio_trigger_register(st->trig); - - /* select default trigger */ - indio_dev->trig = st->trig; - if (ret) - goto error_free_irq; - - return 0; - -error_free_irq: - free_irq(st->us->irq, st->trig); -error_free_trig: - iio_trigger_free(st->trig); -error_ret: - return ret; -} - -void adis16400_remove_trigger(struct iio_dev *indio_dev) -{ - struct adis16400_state *st = iio_priv(indio_dev); - - iio_trigger_unregister(st->trig); - free_irq(st->us->irq, st->trig); - iio_trigger_free(st->trig); -} diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig index 4bed30e..ca8d6e6 100644 --- a/drivers/staging/iio/light/Kconfig +++ b/drivers/staging/iio/light/Kconfig @@ -25,16 +25,6 @@ config SENSORS_ISL29028 Proximity value via iio. The ISL29028 provides the concurrent sensing of ambient light and proximity. -config SENSORS_TSL2563 - tristate "TAOS TSL2560, TSL2561, TSL2562 and TSL2563 ambient light sensors" - depends on I2C - help - If you say yes here you get support for the Taos TSL2560, - TSL2561, TSL2562 and TSL2563 ambient light sensors. - - This driver can also be built as a module. If so, the module - will be called tsl2563. - config TSL2583 tristate "TAOS TSL2580, TSL2581 and TSL2583 light-to-digital converters" depends on I2C diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile index 141af1e..9960fdf 100644 --- a/drivers/staging/iio/light/Makefile +++ b/drivers/staging/iio/light/Makefile @@ -2,7 +2,6 @@ # Makefile for industrial I/O Light sensors # -obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o obj-$(CONFIG_TSL2583) += tsl2583.o diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c deleted file mode 100644 index 1a9adc0..0000000 --- a/drivers/staging/iio/light/tsl2563.c +++ /dev/null @@ -1,899 +0,0 @@ -/* - * drivers/i2c/chips/tsl2563.c - * - * Copyright (C) 2008 Nokia Corporation - * - * Written by Timo O. Karjalainen <timo.o.karjalainen@nokia.com> - * Contact: Amit Kucheria <amit.kucheria@verdurent.com> - * - * Converted to IIO driver - * Amit Kucheria <amit.kucheria@verdurent.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include <linux/module.h> -#include <linux/i2c.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/sched.h> -#include <linux/mutex.h> -#include <linux/delay.h> -#include <linux/pm.h> -#include <linux/err.h> -#include <linux/slab.h> - -#include <linux/iio/iio.h> -#include <linux/iio/sysfs.h> -#include <linux/iio/events.h> -#include "tsl2563.h" - -/* Use this many bits for fraction part. */ -#define ADC_FRAC_BITS (14) - -/* Given number of 1/10000's in ADC_FRAC_BITS precision. */ -#define FRAC10K(f) (((f) * (1L << (ADC_FRAC_BITS))) / (10000)) - -/* Bits used for fraction in calibration coefficients.*/ -#define CALIB_FRAC_BITS (10) -/* 0.5 in CALIB_FRAC_BITS precision */ -#define CALIB_FRAC_HALF (1 << (CALIB_FRAC_BITS - 1)) -/* Make a fraction from a number n that was multiplied with b. */ -#define CALIB_FRAC(n, b) (((n) << CALIB_FRAC_BITS) / (b)) -/* Decimal 10^(digits in sysfs presentation) */ -#define CALIB_BASE_SYSFS (1000) - -#define TSL2563_CMD (0x80) -#define TSL2563_CLEARINT (0x40) - -#define TSL2563_REG_CTRL (0x00) -#define TSL2563_REG_TIMING (0x01) -#define TSL2563_REG_LOWLOW (0x02) /* data0 low threshold, 2 bytes */ -#define TSL2563_REG_LOWHIGH (0x03) -#define TSL2563_REG_HIGHLOW (0x04) /* data0 high threshold, 2 bytes */ -#define TSL2563_REG_HIGHHIGH (0x05) -#define TSL2563_REG_INT (0x06) -#define TSL2563_REG_ID (0x0a) -#define TSL2563_REG_DATA0LOW (0x0c) /* broadband sensor value, 2 bytes */ -#define TSL2563_REG_DATA0HIGH (0x0d) -#define TSL2563_REG_DATA1LOW (0x0e) /* infrared sensor value, 2 bytes */ -#define TSL2563_REG_DATA1HIGH (0x0f) - -#define TSL2563_CMD_POWER_ON (0x03) -#define TSL2563_CMD_POWER_OFF (0x00) -#define TSL2563_CTRL_POWER_MASK (0x03) - -#define TSL2563_TIMING_13MS (0x00) -#define TSL2563_TIMING_100MS (0x01) -#define TSL2563_TIMING_400MS (0x02) -#define TSL2563_TIMING_MASK (0x03) -#define TSL2563_TIMING_GAIN16 (0x10) -#define TSL2563_TIMING_GAIN1 (0x00) - -#define TSL2563_INT_DISBLED (0x00) -#define TSL2563_INT_LEVEL (0x10) -#define TSL2563_INT_PERSIST(n) ((n) & 0x0F) - -struct tsl2563_gainlevel_coeff { - u8 gaintime; - u16 min; - u16 max; -}; - -static const struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = { - { - .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN16, - .min = 0, - .max = 65534, - }, { - .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN1, - .min = 2048, - .max = 65534, - }, { - .gaintime = TSL2563_TIMING_100MS | TSL2563_TIMING_GAIN1, - .min = 4095, - .max = 37177, - }, { - .gaintime = TSL2563_TIMING_13MS | TSL2563_TIMING_GAIN1, - .min = 3000, - .max = 65535, - }, -}; - -struct tsl2563_chip { - struct mutex lock; - struct i2c_client *client; - struct delayed_work poweroff_work; - - /* Remember state for suspend and resume functions */ - bool suspended; - - struct tsl2563_gainlevel_coeff const *gainlevel; - - u16 low_thres; - u16 high_thres; - u8 intr; - bool int_enabled; - - /* Calibration coefficients */ - u32 calib0; - u32 calib1; - int cover_comp_gain; - - /* Cache current values, to be returned while suspended */ - u32 data0; - u32 data1; -}; - -static int tsl2563_set_power(struct tsl2563_chip *chip, int on) -{ - struct i2c_client *client = chip->client; - u8 cmd; - - cmd = on ? TSL2563_CMD_POWER_ON : TSL2563_CMD_POWER_OFF; - return i2c_smbus_write_byte_data(client, - TSL2563_CMD | TSL2563_REG_CTRL, cmd); -} - -/* - * Return value is 0 for off, 1 for on, or a negative error - * code if reading failed. - */ -static int tsl2563_get_power(struct tsl2563_chip *chip) -{ - struct i2c_client *client = chip->client; - int ret; - - ret = i2c_smbus_read_byte_data(client, TSL2563_CMD | TSL2563_REG_CTRL); - if (ret < 0) - return ret; - - return (ret & TSL2563_CTRL_POWER_MASK) == TSL2563_CMD_POWER_ON; -} - -static int tsl2563_configure(struct tsl2563_chip *chip) -{ - int ret; - - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_TIMING, - chip->gainlevel->gaintime); - if (ret) - goto error_ret; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_HIGHLOW, - chip->high_thres & 0xFF); - if (ret) - goto error_ret; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_HIGHHIGH, - (chip->high_thres >> 8) & 0xFF); - if (ret) - goto error_ret; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_LOWLOW, - chip->low_thres & 0xFF); - if (ret) - goto error_ret; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_LOWHIGH, - (chip->low_thres >> 8) & 0xFF); -/* Interrupt register is automatically written anyway if it is relevant - so is not here */ -error_ret: - return ret; -} - -static void tsl2563_poweroff_work(struct work_struct *work) -{ - struct tsl2563_chip *chip = - container_of(work, struct tsl2563_chip, poweroff_work.work); - tsl2563_set_power(chip, 0); -} - -static int tsl2563_detect(struct tsl2563_chip *chip) -{ - int ret; - - ret = tsl2563_set_power(chip, 1); - if (ret) - return ret; - - ret = tsl2563_get_power(chip); - if (ret < 0) - return ret; - - return ret ? 0 : -ENODEV; -} - -static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id) -{ - struct i2c_client *client = chip->client; - int ret; - - ret = i2c_smbus_read_byte_data(client, TSL2563_CMD | TSL2563_REG_ID); - if (ret < 0) - return ret; - - *id = ret; - - return 0; -} - -/* - * "Normalized" ADC value is one obtained with 400ms of integration time and - * 16x gain. This function returns the number of bits of shift needed to - * convert between normalized values and HW values obtained using given - * timing and gain settings. - */ -static int adc_shiftbits(u8 timing) -{ - int shift = 0; - - switch (timing & TSL2563_TIMING_MASK) { - case TSL2563_TIMING_13MS: - shift += 5; - break; - case TSL2563_TIMING_100MS: - shift += 2; - break; - case TSL2563_TIMING_400MS: - /* no-op */ - break; - } - - if (!(timing & TSL2563_TIMING_GAIN16)) - shift += 4; - - return shift; -} - -/* Convert a HW ADC value to normalized scale. */ -static u32 normalize_adc(u16 adc, u8 timing) -{ - return adc << adc_shiftbits(timing); -} - -static void tsl2563_wait_adc(struct tsl2563_chip *chip) -{ - unsigned int delay; - - switch (chip->gainlevel->gaintime & TSL2563_TIMING_MASK) { - case TSL2563_TIMING_13MS: - delay = 14; - break; - case TSL2563_TIMING_100MS: - delay = 101; - break; - default: - delay = 402; - } - /* - * TODO: Make sure that we wait at least required delay but why we - * have to extend it one tick more? - */ - schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2); -} - -static int tsl2563_adjust_gainlevel(struct tsl2563_chip *chip, u16 adc) -{ - struct i2c_client *client = chip->client; - - if (adc > chip->gainlevel->max || adc < chip->gainlevel->min) { - - (adc > chip->gainlevel->max) ? - chip->gainlevel++ : chip->gainlevel--; - - i2c_smbus_write_byte_data(client, - TSL2563_CMD | TSL2563_REG_TIMING, - chip->gainlevel->gaintime); - - tsl2563_wait_adc(chip); - tsl2563_wait_adc(chip); - - return 1; - } else - return 0; -} - -static int tsl2563_get_adc(struct tsl2563_chip *chip) -{ - struct i2c_client *client = chip->client; - u16 adc0, adc1; - int retry = 1; - int ret = 0; - - if (chip->suspended) - goto out; - - if (!chip->int_enabled) { - cancel_delayed_work(&chip->poweroff_work); - - if (!tsl2563_get_power(chip)) { - ret = tsl2563_set_power(chip, 1); - if (ret) - goto out; - ret = tsl2563_configure(chip); - if (ret) - goto out; - tsl2563_wait_adc(chip); - } - } - - while (retry) { - ret = i2c_smbus_read_word_data(client, - TSL2563_CMD | TSL2563_REG_DATA0LOW); - if (ret < 0) - goto out; - adc0 = ret; - - ret = i2c_smbus_read_word_data(client, - TSL2563_CMD | TSL2563_REG_DATA1LOW); - if (ret < 0) - goto out; - adc1 = ret; - - retry = tsl2563_adjust_gainlevel(chip, adc0); - } - - chip->data0 = normalize_adc(adc0, chip->gainlevel->gaintime); - chip->data1 = normalize_adc(adc1, chip->gainlevel->gaintime); - - if (!chip->int_enabled) - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); - - ret = 0; -out: - return ret; -} - -static inline int calib_to_sysfs(u32 calib) -{ - return (int) (((calib * CALIB_BASE_SYSFS) + - CALIB_FRAC_HALF) >> CALIB_FRAC_BITS); -} - -static inline u32 calib_from_sysfs(int value) -{ - return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS; -} - -/* - * Conversions between lux and ADC values. - * - * The basic formula is lux = c0 * adc0 - c1 * adc1, where c0 and c1 are - * appropriate constants. Different constants are needed for different - * kinds of light, determined by the ratio adc1/adc0 (basically the ratio - * of the intensities in infrared and visible wavelengths). lux_table below - * lists the upper threshold of the adc1/adc0 ratio and the corresponding - * constants. - */ - -struct tsl2563_lux_coeff { - unsigned long ch_ratio; - unsigned long ch0_coeff; - unsigned long ch1_coeff; -}; - -static const struct tsl2563_lux_coeff lux_table[] = { - { - .ch_ratio = FRAC10K(1300), - .ch0_coeff = FRAC10K(315), - .ch1_coeff = FRAC10K(262), - }, { - .ch_ratio = FRAC10K(2600), - .ch0_coeff = FRAC10K(337), - .ch1_coeff = FRAC10K(430), - }, { - .ch_ratio = FRAC10K(3900), - .ch0_coeff = FRAC10K(363), - .ch1_coeff = FRAC10K(529), - }, { - .ch_ratio = FRAC10K(5200), - .ch0_coeff = FRAC10K(392), - .ch1_coeff = FRAC10K(605), - }, { - .ch_ratio = FRAC10K(6500), - .ch0_coeff = FRAC10K(229), - .ch1_coeff = FRAC10K(291), - }, { - .ch_ratio = FRAC10K(8000), - .ch0_coeff = FRAC10K(157), - .ch1_coeff = FRAC10K(180), - }, { - .ch_ratio = FRAC10K(13000), - .ch0_coeff = FRAC10K(34), - .ch1_coeff = FRAC10K(26), - }, { - .ch_ratio = ULONG_MAX, - .ch0_coeff = 0, - .ch1_coeff = 0, - }, -}; - -/* - * Convert normalized, scaled ADC values to lux. - */ -static unsigned int adc_to_lux(u32 adc0, u32 adc1) -{ - const struct tsl2563_lux_coeff *lp = lux_table; - unsigned long ratio, lux, ch0 = adc0, ch1 = adc1; - - ratio = ch0 ? ((ch1 << ADC_FRAC_BITS) / ch0) : ULONG_MAX; - - while (lp->ch_ratio < ratio) - lp++; - - lux = ch0 * lp->ch0_coeff - ch1 * lp->ch1_coeff; - - return (unsigned int) (lux >> ADC_FRAC_BITS); -} - -/*--------------------------------------------------------------*/ -/* Sysfs interface */ -/*--------------------------------------------------------------*/ - - -/* Apply calibration coefficient to ADC count. */ -static u32 calib_adc(u32 adc, u32 calib) -{ - unsigned long scaled = adc; - - scaled *= calib; - scaled >>= CALIB_FRAC_BITS; - - return (u32) scaled; -} - -static int tsl2563_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) -{ - struct tsl2563_chip *chip = iio_priv(indio_dev); - - if (chan->channel == IIO_MOD_LIGHT_BOTH) - chip->calib0 = calib_from_sysfs(val); - else - chip->calib1 = calib_from_sysfs(val); - - return 0; -} - -static int tsl2563_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - int ret = -EINVAL; - u32 calib0, calib1; - struct tsl2563_chip *chip = iio_priv(indio_dev); - - mutex_lock(&chip->lock); - switch (m) { - case IIO_CHAN_INFO_RAW: - case IIO_CHAN_INFO_PROCESSED: - switch (chan->type) { - case IIO_LIGHT: - ret = tsl2563_get_adc(chip); - if (ret) - goto error_ret; - calib0 = calib_adc(chip->data0, chip->calib0) * - chip->cover_comp_gain; - calib1 = calib_adc(chip->data1, chip->calib1) * - chip->cover_comp_gain; - *val = adc_to_lux(calib0, calib1); - ret = IIO_VAL_INT; - break; - case IIO_INTENSITY: - ret = tsl2563_get_adc(chip); - if (ret) - goto error_ret; - if (chan->channel == 0) - *val = chip->data0; - else - *val = chip->data1; - ret = IIO_VAL_INT; - break; - default: - break; - } - break; - - case IIO_CHAN_INFO_CALIBSCALE: - if (chan->channel == 0) - *val = calib_to_sysfs(chip->calib0); - else - *val = calib_to_sysfs(chip->calib1); - ret = IIO_VAL_INT; - break; - default: - ret = -EINVAL; - goto error_ret; - } - -error_ret: - mutex_unlock(&chip->lock); - return ret; -} - -static const struct iio_chan_spec tsl2563_channels[] = { - { - .type = IIO_LIGHT, - .indexed = 1, - .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT, - .channel = 0, - }, { - .type = IIO_INTENSITY, - .modified = 1, - .channel2 = IIO_MOD_LIGHT_BOTH, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, - .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING) | - IIO_EV_BIT(IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING)), - }, { - .type = IIO_INTENSITY, - .modified = 1, - .channel2 = IIO_MOD_LIGHT_IR, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, - } -}; - -static int tsl2563_read_thresh(struct iio_dev *indio_dev, - u64 event_code, - int *val) -{ - struct tsl2563_chip *chip = iio_priv(indio_dev); - - switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { - case IIO_EV_DIR_RISING: - *val = chip->high_thres; - break; - case IIO_EV_DIR_FALLING: - *val = chip->low_thres; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int tsl2563_write_thresh(struct iio_dev *indio_dev, - u64 event_code, - int val) -{ - struct tsl2563_chip *chip = iio_priv(indio_dev); - int ret; - u8 address; - - if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) - address = TSL2563_REG_HIGHLOW; - else - address = TSL2563_REG_LOWLOW; - mutex_lock(&chip->lock); - ret = i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | address, - val & 0xFF); - if (ret) - goto error_ret; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | (address + 1), - (val >> 8) & 0xFF); - if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) - chip->high_thres = val; - else - chip->low_thres = val; - -error_ret: - mutex_unlock(&chip->lock); - - return ret; -} - -static irqreturn_t tsl2563_event_handler(int irq, void *private) -{ - struct iio_dev *dev_info = private; - struct tsl2563_chip *chip = iio_priv(dev_info); - - iio_push_event(dev_info, - IIO_UNMOD_EVENT_CODE(IIO_LIGHT, - 0, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_EITHER), - iio_get_time_ns()); - - /* clear the interrupt and push the event */ - i2c_smbus_write_byte(chip->client, TSL2563_CMD | TSL2563_CLEARINT); - return IRQ_HANDLED; -} - -static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, - u64 event_code, - int state) -{ - struct tsl2563_chip *chip = iio_priv(indio_dev); - int ret = 0; - - mutex_lock(&chip->lock); - if (state && !(chip->intr & 0x30)) { - chip->intr &= ~0x30; - chip->intr |= 0x10; - /* ensure the chip is actually on */ - cancel_delayed_work(&chip->poweroff_work); - if (!tsl2563_get_power(chip)) { - ret = tsl2563_set_power(chip, 1); - if (ret) - goto out; - ret = tsl2563_configure(chip); - if (ret) - goto out; - } - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_INT, - chip->intr); - chip->int_enabled = true; - } - - if (!state && (chip->intr & 0x30)) { - chip->intr &= ~0x30; - ret = i2c_smbus_write_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_INT, - chip->intr); - chip->int_enabled = false; - /* now the interrupt is not enabled, we can go to sleep */ - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); - } -out: - mutex_unlock(&chip->lock); - - return ret; -} - -static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, - u64 event_code) -{ - struct tsl2563_chip *chip = iio_priv(indio_dev); - int ret; - - mutex_lock(&chip->lock); - ret = i2c_smbus_read_byte_data(chip->client, - TSL2563_CMD | TSL2563_REG_INT); - mutex_unlock(&chip->lock); - if (ret < 0) - goto error_ret; - ret = !!(ret & 0x30); -error_ret: - - return ret; -} - -/*--------------------------------------------------------------*/ -/* Probe, Attach, Remove */ -/*--------------------------------------------------------------*/ -static struct i2c_driver tsl2563_i2c_driver; - -static const struct iio_info tsl2563_info_no_irq = { - .driver_module = THIS_MODULE, - .read_raw = &tsl2563_read_raw, - .write_raw = &tsl2563_write_raw, -}; - -static const struct iio_info tsl2563_info = { - .driver_module = THIS_MODULE, - .read_raw = &tsl2563_read_raw, - .write_raw = &tsl2563_write_raw, - .read_event_value = &tsl2563_read_thresh, - .write_event_value = &tsl2563_write_thresh, - .read_event_config = &tsl2563_read_interrupt_config, - .write_event_config = &tsl2563_write_interrupt_config, -}; - -static int tsl2563_probe(struct i2c_client *client, - const struct i2c_device_id *device_id) -{ - struct iio_dev *indio_dev; - struct tsl2563_chip *chip; - struct tsl2563_platform_data *pdata = client->dev.platform_data; - int err = 0; - u8 id = 0; - - indio_dev = iio_device_alloc(sizeof(*chip)); - if (!indio_dev) - return -ENOMEM; - - chip = iio_priv(indio_dev); - - i2c_set_clientdata(client, chip); - chip->client = client; - - err = tsl2563_detect(chip); - if (err) { - dev_err(&client->dev, "detect error %d\n", -err); - goto fail1; - } - - err = tsl2563_read_id(chip, &id); - if (err) { - dev_err(&client->dev, "read id error %d\n", -err); - goto fail1; - } - - mutex_init(&chip->lock); - - /* Default values used until userspace says otherwise */ - chip->low_thres = 0x0; - chip->high_thres = 0xffff; - chip->gainlevel = tsl2563_gainlevel_table; - chip->intr = TSL2563_INT_PERSIST(4); - chip->calib0 = calib_from_sysfs(CALIB_BASE_SYSFS); - chip->calib1 = calib_from_sysfs(CALIB_BASE_SYSFS); - - if (pdata) - chip->cover_comp_gain = pdata->cover_comp_gain; - else - chip->cover_comp_gain = 1; - - dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f); - indio_dev->name = client->name; - indio_dev->channels = tsl2563_channels; - indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); - indio_dev->dev.parent = &client->dev; - indio_dev->modes = INDIO_DIRECT_MODE; - - if (client->irq) - indio_dev->info = &tsl2563_info; - else - indio_dev->info = &tsl2563_info_no_irq; - - if (client->irq) { - err = request_threaded_irq(client->irq, - NULL, - &tsl2563_event_handler, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "tsl2563_event", - indio_dev); - if (err) { - dev_err(&client->dev, "irq request error %d\n", -err); - goto fail1; - } - } - - err = tsl2563_configure(chip); - if (err) { - dev_err(&client->dev, "configure error %d\n", -err); - goto fail2; - } - - INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work); - - /* The interrupt cannot yet be enabled so this is fine without lock */ - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); - - err = iio_device_register(indio_dev); - if (err) { - dev_err(&client->dev, "iio registration error %d\n", -err); - goto fail3; - } - - return 0; - -fail3: - cancel_delayed_work(&chip->poweroff_work); - flush_scheduled_work(); -fail2: - if (client->irq) - free_irq(client->irq, indio_dev); -fail1: - iio_device_free(indio_dev); - return err; -} - -static int tsl2563_remove(struct i2c_client *client) -{ - struct tsl2563_chip *chip = i2c_get_clientdata(client); - struct iio_dev *indio_dev = iio_priv_to_dev(chip); - - iio_device_unregister(indio_dev); - if (!chip->int_enabled) - cancel_delayed_work(&chip->poweroff_work); - /* Ensure that interrupts are disabled - then flush any bottom halves */ - chip->intr &= ~0x30; - i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | TSL2563_REG_INT, - chip->intr); - flush_scheduled_work(); - tsl2563_set_power(chip, 0); - if (client->irq) - free_irq(client->irq, indio_dev); - - iio_device_free(indio_dev); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int tsl2563_suspend(struct device *dev) -{ - struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev)); - int ret; - - mutex_lock(&chip->lock); - - ret = tsl2563_set_power(chip, 0); - if (ret) - goto out; - - chip->suspended = true; - -out: - mutex_unlock(&chip->lock); - return ret; -} - -static int tsl2563_resume(struct device *dev) -{ - struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev)); - int ret; - - mutex_lock(&chip->lock); - - ret = tsl2563_set_power(chip, 1); - if (ret) - goto out; - - ret = tsl2563_configure(chip); - if (ret) - goto out; - - chip->suspended = false; - -out: - mutex_unlock(&chip->lock); - return ret; -} - -static SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend, tsl2563_resume); -#define TSL2563_PM_OPS (&tsl2563_pm_ops) -#else -#define TSL2563_PM_OPS NULL -#endif - -static const struct i2c_device_id tsl2563_id[] = { - { "tsl2560", 0 }, - { "tsl2561", 1 }, - { "tsl2562", 2 }, - { "tsl2563", 3 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, tsl2563_id); - -static struct i2c_driver tsl2563_i2c_driver = { - .driver = { - .name = "tsl2563", - .pm = TSL2563_PM_OPS, - }, - .probe = tsl2563_probe, - .remove = tsl2563_remove, - .id_table = tsl2563_id, -}; -module_i2c_driver(tsl2563_i2c_driver); - -MODULE_AUTHOR("Nokia Corporation"); -MODULE_DESCRIPTION("tsl2563 light sensor driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/iio/light/tsl2563.h b/drivers/staging/iio/light/tsl2563.h deleted file mode 100644 index b97368b..0000000 --- a/drivers/staging/iio/light/tsl2563.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __LINUX_TSL2563_H -#define __LINUX_TSL2563_H - -struct tsl2563_platform_data { - int cover_comp_gain; -}; - -#endif /* __LINUX_TSL2563_H */ - diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index 9e50fbb..a58731e 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -292,59 +292,6 @@ static const u8 device_channel_config[] = { }; /** - * tsl2x7x_parse_buffer() - parse a decimal result from a buffer. - * @*buf: pointer to char buffer to parse - * @*result: pointer to buffer to contain - * resulting interger / decimal as ints. - * - */ -static int -tsl2x7x_parse_buffer(const char *buf, struct tsl2x7x_parse_result *result) -{ - int integer = 0, fract = 0, fract_mult = 100000; - bool integer_part = true, negative = false; - - if (buf[0] == '-') { - negative = true; - buf++; - } - - while (*buf) { - if ('0' <= *buf && *buf <= '9') { - if (integer_part) - integer = integer*10 + *buf - '0'; - else { - fract += fract_mult*(*buf - '0'); - if (fract_mult == 1) - break; - fract_mult /= 10; - } - } else if (*buf == '\n') { - if (*(buf + 1) == '\0') - break; - else - return -EINVAL; - } else if (*buf == '.') { - integer_part = false; - } else { - return -EINVAL; - } - buf++; - } - if (negative) { - if (integer) - integer = -integer; - else - fract = -fract; - } - - result->integer = integer; - result->fract = fract; - - return 0; -} - -/** * tsl2x7x_i2c_read() - Read a byte from a register. * @client: i2c client * @reg: device register to read from @@ -1036,13 +983,12 @@ static ssize_t tsl2x7x_als_time_store(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2x7x_parse_result result; + int ret; - result.integer = 0; - result.fract = 0; - - tsl2x7x_parse_buffer(buf, &result); + ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); + if (ret) + return ret; - result.fract /= 1000; result.fract /= 3; chip->tsl2x7x_settings.als_time = (TSL2X7X_MAX_TIMER_CNT - (u8)result.fract); @@ -1109,12 +1055,12 @@ static ssize_t tsl2x7x_als_persistence_store(struct device *dev, struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2x7x_parse_result result; int y, z, filter_delay; + int ret; - result.integer = 0; - result.fract = 0; - tsl2x7x_parse_buffer(buf, &result); + ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); + if (ret) + return ret; - result.fract /= 1000; y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1; z = y * TSL2X7X_MIN_ITIME; @@ -1155,12 +1101,12 @@ static ssize_t tsl2x7x_prox_persistence_store(struct device *dev, struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2x7x_parse_result result; int y, z, filter_delay; + int ret; - result.integer = 0; - result.fract = 0; - tsl2x7x_parse_buffer(buf, &result); + ret = iio_str_to_fixpoint(buf, 100, &result.integer, &result.fract); + if (ret) + return ret; - result.fract /= 1000; y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1; z = y * TSL2X7X_MIN_ITIME; diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig index d290d27..e53274b 100644 --- a/drivers/staging/iio/meter/Kconfig +++ b/drivers/staging/iio/meter/Kconfig @@ -21,7 +21,7 @@ config ADE7758 tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver" depends on SPI select IIO_TRIGGER if IIO_BUFFER - select IIO_SW_RING if IIO_BUFFER + select IIO_KFIFO_BUF if IIO_BUFFER help Say yes here to build support for Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC with Per Phase Information Driver. diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 51c3bde..e5943e2 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -103,7 +103,6 @@ static int ade7753_spi_read_reg_24(struct device *dev, u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7753_state *st = iio_priv(indio_dev); int ret; @@ -122,10 +121,7 @@ static int ade7753_spi_read_reg_24(struct device *dev, mutex_lock(&st->buf_lock); st->tx[0] = ADE7753_READ_REG(reg_address); - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X", reg_address); diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index b50c89e..7b6503b 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -103,7 +103,6 @@ static int ade7754_spi_read_reg_24(struct device *dev, u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7754_state *st = iio_priv(indio_dev); int ret; @@ -122,9 +121,7 @@ static int ade7754_spi_read_reg_24(struct device *dev, st->tx[2] = 0; st->tx[3] = 0; - spi_message_init(&msg); - spi_message_add_tail(xfers, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X", reg_address); diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 3454e51..53c68dc 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -47,7 +47,6 @@ static int ade7758_spi_write_reg_16(struct device *dev, u16 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7758_state *st = iio_priv(indio_dev); struct spi_transfer xfers[] = { @@ -63,9 +62,7 @@ static int ade7758_spi_write_reg_16(struct device *dev, st->tx[1] = (value >> 8) & 0xFF; st->tx[2] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(xfers, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); mutex_unlock(&st->buf_lock); return ret; @@ -76,7 +73,6 @@ static int ade7758_spi_write_reg_24(struct device *dev, u32 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7758_state *st = iio_priv(indio_dev); struct spi_transfer xfers[] = { @@ -93,9 +89,7 @@ static int ade7758_spi_write_reg_24(struct device *dev, st->tx[2] = (value >> 8) & 0xFF; st->tx[3] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(xfers, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); mutex_unlock(&st->buf_lock); return ret; @@ -105,7 +99,6 @@ int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7758_state *st = iio_priv(indio_dev); int ret; @@ -128,10 +121,7 @@ int ade7758_spi_read_reg_8(struct device *dev, st->tx[0] = ADE7758_READ_REG(reg_address); st->tx[1] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X", reg_address); @@ -148,7 +138,6 @@ static int ade7758_spi_read_reg_16(struct device *dev, u8 reg_address, u16 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7758_state *st = iio_priv(indio_dev); int ret; @@ -173,10 +162,7 @@ static int ade7758_spi_read_reg_16(struct device *dev, st->tx[1] = 0; st->tx[2] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X", reg_address); @@ -194,7 +180,6 @@ static int ade7758_spi_read_reg_24(struct device *dev, u8 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7758_state *st = iio_priv(indio_dev); int ret; @@ -219,10 +204,7 @@ static int ade7758_spi_read_reg_24(struct device *dev, st->tx[2] = 0; st->tx[3] = 0; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X", reg_address); diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index 4552a4c..b29e2d5 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -13,7 +13,7 @@ #include <asm/unaligned.h> #include <linux/iio/iio.h> -#include "../ring_sw.h" +#include <linux/iio/kfifo_buf.h> #include <linux/iio/trigger_consumer.h> #include "ade7758.h" @@ -119,7 +119,7 @@ static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = { void ade7758_unconfigure_ring(struct iio_dev *indio_dev) { iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->buffer); + iio_kfifo_free(indio_dev->buffer); } int ade7758_configure_ring(struct iio_dev *indio_dev) @@ -127,7 +127,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) struct ade7758_state *st = iio_priv(indio_dev); int ret = 0; - indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + indio_dev->buffer = iio_kfifo_allocate(indio_dev); if (!indio_dev->buffer) { ret = -ENOMEM; return ret; @@ -143,7 +143,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; - goto error_iio_sw_rb_free; + goto error_iio_kfifo_free; } indio_dev->modes |= INDIO_BUFFER_TRIGGERED; @@ -183,8 +183,8 @@ int ade7758_configure_ring(struct iio_dev *indio_dev) return 0; -error_iio_sw_rb_free: - iio_sw_rb_free(indio_dev->buffer); +error_iio_kfifo_free: + iio_kfifo_free(indio_dev->buffer); return ret; } diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 10b911b..17dc373 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -103,7 +103,6 @@ static int ade7759_spi_read_reg_40(struct device *dev, u8 reg_address, u64 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7759_state *st = iio_priv(indio_dev); int ret; @@ -120,9 +119,7 @@ static int ade7759_spi_read_reg_40(struct device *dev, st->tx[0] = ADE7759_READ_REG(reg_address); memset(&st->tx[1], 0 , 5); - spi_message_init(&msg); - spi_message_add_tail(xfers, &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem when reading 40 bit register 0x%02X", reg_address); diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c index f0984fa..a802cf2 100644 --- a/drivers/staging/iio/meter/ade7854-spi.c +++ b/drivers/staging/iio/meter/ade7854-spi.c @@ -20,7 +20,6 @@ static int ade7854_spi_write_reg_8(struct device *dev, u8 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); struct spi_transfer xfer = { @@ -35,9 +34,7 @@ static int ade7854_spi_write_reg_8(struct device *dev, st->tx[2] = reg_address & 0xFF; st->tx[3] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, &xfer, 1); mutex_unlock(&st->buf_lock); return ret; @@ -48,7 +45,6 @@ static int ade7854_spi_write_reg_16(struct device *dev, u16 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); struct spi_transfer xfer = { @@ -64,9 +60,7 @@ static int ade7854_spi_write_reg_16(struct device *dev, st->tx[3] = (value >> 8) & 0xFF; st->tx[4] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, &xfer, 1); mutex_unlock(&st->buf_lock); return ret; @@ -77,7 +71,6 @@ static int ade7854_spi_write_reg_24(struct device *dev, u32 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); struct spi_transfer xfer = { @@ -94,9 +87,7 @@ static int ade7854_spi_write_reg_24(struct device *dev, st->tx[4] = (value >> 8) & 0xFF; st->tx[5] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, &xfer, 1); mutex_unlock(&st->buf_lock); return ret; @@ -107,7 +98,6 @@ static int ade7854_spi_write_reg_32(struct device *dev, u32 value) { int ret; - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); struct spi_transfer xfer = { @@ -125,9 +115,7 @@ static int ade7854_spi_write_reg_32(struct device *dev, st->tx[5] = (value >> 8) & 0xFF; st->tx[6] = value & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, &xfer, 1); mutex_unlock(&st->buf_lock); return ret; @@ -137,7 +125,6 @@ static int ade7854_spi_read_reg_8(struct device *dev, u16 reg_address, u8 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); int ret; @@ -159,10 +146,7 @@ static int ade7854_spi_read_reg_8(struct device *dev, st->tx[1] = (reg_address >> 8) & 0xFF; st->tx[2] = reg_address & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->spi->dev, "problem when reading 8 bit register 0x%02X", reg_address); @@ -179,7 +163,6 @@ static int ade7854_spi_read_reg_16(struct device *dev, u16 reg_address, u16 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); int ret; @@ -200,10 +183,7 @@ static int ade7854_spi_read_reg_16(struct device *dev, st->tx[1] = (reg_address >> 8) & 0xFF; st->tx[2] = reg_address & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->spi->dev, "problem when reading 16 bit register 0x%02X", reg_address); @@ -220,7 +200,6 @@ static int ade7854_spi_read_reg_24(struct device *dev, u16 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); int ret; @@ -242,10 +221,7 @@ static int ade7854_spi_read_reg_24(struct device *dev, st->tx[1] = (reg_address >> 8) & 0xFF; st->tx[2] = reg_address & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->spi->dev, "problem when reading 24 bit register 0x%02X", reg_address); @@ -262,7 +238,6 @@ static int ade7854_spi_read_reg_32(struct device *dev, u16 reg_address, u32 *val) { - struct spi_message msg; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7854_state *st = iio_priv(indio_dev); int ret; @@ -284,10 +259,7 @@ static int ade7854_spi_read_reg_32(struct device *dev, st->tx[1] = (reg_address >> 8) & 0xFF; st->tx[2] = reg_address & 0xFF; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->spi, &msg); + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->spi->dev, "problem when reading 32 bit register 0x%02X", reg_address); diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ed07a34..53110b6 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -130,15 +130,12 @@ static int ad2s1210_config_read(struct ad2s1210_state *st, .rx_buf = st->rx, .tx_buf = st->tx, }; - struct spi_message msg; int ret = 0; ad2s1210_set_mode(MOD_CONFIG, st); - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); st->tx[0] = address | AD2S1210_MSB_IS_HIGH; st->tx[1] = AD2S1210_REG_FAULT; - ret = spi_sync(st->sdev, &msg); + ret = spi_sync_transfer(st->sdev, &xfer, 1); if (ret < 0) return ret; st->old_data = true; diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c deleted file mode 100644 index 3a45f9a..0000000 --- a/drivers/staging/iio/ring_sw.c +++ /dev/null @@ -1,366 +0,0 @@ -/* The industrial I/O simple minimally locked ring buffer. - * - * Copyright (c) 2008 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - */ - -#include <linux/slab.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/device.h> -#include <linux/workqueue.h> -#include <linux/sched.h> -#include <linux/poll.h> -#include "ring_sw.h" -#include <linux/iio/trigger.h> - -/** - * struct iio_sw_ring_buffer - software ring buffer - * @buf: generic ring buffer elements - * @data: the ring buffer memory - * @read_p: read pointer (oldest available) - * @write_p: write pointer - * @half_p: half buffer length behind write_p (event generation) - * @update_needed: flag to indicate change in size requested - * - * Note that the first element of all ring buffers must be a - * struct iio_buffer. -**/ -struct iio_sw_ring_buffer { - struct iio_buffer buf; - unsigned char *data; - unsigned char *read_p; - unsigned char *write_p; - /* used to act as a point at which to signal an event */ - unsigned char *half_p; - int update_needed; -}; - -#define iio_to_sw_ring(r) container_of(r, struct iio_sw_ring_buffer, buf) - -static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring, - int bytes_per_datum, int length) -{ - if ((length == 0) || (bytes_per_datum == 0)) - return -EINVAL; - __iio_update_buffer(&ring->buf, bytes_per_datum, length); - ring->data = kmalloc(length*ring->buf.bytes_per_datum, GFP_ATOMIC); - ring->read_p = NULL; - ring->write_p = NULL; - ring->half_p = NULL; - return ring->data ? 0 : -ENOMEM; -} - -static inline void __iio_free_sw_ring_buffer(struct iio_sw_ring_buffer *ring) -{ - kfree(ring->data); -} - -/* Ring buffer related functionality */ -/* Store to ring is typically called in the bh of a data ready interrupt handler - * in the device driver */ -/* Lock always held if their is a chance this may be called */ -/* Only one of these per ring may run concurrently - enforced by drivers */ -static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring, - unsigned char *data) -{ - int ret = 0; - unsigned char *temp_ptr, *change_test_ptr; - - /* initial store */ - if (unlikely(ring->write_p == NULL)) { - ring->write_p = ring->data; - /* Doesn't actually matter if this is out of the set - * as long as the read pointer is valid before this - * passes it - guaranteed as set later in this function. - */ - ring->half_p = ring->data - ring->buf.length*ring->buf.bytes_per_datum/2; - } - /* Copy data to where ever the current write pointer says */ - memcpy(ring->write_p, data, ring->buf.bytes_per_datum); - barrier(); - /* Update the pointer used to get most recent value. - * Always valid as either points to latest or second latest value. - * Before this runs it is null and read attempts fail with -EAGAIN. - */ - barrier(); - /* temp_ptr used to ensure we never have an invalid pointer - * it may be slightly lagging, but never invalid - */ - temp_ptr = ring->write_p + ring->buf.bytes_per_datum; - /* End of ring, back to the beginning */ - if (temp_ptr == ring->data + ring->buf.length*ring->buf.bytes_per_datum) - temp_ptr = ring->data; - /* Update the write pointer - * always valid as long as this is the only function able to write. - * Care needed with smp systems to ensure more than one ring fill - * is never scheduled. - */ - ring->write_p = temp_ptr; - - if (ring->read_p == NULL) - ring->read_p = ring->data; - /* Buffer full - move the read pointer and create / escalate - * ring event */ - /* Tricky case - if the read pointer moves before we adjust it. - * Handle by not pushing if it has moved - may result in occasional - * unnecessary buffer full events when it wasn't quite true. - */ - else if (ring->write_p == ring->read_p) { - change_test_ptr = ring->read_p; - temp_ptr = change_test_ptr + ring->buf.bytes_per_datum; - if (temp_ptr - == ring->data + ring->buf.length*ring->buf.bytes_per_datum) { - temp_ptr = ring->data; - } - /* We are moving pointer on one because the ring is full. Any - * change to the read pointer will be this or greater. - */ - if (change_test_ptr == ring->read_p) - ring->read_p = temp_ptr; - } - /* investigate if our event barrier has been passed */ - /* There are definite 'issues' with this and chances of - * simultaneous read */ - /* Also need to use loop count to ensure this only happens once */ - ring->half_p += ring->buf.bytes_per_datum; - if (ring->half_p == ring->data + ring->buf.length*ring->buf.bytes_per_datum) - ring->half_p = ring->data; - if (ring->half_p == ring->read_p) { - ring->buf.stufftoread = true; - wake_up_interruptible(&ring->buf.pollq); - } - return ret; -} - -static int iio_read_first_n_sw_rb(struct iio_buffer *r, - size_t n, char __user *buf) -{ - struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); - - u8 *initial_read_p, *initial_write_p, *current_read_p, *end_read_p; - u8 *data; - int ret, max_copied, bytes_to_rip, dead_offset; - size_t data_available, buffer_size; - - /* A userspace program has probably made an error if it tries to - * read something that is not a whole number of bpds. - * Return an error. - */ - if (n % ring->buf.bytes_per_datum) { - ret = -EINVAL; - printk(KERN_INFO "Ring buffer read request not whole number of" - "samples: Request bytes %zd, Current bytes per datum %d\n", - n, ring->buf.bytes_per_datum); - goto error_ret; - } - - buffer_size = ring->buf.bytes_per_datum*ring->buf.length; - - /* Limit size to whole of ring buffer */ - bytes_to_rip = min_t(size_t, buffer_size, n); - - data = kmalloc(bytes_to_rip, GFP_KERNEL); - if (data == NULL) { - ret = -ENOMEM; - goto error_ret; - } - - /* build local copy */ - initial_read_p = ring->read_p; - if (unlikely(initial_read_p == NULL)) { /* No data here as yet */ - ret = 0; - goto error_free_data_cpy; - } - - initial_write_p = ring->write_p; - - /* Need a consistent pair */ - while ((initial_read_p != ring->read_p) - || (initial_write_p != ring->write_p)) { - initial_read_p = ring->read_p; - initial_write_p = ring->write_p; - } - if (initial_write_p == initial_read_p) { - /* No new data available.*/ - ret = 0; - goto error_free_data_cpy; - } - - if (initial_write_p >= initial_read_p) - data_available = initial_write_p - initial_read_p; - else - data_available = buffer_size - (initial_read_p - initial_write_p); - - if (data_available < bytes_to_rip) - bytes_to_rip = data_available; - - if (initial_read_p + bytes_to_rip >= ring->data + buffer_size) { - max_copied = ring->data + buffer_size - initial_read_p; - memcpy(data, initial_read_p, max_copied); - memcpy(data + max_copied, ring->data, bytes_to_rip - max_copied); - end_read_p = ring->data + bytes_to_rip - max_copied; - } else { - memcpy(data, initial_read_p, bytes_to_rip); - end_read_p = initial_read_p + bytes_to_rip; - } - - /* Now to verify which section was cleanly copied - i.e. how far - * read pointer has been pushed */ - current_read_p = ring->read_p; - - if (initial_read_p <= current_read_p) - dead_offset = current_read_p - initial_read_p; - else - dead_offset = buffer_size - (initial_read_p - current_read_p); - - /* possible issue if the initial write has been lapped or indeed - * the point we were reading to has been passed */ - /* No valid data read. - * In this case the read pointer is already correct having been - * pushed further than we would look. */ - if (bytes_to_rip - dead_offset < 0) { - ret = 0; - goto error_free_data_cpy; - } - - /* setup the next read position */ - /* Beware, this may fail due to concurrency fun and games. - * Possible that sufficient fill commands have run to push the read - * pointer past where we would be after the rip. If this occurs, leave - * it be. - */ - /* Tricky - deal with loops */ - - while (ring->read_p != end_read_p) - ring->read_p = end_read_p; - - ret = bytes_to_rip - dead_offset; - - if (copy_to_user(buf, data + dead_offset, ret)) { - ret = -EFAULT; - goto error_free_data_cpy; - } - - if (bytes_to_rip >= ring->buf.length*ring->buf.bytes_per_datum/2) - ring->buf.stufftoread = 0; - -error_free_data_cpy: - kfree(data); -error_ret: - - return ret; -} - -static int iio_store_to_sw_rb(struct iio_buffer *r, - u8 *data) -{ - struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); - return iio_store_to_sw_ring(ring, data); -} - -static int iio_request_update_sw_rb(struct iio_buffer *r) -{ - int ret = 0; - struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); - - r->stufftoread = false; - if (!ring->update_needed) - goto error_ret; - __iio_free_sw_ring_buffer(ring); - ret = __iio_allocate_sw_ring_buffer(ring, ring->buf.bytes_per_datum, - ring->buf.length); -error_ret: - return ret; -} - -static int iio_get_bytes_per_datum_sw_rb(struct iio_buffer *r) -{ - struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); - return ring->buf.bytes_per_datum; -} - -static int iio_mark_update_needed_sw_rb(struct iio_buffer *r) -{ - struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); - ring->update_needed = true; - return 0; -} - -static int iio_set_bytes_per_datum_sw_rb(struct iio_buffer *r, size_t bpd) -{ - if (r->bytes_per_datum != bpd) { - r->bytes_per_datum = bpd; - iio_mark_update_needed_sw_rb(r); - } - return 0; -} - -static int iio_get_length_sw_rb(struct iio_buffer *r) -{ - return r->length; -} - -static int iio_set_length_sw_rb(struct iio_buffer *r, int length) -{ - if (r->length != length) { - r->length = length; - iio_mark_update_needed_sw_rb(r); - } - return 0; -} - -static IIO_BUFFER_ENABLE_ATTR; -static IIO_BUFFER_LENGTH_ATTR; - -/* Standard set of ring buffer attributes */ -static struct attribute *iio_ring_attributes[] = { - &dev_attr_length.attr, - &dev_attr_enable.attr, - NULL, -}; - -static struct attribute_group iio_ring_attribute_group = { - .attrs = iio_ring_attributes, - .name = "buffer", -}; - -static const struct iio_buffer_access_funcs ring_sw_access_funcs = { - .store_to = &iio_store_to_sw_rb, - .read_first_n = &iio_read_first_n_sw_rb, - .request_update = &iio_request_update_sw_rb, - .get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb, - .set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb, - .get_length = &iio_get_length_sw_rb, - .set_length = &iio_set_length_sw_rb, -}; - -struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) -{ - struct iio_buffer *buf; - struct iio_sw_ring_buffer *ring; - - ring = kzalloc(sizeof *ring, GFP_KERNEL); - if (!ring) - return NULL; - ring->update_needed = true; - buf = &ring->buf; - iio_buffer_init(buf); - buf->attrs = &iio_ring_attribute_group; - buf->access = &ring_sw_access_funcs; - - return buf; -} -EXPORT_SYMBOL(iio_sw_rb_allocate); - -void iio_sw_rb_free(struct iio_buffer *r) -{ - kfree(iio_to_sw_ring(r)); -} -EXPORT_SYMBOL(iio_sw_rb_free); - -MODULE_DESCRIPTION("Industrial I/O software ring buffer"); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h deleted file mode 100644 index a5857aa..0000000 --- a/drivers/staging/iio/ring_sw.h +++ /dev/null @@ -1,30 +0,0 @@ -/* The industrial I/O simple minimally locked ring buffer. - * - * Copyright (c) 2008 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This code is deliberately kept separate from the main industrialio I/O core - * as it is intended that in the future a number of different software ring - * buffer implementations will exist with different characteristics to suit - * different applications. - * - * This particular one was designed for a data capture application where it was - * particularly important that no userspace reads would interrupt the capture - * process. To this end the ring is not locked during a read. - * - * Comments on this buffer design welcomed. It's far from efficient and some of - * my understanding of the effects of scheduling on this are somewhat limited. - * Frankly, to my mind, this is the current weak point in the industrial I/O - * patch set. - */ - -#ifndef _IIO_RING_SW_H_ -#define _IIO_RING_SW_H_ -#include <linux/iio/buffer.h> - -struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev); -void iio_sw_rb_free(struct iio_buffer *ring); -#endif /* _IIO_RING_SW_H_ */ diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index f7059cd..366f259 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -1142,9 +1142,6 @@ failed_ioremap: static int ipu_remove(struct platform_device *pdev) { struct ipu_soc *ipu = platform_get_drvdata(pdev); - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); platform_device_unregister_children(pdev); ipu_submodules_exit(ipu); diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 67d974f..ec340da 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -677,7 +677,7 @@ int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id, goto failed_clk_register; } - dev_info(dev, "DI%d base: 0x%08lx remapped to %p\n", + dev_dbg(dev, "DI%d base: 0x%08lx remapped to %p\n", id, base, di->base); di->inuse = false; di->ipu = ipu; diff --git a/drivers/staging/keucr/usb.c b/drivers/staging/keucr/usb.c index 55a0b82..f656f8a 100644 --- a/drivers/staging/keucr/usb.c +++ b/drivers/staging/keucr/usb.c @@ -42,19 +42,12 @@ static int eucr_suspend(struct usb_interface *iface, pm_message_t message) /* Wait until no command is running */ mutex_lock(&us->dev_mutex); - //US_DEBUGP("%s\n", __func__); if (us->suspend_resume_hook) (us->suspend_resume_hook)(us, US_SUSPEND); - /* When runtime PM is working, we'll set a flag to indicate - * whether we should autoresume when a SCSI request arrives. */ - // us->Power_IsResum = true; - //us->SD_Status.Ready = 0; - mutex_unlock(&us->dev_mutex); return 0; } -//EXPORT_SYMBOL_GPL(eucr_suspend); static int eucr_resume(struct usb_interface *iface) { @@ -64,43 +57,40 @@ static int eucr_resume(struct usb_interface *iface) pr_info("--- eucr_resume---\n"); mutex_lock(&us->dev_mutex); - //US_DEBUGP("%s\n", __func__); if (us->suspend_resume_hook) (us->suspend_resume_hook)(us, US_RESUME); mutex_unlock(&us->dev_mutex); - - us->Power_IsResum = true; - // - //us->SD_Status.Ready = 0; //?? - us->SM_Status = *(PSM_STATUS)&tmp; - + us->Power_IsResum = true; + + us->SM_Status = *(PSM_STATUS)&tmp; + return 0; } -//EXPORT_SYMBOL_GPL(eucr_resume); + static int eucr_reset_resume(struct usb_interface *iface) { BYTE tmp = 0; struct us_data *us = usb_get_intfdata(iface); pr_info("--- eucr_reset_resume---\n"); - //US_DEBUGP("%s\n", __func__); /* Report the reset to the SCSI core */ usb_stor_report_bus_reset(us); - /* FIXME: Notify the subdrivers that they need to reinitialize - * the device */ - //ENE_InitMedia(us); + /* + * FIXME: Notify the subdrivers that they need to reinitialize + * the device + */ + us->Power_IsResum = true; - // - //us->SD_Status.Ready = 0; //?? - us->SM_Status = *(PSM_STATUS)&tmp; + + us->SM_Status = *(PSM_STATUS)&tmp; + return 0; } -//EXPORT_SYMBOL_GPL(usb_stor_reset_resume); #else @@ -110,7 +100,6 @@ static int eucr_reset_resume(struct usb_interface *iface) #endif -//----- eucr_pre_reset() --------------------- static int eucr_pre_reset(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); @@ -122,7 +111,6 @@ static int eucr_pre_reset(struct usb_interface *iface) return 0; } -//----- eucr_post_reset() --------------------- static int eucr_post_reset(struct usb_interface *iface) { struct us_data *us = usb_get_intfdata(iface); @@ -136,19 +124,15 @@ static int eucr_post_reset(struct usb_interface *iface) return 0; } -//----- fill_inquiry_response() --------------------- void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len) { pr_info("usb --- fill_inquiry_response\n"); - if (data_len<36) // You lose. + if (data_len < 36) /* You lose. */ return; - if (data[0]&0x20) - { + if (data[0]&0x20) { memset(data+8,0,28); - } - else - { + } else { u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); memcpy(data+8, us->unusual_dev->vendorName, strlen(us->unusual_dev->vendorName) > 8 ? 8 : @@ -164,18 +148,16 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF); } -//----- usb_stor_control_thread() --------------------- static int usb_stor_control_thread(void * __us) { struct us_data *us = (struct us_data *)__us; struct Scsi_Host *host = us_to_host(us); pr_info("usb --- usb_stor_control_thread\n"); - for(;;) - { + for (;;) { if (wait_for_completion_interruptible(&us->cmnd_ready)) break; - + /* lock the device pointers */ mutex_lock(&(us->dev_mutex)); @@ -189,44 +171,34 @@ static int usb_stor_control_thread(void * __us) scsi_lock(host); /* When we are called with no command pending, we're done */ - if (us->srb == NULL) - { + if (us->srb == NULL) { scsi_unlock(host); mutex_unlock(&us->dev_mutex); - //US_DEBUGP("-- exiting\n"); break; } /* has the command timed out *already* ? */ - if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) - { + if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { us->srb->result = DID_ABORT << 16; goto SkipForAbort; } scsi_unlock(host); - if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) - { + if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { us->srb->result = DID_ERROR << 16; - } - else if (us->srb->device->id && !(us->fflags & US_FL_SCM_MULT_TARG)) - { + } else if (us->srb->device->id + && !(us->fflags & US_FL_SCM_MULT_TARG)) { us->srb->result = DID_BAD_TARGET << 16; - } - else if (us->srb->device->lun > us->max_lun) - { + } else if (us->srb->device->lun > us->max_lun) { us->srb->result = DID_BAD_TARGET << 16; - } - else if ((us->srb->cmnd[0] == INQUIRY) && (us->fflags & US_FL_FIX_INQUIRY)) - { + } else if ((us->srb->cmnd[0] == INQUIRY) + && (us->fflags & US_FL_FIX_INQUIRY)) { unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00}; fill_inquiry_response(us, data_ptr, 36); us->srb->result = SAM_STAT_GOOD; - } - else - { + } else { us->proto_handler(us->srb, us); } @@ -234,18 +206,14 @@ static int usb_stor_control_thread(void * __us) scsi_lock(host); /* indicate that the command is done */ - if (us->srb->result != DID_ABORT << 16) - { + if (us->srb->result != DID_ABORT << 16) { us->srb->scsi_done(us->srb); - } - else - { + } else { SkipForAbort: pr_info("scsi command aborted\n"); } - if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) - { + if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { complete(&(us->notify)); /* Allow USB transfers to resume */ @@ -262,8 +230,7 @@ SkipForAbort: } /* for (;;) */ /* Wait until we are told to stop */ - for (;;) - { + for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (kthread_should_stop()) break; @@ -271,9 +238,8 @@ SkipForAbort: } __set_current_state(TASK_RUNNING); return 0; -} +} -//----- associate_dev() --------------------- static int associate_dev(struct us_data *us, struct usb_interface *intf) { pr_info("usb --- associate_dev\n"); @@ -288,29 +254,24 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) /* Allocate the device-related DMA-mapped buffers */ us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma); - if (!us->cr) - { + if (!us->cr) { pr_info("usb_ctrlrequest allocation failed\n"); return -ENOMEM; } us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma); - if (!us->iobuf) - { + if (!us->iobuf) { pr_info("I/O buffer allocation failed\n"); return -ENOMEM; } us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL); if (!us->sensebuf) - { - pr_info("Sense buffer allocation failed\n"); return -ENOMEM; - } + return 0; } -//----- get_device_info() --------------------- static int get_device_info(struct us_data *us, const struct usb_device_id *id) { struct usb_device *dev = us->pusb_dev; @@ -323,8 +284,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id) us->fflags = id->driver_info; us->Power_IsResum = false; - if (us->fflags & US_FL_IGNORE_DEVICE) - { + if (us->fflags & US_FL_IGNORE_DEVICE) { pr_info("device ignored\n"); return -ENODEV; } @@ -335,7 +295,6 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id) return 0; } -//----- get_transport() --------------------- static int get_transport(struct us_data *us) { pr_info("usb --- get_transport\n"); @@ -349,7 +308,6 @@ static int get_transport(struct us_data *us) default: return -EIO; } - /* pr_info("Transport: %s\n", us->transport_name); */ /* fix for single-lun devices */ if (us->fflags & US_FL_SINGLE_LUN) @@ -357,7 +315,6 @@ static int get_transport(struct us_data *us) return 0; } -//----- get_protocol() --------------------- static int get_protocol(struct us_data *us) { pr_info("usb --- get_protocol\n"); @@ -368,7 +325,8 @@ static int get_protocol(struct us_data *us) switch (us->subclass) { case USB_SC_SCSI: us->protocol_name = "Transparent SCSI"; - if( (us->pusb_dev->descriptor.idVendor == 0x0CF2) && (us->pusb_dev->descriptor.idProduct == 0x6250) ) + if ((us->pusb_dev->descriptor.idVendor == 0x0CF2) + && (us->pusb_dev->descriptor.idProduct == 0x6250)) us->proto_handler = ENE_stor_invoke_transport; else us->proto_handler = usb_stor_invoke_transport; @@ -377,11 +335,9 @@ static int get_protocol(struct us_data *us) default: return -EIO; } - /* pr_info("Protocol: %s\n", us->protocol_name); */ return 0; } -//----- get_pipes() --------------------- static int get_pipes(struct us_data *us) { struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; @@ -393,32 +349,24 @@ static int get_pipes(struct us_data *us) pr_info("usb --- get_pipes\n"); - for (i = 0; i < altsetting->desc.bNumEndpoints; i++) - { + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { ep = &altsetting->endpoint[i].desc; - if (usb_endpoint_xfer_bulk(ep)) - { - if (usb_endpoint_dir_in(ep)) - { + if (usb_endpoint_xfer_bulk(ep)) { + if (usb_endpoint_dir_in(ep)) { if (!ep_in) ep_in = ep; - } - else - { + } else { if (!ep_out) ep_out = ep; } - } - else if (usb_endpoint_is_int_in(ep)) - { + } else if (usb_endpoint_is_int_in(ep)) { if (!ep_int) ep_int = ep; } } - if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) - { + if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { pr_info("Endpoint sanity check failed! Rejecting dev.\n"); return -EIO; } @@ -428,31 +376,27 @@ static int get_pipes(struct us_data *us) us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - if (ep_int) - { + if (ep_int) { us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); us->ep_bInterval = ep_int->bInterval; } return 0; } -//----- usb_stor_acquire_resources() --------------------- static int usb_stor_acquire_resources(struct us_data *us) { struct task_struct *th; pr_info("usb --- usb_stor_acquire_resources\n"); us->current_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!us->current_urb) - { + if (!us->current_urb) { pr_info("URB allocation failed\n"); return -ENOMEM; } /* Start up our control thread */ th = kthread_run(usb_stor_control_thread, us, "eucr-storage"); - if (IS_ERR(th)) - { + if (IS_ERR(th)) { pr_info("Unable to start control thread\n"); return PTR_ERR(th); } @@ -461,7 +405,6 @@ static int usb_stor_acquire_resources(struct us_data *us) return 0; } -//----- usb_stor_release_resources() --------------------- static void usb_stor_release_resources(struct us_data *us) { pr_info("usb --- usb_stor_release_resources\n"); @@ -473,8 +416,7 @@ static void usb_stor_release_resources(struct us_data *us) kthread_stop(us->ctl_thread); /* Call the destructor routine, if it exists */ - if (us->extra_destructor) - { + if (us->extra_destructor) { pr_info("-- calling extra_destructor()\n"); us->extra_destructor(us->extra); } @@ -484,7 +426,6 @@ static void usb_stor_release_resources(struct us_data *us) usb_free_urb(us->current_urb); } -//----- dissociate_dev() --------------------- static void dissociate_dev(struct us_data *us) { pr_info("usb --- dissociate_dev\n"); @@ -501,7 +442,6 @@ static void dissociate_dev(struct us_data *us) usb_set_intfdata(us->pusb_intf, NULL); } -//----- quiesce_and_remove_host() --------------------- static void quiesce_and_remove_host(struct us_data *us) { struct Scsi_Host *host = us_to_host(us); @@ -512,19 +452,22 @@ static void quiesce_and_remove_host(struct us_data *us) if (us->pusb_dev->state == USB_STATE_NOTATTACHED) set_bit(US_FLIDX_DISCONNECTING, &us->dflags); - /* Prevent SCSI-scanning (if it hasn't started yet) + /* + * Prevent SCSI-scanning (if it hasn't started yet) * and wait for the SCSI-scanning thread to stop. */ set_bit(US_FLIDX_DONT_SCAN, &us->dflags); wake_up(&us->delay_wait); wait_for_completion(&us->scanning_done); - /* Removing the host will perform an orderly shutdown: caches + /* + * Removing the host will perform an orderly shutdown: caches * synchronized, disks spun down, etc. */ scsi_remove_host(host); - /* Prevent any new commands from being accepted and cut short + /* + * Prevent any new commands from being accepted and cut short * reset delays. */ scsi_lock(host); @@ -533,7 +476,6 @@ static void quiesce_and_remove_host(struct us_data *us) wake_up(&us->delay_wait); } -//----- release_everything() --------------------- static void release_everything(struct us_data *us) { pr_info("usb --- release_everything\n"); @@ -543,7 +485,6 @@ static void release_everything(struct us_data *us) scsi_host_put(us_to_host(us)); } -//----- usb_stor_scan_thread() --------------------- static int usb_stor_scan_thread(void * __us) { struct us_data *us = (struct us_data *)__us; @@ -560,11 +501,10 @@ static int usb_stor_scan_thread(void * __us) } /* If the device is still connected, perform the scanning */ - if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) - { + if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) { /* For bulk-only devices, determine the max LUN value */ - if (us->protocol == USB_PR_BULK && !(us->fflags & US_FL_SINGLE_LUN)) - { + if (us->protocol == USB_PR_BULK + && !(us->fflags & US_FL_SINGLE_LUN)) { mutex_lock(&us->dev_mutex); us->max_lun = usb_stor_Bulk_max_lun(us); mutex_unlock(&us->dev_mutex); @@ -575,7 +515,6 @@ static int usb_stor_scan_thread(void * __us) complete_and_exit(&us->scanning_done, 0); } -//----- eucr_probe() --------------------- static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct Scsi_Host *host; @@ -587,8 +526,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id pr_info("usb --- eucr_probe\n"); host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); - if (!host) - { + if (!host) { pr_info("Unable to allocate the scsi host\n"); return -ENOMEM; } @@ -630,8 +568,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id goto BadDevice; result = scsi_add_host(host, &intf->dev); - if (result) - { + if (result) { pr_info("Unable to add the scsi host\n"); goto BadDevice; } @@ -673,7 +610,6 @@ BadDevice: return result; } -//----- eucr_disconnect() --------------------- static void eucr_disconnect(struct usb_interface *intf) { struct us_data *us = usb_get_intfdata(intf); @@ -683,11 +619,7 @@ static void eucr_disconnect(struct usb_interface *intf) release_everything(us); } -/*********************************************************************** - * Initialization and registration - ***********************************************************************/ - -//----- usb_storage_driver() --------------------- +/* Initialization and registration */ static struct usb_driver usb_storage_driver = { .name = "eucr", .probe = eucr_probe, diff --git a/drivers/staging/line6/Kconfig b/drivers/staging/line6/Kconfig index b635436..4f1219b 100644 --- a/drivers/staging/line6/Kconfig +++ b/drivers/staging/line6/Kconfig @@ -23,16 +23,6 @@ menuconfig LINE6_USB if LINE6_USB -config LINE6_USB_DUMP_PCM - bool "dump PCM data" - default n - help - Say Y here to write PCM data sent to and received from Line6 - devices to the syslog. This will produce a huge amount of - syslog data during playback and capture. - - If unsure, say N. - config LINE6_USB_IMPULSE_RESPONSE bool "measure impulse response" default n diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c index 389c41f..f8316b7 100644 --- a/drivers/staging/line6/capture.c +++ b/drivers/staging/line6/capture.c @@ -216,16 +216,6 @@ static void audio_in_callback(struct urb *urb) if (urb == line6pcm->urb_audio_in[index]) break; -#ifdef CONFIG_LINE6_USB_DUMP_PCM - for (i = 0; i < LINE6_ISO_PACKETS; ++i) { - struct usb_iso_packet_descriptor *fout = - &urb->iso_frame_desc[i]; - line6_write_hexdump(line6pcm->line6, 'C', - urb->transfer_buffer + fout->offset, - fout->length); - } -#endif - spin_lock_irqsave(&line6pcm->lock_audio_in, flags); for (i = 0; i < LINE6_ISO_PACKETS; ++i) { diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 1e4ce500..6252aca 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -135,47 +135,6 @@ static void line6_stop_listen(struct usb_line6 *line6) usb_kill_urb(line6->urb_listen); } -#ifdef CONFIG_LINE6_USB_DUMP_ANY -/* - Write hexdump to syslog. -*/ -void line6_write_hexdump(struct usb_line6 *line6, char dir, - const unsigned char *buffer, int size) -{ - static const int BYTES_PER_LINE = 8; - char hexdump[100]; - char asc[BYTES_PER_LINE + 1]; - int i, j; - - for (i = 0; i < size; i += BYTES_PER_LINE) { - int hexdumpsize = sizeof(hexdump); - char *p = hexdump; - int n = min(size - i, BYTES_PER_LINE); - asc[n] = 0; - - for (j = 0; j < BYTES_PER_LINE; ++j) { - int bytes; - - if (j < n) { - unsigned char val = buffer[i + j]; - bytes = snprintf(p, hexdumpsize, " %02X", val); - asc[j] = ((val >= 0x20) - && (val < 0x7f)) ? val : '.'; - } else - bytes = snprintf(p, hexdumpsize, " "); - - if (bytes > hexdumpsize) - break; /* buffer overflow */ - - p += bytes; - hexdumpsize -= bytes; - } - - dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc); - } -} -#endif - /* Send raw message in pieces of wMaxPacketSize bytes. */ @@ -274,11 +233,8 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, /* create message: */ msg = kmalloc(sizeof(struct message), GFP_ATOMIC); - - if (msg == NULL) { - dev_err(line6->ifcdev, "Out of memory\n"); + if (msg == NULL) return -ENOMEM; - } /* create URB: */ urb = usb_alloc_urb(0, GFP_ATOMIC); @@ -307,14 +263,13 @@ int line6_version_request_async(struct usb_line6 *line6) char *buffer; int retval; - buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC); + buffer = kmemdup(line6_request_version, + sizeof(line6_request_version), GFP_ATOMIC); if (buffer == NULL) { dev_err(line6->ifcdev, "Out of memory"); return -ENOMEM; } - memcpy(buffer, line6_request_version, sizeof(line6_request_version)); - retval = line6_send_raw_message_async(line6, buffer, sizeof(line6_request_version)); kfree(buffer); @@ -333,17 +288,6 @@ int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, } /* - Send sysex message in pieces of wMaxPacketSize bytes. -*/ -int line6_send_sysex_message_async(struct usb_line6 *line6, const char *buffer, - int size) -{ - return line6_send_raw_message_async(line6, buffer, - size + SYSEX_EXTRA_SIZE) - - SYSEX_EXTRA_SIZE; -} - -/* Allocate buffer for sysex message and prepare header. @param code sysex message code @param size number of bytes between code and sysex end @@ -353,10 +297,8 @@ char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, { char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC); - if (!buffer) { - dev_err(line6->ifcdev, "out of memory\n"); + if (!buffer) return NULL; - } buffer[0] = LINE6_SYSEX_BEGIN; memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id)); @@ -372,7 +314,7 @@ char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, static void line6_data_received(struct urb *urb) { struct usb_line6 *line6 = (struct usb_line6 *)urb->context; - struct MidiBuffer *mb = &line6->line6midi->midibuf_in; + struct midi_buffer *mb = &line6->line6midi->midibuf_in; int done; if (urb->status == -ESHUTDOWN) @@ -456,11 +398,8 @@ int line6_send_program(struct usb_line6 *line6, u8 value) int partial; buffer = kmalloc(2, GFP_KERNEL); - - if (!buffer) { - dev_err(line6->ifcdev, "out of memory\n"); + if (!buffer) return -ENOMEM; - } buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; buffer[1] = value; @@ -488,11 +427,8 @@ int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value) int partial; buffer = kmalloc(3, GFP_KERNEL); - - if (!buffer) { - dev_err(line6->ifcdev, "out of memory\n"); + if (!buffer) return -ENOMEM; - } buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; buffer[1] = param; @@ -532,7 +468,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, return ret; } - /* Wait for data length. We'll get a couple of 0xff until length arrives. */ + /* Wait for data length. We'll get 0xff until length arrives. */ do { ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | @@ -887,9 +823,7 @@ static int line6_probe(struct usb_interface *interface, } line6 = kzalloc(size, GFP_KERNEL); - if (line6 == NULL) { - dev_err(&interface->dev, "Out of memory\n"); ret = -ENODEV; goto err_put; } @@ -928,18 +862,14 @@ static int line6_probe(struct usb_interface *interface, /* initialize USB buffers: */ line6->buffer_listen = kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); - if (line6->buffer_listen == NULL) { - dev_err(&interface->dev, "Out of memory\n"); ret = -ENOMEM; goto err_destruct; } line6->buffer_message = kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); - if (line6->buffer_message == NULL) { - dev_err(&interface->dev, "Out of memory\n"); ret = -ENOMEM; goto err_destruct; } diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h index f0be5a2..a8341f9 100644 --- a/drivers/staging/line6/driver.h +++ b/drivers/staging/line6/driver.h @@ -20,10 +20,6 @@ #define DRIVER_NAME "line6usb" -#if defined(CONFIG_LINE6_USB_DUMP_PCM) -#define CONFIG_LINE6_USB_DUMP_ANY -#endif - #define LINE6_TIMEOUT 1 #define LINE6_BUFSIZE_LISTEN 32 #define LINE6_MESSAGE_MAXLEN 256 @@ -53,7 +49,7 @@ #define LINE6_CHANNEL_MASK 0x0f #define MISSING_CASE \ - printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \ + pr_err("line6usb driver bug: missing case in %s:%d\n", \ __FILE__, __LINE__) #define CHECK_RETURN(x) \ @@ -208,8 +204,6 @@ extern int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size); extern int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int size); -extern int line6_send_sysex_message_async(struct usb_line6 *line6, - const char *buffer, int size); extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); extern void line6_start_timer(struct timer_list *timer, unsigned int msecs, @@ -221,9 +215,4 @@ extern int line6_version_request_async(struct usb_line6 *line6); extern int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen); -#ifdef CONFIG_LINE6_USB_DUMP_ANY -extern void line6_write_hexdump(struct usb_line6 *line6, char dir, - const unsigned char *buffer, int size); -#endif - #endif diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c index 6982eca..e3f9a53 100644 --- a/drivers/staging/line6/midi.c +++ b/drivers/staging/line6/midi.c @@ -45,7 +45,7 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6; struct snd_line6_midi *line6midi = line6->line6midi; - struct MidiBuffer *mb = &line6midi->midibuf_out; + struct midi_buffer *mb = &line6midi->midibuf_out; unsigned long flags; unsigned char chunk[line6->max_packet_size]; int req, done; diff --git a/drivers/staging/line6/midi.h b/drivers/staging/line6/midi.h index 19dabd5..78f903f 100644 --- a/drivers/staging/line6/midi.h +++ b/drivers/staging/line6/midi.h @@ -57,12 +57,12 @@ struct snd_line6_midi { /** Buffer for incoming MIDI stream. */ - struct MidiBuffer midibuf_in; + struct midi_buffer midibuf_in; /** Buffer for outgoing MIDI stream. */ - struct MidiBuffer midibuf_out; + struct midi_buffer midibuf_out; }; extern int line6_init_midi(struct usb_line6 *line6); diff --git a/drivers/staging/line6/midibuf.c b/drivers/staging/line6/midibuf.c index 968e0de..f0adb7b 100644 --- a/drivers/staging/line6/midibuf.c +++ b/drivers/staging/line6/midibuf.c @@ -33,23 +33,23 @@ static int midibuf_message_length(unsigned char code) } } -static int midibuf_is_empty(struct MidiBuffer *this) +static int midibuf_is_empty(struct midi_buffer *this) { return (this->pos_read == this->pos_write) && !this->full; } -static int midibuf_is_full(struct MidiBuffer *this) +static int midibuf_is_full(struct midi_buffer *this) { return this->full; } -void line6_midibuf_reset(struct MidiBuffer *this) +void line6_midibuf_reset(struct midi_buffer *this) { this->pos_read = this->pos_write = this->full = 0; this->command_prev = -1; } -int line6_midibuf_init(struct MidiBuffer *this, int size, int split) +int line6_midibuf_init(struct midi_buffer *this, int size, int split) { this->buf = kmalloc(size, GFP_KERNEL); @@ -62,14 +62,14 @@ int line6_midibuf_init(struct MidiBuffer *this, int size, int split) return 0; } -void line6_midibuf_status(struct MidiBuffer *this) +void line6_midibuf_status(struct midi_buffer *this) { pr_debug("midibuf size=%d split=%d pos_read=%d pos_write=%d full=%d command_prev=%02x\n", this->size, this->split, this->pos_read, this->pos_write, this->full, this->command_prev); } -int line6_midibuf_bytes_free(struct MidiBuffer *this) +int line6_midibuf_bytes_free(struct midi_buffer *this) { return midibuf_is_full(this) ? @@ -78,7 +78,7 @@ int line6_midibuf_bytes_free(struct MidiBuffer *this) 1; } -int line6_midibuf_bytes_used(struct MidiBuffer *this) +int line6_midibuf_bytes_used(struct midi_buffer *this) { return midibuf_is_empty(this) ? @@ -87,7 +87,7 @@ int line6_midibuf_bytes_used(struct MidiBuffer *this) 1; } -int line6_midibuf_write(struct MidiBuffer *this, unsigned char *data, +int line6_midibuf_write(struct midi_buffer *this, unsigned char *data, int length) { int bytes_free; @@ -130,7 +130,8 @@ int line6_midibuf_write(struct MidiBuffer *this, unsigned char *data, return length + skip_active_sense; } -int line6_midibuf_read(struct MidiBuffer *this, unsigned char *data, int length) +int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, + int length) { int bytes_used; int length1, length2; @@ -234,7 +235,7 @@ int line6_midibuf_read(struct MidiBuffer *this, unsigned char *data, int length) return length + repeat; } -int line6_midibuf_ignore(struct MidiBuffer *this, int length) +int line6_midibuf_ignore(struct midi_buffer *this, int length) { int bytes_used = line6_midibuf_bytes_used(this); @@ -246,7 +247,7 @@ int line6_midibuf_ignore(struct MidiBuffer *this, int length) return length; } -int line6_midibuf_skip_message(struct MidiBuffer *this, unsigned short mask) +int line6_midibuf_skip_message(struct midi_buffer *this, unsigned short mask) { int cmd = this->command_prev; @@ -257,7 +258,7 @@ int line6_midibuf_skip_message(struct MidiBuffer *this, unsigned short mask) return 0; } -void line6_midibuf_destroy(struct MidiBuffer *this) +void line6_midibuf_destroy(struct midi_buffer *this) { kfree(this->buf); this->buf = NULL; diff --git a/drivers/staging/line6/midibuf.h b/drivers/staging/line6/midibuf.h index 444cb3a..707482b 100644 --- a/drivers/staging/line6/midibuf.h +++ b/drivers/staging/line6/midibuf.h @@ -12,7 +12,7 @@ #ifndef MIDIBUF_H #define MIDIBUF_H -struct MidiBuffer { +struct midi_buffer { unsigned char *buf; int size; int split; @@ -21,18 +21,18 @@ struct MidiBuffer { int command_prev; }; -extern int line6_midibuf_bytes_used(struct MidiBuffer *mb); -extern int line6_midibuf_bytes_free(struct MidiBuffer *mb); -extern void line6_midibuf_destroy(struct MidiBuffer *mb); -extern int line6_midibuf_ignore(struct MidiBuffer *mb, int length); -extern int line6_midibuf_init(struct MidiBuffer *mb, int size, int split); -extern int line6_midibuf_read(struct MidiBuffer *mb, unsigned char *data, +extern int line6_midibuf_bytes_used(struct midi_buffer *mb); +extern int line6_midibuf_bytes_free(struct midi_buffer *mb); +extern void line6_midibuf_destroy(struct midi_buffer *mb); +extern int line6_midibuf_ignore(struct midi_buffer *mb, int length); +extern int line6_midibuf_init(struct midi_buffer *mb, int size, int split); +extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data, int length); -extern void line6_midibuf_reset(struct MidiBuffer *mb); -extern int line6_midibuf_skip_message(struct MidiBuffer *mb, +extern void line6_midibuf_reset(struct midi_buffer *mb); +extern int line6_midibuf_skip_message(struct midi_buffer *mb, unsigned short mask); -extern void line6_midibuf_status(struct MidiBuffer *mb); -extern int line6_midibuf_write(struct MidiBuffer *mb, unsigned char *data, +extern void line6_midibuf_status(struct midi_buffer *mb); +extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data, int length); #endif diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 6c1e313..02f77d7 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -49,11 +49,11 @@ static ssize_t pcm_set_impulse_volume(struct device *dev, { struct snd_line6_pcm *line6pcm = dev2pcm(dev); int value; - int rv; + int ret; - rv = kstrtoint(buf, 10, &value); - if (rv < 0) - return rv; + ret = kstrtoint(buf, 10, &value); + if (ret < 0) + return ret; line6pcm->impulse_volume = value; @@ -81,7 +81,14 @@ static ssize_t pcm_set_impulse_period(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - dev2pcm(dev)->impulse_period = simple_strtoul(buf, NULL, 10); + int value; + int ret; + + ret = kstrtoint(buf, 10, &value); + if (ret < 0) + return ret; + + dev2pcm(dev)->impulse_period = value; return count; } @@ -114,10 +121,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->buffer_in) { - dev_err(line6pcm->line6->ifcdev, - "cannot malloc capture buffer\n"); err = -ENOMEM; goto pcm_acquire_error; } @@ -153,10 +157,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) line6pcm->buffer_out = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->buffer_out) { - dev_err(line6pcm->line6->ifcdev, - "cannot malloc playback buffer\n"); err = -ENOMEM; goto pcm_acquire_error; } @@ -455,13 +456,12 @@ int line6_init_pcm(struct usb_line6 *line6, ep_write = 0x01; break; - /* this is for interface_number == 1: - case LINE6_DEVID_TONEPORT_UX2: - case LINE6_DEVID_PODSTUDIO_UX2: - ep_read = 0x87; - ep_write = 0x00; - break; - */ + /* this is for interface_number == 1: + case LINE6_DEVID_TONEPORT_UX2: + case LINE6_DEVID_PODSTUDIO_UX2: + ep_read = 0x87; + ep_write = 0x00; + break; */ default: MISSING_CASE; diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c index 4cf23af..f9135c7 100644 --- a/drivers/staging/line6/playback.c +++ b/drivers/staging/line6/playback.c @@ -264,15 +264,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) } #endif } -#ifdef CONFIG_LINE6_USB_DUMP_PCM - for (i = 0; i < LINE6_ISO_PACKETS; ++i) { - struct usb_iso_packet_descriptor *fout = - &urb_out->iso_frame_desc[i]; - line6_write_hexdump(line6pcm->line6, 'P', - urb_out->transfer_buffer + fout->offset, - fout->length); - } -#endif ret = usb_submit_urb(urb_out, GFP_ATOMIC); diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index e542540..74898c3 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -34,12 +34,14 @@ enum { POD_SYSEX_DUMPMEM = 0x73, POD_SYSEX_DUMP = 0x74, POD_SYSEX_DUMPREQ = 0x75 - /* POD_SYSEX_DUMPMEM2 = 0x76 */ /* dumps entire internal memory of PODxt Pro */ + + /* dumps entire internal memory of PODxt Pro */ + /* POD_SYSEX_DUMPMEM2 = 0x76 */ }; enum { - POD_monitor_level = 0x04, - POD_system_invalid = 0x10000 + POD_MONITOR_LEVEL = 0x04, + POD_SYSTEM_INVALID = 0x10000 }; /* *INDENT-ON* */ @@ -133,84 +135,27 @@ void line6_pod_process_message(struct usb_line6_pod *pod) { const unsigned char *buf = pod->line6.buffer_message; - /* filter messages by type */ - switch (buf[0] & 0xf0) { - case LINE6_PARAM_CHANGE: - case LINE6_PROGRAM_CHANGE: - case LINE6_SYSEX_BEGIN: - break; /* handle these further down */ + if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { + pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15]; + pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) | + (int) buf[10]; + pod_startup3(pod); + return; + } - default: - return; /* ignore all others */ + /* Only look for sysex messages from this device */ + if (buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE) && + buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN)) { + return; + } + if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) != 0) { + return; } - /* process all remaining messages */ - switch (buf[0]) { - case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE: - case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST: - break; - - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE: - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST: - break; - - case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE: - case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN: - if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) { - switch (buf[5]) { - case POD_SYSEX_DUMP: - break; - - case POD_SYSEX_SYSTEM:{ - short value = - ((int)buf[7] << 12) | ((int)buf[8] - << 8) | - ((int)buf[9] << 4) | (int)buf[10]; - - if (buf[6] == POD_monitor_level) - pod->monitor_level = value; - break; - } - - case POD_SYSEX_FINISH: - /* do we need to respond to this? */ - break; - - case POD_SYSEX_SAVE: - break; - - case POD_SYSEX_STORE: - dev_dbg(pod->line6.ifcdev, - "message %02X not yet implemented\n", - buf[5]); - break; - - default: - dev_dbg(pod->line6.ifcdev, - "unknown sysex message %02X\n", - buf[5]); - } - } else - if (memcmp - (buf, pod_version_header, - sizeof(pod_version_header)) == 0) { - pod->firmware_version = - buf[13] * 100 + buf[14] * 10 + buf[15]; - pod->device_id = - ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int) - buf[10]; - pod_startup3(pod); - } else - dev_dbg(pod->line6.ifcdev, "unknown sysex header\n"); - - break; - - case LINE6_SYSEX_END: - break; - - default: - dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n", - buf[0]); + if (buf[5] == POD_SYSEX_SYSTEM && buf[6] == POD_MONITOR_LEVEL) { + short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) | + ((int)buf[9] << 4) | (int)buf[10]; + pod->monitor_level = value; } } @@ -369,7 +314,7 @@ static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, pod->monitor_level = ucontrol->value.integer.value[0]; pod_set_system_param_int(pod, ucontrol->value.integer.value[0], - POD_monitor_level); + POD_MONITOR_LEVEL); return 1; } @@ -460,7 +405,7 @@ static int pod_try_init(struct usb_interface *interface, */ if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) { - pod->monitor_level = POD_system_invalid; + pod->monitor_level = POD_SYSTEM_INVALID; /* initiate startup procedure: */ pod_startup1(pod); diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c index a529dd3..2f44d56 100644 --- a/drivers/staging/line6/toneport.c +++ b/drivers/staging/line6/toneport.c @@ -87,12 +87,10 @@ static struct line6_pcm_properties toneport_pcm_properties = { static int led_red = 0x00; static int led_green = 0x26; -struct ToneportSourceInfo { +static const struct { const char *name; int code; -}; - -static const struct ToneportSourceInfo toneport_source_info[] = { +} toneport_source_info[] = { {"Microphone", 0x0a01}, {"Line", 0x0801}, {"Instrument", 0x0b01}, diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c index 4fca58f..bd0f694 100644 --- a/drivers/staging/line6/variax.c +++ b/drivers/staging/line6/variax.c @@ -133,13 +133,6 @@ void line6_variax_process_message(struct usb_line6_variax *variax) const unsigned char *buf = variax->line6.buffer_message; switch (buf[0]) { - case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST: - break; - - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE: - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST: - break; - case LINE6_RESET: dev_info(variax->line6.ifcdev, "VARIAX reset\n"); break; @@ -154,13 +147,6 @@ void line6_variax_process_message(struct usb_line6_variax *variax) variax_startup4((unsigned long)variax); } break; - - case LINE6_SYSEX_END: - break; - - default: - dev_dbg(variax->line6.ifcdev, - "Variax: unknown message %02X\n", buf[0]); } } diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 492e0b6..6a0b6ec 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -72,9 +72,16 @@ enum nvec_msg_category { NVEC_MSG_TX, }; -static const unsigned char EC_DISABLE_EVENT_REPORTING[3] = "\x04\x00\x00"; -static const unsigned char EC_ENABLE_EVENT_REPORTING[3] = "\x04\x00\x01"; -static const unsigned char EC_GET_FIRMWARE_VERSION[2] = "\x07\x15"; +enum nvec_sleep_subcmds { + GLOBAL_EVENTS, + AP_PWR_DOWN, + AP_SUSPEND, +}; + +#define CNF_EVENT_REPORTING 0x01 +#define GET_FIRMWARE_VERSION 0x15 +#define LID_SWITCH BIT(1) +#define PWR_BUTTON BIT(15) static struct nvec_chip *nvec_power_handle; @@ -318,6 +325,41 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, EXPORT_SYMBOL(nvec_write_sync); /** + * nvec_toggle_global_events - enables or disables global event reporting + * @nvec: nvec handle + * @state: true for enable, false for disable + * + * This switches on/off global event reports by the embedded controller. + */ +static void nvec_toggle_global_events(struct nvec_chip *nvec, bool state) +{ + unsigned char global_events[] = { NVEC_SLEEP, GLOBAL_EVENTS, state }; + + nvec_write_async(nvec, global_events, 3); +} + +/** + * nvec_event_mask - fill the command string with event bitfield + * ev: points to event command string + * mask: bit to insert into the event mask + * + * Configure event command expects a 32 bit bitfield which describes + * which events to enable. The bitfield has the following structure + * (from highest byte to lowest): + * system state bits 7-0 + * system state bits 15-8 + * oem system state bits 7-0 + * oem system state bits 15-8 + */ +static void nvec_event_mask(char *ev, u32 mask) +{ + ev[3] = mask >> 16 && 0xff; + ev[4] = mask >> 24 && 0xff; + ev[5] = mask >> 0 && 0xff; + ev[6] = mask >> 8 && 0xff; +} + +/** * nvec_request_master - Process outgoing messages * @work: A &struct work_struct (the tx_worker member of &struct nvec_chip) * @@ -711,8 +753,10 @@ static void nvec_disable_i2c_slave(struct nvec_chip *nvec) static void nvec_power_off(void) { - nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3); - nvec_write_async(nvec_power_handle, "\x04\x01", 2); + char ap_pwr_down[] = { NVEC_SLEEP, AP_PWR_DOWN }; + + nvec_toggle_global_events(nvec_power_handle, false); + nvec_write_async(nvec_power_handle, ap_pwr_down, 2); } static int tegra_nvec_probe(struct platform_device *pdev) @@ -724,6 +768,9 @@ static int tegra_nvec_probe(struct platform_device *pdev) struct nvec_msg *msg; struct resource *res; void __iomem *base; + char get_firmware_version[] = { NVEC_CNTL, GET_FIRMWARE_VERSION }, + unmute_speakers[] = { NVEC_OEM0, 0x10, 0x59, 0x95 }, + enable_event[7] = { NVEC_SYS, CNF_EVENT_REPORTING, true }; nvec = devm_kzalloc(&pdev->dev, sizeof(struct nvec_chip), GFP_KERNEL); if (nvec == NULL) { @@ -813,8 +860,7 @@ static int tegra_nvec_probe(struct platform_device *pdev) /* enable event reporting */ - nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, - sizeof(EC_ENABLE_EVENT_REPORTING)); + nvec_toggle_global_events(nvec, true); nvec->nvec_status_notifier.notifier_call = nvec_status_notifier; nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0); @@ -823,8 +869,7 @@ static int tegra_nvec_probe(struct platform_device *pdev) pm_power_off = nvec_power_off; /* Get Firmware Version */ - msg = nvec_write_sync(nvec, EC_GET_FIRMWARE_VERSION, - sizeof(EC_GET_FIRMWARE_VERSION)); + msg = nvec_write_sync(nvec, get_firmware_version, 2); if (msg) { dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", @@ -839,13 +884,15 @@ static int tegra_nvec_probe(struct platform_device *pdev) dev_err(nvec->dev, "error adding subdevices\n"); /* unmute speakers? */ - nvec_write_async(nvec, "\x0d\x10\x59\x95", 4); + nvec_write_async(nvec, unmute_speakers, 4); /* enable lid switch event */ - nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x02\x00", 7); + nvec_event_mask(enable_event, LID_SWITCH); + nvec_write_async(nvec, enable_event, 7); /* enable power button event */ - nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x80\x00", 7); + nvec_event_mask(enable_event, PWR_BUTTON); + nvec_write_async(nvec, enable_event, 7); return 0; } @@ -854,7 +901,7 @@ static int tegra_nvec_remove(struct platform_device *pdev) { struct nvec_chip *nvec = platform_get_drvdata(pdev); - nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3); + nvec_toggle_global_events(nvec, false); mfd_remove_devices(nvec->dev); cancel_work_sync(&nvec->rx_work); cancel_work_sync(&nvec->tx_work); @@ -868,13 +915,14 @@ static int nvec_suspend(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct nvec_chip *nvec = platform_get_drvdata(pdev); struct nvec_msg *msg; + char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND }; dev_dbg(nvec->dev, "suspending\n"); /* keep these sync or you'll break suspend */ - msg = nvec_write_sync(nvec, EC_DISABLE_EVENT_REPORTING, 3); - nvec_msg_free(nvec, msg); - msg = nvec_write_sync(nvec, "\x04\x02", 2); + nvec_toggle_global_events(nvec, false); + + msg = nvec_write_sync(nvec, ap_suspend, sizeof(ap_suspend)); nvec_msg_free(nvec, msg); nvec_disable_i2c_slave(nvec); @@ -889,7 +937,7 @@ static int nvec_resume(struct device *dev) dev_dbg(nvec->dev, "resuming\n"); tegra_init_i2c_slave(nvec); - nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3); + nvec_toggle_global_events(nvec, true); return 0; } diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h index ba6ed8f..b7a14bc 100644 --- a/drivers/staging/nvec/nvec.h +++ b/drivers/staging/nvec/nvec.h @@ -71,9 +71,12 @@ enum nvec_event_size { enum nvec_msg_type { NVEC_SYS = 1, NVEC_BAT, - NVEC_KBD = 5, + NVEC_GPIO, + NVEC_SLEEP, + NVEC_KBD, NVEC_PS2, NVEC_CNTL, + NVEC_OEM0 = 0x0d, NVEC_KB_EVT = 0x80, NVEC_PS2_EVT, }; diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 7cb149b..7445ce6 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -21,10 +21,14 @@ #include "nvec-keytable.h" #include "nvec.h" -#define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} +enum kbd_subcmds { + CNFG_WAKE = 3, + CNFG_WAKE_KEY_REPORTING, + SET_LEDS = 0xed, + ENABLE_KBD = 0xf4, + DISABLE_KBD, +}; -static const char led_on[3] = "\x05\xed\x07"; -static const char led_off[3] = "\x05\xed\x00"; static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) + ARRAY_SIZE(extcode_tab_us102)]; @@ -39,12 +43,15 @@ static struct nvec_keys keys_dev; static void nvec_kbd_toggle_led(void) { + char buf[] = { NVEC_KBD, SET_LEDS, 0 }; + keys_dev.caps_lock = !keys_dev.caps_lock; if (keys_dev.caps_lock) - nvec_write_async(keys_dev.nvec, led_on, sizeof(led_on)); - else - nvec_write_async(keys_dev.nvec, led_off, sizeof(led_off)); + /* should be BIT(0) only, firmware bug? */ + buf[2] = BIT(0) | BIT(1) | BIT(2); + + nvec_write_async(keys_dev.nvec, buf, sizeof(buf)); } static int nvec_keys_notifier(struct notifier_block *nb, @@ -82,8 +89,8 @@ static int nvec_keys_notifier(struct notifier_block *nb, static int nvec_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { - unsigned char buf[] = ACK_KBD_EVENT; struct nvec_chip *nvec = keys_dev.nvec; + char buf[] = { NVEC_KBD, SET_LEDS, 0 }; if (type == EV_REP) return 0; @@ -105,6 +112,11 @@ static int nvec_kbd_probe(struct platform_device *pdev) struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); int i, j, err; struct input_dev *idev; + char clear_leds[] = { NVEC_KBD, SET_LEDS, 0 }, + enable_kbd[] = { NVEC_KBD, ENABLE_KBD }, + cnfg_wake[] = { NVEC_KBD, CNFG_WAKE, true, true }, + cnfg_wake_key_reporting[] = { NVEC_KBD, CNFG_WAKE_KEY_REPORTING, + true }; j = 0; @@ -138,19 +150,15 @@ static int nvec_kbd_probe(struct platform_device *pdev) nvec_register_notifier(nvec, &keys_dev.notifier, 0); /* Enable keyboard */ - nvec_write_async(nvec, "\x05\xf4", 2); + nvec_write_async(nvec, enable_kbd, 2); - /* keyboard reset? */ - nvec_write_async(nvec, "\x05\x03\x01\x01", 4); - nvec_write_async(nvec, "\x05\x04\x01", 3); - nvec_write_async(nvec, "\x06\x01\xff\x03", 4); -/* FIXME - wait until keyboard reset is finished - or until we have a sync write */ - mdelay(1000); + /* configures wake on special keys */ + nvec_write_async(nvec, cnfg_wake, 4); + /* enable wake key reporting */ + nvec_write_async(nvec, cnfg_wake_key_reporting, 3); /* Disable caps lock LED */ - nvec_write_async(nvec, led_off, sizeof(led_off)); + nvec_write_async(nvec, clear_leds, sizeof(clear_leds)); return 0; diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c index b7b6d54..296f7b9 100644 --- a/drivers/staging/nvec/nvec_power.c +++ b/drivers/staging/nvec/nvec_power.c @@ -22,6 +22,8 @@ #include "nvec.h" +#define GET_SYSTEM_STATUS 0x00 + struct nvec_power { struct notifier_block notifier; struct delayed_work poller; @@ -111,7 +113,7 @@ static const int bat_init[] = { static void get_bat_mfg_data(struct nvec_power *power) { int i; - char buf[] = { '\x02', '\x00' }; + char buf[] = { NVEC_BAT, SLOT_STATUS }; for (i = 0; i < ARRAY_SIZE(bat_init); i++) { buf[1] = bat_init[i]; @@ -348,7 +350,7 @@ static int const bat_iter[] = { static void nvec_power_poll(struct work_struct *work) { - char buf[] = { '\x01', '\x00' }; + char buf[] = { NVEC_SYS, GET_SYSTEM_STATUS }; struct nvec_power *power = container_of(work, struct nvec_power, poller.work); @@ -361,7 +363,7 @@ static void nvec_power_poll(struct work_struct *work) /* select a battery request function via round robin doing it all at once seems to overload the power supply */ - buf[0] = '\x02'; /* battery */ + buf[0] = NVEC_BAT; buf[1] = bat_iter[counter++]; nvec_write_async(power->nvec, buf, 2); diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index 88dd288..aff6b9b 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -21,9 +21,11 @@ #include "nvec.h" -#define START_STREAMING {'\x06', '\x03', '\x06'} -#define STOP_STREAMING {'\x06', '\x04'} -#define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'} +#define PACKET_SIZE 6 + +#define ENABLE_MOUSE 0xf4 +#define DISABLE_MOUSE 0xf5 +#define PSMOUSE_RST 0xff #ifdef NVEC_PS2_DEBUG #define NVEC_PHD(str, buf, len) \ @@ -33,7 +35,12 @@ #define NVEC_PHD(str, buf, len) #endif -static const unsigned char MOUSE_RESET[] = {'\x06', '\x01', '\xff', '\x03'}; +enum ps2_subcmds { + SEND_COMMAND = 1, + RECEIVE_N, + AUTO_RECEIVE_N, + CANCEL_AUTO_RECEIVE, +}; struct nvec_ps2 { struct serio *ser_dev; @@ -45,19 +52,19 @@ static struct nvec_ps2 ps2_dev; static int ps2_startstreaming(struct serio *ser_dev) { - unsigned char buf[] = START_STREAMING; + unsigned char buf[] = { NVEC_PS2, AUTO_RECEIVE_N, PACKET_SIZE }; return nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static void ps2_stopstreaming(struct serio *ser_dev) { - unsigned char buf[] = STOP_STREAMING; + unsigned char buf[] = { NVEC_PS2, CANCEL_AUTO_RECEIVE }; nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) { - unsigned char buf[] = SEND_COMMAND; + unsigned char buf[] = { NVEC_PS2, SEND_COMMAND, ENABLE_MOUSE, 1 }; buf[2] = cmd & 0xff; @@ -97,6 +104,7 @@ static int nvec_mouse_probe(struct platform_device *pdev) { struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); struct serio *ser_dev; + char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 }; ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL); if (ser_dev == NULL) @@ -118,7 +126,7 @@ static int nvec_mouse_probe(struct platform_device *pdev) serio_register_port(ser_dev); /* mouse reset */ - nvec_write_async(nvec, MOUSE_RESET, 4); + nvec_write_async(nvec, mouse_reset, sizeof(mouse_reset)); return 0; } @@ -133,27 +141,22 @@ static int nvec_mouse_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int nvec_mouse_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); - /* disable mouse */ - nvec_write_async(nvec, "\x06\xf4", 2); + ps2_sendcommand(ps2_dev.ser_dev, DISABLE_MOUSE); /* send cancel autoreceive */ - nvec_write_async(nvec, "\x06\x04", 2); + ps2_stopstreaming(ps2_dev.ser_dev); return 0; } static int nvec_mouse_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); - + /* start streaming */ ps2_startstreaming(ps2_dev.ser_dev); /* enable mouse */ - nvec_write_async(nvec, "\x06\xf5", 2); + ps2_sendcommand(ps2_dev.ser_dev, ENABLE_MOUSE); return 0; } diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c index 21fd91b..dcc1448 100644 --- a/drivers/staging/omap-thermal/omap-bandgap.c +++ b/drivers/staging/omap-thermal/omap-bandgap.c @@ -568,8 +568,6 @@ int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id, tsr = bg_ptr->conf->sensors[id].registers; time = omap_bandgap_readl(bg_ptr, tsr->bgap_counter); - if (ret) - return ret; time = (time & tsr->counter_mask) >> __ffs(tsr->counter_mask); time = time * 1000 / bg_ptr->clk_rate; diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c index 61f1070..79a55aa 100644 --- a/drivers/staging/omap-thermal/omap-thermal-common.c +++ b/drivers/staging/omap-thermal/omap-thermal-common.c @@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id, data = omap_bandgap_get_sensor_data(bg_ptr, id); - if (!data) + if (IS_ERR(data)) data = omap_thermal_build_data(bg_ptr, id); if (!data) @@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id) struct omap_thermal_data *data; data = omap_bandgap_get_sensor_data(bg_ptr, id); - if (!data) + if (IS_ERR(data)) data = omap_thermal_build_data(bg_ptr, id); if (!data) diff --git a/drivers/staging/omapdrm/omap_connector.c b/drivers/staging/omapdrm/omap_connector.c index 4cc9ee7..8979c80 100644 --- a/drivers/staging/omapdrm/omap_connector.c +++ b/drivers/staging/omapdrm/omap_connector.c @@ -261,10 +261,8 @@ struct drm_connector *omap_connector_init(struct drm_device *dev, omap_dss_get_device(dssdev); omap_connector = kzalloc(sizeof(struct omap_connector), GFP_KERNEL); - if (!omap_connector) { - dev_err(dev->dev, "could not allocate connector\n"); + if (!omap_connector) goto fail; - } omap_connector->dssdev = dssdev; omap_connector->encoder = encoder; diff --git a/drivers/staging/omapdrm/omap_crtc.c b/drivers/staging/omapdrm/omap_crtc.c index 5c6ed60..32109c0 100644 --- a/drivers/staging/omapdrm/omap_crtc.c +++ b/drivers/staging/omapdrm/omap_crtc.c @@ -601,11 +601,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, DBG("%s", channel_names[channel]); omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL); - - if (!omap_crtc) { - dev_err(dev->dev, "could not allocate CRTC\n"); + if (!omap_crtc) goto fail; - } crtc = &omap_crtc->base; diff --git a/drivers/staging/omapdrm/omap_dmm_priv.h b/drivers/staging/omapdrm/omap_dmm_priv.h index 273ec12..58bcd6a 100644 --- a/drivers/staging/omapdrm/omap_dmm_priv.h +++ b/drivers/staging/omapdrm/omap_dmm_priv.h @@ -118,6 +118,11 @@ struct pat { #define DESCR_SIZE 128 #define REFILL_BUFFER_SIZE ((4 * 128 * 256) + (3 * DESCR_SIZE)) +/* For OMAP5, a fixed offset is added to all Y coordinates for 1D buffers. + * This is used in programming to address the upper portion of the LUT +*/ +#define OMAP5_LUT_OFFSET 128 + struct dmm; struct dmm_txn { diff --git a/drivers/staging/omapdrm/omap_dmm_tiler.c b/drivers/staging/omapdrm/omap_dmm_tiler.c index 59bf438..9b794c9 100644 --- a/drivers/staging/omapdrm/omap_dmm_tiler.c +++ b/drivers/staging/omapdrm/omap_dmm_tiler.c @@ -213,6 +213,11 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area, txn->last_pat->next_pa = (uint32_t)pat_pa; pat->area = *area; + + /* adjust Y coordinates based off of container parameters */ + pat->area.y0 += engine->tcm->y_offset; + pat->area.y1 += engine->tcm->y_offset; + pat->ctrl = (struct pat_ctrl){ .start = 1, .lut_id = engine->tcm->lut_id, @@ -576,10 +581,8 @@ static int omap_dmm_probe(struct platform_device *dev) struct resource *mem; omap_dmm = kzalloc(sizeof(*omap_dmm), GFP_KERNEL); - if (!omap_dmm) { - dev_err(&dev->dev, "failed to allocate driver data section\n"); + if (!omap_dmm) goto fail; - } /* initialize lists */ INIT_LIST_HEAD(&omap_dmm->alloc_head); @@ -622,6 +625,11 @@ static int omap_dmm_probe(struct platform_device *dev) omap_dmm->lut_width = ((pat_geom >> 16) & 0xF) << 5; omap_dmm->lut_height = ((pat_geom >> 24) & 0xF) << 5; + /* increment LUT by one if on OMAP5 */ + /* LUT has twice the height, and is split into a separate container */ + if (omap_dmm->lut_height != omap_dmm->container_height) + omap_dmm->num_lut++; + /* initialize DMM registers */ writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__0); writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__1); @@ -671,11 +679,9 @@ static int omap_dmm_probe(struct platform_device *dev) } /* alloc engines */ - omap_dmm->engines = kzalloc( - omap_dmm->num_engines * sizeof(struct refill_engine), - GFP_KERNEL); + omap_dmm->engines = kcalloc(omap_dmm->num_engines, + sizeof(struct refill_engine), GFP_KERNEL); if (!omap_dmm->engines) { - dev_err(&dev->dev, "could not allocate engines\n"); ret = -ENOMEM; goto fail; } @@ -692,15 +698,17 @@ static int omap_dmm_probe(struct platform_device *dev) list_add(&omap_dmm->engines[i].idle_node, &omap_dmm->idle_head); } - omap_dmm->tcm = kzalloc(omap_dmm->num_lut * sizeof(*omap_dmm->tcm), + omap_dmm->tcm = kcalloc(omap_dmm->num_lut, sizeof(*omap_dmm->tcm), GFP_KERNEL); if (!omap_dmm->tcm) { - dev_err(&dev->dev, "failed to allocate lut ptrs\n"); ret = -ENOMEM; goto fail; } /* init containers */ + /* Each LUT is associated with a TCM (container manager). We use the + lut_id to denote the lut_id used to identify the correct LUT for + programming during reill operations */ for (i = 0; i < omap_dmm->num_lut; i++) { omap_dmm->tcm[i] = sita_init(omap_dmm->container_width, omap_dmm->container_height, @@ -717,13 +725,23 @@ static int omap_dmm_probe(struct platform_device *dev) /* assign access mode containers to applicable tcm container */ /* OMAP 4 has 1 container for all 4 views */ + /* OMAP 5 has 2 containers, 1 for 2D and 1 for 1D */ containers[TILFMT_8BIT] = omap_dmm->tcm[0]; containers[TILFMT_16BIT] = omap_dmm->tcm[0]; containers[TILFMT_32BIT] = omap_dmm->tcm[0]; - containers[TILFMT_PAGE] = omap_dmm->tcm[0]; + + if (omap_dmm->container_height != omap_dmm->lut_height) { + /* second LUT is used for PAGE mode. Programming must use + y offset that is added to all y coordinates. LUT id is still + 0, because it is the same LUT, just the upper 128 lines */ + containers[TILFMT_PAGE] = omap_dmm->tcm[1]; + omap_dmm->tcm[1]->y_offset = OMAP5_LUT_OFFSET; + omap_dmm->tcm[1]->lut_id = 0; + } else { + containers[TILFMT_PAGE] = omap_dmm->tcm[0]; + } area = (struct tcm_area) { - .is2d = true, .tcm = NULL, .p1.x = omap_dmm->container_width - 1, .p1.y = omap_dmm->container_height - 1, @@ -835,64 +853,81 @@ int tiler_map_show(struct seq_file *s, void *arg) int h_adj; int w_adj; unsigned long flags; + int lut_idx; + if (!omap_dmm) { /* early return if dmm/tiler device is not initialized */ return 0; } - h_adj = omap_dmm->lut_height / ydiv; - w_adj = omap_dmm->lut_width / xdiv; + h_adj = omap_dmm->container_height / ydiv; + w_adj = omap_dmm->container_width / xdiv; - map = kzalloc(h_adj * sizeof(*map), GFP_KERNEL); - global_map = kzalloc((w_adj + 1) * h_adj, GFP_KERNEL); + map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL); + global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL); if (!map || !global_map) goto error; - memset(global_map, ' ', (w_adj + 1) * h_adj); - for (i = 0; i < omap_dmm->lut_height; i++) { - map[i] = global_map + i * (w_adj + 1); - map[i][w_adj] = 0; - } - spin_lock_irqsave(&list_lock, flags); + for (lut_idx = 0; lut_idx < omap_dmm->num_lut; lut_idx++) { + memset(map, 0, sizeof(h_adj * sizeof(*map))); + memset(global_map, ' ', (w_adj + 1) * h_adj); - list_for_each_entry(block, &omap_dmm->alloc_head, alloc_node) { - if (block->fmt != TILFMT_PAGE) { - fill_map(map, xdiv, ydiv, &block->area, *m2dp, true); - if (!*++a2dp) - a2dp = a2d; - if (!*++m2dp) - m2dp = m2d; - map_2d_info(map, xdiv, ydiv, nice, &block->area); - } else { - bool start = read_map_pt(map, xdiv, ydiv, - &block->area.p0) - == ' '; - bool end = read_map_pt(map, xdiv, ydiv, &block->area.p1) - == ' '; - tcm_for_each_slice(a, block->area, p) - fill_map(map, xdiv, ydiv, &a, '=', true); - fill_map_pt(map, xdiv, ydiv, &block->area.p0, + for (i = 0; i < omap_dmm->container_height; i++) { + map[i] = global_map + i * (w_adj + 1); + map[i][w_adj] = 0; + } + + spin_lock_irqsave(&list_lock, flags); + + list_for_each_entry(block, &omap_dmm->alloc_head, alloc_node) { + if (block->area.tcm == omap_dmm->tcm[lut_idx]) { + if (block->fmt != TILFMT_PAGE) { + fill_map(map, xdiv, ydiv, &block->area, + *m2dp, true); + if (!*++a2dp) + a2dp = a2d; + if (!*++m2dp) + m2dp = m2d; + map_2d_info(map, xdiv, ydiv, nice, + &block->area); + } else { + bool start = read_map_pt(map, xdiv, + ydiv, &block->area.p0) == ' '; + bool end = read_map_pt(map, xdiv, ydiv, + &block->area.p1) == ' '; + + tcm_for_each_slice(a, block->area, p) + fill_map(map, xdiv, ydiv, &a, + '=', true); + fill_map_pt(map, xdiv, ydiv, + &block->area.p0, start ? '<' : 'X'); - fill_map_pt(map, xdiv, ydiv, &block->area.p1, + fill_map_pt(map, xdiv, ydiv, + &block->area.p1, end ? '>' : 'X'); - map_1d_info(map, xdiv, ydiv, nice, &block->area); + map_1d_info(map, xdiv, ydiv, nice, + &block->area); + } + } } - } - spin_unlock_irqrestore(&list_lock, flags); + spin_unlock_irqrestore(&list_lock, flags); - if (s) { - seq_printf(s, "BEGIN DMM TILER MAP\n"); - for (i = 0; i < 128; i++) - seq_printf(s, "%03d:%s\n", i, map[i]); - seq_printf(s, "END TILER MAP\n"); - } else { - dev_dbg(omap_dmm->dev, "BEGIN DMM TILER MAP\n"); - for (i = 0; i < 128; i++) - dev_dbg(omap_dmm->dev, "%03d:%s\n", i, map[i]); - dev_dbg(omap_dmm->dev, "END TILER MAP\n"); + if (s) { + seq_printf(s, "CONTAINER %d DUMP BEGIN\n", lut_idx); + for (i = 0; i < 128; i++) + seq_printf(s, "%03d:%s\n", i, map[i]); + seq_printf(s, "CONTAINER %d DUMP END\n", lut_idx); + } else { + dev_dbg(omap_dmm->dev, "CONTAINER %d DUMP BEGIN\n", + lut_idx); + for (i = 0; i < 128; i++) + dev_dbg(omap_dmm->dev, "%03d:%s\n", i, map[i]); + dev_dbg(omap_dmm->dev, "CONTAINER %d DUMP END\n", + lut_idx); + } } error: @@ -903,12 +938,45 @@ error: } #endif +#ifdef CONFIG_PM +static int omap_dmm_resume(struct device *dev) +{ + struct tcm_area area; + int i; + + if (!omap_dmm) + return -ENODEV; + + area = (struct tcm_area) { + .tcm = NULL, + .p1.x = omap_dmm->container_width - 1, + .p1.y = omap_dmm->container_height - 1, + }; + + /* initialize all LUTs to dummy page entries */ + for (i = 0; i < omap_dmm->num_lut; i++) { + area.tcm = omap_dmm->tcm[i]; + if (fill(&area, NULL, 0, 0, true)) + dev_err(dev, "refill failed"); + } + + return 0; +} + +static const struct dev_pm_ops omap_dmm_pm_ops = { + .resume = omap_dmm_resume, +}; +#endif + struct platform_driver omap_dmm_driver = { .probe = omap_dmm_probe, .remove = omap_dmm_remove, .driver = { .owner = THIS_MODULE, .name = DMM_DRIVER_NAME, +#ifdef CONFIG_PM + .pm = &omap_dmm_pm_ops, +#endif }, }; diff --git a/drivers/staging/omapdrm/omap_drv.c b/drivers/staging/omapdrm/omap_drv.c index ae5ecc2..480dc34 100644 --- a/drivers/staging/omapdrm/omap_drv.c +++ b/drivers/staging/omapdrm/omap_drv.c @@ -335,10 +335,8 @@ static int dev_load(struct drm_device *dev, unsigned long flags) DBG("load: dev=%p", dev); priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) { - dev_err(dev->dev, "could not allocate priv\n"); + if (!priv) return -ENOMEM; - } priv->omaprev = pdata->omaprev; @@ -368,6 +366,9 @@ static int dev_load(struct drm_device *dev, unsigned long flags) /* well, limp along without an fbdev.. maybe X11 will work? */ } + /* store off drm_device for use in pm ops */ + dev_set_drvdata(dev->dev, dev); + drm_kms_helper_poll_init(dev); return 0; @@ -393,6 +394,8 @@ static int dev_unload(struct drm_device *dev) kfree(dev->dev_private); dev->dev_private = NULL; + dev_set_drvdata(dev->dev, NULL); + return 0; } @@ -558,10 +561,19 @@ static int pdev_remove(struct platform_device *device) return 0; } +#ifdef CONFIG_PM +static const struct dev_pm_ops omapdrm_pm_ops = { + .resume = omap_gem_resume, +}; +#endif + struct platform_driver pdev = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, +#ifdef CONFIG_PM + .pm = &omapdrm_pm_ops, +#endif }, .probe = pdev_probe, .remove = pdev_remove, diff --git a/drivers/staging/omapdrm/omap_drv.h b/drivers/staging/omapdrm/omap_drv.h index cd1f22b..f921027 100644 --- a/drivers/staging/omapdrm/omap_drv.h +++ b/drivers/staging/omapdrm/omap_drv.h @@ -135,6 +135,10 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m); void omap_gem_describe_objects(struct list_head *list, struct seq_file *m); #endif +#ifdef CONFIG_PM +int omap_gem_resume(struct device *dev); +#endif + int omap_irq_enable_vblank(struct drm_device *dev, int crtc); void omap_irq_disable_vblank(struct drm_device *dev, int crtc); irqreturn_t omap_irq_handler(DRM_IRQ_ARGS); diff --git a/drivers/staging/omapdrm/omap_encoder.c b/drivers/staging/omapdrm/omap_encoder.c index e053160..25fc0c7 100644 --- a/drivers/staging/omapdrm/omap_encoder.c +++ b/drivers/staging/omapdrm/omap_encoder.c @@ -147,10 +147,8 @@ struct drm_encoder *omap_encoder_init(struct drm_device *dev, struct omap_encoder *omap_encoder; omap_encoder = kzalloc(sizeof(*omap_encoder), GFP_KERNEL); - if (!omap_encoder) { - dev_err(dev->dev, "could not allocate encoder\n"); + if (!omap_encoder) goto fail; - } omap_encoder->dssdev = dssdev; diff --git a/drivers/staging/omapdrm/omap_fb.c b/drivers/staging/omapdrm/omap_fb.c index 09028e9..bb49699 100644 --- a/drivers/staging/omapdrm/omap_fb.c +++ b/drivers/staging/omapdrm/omap_fb.c @@ -418,7 +418,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, omap_fb = kzalloc(sizeof(*omap_fb), GFP_KERNEL); if (!omap_fb) { - dev_err(dev->dev, "could not allocate fb\n"); ret = -ENOMEM; goto fail; } diff --git a/drivers/staging/omapdrm/omap_fbdev.c b/drivers/staging/omapdrm/omap_fbdev.c index 8a027bb..70f2d6e 100644 --- a/drivers/staging/omapdrm/omap_fbdev.c +++ b/drivers/staging/omapdrm/omap_fbdev.c @@ -348,10 +348,8 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) int ret = 0; fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); - if (!fbdev) { - dev_err(dev->dev, "could not allocate fbdev\n"); + if (!fbdev) goto fail; - } INIT_WORK(&fbdev->work, pan_worker); diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c index c38992b..518d03d 100644 --- a/drivers/staging/omapdrm/omap_gem.c +++ b/drivers/staging/omapdrm/omap_gem.c @@ -964,6 +964,34 @@ void *omap_gem_vaddr(struct drm_gem_object *obj) return omap_obj->vaddr; } +#ifdef CONFIG_PM +/* re-pin objects in DMM in resume path: */ +int omap_gem_resume(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + struct omap_drm_private *priv = drm_dev->dev_private; + struct omap_gem_object *omap_obj; + int ret = 0; + + list_for_each_entry(omap_obj, &priv->obj_list, mm_list) { + if (omap_obj->block) { + struct drm_gem_object *obj = &omap_obj->base; + uint32_t npages = obj->size >> PAGE_SHIFT; + WARN_ON(!omap_obj->pages); /* this can't happen */ + ret = tiler_pin(omap_obj->block, + omap_obj->pages, npages, + omap_obj->roll, true); + if (ret) { + dev_err(dev, "could not repin: %d\n", ret); + return ret; + } + } + } + + return 0; +} +#endif + #ifdef CONFIG_DEBUG_FS void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) { @@ -1239,12 +1267,12 @@ int omap_gem_set_sync_object(struct drm_gem_object *obj, void *syncobj) if ((omap_obj->flags & OMAP_BO_EXT_SYNC) && !syncobj) { /* clearing a previously set syncobj */ - syncobj = kzalloc(sizeof(*omap_obj->sync), GFP_ATOMIC); + syncobj = kmemdup(omap_obj->sync, sizeof(*omap_obj->sync), + GFP_ATOMIC); if (!syncobj) { ret = -ENOMEM; goto unlock; } - memcpy(syncobj, omap_obj->sync, sizeof(*omap_obj->sync)); omap_obj->flags &= ~OMAP_BO_EXT_SYNC; omap_obj->sync = syncobj; } else if (syncobj && !(omap_obj->flags & OMAP_BO_EXT_SYNC)) { @@ -1374,10 +1402,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, } omap_obj = kzalloc(sizeof(*omap_obj), GFP_KERNEL); - if (!omap_obj) { - dev_err(dev->dev, "could not allocate GEM object\n"); + if (!omap_obj) goto fail; - } list_add(&omap_obj->mm_list, &priv->obj_list); @@ -1433,11 +1459,9 @@ void omap_gem_init(struct drm_device *dev) return; } - usergart = kzalloc(3 * sizeof(*usergart), GFP_KERNEL); - if (!usergart) { - dev_warn(dev->dev, "could not allocate usergart\n"); + usergart = kcalloc(3, sizeof(*usergart), GFP_KERNEL); + if (!usergart) return; - } /* reserve 4k aligned/wide regions for userspace mappings: */ for (i = 0; i < ARRAY_SIZE(fmts); i++) { diff --git a/drivers/staging/omapdrm/omap_gem_dmabuf.c b/drivers/staging/omapdrm/omap_gem_dmabuf.c index b6c5b5c..a3236ab 100644 --- a/drivers/staging/omapdrm/omap_gem_dmabuf.c +++ b/drivers/staging/omapdrm/omap_gem_dmabuf.c @@ -53,10 +53,10 @@ static struct sg_table *omap_gem_map_dma_buf( /* this should be after _get_paddr() to ensure we have pages attached */ omap_gem_dma_sync(obj, dir); -out: - if (ret) - return ERR_PTR(ret); return sg; +out: + kfree(sg); + return ERR_PTR(ret); } static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment, diff --git a/drivers/staging/omapdrm/omap_plane.c b/drivers/staging/omapdrm/omap_plane.c index bb989d7..c063476 100644 --- a/drivers/staging/omapdrm/omap_plane.c +++ b/drivers/staging/omapdrm/omap_plane.c @@ -390,10 +390,8 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, DBG("%s: priv=%d", plane_names[id], private_plane); omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL); - if (!omap_plane) { - dev_err(dev->dev, "could not allocate plane\n"); + if (!omap_plane) goto fail; - } ret = kfifo_alloc(&omap_plane->unpin_fifo, 16, GFP_KERNEL); if (ret) { diff --git a/drivers/staging/omapdrm/tcm.h b/drivers/staging/omapdrm/tcm.h index d273e3e..a8d5ce4 100644 --- a/drivers/staging/omapdrm/tcm.h +++ b/drivers/staging/omapdrm/tcm.h @@ -59,6 +59,8 @@ struct tcm { u16 width, height; /* container dimensions */ int lut_id; /* Lookup table identifier */ + unsigned int y_offset; /* offset to use for y coordinates */ + /* 'pvt' structure shall contain any tcm details (attr) along with linked list of allocated areas and mutex for mutually exclusive access to the list. It may also contain copies of width and height to notice diff --git a/drivers/staging/ozwpan/TODO b/drivers/staging/ozwpan/TODO index b5db245..b4febd7 100644 --- a/drivers/staging/ozwpan/TODO +++ b/drivers/staging/ozwpan/TODO @@ -10,6 +10,5 @@ TODO: - testing with as many devices as possible. Please send any patches for this driver to -Rupesh Gujare <rgujare@ozmodevices.com> -Chris Kelly <ckelly@ozmodevices.com> +Rupesh Gujare <rupesh.gujare@atmel.com> and Greg Kroah-Hartman <gregkh@linuxfoundation.org>. diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 64913ae..ba15aeb 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -19,6 +19,7 @@ #include "ozpd.h" #include "ozproto.h" #include "ozevent.h" +#include "ozcdev.h" /*------------------------------------------------------------------------------ */ #define OZ_RD_BUF_SZ 256 @@ -43,7 +44,7 @@ struct oz_serial_ctx { /*------------------------------------------------------------------------------ */ static struct oz_cdev g_cdev; -struct class *g_oz_class; +static struct class *g_oz_class; /*------------------------------------------------------------------------------ * Context: process and softirq */ @@ -70,7 +71,7 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) /*------------------------------------------------------------------------------ * Context: process */ -int oz_cdev_open(struct inode *inode, struct file *filp) +static int oz_cdev_open(struct inode *inode, struct file *filp) { struct oz_cdev *dev; oz_trace("oz_cdev_open()\n"); @@ -82,7 +83,7 @@ int oz_cdev_open(struct inode *inode, struct file *filp) /*------------------------------------------------------------------------------ * Context: process */ -int oz_cdev_release(struct inode *inode, struct file *filp) +static int oz_cdev_release(struct inode *inode, struct file *filp) { oz_trace("oz_cdev_release()\n"); return 0; @@ -90,14 +91,14 @@ int oz_cdev_release(struct inode *inode, struct file *filp) /*------------------------------------------------------------------------------ * Context: process */ -ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, +static ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, loff_t *fpos) { int n; int ix; struct oz_pd *pd; - struct oz_serial_ctx *ctx = 0; + struct oz_serial_ctx *ctx; spin_lock_bh(&g_cdev.lock); pd = g_cdev.active_pd; @@ -142,12 +143,12 @@ out2: /*------------------------------------------------------------------------------ * Context: process */ -ssize_t oz_cdev_write(struct file *filp, const char __user *buf, size_t count, - loff_t *fpos) +static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, + size_t count, loff_t *fpos) { struct oz_pd *pd; struct oz_elt_buf *eb; - struct oz_elt_info *ei = 0; + struct oz_elt_info *ei; struct oz_elt *elt; struct oz_app_hdr *app_hdr; struct oz_serial_ctx *ctx; @@ -182,7 +183,7 @@ ssize_t oz_cdev_write(struct file *filp, const char __user *buf, size_t count, ctx->tx_seq_num = 1; spin_lock(&eb->lock); if (oz_queue_elt_info(eb, 0, 0, ei) == 0) - ei = 0; + ei = NULL; spin_unlock(&eb->lock); } spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); @@ -199,7 +200,7 @@ out: /*------------------------------------------------------------------------------ * Context: process */ -static int oz_set_active_pd(u8 *addr) +static int oz_set_active_pd(const u8 *addr) { int rc = 0; struct oz_pd *pd; @@ -217,7 +218,7 @@ static int oz_set_active_pd(u8 *addr) if (is_zero_ether_addr(addr)) { spin_lock_bh(&g_cdev.lock); pd = g_cdev.active_pd; - g_cdev.active_pd = 0; + g_cdev.active_pd = NULL; memset(g_cdev.active_addr, 0, sizeof(g_cdev.active_addr)); spin_unlock_bh(&g_cdev.lock); @@ -232,7 +233,8 @@ static int oz_set_active_pd(u8 *addr) /*------------------------------------------------------------------------------ * Context: process */ -long oz_cdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) { int rc = 0; if (_IOC_TYPE(cmd) != OZ_IOCTL_MAGIC) @@ -296,7 +298,7 @@ long oz_cdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) /*------------------------------------------------------------------------------ * Context: process */ -unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) +static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) { unsigned int ret = 0; struct oz_cdev *dev = filp->private_data; @@ -317,7 +319,7 @@ unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) } /*------------------------------------------------------------------------------ */ -const struct file_operations oz_fops = { +static const struct file_operations oz_fops = { .owner = THIS_MODULE, .open = oz_cdev_open, .release = oz_cdev_release, @@ -385,7 +387,7 @@ int oz_cdev_deregister(void) */ int oz_cdev_init(void) { - oz_event_log(OZ_EVT_SERVICE, 1, OZ_APPID_SERIAL, 0, 0); + oz_event_log(OZ_EVT_SERVICE, 1, OZ_APPID_SERIAL, NULL, 0); oz_app_enable(OZ_APPID_SERIAL, 1); return 0; } @@ -394,7 +396,7 @@ int oz_cdev_init(void) */ void oz_cdev_term(void) { - oz_event_log(OZ_EVT_SERVICE, 2, OZ_APPID_SERIAL, 0, 0); + oz_event_log(OZ_EVT_SERVICE, 2, OZ_APPID_SERIAL, NULL, 0); oz_app_enable(OZ_APPID_SERIAL, 0); } /*------------------------------------------------------------------------------ @@ -403,8 +405,8 @@ void oz_cdev_term(void) int oz_cdev_start(struct oz_pd *pd, int resume) { struct oz_serial_ctx *ctx; - struct oz_serial_ctx *old_ctx = 0; - oz_event_log(OZ_EVT_SERVICE, 3, OZ_APPID_SERIAL, 0, resume); + struct oz_serial_ctx *old_ctx; + oz_event_log(OZ_EVT_SERVICE, 3, OZ_APPID_SERIAL, NULL, resume); if (resume) { oz_trace("Serial service resumed.\n"); return 0; @@ -440,22 +442,22 @@ int oz_cdev_start(struct oz_pd *pd, int resume) void oz_cdev_stop(struct oz_pd *pd, int pause) { struct oz_serial_ctx *ctx; - oz_event_log(OZ_EVT_SERVICE, 4, OZ_APPID_SERIAL, 0, pause); + oz_event_log(OZ_EVT_SERVICE, 4, OZ_APPID_SERIAL, NULL, pause); if (pause) { oz_trace("Serial service paused.\n"); return; } spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; - pd->app_ctx[OZ_APPID_SERIAL-1] = 0; + pd->app_ctx[OZ_APPID_SERIAL-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); if (ctx) oz_cdev_release_ctx(ctx); spin_lock(&g_cdev.lock); if (pd == g_cdev.active_pd) - g_cdev.active_pd = 0; + g_cdev.active_pd = NULL; else - pd = 0; + pd = NULL; spin_unlock(&g_cdev.lock); if (pd) { oz_pd_put(pd); @@ -523,9 +525,3 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) out: oz_cdev_release_ctx(ctx); } -/*------------------------------------------------------------------------------ - * Context: softirq - */ -void oz_cdev_heartbeat(struct oz_pd *pd) -{ -} diff --git a/drivers/staging/ozwpan/ozcdev.h b/drivers/staging/ozwpan/ozcdev.h index 698014b..dd11935 100644 --- a/drivers/staging/ozwpan/ozcdev.h +++ b/drivers/staging/ozwpan/ozcdev.h @@ -13,6 +13,5 @@ void oz_cdev_term(void); int oz_cdev_start(struct oz_pd *pd, int resume); void oz_cdev_stop(struct oz_pd *pd, int pause); void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt); -void oz_cdev_heartbeat(struct oz_pd *pd); #endif /* _OZCDEV_H */ diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index 988f522..ac90fc7 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -64,7 +64,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) */ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) { - struct oz_elt_info *ei = 0; + struct oz_elt_info *ei = NULL; spin_lock_bh(&buf->lock); if (buf->free_elts && buf->elt_pool) { ei = container_of(buf->elt_pool, struct oz_elt_info, link); @@ -82,9 +82,9 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) if (ei) { ei->flags = 0; ei->app_id = 0; - ei->callback = 0; + ei->callback = NULL; ei->context = 0; - ei->stream = 0; + ei->stream = NULL; ei->magic = OZ_ELT_INFO_MAGIC_USED; INIT_LIST_HEAD(&ei->link); INIT_LIST_HEAD(&ei->link_order); @@ -135,7 +135,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) oz_trace("oz_elt_stream_create(0x%x)\n", id); st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO); - if (st == 0) + if (st == NULL) return -ENOMEM; atomic_set(&st->ref_count, 1); st->id = id; @@ -151,7 +151,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) { struct list_head *e; - struct oz_elt_stream *st; + struct oz_elt_stream *st = NULL; oz_trace("oz_elt_stream_delete(0x%x)\n", id); spin_lock_bh(&buf->lock); e = buf->stream_list.next; @@ -161,7 +161,7 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) list_del(e); break; } - st = 0; + st = NULL; } if (!st) { spin_unlock_bh(&buf->lock); @@ -208,7 +208,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st) int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, struct oz_elt_info *ei) { - struct oz_elt_stream *st = 0; + struct oz_elt_stream *st = NULL; struct list_head *e; if (id) { list_for_each(e, &buf->stream_list) { @@ -297,7 +297,7 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, "Stream down: %d %d\n", ei->stream->buf_count, ei->length); oz_elt_stream_put(ei->stream); - ei->stream = 0; + ei->stream = NULL; } INIT_LIST_HEAD(&ei->link_order); list_add_tail(&ei->link, list); @@ -319,7 +319,7 @@ int oz_are_elts_available(struct oz_elt_buf *buf) */ void oz_trim_elt_pool(struct oz_elt_buf *buf) { - struct list_head *free = 0; + struct list_head *free = NULL; struct list_head *e; spin_lock_bh(&buf->lock); while (buf->free_elts > buf->max_free_elts) { diff --git a/drivers/staging/ozwpan/ozevent.c b/drivers/staging/ozwpan/ozevent.c index 50578ba..77e8675 100644 --- a/drivers/staging/ozwpan/ozevent.c +++ b/drivers/staging/ozwpan/ozevent.c @@ -92,7 +92,7 @@ static void oz_events_clear(struct oz_evtdev *dev) /*------------------------------------------------------------------------------ * Context: process */ -int oz_events_open(struct inode *inode, struct file *filp) +static int oz_events_open(struct inode *inode, struct file *filp) { oz_trace("oz_evt_open()\n"); oz_trace("Open flags: 0x%x\n", filp->f_flags); @@ -107,7 +107,7 @@ int oz_events_open(struct inode *inode, struct file *filp) /*------------------------------------------------------------------------------ * Context: process */ -int oz_events_release(struct inode *inode, struct file *filp) +static int oz_events_release(struct inode *inode, struct file *filp) { oz_events_clear(&g_evtdev); atomic_dec(&g_evtdev.users); @@ -118,7 +118,7 @@ int oz_events_release(struct inode *inode, struct file *filp) /*------------------------------------------------------------------------------ * Context: process */ -ssize_t oz_events_read(struct file *filp, char __user *buf, size_t count, +static ssize_t oz_events_read(struct file *filp, char __user *buf, size_t count, loff_t *fpos) { struct oz_evtdev *dev = &g_evtdev; @@ -157,7 +157,7 @@ out: } /*------------------------------------------------------------------------------ */ -const struct file_operations oz_events_fops = { +static const struct file_operations oz_events_fops = { .owner = THIS_MODULE, .open = oz_events_open, .release = oz_events_release, diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index b2d77df..8ac26f5 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -36,6 +36,7 @@ #include "oztrace.h" #include "ozurbparanoia.h" #include "ozevent.h" +#include "ozhcd.h" /*------------------------------------------------------------------------------ * Number of units of buffering to capture for an isochronous IN endpoint before * allowing data to be indicated up. @@ -248,7 +249,7 @@ static int oz_get_port_from_addr(struct oz_hcd *ozhcd, u8 bus_addr) */ static struct oz_urb_link *oz_alloc_urb_link(void) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; unsigned long irq_state; spin_lock_irqsave(&g_link_lock, irq_state); if (g_link_pool) { @@ -257,7 +258,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void) --g_link_pool_size; } spin_unlock_irqrestore(&g_link_lock, irq_state); - if (urbl == 0) + if (urbl == NULL) urbl = kmalloc(sizeof(struct oz_urb_link), GFP_ATOMIC); return urbl; } @@ -274,7 +275,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) if (g_link_pool_size < OZ_MAX_LINK_POOL_SIZE) { urbl->link.next = g_link_pool; g_link_pool = &urbl->link; - urbl = 0; + urbl = NULL; g_link_pool_size++; } spin_unlock_irqrestore(&g_link_lock, irq_state); @@ -291,7 +292,7 @@ static void oz_empty_link_pool(void) unsigned long irq_state; spin_lock_irqsave(&g_link_lock, irq_state); e = g_link_pool; - g_link_pool = 0; + g_link_pool = NULL; g_link_pool_size = 0; spin_unlock_irqrestore(&g_link_lock, irq_state); while (e) { @@ -326,7 +327,7 @@ static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size) * disabled. * Context: softirq or process */ -struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb) +static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb) { struct oz_urb_link *urbl; struct list_head *e; @@ -337,7 +338,7 @@ struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb) return urbl; } } - return 0; + return NULL; } /*------------------------------------------------------------------------------ * This is called when we have finished processing an urb. It unlinks it from @@ -349,13 +350,13 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, { struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned long irq_state; - struct oz_urb_link *cancel_urbl = 0; + struct oz_urb_link *cancel_urbl = NULL; spin_lock_irqsave(&g_tasklet_lock, irq_state); usb_hcd_unlink_urb_from_ep(hcd, urb); /* Clear hcpriv which will prevent it being put in the cancel list * in the event that an attempt is made to cancel it. */ - urb->hcpriv = 0; + urb->hcpriv = NULL; /* Walk the cancel list in case the urb is already sitting there. * Since we process the cancel list in a tasklet rather than in * the dequeue function this could happen. @@ -416,7 +417,8 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) /*------------------------------------------------------------------------------ * Context: softirq */ -void oz_complete_buffered_urb(struct oz_port *port, struct oz_endpoint *ep, +static void oz_complete_buffered_urb(struct oz_port *port, + struct oz_endpoint *ep, struct urb *urb) { u8 data_len, available_space, copy_len; @@ -507,7 +509,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, ep->last_jiffies = jiffies; ep->credit = 0; oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num, - 0, 0, ep->credit); + 0, NULL, ep->credit); } } else { err = -EPIPE; @@ -525,7 +527,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct oz_endpoint *ep; spin_lock_bh(&port->ozhcd->hcd_lock); if (in_dir) @@ -540,7 +542,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, list_del_init(e); break; } - urbl = 0; + urbl = NULL; } } spin_unlock_bh(&port->ozhcd->hcd_lock); @@ -556,8 +558,8 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, u8 req_id) { struct oz_hcd *ozhcd = port->ozhcd; - struct urb *urb = 0; - struct oz_urb_link *urbl = 0; + struct urb *urb = NULL; + struct oz_urb_link *urbl = NULL; struct oz_endpoint *ep; spin_lock_bh(&ozhcd->hcd_lock); @@ -630,13 +632,13 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) void *oz_hcd_pd_arrived(void *hpd) { int i; - void *hport = 0; - struct oz_hcd *ozhcd = 0; + void *hport = NULL; + struct oz_hcd *ozhcd = NULL; struct oz_endpoint *ep; oz_trace("oz_hcd_pd_arrived()\n"); ozhcd = oz_hcd_claim(); - if (ozhcd == 0) - return 0; + if (ozhcd == NULL) + return NULL; /* Allocate an endpoint object in advance (before holding hcd lock) to * use for out endpoint 0. */ @@ -663,7 +665,7 @@ void *oz_hcd_pd_arrived(void *hpd) /* Attach out endpoint 0. */ ozhcd->ports[i].out_ep[0] = ep; - ep = 0; + ep = NULL; hport = &ozhcd->ports[i]; spin_unlock_bh(&ozhcd->hcd_lock); if (ozhcd->flags & OZ_HDC_F_SUSPENDED) { @@ -676,7 +678,7 @@ void *oz_hcd_pd_arrived(void *hpd) } out: if (ep) /* ep is non-null if not used. */ - oz_ep_free(0, ep); + oz_ep_free(NULL, ep); oz_hcd_put(ozhcd); return hport; } @@ -691,15 +693,15 @@ void oz_hcd_pd_departed(void *hport) struct oz_port *port = (struct oz_port *)hport; struct oz_hcd *ozhcd; void *hpd; - struct oz_endpoint *ep = 0; + struct oz_endpoint *ep = NULL; oz_trace("oz_hcd_pd_departed()\n"); - if (port == 0) { + if (port == NULL) { oz_trace("oz_hcd_pd_departed() port = 0\n"); return; } ozhcd = port->ozhcd; - if (ozhcd == 0) + if (ozhcd == NULL) return; /* Check if this is the connection port - if so clear it. */ @@ -717,7 +719,7 @@ void oz_hcd_pd_departed(void *hport) oz_clean_endpoints_for_config(ozhcd->hcd, port); spin_lock_bh(&port->port_lock); hpd = port->hpd; - port->hpd = 0; + port->hpd = NULL; port->bus_addr = 0xff; port->flags &= ~(OZ_PORT_F_PRESENT | OZ_PORT_F_DYING); port->flags |= OZ_PORT_F_CHANGED; @@ -728,7 +730,7 @@ void oz_hcd_pd_departed(void *hport) */ if (port->out_ep[0]) { ep = port->out_ep[0]; - port->out_ep[0] = 0; + port->out_ep[0] = NULL; } spin_unlock_bh(&port->port_lock); if (ep) @@ -757,14 +759,14 @@ void oz_hcd_pd_reset(void *hpd, void *hport) /*------------------------------------------------------------------------------ * Context: softirq */ -void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, u8 *desc, +void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, int length, int offset, int total_size) { struct oz_port *port = (struct oz_port *)hport; struct urb *urb; int err = 0; - oz_event_log(OZ_EVT_CTRL_CNF, 0, req_id, 0, status); + oz_event_log(OZ_EVT_CTRL_CNF, 0, req_id, NULL, status); oz_trace("oz_hcd_get_desc_cnf length = %d offs = %d tot_size = %d\n", length, offset, total_size); urb = oz_find_urb_by_id(port, 0, req_id); @@ -893,7 +895,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, /*------------------------------------------------------------------------------ * Context: softirq */ -void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, u8 *data, +void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, int data_len) { struct oz_port *port = (struct oz_port *)hport; @@ -903,7 +905,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, u8 *data, unsigned windex; unsigned wvalue; - oz_event_log(OZ_EVT_CTRL_CNF, 0, req_id, 0, rcode); + oz_event_log(OZ_EVT_CTRL_CNF, 0, req_id, NULL, rcode); oz_trace("oz_hcd_control_cnf rcode=%u len=%d\n", rcode, data_len); urb = oz_find_urb_by_id(port, 0, req_id); if (!urb) { @@ -946,7 +948,8 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, u8 *data, /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -static int oz_hcd_buffer_data(struct oz_endpoint *ep, u8 *data, int data_len) +static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, + int data_len) { int space; int copy_len; @@ -981,14 +984,14 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, u8 *data, int data_len) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -void oz_hcd_data_ind(void *hport, u8 endpoint, u8 *data, int data_len) +void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) { struct oz_port *port = (struct oz_port *)hport; struct oz_endpoint *ep; struct oz_hcd *ozhcd = port->ozhcd; spin_lock_bh(&ozhcd->hcd_lock); ep = port->in_ep[endpoint & USB_ENDPOINT_NUMBER_MASK]; - if (ep == 0) + if (ep == NULL) goto done; switch (ep->attrib & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_INT: @@ -1056,7 +1059,8 @@ int oz_hcd_heartbeat(void *hport) ep->credit += jiffies_to_msecs(now - ep->last_jiffies); if (ep->credit > ep->credit_ceiling) ep->credit = ep->credit_ceiling; - oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num, 0, 0, ep->credit); + oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num, 0, NULL, + ep->credit); ep->last_jiffies = now; while (ep->credit && !list_empty(&ep->urb_list)) { urbl = list_first_entry(&ep->urb_list, @@ -1065,8 +1069,8 @@ int oz_hcd_heartbeat(void *hport) if ((ep->credit + 1) < urb->number_of_packets) break; ep->credit -= urb->number_of_packets; - oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num, 0, 0, - ep->credit); + oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num, 0, NULL, + ep->credit); list_move_tail(&urbl->link, &xfr_list); } } @@ -1091,22 +1095,22 @@ int oz_hcd_heartbeat(void *hport) list_for_each(e, &port->isoc_in_ep) { struct oz_endpoint *ep = ep_from_link(e); if (ep->flags & OZ_F_EP_BUFFERING) { - if (ep->buffered_units * OZ_IN_BUFFERING_UNITS) { + if (ep->buffered_units >= OZ_IN_BUFFERING_UNITS) { ep->flags &= ~OZ_F_EP_BUFFERING; ep->credit = 0; oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num | USB_DIR_IN, - 0, 0, ep->credit); + 0, NULL, ep->credit); ep->last_jiffies = now; ep->start_frame = 0; oz_event_log(OZ_EVT_EP_BUFFERING, - ep->ep_num | USB_DIR_IN, 0, 0, 0); + ep->ep_num | USB_DIR_IN, 0, NULL, 0); } continue; } ep->credit += jiffies_to_msecs(now - ep->last_jiffies); oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num | USB_DIR_IN, - 0, 0, ep->credit); + 0, NULL, ep->credit); ep->last_jiffies = now; while (!list_empty(&ep->urb_list)) { struct oz_urb_link *urbl = @@ -1151,7 +1155,7 @@ int oz_hcd_heartbeat(void *hport) list_move_tail(&urbl->link, &xfr_list); ep->credit -= urb->number_of_packets; oz_event_log(OZ_EVT_EP_CREDIT, ep->ep_num | USB_DIR_IN, - 0, 0, ep->credit); + 0, NULL, ep->credit); } } if (!list_empty(&port->isoc_out_ep) || !list_empty(&port->isoc_in_ep)) @@ -1244,7 +1248,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, if (ep_addr & USB_ENDPOINT_DIR_MASK) { ep->flags |= OZ_F_EP_BUFFERING; oz_event_log(OZ_EVT_EP_BUFFERING, - ep->ep_num | USB_DIR_IN, 1, 0, 0); + ep->ep_num | USB_DIR_IN, 1, NULL, 0); } else { ep->flags |= OZ_F_EP_HAVE_STREAM; if (oz_usb_stream_create(port->hpd, ep_num)) @@ -1300,7 +1304,7 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, */ if ((mask & (1<<i)) && port->out_ep[i]) { e = &port->out_ep[i]->link; - port->out_ep[i] = 0; + port->out_ep[i] = NULL; /* Remove from isoc list if present. */ list_move_tail(e, &ep_list); @@ -1309,7 +1313,7 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, */ if ((mask & (1<<(i+OZ_NB_ENDPOINTS))) && port->in_ep[i]) { e = &port->in_ep[i]->link; - port->in_ep[i] = 0; + port->in_ep[i] = NULL; list_move_tail(e, &ep_list); } } @@ -1370,7 +1374,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, if (port->iface) { oz_trace("Freeing interfaces object.\n"); kfree(port->iface); - port->iface = 0; + port->iface = NULL; } port->num_iface = 0; spin_unlock_bh(&ozhcd->hcd_lock); @@ -1380,7 +1384,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, */ static void *oz_claim_hpd(struct oz_port *port) { - void *hpd = 0; + void *hpd = NULL; struct oz_hcd *ozhcd = port->ozhcd; spin_lock_bh(&ozhcd->hcd_lock); hpd = port->hpd; @@ -1399,13 +1403,13 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, unsigned windex; unsigned wvalue; unsigned wlength; - void *hpd = 0; + void *hpd = NULL; u8 req_id; int rc = 0; unsigned complete = 0; int port_ix = -1; - struct oz_port *port = 0; + struct oz_port *port = NULL; oz_trace2(OZ_TRACE_URB, "%lu: oz_process_ep0_urb(%p)\n", jiffies, urb); port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum); @@ -1437,7 +1441,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, req_id = port->next_req_id++; hpd = oz_claim_hpd(port); - if (hpd == 0) { + if (hpd == NULL) { oz_trace("Cannot claim port\n"); rc = -EPIPE; goto out; @@ -1452,7 +1456,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, break; case USB_REQ_SET_ADDRESS: oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, - 0, 0, setup->bRequestType); + 0, NULL, setup->bRequestType); oz_trace("USB_REQ_SET_ADDRESS - req\n"); oz_trace("Port %d address is 0x%x\n", ozhcd->conn_port, (u8)le16_to_cpu(setup->wValue)); @@ -1473,8 +1477,8 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, /* We short circuit this case and reply directly since * we have the selected configuration number cached. */ - oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, 0, - setup->bRequestType); + oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, + NULL, setup->bRequestType); oz_trace("USB_REQ_GET_CONFIGURATION - reply now\n"); if (urb->transfer_buffer_length >= 1) { urb->actual_length = 1; @@ -1489,8 +1493,8 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, /* We short circuit this case and reply directly since * we have the selected interface alternative cached. */ - oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, 0, - setup->bRequestType); + oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, + NULL, setup->bRequestType); oz_trace("USB_REQ_GET_INTERFACE - reply now\n"); if (urb->transfer_buffer_length >= 1) { urb->actual_length = 1; @@ -1583,7 +1587,7 @@ static void oz_urb_process_tasklet(unsigned long unused) struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); int rc = 0; - if (ozhcd == 0) + if (ozhcd == NULL) return; /* This is called from a tasklet so is in softirq context but the urb * list is filled from any context so we need to lock @@ -1617,17 +1621,17 @@ static void oz_urb_process_tasklet(unsigned long unused) */ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct list_head *e; struct oz_hcd *ozhcd; unsigned long irq_state; u8 ix; - if (port == 0) { + if (port == NULL) { oz_trace("ERRORERROR: oz_urb_cancel(%p) port is null\n", urb); return; } ozhcd = port->ozhcd; - if (ozhcd == 0) { + if (ozhcd == NULL) { oz_trace("ERRORERROR: oz_urb_cancel(%p) ozhcd is null\n", urb); return; } @@ -1644,7 +1648,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) } } spin_unlock_irqrestore(&g_tasklet_lock, irq_state); - urbl = 0; + urbl = NULL; /* Look in the orphanage. */ @@ -1658,7 +1662,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) } } ix = (ep_num & 0xf); - urbl = 0; + urbl = NULL; if ((ep_num & USB_DIR_IN) && ix) urbl = oz_remove_urb(port->in_ep[ix], urb); else @@ -1680,7 +1684,7 @@ static void oz_urb_cancel_tasklet(unsigned long unused) unsigned long irq_state; struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); - if (ozhcd == 0) + if (ozhcd == NULL) return; spin_lock_irqsave(&g_tasklet_lock, irq_state); while (!list_empty(&ozhcd->urb_cancel_list)) { @@ -1772,7 +1776,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, jiffies, urb); oz_event_log(OZ_EVT_URB_SUBMIT, oz_get_irq_ctx(), (u16)urb->number_of_packets, urb, urb->pipe); - if (unlikely(ozhcd == 0)) { + if (unlikely(ozhcd == NULL)) { oz_trace2(OZ_TRACE_URB, "%lu: Refused urb(%p) not ozhcd.\n", jiffies, urb); return -EPIPE; @@ -1786,7 +1790,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (port_ix < 0) return -EPIPE; port = &ozhcd->ports[port_ix]; - if (port == 0) + if (port == NULL) return -EPIPE; if ((port->flags & OZ_PORT_F_PRESENT) == 0) { oz_trace("Refusing URB port_ix = %d devnum = %d\n", @@ -1797,7 +1801,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, /* Put request in queue for processing by tasklet. */ urbl = oz_alloc_urb_link(); - if (unlikely(urbl == 0)) + if (unlikely(urbl == NULL)) return -ENOMEM; urbl->urb = urb; spin_lock_irqsave(&g_tasklet_lock, irq_state); @@ -1819,10 +1823,10 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct list_head *e; - if (unlikely(ep == 0)) - return 0; + if (unlikely(ep == NULL)) + return NULL; list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (urbl->urb == urb) { @@ -1834,12 +1838,12 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, oz_event_log(OZ_EVT_EP_CREDIT, usb_pipein(urb->pipe) ? (ep->ep_num | USB_DIR_IN) : ep->ep_num, - 0, 0, ep->credit); + 0, NULL, ep->credit); } return urbl; } } - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Called to dequeue a previously submitted urb for the device. @@ -1848,12 +1852,12 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct oz_hcd *ozhcd = oz_hcd_private(hcd); - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; int rc; unsigned long irq_state; oz_trace2(OZ_TRACE_URB, "%lu: oz_hcd_urb_dequeue(%p)\n", jiffies, urb); urbl = oz_alloc_urb_link(); - if (unlikely(urbl == 0)) + if (unlikely(urbl == NULL)) return -ENOMEM; spin_lock_irqsave(&g_tasklet_lock, irq_state); /* The following function checks the urb is still in the queue @@ -2193,7 +2197,7 @@ static int oz_plat_probe(struct platform_device *dev) struct oz_hcd *ozhcd; oz_trace("oz_plat_probe()\n"); hcd = usb_create_hcd(&g_oz_hc_drv, &dev->dev, dev_name(&dev->dev)); - if (hcd == 0) { + if (hcd == NULL) { oz_trace("Failed to created hcd object OK\n"); return -ENOMEM; } @@ -2232,12 +2236,12 @@ static int oz_plat_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct oz_hcd *ozhcd; oz_trace("oz_plat_remove()\n"); - if (hcd == 0) + if (hcd == NULL) return -1; ozhcd = oz_hcd_private(hcd); spin_lock_bh(&g_hcdlock); if (ozhcd == g_ozhcd) - g_ozhcd = 0; + g_ozhcd = NULL; spin_unlock_bh(&g_hcdlock); oz_trace("Clearing orphanage\n"); oz_hcd_clear_orphanage(ozhcd, -EPIPE); @@ -2278,7 +2282,7 @@ int oz_hcd_init(void) if (err) goto error; g_plat_dev = platform_device_alloc(OZ_PLAT_DEV_NAME, -1); - if (g_plat_dev == 0) { + if (g_plat_dev == NULL) { err = -ENOMEM; goto error1; } diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c index ef6c5ab..57a0cbd 100644 --- a/drivers/staging/ozwpan/ozmain.c +++ b/drivers/staging/ozwpan/ozmain.c @@ -22,7 +22,7 @@ * bind to nothing. '*' means bind to all netcards - this includes non-802.11 * netcards. Bindings can be added later using an IOCTL. */ -char *g_net_dev = ""; +static char *g_net_dev = ""; /*------------------------------------------------------------------------------ * Context: process */ diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 118a4db..f8b9da0 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -46,7 +46,7 @@ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt); static atomic_t g_submitted_isoc = ATOMIC_INIT(0); /* Application handler functions. */ -static struct oz_app_if g_app_if[OZ_APPID_MAX] = { +static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { {oz_usb_init, oz_usb_term, oz_usb_start, @@ -61,8 +61,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED1}, {oz_def_app_init, @@ -70,8 +70,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED2}, {oz_cdev_init, @@ -79,8 +79,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_cdev_start, oz_cdev_stop, oz_cdev_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_SERIAL}, }; /*------------------------------------------------------------------------------ @@ -121,7 +121,7 @@ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt) void oz_pd_set_state(struct oz_pd *pd, unsigned state) { pd->state = state; - oz_event_log(OZ_EVT_PD_STATE, 0, 0, 0, state); + oz_event_log(OZ_EVT_PD_STATE, 0, 0, NULL, state); #ifdef WANT_TRACE switch (state) { case OZ_PD_S_IDLE: @@ -157,7 +157,7 @@ void oz_pd_put(struct oz_pd *pd) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -struct oz_pd *oz_pd_alloc(u8 *mac_addr) +struct oz_pd *oz_pd_alloc(const u8 *mac_addr) { struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC); if (pd) { @@ -171,7 +171,7 @@ struct oz_pd *oz_pd_alloc(u8 *mac_addr) memcpy(pd->mac_addr, mac_addr, ETH_ALEN); if (0 != oz_elt_buf_init(&pd->elt_buff)) { kfree(pd); - pd = 0; + pd = NULL; } spin_lock_init(&pd->tx_frame_lock); INIT_LIST_HEAD(&pd->tx_queue); @@ -235,7 +235,7 @@ void oz_pd_destroy(struct oz_pd *pd) */ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) { - struct oz_app_if *ai; + const struct oz_app_if *ai; int rc = 0; oz_trace("oz_services_start(0x%x) resume(%d)\n", apps, resume); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { @@ -260,7 +260,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) */ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) { - struct oz_app_if *ai; + const struct oz_app_if *ai; oz_trace("oz_stop_services(0x%x) pause(%d)\n", apps, pause); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<<ai->app_id)) { @@ -281,7 +281,7 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) */ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) { - struct oz_app_if *ai; + const struct oz_app_if *ai; int more = 0; for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (ai->heartbeat && (apps & (1<<ai->app_id))) { @@ -355,7 +355,7 @@ int oz_pd_sleep(struct oz_pd *pd) */ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) { - struct oz_tx_frame *f = 0; + struct oz_tx_frame *f = NULL; spin_lock_bh(&pd->tx_frame_lock); if (pd->tx_pool) { f = container_of(pd->tx_pool, struct oz_tx_frame, link); @@ -363,7 +363,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) pd->tx_pool_count--; } spin_unlock_bh(&pd->tx_frame_lock); - if (f == 0) + if (f == NULL) f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC); if (f) { f->total_size = sizeof(struct oz_hdr); @@ -399,7 +399,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) f->link.next = pd->tx_pool; pd->tx_pool = &f->link; pd->tx_pool_count++; - f = 0; + f = NULL; } spin_unlock_bh(&pd->tx_frame_lock); kfree(f); @@ -407,7 +407,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -void oz_set_more_bit(struct sk_buff *skb) +static void oz_set_more_bit(struct sk_buff *skb) { struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); oz_hdr->control |= OZ_F_MORE_DATA; @@ -415,7 +415,7 @@ void oz_set_more_bit(struct sk_buff *skb) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) +static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) { struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK; @@ -433,7 +433,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) if (!empty && !oz_are_elts_available(&pd->elt_buff)) return -1; f = oz_tx_frame_alloc(pd); - if (f == 0) + if (f == NULL) return -1; f->skb = NULL; f->hdr.control = @@ -455,7 +455,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) */ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) { - struct sk_buff *skb = 0; + struct sk_buff *skb; struct net_device *dev = pd->net_dev; struct oz_hdr *oz_hdr; struct oz_elt *elt; @@ -464,8 +464,8 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) * as the space we need. */ skb = alloc_skb(f->total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) - return 0; + if (skb == NULL) + return NULL; /* Reserve the head room for lower layers. */ skb_reserve(skb, LL_RESERVED_SPACE(dev)); @@ -492,7 +492,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) return skb; fail: kfree_skb(skb); - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Context: softirq or process @@ -544,7 +544,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) if (dev_queue_xmit(skb) < 0) { oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame\n"); - oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0); + oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0); return -1; } atomic_inc(&g_submitted_isoc); @@ -555,7 +555,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) } else { kfree_skb(skb); oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n"); - oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0); + oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0); return -1; } } @@ -570,7 +570,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) oz_event_log(OZ_EVT_TX_FRAME, 0, (((u16)f->hdr.control)<<8)|f->hdr.last_pkt_num, - 0, f->hdr.pkt_num); + NULL, f->hdr.pkt_num); if (dev_queue_xmit(skb) < 0) return -1; @@ -620,7 +620,7 @@ out: oz_prepare_frame(pd, 1); */ static int oz_send_isoc_frame(struct oz_pd *pd) { - struct sk_buff *skb = 0; + struct sk_buff *skb; struct net_device *dev = pd->net_dev; struct oz_hdr *oz_hdr; struct oz_elt *elt; @@ -634,7 +634,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) if (list.next == &list) return 0; skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) { + if (skb == NULL) { oz_trace("Cannot alloc skb\n"); oz_elt_info_free_chain(&pd->elt_buff, &list); return -1; @@ -659,7 +659,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) memcpy(elt, ei->data, ei->length); elt = oz_next_elt(elt); } - oz_event_log(OZ_EVT_TX_ISOC, 0, 0, 0, 0); + oz_event_log(OZ_EVT_TX_ISOC, 0, 0, NULL, 0); dev_queue_xmit(skb); oz_elt_info_free_chain(&pd->elt_buff, &list); return 0; @@ -671,8 +671,8 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) { struct list_head *e; struct oz_tx_frame *f; - struct list_head *first = 0; - struct list_head *last = 0; + struct list_head *first = NULL; + struct list_head *last = NULL; u8 diff; u32 pkt_num; @@ -686,7 +686,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) break; oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n", pkt_num, pd->nb_queued_frames); - if (first == 0) + if (first == NULL) first = e; last = e; e = e->next; @@ -695,7 +695,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) if (first) { last->next->prev = &pd->tx_queue; pd->tx_queue.next = last->next; - last->next = 0; + last->next = NULL; } pd->last_sent_frame = &pd->tx_queue; spin_unlock(&pd->tx_frame_lock); @@ -718,7 +718,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num) if (st->ep_num == ep_num) return st; } - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Context: softirq @@ -733,7 +733,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) spin_lock_bh(&pd->stream_lock); if (!pd_stream_find(pd, ep_num)) { list_add(&st->link, &pd->stream_list); - st = 0; + st = NULL; } spin_unlock_bh(&pd->stream_lock); kfree(st); @@ -774,19 +774,19 @@ static void oz_isoc_destructor(struct sk_buff *skb) /*------------------------------------------------------------------------------ * Context: softirq */ -int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) +int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) { struct net_device *dev = pd->net_dev; struct oz_isoc_stream *st; u8 nb_units = 0; - struct sk_buff *skb = 0; - struct oz_hdr *oz_hdr = 0; + struct sk_buff *skb = NULL; + struct oz_hdr *oz_hdr = NULL; int size = 0; spin_lock_bh(&pd->stream_lock); st = pd_stream_find(pd, ep_num); if (st) { skb = st->skb; - st->skb = 0; + st->skb = NULL; nb_units = st->nb_units; st->nb_units = 0; oz_hdr = st->oz_hdr; @@ -799,7 +799,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) /* Allocate enough space for max size frame. */ skb = alloc_skb(pd->max_tx_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return 0; /* Reserve the head room for lower layers. */ skb_reserve(skb, LL_RESERVED_SPACE(dev)); @@ -874,13 +874,13 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) oz_event_log(OZ_EVT_TX_ISOC, nb_units, iso.frame_number, skb, atomic_read(&g_submitted_isoc)); if (dev_queue_xmit(skb) < 0) { - oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0); + oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0); return -1; } else return 0; } -out: oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0); +out: oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0); kfree_skb(skb); return -1; @@ -913,7 +913,7 @@ void oz_apps_term(void) */ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) { - struct oz_app_if *ai; + const struct oz_app_if *ai; if (app_id == 0 || app_id > OZ_APPID_MAX) return; ai = &g_app_if[app_id-1]; @@ -925,7 +925,7 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) void oz_pd_indicate_farewells(struct oz_pd *pd) { struct oz_farewell *f; - struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; + const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; while (1) { oz_polling_lock_bh(); if (list_empty(&pd->farewell_list)) { diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index d35b0ea..fbf47cb 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -99,7 +99,7 @@ struct oz_pd { #define OZ_MAX_QUEUED_FRAMES 4 -struct oz_pd *oz_pd_alloc(u8 *mac_addr); +struct oz_pd *oz_pd_alloc(const u8 *mac_addr); void oz_pd_destroy(struct oz_pd *pd); void oz_pd_get(struct oz_pd *pd); void oz_pd_put(struct oz_pd *pd); @@ -115,7 +115,7 @@ void oz_send_queued_frames(struct oz_pd *pd, int backlog); void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn); int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num); int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num); -int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len); +int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len); void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt); void oz_apps_init(void); void oz_apps_term(void); diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index e00a539..3badf15 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -98,7 +98,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) int sz = sizeof(struct oz_hdr) + sizeof(struct oz_elt) + sizeof(struct oz_elt_connect_rsp); skb = alloc_skb(sz + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return; skb_reserve(skb, LL_RESERVED_SPACE(dev)); skb_reset_network_header(skb); @@ -116,7 +116,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) oz_hdr->control = (OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT); oz_hdr->last_pkt_num = 0; put_unaligned(0, &oz_hdr->pkt_num); - oz_event_log(OZ_EVT_CONNECT_RSP, 0, 0, 0, 0); + oz_event_log(OZ_EVT_CONNECT_RSP, 0, 0, NULL, 0); elt->type = OZ_ELT_CONNECT_RSP; elt->length = sizeof(struct oz_elt_connect_rsp); memset(body, 0, sizeof(struct oz_elt_connect_rsp)); @@ -171,7 +171,7 @@ static void pd_set_presleep(struct oz_pd *pd, u8 presleep) * Context: softirq-serialized */ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, - u8 *pd_addr, struct net_device *net_dev) + const u8 *pd_addr, struct net_device *net_dev) { struct oz_pd *pd; struct oz_elt_connect_req *body = @@ -179,17 +179,17 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, u8 rsp_status = OZ_STATUS_SUCCESS; u8 stop_needed = 0; u16 new_apps = g_apps; - struct net_device *old_net_dev = 0; - struct oz_pd *free_pd = 0; + struct net_device *old_net_dev = NULL; + struct oz_pd *free_pd = NULL; if (cur_pd) { pd = cur_pd; spin_lock_bh(&g_polling_lock); } else { - struct oz_pd *pd2 = 0; + struct oz_pd *pd2 = NULL; struct list_head *e; pd = oz_pd_alloc(pd_addr); - if (pd == 0) - return 0; + if (pd == NULL) + return NULL; pd->last_rx_time_j = jiffies; spin_lock_bh(&g_polling_lock); list_for_each(e, &g_pd_list) { @@ -203,9 +203,9 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, if (pd != pd2) list_add_tail(&pd->link, &g_pd_list); } - if (pd == 0) { + if (pd == NULL) { spin_unlock_bh(&g_polling_lock); - return 0; + return NULL; } if (pd->net_dev != net_dev) { old_net_dev = pd->net_dev; @@ -294,7 +294,7 @@ done: if (stop_needed) oz_pd_stop(pd); oz_pd_put(pd); - pd = 0; + pd = NULL; } if (old_net_dev) dev_put(old_net_dev); @@ -306,7 +306,7 @@ done: * Context: softirq-serialized */ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, - u8 *report, u8 len) + const u8 *report, u8 len) { struct oz_farewell *f; struct oz_farewell *f2; @@ -340,14 +340,14 @@ static void oz_rx_frame(struct sk_buff *skb) u8 *src_addr; struct oz_elt *elt; int length; - struct oz_pd *pd = 0; + struct oz_pd *pd = NULL; struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); int dup = 0; u32 pkt_num; oz_event_log(OZ_EVT_RX_PROCESS, 0, (((u16)oz_hdr->control)<<8)|oz_hdr->last_pkt_num, - 0, oz_hdr->pkt_num); + NULL, oz_hdr->pkt_num); oz_trace2(OZ_TRACE_RX_FRAMES, "RX frame PN=0x%x LPN=0x%x control=0x%x\n", oz_hdr->pkt_num, oz_hdr->last_pkt_num, oz_hdr->control); @@ -402,7 +402,7 @@ static void oz_rx_frame(struct sk_buff *skb) break; switch (elt->type) { case OZ_ELT_CONNECT_REQ: - oz_event_log(OZ_EVT_CONNECT_REQ, 0, 0, 0, 0); + oz_event_log(OZ_EVT_CONNECT_REQ, 0, 0, NULL, 0); oz_trace("RX: OZ_ELT_CONNECT_REQ\n"); pd = oz_connect_req(pd, elt, src_addr, skb->dev); break; @@ -456,7 +456,7 @@ done: */ void oz_protocol_term(void) { - struct list_head *chain = 0; + struct list_head *chain; del_timer_sync(&g_timer); /* Walk the list of bindings and remove each one. */ @@ -487,7 +487,7 @@ void oz_protocol_term(void) spin_lock_bh(&g_polling_lock); } chain = g_timer_pool; - g_timer_pool = 0; + g_timer_pool = NULL; spin_unlock_bh(&g_polling_lock); while (chain) { struct oz_timer *t = container_of(chain, struct oz_timer, link); @@ -534,25 +534,25 @@ static void oz_protocol_timer(unsigned long arg) /* This happens if we remove the current timer but can't stop * the timer from firing. In this case just get out. */ - oz_event_log(OZ_EVT_TIMER, 0, 0, 0, 0); + oz_event_log(OZ_EVT_TIMER, 0, 0, NULL, 0); spin_unlock_bh(&g_polling_lock); return; } g_timer_state = OZ_TIMER_IN_HANDLER; t = g_cur_timer; - g_cur_timer = 0; + g_cur_timer = NULL; list_del(&t->link); spin_unlock_bh(&g_polling_lock); do { pd = t->pd; - oz_event_log(OZ_EVT_TIMER, 0, t->type, 0, 0); + oz_event_log(OZ_EVT_TIMER, 0, t->type, NULL, 0); oz_pd_handle_timer(pd, t->type); spin_lock_bh(&g_polling_lock); if (g_timer_pool_count < OZ_MAX_TIMER_POOL_SIZE) { t->link.next = g_timer_pool; g_timer_pool = &t->link; g_timer_pool_count++; - t = 0; + t = NULL; } if (!list_empty(&g_timer_list)) { t2 = container_of(g_timer_list.next, @@ -560,9 +560,9 @@ static void oz_protocol_timer(unsigned long arg) if (time_before_eq(t2->due_time, jiffies)) list_del(&t2->link); else - t2 = 0; + t2 = NULL; } else { - t2 = 0; + t2 = NULL; } spin_unlock_bh(&g_polling_lock); oz_pd_put(pd); @@ -583,12 +583,12 @@ static void oz_protocol_timer_start(void) container_of(g_timer_list.next, struct oz_timer, link); if (g_timer_state == OZ_TIMER_SET) { oz_event_log(OZ_EVT_TIMER_CTRL, 3, - (u16)g_cur_timer->type, 0, + (u16)g_cur_timer->type, NULL, (unsigned)g_cur_timer->due_time); mod_timer(&g_timer, g_cur_timer->due_time); } else { oz_event_log(OZ_EVT_TIMER_CTRL, 4, - (u16)g_cur_timer->type, 0, + (u16)g_cur_timer->type, NULL, (unsigned)g_cur_timer->due_time); g_timer.expires = g_cur_timer->due_time; g_timer.function = oz_protocol_timer; @@ -608,9 +608,9 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, int remove) { struct list_head *e; - struct oz_timer *t = 0; + struct oz_timer *t = NULL; int restart_needed = 0; - oz_event_log(OZ_EVT_TIMER_CTRL, 1, (u16)type, 0, (unsigned)due_time); + oz_event_log(OZ_EVT_TIMER_CTRL, 1, (u16)type, NULL, (unsigned)due_time); spin_lock(&g_polling_lock); if (remove) { list_for_each(e, &g_timer_list) { @@ -618,12 +618,12 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, if ((t->pd == pd) && (t->type == type)) { if (g_cur_timer == t) { restart_needed = 1; - g_cur_timer = 0; + g_cur_timer = NULL; } list_del(e); break; } - t = 0; + t = NULL; } } if (!t) { @@ -647,7 +647,7 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, t2 = container_of(e, struct oz_timer, link); if (time_before(due_time, t2->due_time)) { if (t2 == g_cur_timer) { - g_cur_timer = 0; + g_cur_timer = NULL; restart_needed = 1; } break; @@ -668,18 +668,18 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, */ void oz_timer_delete(struct oz_pd *pd, int type) { - struct list_head *chain = 0; + struct list_head *chain = NULL; struct oz_timer *t; struct oz_timer *n; int restart_needed = 0; int release = 0; - oz_event_log(OZ_EVT_TIMER_CTRL, 2, (u16)type, 0, 0); + oz_event_log(OZ_EVT_TIMER_CTRL, 2, (u16)type, NULL, 0); spin_lock(&g_polling_lock); list_for_each_entry_safe(t, n, &g_timer_list, link) { if ((t->pd == pd) && ((type == 0) || (t->type == type))) { if (g_cur_timer == t) { restart_needed = 1; - g_cur_timer = 0; + g_cur_timer = NULL; del_timer(&g_timer); } list_del(&t->link); @@ -734,7 +734,7 @@ void oz_pd_request_heartbeat(struct oz_pd *pd) /*------------------------------------------------------------------------------ * Context: softirq or process */ -struct oz_pd *oz_pd_find(u8 *mac_addr) +struct oz_pd *oz_pd_find(const u8 *mac_addr) { struct oz_pd *pd; struct list_head *e; @@ -748,7 +748,7 @@ struct oz_pd *oz_pd_find(u8 *mac_addr) } } spin_unlock_bh(&g_polling_lock); - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Context: process @@ -770,9 +770,9 @@ void oz_app_enable(int app_id, int enable) static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { - oz_event_log(OZ_EVT_RX_FRAME, 0, 0, 0, 0); + oz_event_log(OZ_EVT_RX_FRAME, 0, 0, NULL, 0); skb = skb_share_check(skb, GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return 0; spin_lock_bh(&g_rx_queue.lock); if (g_processing_rx) { @@ -815,14 +815,14 @@ void oz_binding_add(char *net_dev) oz_trace("Adding binding: %s\n", net_dev); binding->ptype.dev = dev_get_by_name(&init_net, net_dev); - if (binding->ptype.dev == 0) { + if (binding->ptype.dev == NULL) { oz_trace("Netdev %s not found\n", net_dev); kfree(binding); - binding = 0; + binding = NULL; } } else { oz_trace("Binding to all netcards\n"); - binding->ptype.dev = 0; + binding->ptype.dev = NULL; } if (binding) { dev_add_pack(&binding->ptype); @@ -876,7 +876,7 @@ static void pd_stop_all_for_device(struct net_device *net_dev) */ void oz_binding_remove(char *net_dev) { - struct oz_binding *binding = 0; + struct oz_binding *binding; struct oz_binding **link; oz_trace("Removing binding: %s\n", net_dev); spin_lock_bh(&g_binding_lock); @@ -923,7 +923,7 @@ int oz_protocol_init(char *devs) { skb_queue_head_init(&g_rx_queue); if (devs && (devs[0] == '*')) { - oz_binding_add(0); + oz_binding_add(NULL); } else { char d[32]; while (*devs) { diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 755a08d..93bb4c0 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -62,7 +62,7 @@ int oz_protocol_init(char *devs); void oz_protocol_term(void); int oz_get_pd_list(struct oz_mac_addr *addr, int max_count); void oz_app_enable(int app_id, int enable); -struct oz_pd *oz_pd_find(u8 *mac_addr); +struct oz_pd *oz_pd_find(const u8 *mac_addr); void oz_binding_add(char *net_dev); void oz_binding_remove(char *net_dev); void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, diff --git a/drivers/staging/ozwpan/ozusbif.h b/drivers/staging/ozwpan/ozusbif.h index 3acf598..8531438 100644 --- a/drivers/staging/ozwpan/ozusbif.h +++ b/drivers/staging/ozwpan/ozusbif.h @@ -21,7 +21,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num); /* Request functions. */ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, - u8 *data, int data_len); + const u8 *data, int data_len); int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, u8 index, u16 windex, int offset, int len); int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb); @@ -30,13 +30,13 @@ void oz_usb_request_heartbeat(void *hpd); /* Confirmation functions. */ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, - u8 *desc, int length, int offset, int total_size); + const u8 *desc, int length, int offset, int total_size); void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, - u8 *data, int data_len); + const u8 *data, int data_len); /* Indication functions. */ -void oz_hcd_data_ind(void *hport, u8 endpoint, u8 *data, int data_len); +void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len); int oz_hcd_heartbeat(void *hport); diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 8fa7f25..543a941 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -34,7 +34,7 @@ */ int oz_usb_init(void) { - oz_event_log(OZ_EVT_SERVICE, 1, OZ_APPID_USB, 0, 0); + oz_event_log(OZ_EVT_SERVICE, 1, OZ_APPID_USB, NULL, 0); return oz_hcd_init(); } /*------------------------------------------------------------------------------ @@ -43,7 +43,7 @@ int oz_usb_init(void) */ void oz_usb_term(void) { - oz_event_log(OZ_EVT_SERVICE, 2, OZ_APPID_USB, 0, 0); + oz_event_log(OZ_EVT_SERVICE, 2, OZ_APPID_USB, NULL, 0); oz_hcd_term(); } /*------------------------------------------------------------------------------ @@ -54,8 +54,8 @@ int oz_usb_start(struct oz_pd *pd, int resume) { int rc = 0; struct oz_usb_ctx *usb_ctx; - struct oz_usb_ctx *old_ctx = 0; - oz_event_log(OZ_EVT_SERVICE, 3, OZ_APPID_USB, 0, resume); + struct oz_usb_ctx *old_ctx; + oz_event_log(OZ_EVT_SERVICE, 3, OZ_APPID_USB, NULL, resume); if (resume) { oz_trace("USB service resumed.\n"); return 0; @@ -65,7 +65,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) * has a USB context then we will destroy it. */ usb_ctx = kzalloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC); - if (usb_ctx == 0) + if (usb_ctx == NULL) return -ENOMEM; atomic_set(&usb_ctx->ref_count, 1); usb_ctx->pd = pd; @@ -76,7 +76,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) */ spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); old_ctx = pd->app_ctx[OZ_APPID_USB-1]; - if (old_ctx == 0) + if (old_ctx == NULL) pd->app_ctx[OZ_APPID_USB-1] = usb_ctx; oz_usb_get(pd->app_ctx[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); @@ -98,10 +98,10 @@ int oz_usb_start(struct oz_pd *pd, int resume) oz_hcd_pd_reset(usb_ctx, usb_ctx->hport); } else { usb_ctx->hport = oz_hcd_pd_arrived(usb_ctx); - if (usb_ctx->hport == 0) { + if (usb_ctx->hport == NULL) { oz_trace("USB hub returned null port.\n"); spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); - pd->app_ctx[OZ_APPID_USB-1] = 0; + pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); oz_usb_put(usb_ctx); rc = -1; @@ -117,14 +117,14 @@ int oz_usb_start(struct oz_pd *pd, int resume) void oz_usb_stop(struct oz_pd *pd, int pause) { struct oz_usb_ctx *usb_ctx; - oz_event_log(OZ_EVT_SERVICE, 4, OZ_APPID_USB, 0, pause); + oz_event_log(OZ_EVT_SERVICE, 4, OZ_APPID_USB, NULL, pause); if (pause) { oz_trace("USB service paused.\n"); return; } spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; - pd->app_ctx[OZ_APPID_USB-1] = 0; + pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); if (usb_ctx) { unsigned long tout = jiffies + HZ; @@ -182,7 +182,7 @@ int oz_usb_heartbeat(struct oz_pd *pd) if (usb_ctx) oz_usb_get(usb_ctx); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); - if (usb_ctx == 0) + if (usb_ctx == NULL) return rc; if (usb_ctx->stopped) goto done; diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 66bd576..4e4b650 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -71,7 +71,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, oz_trace(" len = 0x%x\n", len); if (len > 200) len = 200; - if (ei == 0) + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; elt->length = sizeof(struct oz_get_desc_req); @@ -97,7 +97,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_set_config_req *body; - if (ei == 0) + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; elt->length = sizeof(struct oz_set_config_req); @@ -118,7 +118,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_set_interface_req *body; - if (ei == 0) + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; elt->length = sizeof(struct oz_set_interface_req); @@ -141,7 +141,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_feature_req *body; - if (ei == 0) + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; elt->length = sizeof(struct oz_feature_req); @@ -157,7 +157,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, * Context: tasklet */ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, - u8 request, __le16 value, __le16 index, u8 *data, int data_len) + u8 request, __le16 value, __le16 index, const u8 *data, int data_len) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; struct oz_pd *pd = usb_ctx->pd; @@ -165,7 +165,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_vendor_class_req *body; - if (ei == 0) + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; elt->length = sizeof(struct oz_vendor_class_req) - 1 + data_len; @@ -184,7 +184,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, * Context: tasklet */ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, - u8 *data, int data_len) + const u8 *data, int data_len) { unsigned wvalue = le16_to_cpu(setup->wValue); unsigned windex = le16_to_cpu(setup->wIndex); @@ -264,7 +264,7 @@ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) int unit_count; int unit_size; int rem; - if (ei == 0) + if (ei == NULL) return -1; rem = MAX_ISOC_FIXED_DATA; elt = (struct oz_elt *)ei->data; @@ -305,7 +305,7 @@ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, +static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, struct oz_usb_hdr *usb_hdr, int len) { struct oz_data *data_hdr = (struct oz_data *)usb_hdr; @@ -359,7 +359,7 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) if (usb_ctx) oz_usb_get(usb_ctx); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); - if (usb_ctx == 0) + if (usb_ctx == NULL) return; /* Context has gone so nothing to do. */ if (usb_ctx->stopped) goto done; @@ -391,14 +391,14 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) struct oz_set_config_rsp *body = (struct oz_set_config_rsp *)usb_hdr; oz_hcd_control_cnf(usb_ctx->hport, body->req_id, - body->rcode, 0, 0); + body->rcode, NULL, 0); } break; case OZ_SET_INTERFACE_RSP: { struct oz_set_interface_rsp *body = (struct oz_set_interface_rsp *)usb_hdr; oz_hcd_control_cnf(usb_ctx->hport, - body->req_id, body->rcode, 0, 0); + body->req_id, body->rcode, NULL, 0); } break; case OZ_VENDOR_CLASS_RSP: { @@ -427,7 +427,7 @@ void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len) if (usb_ctx) oz_usb_get(usb_ctx); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); - if (usb_ctx == 0) + if (usb_ctx == NULL) return; /* Context has gone so nothing to do. */ if (!usb_ctx->stopped) { oz_trace("Farewell indicated ep = 0x%x\n", ep_num); diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index e3113ec..c54df39 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -185,7 +185,7 @@ struct logical_input { } u; }; -LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ +static LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ /* physical contacts history * Physical contacts are a 45 bits string of 9 groups of 5 bits each. @@ -527,10 +527,10 @@ MODULE_PARM_DESC(lcd_cl_pin, "# of the // port pin connected to serial LCD 'SCL' " "signal, with polarity (-17..17)"); -static unsigned char *lcd_char_conv; +static const unsigned char *lcd_char_conv; /* for some LCD drivers (ks0074) we need a charset conversion table. */ -static unsigned char lcd_char_conv_ks0074[256] = { +static const unsigned char lcd_char_conv_ks0074[256] = { /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */ /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -566,7 +566,7 @@ static unsigned char lcd_char_conv_ks0074[256] = { /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79, }; -char old_keypad_profile[][4][9] = { +static const char old_keypad_profile[][4][9] = { {"S0", "Left\n", "Left\n", ""}, {"S1", "Down\n", "Down\n", ""}, {"S2", "Up\n", "Up\n", ""}, @@ -577,7 +577,7 @@ char old_keypad_profile[][4][9] = { }; /* signals, press, repeat, release */ -char new_keypad_profile[][4][9] = { +static const char new_keypad_profile[][4][9] = { {"S0", "Left\n", "Left\n", ""}, {"S1", "Down\n", "Down\n", ""}, {"S2", "Up\n", "Up\n", ""}, @@ -590,7 +590,7 @@ char new_keypad_profile[][4][9] = { }; /* signals, press, repeat, release */ -char nexcom_keypad_profile[][4][9] = { +static const char nexcom_keypad_profile[][4][9] = { {"a-p-e-", "Down\n", "Down\n", ""}, {"a-p-E-", "Ret\n", "Ret\n", ""}, {"a-P-E-", "Esc\n", "Esc\n", ""}, @@ -599,7 +599,7 @@ char nexcom_keypad_profile[][4][9] = { {"", "", "", ""} }; -static char (*keypad_profile)[4][9] = old_keypad_profile; +static const char (*keypad_profile)[4][9] = old_keypad_profile; /* FIXME: this should be converted to a bit array containing signals states */ static struct { @@ -669,7 +669,7 @@ static void panel_set_bits(void) * out(dport, in(dport) & d_val[2] | d_val[signal_state]) * out(cport, in(cport) & c_val[2] | c_val[signal_state]) */ -void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) +static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) { int d_bit, c_bit, inv; @@ -1372,14 +1372,14 @@ static struct miscdevice lcd_dev = { }; /* public function usable from the kernel for any purpose */ -void panel_lcd_print(char *s) +static void panel_lcd_print(const char *s) { if (lcd_enabled && lcd_initialized) lcd_write(NULL, s, strlen(s), NULL); } /* initialize the LCD driver */ -void lcd_init(void) +static void lcd_init(void) { switch (lcd_type) { case LCD_TYPE_OLD: @@ -1638,7 +1638,7 @@ static struct miscdevice keypad_dev = { &keypad_fops }; -static void keypad_send_key(char *string, int max_len) +static void keypad_send_key(const char *string, int max_len) { if (init_in_progress) return; @@ -1929,7 +1929,7 @@ static void init_scan_timer(void) * corresponding to out and in bits respectively. * returns 1 if ok, 0 if error (in which case, nothing is written). */ -static int input_name2mask(char *name, pmask_t *mask, pmask_t *value, +static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value, char *imask, char *omask) { static char sigtab[10] = "EeSsPpAaBb"; @@ -1977,8 +1977,9 @@ static int input_name2mask(char *name, pmask_t *mask, pmask_t *value, * strings <press>, <repeat>, <release> for these respective events. * Returns the pointer to the new key if ok, NULL if the key could not be bound. */ -static struct logical_input *panel_bind_key(char *name, char *press, - char *repeat, char *release) +static struct logical_input *panel_bind_key(const char *name, const char *press, + const char *repeat, + const char *release) { struct logical_input *key; @@ -2178,7 +2179,7 @@ static struct parport_driver panel_driver = { }; /* init function */ -int panel_init(void) +static int panel_init(void) { /* for backwards compatibility */ if (keypad_type < 0) diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig deleted file mode 100644 index 3abf661..0000000 --- a/drivers/staging/ramster/Kconfig +++ /dev/null @@ -1,31 +0,0 @@ -config ZCACHE2 - bool "Dynamic compression of swap pages and clean pagecache pages" - depends on CRYPTO=y && SWAP=y && CLEANCACHE && FRONTSWAP && !ZCACHE - select CRYPTO_LZO - default n - help - Zcache2 doubles RAM efficiency while providing a significant - performance boosts on many workloads. Zcache2 uses - compression and an in-kernel implementation of transcendent - memory to store clean page cache pages and swap in RAM, - providing a noticeable reduction in disk I/O. Zcache2 - is a complete rewrite of the older zcache; it was intended to - be a merge but that has been blocked due to political and - technical disagreements. It is intended that they will merge - again in the future. Until then, zcache2 is a single-node - version of ramster. - -config RAMSTER - bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem" - depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE2=y - depends on NET - # must ensure struct page is 8-byte aligned - select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT - default n - help - RAMster allows RAM on other machines in a cluster to be utilized - dynamically and symmetrically instead of swapping to a local swap - disk, thus improving performance on memory-constrained workloads - while minimizing total RAM across the cluster. RAMster, like - zcache2, compresses swap pages into local RAM, but then remotifies - the compressed pages to another node in the RAMster cluster. diff --git a/drivers/staging/ramster/Makefile b/drivers/staging/ramster/Makefile deleted file mode 100644 index 2d8b9d0..0000000 --- a/drivers/staging/ramster/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -zcache-y := zcache-main.o tmem.o zbud.o -zcache-$(CONFIG_RAMSTER) += ramster/ramster.o ramster/r2net.o -zcache-$(CONFIG_RAMSTER) += ramster/nodemanager.o ramster/tcp.o -zcache-$(CONFIG_RAMSTER) += ramster/heartbeat.o ramster/masklog.o - -obj-$(CONFIG_ZCACHE2) += zcache.o diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c deleted file mode 100644 index a2b7e03..0000000 --- a/drivers/staging/ramster/tmem.c +++ /dev/null @@ -1,894 +0,0 @@ -/* - * In-kernel transcendent memory (generic implementation) - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - * - * The primary purpose of Transcedent Memory ("tmem") is to map object-oriented - * "handles" (triples containing a pool id, and object id, and an index), to - * pages in a page-accessible memory (PAM). Tmem references the PAM pages via - * an abstract "pampd" (PAM page-descriptor), which can be operated on by a - * set of functions (pamops). Each pampd contains some representation of - * PAGE_SIZE bytes worth of data. For those familiar with key-value stores, - * the tmem handle is a three-level hierarchical key, and the value is always - * reconstituted (but not necessarily stored) as PAGE_SIZE bytes and is - * referenced in the datastore by the pampd. The hierarchy is required - * to ensure that certain invalidation functions can be performed efficiently - * (i.e. flush all indexes associated with this object_id, or - * flush all objects associated with this pool). - * - * Tmem must support potentially millions of pages and must be able to insert, - * find, and delete these pages at a potential frequency of thousands per - * second concurrently across many CPUs, (and, if used with KVM, across many - * vcpus across many guests). Tmem is tracked with a hierarchy of data - * structures, organized by the elements in the handle-tuple: pool_id, - * object_id, and page index. One or more "clients" (e.g. guests) each - * provide one or more tmem_pools. Each pool, contains a hash table of - * rb_trees of tmem_objs. Each tmem_obj contains a radix-tree-like tree - * of pointers, with intermediate nodes called tmem_objnodes. Each leaf - * pointer in this tree points to a pampd, which is accessible only through - * a small set of callbacks registered by the PAM implementation (see - * tmem_register_pamops). Tmem only needs to memory allocation for objs - * and objnodes and this is done via a set of callbacks that must be - * registered by the tmem host implementation (e.g. see tmem_register_hostops). - */ - -#include <linux/list.h> -#include <linux/spinlock.h> -#include <linux/atomic.h> -#ifdef CONFIG_RAMSTER -#include <linux/delay.h> -#endif - -#include "tmem.h" - -/* data structure sentinels used for debugging... see tmem.h */ -#define POOL_SENTINEL 0x87658765 -#define OBJ_SENTINEL 0x12345678 -#define OBJNODE_SENTINEL 0xfedcba09 - -/* - * A tmem host implementation must use this function to register callbacks - * for memory allocation. - */ -static struct tmem_hostops tmem_hostops; - -static void tmem_objnode_tree_init(void); - -void tmem_register_hostops(struct tmem_hostops *m) -{ - tmem_objnode_tree_init(); - tmem_hostops = *m; -} - -/* - * A tmem host implementation must use this function to register - * callbacks for a page-accessible memory (PAM) implementation. - */ -static struct tmem_pamops tmem_pamops; - -void tmem_register_pamops(struct tmem_pamops *m) -{ - tmem_pamops = *m; -} - -/* - * Oid's are potentially very sparse and tmem_objs may have an indeterminately - * short life, being added and deleted at a relatively high frequency. - * So an rb_tree is an ideal data structure to manage tmem_objs. But because - * of the potentially huge number of tmem_objs, each pool manages a hashtable - * of rb_trees to reduce search, insert, delete, and rebalancing time. - * Each hashbucket also has a lock to manage concurrent access and no - * searches, inserts, or deletions can be performed unless the lock is held. - * As a result, care must be taken to ensure tmem routines are not called - * recursively; the vast majority of the time, a recursive call may work - * but a deadlock will occur a small fraction of the time due to the - * hashbucket lock. - * - * The following routines manage tmem_objs. In all of these routines, - * the hashbucket lock is already held. - */ - -/* Search for object==oid in pool, returns object if found. */ -static struct tmem_obj *__tmem_obj_find(struct tmem_hashbucket *hb, - struct tmem_oid *oidp, - struct rb_node **parent, - struct rb_node ***link) -{ - struct rb_node *_parent = NULL, **rbnode; - struct tmem_obj *obj = NULL; - - rbnode = &hb->obj_rb_root.rb_node; - while (*rbnode) { - BUG_ON(RB_EMPTY_NODE(*rbnode)); - _parent = *rbnode; - obj = rb_entry(*rbnode, struct tmem_obj, - rb_tree_node); - switch (tmem_oid_compare(oidp, &obj->oid)) { - case 0: /* equal */ - goto out; - case -1: - rbnode = &(*rbnode)->rb_left; - break; - case 1: - rbnode = &(*rbnode)->rb_right; - break; - } - } - - if (parent) - *parent = _parent; - if (link) - *link = rbnode; - obj = NULL; -out: - return obj; -} - -static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb, - struct tmem_oid *oidp) -{ - return __tmem_obj_find(hb, oidp, NULL, NULL); -} - -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *, bool); - -/* Free an object that has no more pampds in it. */ -static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb) -{ - struct tmem_pool *pool; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pampd_count > 0); - pool = obj->pool; - BUG_ON(pool == NULL); - if (obj->objnode_tree_root != NULL) /* may be "stump" with no leaves */ - tmem_pampd_destroy_all_in_obj(obj, false); - BUG_ON(obj->objnode_tree_root != NULL); - BUG_ON((long)obj->objnode_count != 0); - atomic_dec(&pool->obj_count); - BUG_ON(atomic_read(&pool->obj_count) < 0); - INVERT_SENTINEL(obj, OBJ); - obj->pool = NULL; - tmem_oid_set_invalid(&obj->oid); - rb_erase(&obj->rb_tree_node, &hb->obj_rb_root); -} - -/* - * Initialize, and insert an tmem_object_root (called only if find failed). - */ -static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, - struct tmem_pool *pool, - struct tmem_oid *oidp) -{ - struct rb_root *root = &hb->obj_rb_root; - struct rb_node **new = NULL, *parent = NULL; - - BUG_ON(pool == NULL); - atomic_inc(&pool->obj_count); - obj->objnode_tree_height = 0; - obj->objnode_tree_root = NULL; - obj->pool = pool; - obj->oid = *oidp; - obj->objnode_count = 0; - obj->pampd_count = 0; -#ifdef CONFIG_RAMSTER - if (tmem_pamops.new_obj != NULL) - (*tmem_pamops.new_obj)(obj); -#endif - SET_SENTINEL(obj, OBJ); - - if (__tmem_obj_find(hb, oidp, &parent, &new)) - BUG(); - - rb_link_node(&obj->rb_tree_node, parent, new); - rb_insert_color(&obj->rb_tree_node, root); -} - -/* - * Tmem is managed as a set of tmem_pools with certain attributes, such as - * "ephemeral" vs "persistent". These attributes apply to all tmem_objs - * and all pampds that belong to a tmem_pool. A tmem_pool is created - * or deleted relatively rarely (for example, when a filesystem is - * mounted or unmounted). - */ - -/* flush all data from a pool and, optionally, free it */ -static void tmem_pool_flush(struct tmem_pool *pool, bool destroy) -{ - struct rb_node *rbnode; - struct tmem_obj *obj; - struct tmem_hashbucket *hb = &pool->hashbucket[0]; - int i; - - BUG_ON(pool == NULL); - for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) { - spin_lock(&hb->lock); - rbnode = rb_first(&hb->obj_rb_root); - while (rbnode != NULL) { - obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node); - rbnode = rb_next(rbnode); - tmem_pampd_destroy_all_in_obj(obj, true); - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - } - spin_unlock(&hb->lock); - } - if (destroy) - list_del(&pool->pool_list); -} - -/* - * A tmem_obj contains a radix-tree-like tree in which the intermediate - * nodes are called tmem_objnodes. (The kernel lib/radix-tree.c implementation - * is very specialized and tuned for specific uses and is not particularly - * suited for use from this code, though some code from the core algorithms has - * been reused, thus the copyright notices below). Each tmem_objnode contains - * a set of pointers which point to either a set of intermediate tmem_objnodes - * or a set of of pampds. - * - * Portions Copyright (C) 2001 Momchil Velikov - * Portions Copyright (C) 2001 Christoph Hellwig - * Portions Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com> - */ - -struct tmem_objnode_tree_path { - struct tmem_objnode *objnode; - int offset; -}; - -/* objnode height_to_maxindex translation */ -static unsigned long tmem_objnode_tree_h2max[OBJNODE_TREE_MAX_PATH + 1]; - -static void tmem_objnode_tree_init(void) -{ - unsigned int ht, tmp; - - for (ht = 0; ht < ARRAY_SIZE(tmem_objnode_tree_h2max); ht++) { - tmp = ht * OBJNODE_TREE_MAP_SHIFT; - if (tmp >= OBJNODE_TREE_INDEX_BITS) - tmem_objnode_tree_h2max[ht] = ~0UL; - else - tmem_objnode_tree_h2max[ht] = - (~0UL >> (OBJNODE_TREE_INDEX_BITS - tmp - 1)) >> 1; - } -} - -static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj) -{ - struct tmem_objnode *objnode; - - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - objnode = (*tmem_hostops.objnode_alloc)(obj->pool); - if (unlikely(objnode == NULL)) - goto out; - objnode->obj = obj; - SET_SENTINEL(objnode, OBJNODE); - memset(&objnode->slots, 0, sizeof(objnode->slots)); - objnode->slots_in_use = 0; - obj->objnode_count++; -out: - return objnode; -} - -static void tmem_objnode_free(struct tmem_objnode *objnode) -{ - struct tmem_pool *pool; - int i; - - BUG_ON(objnode == NULL); - for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++) - BUG_ON(objnode->slots[i] != NULL); - ASSERT_SENTINEL(objnode, OBJNODE); - INVERT_SENTINEL(objnode, OBJNODE); - BUG_ON(objnode->obj == NULL); - ASSERT_SENTINEL(objnode->obj, OBJ); - pool = objnode->obj->pool; - BUG_ON(pool == NULL); - ASSERT_SENTINEL(pool, POOL); - objnode->obj->objnode_count--; - objnode->obj = NULL; - (*tmem_hostops.objnode_free)(objnode, pool); -} - -/* - * Lookup index in object and return associated pampd (or NULL if not found). - */ -static void **__tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) -{ - unsigned int height, shift; - struct tmem_objnode **slot = NULL; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - - height = obj->objnode_tree_height; - if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height]) - goto out; - if (height == 0 && obj->objnode_tree_root) { - slot = &obj->objnode_tree_root; - goto out; - } - shift = (height-1) * OBJNODE_TREE_MAP_SHIFT; - slot = &obj->objnode_tree_root; - while (height > 0) { - if (*slot == NULL) - goto out; - slot = (struct tmem_objnode **) - ((*slot)->slots + - ((index >> shift) & OBJNODE_TREE_MAP_MASK)); - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } -out: - return slot != NULL ? (void **)slot : NULL; -} - -static void *tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) -{ - struct tmem_objnode **slot; - - slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index); - return slot != NULL ? *slot : NULL; -} - -#ifdef CONFIG_RAMSTER -static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index, - void *new_pampd, bool no_free) -{ - struct tmem_objnode **slot; - void *ret = NULL; - - slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index); - if ((slot != NULL) && (*slot != NULL)) { - void *old_pampd = *(void **)slot; - *(void **)slot = new_pampd; - if (!no_free) - (*tmem_pamops.free)(old_pampd, obj->pool, - NULL, 0, false); - ret = new_pampd; - } - return ret; -} -#endif - -static int tmem_pampd_add_to_obj(struct tmem_obj *obj, uint32_t index, - void *pampd) -{ - int ret = 0; - struct tmem_objnode *objnode = NULL, *newnode, *slot; - unsigned int height, shift; - int offset = 0; - - /* if necessary, extend the tree to be higher */ - if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height]) { - height = obj->objnode_tree_height + 1; - if (index > tmem_objnode_tree_h2max[height]) - while (index > tmem_objnode_tree_h2max[height]) - height++; - if (obj->objnode_tree_root == NULL) { - obj->objnode_tree_height = height; - goto insert; - } - do { - newnode = tmem_objnode_alloc(obj); - if (!newnode) { - ret = -ENOMEM; - goto out; - } - newnode->slots[0] = obj->objnode_tree_root; - newnode->slots_in_use = 1; - obj->objnode_tree_root = newnode; - obj->objnode_tree_height++; - } while (height > obj->objnode_tree_height); - } -insert: - slot = obj->objnode_tree_root; - height = obj->objnode_tree_height; - shift = (height-1) * OBJNODE_TREE_MAP_SHIFT; - while (height > 0) { - if (slot == NULL) { - /* add a child objnode. */ - slot = tmem_objnode_alloc(obj); - if (!slot) { - ret = -ENOMEM; - goto out; - } - if (objnode) { - - objnode->slots[offset] = slot; - objnode->slots_in_use++; - } else - obj->objnode_tree_root = slot; - } - /* go down a level */ - offset = (index >> shift) & OBJNODE_TREE_MAP_MASK; - objnode = slot; - slot = objnode->slots[offset]; - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } - BUG_ON(slot != NULL); - if (objnode) { - objnode->slots_in_use++; - objnode->slots[offset] = pampd; - } else - obj->objnode_tree_root = pampd; - obj->pampd_count++; -out: - return ret; -} - -static void *tmem_pampd_delete_from_obj(struct tmem_obj *obj, uint32_t index) -{ - struct tmem_objnode_tree_path path[OBJNODE_TREE_MAX_PATH + 1]; - struct tmem_objnode_tree_path *pathp = path; - struct tmem_objnode *slot = NULL; - unsigned int height, shift; - int offset; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - height = obj->objnode_tree_height; - if (index > tmem_objnode_tree_h2max[height]) - goto out; - slot = obj->objnode_tree_root; - if (height == 0 && obj->objnode_tree_root) { - obj->objnode_tree_root = NULL; - goto out; - } - shift = (height - 1) * OBJNODE_TREE_MAP_SHIFT; - pathp->objnode = NULL; - do { - if (slot == NULL) - goto out; - pathp++; - offset = (index >> shift) & OBJNODE_TREE_MAP_MASK; - pathp->offset = offset; - pathp->objnode = slot; - slot = slot->slots[offset]; - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } while (height > 0); - if (slot == NULL) - goto out; - while (pathp->objnode) { - pathp->objnode->slots[pathp->offset] = NULL; - pathp->objnode->slots_in_use--; - if (pathp->objnode->slots_in_use) { - if (pathp->objnode == obj->objnode_tree_root) { - while (obj->objnode_tree_height > 0 && - obj->objnode_tree_root->slots_in_use == 1 && - obj->objnode_tree_root->slots[0]) { - struct tmem_objnode *to_free = - obj->objnode_tree_root; - - obj->objnode_tree_root = - to_free->slots[0]; - obj->objnode_tree_height--; - to_free->slots[0] = NULL; - to_free->slots_in_use = 0; - tmem_objnode_free(to_free); - } - } - goto out; - } - tmem_objnode_free(pathp->objnode); /* 0 slots used, free it */ - pathp--; - } - obj->objnode_tree_height = 0; - obj->objnode_tree_root = NULL; - -out: - if (slot != NULL) - obj->pampd_count--; - BUG_ON(obj->pampd_count < 0); - return slot; -} - -/* Recursively walk the objnode_tree destroying pampds and objnodes. */ -static void tmem_objnode_node_destroy(struct tmem_obj *obj, - struct tmem_objnode *objnode, - unsigned int ht) -{ - int i; - - if (ht == 0) - return; - for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++) { - if (objnode->slots[i]) { - if (ht == 1) { - obj->pampd_count--; - (*tmem_pamops.free)(objnode->slots[i], - obj->pool, NULL, 0, true); - objnode->slots[i] = NULL; - continue; - } - tmem_objnode_node_destroy(obj, objnode->slots[i], ht-1); - tmem_objnode_free(objnode->slots[i]); - objnode->slots[i] = NULL; - } - } -} - -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj, - bool pool_destroy) -{ - if (obj->objnode_tree_root == NULL) - return; - if (obj->objnode_tree_height == 0) { - obj->pampd_count--; - (*tmem_pamops.free)(obj->objnode_tree_root, - obj->pool, NULL, 0, true); - } else { - tmem_objnode_node_destroy(obj, obj->objnode_tree_root, - obj->objnode_tree_height); - tmem_objnode_free(obj->objnode_tree_root); - obj->objnode_tree_height = 0; - } - obj->objnode_tree_root = NULL; -#ifdef CONFIG_RAMSTER - if (tmem_pamops.free_obj != NULL) - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy); -#endif -} - -/* - * Tmem is operated on by a set of well-defined actions: - * "put", "get", "flush", "flush_object", "new pool" and "destroy pool". - * (The tmem ABI allows for subpages and exchanges but these operations - * are not included in this implementation.) - * - * These "tmem core" operations are implemented in the following functions. - */ - -/* - * "Put" a page, e.g. associate the passed pampd with the passed handle. - * Tmem_put is complicated by a corner case: What if a page with matching - * handle already exists in tmem? To guarantee coherency, one of two - * actions is necessary: Either the data for the page must be overwritten, - * or the page must be "flushed" so that the data is not accessible to a - * subsequent "get". Since these "duplicate puts" are relatively rare, - * this implementation always flushes for simplicity. - */ -int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - bool raw, void *pampd_to_use) -{ - struct tmem_obj *obj = NULL, *objfound = NULL, *objnew = NULL; - void *pampd = NULL, *pampd_del = NULL; - int ret = -ENOMEM; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = objfound = tmem_obj_find(hb, oidp); - if (obj != NULL) { - pampd = tmem_pampd_lookup_in_obj(objfound, index); - if (pampd != NULL) { - /* if found, is a dup put, flush the old one */ - pampd_del = tmem_pampd_delete_from_obj(obj, index); - BUG_ON(pampd_del != pampd); - (*tmem_pamops.free)(pampd, pool, oidp, index, true); - if (obj->pampd_count == 0) { - objnew = obj; - objfound = NULL; - } - pampd = NULL; - } - } else { - obj = objnew = (*tmem_hostops.obj_alloc)(pool); - if (unlikely(obj == NULL)) { - ret = -ENOMEM; - goto out; - } - tmem_obj_init(obj, hb, pool, oidp); - } - BUG_ON(obj == NULL); - BUG_ON(((objnew != obj) && (objfound != obj)) || (objnew == objfound)); - pampd = pampd_to_use; - BUG_ON(pampd_to_use == NULL); - ret = tmem_pampd_add_to_obj(obj, index, pampd); - if (unlikely(ret == -ENOMEM)) - /* may have partially built objnode tree ("stump") */ - goto delete_and_free; - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool)); - goto out; - -delete_and_free: - (void)tmem_pampd_delete_from_obj(obj, index); - if (pampd) - (*tmem_pamops.free)(pampd, pool, NULL, 0, true); - if (objnew) { - tmem_obj_free(objnew, hb); - (*tmem_hostops.obj_free)(objnew, pool); - } -out: - spin_unlock(&hb->lock); - return ret; -} - -#ifdef CONFIG_RAMSTER -/* - * For ramster only: The following routines provide a two-step sequence - * to allow the caller to replace a pampd in the tmem data structures with - * another pampd. Here, we lookup the passed handle and, if found, return the - * associated pampd and object, leaving the hashbucket locked and returning - * a reference to it. The caller is expected to immediately call the - * matching tmem_localify_finish routine which will handles the replacement - * and unlocks the hashbucket. - */ -void *tmem_localify_get_pampd(struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, struct tmem_obj **ret_obj, - void **saved_hb) -{ - struct tmem_hashbucket *hb; - struct tmem_obj *obj = NULL; - void *pampd = NULL; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (likely(obj != NULL)) - pampd = tmem_pampd_lookup_in_obj(obj, index); - *ret_obj = obj; - *saved_hb = (void *)hb; - /* note, hashbucket remains locked */ - return pampd; -} - -void tmem_localify_finish(struct tmem_obj *obj, uint32_t index, - void *pampd, void *saved_hb, bool delete) -{ - struct tmem_hashbucket *hb = (struct tmem_hashbucket *)saved_hb; - - BUG_ON(!spin_is_locked(&hb->lock)); - if (pampd != NULL) { - BUG_ON(obj == NULL); - (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1); - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool)); - } else if (delete) { - BUG_ON(obj == NULL); - (void)tmem_pampd_delete_from_obj(obj, index); - } - spin_unlock(&hb->lock); -} - -/* - * For ramster only. Helper function to support asynchronous tmem_get. - */ -static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb, - struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, bool free, char *data) -{ - void *old_pampd = *ppampd, *new_pampd = NULL; - bool intransit = false; - int ret = 0; - - if (!is_ephemeral(pool)) - new_pampd = (*tmem_pamops.repatriate_preload)( - old_pampd, pool, oidp, index, &intransit); - if (intransit) - ret = -EAGAIN; - else if (new_pampd != NULL) - *ppampd = new_pampd; - /* must release the hb->lock else repatriate can't sleep */ - spin_unlock(&hb->lock); - if (!intransit) - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool, - oidp, index, free, data); - if (ret == -EAGAIN) { - /* rare I think, but should cond_resched()??? */ - usleep_range(10, 1000); - } else if (ret == -ENOTCONN || ret == -EHOSTDOWN) { - ret = -1; - } else if (ret != 0 && ret != -ENOENT) { - ret = -1; - } - /* note hb->lock has now been unlocked */ - return ret; -} - -/* - * For ramster only. If a page in tmem matches the handle, replace the - * page so that any subsequent "get" gets the new page. Returns 0 if - * there was a page to replace, else returns -1. - */ -int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, void *new_pampd) -{ - struct tmem_obj *obj; - int ret = -1; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0); - /* if we bug here, pamops wasn't properly set up for ramster */ - BUG_ON(tmem_pamops.replace_in_obj == NULL); - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj); -out: - spin_unlock(&hb->lock); - return ret; -} -#endif - -/* - * "Get" a page, e.g. if a pampd can be found matching the passed handle, - * use a pamops callback to recreated the page from the pampd with the - * matching handle. By tmem definition, when a "get" is successful on - * an ephemeral page, the page is "flushed", and when a "get" is successful - * on a persistent page, the page is retained in tmem. Note that to preserve - * coherency, "get" can never be skipped if tmem contains the data. - * That is, if a get is done with a certain handle and fails, any - * subsequent "get" must also fail (unless of course there is a - * "put" done with the same handle). - */ -int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - char *data, size_t *sizep, bool raw, int get_and_free) -{ - struct tmem_obj *obj; - void *pampd = NULL; - bool ephemeral = is_ephemeral(pool); - int ret = -1; - struct tmem_hashbucket *hb; - bool free = (get_and_free == 1) || ((get_and_free == 0) && ephemeral); - bool lock_held = false; - void **ppampd; - - do { - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - lock_held = true; - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - ppampd = __tmem_pampd_lookup_in_obj(obj, index); - if (ppampd == NULL) - goto out; -#ifdef CONFIG_RAMSTER - if ((tmem_pamops.is_remote != NULL) && - tmem_pamops.is_remote(*ppampd)) { - ret = tmem_repatriate(ppampd, hb, pool, oidp, - index, free, data); - /* tmem_repatriate releases hb->lock */ - lock_held = false; - *sizep = PAGE_SIZE; - if (ret != -EAGAIN) - goto out; - } -#endif - } while (ret == -EAGAIN); - if (free) - pampd = tmem_pampd_delete_from_obj(obj, index); - else - pampd = tmem_pampd_lookup_in_obj(obj, index); - if (pampd == NULL) - goto out; - if (free) { - if (obj->pampd_count == 0) { - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - obj = NULL; - } - } - if (free) - ret = (*tmem_pamops.get_data_and_free)( - data, sizep, raw, pampd, pool, oidp, index); - else - ret = (*tmem_pamops.get_data)( - data, sizep, raw, pampd, pool, oidp, index); - if (ret < 0) - goto out; - ret = 0; -out: - if (lock_held) - spin_unlock(&hb->lock); - return ret; -} - -/* - * If a page in tmem matches the handle, "flush" this page from tmem such - * that any subsequent "get" does not succeed (unless, of course, there - * was another "put" with the same handle). - */ -int tmem_flush_page(struct tmem_pool *pool, - struct tmem_oid *oidp, uint32_t index) -{ - struct tmem_obj *obj; - void *pampd; - int ret = -1; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - pampd = tmem_pampd_delete_from_obj(obj, index); - if (pampd == NULL) - goto out; - (*tmem_pamops.free)(pampd, pool, oidp, index, true); - if (obj->pampd_count == 0) { - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - } - ret = 0; - -out: - spin_unlock(&hb->lock); - return ret; -} - -/* - * "Flush" all pages in tmem matching this oid. - */ -int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp) -{ - struct tmem_obj *obj; - struct tmem_hashbucket *hb; - int ret = -1; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - tmem_pampd_destroy_all_in_obj(obj, false); - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - ret = 0; - -out: - spin_unlock(&hb->lock); - return ret; -} - -/* - * "Flush" all pages (and tmem_objs) from this tmem_pool and disable - * all subsequent access to this tmem_pool. - */ -int tmem_destroy_pool(struct tmem_pool *pool) -{ - int ret = -1; - - if (pool == NULL) - goto out; - tmem_pool_flush(pool, 1); - ret = 0; -out: - return ret; -} - -static LIST_HEAD(tmem_global_pool_list); - -/* - * Create a new tmem_pool with the provided flag and return - * a pool id provided by the tmem host implementation. - */ -void tmem_new_pool(struct tmem_pool *pool, uint32_t flags) -{ - int persistent = flags & TMEM_POOL_PERSIST; - int shared = flags & TMEM_POOL_SHARED; - struct tmem_hashbucket *hb = &pool->hashbucket[0]; - int i; - - for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) { - hb->obj_rb_root = RB_ROOT; - spin_lock_init(&hb->lock); - } - INIT_LIST_HEAD(&pool->pool_list); - atomic_set(&pool->obj_count, 0); - SET_SENTINEL(pool, POOL); - list_add_tail(&pool->pool_list, &tmem_global_pool_list); - pool->persistent = persistent; - pool->shared = shared; -} diff --git a/drivers/staging/ramster/tmem.h b/drivers/staging/ramster/tmem.h deleted file mode 100644 index adbe5a8..0000000 --- a/drivers/staging/ramster/tmem.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - * tmem.h - * - * Transcendent memory - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - */ - -#ifndef _TMEM_H_ -#define _TMEM_H_ - -#include <linux/types.h> -#include <linux/highmem.h> -#include <linux/hash.h> -#include <linux/atomic.h> - -/* - * These are defined by the Xen<->Linux ABI so should remain consistent - */ -#define TMEM_POOL_PERSIST 1 -#define TMEM_POOL_SHARED 2 -#define TMEM_POOL_PRECOMPRESSED 4 -#define TMEM_POOL_PAGESIZE_SHIFT 4 -#define TMEM_POOL_PAGESIZE_MASK 0xf -#define TMEM_POOL_RESERVED_BITS 0x00ffff00 - -/* - * sentinels have proven very useful for debugging but can be removed - * or disabled before final merge. - */ -#undef SENTINELS -#ifdef SENTINELS -#define DECL_SENTINEL uint32_t sentinel; -#define SET_SENTINEL(_x, _y) (_x->sentinel = _y##_SENTINEL) -#define INVERT_SENTINEL(_x, _y) (_x->sentinel = ~_y##_SENTINEL) -#define ASSERT_SENTINEL(_x, _y) WARN_ON(_x->sentinel != _y##_SENTINEL) -#define ASSERT_INVERTED_SENTINEL(_x, _y) WARN_ON(_x->sentinel != ~_y##_SENTINEL) -#else -#define DECL_SENTINEL -#define SET_SENTINEL(_x, _y) do { } while (0) -#define INVERT_SENTINEL(_x, _y) do { } while (0) -#define ASSERT_SENTINEL(_x, _y) do { } while (0) -#define ASSERT_INVERTED_SENTINEL(_x, _y) do { } while (0) -#endif - -#define ASSERT_SPINLOCK(_l) lockdep_assert_held(_l) - -/* - * A pool is the highest-level data structure managed by tmem and - * usually corresponds to a large independent set of pages such as - * a filesystem. Each pool has an id, and certain attributes and counters. - * It also contains a set of hash buckets, each of which contains an rbtree - * of objects and a lock to manage concurrency within the pool. - */ - -#define TMEM_HASH_BUCKET_BITS 8 -#define TMEM_HASH_BUCKETS (1<<TMEM_HASH_BUCKET_BITS) - -struct tmem_hashbucket { - struct rb_root obj_rb_root; - spinlock_t lock; -}; - -struct tmem_pool { - void *client; /* "up" for some clients, avoids table lookup */ - struct list_head pool_list; - uint32_t pool_id; - bool persistent; - bool shared; - atomic_t obj_count; - atomic_t refcount; - struct tmem_hashbucket hashbucket[TMEM_HASH_BUCKETS]; - DECL_SENTINEL -}; - -#define is_persistent(_p) (_p->persistent) -#define is_ephemeral(_p) (!(_p->persistent)) - -/* - * An object id ("oid") is large: 192-bits (to ensure, for example, files - * in a modern filesystem can be uniquely identified). - */ - -struct tmem_oid { - uint64_t oid[3]; -}; - -static inline void tmem_oid_set_invalid(struct tmem_oid *oidp) -{ - oidp->oid[0] = oidp->oid[1] = oidp->oid[2] = -1UL; -} - -static inline bool tmem_oid_valid(struct tmem_oid *oidp) -{ - return oidp->oid[0] != -1UL || oidp->oid[1] != -1UL || - oidp->oid[2] != -1UL; -} - -static inline int tmem_oid_compare(struct tmem_oid *left, - struct tmem_oid *right) -{ - int ret; - - if (left->oid[2] == right->oid[2]) { - if (left->oid[1] == right->oid[1]) { - if (left->oid[0] == right->oid[0]) - ret = 0; - else if (left->oid[0] < right->oid[0]) - ret = -1; - else - return 1; - } else if (left->oid[1] < right->oid[1]) - ret = -1; - else - ret = 1; - } else if (left->oid[2] < right->oid[2]) - ret = -1; - else - ret = 1; - return ret; -} - -static inline unsigned tmem_oid_hash(struct tmem_oid *oidp) -{ - return hash_long(oidp->oid[0] ^ oidp->oid[1] ^ oidp->oid[2], - TMEM_HASH_BUCKET_BITS); -} - -#ifdef CONFIG_RAMSTER -struct tmem_xhandle { - uint8_t client_id; - uint8_t xh_data_cksum; - uint16_t xh_data_size; - uint16_t pool_id; - struct tmem_oid oid; - uint32_t index; - void *extra; -}; - -static inline struct tmem_xhandle tmem_xhandle_fill(uint16_t client_id, - struct tmem_pool *pool, - struct tmem_oid *oidp, - uint32_t index) -{ - struct tmem_xhandle xh; - xh.client_id = client_id; - xh.xh_data_cksum = (uint8_t)-1; - xh.xh_data_size = (uint16_t)-1; - xh.pool_id = pool->pool_id; - xh.oid = *oidp; - xh.index = index; - return xh; -} -#endif - - -/* - * A tmem_obj contains an identifier (oid), pointers to the parent - * pool and the rb_tree to which it belongs, counters, and an ordered - * set of pampds, structured in a radix-tree-like tree. The intermediate - * nodes of the tree are called tmem_objnodes. - */ - -struct tmem_objnode; - -struct tmem_obj { - struct tmem_oid oid; - struct tmem_pool *pool; - struct rb_node rb_tree_node; - struct tmem_objnode *objnode_tree_root; - unsigned int objnode_tree_height; - unsigned long objnode_count; - long pampd_count; -#ifdef CONFIG_RAMSTER - /* - * for current design of ramster, all pages belonging to - * an object reside on the same remotenode and extra is - * used to record the number of the remotenode so a - * flush-object operation can specify it - */ - void *extra; /* for private use by pampd implementation */ -#endif - DECL_SENTINEL -}; - -#define OBJNODE_TREE_MAP_SHIFT 6 -#define OBJNODE_TREE_MAP_SIZE (1UL << OBJNODE_TREE_MAP_SHIFT) -#define OBJNODE_TREE_MAP_MASK (OBJNODE_TREE_MAP_SIZE-1) -#define OBJNODE_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long)) -#define OBJNODE_TREE_MAX_PATH \ - (OBJNODE_TREE_INDEX_BITS/OBJNODE_TREE_MAP_SHIFT + 2) - -struct tmem_objnode { - struct tmem_obj *obj; - DECL_SENTINEL - void *slots[OBJNODE_TREE_MAP_SIZE]; - unsigned int slots_in_use; -}; - -struct tmem_handle { - struct tmem_oid oid; /* 24 bytes */ - uint32_t index; - uint16_t pool_id; - uint16_t client_id; -}; - - -/* pampd abstract datatype methods provided by the PAM implementation */ -struct tmem_pamops { - void (*create_finish)(void *, bool); - int (*get_data)(char *, size_t *, bool, void *, struct tmem_pool *, - struct tmem_oid *, uint32_t); - int (*get_data_and_free)(char *, size_t *, bool, void *, - struct tmem_pool *, struct tmem_oid *, - uint32_t); - void (*free)(void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool); -#ifdef CONFIG_RAMSTER - void (*new_obj)(struct tmem_obj *); - void (*free_obj)(struct tmem_pool *, struct tmem_obj *, bool); - void *(*repatriate_preload)(void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool *); - int (*repatriate)(void *, void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool, void *); - bool (*is_remote)(void *); - int (*replace_in_obj)(void *, struct tmem_obj *); -#endif -}; -extern void tmem_register_pamops(struct tmem_pamops *m); - -/* memory allocation methods provided by the host implementation */ -struct tmem_hostops { - struct tmem_obj *(*obj_alloc)(struct tmem_pool *); - void (*obj_free)(struct tmem_obj *, struct tmem_pool *); - struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *); - void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *); -}; -extern void tmem_register_hostops(struct tmem_hostops *m); - -/* core tmem accessor functions */ -extern int tmem_put(struct tmem_pool *, struct tmem_oid *, uint32_t index, - bool, void *); -extern int tmem_get(struct tmem_pool *, struct tmem_oid *, uint32_t index, - char *, size_t *, bool, int); -extern int tmem_flush_page(struct tmem_pool *, struct tmem_oid *, - uint32_t index); -extern int tmem_flush_object(struct tmem_pool *, struct tmem_oid *); -extern int tmem_destroy_pool(struct tmem_pool *); -extern void tmem_new_pool(struct tmem_pool *, uint32_t); -#ifdef CONFIG_RAMSTER -extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index, - void *); -extern void *tmem_localify_get_pampd(struct tmem_pool *, struct tmem_oid *, - uint32_t index, struct tmem_obj **, - void **); -extern void tmem_localify_finish(struct tmem_obj *, uint32_t index, - void *, void *, bool); -#endif -#endif /* _TMEM_H */ diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c deleted file mode 100644 index a09dd5c..0000000 --- a/drivers/staging/ramster/zcache-main.c +++ /dev/null @@ -1,1820 +0,0 @@ -/* - * zcache.c - * - * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. - * Copyright (c) 2010,2011, Nitin Gupta - * - * Zcache provides an in-kernel "host implementation" for transcendent memory - * ("tmem") and, thus indirectly, for cleancache and frontswap. Zcache uses - * lzo1x compression to improve density and an embedded allocator called - * "zbud" which "buddies" two compressed pages semi-optimally in each physical - * pageframe. Zbud is integrally tied into tmem to allow pageframes to - * be "reclaimed" efficiently. - */ - -#include <linux/module.h> -#include <linux/cpu.h> -#include <linux/highmem.h> -#include <linux/list.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/types.h> -#include <linux/atomic.h> -#include <linux/math64.h> -#include <linux/crypto.h> - -#include <linux/cleancache.h> -#include <linux/frontswap.h> -#include "tmem.h" -#include "zcache.h" -#include "zbud.h" -#include "ramster.h" -#ifdef CONFIG_RAMSTER -static int ramster_enabled; -#else -#define ramster_enabled 0 -#endif - -#ifndef __PG_WAS_ACTIVE -static inline bool PageWasActive(struct page *page) -{ - return true; -} - -static inline void SetPageWasActive(struct page *page) -{ -} -#endif - -#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS -static bool frontswap_has_exclusive_gets __read_mostly = true; -#else -static bool frontswap_has_exclusive_gets __read_mostly; -static inline void frontswap_tmem_exclusive_gets(bool b) -{ -} -#endif - -static int zcache_enabled __read_mostly; -static int disable_cleancache __read_mostly; -static int disable_frontswap __read_mostly; -static int disable_frontswap_ignore_nonactive __read_mostly; -static int disable_cleancache_ignore_nonactive __read_mostly; -static char *namestr __read_mostly = "zcache"; - -#define ZCACHE_GFP_MASK \ - (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC) - -MODULE_LICENSE("GPL"); - -/* crypto API for zcache */ -#define ZCACHE_COMP_NAME_SZ CRYPTO_MAX_ALG_NAME -static char zcache_comp_name[ZCACHE_COMP_NAME_SZ] __read_mostly; -static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms __read_mostly; - -enum comp_op { - ZCACHE_COMPOP_COMPRESS, - ZCACHE_COMPOP_DECOMPRESS -}; - -static inline int zcache_comp_op(enum comp_op op, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - struct crypto_comp *tfm; - int ret = -1; - - BUG_ON(!zcache_comp_pcpu_tfms); - tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu()); - BUG_ON(!tfm); - switch (op) { - case ZCACHE_COMPOP_COMPRESS: - ret = crypto_comp_compress(tfm, src, slen, dst, dlen); - break; - case ZCACHE_COMPOP_DECOMPRESS: - ret = crypto_comp_decompress(tfm, src, slen, dst, dlen); - break; - default: - ret = -EINVAL; - } - put_cpu(); - return ret; -} - -/* - * policy parameters - */ - -/* - * byte count defining poor compression; pages with greater zsize will be - * rejected - */ -static unsigned int zbud_max_zsize __read_mostly = (PAGE_SIZE / 8) * 7; -/* - * byte count defining poor *mean* compression; pages with greater zsize - * will be rejected until sufficient better-compressed pages are accepted - * driving the mean below this threshold - */ -static unsigned int zbud_max_mean_zsize __read_mostly = (PAGE_SIZE / 8) * 5; - -/* - * for now, used named slabs so can easily track usage; later can - * either just use kmalloc, or perhaps add a slab-like allocator - * to more carefully manage total memory utilization - */ -static struct kmem_cache *zcache_objnode_cache; -static struct kmem_cache *zcache_obj_cache; - -static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, }; - -/* we try to keep these statistics SMP-consistent */ -static long zcache_obj_count; -static atomic_t zcache_obj_atomic = ATOMIC_INIT(0); -static long zcache_obj_count_max; -static long zcache_objnode_count; -static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0); -static long zcache_objnode_count_max; -static u64 zcache_eph_zbytes; -static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0); -static u64 zcache_eph_zbytes_max; -static u64 zcache_pers_zbytes; -static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0); -static u64 zcache_pers_zbytes_max; -static long zcache_eph_pageframes; -static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0); -static long zcache_eph_pageframes_max; -static long zcache_pers_pageframes; -static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0); -static long zcache_pers_pageframes_max; -static long zcache_pageframes_alloced; -static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0); -static long zcache_pageframes_freed; -static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0); -static long zcache_eph_zpages; -static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0); -static long zcache_eph_zpages_max; -static long zcache_pers_zpages; -static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0); -static long zcache_pers_zpages_max; - -/* but for the rest of these, counting races are ok */ -static unsigned long zcache_flush_total; -static unsigned long zcache_flush_found; -static unsigned long zcache_flobj_total; -static unsigned long zcache_flobj_found; -static unsigned long zcache_failed_eph_puts; -static unsigned long zcache_failed_pers_puts; -static unsigned long zcache_failed_getfreepages; -static unsigned long zcache_failed_alloc; -static unsigned long zcache_put_to_flush; -static unsigned long zcache_compress_poor; -static unsigned long zcache_mean_compress_poor; -static unsigned long zcache_eph_ate_tail; -static unsigned long zcache_eph_ate_tail_failed; -static unsigned long zcache_pers_ate_eph; -static unsigned long zcache_pers_ate_eph_failed; -static unsigned long zcache_evicted_eph_zpages; -static unsigned long zcache_evicted_eph_pageframes; -static unsigned long zcache_last_active_file_pageframes; -static unsigned long zcache_last_inactive_file_pageframes; -static unsigned long zcache_last_active_anon_pageframes; -static unsigned long zcache_last_inactive_anon_pageframes; -static unsigned long zcache_eph_nonactive_puts_ignored; -static unsigned long zcache_pers_nonactive_puts_ignored; - -#ifdef CONFIG_DEBUG_FS -#include <linux/debugfs.h> -#define zdfs debugfs_create_size_t -#define zdfs64 debugfs_create_u64 -static int zcache_debugfs_init(void) -{ - struct dentry *root = debugfs_create_dir("zcache", NULL); - if (root == NULL) - return -ENXIO; - - zdfs("obj_count", S_IRUGO, root, &zcache_obj_count); - zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max); - zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count); - zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max); - zdfs("flush_total", S_IRUGO, root, &zcache_flush_total); - zdfs("flush_found", S_IRUGO, root, &zcache_flush_found); - zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total); - zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found); - zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts); - zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts); - zdfs("failed_get_free_pages", S_IRUGO, root, - &zcache_failed_getfreepages); - zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc); - zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush); - zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor); - zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor); - zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail); - zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed); - zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph); - zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed); - zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages); - zdfs("evicted_eph_pageframes", S_IRUGO, root, - &zcache_evicted_eph_pageframes); - zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes); - zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max); - zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes); - zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max); - zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages); - zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max); - zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages); - zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max); - zdfs("last_active_file_pageframes", S_IRUGO, root, - &zcache_last_active_file_pageframes); - zdfs("last_inactive_file_pageframes", S_IRUGO, root, - &zcache_last_inactive_file_pageframes); - zdfs("last_active_anon_pageframes", S_IRUGO, root, - &zcache_last_active_anon_pageframes); - zdfs("last_inactive_anon_pageframes", S_IRUGO, root, - &zcache_last_inactive_anon_pageframes); - zdfs("eph_nonactive_puts_ignored", S_IRUGO, root, - &zcache_eph_nonactive_puts_ignored); - zdfs("pers_nonactive_puts_ignored", S_IRUGO, root, - &zcache_pers_nonactive_puts_ignored); - zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes); - zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max); - zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes); - zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max); - return 0; -} -#undef zdebugfs -#undef zdfs64 -#endif - -#define ZCACHE_DEBUG -#ifdef ZCACHE_DEBUG -/* developers can call this in case of ooms, e.g. to find memory leaks */ -void zcache_dump(void) -{ - pr_info("zcache: obj_count=%lu\n", zcache_obj_count); - pr_info("zcache: obj_count_max=%lu\n", zcache_obj_count_max); - pr_info("zcache: objnode_count=%lu\n", zcache_objnode_count); - pr_info("zcache: objnode_count_max=%lu\n", zcache_objnode_count_max); - pr_info("zcache: flush_total=%lu\n", zcache_flush_total); - pr_info("zcache: flush_found=%lu\n", zcache_flush_found); - pr_info("zcache: flobj_total=%lu\n", zcache_flobj_total); - pr_info("zcache: flobj_found=%lu\n", zcache_flobj_found); - pr_info("zcache: failed_eph_puts=%lu\n", zcache_failed_eph_puts); - pr_info("zcache: failed_pers_puts=%lu\n", zcache_failed_pers_puts); - pr_info("zcache: failed_get_free_pages=%lu\n", - zcache_failed_getfreepages); - pr_info("zcache: failed_alloc=%lu\n", zcache_failed_alloc); - pr_info("zcache: put_to_flush=%lu\n", zcache_put_to_flush); - pr_info("zcache: compress_poor=%lu\n", zcache_compress_poor); - pr_info("zcache: mean_compress_poor=%lu\n", - zcache_mean_compress_poor); - pr_info("zcache: eph_ate_tail=%lu\n", zcache_eph_ate_tail); - pr_info("zcache: eph_ate_tail_failed=%lu\n", - zcache_eph_ate_tail_failed); - pr_info("zcache: pers_ate_eph=%lu\n", zcache_pers_ate_eph); - pr_info("zcache: pers_ate_eph_failed=%lu\n", - zcache_pers_ate_eph_failed); - pr_info("zcache: evicted_eph_zpages=%lu\n", zcache_evicted_eph_zpages); - pr_info("zcache: evicted_eph_pageframes=%lu\n", - zcache_evicted_eph_pageframes); - pr_info("zcache: eph_pageframes=%lu\n", zcache_eph_pageframes); - pr_info("zcache: eph_pageframes_max=%lu\n", zcache_eph_pageframes_max); - pr_info("zcache: pers_pageframes=%lu\n", zcache_pers_pageframes); - pr_info("zcache: pers_pageframes_max=%lu\n", - zcache_pers_pageframes_max); - pr_info("zcache: eph_zpages=%lu\n", zcache_eph_zpages); - pr_info("zcache: eph_zpages_max=%lu\n", zcache_eph_zpages_max); - pr_info("zcache: pers_zpages=%lu\n", zcache_pers_zpages); - pr_info("zcache: pers_zpages_max=%lu\n", zcache_pers_zpages_max); - pr_info("zcache: eph_zbytes=%llu\n", - (unsigned long long)zcache_eph_zbytes); - pr_info("zcache: eph_zbytes_max=%llu\n", - (unsigned long long)zcache_eph_zbytes_max); - pr_info("zcache: pers_zbytes=%llu\n", - (unsigned long long)zcache_pers_zbytes); - pr_info("zcache: pers_zbytes_max=%llu\n", - (unsigned long long)zcache_pers_zbytes_max); -} -#endif - -/* - * zcache core code starts here - */ - -static struct zcache_client zcache_host; -static struct zcache_client zcache_clients[MAX_CLIENTS]; - -static inline bool is_local_client(struct zcache_client *cli) -{ - return cli == &zcache_host; -} - -static struct zcache_client *zcache_get_client_by_id(uint16_t cli_id) -{ - struct zcache_client *cli = &zcache_host; - - if (cli_id != LOCAL_CLIENT) { - if (cli_id >= MAX_CLIENTS) - goto out; - cli = &zcache_clients[cli_id]; - } -out: - return cli; -} - -/* - * Tmem operations assume the poolid implies the invoking client. - * Zcache only has one client (the kernel itself): LOCAL_CLIENT. - * RAMster has each client numbered by cluster node, and a KVM version - * of zcache would have one client per guest and each client might - * have a poolid==N. - */ -struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid) -{ - struct tmem_pool *pool = NULL; - struct zcache_client *cli = NULL; - - cli = zcache_get_client_by_id(cli_id); - if (cli == NULL) - goto out; - if (!is_local_client(cli)) - atomic_inc(&cli->refcount); - if (poolid < MAX_POOLS_PER_CLIENT) { - pool = cli->tmem_pools[poolid]; - if (pool != NULL) - atomic_inc(&pool->refcount); - } -out: - return pool; -} - -void zcache_put_pool(struct tmem_pool *pool) -{ - struct zcache_client *cli = NULL; - - if (pool == NULL) - BUG(); - cli = pool->client; - atomic_dec(&pool->refcount); - if (!is_local_client(cli)) - atomic_dec(&cli->refcount); -} - -int zcache_new_client(uint16_t cli_id) -{ - struct zcache_client *cli; - int ret = -1; - - cli = zcache_get_client_by_id(cli_id); - if (cli == NULL) - goto out; - if (cli->allocated) - goto out; - cli->allocated = 1; - ret = 0; -out: - return ret; -} - -/* - * zcache implementation for tmem host ops - */ - -static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool) -{ - struct tmem_objnode *objnode = NULL; - struct zcache_preload *kp; - int i; - - kp = &__get_cpu_var(zcache_preloads); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - objnode = kp->objnodes[i]; - if (objnode != NULL) { - kp->objnodes[i] = NULL; - break; - } - } - BUG_ON(objnode == NULL); - zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic); - if (zcache_objnode_count > zcache_objnode_count_max) - zcache_objnode_count_max = zcache_objnode_count; - return objnode; -} - -static void zcache_objnode_free(struct tmem_objnode *objnode, - struct tmem_pool *pool) -{ - zcache_objnode_count = - atomic_dec_return(&zcache_objnode_atomic); - BUG_ON(zcache_objnode_count < 0); - kmem_cache_free(zcache_objnode_cache, objnode); -} - -static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool) -{ - struct tmem_obj *obj = NULL; - struct zcache_preload *kp; - - kp = &__get_cpu_var(zcache_preloads); - obj = kp->obj; - BUG_ON(obj == NULL); - kp->obj = NULL; - zcache_obj_count = atomic_inc_return(&zcache_obj_atomic); - if (zcache_obj_count > zcache_obj_count_max) - zcache_obj_count_max = zcache_obj_count; - return obj; -} - -static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool) -{ - zcache_obj_count = - atomic_dec_return(&zcache_obj_atomic); - BUG_ON(zcache_obj_count < 0); - kmem_cache_free(zcache_obj_cache, obj); -} - -static struct tmem_hostops zcache_hostops = { - .obj_alloc = zcache_obj_alloc, - .obj_free = zcache_obj_free, - .objnode_alloc = zcache_objnode_alloc, - .objnode_free = zcache_objnode_free, -}; - -static struct page *zcache_alloc_page(void) -{ - struct page *page = alloc_page(ZCACHE_GFP_MASK); - - if (page != NULL) - zcache_pageframes_alloced = - atomic_inc_return(&zcache_pageframes_alloced_atomic); - return page; -} - -#ifdef FRONTSWAP_HAS_UNUSE -static void zcache_unacct_page(void) -{ - zcache_pageframes_freed = - atomic_inc_return(&zcache_pageframes_freed_atomic); -} -#endif - -static void zcache_free_page(struct page *page) -{ - long curr_pageframes; - static long max_pageframes, min_pageframes; - - if (page == NULL) - BUG(); - __free_page(page); - zcache_pageframes_freed = - atomic_inc_return(&zcache_pageframes_freed_atomic); - curr_pageframes = zcache_pageframes_alloced - - atomic_read(&zcache_pageframes_freed_atomic) - - atomic_read(&zcache_eph_pageframes_atomic) - - atomic_read(&zcache_pers_pageframes_atomic); - if (curr_pageframes > max_pageframes) - max_pageframes = curr_pageframes; - if (curr_pageframes < min_pageframes) - min_pageframes = curr_pageframes; -#ifdef ZCACHE_DEBUG - if (curr_pageframes > 2L || curr_pageframes < -2L) { - /* pr_info here */ - } -#endif -} - -/* - * zcache implementations for PAM page descriptor ops - */ - -/* forward reference */ -static void zcache_compress(struct page *from, - void **out_va, unsigned *out_len); - -static struct page *zcache_evict_eph_pageframe(void); - -static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, - struct tmem_handle *th) -{ - void *pampd = NULL, *cdata = data; - unsigned clen = size; - struct page *page = (struct page *)(data), *newpage; - - if (!raw) { - zcache_compress(page, &cdata, &clen); - if (clen > zbud_max_buddy_size()) { - zcache_compress_poor++; - goto out; - } - } else { - BUG_ON(clen > zbud_max_buddy_size()); - } - - /* look for space via an existing match first */ - pampd = (void *)zbud_match_prep(th, true, cdata, clen); - if (pampd != NULL) - goto got_pampd; - - /* no match, now we need to find (or free up) a full page */ - newpage = zcache_alloc_page(); - if (newpage != NULL) - goto create_in_new_page; - - zcache_failed_getfreepages++; - /* can't allocate a page, evict an ephemeral page via LRU */ - newpage = zcache_evict_eph_pageframe(); - if (newpage == NULL) { - zcache_eph_ate_tail_failed++; - goto out; - } - zcache_eph_ate_tail++; - -create_in_new_page: - pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage); - BUG_ON(pampd == NULL); - zcache_eph_pageframes = - atomic_inc_return(&zcache_eph_pageframes_atomic); - if (zcache_eph_pageframes > zcache_eph_pageframes_max) - zcache_eph_pageframes_max = zcache_eph_pageframes; - -got_pampd: - zcache_eph_zbytes = - atomic_long_add_return(clen, &zcache_eph_zbytes_atomic); - if (zcache_eph_zbytes > zcache_eph_zbytes_max) - zcache_eph_zbytes_max = zcache_eph_zbytes; - zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic); - if (zcache_eph_zpages > zcache_eph_zpages_max) - zcache_eph_zpages_max = zcache_eph_zpages; - if (ramster_enabled && raw) - ramster_count_foreign_pages(true, 1); -out: - return pampd; -} - -static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, - struct tmem_handle *th) -{ - void *pampd = NULL, *cdata = data; - unsigned clen = size; - struct page *page = (struct page *)(data), *newpage; - unsigned long zbud_mean_zsize; - unsigned long curr_pers_zpages, total_zsize; - - if (data == NULL) { - BUG_ON(!ramster_enabled); - goto create_pampd; - } - curr_pers_zpages = zcache_pers_zpages; -/* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ - if (!raw) - zcache_compress(page, &cdata, &clen); - /* reject if compression is too poor */ - if (clen > zbud_max_zsize) { - zcache_compress_poor++; - goto out; - } - /* reject if mean compression is too poor */ - if ((clen > zbud_max_mean_zsize) && (curr_pers_zpages > 0)) { - total_zsize = zcache_pers_zbytes; - if ((long)total_zsize < 0) - total_zsize = 0; - zbud_mean_zsize = div_u64(total_zsize, - curr_pers_zpages); - if (zbud_mean_zsize > zbud_max_mean_zsize) { - zcache_mean_compress_poor++; - goto out; - } - } - -create_pampd: - /* look for space via an existing match first */ - pampd = (void *)zbud_match_prep(th, false, cdata, clen); - if (pampd != NULL) - goto got_pampd; - - /* no match, now we need to find (or free up) a full page */ - newpage = zcache_alloc_page(); - if (newpage != NULL) - goto create_in_new_page; - /* - * FIXME do the following only if eph is oversized? - * if (zcache_eph_pageframes > - * (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) + - * global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE))) - */ - zcache_failed_getfreepages++; - /* can't allocate a page, evict an ephemeral page via LRU */ - newpage = zcache_evict_eph_pageframe(); - if (newpage == NULL) { - zcache_pers_ate_eph_failed++; - goto out; - } - zcache_pers_ate_eph++; - -create_in_new_page: - pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage); - BUG_ON(pampd == NULL); - zcache_pers_pageframes = - atomic_inc_return(&zcache_pers_pageframes_atomic); - if (zcache_pers_pageframes > zcache_pers_pageframes_max) - zcache_pers_pageframes_max = zcache_pers_pageframes; - -got_pampd: - zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic); - if (zcache_pers_zpages > zcache_pers_zpages_max) - zcache_pers_zpages_max = zcache_pers_zpages; - zcache_pers_zbytes = - atomic_long_add_return(clen, &zcache_pers_zbytes_atomic); - if (zcache_pers_zbytes > zcache_pers_zbytes_max) - zcache_pers_zbytes_max = zcache_pers_zbytes; - if (ramster_enabled && raw) - ramster_count_foreign_pages(false, 1); -out: - return pampd; -} - -/* - * This is called directly from zcache_put_page to pre-allocate space - * to store a zpage. - */ -void *zcache_pampd_create(char *data, unsigned int size, bool raw, - int eph, struct tmem_handle *th) -{ - void *pampd = NULL; - struct zcache_preload *kp; - struct tmem_objnode *objnode; - struct tmem_obj *obj; - int i; - - BUG_ON(!irqs_disabled()); - /* pre-allocate per-cpu metadata */ - BUG_ON(zcache_objnode_cache == NULL); - BUG_ON(zcache_obj_cache == NULL); - kp = &__get_cpu_var(zcache_preloads); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - objnode = kp->objnodes[i]; - if (objnode == NULL) { - objnode = kmem_cache_alloc(zcache_objnode_cache, - ZCACHE_GFP_MASK); - if (unlikely(objnode == NULL)) { - zcache_failed_alloc++; - goto out; - } - kp->objnodes[i] = objnode; - } - } - if (kp->obj == NULL) { - obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); - kp->obj = obj; - } - if (unlikely(kp->obj == NULL)) { - zcache_failed_alloc++; - goto out; - } - /* - * ok, have all the metadata pre-allocated, now do the data - * but since how we allocate the data is dependent on ephemeral - * or persistent, we split the call here to different sub-functions - */ - if (eph) - pampd = zcache_pampd_eph_create(data, size, raw, th); - else - pampd = zcache_pampd_pers_create(data, size, raw, th); -out: - return pampd; -} - -/* - * This is a pamops called via tmem_put and is necessary to "finish" - * a pampd creation. - */ -void zcache_pampd_create_finish(void *pampd, bool eph) -{ - zbud_create_finish((struct zbudref *)pampd, eph); -} - -/* - * This is passed as a function parameter to zbud_decompress so that - * zbud need not be familiar with the details of crypto. It assumes that - * the bytes from_va and to_va through from_va+size-1 and to_va+size-1 are - * kmapped. It must be successful, else there is a logic bug somewhere. - */ -static void zcache_decompress(char *from_va, unsigned int size, char *to_va) -{ - int ret; - unsigned int outlen = PAGE_SIZE; - - ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size, - to_va, &outlen); - BUG_ON(ret); - BUG_ON(outlen != PAGE_SIZE); -} - -/* - * Decompress from the kernel va to a pageframe - */ -void zcache_decompress_to_page(char *from_va, unsigned int size, - struct page *to_page) -{ - char *to_va = kmap_atomic(to_page); - zcache_decompress(from_va, size, to_va); - kunmap_atomic(to_va); -} - -/* - * fill the pageframe corresponding to the struct page with the data - * from the passed pampd - */ -static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, - void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index) -{ - int ret; - bool eph = !is_persistent(pool); - - BUG_ON(preemptible()); - BUG_ON(eph); /* fix later if shared pools get implemented */ - BUG_ON(pampd_is_remote(pampd)); - if (raw) - ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, - sizep, eph); - else { - ret = zbud_decompress((struct page *)(data), - (struct zbudref *)pampd, false, - zcache_decompress); - *sizep = PAGE_SIZE; - } - return ret; -} - -/* - * fill the pageframe corresponding to the struct page with the data - * from the passed pampd - */ -static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, - void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index) -{ - int ret; - bool eph = !is_persistent(pool); - struct page *page = NULL; - unsigned int zsize, zpages; - - BUG_ON(preemptible()); - BUG_ON(pampd_is_remote(pampd)); - if (raw) - ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, - sizep, eph); - else { - ret = zbud_decompress((struct page *)(data), - (struct zbudref *)pampd, eph, - zcache_decompress); - *sizep = PAGE_SIZE; - } - page = zbud_free_and_delist((struct zbudref *)pampd, eph, - &zsize, &zpages); - if (eph) { - if (page) - zcache_eph_pageframes = - atomic_dec_return(&zcache_eph_pageframes_atomic); - zcache_eph_zpages = - atomic_sub_return(zpages, &zcache_eph_zpages_atomic); - zcache_eph_zbytes = - atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic); - } else { - if (page) - zcache_pers_pageframes = - atomic_dec_return(&zcache_pers_pageframes_atomic); - zcache_pers_zpages = - atomic_sub_return(zpages, &zcache_pers_zpages_atomic); - zcache_pers_zbytes = - atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic); - } - if (!is_local_client(pool->client)) - ramster_count_foreign_pages(eph, -1); - if (page) - zcache_free_page(page); - return ret; -} - -/* - * free the pampd and remove it from any zcache lists - * pampd must no longer be pointed to from any tmem data structures! - */ -static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index, bool acct) -{ - struct page *page = NULL; - unsigned int zsize, zpages; - - BUG_ON(preemptible()); - if (pampd_is_remote(pampd)) { - BUG_ON(!ramster_enabled); - pampd = ramster_pampd_free(pampd, pool, oid, index, acct); - if (pampd == NULL) - return; - } - if (is_ephemeral(pool)) { - page = zbud_free_and_delist((struct zbudref *)pampd, - true, &zsize, &zpages); - if (page) - zcache_eph_pageframes = - atomic_dec_return(&zcache_eph_pageframes_atomic); - zcache_eph_zpages = - atomic_sub_return(zpages, &zcache_eph_zpages_atomic); - zcache_eph_zbytes = - atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic); - /* FIXME CONFIG_RAMSTER... check acct parameter? */ - } else { - page = zbud_free_and_delist((struct zbudref *)pampd, - false, &zsize, &zpages); - if (page) - zcache_pers_pageframes = - atomic_dec_return(&zcache_pers_pageframes_atomic); - zcache_pers_zpages = - atomic_sub_return(zpages, &zcache_pers_zpages_atomic); - zcache_pers_zbytes = - atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic); - } - if (!is_local_client(pool->client)) - ramster_count_foreign_pages(is_ephemeral(pool), -1); - if (page) - zcache_free_page(page); -} - -static struct tmem_pamops zcache_pamops = { - .create_finish = zcache_pampd_create_finish, - .get_data = zcache_pampd_get_data, - .get_data_and_free = zcache_pampd_get_data_and_free, - .free = zcache_pampd_free, -}; - -/* - * zcache compression/decompression and related per-cpu stuff - */ - -static DEFINE_PER_CPU(unsigned char *, zcache_dstmem); -#define ZCACHE_DSTMEM_ORDER 1 - -static void zcache_compress(struct page *from, void **out_va, unsigned *out_len) -{ - int ret; - unsigned char *dmem = __get_cpu_var(zcache_dstmem); - char *from_va; - - BUG_ON(!irqs_disabled()); - /* no buffer or no compressor so can't compress */ - BUG_ON(dmem == NULL); - *out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER; - from_va = kmap_atomic(from); - mb(); - ret = zcache_comp_op(ZCACHE_COMPOP_COMPRESS, from_va, PAGE_SIZE, dmem, - out_len); - BUG_ON(ret); - *out_va = dmem; - kunmap_atomic(from_va); -} - -static int zcache_comp_cpu_up(int cpu) -{ - struct crypto_comp *tfm; - - tfm = crypto_alloc_comp(zcache_comp_name, 0, 0); - if (IS_ERR(tfm)) - return NOTIFY_BAD; - *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = tfm; - return NOTIFY_OK; -} - -static void zcache_comp_cpu_down(int cpu) -{ - struct crypto_comp *tfm; - - tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu); - crypto_free_comp(tfm); - *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = NULL; -} - -static int zcache_cpu_notifier(struct notifier_block *nb, - unsigned long action, void *pcpu) -{ - int ret, i, cpu = (long)pcpu; - struct zcache_preload *kp; - - switch (action) { - case CPU_UP_PREPARE: - ret = zcache_comp_cpu_up(cpu); - if (ret != NOTIFY_OK) { - pr_err("%s: can't allocate compressor xform\n", - namestr); - return ret; - } - per_cpu(zcache_dstmem, cpu) = (void *)__get_free_pages( - GFP_KERNEL | __GFP_REPEAT, ZCACHE_DSTMEM_ORDER); - if (ramster_enabled) - ramster_cpu_up(cpu); - break; - case CPU_DEAD: - case CPU_UP_CANCELED: - zcache_comp_cpu_down(cpu); - free_pages((unsigned long)per_cpu(zcache_dstmem, cpu), - ZCACHE_DSTMEM_ORDER); - per_cpu(zcache_dstmem, cpu) = NULL; - kp = &per_cpu(zcache_preloads, cpu); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - if (kp->objnodes[i]) - kmem_cache_free(zcache_objnode_cache, - kp->objnodes[i]); - } - if (kp->obj) { - kmem_cache_free(zcache_obj_cache, kp->obj); - kp->obj = NULL; - } - if (ramster_enabled) - ramster_cpu_down(cpu); - break; - default: - break; - } - return NOTIFY_OK; -} - -static struct notifier_block zcache_cpu_notifier_block = { - .notifier_call = zcache_cpu_notifier -}; - -/* - * The following code interacts with the zbud eviction and zbud - * zombify code to access LRU pages - */ - -static struct page *zcache_evict_eph_pageframe(void) -{ - struct page *page; - unsigned int zsize = 0, zpages = 0; - - page = zbud_evict_pageframe_lru(&zsize, &zpages); - if (page == NULL) - goto out; - zcache_eph_zbytes = atomic_long_sub_return(zsize, - &zcache_eph_zbytes_atomic); - zcache_eph_zpages = atomic_sub_return(zpages, - &zcache_eph_zpages_atomic); - zcache_evicted_eph_zpages++; - zcache_eph_pageframes = - atomic_dec_return(&zcache_eph_pageframes_atomic); - zcache_evicted_eph_pageframes++; -out: - return page; -} - -#ifdef FRONTSWAP_HAS_UNUSE -static void unswiz(struct tmem_oid oid, u32 index, - unsigned *type, pgoff_t *offset); - -/* - * Choose an LRU persistent pageframe and attempt to "unuse" it by - * calling frontswap_unuse on both zpages. - * - * This is work-in-progress. - */ - -static int zcache_frontswap_unuse(void) -{ - struct tmem_handle th[2]; - int ret = -ENOMEM; - int nzbuds, unuse_ret; - unsigned type; - struct page *newpage1 = NULL, *newpage2 = NULL; - struct page *evictpage1 = NULL, *evictpage2 = NULL; - pgoff_t offset; - - newpage1 = alloc_page(ZCACHE_GFP_MASK); - newpage2 = alloc_page(ZCACHE_GFP_MASK); - if (newpage1 == NULL) - evictpage1 = zcache_evict_eph_pageframe(); - if (newpage2 == NULL) - evictpage2 = zcache_evict_eph_pageframe(); - if (evictpage1 == NULL || evictpage2 == NULL) - goto free_and_out; - /* ok, we have two pages pre-allocated */ - nzbuds = zbud_make_zombie_lru(&th[0], NULL, NULL, false); - if (nzbuds == 0) { - ret = -ENOENT; - goto free_and_out; - } - unswiz(th[0].oid, th[0].index, &type, &offset); - unuse_ret = frontswap_unuse(type, offset, - newpage1 != NULL ? newpage1 : evictpage1, - ZCACHE_GFP_MASK); - if (unuse_ret != 0) - goto free_and_out; - else if (evictpage1 != NULL) - zcache_unacct_page(); - newpage1 = NULL; - evictpage1 = NULL; - if (nzbuds == 2) { - unswiz(th[1].oid, th[1].index, &type, &offset); - unuse_ret = frontswap_unuse(type, offset, - newpage2 != NULL ? newpage2 : evictpage2, - ZCACHE_GFP_MASK); - if (unuse_ret != 0) { - goto free_and_out; - } else if (evictpage2 != NULL) { - zcache_unacct_page(); - } - } - ret = 0; - goto out; - -free_and_out: - if (newpage1 != NULL) - __free_page(newpage1); - if (newpage2 != NULL) - __free_page(newpage2); - if (evictpage1 != NULL) - zcache_free_page(evictpage1); - if (evictpage2 != NULL) - zcache_free_page(evictpage2); -out: - return ret; -} -#endif - -/* - * When zcache is disabled ("frozen"), pools can be created and destroyed, - * but all puts (and thus all other operations that require memory allocation) - * must fail. If zcache is unfrozen, accepts puts, then frozen again, - * data consistency requires all puts while frozen to be converted into - * flushes. - */ -static bool zcache_freeze; - -/* - * This zcache shrinker interface reduces the number of ephemeral pageframes - * used by zcache to approximately the same as the total number of LRU_FILE - * pageframes in use. - */ -static int shrink_zcache_memory(struct shrinker *shrink, - struct shrink_control *sc) -{ - static bool in_progress; - int ret = -1; - int nr = sc->nr_to_scan; - int nr_evict = 0; - int nr_unuse = 0; - struct page *page; -#ifdef FRONTSWAP_HAS_UNUSE - int unuse_ret; -#endif - - if (nr <= 0) - goto skip_evict; - - /* don't allow more than one eviction thread at a time */ - if (in_progress) - goto skip_evict; - - in_progress = true; - - /* we are going to ignore nr, and target a different value */ - zcache_last_active_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); - zcache_last_inactive_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); - nr_evict = zcache_eph_pageframes - zcache_last_active_file_pageframes + - zcache_last_inactive_file_pageframes; - while (nr_evict-- > 0) { - page = zcache_evict_eph_pageframe(); - if (page == NULL) - break; - zcache_free_page(page); - } - - zcache_last_active_anon_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON); - zcache_last_inactive_anon_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON); - nr_unuse = zcache_pers_pageframes - zcache_last_active_anon_pageframes + - zcache_last_inactive_anon_pageframes; -#ifdef FRONTSWAP_HAS_UNUSE - /* rate limit for testing */ - if (nr_unuse > 32) - nr_unuse = 32; - while (nr_unuse-- > 0) { - unuse_ret = zcache_frontswap_unuse(); - if (unuse_ret == -ENOMEM) - break; - } -#endif - in_progress = false; - -skip_evict: - /* resample: has changed, but maybe not all the way yet */ - zcache_last_active_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); - zcache_last_inactive_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); - ret = zcache_eph_pageframes - zcache_last_active_file_pageframes + - zcache_last_inactive_file_pageframes; - if (ret < 0) - ret = 0; - return ret; -} - -static struct shrinker zcache_shrinker = { - .shrink = shrink_zcache_memory, - .seeks = DEFAULT_SEEKS, -}; - -/* - * zcache shims between cleancache/frontswap ops and tmem - */ - -/* FIXME rename these core routines to zcache_tmemput etc? */ -int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, void *page, - unsigned int size, bool raw, int ephemeral) -{ - struct tmem_pool *pool; - struct tmem_handle th; - int ret = -1; - void *pampd = NULL; - - BUG_ON(!irqs_disabled()); - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (unlikely(pool == NULL)) - goto out; - if (!zcache_freeze) { - ret = 0; - th.client_id = cli_id; - th.pool_id = pool_id; - th.oid = *oidp; - th.index = index; - pampd = zcache_pampd_create((char *)page, size, raw, - ephemeral, &th); - if (pampd == NULL) { - ret = -ENOMEM; - if (ephemeral) - zcache_failed_eph_puts++; - else - zcache_failed_pers_puts++; - } else { - if (ramster_enabled) - ramster_do_preload_flnode(pool); - ret = tmem_put(pool, oidp, index, 0, pampd); - if (ret < 0) - BUG(); - } - zcache_put_pool(pool); - } else { - zcache_put_to_flush++; - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (atomic_read(&pool->obj_count) > 0) - /* the put fails whether the flush succeeds or not */ - (void)tmem_flush_page(pool, oidp, index); - zcache_put_pool(pool); - } -out: - return ret; -} - -int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, void *page, - size_t *sizep, bool raw, int get_and_free) -{ - struct tmem_pool *pool; - int ret = -1; - bool eph; - - if (!raw) { - BUG_ON(irqs_disabled()); - BUG_ON(in_softirq()); - } - pool = zcache_get_pool_by_id(cli_id, pool_id); - eph = is_ephemeral(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_get(pool, oidp, index, (char *)(page), - sizep, raw, get_and_free); - zcache_put_pool(pool); - } - WARN_ONCE((!is_ephemeral(pool) && (ret != 0)), - "zcache_get fails on persistent pool, " - "bad things are very likely to happen soon\n"); -#ifdef RAMSTER_TESTING - if (ret != 0 && ret != -1 && !(ret == -EINVAL && is_ephemeral(pool))) - pr_err("TESTING zcache_get tmem_get returns ret=%d\n", ret); -#endif - return ret; -} - -int zcache_flush_page(int cli_id, int pool_id, - struct tmem_oid *oidp, uint32_t index) -{ - struct tmem_pool *pool; - int ret = -1; - unsigned long flags; - - local_irq_save(flags); - zcache_flush_total++; - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_flush_page(pool, oidp, index); - zcache_put_pool(pool); - } - if (ret >= 0) - zcache_flush_found++; - local_irq_restore(flags); - return ret; -} - -int zcache_flush_object(int cli_id, int pool_id, - struct tmem_oid *oidp) -{ - struct tmem_pool *pool; - int ret = -1; - unsigned long flags; - - local_irq_save(flags); - zcache_flobj_total++; - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_flush_object(pool, oidp); - zcache_put_pool(pool); - } - if (ret >= 0) - zcache_flobj_found++; - local_irq_restore(flags); - return ret; -} - -static int zcache_client_destroy_pool(int cli_id, int pool_id) -{ - struct tmem_pool *pool = NULL; - struct zcache_client *cli = NULL; - int ret = -1; - - if (pool_id < 0) - goto out; - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; - if (cli == NULL) - goto out; - atomic_inc(&cli->refcount); - pool = cli->tmem_pools[pool_id]; - if (pool == NULL) - goto out; - cli->tmem_pools[pool_id] = NULL; - /* wait for pool activity on other cpus to quiesce */ - while (atomic_read(&pool->refcount) != 0) - ; - atomic_dec(&cli->refcount); - local_bh_disable(); - ret = tmem_destroy_pool(pool); - local_bh_enable(); - kfree(pool); - if (cli_id == LOCAL_CLIENT) - pr_info("%s: destroyed local pool id=%d\n", namestr, pool_id); - else - pr_info("%s: destroyed pool id=%d, client=%d\n", - namestr, pool_id, cli_id); -out: - return ret; -} - -int zcache_new_pool(uint16_t cli_id, uint32_t flags) -{ - int poolid = -1; - struct tmem_pool *pool; - struct zcache_client *cli = NULL; - - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; - if (cli == NULL) - goto out; - atomic_inc(&cli->refcount); - pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); - if (pool == NULL) { - pr_info("%s: pool creation failed: out of memory\n", namestr); - goto out; - } - - for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++) - if (cli->tmem_pools[poolid] == NULL) - break; - if (poolid >= MAX_POOLS_PER_CLIENT) { - pr_info("%s: pool creation failed: max exceeded\n", namestr); - kfree(pool); - poolid = -1; - goto out; - } - atomic_set(&pool->refcount, 0); - pool->client = cli; - pool->pool_id = poolid; - tmem_new_pool(pool, flags); - cli->tmem_pools[poolid] = pool; - if (cli_id == LOCAL_CLIENT) - pr_info("%s: created %s local tmem pool, id=%d\n", namestr, - flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - poolid); - else - pr_info("%s: created %s tmem pool, id=%d, client=%d\n", namestr, - flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - poolid, cli_id); -out: - if (cli != NULL) - atomic_dec(&cli->refcount); - return poolid; -} - -static int zcache_local_new_pool(uint32_t flags) -{ - return zcache_new_pool(LOCAL_CLIENT, flags); -} - -int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph) -{ - struct tmem_pool *pool; - struct zcache_client *cli; - uint32_t flags = eph ? 0 : TMEM_POOL_PERSIST; - int ret = -1; - - BUG_ON(!ramster_enabled); - if (cli_id == LOCAL_CLIENT) - goto out; - if (pool_id >= MAX_POOLS_PER_CLIENT) - goto out; - if (cli_id >= MAX_CLIENTS) - goto out; - - cli = &zcache_clients[cli_id]; - if ((eph && disable_cleancache) || (!eph && disable_frontswap)) { - pr_err("zcache_autocreate_pool: pool type disabled\n"); - goto out; - } - if (!cli->allocated) { - if (zcache_new_client(cli_id)) { - pr_err("zcache_autocreate_pool: can't create client\n"); - goto out; - } - cli = &zcache_clients[cli_id]; - } - atomic_inc(&cli->refcount); - pool = cli->tmem_pools[pool_id]; - if (pool != NULL) { - if (pool->persistent && eph) { - pr_err("zcache_autocreate_pool: type mismatch\n"); - goto out; - } - ret = 0; - goto out; - } - pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL); - if (pool == NULL) { - pr_info("%s: pool creation failed: out of memory\n", namestr); - goto out; - } - atomic_set(&pool->refcount, 0); - pool->client = cli; - pool->pool_id = pool_id; - tmem_new_pool(pool, flags); - cli->tmem_pools[pool_id] = pool; - pr_info("%s: AUTOcreated %s tmem poolid=%d, for remote client=%d\n", - namestr, flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - pool_id, cli_id); - ret = 0; -out: - if (cli != NULL) - atomic_dec(&cli->refcount); - return ret; -} - -/********** - * Two kernel functionalities currently can be layered on top of tmem. - * These are "cleancache" which is used as a second-chance cache for clean - * page cache pages; and "frontswap" which is used for swap pages - * to avoid writes to disk. A generic "shim" is provided here for each - * to translate in-kernel semantics to zcache semantics. - */ - -static void zcache_cleancache_put_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index, struct page *page) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - - if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) { - zcache_eph_nonactive_puts_ignored++; - return; - } - if (likely(ind == index)) - (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index, - page, PAGE_SIZE, false, 1); -} - -static int zcache_cleancache_get_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index, struct page *page) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - size_t size; - int ret = -1; - - if (likely(ind == index)) { - ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index, - page, &size, false, 0); - BUG_ON(ret >= 0 && size != PAGE_SIZE); - if (ret == 0) - SetPageWasActive(page); - } - return ret; -} - -static void zcache_cleancache_flush_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - - if (likely(ind == index)) - (void)zcache_flush_page(LOCAL_CLIENT, pool_id, &oid, ind); -} - -static void zcache_cleancache_flush_inode(int pool_id, - struct cleancache_filekey key) -{ - struct tmem_oid oid = *(struct tmem_oid *)&key; - - (void)zcache_flush_object(LOCAL_CLIENT, pool_id, &oid); -} - -static void zcache_cleancache_flush_fs(int pool_id) -{ - if (pool_id >= 0) - (void)zcache_client_destroy_pool(LOCAL_CLIENT, pool_id); -} - -static int zcache_cleancache_init_fs(size_t pagesize) -{ - BUG_ON(sizeof(struct cleancache_filekey) != - sizeof(struct tmem_oid)); - BUG_ON(pagesize != PAGE_SIZE); - return zcache_local_new_pool(0); -} - -static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize) -{ - /* shared pools are unsupported and map to private */ - BUG_ON(sizeof(struct cleancache_filekey) != - sizeof(struct tmem_oid)); - BUG_ON(pagesize != PAGE_SIZE); - return zcache_local_new_pool(0); -} - -static struct cleancache_ops zcache_cleancache_ops = { - .put_page = zcache_cleancache_put_page, - .get_page = zcache_cleancache_get_page, - .invalidate_page = zcache_cleancache_flush_page, - .invalidate_inode = zcache_cleancache_flush_inode, - .invalidate_fs = zcache_cleancache_flush_fs, - .init_shared_fs = zcache_cleancache_init_shared_fs, - .init_fs = zcache_cleancache_init_fs -}; - -struct cleancache_ops zcache_cleancache_register_ops(void) -{ - struct cleancache_ops old_ops = - cleancache_register_ops(&zcache_cleancache_ops); - - return old_ops; -} - -/* a single tmem poolid is used for all frontswap "types" (swapfiles) */ -static int zcache_frontswap_poolid __read_mostly = -1; - -/* - * Swizzling increases objects per swaptype, increasing tmem concurrency - * for heavy swaploads. Later, larger nr_cpus -> larger SWIZ_BITS - * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from - * frontswap_get_page(), but has side-effects. Hence using 8. - */ -#define SWIZ_BITS 8 -#define SWIZ_MASK ((1 << SWIZ_BITS) - 1) -#define _oswiz(_type, _ind) ((_type << SWIZ_BITS) | (_ind & SWIZ_MASK)) -#define iswiz(_ind) (_ind >> SWIZ_BITS) - -static inline struct tmem_oid oswiz(unsigned type, u32 ind) -{ - struct tmem_oid oid = { .oid = { 0 } }; - oid.oid[0] = _oswiz(type, ind); - return oid; -} - -#ifdef FRONTSWAP_HAS_UNUSE -static void unswiz(struct tmem_oid oid, u32 index, - unsigned *type, pgoff_t *offset) -{ - *type = (unsigned)(oid.oid[0] >> SWIZ_BITS); - *offset = (pgoff_t)((index << SWIZ_BITS) | - (oid.oid[0] & SWIZ_MASK)); -} -#endif - -static int zcache_frontswap_put_page(unsigned type, pgoff_t offset, - struct page *page) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - int ret = -1; - unsigned long flags; - - BUG_ON(!PageLocked(page)); - if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) { - zcache_pers_nonactive_puts_ignored++; - ret = -ERANGE; - goto out; - } - if (likely(ind64 == ind)) { - local_irq_save(flags); - ret = zcache_put_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), - page, PAGE_SIZE, false, 0); - local_irq_restore(flags); - } -out: - return ret; -} - -/* returns 0 if the page was successfully gotten from frontswap, -1 if - * was not present (should never happen!) */ -static int zcache_frontswap_get_page(unsigned type, pgoff_t offset, - struct page *page) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - size_t size; - int ret = -1, get_and_free; - - if (frontswap_has_exclusive_gets) - get_and_free = 1; - else - get_and_free = -1; - BUG_ON(!PageLocked(page)); - if (likely(ind64 == ind)) { - ret = zcache_get_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), - page, &size, false, get_and_free); - BUG_ON(ret >= 0 && size != PAGE_SIZE); - } - return ret; -} - -/* flush a single page from frontswap */ -static void zcache_frontswap_flush_page(unsigned type, pgoff_t offset) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - - if (likely(ind64 == ind)) - (void)zcache_flush_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind)); -} - -/* flush all pages from the passed swaptype */ -static void zcache_frontswap_flush_area(unsigned type) -{ - struct tmem_oid oid; - int ind; - - for (ind = SWIZ_MASK; ind >= 0; ind--) { - oid = oswiz(type, ind); - (void)zcache_flush_object(LOCAL_CLIENT, - zcache_frontswap_poolid, &oid); - } -} - -static void zcache_frontswap_init(unsigned ignored) -{ - /* a single tmem poolid is used for all frontswap "types" (swapfiles) */ - if (zcache_frontswap_poolid < 0) - zcache_frontswap_poolid = - zcache_local_new_pool(TMEM_POOL_PERSIST); -} - -static struct frontswap_ops zcache_frontswap_ops = { - .store = zcache_frontswap_put_page, - .load = zcache_frontswap_get_page, - .invalidate_page = zcache_frontswap_flush_page, - .invalidate_area = zcache_frontswap_flush_area, - .init = zcache_frontswap_init -}; - -struct frontswap_ops zcache_frontswap_register_ops(void) -{ - struct frontswap_ops old_ops = - frontswap_register_ops(&zcache_frontswap_ops); - - return old_ops; -} - -/* - * zcache initialization - * NOTE FOR NOW zcache or ramster MUST BE PROVIDED AS A KERNEL BOOT PARAMETER - * OR NOTHING HAPPENS! - */ - -static int __init enable_zcache(char *s) -{ - zcache_enabled = 1; - return 1; -} -__setup("zcache", enable_zcache); - -static int __init enable_ramster(char *s) -{ - zcache_enabled = 1; -#ifdef CONFIG_RAMSTER - ramster_enabled = 1; -#endif - return 1; -} -__setup("ramster", enable_ramster); - -/* allow independent dynamic disabling of cleancache and frontswap */ - -static int __init no_cleancache(char *s) -{ - disable_cleancache = 1; - return 1; -} - -__setup("nocleancache", no_cleancache); - -static int __init no_frontswap(char *s) -{ - disable_frontswap = 1; - return 1; -} - -__setup("nofrontswap", no_frontswap); - -static int __init no_frontswap_exclusive_gets(char *s) -{ - frontswap_has_exclusive_gets = false; - return 1; -} - -__setup("nofrontswapexclusivegets", no_frontswap_exclusive_gets); - -static int __init no_frontswap_ignore_nonactive(char *s) -{ - disable_frontswap_ignore_nonactive = 1; - return 1; -} - -__setup("nofrontswapignorenonactive", no_frontswap_ignore_nonactive); - -static int __init no_cleancache_ignore_nonactive(char *s) -{ - disable_cleancache_ignore_nonactive = 1; - return 1; -} - -__setup("nocleancacheignorenonactive", no_cleancache_ignore_nonactive); - -static int __init enable_zcache_compressor(char *s) -{ - strncpy(zcache_comp_name, s, ZCACHE_COMP_NAME_SZ); - zcache_enabled = 1; - return 1; -} -__setup("zcache=", enable_zcache_compressor); - - -static int __init zcache_comp_init(void) -{ - int ret = 0; - - /* check crypto algorithm */ - if (*zcache_comp_name != '\0') { - ret = crypto_has_comp(zcache_comp_name, 0, 0); - if (!ret) - pr_info("zcache: %s not supported\n", - zcache_comp_name); - } - if (!ret) - strcpy(zcache_comp_name, "lzo"); - ret = crypto_has_comp(zcache_comp_name, 0, 0); - if (!ret) { - ret = 1; - goto out; - } - pr_info("zcache: using %s compressor\n", zcache_comp_name); - - /* alloc percpu transforms */ - ret = 0; - zcache_comp_pcpu_tfms = alloc_percpu(struct crypto_comp *); - if (!zcache_comp_pcpu_tfms) - ret = 1; -out: - return ret; -} - -static int __init zcache_init(void) -{ - int ret = 0; - - if (ramster_enabled) { - namestr = "ramster"; - ramster_register_pamops(&zcache_pamops); - } -#ifdef CONFIG_DEBUG_FS - zcache_debugfs_init(); -#endif - if (zcache_enabled) { - unsigned int cpu; - - tmem_register_hostops(&zcache_hostops); - tmem_register_pamops(&zcache_pamops); - ret = register_cpu_notifier(&zcache_cpu_notifier_block); - if (ret) { - pr_err("%s: can't register cpu notifier\n", namestr); - goto out; - } - ret = zcache_comp_init(); - if (ret) { - pr_err("%s: compressor initialization failed\n", - namestr); - goto out; - } - for_each_online_cpu(cpu) { - void *pcpu = (void *)(long)cpu; - zcache_cpu_notifier(&zcache_cpu_notifier_block, - CPU_UP_PREPARE, pcpu); - } - } - zcache_objnode_cache = kmem_cache_create("zcache_objnode", - sizeof(struct tmem_objnode), 0, 0, NULL); - zcache_obj_cache = kmem_cache_create("zcache_obj", - sizeof(struct tmem_obj), 0, 0, NULL); - ret = zcache_new_client(LOCAL_CLIENT); - if (ret) { - pr_err("%s: can't create client\n", namestr); - goto out; - } - zbud_init(); - if (zcache_enabled && !disable_cleancache) { - struct cleancache_ops old_ops; - - register_shrinker(&zcache_shrinker); - old_ops = zcache_cleancache_register_ops(); - pr_info("%s: cleancache enabled using kernel transcendent " - "memory and compression buddies\n", namestr); -#ifdef ZCACHE_DEBUG - pr_info("%s: cleancache: ignorenonactive = %d\n", - namestr, !disable_cleancache_ignore_nonactive); -#endif - if (old_ops.init_fs != NULL) - pr_warn("%s: cleancache_ops overridden\n", namestr); - } - if (zcache_enabled && !disable_frontswap) { - struct frontswap_ops old_ops; - - old_ops = zcache_frontswap_register_ops(); - if (frontswap_has_exclusive_gets) - frontswap_tmem_exclusive_gets(true); - pr_info("%s: frontswap enabled using kernel transcendent " - "memory and compression buddies\n", namestr); -#ifdef ZCACHE_DEBUG - pr_info("%s: frontswap: excl gets = %d active only = %d\n", - namestr, frontswap_has_exclusive_gets, - !disable_frontswap_ignore_nonactive); -#endif - if (old_ops.init != NULL) - pr_warn("%s: frontswap_ops overridden\n", namestr); - } - if (ramster_enabled) - ramster_init(!disable_cleancache, !disable_frontswap, - frontswap_has_exclusive_gets); -out: - return ret; -} - -late_initcall(zcache_init); diff --git a/drivers/staging/rtl8187se/ieee80211/dot11d.c b/drivers/staging/rtl8187se/ieee80211/dot11d.c index 0e93eb0..9d2d5c5 100644 --- a/drivers/staging/rtl8187se/ieee80211/dot11d.c +++ b/drivers/staging/rtl8187se/ieee80211/dot11d.c @@ -39,12 +39,11 @@ Dot11d_Reset(struct ieee80211_device *ieee) memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1); memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1); // Set new channel map - for (i=1; i<=11; i++) { + for (i = 1; i <= 11; i++) (pDot11dInfo->channel_map)[i] = 1; - } - for (i=12; i<=14; i++) { + + for (i = 12; i <= 14; i++) (pDot11dInfo->channel_map)[i] = 2; - } pDot11dInfo->State = DOT11D_STATE_NONE; pDot11dInfo->CountryIeLen = 0; @@ -68,17 +67,16 @@ Dot11d_Reset(struct ieee80211_device *ieee) void Dot11d_UpdateCountryIe( struct ieee80211_device *dev, - u8 * pTaddr, + u8 *pTaddr, u16 CoutryIeLen, - u8 * pCoutryIe + u8 *pCoutryIe ) { PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); u8 i, j, NumTriples, MaxChnlNum; PCHNL_TXPOWER_TRIPLE pTriple; - if((CoutryIeLen - 3)%3 != 0) - { + if ((CoutryIeLen - 3)%3 != 0) { printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); Dot11d_Reset(dev); return; @@ -89,35 +87,33 @@ Dot11d_UpdateCountryIe( MaxChnlNum = 0; NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string. pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3); - for(i = 0; i < NumTriples; i++) - { - if(MaxChnlNum >= pTriple->FirstChnl) - { // It is not in a monotonically increasing order, so stop processing. + for (i = 0; i < NumTriples; i++) { + if (MaxChnlNum >= pTriple->FirstChnl) { + // It is not in a monotonically increasing order, so stop processing. printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n"); Dot11d_Reset(dev); return; } - if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) - { // It is not a valid set of channel id, so stop processing. + if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) { + // It is not a valid set of channel id, so stop processing. printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n"); Dot11d_Reset(dev); return; } - for(j = 0 ; j < pTriple->NumChnls; j++) - { + for (j = 0 ; j < pTriple->NumChnls; j++) { pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1; pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm; MaxChnlNum = pTriple->FirstChnl + j; } - pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3); + pTriple = (PCHNL_TXPOWER_TRIPLE)((u8 *)pTriple + 3); } #if 1 //printk("Dot11d_UpdateCountryIe(): Channel List:\n"); printk("Channel List:"); - for(i=1; i<= MAX_CHANNEL_NUMBER; i++) - if(pDot11dInfo->channel_map[i] > 0) + for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) + if (pDot11dInfo->channel_map[i] > 0) printk(" %d", i); printk("\n"); #endif @@ -125,7 +121,7 @@ Dot11d_UpdateCountryIe( UPDATE_CIE_SRC(dev, pTaddr); pDot11dInfo->CountryIeLen = CoutryIeLen; - memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen); + memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen); pDot11dInfo->State = DOT11D_STATE_LEARNED; } @@ -138,13 +134,11 @@ DOT11D_GetMaxTxPwrInDbm( PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); u8 MaxTxPwrInDbm = 255; - if(MAX_CHANNEL_NUMBER < Channel) - { + if (MAX_CHANNEL_NUMBER < Channel) { printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n"); return MaxTxPwrInDbm; } - if(pDot11dInfo->channel_map[Channel]) - { + if (pDot11dInfo->channel_map[Channel]) { MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel]; } @@ -154,20 +148,19 @@ DOT11D_GetMaxTxPwrInDbm( void DOT11D_ScanComplete( - struct ieee80211_device * dev + struct ieee80211_device *dev ) { PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - switch(pDot11dInfo->State) - { + switch (pDot11dInfo->State) { case DOT11D_STATE_LEARNED: pDot11dInfo->State = DOT11D_STATE_DONE; break; case DOT11D_STATE_DONE: - if( GET_CIE_WATCHDOG(dev) == 0 ) - { // Reset country IE if previous one is gone. + if (GET_CIE_WATCHDOG(dev) == 0) { + // Reset country IE if previous one is gone. Dot11d_Reset(dev); } break; @@ -177,24 +170,23 @@ DOT11D_ScanComplete( } int IsLegalChannel( - struct ieee80211_device * dev, + struct ieee80211_device *dev, u8 channel ) { PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev); - if(MAX_CHANNEL_NUMBER < channel) - { + if (MAX_CHANNEL_NUMBER < channel) { printk("IsLegalChannel(): Invalid Channel\n"); return 0; } - if(pDot11dInfo->channel_map[channel] > 0) + if (pDot11dInfo->channel_map[channel] > 0) return 1; return 0; } int ToLegalChannel( - struct ieee80211_device * dev, + struct ieee80211_device *dev, u8 channel ) { @@ -202,22 +194,19 @@ int ToLegalChannel( u8 default_chn = 0; u32 i = 0; - for (i=1; i<= MAX_CHANNEL_NUMBER; i++) - { - if(pDot11dInfo->channel_map[i] > 0) - { + for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) { + if (pDot11dInfo->channel_map[i] > 0) { default_chn = i; break; } } - if(MAX_CHANNEL_NUMBER < channel) - { + if (MAX_CHANNEL_NUMBER < channel) { printk("IsLegalChannel(): Invalid Channel\n"); return default_chn; } - if(pDot11dInfo->channel_map[channel] > 0) + if (pDot11dInfo->channel_map[channel] > 0) return channel; return default_chn; diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c index 4358c4b..07a1fbb 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c @@ -68,10 +68,8 @@ static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) ieee->networks = kcalloc( MAX_NETWORK_COUNT, sizeof(struct ieee80211_network), GFP_KERNEL); - if (!ieee->networks) { - netdev_warn(ieee->dev, "Out of memory allocating beacons\n"); + if (!ieee->networks) return -ENOMEM; - } return 0; } diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c index 446f15e..e303159 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c @@ -408,11 +408,9 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, // if (memcmp(entry->mac, mac, ETH_ALEN)){ if (p == &ieee->ibss_mac_hash[index]) { entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC); - if (!entry) { - netdev_warn(ieee->dev, - "Cannot malloc new mac entry\n"); + if (!entry) return 0; - } + memcpy(entry->mac, mac, ETH_ALEN); entry->seq_num[tid] = seq; entry->frag_num[tid] = frag; diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c index c7917b2..e014f7e 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c @@ -41,9 +41,9 @@ static const char *ieee80211_modes[] = { #define MAX_CUSTOM_LEN 64 static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, - char *start, char *stop, - struct ieee80211_network *network, - struct iw_request_info *info) + char *start, char *stop, + struct ieee80211_network *network, + struct iw_request_info *info) { char custom[MAX_CUSTOM_LEN]; char *p; @@ -78,9 +78,9 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]); start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); - /* Add mode */ - iwe.cmd = SIOCGIWMODE; - if (network->capability & + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + if (network->capability & (WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) { if (network->capability & WLAN_CAPABILITY_BSS) iwe.u.mode = IW_MODE_MASTER; @@ -90,7 +90,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); } - /* Add frequency/channel */ + /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; /* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ @@ -168,23 +168,23 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, if (iwe.u.data.length) start = iwe_stream_add_point(info, start, stop, &iwe, custom); - memset(&iwe, 0, sizeof(iwe)); - if (network->wpa_ie_len) { + memset(&iwe, 0, sizeof(iwe)); + if (network->wpa_ie_len) { // printk("wpa_ie_len:%d\n", network->wpa_ie_len); - char buf[MAX_WPA_IE_LEN]; - memcpy(buf, network->wpa_ie, network->wpa_ie_len); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = network->wpa_ie_len; - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - } - - memset(&iwe, 0, sizeof(iwe)); - if (network->rsn_ie_len) { + char buf[MAX_WPA_IE_LEN]; + memcpy(buf, network->wpa_ie, network->wpa_ie_len); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = network->wpa_ie_len; + start = iwe_stream_add_point(info, start, stop, &iwe, buf); + } + + memset(&iwe, 0, sizeof(iwe)); + if (network->rsn_ie_len) { // printk("=====>rsn_ie_len:\n", network->rsn_ie_len); - char buf[MAX_WPA_IE_LEN]; - memcpy(buf, network->rsn_ie, network->rsn_ie_len); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = network->rsn_ie_len; + char buf[MAX_WPA_IE_LEN]; + memcpy(buf, network->rsn_ie, network->rsn_ie_len); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = network->rsn_ie_len; start = iwe_stream_add_point(info, start, stop, &iwe, buf); } @@ -217,22 +217,18 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, down(&ieee->wx_sem); spin_lock_irqsave(&ieee->lock, flags); - if(!ieee->bHwRadioOff) - { + if (!ieee->bHwRadioOff) { list_for_each_entry(network, &ieee->network_list, list) { i++; - if((stop-ev)<200) - { + if ((stop-ev) < 200) { err = -E2BIG; break; } if (ieee->scan_age == 0 || - time_after(network->last_scanned + ieee->scan_age, jiffies)) - { + time_after(network->last_scanned + ieee->scan_age, jiffies)) { ev = rtl818x_translate_scan(ieee, ev, stop, network, info); - } - else + } else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" "%pM)' due to age (%lums).\n", @@ -340,9 +336,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, kfree(new_crypt); new_crypt = NULL; - printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", - dev->name); + netdev_warn(ieee->dev, + "could not initialize WEP: load module ieee80211_crypt_wep\n"); return -EOPNOTSUPP; } *crypt = new_crypt; @@ -359,7 +354,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, key, escape_essid(sec.keys[key], len), erq->length, len); sec.key_sizes[key] = len; - (*crypt)->ops->set_key(sec.keys[key], len, NULL, + (*crypt)->ops->set_key(sec.keys[key], len, NULL, (*crypt)->priv); sec.flags |= (1 << key); /* This ensures a key will be activated if no key is @@ -414,7 +409,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(dev)) { - printk(KERN_DEBUG "%s: reset_port failed\n", dev->name); + netdev_dbg(ieee->dev, "reset_port failed\n"); return -EINVAL; } return 0; @@ -430,7 +425,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, IEEE80211_DEBUG_WX("GET_ENCODE\n"); - if(ieee->iw_mode == IW_MODE_MONITOR) + if (ieee->iw_mode == IW_MODE_MONITOR) return -1; key = erq->flags & IW_ENCODE_INDEX; @@ -472,240 +467,240 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, } int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct net_device *dev = ieee->dev; - struct iw_point *encoding = &wrqu->encoding; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - int i, idx, ret = 0; - int group_key = 0; - const char *alg; - struct ieee80211_crypto_ops *ops; - struct ieee80211_crypt_data **crypt; - - struct ieee80211_security sec = { - .flags = 0, - }; + struct iw_point *encoding = &wrqu->encoding; + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; + int i, idx, ret = 0; + int group_key = 0; + const char *alg; + struct ieee80211_crypto_ops *ops; + struct ieee80211_crypt_data **crypt; + + struct ieee80211_security sec = { + .flags = 0, + }; //printk("======>encoding flag:%x,ext flag:%x, ext alg:%d\n", encoding->flags,ext->ext_flags, ext->alg); - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) { - if (idx < 1 || idx > WEP_KEYS) - return -EINVAL; - idx--; - } else - idx = ieee->tx_keyidx; - - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { - crypt = &ieee->crypt[idx]; - group_key = 1; - } else { - /* some Cisco APs use idx>0 for unicast in dynamic WEP */ + idx = encoding->flags & IW_ENCODE_INDEX; + if (idx) { + if (idx < 1 || idx > WEP_KEYS) + return -EINVAL; + idx--; + } else + idx = ieee->tx_keyidx; + + if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { + crypt = &ieee->crypt[idx]; + group_key = 1; + } else { + /* some Cisco APs use idx>0 for unicast in dynamic WEP */ //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg); - if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) - return -EINVAL; - if (ieee->iw_mode == IW_MODE_INFRA) - crypt = &ieee->crypt[idx]; - else - return -EINVAL; - } - - sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT; - if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) { - if (*crypt) - ieee80211_crypt_delayed_deinit(ieee, crypt); - - for (i = 0; i < WEP_KEYS; i++) - if (ieee->crypt[i] != NULL) - break; - - if (i == WEP_KEYS) { - sec.enabled = 0; - // sec.encrypt = 0; - sec.level = SEC_LEVEL_0; - sec.flags |= SEC_LEVEL; - } + if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) + return -EINVAL; + if (ieee->iw_mode == IW_MODE_INFRA) + crypt = &ieee->crypt[idx]; + else + return -EINVAL; + } + + sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT; + if ((encoding->flags & IW_ENCODE_DISABLED) || + ext->alg == IW_ENCODE_ALG_NONE) { + if (*crypt) + ieee80211_crypt_delayed_deinit(ieee, crypt); + + for (i = 0; i < WEP_KEYS; i++) + if (ieee->crypt[i] != NULL) + break; + + if (i == WEP_KEYS) { + sec.enabled = 0; + // sec.encrypt = 0; + sec.level = SEC_LEVEL_0; + sec.flags |= SEC_LEVEL; + } //printk("disabled: flag:%x\n", encoding->flags); - goto done; - } + goto done; + } sec.enabled = 1; // sec.encrypt = 1; - switch (ext->alg) { - case IW_ENCODE_ALG_WEP: - alg = "WEP"; - break; - case IW_ENCODE_ALG_TKIP: - alg = "TKIP"; - break; - case IW_ENCODE_ALG_CCMP: - alg = "CCMP"; - break; - default: - IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - ret = -EINVAL; - goto done; - } + switch (ext->alg) { + case IW_ENCODE_ALG_WEP: + alg = "WEP"; + break; + case IW_ENCODE_ALG_TKIP: + alg = "TKIP"; + break; + case IW_ENCODE_ALG_CCMP: + alg = "CCMP"; + break; + default: + IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + ret = -EINVAL; + goto done; + } // printk("8-09-08-9=====>%s, alg name:%s\n",__func__, alg); - ops = ieee80211_get_crypto_ops(alg); - if (ops == NULL) - ops = ieee80211_get_crypto_ops(alg); - if (ops == NULL) { - IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); + ops = ieee80211_get_crypto_ops(alg); + if (ops == NULL) + ops = ieee80211_get_crypto_ops(alg); + if (ops == NULL) { + IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); printk("========>unknown crypto alg %d\n", ext->alg); - ret = -EINVAL; - goto done; - } - - if (*crypt == NULL || (*crypt)->ops != ops) { - struct ieee80211_crypt_data *new_crypt; - - ieee80211_crypt_delayed_deinit(ieee, crypt); - - new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - new_crypt->ops = ops; - if (new_crypt->ops) - new_crypt->priv = new_crypt->ops->init(idx); - if (new_crypt->priv == NULL) { - kfree(new_crypt); - ret = -EINVAL; - goto done; - } - *crypt = new_crypt; - - } - - if (ext->key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, - (*crypt)->priv) < 0) { - IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); + ret = -EINVAL; + goto done; + } + + if (*crypt == NULL || (*crypt)->ops != ops) { + struct ieee80211_crypt_data *new_crypt; + + ieee80211_crypt_delayed_deinit(ieee, crypt); + + new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); + if (new_crypt == NULL) { + ret = -ENOMEM; + goto done; + } + new_crypt->ops = ops; + if (new_crypt->ops) + new_crypt->priv = new_crypt->ops->init(idx); + if (new_crypt->priv == NULL) { + kfree(new_crypt); + ret = -EINVAL; + goto done; + } + *crypt = new_crypt; + + } + + if (ext->key_len > 0 && (*crypt)->ops->set_key && + (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, + (*crypt)->priv) < 0) { + IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); printk("key setting failed\n"); - ret = -EINVAL; - goto done; - } + ret = -EINVAL; + goto done; + } #if 1 //skip_host_crypt: //printk("skip_host_crypt:ext_flags:%x\n", ext->ext_flags); - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - ieee->tx_keyidx = idx; - sec.active_key = idx; - sec.flags |= SEC_ACTIVE_KEY; - } - - if (ext->alg != IW_ENCODE_ALG_NONE) { - memcpy(sec.keys[idx], ext->key, ext->key_len); - sec.key_sizes[idx] = ext->key_len; - sec.flags |= (1 << idx); - if (ext->alg == IW_ENCODE_ALG_WEP) { - // sec.encode_alg[idx] = SEC_ALG_WEP; - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - // sec.encode_alg[idx] = SEC_ALG_TKIP; - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - // sec.encode_alg[idx] = SEC_ALG_CCMP; - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - /* Don't set sec level for group keys. */ - if (group_key) - sec.flags &= ~SEC_LEVEL; - } + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { + ieee->tx_keyidx = idx; + sec.active_key = idx; + sec.flags |= SEC_ACTIVE_KEY; + } + + if (ext->alg != IW_ENCODE_ALG_NONE) { + memcpy(sec.keys[idx], ext->key, ext->key_len); + sec.key_sizes[idx] = ext->key_len; + sec.flags |= (1 << idx); + if (ext->alg == IW_ENCODE_ALG_WEP) { + // sec.encode_alg[idx] = SEC_ALG_WEP; + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } else if (ext->alg == IW_ENCODE_ALG_TKIP) { + // sec.encode_alg[idx] = SEC_ALG_TKIP; + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_2; + } else if (ext->alg == IW_ENCODE_ALG_CCMP) { + // sec.encode_alg[idx] = SEC_ALG_CCMP; + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_3; + } + /* Don't set sec level for group keys. */ + if (group_key) + sec.flags &= ~SEC_LEVEL; + } #endif done: - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(dev)) { - IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name); - return -EINVAL; - } + ieee->iw_mode != IW_MODE_INFRA && + ieee->reset_port && ieee->reset_port(dev)) { + IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name); + return -EINVAL; + } - return ret; + return ret; } int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct iw_mlme *mlme = (struct iw_mlme *) extra; // printk("\ndkgadfslkdjgalskdf===============>%s(), cmd:%x\n", __func__, mlme->cmd); #if 1 switch (mlme->cmd) { - case IW_MLME_DEAUTH: + case IW_MLME_DEAUTH: case IW_MLME_DISASSOC: // printk("disassoc now\n"); ieee80211_disassociate(ieee); break; default: - return -EOPNOTSUPP; - } + return -EOPNOTSUPP; + } #endif return 0; } int ieee80211_wx_set_auth(struct ieee80211_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra) + struct iw_request_info *info, + struct iw_param *data, char *extra) { /* struct ieee80211_security sec = { - .flags = SEC_AUTH_MODE, + .flags = SEC_AUTH_MODE, } */ //printk("set auth:flag:%x, data value:%x\n", data->flags, data->value); switch (data->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: + case IW_AUTH_WPA_VERSION: /*need to support wpa2 here*/ //printk("wpa version:%x\n", data->value); break; - case IW_AUTH_CIPHER_PAIRWISE: - case IW_AUTH_CIPHER_GROUP: - case IW_AUTH_KEY_MGMT: - /* + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: + /* * * Host AP driver does not use these parameters and allows * * wpa_supplicant to control them internally. * */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures = data->value; - break; - case IW_AUTH_DROP_UNENCRYPTED: - ieee->drop_unencrypted = data->value; + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + ieee->tkip_countermeasures = data->value; + break; + case IW_AUTH_DROP_UNENCRYPTED: + ieee->drop_unencrypted = data->value; break; case IW_AUTH_80211_AUTH_ALG: - ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM)?1:0; + ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM) ? 1 : 0; //printk("open_wep:%d\n", ieee->open_wep); break; #if 1 case IW_AUTH_WPA_ENABLED: - ieee->wpa_enabled = (data->value)?1:0; + ieee->wpa_enabled = (data->value) ? 1 : 0; //printk("enable wpa:%d\n", ieee->wpa_enabled); break; #endif case IW_AUTH_RX_UNENCRYPTED_EAPOL: - ieee->ieee802_1x = data->value; + ieee->ieee802_1x = data->value; break; case IW_AUTH_PRIVACY_INVOKED: ieee->privacy_invoked = data->value; break; default: - return -EOPNOTSUPP; + return -EOPNOTSUPP; } return 0; } @@ -715,15 +710,13 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) { u8 *buf = NULL; - if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) - { + if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { printk("return error out, len:%zu\n", len); return -EINVAL; } - if (len) - { - if (len != ie[1]+2){ + if (len) { + if (len != ie[1]+2) { printk("len:%zu, ie:%d\n", len, ie[1]); return -EINVAL; } @@ -733,8 +726,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) kfree(ieee->wpa_ie); ieee->wpa_ie = buf; ieee->wpa_ie_len = len; - } - else{ + } else { kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c index f1db9e4..978dc5f 100644 --- a/drivers/staging/rtl8187se/r8185b_init.c +++ b/drivers/staging/rtl8187se/r8185b_init.c @@ -115,21 +115,24 @@ static u8 OFDM_CONFIG[] = { *--------------------------------------------------------------- */ -void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data) +static u8 PlatformIORead1Byte(struct net_device *dev, u32 offset) +{ + return read_nic_byte(dev, offset); +} + +static void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data) { write_nic_byte(dev, offset, data); read_nic_byte(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */ } -void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data) +static void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data) { write_nic_word(dev, offset, data); read_nic_word(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */ } -u8 PlatformIORead1Byte(struct net_device *dev, u32 offset); - -void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data) +static void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data) { if (offset == PhyAddr) { /* For Base Band configuration. */ @@ -172,37 +175,7 @@ void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data) } } -u8 PlatformIORead1Byte(struct net_device *dev, u32 offset) -{ - u8 data = 0; - - data = read_nic_byte(dev, offset); - - - return data; -} - -u16 PlatformIORead2Byte(struct net_device *dev, u32 offset) -{ - u16 data = 0; - - data = read_nic_word(dev, offset); - - - return data; -} - -u32 PlatformIORead4Byte(struct net_device *dev, u32 offset) -{ - u32 data = 0; - - data = read_nic_dword(dev, offset); - - - return data; -} - -void SetOutputEnableOfRfPins(struct net_device *dev) +static void SetOutputEnableOfRfPins(struct net_device *dev) { write_nic_word(dev, RFPinsEnable, 0x1bff); } @@ -287,35 +260,19 @@ u16 RF_ReadReg(struct net_device *dev, u8 offset) return reg; } +static u8 ReadBBPortUchar(struct net_device *dev, u32 addr) +{ + PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f); + return PlatformIORead1Byte(dev, PhyDataR); +} /* by Owen on 04/07/14 for writing BB register successfully */ -void WriteBBPortUchar(struct net_device *dev, u32 Data) +static void WriteBBPortUchar(struct net_device *dev, u32 Data) { - /* u8 TimeoutCounter; */ - u8 RegisterContent; - u8 UCharData; - - UCharData = (u8)((Data & 0x0000ff00) >> 8); PlatformIOWrite4Byte(dev, PhyAddr, Data); - /* for(TimeoutCounter = 10; TimeoutCounter > 0; TimeoutCounter--) */ - { - PlatformIOWrite4Byte(dev, PhyAddr, Data & 0xffffff7f); - RegisterContent = PlatformIORead1Byte(dev, PhyDataR); - /*if(UCharData == RegisterContent) */ - /* break; */ - } + ReadBBPortUchar(dev, Data); } -u8 ReadBBPortUchar(struct net_device *dev, u32 addr) -{ - /*u8 TimeoutCounter; */ - u8 RegisterContent; - - PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f); - RegisterContent = PlatformIORead1Byte(dev, PhyDataR); - - return RegisterContent; -} /* * Description: * Perform Antenna settings with antenna diversity on 87SE. @@ -327,62 +284,38 @@ bool SetAntennaConfig87SE(struct net_device *dev, { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); bool bAntennaSwitched = true; + u8 ant_diversity_offset = 0x00; /* 0x00 = disabled, 0x80 = enabled */ /* printk("SetAntennaConfig87SE(): DefaultAnt(%d), bAntDiversity(%d)\n", DefaultAnt, bAntDiversity); */ /* Threshold for antenna diversity. */ write_phy_cck(dev, 0x0c, 0x09); /* Reg0c : 09 */ - if (bAntDiversity) { /* Enable Antenna Diversity. */ - if (DefaultAnt == 1) { /* aux antenna */ - - /* Mac register, aux antenna */ - write_nic_byte(dev, ANTSEL, 0x00); - - /* Config CCK RX antenna. */ - write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */ - write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */ - - /* Config OFDM RX antenna. */ - write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */ - write_phy_ofdm(dev, 0x18, 0xb2); /* Reg18 : b2 */ - } else { /* use main antenna */ - /* Mac register, main antenna */ - write_nic_byte(dev, ANTSEL, 0x03); - /* base band */ - /* Config CCK RX antenna. */ - write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */ - write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */ - - /* Config OFDM RX antenna. */ - write_phy_ofdm(dev, 0x0d, 0x5c); /* Reg0d : 5c */ - write_phy_ofdm(dev, 0x18, 0xb2); /* Reg18 : b2 */ - } - } else { - /* Disable Antenna Diversity. */ - if (DefaultAnt == 1) { /* aux Antenna */ - /* Mac register, aux antenna */ - write_nic_byte(dev, ANTSEL, 0x00); - - /* Config CCK RX antenna. */ - write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */ - write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */ - - /* Config OFDM RX antenna. */ - write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */ - write_phy_ofdm(dev, 0x18, 0x32); /* Reg18 : 32 */ - } else { /* main Antenna */ - /* Mac register, main antenna */ - write_nic_byte(dev, ANTSEL, 0x03); - - /* Config CCK RX antenna. */ - write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */ - write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */ - - /* Config OFDM RX antenna. */ - write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */ - write_phy_ofdm(dev, 0x18, 0x32); /*Reg18 : 32 */ - } + if (bAntDiversity) /* Enable Antenna Diversity. */ + ant_diversity_offset = 0x80; + + if (DefaultAnt == 1) { /* aux Antenna */ + /* Mac register, aux antenna */ + write_nic_byte(dev, ANTSEL, 0x00); + + /* Config CCK RX antenna. */ + write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */ + write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 | ant_diversity_offset */ + + /* Config OFDM RX antenna. */ + write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */ + write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset); /* Reg18 : 32 */ + } else { /* main Antenna */ + /* Mac register, main antenna */ + write_nic_byte(dev, ANTSEL, 0x03); + + /* Config CCK RX antenna. */ + write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */ + write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 */ + + /* Config OFDM RX antenna. */ + write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */ + write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset); /*Reg18 : 32 */ } priv->CurrAntennaIndex = DefaultAnt; /* Update default settings. */ return bAntennaSwitched; @@ -394,7 +327,7 @@ bool SetAntennaConfig87SE(struct net_device *dev, *-------------------------------------------------------------- */ -void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev) +static void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); @@ -695,7 +628,7 @@ void UpdateInitialGain(struct net_device *dev) * Tx Power tracking mechanism routine on 87SE. * Created by Roger, 2007.12.11. */ -void InitTxPwrTracking87SE(struct net_device *dev) +static void InitTxPwrTracking87SE(struct net_device *dev) { u32 u4bRfReg; @@ -705,7 +638,7 @@ void InitTxPwrTracking87SE(struct net_device *dev) RF_WriteReg(dev, 0x02, u4bRfReg|PWR_METER_EN); mdelay(1); } -void PhyConfig8185(struct net_device *dev) +static void PhyConfig8185(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); write_nic_dword(dev, RCR, priv->ReceiveConfig); @@ -732,7 +665,7 @@ void PhyConfig8185(struct net_device *dev) return; } -void HwConfigureRTL8185(struct net_device *dev) +static void HwConfigureRTL8185(struct net_device *dev) { /* RTL8185_TODO: Determine Retrylimit, TxAGC, AutoRateFallback control. */ u8 bUNIVERSAL_CONTROL_RL = 0; @@ -857,21 +790,16 @@ static void MacConfig_85BASIC(struct net_device *dev) write_nic_byte(dev, 0x24E, 0x01); } -u8 GetSupportedWirelessMode8185(struct net_device *dev) +static u8 GetSupportedWirelessMode8185(struct net_device *dev) { return WIRELESS_MODE_B | WIRELESS_MODE_G; } -void ActUpdateChannelAccessSetting(struct net_device *dev, +static void ActUpdateChannelAccessSetting(struct net_device *dev, WIRELESS_MODE WirelessMode, PCHANNEL_ACCESS_SETTING ChnlAccessSetting) { - struct r8180_priv *priv = ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee80211; AC_CODING eACI; - AC_PARAM AcParam; - u8 bFollowLegacySetting = 0; - u8 u1bAIFS; /* * <RJ_TODO_8185B> @@ -893,131 +821,16 @@ void ActUpdateChannelAccessSetting(struct net_device *dev, write_nic_byte(dev, SIFS, ChnlAccessSetting->SIFS_Timer); write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); /* Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. */ - u1bAIFS = aSifsTime + (2 * ChnlAccessSetting->SlotTimeTimer); - write_nic_byte(dev, EIFS, ChnlAccessSetting->EIFS_Timer); write_nic_byte(dev, AckTimeOutReg, 0x5B); /* <RJ_EXPR_QOS> Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. */ - { /* Legacy 802.11. */ - bFollowLegacySetting = 1; - - } - - /* this setting is copied from rtl8187B. xiong-2006-11-13 */ - if (bFollowLegacySetting) { - - /* - * Follow 802.11 seeting to AC parameter, all AC shall use the same parameter. - * 2005.12.01, by rcnjko. - */ - AcParam.longData = 0; - AcParam.f.AciAifsn.f.AIFSN = 2; /* Follow 802.11 DIFS. */ - AcParam.f.AciAifsn.f.ACM = 0; - AcParam.f.Ecw.f.ECWmin = ChnlAccessSetting->CWminIndex; /* Follow 802.11 CWmin. */ - AcParam.f.Ecw.f.ECWmax = ChnlAccessSetting->CWmaxIndex; /* Follow 802.11 CWmax. */ - AcParam.f.TXOPLimit = 0; - - /* lzm reserved 080826 */ - /* For turbo mode setting. port from 87B by Isaiah 2008-08-01 */ - if (ieee->current_network.Turbo_Enable == 1) - AcParam.f.TXOPLimit = 0x01FF; - /* For 87SE with Intel 4965 Ad-Hoc mode have poor throughput (19MB) */ - if (ieee->iw_mode == IW_MODE_ADHOC) - AcParam.f.TXOPLimit = 0x0020; - - for (eACI = 0; eACI < AC_MAX; eACI++) { - AcParam.f.AciAifsn.f.ACI = (u8)eACI; - { - PAC_PARAM pAcParam = (PAC_PARAM)(&AcParam); - AC_CODING eACI; - u8 u1bAIFS; - u32 u4bAcParam; - - /* Retrieve parameters to update. */ - eACI = pAcParam->f.AciAifsn.f.ACI; - u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * ChnlAccessSetting->SlotTimeTimer + aSifsTime; - u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); - - switch (eACI) { - case AC1_BK: - /* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */ - break; - - case AC0_BE: - /* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */ - break; - - case AC2_VI: - /* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */ - break; - - case AC3_VO: - /* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */ - break; - - default: - DMESGW("SetHwReg8185(): invalid ACI: %d !\n", eACI); - break; - } - - /* Cehck ACM bit. */ - /* If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13. */ - { - PACI_AIFSN pAciAifsn = (PACI_AIFSN)(&pAcParam->f.AciAifsn); - AC_CODING eACI = pAciAifsn->f.ACI; - - /*for 8187B AsynIORead issue */ - u8 AcmCtrl = 0; - if (pAciAifsn->f.ACM) { - /* ACM bit is 1. */ - switch (eACI) { - case AC0_BE: - AcmCtrl |= (BEQ_ACM_EN|BEQ_ACM_CTL|ACM_HW_EN); /* or 0x21 */ - break; - - case AC2_VI: - AcmCtrl |= (VIQ_ACM_EN|VIQ_ACM_CTL|ACM_HW_EN); /* or 0x42 */ - break; - - case AC3_VO: - AcmCtrl |= (VOQ_ACM_EN|VOQ_ACM_CTL|ACM_HW_EN); /* or 0x84 */ - break; - - default: - DMESGW("SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI); - break; - } - } else { - /* ACM bit is 0. */ - switch (eACI) { - case AC0_BE: - AcmCtrl &= ((~BEQ_ACM_EN) & (~BEQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xDE */ - break; - - case AC2_VI: - AcmCtrl &= ((~VIQ_ACM_EN) & (~VIQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xBD */ - break; - - case AC3_VO: - AcmCtrl &= ((~VOQ_ACM_EN) & (~VOQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0x7B */ - break; - - default: - break; - } - } - write_nic_byte(dev, ACM_CONTROL, 0); - } - } - } + for (eACI = 0; eACI < AC_MAX; eACI++) { + write_nic_byte(dev, ACM_CONTROL, 0); } } -void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode) +static void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; @@ -1074,7 +887,7 @@ void rtl8185b_irq_enable(struct net_device *dev) write_nic_dword(dev, IMR, priv->IntrMask); } -void MgntDisconnectIBSS(struct net_device *dev) +static void MgntDisconnectIBSS(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u8 i; @@ -1100,7 +913,7 @@ void MgntDisconnectIBSS(struct net_device *dev) notify_wx_assoc_event(priv->ieee80211); } -void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn) +static void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u8 i; @@ -1117,7 +930,7 @@ void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn) } } -void MgntDisconnectAP(struct net_device *dev, u8 asRsn) +static void MgntDisconnectAP(struct net_device *dev, u8 asRsn) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); @@ -1135,7 +948,7 @@ void MgntDisconnectAP(struct net_device *dev, u8 asRsn) priv->ieee80211->state = IEEE80211_NOLINK; } -bool MgntDisconnect(struct net_device *dev, u8 asRsn) +static bool MgntDisconnect(struct net_device *dev, u8 asRsn) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); /* @@ -1171,7 +984,7 @@ bool MgntDisconnect(struct net_device *dev, u8 asRsn) * Assumption: * PASSIVE LEVEL. */ -bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState) +static bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); bool bResult = false; @@ -1275,7 +1088,7 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u return bActionAllowed; } -void InactivePowerSave(struct net_device *dev) +static void InactivePowerSave(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); /* diff --git a/drivers/staging/rtl8192u/changes b/drivers/staging/rtl8192u/changes index 87c33fd..0485d6e 100644 --- a/drivers/staging/rtl8192u/changes +++ b/drivers/staging/rtl8192u/changes @@ -2,4 +2,3 @@ v 0.1 First version. This is based on the rtl8180-sa2400 pre-0.22-CVS code.. - diff --git a/drivers/staging/rtl8192u/ieee80211/Makefile b/drivers/staging/rtl8192u/ieee80211/Makefile index 51effd6..b5d0c2e 100644 --- a/drivers/staging/rtl8192u/ieee80211/Makefile +++ b/drivers/staging/rtl8192u/ieee80211/Makefile @@ -25,4 +25,3 @@ obj-m +=ieee80211_crypt-rsl.o obj-m +=ieee80211_crypt_wep-rsl.o obj-m +=ieee80211_crypt_tkip-rsl.o obj-m +=ieee80211_crypt_ccmp-rsl.o - diff --git a/drivers/staging/rtl8192u/ieee80211/aes.c b/drivers/staging/rtl8192u/ieee80211/aes.c index a6bb6c9..abc1023 100644 --- a/drivers/staging/rtl8192u/ieee80211/aes.c +++ b/drivers/staging/rtl8192u/ieee80211/aes.c @@ -443,7 +443,7 @@ static struct crypto_alg aes_alg = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, .cia_max_keysize = AES_MAX_KEY_SIZE, - .cia_setkey = aes_set_key, + .cia_setkey = aes_set_key, .cia_encrypt = aes_encrypt, .cia_decrypt = aes_decrypt } @@ -466,4 +466,3 @@ module_exit(aes_fini); MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm"); MODULE_LICENSE("Dual BSD/GPL"); - diff --git a/drivers/staging/rtl8192u/ieee80211/arc4.c b/drivers/staging/rtl8192u/ieee80211/arc4.c index e3ad8d2..b790e9a 100644 --- a/drivers/staging/rtl8192u/ieee80211/arc4.c +++ b/drivers/staging/rtl8192u/ieee80211/arc4.c @@ -79,7 +79,7 @@ static struct crypto_alg arc4_alg = { .cra_u = { .cipher = { .cia_min_keysize = ARC4_MIN_KEY_SIZE, .cia_max_keysize = ARC4_MAX_KEY_SIZE, - .cia_setkey = arc4_set_key, + .cia_setkey = arc4_set_key, .cia_encrypt = arc4_crypt, .cia_decrypt = arc4_crypt } } }; diff --git a/drivers/staging/rtl8192u/ieee80211/crypto_compat.h b/drivers/staging/rtl8192u/ieee80211/crypto_compat.h index da48658..2ba374a 100644 --- a/drivers/staging/rtl8192u/ieee80211/crypto_compat.h +++ b/drivers/staging/rtl8192u/ieee80211/crypto_compat.h @@ -56,5 +56,3 @@ static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, } //EXPORT_SYMBOL_GPL(crypto_alloc_tfm); //EXPORT_SYMBOL_GPL(crypto_free_tfm); - - diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index ce63fc3..f10fd5a 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -218,4 +218,3 @@ EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm); EXPORT_SYMBOL(DOT11D_ScanComplete); EXPORT_SYMBOL(IsLegalChannel); EXPORT_SYMBOL(ToLegalChannel); - diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 502bfdb..210898c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -64,7 +64,7 @@ #endif #define KEY_TYPE_NA 0x0 -#define KEY_TYPE_WEP40 0x1 +#define KEY_TYPE_WEP40 0x1 #define KEY_TYPE_TKIP 0x2 #define KEY_TYPE_CCMP 0x4 #define KEY_TYPE_WEP104 0x5 @@ -195,21 +195,21 @@ enum _ReasonCode{ auth_not_valid = 0x2, deauth_lv_ss = 0x3, inactivity = 0x4, - ap_overload = 0x5, + ap_overload = 0x5, class2_err = 0x6, class3_err = 0x7, - disas_lv_ss = 0x8, + disas_lv_ss = 0x8, asoc_not_auth = 0x9, //----MIC_CHECK - mic_failure = 0xe, + mic_failure = 0xe, //----END MIC_CHECK // Reason code defined in 802.11i D10.0 p.28. invalid_IE = 0x0d, four_way_tmout = 0x0f, two_way_tmout = 0x10, - IE_dismatch = 0x11, + IE_dismatch = 0x11, invalid_Gcipher = 0x12, invalid_Pcipher = 0x13, invalid_AKMP = 0x14, @@ -222,7 +222,7 @@ enum _ReasonCode{ QoS_unspec = 0x20, // 32 QAP_bandwidth = 0x21, // 33 poor_condition = 0x22, // 34 - no_facility = 0x23, // 35 + no_facility = 0x23, // 35 // Where is 36??? req_declined = 0x25, // 37 invalid_param = 0x26, // 38 @@ -265,7 +265,7 @@ enum _ReasonCode{ #define IEEE_WPAX_USEGROUP 0 #define IEEE_WPAX_WEP40 1 #define IEEE_WPAX_TKIP 2 -#define IEEE_WPAX_WRAP 3 +#define IEEE_WPAX_WRAP 3 #define IEEE_WPAX_CCMP 4 #define IEEE_WPAX_WEP104 5 @@ -289,12 +289,12 @@ enum _ReasonCode{ #define MAX_IE_LEN 0xff // added for kernel conflict -#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl -#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl -#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl -#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl +#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl +#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl +#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl +#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl #define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl -#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl +#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl #define ieee80211_ccmp_null ieee80211_ccmp_null_rsl @@ -302,10 +302,10 @@ enum _ReasonCode{ #define ieee80211_wep_null ieee80211_wep_null_rsl -#define free_ieee80211 free_ieee80211_rsl -#define alloc_ieee80211 alloc_ieee80211_rsl +#define free_ieee80211 free_ieee80211_rsl +#define alloc_ieee80211 alloc_ieee80211_rsl -#define ieee80211_rx ieee80211_rx_rsl +#define ieee80211_rx ieee80211_rx_rsl #define ieee80211_rx_mgt ieee80211_rx_mgt_rsl #define ieee80211_get_beacon ieee80211_get_beacon_rsl @@ -450,7 +450,7 @@ typedef struct ieee_param { /* management */ #define IEEE80211_STYPE_ASSOC_REQ 0x0000 -#define IEEE80211_STYPE_ASSOC_RESP 0x0010 +#define IEEE80211_STYPE_ASSOC_RESP 0x0010 #define IEEE80211_STYPE_REASSOC_REQ 0x0020 #define IEEE80211_STYPE_REASSOC_RESP 0x0030 #define IEEE80211_STYPE_PROBE_REQ 0x0040 @@ -536,7 +536,7 @@ do { if (ieee80211_debug_level & (level)) \ //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA #define IEEE80211_DEBUG_DATA(level, data, datalen) \ do{ if ((ieee80211_debug_level & (level)) == (level)) \ - { \ + { \ int i; \ u8* pdata = (u8*) data; \ printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \ @@ -623,20 +623,20 @@ do { if (ieee80211_debug_level & (level)) \ #define MAX_STR_LEN 64 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ #define PRINTABLE(_ch) (_ch>'!' && _ch<'~') -#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if((_Comp) & level) \ +#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ + if((_Comp) & level) \ { \ int __i; \ - u8 buffer[MAX_STR_LEN]; \ - int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \ - memset(buffer, 0, MAX_STR_LEN); \ - memcpy(buffer, (u8 *)_Ptr, length ); \ + u8 buffer[MAX_STR_LEN]; \ + int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \ + memset(buffer, 0, MAX_STR_LEN); \ + memcpy(buffer, (u8 *)_Ptr, length ); \ for( __i=0; __i<MAX_STR_LEN; __i++ ) \ { \ - if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \ + if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \ } \ buffer[length] = '\0'; \ - printk("Rtl819x: "); \ + printk("Rtl819x: "); \ printk(_TitleString); \ printk(": %d, <%s>\n", _Len, buffer); \ } @@ -785,12 +785,12 @@ enum ieee80211_reasoncode { #define IEEE80211_24GHZ_BAND (1<<0) #define IEEE80211_52GHZ_BAND (1<<1) -#define IEEE80211_CCK_RATE_LEN 4 +#define IEEE80211_CCK_RATE_LEN 4 #define IEEE80211_CCK_RATE_1MB 0x02 #define IEEE80211_CCK_RATE_2MB 0x04 #define IEEE80211_CCK_RATE_5MB 0x0B #define IEEE80211_CCK_RATE_11MB 0x16 -#define IEEE80211_OFDM_RATE_LEN 8 +#define IEEE80211_OFDM_RATE_LEN 8 #define IEEE80211_OFDM_RATE_6MB 0x0C #define IEEE80211_OFDM_RATE_9MB 0x12 #define IEEE80211_OFDM_RATE_12MB 0x18 @@ -919,10 +919,10 @@ struct ieee80211_rx_stats { u16 fraglength; // FragLength should equal to PacketLength in non-fragment case u16 fragoffset; // Data offset for this fragment u16 ntotalfrag; - bool bisrxaggrsubframe; + bool bisrxaggrsubframe; bool bPacketBeacon; //cosa add for rssi bool bToSelfBA; //cosa add for rssi - char cck_adc_pwdb[4]; //cosa add for rx path selection + char cck_adc_pwdb[4]; //cosa add for rx path selection u16 Seq_Num; }; @@ -992,7 +992,7 @@ struct ieee80211_device; #define SEC_ALG_TKIP 2 #define SEC_ALG_CCMP 3 -#define WEP_KEYS 4 +#define WEP_KEYS 4 #define WEP_KEY_LEN 13 #define SCM_KEY_LEN 32 #define SCM_TEMPORAL_KEY_LENGTH 16 @@ -1205,7 +1205,7 @@ struct ieee80211_drv_agg_txb { struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; }__attribute__((packed)); -#define MAX_SUBFRAME_COUNT 64 +#define MAX_SUBFRAME_COUNT 64 struct ieee80211_rxb { u8 nr_subframes; struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; @@ -1534,7 +1534,7 @@ struct ieee80211_network { bool bWithAironetIE; bool bCkipSupported; bool bCcxRmEnable; - u16 CcxRmState[2]; + u16 CcxRmState[2]; // CCXv4 S59, MBSSID. bool bMBssidValid; u8 MBssidMask; @@ -1655,8 +1655,7 @@ typedef struct tx_pending_t{ struct ieee80211_txb *txb; }tx_pending_t; -typedef struct _bandwidth_autoswitch -{ +typedef struct _bandwidth_autoswitch { long threshold_20Mhzto40Mhz; long threshold_40Mhzto20Mhz; bool bforced_tx20Mhz; @@ -1668,8 +1667,7 @@ typedef struct _bandwidth_autoswitch #define REORDER_WIN_SIZE 128 #define REORDER_ENTRY_NUM 128 -typedef struct _RX_REORDER_ENTRY -{ +typedef struct _RX_REORDER_ENTRY { struct list_head List; u16 SeqNum; struct ieee80211_rxb* prxb; @@ -1709,15 +1707,13 @@ typedef struct _IbssParms{ #define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. // RF state. -typedef enum _RT_RF_POWER_STATE -{ +typedef enum _RT_RF_POWER_STATE { eRfOn, eRfSleep, eRfOff }RT_RF_POWER_STATE; -typedef struct _RT_POWER_SAVE_CONTROL -{ +typedef struct _RT_POWER_SAVE_CONTROL { // // Inactive Power Save(IPS) : Disable RF when disconnected @@ -1726,7 +1722,7 @@ typedef struct _RT_POWER_SAVE_CONTROL bool bIPSModeBackup; bool bSwRfProcessing; RT_RF_POWER_STATE eInactivePowerState; - struct work_struct InactivePsWorkItem; + struct work_struct InactivePsWorkItem; struct timer_list InactivePsTimer; // Return point for join action @@ -1837,11 +1833,11 @@ struct ieee80211_device { u8 HTHighestOperaRate; //wb added for rate operation mode to firmware u8 bTxDisableRateFallBack; - u8 bTxUseDriverAssingedRate; + u8 bTxUseDriverAssingedRate; atomic_t atm_chnlop; atomic_t atm_swbw; // u8 HTHighestOperaRate; -// u8 HTCurrentOperaRate; +// u8 HTCurrentOperaRate; // 802.11e and WMM Traffic Stream Info (TX) struct list_head Tx_TS_Admit_List; @@ -2055,9 +2051,9 @@ struct ieee80211_device { bool bdynamic_txpower_enable; bool bCTSToSelfEnable; - u8 CTSToSelfTH; + u8 CTSToSelfTH; - u32 fsync_time_interval; + u32 fsync_time_interval; u32 fsync_rate_bitmap; u8 fsync_rssi_threshold; bool bfsync_enable; @@ -2092,10 +2088,10 @@ struct ieee80211_device { struct delayed_work start_ibss_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; - // Qos related. Added by Annie, 2005-11-01. - //STA_QOS StaQos; + // Qos related. Added by Annie, 2005-11-01. + //STA_QOS StaQos; - //u32 STA_EDCA_PARAM[4]; + //u32 STA_EDCA_PARAM[4]; //CHANNEL_ACCESS_SETTING ChannelAccessSetting; @@ -2111,11 +2107,11 @@ struct ieee80211_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device * dev, int pri); + int (*is_queue_full) (struct net_device * dev, int pri); - int (*handle_management) (struct net_device * dev, - struct ieee80211_network * network, u16 type); - int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + int (*handle_management) (struct net_device * dev, + struct ieee80211_network * network, u16 type); + int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (management) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -2214,7 +2210,7 @@ struct ieee80211_device { #define IEEE_A (1<<0) #define IEEE_B (1<<1) #define IEEE_G (1<<2) -#define IEEE_N_24G (1<<4) +#define IEEE_N_24G (1<<4) #define IEEE_N_5G (1<<5) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index 82d4bf6..76c56e5 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -220,7 +220,7 @@ void free_ieee80211(struct net_device *dev) #ifdef CONFIG_IEEE80211_DEBUG -u32 ieee80211_debug_level = 0; +u32 ieee80211_debug_level; static int debug = \ // IEEE80211_DL_INFO | // IEEE80211_DL_WX | @@ -233,15 +233,15 @@ static int debug = \ // IEEE80211_DL_TX | // IEEE80211_DL_RX | //IEEE80211_DL_QOS | - // IEEE80211_DL_HT | + // IEEE80211_DL_HT | // IEEE80211_DL_TS | -// IEEE80211_DL_BA | +// IEEE80211_DL_BA | // IEEE80211_DL_REORDER| // IEEE80211_DL_TRACE | //IEEE80211_DL_DATA | IEEE80211_DL_ERR //awayls open this flags to show error out ; -struct proc_dir_entry *ieee80211_proc = NULL; +struct proc_dir_entry *ieee80211_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index e3cf7a4..ee7ce5f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -52,7 +52,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, u16 fc = le16_to_cpu(hdr->frame_ctl); skb->dev = ieee->dev; - skb_reset_mac_header(skb); + skb_reset_mac_header(skb); skb_pull(skb, ieee80211_get_hdrlen(fc)); skb->pkt_type = PACKET_OTHERHOST; @@ -218,16 +218,16 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, * this is not mandatory.... but seems that the probe * response parser uses it */ - struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data; + struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data; rx_stats->len = skb->len; ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats); - //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) - if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames - { - dev_kfree_skb_any(skb); - return 0; - } + //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) + if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames + { + dev_kfree_skb_any(skb); + return 0; + } ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype); @@ -608,7 +608,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee, u16 SeqNum) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - PRX_REORDER_ENTRY pReorderEntry = NULL; + PRX_REORDER_ENTRY pReorderEntry = NULL; struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; u8 WinSize = pHTInfo->RxReorderWinSize; u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; @@ -773,7 +773,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee, } u8 parse_subframe(struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, + struct ieee80211_rx_stats *rx_stats, struct ieee80211_rxb *rxb,u8* src,u8* dst) { struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr* )skb->data; @@ -1043,7 +1043,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, { // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc)); - if( (fc & (1<<11)) && + if( (fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) ) { @@ -1154,8 +1154,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, type, stype, skb->len); goto rx_dropped; } - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) - goto rx_dropped; + if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) + goto rx_dropped; /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ @@ -1402,19 +1402,19 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; * the right values */ static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element - *info_element, int sub_type) + *info_element, int sub_type) { - if (info_element->qui_subtype != sub_type) - return -1; - if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) - return -1; - if (info_element->qui_type != QOS_OUI_TYPE) - return -1; - if (info_element->version != QOS_VERSION_1) - return -1; + if (info_element->qui_subtype != sub_type) + return -1; + if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) + return -1; + if (info_element->qui_type != QOS_OUI_TYPE) + return -1; + if (info_element->version != QOS_VERSION_1) + return -1; - return 0; + return 0; } @@ -1422,56 +1422,56 @@ static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element * Parse a QoS parameter element */ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info - *element_param, struct ieee80211_info_element - *info_element) + *element_param, struct ieee80211_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; - - if ((info_element == NULL) || (element_param == NULL)) - return -1; - - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = ieee80211_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + int ret = 0; + u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; + + if ((info_element == NULL) || (element_param == NULL)) + return -1; + + if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { + memcpy(element_param->info_element.qui, info_element->data, + info_element->len); + element_param->info_element.elementID = info_element->id; + element_param->info_element.length = info_element->len; + } else + ret = -1; + if (ret == 0) + ret = ieee80211_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); + return ret; } /* * Parse a QoS information element */ static int ieee80211_read_qos_info_element(struct - ieee80211_qos_information_element - *element_info, struct ieee80211_info_element - *info_element) + ieee80211_qos_information_element + *element_info, struct ieee80211_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_information_element) - 2; - - if (element_info == NULL) - return -1; - if (info_element == NULL) - return -1; - - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; - - if (ret == 0) - ret = ieee80211_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + int ret = 0; + u16 size = sizeof(struct ieee80211_qos_information_element) - 2; + + if (element_info == NULL) + return -1; + if (info_element == NULL) + return -1; + + if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + memcpy(element_info->qui, info_element->data, + info_element->len); + element_info->elementID = info_element->id; + element_info->length = info_element->len; + } else + ret = -1; + + if (ret == 0) + ret = ieee80211_verify_qos_info(element_info, + QOS_OUI_INFO_SUB_TYPE); + return ret; } @@ -1479,39 +1479,39 @@ static int ieee80211_read_qos_info_element(struct * Write QoS parameters from the ac parameters. */ static int ieee80211_qos_convert_ac_to_parameters(struct - ieee80211_qos_parameter_info - *param_elm, struct - ieee80211_qos_parameters - *qos_param) + ieee80211_qos_parameter_info + *param_elm, struct + ieee80211_qos_parameters + *qos_param) { - int rc = 0; - int i; - struct ieee80211_qos_ac_parameter *ac_params; + int rc = 0; + int i; + struct ieee80211_qos_ac_parameter *ac_params; u8 aci; - //u8 cw_min; - //u8 cw_max; + //u8 cw_min; + //u8 cw_max; - for (i = 0; i < QOS_QUEUE_NUM; i++) { - ac_params = &(param_elm->ac_params_record[i]); + for (i = 0; i < QOS_QUEUE_NUM; i++) { + ac_params = &(param_elm->ac_params_record[i]); aci = (ac_params->aci_aifsn & 0x60) >> 5; if(aci >= QOS_QUEUE_NUM) continue; - qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; + qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; + qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; + qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; + qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; - qos_param->flag[aci] = - (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); - } - return rc; + qos_param->flag[aci] = + (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; + qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); + } + return rc; } /* @@ -1520,38 +1520,38 @@ static int ieee80211_qos_convert_ac_to_parameters(struct * which type to read */ static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element - *info_element, - struct ieee80211_network *network) + *info_element, + struct ieee80211_network *network) { - int rc = 0; - struct ieee80211_qos_parameters *qos_param = NULL; - struct ieee80211_qos_information_element qos_info_element; - - rc = ieee80211_read_qos_info_element(&qos_info_element, info_element); - - if (rc == 0) { - network->qos_data.param_count = qos_info_element.ac_info & 0x0F; - network->flags |= NETWORK_HAS_QOS_INFORMATION; - } else { - struct ieee80211_qos_parameter_info param_element; - - rc = ieee80211_read_qos_param_element(¶m_element, - info_element); - if (rc == 0) { - qos_param = &(network->qos_data.parameters); - ieee80211_qos_convert_ac_to_parameters(¶m_element, - qos_param); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } - } - - if (rc == 0) { - IEEE80211_DEBUG_QOS("QoS is supported\n"); - network->qos_data.supported = 1; - } - return rc; + int rc = 0; + struct ieee80211_qos_parameters *qos_param = NULL; + struct ieee80211_qos_information_element qos_info_element; + + rc = ieee80211_read_qos_info_element(&qos_info_element, info_element); + + if (rc == 0) { + network->qos_data.param_count = qos_info_element.ac_info & 0x0F; + network->flags |= NETWORK_HAS_QOS_INFORMATION; + } else { + struct ieee80211_qos_parameter_info param_element; + + rc = ieee80211_read_qos_param_element(¶m_element, + info_element); + if (rc == 0) { + qos_param = &(network->qos_data.parameters); + ieee80211_qos_convert_ac_to_parameters(¶m_element, + qos_param); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; + } + } + + if (rc == 0) { + IEEE80211_DEBUG_QOS("QoS is supported\n"); + network->qos_data.supported = 1; + } + return rc; } #ifdef CONFIG_IEEE80211_DEBUG @@ -1559,37 +1559,37 @@ static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element static const char *get_info_element_string(u16 id) { - switch (id) { - MFIE_STRING(SSID); - MFIE_STRING(RATES); - MFIE_STRING(FH_SET); - MFIE_STRING(DS_SET); - MFIE_STRING(CF_SET); - MFIE_STRING(TIM); - MFIE_STRING(IBSS_SET); - MFIE_STRING(COUNTRY); - MFIE_STRING(HOP_PARAMS); - MFIE_STRING(HOP_TABLE); - MFIE_STRING(REQUEST); - MFIE_STRING(CHALLENGE); - MFIE_STRING(POWER_CONSTRAINT); - MFIE_STRING(POWER_CAPABILITY); - MFIE_STRING(TPC_REQUEST); - MFIE_STRING(TPC_REPORT); - MFIE_STRING(SUPP_CHANNELS); - MFIE_STRING(CSA); - MFIE_STRING(MEASURE_REQUEST); - MFIE_STRING(MEASURE_REPORT); - MFIE_STRING(QUIET); - MFIE_STRING(IBSS_DFS); - // MFIE_STRING(ERP_INFO); - MFIE_STRING(RSN); - MFIE_STRING(RATES_EX); - MFIE_STRING(GENERIC); - MFIE_STRING(QOS_PARAMETER); - default: - return "UNKNOWN"; - } + switch (id) { + MFIE_STRING(SSID); + MFIE_STRING(RATES); + MFIE_STRING(FH_SET); + MFIE_STRING(DS_SET); + MFIE_STRING(CF_SET); + MFIE_STRING(TIM); + MFIE_STRING(IBSS_SET); + MFIE_STRING(COUNTRY); + MFIE_STRING(HOP_PARAMS); + MFIE_STRING(HOP_TABLE); + MFIE_STRING(REQUEST); + MFIE_STRING(CHALLENGE); + MFIE_STRING(POWER_CONSTRAINT); + MFIE_STRING(POWER_CAPABILITY); + MFIE_STRING(TPC_REQUEST); + MFIE_STRING(TPC_REPORT); + MFIE_STRING(SUPP_CHANNELS); + MFIE_STRING(CSA); + MFIE_STRING(MEASURE_REQUEST); + MFIE_STRING(MEASURE_REPORT); + MFIE_STRING(QUIET); + MFIE_STRING(IBSS_DFS); + // MFIE_STRING(ERP_INFO); + MFIE_STRING(RSN); + MFIE_STRING(RATES_EX); + MFIE_STRING(GENERIC); + MFIE_STRING(QOS_PARAMETER); + default: + return "UNKNOWN"; + } } #endif @@ -1634,7 +1634,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, { u8 i; short offset; - u16 tmp_htcap_len=0; + u16 tmp_htcap_len=0; u16 tmp_htinfo_len=0; u16 ht_realtek_agg_len=0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; @@ -1752,34 +1752,34 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, network->tim.tim_count = info_element->data[0]; network->tim.tim_period = info_element->data[1]; - network->dtim_period = info_element->data[1]; - if(ieee->state != IEEE80211_LINKED) - break; + network->dtim_period = info_element->data[1]; + if(ieee->state != IEEE80211_LINKED) + break; - network->last_dtim_sta_time[0] = stats->mac_time[0]; - network->last_dtim_sta_time[1] = stats->mac_time[1]; + network->last_dtim_sta_time[0] = stats->mac_time[0]; + network->last_dtim_sta_time[1] = stats->mac_time[1]; - network->dtim_data = IEEE80211_DTIM_VALID; + network->dtim_data = IEEE80211_DTIM_VALID; - if(info_element->data[0] != 0) - break; + if(info_element->data[0] != 0) + break; - if(info_element->data[2] & 1) - network->dtim_data |= IEEE80211_DTIM_MBCAST; + if(info_element->data[2] & 1) + network->dtim_data |= IEEE80211_DTIM_MBCAST; - offset = (info_element->data[2] >> 1)*2; + offset = (info_element->data[2] >> 1)*2; - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - if(ieee->assoc_id < 8*offset || - ieee->assoc_id > 8*(offset + info_element->len -3)) + if(ieee->assoc_id < 8*offset || + ieee->assoc_id > 8*(offset + info_element->len -3)) - break; + break; - offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ; + offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ; - if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) - network->dtim_data |= IEEE80211_DTIM_UCAST; + if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) + network->dtim_data |= IEEE80211_DTIM_UCAST; //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n"); break; @@ -1820,17 +1820,17 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, } #ifdef THOMAS_TURBO - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) { - network->Turbo_Enable = 1; - } + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) { + network->Turbo_Enable = 1; + } #endif - //for HTcap and HTinfo parameters + //for HTcap and HTinfo parameters if(tmp_htcap_len == 0){ if(info_element->len >= 4 && info_element->data[0] == 0x00 && @@ -1839,12 +1839,12 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, info_element->data[3] == 0x033){ tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if(tmp_htcap_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + if(tmp_htcap_len != 0){ + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); - } + } } if(tmp_htcap_len != 0) network->bssht.bdSupportHT = true; @@ -1856,9 +1856,9 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, if(tmp_htinfo_len == 0){ if(info_element->len >= 4 && info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034){ + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034){ tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); if(tmp_htinfo_len != 0){ @@ -2014,7 +2014,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, network->rsn_ie_len); break; - //HT related element. + //HT related element. case MFIE_TYPE_HT_CAP: IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", info_element->len); @@ -2027,7 +2027,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT() // windows driver will update WMM parameters each beacon received once connected - // Linux driver is a bit different. + // Linux driver is a bit different. network->bssht.bdSupportHT = true; } else @@ -2060,7 +2060,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, if( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) { - network->bCkipSupported = true; + network->bCkipSupported = true; } else { @@ -2070,7 +2070,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, else { network->bWithAironetIE = false; - network->bCkipSupported = false; + network->bCkipSupported = false; } break; case MFIE_TYPE_QOS_PARAMETER: @@ -2189,10 +2189,10 @@ static inline int ieee80211_network_init( //char *p; #endif - network->qos_data.active = 0; - network->qos_data.supported = 0; - network->qos_data.param_count = 0; - network->qos_data.old_param_count = 0; + network->qos_data.active = 0; + network->qos_data.supported = 0; + network->qos_data.param_count = 0; + network->qos_data.old_param_count = 0; /* Pull out fixed field data */ memcpy(network->bssid, beacon->header.addr3, ETH_ALEN); @@ -2209,9 +2209,9 @@ static inline int ieee80211_network_init( network->flags = 0; network->atim_window = 0; network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? - 0x3 : 0x0; + 0x3 : 0x0; network->berp_info_valid = false; - network->broadcom_cap_exist = false; + network->broadcom_cap_exist = false; network->ralink_cap_exist = false; network->atheros_cap_exist = false; network->cisco_cap_exist = false; @@ -2230,12 +2230,12 @@ static inline int ieee80211_network_init( } else network->flags |= NETWORK_HAS_CCK; - network->wpa_ie_len = 0; - network->rsn_ie_len = 0; + network->wpa_ie_len = 0; + network->rsn_ie_len = 0; - if (ieee80211_parse_info_param - (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats)) - return 1; + if (ieee80211_parse_info_param + (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats)) + return 1; network->mode = 0; if (stats->freq == IEEE80211_52GHZ_BAND) @@ -2329,7 +2329,7 @@ static inline void update_network(struct ieee80211_network *dst, dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters)); - dst->bssht.bdSupportHT = src->bssht.bdSupportHT; + dst->bssht.bdSupportHT = src->bssht.bdSupportHT; dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 7a07078..454f889 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -498,7 +498,7 @@ void ieee80211_softmac_scan_wq(struct work_struct *work) { struct delayed_work *dwork = container_of(work, struct delayed_work, work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); - static short watchdog = 0; + static short watchdog; u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); if(!ieee->ieee_up) @@ -1948,166 +1948,166 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - case IEEE80211_STYPE_ASSOC_RESP: - case IEEE80211_STYPE_REASSOC_RESP: - - IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && - ieee->iw_mode == IW_MODE_INFRA){ - struct ieee80211_network network_resp; - struct ieee80211_network *network = &network_resp; - - if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ - ieee->state=IEEE80211_LINKED; - ieee->assoc_id = aid; - ieee->softmac_stats.rx_ass_ok++; - /* station support qos */ - /* Let the register setting defaultly with Legacy station */ - if(ieee->qos_support) { - assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data; - memset(network, 0, sizeof(*network)); - if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ - return 1; - } - else - { //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. - memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); - } - if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network); + case IEEE80211_STYPE_ASSOC_RESP: + case IEEE80211_STYPE_REASSOC_RESP: + + IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && + ieee->iw_mode == IW_MODE_INFRA){ + struct ieee80211_network network_resp; + struct ieee80211_network *network = &network_resp; + + if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ + ieee->state=IEEE80211_LINKED; + ieee->assoc_id = aid; + ieee->softmac_stats.rx_ass_ok++; + /* station support qos */ + /* Let the register setting defaultly with Legacy station */ + if(ieee->qos_support) { + assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data; + memset(network, 0, sizeof(*network)); + if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\ + rx_stats->len - sizeof(*assoc_resp),\ + network,rx_stats)){ + return 1; } - ieee80211_associate_complete(ieee); - } else { - /* aid could not been allocated */ - ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", - errcode); - IEEE80211_DEBUG_MGMT( - "Association response status code 0x%x\n", - errcode); - if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } else { - ieee80211_associate_abort(ieee); + else + { //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network. + memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); } + if (ieee->handle_assoc_response != NULL) + ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network); + } + ieee80211_associate_complete(ieee); + } else { + /* aid could not been allocated */ + ieee->softmac_stats.rx_ass_err++; + printk( + "Association response status code 0x%x\n", + errcode); + IEEE80211_DEBUG_MGMT( + "Association response status code 0x%x\n", + errcode); + if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { + queue_work(ieee->wq, &ieee->associate_procedure_wq); + } else { + ieee80211_associate_abort(ieee); } } - break; + } + break; - case IEEE80211_STYPE_ASSOC_REQ: - case IEEE80211_STYPE_REASSOC_REQ: + case IEEE80211_STYPE_ASSOC_REQ: + case IEEE80211_STYPE_REASSOC_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->iw_mode == IW_MODE_MASTER) - ieee80211_rx_assoc_rq(ieee, skb); - break; + ieee80211_rx_assoc_rq(ieee, skb); + break; - case IEEE80211_STYPE_AUTH: + case IEEE80211_STYPE_AUTH: - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && - ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && + ieee->iw_mode == IW_MODE_INFRA){ - IEEE80211_DEBUG_MGMT("Received authentication response"); + IEEE80211_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ - if(ieee->open_wep || !challenge){ - ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; - ieee->softmac_stats.rx_auth_rs_ok++; - if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) + if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ + if(ieee->open_wep || !challenge){ + ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; + ieee->softmac_stats.rx_auth_rs_ok++; + if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) + { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) + // WEP or TKIP encryption + if(IsHTHalfNmodeAPs(ieee)) { - // WEP or TKIP encryption - if(IsHTHalfNmodeAPs(ieee)) - { - bSupportNmode = true; - bHalfSupportNmode = true; - } - else - { - bSupportNmode = false; - bHalfSupportNmode = false; - } - printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode); + bSupportNmode = true; + bHalfSupportNmode = true; } + else + { + bSupportNmode = false; + bHalfSupportNmode = false; + } + printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode); } - /* Dummy wirless mode setting to avoid encryption issue */ - if(bSupportNmode) { - //N mode setting - ieee->SetWirelessMode(ieee->dev, \ - ieee->current_network.mode); - }else{ - //b/g mode setting - /*TODO*/ - ieee->SetWirelessMode(ieee->dev, IEEE_G); - } - - if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) - { - printk("===============>entern half N mode\n"); - ieee->bHalfWirelessN24GMode = true; - } - else - ieee->bHalfWirelessN24GMode = false; - - ieee80211_associate_step2(ieee); + } + /* Dummy wirless mode setting to avoid encryption issue */ + if(bSupportNmode) { + //N mode setting + ieee->SetWirelessMode(ieee->dev, \ + ieee->current_network.mode); }else{ - ieee80211_auth_challenge(ieee, challenge, chlen); + //b/g mode setting + /*TODO*/ + ieee->SetWirelessMode(ieee->dev, IEEE_G); } + + if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) + { + printk("===============>entern half N mode\n"); + ieee->bHalfWirelessN24GMode = true; + } + else + ieee->bHalfWirelessN24GMode = false; + + ieee80211_associate_step2(ieee); }else{ - ieee->softmac_stats.rx_auth_rs_err++; - IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode); - ieee80211_associate_abort(ieee); + ieee80211_auth_challenge(ieee, challenge, chlen); } - - }else if (ieee->iw_mode == IW_MODE_MASTER){ - ieee80211_rx_auth_rq(ieee, skb); + }else{ + ieee->softmac_stats.rx_auth_rs_err++; + IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode); + ieee80211_associate_abort(ieee); } + + }else if (ieee->iw_mode == IW_MODE_MASTER){ + ieee80211_rx_auth_rq(ieee, skb); } - break; + } + break; - case IEEE80211_STYPE_PROBE_REQ: + case IEEE80211_STYPE_PROBE_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == IEEE80211_LINKED)){ - ieee80211_rx_probe_rq(ieee, skb); - } - break; + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == IEEE80211_LINKED)){ + ieee80211_rx_probe_rq(ieee, skb); + } + break; - case IEEE80211_STYPE_DISASSOC: - case IEEE80211_STYPE_DEAUTH: - /* FIXME for now repeat all the association procedure - * both for disassociation and deauthentication - */ - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == IEEE80211_LINKED && - ieee->iw_mode == IW_MODE_INFRA){ - - ieee->state = IEEE80211_ASSOCIATING; - ieee->softmac_stats.reassoc++; - - notify_wx_assoc_event(ieee); - //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - RemovePeerTS(ieee, header->addr2); - queue_work(ieee->wq, &ieee->associate_procedure_wq); - } - break; - case IEEE80211_STYPE_MANAGE_ACT: - ieee80211_process_action(ieee,skb); - break; - default: - return -1; - break; + case IEEE80211_STYPE_DISASSOC: + case IEEE80211_STYPE_DEAUTH: + /* FIXME for now repeat all the association procedure + * both for disassociation and deauthentication + */ + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->state == IEEE80211_LINKED && + ieee->iw_mode == IW_MODE_INFRA){ + + ieee->state = IEEE80211_ASSOCIATING; + ieee->softmac_stats.reassoc++; + + notify_wx_assoc_event(ieee); + //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); + RemovePeerTS(ieee, header->addr2); + queue_work(ieee->wq, &ieee->associate_procedure_wq); + } + break; + case IEEE80211_STYPE_MANAGE_ACT: + ieee80211_process_action(ieee,skb); + break; + default: + return -1; + break; } //dev_kfree_skb_any(skb); @@ -2503,8 +2503,8 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) } void ieee80211_associate_retry_wq(struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); + struct delayed_work *dwork = container_of(work, struct delayed_work, work); + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); unsigned long flags; down(&ieee->wx_sem); @@ -3124,7 +3124,7 @@ inline struct sk_buff *ieee80211_disassociate_skb( void SendDisassociation( struct ieee80211_device *ieee, - u8* asSta, + u8* asSta, u8 asRsn ) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 421da8a..60746b8 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -302,7 +302,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) HT_EXTCHNL_OFFSET chan_offset=0; HT_CHANNEL_WIDTH bandwidth=0; int b40M = 0; - static int count = 0; + static int count; chan = ieee->current_network.channel; netif_carrier_off(ieee->dev); @@ -482,22 +482,23 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - strcpy(wrqu->name, "802.11"); - if(ieee->modulation & IEEE80211_CCK_MODULATION){ - strcat(wrqu->name, "b"); - if(ieee->modulation & IEEE80211_OFDM_MODULATION) - strcat(wrqu->name, "/g"); - }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) - strcat(wrqu->name, "g"); - if (ieee->mode & (IEEE_N_24G | IEEE_N_5G)) - strcat(wrqu->name, "/n"); + strlcpy(wrqu->name, "802.11", IFNAMSIZ); + if (ieee->modulation & IEEE80211_CCK_MODULATION) { + strlcat(wrqu->name, "b", IFNAMSIZ); + if (ieee->modulation & IEEE80211_OFDM_MODULATION) + strlcat(wrqu->name, "/g", IFNAMSIZ); + } else if (ieee->modulation & IEEE80211_OFDM_MODULATION) { + strlcat(wrqu->name, "g", IFNAMSIZ); + } - if((ieee->state == IEEE80211_LINKED) || - (ieee->state == IEEE80211_LINKED_SCANNING)) - strcat(wrqu->name," linked"); - else if(ieee->state != IEEE80211_NOLINK) - strcat(wrqu->name," link.."); + if (ieee->mode & (IEEE_N_24G | IEEE_N_5G)) + strlcat(wrqu->name, "/n", IFNAMSIZ); + if ((ieee->state == IEEE80211_LINKED) || + (ieee->state == IEEE80211_LINKED_SCANNING)) + strlcat(wrqu->name, " linked", IFNAMSIZ); + else if (ieee->state != IEEE80211_NOLINK) + strlcat(wrqu->name, " link..", IFNAMSIZ); return 0; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 3f5ceeb..c39e680 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -70,7 +70,7 @@ val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep | | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | '-----------------------------------------------------------------------------------------' - /\ + /\ | 802.11 Data Frame | ,--------- 'ctrl' expands to >-----------' @@ -283,22 +283,22 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network) // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len); ip = ip_hdr(skb); switch (ip->tos & 0xfc) { - case 0x20: - return 2; - case 0x40: - return 1; - case 0x60: - return 3; - case 0x80: - return 4; - case 0xa0: - return 5; - case 0xc0: - return 6; - case 0xe0: - return 7; - default: - return 0; + case 0x20: + return 2; + case 0x40: + return 1; + case 0x60: + return 3; + case 0x80: + return 4; + case 0xa0: + return 5; + case 0xc0: + return 6; + case 0xe0: + return 7; + default: + return 0; } } @@ -395,7 +395,7 @@ ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, cb_desc *tcb_desc) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - tcb_desc->bUseShortGI = false; + tcb_desc->bUseShortGI = false; if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; @@ -514,7 +514,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_ if(pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { tcb_desc->bCTSEnable = true; - tcb_desc->rts_rate = MGN_24M; + tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } @@ -527,7 +527,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_ { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; + tcb_desc->bRTSEnable = true; } if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) tcb_desc->bUseShortPreamble = true; @@ -656,17 +656,17 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) memcpy(&dest, skb->data, ETH_ALEN); memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); - /* Advance the SKB to the start of the payload */ - skb_pull(skb, sizeof(struct ethhdr)); + /* Advance the SKB to the start of the payload */ + skb_pull(skb, sizeof(struct ethhdr)); - /* Determine total amount of storage required for TXB packets */ - bytes = skb->len + SNAP_SIZE + sizeof(u16); + /* Determine total amount of storage required for TXB packets */ + bytes = skb->len + SNAP_SIZE + sizeof(u16); if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_WEP; else - fc = IEEE80211_FTYPE_DATA; + fc = IEEE80211_FTYPE_DATA; //if(ieee->current_network.QoS_Enable) if(qos_actived) @@ -689,7 +689,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } - header.frame_ctl = cpu_to_le16(fc); + header.frame_ctl = cpu_to_le16(fc); /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ @@ -833,7 +833,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) else ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; } else { - if (ieee->seq_ctrl[0] == 0xFFF) + if (ieee->seq_ctrl[0] == 0xFFF) ieee->seq_ctrl[0] = 0; else ieee->seq_ctrl[0]++; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index f0ba7f4..e1fe54a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -761,7 +761,7 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, case IW_MLME_DISASSOC: ieee80211_disassociate(ieee); break; - default: + default: return -EOPNOTSUPP; } return 0; diff --git a/drivers/staging/rtl8192u/ieee80211/internal.h b/drivers/staging/rtl8192u/ieee80211/internal.h index bebe13a..6f54cfe 100644 --- a/drivers/staging/rtl8192u/ieee80211/internal.h +++ b/drivers/staging/rtl8192u/ieee80211/internal.h @@ -79,4 +79,3 @@ void crypto_exit_cipher_ops(struct crypto_tfm *tfm); void crypto_exit_compress_ops(struct crypto_tfm *tfm); #endif /* _CRYPTO_INTERNAL_H */ - diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h index 8ddc8bf9..2c398ca 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h @@ -1,7 +1,7 @@ #ifndef _BATYPE_H_ #define _BATYPE_H_ -#define TOTAL_TXBA_NUM 16 +#define TOTAL_TXBA_NUM 16 #define TOTAL_RXBA_NUM 16 #define BA_SETUP_TIMEOUT 200 @@ -28,8 +28,7 @@ struct ieee80211_ADDBA_Req{ //Is this need?I put here just to make it easier to define structure BA_RECORD //WB typedef union _SEQUENCE_CONTROL{ u16 ShortData; - struct - { + struct { u16 FragNum:4; u16 SeqNum:12; }field; @@ -66,4 +65,3 @@ typedef struct _BA_RECORD { } BA_RECORD, *PBA_RECORD; #endif //end _BATYPE_H_ - diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 1ebea3d..69735d3 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -9,8 +9,8 @@ /******************************************************************************************************************** *function: Activate BA entry. And if Time is nozero, start timer. - * input: PBA_RECORD pBA //BA entry to be enabled - * u16 Time //indicate time delay. + * input: PBA_RECORD pBA //BA entry to be enabled + * u16 Time //indicate time delay. * output: none ********************************************************************************************************************/ void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time) @@ -22,7 +22,7 @@ void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time) /******************************************************************************************************************** *function: deactivate BA entry, including its timer. - * input: PBA_RECORD pBA //BA entry to be disabled + * input: PBA_RECORD pBA //BA entry to be disabled * output: none ********************************************************************************************************************/ void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA) @@ -33,7 +33,7 @@ void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA) /******************************************************************************************************************** *function: deactivete BA entry in Tx Ts, and send DELBA. * input: - * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry. + * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry. * output: none * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME ********************************************************************************************************************/ @@ -63,7 +63,7 @@ u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs) /******************************************************************************************************************** *function: deactivete BA entry in Tx Ts, and send DELBA. * input: - * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry. + * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry. * output: none * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above ********************************************************************************************************************/ @@ -84,7 +84,7 @@ u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs) /******************************************************************************************************************** *function: reset BA entry * input: - * PBA_RECORD pBA //entry to be reset + * PBA_RECORD pBA //entry to be reset * output: none ********************************************************************************************************************/ void ResetBaEntry( PBA_RECORD pBA) @@ -98,12 +98,12 @@ void ResetBaEntry( PBA_RECORD pBA) //These functions need porting here or not? /******************************************************************************************************************************* *function: construct ADDBAREQ and ADDBARSP frame here together. - * input: u8* Dst //ADDBA frame's destination - * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA. - * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?) - * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ) + * input: u8* Dst //ADDBA frame's destination + * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA. + * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?) + * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ) * output: none - * return: sk_buff* skb //return constructed skb to xmit + * return: sk_buff* skb //return constructed skb to xmit *******************************************************************************************************************************/ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) { @@ -126,7 +126,7 @@ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, P return NULL; } - memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. + memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. skb_reserve(skb, ieee->tx_headroom); BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); @@ -177,12 +177,12 @@ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, P /******************************************************************************************************************** *function: construct DELBA frame - * input: u8* dst //DELBA frame's destination - * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA - * TR_SELECT TxRxSelect //TX RX direction - * u16 ReasonCode //status code. + * input: u8* dst //DELBA frame's destination + * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA + * TR_SELECT TxRxSelect //TX RX direction + * u16 ReasonCode //status code. * output: none - * return: sk_buff* skb //return constructed skb to xmit + * return: sk_buff* skb //return constructed skb to xmit ********************************************************************************************************************/ static struct sk_buff* ieee80211_DELBA( struct ieee80211_device* ieee, @@ -246,8 +246,8 @@ static struct sk_buff* ieee80211_DELBA( /******************************************************************************************************************** *function: send ADDBAReq frame out - * input: u8* dst //ADDBAReq frame's destination - * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA + * input: u8* dst //ADDBAReq frame's destination + * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA * output: none * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does ********************************************************************************************************************/ @@ -272,9 +272,9 @@ void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD /******************************************************************************************************************** *function: send ADDBARSP frame out - * input: u8* dst //DELBA frame's destination - * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA - * u16 StatusCode //RSP StatusCode + * input: u8* dst //DELBA frame's destination + * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA + * u16 StatusCode //RSP StatusCode * output: none * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does ********************************************************************************************************************/ @@ -297,10 +297,10 @@ void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD } /******************************************************************************************************************** *function: send ADDBARSP frame out - * input: u8* dst //DELBA frame's destination - * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA - * TR_SELECT TxRxSelect //TX or RX - * u16 ReasonCode //DEL ReasonCode + * input: u8* dst //DELBA frame's destination + * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA + * TR_SELECT TxRxSelect //TX or RX + * u16 ReasonCode //DEL ReasonCode * output: none * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does ********************************************************************************************************************/ @@ -340,7 +340,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb) if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); + IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); return -1; } @@ -439,7 +439,7 @@ int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb) if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); + IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9)); return -1; } rsp = ( struct ieee80211_hdr_3addr*)skb->data; @@ -569,7 +569,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb) if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6)); + IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6)); return -1; } @@ -589,7 +589,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb) if(pDelBaParamSet->field.Initiator == 1) { - PRX_TS_RECORD pRxTs; + PRX_TS_RECORD pRxTs; if( !GetTs( ieee, @@ -657,7 +657,7 @@ TsInitAddBA( // BufferSize: This need to be set according to A-MPDU vector pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer - pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later. + pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later. ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT); @@ -734,4 +734,3 @@ void RxBaInactTimeout(unsigned long data) DELBA_REASON_TIMEOUT); return ; } - diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h index a60b39c..2b82835 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h @@ -121,7 +121,7 @@ typedef union _HT_CAPABILITY_MACPARA{ typedef enum _HT_ACTION{ ACT_RECOMMAND_WIDTH = 0, - ACT_MIMO_PWR_SAVE = 1, + ACT_MIMO_PWR_SAVE = 1, ACT_PSMP = 2, ACT_SET_PCO_PHASE = 3, ACT_MIMO_CHL_MEASURE = 4, @@ -398,9 +398,9 @@ typedef struct _BSS_HT{ typedef struct _MIMO_RSSI{ u32 EnableAntenna; u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; + u32 AntennaB; + u32 AntennaC; + u32 AntennaD; u32 Average; }MIMO_RSSI, *PMIMO_RSSI; @@ -436,11 +436,11 @@ extern u8 MCS_FILTER_1SS[16]; // MCS Bw 40 {1~7, 12~15,32} -#define RATE_ADPT_1SS_MASK 0xFF +#define RATE_ADPT_1SS_MASK 0xFF #define RATE_ADPT_2SS_MASK 0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily #define RATE_ADPT_MCS32_MASK 0x01 -#define IS_11N_MCS_RATE(rate) (rate&0x80) +#define IS_11N_MCS_RATE(rate) (rate&0x80) typedef enum _HT_AGGRE_SIZE{ HT_AGG_SIZE_8K = 0, @@ -478,4 +478,3 @@ typedef enum _HT_IOT_ACTION{ }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; #endif //_RTL819XU_HTTYPE_H_ - diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index ebb5239..268b270 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -21,7 +21,7 @@ u16 MCS_DATA_RATE[2][2][77] = 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, - 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz + 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, // Long GI, 40MHz {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, @@ -88,7 +88,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device* ieee) ieee->bTxDisableRateFallBack = 0; ieee->bTxUseDriverAssingedRate = 0; -#ifdef TO_DO_LIST +#ifdef TO_DO_LIST // 8190 only. Assign duration operation mode to firmware pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur; #endif @@ -116,7 +116,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device* ieee) /******************************************************************************************************************** *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq) * input: u8* CapIE //Capability IE to be printed out - * u8* TitleString //mainly print out caller function + * u8* TitleString //mainly print out caller function * output: none * return: none * notice: Driver should not print out this message by default. @@ -125,7 +125,7 @@ void HTDebugHTCapability(u8* CapIE, u8* TitleString ) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily - PHT_CAPABILITY_ELE pCapELE; + PHT_CAPABILITY_ELE pCapELE; if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { @@ -153,7 +153,7 @@ void HTDebugHTCapability(u8* CapIE, u8* TitleString ) /******************************************************************************************************************** *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp) * input: u8* InfoIE //Capability IE to be printed out - * u8* TitleString //mainly print out caller function + * u8* TitleString //mainly print out caller function * output: none * return: none * notice: Driver should not print out this message by default. @@ -217,7 +217,7 @@ void HTDebugHTInfo(u8* InfoIE, u8* TitleString) } /* -* Return: true if station in half n mode and AP supports 40 bw +* Return: true if station in half n mode and AP supports 40 bw */ bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee) { @@ -228,7 +228,7 @@ bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee) retValue = false; else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw retValue = false; - else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode + else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode retValue = false; else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw retValue = true; @@ -245,7 +245,7 @@ bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz) if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode retValue = false; - else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode + else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode retValue = false; else if(is40MHz) // ap support 40 bw { @@ -265,7 +265,7 @@ bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz) return retValue; } -u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate) +u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate) { u8 is40MHz; @@ -291,8 +291,8 @@ u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate) /******************************************************************************************************************** *function: This function returns current datarate. - * input: struct ieee80211_device* ieee - * u8 nDataRate + * input: struct ieee80211_device* ieee + * u8 nDataRate * output: none * return: tx rate * notice: quite unsure about how to use this function //wb @@ -371,7 +371,7 @@ bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee) /******************************************************************************************************************** *function: This function returns peer IOT. - * input: struct ieee80211_device* ieee + * input: struct ieee80211_device* ieee * output: none * return: * notice: @@ -408,8 +408,8 @@ void HTIOTPeerDetermine(struct ieee80211_device* ieee) /******************************************************************************************************************** *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good * at receiving MCS14~15 frame from some AP. - * input: struct ieee80211_device* ieee - * u8 * PeerMacAddr + * input: struct ieee80211_device* ieee + * u8 * PeerMacAddr * output: none * return: return 1 if driver should declare MCS13 only(otherwise return 0) * *****************************************************************************************************************/ @@ -429,7 +429,7 @@ u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr) * PADAPTER Adapter, * * Output: None -* Return: true if driver should disable MCS15 +* Return: true if driver should disable MCS15 * 2008.04.15 Emily */ bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee) @@ -466,7 +466,7 @@ bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee) * PADAPTER Adapter, * * Output: None -* Return: true if driver should disable all two spatial stream packet +* Return: true if driver should disable all two spatial stream packet * 2008.04.21 Emily */ bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *PeerMacAddr) @@ -481,12 +481,12 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *Pee /******************************************************************************************************************** *function: Check whether driver should disable EDCA turbo mode - * input: struct ieee80211_device* ieee - * u8* PeerMacAddr + * input: struct ieee80211_device* ieee + * u8* PeerMacAddr * output: none * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0) * *****************************************************************************************************************/ -u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr) { u8 retValue = false; // default enable EDCA Turbo mode. // Set specific EDCA parameter for different AP in DM handler. @@ -539,10 +539,10 @@ void HTResetIOTSetting( /******************************************************************************************************************** *function: Construct Capablility Element in Beacon... if HTEnable is turned on - * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Capability Ele - * u8* len //store length of CE - * u8 IsEncrypt //whether encrypt, needed further + * input: struct ieee80211_device* ieee + * u8* posHTCap //pointer to store Capability Ele + * u8* len //store length of CE + * u8 IsEncrypt //whether encrypt, needed further * output: none * return: none * notice: posHTCap can't be null and should be initialized before. @@ -550,7 +550,7 @@ void HTResetIOTSetting( void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt) { PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo; - PHT_CAPABILITY_ELE pCapELE = NULL; + PHT_CAPABILITY_ELE pCapELE = NULL; //u8 bIsDeclareMCS13; if ((posHTCap == NULL) || (pHT == NULL)) @@ -571,7 +571,7 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u //HT capability info - pCapELE->AdvCoding = 0; // This feature is not supported now!! + pCapELE->AdvCoding = 0; // This feature is not supported now!! if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { pCapELE->ChlWidth = 0; @@ -581,18 +581,18 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); } -// pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); - pCapELE->MimoPwrSave = pHT->SelfMimoPs; +// pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); + pCapELE->MimoPwrSave = pHT->SelfMimoPs; pCapELE->GreenField = 0; // This feature is not supported now!! pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!! pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!! //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r", //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz); - pCapELE->TxSTBC = 1; - pCapELE->RxSTBC = 0; + pCapELE->TxSTBC = 1; + pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; // Do not support now!! pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; - pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); + pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); pCapELE->PSMP = 0; // Do not support now!! pCapELE->LSigTxopProtect = 0; // Do not support now!! @@ -603,13 +603,13 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u if( IsEncrypt) { - pCapELE->MPDUDensity = 7; // 8us - pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K + pCapELE->MPDUDensity = 7; // 8us + pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K } else { - pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K - pCapELE->MPDUDensity = 0; // no density + pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K + pCapELE->MPDUDensity = 0; // no density } //Supported MCS set @@ -658,10 +658,10 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u } /******************************************************************************************************************** *function: Construct Information Element in Beacon... if HTEnable is turned on - * input: struct ieee80211_device* ieee - * u8* posHTCap //pointer to store Information Ele - * u8* len //store len of - * u8 IsEncrypt //whether encrypt, needed further + * input: struct ieee80211_device* ieee + * u8* posHTCap //pointer to store Information Ele + * u8* len //store len of + * u8 IsEncrypt //whether encrypt, needed further * output: none * return: none * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this @@ -679,12 +679,12 @@ void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* le memset(posHTInfo, 0, *len); if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported { - pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: + pHTInfoEle->ControlChl = ieee->current_network.channel; + pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: (ieee->current_network.channel<=6)? HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; - pHTInfoEle->RIFS = 0; + pHTInfoEle->RIFS = 0; pHTInfoEle->PSMPAccessOnly = 0; pHTInfoEle->SrvIntGranularity = 0; pHTInfoEle->OptMode = pHT->CurrentOpMode; @@ -723,17 +723,17 @@ void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* le * Element ID Length OUI Type1 Reserved * 1 byte 1 byte 3 bytes 1 byte 1 byte * - * OUI = 0x00, 0xe0, 0x4c, - * Type = 0x02 - * Reserved = 0x00 + * OUI = 0x00, 0xe0, 0x4c, + * Type = 0x02 + * Reserved = 0x00 * * 2007.8.21 by Emily */ /******************************************************************************************************************** *function: Construct Information Element in Beacon... in RT2RT condition - * input: struct ieee80211_device* ieee - * u8* posRT2RTAgg //pointer to store Information Ele - * u8* len //store len + * input: struct ieee80211_device* ieee + * u8* posRT2RTAgg //pointer to store Information Ele + * u8* len //store len * output: none * return: none * notice: @@ -787,8 +787,8 @@ void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, /******************************************************************************************************************** *function: Pick the right Rate Adaptive table to use - * input: struct ieee80211_device* ieee - * u8* pOperateMCS //A pointer to MCS rate bitmap + * input: struct ieee80211_device* ieee + * u8* pOperateMCS //A pointer to MCS rate bitmap * return: always we return true * notice: * *****************************************************************************************************************/ @@ -840,7 +840,7 @@ u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS) * Description: * This function will get the highest speed rate in input MCS set. * -* /param Adapter Pionter to Adapter entity +* /param Adapter Pionter to Adapter entity * pMCSRateSet Pointer to MCS rate bitmap * pMCSFilter Pointer to MCS rate filter * @@ -849,9 +849,9 @@ u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS) */ /******************************************************************************************************************** *function: This function will get the highest speed rate in input MCS set. - * input: struct ieee80211_device* ieee - * u8* pMCSRateSet //Pointer to MCS rate bitmap - * u8* pMCSFilter //Pointer to MCS rate filter + * input: struct ieee80211_device* ieee + * u8* pMCSRateSet //Pointer to MCS rate bitmap + * u8* pMCSFilter //Pointer to MCS rate filter * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter * notice: * *****************************************************************************************************************/ @@ -1062,7 +1062,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) else pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; if(ieee->pairwise_key_type != KEY_TYPE_NA ) - pHTInfo->CurrentMPDUDensity = 7; // 8us + pHTInfo->CurrentMPDUDensity = 7; // 8us // Force TX AMSDU // Lanhsin: mark for tmp to avoid deauth by ap from s3 @@ -1118,7 +1118,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) void HTSetConnectBwModeCallback(struct ieee80211_device* ieee); /******************************************************************************************************************** *function: initialize HT info(struct PRT_HIGH_THROUGHPUT) - * input: struct ieee80211_device* ieee + * input: struct ieee80211_device* ieee * output: none * return: none * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP @@ -1208,13 +1208,13 @@ void HTInitializeBssDesc(PBSS_HT pBssHT) } /******************************************************************************************************************** *function: initialize Bss HT structure(struct PBSS_HT) - * input: struct ieee80211_device *ieee - * struct ieee80211_network *pNetwork //usually current network we are live in + * input: struct ieee80211_device *ieee + * struct ieee80211_network *pNetwork //usually current network we are live in * output: none * return: none * notice: This function should ONLY be called before association ********************************************************************************************************************/ -void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) +void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; // u16 nMaxAMSDUSize; @@ -1235,7 +1235,7 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80 pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; // Save HTCap and HTInfo information Element - if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) + if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) @@ -1297,7 +1297,7 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80 } -void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) +void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; // PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf; @@ -1364,8 +1364,8 @@ void HTUseDefaultSetting(struct ieee80211_device* ieee) } /******************************************************************************************************************** *function: check whether HT control field exists - * input: struct ieee80211_device *ieee - * u8* pFrame //coming skb->data + * input: struct ieee80211_device *ieee + * u8* pFrame //coming skb->data * output: none * return: return true if HT control field exists(false otherwise) * notice: diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 9e4ced1..2348ccd 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -81,8 +81,7 @@ typedef union _QOS_CTRL_FIELD{ u16 shortData; // WMM spec - struct - { + struct { u8 UP:3; u8 usRsvd1:1; u8 EOSP:1; @@ -92,8 +91,7 @@ typedef union _QOS_CTRL_FIELD{ }WMM; // 802.11e: QoS data type frame sent by non-AP QSTAs. - struct - { + struct { u8 TID:4; u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size. u8 AckPolicy:2; @@ -102,8 +100,7 @@ typedef union _QOS_CTRL_FIELD{ }BySta; // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC. - struct - { + struct { u8 TID:4; u8 EOSP:1; u8 AckPolicy:2; @@ -112,8 +109,7 @@ typedef union _QOS_CTRL_FIELD{ }ByHc_Data; // 802.11e: QoS (+) CF-Poll frames sent by HC. - struct - { + struct { u8 TID:4; u8 EOSP:1; u8 AckPolicy:2; @@ -133,14 +129,12 @@ typedef union _QOS_CTRL_FIELD{ typedef union _QOS_INFO_FIELD{ u8 charData; - struct - { + struct { u8 ucParameterSetCount:4; u8 ucReserved:4; }WMM; - struct - { + struct { //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah u8 ucAC_VO_UAPSD:1; u8 ucAC_VI_UAPSD:1; @@ -152,16 +146,14 @@ typedef union _QOS_INFO_FIELD{ }ByWmmPsSta; - struct - { + struct { //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah u8 ucParameterSetCount:4; u8 ucReserved:3; u8 ucApUapsd:1; }ByWmmPsAp; - struct - { + struct { u8 ucAC3_UAPSD:1; u8 ucAC2_UAPSD:1; u8 ucAC1_UAPSD:1; @@ -171,8 +163,7 @@ typedef union _QOS_INFO_FIELD{ u8 ucMoreDataAck:1; } By11eSta; - struct - { + struct { u8 ucParameterSetCount:4; u8 ucQAck:1; u8 ucQueueReq:1; @@ -180,16 +171,14 @@ typedef union _QOS_INFO_FIELD{ u8 ucReserved:1; } By11eAp; - struct - { + struct { u8 ucReserved1:4; u8 ucQAck:1; u8 ucReserved2:2; u8 ucMoreDataAck:1; } ByWmmsaSta; - struct - { + struct { u8 ucReserved1:4; u8 ucQAck:1; u8 ucQueueReq:1; @@ -197,8 +186,7 @@ typedef union _QOS_INFO_FIELD{ u8 ucReserved2:1; } ByWmmsaAp; - struct - { + struct { u8 ucAC3_UAPSD:1; u8 ucAC2_UAPSD:1; u8 ucAC1_UAPSD:1; @@ -208,8 +196,7 @@ typedef union _QOS_INFO_FIELD{ u8 ucMoreDataAck:1; } ByAllSta; - struct - { + struct { u8 ucParameterSetCount:4; u8 ucQAck:1; u8 ucQueueReq:1; @@ -246,8 +233,7 @@ typedef u32 AC_CODING; typedef union _ACI_AIFSN{ u8 charData; - struct - { + struct { u8 AIFSN:4; u8 ACM:1; u8 ACI:2; @@ -261,8 +247,7 @@ typedef union _ACI_AIFSN{ // typedef union _ECW{ u8 charData; - struct - { + struct { u8 ECWmin:4; u8 ECWmax:4; }f; // Field @@ -276,8 +261,7 @@ typedef union _AC_PARAM{ u32 longData; u8 charData[4]; - struct - { + struct { ACI_AIFSN AciAifsn; ECW Ecw; u16 TXOPLimit; @@ -336,8 +320,7 @@ typedef union _QOS_TSINFO{ typedef union _TSPEC_BODY{ u8 charData[55]; - struct - { + struct { QOS_TSINFO TSInfo; //u8 TSInfo[3]; u16 NominalMSDUsize; u16 MaxMSDUsize; @@ -412,14 +395,14 @@ typedef union _QOS_TCLAS{ struct _TYPE_GENERAL{ u8 Priority; - u8 ClassifierType; - u8 Mask; + u8 ClassifierType; + u8 Mask; } TYPE_GENERAL; struct _TYPE0_ETH{ u8 Priority; - u8 ClassifierType; - u8 Mask; + u8 ClassifierType; + u8 Mask; u8 SrcAddr[6]; u8 DstAddr[6]; u16 Type; @@ -427,9 +410,9 @@ typedef union _QOS_TCLAS{ struct _TYPE1_IPV4{ u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; + u8 ClassifierType; + u8 Mask; + u8 Version; u8 SrcIP[4]; u8 DstIP[4]; u16 SrcPort; @@ -441,9 +424,9 @@ typedef union _QOS_TCLAS{ struct _TYPE1_IPV6{ u8 Priority; - u8 ClassifierType; - u8 Mask; - u8 Version; + u8 ClassifierType; + u8 Mask; + u8 Version; u8 SrcIP[16]; u8 DstIP[16]; u16 SrcPort; @@ -453,8 +436,8 @@ typedef union _QOS_TCLAS{ struct _TYPE2_8021Q{ u8 Priority; - u8 ClassifierType; - u8 Mask; + u8 ClassifierType; + u8 Mask; u16 TagType; } TYPE2_8021Q; } QOS_TCLAS, *PQOS_TCLAS; @@ -481,7 +464,7 @@ typedef struct _QOS_TSTREAM{ // "Qos control field" and "Qos info field" //typedef struct _QOS_UAPSD{ // u8 bTriggerEnable[4]; -// u8 MaxSPLength; +// u8 MaxSPLength; // u8 HighestBufAC; //} QOS_UAPSD, *PQOS_APSD; @@ -489,7 +472,7 @@ typedef struct _QOS_TSTREAM{ // 802.11 Management frame Status Code field //---------------------------------------------------------------------------- typedef struct _OCTET_STRING{ - u8 *Octet; + u8 *Octet; u16 Length; }OCTET_STRING, *POCTET_STRING; @@ -512,7 +495,7 @@ typedef struct _STA_QOS{ AC_UAPSD Curr4acUapsd; u8 bInServicePeriod; u8 MaxSPLength; - int NumBcnBeforeTrigger; + int NumBcnBeforeTrigger; // Part 2. EDCA Parameter (perAC) u8 * pWMMInfoEle; @@ -523,7 +506,7 @@ typedef struct _STA_QOS{ //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element. // By Bruce, 2008-01-30. // Part 2. EDCA Parameter (perAC) - QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA + QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP AC_PARAM CurAcParameters[4]; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h index e7e26fd..7ed7243 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h @@ -28,7 +28,7 @@ typedef struct _TS_COMMON_INFO{ typedef struct _TX_TS_RECORD{ TS_COMMON_INFO TsCommonInfo; u16 TxCurSeq; - BA_RECORD TxPendingBARecord; // For BA Originator + BA_RECORD TxPendingBARecord; // For BA Originator BA_RECORD TxAdmittedBARecord; // For BA Originator // QOS_DL_RECORD DLRecord; u8 bAddBaReqInProgress; @@ -53,4 +53,3 @@ typedef struct _RX_TS_RECORD { #endif - diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 06a9824..0310d07 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -27,7 +27,7 @@ void RxPktPendingTimeout(unsigned long data) PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); - PRX_REORDER_ENTRY pReorderEntry = NULL; + PRX_REORDER_ENTRY pReorderEntry = NULL; //u32 flags = 0; unsigned long flags = 0; @@ -236,8 +236,8 @@ void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 I PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) { - //DIRECTION_VALUE dir; - u8 dir; + //DIRECTION_VALUE dir; + u8 dir; bool search_dir[4] = {0, 0, 0, 0}; struct list_head* psearch_list; //FIXME PTS_COMMON_INFO pRet = NULL; @@ -250,14 +250,14 @@ PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 } else { - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; search_dir[DIR_BI_DIR]= true; } } else if(ieee->iw_mode == IW_MODE_ADHOC) { if(TxRxSelect == TX_DIR) - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; else search_dir[DIR_DOWN] = true; } @@ -265,7 +265,7 @@ PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 { if(TxRxSelect == TX_DIR) { - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; search_dir[DIR_BI_DIR]= true; search_dir[DIR_DIRECT]= true; } @@ -450,8 +450,8 @@ bool GetTs( pTSInfo->field.ucTSID = UP; // TSID pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. pTSInfo->field.ucAccessPolicy = 1; // Access policy - pTSInfo->field.ucAggregation = 0; // Aggregation - pTSInfo->field.ucPSB = 0; // Aggregation + pTSInfo->field.ucAggregation = 0; // Aggregation + pTSInfo->field.ucPSB = 0; // Aggregation pTSInfo->field.ucUP = UP; // User priority pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy pTSInfo->field.ucSchedule = 0; // Schedule @@ -488,7 +488,7 @@ void RemoveTsEntry( { //#ifdef TO_DO_LIST PRX_REORDER_ENTRY pRxReorderEntry; - PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; + PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; if(timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h b/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h index ccf6ae7..c3c8710 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h +++ b/drivers/staging/rtl8192u/ieee80211/rtl_crypto.h @@ -52,10 +52,10 @@ #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 -#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 -#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 -#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000 -#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000 +#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 +#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 +#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000 +#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000 /* * Miscellaneous stuff. @@ -73,7 +73,7 @@ struct cipher_alg { unsigned int cia_min_keysize; unsigned int cia_max_keysize; int (*cia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); }; @@ -84,16 +84,16 @@ struct digest_alg { void (*dia_update)(void *ctx, const u8 *data, unsigned int len); void (*dia_final)(void *ctx, u8 *out); int (*dia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); }; struct compress_alg { int (*coa_init)(void *ctx); void (*coa_exit)(void *ctx); int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); }; #define cra_cipher cra_u.cipher @@ -139,15 +139,15 @@ struct cipher_tfm { unsigned int cit_ivsize; u32 cit_mode; int (*cit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); int (*cit_encrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes); int (*cit_encrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv); int (*cit_decrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, @@ -162,12 +162,12 @@ struct cipher_tfm { struct digest_tfm { void (*dit_init)(struct crypto_tfm *tfm); void (*dit_update)(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); + struct scatterlist *sg, unsigned int nsg); void (*dit_final)(struct crypto_tfm *tfm, u8 *out); void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, - unsigned int nsg, u8 *out); + unsigned int nsg, u8 *out); int (*dit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); #ifdef CONFIG_CRYPTO_HMAC void *dit_hmac_block; #endif @@ -175,11 +175,11 @@ struct digest_tfm { struct compress_tfm { int (*cot_compress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); int (*cot_decompress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); }; #define crt_cipher crt_u.cipher @@ -277,8 +277,8 @@ static inline void crypto_digest_init(struct crypto_tfm *tfm) } static inline void crypto_digest_update(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg) + struct scatterlist *sg, + unsigned int nsg) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_update(tfm, sg, nsg); @@ -291,15 +291,15 @@ static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out) } static inline void crypto_digest_digest(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg, u8 *out) + struct scatterlist *sg, + unsigned int nsg, u8 *out) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_digest(tfm, sg, nsg, out); } static inline int crypto_digest_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); if (tfm->crt_digest.dit_setkey == NULL) @@ -308,25 +308,25 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm, } static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_setkey(tfm, key, keylen); } static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -334,18 +334,18 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, } static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -353,30 +353,30 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, } static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, - const u8 *src, unsigned int len) + const u8 *src, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(tfm->crt_cipher.cit_iv, src, len); } static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, - u8 *dst, unsigned int len) + u8 *dst, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(dst, tfm->crt_cipher.cit_iv, len); } static inline int crypto_comp_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen); } static inline int crypto_comp_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); @@ -388,12 +388,11 @@ static inline int crypto_comp_decompress(struct crypto_tfm *tfm, #ifdef CONFIG_CRYPTO_HMAC void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen); void crypto_hmac_update(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); + struct scatterlist *sg, unsigned int nsg); void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key, - unsigned int *keylen, u8 *out); + unsigned int *keylen, u8 *out); void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen, - struct scatterlist *sg, unsigned int nsg, u8 *out); + struct scatterlist *sg, unsigned int nsg, u8 *out); #endif /* CONFIG_CRYPTO_HMAC */ #endif /* _LINUX_CRYPTO_H */ - diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index 3c515b7..7e49ad8 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c @@ -95,7 +95,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) u32 ret; ret=0; - //enable EPROM programming + //enable EPROM programming write_nic_byte_E(dev, EPROM_CMD, (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT)); force_pci_posting(dev); diff --git a/drivers/staging/rtl8192u/r8180_pm.h b/drivers/staging/rtl8192u/r8180_pm.h index c7d18a8..52d6fba 100644 --- a/drivers/staging/rtl8192u/r8180_pm.h +++ b/drivers/staging/rtl8192u/r8180_pm.h @@ -1,5 +1,5 @@ /* - Power management interface routines. + Power management interface routines. Written by Mariusz Matuszek. This code is currently just a placeholder for later work and does not do anything useful. diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index 74ff337..cf9713f 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -16,9 +16,9 @@ #include "r8190_rtl8256.h" /*-------------------------------------------------------------------------- - * Overview: set RF band width (20M or 40M) + * Overview: set RF band width (20M or 40M) * Input: struct net_device* dev - * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M + * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M * Output: NONE * Return: NONE * Note: 8226 support both 20M and 40 MHz @@ -106,16 +106,16 @@ void PHY_RF8256_Config(struct net_device* dev) *---------------------------------------------------------------------------*/ void phy_RF8256_Config_ParaFile(struct net_device* dev) { - u32 u4RegValue = 0; + u32 u4RegValue = 0; //static s1Byte szRadioAFile[] = RTL819X_PHY_RADIO_A; //static s1Byte szRadioBFile[] = RTL819X_PHY_RADIO_B; //static s1Byte szRadioCFile[] = RTL819X_PHY_RADIO_C; //static s1Byte szRadioDFile[] = RTL819X_PHY_RADIO_D; - u8 eRFPath; + u8 eRFPath; BB_REGISTER_DEFINITION_T *pPhyReg; struct r8192_priv *priv = ieee80211_priv(dev); u32 RegOffSetToBeCheck = 0x3; - u32 RegValueToBeCheck = 0x7f1; + u32 RegValueToBeCheck = 0x7f1; u32 RF3_Final_Value = 0; u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; @@ -152,7 +152,7 @@ void phy_RF8256_Config_ParaFile(struct net_device* dev) rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); /* Set bit number of Address and Data for RF register */ - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258 + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258 rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ??? rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf); @@ -309,4 +309,3 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) return; } - diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 57e3383..e538e02 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -110,7 +110,7 @@ do { if(rt_global_debug_component & component) \ #define COMP_RATE BIT12 // For Rate Adaptive mechanism, 2006.07.02, by rcnjko. #define COMP_RM BIT13 // For Radio Measurement. #define COMP_DIG BIT14 // For DIG, 2006.09.25, by rcnjko. -#define COMP_PHY BIT15 +#define COMP_PHY BIT15 #define COMP_CH BIT16 //channel setting debug #define COMP_TXAGC BIT17 // For Tx power, 060928, by rcnjko. #define COMP_HIPWR BIT18 // For High Power Mechanism, 060928, by rcnjko. @@ -136,26 +136,26 @@ do { if(rt_global_debug_component & component) \ #define RTL819x_DEBUG #ifdef RTL819x_DEBUG #define assert(expr) \ - if (!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n", \ - #expr,__FILE__,__FUNCTION__,__LINE__); \ - } + if (!(expr)) { \ + printk( "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr,__FILE__,__FUNCTION__,__LINE__); \ + } //wb added to debug out data buf //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA #define RT_DEBUG_DATA(level, data, datalen) \ - do{ if ((rt_global_debug_component & (level)) == (level)) \ - { \ - int i; \ - u8* pdata = (u8*) data; \ - printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__); \ - for(i=0; i<(int)(datalen); i++) \ - { \ - printk("%2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) + do{ if ((rt_global_debug_component & (level)) == (level)) \ + { \ + int i; \ + u8* pdata = (u8*) data; \ + printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__); \ + for(i=0; i<(int)(datalen); i++) \ + { \ + printk("%2x ", pdata[i]); \ + if ((i+1)%16 == 0) printk("\n"); \ + } \ + printk("\n"); \ + } \ + } while (0) #else #define assert(expr) do {} while (0) #define RT_DEBUG_DATA(level, data, datalen) do {} while(0) @@ -209,47 +209,47 @@ do { if(rt_global_debug_component & component) \ #define IEEE80211_WATCH_DOG_TIME 2000 #define PHY_Beacon_RSSI_SLID_WIN_MAX 10 //for txpowertracking by amy -#define OFDM_Table_Length 19 +#define OFDM_Table_Length 19 #define CCK_Table_length 12 /* for rtl819x */ typedef struct _tx_desc_819x_usb { - //DWORD 0 - u16 PktSize; - u8 Offset; - u8 Reserved0:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; - - //DWORD 1 - u8 TxFWInfoSize; - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Reserved1:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; - - //DWORD 2 - u16 TxBufferSize; - //u16 Reserved2; - u8 ResvForPaddingLen:7; - u8 Reserved3:1; - u8 Reserved4; - - //DWORD 3, 4, 5 - u32 Reserved5; - u32 Reserved6; - u32 Reserved7; + //DWORD 0 + u16 PktSize; + u8 Offset; + u8 Reserved0:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; + + //DWORD 1 + u8 TxFWInfoSize; + u8 RATid:3; + u8 DISFB:1; + u8 USERATE:1; + u8 MOREFRAG:1; + u8 NoEnc:1; + u8 PIFS:1; + u8 QueueSelect:5; + u8 NoACM:1; + u8 Reserved1:2; + u8 SecCAMID:5; + u8 SecDescAssign:1; + u8 SecType:2; + + //DWORD 2 + u16 TxBufferSize; + //u16 Reserved2; + u8 ResvForPaddingLen:7; + u8 Reserved3:1; + u8 Reserved4; + + //DWORD 3, 4, 5 + u32 Reserved5; + u32 Reserved6; + u32 Reserved7; }tx_desc_819x_usb, *ptx_desc_819x_usb; #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE @@ -280,7 +280,7 @@ typedef struct _tx_desc_819x_usb_aggr_subframe { typedef struct _tx_desc_cmd_819x_usb { - //DWORD 0 + //DWORD 0 u16 Reserved0; u8 Reserved1; u8 Reserved2:3; @@ -290,15 +290,15 @@ typedef struct _tx_desc_cmd_819x_usb { u8 LINIP:1; u8 OWN:1; - //DOWRD 1 + //DOWRD 1 //u32 Reserved3; u8 TxFWInfoSize; u8 Reserved3; u8 QueueSelect; u8 Reserved4; - //DOWRD 2 - u16 TxBufferSize; + //DOWRD 2 + u16 TxBufferSize; u16 Reserved5; //DWORD 3,4,5 @@ -311,34 +311,34 @@ typedef struct _tx_desc_cmd_819x_usb { typedef struct _tx_fwinfo_819x_usb { - //DOWRD 0 - u8 TxRate:7; - u8 CtsEnable:1; - u8 RtsRate:7; - u8 RtsEnable:1; - u8 TxHT:1; - u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 TxBandwidth:1; // This is used for HT MCS rate only. - u8 TxSubCarrier:2; // This is used for legacy OFDM rate only. - u8 STBC:2; - u8 AllowAggregation:1; - u8 RtsHT:1; //Interpret RtsRate field as high throughput data rate - u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS - u8 RtsBandwidth:1; // This is used for HT MCS rate only. - u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only. - u8 RtsSTBC:2; - u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration - - //DWORD 1 - u32 RxMF:2; - u32 RxAMD:3; - u32 TxPerPktInfoFeedback:1;//1 indicate Tx info gathtered by firmware and returned by Rx Cmd - u32 Reserved1:2; - u32 TxAGCOffSet:4; - u32 TxAGCSign:1; - u32 Tx_INFO_RSVD:6; + //DOWRD 0 + u8 TxRate:7; + u8 CtsEnable:1; + u8 RtsRate:7; + u8 RtsEnable:1; + u8 TxHT:1; + u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS + u8 TxBandwidth:1; // This is used for HT MCS rate only. + u8 TxSubCarrier:2; // This is used for legacy OFDM rate only. + u8 STBC:2; + u8 AllowAggregation:1; + u8 RtsHT:1; //Interpret RtsRate field as high throughput data rate + u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS + u8 RtsBandwidth:1; // This is used for HT MCS rate only. + u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only. + u8 RtsSTBC:2; + u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration + + //DWORD 1 + u32 RxMF:2; + u32 RxAMD:3; + u32 TxPerPktInfoFeedback:1;//1 indicate Tx info gathtered by firmware and returned by Rx Cmd + u32 Reserved1:2; + u32 TxAGCOffSet:4; + u32 TxAGCSign:1; + u32 Tx_INFO_RSVD:6; u32 PacketID:13; - //u32 Reserved; + //u32 Reserved; }tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb; typedef struct rtl8192_rx_info { @@ -391,7 +391,7 @@ typedef struct _rx_desc_819x_usb_aggr_subframe{ //DWORD 2 //u4Byte Reserved3; //DWORD 3 - //u4Byte BufferAddress; + //u4Byte BufferAddress; }rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe; #endif @@ -424,7 +424,7 @@ typedef struct rx_drvinfo_819x_usb{ #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 #define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb) -#define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb)) +#define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb)) #define MAX_FRAGMENT_COUNT 8 #ifdef RTL8192U #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE @@ -433,7 +433,7 @@ typedef struct rx_drvinfo_819x_usb{ #define MAX_TRANSMIT_BUFFER_SIZE 8000 #endif #else -#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) +#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) #endif #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE #define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb)) @@ -559,22 +559,21 @@ typedef enum _WIRELESS_MODE { #define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 -typedef struct buffer -{ +typedef struct buffer { struct buffer *next; u32 *buf; } buffer; typedef struct rtl_reg_debug{ - unsigned int cmd; - struct { - unsigned char type; - unsigned char addr; - unsigned char page; - unsigned char length; - } head; - unsigned char buf[0xff]; + unsigned int cmd; + struct { + unsigned char type; + unsigned char addr; + unsigned char page; + unsigned char length; + } head; + unsigned char buf[0xff]; }rtl_reg_debug; @@ -600,8 +599,7 @@ typedef struct _RT_SMOOTH_DATA_4RF { #define MAX_8192U_RX_SIZE 8192 // This maybe changed for D-cut larger aggregation size //stats seems messed up, clean it ASAP -typedef struct Stats -{ +typedef struct Stats { unsigned long txrdu; // unsigned long rxrdu; //unsigned long rxnolast; @@ -711,7 +709,7 @@ typedef struct Stats //+by amy 080507 -typedef struct ChnlAccessSetting { +typedef struct ChnlAccessSetting { u16 SIFS_Timer; u16 DIFS_Timer; u16 SlotTimeTimer; @@ -721,35 +719,34 @@ typedef struct ChnlAccessSetting { }*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING; typedef struct _BB_REGISTER_DEFINITION{ - u32 rfintfs; // set software control: // 0x870~0x877[8 bytes] - u32 rfintfi; // readback data: // 0x8e0~0x8e7[8 bytes] - u32 rfintfo; // output data: // 0x860~0x86f [16 bytes] - u32 rfintfe; // output enable: // 0x860~0x86f [16 bytes] - u32 rf3wireOffset; // LSSI data: // 0x840~0x84f [16 bytes] - u32 rfLSSI_Select; // BB Band Select: // 0x878~0x87f [8 bytes] + u32 rfintfs; // set software control: // 0x870~0x877[8 bytes] + u32 rfintfi; // readback data: // 0x8e0~0x8e7[8 bytes] + u32 rfintfo; // output data: // 0x860~0x86f [16 bytes] + u32 rfintfe; // output enable: // 0x860~0x86f [16 bytes] + u32 rf3wireOffset; // LSSI data: // 0x840~0x84f [16 bytes] + u32 rfLSSI_Select; // BB Band Select: // 0x878~0x87f [8 bytes] u32 rfTxGainStage; // Tx gain stage: // 0x80c~0x80f [4 bytes] - u32 rfHSSIPara1; // wire parameter control1 : // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes] - u32 rfHSSIPara2; // wire parameter control2 : // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes] - u32 rfSwitchControl; //Tx Rx antenna control : // 0x858~0x85f [16 bytes] - u32 rfAGCControl1; //AGC parameter control1 : // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes] - u32 rfAGCControl2; //AGC parameter control2 : // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes] - u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix : // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes] - u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes] - u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes] - u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes] - u32 rfLSSIReadBack; //LSSI RF readback data // 0x8a0~0x8af [16 bytes] + u32 rfHSSIPara1; // wire parameter control1 : // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes] + u32 rfHSSIPara2; // wire parameter control2 : // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes] + u32 rfSwitchControl; //Tx Rx antenna control : // 0x858~0x85f [16 bytes] + u32 rfAGCControl1; //AGC parameter control1 : // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes] + u32 rfAGCControl2; //AGC parameter control2 : // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes] + u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix : // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes] + u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes] + u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes] + u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes] + u32 rfLSSIReadBack; //LSSI RF readback data // 0x8a0~0x8af [16 bytes] }BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T; typedef enum _RT_RF_TYPE_819xU{ - RF_TYPE_MIN = 0, - RF_8225, - RF_8256, - RF_8258, - RF_PSEUDO_11N = 4, + RF_TYPE_MIN = 0, + RF_8225, + RF_8256, + RF_8258, + RF_PSEUDO_11N = 4, }RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU; -typedef struct _rate_adaptive -{ +typedef struct _rate_adaptive { u8 rate_adaptive_disabled; u8 ratr_state; u16 reserve; @@ -775,21 +772,18 @@ typedef struct _rate_adaptive #define TxBBGainTableLength 37 #define CCKTxBBGainTableLength 23 -typedef struct _txbbgain_struct -{ +typedef struct _txbbgain_struct { long txbb_iq_amplifygain; u32 txbbgain_value; } txbbgain_struct, *ptxbbgain_struct; -typedef struct _ccktxbbgain_struct -{ +typedef struct _ccktxbbgain_struct { //The Value is from a22 to a29 one Byte one time is much Safer u8 ccktxbb_valuearray[8]; } ccktxbbgain_struct,*pccktxbbgain_struct; -typedef struct _init_gain -{ +typedef struct _init_gain { u8 xaagccore1; u8 xbagccore1; u8 xcagccore1; @@ -799,8 +793,7 @@ typedef struct _init_gain } init_gain, *pinit_gain; //by amy 0606 -typedef struct _phy_ofdm_rx_status_report_819xusb -{ +typedef struct _phy_ofdm_rx_status_report_819xusb { u8 trsw_gain_X[4]; u8 pwdb_all; u8 cfosho_X[4]; @@ -816,8 +809,7 @@ typedef struct _phy_ofdm_rx_status_report_819xusb u8 rxsc_sgien_exflg; }phy_sts_ofdm_819xusb_t; -typedef struct _phy_cck_rx_status_report_819xusb -{ +typedef struct _phy_cck_rx_status_report_819xusb { /* For CCK rate descriptor. This is a unsigned 8:1 variable. LSB bit presend 0.5. And MSB 7 bts presend a signed value. Range from -64~+63.5. */ u8 adc_pwdb_X[4]; @@ -881,8 +873,7 @@ typedef enum _tag_TxCmd_Config_Index{ TXCMD_XXXX_CTRL, }DCMD_TXCMD_OP; -typedef struct r8192_priv -{ +typedef struct r8192_priv { struct usb_device *udev; //added for maintain info from eeprom short epromtype; @@ -907,7 +898,7 @@ typedef struct r8192_priv spinlock_t irq_lock; // spinlock_t irq_th_lock; spinlock_t tx_lock; - struct mutex mutex; + struct mutex mutex; //spinlock_t rf_lock; //used to lock rf write operation added by wb u16 irq_mask; @@ -970,8 +961,8 @@ typedef struct r8192_priv atomic_t irt_counter;//count for irq_rx_tasklet #endif #ifdef JACKSON_NEW_RX - struct sk_buff **pp_rxskb; - int rx_inx; + struct sk_buff **pp_rxskb; + int rx_inx; #endif /* modified by davad for Rx process */ @@ -1006,7 +997,7 @@ typedef struct r8192_priv u8 retry_rts; u16 rts; - struct ChnlAccessSetting ChannelAccessSetting; + struct ChnlAccessSetting ChannelAccessSetting; struct work_struct reset_wq; /**********************************************************/ @@ -1014,7 +1005,7 @@ typedef struct r8192_priv u16 basic_rate; u8 short_preamble; u8 slot_time; - bool bDcut; + bool bDcut; bool bCurrentRxAggrEnable; u8 Rf_Mode; //add for Firmware RF -R/W switch prt_firmware pFirmware; @@ -1050,7 +1041,7 @@ typedef struct r8192_priv //for set channel u8 SwChnlInProgress; - u8 SwChnlStage; + u8 SwChnlStage; u8 SwChnlStep; u8 SetBWModeInProgress; HT_CHANNEL_WIDTH CurrentChannelBW; @@ -1062,8 +1053,8 @@ typedef struct r8192_priv // We save RF reg0 in this variable to reduce RF reading. // u32 RfReg0Value[4]; - u8 NumTotalRFPath; - bool brfpath_rxenable[4]; + u8 NumTotalRFPath; + bool brfpath_rxenable[4]; //RF set related bool SetRFPowerStateInProgress; //+by amy 080507 @@ -1104,7 +1095,7 @@ typedef struct r8192_priv bool btxpower_tracking; bool bcck_in_ch14; bool btxpowerdata_readfromEEPORM; - u16 TSSI_13dBm; + u16 TSSI_13dBm; //For Backup Initial Gain init_gain initgain_backup; u8 DefaultInitialGain[4]; @@ -1114,17 +1105,17 @@ typedef struct r8192_priv bool bis_cur_rdlstate; struct timer_list fsync_timer; bool bfsync_processing; // 500ms Fsync timer is active or not - u32 rate_record; - u32 rateCountDiffRecord; + u32 rate_record; + u32 rateCountDiffRecord; u32 ContinueDiffCount; bool bswitch_fsync; u8 framesync; - u32 framesyncC34; - u8 framesyncMonitor; - //Added by amy 080516 for RX related - u16 nrxAMPDU_size; - u8 nrxAMPDU_aggr_num; + u32 framesyncC34; + u8 framesyncMonitor; + //Added by amy 080516 for RX related + u16 nrxAMPDU_size; + u8 nrxAMPDU_aggr_num; //by amy for gpio bool bHwRadioOff; @@ -1204,7 +1195,7 @@ typedef enum{ #ifdef JOHN_HWSEC struct ssid_thread { struct net_device *dev; - u8 name[IW_ESSID_MAX_SIZE + 1]; + u8 name[IW_ESSID_MAX_SIZE + 1]; }; #endif diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 56367f2..f7de2f6 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -80,9 +80,9 @@ double __extendsfdf2(float a) {return a;} #include "dot11d.h" //set here to open your trace code. //WB u32 rt_global_debug_component = \ - // COMP_INIT | + // COMP_INIT | // COMP_DBG | - // COMP_EPROM | + // COMP_EPROM | // COMP_PHY | // COMP_RF | // COMP_FIRMWARE | @@ -159,23 +159,22 @@ static struct usb_driver rtl8192_usb_driver = { .resume = rtl8192_resume, /* PM resume fn */ #else .suspend = NULL, /* PM suspend fn */ - .resume = NULL, /* PM resume fn */ + .resume = NULL, /* PM resume fn */ #endif }; -typedef struct _CHANNEL_LIST -{ +typedef struct _CHANNEL_LIST { u8 Channel[32]; u8 Len; }CHANNEL_LIST, *PCHANNEL_LIST; static CHANNEL_LIST ChannelPlan[] = { - {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC - {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC - {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI + {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC + {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC + {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI. - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. + {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI. {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel. @@ -190,57 +189,51 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) struct ieee80211_device* ieee = priv->ieee80211; switch (channel_plan) { - case COUNTRY_CODE_FCC: - case COUNTRY_CODE_IC: - case COUNTRY_CODE_ETSI: - case COUNTRY_CODE_SPAIN: - case COUNTRY_CODE_FRANCE: - case COUNTRY_CODE_MKK: - case COUNTRY_CODE_MKK1: - case COUNTRY_CODE_ISRAEL: - case COUNTRY_CODE_TELEC: - case COUNTRY_CODE_MIC: - { - Dot11d_Init(ieee); - ieee->bGlobalDomain = false; - //actually 8225 & 8256 rf chips only support B,G,24N mode - if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256)) - { - min_chan = 1; - max_chan = 14; - } - else - { - RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__); - } - if (ChannelPlan[channel_plan].Len != 0){ - // Clear old channel map - memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); - // Set new channel map - for (i=0;i<ChannelPlan[channel_plan].Len;i++) - { - if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan) + case COUNTRY_CODE_FCC: + case COUNTRY_CODE_IC: + case COUNTRY_CODE_ETSI: + case COUNTRY_CODE_SPAIN: + case COUNTRY_CODE_FRANCE: + case COUNTRY_CODE_MKK: + case COUNTRY_CODE_MKK1: + case COUNTRY_CODE_ISRAEL: + case COUNTRY_CODE_TELEC: + case COUNTRY_CODE_MIC: + Dot11d_Init(ieee); + ieee->bGlobalDomain = false; + //actually 8225 & 8256 rf chips only support B,G,24N mode + if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256)) { + min_chan = 1; + max_chan = 14; + } + else { + RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__); + } + if (ChannelPlan[channel_plan].Len != 0) { + // Clear old channel map + memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); + // Set new channel map + for (i=0;i<ChannelPlan[channel_plan].Len;i++) { + if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan) break; - GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; - } + GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; } - break; } - case COUNTRY_CODE_GLOBAL_DOMAIN: - { - GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings. - Dot11d_Reset(ieee); - ieee->bGlobalDomain = true; - break; - } - default: - break; + break; + + case COUNTRY_CODE_GLOBAL_DOMAIN: + GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings. + Dot11d_Reset(ieee); + ieee->bGlobalDomain = true; + break; + + default: + break; } - return; } -#define rx_hal_is_cck_rate(_pdrvinfo)\ +#define rx_hal_is_cck_rate(_pdrvinfo)\ (_pdrvinfo->RxRate == DESC90_RATE1M ||\ _pdrvinfo->RxRate == DESC90_RATE2M ||\ _pdrvinfo->RxRate == DESC90_RATE5_5M ||\ @@ -516,55 +509,50 @@ static int proc_get_registers(char *page, char **start, int max=0xff; /* This dump the current register page */ -len += snprintf(page + len, count - len, + len += snprintf(page + len, count - len, "\n####################page 0##################\n "); - for(n=0;n<=max;) - { + for (n=0;n<=max;) { //printk( "\nD: %2x> ", n); len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x000|n)); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(dev,0x000|n)); // printk("%2x ",read_nic_byte(dev,n)); } -len += snprintf(page + len, count - len, + len += snprintf(page + len, count - len, "\n####################page 1##################\n "); - for(n=0;n<=max;) - { + for (n=0;n<=max;) { //printk( "\nD: %2x> ", n); len += snprintf(page + len, count - len, - "\nD: %2x > ",n); + "\nD: %2x > ",n); - for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x100|n)); + for (i=0;i<16 && n<=max;i++,n++) + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(dev,0x100|n)); // printk("%2x ",read_nic_byte(dev,n)); } -len += snprintf(page + len, count - len, + len += snprintf(page + len, count - len, "\n####################page 3##################\n "); - for(n=0;n<=max;) - { + for (n=0;n<=max;) { //printk( "\nD: %2x> ", n); len += snprintf(page + len, count - len, "\nD: %2x > ",n); for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x300|n)); + len += snprintf(page + len, count - len, + "%2x ",read_nic_byte(dev,0x300|n)); // printk("%2x ",read_nic_byte(dev,n)); } - len += snprintf(page + len, count - len,"\n"); *eof = 1; return len; - } @@ -1272,8 +1260,8 @@ struct sk_buff *DrvAggr_Aggregation(struct net_device *dev, struct ieee80211_drv { struct ieee80211_device *ieee = netdev_priv(dev); struct r8192_priv *priv = ieee80211_priv(dev); - cb_desc *tcb_desc = NULL; - u8 i; + cb_desc *tcb_desc = NULL; + u8 i; u32 TotalLength; struct sk_buff *skb; struct sk_buff *agg_skb; @@ -1444,7 +1432,7 @@ u8 DrvAggr_GetAggregatibleList(struct net_device *dev, struct sk_buff *skb, struct ieee80211_device *ieee = netdev_priv(dev); PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; u16 nMaxAggrNum = pHTInfo->UsbTxAggrNum; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 QueueID = tcb_desc->queue_index; do { @@ -1812,7 +1800,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) int status; struct urb *tx_urb; //int urb_buf_len; - unsigned int idx_pipe; + unsigned int idx_pipe; tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; @@ -1876,43 +1864,43 @@ u8 MapHwQueueToFirmwareQueue(u8 QueueID) u8 QueueSelect = 0x0; //defualt set to switch(QueueID) { - case BE_QUEUE: - QueueSelect = QSLT_BE; //or QSelect = pTcb->priority; - break; + case BE_QUEUE: + QueueSelect = QSLT_BE; //or QSelect = pTcb->priority; + break; - case BK_QUEUE: - QueueSelect = QSLT_BK; //or QSelect = pTcb->priority; - break; + case BK_QUEUE: + QueueSelect = QSLT_BK; //or QSelect = pTcb->priority; + break; - case VO_QUEUE: - QueueSelect = QSLT_VO; //or QSelect = pTcb->priority; - break; + case VO_QUEUE: + QueueSelect = QSLT_VO; //or QSelect = pTcb->priority; + break; - case VI_QUEUE: - QueueSelect = QSLT_VI; //or QSelect = pTcb->priority; - break; - case MGNT_QUEUE: - QueueSelect = QSLT_MGNT; - break; + case VI_QUEUE: + QueueSelect = QSLT_VI; //or QSelect = pTcb->priority; + break; + case MGNT_QUEUE: + QueueSelect = QSLT_MGNT; + break; - case BEACON_QUEUE: - QueueSelect = QSLT_BEACON; - break; + case BEACON_QUEUE: + QueueSelect = QSLT_BEACON; + break; - // TODO: 2006.10.30 mark other queue selection until we verify it is OK - // TODO: Remove Assertions + // TODO: 2006.10.30 mark other queue selection until we verify it is OK + // TODO: Remove Assertions //#if (RTL819X_FPGA_VER & RTL819X_FPGA_GUANGAN_070502) - case TXCMD_QUEUE: - QueueSelect = QSLT_CMD; - break; + case TXCMD_QUEUE: + QueueSelect = QSLT_CMD; + break; //#endif - case HIGH_QUEUE: - QueueSelect = QSLT_HIGH; - break; + case HIGH_QUEUE: + QueueSelect = QSLT_HIGH; + break; - default: - RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID); - break; + default: + RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID); + break; } return QueueSelect; } @@ -1922,39 +1910,39 @@ u8 MRateToHwRate8190Pci(u8 rate) u8 ret = DESC90_RATE1M; switch(rate) { - case MGN_1M: ret = DESC90_RATE1M; break; - case MGN_2M: ret = DESC90_RATE2M; break; - case MGN_5_5M: ret = DESC90_RATE5_5M; break; - case MGN_11M: ret = DESC90_RATE11M; break; - case MGN_6M: ret = DESC90_RATE6M; break; - case MGN_9M: ret = DESC90_RATE9M; break; - case MGN_12M: ret = DESC90_RATE12M; break; - case MGN_18M: ret = DESC90_RATE18M; break; - case MGN_24M: ret = DESC90_RATE24M; break; - case MGN_36M: ret = DESC90_RATE36M; break; - case MGN_48M: ret = DESC90_RATE48M; break; - case MGN_54M: ret = DESC90_RATE54M; break; - - // HT rate since here - case MGN_MCS0: ret = DESC90_RATEMCS0; break; - case MGN_MCS1: ret = DESC90_RATEMCS1; break; - case MGN_MCS2: ret = DESC90_RATEMCS2; break; - case MGN_MCS3: ret = DESC90_RATEMCS3; break; - case MGN_MCS4: ret = DESC90_RATEMCS4; break; - case MGN_MCS5: ret = DESC90_RATEMCS5; break; - case MGN_MCS6: ret = DESC90_RATEMCS6; break; - case MGN_MCS7: ret = DESC90_RATEMCS7; break; - case MGN_MCS8: ret = DESC90_RATEMCS8; break; - case MGN_MCS9: ret = DESC90_RATEMCS9; break; - case MGN_MCS10: ret = DESC90_RATEMCS10; break; - case MGN_MCS11: ret = DESC90_RATEMCS11; break; - case MGN_MCS12: ret = DESC90_RATEMCS12; break; - case MGN_MCS13: ret = DESC90_RATEMCS13; break; - case MGN_MCS14: ret = DESC90_RATEMCS14; break; - case MGN_MCS15: ret = DESC90_RATEMCS15; break; - case (0x80|0x20): ret = DESC90_RATEMCS32; break; - - default: break; + case MGN_1M: ret = DESC90_RATE1M; break; + case MGN_2M: ret = DESC90_RATE2M; break; + case MGN_5_5M: ret = DESC90_RATE5_5M; break; + case MGN_11M: ret = DESC90_RATE11M; break; + case MGN_6M: ret = DESC90_RATE6M; break; + case MGN_9M: ret = DESC90_RATE9M; break; + case MGN_12M: ret = DESC90_RATE12M; break; + case MGN_18M: ret = DESC90_RATE18M; break; + case MGN_24M: ret = DESC90_RATE24M; break; + case MGN_36M: ret = DESC90_RATE36M; break; + case MGN_48M: ret = DESC90_RATE48M; break; + case MGN_54M: ret = DESC90_RATE54M; break; + + // HT rate since here + case MGN_MCS0: ret = DESC90_RATEMCS0; break; + case MGN_MCS1: ret = DESC90_RATEMCS1; break; + case MGN_MCS2: ret = DESC90_RATEMCS2; break; + case MGN_MCS3: ret = DESC90_RATEMCS3; break; + case MGN_MCS4: ret = DESC90_RATEMCS4; break; + case MGN_MCS5: ret = DESC90_RATEMCS5; break; + case MGN_MCS6: ret = DESC90_RATEMCS6; break; + case MGN_MCS7: ret = DESC90_RATEMCS7; break; + case MGN_MCS8: ret = DESC90_RATEMCS8; break; + case MGN_MCS9: ret = DESC90_RATEMCS9; break; + case MGN_MCS10: ret = DESC90_RATEMCS10; break; + case MGN_MCS11: ret = DESC90_RATEMCS11; break; + case MGN_MCS12: ret = DESC90_RATEMCS12; break; + case MGN_MCS13: ret = DESC90_RATEMCS13; break; + case MGN_MCS14: ret = DESC90_RATEMCS14; break; + case MGN_MCS15: ret = DESC90_RATEMCS15; break; + case (0x80|0x20): ret = DESC90_RATEMCS32; break; + + default: break; } return ret; } @@ -2182,7 +2170,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) dev->trans_start = jiffies; atomic_inc(&priv->tx_pending[tcb_desc->queue_index]); return 0; - }else{ + } else { RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); return -1; @@ -2320,33 +2308,33 @@ void rtl8192_link_change(struct net_device *dev) // RT_TRACE(COMP_CH, "========>%s(), chan:%d\n", __FUNCTION__, priv->chan); // rtl8192_set_chan(dev, priv->chan); if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { - u32 reg = 0; - reg = read_nic_dword(dev, RCR); - if (priv->ieee80211->state == IEEE80211_LINKED) - priv->ReceiveConfig = reg |= RCR_CBSSID; - else - priv->ReceiveConfig = reg &= ~RCR_CBSSID; - write_nic_dword(dev, RCR, reg); - } + { + u32 reg = 0; + reg = read_nic_dword(dev, RCR); + if (priv->ieee80211->state == IEEE80211_LINKED) + priv->ReceiveConfig = reg |= RCR_CBSSID; + else + priv->ReceiveConfig = reg &= ~RCR_CBSSID; + write_nic_dword(dev, RCR, reg); + } // rtl8192_set_rxconf(dev); } static struct ieee80211_qos_parameters def_qos_parameters = { - {3,3,3,3},/* cw_min */ - {7,7,7,7},/* cw_max */ - {2,2,2,2},/* aifs */ - {0,0,0,0},/* flags */ - {0,0,0,0} /* tx_op_limit */ + {3,3,3,3},/* cw_min */ + {7,7,7,7},/* cw_max */ + {2,2,2,2},/* aifs */ + {0,0,0,0},/* flags */ + {0,0,0,0} /* tx_op_limit */ }; void rtl8192_update_beacon(struct work_struct * work) { - struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); - struct net_device *dev = priv->ieee80211->dev; - struct ieee80211_device* ieee = priv->ieee80211; + struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); + struct net_device *dev = priv->ieee80211->dev; + struct ieee80211_device* ieee = priv->ieee80211; struct ieee80211_network* net = &ieee->current_network; if (ieee->pHTInfo->bCurrentHTSupport) @@ -2717,7 +2705,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->bDisableNormalResetCheck = false; priv->force_reset = false; - priv->ieee80211->FwRWRF = 0; //we don't use FW read/write RF until stable firmware is available. + priv->ieee80211->FwRWRF = 0; //we don't use FW read/write RF until stable firmware is available. priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | @@ -2778,11 +2766,11 @@ static void rtl8192_init_priv_variable(struct net_device* dev) #ifdef TO_DO_LIST if(Adapter->bInHctTest) pHalData->ReceiveConfig = pHalData->CSMethod | - RCR_AMF | RCR_ADF | //RCR_AAP | //accept management/data + RCR_AMF | RCR_ADF | //RCR_AAP | //accept management/data //guangan200710 RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet + RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet ((u32)7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited. (pHalData->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold. (pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt:0); @@ -2793,7 +2781,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) RCR_AMF | RCR_ADF | //accept management/data RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - //RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet + //RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet ((u32)7<<RCR_MXDMA_OFFSET)| // Max DMA Burst Size per Rx DMA Burst, 7: unlimited. (priv->EarlyRxThreshold<<RX_FIFO_THRESHOLD_SHIFT) | // Rx FIFO Threshold, 7: No Rx threshold. (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0); @@ -3549,7 +3537,7 @@ HalTxCheckStuck819xUsb( ) { struct r8192_priv *priv = ieee80211_priv(dev); - u16 RegTxCounter = read_nic_word(dev, 0x128); + u16 RegTxCounter = read_nic_word(dev, 0x128); bool bStuck = FALSE; RT_TRACE(COMP_RESET,"%s():RegTxCounter is %d,TxCounter is %d\n",__FUNCTION__,RegTxCounter,priv->TxCounter); if(priv->TxCounter==RegTxCounter) @@ -3583,16 +3571,16 @@ TxCheckStuck(struct net_device *dev) // spin_lock_irqsave(&priv->ieee80211->lock,flags); for (QueueID = 0; QueueID<=BEACON_QUEUE;QueueID ++) { - if(QueueID == TXCMD_QUEUE) - continue; + if(QueueID == TXCMD_QUEUE) + continue; #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_drv_aggQ[QueueID]) == 0)) #else - if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0)) + if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0)) #endif - continue; + continue; - bCheckFwTxCnt = true; + bCheckFwTxCnt = true; } // PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK); // spin_unlock_irqrestore(&priv->ieee80211->lock,flags); @@ -3611,10 +3599,10 @@ TxCheckStuck(struct net_device *dev) bool HalRxCheckStuck819xUsb(struct net_device *dev) { - u16 RegRxCounter = read_nic_word(dev, 0x130); + u16 RegRxCounter = read_nic_word(dev, 0x130); struct r8192_priv *priv = ieee80211_priv(dev); bool bStuck = FALSE; - static u8 rx_chk_cnt = 0; + static u8 rx_chk_cnt; RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n",__FUNCTION__,RegRxCounter,priv->RxCounter); // If rssi is small, we should check rx for long time because of bad rx. // or maybe it will continuous silent reset every 2 seconds. @@ -3718,7 +3706,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); RESET_TYPE TxResetType = RESET_TYPE_NORESET; RESET_TYPE RxResetType = RESET_TYPE_NORESET; - RT_RF_POWER_STATE rfState; + RT_RF_POWER_STATE rfState; rfState = priv->ieee80211->eRFPowerState; @@ -4006,18 +3994,18 @@ RESET_START: void CAM_read_entry( struct net_device *dev, - u32 iIndex + u32 iIndex ) { - u32 target_command=0; + u32 target_command=0; u32 target_content=0; u8 entry_i=0; u32 ulStatus; s32 i=100; // printk("=======>start read CAM\n"); - for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++) - { - // polling bit, and No Write enable, and address + for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++) + { + // polling bit, and No Write enable, and address target_command= entry_i+CAM_CONTENT_COUNT*iIndex; target_command= target_command | BIT31; @@ -4049,7 +4037,7 @@ void rtl819x_update_rxcounts( u32* TotalRxDataNum ) { - u16 SlotIndex; + u16 SlotIndex; u8 i; *TotalRxBcnNum = 0; @@ -4072,7 +4060,7 @@ extern void rtl819x_watchdog_wqcallback(struct work_struct *work) struct net_device *dev = priv->ieee80211->dev; struct ieee80211_device* ieee = priv->ieee80211; RESET_TYPE ResetType = RESET_TYPE_NORESET; - static u8 check_reset_cnt=0; + static u8 check_reset_cnt; bool bBusyTraffic = false; if(!priv->up) @@ -4111,7 +4099,7 @@ extern void rtl819x_watchdog_wqcallback(struct work_struct *work) notify_wx_assoc_event(priv->ieee80211); RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); priv->ieee80211->link_change(dev); - queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); + queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); } } @@ -4122,7 +4110,7 @@ extern void rtl819x_watchdog_wqcallback(struct work_struct *work) //check if reset the driver if(check_reset_cnt++ >= 3) { - ResetType = rtl819x_ifcheck_resetornot(dev); + ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; //DbgPrint("Start to check silent reset\n"); } @@ -4365,66 +4353,66 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: + case RTL_IOCTL_WPA_SUPPLICANT: //parse here for HW security - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) + { + if (ipw->u.crypt.set_tx) { - if (ipw->u.crypt.set_tx) + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } - else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) - { - memcpy((u8*)key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(dev); - //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching! - //added by WB. - setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - if (ieee->auth_mode != 2) - setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - } + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = KEY_TYPE_WEP40; } - else //if (ipw->u.crypt.idx) //group key use idx > 0 + else + ieee->pairwise_key_type = KEY_TYPE_NA; + + if (ieee->pairwise_key_type) { memcpy((u8*)key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } - else - ieee->group_key_type = KEY_TYPE_NA; + EnableHWSecurityConfig8192(dev); + //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching! + //added by WB. + setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); + if (ieee->auth_mode != 2) + setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); + } + } + else //if (ipw->u.crypt.idx) //group key use idx > 0 + { + memcpy((u8*)key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type= KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) + { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = KEY_TYPE_WEP40; + } + else + ieee->group_key_type = KEY_TYPE_NA; - if (ieee->group_key_type) - { - setKey( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, //KeyIndex - ieee->group_key_type, //KeyType - broadcast_addr, //MacAddr - 0, //DefaultKey - key); //KeyContent - } + if (ieee->group_key_type) + { + setKey( dev, + ipw->u.crypt.idx, + ipw->u.crypt.idx, //KeyIndex + ieee->group_key_type, //KeyType + broadcast_addr, //MacAddr + 0, //DefaultKey + key); //KeyContent } } + } #ifdef JOHN_HWSEC_DEBUG //john's test 0711 printk("@@ wrq->u pointer = "); @@ -4437,7 +4425,7 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); break; - default: + default: ret = -EOPNOTSUPP; break; } @@ -4454,49 +4442,49 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) if(!bIsHT) { switch(rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; - - default: - ret_rate = 0xff; - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + case DESC90_RATE1M: ret_rate = MGN_1M; break; + case DESC90_RATE2M: ret_rate = MGN_2M; break; + case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; + case DESC90_RATE11M: ret_rate = MGN_11M; break; + case DESC90_RATE6M: ret_rate = MGN_6M; break; + case DESC90_RATE9M: ret_rate = MGN_9M; break; + case DESC90_RATE12M: ret_rate = MGN_12M; break; + case DESC90_RATE18M: ret_rate = MGN_18M; break; + case DESC90_RATE24M: ret_rate = MGN_24M; break; + case DESC90_RATE36M: ret_rate = MGN_36M; break; + case DESC90_RATE48M: ret_rate = MGN_48M; break; + case DESC90_RATE54M: ret_rate = MGN_54M; break; + + default: + ret_rate = 0xff; + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } else { switch(rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; - - default: - ret_rate = 0xff; - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; + case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; + case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; + case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; + case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; + case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; + case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; + case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; + case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; + case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; + case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; + case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; + case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; + case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; + case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; + case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; + case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; + case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + + default: + ret_rate = 0xff; + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); + break; } } @@ -4555,12 +4543,12 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee802 u8 rfpath; u32 nspatial_stream, tmp_val; //u8 i; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; + static u32 slide_rssi_index, slide_rssi_statistics; + static u32 slide_evm_index, slide_evm_statistics; + static u32 last_rssi, last_evm; - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; + static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics; + static u32 last_beacon_adc_pwdb; struct ieee80211_hdr_3addr *hdr; u16 sc ; @@ -4578,11 +4566,8 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee802 { // if previous packet is not aggregated packet bcheck = true; - }else - { } - if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; @@ -4808,9 +4793,9 @@ rtl819x_evm_dbtopercentage( ret_val = value; if(ret_val >= 0) - ret_val = 0; + ret_val = 0; if(ret_val <= -33) - ret_val = -33; + ret_val = -33; ret_val = 0 - ret_val; ret_val*=3; if(ret_val == 99) @@ -4819,7 +4804,7 @@ rtl819x_evm_dbtopercentage( } // // Description: -// We want good-looking for signal strength/quality +// We want good-looking for signal strength/quality // 2007/7/19 01:09, by cosa. // long @@ -5203,7 +5188,7 @@ void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, * Overview: Record the received data rate * * Input: -* struct net_device *dev +* struct net_device *dev * struct ieee80211_rx_stats *stats * * Output: @@ -5581,7 +5566,7 @@ rtl819xusb_process_received_packet( ) { // bool bfreerfd=false, bqueued=false; - u8* frame; + u8* frame; u16 frame_len=0; struct r8192_priv *priv = ieee80211_priv(dev); // u8 index = 0; @@ -5682,10 +5667,6 @@ void rtl8192_rx_cmd(struct sk_buff *skb) dev_kfree_skb_any(skb); } - else - ; - - } void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) @@ -5697,25 +5678,25 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) info = (struct rtl8192_rx_info *)skb->cb; switch (info->out_pipe) { /* Nomal packet pipe */ - case 3: - //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe); - priv->IrpPendingCount--; - rtl8192_rx_nomal(skb); - break; + case 3: + //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe); + priv->IrpPendingCount--; + rtl8192_rx_nomal(skb); + break; - /* Command packet pipe */ - case 9: - RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\ - info->out_pipe); + /* Command packet pipe */ + case 9: + RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\ + info->out_pipe); - rtl8192_rx_cmd(skb); - break; + rtl8192_rx_cmd(skb); + break; - default: /* should never get here! */ - RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\ - info->out_pipe); - dev_kfree_skb(skb); - break; + default: /* should never get here! */ + RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\ + info->out_pipe); + dev_kfree_skb(skb); + break; } } @@ -6007,7 +5988,7 @@ void setKey( struct net_device *dev, // printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo)); } else if(i==1){//MAC - TargetContent = (u32)(*(MacAddr+2)) | + TargetContent = (u32)(*(MacAddr+2)) | (u32)(*(MacAddr+3)) << 8| (u32)(*(MacAddr+4)) << 16| (u32)(*(MacAddr+5)) << 24; diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index cd8dc85..ea46717f 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -8,7 +8,7 @@ Abstract: HW dynamic mechanism. Major Change History: - When Who What + When Who What ---------- --------------- ------------------------------- 2008-05-14 amy create version 0 porting from windows code. @@ -25,9 +25,9 @@ Major Change History: // Indicate different AP vendor for IOT issue. // static u32 edca_setting_DL[HT_IOT_PEER_MAX] = - { 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f}; + { 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f}; static u32 edca_setting_UL[HT_IOT_PEER_MAX] = - { 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f}; + { 0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f}; #define RTK_UL_EDCA 0xa44f @@ -134,7 +134,7 @@ static void dm_check_pbc_gpio(struct net_device *dev); // DM --> Check current RX RF path state static void dm_check_rx_path_selection(struct net_device *dev); -static void dm_init_rxpath_selection(struct net_device *dev); +static void dm_init_rxpath_selection(struct net_device *dev); static void dm_rxpath_sel_byrssi(struct net_device *dev); @@ -201,8 +201,8 @@ extern void deinit_hal_dm(struct net_device *dev) void dm_CheckRxAggregation(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev); PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; unsigned long curTxOkCnt = 0; unsigned long curRxOkCnt = 0; @@ -259,7 +259,7 @@ extern void hal_dm_watchdog(struct net_device *dev) { //struct r8192_priv *priv = ieee80211_priv(dev); - //static u8 previous_bssid[6] ={0}; + //static u8 previous_bssid[6] ={0}; /*Add by amy 2008/05/15 ,porting from windows code.*/ dm_check_rate_adaptive(dev); @@ -315,21 +315,21 @@ extern void init_rate_adaptive(struct net_device * dev) { // 07/10/08 MH Modify for RA smooth scheme. /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/ - pra->upper_rssi_threshold_ratr = 0x8f0f0000; - pra->middle_rssi_threshold_ratr = 0x8f0ff000; - pra->low_rssi_threshold_ratr = 0x8f0ff001; - pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; - pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; - pra->ping_rssi_ratr = 0x0000000d;//cosa add for test + pra->upper_rssi_threshold_ratr = 0x8f0f0000; + pra->middle_rssi_threshold_ratr = 0x8f0ff000; + pra->low_rssi_threshold_ratr = 0x8f0ff001; + pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; + pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; + pra->ping_rssi_ratr = 0x0000000d;//cosa add for test } else if (priv->rf_type == RF_1T2R) { - pra->upper_rssi_threshold_ratr = 0x000f0000; - pra->middle_rssi_threshold_ratr = 0x000ff000; - pra->low_rssi_threshold_ratr = 0x000ff001; - pra->low_rssi_threshold_ratr_40M = 0x000ff005; - pra->low_rssi_threshold_ratr_20M = 0x000ff001; - pra->ping_rssi_ratr = 0x0000000d;//cosa add for test + pra->upper_rssi_threshold_ratr = 0x000f0000; + pra->middle_rssi_threshold_ratr = 0x000ff000; + pra->low_rssi_threshold_ratr = 0x000ff001; + pra->low_rssi_threshold_ratr_40M = 0x000ff005; + pra->low_rssi_threshold_ratr_20M = 0x000ff001; + pra->ping_rssi_ratr = 0x0000000d;//cosa add for test } } // InitRateAdaptive @@ -348,7 +348,7 @@ extern void init_rate_adaptive(struct net_device * dev) * * Revised History: * When Who Remark - * 05/26/08 amy Create version 0 porting from windows code. + * 05/26/08 amy Create version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void dm_check_rate_adaptive(struct net_device * dev) @@ -359,7 +359,7 @@ static void dm_check_rate_adaptive(struct net_device * dev) u32 currentRATR, targetRATR = 0; u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; bool bshort_gi_enabled = false; - static u8 ping_rssi_state=0; + static u8 ping_rssi_state; if(!priv->up) @@ -413,14 +413,14 @@ static void dm_check_rate_adaptive(struct net_device * dev) to prevent jumping frequently. */ if (pra->ratr_state == DM_RATR_STA_HIGH) { - HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; + HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); } else if (pra->ratr_state == DM_RATR_STA_LOW) { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); } else @@ -599,7 +599,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) u32 Value; u8 Pwr_Flag; u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; - //RT_STATUS rtStatus = RT_STATUS_SUCCESS; + //RT_STATUS rtStatus = RT_STATUS_SUCCESS; bool rtStatus = true; u32 delta=0; @@ -954,79 +954,79 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); //Initial the Tx BB index and mapping value - priv->txbbgain_table[0].txbb_iq_amplifygain = 12; + priv->txbbgain_table[0].txbb_iq_amplifygain = 12; priv->txbbgain_table[0].txbbgain_value=0x7f8001fe; - priv->txbbgain_table[1].txbb_iq_amplifygain = 11; + priv->txbbgain_table[1].txbb_iq_amplifygain = 11; priv->txbbgain_table[1].txbbgain_value=0x788001e2; - priv->txbbgain_table[2].txbb_iq_amplifygain = 10; + priv->txbbgain_table[2].txbb_iq_amplifygain = 10; priv->txbbgain_table[2].txbbgain_value=0x71c001c7; - priv->txbbgain_table[3].txbb_iq_amplifygain = 9; + priv->txbbgain_table[3].txbb_iq_amplifygain = 9; priv->txbbgain_table[3].txbbgain_value=0x6b8001ae; - priv->txbbgain_table[4].txbb_iq_amplifygain = 8; + priv->txbbgain_table[4].txbb_iq_amplifygain = 8; priv->txbbgain_table[4].txbbgain_value=0x65400195; - priv->txbbgain_table[5].txbb_iq_amplifygain = 7; + priv->txbbgain_table[5].txbb_iq_amplifygain = 7; priv->txbbgain_table[5].txbbgain_value=0x5fc0017f; - priv->txbbgain_table[6].txbb_iq_amplifygain = 6; + priv->txbbgain_table[6].txbb_iq_amplifygain = 6; priv->txbbgain_table[6].txbbgain_value=0x5a400169; - priv->txbbgain_table[7].txbb_iq_amplifygain = 5; + priv->txbbgain_table[7].txbb_iq_amplifygain = 5; priv->txbbgain_table[7].txbbgain_value=0x55400155; - priv->txbbgain_table[8].txbb_iq_amplifygain = 4; + priv->txbbgain_table[8].txbb_iq_amplifygain = 4; priv->txbbgain_table[8].txbbgain_value=0x50800142; - priv->txbbgain_table[9].txbb_iq_amplifygain = 3; + priv->txbbgain_table[9].txbb_iq_amplifygain = 3; priv->txbbgain_table[9].txbbgain_value=0x4c000130; - priv->txbbgain_table[10].txbb_iq_amplifygain = 2; + priv->txbbgain_table[10].txbb_iq_amplifygain = 2; priv->txbbgain_table[10].txbbgain_value=0x47c0011f; - priv->txbbgain_table[11].txbb_iq_amplifygain = 1; + priv->txbbgain_table[11].txbb_iq_amplifygain = 1; priv->txbbgain_table[11].txbbgain_value=0x43c0010f; - priv->txbbgain_table[12].txbb_iq_amplifygain = 0; + priv->txbbgain_table[12].txbb_iq_amplifygain = 0; priv->txbbgain_table[12].txbbgain_value=0x40000100; - priv->txbbgain_table[13].txbb_iq_amplifygain = -1; + priv->txbbgain_table[13].txbb_iq_amplifygain = -1; priv->txbbgain_table[13].txbbgain_value=0x3c8000f2; - priv->txbbgain_table[14].txbb_iq_amplifygain = -2; + priv->txbbgain_table[14].txbb_iq_amplifygain = -2; priv->txbbgain_table[14].txbbgain_value=0x390000e4; - priv->txbbgain_table[15].txbb_iq_amplifygain = -3; + priv->txbbgain_table[15].txbb_iq_amplifygain = -3; priv->txbbgain_table[15].txbbgain_value=0x35c000d7; - priv->txbbgain_table[16].txbb_iq_amplifygain = -4; + priv->txbbgain_table[16].txbb_iq_amplifygain = -4; priv->txbbgain_table[16].txbbgain_value=0x32c000cb; - priv->txbbgain_table[17].txbb_iq_amplifygain = -5; + priv->txbbgain_table[17].txbb_iq_amplifygain = -5; priv->txbbgain_table[17].txbbgain_value=0x300000c0; - priv->txbbgain_table[18].txbb_iq_amplifygain = -6; + priv->txbbgain_table[18].txbb_iq_amplifygain = -6; priv->txbbgain_table[18].txbbgain_value=0x2d4000b5; - priv->txbbgain_table[19].txbb_iq_amplifygain = -7; + priv->txbbgain_table[19].txbb_iq_amplifygain = -7; priv->txbbgain_table[19].txbbgain_value=0x2ac000ab; - priv->txbbgain_table[20].txbb_iq_amplifygain = -8; + priv->txbbgain_table[20].txbb_iq_amplifygain = -8; priv->txbbgain_table[20].txbbgain_value=0x288000a2; - priv->txbbgain_table[21].txbb_iq_amplifygain = -9; + priv->txbbgain_table[21].txbb_iq_amplifygain = -9; priv->txbbgain_table[21].txbbgain_value=0x26000098; - priv->txbbgain_table[22].txbb_iq_amplifygain = -10; + priv->txbbgain_table[22].txbb_iq_amplifygain = -10; priv->txbbgain_table[22].txbbgain_value=0x24000090; - priv->txbbgain_table[23].txbb_iq_amplifygain = -11; + priv->txbbgain_table[23].txbb_iq_amplifygain = -11; priv->txbbgain_table[23].txbbgain_value=0x22000088; - priv->txbbgain_table[24].txbb_iq_amplifygain = -12; + priv->txbbgain_table[24].txbb_iq_amplifygain = -12; priv->txbbgain_table[24].txbbgain_value=0x20000080; - priv->txbbgain_table[25].txbb_iq_amplifygain = -13; + priv->txbbgain_table[25].txbb_iq_amplifygain = -13; priv->txbbgain_table[25].txbbgain_value=0x1a00006c; - priv->txbbgain_table[26].txbb_iq_amplifygain = -14; + priv->txbbgain_table[26].txbb_iq_amplifygain = -14; priv->txbbgain_table[26].txbbgain_value=0x1c800072; - priv->txbbgain_table[27].txbb_iq_amplifygain = -15; + priv->txbbgain_table[27].txbb_iq_amplifygain = -15; priv->txbbgain_table[27].txbbgain_value=0x18000060; - priv->txbbgain_table[28].txbb_iq_amplifygain = -16; + priv->txbbgain_table[28].txbb_iq_amplifygain = -16; priv->txbbgain_table[28].txbbgain_value=0x19800066; - priv->txbbgain_table[29].txbb_iq_amplifygain = -17; + priv->txbbgain_table[29].txbb_iq_amplifygain = -17; priv->txbbgain_table[29].txbbgain_value=0x15800056; - priv->txbbgain_table[30].txbb_iq_amplifygain = -18; + priv->txbbgain_table[30].txbb_iq_amplifygain = -18; priv->txbbgain_table[30].txbbgain_value=0x26c0005b; - priv->txbbgain_table[31].txbb_iq_amplifygain = -19; + priv->txbbgain_table[31].txbb_iq_amplifygain = -19; priv->txbbgain_table[31].txbbgain_value=0x14400051; - priv->txbbgain_table[32].txbb_iq_amplifygain = -20; + priv->txbbgain_table[32].txbb_iq_amplifygain = -20; priv->txbbgain_table[32].txbbgain_value=0x24400051; - priv->txbbgain_table[33].txbb_iq_amplifygain = -21; + priv->txbbgain_table[33].txbb_iq_amplifygain = -21; priv->txbbgain_table[33].txbbgain_value=0x1300004c; - priv->txbbgain_table[34].txbb_iq_amplifygain = -22; + priv->txbbgain_table[34].txbb_iq_amplifygain = -22; priv->txbbgain_table[34].txbbgain_value=0x12000048; - priv->txbbgain_table[35].txbb_iq_amplifygain = -23; + priv->txbbgain_table[35].txbb_iq_amplifygain = -23; priv->txbbgain_table[35].txbbgain_value=0x11000044; - priv->txbbgain_table[36].txbb_iq_amplifygain = -24; + priv->txbbgain_table[36].txbb_iq_amplifygain = -24; priv->txbbgain_table[36].txbbgain_value=0x10000040; //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 @@ -1486,7 +1486,7 @@ void dm_initialize_txpower_tracking(struct net_device *dev) static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u32 tx_power_track_counter = 0; + static u32 tx_power_track_counter; if(!priv->btxpower_tracking) return; @@ -1505,7 +1505,7 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u8 TM_Trigger=0; + static u8 TM_Trigger; //DbgPrint("dm_CheckTXPowerTracking() \n"); if(!priv->btxpower_tracking) return; @@ -1564,40 +1564,40 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) TempVal = 0; if(!bInCH14){ //Write 0xa22 0xa23 - TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] + + TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); //Write 0xa24 ~ 0xa27 TempVal = 0; - TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + + TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); //Write 0xa28 0xa29 TempVal = 0; - TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + + TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); } else { - TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] + + TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); //Write 0xa24 ~ 0xa27 TempVal = 0; - TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + + TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); //Write 0xa28 0xa29 TempVal = 0; - TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + + TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); @@ -1615,14 +1615,14 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH if(!bInCH14) { //Write 0xa22 0xa23 - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); //Write 0xa24 ~ 0xa27 TempVal = 0; - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); @@ -1631,7 +1631,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rCCK0_TxFilter2, TempVal); //Write 0xa28 0xa29 TempVal = 0; - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + + TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); @@ -1642,7 +1642,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH { // priv->CCKTxPowerAdjustCntNotCh14++; //cosa add for debug. //Write 0xa22 0xa23 - TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + + TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); @@ -1650,7 +1650,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rCCK0_TxFilter1, TempVal); //Write 0xa24 ~ 0xa27 TempVal = 0; - TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + + TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); @@ -1659,7 +1659,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rCCK0_TxFilter2, TempVal); //Write 0xa28 0xa29 TempVal = 0; - TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + + TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); @@ -1713,7 +1713,7 @@ static void dm_txpower_reset_recovery( extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - u32 reg_ratr = priv->rate_adaptive.last_ratr; + u32 reg_ratr = priv->rate_adaptive.last_ratr; if(!priv->up) { @@ -1934,7 +1934,7 @@ dm_change_rxpath_selection_setting( s32 DM_Value) { struct r8192_priv *priv = ieee80211_priv(dev); - prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive); + prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive); if(DM_Type == 0) @@ -2036,8 +2036,8 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; dm_digtable.initialgain_lowerbound_state = false; - dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; - dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; + dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW; + dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH; dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW; dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH; @@ -2091,7 +2091,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( { struct r8192_priv *priv = ieee80211_priv(dev); u8 i; - static u8 fw_dig=0; + static u8 fw_dig; if (dm_digtable.dig_enable_flag == false) return; @@ -2131,7 +2131,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u32 reset_cnt = 0; + static u32 reset_cnt; u8 i; if (dm_digtable.dig_enable_flag == false) @@ -2319,7 +2319,7 @@ static void dm_ctrl_initgain_byrssi_highpwr( struct net_device * dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u32 reset_cnt_highpwr = 0; + static u32 reset_cnt_highpwr; // For smooth, we can not change high power DIG state in the range. if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && @@ -2395,8 +2395,8 @@ static void dm_initial_gain( { struct r8192_priv *priv = ieee80211_priv(dev); u8 initial_gain=0; - static u8 initialized=0, force_write=0; - static u32 reset_cnt=0; + static u8 initialized, force_write; + static u32 reset_cnt; if(dm_digtable.dig_algorithm_switch) { @@ -2462,8 +2462,8 @@ static void dm_pd_th( struct net_device * dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u8 initialized=0, force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; if(dm_digtable.dig_algorithm_switch) { @@ -2574,8 +2574,8 @@ static void dm_cs_ratio( struct net_device * dev) { struct r8192_priv *priv = ieee80211_priv(dev); - static u8 initialized=0,force_write=0; - static u32 reset_cnt = 0; + static u8 initialized,force_write; + static u32 reset_cnt; if(dm_digtable.dig_algorithm_switch) { @@ -2651,8 +2651,8 @@ static void dm_check_edca_turbo( //PSTA_QOS pStaQos = pMgntInfo->pStaQos; // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo. - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; unsigned long curTxOkCnt = 0; unsigned long curRxOkCnt = 0; @@ -2785,8 +2785,8 @@ static void dm_ctstoself(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev); PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; unsigned long curTxOkCnt = 0; unsigned long curRxOkCnt = 0; @@ -2871,7 +2871,7 @@ static void dm_check_rfctrl_gpio(struct net_device * dev) * * Revised History: * When Who Remark - * 05/28/2008 amy Create Version 0 porting from windows code. + * 05/28/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void dm_check_pbc_gpio(struct net_device *dev) @@ -3044,7 +3044,7 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; u8 cur_rf_rssi; long cur_cck_pwdb; - static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; + static u8 disabled_rf_cnt, cck_Rx_Path_initialized; u8 update_cck_rx_path; if(priv->rf_type != RF_2T4R) @@ -3517,8 +3517,8 @@ static void dm_EndSWFsync(struct net_device *dev) static void dm_StartSWFsync(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - u32 rateIndex; - u32 rateBitmap; + u32 rateIndex; + u32 rateBitmap; RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__); // Initial rate record to zero, start to record. @@ -3569,9 +3569,9 @@ void dm_check_fsync(struct net_device *dev) #define RegC38_NonFsync_Other_AP 1 #define RegC38_Fsync_AP_BCM 2 struct r8192_priv *priv = ieee80211_priv(dev); - //u32 framesyncC34; + //u32 framesyncC34; static u8 reg_c38_State=RegC38_Default; - static u32 reset_cnt=0; + static u32 reset_cnt; RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->ieee80211->fsync_rssi_threshold, priv->ieee80211->fsync_time_interval, priv->ieee80211->fsync_multiple_timeinterval); RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->ieee80211->fsync_rate_bitmap, priv->ieee80211->fsync_firstdiff_ratethreshold, priv->ieee80211->fsync_seconddiff_ratethreshold); @@ -3887,4 +3887,3 @@ static void dm_send_rssi_tofw(struct net_device *dev) } /*---------------------------Define function prototype------------------------*/ - diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 3ceb59b..ffb083c 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -13,7 +13,7 @@ * * History: * Data Who Remark - * 10/04/2007 MHC Create initial version. + * 10/04/2007 MHC Create initial version. * *****************************************************************************/ /* Check to see if the file has been included already. */ @@ -55,20 +55,19 @@ #define TX_POWER_NEAR_FIELD_THRESH_LOW 62 //added by amy for atheros AP #define TX_POWER_ATHEROAP_THRESH_HIGH 78 -#define TX_POWER_ATHEROAP_THRESH_LOW 72 +#define TX_POWER_ATHEROAP_THRESH_LOW 72 //defined by vivi, for showing on UI -#define Current_Tx_Rate_Reg 0x1b8 -#define Initial_Tx_Rate_Reg 0x1b9 -#define Tx_Retry_Count_Reg 0x1ac +#define Current_Tx_Rate_Reg 0x1b8 +#define Initial_Tx_Rate_Reg 0x1b9 +#define Tx_Retry_Count_Reg 0x1ac #define RegC38_TH 20 /*--------------------------Define Parameters-------------------------------*/ /*------------------------------Define structure----------------------------*/ /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */ -typedef struct _dynamic_initial_gain_threshold_ -{ +typedef struct _dynamic_initial_gain_threshold_ { u8 dig_enable_flag; u8 dig_algorithm; u8 dbg_mode; @@ -132,8 +131,8 @@ typedef enum tag_dynamic_init_gain_operation_type_definition DIG_TYPE_PWDB_FACTOR = 8, DIG_TYPE_RX_GAIN_MIN = 9, DIG_TYPE_RX_GAIN_MAX = 10, - DIG_TYPE_ENABLE = 20, - DIG_TYPE_DISABLE = 30, + DIG_TYPE_ENABLE = 20, + DIG_TYPE_DISABLE = 30, DIG_OP_TYPE_MAX }dm_dig_op_e; @@ -172,8 +171,7 @@ typedef enum tag_dig_cck_cs_ratio_state_definition DIG_CS_RATIO_HIGHER = 1, DIG_CS_MAX }dm_dig_cs_ratio_e; -typedef struct _Dynamic_Rx_Path_Selection_ -{ +typedef struct _Dynamic_Rx_Path_Selection_ { u8 Enable; u8 DbgMode; u8 cck_method; @@ -203,8 +201,7 @@ typedef enum tag_DM_DbgMode_Definition DM_DBG_MAX }DM_DBG_E; -typedef struct tag_Tx_Config_Cmd_Format -{ +typedef struct tag_Tx_Config_Cmd_Format { u32 Op; /* Command packet type. */ u32 Length; /* Command packet length. */ u32 Value; @@ -251,4 +248,3 @@ extern void dm_initialize_txpower_tracking(struct net_device *dev); /* End of r8192U_dm.h */ - diff --git a/drivers/staging/rtl8192u/r8192U_hw.h b/drivers/staging/rtl8192u/r8192U_hw.h index 1bfe871..15b0423 100644 --- a/drivers/staging/rtl8192u/r8192U_hw.h +++ b/drivers/staging/rtl8192u/r8192U_hw.h @@ -122,7 +122,7 @@ enum _RTL8192Usb_HW { SIFS = 0x03E, // SIFS register TCR = 0x040, // Transmit Configuration Register -#define TCR_MXDMA_2048 7 +#define TCR_MXDMA_2048 7 #define TCR_LRL_OFFSET 0 #define TCR_SRL_OFFSET 8 #define TCR_MXDMA_OFFSET 21 @@ -379,7 +379,7 @@ enum _RTL8192Usb_HW { // IMR_POLL = 0x360, MacBlkCtrl = 0x403, // Mac block on/off control register - EPROM_CMD = 0xfe58, + EPROM_CMD = 0xfe58, #define Cmd9346CR_9356SEL (1<<4) #define EPROM_CMD_RESERVED_MASK (1<<5) #define EPROM_CMD_OPERATING_MODE_SHIFT 6 @@ -392,12 +392,12 @@ enum _RTL8192Usb_HW { #define EPROM_CK_SHIFT 2 #define EPROM_W_SHIFT 1 #define EPROM_R_SHIFT 0 - MAC0 = 0x000, - MAC1 = 0x001, - MAC2 = 0x002, - MAC3 = 0x003, - MAC4 = 0x004, - MAC5 = 0x005, + MAC0 = 0x000, + MAC1 = 0x001, + MAC2 = 0x002, + MAC3 = 0x003, + MAC4 = 0x004, + MAC5 = 0x005, }; //---------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 71f2d23..c904aa8 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -354,8 +354,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, return ret; } -struct iw_range_with_scan_capa -{ +struct iw_range_with_scan_capa { /* Informative stuff (to choose between different interface) */ __u32 throughput; /* To give an idea... */ /* In theory this value should be the maximum benchmarked @@ -711,12 +710,12 @@ static int r8192_wx_set_enc(struct net_device *dev, #define CONF_WEP104 0x14 switch(wrqu->encoding.flags & IW_ENCODE_INDEX){ - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; + case 0: key_idx = ieee->tx_keyidx; break; + case 1: key_idx = 0; break; + case 2: key_idx = 1; break; + case 3: key_idx = 2; break; + case 4: key_idx = 3; break; + default: break; } if(wrqu->encoding.length==0x5){ @@ -1021,7 +1020,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a, static iw_handler r8192_wx_handlers[] = { NULL, /* SIOCSIWCOMMIT */ - r8192_wx_get_name, /* SIOCGIWNAME */ + r8192_wx_get_name, /* SIOCGIWNAME */ dummy, /* SIOCSIWNWID */ dummy, /* SIOCGIWNWID */ r8192_wx_set_freq, /* SIOCSIWFREQ */ @@ -1040,7 +1039,7 @@ static iw_handler r8192_wx_handlers[] = dummy, /* SIOCGIWSPY */ NULL, /* SIOCGIWTHRSPY */ NULL, /* SIOCWIWTHRSPY */ - r8192_wx_set_wap, /* SIOCSIWAP */ + r8192_wx_set_wap, /* SIOCSIWAP */ r8192_wx_get_wap, /* SIOCGIWAP */ #if (WIRELESS_EXT >= 18) r8192_wx_set_mlme, /* MLME-- */ @@ -1071,23 +1070,23 @@ static iw_handler r8192_wx_handlers[] = r8192_wx_set_power, /* SIOCSIWPOWER */ r8192_wx_get_power, /* SIOCGIWPOWER */ NULL, /*---hole---*/ - NULL, /*---hole---*/ - r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */ - NULL, /* SIOCSIWGENIE */ + NULL, /*---hole---*/ + r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */ + NULL, /* SIOCSIWGENIE */ #if (WIRELESS_EXT >= 18) - r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */ - NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */ - r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */ + r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */ + NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */ + r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ + NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */ #else NULL, NULL, NULL, NULL, #endif - NULL, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ + NULL, /* SIOCSIWPMKSA */ + NULL, /*---hole---*/ }; diff --git a/drivers/staging/rtl8192u/r819xU_HTGen.h b/drivers/staging/rtl8192u/r819xU_HTGen.h index f37b6d6..6a4678f 100644 --- a/drivers/staging/rtl8192u/r819xU_HTGen.h +++ b/drivers/staging/rtl8192u/r819xU_HTGen.h @@ -10,4 +10,3 @@ typedef enum _HT_IOT_ACTION{ HT_IOT_ACT_CDD_FSYNC = 0x00000020, HT_IOT_ACT_PURE_N_MODE = 0x00000040, }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E; - diff --git a/drivers/staging/rtl8192u/r819xU_HTType.h b/drivers/staging/rtl8192u/r819xU_HTType.h index 6c1d05e..19a7bdd 100644 --- a/drivers/staging/rtl8192u/r819xU_HTType.h +++ b/drivers/staging/rtl8192u/r819xU_HTType.h @@ -89,7 +89,7 @@ typedef enum _CHNLOP{ typedef enum _HT_ACTION{ ACT_RECOMMAND_WIDTH = 0, - ACT_MIMO_PWR_SAVE = 1, + ACT_MIMO_PWR_SAVE = 1, ACT_PSMP = 2, ACT_SET_PCO_PHASE = 3, ACT_MIMO_CHL_MEASURE = 4, @@ -367,9 +367,9 @@ typedef struct _BSS_HT{ typedef struct _MIMO_RSSI{ u32 EnableAntenna; u32 AntennaA; - u32 AntennaB; - u32 AntennaC; - u32 AntennaD; + u32 AntennaB; + u32 AntennaC; + u32 AntennaD; u32 Average; }MIMO_RSSI, *PMIMO_RSSI; @@ -388,4 +388,3 @@ typedef struct _FALSE_ALARM_STATISTICS{ #endif //__INC_HTTYPE_H - diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index a8a6dc2..b755eb4 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -18,7 +18,7 @@ History: Data Who Remark - 05/06/2008 amy Create initial version porting from windows driver. + 05/06/2008 amy Create initial version porting from windows driver. ******************************************************************************/ #include "r8192U.h" @@ -41,7 +41,7 @@ rt_status SendTxCommandPacket( struct net_device *dev, - void* pData, + void* pData, u32 DataLen ) { @@ -106,7 +106,7 @@ SendTxCommandPacket( u32 buffer_len) { - bool rt_status = true; + bool rt_status = true; #ifdef RTL8192U return rt_status; #else @@ -188,7 +188,7 @@ SendTxCommandPacket( * * Overview: * - * Input: PADAPTER pAdapter - . + * Input: PADAPTER pAdapter - . * CMPK_TXFB_T *psTx_FB - . * * Output: NONE @@ -197,7 +197,7 @@ SendTxCommandPacket( * * Revised History: * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void @@ -289,7 +289,7 @@ cmpk_count_txstatistic( * in the command packet. * * Input: struct net_device * dev - * u8 * pmsg - Msg Ptr of the command packet. + * u8 * pmsg - Msg Ptr of the command packet. * * Output: NONE * @@ -369,7 +369,7 @@ cmdpkt_beacontimerinterrupt_819xusb( * Overview: The function is responsible for extract the message from * firmware. It will contain dedicated info in * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. - * Please refer to chapter "Interrupt Status Element". + * Please refer to chapter "Interrupt Status Element". * * Input: struct net_device *dev, * u8* pmsg - Message Pointer of the command packet. @@ -400,8 +400,8 @@ cmpk_handle_interrupt_status( /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - //rx_bcn_state.Element_ID = pMsg[0]; - //rx_bcn_state.Length = pMsg[1]; + //rx_bcn_state.Element_ID = pMsg[0]; + //rx_bcn_state.Length = pMsg[1]; rx_intr_status.length = pmsg[1]; if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { @@ -478,16 +478,16 @@ cmpk_handle_query_config_rx( /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - //rx_query_cfg.Element_ID = pMsg[0]; - //rx_query_cfg.Length = pMsg[1]; - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + //rx_query_cfg.Element_ID = pMsg[0]; + //rx_query_cfg.Length = pMsg[1]; + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | (pmsg[14] << 8) | (pmsg[15] << 0); } /* cmpk_Handle_Query_Config_Rx */ @@ -511,7 +511,7 @@ cmpk_handle_query_config_rx( * *---------------------------------------------------------------------------*/ static void cmpk_count_tx_status( struct net_device *dev, - cmpk_tx_status_t *pstx_status) + cmpk_tx_status_t *pstx_status) { struct r8192_priv *priv = ieee80211_priv(dev); diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/drivers/staging/rtl8192u/r819xU_cmdpkt.h index a8855e6..59caa4e 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -19,8 +19,7 @@ /*------------------------------Define structure----------------------------*/ /* Define different command packet structure. */ /* 1. RX side: TX feedback packet. */ -typedef struct tag_cmd_pkt_tx_feedback -{ +typedef struct tag_cmd_pkt_tx_feedback { // DWORD 0 u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ @@ -57,8 +56,7 @@ typedef struct tag_cmd_pkt_tx_feedback /* 2. RX side: Interrupt status packet. It includes Beacon State, Beacon Timer Interrupt and other useful informations in MAC ISR Reg. */ -typedef struct tag_cmd_pkt_interrupt_status -{ +typedef struct tag_cmd_pkt_interrupt_status { u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ u16 reserve; @@ -67,12 +65,11 @@ typedef struct tag_cmd_pkt_interrupt_status /* 3. TX side: Set configuration packet. */ -typedef struct tag_cmd_pkt_set_configuration -{ +typedef struct tag_cmd_pkt_set_configuration { u8 element_id; /* Command packet type. */ u8 length; /* Command packet length. */ u16 reserve1; /* */ - u8 cfg_reserve1:3; + u8 cfg_reserve1:3; u8 cfg_size:2; /* Configuration info. */ u8 cfg_type:2; /* Configuration info. */ u8 cfg_action:1; /* Configuration info. */ @@ -89,25 +86,24 @@ typedef struct tag_cmd_pkt_set_configuration #define cmpk_query_cfg_t cmpk_set_cfg_t /* 5. Multi packet feedback status. */ -typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007 -{ +typedef struct tag_tx_stats_feedback { // PJ quick rxcmd 09042007 // For endian transfer --> Driver will not the same as firmware structure. // DW 0 u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type + u8 length; // Command packet length + u8 element_id; // Command packet type // DW 1 u16 txfail; // Tx Fail count - u16 txok; // Tx ok count + u16 txok; // Tx ok count // DW 2 - u16 txmcok; // tx multicast - u16 txretry; // Tx Retry count + u16 txmcok; // tx multicast + u16 txretry; // Tx Retry count // DW 3 u16 txucok; // tx unicast - u16 txbcok; // tx broadcast + u16 txbcok; // tx broadcast // DW 4 u16 txbcfail; // @@ -130,13 +126,12 @@ typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007 /* 6. Debug feedback message. */ /* 2007/10/23 MH Define RX debug message */ -typedef struct tag_rx_debug_message_feedback -{ +typedef struct tag_rx_debug_message_feedback { // For endian transfer --> for driver // DW 0 u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type + u8 length; // Command packet length + u8 element_id; // Command packet type // DW 1-?? // Variable debug message. @@ -144,19 +139,18 @@ typedef struct tag_rx_debug_message_feedback }cmpk_rx_dbginfo_t; /* 2008/03/20 MH Define transmit rate history. For big endian format. */ -typedef struct tag_tx_rate_history -{ +typedef struct tag_tx_rate_history { // For endian transfer --> for driver // DW 0 - u8 element_id; // Command packet type - u8 length; // Command packet length + u8 element_id; // Command packet type + u8 length; // Command packet length u16 reserved1; // DW 1-2 CCK rate counter - u16 cck[4]; + u16 cck[4]; // DW 3-6 - u16 ofdm[8]; + u16 ofdm[8]; // DW 7-14 //UINT16 MCS_BW0_SG0[16]; diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index b12d190..573e9cd 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -2,7 +2,7 @@ * Procedure: Init boot code/firmware code/data session * * Description: This routine will initialize firmware. If any error occurs during the initialization - * process, the routine shall terminate immediately and return fail. + * process, the routine shall terminate immediately and return fail. * NIC driver should call NdisOpenFile only from MiniportInitialize. * * Arguments: The pointer of the adapter @@ -19,7 +19,7 @@ #include <linux/firmware.h> void firmware_init_param(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); + struct r8192_priv *priv = ieee80211_priv(dev); rt_firmware *pfirmware = priv->pFirmware; pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); @@ -32,7 +32,7 @@ void firmware_init_param(struct net_device *dev) bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) { struct r8192_priv *priv = ieee80211_priv(dev); - bool rt_status = true; + bool rt_status = true; u16 frag_threshold; u16 frag_length, frag_offset = 0; //u16 total_size; @@ -241,17 +241,17 @@ CPUCheckFirmwareReady_Fail: bool init_firmware(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); + struct r8192_priv *priv = ieee80211_priv(dev); bool rt_status = TRUE; u32 file_length = 0; u8 *mapped_file = NULL; u32 init_step = 0; opt_rst_type_e rst_opt = OPT_SYSTEM_RESET; - firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT; + firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT; rt_firmware *pfirmware = priv->pFirmware; - const struct firmware *fw_entry; + const struct firmware *fw_entry; const char *fw_name[3] = { "RTL8192U/boot.img", "RTL8192U/main.img", "RTL8192U/data.img"}; @@ -334,56 +334,56 @@ bool init_firmware(struct net_device *dev) } switch(init_step) { - case FW_INIT_STEP0_BOOT: - /* Download boot - * initialize command descriptor. - * will set polling bit when firmware code is also configured - */ - pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE; + case FW_INIT_STEP0_BOOT: + /* Download boot + * initialize command descriptor. + * will set polling bit when firmware code is also configured + */ + pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE; #ifdef RTL8190P - // To initialize IMEM, CPU move code from 0x80000080, hence, we send 0x80 byte packet - rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET); - if(rt_status != true) - { - RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n"); - goto download_firmware_fail; - } + // To initialize IMEM, CPU move code from 0x80000080, hence, we send 0x80 byte packet + rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET); + if(rt_status != true) + { + RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n"); + goto download_firmware_fail; + } #endif - //mdelay(1000); - /* - * To initialize IMEM, CPU move code from 0x80000080, - * hence, we send 0x80 byte packet - */ - break; - - case FW_INIT_STEP1_MAIN: - /* Download firmware code. Wait until Boot Ready and Turn on CPU */ - pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; - - /* Check Put Code OK and Turn On CPU */ - rt_status = CPUcheck_maincodeok_turnonCPU(dev); - if(rt_status != TRUE) { - RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n"); - goto download_firmware_fail; - } - - pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; - break; - - case FW_INIT_STEP2_DATA: - /* download initial data code */ - pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE; - mdelay(1); - - rt_status = CPUcheck_firmware_ready(dev); - if(rt_status != TRUE) { - RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); - goto download_firmware_fail; - } - - /* wait until data code is initialized ready.*/ - pfirmware->firmware_status = FW_STATUS_5_READY; - break; + //mdelay(1000); + /* + * To initialize IMEM, CPU move code from 0x80000080, + * hence, we send 0x80 byte packet + */ + break; + + case FW_INIT_STEP1_MAIN: + /* Download firmware code. Wait until Boot Ready and Turn on CPU */ + pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; + + /* Check Put Code OK and Turn On CPU */ + rt_status = CPUcheck_maincodeok_turnonCPU(dev); + if(rt_status != TRUE) { + RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n"); + goto download_firmware_fail; + } + + pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; + break; + + case FW_INIT_STEP2_DATA: + /* download initial data code */ + pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE; + mdelay(1); + + rt_status = CPUcheck_firmware_ready(dev); + if(rt_status != TRUE) { + RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); + goto download_firmware_fail; + } + + /* wait until data code is initialized ready.*/ + pfirmware->firmware_status = FW_STATUS_5_READY; + break; } } @@ -402,4 +402,3 @@ download_firmware_fail: MODULE_FIRMWARE("RTL8192U/boot.img"); MODULE_FIRMWARE("RTL8192U/main.img"); MODULE_FIRMWARE("RTL8192U/data.img"); - diff --git a/drivers/staging/rtl8192u/r819xU_firmware.h b/drivers/staging/rtl8192u/r819xU_firmware.h index a4bceeef..c48c884 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.h +++ b/drivers/staging/rtl8192u/r819xU_firmware.h @@ -24,4 +24,3 @@ typedef enum _opt_rst_type{ }opt_rst_type_e; #endif - diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index dd1954d..17fac41 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -124,10 +124,10 @@ static void phy_FwRFSerialWrite( struct net_device* dev, RF90_RADIO_PATH_E /****************************************************************************** *function: This function read register from RF chip * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D * u32 Offset //target address to be read * output: none - * return: u32 readback value + * return: u32 readback value * notice: There are three types of serial operations:(1) Software serial write.(2)Hardware LSSI-Low Speed Serial Interface.(3)Hardware HSSI-High speed serial write. Driver here need to implement (1) and (2)---need more spec for this information. * ****************************************************************************/ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset) @@ -201,7 +201,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, /****************************************************************************** *function: This function write data to RF register * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D * u32 Offset //target address to be written * u32 Data //The new register data to be written * output: none @@ -283,7 +283,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath /****************************************************************************** *function: This function set specific bits to RF register * input: net_device dev - * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D + * RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D * u32 RegAddr //target addr to be modified * u32 BitMask //taget bit pos in the addr to be modified * u32 Data //value to be write @@ -684,8 +684,8 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) /****************************************************************************** *function: This function is to write register and then readback to make sure whether BB and RF is OK * input: net_device dev - * HW90_BLOCK_E CheckBlock - * RF90_RADIO_PATH_E eRFPath //only used when checkblock is HW90_BLOCK_RF + * HW90_BLOCK_E CheckBlock + * RF90_RADIO_PATH_E eRFPath //only used when checkblock is HW90_BLOCK_RF * output: none * return: return whether BB and RF is ok(0:OK; 1:Fail) * notice: This function may be removed in the ASIC @@ -957,56 +957,56 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E u8 ret = 0; switch(eRFPath){ - case RF90_PATH_A: - for(i = 0;i<RadioA_ArrayLength; i=i+2){ - - if(rtl819XRadioA_Array[i] == 0xfe){ - mdelay(100); - continue; - } - rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioA_Array[i], bMask12Bits, rtl819XRadioA_Array[i+1]); - mdelay(1); + case RF90_PATH_A: + for(i = 0;i<RadioA_ArrayLength; i=i+2){ + if(rtl819XRadioA_Array[i] == 0xfe){ + mdelay(100); + continue; } - break; - case RF90_PATH_B: - for(i = 0;i<RadioB_ArrayLength; i=i+2){ + rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioA_Array[i], bMask12Bits, rtl819XRadioA_Array[i+1]); + mdelay(1); - if(rtl819XRadioB_Array[i] == 0xfe){ - mdelay(100); - continue; - } - rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioB_Array[i], bMask12Bits, rtl819XRadioB_Array[i+1]); - mdelay(1); + } + break; + case RF90_PATH_B: + for(i = 0;i<RadioB_ArrayLength; i=i+2){ + if(rtl819XRadioB_Array[i] == 0xfe){ + mdelay(100); + continue; } - break; - case RF90_PATH_C: - for(i = 0;i<RadioC_ArrayLength; i=i+2){ + rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioB_Array[i], bMask12Bits, rtl819XRadioB_Array[i+1]); + mdelay(1); - if(rtl819XRadioC_Array[i] == 0xfe){ - mdelay(100); - continue; - } - rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioC_Array[i], bMask12Bits, rtl819XRadioC_Array[i+1]); - mdelay(1); + } + break; + case RF90_PATH_C: + for(i = 0;i<RadioC_ArrayLength; i=i+2){ + if(rtl819XRadioC_Array[i] == 0xfe){ + mdelay(100); + continue; } - break; - case RF90_PATH_D: - for(i = 0;i<RadioD_ArrayLength; i=i+2){ + rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioC_Array[i], bMask12Bits, rtl819XRadioC_Array[i+1]); + mdelay(1); - if(rtl819XRadioD_Array[i] == 0xfe){ - mdelay(100); - continue; - } - rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioD_Array[i], bMask12Bits, rtl819XRadioD_Array[i+1]); - mdelay(1); + } + break; + case RF90_PATH_D: + for(i = 0;i<RadioD_ArrayLength; i=i+2){ + if(rtl819XRadioD_Array[i] == 0xfe){ + mdelay(100); + continue; } - break; - default: - break; + rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioD_Array[i], bMask12Bits, rtl819XRadioD_Array[i+1]); + mdelay(1); + + } + break; + default: + break; } return ret; @@ -1015,7 +1015,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E /****************************************************************************** *function: This function set Tx Power of the channel * input: struct net_device *dev - * u8 channel + * u8 channel * output: none * return: none * Note: @@ -1052,7 +1052,7 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) /****************************************************************************** *function: This function set RF state on or off * input: struct net_device *dev - * RT_RF_POWER_STATE eRFPowerState //Power State to set + * RT_RF_POWER_STATE eRFPowerState //Power State to set * output: none * return: none * Note: @@ -1183,10 +1183,10 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerS /**************************************************************************************** *function: This function set command table variable(struct SwChnlCmd). - * input: SwChnlCmd* CmdTable //table to be set. - * u32 CmdTableIdx //variable index in table to be set - * u32 CmdTableSz //table size. - * SwChnlCmdID CmdID //command ID to set. + * input: SwChnlCmd* CmdTable //table to be set. + * u32 CmdTableIdx //variable index in table to be set + * u32 CmdTableSz //table size. + * SwChnlCmdID CmdID //command ID to set. * u32 Para1 * u32 Para2 * u32 msDelay @@ -1229,10 +1229,10 @@ u8 rtl8192_phy_SetSwChnlCmdArray( /****************************************************************************** *function: This function set channel step by step * input: struct net_device *dev - * u8 channel - * u8* stage //3 stages - * u8* step // - * u32* delay //whether need to delay + * u8 channel + * u8* stage //3 stages + * u8* step // + * u32* delay //whether need to delay * output: store new stage, step and delay for next step(combine with function above) * return: true if finished, false otherwise * Note: Wait for simpler function to replace it //wb @@ -1386,7 +1386,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u /****************************************************************************** *function: This function does actually set channel work * input: struct net_device *dev - * u8 channel + * u8 channel * output: none * return: noin * Note: We should not call this function directly @@ -1427,7 +1427,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) /****************************************************************************** *function: This function scheduled actual work item to set channel * input: net_device dev - * u8 channel //channel to set + * u8 channel //channel to set * output: none * return: return code show if workitem is scheduled(1:pass, 0:fail) * Note: Delay may be required for RF configuration @@ -1501,12 +1501,12 @@ if (0) //to test current channel from RF reg 0x7. /****************************************************************************** *function: Callback routine of the work item for set bandwidth mode. * input: struct net_device *dev - * HT_CHANNEL_WIDTH Bandwidth //20M or 40M - * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care + * HT_CHANNEL_WIDTH Bandwidth //20M or 40M + * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care * output: none * return: none * Note: I doubt whether SetBWModeInProgress flag is necessary as we can - * test whether current work in the queue or not.//do I? + * test whether current work in the queue or not.//do I? * ***************************************************************************/ void rtl8192_SetBWModeWorkItem(struct net_device *dev) { @@ -1649,12 +1649,12 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) /****************************************************************************** *function: This function schedules bandwidth switch work. * input: struct net_device *dev - * HT_CHANNEL_WIDTH Bandwidth //20M or 40M - * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care + * HT_CHANNEL_WIDTH Bandwidth //20M or 40M + * HT_EXTCHNL_OFFSET Offset //Upper, Lower, or Don't care * output: none * return: none * Note: I doubt whether SetBWModeInProgress flag is necessary as we can - * test whether current work in the queue or not.//do I? + * test whether current work in the queue or not.//do I? * ***************************************************************************/ void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset) { @@ -1770,4 +1770,3 @@ extern void InitialGainOperateWorkItemCallBack(struct work_struct *work) break; } } - diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index cca34c0..64285d6 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -6,185 +6,185 @@ //Register //duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF //page 1 -#define rPMAC_Reset 0x100 -#define rPMAC_TxStart 0x104 -#define rPMAC_TxLegacySIG 0x108 -#define rPMAC_TxHTSIG1 0x10c -#define rPMAC_TxHTSIG2 0x110 -#define rPMAC_PHYDebug 0x114 -#define rPMAC_TxPacketNum 0x118 -#define rPMAC_TxIdle 0x11c -#define rPMAC_TxMACHeader0 0x120 -#define rPMAC_TxMACHeader1 0x124 -#define rPMAC_TxMACHeader2 0x128 -#define rPMAC_TxMACHeader3 0x12c -#define rPMAC_TxMACHeader4 0x130 -#define rPMAC_TxMACHeader5 0x134 -#define rPMAC_TxDataType 0x138 -#define rPMAC_TxRandomSeed 0x13c -#define rPMAC_CCKPLCPPreamble 0x140 -#define rPMAC_CCKPLCPHeader 0x144 -#define rPMAC_CCKCRC16 0x148 -#define rPMAC_OFDMRxCRC32OK 0x170 -#define rPMAC_OFDMRxCRC32Er 0x174 -#define rPMAC_OFDMRxParityEr 0x178 -#define rPMAC_OFDMRxCRC8Er 0x17c -#define rPMAC_CCKCRxRC16Er 0x180 -#define rPMAC_CCKCRxRC32Er 0x184 -#define rPMAC_CCKCRxRC32OK 0x188 -#define rPMAC_TxStatus 0x18c +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c //page8 -#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC -#define rFPGA0_TxInfo 0x804 -#define rFPGA0_PSDFunction 0x808 -#define rFPGA0_TxGainStage 0x80c -#define rFPGA0_RFTiming1 0x810 -#define rFPGA0_RFTiming2 0x814 -//#define rFPGA0_XC_RFTiming 0x818 -//#define rFPGA0_XD_RFTiming 0x81c -#define rFPGA0_XA_HSSIParameter1 0x820 -#define rFPGA0_XA_HSSIParameter2 0x824 -#define rFPGA0_XB_HSSIParameter1 0x828 -#define rFPGA0_XB_HSSIParameter2 0x82c -#define rFPGA0_XC_HSSIParameter1 0x830 -#define rFPGA0_XC_HSSIParameter2 0x834 -#define rFPGA0_XD_HSSIParameter1 0x838 -#define rFPGA0_XD_HSSIParameter2 0x83c -#define rFPGA0_XA_LSSIParameter 0x840 -#define rFPGA0_XB_LSSIParameter 0x844 -#define rFPGA0_XC_LSSIParameter 0x848 -#define rFPGA0_XD_LSSIParameter 0x84c -#define rFPGA0_RFWakeUpParameter 0x850 -#define rFPGA0_RFSleepUpParameter 0x854 -#define rFPGA0_XAB_SwitchControl 0x858 -#define rFPGA0_XCD_SwitchControl 0x85c -#define rFPGA0_XA_RFInterfaceOE 0x860 -#define rFPGA0_XB_RFInterfaceOE 0x864 -#define rFPGA0_XC_RFInterfaceOE 0x868 -#define rFPGA0_XD_RFInterfaceOE 0x86c -#define rFPGA0_XAB_RFInterfaceSW 0x870 -#define rFPGA0_XCD_RFInterfaceSW 0x874 -#define rFPGA0_XAB_RFParameter 0x878 -#define rFPGA0_XCD_RFParameter 0x87c -#define rFPGA0_AnalogParameter1 0x880 -#define rFPGA0_AnalogParameter2 0x884 -#define rFPGA0_AnalogParameter3 0x888 -#define rFPGA0_AnalogParameter4 0x88c -#define rFPGA0_XA_LSSIReadBack 0x8a0 -#define rFPGA0_XB_LSSIReadBack 0x8a4 -#define rFPGA0_XC_LSSIReadBack 0x8a8 -#define rFPGA0_XD_LSSIReadBack 0x8ac -#define rFPGA0_PSDReport 0x8b4 -#define rFPGA0_XAB_RFInterfaceRB 0x8e0 -#define rFPGA0_XCD_RFInterfaceRB 0x8e4 +#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC +#define rFPGA0_TxInfo 0x804 +#define rFPGA0_PSDFunction 0x808 +#define rFPGA0_TxGainStage 0x80c +#define rFPGA0_RFTiming1 0x810 +#define rFPGA0_RFTiming2 0x814 +//#define rFPGA0_XC_RFTiming 0x818 +//#define rFPGA0_XD_RFTiming 0x81c +#define rFPGA0_XA_HSSIParameter1 0x820 +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c +#define rFPGA0_XC_HSSIParameter1 0x830 +#define rFPGA0_XC_HSSIParameter2 0x834 +#define rFPGA0_XD_HSSIParameter1 0x838 +#define rFPGA0_XD_HSSIParameter2 0x83c +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 +#define rFPGA0_XC_LSSIParameter 0x848 +#define rFPGA0_XD_LSSIParameter 0x84c +#define rFPGA0_RFWakeUpParameter 0x850 +#define rFPGA0_RFSleepUpParameter 0x854 +#define rFPGA0_XAB_SwitchControl 0x858 +#define rFPGA0_XCD_SwitchControl 0x85c +#define rFPGA0_XA_RFInterfaceOE 0x860 +#define rFPGA0_XB_RFInterfaceOE 0x864 +#define rFPGA0_XC_RFInterfaceOE 0x868 +#define rFPGA0_XD_RFInterfaceOE 0x86c +#define rFPGA0_XAB_RFInterfaceSW 0x870 +#define rFPGA0_XCD_RFInterfaceSW 0x874 +#define rFPGA0_XAB_RFParameter 0x878 +#define rFPGA0_XCD_RFParameter 0x87c +#define rFPGA0_AnalogParameter1 0x880 +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 +#define rFPGA0_AnalogParameter4 0x88c +#define rFPGA0_XA_LSSIReadBack 0x8a0 +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac +#define rFPGA0_PSDReport 0x8b4 +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 //page 9 -#define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC -#define rFPGA1_TxBlock 0x904 -#define rFPGA1_DebugSelect 0x908 -#define rFPGA1_TxInfo 0x90c +#define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC +#define rFPGA1_TxBlock 0x904 +#define rFPGA1_DebugSelect 0x908 +#define rFPGA1_TxInfo 0x90c //page a -#define rCCK0_System 0xa00 -#define rCCK0_AFESetting 0xa04 -#define rCCK0_CCA 0xa08 -#define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level -#define rCCK0_RxAGC2 0xa10 //AGC & DAGC -#define rCCK0_RxHP 0xa14 -#define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold -#define rCCK0_DSPParameter2 0xa1c //SQ threshold -#define rCCK0_TxFilter1 0xa20 -#define rCCK0_TxFilter2 0xa24 -#define rCCK0_DebugPort 0xa28 //debug port and Tx filter3 -#define rCCK0_FalseAlarmReport 0xa2c //0xa2d -#define rCCK0_TRSSIReport 0xa50 -#define rCCK0_RxReport 0xa54 //0xa57 -#define rCCK0_FACounterLower 0xa5c //0xa5b -#define rCCK0_FACounterUpper 0xa58 //0xa5c +#define rCCK0_System 0xa00 +#define rCCK0_AFESetting 0xa04 +#define rCCK0_CCA 0xa08 +#define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level +#define rCCK0_RxAGC2 0xa10 //AGC & DAGC +#define rCCK0_RxHP 0xa14 +#define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold +#define rCCK0_DSPParameter2 0xa1c //SQ threshold +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 //debug port and Tx filter3 +#define rCCK0_FalseAlarmReport 0xa2c //0xa2d +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 //0xa57 +#define rCCK0_FACounterLower 0xa5c //0xa5b +#define rCCK0_FACounterUpper 0xa58 //0xa5c //page c -#define rOFDM0_LSTF 0xc00 -#define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 -#define rOFDM0_TRSWIsolation 0xc0c -#define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter -#define rOFDM0_XARxIQImbalance 0xc14 //RxIQ imblance matrix -#define rOFDM0_XBRxAFE 0xc18 -#define rOFDM0_XBRxIQImbalance 0xc1c -#define rOFDM0_XCRxAFE 0xc20 -#define rOFDM0_XCRxIQImbalance 0xc24 -#define rOFDM0_XDRxAFE 0xc28 -#define rOFDM0_XDRxIQImbalance 0xc2c -#define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD -#define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync. -#define rOFDM0_RxDetector3 0xc38 //Frame Sync. -#define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI -#define rOFDM0_RxDSP 0xc40 //Rx Sync Path -#define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC -#define rOFDM0_CCADropThreshold 0xc48 //CCA Drop threshold -#define rOFDM0_ECCAThreshold 0xc4c // energy CCA -#define rOFDM0_XAAGCCore1 0xc50 -#define rOFDM0_XAAGCCore2 0xc54 -#define rOFDM0_XBAGCCore1 0xc58 -#define rOFDM0_XBAGCCore2 0xc5c -#define rOFDM0_XCAGCCore1 0xc60 -#define rOFDM0_XCAGCCore2 0xc64 -#define rOFDM0_XDAGCCore1 0xc68 -#define rOFDM0_XDAGCCore2 0xc6c -#define rOFDM0_AGCParameter1 0xc70 -#define rOFDM0_AGCParameter2 0xc74 -#define rOFDM0_AGCRSSITable 0xc78 -#define rOFDM0_HTSTFAGC 0xc7c -#define rOFDM0_XATxIQImbalance 0xc80 -#define rOFDM0_XATxAFE 0xc84 -#define rOFDM0_XBTxIQImbalance 0xc88 -#define rOFDM0_XBTxAFE 0xc8c -#define rOFDM0_XCTxIQImbalance 0xc90 -#define rOFDM0_XCTxAFE 0xc94 -#define rOFDM0_XDTxIQImbalance 0xc98 -#define rOFDM0_XDTxAFE 0xc9c -#define rOFDM0_RxHPParameter 0xce0 -#define rOFDM0_TxPseudoNoiseWgt 0xce4 -#define rOFDM0_FrameSync 0xcf0 -#define rOFDM0_DFSReport 0xcf4 -#define rOFDM0_TxCoeff1 0xca4 -#define rOFDM0_TxCoeff2 0xca8 -#define rOFDM0_TxCoeff3 0xcac -#define rOFDM0_TxCoeff4 0xcb0 -#define rOFDM0_TxCoeff5 0xcb4 -#define rOFDM0_TxCoeff6 0xcb8 +#define rOFDM0_LSTF 0xc00 +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c +#define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter +#define rOFDM0_XARxIQImbalance 0xc14 //RxIQ imblance matrix +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c +#define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD +#define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync. +#define rOFDM0_RxDetector3 0xc38 //Frame Sync. +#define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI +#define rOFDM0_RxDSP 0xc40 //Rx Sync Path +#define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC +#define rOFDM0_CCADropThreshold 0xc48 //CCA Drop threshold +#define rOFDM0_ECCAThreshold 0xc4c // energy CCA +#define rOFDM0_XAAGCCore1 0xc50 +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c +#define rOFDM0_XATxIQImbalance 0xc80 +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 //page d -#define rOFDM1_LSTF 0xd00 -#define rOFDM1_TRxPathEnable 0xd04 -#define rOFDM1_CFO 0xd08 -#define rOFDM1_CSI1 0xd10 -#define rOFDM1_SBD 0xd14 -#define rOFDM1_CSI2 0xd18 -#define rOFDM1_CFOTracking 0xd2c -#define rOFDM1_TRxMesaure1 0xd34 -#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 +#define rOFDM1_CFO 0xd08 +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c #define rOFDM1_PseudoNoiseStateAB 0xd50 #define rOFDM1_PseudoNoiseStateCD 0xd54 #define rOFDM1_RxPseudoNoiseWgt 0xd58 -#define rOFDM_PHYCounter1 0xda0 //cca, parity fail -#define rOFDM_PHYCounter2 0xda4 //rate illegal, crc8 fail -#define rOFDM_PHYCounter3 0xda8 //MCS not support -#define rOFDM_ShortCFOAB 0xdac -#define rOFDM_ShortCFOCD 0xdb0 -#define rOFDM_LongCFOAB 0xdb4 -#define rOFDM_LongCFOCD 0xdb8 -#define rOFDM_TailCFOAB 0xdbc -#define rOFDM_TailCFOCD 0xdc0 -#define rOFDM_PWMeasure1 0xdc4 -#define rOFDM_PWMeasure2 0xdc8 -#define rOFDM_BWReport 0xdcc -#define rOFDM_AGCReport 0xdd0 -#define rOFDM_RxSNR 0xdd4 -#define rOFDM_RxEVMCSI 0xdd8 -#define rOFDM_SIGReport 0xddc +#define rOFDM_PHYCounter1 0xda0 //cca, parity fail +#define rOFDM_PHYCounter2 0xda4 //rate illegal, crc8 fail +#define rOFDM_PHYCounter3 0xda8 //MCS not support +#define rOFDM_ShortCFOAB 0xdac +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc //page e #define rTxAGC_Rate18_06 0xe00 @@ -198,373 +198,373 @@ //RF //Zebra1 -#define rZebra1_HSSIEnable 0x0 -#define rZebra1_TRxEnable1 0x1 -#define rZebra1_TRxEnable2 0x2 -#define rZebra1_AGC 0x4 -#define rZebra1_ChargePump 0x5 -#define rZebra1_Channel 0x7 -#define rZebra1_TxGain 0x8 -#define rZebra1_TxLPF 0x9 -#define rZebra1_RxLPF 0xb -#define rZebra1_RxHPFCorner 0xc +#define rZebra1_HSSIEnable 0x0 +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +#define rZebra1_Channel 0x7 +#define rZebra1_TxGain 0x8 +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc //Zebra4 -#define rGlobalCtrl 0 -#define rRTL8256_TxLPF 19 -#define rRTL8256_RxLPF 11 +#define rGlobalCtrl 0 +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 //RTL8258 -#define rRTL8258_TxLPF 0x11 -#define rRTL8258_RxLPF 0x13 -#define rRTL8258_RSSILPF 0xa +#define rRTL8258_TxLPF 0x11 +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa //Bit Mask //page-1 -#define bBBResetB 0x100 -#define bGlobalResetB 0x200 -#define bOFDMTxStart 0x4 -#define bCCKTxStart 0x8 -#define bCRC32Debug 0x100 -#define bPMACLoopback 0x10 -#define bTxLSIG 0xffffff -#define bOFDMTxRate 0xf -#define bOFDMTxReserved 0x10 -#define bOFDMTxLength 0x1ffe0 -#define bOFDMTxParity 0x20000 -#define bTxHTSIG1 0xffffff -#define bTxHTMCSRate 0x7f -#define bTxHTBW 0x80 -#define bTxHTLength 0xffff00 -#define bTxHTSIG2 0xffffff -#define bTxHTSmoothing 0x1 -#define bTxHTSounding 0x2 -#define bTxHTReserved 0x4 -#define bTxHTAggreation 0x8 -#define bTxHTSTBC 0x30 -#define bTxHTAdvanceCoding 0x40 -#define bTxHTShortGI 0x80 -#define bTxHTNumberHT_LTF 0x300 -#define bTxHTCRC8 0x3fc00 -#define bCounterReset 0x10000 -#define bNumOfOFDMTx 0xffff -#define bNumOfCCKTx 0xffff0000 -#define bTxIdleInterval 0xffff -#define bOFDMService 0xffff0000 -#define bTxMACHeader 0xffffffff -#define bTxDataInit 0xff -#define bTxHTMode 0x100 -#define bTxDataType 0x30000 -#define bTxRandomSeed 0xffffffff -#define bCCKTxPreamble 0x1 -#define bCCKTxSFD 0xffff0000 -#define bCCKTxSIG 0xff -#define bCCKTxService 0xff00 -#define bCCKLengthExt 0x8000 -#define bCCKTxLength 0xffff0000 -#define bCCKTxCRC16 0xffff -#define bCCKTxStatus 0x1 -#define bOFDMTxStatus 0x2 +#define bBBResetB 0x100 +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 //page-8 -#define bRFMOD 0x1 -#define bJapanMode 0x2 -#define bCCKTxSC 0x30 -#define bCCKEn 0x1000000 -#define bOFDMEn 0x2000000 -#define bOFDMRxADCPhase 0x10000 -#define bOFDMTxDACPhase 0x40000 -#define bXATxAGC 0x3f -#define bXBTxAGC 0xf00 -#define bXCTxAGC 0xf000 -#define bXDTxAGC 0xf0000 -#define bPAStart 0xf0000000 -#define bTRStart 0x00f00000 -#define bRFStart 0x0000f000 -#define bBBStart 0x000000f0 -#define bBBCCKStart 0x0000000f -#define bPAEnd 0xf //Reg0x814 -#define bTREnd 0x0f000000 -#define bRFEnd 0x000f0000 -#define bCCAMask 0x000000f0 //T2R -#define bR2RCCAMask 0x00000f00 -#define bHSSI_R2TDelay 0xf8000000 -#define bHSSI_T2RDelay 0xf80000 -#define bContTxHSSI 0x400 //chane gain at continue Tx -#define bIGFromCCK 0x200 -#define bAGCAddress 0x3f -#define bRxHPTx 0x7000 -#define bRxHPT2R 0x38000 -#define bRxHPCCKIni 0xc0000 -#define bAGCTxCode 0xc00000 -#define bAGCRxCode 0x300000 -#define b3WireDataLength 0x800 -#define b3WireAddressLength 0x400 -#define b3WireRFPowerDown 0x1 -//#define bHWSISelect 0x8 -#define b5GPAPEPolarity 0x40000000 -#define b2GPAPEPolarity 0x80000000 -#define bRFSW_TxDefaultAnt 0x3 -#define bRFSW_TxOptionAnt 0x30 -#define bRFSW_RxDefaultAnt 0x300 -#define bRFSW_RxOptionAnt 0x3000 -#define bRFSI_3WireData 0x1 -#define bRFSI_3WireClock 0x2 -#define bRFSI_3WireLoad 0x4 -#define bRFSI_3WireRW 0x8 -#define bRFSI_3Wire 0xf //3-wire total control -#define bRFSI_RFENV 0x10 -#define bRFSI_TRSW 0x20 -#define bRFSI_TRSWB 0x40 -#define bRFSI_ANTSW 0x100 -#define bRFSI_ANTSWB 0x200 -#define bRFSI_PAPE 0x400 -#define bRFSI_PAPE5G 0x800 -#define bBandSelect 0x1 -#define bHTSIG2_GI 0x80 -#define bHTSIG2_Smoothing 0x01 -#define bHTSIG2_Sounding 0x02 -#define bHTSIG2_Aggreaton 0x08 -#define bHTSIG2_STBC 0x30 -#define bHTSIG2_AdvCoding 0x40 -#define bHTSIG2_NumOfHTLTF 0x300 -#define bHTSIG2_CRC8 0x3fc -#define bHTSIG1_MCS 0x7f -#define bHTSIG1_BandWidth 0x80 -#define bHTSIG1_HTLength 0xffff -#define bLSIG_Rate 0xf -#define bLSIG_Reserved 0x10 -#define bLSIG_Length 0x1fffe -#define bLSIG_Parity 0x20 -#define bCCKRxPhase 0x4 -#define bLSSIReadAddress 0x3f000000 //LSSI "Read" Address -#define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal -#define bLSSIReadBackData 0xfff -#define bLSSIReadOKFlag 0x1000 -#define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz - -#define bRegulator0Standby 0x1 -#define bRegulatorPLLStandby 0x2 -#define bRegulator1Standby 0x4 -#define bPLLPowerUp 0x8 -#define bDPLLPowerUp 0x10 -#define bDA10PowerUp 0x20 -#define bAD7PowerUp 0x200 -#define bDA6PowerUp 0x2000 -#define bXtalPowerUp 0x4000 -#define b40MDClkPowerUP 0x8000 -#define bDA6DebugMode 0x20000 -#define bDA6Swing 0x380000 -#define bADClkPhase 0x4000000 -#define b80MClkDelay 0x18000000 -#define bAFEWatchDogEnable 0x20000000 -#define bXtalCap 0x0f000000 -#define bIntDifClkEnable 0x400 -#define bExtSigClkEnable 0x800 -#define bBandgapMbiasPowerUp 0x10000 -#define bAD11SHGain 0xc0000 -#define bAD11InputRange 0x700000 -#define bAD11OPCurrent 0x3800000 -#define bIPathLoopback 0x4000000 -#define bQPathLoopback 0x8000000 -#define bAFELoopback 0x10000000 -#define bDA10Swing 0x7e0 -#define bDA10Reverse 0x800 -#define bDAClkSource 0x1000 -#define bAD7InputRange 0x6000 -#define bAD7Gain 0x38000 -#define bAD7OutputCMMode 0x40000 -#define bAD7InputCMMode 0x380000 -#define bAD7Current 0xc00000 -#define bRegulatorAdjust 0x7000000 -#define bAD11PowerUpAtTx 0x1 -#define bDA10PSAtTx 0x10 -#define bAD11PowerUpAtRx 0x100 -#define bDA10PSAtRx 0x1000 - -#define bCCKRxAGCFormat 0x200 - -#define bPSDFFTSamplepPoint 0xc000 -#define bPSDAverageNum 0x3000 -#define bIQPathControl 0xc00 -#define bPSDFreq 0x3ff -#define bPSDAntennaPath 0x30 -#define bPSDIQSwitch 0x40 -#define bPSDRxTrigger 0x400000 -#define bPSDTxTrigger 0x80000000 -#define bPSDSineToneScale 0x7f000000 -#define bPSDReport 0xffff +#define bRFMOD 0x1 +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 +#define bOFDMRxADCPhase 0x10000 +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f +#define bXBTxAGC 0xf00 +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 +#define bPAStart 0xf0000000 +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf //Reg0x814 +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 //T2R +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 //chane gain at continue Tx +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 +#define b3WireDataLength 0x800 +#define b3WireAddressLength 0x400 +#define b3WireRFPowerDown 0x1 +//#define bHWSISelect 0x8 +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf //3-wire total control +#define bRFSI_RFENV 0x10 +#define bRFSI_TRSW 0x20 +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 +#define bLSSIReadAddress 0x3f000000 //LSSI "Read" Address +#define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal +#define bLSSIReadBackData 0xfff +#define bLSSIReadOKFlag 0x1000 +#define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz + +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 +#define bADClkPhase 0x4000000 +#define b80MClkDelay 0x18000000 +#define bAFEWatchDogEnable 0x20000000 +#define bXtalCap 0x0f000000 +#define bIntDifClkEnable 0x400 +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 + +#define bCCKRxAGCFormat 0x200 + +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff //page-9 -#define bOFDMTxSC 0x30000000 -#define bCCKTxOn 0x1 -#define bOFDMTxOn 0x2 -#define bDebugPage 0xfff //reset debug page and also HWord, LWord -#define bDebugItem 0xff //reset debug page and LWord -#define bAntL 0x10 -#define bAntNonHT 0x100 -#define bAntHT1 0x1000 -#define bAntHT2 0x10000 -#define bAntHT1S1 0x100000 -#define bAntNonHTS1 0x1000000 +#define bOFDMTxSC 0x30000000 +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff //reset debug page and also HWord, LWord +#define bDebugItem 0xff //reset debug page and LWord +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 //page-a -#define bCCKBBMode 0x3 -#define bCCKTxPowerSaving 0x80 -#define bCCKRxPowerSaving 0x40 -#define bCCKSideBand 0x10 -#define bCCKScramble 0x8 -#define bCCKAntDiversity 0x8000 -#define bCCKCarrierRecovery 0x4000 -#define bCCKTxRate 0x3000 -#define bCCKDCCancel 0x0800 -#define bCCKISICancel 0x0400 -#define bCCKMatchFilter 0x0200 -#define bCCKEqualizer 0x0100 -#define bCCKPreambleDetect 0x800000 -#define bCCKFastFalseCCA 0x400000 -#define bCCKChEstStart 0x300000 -#define bCCKCCACount 0x080000 -#define bCCKcs_lim 0x070000 -#define bCCKBistMode 0x80000000 -#define bCCKCCAMask 0x40000000 -#define bCCKTxDACPhase 0x4 -#define bCCKRxADCPhase 0x20000000 //r_rx_clk -#define bCCKr_cp_mode0 0x0100 -#define bCCKTxDCOffset 0xf0 -#define bCCKRxDCOffset 0xf -#define bCCKCCAMode 0xc000 -#define bCCKFalseCS_lim 0x3f00 -#define bCCKCS_ratio 0xc00000 -#define bCCKCorgBit_sel 0x300000 -#define bCCKPD_lim 0x0f0000 -#define bCCKNewCCA 0x80000000 -#define bCCKRxHPofIG 0x8000 -#define bCCKRxIG 0x7f00 -#define bCCKLNAPolarity 0x800000 -#define bCCKRx1stGain 0x7f0000 -#define bCCKRFExtend 0x20000000 //CCK Rx initial gain polarity -#define bCCKRxAGCSatLevel 0x1f000000 -#define bCCKRxAGCSatCount 0xe0 -#define bCCKRxRFSettle 0x1f //AGCsamp_dly -#define bCCKFixedRxAGC 0x8000 -//#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824 -#define bCCKAntennaPolarity 0x2000 -#define bCCKTxFilterType 0x0c00 -#define bCCKRxAGCReportType 0x0300 -#define bCCKRxDAGCEn 0x80000000 -#define bCCKRxDAGCPeriod 0x20000000 -#define bCCKRxDAGCSatLevel 0x1f000000 -#define bCCKTimingRecovery 0x800000 -#define bCCKTxC0 0x3f0000 -#define bCCKTxC1 0x3f000000 -#define bCCKTxC2 0x3f -#define bCCKTxC3 0x3f00 -#define bCCKTxC4 0x3f0000 -#define bCCKTxC5 0x3f000000 -#define bCCKTxC6 0x3f -#define bCCKTxC7 0x3f00 -#define bCCKDebugPort 0xff0000 -#define bCCKDACDebug 0x0f000000 -#define bCCKFalseAlarmEnable 0x8000 -#define bCCKFalseAlarmRead 0x4000 -#define bCCKTRSSI 0x7f -#define bCCKRxAGCReport 0xfe -#define bCCKRxReport_AntSel 0x80000000 -#define bCCKRxReport_MFOff 0x40000000 -#define bCCKRxRxReport_SQLoss 0x20000000 -#define bCCKRxReport_Pktloss 0x10000000 -#define bCCKRxReport_Lockedbit 0x08000000 -#define bCCKRxReport_RateError 0x04000000 -#define bCCKRxReport_RxRate 0x03000000 -#define bCCKRxFACounterLower 0xff -#define bCCKRxFACounterUpper 0xff000000 -#define bCCKRxHPAGCStart 0xe000 -#define bCCKRxHPAGCFinal 0x1c00 - -#define bCCKRxFalseAlarmEnable 0x8000 -#define bCCKFACounterFreeze 0x4000 - -#define bCCKTxPathSel 0x10000000 -#define bCCKDefaultRxPath 0xc000000 -#define bCCKOptionRxPath 0x3000000 +#define bCCKBBMode 0x3 +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 +#define bCCKSideBand 0x10 +#define bCCKScramble 0x8 +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 //r_rx_clk +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 //CCK Rx initial gain polarity +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f //AGCsamp_dly +#define bCCKFixedRxAGC 0x8000 +//#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 + +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 + +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 //page c -#define bNumOfSTF 0x3 -#define bShift_L 0xc0 -#define bGI_TH 0xc -#define bRxPathA 0x1 -#define bRxPathB 0x2 -#define bRxPathC 0x4 -#define bRxPathD 0x8 -#define bTxPathA 0x1 -#define bTxPathB 0x2 -#define bTxPathC 0x4 -#define bTxPathD 0x8 -#define bTRSSIFreq 0x200 -#define bADCBackoff 0x3000 -#define bDFIRBackoff 0xc000 -#define bTRSSILatchPhase 0x10000 -#define bRxIDCOffset 0xff -#define bRxQDCOffset 0xff00 -#define bRxDFIRMode 0x1800000 -#define bRxDCNFType 0xe000000 -#define bRXIQImb_A 0x3ff -#define bRXIQImb_B 0xfc00 -#define bRXIQImb_C 0x3f0000 -#define bRXIQImb_D 0xffc00000 -#define bDC_dc_Notch 0x60000 -#define bRxNBINotch 0x1f000000 -#define bPD_TH 0xf -#define bPD_TH_Opt2 0xc000 -#define bPWED_TH 0x700 -#define bIfMF_Win_L 0x800 -#define bPD_Option 0x1000 -#define bMF_Win_L 0xe000 -#define bBW_Search_L 0x30000 -#define bwin_enh_L 0xc0000 -#define bBW_TH 0x700000 -#define bED_TH2 0x3800000 -#define bBW_option 0x4000000 -#define bRatio_TH 0x18000000 -#define bWindow_L 0xe0000000 -#define bSBD_Option 0x1 -#define bFrame_TH 0x1c -#define bFS_Option 0x60 -#define bDC_Slope_check 0x80 -#define bFGuard_Counter_DC_L 0xe00 -#define bFrame_Weight_Short 0x7000 -#define bSub_Tune 0xe00000 -#define bFrame_DC_Length 0xe000000 -#define bSBD_start_offset 0x30000000 -#define bFrame_TH_2 0x7 -#define bFrame_GI2_TH 0x38 -#define bGI2_Sync_en 0x40 -#define bSarch_Short_Early 0x300 -#define bSarch_Short_Late 0xc00 -#define bSarch_GI2_Late 0x70000 -#define bCFOAntSum 0x1 -#define bCFOAcc 0x2 -#define bCFOStartOffset 0xc -#define bCFOLookBack 0x70 -#define bCFOSumWeight 0x80 -#define bDAGCEnable 0x10000 -#define bTXIQImb_A 0x3ff -#define bTXIQImb_B 0xfc00 -#define bTXIQImb_C 0x3f0000 -#define bTXIQImb_D 0xffc00000 -#define bTxIDCOffset 0xff -#define bTxQDCOffset 0xff00 -#define bTxDFIRMode 0x10000 -#define bTxPesudoNoiseOn 0x4000000 -#define bTxPesudoNoise_A 0xff -#define bTxPesudoNoise_B 0xff00 -#define bTxPesudoNoise_C 0xff0000 -#define bTxPesudoNoise_D 0xff000000 -#define bCCADropOption 0x20000 -#define bCCADropThres 0xfff00000 -#define bEDCCA_H 0xf -#define bEDCCA_L 0xf0 +#define bNumOfSTF 0x3 +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 #define bLambda_ED 0x300 #define bRxInitialGain 0x7f #define bRxAntDivEn 0x80 @@ -862,10 +862,10 @@ #define PathD 0x3 #define rRTL8256RxMixerPole 0xb -#define bZebraRxMixerPole 0x6 -#define rRTL8256TxBBOPBias 0x9 -#define bRTL8256TxBBOPBias 0x400 -#define rRTL8256TxBBBW 19 -#define bRTL8256TxBBBW 0x18 +#define bZebraRxMixerPole 0x6 +#define rRTL8256TxBBOPBias 0x9 +#define bRTL8256TxBBOPBias 0x400 +#define rRTL8256TxBBBW 19 +#define bRTL8256TxBBBW 0x18 #endif //__INC_HAL8190PCIPHYREG_H diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h index 9095420..fad173f 100644 --- a/drivers/staging/rtl8712/ethernet.h +++ b/drivers/staging/rtl8712/ethernet.h @@ -26,15 +26,8 @@ #ifndef __INC_ETHERNET_H #define __INC_ETHERNET_H -#define ETHERNET_ADDRESS_LENGTH 6 /*!< Ethernet Address Length*/ #define ETHERNET_HEADER_SIZE 14 /*!< Ethernet Header Length*/ #define LLC_HEADER_SIZE 6 /*!< LLC Header Length*/ -#define TYPE_LENGTH_FIELD_SIZE 2 /*!< Type/Length Size*/ -#define MINIMUM_ETHERNET_PACKET_SIZE 60 /*!< Min Ethernet Packet Size*/ -#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /*!< Max Ethernet Packet Size*/ - -/*!< Is Multicast Address? */ -#define RT_ETH_IS_MULTICAST(_pAddr) ((((u8 *)(_pAddr))[0]&0x01) != 0) #endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index cb9d4cf..d801c5a 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -49,7 +49,7 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) if (!firmware) { struct usb_device *udev = padapter->dvobjpriv.pusbdev; struct usb_interface *pusb_intf = padapter->pusb_intf; - printk(KERN_ERR "r8712u: Firmware request failed\n"); + dev_err(&udev->dev, "r8712u: Firmware request failed\n"); padapter->fw_found = false; usb_put_dev(udev); usb_set_intfdata(pusb_intf, NULL); @@ -69,12 +69,11 @@ int rtl871x_load_fw(struct _adapter *padapter) int rc; init_completion(&padapter->rtl8712_fw_ready); - printk(KERN_INFO "r8712u: Loading firmware from \"%s\"\n", - firmware_file); + dev_info(dev, "r8712u: Loading firmware from \"%s\"\n", firmware_file); rc = request_firmware_nowait(THIS_MODULE, 1, firmware_file, dev, GFP_KERNEL, padapter, rtl871x_load_fw_cb); if (rc) - printk(KERN_ERR "r8712u: Firmware request error %d\n", rc); + dev_err(dev, "r8712u: Firmware request error %d\n", rc); return rc; } MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); @@ -84,8 +83,8 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw) const struct firmware **praw = &padapter->fw; if (padapter->fw->size > 200000) { - printk(KERN_ERR "r8172u: Badfw->size of %d\n", - (int)padapter->fw->size); + dev_err(&padapter->pnetdev->dev, "r8172u: Badfw->size of %d\n", + (int)padapter->fw->size); return 0; } *ppmappedfw = (u8 *)((*praw)->data); @@ -334,11 +333,13 @@ uint rtl8712_hal_init(struct _adapter *padapter) if (rtl8712_dl_fw(padapter) != _SUCCESS) return _FAIL; - printk(KERN_INFO "r8712u: 1 RCR=0x%x\n", r8712_read32(padapter, RCR)); + netdev_info(padapter->pnetdev, "1 RCR=0x%x\n", + r8712_read32(padapter, RCR)); val32 = r8712_read32(padapter, RCR); r8712_write32(padapter, RCR, (val32 | BIT(26))); /* Enable RX TCP Checksum offload */ - printk(KERN_INFO "r8712u: 2 RCR=0x%x\n", r8712_read32(padapter, RCR)); + netdev_info(padapter->pnetdev, "2 RCR=0x%x\n", + r8712_read32(padapter, RCR)); val32 = r8712_read32(padapter, RCR); r8712_write32(padapter, RCR, (val32|BIT(25))); /* Append PHY status */ val32 = 0; diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index 21515c3..da4000e 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -777,7 +777,7 @@ extern inline int ieee80211_get_hdrlen(u16 fc) struct registry_priv; u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen); -u8 *r8712_get_ie(u8*pbuf, sint index, sint *len, sint limit); +u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit); unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit); unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index 7279854..f569a70 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -106,8 +106,6 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter) * disconnect with AP for 60 seconds. */ - memset(&backupPMKIDList[0], 0x00, sizeof( - struct RT_PMKID_LIST) * NUM_PMKID_CACHE); memcpy(&backupPMKIDList[0], &adapter->securitypriv. PMKIDList[0], sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE); diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index e00f791..b65bf5e 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -224,8 +224,7 @@ struct net_device *r8712_init_netdev(void) } padapter = (struct _adapter *) netdev_priv(pnetdev); padapter->pnetdev = pnetdev; - printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to" - " netdev_ops\n"); + pr_info("r8712u: register rtl8712_netdev_ops to netdev_ops\n"); pnetdev->netdev_ops = &rtl8712_netdev_ops; pnetdev->watchdog_timeo = HZ; /* 1 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *) diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index c76732c..d59a74a 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -115,11 +115,11 @@ void r8712_free_recv_priv(struct recv_priv *precvpriv) kfree(precvpriv->pallocated_recv_buf); skb_queue_purge(&precvpriv->rx_skb_queue); if (skb_queue_len(&precvpriv->rx_skb_queue)) - printk(KERN_WARNING "r8712u: rx_skb_queue not empty\n"); + netdev_warn(padapter->pnetdev, "r8712u: rx_skb_queue not empty\n"); skb_queue_purge(&precvpriv->free_recv_skb_queue); if (skb_queue_len(&precvpriv->free_recv_skb_queue)) - printk(KERN_WARNING "r8712u: free_recv_skb_queue not empty " - "%d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); + netdev_warn(padapter->pnetdev, "r8712u: free_recv_skb_queue not empty %d\n", + skb_queue_len(&precvpriv->free_recv_skb_queue)); } int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf) @@ -364,9 +364,8 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) nSubframe_Length = (nSubframe_Length >> 8) + (nSubframe_Length << 8); if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { - printk(KERN_WARNING "r8712u: nRemain_Length is %d and" - " nSubframe_Length is: %d\n", - a_len, nSubframe_Length); + netdev_warn(padapter->pnetdev, "r8712u: nRemain_Length is %d and nSubframe_Length is: %d\n", + a_len, nSubframe_Length); goto exit; } /* move the data point to data content */ @@ -381,8 +380,7 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) memcpy(data_ptr, pdata, nSubframe_Length); subframes[nr_subframes++] = sub_skb; if (nr_subframes >= MAX_SUBFRAME_COUNT) { - printk(KERN_WARNING "r8712u: ParseSubframe(): Too" - " many Subframes! Packets dropped!\n"); + netdev_warn(padapter->pnetdev, "r8712u: ParseSubframe(): Too many Subframes! Packets dropped!\n"); break; } pdata += nSubframe_Length; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 31f31dbf..f16307f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -525,7 +525,6 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) kfree(pcmd); return _FAIL; } - memset(psecnetwork, 0, t_len); memcpy(psecnetwork, &pnetwork->network, t_len); auth = &psecuritypriv->authenticator_ie[0]; psecuritypriv->authenticator_ie[0] = (unsigned char) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 9d93189..0ce79b1 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -749,7 +749,7 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter, u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset); -u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval); +u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); u8 r8712_setrttbl_cmd(struct _adapter *padapter, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 3a64790..f034567 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -188,8 +188,7 @@ static inline char *translate_scan(struct _adapter *padapter, /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - iwe.u.data.length = (u16)min((u16)pnetwork->network.Ssid.SsidLength, - (u16)32); + iwe.u.data.length = min_t(u32, pnetwork->network.Ssid.SsidLength, 32); start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); /* parsing HT_CAP_IE */ @@ -415,8 +414,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, } else return -EINVAL; if (strcmp(param->u.crypt.alg, "WEP") == 0) { - printk(KERN_INFO "r8712u: wpa_set_encryption, crypt.alg =" - " WEP\n"); + netdev_info(dev, "r8712u: %s: crypt.alg = WEP\n", __func__); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.PrivacyAlgrthm = _WEP40_; @@ -608,8 +606,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { - printk(KERN_INFO "r8712u: " - "SET WPS_IE\n"); + netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE\n"); padapter->securitypriv.wps_ie_len = ((buf[cnt+1] + 2) < (MAX_WPA_IE_LEN << 2)) ? @@ -620,8 +617,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, padapter->securitypriv.wps_ie_len); padapter->securitypriv.wps_phase = true; - printk(KERN_INFO "r8712u: SET WPS_IE," - " wps_phase==true\n"); + netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n"); cnt += buf[cnt+1]+2; break; } else @@ -829,8 +825,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev, strIssueBssid, ETH_ALEN)) { /* BSSID is matched, the same AP => rewrite * with new PMKID. */ - printk(KERN_INFO "r8712u: r871x_wx_set_pmkid:" - " BSSID exists in the PMKList.\n"); + netdev_info(dev, "r8712u: %s: BSSID exists in the PMKList.\n", + __func__); memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); psecuritypriv->PMKIDList[j].bUsed = true; @@ -841,9 +837,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev, } if (!blInserted) { /* Find a new entry */ - printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: Use the" - " new entry index = %d for this PMKID.\n", - psecuritypriv->PMKIDIndex); + netdev_info(dev, "r8712u: %s: Use the new entry index = %d for this PMKID.\n", + __func__, psecuritypriv->PMKIDIndex); memcpy(psecuritypriv->PMKIDList[psecuritypriv-> PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); memcpy(psecuritypriv->PMKIDList[psecuritypriv-> @@ -876,8 +871,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev, intReturn = true; break; default: - printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: " - "unknown Command\n"); + netdev_info(dev, "r8712u: %s: unknown Command\n", __func__); intReturn = false; break; } @@ -1045,8 +1039,8 @@ static int r871x_wx_set_priv(struct net_device *dev, ); sprintf(ext, "OK"); } else { - printk(KERN_INFO "r8712u: r871x_wx_set_priv: unknown Command" - " %s.\n", ext); + netdev_info(dev, "r8712u: %s: unknown Command %s.\n", + __func__, ext); goto FREE_EXT; } if (copy_to_user(dwrq->pointer, ext, @@ -1131,11 +1125,11 @@ static int r8711_wx_get_wap(struct net_device *dev, struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; wrqu->ap_addr.sa_family = ARPHRD_ETHER; - memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - if (check_fwstate(pmlmepriv, _FW_LINKED | - WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE | + WIFI_AP_STATE)) memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); - } + else + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); return 0; } @@ -1183,8 +1177,8 @@ static int r8711_wx_set_scan(struct net_device *dev, u8 status = true; if (padapter->bDriverStopped == true) { - printk(KERN_WARNING "r8712u: in r8711_wx_set_scan: " - "bDriverStopped=%d\n", padapter->bDriverStopped); + netdev_info(dev, "In %s: bDriverStopped=%d\n", + __func__, padapter->bDriverStopped); return -1; } if (padapter->bup == false) @@ -1199,8 +1193,7 @@ static int r8711_wx_set_scan(struct net_device *dev, if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { struct ndis_802_11_ssid ssid; unsigned long irqL; - u32 len = (u32) min((u8)req->essid_len, - (u8)IW_ESSID_MAX_SIZE); + u32 len = min_t(u8, req->essid_len, IW_ESSID_MAX_SIZE); memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(ssid.Ssid, req->essid, len); @@ -1556,8 +1549,7 @@ static int r8711_wx_set_enc(struct net_device *dev, key = erq->flags & IW_ENCODE_INDEX; memset(&wep, 0, sizeof(struct NDIS_802_11_WEP)); if (erq->flags & IW_ENCODE_DISABLED) { - printk(KERN_INFO "r8712u: r8711_wx_set_enc: " - "EncryptionDisabled\n"); + netdev_info(dev, "r8712u: %s: EncryptionDisabled\n", __func__); padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; padapter->securitypriv.PrivacyAlgrthm = _NO_PRIVACY_; @@ -1578,8 +1570,7 @@ static int r8711_wx_set_enc(struct net_device *dev, } /* set authentication mode */ if (erq->flags & IW_ENCODE_OPEN) { - printk(KERN_INFO "r8712u: r8711_wx_set_enc: " - "IW_ENCODE_OPEN\n"); + netdev_info(dev, "r8712u: %s: IW_ENCODE_OPEN\n", __func__); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.AuthAlgrthm = 0; /* open system */ @@ -1588,8 +1579,7 @@ static int r8711_wx_set_enc(struct net_device *dev, authmode = Ndis802_11AuthModeOpen; padapter->securitypriv.ndisauthtype = authmode; } else if (erq->flags & IW_ENCODE_RESTRICTED) { - printk(KERN_INFO "r8712u: r8711_wx_set_enc: " - "IW_ENCODE_RESTRICTED\n"); + netdev_info(dev, "r8712u: %s: IW_ENCODE_RESTRICTED\n", __func__); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.AuthAlgrthm = 1; /* shared system */ @@ -1977,9 +1967,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev, status = phandler->handler(&oid_par); /* todo:check status, BytesNeeded, etc. */ } else { - printk(KERN_INFO "r8712u: r871x_mp_ioctl_hdl(): err!," - " subcode=%d, oid=%d, handler=%p\n", - poidparam->subcode, phandler->oid, phandler->handler); + netdev_info(dev, "r8712u: %s: err!, subcode=%d, oid=%d, handler=%p\n", + __func__, poidparam->subcode, phandler->oid, + phandler->handler); ret = -EFAULT; goto _r871x_mp_ioctl_hdl_exit; } @@ -2034,13 +2024,13 @@ static int r871x_get_ap_info(struct net_device *dev, break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); if (hwaddr_aton_i(data, bssid)) { - printk(KERN_INFO "r8712u: Invalid BSSID '%s'.\n", - (u8 *)data); + netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n", + (u8 *)data); spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock), - irqL); + irqL); return -EINVAL; } - printk(KERN_INFO "r8712u: BSSID:%pM\n", bssid); + netdev_info(dev, "r8712u: BSSID:%pM\n", bssid); if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */ pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12], diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c index 9a33eae..5d6d55e 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c @@ -28,6 +28,7 @@ #define _RTL871X_IOCTL_RTL_C_ +#include <linux/rndis.h> #include "osdep_service.h" #include "drv_types.h" #include "wlan_bssdef.h" @@ -42,8 +43,8 @@ uint oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv) @@ -52,14 +53,14 @@ uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_smallpacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv) @@ -68,14 +69,14 @@ uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_middlepacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv) @@ -84,29 +85,29 @@ uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_largepacket_crcerr; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv) @@ -115,29 +116,29 @@ uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_pkts + padapter->recvpriv.rx_drop; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv) @@ -146,22 +147,22 @@ uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(uint *)poid_par_priv->information_buf = padapter->recvpriv.rx_icv_err; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH ; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH ; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv) @@ -171,7 +172,7 @@ uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv) u32 preamblemode = 0 ; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { if (padapter->registrypriv.preamble == PREAMBLE_LONG) preamblemode = 0; @@ -182,15 +183,15 @@ uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = preamblemode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv) @@ -200,10 +201,10 @@ uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv) struct eeprom_priv *peeprompriv = &padapter->eeprompriv; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; *(u16 *)poid_par_priv->information_buf = peeprompriv->channel_plan; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_channelplan_hdl(struct oid_par_priv @@ -214,9 +215,9 @@ uint oid_rt_set_channelplan_hdl(struct oid_par_priv struct eeprom_priv *peeprompriv = &padapter->eeprompriv; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; peeprompriv->channel_plan = *(u16 *)poid_par_priv->information_buf; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv @@ -227,7 +228,7 @@ uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv u32 preamblemode = 0; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { preamblemode = *(u32 *)poid_par_priv->information_buf; if (preamblemode == 0) @@ -239,21 +240,21 @@ uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv *(u32 *)poid_par_priv->information_buf = preamblemode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_dedicate_probe_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv @@ -263,14 +264,14 @@ uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->xmitpriv.tx_bytes; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv @@ -280,37 +281,37 @@ uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = padapter->recvpriv.rx_bytes; *poid_par_priv->bytes_rw = poid_par_priv-> information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_current_tx_power_level_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv) @@ -322,7 +323,7 @@ uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv) u32 channelnum; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) pnic_Config = &pmlmepriv->cur_network.network.Configuration; @@ -332,22 +333,22 @@ uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv) channelnum = pnic_Config->DSConfig; *(u32 *)poid_par_priv->information_buf = channelnum; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv @@ -356,7 +357,7 @@ uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv u32 ulInfo = 0; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len >= sizeof(u32)) { ulInfo |= 0x0100; /* WIRELESS_MODE_B */ ulInfo |= 0x0200; /* WIRELESS_MODE_G */ @@ -364,108 +365,108 @@ uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv *(u32 *) poid_par_priv->information_buf = ulInfo; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - return NDIS_STATUS_INVALID_LENGTH; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv* poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv* poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */ - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len == (sizeof(unsigned long) * 3)) { if (!r8712_setrfreg_cmd(Adapter, *(unsigned char *)poid_par_priv->information_buf, (unsigned long)(*((unsigned long *) poid_par_priv->information_buf + 2)))) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */ - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) { if (Adapter->mppriv.act_in_progress == true) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; else { /* init workparam */ Adapter->mppriv.act_in_progress = true; @@ -486,10 +487,10 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv) *(unsigned char *)poid_par_priv->information_buf, (unsigned char *)&Adapter->mppriv.workparam. io_value)) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; } } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } @@ -508,7 +509,7 @@ uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv) u32 ulInfo; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; /* nStatus==0 CheckingStatus * nStatus==1 Associated * nStatus==2 AdHocMode @@ -524,12 +525,12 @@ uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv) ulInfo = NOTASSOCIATED ; *(u32 *)poid_par_priv->information_buf = ulInfo; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index d3ab24e..53a7c8c 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -97,8 +97,6 @@ static u8 do_join(struct _adapter *padapter) pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; pibss = padapter->registrypriv.dev_network. MacAddress; - memset(&pdev_network->Ssid, 0, - sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index c51ad9e..6596154 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -604,9 +604,6 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) adapter->registrypriv. dev_network.MacAddress; pmlmepriv->fw_state ^= _FW_UNDER_SURVEY; - memset(&pdev_network->Ssid, 0, - sizeof(struct - ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct @@ -1006,8 +1003,6 @@ void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf) memcpy(pdev_network, &tgt_network->network, r8712_get_ndis_wlan_bssid_ex_sz(&tgt_network-> network)); - memset(&pdev_network->Ssid, 0, - sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); @@ -1048,8 +1043,8 @@ void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf) struct sta_priv *pstapriv = &adapter->stapriv; struct recv_reorder_ctrl *precvreorder_ctrl = NULL; - printk(KERN_INFO "r8712u: [%s] mac = %pM, seq = %d, tid = %d\n", - __func__, pAddbareq_pram->MacAddress, + netdev_info(adapter->pnetdev, "%s: mac = %pM, seq = %d, tid = %d\n", + __func__, pAddbareq_pram->MacAddress, pAddbareq_pram->StartSeqNum, pAddbareq_pram->tid); psta = r8712_get_stainfo(pstapriv, pAddbareq_pram->MacAddress); if (psta) { diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h index 255dc94..51395d1 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.h +++ b/drivers/staging/rtl8712/rtl871x_mp.h @@ -26,62 +26,6 @@ #ifndef __RTL871X_MP_H_ #define __RTL871X_MP_H_ -/* 00 - Success */ -/* 11 - Error */ -#define STATUS_SUCCESS (0x00000000L) -#define STATUS_PENDING (0x00000103L) -#define STATUS_UNSUCCESSFUL (0xC0000001L) -#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL) -#define STATUS_NOT_SUPPORTED (0xC00000BBL) -#define NDIS_STATUS_SUCCESS ((uint)STATUS_SUCCESS) -#define NDIS_STATUS_PENDING ((uint) STATUS_PENDING) -#define NDIS_STATUS_NOT_RECOGNIZED ((uint)0x00010001L) -#define NDIS_STATUS_NOT_COPIED ((uint)0x00010002L) -#define NDIS_STATUS_NOT_ACCEPTED ((uint)0x00010003L) -#define NDIS_STATUS_CALL_ACTIVE ((uint)0x00010007L) -#define NDIS_STATUS_FAILURE ((uint) STATUS_UNSUCCESSFUL) -#define NDIS_STATUS_RESOURCES ((uint)\ - STATUS_INSUFFICIENT_RESOURCES) -#define NDIS_STATUS_CLOSING ((uint)0xC0010002L) -#define NDIS_STATUS_BAD_VERSION ((uint)0xC0010004L) -#define NDIS_STATUS_BAD_CHARACTERISTICS ((uint)0xC0010005L) -#define NDIS_STATUS_ADAPTER_NOT_FOUND ((uint)0xC0010006L) -#define NDIS_STATUS_OPEN_FAILED ((uint)0xC0010007L) -#define NDIS_STATUS_DEVICE_FAILED ((uint)0xC0010008L) -#define NDIS_STATUS_MULTICAST_FULL ((uint)0xC0010009L) -#define NDIS_STATUS_MULTICAST_EXISTS ((uint)0xC001000AL) -#define NDIS_STATUS_MULTICAST_NOT_FOUND ((uint)0xC001000BL) -#define NDIS_STATUS_REQUEST_ABORTED ((uint)0xC001000CL) -#define NDIS_STATUS_RESET_IN_PROGRESS ((uint)0xC001000DL) -#define NDIS_STATUS_CLOSING_INDICATING ((uint)0xC001000EL) -#define NDIS_STATUS_NOT_SUPPORTED ((uint)STATUS_NOT_SUPPORTED) -#define NDIS_STATUS_INVALID_PACKET ((uint)0xC001000FL) -#define NDIS_STATUS_OPEN_LIST_FULL ((uint)0xC0010010L) -#define NDIS_STATUS_ADAPTER_NOT_READY ((uint)0xC0010011L) -#define NDIS_STATUS_ADAPTER_NOT_OPEN ((uint)0xC0010012L) -#define NDIS_STATUS_NOT_INDICATING ((uint)0xC0010013L) -#define NDIS_STATUS_INVALID_LENGTH ((uint)0xC0010014L) -#define NDIS_STATUS_INVALID_DATA ((uint)0xC0010015L) -#define NDIS_STATUS_BUFFER_TOO_SHORT ((uint)0xC0010016L) -#define NDIS_STATUS_INVALID_OID ((uint)0xC0010017L) -#define NDIS_STATUS_ADAPTER_REMOVED ((uint)0xC0010018L) -#define NDIS_STATUS_UNSUPPORTED_MEDIA ((uint)0xC0010019L) -#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((uint)0xC001001AL) -#define NDIS_STATUS_FILE_NOT_FOUND ((uint)0xC001001BL) -#define NDIS_STATUS_ERROR_READING_FILE ((uint)0xC001001CL) -#define NDIS_STATUS_ALREADY_MAPPED ((uint)0xC001001DL) -#define NDIS_STATUS_RESOURCE_CONFLICT ((uint)0xC001001EL) -#define NDIS_STATUS_NO_CABLE ((uint)0xC001001FL) -#define NDIS_STATUS_INVALID_SAP ((uint)0xC0010020L) -#define NDIS_STATUS_SAP_IN_USE ((uint)0xC0010021L) -#define NDIS_STATUS_INVALID_ADDRESS ((uint)0xC0010022L) -#define NDIS_STATUS_VC_NOT_ACTIVATED ((uint)0xC0010023L) -#define NDIS_STATUS_DEST_OUT_OF_ORDER ((uint)0xC0010024L) /* cause 27*/ -#define NDIS_STATUS_VC_NOT_AVAILABLE ((uint)0xC0010025L) /* 35,45*/ -#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((uint)0xC0010026L) /* 37*/ -#define NDIS_STATUS_INCOMPATABLE_QOS ((uint)0xC0010027L) /* 49*/ -#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((uint)0xC0010028L) /* 93*/ -#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((uint)0xC0010029L) /* 3*/ #define MPT_NOOP 0 #define MPT_READ_MAC_1BYTE 1 #define MPT_READ_MAC_2BYTE 2 diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 5eb461b..5bd4296 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -26,6 +26,7 @@ * ******************************************************************************/ +#include <linux/rndis.h> #include "osdep_service.h" #include "drv_types.h" #include "mlme_osdep.h" @@ -34,12 +35,12 @@ uint oid_null_function(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -48,7 +49,7 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) Adapter->registrypriv.wireless_mode = *(u8 *)poid_par_priv->information_buf; else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; } else if (poid_par_priv->type_of_oid == QUERY_OID) { if (poid_par_priv->information_buf_len >= sizeof(u8)) { *(u8 *)poid_par_priv->information_buf = @@ -56,16 +57,16 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; } else { - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; } return status; } uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct bb_reg_param *pbbreg; @@ -73,9 +74,9 @@ uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) u32 value; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/ if (offset < BB_REG_BASE_ADDR) @@ -87,7 +88,7 @@ uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct bb_reg_param *pbbreg; @@ -95,9 +96,9 @@ uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) u32 value; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/ if (offset < BB_REG_BASE_ADDR) @@ -110,7 +111,7 @@ uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct rf_reg_param *pbbreg; @@ -119,13 +120,13 @@ uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) u32 value; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); path = (u8)pbbreg->path; if (path > RF_PATH_B) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; offset = (u8)pbbreg->offset; value = pbbreg->value; r8712_rf_reg_write(Adapter, path, offset, value); @@ -136,20 +137,20 @@ uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct rf_reg_param *pbbreg; u8 path; u8 offset; u32 value; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); path = (u8)pbbreg->path; if (path > RF_PATH_B) /* 1T2R path_a /path_b */ - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; offset = (u8)pbbreg->offset; value = r8712_rf_reg_read(Adapter, path, offset); pbbreg->value = value; @@ -265,16 +266,16 @@ uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 ratevalue; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; ratevalue = *((u32 *)poid_par_priv->information_buf); if (ratevalue >= MPT_RATE_LAST) - return NDIS_STATUS_INVALID_DATA; + return RNDIS_STATUS_INVALID_DATA; Adapter->mppriv.curr_rateidx = ratevalue; r8712_SetDataRate(Adapter); return status; @@ -284,16 +285,16 @@ uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 mode; u8 val8; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; mode = *((u32 *)poid_par_priv->information_buf); Adapter->mppriv.mode = mode;/* 1 for loopback*/ if (mp_start_test(Adapter) == _FAIL) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */ r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */ /* RCR disable Check BSSID, 0x1025004a */ @@ -313,12 +314,12 @@ uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (mp_stop_test(Adapter) == _FAIL) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } @@ -327,16 +328,16 @@ uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 Channel; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; Channel = *((u32 *)poid_par_priv->information_buf); if (Channel > 14) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_ch = Channel; r8712_SetChannel(Adapter); return status; @@ -346,13 +347,13 @@ uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 antenna; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; antenna = *((u32 *)poid_par_priv->information_buf); Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); @@ -365,16 +366,16 @@ uint oid_rt_pro_set_tx_power_control_hdl( { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 tx_pwr_idx; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; tx_pwr_idx = *((u32 *)poid_par_priv->information_buf); if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_txpoweridx = (u8)tx_pwr_idx; r8712_SetTxPower(Adapter); return status; @@ -383,12 +384,12 @@ uint oid_rt_pro_set_tx_power_control_hdl( uint oid_rt_pro_query_tx_packet_sent_hdl( struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } if (poid_par_priv->information_buf_len == sizeof(u32)) { @@ -396,19 +397,19 @@ uint oid_rt_pro_query_tx_packet_sent_hdl( Adapter->mppriv.tx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } uint oid_rt_pro_query_rx_packet_received_hdl( struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } if (poid_par_priv->information_buf_len == sizeof(u32)) { @@ -416,19 +417,19 @@ uint oid_rt_pro_query_rx_packet_received_hdl( Adapter->mppriv.rx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } uint oid_rt_pro_query_rx_packet_crc32_error_hdl( struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } if (poid_par_priv->information_buf_len == sizeof(u32)) { @@ -436,7 +437,7 @@ uint oid_rt_pro_query_rx_packet_crc32_error_hdl( Adapter->mppriv.rx_crcerrpktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } @@ -447,25 +448,25 @@ uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.tx_pktcount = 0; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len == sizeof(u32)) { Adapter->mppriv.rx_pktcount = 0; Adapter->mppriv.rx_crcerrpktcount = 0; } else - status = NDIS_STATUS_INVALID_LENGTH; + status = RNDIS_STATUS_INVALID_LENGTH; return status; } @@ -476,9 +477,9 @@ uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; r8712_ResetPhyRxPktCount(Adapter); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv @@ -488,13 +489,13 @@ uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; *(u32 *)poid_par_priv->information_buf = r8712_GetPhyRxPktReceived(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv @@ -504,13 +505,13 @@ uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; *(u32 *)poid_par_priv->information_buf = r8712_GetPhyRxPktCRC32Error(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv @@ -520,10 +521,10 @@ uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_modem = *((u8 *)poid_par_priv->information_buf); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv @@ -534,10 +535,10 @@ uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv u32 bStartTest; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; bStartTest = *((u32 *)poid_par_priv->information_buf); r8712_SetContinuousTx(Adapter, (u8)bStartTest); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv @@ -548,10 +549,10 @@ uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv u32 bStartTest; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; bStartTest = *((u32 *)poid_par_priv->information_buf); r8712_SetSingleCarrierTx(Adapter, (u8)bStartTest); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv @@ -562,10 +563,10 @@ uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv u32 bStartTest; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; bStartTest = *((u32 *)poid_par_priv->information_buf); r8712_SetCarrierSuppressionTx(Adapter, (u8)bStartTest); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv @@ -576,28 +577,28 @@ uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv u32 bStartTest; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; bStartTest = *((u32 *)poid_par_priv->information_buf); r8712_SetSingleToneTx(Adapter, (u8)bStartTest); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct ndis_802_11_ssid *pssid; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_needed = (u32)sizeof(struct ndis_802_11_ssid); *poid_par_priv->bytes_rw = 0; if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pssid = (struct ndis_802_11_ssid *)poid_par_priv->information_buf; if (mp_start_joinbss(Adapter, pssid) == _FAIL) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_rw = sizeof(struct ndis_802_11_ssid); return status; } @@ -607,12 +608,12 @@ uint oid_rt_pro_read_register_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct mp_rw_reg *RegRWStruct; u16 offset; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; if ((RegRWStruct->offset >= 0x10250800) && (RegRWStruct->offset <= 0x10250FFF)) { @@ -635,7 +636,7 @@ uint oid_rt_pro_read_register_hdl(struct oid_par_priv RegRWStruct->offset); break; default: - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; break; } } @@ -647,14 +648,14 @@ uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct mp_rw_reg *RegRWStruct; u16 offset; u32 value; u32 oldValue = 0; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; if ((RegRWStruct->offset >= 0x10250800) && (RegRWStruct->offset <= 0x10250FFF)) { @@ -691,11 +692,11 @@ uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) (unsigned int)RegRWStruct->value); break; default: - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; break; } - if ((status == NDIS_STATUS_SUCCESS) && + if ((status == RNDIS_STATUS_SUCCESS) && (RegRWStruct->offset == HIMR) && (RegRWStruct->width == 4)) Adapter->ImrContent = RegRWStruct->value; @@ -711,12 +712,12 @@ uint oid_rt_pro_burst_read_register_hdl(struct oid_par_priv struct burst_rw_reg *pBstRwReg; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf; r8712_read_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len, pBstRwReg->Data); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv @@ -727,16 +728,16 @@ uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv struct burst_rw_reg *pBstRwReg; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf; r8712_write_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len, pBstRwReg->Data); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) @@ -746,12 +747,12 @@ uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) struct eeprom_rw_param *pEEPROM; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf; pEEPROM->value = r8712_eeprom_read16(Adapter, (u16)(pEEPROM->offset >> 1)); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv) @@ -761,12 +762,12 @@ uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv) struct eeprom_rw_param *pEEPROM; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf; r8712_eeprom_write16(Adapter, (u16)(pEEPROM->offset >> 1), pEEPROM->value); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) @@ -776,17 +777,17 @@ uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) struct mp_wiparam *pwi_param; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct mp_wiparam)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; if (Adapter->mppriv.workparam.bcompleted == false) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pwi_param = (struct mp_wiparam *)poid_par_priv->information_buf; memcpy(pwi_param, &Adapter->mppriv.workparam, sizeof(struct mp_wiparam)); Adapter->mppriv.act_in_progress = false; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) @@ -795,42 +796,42 @@ uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(uint) * 2) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; if (*(uint *)poid_par_priv->information_buf == 1) Adapter->mppriv.rx_pktloss = 0; *((uint *)poid_par_priv->information_buf+1) = Adapter->mppriv.rx_pktloss; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (r8712_setrfintfs_cmd(Adapter, *(unsigned char *) poid_par_priv->information_buf) == _FAIL) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } @@ -838,10 +839,10 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; memcpy(poid_par_priv->information_buf, (unsigned char *)&Adapter->mppriv.rxstat, sizeof(struct recv_stat)); @@ -852,7 +853,7 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) uint oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv @@ -860,13 +861,13 @@ uint oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (r8712_setdatarate_cmd(Adapter, poid_par_priv->information_buf) != _SUCCESS) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } @@ -874,16 +875,16 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (Adapter->mppriv.act_in_progress == true) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; /*init workparam*/ Adapter->mppriv.act_in_progress = true; Adapter->mppriv.workparam.bcompleted = false; @@ -904,14 +905,14 @@ uint oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; if (!r8712_setptm_cmd(Adapter, *((u8 *)poid_par_priv->information_buf))) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } @@ -920,13 +921,13 @@ uint oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 ratevalue; u8 datarates[NumRates]; int i; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; ratevalue = *((u32 *)poid_par_priv->information_buf); for (i = 0; i < NumRates; i++) { if (ratevalue == mpdatarate[i]) @@ -935,7 +936,7 @@ uint oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) datarates[i] = 0xff; } if (r8712_setbasicrate_cmd(Adapter, datarates) != _SUCCESS) - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } @@ -945,14 +946,14 @@ uint oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < 8) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; *poid_par_priv->bytes_rw = 8; memcpy(poid_par_priv->information_buf, &(Adapter->pwrctrlpriv.pwr_mode), 8); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) @@ -962,18 +963,18 @@ uint oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) uint pwr_mode, smart_ps; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_rw = 0; *poid_par_priv->bytes_needed = 8; if (poid_par_priv->information_buf_len < 8) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pwr_mode = *(uint *)(poid_par_priv->information_buf); smart_ps = *(uint *)((addr_t)poid_par_priv->information_buf + 4); if (pwr_mode != Adapter->pwrctrlpriv.pwr_mode || smart_ps != Adapter->pwrctrlpriv.smart_ps) r8712_set_ps_mode(Adapter, pwr_mode, smart_ps); *poid_par_priv->bytes_rw = 8; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv @@ -981,20 +982,20 @@ uint oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct setratable_parm *prate_table; u8 res; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_needed = sizeof(struct setratable_parm); if (poid_par_priv->information_buf_len < sizeof(struct setratable_parm)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; prate_table = (struct setratable_parm *)poid_par_priv->information_buf; res = r8712_setrttbl_cmd(Adapter, prate_table); if (res == _FAIL) - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; return status; } @@ -1002,8 +1003,8 @@ uint oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) { if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv @@ -1016,7 +1017,7 @@ uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv->bytes_needed = sizeof(u8); if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; if (poid_par_priv->type_of_oid == SET_OID) { encry_mode = *((u8 *)poid_par_priv->information_buf); @@ -1054,7 +1055,7 @@ uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *(u8 *)poid_par_priv->information_buf = encry_mode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } /*----------------------------------------------------------------------*/ uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) @@ -1062,24 +1063,24 @@ uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct sta_info *psta = NULL; u8 *macaddr; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_needed = ETH_ALEN; if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; macaddr = (u8 *) poid_par_priv->information_buf; psta = r8712_get_stainfo(&Adapter->stapriv, macaddr); if (psta == NULL) { /* the sta in sta_info_queue => do nothing*/ psta = r8712_alloc_stainfo(&Adapter->stapriv, macaddr); if (psta == NULL) - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; } return status; } @@ -1090,18 +1091,18 @@ uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); unsigned long irqL; - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct sta_info *psta = NULL; u8 *macaddr; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_needed = ETH_ALEN; if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; macaddr = (u8 *)poid_par_priv->information_buf; @@ -1125,15 +1126,15 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct DR_VARIABLE_STRUCT *pdrv_var; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; *poid_par_priv->bytes_needed = sizeof(struct DR_VARIABLE_STRUCT); if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pdrv_var = (struct DR_VARIABLE_STRUCT *)poid_par_priv->information_buf; pdrv_var->variable = mp_query_drv_var(Adapter, pdrv_var->offset, pdrv_var->variable); @@ -1144,7 +1145,7 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) /*--------------------------------------------------------------------------*/ uint oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } /*------------------------------------------------------------------------*/ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) @@ -1152,17 +1153,17 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct EFUSE_ACCESS_STRUCT *pefuse; u8 *data; u16 addr = 0, cnts = 0; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(struct EFUSE_ACCESS_STRUCT)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf; addr = pefuse->start_addr; cnts = pefuse->cnts; @@ -1170,9 +1171,9 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) memset(data, 0xFF, cnts); if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) > EFUSE_MAX_SIZE) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (r8712_efuse_access(Adapter, true, addr, cnts, data) == false) - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; return status; } @@ -1182,14 +1183,14 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct EFUSE_ACCESS_STRUCT *pefuse; u8 *data; u16 addr = 0, cnts = 0; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf; addr = pefuse->start_addr; @@ -1198,9 +1199,9 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) > r8712_efuse_get_max_size(Adapter)) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (r8712_efuse_access(Adapter, false, addr, cnts, data) == false) - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; return status; } /*----------------------------------------------------------------------*/ @@ -1208,12 +1209,12 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct PGPKT_STRUCT *ppgpkt; *poid_par_priv->bytes_rw = 0; if (poid_par_priv->information_buf_len < sizeof(struct PGPKT_STRUCT)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; ppgpkt = (struct PGPKT_STRUCT *)poid_par_priv->information_buf; if (poid_par_priv->type_of_oid == QUERY_OID) { if (r8712_efuse_pg_packet_read(Adapter, ppgpkt->offset, @@ -1221,7 +1222,7 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; else - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; } else { if (r8712_efuse_reg_init(Adapter) == true) { if (r8712_efuse_pg_packet_write(Adapter, ppgpkt->offset, @@ -1229,10 +1230,10 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; else - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; r8712_efuse_reg_uninit(Adapter); } else - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; } return status; } @@ -1242,12 +1243,12 @@ uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(int)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; r8712_efuse_reg_init(Adapter); *(int *)poid_par_priv->information_buf = r8712_efuse_get_current_size(Adapter); @@ -1260,12 +1261,12 @@ uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; *(int *)poid_par_priv->information_buf = r8712_efuse_get_max_size(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -1274,7 +1275,7 @@ uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) { - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid == QUERY_OID) status = oid_rt_pro_read_efuse_hdl(poid_par_priv); @@ -1287,18 +1288,18 @@ uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u8 *data; *poid_par_priv->bytes_rw = 0; if (poid_par_priv->information_buf_len < EFUSE_MAP_MAX_SIZE) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; data = (u8 *)poid_par_priv->information_buf; if (poid_par_priv->type_of_oid == QUERY_OID) { if (r8712_efuse_map_read(Adapter, 0, EFUSE_MAP_MAX_SIZE, data)) *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE; else - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; } else { /* SET_OID */ if (r8712_efuse_reg_init(Adapter) == true) { @@ -1306,10 +1307,10 @@ uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) EFUSE_MAP_MAX_SIZE, data)) *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE; else - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; r8712_efuse_reg_uninit(Adapter); } else { - status = NDIS_STATUS_FAILURE; + status = RNDIS_STATUS_FAILURE; } } return status; @@ -1319,13 +1320,13 @@ uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 bandwidth; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; bandwidth = *((u32 *)poid_par_priv->information_buf);/*4*/ if (bandwidth != HT_CHANNEL_WIDTH_20) bandwidth = HT_CHANNEL_WIDTH_40; @@ -1338,16 +1339,16 @@ uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; u32 crystal_cap = 0; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; crystal_cap = *((u32 *)poid_par_priv->information_buf);/*4*/ if (crystal_cap > 0xf) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_crystalcap = crystal_cap; r8712_SetCrystalCap(Adapter); return status; @@ -1362,9 +1363,9 @@ uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv u32 rcr_val32; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/*4*/ rcr_val32 = r8712_read32(Adapter, RCR);/*RCR = 0x10250048*/ rcr_val32 &= ~(RCR_CBSSID | RCR_AB | RCR_AM | RCR_APM | RCR_AAP); @@ -1391,7 +1392,7 @@ uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv else Adapter->mppriv.check_mp_pkt = 0; r8712_write32(Adapter, RCR, rcr_val32); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv @@ -1402,12 +1403,12 @@ uint oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv u32 txagc; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; txagc = *(u32 *)poid_par_priv->information_buf; r8712_SetTxAGCOffset(Adapter, txagc); - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv @@ -1415,16 +1416,16 @@ uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = NDIS_STATUS_SUCCESS; + uint status = RNDIS_STATUS_SUCCESS; struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; struct mp_priv *pmppriv = &Adapter->mppriv; u32 type; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; type = *(u32 *)poid_par_priv->information_buf; @@ -1435,7 +1436,7 @@ uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv pmppriv->mode = type; _clr_fwstate_(pmlmepriv, WIFI_MP_LPBK_STATE); } else - status = NDIS_STATUS_NOT_ACCEPTED; + status = RNDIS_STATUS_NOT_ACCEPTED; return status; } /*--------------------------------------------------------------------------*/ @@ -1450,10 +1451,10 @@ uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) u8 bpwrup; if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; bpwrup = *(u8 *)poid_par_priv->information_buf; /*CALL the power_down function*/ - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } /*-------------------------------------------------------------------------- */ @@ -1463,11 +1464,11 @@ uint oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; *(int *)poid_par_priv->information_buf = Adapter->registrypriv.low_power ? POWER_LOW : POWER_NORMAL; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return NDIS_STATUS_SUCCESS; + return RNDIS_STATUS_SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h index a13395f..c732aea 100644 --- a/drivers/staging/rtl8712/rtl871x_security.h +++ b/drivers/staging/rtl8712/rtl871x_security.h @@ -207,9 +207,9 @@ void seccalctkipmic( u8 *Miccode, u8 priority); -void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key); -void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes); -void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst); +void r8712_secmicsetkey(struct mic_data *pmicdata, u8 *key); +void r8712_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); +void r8712_secgetmic(struct mic_data *pmicdata, u8 *dst); u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe); u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe); void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe); diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h index f8016e9..c4e0ef2 100644 --- a/drivers/staging/rtl8712/sta_info.h +++ b/drivers/staging/rtl8712/sta_info.h @@ -140,7 +140,7 @@ void r8712_free_all_stainfo(struct _adapter *padapter); struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr); void r8712_init_bcmc_stainfo(struct _adapter *padapter); struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter); -u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 * mac_addr); +u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr); #endif /* _STA_INFO_H_ */ diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index a96cd06..c812d6c7 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -205,9 +205,9 @@ static int r871x_suspend(struct usb_interface *pusb_intf, pm_message_t state) { struct net_device *pnetdev = usb_get_intfdata(pusb_intf); - printk(KERN_INFO "r8712: suspending...\n"); + netdev_info(pnetdev, "Suspending...\n"); if (!pnetdev || !netif_running(pnetdev)) { - printk(KERN_INFO "r8712: unable to suspend\n"); + netdev_info(pnetdev, "Unable to suspend\n"); return 0; } if (pnetdev->netdev_ops->ndo_stop) @@ -221,9 +221,9 @@ static int r871x_resume(struct usb_interface *pusb_intf) { struct net_device *pnetdev = usb_get_intfdata(pusb_intf); - printk(KERN_INFO "r8712: resuming...\n"); + netdev_info(pnetdev, "Resuming...\n"); if (!pnetdev || !netif_running(pnetdev)) { - printk(KERN_INFO "r8712: unable to resume\n"); + netdev_info(pnetdev, "Unable to resume\n"); return 0; } netif_device_attach(pnetdev); @@ -273,12 +273,12 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter) pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; if (pusbd->speed == USB_SPEED_HIGH) { pdvobjpriv->ishighspeed = true; - printk(KERN_INFO "r8712u: USB_SPEED_HIGH with %d endpoints\n", - pdvobjpriv->nr_endpoint); + dev_info(&pusbd->dev, "r8712u: USB_SPEED_HIGH with %d endpoints\n", + pdvobjpriv->nr_endpoint); } else { pdvobjpriv->ishighspeed = false; - printk(KERN_INFO "r8712u: USB_SPEED_LOW with %d endpoints\n", - pdvobjpriv->nr_endpoint); + dev_info(&pusbd->dev, "r8712u: USB_SPEED_LOW with %d endpoints\n", + pdvobjpriv->nr_endpoint); } if ((r8712_alloc_io_queue(padapter)) == _FAIL) status = _FAIL; @@ -423,9 +423,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, tmpU1b = r8712_read8(padapter, EE_9346CR);/*CR9346*/ /* To check system boot selection.*/ - printk(KERN_INFO "r8712u: Boot from %s: Autoload %s\n", - (tmpU1b & _9356SEL) ? "EEPROM" : "EFUSE", - (tmpU1b & _EEPROM_EN) ? "OK" : "Failed"); + dev_info(&udev->dev, "r8712u: Boot from %s: Autoload %s\n", + (tmpU1b & _9356SEL) ? "EEPROM" : "EFUSE", + (tmpU1b & _EEPROM_EN) ? "OK" : "Failed"); /* To check autoload success or not.*/ if (tmpU1b & _EEPROM_EN) { @@ -533,8 +533,8 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, RT_CID_DEFAULT; break; } - printk(KERN_INFO "r8712u: CustomerID = 0x%.4x\n", - padapter->eeprompriv.CustomerID); + dev_info(&udev->dev, "r8712u: CustomerID = 0x%.4x\n", + padapter->eeprompriv.CustomerID); /* Led mode */ switch (padapter->eeprompriv.CustomerID) { case RT_CID_DEFAULT: @@ -590,11 +590,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, * address by setting bit 1 of first octet. */ mac[0] &= 0xFE; - printk(KERN_INFO "r8712u: MAC Address from user = " - "%pM\n", mac); + dev_info(&udev->dev, "r8712u: MAC Address from user = %pM\n", mac); } else - printk(KERN_INFO "r8712u: MAC Address from efuse = " - "%pM\n", mac); + dev_info(&udev->dev, "r8712u: MAC Address from efuse = %pM\n", mac); memcpy(pnetdev->dev_addr, mac, ETH_ALEN); } /* step 6. Load the firmware asynchronously */ @@ -661,7 +659,6 @@ static void __exit r8712u_drv_halt(void) { drvpriv.drv_registered = false; usb_deregister(&drvpriv.r871xu_drv); - printk(KERN_INFO "r8712u: Driver unloaded\n"); } module_init(r8712u_drv_entry); diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 24e1ec5..dca398a 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -45,9 +45,6 @@ struct zero_bulkout_context { void *padapter; }; -#define usb_write_cmd r8712_usb_write_mem -#define usb_write_cmd_complete usb_write_mem_complete - uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv) { pintfpriv->piorw_urb = usb_alloc_urb(0, GFP_ATOMIC); @@ -243,8 +240,7 @@ static void r8712_usb_read_port_complete(struct urb *purb) (unsigned char *)precvbuf); break; case -EINPROGRESS: - printk(KERN_ERR "r8712u: ERROR: URB IS IN" - " PROGRESS!/n"); + netdev_err(padapter->pnetdev, "ERROR: URB IS IN PROGRESS!\n"); break; default: break; @@ -336,8 +332,7 @@ void r8712_xmit_bh(void *priv) if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) { - printk(KERN_ERR "r8712u: xmit_bh => bDriverStopped" - " or bSurpriseRemoved\n"); + netdev_err(padapter->pnetdev, "xmit_bh => bDriverStopped or bSurpriseRemoved\n"); return; } ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL); @@ -387,7 +382,7 @@ static void usb_write_port_complete(struct urb *purb) case 0: break; default: - printk(KERN_WARNING "r8712u: pipe error: (%d)\n", purb->status); + netdev_warn(padapter->pnetdev, "r8712u: pipe error: (%d)\n", purb->status); break; } /* not to consider tx fragment */ @@ -502,8 +497,8 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value, palloc_buf = _malloc((u32) len + 16); if (palloc_buf == NULL) { - printk(KERN_ERR "r8712u: [%s] Can't alloc memory for vendor" - " request\n", __func__); + dev_err(&udev->dev, "%s: Can't alloc memory for vendor request\n", + __func__); return -1; } pIo_buf = palloc_buf + 16 - ((addr_t)(palloc_buf) & 0x0f); diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 793443e..73d7cd2 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -159,99 +159,85 @@ enum WIFI_REG_DOMAIN { #define _PRIVACY_ BIT(14) #define _ORDER_ BIT(15) -#define SetToDs(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \ - } while (0) +#define SetToDs(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \ +}) #define GetToDs(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_TO_DS_)) != 0) -#define ClearToDs(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \ - } while (0) +#define ClearToDs(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \ +}) -#define SetFrDs(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \ - } while (0) +#define SetFrDs(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \ +}) #define GetFrDs(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_FROM_DS_)) != 0) -#define ClearFrDs(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \ - } while (0) +#define ClearFrDs(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \ +}) #define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) -#define SetMFrag(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \ - } while (0) +#define SetMFrag(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \ +}) #define GetMFrag(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_MORE_FRAG_)) != 0) -#define ClearMFrag(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \ - } while (0) +#define ClearMFrag(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \ +}) -#define SetRetry(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \ - } while (0) +#define SetRetry(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \ +}) #define GetRetry(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_RETRY_)) != 0) -#define ClearRetry(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \ - } while (0) +#define ClearRetry(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \ +}) -#define SetPwrMgt(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \ - } while (0) +#define SetPwrMgt(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \ +}) #define GetPwrMgt(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_PWRMGT_)) != 0) -#define ClearPwrMgt(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \ - } while (0) +#define ClearPwrMgt(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \ +}) -#define SetMData(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \ - } while (0) +#define SetMData(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \ +}) #define GetMData(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_MORE_DATA_)) != 0) -#define ClearMData(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \ - } while (0) +#define ClearMData(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \ +}) -#define SetPrivacy(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \ - } while (0) +#define SetPrivacy(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \ +}) #define GetPrivacy(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_PRIVACY_)) != 0) -#define ClearPrivacy(pbuf) \ - do { \ - *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \ - } while (0) +#define ClearPrivacy(pbuf) ({ \ + *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \ +}) #define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \ @@ -287,48 +273,42 @@ enum WIFI_REG_DOMAIN { #define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)\ ((addr_t)(pbuf) + 22))) -#define SetFragNum(pbuf, num) \ - do { \ - *(unsigned short *)((addr_t)(pbuf) + 22) = \ - ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \ - le16_to_cpu(~(0x000f))) | \ - cpu_to_le16(0x0f & (num)); \ - } while (0) - -#define SetSeqNum(pbuf, num) \ - do { \ - *(unsigned short *)((addr_t)(pbuf) + 22) = \ - ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \ - le16_to_cpu((unsigned short)0x000f)) | \ - le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \ - } while (0) - -#define SetDuration(pbuf, dur) \ - do { \ - *(unsigned short *)((addr_t)(pbuf) + 2) |= \ - cpu_to_le16(0xffff & (dur)); \ - } while (0) - -#define SetPriority(pbuf, tid) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \ - } while (0) +#define SetFragNum(pbuf, num) ({ \ + *(unsigned short *)((addr_t)(pbuf) + 22) = \ + ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \ + le16_to_cpu(~(0x000f))) | \ + cpu_to_le16(0x0f & (num)); \ +}) + +#define SetSeqNum(pbuf, num) ({ \ + *(unsigned short *)((addr_t)(pbuf) + 22) = \ + ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \ + le16_to_cpu((unsigned short)0x000f)) | \ + le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \ +}) + +#define SetDuration(pbuf, dur) ({ \ + *(unsigned short *)((addr_t)(pbuf) + 2) |= \ + cpu_to_le16(0xffff & (dur)); \ +}) + +#define SetPriority(pbuf, tid) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \ +}) #define GetPriority(pbuf) ((le16_to_cpu(*(unsigned short *)(pbuf))) & 0xf) -#define SetAckpolicy(pbuf, ack) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \ - } while (0) +#define SetAckpolicy(pbuf, ack) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \ +}) #define GetAckpolicy(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 5) & 0x3) #define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1) -#define SetAMsdu(pbuf, amsdu) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \ - } while (0) +#define SetAMsdu(pbuf, amsdu) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \ +}) #define GetAid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + 2)) \ & 0x3fff) @@ -457,11 +437,7 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define _SSID_IE_ 0 #define _SUPPORTEDRATES_IE_ 1 #define _DSSET_IE_ 3 -#define _TIM_IE_ 5 #define _IBSS_PARA_IE_ 6 -#define _CHLGETXT_IE_ 16 -#define _RSN_IE_2_ 48` -#define _SSN_IE_1_ 221 #define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 @@ -526,10 +502,9 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 -#define SetOrderBit(pbuf) \ - do { \ - *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \ - } while (0) +#define SetOrderBit(pbuf) ({ \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \ +}) #define GetOrderBit(pbuf) (((*(unsigned short *)(pbuf)) & \ le16_to_cpu(_ORDER_)) != 0) diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 65542cb..4d22bb7 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -134,8 +134,7 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter, for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); if (pxmitbuf->pxmit_urb[i] == NULL) { - printk(KERN_ERR "r8712u: pxmitbuf->pxmit_urb[i]" - " == NULL"); + netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n"); return _FAIL; } } diff --git a/drivers/staging/sb105x/sb_mp_register.h b/drivers/staging/sb105x/sb_mp_register.h index 5480ae1..a2087f5b 100644 --- a/drivers/staging/sb105x/sb_mp_register.h +++ b/drivers/staging/sb105x/sb_mp_register.h @@ -45,7 +45,7 @@ #define IIR_RS232 0x00 /* RS232 type */ #define IIR_RS422 0x10 /* RS422 type */ #define IIR_RS485 0x20 /* RS485 type */ -#define IIR_UNKNOWN 0x30 /* unknown type */ +#define IIR_TYPE_MASK 0x30 /* Interrrupt Mask Register */ #define MP_OPTR_IMR0 0x0C /* port0 ~ port8 */ diff --git a/drivers/staging/sb105x/sb_pci_mp.c b/drivers/staging/sb105x/sb_pci_mp.c index 9464f38..f75ee1d 100644 --- a/drivers/staging/sb105x/sb_pci_mp.c +++ b/drivers/staging/sb105x/sb_pci_mp.c @@ -1563,13 +1563,13 @@ static int mp_open(struct tty_struct *tty, struct file *filp) state = uart_get(drv, line); - mtpt = (struct mp_port *)state->port; - if (IS_ERR(state)) { retval = PTR_ERR(state); goto fail; } + mtpt = (struct mp_port *)state->port; + tty->driver_data = state; tty->low_latency = (state->port->flags & UPF_LOW_LATENCY) ? 1 : 0; tty->alt_speed = 0; @@ -2851,18 +2851,12 @@ static void __init multi_init_ports(void) printk("IIR_RET = %x\n",b_ret); } - if(IIR_RS232 == (b_ret & IIR_RS232)) - { - mtpt->interface = RS232; - } - if(IIR_RS422 == (b_ret & IIR_RS422)) - { + /* default to RS232 */ + mtpt->interface = RS232; + if (IIR_RS422 == (b_ret & IIR_TYPE_MASK)) mtpt->interface = RS422PTP; - } - if(IIR_RS485 == (b_ret & IIR_RS485)) - { + if (IIR_RS485 == (b_ret & IIR_TYPE_MASK)) mtpt->interface = RS485NE; - } } } } diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c index daadd6e..f207b9e 100644 --- a/drivers/staging/sbe-2t3e3/dc.c +++ b/drivers/staging/sbe-2t3e3/dc.c @@ -315,20 +315,17 @@ static int dc_init_descriptor_list(struct channel *sc) struct sk_buff *m; if (sc->ether.rx_ring == NULL) - sc->ether.rx_ring = kzalloc(SBE_2T3E3_RX_DESC_RING_SIZE * + sc->ether.rx_ring = kcalloc(SBE_2T3E3_RX_DESC_RING_SIZE, sizeof(t3e3_rx_desc_t), GFP_KERNEL); - if (sc->ether.rx_ring == NULL) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n"); + if (sc->ether.rx_ring == NULL) return -ENOMEM; - } if (sc->ether.tx_ring == NULL) - sc->ether.tx_ring = kzalloc(SBE_2T3E3_TX_DESC_RING_SIZE * + sc->ether.tx_ring = kcalloc(SBE_2T3E3_TX_DESC_RING_SIZE, sizeof(t3e3_tx_desc_t), GFP_KERNEL); if (sc->ether.tx_ring == NULL) { kfree(sc->ether.rx_ring); sc->ether.rx_ring = NULL; - dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n"); return -ENOMEM; } diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c index ae7af39..0e32be5 100644 --- a/drivers/staging/sbe-2t3e3/module.c +++ b/drivers/staging/sbe-2t3e3/module.c @@ -154,11 +154,10 @@ static int t3e3_init_card(struct pci_dev *pdev, const struct pci_device_id *ent) /* holds the reference for pdev1 */ } - card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), GFP_KERNEL); - if (!card) { - dev_err(&pdev->dev, "Out of memory\n"); + card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), + GFP_KERNEL); + if (!card) return -ENOBUFS; - } spin_lock_init(&card->bootrom_lock); card->bootrom_addr = pci_resource_start(pdev, 0); diff --git a/drivers/staging/sep/sep_crypto.c b/drivers/staging/sep/sep_crypto.c index 34710ce..cd3bb39 100644 --- a/drivers/staging/sep/sep_crypto.c +++ b/drivers/staging/sep/sep_crypto.c @@ -178,11 +178,9 @@ static struct scatterlist *sep_alloc_sg_buf( nbr_pages += 1; } - sg = kmalloc((sizeof(struct scatterlist) * nbr_pages), GFP_ATOMIC); - if (!sg) { - dev_warn(&sep->pdev->dev, "Cannot allocate page for new sg\n"); + sg = kmalloc_array(nbr_pages, sizeof(struct scatterlist), GFP_ATOMIC); + if (!sg) return NULL; - } sg_init_table(sg, nbr_pages); @@ -3908,13 +3906,9 @@ int sep_crypto_setup(void) return -ENOMEM; } - i = 0; - j = 0; - spin_lock_init(&queue_lock); err = 0; - for (i = 0; i < ARRAY_SIZE(hash_algs); i++) { err = crypto_register_ahash(&hash_algs[i]); if (err) diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c index 15c6e3d..30e8d25 100644 --- a/drivers/staging/sep/sep_main.c +++ b/drivers/staging/sep/sep_main.c @@ -219,12 +219,8 @@ static int sep_allocate_dmatables_region(struct sep_device *sep, dev_dbg(&sep->pdev->dev, "[PID%d] oldlen = 0x%08X\n", current->pid, dma_ctx->dmatables_len); tmp_region = kzalloc(new_len + dma_ctx->dmatables_len, GFP_KERNEL); - if (!tmp_region) { - dev_warn(&sep->pdev->dev, - "[PID%d] no mem for dma tables region\n", - current->pid); + if (!tmp_region) return -ENOMEM; - } /* Were there any previous tables that need to be preserved ? */ if (*dmatables_region) { @@ -1245,27 +1241,23 @@ static int sep_lock_user_pages(struct sep_device *sep, current->pid, num_pages); /* Allocate array of pages structure pointers */ - page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); + page_array = kmalloc_array(num_pages, sizeof(struct page *), + GFP_ATOMIC); if (!page_array) { error = -ENOMEM; goto end_function; } - map_array = kmalloc(sizeof(struct sep_dma_map) * num_pages, GFP_ATOMIC); + + map_array = kmalloc_array(num_pages, sizeof(struct sep_dma_map), + GFP_ATOMIC); if (!map_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for map_array failed\n", - current->pid); error = -ENOMEM; goto end_function_with_error1; } - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, - GFP_ATOMIC); - + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), + GFP_ATOMIC); if (!lli_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for lli_array failed\n", - current->pid); error = -ENOMEM; goto end_function_with_error2; } @@ -1448,15 +1440,10 @@ static int sep_lli_table_secure_dma(struct sep_device *sep, dev_dbg(&sep->pdev->dev, "[PID%d] num_pages is (hex) %x\n", current->pid, num_pages); - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, - GFP_ATOMIC); - - if (!lli_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for lli_array failed\n", - current->pid); + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), + GFP_ATOMIC); + if (!lli_array) return -ENOMEM; - } /* * Fill the lli_array @@ -3419,11 +3406,9 @@ static ssize_t sep_create_dcb_dmatables_context(struct sep_device *sep, goto end_function; } - dcb_args = kzalloc(num_dcbs * sizeof(struct build_dcb_struct), + dcb_args = kcalloc(num_dcbs, sizeof(struct build_dcb_struct), GFP_KERNEL); if (!dcb_args) { - dev_warn(&sep->pdev->dev, "[PID%d] no memory for dcb args\n", - current->pid); error = -ENOMEM; goto end_function; } @@ -3610,9 +3595,6 @@ static ssize_t sep_create_msgarea_context(struct sep_device *sep, /* Allocate thread-specific memory for message buffer */ *msg_region = kzalloc(msg_len, GFP_KERNEL); if (!(*msg_region)) { - dev_warn(&sep->pdev->dev, - "[PID%d] no mem for msgarea context\n", - current->pid); error = -ENOMEM; goto end_function; } @@ -4133,8 +4115,6 @@ static int sep_probe(struct pci_dev *pdev, /* Allocate the sep_device structure for this device */ sep_dev = kzalloc(sizeof(struct sep_device), GFP_ATOMIC); if (sep_dev == NULL) { - dev_warn(&pdev->dev, - "can't kmalloc the sep_device structure\n"); error = -ENOMEM; goto end_function_disable_device; } diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index ebdcc6f..4c7822b 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -43,15 +43,15 @@ /* firmware stuff */ #define OASIS_UCODE_VERS_STRING "1.2" -#define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37" -#define OASIS_UCODE_HOSTIF_ID 3 +#define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37" +#define OASIS_UCODE_HOSTIF_ID 3 #define MOJAVE_UCODE_VERS_STRING "1.2" -#define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22" -#define MOJAVE_UCODE_HOSTIF_ID 3 +#define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22" +#define MOJAVE_UCODE_HOSTIF_ID 3 #define GB_RCVUCODE_VERS_STRING "1.2" -#define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15" +#define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15" static u32 OasisRcvUCodeLen = 512; static u32 GBRcvUCodeLen = 512; #define SECTION_SIZE 65536 @@ -65,12 +65,12 @@ struct slic_spinlock { #define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE) struct slic_rspqueue { - u32 offset; - u32 pageindex; - u32 num_pages; - struct slic_rspbuf *rspbuf; - u32 *vaddr[SLIC_RSPQ_PAGES_GB]; - dma_addr_t paddr[SLIC_RSPQ_PAGES_GB]; + u32 offset; + u32 pageindex; + u32 num_pages; + struct slic_rspbuf *rspbuf; + u32 *vaddr[SLIC_RSPQ_PAGES_GB]; + dma_addr_t paddr[SLIC_RSPQ_PAGES_GB]; }; #define SLIC_RCVQ_EXPANSION 1 @@ -82,20 +82,20 @@ struct slic_rspqueue { #define SLIC_RCVQ_FILLTHRESH (SLIC_RCVQ_ENTRIES - SLIC_RCVQ_FILLENTRIES) struct slic_rcvqueue { - struct sk_buff *head; - struct sk_buff *tail; - u32 count; - u32 size; - u32 errors; + struct sk_buff *head; + struct sk_buff *tail; + u32 count; + u32 size; + u32 errors; }; struct slic_rcvbuf_info { - u32 id; - u32 starttime; - u32 stoptime; - u32 slicworld; - u32 lasttime; - u32 lastid; + u32 id; + u32 starttime; + u32 stoptime; + u32 slicworld; + u32 lasttime; + u32 lastid; }; /* SLIC Handle structure. Used to restrict handle values to @@ -113,12 +113,12 @@ struct slic_handle_word { }; struct slic_handle { - struct slic_handle_word token; /* token passed between host and card*/ - ushort type; - void *address; /* actual address of the object*/ - ushort offset; - struct slic_handle *other_handle; - struct slic_handle *next; + struct slic_handle_word token; /* token passed between host and card*/ + ushort type; + void *address; /* actual address of the object*/ + ushort offset; + struct slic_handle *other_handle; + struct slic_handle *next; }; #define SLIC_HANDLE_FREE 0x0000 @@ -134,17 +134,17 @@ struct slic_handle { #define SLIC_HOSTCMD_SIZE 512 struct slic_hostcmd { - struct slic_host64_cmd cmd64; - u32 type; - struct sk_buff *skb; - u32 paddrl; - u32 paddrh; - u32 busy; - u32 cmdsize; - ushort numbufs; - struct slic_handle *pslic_handle;/* handle associated with command */ - struct slic_hostcmd *next; - struct slic_hostcmd *next_all; + struct slic_host64_cmd cmd64; + u32 type; + struct sk_buff *skb; + u32 paddrl; + u32 paddrh; + u32 busy; + u32 cmdsize; + ushort numbufs; + struct slic_handle *pslic_handle;/* handle associated with command */ + struct slic_hostcmd *next; + struct slic_hostcmd *next_all; }; #define SLIC_CMDQ_CMDSINPAGE (PAGE_SIZE / SLIC_HOSTCMD_SIZE) @@ -228,35 +228,35 @@ struct mcast_address { #define SLIC_CARD_STATE(x) ((x == CARD_UP) ? "UP" : "Down") struct slic_iface_stats { - /* - * Stats - */ - u64 xmt_bytes; - u64 xmt_ucast; - u64 xmt_mcast; - u64 xmt_bcast; - u64 xmt_errors; - u64 xmt_discards; - u64 xmit_collisions; - u64 xmit_excess_xmit_collisions; - u64 rcv_bytes; - u64 rcv_ucast; - u64 rcv_mcast; - u64 rcv_bcast; - u64 rcv_errors; - u64 rcv_discards; + /* + * Stats + */ + u64 xmt_bytes; + u64 xmt_ucast; + u64 xmt_mcast; + u64 xmt_bcast; + u64 xmt_errors; + u64 xmt_discards; + u64 xmit_collisions; + u64 xmit_excess_xmit_collisions; + u64 rcv_bytes; + u64 rcv_ucast; + u64 rcv_mcast; + u64 rcv_bcast; + u64 rcv_errors; + u64 rcv_discards; }; struct sliccp_stats { - u64 xmit_tcp_segs; - u64 xmit_tcp_bytes; - u64 rcv_tcp_segs; - u64 rcv_tcp_bytes; + u64 xmit_tcp_segs; + u64 xmit_tcp_bytes; + u64 rcv_tcp_segs; + u64 rcv_tcp_bytes; }; struct slicnet_stats { - struct sliccp_stats tcp; - struct slic_iface_stats iface; + struct sliccp_stats tcp; + struct slic_iface_stats iface; }; #define SLIC_LOADTIMER_PERIOD 1 @@ -285,51 +285,51 @@ struct slicnet_stats { #define SLIC_INTAGG_5GB 100 struct ether_header { - unsigned char ether_dhost[6]; - unsigned char ether_shost[6]; - ushort ether_type; + unsigned char ether_dhost[6]; + unsigned char ether_shost[6]; + ushort ether_type; }; struct sliccard { - uint busnumber; - uint slotnumber; - uint state; - uint cardnum; - uint card_size; - uint adapters_activated; - uint adapters_allocated; - uint adapters_sleeping; - uint gennumber; - u32 events; - u32 loadlevel_current; - u32 load; - uint reset_in_progress; - u32 pingstatus; - u32 bad_pingstatus; - struct timer_list loadtimer; - u32 loadtimerset; - uint config_set; - struct slic_config config; - struct dentry *debugfs_dir; - struct dentry *debugfs_cardinfo; - struct adapter *master; - struct adapter *adapter[SLIC_MAX_PORTS]; - struct sliccard *next; - u32 error_interrupts; - u32 error_rmiss_interrupts; - u32 rcv_interrupts; - u32 xmit_interrupts; - u32 num_isrs; - u32 false_interrupts; - u32 max_isr_rcvs; - u32 max_isr_xmits; - u32 rcv_interrupt_yields; - u32 tx_packets; - u32 debug_ix; - ushort reg_type[32]; - ushort reg_offset[32]; - u32 reg_value[32]; - u32 reg_valueh[32]; + uint busnumber; + uint slotnumber; + uint state; + uint cardnum; + uint card_size; + uint adapters_activated; + uint adapters_allocated; + uint adapters_sleeping; + uint gennumber; + u32 events; + u32 loadlevel_current; + u32 load; + uint reset_in_progress; + u32 pingstatus; + u32 bad_pingstatus; + struct timer_list loadtimer; + u32 loadtimerset; + uint config_set; + struct slic_config config; + struct dentry *debugfs_dir; + struct dentry *debugfs_cardinfo; + struct adapter *master; + struct adapter *adapter[SLIC_MAX_PORTS]; + struct sliccard *next; + u32 error_interrupts; + u32 error_rmiss_interrupts; + u32 rcv_interrupts; + u32 xmit_interrupts; + u32 num_isrs; + u32 false_interrupts; + u32 max_isr_rcvs; + u32 max_isr_xmits; + u32 rcv_interrupt_yields; + u32 tx_packets; + u32 debug_ix; + ushort reg_type[32]; + ushort reg_offset[32]; + u32 reg_value[32]; + u32 reg_valueh[32]; }; #define NUM_CFG_SPACES 2 @@ -337,182 +337,182 @@ struct sliccard { #define NUM_CFG_REG_ULONGS (NUM_CFG_REGS / sizeof(u32)) struct physcard { - struct adapter *adapter[SLIC_MAX_PORTS]; - struct physcard *next; - uint adapters_allocd; + struct adapter *adapter[SLIC_MAX_PORTS]; + struct physcard *next; + uint adapters_allocd; - /* the following is not currently needed - u32 bridge_busnum; - u32 bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS]; - */ +/* the following is not currently needed + u32 bridge_busnum; + u32 bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS]; +*/ }; struct base_driver { - struct slic_spinlock driver_lock; - u32 num_slic_cards; - u32 num_slic_ports; - u32 num_slic_ports_active; - u32 dynamic_intagg; - struct sliccard *slic_card; - struct physcard *phys_card; - uint cardnuminuse[SLIC_MAX_CARDS]; + struct slic_spinlock driver_lock; + u32 num_slic_cards; + u32 num_slic_ports; + u32 num_slic_ports_active; + u32 dynamic_intagg; + struct sliccard *slic_card; + struct physcard *phys_card; + uint cardnuminuse[SLIC_MAX_CARDS]; }; struct slic_shmem { - volatile u32 isr; - volatile u32 linkstatus; - volatile struct slic_stats inicstats; + volatile u32 isr; + volatile u32 linkstatus; + volatile struct slic_stats inicstats; }; struct slic_reg_params { - u32 linkspeed; - u32 linkduplex; - u32 fail_on_bad_eeprom; + u32 linkspeed; + u32 linkduplex; + u32 fail_on_bad_eeprom; }; struct slic_upr { - uint adapter; - u32 upr_request; - u32 upr_data; - u32 upr_data_h; - u32 upr_buffer; - u32 upr_buffer_h; - struct slic_upr *next; + uint adapter; + u32 upr_request; + u32 upr_data; + u32 upr_data_h; + u32 upr_buffer; + u32 upr_buffer_h; + struct slic_upr *next; }; struct slic_ifevents { - uint oflow802; - uint uflow802; - uint Tprtoflow; - uint rcvearly; - uint Bufov; - uint Carre; - uint Longe; - uint Invp; - uint Crc; - uint Drbl; - uint Code; - uint IpHlen; - uint IpLen; - uint IpCsum; - uint TpCsum; - uint TpHlen; + uint oflow802; + uint uflow802; + uint Tprtoflow; + uint rcvearly; + uint Bufov; + uint Carre; + uint Longe; + uint Invp; + uint Crc; + uint Drbl; + uint Code; + uint IpHlen; + uint IpLen; + uint IpCsum; + uint TpCsum; + uint TpHlen; }; struct adapter { - void *ifp; - struct sliccard *card; - uint port; - struct physcard *physcard; - uint physport; - uint cardindex; - uint card_size; - uint chipid; - struct net_device *netdev; - struct net_device *next_netdevice; - struct slic_spinlock adapter_lock; - struct slic_spinlock reset_lock; - struct pci_dev *pcidev; - uint busnumber; - uint slotnumber; - uint functionnumber; - ushort vendid; - ushort devid; - ushort subsysid; - u32 irq; - void __iomem *memorybase; - u32 memorylength; - u32 drambase; - u32 dramlength; - uint queues_initialized; - uint allocated; - uint activated; - u32 intrregistered; - uint isp_initialized; - uint gennumber; - u32 curaddrupper; - struct slic_shmem *pshmem; - dma_addr_t phys_shmem; - u32 isrcopy; - __iomem struct slic_regs *slic_regs; - unsigned char state; - unsigned char linkstate; - unsigned char linkspeed; - unsigned char linkduplex; - uint flags; - unsigned char macaddr[6]; - unsigned char currmacaddr[6]; - u32 macopts; - ushort devflags_prev; - u64 mcastmask; - struct mcast_address *mcastaddrs; - struct slic_upr *upr_list; - uint upr_busy; - struct timer_list pingtimer; - u32 pingtimerset; - struct timer_list loadtimer; - u32 loadtimerset; - struct dentry *debugfs_entry; - struct slic_spinlock upr_lock; - struct slic_spinlock bit64reglock; - struct slic_rspqueue rspqueue; - struct slic_rcvqueue rcvqueue; - struct slic_cmdqueue cmdq_free; - struct slic_cmdqueue cmdq_done; - struct slic_cmdqueue cmdq_all; - struct slic_cmdqmem cmdqmem; - /* - * SLIC Handles - */ - struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/ - struct slic_handle *pfree_slic_handles; /* Free object handles*/ - struct slic_spinlock handle_lock; /* Object handle list lock*/ - ushort slic_handle_ix; - - u32 xmitq_full; - u32 all_reg_writes; - u32 icr_reg_writes; - u32 isr_reg_writes; - u32 error_interrupts; - u32 error_rmiss_interrupts; - u32 rx_errors; - u32 rcv_drops; - u32 rcv_interrupts; - u32 xmit_interrupts; - u32 linkevent_interrupts; - u32 upr_interrupts; - u32 num_isrs; - u32 false_interrupts; - u32 tx_packets; - u32 xmit_completes; - u32 tx_drops; - u32 rcv_broadcasts; - u32 rcv_multicasts; - u32 rcv_unicasts; - u32 max_isr_rcvs; - u32 max_isr_xmits; - u32 rcv_interrupt_yields; - u32 intagg_period; - struct inicpm_state *inicpm_info; - void *pinicpm_info; - struct slic_reg_params reg_params; - struct slic_ifevents if_events; - struct slic_stats inicstats_prev; - struct slicnet_stats slic_stats; + void *ifp; + struct sliccard *card; + uint port; + struct physcard *physcard; + uint physport; + uint cardindex; + uint card_size; + uint chipid; + struct net_device *netdev; + struct net_device *next_netdevice; + struct slic_spinlock adapter_lock; + struct slic_spinlock reset_lock; + struct pci_dev *pcidev; + uint busnumber; + uint slotnumber; + uint functionnumber; + ushort vendid; + ushort devid; + ushort subsysid; + u32 irq; + void __iomem *memorybase; + u32 memorylength; + u32 drambase; + u32 dramlength; + uint queues_initialized; + uint allocated; + uint activated; + u32 intrregistered; + uint isp_initialized; + uint gennumber; + u32 curaddrupper; + struct slic_shmem *pshmem; + dma_addr_t phys_shmem; + u32 isrcopy; + __iomem struct slic_regs *slic_regs; + unsigned char state; + unsigned char linkstate; + unsigned char linkspeed; + unsigned char linkduplex; + uint flags; + unsigned char macaddr[6]; + unsigned char currmacaddr[6]; + u32 macopts; + ushort devflags_prev; + u64 mcastmask; + struct mcast_address *mcastaddrs; + struct slic_upr *upr_list; + uint upr_busy; + struct timer_list pingtimer; + u32 pingtimerset; + struct timer_list loadtimer; + u32 loadtimerset; + struct dentry *debugfs_entry; + struct slic_spinlock upr_lock; + struct slic_spinlock bit64reglock; + struct slic_rspqueue rspqueue; + struct slic_rcvqueue rcvqueue; + struct slic_cmdqueue cmdq_free; + struct slic_cmdqueue cmdq_done; + struct slic_cmdqueue cmdq_all; + struct slic_cmdqmem cmdqmem; + /* + * SLIC Handles + */ + struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/ + struct slic_handle *pfree_slic_handles; /* Free object handles*/ + struct slic_spinlock handle_lock; /* Object handle list lock*/ + ushort slic_handle_ix; + + u32 xmitq_full; + u32 all_reg_writes; + u32 icr_reg_writes; + u32 isr_reg_writes; + u32 error_interrupts; + u32 error_rmiss_interrupts; + u32 rx_errors; + u32 rcv_drops; + u32 rcv_interrupts; + u32 xmit_interrupts; + u32 linkevent_interrupts; + u32 upr_interrupts; + u32 num_isrs; + u32 false_interrupts; + u32 tx_packets; + u32 xmit_completes; + u32 tx_drops; + u32 rcv_broadcasts; + u32 rcv_multicasts; + u32 rcv_unicasts; + u32 max_isr_rcvs; + u32 max_isr_xmits; + u32 rcv_interrupt_yields; + u32 intagg_period; + struct inicpm_state *inicpm_info; + void *pinicpm_info; + struct slic_reg_params reg_params; + struct slic_ifevents if_events; + struct slic_stats inicstats_prev; + struct slicnet_stats slic_stats; }; #define UPDATE_STATS(largestat, newstat, oldstat) \ { \ - if ((newstat) < (oldstat)) \ - (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \ - else \ - (largestat) += ((newstat) - (oldstat)); \ + if ((newstat) < (oldstat)) \ + (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \ + else \ + (largestat) += ((newstat) - (oldstat)); \ } #define UPDATE_STATS_GB(largestat, newstat, oldstat) \ { \ - (largestat) += ((newstat) - (oldstat)); \ + (largestat) += ((newstat) - (oldstat)); \ } #if BITS_PER_LONG == 64 diff --git a/drivers/staging/slicoss/slichw.h b/drivers/staging/slicoss/slichw.h index 6275d45..21cd02b 100644 --- a/drivers/staging/slicoss/slichw.h +++ b/drivers/staging/slicoss/slichw.h @@ -450,7 +450,7 @@ struct slic_regs { u32 pad34; #define SLIC_DBAR64 0x0108 - u32 slic_cbar64; /* 64 bit Xmt Cmd buf addr regs. */ + u32 slic_cbar64; /* 64 bit Xmt Cmd buf addr regs. */ u32 pad35; #define SLIC_CBAR64 0x0110 @@ -478,11 +478,11 @@ struct slic_regs { u32 slic_read_xf_info; /* Read Transformer info */ u32 pad41; -#define SLIC_READ_XF_INFO 0x0140 +#define SLIC_READ_XF_INFO 0x0140 u32 slic_write_xf_info; /* Write Transformer info */ u32 pad42; -#define SLIC_WRITE_XF_INFO 0x0148 +#define SLIC_WRITE_XF_INFO 0x0148 u32 RSVD1; /* TOE Only */ u32 pad43; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 78578ee..76fc2e5 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -144,24 +144,24 @@ MODULE_DEVICE_TABLE(pci, slic_pci_tbl); #define SLIC_GET_SLIC_HANDLE(_adapter, _pslic_handle) \ { \ - spin_lock_irqsave(&_adapter->handle_lock.lock, \ + spin_lock_irqsave(&_adapter->handle_lock.lock, \ _adapter->handle_lock.flags); \ - _pslic_handle = _adapter->pfree_slic_handles; \ - if (_pslic_handle) { \ - _adapter->pfree_slic_handles = _pslic_handle->next; \ - } \ - spin_unlock_irqrestore(&_adapter->handle_lock.lock, \ + _pslic_handle = _adapter->pfree_slic_handles; \ + if (_pslic_handle) { \ + _adapter->pfree_slic_handles = _pslic_handle->next; \ + } \ + spin_unlock_irqrestore(&_adapter->handle_lock.lock, \ _adapter->handle_lock.flags); \ } #define SLIC_FREE_SLIC_HANDLE(_adapter, _pslic_handle) \ { \ - _pslic_handle->type = SLIC_HANDLE_FREE; \ - spin_lock_irqsave(&_adapter->handle_lock.lock, \ + _pslic_handle->type = SLIC_HANDLE_FREE; \ + spin_lock_irqsave(&_adapter->handle_lock.lock, \ _adapter->handle_lock.flags); \ - _pslic_handle->next = _adapter->pfree_slic_handles; \ - _adapter->pfree_slic_handles = _pslic_handle; \ - spin_unlock_irqrestore(&_adapter->handle_lock.lock, \ + _pslic_handle->next = _adapter->pfree_slic_handles; \ + _adapter->pfree_slic_handles = _pslic_handle; \ + spin_unlock_irqrestore(&_adapter->handle_lock.lock, \ _adapter->handle_lock.flags); \ } @@ -209,7 +209,7 @@ static u32 slic_crc_init; /* Is table initialized */ */ static void slic_mcast_init_crc32(void) { - u32 c; /* CRC shit reg */ + u32 c; /* CRC reg */ u32 e = 0; /* Poly X-or pattern */ int i; /* counter */ int k; /* byte being shifted into crc */ @@ -2930,11 +2930,14 @@ static int slic_if_init(struct adapter *adapter) } if (!adapter->queues_initialized) { - if ((rc = slic_rspqueue_init(adapter))) + rc = slic_rspqueue_init(adapter); + if (rc) goto err; - if ((rc = slic_cmdq_init(adapter))) + rc = slic_cmdq_init(adapter); + if (rc) goto err; - if ((rc = slic_rcvqueue_init(adapter))) + rc = slic_rcvqueue_init(adapter); + if (rc) goto err; adapter->queues_initialized = 1; } @@ -3437,7 +3440,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) (eecodesize - 2)); /* if the ucdoe chksum flag bit worked, - we wouldn't need this shit + we wouldn't need this */ if (ee_chksum == calc_chksum) card->config.EepromValid = true; diff --git a/drivers/staging/speakup/Kconfig b/drivers/staging/speakup/Kconfig index d288cf0..b416ace 100644 --- a/drivers/staging/speakup/Kconfig +++ b/drivers/staging/speakup/Kconfig @@ -8,7 +8,7 @@ config SPEAKUP video console for blind people. If built in to the kernel, it can speak everything on the text console from boot up to shutdown. For more information on Speakup, - point your browser at http://www.linux-speakup.org/. + point your browser at <http://www.linux-speakup.org/>. There is also a mailing list at the above url that you can subscribe to. diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c index a2db956..382973e 100644 --- a/drivers/staging/speakup/buffers.c +++ b/drivers/staging/speakup/buffers.c @@ -5,12 +5,12 @@ #include "speakup.h" #include "spk_priv.h" -#define synthBufferSize 8192 /* currently 8K bytes */ +#define SYNTH_BUF_SIZE 8192 /* currently 8K bytes */ -static u_char synth_buffer[synthBufferSize]; /* guess what this is for! */ +static u_char synth_buffer[SYNTH_BUF_SIZE]; /* guess what this is for! */ static u_char *buff_in = synth_buffer; static u_char *buff_out = synth_buffer; -static u_char *buffer_end = synth_buffer+synthBufferSize-1; +static u_char *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1; /* These try to throttle applications by stopping the TTYs * Note: we need to make sure that we will restart them eventually, which is @@ -44,13 +44,13 @@ static void speakup_stop_ttys(void) static int synth_buffer_free(void) { - int bytesFree; + int bytes_free; if (buff_in >= buff_out) - bytesFree = synthBufferSize - (buff_in - buff_out); + bytes_free = SYNTH_BUF_SIZE - (buff_in - buff_out); else - bytesFree = buff_out - buff_in; - return bytesFree; + bytes_free = buff_out - buff_in; + return bytes_free; } int synth_buffer_empty(void) diff --git a/drivers/staging/speakup/fakekey.c b/drivers/staging/speakup/fakekey.c index 1b34a87..4299cf4 100644 --- a/drivers/staging/speakup/fakekey.c +++ b/drivers/staging/speakup/fakekey.c @@ -28,7 +28,7 @@ #define PRESSED 1 #define RELEASED 0 -DEFINE_PER_CPU(bool, reporting_keystroke); +static DEFINE_PER_CPU(bool, reporting_keystroke); static struct input_dev *virt_keyboard; diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c index 7c1658b..2add1fc 100644 --- a/drivers/staging/speakup/i18n.c +++ b/drivers/staging/speakup/i18n.c @@ -390,7 +390,7 @@ static struct msg_group_t all_groups[] = { static const int num_groups = sizeof(all_groups) / sizeof(struct msg_group_t); -char *msg_get(enum msg_index_t index) +char *spk_msg_get(enum msg_index_t index) { char *ch; @@ -540,7 +540,7 @@ static int fmt_validate(char *template, char *user) * -EINVAL - Invalid format specifiers in formatted message or illegal index. * -ENOMEM - Unable to allocate memory. */ -ssize_t msg_set(enum msg_index_t index, char *text, size_t length) +ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length) { int rc = 0; char *newstr = NULL; @@ -576,7 +576,7 @@ ssize_t msg_set(enum msg_index_t index, char *text, size_t length) * Find a message group, given its name. Return a pointer to the structure * if found, or NULL otherwise. */ -struct msg_group_t *find_msg_group(const char *group_name) +struct msg_group_t *spk_find_msg_group(const char *group_name) { struct msg_group_t *group = NULL; int i; @@ -590,7 +590,7 @@ struct msg_group_t *find_msg_group(const char *group_name) return group; } -void reset_msg_group(struct msg_group_t *group) +void spk_reset_msg_group(struct msg_group_t *group) { unsigned long flags; enum msg_index_t i; @@ -606,14 +606,14 @@ void reset_msg_group(struct msg_group_t *group) } /* Called at initialization time, to establish default messages. */ -void initialize_msgs(void) +void spk_initialize_msgs(void) { memcpy(speakup_msgs, speakup_default_msgs, sizeof(speakup_default_msgs)); } /* Free user-supplied strings when module is unloaded: */ -void free_user_msgs(void) +void spk_free_user_msgs(void) { enum msg_index_t index; unsigned long flags; diff --git a/drivers/staging/speakup/i18n.h b/drivers/staging/speakup/i18n.h index 65caa80..dd338f4 100644 --- a/drivers/staging/speakup/i18n.h +++ b/drivers/staging/speakup/i18n.h @@ -218,11 +218,11 @@ struct msg_group_t { enum msg_index_t end; }; -extern char *msg_get(enum msg_index_t index); -extern ssize_t msg_set(enum msg_index_t index, char *text, size_t length); -extern struct msg_group_t *find_msg_group(const char *group_name); -extern void reset_msg_group(struct msg_group_t *group); -extern void initialize_msgs(void); -extern void free_user_msgs(void); +extern char *spk_msg_get(enum msg_index_t index); +extern ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length); +extern struct msg_group_t *spk_find_msg_group(const char *group_name); +extern void spk_reset_msg_group(struct msg_group_t *group); +extern void spk_initialize_msgs(void); +extern void spk_free_user_msgs(void); #endif diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c index 170f388..5091625 100644 --- a/drivers/staging/speakup/keyhelp.c +++ b/drivers/staging/speakup/keyhelp.c @@ -115,10 +115,11 @@ static void say_key(int key) key &= 0xff; for (i = 0; i < 6; i++) { if (state & masks[i]) - synth_printf(" %s", msg_get(MSG_STATES_START + i)); + synth_printf(" %s", spk_msg_get(MSG_STATES_START + i)); } if ((key > 0) && (key <= num_key_names)) - synth_printf(" %s\n", msg_get(MSG_KEYNAMES_START + (key - 1))); + synth_printf(" %s\n", + spk_msg_get(MSG_KEYNAMES_START + (key - 1))); } static int help_init(void) @@ -126,9 +127,9 @@ static int help_init(void) char start = SPACE; int i; int num_funcs = MSG_FUNCNAMES_END - MSG_FUNCNAMES_START + 1; -state_tbl = our_keys[0]+SHIFT_TBL_SIZE+2; +state_tbl = spk_our_keys[0]+SHIFT_TBL_SIZE+2; for (i = 0; i < num_funcs; i++) { - char *cur_funcname = msg_get(MSG_FUNCNAMES_START + i); + char *cur_funcname = spk_msg_get(MSG_FUNCNAMES_START + i); if (start == *cur_funcname) continue; start = *cur_funcname; @@ -137,7 +138,7 @@ state_tbl = our_keys[0]+SHIFT_TBL_SIZE+2; return 0; } -int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) +int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) { int i, n; char *name; @@ -147,15 +148,15 @@ int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) help_init(); if (type == KT_LATIN) { if (ch == SPACE) { - special_handler = NULL; - synth_printf("%s\n", msg_get(MSG_LEAVING_HELP)); + spk_special_handler = NULL; + synth_printf("%s\n", spk_msg_get(MSG_LEAVING_HELP)); return 1; } ch |= 32; /* lower case */ if (ch < 'a' || ch > 'z') return -1; if (letter_offsets[ch-'a'] == -1) { - synth_printf(msg_get(MSG_NO_COMMAND), ch); + synth_printf(spk_msg_get(MSG_NO_COMMAND), ch); synth_printf("\n"); return 1; } @@ -169,47 +170,49 @@ int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) cur_item--; else return -1; - } else if (type == KT_SPKUP && ch == SPEAKUP_HELP && !special_handler) { - special_handler = handle_help; - synth_printf("%s\n", msg_get(MSG_HELP_INFO)); + } else if (type == KT_SPKUP + && ch == SPEAKUP_HELP + && !spk_special_handler) { + spk_special_handler = spk_handle_help; + synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO)); build_key_data(); /* rebuild each time in case new mapping */ return 1; } else { name = NULL; if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { synth_printf("%s\n", - msg_get(MSG_KEYNAMES_START + key-1)); + spk_msg_get(MSG_KEYNAMES_START + key-1)); return 1; } for (i = 0; funcvals[i] != 0 && !name; i++) { if (ch == funcvals[i]) - name = msg_get(MSG_FUNCNAMES_START + i); + name = spk_msg_get(MSG_FUNCNAMES_START + i); } if (!name) return -1; - kp = our_keys[key]+1; + kp = spk_our_keys[key]+1; for (i = 0; i < nstates; i++) { if (ch == kp[i]) break; } key += (state_tbl[i] << 8); say_key(key); - synth_printf(msg_get(MSG_KEYDESC), name); + synth_printf(spk_msg_get(MSG_KEYDESC), name); synth_printf("\n"); return 1; } - name = msg_get(MSG_FUNCNAMES_START + cur_item); + name = spk_msg_get(MSG_FUNCNAMES_START + cur_item); func = funcvals[cur_item]; synth_printf("%s", name); if (key_offsets[func] == 0) { - synth_printf(" %s\n", msg_get(MSG_IS_UNASSIGNED)); + synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED)); return 1; } p_keys = key_data + key_offsets[func]; for (n = 0; p_keys[n]; n++) { val = p_keys[n]; if (n > 0) - synth_printf("%s ", msg_get(MSG_DISJUNCTION)); + synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION)); say_key(val); } return 1; diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 2093896..35f647c 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -41,7 +41,7 @@ static ssize_t chars_chartab_show(struct kobject *kobj, break; if (strcmp("characters", attr->attr.name) == 0) { len = scnprintf(buf_pointer, bufsize, "%d\t%s\n", - i, characters[i]); + i, spk_characters[i]); } else { /* show chartab entry */ if (IS_TYPE(i, B_CTL)) cp = "B_CTL"; @@ -185,12 +185,12 @@ static ssize_t chars_chartab_store(struct kobject *kobj, outptr[desc_length] = '\0'; if (do_characters) { - if (characters[index] != default_chars[index]) - kfree(characters[index]); - characters[index] = desc; + if (spk_characters[index] != spk_default_chars[index]) + kfree(spk_characters[index]); + spk_characters[index] = desc; used++; } else { - charclass = chartab_get_value(keyword); + charclass = spk_chartab_get_value(keyword); if (charclass == 0) { rejected++; cp = linefeed + 1; @@ -206,9 +206,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj, if (reset) { if (do_characters) - reset_default_chars(); + spk_reset_default_chars(); else - reset_default_chartab(); + spk_reset_default_chartab(); } spk_unlock(flags); @@ -232,7 +232,7 @@ static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, u_char ch; unsigned long flags; spk_lock(flags); - cp1 = key_buf + SHIFT_TBL_SIZE; + cp1 = spk_key_buf + SHIFT_TBL_SIZE; num_keys = (int)(*cp1); nstates = (int)cp1[1]; cp += sprintf(cp, "%d, %d, %d,\n", KEY_MAP_VER, num_keys, nstates); @@ -271,7 +271,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, return -ENOMEM; } if (strchr("dDrR", *in_buff)) { - set_key_info(key_defaults, key_buf); + spk_set_key_info(spk_key_defaults, spk_key_buf); pr_info("keymap set to default values\n"); kfree(in_buff); spk_unlock(flags); @@ -282,14 +282,14 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, cp = in_buff; cp1 = (u_char *)in_buff; for (i = 0; i < 3; i++) { - cp = s2uchar(cp, cp1); + cp = spk_s2uchar(cp, cp1); cp1++; } i = (int)cp1[-2]+1; i *= (int)cp1[-1]+1; i += 2; /* 0 and last map ver */ if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 || - i+SHIFT_TBL_SIZE+4 >= sizeof(key_buf)) { + i+SHIFT_TBL_SIZE+4 >= sizeof(spk_key_buf)) { pr_warn("i %d %d %d %d\n", i, (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); kfree(in_buff); @@ -297,7 +297,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; } while (--i >= 0) { - cp = s2uchar(cp, cp1); + cp = spk_s2uchar(cp, cp1); cp1++; if (!(*cp)) break; @@ -307,8 +307,8 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, pr_warn("end %d %d %d %d\n", i, (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); } else { - if (set_key_info(in_buff, key_buf)) { - set_key_info(key_defaults, key_buf); + if (spk_set_key_info(in_buff, spk_key_buf)) { + spk_set_key_info(spk_key_defaults, spk_key_buf); ret = -EINVAL; pr_warn("set key failed\n"); } @@ -343,7 +343,7 @@ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, spk_lock(flags); if (ch&2) { shut = 1; - do_flush(); + spk_do_flush(); } else { shut = 0; } @@ -388,7 +388,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, if (new_synth_name[len - 1] == '\n') len--; new_synth_name[len] = '\0'; - strlwr(new_synth_name); + spk_strlwr(new_synth_name); if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { pr_warn("%s already in use\n", new_synth_name); } else if (synth_init(new_synth_name) != 0) { @@ -417,7 +417,7 @@ static ssize_t synth_direct_store(struct kobject *kobj, bytes = min_t(size_t, len, 250); strncpy(tmp, ptr, bytes); tmp[bytes] = '\0'; - xlate(tmp); + spk_xlate(tmp); synth_printf("%s", tmp); ptr += bytes; len -= bytes; @@ -455,14 +455,14 @@ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, short mask; unsigned long flags; - p_header = var_header_by_name(attr->attr.name); + p_header = spk_var_header_by_name(attr->attr.name); if (p_header == NULL) { pr_warn("p_header is null, attr->attr.name is %s\n", attr->attr.name); return -EINVAL; } - var = get_punc_var(p_header->var_id); + var = spk_get_punc_var(p_header->var_id); if (var == NULL) { pr_warn("var is null, p_header->var_id is %i\n", p_header->var_id); @@ -470,7 +470,7 @@ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, } spk_lock(flags); - pb = (struct st_bits_data *) &punc_info[var->value]; + pb = (struct st_bits_data *) &spk_punc_info[var->value]; mask = pb->mask; for (i = 33; i < 128; i++) { if (!(spk_chartab[i]&mask)) @@ -497,14 +497,14 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, if (x < 1 || x > 99) return -EINVAL; - p_header = var_header_by_name(attr->attr.name); + p_header = spk_var_header_by_name(attr->attr.name); if (p_header == NULL) { pr_warn("p_header is null, attr->attr.name is %s\n", attr->attr.name); return -EINVAL; } - var = get_punc_var(p_header->var_id); + var = spk_get_punc_var(p_header->var_id); if (var == NULL) { pr_warn("var is null, p_header->var_id is %i\n", p_header->var_id); @@ -520,9 +520,9 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, spk_lock(flags); if (*punc_buf == 'd' || *punc_buf == 'r') - x = set_mask_bits(0, var->value, 3); + x = spk_set_mask_bits(0, var->value, 3); else - x = set_mask_bits(punc_buf, var->value, 3); + x = spk_set_mask_bits(punc_buf, var->value, 3); spk_unlock(flags); return count; @@ -542,7 +542,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, char ch; unsigned long flags; - param = var_header_by_name(attr->attr.name); + param = spk_var_header_by_name(attr->attr.name); if (param == NULL) return -EINVAL; @@ -599,13 +599,13 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, int value; unsigned long flags; - param = var_header_by_name(attr->attr.name); + param = spk_var_header_by_name(attr->attr.name); if (param == NULL) return -EINVAL; if (param->data == NULL) return 0; ret = 0; - cp = xlate((char *) buf); + cp = spk_xlate((char *) buf); spk_lock(flags); switch (param->var_type) { @@ -618,7 +618,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, else len = E_SET; speakup_s2i(cp, &value); - ret = set_num_var(value, param, len); + ret = spk_set_num_var(value, param, len); if (ret == E_RANGE) { var_data = param->data; pr_warn("value for %s out of range, expect %d to %d\n", @@ -636,7 +636,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, } cp = (char *) buf; cp[len] = '\0'; - ret = set_string_var(buf, param, len); + ret = spk_set_string_var(buf, param, len); if (ret == E_TOOLONG) pr_warn("value too long for %s\n", attr->attr.name); @@ -652,19 +652,19 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, */ if (strcmp(attr->attr.name, "voice") == 0) { if (synth && synth->default_pitch) { - param = var_header_by_name("pitch"); + param = spk_var_header_by_name("pitch"); if (param) { - set_num_var(synth->default_pitch[value], param, - E_NEW_DEFAULT); - set_num_var(0, param, E_DEFAULT); + spk_set_num_var(synth->default_pitch[value], + param, E_NEW_DEFAULT); + spk_set_num_var(0, param, E_DEFAULT); } } if (synth && synth->default_vol) { - param = var_header_by_name("vol"); + param = spk_var_header_by_name("vol"); if (param) { - set_num_var(synth->default_vol[value], param, - E_NEW_DEFAULT); - set_num_var(0, param, E_DEFAULT); + spk_set_num_var(synth->default_vol[value], + param, E_NEW_DEFAULT); + spk_set_num_var(0, param, E_DEFAULT); } } } @@ -694,7 +694,7 @@ static ssize_t message_show_helper(char *buf, enum msg_index_t first, if (bufsize <= 1) break; printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n", - index, msg_get(cursor)); + index, spk_msg_get(cursor)); buf_pointer += printed; bufsize -= printed; } @@ -788,7 +788,7 @@ static ssize_t message_store_helper(const char *buf, size_t count, continue; } - msg_stored = msg_set(curmessage, temp, desc_length); + msg_stored = spk_msg_set(curmessage, temp, desc_length); if (msg_stored < 0) { retval = msg_stored; if (msg_stored == -ENOMEM) @@ -802,7 +802,7 @@ static ssize_t message_store_helper(const char *buf, size_t count, } if (reset) - reset_msg_group(group); + spk_reset_msg_group(group); report_msg_status(reset, received, used, rejected, group->name); return retval; @@ -812,7 +812,7 @@ static ssize_t message_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { ssize_t retval = 0; - struct msg_group_t *group = find_msg_group(attr->attr.name); + struct msg_group_t *group = spk_find_msg_group(attr->attr.name); unsigned long flags; BUG_ON(!group); @@ -826,7 +826,7 @@ static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { ssize_t retval = 0; - struct msg_group_t *group = find_msg_group(attr->attr.name); + struct msg_group_t *group = spk_find_msg_group(attr->attr.name); BUG_ON(!group); retval = message_store_helper(buf, count, group); diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 40e2488..9916e94 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -65,23 +65,23 @@ MODULE_VERSION(SPEAKUP_VERSION); char *synth_name; module_param_named(synth, synth_name, charp, S_IRUGO); -module_param_named(quiet, quiet_boot, bool, S_IRUGO); +module_param_named(quiet, spk_quiet_boot, bool, S_IRUGO); MODULE_PARM_DESC(synth, "Synth to start if speakup is built in."); MODULE_PARM_DESC(quiet, "Do not announce when the synthesizer is found."); -special_func special_handler; +special_func spk_special_handler; -short pitch_shift, synth_flags; +short spk_pitch_shift, synth_flags; static char buf[256]; -int attrib_bleep, bleeps, bleep_time = 10; -int no_intr, spell_delay; -int key_echo, say_word_ctl; -int say_ctrl, bell_pos; -short punc_mask; -int punc_level, reading_punc; -char str_caps_start[MAXVARLEN + 1] = "\0", str_caps_stop[MAXVARLEN + 1] = "\0"; -const struct st_bits_data punc_info[] = { +int spk_attrib_bleep, spk_bleeps, spk_bleep_time = 10; +int spk_no_intr, spk_spell_delay; +int spk_key_echo, spk_say_word_ctl; +int spk_say_ctrl, spk_bell_pos; +short spk_punc_mask; +int spk_punc_level, spk_reading_punc; +char spk_str_caps_start[MAXVARLEN + 1] = "\0", spk_str_caps_stop[MAXVARLEN + 1] = "\0"; +const struct st_bits_data spk_punc_info[] = { {"none", "", 0}, {"some", "/$%&@", SOME}, {"most", "$%&#()=+*/@^<>|\\", MOST}, @@ -95,9 +95,9 @@ const struct st_bits_data punc_info[] = { static char mark_cut_flag; #define MAX_KEY 160 -u_char *our_keys[MAX_KEY], *shift_table; -u_char key_buf[600]; -const u_char key_defaults[] = { +u_char *spk_our_keys[MAX_KEY], *spk_shift_table; +u_char spk_key_buf[600]; +const u_char spk_key_defaults[] = { #include "speakupmap.h" }; @@ -129,9 +129,9 @@ static char *phonetic[] = { /* array of 256 char pointers (one for each character description) * initialized to default_chars and user selectable via * /proc/speakup/characters */ -char *characters[256]; +char *spk_characters[256]; -char *default_chars[256] = { +char *spk_default_chars[256] = { /*000*/ "null", "^a", "^b", "^c", "^d", "^e", "^f", "^g", /*008*/ "^h", "^i", "^j", "^k", "^l", "^m", "^n", "^o", /*016*/ "^p", "^q", "^r", "^s", "^t", "^u", "^v", "^w", @@ -238,7 +238,7 @@ static u_short default_chartab[256] = { }; struct task_struct *speakup_task; -struct bleep unprocessed_sound; +struct bleep spk_unprocessed_sound; static int spk_keydown; static u_char spk_lastkey, spk_close_press, keymap_flags; static u_char last_keycode, this_speakup_key; @@ -251,14 +251,14 @@ DEFINE_MUTEX(spk_mutex); static int keyboard_notifier_call(struct notifier_block *, unsigned long code, void *param); -struct notifier_block keyboard_notifier_block = { +static struct notifier_block keyboard_notifier_block = { .notifier_call = keyboard_notifier_call, }; static int vt_notifier_call(struct notifier_block *, unsigned long code, void *param); -struct notifier_block vt_notifier_block = { +static struct notifier_block vt_notifier_block = { .notifier_call = vt_notifier_call, }; @@ -282,13 +282,13 @@ static void bleep(u_short val) 350, 370, 392, 414, 440, 466, 491, 523, 554, 587, 619, 659 }; short freq; - int time = bleep_time; + int time = spk_bleep_time; freq = vals[val % 12]; if (val > 11) freq *= (1 << (val / 12)); - unprocessed_sound.freq = freq; - unprocessed_sound.jiffies = msecs_to_jiffies(time); - unprocessed_sound.active = 1; + spk_unprocessed_sound.freq = freq; + spk_unprocessed_sound.jiffies = msecs_to_jiffies(time); + spk_unprocessed_sound.active = 1; /* We can only have 1 active sound at a time. */ } @@ -300,7 +300,7 @@ static void speakup_shut_up(struct vc_data *vc) spk_parked &= 0xfe; speakup_date(vc); if (synth != NULL) - do_flush(); + spk_do_flush(); } static void speech_kill(struct vc_data *vc) @@ -313,9 +313,9 @@ static void speech_kill(struct vc_data *vc) if (val == 2 || spk_killed) { /* dead */ spk_shut_up &= ~0x40; - synth_printf("%s\n", msg_get(MSG_IAM_ALIVE)); + synth_printf("%s\n", spk_msg_get(MSG_IAM_ALIVE)); } else { - synth_printf("%s\n", msg_get(MSG_YOU_KILLED_SPEAKUP)); + synth_printf("%s\n", spk_msg_get(MSG_YOU_KILLED_SPEAKUP)); spk_shut_up |= 0x40; } } @@ -324,10 +324,10 @@ static void speakup_off(struct vc_data *vc) { if (spk_shut_up & 0x80) { spk_shut_up &= 0x7f; - synth_printf("%s\n", msg_get(MSG_HEY_THATS_BETTER)); + synth_printf("%s\n", spk_msg_get(MSG_HEY_THATS_BETTER)); } else { spk_shut_up |= 0x80; - synth_printf("%s\n", msg_get(MSG_YOU_TURNED_ME_OFF)); + synth_printf("%s\n", spk_msg_get(MSG_YOU_TURNED_ME_OFF)); } speakup_date(vc); } @@ -336,10 +336,10 @@ static void speakup_parked(struct vc_data *vc) { if (spk_parked & 0x80) { spk_parked = 0; - synth_printf("%s\n", msg_get(MSG_UNPARKED)); + synth_printf("%s\n", spk_msg_get(MSG_UNPARKED)); } else { spk_parked |= 0x80; - synth_printf("%s\n", msg_get(MSG_PARKED)); + synth_printf("%s\n", spk_msg_get(MSG_PARKED)); } } @@ -350,16 +350,16 @@ static void speakup_cut(struct vc_data *vc) if (!mark_cut_flag) { mark_cut_flag = 1; - xs = (u_short) spk_x; - ys = (u_short) spk_y; + spk_xs = (u_short) spk_x; + spk_ys = (u_short) spk_y; spk_sel_cons = vc; - synth_printf("%s\n", msg_get(MSG_MARK)); + synth_printf("%s\n", spk_msg_get(MSG_MARK)); return; } - xe = (u_short) spk_x; - ye = (u_short) spk_y; + spk_xe = (u_short) spk_x; + spk_ye = (u_short) spk_y; mark_cut_flag = 0; - synth_printf("%s\n", msg_get(MSG_CUT)); + synth_printf("%s\n", spk_msg_get(MSG_CUT)); speakup_clear_selection(); ret = speakup_set_selection(tty); @@ -383,9 +383,9 @@ static void speakup_paste(struct vc_data *vc) { if (mark_cut_flag) { mark_cut_flag = 0; - synth_printf("%s\n", msg_get(MSG_MARK_CLEARED)); + synth_printf("%s\n", spk_msg_get(MSG_MARK_CLEARED)); } else { - synth_printf("%s\n", msg_get(MSG_PASTE)); + synth_printf("%s\n", spk_msg_get(MSG_PASTE)); speakup_paste_selection(tty); } } @@ -395,16 +395,16 @@ static void say_attributes(struct vc_data *vc) int fg = spk_attr & 0x0f; int bg = spk_attr >> 4; if (fg > 8) { - synth_printf("%s ", msg_get(MSG_BRIGHT)); + synth_printf("%s ", spk_msg_get(MSG_BRIGHT)); fg -= 8; } - synth_printf("%s", msg_get(MSG_COLORS_START + fg)); + synth_printf("%s", spk_msg_get(MSG_COLORS_START + fg)); if (bg > 7) { - synth_printf(" %s ", msg_get(MSG_ON_BLINKING)); + synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING)); bg -= 8; } else - synth_printf(" %s ", msg_get(MSG_ON)); - synth_printf("%s\n", msg_get(MSG_COLORS_START + bg)); + synth_printf(" %s ", spk_msg_get(MSG_ON)); + synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg)); } enum { @@ -417,24 +417,24 @@ enum { static void announce_edge(struct vc_data *vc, int msg_id) { - if (bleeps & 1) + if (spk_bleeps & 1) bleep(spk_y); - if ((bleeps & 2) && (msg_id < edge_quiet)) - synth_printf("%s\n", msg_get(MSG_EDGE_MSGS_START + msg_id - 1)); + if ((spk_bleeps & 2) && (msg_id < edge_quiet)) + synth_printf("%s\n", spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1)); } static void speak_char(u_char ch) { - char *cp = characters[ch]; - struct var_t *direct = get_var(DIRECT); + char *cp = spk_characters[ch]; + struct var_t *direct = spk_get_var(DIRECT); if (direct && direct->u.n.value) { if (IS_CHAR(ch, B_CAP)) { - pitch_shift++; - synth_printf("%s", str_caps_start); + spk_pitch_shift++; + synth_printf("%s", spk_str_caps_start); } synth_printf("%c", ch); if (IS_CHAR(ch, B_CAP)) - synth_printf("%s", str_caps_stop); + synth_printf("%s", spk_str_caps_stop); return; } if (cp == NULL) { @@ -443,13 +443,13 @@ static void speak_char(u_char ch) } synth_buffer_add(SPACE); if (IS_CHAR(ch, B_CAP)) { - pitch_shift++; - synth_printf("%s", str_caps_start); + spk_pitch_shift++; + synth_printf("%s", spk_str_caps_start); synth_printf("%s", cp); - synth_printf("%s", str_caps_stop); + synth_printf("%s", spk_str_caps_stop); } else { if (*cp == '^') { - synth_printf("%s", msg_get(MSG_CTRL)); + synth_printf("%s", spk_msg_get(MSG_CTRL)); cp++; } synth_printf("%s", cp); @@ -479,9 +479,9 @@ static void say_char(struct vc_data *vc) spk_old_attr = spk_attr; ch = get_char(vc, (u_short *) spk_pos, &spk_attr); if (spk_attr != spk_old_attr) { - if (attrib_bleep & 1) + if (spk_attrib_bleep & 1) bleep(spk_y); - if (attrib_bleep & 2) + if (spk_attrib_bleep & 2) say_attributes(vc); } speak_char(ch & 0xff); @@ -497,7 +497,7 @@ static void say_phonetic_char(struct vc_data *vc) synth_printf("%s\n", phonetic[--ch]); } else { if (IS_CHAR(ch, B_NUM)) - synth_printf("%s ", msg_get(MSG_NUMBER)); + synth_printf("%s ", spk_msg_get(MSG_NUMBER)); speak_char(ch); } } @@ -527,8 +527,8 @@ static void say_next_char(struct vc_data *vc) } /* get_word - will first check to see if the character under the - * reading cursor is a space and if say_word_ctl is true it will - * return the word space. If say_word_ctl is not set it will check to + * reading cursor is a space and if spk_say_word_ctl is true it will + * return the word space. If spk_say_word_ctl is not set it will check to * see if there is a word starting on the next position to the right * and return that word if it exists. If it does not exist it will * move left to the beginning of any previous word on the line or the @@ -544,9 +544,9 @@ static u_long get_word(struct vc_data *vc) ch = (char)get_char(vc, (u_short *) tmp_pos, &temp); /* decided to take out the sayword if on a space (mis-information */ - if (say_word_ctl && ch == SPACE) { + if (spk_say_word_ctl && ch == SPACE) { *buf = '\0'; - synth_printf("%s\n", msg_get(MSG_SPACE)); + synth_printf("%s\n", spk_msg_get(MSG_SPACE)); return 0; } else if ((tmpx < vc->vc_cols - 2) && (ch == SPACE || ch == 0 || IS_WDLM(ch)) @@ -582,13 +582,13 @@ static u_long get_word(struct vc_data *vc) static void say_word(struct vc_data *vc) { u_long cnt = get_word(vc); - u_short saved_punc_mask = punc_mask; + u_short saved_punc_mask = spk_punc_mask; if (cnt == 0) return; - punc_mask = PUNC; + spk_punc_mask = PUNC; buf[cnt++] = SPACE; spkup_write(buf, cnt); - punc_mask = saved_punc_mask; + spk_punc_mask = saved_punc_mask; } static void say_prev_word(struct vc_data *vc) @@ -686,22 +686,22 @@ static void say_next_word(struct vc_data *vc) static void spell_word(struct vc_data *vc) { static char *delay_str[] = { "", ",", ".", ". .", ". . ." }; - char *cp = buf, *str_cap = str_caps_stop; - char *cp1, *last_cap = str_caps_stop; + char *cp = buf, *str_cap = spk_str_caps_stop; + char *cp1, *last_cap = spk_str_caps_stop; u_char ch; if (!get_word(vc)) return; while ((ch = (u_char) *cp)) { if (cp != buf) - synth_printf(" %s ", delay_str[spell_delay]); + synth_printf(" %s ", delay_str[spk_spell_delay]); if (IS_CHAR(ch, B_CAP)) { - str_cap = str_caps_start; - if (*str_caps_stop) - pitch_shift++; + str_cap = spk_str_caps_start; + if (*spk_str_caps_stop) + spk_pitch_shift++; else /* synth has no pitch */ - last_cap = str_caps_stop; + last_cap = spk_str_caps_stop; } else - str_cap = str_caps_stop; + str_cap = spk_str_caps_stop; if (str_cap != last_cap) { synth_printf("%s", str_cap); last_cap = str_cap; @@ -711,17 +711,17 @@ static void spell_word(struct vc_data *vc) ch &= 31; cp1 = phonetic[--ch]; } else { - cp1 = characters[ch]; + cp1 = spk_characters[ch]; if (*cp1 == '^') { - synth_printf("%s", msg_get(MSG_CTRL)); + synth_printf("%s", spk_msg_get(MSG_CTRL)); cp1++; } } synth_printf("%s", cp1); cp++; } - if (str_cap != str_caps_stop) - synth_printf("%s", str_caps_stop); + if (str_cap != spk_str_caps_stop) + synth_printf("%s", spk_str_caps_stop); } static int get_line(struct vc_data *vc) @@ -746,9 +746,9 @@ static void say_line(struct vc_data *vc) { int i = get_line(vc); char *cp; - u_short saved_punc_mask = punc_mask; + u_short saved_punc_mask = spk_punc_mask; if (i == 0) { - synth_printf("%s\n", msg_get(MSG_BLANK)); + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); return; } buf[i++] = '\n'; @@ -758,9 +758,9 @@ static void say_line(struct vc_data *vc) cp++; synth_printf("%d, ", (cp - buf) + 1); } - punc_mask = punc_masks[reading_punc]; + spk_punc_mask = spk_punc_masks[spk_reading_punc]; spkup_write(buf, i); - punc_mask = saved_punc_mask; + spk_punc_mask = saved_punc_mask; } static void say_prev_line(struct vc_data *vc) @@ -792,7 +792,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to, { int i = 0; u_char tmp; - u_short saved_punc_mask = punc_mask; + u_short saved_punc_mask = spk_punc_mask; spk_old_attr = spk_attr; spk_attr = get_attributes((u_short *) from); while (from < to) { @@ -809,10 +809,10 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to, if (i < 1) return i; if (read_punc) - punc_mask = punc_info[reading_punc].mask; + spk_punc_mask = spk_punc_info[spk_reading_punc].mask; spkup_write(buf, i); if (read_punc) - punc_mask = saved_punc_mask; + spk_punc_mask = saved_punc_mask; return i - 1; } @@ -824,7 +824,7 @@ static void say_line_from_to(struct vc_data *vc, u_long from, u_long to, start += from * 2; if (say_from_to(vc, start, end, read_punc) <= 0) if (cursor_track != read_all_mode) - synth_printf("%s\n", msg_get(MSG_BLANK)); + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); } /* Sentence Reading Commands */ @@ -924,7 +924,7 @@ static void speakup_win_say(struct vc_data *vc) { u_long start, end, from, to; if (win_start < 2) { - synth_printf("%s\n", msg_get(MSG_NO_WINDOW)); + synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); return; } start = vc->vc_origin + (win_top * vc->vc_size_row); @@ -975,7 +975,7 @@ static void say_first_char(struct vc_data *vc) u_char ch; spk_parked |= 0x01; if (len == 0) { - synth_printf("%s\n", msg_get(MSG_BLANK)); + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); return; } for (i = 0; i < len; i++) @@ -994,7 +994,7 @@ static void say_last_char(struct vc_data *vc) u_char ch; spk_parked |= 0x01; if (len == 0) { - synth_printf("%s\n", msg_get(MSG_BLANK)); + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); return; } ch = buf[--len]; @@ -1006,7 +1006,7 @@ static void say_last_char(struct vc_data *vc) static void say_position(struct vc_data *vc) { - synth_printf(msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1, + synth_printf(spk_msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1, vc->vc_num + 1); synth_printf("\n"); } @@ -1017,7 +1017,7 @@ static void say_char_num(struct vc_data *vc) u_char tmp; u_short ch = get_char(vc, (u_short *) spk_pos, &tmp); ch &= 0xff; - synth_printf(msg_get(MSG_CHAR_INFO), ch, ch); + synth_printf(spk_msg_get(MSG_CHAR_INFO), ch, ch); } /* these are stub functions to keep keyboard.c happy. */ @@ -1066,7 +1066,7 @@ static void spkup_write(const char *in_buf, int count) } else { if ((last_type & CH_RPT) && rep_count > 2) { synth_printf(" "); - synth_printf(msg_get(MSG_REPEAT_DESC), + synth_printf(spk_msg_get(MSG_REPEAT_DESC), ++rep_count); synth_printf(" "); } @@ -1074,7 +1074,7 @@ static void spkup_write(const char *in_buf, int count) } if (ch == spk_lastkey) { rep_count = 0; - if (key_echo == 1 && ch >= MINECHOCHAR) + if (spk_key_echo == 1 && ch >= MINECHOCHAR) speak_char(ch); } else if (char_type & B_ALPHA) { if ((synth_flags & SF_DEC) && (last_type & PUNC)) @@ -1083,7 +1083,7 @@ static void spkup_write(const char *in_buf, int count) } else if (char_type & B_NUM) { rep_count = 0; synth_printf("%c", ch); - } else if (char_type & punc_mask) { + } else if (char_type & spk_punc_mask) { speak_char(ch); char_type &= ~PUNC; /* for dec nospell processing */ } else if (char_type & SYNTH_OK) { @@ -1111,7 +1111,7 @@ static void spkup_write(const char *in_buf, int count) if (in_count > 2 && rep_count > 2) { if (last_type & CH_RPT) { synth_printf(" "); - synth_printf(msg_get(MSG_REPEAT_DESC2), ++rep_count); + synth_printf(spk_msg_get(MSG_REPEAT_DESC2), ++rep_count); synth_printf(" "); } rep_count = 0; @@ -1135,22 +1135,22 @@ static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag) case KVAL(K_SHIFT): del_timer(&cursor_timer); spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); read_all_doc(vc); break; case KVAL(K_CTRL): del_timer(&cursor_timer); cursor_track = prev_cursor_track; spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); break; } } else { spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); } - if (say_ctrl && value < NUM_CTL_LABELS) - synth_printf("%s", msg_get(MSG_CTL_START + value)); + if (spk_say_ctrl && value < NUM_CTL_LABELS) + synth_printf("%s", spk_msg_get(MSG_CTL_START + value)); spk_unlock(flags); } @@ -1171,12 +1171,12 @@ static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag) spk_lastkey = value; spk_keydown++; spk_parked &= 0xfe; - if (key_echo == 2 && value >= MINECHOCHAR) + if (spk_key_echo == 2 && value >= MINECHOCHAR) speak_char(value); spk_unlock(flags); } -int set_key_info(const u_char *key_info, u_char *k_buffer) +int spk_set_key_info(const u_char *key_info, u_char *k_buffer) { int i = 0, states, key_data_len; const u_char *cp = key_info; @@ -1188,12 +1188,12 @@ int set_key_info(const u_char *key_info, u_char *k_buffer) num_keys = *cp; states = (int)cp[1]; key_data_len = (states + 1) * (num_keys + 1); - if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(key_buf)) + if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) return -2; memset(k_buffer, 0, SHIFT_TBL_SIZE); - memset(our_keys, 0, sizeof(our_keys)); - shift_table = k_buffer; - our_keys[0] = shift_table; + memset(spk_our_keys, 0, sizeof(spk_our_keys)); + spk_shift_table = k_buffer; + spk_our_keys[0] = spk_shift_table; cp1 += SHIFT_TBL_SIZE; memcpy(cp1, cp, key_data_len + 3); /* get num_keys, states and data */ @@ -1202,13 +1202,13 @@ int set_key_info(const u_char *key_info, u_char *k_buffer) ch = *cp1++; if (ch >= SHIFT_TBL_SIZE) return -3; - shift_table[ch] = i; + spk_shift_table[ch] = i; } keymap_flags = *cp1++; while ((ch = *cp1)) { if (ch >= MAX_KEY) return -4; - our_keys[ch] = cp1; + spk_our_keys[ch] = cp1; cp1 += states + 1; } return 0; @@ -1237,24 +1237,24 @@ static void toggle_cursoring(struct vc_data *vc) cursor_track = prev_cursor_track; if (++cursor_track >= CT_Max) cursor_track = 0; - synth_printf("%s\n", msg_get(MSG_CURSOR_MSGS_START + cursor_track)); + synth_printf("%s\n", spk_msg_get(MSG_CURSOR_MSGS_START + cursor_track)); } -void reset_default_chars(void) +void spk_reset_default_chars(void) { int i; /* First, free any non-default */ for (i = 0; i < 256; i++) { - if ((characters[i] != NULL) - && (characters[i] != default_chars[i])) - kfree(characters[i]); + if ((spk_characters[i] != NULL) + && (spk_characters[i] != spk_default_chars[i])) + kfree(spk_characters[i]); } - memcpy(characters, default_chars, sizeof(default_chars)); + memcpy(spk_characters, spk_default_chars, sizeof(spk_default_chars)); } -void reset_default_chartab(void) +void spk_reset_default_chartab(void) { memcpy(spk_chartab, default_chartab, sizeof(default_chartab)); } @@ -1267,8 +1267,8 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key) if (type != KT_LATIN || (ch_type & B_NUM) || ch < SPACE) return -1; if (ch == SPACE) { - synth_printf("%s\n", msg_get(MSG_EDIT_DONE)); - special_handler = NULL; + synth_printf("%s\n", spk_msg_get(MSG_EDIT_DONE)); + spk_special_handler = NULL; return 1; } if (mask < PUNC && !(ch_type & PUNC)) @@ -1276,8 +1276,8 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key) spk_chartab[ch] ^= mask; speak_char(ch); synth_printf(" %s\n", - (spk_chartab[ch] & mask) ? msg_get(MSG_ON) : - msg_get(MSG_OFF)); + (spk_chartab[ch] & mask) ? spk_msg_get(MSG_ON) : + spk_msg_get(MSG_OFF)); return 1; } @@ -1346,7 +1346,7 @@ static void read_all_doc(struct vc_data *vc) if (cursor_track != read_all_mode) prev_cursor_track = cursor_track; cursor_track = read_all_mode; - reset_index_count(0); + spk_reset_index_count(0); if (get_sentence_buf(vc, 0) == -1) kbd_fakekey2(vc, RA_DOWN_ARROW); else { @@ -1361,7 +1361,7 @@ static void stop_read_all(struct vc_data *vc) del_timer(&cursor_timer); cursor_track = prev_cursor_track; spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); } static void start_read_all_timer(struct vc_data *vc, int command) @@ -1370,7 +1370,7 @@ static void start_read_all_timer(struct vc_data *vc, int command) cursor_con = vc->vc_num; read_all_key = command; - cursor_timeout = get_var(CURSOR_TIME); + cursor_timeout = spk_get_var(CURSOR_TIME); mod_timer(&cursor_timer, jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); } @@ -1382,9 +1382,9 @@ static void handle_cursor_read_all(struct vc_data *vc, int command) switch (command) { case RA_NEXT_SENT: /* Get Current Sentence */ - get_index_count(&indcount, &sentcount); + spk_get_index_count(&indcount, &sentcount); /*printk("%d %d ", indcount, sentcount); */ - reset_index_count(sentcount + 1); + spk_reset_index_count(sentcount + 1); if (indcount == 1) { if (!say_sentence_num(sentcount + 1, 0)) { kbd_fakekey2(vc, RA_FIND_NEXT_SENT); @@ -1395,7 +1395,7 @@ static void handle_cursor_read_all(struct vc_data *vc, int command) sn = 0; if (!say_sentence_num(sentcount + 1, 1)) { sn = 1; - reset_index_count(sn); + spk_reset_index_count(sn); } else synth_insert_next_index(0); if (!say_sentence_num(sn, 0)) { @@ -1437,7 +1437,7 @@ static void handle_cursor_read_all(struct vc_data *vc, int command) case RA_FIND_PREV_SENT: break; case RA_TIMER: - get_index_count(&indcount, &sentcount); + spk_get_index_count(&indcount, &sentcount); if (indcount < 2) kbd_fakekey2(vc, RA_DOWN_ARROW); else @@ -1458,7 +1458,7 @@ static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag) } del_timer(&cursor_timer); spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); start_read_all_timer(vc, value + 1); spk_unlock(flags); return NOTIFY_STOP; @@ -1479,8 +1479,8 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag) return; } spk_shut_up &= 0xfe; - if (no_intr) - do_flush(); + if (spk_no_intr) + spk_do_flush(); /* the key press flushes if !no_inter but we want to flush on cursor * moves regardless of no_inter state */ is_cursor = value + 1; @@ -1491,7 +1491,7 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag) cursor_con = vc->vc_num; if (cursor_track == CT_Highlight) reset_highlight_buffers(vc); - cursor_timeout = get_var(CURSOR_TIME); + cursor_timeout = spk_get_var(CURSOR_TIME); mod_timer(&cursor_timer, jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); spk_unlock(flags); @@ -1603,7 +1603,7 @@ static int speak_highlight(struct vc_data *vc) if (speakup_console[vc_num]->ht.ry[hc] != vc->vc_y) return 0; spk_parked |= 0x01; - do_flush(); + spk_do_flush(); spkup_write(speakup_console[vc_num]->ht.highbuf[hc], speakup_console[vc_num]->ht.highsize[hc]); spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc]; @@ -1685,7 +1685,7 @@ static void speakup_con_write(struct vc_data *vc, const char *str, int len) if (!spk_trylock(flags)) /* Speakup output, discard */ return; - if (bell_pos && spk_keydown && (vc->vc_x == bell_pos - 1)) + if (spk_bell_pos && spk_keydown && (vc->vc_x == spk_bell_pos - 1)) bleep(3); if ((is_cursor) || (cursor_track == read_all_mode)) { if (cursor_track == CT_Highlight) @@ -1726,19 +1726,19 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag) return; spk_lock(flags); spk_shut_up &= 0xfe; - if (no_intr) - do_flush(); + if (spk_no_intr) + spk_do_flush(); switch (value) { case KVAL(K_CAPS): - label = msg_get(MSG_KEYNAME_CAPSLOCK); + label = spk_msg_get(MSG_KEYNAME_CAPSLOCK); on_off = vt_get_leds(fg_console, VC_CAPSLOCK); break; case KVAL(K_NUM): - label = msg_get(MSG_KEYNAME_NUMLOCK); + label = spk_msg_get(MSG_KEYNAME_NUMLOCK); on_off = vt_get_leds(fg_console, VC_NUMLOCK); break; case KVAL(K_HOLD): - label = msg_get(MSG_KEYNAME_SCROLLLOCK); + label = spk_msg_get(MSG_KEYNAME_SCROLLLOCK); on_off = vt_get_leds(fg_console, VC_SCROLLOCK); if (speakup_console[vc->vc_num]) speakup_console[vc->vc_num]->tty_stopped = on_off; @@ -1750,7 +1750,7 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag) } if (on_off < 2) synth_printf("%s %s\n", - label, msg_get(MSG_STATUS_START + on_off)); + label, spk_msg_get(MSG_STATUS_START + on_off)); spk_unlock(flags); } @@ -1764,13 +1764,13 @@ static int inc_dec_var(u_char value) int var_id = (int)value - VAR_START; int how = (var_id & 1) ? E_INC : E_DEC; var_id = var_id / 2 + FIRST_SET_VAR; - p_header = get_var_header(var_id); + p_header = spk_get_var_header(var_id); if (p_header == NULL) return -1; if (p_header->var_type != VAR_NUM) return -1; var_data = p_header->data; - if (set_num_var(1, p_header, how) != 0) + if (spk_set_num_var(1, p_header, how) != 0) return -1; if (!spk_close_press) { for (pn = p_header->name; *pn; pn++) { @@ -1790,18 +1790,18 @@ static void speakup_win_set(struct vc_data *vc) { char info[40]; if (win_start > 1) { - synth_printf("%s\n", msg_get(MSG_WINDOW_ALREADY_SET)); + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_ALREADY_SET)); return; } if (spk_x < win_left || spk_y < win_top) { - synth_printf("%s\n", msg_get(MSG_END_BEFORE_START)); + synth_printf("%s\n", spk_msg_get(MSG_END_BEFORE_START)); return; } if (win_start && spk_x == win_left && spk_y == win_top) { win_left = 0; win_right = vc->vc_cols - 1; win_bottom = spk_y; - snprintf(info, sizeof(info), msg_get(MSG_WINDOW_LINE), + snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_LINE), (int)win_top + 1); } else { if (!win_start) { @@ -1811,8 +1811,8 @@ static void speakup_win_set(struct vc_data *vc) win_bottom = spk_y; win_right = spk_x; } - snprintf(info, sizeof(info), msg_get(MSG_WINDOW_BOUNDARY), - (win_start) ? msg_get(MSG_END) : msg_get(MSG_START), + snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_BOUNDARY), + (win_start) ? spk_msg_get(MSG_END) : spk_msg_get(MSG_START), (int)spk_y + 1, (int)spk_x + 1); } synth_printf("%s\n", info); @@ -1824,32 +1824,32 @@ static void speakup_win_clear(struct vc_data *vc) win_top = win_bottom = 0; win_left = win_right = 0; win_start = 0; - synth_printf("%s\n", msg_get(MSG_WINDOW_CLEARED)); + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_CLEARED)); } static void speakup_win_enable(struct vc_data *vc) { if (win_start < 2) { - synth_printf("%s\n", msg_get(MSG_NO_WINDOW)); + synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); return; } win_enabled ^= 1; if (win_enabled) - synth_printf("%s\n", msg_get(MSG_WINDOW_SILENCED)); + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCED)); else - synth_printf("%s\n", msg_get(MSG_WINDOW_SILENCE_DISABLED)); + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCE_DISABLED)); } static void speakup_bits(struct vc_data *vc) { int val = this_speakup_key - (FIRST_EDIT_BITS - 1); - if (special_handler != NULL || val < 1 || val > 6) { - synth_printf("%s\n", msg_get(MSG_ERROR)); + if (spk_special_handler != NULL || val < 1 || val > 6) { + synth_printf("%s\n", spk_msg_get(MSG_ERROR)); return; } - pb_edit = &punc_info[val]; - synth_printf(msg_get(MSG_EDIT_PROMPT), pb_edit->name); - special_handler = edit_bits; + pb_edit = &spk_punc_info[val]; + synth_printf(spk_msg_get(MSG_EDIT_PROMPT), pb_edit->name); + spk_special_handler = edit_bits; } static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key) @@ -1887,9 +1887,9 @@ static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key) if (ch < 'x' || ch > 'y') { oops: if (!spk_killed) - synth_printf(" %s\n", msg_get(MSG_GOTO_CANCELED)); + synth_printf(" %s\n", spk_msg_get(MSG_GOTO_CANCELED)); goto_buf[num = 0] = '\0'; - special_handler = NULL; + spk_special_handler = NULL; return 1; } cp = speakup_s2i(goto_buf, &go_pos); @@ -1917,7 +1917,7 @@ oops: } goto_buf[num = 0] = '\0'; do_goto: - special_handler = NULL; + spk_special_handler = NULL; spk_parked |= 0x01; if (goto_x) { spk_pos -= spk_x * 2; @@ -1934,18 +1934,18 @@ do_goto: static void speakup_goto(struct vc_data *vc) { - if (special_handler != NULL) { - synth_printf("%s\n", msg_get(MSG_ERROR)); + if (spk_special_handler != NULL) { + synth_printf("%s\n", spk_msg_get(MSG_ERROR)); return; } - synth_printf("%s\n", msg_get(MSG_GOTO)); - special_handler = handle_goto; + synth_printf("%s\n", spk_msg_get(MSG_GOTO)); + spk_special_handler = handle_goto; return; } static void speakup_help(struct vc_data *vc) { - handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0); + spk_handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0); } static void do_nothing(struct vc_data *vc) @@ -1992,7 +1992,7 @@ static void do_spkup(struct vc_data *vc, u_char value) spk_shut_up &= 0xfe; this_speakup_key = value; if (value < SPKUP_MAX_FUNC && spkup_handler[value]) { - do_flush(); + spk_do_flush(); (*spkup_handler[value]) (vc); } else { if (inc_dec_var(value) < 0) @@ -2032,7 +2032,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, } if (keycode >= MAX_KEY) goto no_map; - key_info = our_keys[keycode]; + key_info = spk_our_keys[keycode]; if (key_info == 0) goto no_map; /* Check valid read all mode keys */ @@ -2051,7 +2051,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, } } shift_info = (shift_state & 0x0f) + key_speakup; - offset = shift_table[shift_info]; + offset = spk_shift_table[shift_info]; if (offset) { new_key = key_info[offset]; if (new_key) { @@ -2062,7 +2062,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, if (up_flag || spk_killed) goto out; spk_shut_up &= 0xfe; - do_flush(); + spk_do_flush(); goto out; } if (up_flag) @@ -2070,7 +2070,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, if (last_keycode == keycode && last_spk_jiffy + MAX_DELAY > jiffies) { spk_close_press = 1; - offset = shift_table[shift_info + 32]; + offset = spk_shift_table[shift_info + 32]; /* double press? */ if (offset && key_info[offset]) new_key = key_info[offset]; @@ -2082,7 +2082,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, } } no_map: - if (type == KT_SPKUP && special_handler == NULL) { + if (type == KT_SPKUP && spk_special_handler == NULL) { do_spkup(vc, new_key); spk_close_press = 0; ret = 1; @@ -2096,9 +2096,9 @@ no_map: || (value == KVAL(K_LEFT)) || (value == KVAL(K_RIGHT)); if ((cursor_track != read_all_mode) || !kh) - if (!no_intr) - do_flush(); - if (special_handler) { + if (!spk_no_intr) + spk_do_flush(); + if (spk_special_handler) { if (type == KT_SPEC && value == 1) { value = '\n'; type = KT_LATIN; @@ -2106,7 +2106,7 @@ no_map: type = KT_LATIN; else if (value == 0x7f) value = 8; /* make del = backspace */ - ret = (*special_handler) (vc, type, value, keycode); + ret = (*spk_special_handler) (vc, type, value, keycode); spk_close_press = 0; if (ret < 0) bleep(9); @@ -2237,11 +2237,11 @@ static void __exit speakup_exit(void) speakup_unregister_var(i); for (i = 0; i < 256; i++) { - if (characters[i] != default_chars[i]) - kfree(characters[i]); + if (spk_characters[i] != spk_default_chars[i]) + kfree(spk_characters[i]); } - free_user_msgs(); + spk_free_user_msgs(); } /* call by: module_init() */ @@ -2254,20 +2254,20 @@ static int __init speakup_init(void) struct var_t *var; /* These first few initializations cannot fail. */ - initialize_msgs(); /* Initialize arrays for i18n. */ - reset_default_chars(); - reset_default_chartab(); - strlwr(synth_name); + spk_initialize_msgs(); /* Initialize arrays for i18n. */ + spk_reset_default_chars(); + spk_reset_default_chartab(); + spk_strlwr(synth_name); spk_vars[0].u.n.high = vc->vc_cols; for (var = spk_vars; var->var_id != MAXVARS; var++) speakup_register_var(var); for (var = synth_time_vars; (var->var_id >= 0) && (var->var_id < MAXVARS); var++) speakup_register_var(var); - for (i = 1; punc_info[i].mask != 0; i++) - set_mask_bits(0, i, 2); + for (i = 1; spk_punc_info[i].mask != 0; i++) + spk_set_mask_bits(0, i, 2); - set_key_info(key_defaults, key_buf); + spk_set_key_info(spk_key_defaults, spk_key_buf); /* From here on out, initializations can fail. */ err = speakup_add_virtual_keyboard(); @@ -2290,7 +2290,7 @@ static int __init speakup_init(void) goto error_kobjects; } - if (quiet_boot) + if (spk_quiet_boot) spk_shut_up |= 0x01; err = speakup_kobj_init(); @@ -2352,11 +2352,11 @@ error_virtkeyboard: speakup_unregister_var(i); for (i = 0; i < 256; i++) { - if (characters[i] != default_chars[i]) - kfree(characters[i]); + if (spk_characters[i] != spk_default_chars[i]) + kfree(spk_characters[i]); } - free_user_msgs(); + spk_free_user_msgs(); out: return err; diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c index 0612df0..822ac3d 100644 --- a/drivers/staging/speakup/selection.c +++ b/drivers/staging/speakup/selection.c @@ -10,7 +10,7 @@ /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */ #define ishardspace(c) ((c) == ' ') -unsigned short xs, ys, xe, ye; /* our region points */ +unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ /* Variables for selection control. */ /* must not be disallocated */ @@ -51,12 +51,12 @@ int speakup_set_selection(struct tty_struct *tty) int i, ps, pe; struct vc_data *vc = vc_cons[fg_console].d; - xs = limit(xs, vc->vc_cols - 1); - ys = limit(ys, vc->vc_rows - 1); - xe = limit(xe, vc->vc_cols - 1); - ye = limit(ye, vc->vc_rows - 1); - ps = ys * vc->vc_size_row + (xs << 1); - pe = ye * vc->vc_size_row + (xe << 1); + spk_xs = limit(spk_xs, vc->vc_cols - 1); + spk_ys = limit(spk_ys, vc->vc_rows - 1); + spk_xe = limit(spk_xe, vc->vc_cols - 1); + spk_ye = limit(spk_ye, vc->vc_rows - 1); + ps = spk_ys * vc->vc_size_row + (spk_xs << 1); + pe = spk_ye * vc->vc_size_row + (spk_xe << 1); if (ps > pe) { /* make sel_start <= sel_end */ @@ -95,7 +95,6 @@ int speakup_set_selection(struct tty_struct *tty) /* Allocate a new buffer before freeing the old one ... */ bp = kmalloc((sel_end-sel_start)/2+1, GFP_ATOMIC); if (!bp) { - dev_warn(tty->dev, "selection: kmalloc() failed\n"); speakup_clear_selection(); return -ENOMEM; } diff --git a/drivers/staging/speakup/serialio.c b/drivers/staging/speakup/serialio.c index a97d3d5..e4d27aa 100644 --- a/drivers/staging/speakup/serialio.c +++ b/drivers/staging/speakup/serialio.c @@ -116,7 +116,7 @@ static void start_serial_interrupt(int irq) outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */ } -void stop_serial_interrupt(void) +void spk_stop_serial_interrupt(void) { if (speakup_info.port_tts == 0) return; @@ -130,7 +130,7 @@ void stop_serial_interrupt(void) free_irq(serstate->irq, (void *) synth_readbuf_handler); } -int wait_for_xmitr(void) +int spk_wait_for_xmitr(void) { int tmout = SPK_XMITR_TIMEOUT; if ((synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) { @@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(spk_serial_in_nowait); int spk_serial_out(const char ch) { - if (synth->alive && wait_for_xmitr()) { + if (synth->alive && spk_wait_for_xmitr()) { outb_p(ch, speakup_info.port_tts); return 1; } diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h index e66579e..22f0fbb 100644 --- a/drivers/staging/speakup/speakup.h +++ b/drivers/staging/speakup/speakup.h @@ -50,34 +50,34 @@ #define E_UNDEF -1 extern int speakup_thread(void *data); -extern void reset_default_chars(void); -extern void reset_default_chartab(void); +extern void spk_reset_default_chars(void); +extern void spk_reset_default_chartab(void); extern void synth_start(void); void synth_insert_next_index(int sent_num); -void reset_index_count(int sc); -void get_index_count(int *linecount, int *sentcount); -extern int set_key_info(const u_char *key_info, u_char *k_buffer); -extern char *strlwr(char *s); +void spk_reset_index_count(int sc); +void spk_get_index_count(int *linecount, int *sentcount); +extern int spk_set_key_info(const u_char *key_info, u_char *k_buffer); +extern char *spk_strlwr(char *s); extern char *speakup_s2i(char *start, int *dest); -extern char *s2uchar(char *start, char *dest); -extern char *xlate(char *s); +extern char *spk_s2uchar(char *start, char *dest); +extern char *spk_xlate(char *s); extern int speakup_kobj_init(void); extern void speakup_kobj_exit(void); -extern int chartab_get_value(char *keyword); +extern int spk_chartab_get_value(char *keyword); extern void speakup_register_var(struct var_t *var); extern void speakup_unregister_var(enum var_id_t var_id); -extern struct st_var_header *get_var_header(enum var_id_t var_id); -extern struct st_var_header *var_header_by_name(const char *name); -extern struct punc_var_t *get_punc_var(enum var_id_t var_id); -extern int set_num_var(int val, struct st_var_header *var, int how); -extern int set_string_var(const char *page, struct st_var_header *var, int len); -extern int set_mask_bits(const char *input, const int which, const int how); -extern special_func special_handler; -extern int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key); +extern struct st_var_header *spk_get_var_header(enum var_id_t var_id); +extern struct st_var_header *spk_var_header_by_name(const char *name); +extern struct punc_var_t *spk_get_punc_var(enum var_id_t var_id); +extern int spk_set_num_var(int val, struct st_var_header *var, int how); +extern int spk_set_string_var(const char *page, struct st_var_header *var, int len); +extern int spk_set_mask_bits(const char *input, const int which, const int how); +extern special_func spk_special_handler; +extern int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key); extern int synth_init(char *name); extern void synth_release(void); -extern void do_flush(void); +extern void spk_do_flush(void); extern void speakup_start_ttys(void); extern void synth_buffer_add(char ch); extern void synth_buffer_clear(void); @@ -90,35 +90,35 @@ extern void synth_write(const char *buf, size_t count); extern int synth_supports_indexing(void); extern struct vc_data *spk_sel_cons; -extern unsigned short xs, ys, xe, ye; /* our region points */ +extern unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ extern wait_queue_head_t speakup_event; extern struct kobject *speakup_kobj; extern struct task_struct *speakup_task; -extern const u_char key_defaults[]; +extern const u_char spk_key_defaults[]; /* Protect speakup synthesizer list */ extern struct mutex spk_mutex; extern struct st_spk_t *speakup_console[]; extern struct spk_synth *synth; -extern char pitch_buff[]; -extern u_char *our_keys[]; -extern short punc_masks[]; -extern char str_caps_start[], str_caps_stop[]; -extern const struct st_bits_data punc_info[]; -extern u_char key_buf[600]; -extern char *characters[]; -extern char *default_chars[]; +extern char spk_pitch_buff[]; +extern u_char *spk_our_keys[]; +extern short spk_punc_masks[]; +extern char spk_str_caps_start[], spk_str_caps_stop[]; +extern const struct st_bits_data spk_punc_info[]; +extern u_char spk_key_buf[600]; +extern char *spk_characters[]; +extern char *spk_default_chars[]; extern u_short spk_chartab[]; -extern int no_intr, say_ctrl, say_word_ctl, punc_level; -extern int reading_punc, attrib_bleep, bleeps; -extern int bleep_time, bell_pos; -extern int spell_delay, key_echo; -extern short punc_mask; -extern short pitch_shift, synth_flags; -extern bool quiet_boot; +extern int spk_no_intr, spk_say_ctrl, spk_say_word_ctl, spk_punc_level; +extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps; +extern int spk_bleep_time, spk_bell_pos; +extern int spk_spell_delay, spk_key_echo; +extern short spk_punc_mask; +extern short spk_pitch_shift, synth_flags; +extern bool spk_quiet_boot; extern char *synth_name; -extern struct bleep unprocessed_sound; +extern struct bleep spk_unprocessed_sound; /* Prototypes from fakekey.c. */ int speakup_add_virtual_keyboard(void); diff --git a/drivers/staging/speakup/speakup_acntpc.c b/drivers/staging/speakup/speakup_acntpc.c index bbe28b6..1c1f0d5 100644 --- a/drivers/staging/speakup/speakup_acntpc.c +++ b/drivers/staging/speakup/speakup_acntpc.c @@ -182,9 +182,9 @@ static void do_catch_up(struct spk_synth *synth) struct var_t *full_time; struct var_t *jiffy_delta; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); - full_time = get_var(FULL); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; diff --git a/drivers/staging/speakup/speakup_acntsa.c b/drivers/staging/speakup/speakup_acntsa.c index 590fa6b..22a8b72 100644 --- a/drivers/staging/speakup/speakup_acntsa.c +++ b/drivers/staging/speakup/speakup_acntsa.c @@ -128,7 +128,7 @@ static int synth_probe(struct spk_synth *synth) { int failed; - failed = serial_synth_probe(synth); + failed = spk_serial_synth_probe(synth); if (failed == 0) { spk_synth_immediate(synth, "\033=R\r"); mdelay(100); diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c index 00d5ced..3e450cc 100644 --- a/drivers/staging/speakup/speakup_apollo.c +++ b/drivers/staging/speakup/speakup_apollo.c @@ -112,7 +112,7 @@ static struct spk_synth synth_apollo = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = do_catch_up, @@ -145,9 +145,9 @@ static void do_catch_up(struct spk_synth *synth) int delay_time_val = 0; int jiffy_delta_val = 0; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); - full_time = get_var(FULL); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; spk_unlock(flags); diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c index 94e5099..3508aee 100644 --- a/drivers/staging/speakup/speakup_audptr.c +++ b/drivers/staging/speakup/speakup_audptr.c @@ -162,7 +162,7 @@ static int synth_probe(struct spk_synth *synth) { int failed = 0; - failed = serial_synth_probe(synth); + failed = spk_serial_synth_probe(synth); if (failed == 0) synth_version(synth); synth->alive = !failed; diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c index 43e5b54..4bfe3d4 100644 --- a/drivers/staging/speakup/speakup_bns.c +++ b/drivers/staging/speakup/speakup_bns.c @@ -100,7 +100,7 @@ static struct spk_synth synth_bns = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = spk_do_catch_up, diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c index b4ef915..d39a0de 100644 --- a/drivers/staging/speakup/speakup_decext.c +++ b/drivers/staging/speakup/speakup_decext.c @@ -130,7 +130,7 @@ static struct spk_synth synth_decext = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = do_catch_up, @@ -162,8 +162,8 @@ static void do_catch_up(struct spk_synth *synth) int jiffy_delta_val = 0; int delay_time_val = 0; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c index a09a0c9..6c88b55 100644 --- a/drivers/staging/speakup/speakup_decpc.c +++ b/drivers/staging/speakup/speakup_decpc.c @@ -375,8 +375,8 @@ static void do_catch_up(struct spk_synth *synth) int jiffy_delta_val; int delay_time_val; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; spk_unlock(flags); diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c index daff3b9..0dd2eb9 100644 --- a/drivers/staging/speakup/speakup_dectlk.c +++ b/drivers/staging/speakup/speakup_dectlk.c @@ -134,7 +134,7 @@ static struct spk_synth synth_dectlk = { .vars = vars, .default_pitch = ap_defaults, .default_vol = g5_defaults, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = do_catch_up, @@ -214,8 +214,8 @@ static void do_catch_up(struct spk_synth *synth) int jiffy_delta_val; int delay_time_val; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; spk_unlock(flags); diff --git a/drivers/staging/speakup/speakup_dtlk.c b/drivers/staging/speakup/speakup_dtlk.c index 97bc476..a9cefbd 100644 --- a/drivers/staging/speakup/speakup_dtlk.c +++ b/drivers/staging/speakup/speakup_dtlk.c @@ -198,8 +198,8 @@ static void do_catch_up(struct spk_synth *synth) int jiffy_delta_val; int delay_time_val; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; spk_unlock(flags); diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c index c20f411..4a24b9c 100644 --- a/drivers/staging/speakup/speakup_dummy.c +++ b/drivers/staging/speakup/speakup_dummy.c @@ -102,7 +102,7 @@ static struct spk_synth synth_dummy = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = spk_do_catch_up, diff --git a/drivers/staging/speakup/speakup_keypc.c b/drivers/staging/speakup/speakup_keypc.c index 496e014..feb5f22 100644 --- a/drivers/staging/speakup/speakup_keypc.c +++ b/drivers/staging/speakup/speakup_keypc.c @@ -184,9 +184,9 @@ static void do_catch_up(struct spk_synth *synth) int full_time_val; int jiffy_delta_val; - jiffy_delta = get_var(JIFFY); - delay_time = get_var(DELAY); - full_time = get_var(FULL); + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; spk_unlock(flags); diff --git a/drivers/staging/speakup/speakup_ltlk.c b/drivers/staging/speakup/speakup_ltlk.c index 971de1a..326f94d 100644 --- a/drivers/staging/speakup/speakup_ltlk.c +++ b/drivers/staging/speakup/speakup_ltlk.c @@ -161,7 +161,7 @@ static int synth_probe(struct spk_synth *synth) { int failed = 0; - failed = serial_synth_probe(synth); + failed = spk_serial_synth_probe(synth); if (failed == 0) synth_interrogate(synth); synth->alive = !failed; diff --git a/drivers/staging/speakup/speakup_spkout.c b/drivers/staging/speakup/speakup_spkout.c index 9a3a80d..e74f856 100644 --- a/drivers/staging/speakup/speakup_spkout.c +++ b/drivers/staging/speakup/speakup_spkout.c @@ -107,7 +107,7 @@ static struct spk_synth synth_spkout = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = spk_do_catch_up, diff --git a/drivers/staging/speakup/speakup_txprt.c b/drivers/staging/speakup/speakup_txprt.c index 5d5bf7c..5a29b9f 100644 --- a/drivers/staging/speakup/speakup_txprt.c +++ b/drivers/staging/speakup/speakup_txprt.c @@ -100,7 +100,7 @@ static struct spk_synth synth_txprt = { .startup = SYNTH_START, .checkval = SYNTH_CHECK, .vars = vars, - .probe = serial_synth_probe, + .probe = spk_serial_synth_probe, .release = spk_serial_release, .synth_immediate = spk_synth_immediate, .catch_up = spk_do_catch_up, diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h index a47c5b7..303105b 100644 --- a/drivers/staging/speakup/spk_priv.h +++ b/drivers/staging/speakup/spk_priv.h @@ -45,8 +45,8 @@ #define KT_SPKUP 15 extern const struct old_serial_port *spk_serial_init(int index); -extern void stop_serial_interrupt(void); -extern int wait_for_xmitr(void); +extern void spk_stop_serial_interrupt(void); +extern int spk_wait_for_xmitr(void); extern unsigned char spk_serial_in(void); extern unsigned char spk_serial_in_nowait(void); extern int spk_serial_out(const char ch); @@ -55,13 +55,13 @@ extern void spk_serial_release(void); extern char synth_buffer_getc(void); extern char synth_buffer_peek(void); extern int synth_buffer_empty(void); -extern struct var_t *get_var(enum var_id_t var_id); +extern struct var_t *spk_get_var(enum var_id_t var_id); extern ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf); extern ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count); -extern int serial_synth_probe(struct spk_synth *synth); +extern int spk_serial_synth_probe(struct spk_synth *synth); extern const char *spk_synth_immediate(struct spk_synth *synth, const char *buff); extern void spk_do_catch_up(struct spk_synth *synth); extern void spk_synth_flush(struct spk_synth *synth); diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 7616f05..d867dd9 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -20,9 +20,9 @@ #define MAXSYNTHS 16 /* Max number of synths in array. */ static struct spk_synth *synths[MAXSYNTHS]; struct spk_synth *synth; -char pitch_buff[32] = ""; +char spk_pitch_buff[32] = ""; static int module_status; -bool quiet_boot; +bool spk_quiet_boot; struct speakup_info_t speakup_info = { .spinlock = __SPIN_LOCK_UNLOCKED(speakup_info.spinlock), @@ -32,7 +32,7 @@ EXPORT_SYMBOL_GPL(speakup_info); static int do_synth_init(struct spk_synth *in_synth); -int serial_synth_probe(struct spk_synth *synth) +int spk_serial_synth_probe(struct spk_synth *synth) { const struct old_serial_port *ser; int failed = 0; @@ -59,7 +59,7 @@ int serial_synth_probe(struct spk_synth *synth) synth->alive = 1; return 0; } -EXPORT_SYMBOL_GPL(serial_synth_probe); +EXPORT_SYMBOL_GPL(spk_serial_synth_probe); /* Main loop of the progression thread: keep eating from the buffer * and push to the serial port, waiting as needed @@ -79,9 +79,9 @@ void spk_do_catch_up(struct spk_synth *synth) int delay_time_val; int full_time_val; - jiffy_delta = get_var(JIFFY); - full_time = get_var(FULL); - delay_time = get_var(DELAY); + jiffy_delta = spk_get_var(JIFFY); + full_time = spk_get_var(FULL); + delay_time = spk_get_var(DELAY); spk_lock(flags); jiffy_delta_val = jiffy_delta->u.n.value; @@ -139,7 +139,7 @@ const char *spk_synth_immediate(struct spk_synth *synth, const char *buff) while ((ch = *buff)) { if (ch == '\n') ch = synth->procspeech; - if (wait_for_xmitr()) + if (spk_wait_for_xmitr()) outb(ch, speakup_info.port_tts); else return buff; @@ -166,7 +166,7 @@ int spk_synth_is_alive_restart(struct spk_synth *synth) { if (synth->alive) return 1; - if (!synth->alive && wait_for_xmitr() > 0) { + if (!synth->alive && spk_wait_for_xmitr() > 0) { /* restart */ synth->alive = 1; synth_printf("%s", synth->init); @@ -192,20 +192,20 @@ void synth_start(void) synth_buffer_clear(); return; } - trigger_time = get_var(TRIGGER); + trigger_time = spk_get_var(TRIGGER); if (!timer_pending(&thread_timer)) mod_timer(&thread_timer, jiffies + msecs_to_jiffies(trigger_time->u.n.value)); } -void do_flush(void) +void spk_do_flush(void) { speakup_info.flushing = 1; synth_buffer_clear(); if (synth->alive) { - if (pitch_shift) { - synth_printf("%s", pitch_buff); - pitch_shift = 0; + if (spk_pitch_shift) { + synth_printf("%s", spk_pitch_buff); + spk_pitch_shift = 0; } } wake_up_interruptible_all(&speakup_event); @@ -241,7 +241,7 @@ EXPORT_SYMBOL_GPL(synth_printf); static int index_count; static int sentence_count; -void reset_index_count(int sc) +void spk_reset_index_count(int sc) { static int first = 1; if (first) @@ -277,7 +277,7 @@ void synth_insert_next_index(int sent_num) } } -void get_index_count(int *linecount, int *sentcount) +void spk_get_index_count(int *linecount, int *sentcount) { int ind = synth->get_index(); if (ind) { @@ -384,7 +384,7 @@ static int do_synth_init(struct spk_synth *in_synth) for (var = synth->vars; (var->var_id >= 0) && (var->var_id < MAXVARS); var++) speakup_register_var(var); - if (!quiet_boot) + if (!spk_quiet_boot) synth_printf("%s found\n", synth->long_name); if (synth->attributes.name && sysfs_create_group(speakup_kobj, &(synth->attributes)) < 0) @@ -412,7 +412,7 @@ void synth_release(void) sysfs_remove_group(speakup_kobj, &(synth->attributes)); for (var = synth->vars; var->var_id != MAXVARS; var++) speakup_unregister_var(var->var_id); - stop_serial_interrupt(); + spk_stop_serial_interrupt(); synth->release(); synth = NULL; } @@ -460,4 +460,4 @@ void synth_remove(struct spk_synth *in_synth) } EXPORT_SYMBOL_GPL(synth_remove); -short punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM }; +short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM }; diff --git a/drivers/staging/speakup/thread.c b/drivers/staging/speakup/thread.c index 103c5c8..42fa660 100644 --- a/drivers/staging/speakup/thread.c +++ b/drivers/staging/speakup/thread.c @@ -23,8 +23,8 @@ int speakup_thread(void *data) DEFINE_WAIT(wait); while (1) { spk_lock(flags); - our_sound = unprocessed_sound; - unprocessed_sound.active = 0; + our_sound = spk_unprocessed_sound; + spk_unprocessed_sound.active = 0; prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); should_break = kthread_should_stop() || diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index ab7de93..f8c1e45 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -16,24 +16,24 @@ static struct st_var_header var_headers[] = { { "ex_num", EXNUMBER, VAR_PROC, NULL, NULL }, { "characters", CHARS, VAR_PROC, NULL, NULL }, { "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL }, - { "caps_start", CAPS_START, VAR_STRING, str_caps_start, NULL }, - { "caps_stop", CAPS_STOP, VAR_STRING, str_caps_stop, NULL }, + { "caps_start", CAPS_START, VAR_STRING, spk_str_caps_start, NULL }, + { "caps_stop", CAPS_STOP, VAR_STRING, spk_str_caps_stop, NULL }, { "delay_time", DELAY, VAR_TIME, NULL, NULL }, { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL }, { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL }, { "full_time", FULL, VAR_TIME, NULL, NULL }, - { "spell_delay", SPELL_DELAY, VAR_NUM, &spell_delay, NULL }, - { "bleeps", BLEEPS, VAR_NUM, &bleeps, NULL }, - { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &attrib_bleep, NULL }, - { "bleep_time", BLEEP_TIME, VAR_TIME, &bleep_time, NULL }, + { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL }, + { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL }, + { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL }, + { "bleep_time", BLEEP_TIME, VAR_TIME, &spk_bleep_time, NULL }, { "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL }, - { "punc_level", PUNC_LEVEL, VAR_NUM, &punc_level, NULL }, - { "reading_punc", READING_PUNC, VAR_NUM, &reading_punc, NULL }, - { "say_control", SAY_CONTROL, VAR_NUM, &say_ctrl, NULL }, - { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &say_word_ctl, NULL }, - { "no_interrupt", NO_INTERRUPT, VAR_NUM, &no_intr, NULL }, - { "key_echo", KEY_ECHO, VAR_NUM, &key_echo, NULL }, - { "bell_pos", BELL_POS, VAR_NUM, &bell_pos, NULL }, + { "punc_level", PUNC_LEVEL, VAR_NUM, &spk_punc_level, NULL }, + { "reading_punc", READING_PUNC, VAR_NUM, &spk_reading_punc, NULL }, + { "say_control", SAY_CONTROL, VAR_NUM, &spk_say_ctrl, NULL }, + { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &spk_say_word_ctl, NULL }, + { "no_interrupt", NO_INTERRUPT, VAR_NUM, &spk_no_intr, NULL }, + { "key_echo", KEY_ECHO, VAR_NUM, &spk_key_echo, NULL }, + { "bell_pos", BELL_POS, VAR_NUM, &spk_bell_pos, NULL }, { "rate", RATE, VAR_NUM, NULL, NULL }, { "pitch", PITCH, VAR_NUM, NULL, NULL }, { "vol", VOL, VAR_NUM, NULL, NULL }, @@ -58,7 +58,7 @@ static struct punc_var_t punc_vars[] = { { -1, -1 }, }; -int chartab_get_value(char *keyword) +int spk_chartab_get_value(char *keyword) { int value = 0; @@ -103,11 +103,11 @@ void speakup_register_var(struct var_t *var) p_header->data = var; switch (p_header->var_type) { case VAR_STRING: - set_string_var(nothing, p_header, 0); + spk_set_string_var(nothing, p_header, 0); break; case VAR_NUM: case VAR_TIME: - set_num_var(0, p_header, E_DEFAULT); + spk_set_num_var(0, p_header, E_DEFAULT); break; default: break; @@ -123,7 +123,7 @@ void speakup_unregister_var(enum var_id_t var_id) p_header->data = NULL; } -struct st_var_header *get_var_header(enum var_id_t var_id) +struct st_var_header *spk_get_var_header(enum var_id_t var_id) { struct st_var_header *p_header; if (var_id < 0 || var_id >= MAXVARS) @@ -134,7 +134,7 @@ struct st_var_header *get_var_header(enum var_id_t var_id) return p_header; } -struct st_var_header *var_header_by_name(const char *name) +struct st_var_header *spk_var_header_by_name(const char *name) { int i; struct st_var_header *where = NULL; @@ -151,15 +151,15 @@ struct st_var_header *var_header_by_name(const char *name) return where; } -struct var_t *get_var(enum var_id_t var_id) +struct var_t *spk_get_var(enum var_id_t var_id) { BUG_ON(var_id < 0 || var_id >= MAXVARS); BUG_ON(!var_ptrs[var_id]); return var_ptrs[var_id]->data; } -EXPORT_SYMBOL_GPL(get_var); +EXPORT_SYMBOL_GPL(spk_get_var); -struct punc_var_t *get_punc_var(enum var_id_t var_id) +struct punc_var_t *spk_get_punc_var(enum var_id_t var_id) { struct punc_var_t *rv = NULL; struct punc_var_t *where; @@ -175,7 +175,7 @@ struct punc_var_t *get_punc_var(enum var_id_t var_id) } /* handlers for setting vars */ -int set_num_var(int input, struct st_var_header *var, int how) +int spk_set_num_var(int input, struct st_var_header *var, int how) { int val; short ret = 0; @@ -217,7 +217,7 @@ int set_num_var(int input, struct st_var_header *var, int how) if (p_val != NULL) *p_val = val; if (var->var_id == PUNC_LEVEL) { - punc_mask = punc_masks[val]; + spk_punc_mask = spk_punc_masks[val]; return ret; } if (var_data->u.n.multiplier != 0) @@ -232,7 +232,7 @@ int set_num_var(int input, struct st_var_header *var, int how) if (!var_data->u.n.synth_fmt) return ret; if (var->var_id == PITCH) - cp = pitch_buff; + cp = spk_pitch_buff; else cp = buf; if (!var_data->u.n.out_str) @@ -244,7 +244,7 @@ int set_num_var(int input, struct st_var_header *var, int how) return ret; } -int set_string_var(const char *page, struct st_var_header *var, int len) +int spk_set_string_var(const char *page, struct st_var_header *var, int len) { int ret = 0; struct var_t *var_data = var->data; @@ -267,21 +267,21 @@ int set_string_var(const char *page, struct st_var_header *var, int len) return ret; } -/* set_mask_bits sets or clears the punc/delim/repeat bits, +/* spk_set_mask_bits sets or clears the punc/delim/repeat bits, * if input is null uses the defaults. * values for how: 0 clears bits of chars supplied, * 1 clears allk, 2 sets bits for chars */ -int set_mask_bits(const char *input, const int which, const int how) +int spk_set_mask_bits(const char *input, const int which, const int how) { u_char *cp; - short mask = punc_info[which].mask; + short mask = spk_punc_info[which].mask; if (how&1) { - for (cp = (u_char *)punc_info[3].value; *cp; cp++) + for (cp = (u_char *)spk_punc_info[3].value; *cp; cp++) spk_chartab[*cp] &= ~mask; } cp = (u_char *)input; if (cp == 0) - cp = punc_info[which].value; + cp = spk_punc_info[which].value; else { for ( ; *cp; cp++) { if (*cp < SPACE) @@ -308,7 +308,7 @@ int set_mask_bits(const char *input, const int which, const int how) return 0; } -char *strlwr(char *s) +char *spk_strlwr(char *s) { char *p; if (s == NULL) @@ -341,7 +341,7 @@ char *speakup_s2i(char *start, int *dest) return start; } -char *s2uchar(char *start, char *dest) +char *spk_s2uchar(char *start, char *dest) { int val = 0; while (*start && *start <= SPACE) @@ -357,7 +357,7 @@ char *s2uchar(char *start, char *dest) return start; } -char *xlate(char *s) +char *spk_xlate(char *s) { static const char finds[] = "nrtvafe"; static const char subs[] = "\n\r\t\013\001\014\033"; diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c index 299f518..6a21f67 100644 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c @@ -742,13 +742,9 @@ static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata) case SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM: if (rmi_fd.intr_src_count) { rfi = kmalloc(sizeof(*rfi), - GFP_KERNEL); - if (!rfi) { - dev_err(&client->dev, - "%s:kmalloc failed\n", - __func__); - return -ENOMEM; - } + GFP_KERNEL); + if (!rfi) + return -ENOMEM; retval = synpatics_rmi4_touchpad_detect (pdata, rfi, &rmi_fd, @@ -900,12 +896,10 @@ static int synaptics_rmi4_probe } /* Allocate and initialize the instance data for this client */ - rmi4_data = kzalloc(sizeof(struct synaptics_rmi4_data) * 2, - GFP_KERNEL); - if (!rmi4_data) { - dev_err(&client->dev, "%s: no memory allocated\n", __func__); + rmi4_data = kcalloc(2, sizeof(struct synaptics_rmi4_data), + GFP_KERNEL); + if (!rmi4_data) return -ENOMEM; - } rmi4_data->input_dev = input_allocate_device(); if (rmi4_data->input_dev == NULL) { diff --git a/drivers/staging/tidspbridge/core/msg_sm.c b/drivers/staging/tidspbridge/core/msg_sm.c index ce9557e..7b517eb 100644 --- a/drivers/staging/tidspbridge/core/msg_sm.c +++ b/drivers/staging/tidspbridge/core/msg_sm.c @@ -198,8 +198,7 @@ out_err: */ void bridge_msg_delete(struct msg_mgr *hmsg_mgr) { - if (hmsg_mgr) - delete_msg_mgr(hmsg_mgr); + delete_msg_mgr(hmsg_mgr); } /* diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c index f619fb3..b770b22 100644 --- a/drivers/staging/tidspbridge/core/tiomap3430.c +++ b/drivers/staging/tidspbridge/core/tiomap3430.c @@ -70,14 +70,9 @@ #define PAGES_II_LVL_TABLE 512 #define PHYS_TO_PAGE(phys) pfn_to_page((phys) >> PAGE_SHIFT) -/* - * This is a totally ugly layer violation, but needed until - * omap_ctrl_set_dsp_boot*() are provided. - */ -#define OMAP3_IVA2_BOOTMOD_IDLE 1 -#define OMAP2_CONTROL_GENERAL 0x270 -#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190) -#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194) +/* IVA Boot modes */ +#define DIRECT 0 +#define IDLE 1 /* Forward Declarations: */ static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt); @@ -423,29 +418,14 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt, /* Assert RST1 i.e only the RST only for DSP megacell */ if (!status) { - /* - * XXX: OMAP343X_CTRL_BASE ioremapping MUST be removed once ctrl - * function is made available. - */ - void __iomem *ctrl = ioremap(0x48002000, SZ_4K); - if (!ctrl) { - iounmap(sync_addr); - return -ENOMEM; - } - (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); - /* Mask address with 1K for compatibility */ - __raw_writel(dsp_addr & OMAP3_IVA2_BOOTADDR_MASK, - ctrl + OMAP343X_CONTROL_IVA2_BOOTADDR); - /* - * Set bootmode to self loop if dsp_debug flag is true - */ - __raw_writel((dsp_debug) ? OMAP3_IVA2_BOOTMOD_IDLE : 0, - ctrl + OMAP343X_CONTROL_IVA2_BOOTMOD); - iounmap(ctrl); + /* Mask address with 1K for compatibility */ + pdata->set_bootaddr(dsp_addr & + OMAP3_IVA2_BOOTADDR_MASK); + pdata->set_bootmode(dsp_debug ? IDLE : DIRECT); } } if (!status) { diff --git a/drivers/staging/tidspbridge/include/dspbridge/proc.h b/drivers/staging/tidspbridge/include/dspbridge/proc.h index 851b356..774a3f6 100644 --- a/drivers/staging/tidspbridge/include/dspbridge/proc.h +++ b/drivers/staging/tidspbridge/include/dspbridge/proc.h @@ -23,8 +23,6 @@ #include <dspbridge/devdefs.h> #include <dspbridge/drv.h> -extern char *iva_img; - /* * ======== proc_attach ======== * Purpose: diff --git a/drivers/staging/tidspbridge/pmgr/cod.c b/drivers/staging/tidspbridge/pmgr/cod.c index 4007826..6c29379 100644 --- a/drivers/staging/tidspbridge/pmgr/cod.c +++ b/drivers/staging/tidspbridge/pmgr/cod.c @@ -289,7 +289,7 @@ int cod_get_base_name(struct cod_manager *cod_mgr_obj, char *sz_name, int status = 0; if (usize <= COD_MAXPATHLENGTH) - strncpy(sz_name, cod_mgr_obj->sz_zl_file, usize); + strlcpy(sz_name, cod_mgr_obj->sz_zl_file, usize); else status = -EPERM; diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c index 9f07036..c191ae2 100644 --- a/drivers/staging/tidspbridge/pmgr/dbll.c +++ b/drivers/staging/tidspbridge/pmgr/dbll.c @@ -1382,7 +1382,7 @@ void find_symbol_callback(void *elem, void *user_data) offset < context->cur_best_offset) { context->cur_best_offset = offset; context->sym_addr = symbol_addr; - strncpy(context->name, symbol->name, sizeof(context->name)); + strlcpy(context->name, symbol->name, sizeof(context->name)); } return; diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c index 9ef1ad9..70db4ff 100644 --- a/drivers/staging/tidspbridge/pmgr/dspapi.c +++ b/drivers/staging/tidspbridge/pmgr/dspapi.c @@ -414,10 +414,13 @@ u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt) CP_FM_USR(&uuid_obj, args->args_mgr_registerobject.uuid_obj, status, 1); if (status) goto func_end; - /* path_size is increased by 1 to accommodate NULL */ path_size = strlen_user((char *) - args->args_mgr_registerobject.sz_path_name) + - 1; + args->args_mgr_registerobject.sz_path_name); + if (!path_size) { + status = -EINVAL; + goto func_end; + } + psz_path_name = kmalloc(path_size, GFP_KERNEL); if (!psz_path_name) { status = -ENOMEM; @@ -1540,7 +1543,7 @@ u32 strmwrap_free_buffer(union trapped_args *args, void *pr_ctxt) if (num_bufs > MAX_BUFS) return -EINVAL; - ap_buffer = kmalloc((num_bufs * sizeof(u8 *)), GFP_KERNEL); + ap_buffer = kmalloc_array(num_bufs, sizeof(u8 *), GFP_KERNEL); if (ap_buffer == NULL) return -ENOMEM; diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c index 9d52c3c..3d2a26f 100644 --- a/drivers/staging/tidspbridge/rmgr/dbdcd.c +++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c @@ -852,8 +852,7 @@ int dcd_register_object(struct dsp_uuid *uuid_obj, goto func_end; } - dcd_key->path = kmalloc(strlen(sz_reg_key) + 1, - GFP_KERNEL); + dcd_key->path = kmalloc(dw_path_size, GFP_KERNEL); if (!dcd_key->path) { kfree(dcd_key); diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c index e6f31d8..df0f37e 100644 --- a/drivers/staging/tidspbridge/rmgr/drv_interface.c +++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c @@ -65,7 +65,6 @@ static struct class *bridge_class; static u32 driver_context; static s32 driver_major; static char *base_img; -char *iva_img; static s32 shm_size = 0x500000; /* 5 MB */ static int tc_wordswapon; /* Default value is always false */ #ifdef CONFIG_TIDSPBRIDGE_RECOVERY diff --git a/drivers/staging/tidspbridge/rmgr/nldr.c b/drivers/staging/tidspbridge/rmgr/nldr.c index 6309221b..ca38050 100644 --- a/drivers/staging/tidspbridge/rmgr/nldr.c +++ b/drivers/staging/tidspbridge/rmgr/nldr.c @@ -1802,8 +1802,6 @@ int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr, bool status1 = false; s32 i = 0; struct lib_node root = { NULL, 0, NULL }; - pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", __func__, (u32) nldr_node, - sym_addr, offset_range, (u32) offset_output, sym_name); if (nldr_node->dynamic && *nldr_node->phase_split) { switch (nldr_node->phase) { @@ -1852,6 +1850,10 @@ int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr, pr_debug("%s: Address 0x%x not found in range %d.\n", __func__, sym_addr, offset_range); status = -ESPIPE; + } else { + pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", + __func__, (u32) nldr_node, sym_addr, offset_range, + (u32) offset_output, sym_name); } return status; diff --git a/drivers/staging/tidspbridge/rmgr/node.c b/drivers/staging/tidspbridge/rmgr/node.c index 737f4a9..87dfa92 100644 --- a/drivers/staging/tidspbridge/rmgr/node.c +++ b/drivers/staging/tidspbridge/rmgr/node.c @@ -3012,16 +3012,16 @@ int node_find_addr(struct node_mgr *node_mgr, u32 sym_addr, struct node_object *node_obj; int status = -ENOENT; - pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", __func__, - (unsigned int) node_mgr, - sym_addr, offset_range, - (unsigned int) sym_addr_output, sym_name); - list_for_each_entry(node_obj, &node_mgr->node_list, list_elem) { status = nldr_find_addr(node_obj->nldr_node_obj, sym_addr, offset_range, sym_addr_output, sym_name); - if (!status) + if (!status) { + pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", __func__, + (unsigned int) node_mgr, + sym_addr, offset_range, + (unsigned int) sym_addr_output, sym_name); break; + } } return status; diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c index 5e43938..0df55bd 100644 --- a/drivers/staging/tidspbridge/rmgr/proc.c +++ b/drivers/staging/tidspbridge/rmgr/proc.c @@ -119,16 +119,14 @@ static struct dmm_map_object *add_mapping_info(struct process_context *pr_ctxt, dsp_addr, size); map_obj = kzalloc(sizeof(struct dmm_map_object), GFP_KERNEL); - if (!map_obj) { - pr_err("%s: kzalloc failed\n", __func__); + if (!map_obj) return NULL; - } + INIT_LIST_HEAD(&map_obj->link); map_obj->pages = kcalloc(num_usr_pgs, sizeof(struct page *), - GFP_KERNEL); + GFP_KERNEL); if (!map_obj->pages) { - pr_err("%s: kzalloc failed\n", __func__); kfree(map_obj); return NULL; } @@ -382,7 +380,6 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj, u32 size, char *exec_file) { u8 dev_type; - s32 len; struct drv_data *drv_datap = dev_get_drvdata(bridge); dev_get_dev_type(hdev_obj, (u8 *) &dev_type); @@ -394,13 +391,10 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj, if (!drv_datap || !drv_datap->base_img) return -EFAULT; - if (strlen(drv_datap->base_img) > size) + if (strlen(drv_datap->base_img) >= size) return -EINVAL; strcpy(exec_file, drv_datap->base_img); - } else if (dev_type == IVA_UNIT && iva_img) { - len = strlen(iva_img); - strncpy(exec_file, iva_img, len + 1); } else { return -ENOENT; } @@ -697,7 +691,6 @@ static int memory_give_ownership(struct dmm_map_object *map_obj, sg = kcalloc(num_pages, sizeof(*sg), GFP_KERNEL); if (!sg) { - pr_err("%s: kcalloc failed\n", __func__); ret = -ENOMEM; goto out; } @@ -1231,12 +1224,8 @@ int proc_load(void *hprocessor, const s32 argc_index, (p_proc_object->bridge_context, &brd_state))) { pr_info("%s: Processor Loaded %s\n", __func__, pargv0); kfree(drv_datap->base_img); - drv_datap->base_img = kmalloc(strlen(pargv0) + 1, - GFP_KERNEL); - if (drv_datap->base_img) - strncpy(drv_datap->base_img, pargv0, - strlen(pargv0) + 1); - else + drv_datap->base_img = kstrdup(pargv0, GFP_KERNEL); + if (!drv_datap->base_img) status = -ENOMEM; } } diff --git a/drivers/staging/usbip/Kconfig b/drivers/staging/usbip/Kconfig index 199b1d4..8860009 100644 --- a/drivers/staging/usbip/Kconfig +++ b/drivers/staging/usbip/Kconfig @@ -8,7 +8,7 @@ config USBIP_CORE USB/IP core that is required by both drivers. For more details, and to get the userspace utility - programs, please see http://usbip.sourceforge.net/. + programs, please see <http://usbip.sourceforge.net/>. To compile this as a module, choose M here: the module will be called usbip-core. diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index ee36415..67556ac 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -67,9 +67,9 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr, return -ENODEV; } - spin_lock(&sdev->ud.lock); + spin_lock_irq(&sdev->ud.lock); status = sdev->ud.status; - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); return snprintf(buf, PAGE_SIZE, "%d\n", status); } @@ -97,39 +97,39 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, if (sockfd != -1) { dev_info(dev, "stub up\n"); - spin_lock(&sdev->ud.lock); + spin_lock_irq(&sdev->ud.lock); if (sdev->ud.status != SDEV_ST_AVAILABLE) { dev_err(dev, "not ready\n"); - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); return -EINVAL; } socket = sockfd_to_socket(sockfd); if (!socket) { - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); return -EINVAL; } sdev->ud.tcp_socket = socket; - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, "stub_rx"); sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, "stub_tx"); - spin_lock(&sdev->ud.lock); + spin_lock_irq(&sdev->ud.lock); sdev->ud.status = SDEV_ST_USED; - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); } else { dev_info(dev, "stub down\n"); - spin_lock(&sdev->ud.lock); + spin_lock_irq(&sdev->ud.lock); if (sdev->ud.status != SDEV_ST_USED) { - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); return -EINVAL; } - spin_unlock(&sdev->ud.lock); + spin_unlock_irq(&sdev->ud.lock); usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); } @@ -241,9 +241,9 @@ static void stub_device_reset(struct usbip_device *ud) ret = usb_lock_device_for_reset(udev, sdev->interface); if (ret < 0) { dev_err(&udev->dev, "lock for reset\n"); - spin_lock(&ud->lock); + spin_lock_irq(&ud->lock); ud->status = SDEV_ST_ERROR; - spin_unlock(&ud->lock); + spin_unlock_irq(&ud->lock); return; } @@ -251,7 +251,7 @@ static void stub_device_reset(struct usbip_device *ud) ret = usb_reset_device(udev); usb_unlock_device(udev); - spin_lock(&ud->lock); + spin_lock_irq(&ud->lock); if (ret) { dev_err(&udev->dev, "device reset\n"); ud->status = SDEV_ST_ERROR; @@ -259,14 +259,14 @@ static void stub_device_reset(struct usbip_device *ud) dev_info(&udev->dev, "device reset\n"); ud->status = SDEV_ST_AVAILABLE; } - spin_unlock(&ud->lock); + spin_unlock_irq(&ud->lock); } static void stub_device_unusable(struct usbip_device *ud) { - spin_lock(&ud->lock); + spin_lock_irq(&ud->lock); ud->status = SDEV_ST_ERROR; - spin_unlock(&ud->lock); + spin_unlock_irq(&ud->lock); } /** @@ -286,10 +286,8 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev, /* yes, it's a new device */ sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); - if (!sdev) { - dev_err(&interface->dev, "no memory for stub_device\n"); + if (!sdev) return NULL; - } sdev->interface = usb_get_intf(interface); sdev->udev = usb_get_dev(udev); @@ -528,13 +526,13 @@ static void stub_disconnect(struct usb_interface *interface) * when the device is being reset */ -int stub_pre_reset(struct usb_interface *interface) +static int stub_pre_reset(struct usb_interface *interface) { dev_dbg(&interface->dev, "pre_reset\n"); return 0; } -int stub_post_reset(struct usb_interface *interface) +static int stub_post_reset(struct usb_interface *interface) { dev_dbg(&interface->dev, "post_reset\n"); return 0; diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index 0572a15..715e8a7 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -307,12 +307,12 @@ static int valid_request(struct stub_device *sdev, struct usbip_header *pdu) int valid = 0; if (pdu->base.devid == sdev->devid) { - spin_lock(&ud->lock); + spin_lock_irq(&ud->lock); if (ud->status == SDEV_ST_USED) { /* A request is valid. */ valid = 1; } - spin_unlock(&ud->lock); + spin_unlock_irq(&ud->lock); } return valid; @@ -485,7 +485,6 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, kzalloc(pdu->u.cmd_submit.transfer_buffer_length, GFP_KERNEL); if (!priv->urb->transfer_buffer) { - dev_err(&sdev->interface->dev, "malloc x_buff\n"); usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); return; } diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index 513961f..cd5326a 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -42,7 +42,6 @@ void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum, unlink = kzalloc(sizeof(struct stub_unlink), GFP_ATOMIC); if (!unlink) { - dev_err(&sdev->interface->dev, "alloc stub_unlink\n"); usbip_event_add(&sdev->ud, VDEV_EVENT_ERROR_MALLOC); return; } diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 75189fe..75aa5bf 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -672,9 +672,8 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) return 0; /* my Bluetooth dongle gets ISO URBs which are np = 0 */ - if (np == 0) { + if (np == 0) return 0; - } buff = kzalloc(size, GFP_KERNEL); if (!buff) diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c index d332a34..82123be 100644 --- a/drivers/staging/usbip/usbip_event.c +++ b/drivers/staging/usbip/usbip_event.c @@ -105,10 +105,12 @@ EXPORT_SYMBOL_GPL(usbip_stop_eh); void usbip_event_add(struct usbip_device *ud, unsigned long event) { - spin_lock(&ud->lock); + unsigned long flags; + + spin_lock_irqsave(&ud->lock, flags); ud->event |= event; wake_up(&ud->eh_waitq); - spin_unlock(&ud->lock); + spin_unlock_irqrestore(&ud->lock, flags); } EXPORT_SYMBOL_GPL(usbip_event_add); diff --git a/drivers/staging/usbip/userspace/.gitignore b/drivers/staging/usbip/userspace/.gitignore new file mode 100644 index 0000000..9aad9e3 --- /dev/null +++ b/drivers/staging/usbip/userspace/.gitignore @@ -0,0 +1,28 @@ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +install-sh +libsrc/Makefile +libsrc/Makefile.in +libtool +ltmain.sh +missing +src/Makefile +src/Makefile.in +stamp-h1 +libsrc/libusbip.la +libsrc/libusbip_la-names.lo +libsrc/libusbip_la-usbip_common.lo +libsrc/libusbip_la-usbip_host_driver.lo +libsrc/libusbip_la-vhci_driver.lo +src/usbip +src/usbipd diff --git a/drivers/staging/usbip/userspace/Makefile.am b/drivers/staging/usbip/userspace/Makefile.am index 9ab1949..66f8bf0 100644 --- a/drivers/staging/usbip/userspace/Makefile.am +++ b/drivers/staging/usbip/userspace/Makefile.am @@ -3,4 +3,4 @@ includedir = @includedir@/usbip include_HEADERS := $(addprefix libsrc/, \ usbip_common.h vhci_driver.h usbip_host_driver.h) -dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8 usbip_bind_driver.8) +dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8) diff --git a/drivers/staging/usbip/userspace/README b/drivers/staging/usbip/userspace/README index 63cd107..233d1d7 100644 --- a/drivers/staging/usbip/userspace/README +++ b/drivers/staging/usbip/userspace/README @@ -17,8 +17,6 @@ - gcc >= 4.0 - - libglib2.0-dev >= 2.6.0 - - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac index 43e641e..2be4060 100644 --- a/drivers/staging/usbip/userspace/configure.ac +++ b/drivers/staging/usbip/userspace/configure.ac @@ -91,10 +91,22 @@ AC_ARG_WITH([usbids-dir], [USBIDS_DIR=$withval], [USBIDS_DIR="/usr/share/hwdata/"]) AC_SUBST([USBIDS_DIR]) -GLIB2_REQUIRED=2.6.0 -PKG_CHECK_MODULES([PACKAGE], [glib-2.0 >= $GLIB2_REQUIRED]) -AC_SUBST([PACKAGE_CFLAGS]) -AC_SUBST([PACKAGE_LIBS]) +# use _FORTIFY_SOURCE +AC_MSG_CHECKING([whether to use fortify]) +AC_ARG_WITH([fortify], + [AS_HELP_STRING([--with-fortify], + [use _FORTIFY_SROUCE option when compiling)])], + dnl [ACTION-IF-GIVEN] + [if test "$withval" = "yes"; then + AC_MSG_RESULT([yes]) + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE -O" + else + AC_MSG_RESULT([no]) + CFLAGS="$CFLAGS -U_FORTIFY_SOURCE" + fi + ], + dnl [ACTION-IF-NOT-GIVEN] + [AC_MSG_RESULT([default])]) AC_CONFIG_FILES([Makefile libsrc/Makefile src/Makefile]) AC_OUTPUT diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am index c365a3f..a113003 100644 --- a/drivers/staging/usbip/userspace/src/Makefile.am +++ b/drivers/staging/usbip/userspace/src/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/libsrc -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"' -AM_CFLAGS = @EXTRA_CFLAGS@ @PACKAGE_CFLAGS@ -LDADD = $(top_builddir)/libsrc/libusbip.la @PACKAGE_LIBS@ +AM_CFLAGS = @EXTRA_CFLAGS@ +LDADD = $(top_builddir)/libsrc/libusbip.la sbin_PROGRAMS := usbip usbipd diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index bdf61c0..2da4e44 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -27,6 +27,7 @@ #include <fcntl.h> #include <getopt.h> #include <unistd.h> +#include <errno.h> #include "vhci_driver.h" #include "usbip_common.h" @@ -52,8 +53,18 @@ static int record_connection(char *host, char *port, char *busid, int rhport) int ret; ret = mkdir(VHCI_STATE_PATH, 0700); - if (ret < 0) - return -1; + if (ret < 0) { + /* if VHCI_STATE_PATH exists, then it better be a directory */ + if (errno == EEXIST) { + struct stat s; + ret = stat(VHCI_STATE_PATH, &s); + if (ret < 0) + return -1; + if (!(s.st_mode & S_IFDIR)) + return -1; + } else + return -1; + } snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport); diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 8668a80..34760cc 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -20,6 +20,7 @@ #include "../config.h" #endif +#define _GNU_SOURCE #include <errno.h> #include <unistd.h> #include <netdb.h> @@ -35,10 +36,9 @@ #include <tcpd.h> #endif -#define _GNU_SOURCE #include <getopt.h> -#include <glib.h> #include <signal.h> +#include <poll.h> #include "usbip_host_driver.h" #include "usbip_common.h" @@ -48,7 +48,7 @@ #define PROGNAME "usbipd" #define MAXSOCKFD 20 -GMainLoop *main_loop; +#define MAIN_LOOP_TIMEOUT 10 static const char usbip_version_string[] = PACKAGE_STRING; @@ -310,30 +310,22 @@ static int do_accept(int listenfd) return connfd; } -gboolean process_request(GIOChannel *gio, GIOCondition condition, - gpointer unused_data) +int process_request(int listenfd) { - int listenfd; + pid_t childpid; int connfd; - (void) unused_data; - - if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) { - err("unknown condition"); - BUG(); - } - - if (condition & G_IO_IN) { - listenfd = g_io_channel_unix_get_fd(gio); - connfd = do_accept(listenfd); - if (connfd < 0) - return TRUE; - + connfd = do_accept(listenfd); + if (connfd < 0) + return -1; + childpid = fork(); + if (childpid == 0) { + close(listenfd); recv_pdu(connfd); - close(connfd); + exit(0); } - - return TRUE; + close(connfd); + return 0; } static void log_addrinfo(struct addrinfo *ai) @@ -418,10 +410,7 @@ static struct addrinfo *do_getaddrinfo(char *host, int ai_family) static void signal_handler(int i) { - dbg("received signal: code %d", i); - - if (main_loop) - g_main_loop_quit(main_loop); + dbg("received '%s' signal", strsignal(i)); } static void set_signal(void) @@ -433,14 +422,19 @@ static void set_signal(void) sigemptyset(&act.sa_mask); sigaction(SIGTERM, &act, NULL); sigaction(SIGINT, &act, NULL); + act.sa_handler = SIG_IGN; + sigaction(SIGCLD, &act, NULL); } -static int do_standalone_mode(gboolean daemonize) +static int do_standalone_mode(int daemonize) { struct addrinfo *ai_head; int sockfdlist[MAXSOCKFD]; int nsockfd; - int i; + int i, terminate; + struct pollfd *fds; + struct timespec timeout; + sigset_t sigmask; if (usbip_names_init(USBIDS_FILE)) err("failed to open %s", USBIDS_FILE); @@ -456,7 +450,7 @@ static int do_standalone_mode(gboolean daemonize) err("daemonizing failed: %s", strerror(errno)); return -1; } - + umask(0); usbip_use_syslog = 1; } set_signal(); @@ -472,20 +466,40 @@ static int do_standalone_mode(gboolean daemonize) err("failed to open a listening socket"); return -1; } - + fds = calloc(nsockfd, sizeof(struct pollfd)); for (i = 0; i < nsockfd; i++) { - GIOChannel *gio; - - gio = g_io_channel_unix_new(sockfdlist[i]); - g_io_add_watch(gio, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL), - process_request, NULL); + fds[i].fd = sockfdlist[i]; + fds[i].events = POLLIN; + } + timeout.tv_sec = MAIN_LOOP_TIMEOUT; + timeout.tv_nsec = 0; + + sigfillset(&sigmask); + sigdelset(&sigmask, SIGTERM); + sigdelset(&sigmask, SIGINT); + + terminate = 0; + while (!terminate) { + int r; + + r = ppoll(fds, nsockfd, &timeout, &sigmask); + if (r < 0) { + dbg("%s", strerror(errno)); + terminate = 1; + } else if (r) { + for (i = 0; i < nsockfd; i++) { + if (fds[i].revents & POLLIN) { + dbg("read event on fd[%d]=%d", + i, sockfdlist[i]); + process_request(sockfdlist[i]); + } + } + } else + dbg("heartbeat timeout on ppoll()"); } - - main_loop = g_main_loop_new(FALSE, FALSE); - g_main_loop_run(main_loop); info("shutting down " PROGNAME); - + free(fds); freeaddrinfo(ai_head); usbip_host_driver_close(); usbip_names_free(); @@ -509,7 +523,7 @@ int main(int argc, char *argv[]) cmd_version } cmd; - gboolean daemonize = FALSE; + int daemonize = 0; int opt, rc = -1; usbip_use_stderr = 1; @@ -527,7 +541,7 @@ int main(int argc, char *argv[]) switch (opt) { case 'D': - daemonize = TRUE; + daemonize = 1; break; case 'd': usbip_use_debug = 1; diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index c3aa219..f1ca084 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -121,11 +121,9 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status) void rh_port_connect(int rhport, enum usb_device_speed speed) { - unsigned long flags; - usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION | (1 << USB_PORT_FEAT_C_CONNECTION); @@ -141,24 +139,22 @@ void rh_port_connect(int rhport, enum usb_device_speed speed) break; } - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); } static void rh_port_disconnect(int rhport) { - unsigned long flags; - usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION; the_controller->port_status[rhport] |= (1 << USB_PORT_FEAT_C_CONNECTION); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); } @@ -183,7 +179,6 @@ static void rh_port_disconnect(int rhport) static int vhci_hub_status(struct usb_hcd *hcd, char *buf) { struct vhci_hcd *vhci; - unsigned long flags; int retval; int rhport; int changed = 0; @@ -193,7 +188,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) vhci = hcd_to_vhci(hcd); - spin_lock_irqsave(&vhci->lock, flags); + spin_lock(&vhci->lock); if (!HCD_HW_ACCESSIBLE(hcd)) { usbip_dbg_vhci_rh("hw accessible flag not on?\n"); goto done; @@ -216,7 +211,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) usb_hcd_resume_root_hub(hcd); done: - spin_unlock_irqrestore(&vhci->lock, flags); + spin_unlock(&vhci->lock); return changed ? retval : 0; } @@ -237,7 +232,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, { struct vhci_hcd *dum; int retval = 0; - unsigned long flags; int rhport; u32 prev_port_status[VHCI_NPORTS]; @@ -257,7 +251,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, dum = hcd_to_vhci(hcd); - spin_lock_irqsave(&dum->lock, flags); + spin_lock(&dum->lock); /* store old status and compare now and old later */ if (usbip_dbg_flag_vhci_rh) { @@ -410,7 +404,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, } usbip_dbg_vhci_rh(" bye\n"); - spin_unlock_irqrestore(&dum->lock, flags); + spin_unlock(&dum->lock); return retval; } @@ -433,7 +427,6 @@ static void vhci_tx_urb(struct urb *urb) { struct vhci_device *vdev = get_vdev(urb->dev); struct vhci_priv *priv; - unsigned long flag; if (!vdev) { pr_err("could not get virtual device"); @@ -441,16 +434,13 @@ static void vhci_tx_urb(struct urb *urb) } priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); - - spin_lock_irqsave(&vdev->priv_lock, flag); - if (!priv) { - dev_err(&urb->dev->dev, "malloc vhci_priv\n"); - spin_unlock_irqrestore(&vdev->priv_lock, flag); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC); return; } + spin_lock(&vdev->priv_lock); + priv->seqnum = atomic_inc_return(&the_controller->seqnum); if (priv->seqnum == 0xffff) dev_info(&urb->dev->dev, "seqnum max\n"); @@ -463,7 +453,7 @@ static void vhci_tx_urb(struct urb *urb) list_add_tail(&priv->list, &vdev->priv_tx); wake_up(&vdev->waitq_tx); - spin_unlock_irqrestore(&vdev->priv_lock, flag); + spin_unlock(&vdev->priv_lock); } static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, @@ -471,7 +461,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, { struct device *dev = &urb->dev->dev; int ret = 0; - unsigned long flags; struct vhci_device *vdev; usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", @@ -480,11 +469,11 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, /* patch to usb_sg_init() is in 2.5.60 */ BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); if (urb->status != -EINPROGRESS) { dev_err(dev, "URB already unlinked!, status %d\n", urb->status); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); return urb->status; } @@ -496,7 +485,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, vdev->ud.status == VDEV_ST_ERROR) { dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport); spin_unlock(&vdev->ud.lock); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); return -ENODEV; } spin_unlock(&vdev->ud.lock); @@ -571,14 +560,14 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, out: vhci_tx_urb(urb); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); return 0; no_need_xmit: usb_hcd_unlink_urb_from_ep(hcd, urb); no_need_unlink: - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); return ret; } @@ -631,19 +620,18 @@ no_need_unlink: */ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { - unsigned long flags; struct vhci_priv *priv; struct vhci_device *vdev; pr_info("dequeue a urb %p\n", urb); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); priv = urb->hcpriv; if (!priv) { /* URB was never linked! or will be soon given back by * vhci_rx. */ - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); return 0; } @@ -651,7 +639,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) int ret = 0; ret = usb_hcd_check_unlink_urb(hcd, urb, status); if (ret) { - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); return ret; } } @@ -661,16 +649,14 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) if (!vdev->ud.tcp_socket) { /* tcp connection is closed */ - unsigned long flags2; - - spin_lock_irqsave(&vdev->priv_lock, flags2); + spin_lock(&vdev->priv_lock); pr_info("device %p seems to be disconnected\n", vdev); list_del(&priv->list); kfree(priv); urb->hcpriv = NULL; - spin_unlock_irqrestore(&vdev->priv_lock, flags2); + spin_unlock(&vdev->priv_lock); /* * If tcp connection is alive, we have sent CMD_UNLINK. @@ -681,24 +667,22 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) usb_hcd_unlink_urb_from_ep(hcd, urb); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); } else { /* tcp connection is alive */ - unsigned long flags2; struct vhci_unlink *unlink; - spin_lock_irqsave(&vdev->priv_lock, flags2); + spin_lock(&vdev->priv_lock); /* setup CMD_UNLINK pdu */ unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC); if (!unlink) { - pr_err("malloc vhci_unlink\n"); - spin_unlock_irqrestore(&vdev->priv_lock, flags2); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&vdev->priv_lock); + spin_unlock(&the_controller->lock); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC); return -ENOMEM; } @@ -716,10 +700,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) list_add_tail(&unlink->list, &vdev->unlink_tx); wake_up(&vdev->waitq_tx); - spin_unlock_irqrestore(&vdev->priv_lock, flags2); + spin_unlock(&vdev->priv_lock); } - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usbip_dbg_vhci_hc("leave\n"); return 0; @@ -957,9 +941,9 @@ static int vhci_bus_suspend(struct usb_hcd *hcd) dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); - spin_lock_irq(&vhci->lock); + spin_lock(&vhci->lock); hcd->state = HC_STATE_SUSPENDED; - spin_unlock_irq(&vhci->lock); + spin_unlock(&vhci->lock); return 0; } @@ -971,13 +955,13 @@ static int vhci_bus_resume(struct usb_hcd *hcd) dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); - spin_lock_irq(&vhci->lock); + spin_lock(&vhci->lock); if (!HCD_HW_ACCESSIBLE(hcd)) { rc = -ESHUTDOWN; } else { hcd->state = HC_STATE_RUNNING; } - spin_unlock_irq(&vhci->lock); + spin_unlock(&vhci->lock); return rc; } diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c index ba5f1c0..faf8e60 100644 --- a/drivers/staging/usbip/vhci_rx.c +++ b/drivers/staging/usbip/vhci_rx.c @@ -68,7 +68,6 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, { struct usbip_device *ud = &vdev->ud; struct urb *urb; - unsigned long flags; spin_lock(&vdev->priv_lock); urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum); @@ -101,9 +100,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, usbip_dbg_vhci_rx("now giveback urb %p\n", urb); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); @@ -141,7 +140,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, { struct vhci_unlink *unlink; struct urb *urb; - unsigned long flags; usbip_dump_header(pdu); @@ -171,9 +169,9 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, urb->status = pdu->u.ret_unlink.status; pr_info("urb->status %d\n", urb->status); - spin_lock_irqsave(&the_controller->lock, flags); + spin_lock(&the_controller->lock); usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); - spin_unlock_irqrestore(&the_controller->lock, flags); + spin_unlock(&the_controller->lock); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c index b1f0dcd..409fd99 100644 --- a/drivers/staging/usbip/vhci_tx.c +++ b/drivers/staging/usbip/vhci_tx.c @@ -46,18 +46,17 @@ static void setup_cmd_submit_pdu(struct usbip_header *pdup, struct urb *urb) static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev) { - unsigned long flags; struct vhci_priv *priv, *tmp; - spin_lock_irqsave(&vdev->priv_lock, flags); + spin_lock(&vdev->priv_lock); list_for_each_entry_safe(priv, tmp, &vdev->priv_tx, list) { list_move_tail(&priv->list, &vdev->priv_rx); - spin_unlock_irqrestore(&vdev->priv_lock, flags); + spin_unlock(&vdev->priv_lock); return priv; } - spin_unlock_irqrestore(&vdev->priv_lock, flags); + spin_unlock(&vdev->priv_lock); return NULL; } @@ -136,18 +135,17 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev) { - unsigned long flags; struct vhci_unlink *unlink, *tmp; - spin_lock_irqsave(&vdev->priv_lock, flags); + spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { list_move_tail(&unlink->list, &vdev->unlink_rx); - spin_unlock_irqrestore(&vdev->priv_lock, flags); + spin_unlock(&vdev->priv_lock); return unlink; } - spin_unlock_irqrestore(&vdev->priv_lock, flags); + spin_unlock(&vdev->priv_lock); return NULL; } diff --git a/drivers/staging/vme/devices/Kconfig b/drivers/staging/vme/devices/Kconfig index d0cab17..8e8bbb1 100644 --- a/drivers/staging/vme/devices/Kconfig +++ b/drivers/staging/vme/devices/Kconfig @@ -6,7 +6,7 @@ config VME_USER help If you say Y here you want to be able to access a limited number of VME windows in a manner at least semi-compatible with the interface - provided with the original driver at http://vmelinux.org/. + provided with the original driver at <http://www.vmelinux.org/>. config VME_PIO2 tristate "GE PIO2 VME" diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c index bf73ba2..fd19c25 100644 --- a/drivers/staging/vme/devices/vme_pio2_core.c +++ b/drivers/staging/vme/devices/vme_pio2_core.c @@ -222,7 +222,6 @@ static int pio2_probe(struct vme_dev *vdev) card = kzalloc(sizeof(struct pio2_card), GFP_KERNEL); if (card == NULL) { - dev_err(&vdev->dev, "Unable to allocate card structure\n"); retval = -ENOMEM; goto err_struct; } diff --git a/drivers/staging/vme/devices/vme_pio2_gpio.c b/drivers/staging/vme/devices/vme_pio2_gpio.c index 69d8805..2a2d920 100644 --- a/drivers/staging/vme/devices/vme_pio2_gpio.c +++ b/drivers/staging/vme/devices/vme_pio2_gpio.c @@ -192,10 +192,8 @@ int pio2_gpio_init(struct pio2_card *card) char *label; label = kmalloc(PIO2_NUM_CHANNELS, GFP_KERNEL); - if (label == NULL) { - dev_err(&card->vdev->dev, "Unable to allocate GPIO label\n"); + if (label == NULL) return -ENOMEM; - } sprintf(label, "%s@%s", driver_name, dev_name(&card->vdev->dev)); card->gc.label = label; diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 4ef852c..57474cf 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -761,8 +761,6 @@ static int vme_user_probe(struct vme_dev *vdev) image[i].size_buf = PCI_BUF_SIZE; image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL); if (image[i].kern_buf == NULL) { - dev_warn(&vdev->dev, - "Unable to allocate memory for master window buffers\n"); err = -ENOMEM; goto err_master_buf; } diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 47c156b..aa76e39 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -749,9 +749,9 @@ bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, unsigned char *pbyChannelNumber, unsigned char *pbyMap) { - if (uChannelIndex > CB_MAX_CHANNEL) { + if (uChannelIndex > CB_MAX_CHANNEL) return false; - } + *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber; *pbyMap = sChannelTbl[uChannelIndex].byMAP; return sChannelTbl[uChannelIndex].bValid; @@ -761,9 +761,9 @@ void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, unsigned char byMap) { - if (uChannelIndex > CB_MAX_CHANNEL) { + if (uChannelIndex > CB_MAX_CHANNEL) return; - } + sChannelTbl[uChannelIndex].byMAP |= byMap; } @@ -771,9 +771,8 @@ void clear_channel_map_info(void *pDeviceHandler) { unsigned int ii = 0; - for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) { + for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) sChannelTbl[ii].byMAP = 0; - } } unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index e54e00b..e27244c 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -881,26 +881,14 @@ inline static bool device_get_ip(PSDevice pInfo) { -static inline PDEVICE_RD_INFO alloc_rd_info(void) { - PDEVICE_RD_INFO ptr; - ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC); - if (ptr == NULL) - return NULL; - else { - memset(ptr,0,sizeof(DEVICE_RD_INFO)); - return ptr; - } +static inline PDEVICE_RD_INFO alloc_rd_info(void) +{ + return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC); } -static inline PDEVICE_TD_INFO alloc_td_info(void) { - PDEVICE_TD_INFO ptr; - ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC); - if (ptr == NULL) - return NULL; - else { - memset(ptr,0,sizeof(DEVICE_TD_INFO)); - return ptr; - } +static inline PDEVICE_TD_INFO alloc_td_info(void) +{ + return kzalloc(sizeof(DEVICE_TD_INFO), GFP_ATOMIC); } /*--------------------- Export Functions --------------------------*/ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 875ee44..d66854f 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -2421,7 +2421,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); // Notes: - // Although spec says MMPDU can be fragmented; In most case, + // Although spec says MMPDU can be fragmented; In most cases, // no one will send a MMPDU under fragmentation. With RTS may occur. pDevice->bAES = false; //Set FRAGCTL_WEPTYP @@ -2510,7 +2510,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); //Fill TXKEY - //Kyle: Need fix: TKIP and AES did't encryt Mnt Packet. + //Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet. //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL); //Fill IV(ExtIV,RSNHDR) @@ -2957,7 +2957,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)cbMacHdLen << 10); // Notes: - // Although spec says MMPDU can be fragmented; In most casses, + // Although spec says MMPDU can be fragmented; In most cases, // no one will send a MMPDU under fragmentation. With RTS may occur. pDevice->bAES = false; //Set FRAGCTL_WEPTYP diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 6d0b87a..101c735 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -720,7 +720,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS pDevice->nTxDataTimeCout = 0; } else { - // printk("mike:-->First time triger TimerTxData InSleep\n"); + // printk("mike:-->First time trigger TimerTxData InSleep\n"); } pDevice->IsTxDataTrigger = true; add_timer(&pDevice->sTimerTxData); diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index b6f99ec..b08a611 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -2068,7 +2068,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) if (pBSSList != NULL) { - // Compare PHY paramater setting + // Compare PHY parameter setting if (pMgmt->wCurrCapInfo != pBSSList->wCapInfo) { bUpdatePhyParameter = true; pMgmt->wCurrCapInfo = pBSSList->wCapInfo; diff --git a/drivers/staging/vt6656/80211mgr.c b/drivers/staging/vt6656/80211mgr.c index e6ced95..534d490 100644 --- a/drivers/staging/vt6656/80211mgr.c +++ b/drivers/staging/vt6656/80211mgr.c @@ -96,9 +96,10 @@ vMgrEncodeBeacon( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_BEACON_OFF_TS); + /* Fixed Fields */ + pFrame->pqwTimestamp = + (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -130,9 +131,10 @@ vMgrDecodeBeacon( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_BEACON_OFF_TS); + /* Fixed Fields */ + pFrame->pqwTimestamp = + (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -178,7 +180,7 @@ vMgrDecodeBeacon( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; @@ -391,7 +393,7 @@ vMgrDecodeAssocRequest( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; @@ -561,7 +563,7 @@ vMgrDecodeReassocRequest( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; break; @@ -671,9 +673,10 @@ vMgrEncodeProbeResponse( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_PROBERESP_OFF_TS); + /* Fixed Fields */ + pFrame->pqwTimestamp = + (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -706,9 +709,10 @@ vMgrDecodeProbeResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_PROBERESP_OFF_TS); + /* Fixed Fields */ + pFrame->pqwTimestamp = + (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -749,7 +753,7 @@ vMgrDecodeProbeResponse( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; diff --git a/drivers/staging/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h index e5db73b..f8e16d8 100644 --- a/drivers/staging/vt6656/80211mgr.h +++ b/drivers/staging/vt6656/80211mgr.h @@ -38,7 +38,7 @@ #define WLAN_MIN_ARRAY 1 -// Information Element ID value +/* Information Element ID value */ #define WLAN_EID_SSID 0 #define WLAN_EID_SUPP_RATES 1 #define WLAN_EID_FH_PARMS 2 @@ -59,10 +59,10 @@ #define WLAN_EID_QUIET 40 #define WLAN_EID_IBSS_DFS 41 #define WLAN_EID_ERP 42 -// reference 802.11i 7.3.2 table 20 +/* reference 802.11i 7.3.2 table 20 */ #define WLAN_EID_RSN 48 #define WLAN_EID_EXTSUPP_RATES 50 -// reference WiFi WPA spec. +/* reference WiFi WPA spec */ #define WLAN_EID_RSN_WPA 221 #ifdef Cisco_ccx @@ -75,7 +75,7 @@ #define WLAN_EID_ERP_USE_PROTECTION 0x02 #define WLAN_EID_ERP_BARKER_MODE 0x04 -// Reason Codes +/* reason codes */ #define WLAN_MGMT_REASON_RSVD 0 #define WLAN_MGMT_REASON_UNSPEC 1 #define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2 @@ -100,7 +100,7 @@ #define WLAN_MGMT_REASON_RSNE_CAP_INVALID 22 #define WLAN_MGMT_REASON_80211X_AUTH_FAILED 23 -// Status Codes +/* status codes */ #define WLAN_MGMT_STATUS_SUCCESS 0 #define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1 #define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10 @@ -116,19 +116,16 @@ #define WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC 20 #define WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY 21 -// reference 802.11h 7.3.1.9 -// +/* reference 802.11h 7.3.1.9 */ #define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SPECTRUM_MNG 22 #define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_PWR_CAP 23 #define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SUPP_CH 24 -// -// reference 802.11g 7.3.1.9 -// + +/* reference 802.11g 7.3.1.9 */ #define WLAN_MGMT_STATUS_SHORTSLOTTIME_UNSUPPORTED 25 #define WLAN_MGMT_STATUS_DSSSOFDM_UNSUPPORTED 26 -// -// reference 802.11i 7.3.1.9 table 19 -// + +/* reference 802.11i 7.3.1.9 table 19 */ #define WLAN_MGMT_STATUS_INVALID_IE 40 #define WLAN_MGMT_STATUS_GROUP_CIPHER_INVALID 41 #define WLAN_MGMT_STATUS_PAIRWISE_CIPHER_INVALID 42 @@ -137,17 +134,16 @@ #define WLAN_MGMT_STATUS_INVALID_RSN_IE_CAP 45 #define WLAN_MGMT_STATUS_CIPHER_REJECT 46 - - -// Auth Algorithm +/* auth algorithm */ #define WLAN_AUTH_ALG_OPENSYSTEM 0 #define WLAN_AUTH_ALG_SHAREDKEY 1 +/* management frame field offsets */ - -// Management Frame Field Offsets -// Note: Not all fields are listed because of variable lengths. -// Note: These offsets are from the start of the frame data +/* + * Note: Not all fields are listed because of variable lengths + * Note: These offsets are from the start of the frame data + */ #define WLAN_BEACON_OFF_TS 0 #define WLAN_BEACON_OFF_BCN_INT 8 @@ -189,10 +185,7 @@ #define WLAN_DEAUTHEN_OFF_REASON 0 - -// -// Cipher Suite Selectors defined in 802.11i -// +/* cipher suite selectors defined in 802.11i */ #define WLAN_11i_CSS_USE_GROUP 0 #define WLAN_11i_CSS_WEP40 1 #define WLAN_11i_CSS_TKIP 2 @@ -200,24 +193,22 @@ #define WLAN_11i_CSS_WEP104 5 #define WLAN_11i_CSS_UNKNOWN 255 -// -// Authentication and Key Management Suite Selectors defined in 802.11i -// +/* authentication and key management suite selectors defined in 802.11i */ #define WLAN_11i_AKMSS_802_1X 1 #define WLAN_11i_AKMSS_PSK 2 #define WLAN_11i_AKMSS_UNKNOWN 255 -// Measurement type definitions reference ieee 802.11h Table 20b +/* measurement type definitions reference IEEE 802.11h table 20b */ #define MEASURE_TYPE_BASIC 0 #define MEASURE_TYPE_CCA 1 #define MEASURE_TYPE_RPI 2 -// Measurement request mode definitions reference ieee 802.11h Figure 46h +/* measurement request mode definitions reference IEEE 802.11h figure 46h */ #define MEASURE_MODE_ENABLE 0x02 #define MEASURE_MODE_REQ 0x04 #define MEASURE_MODE_REP 0x08 -// Measurement report mode definitions reference ieee 802.11h Figure 46m +/* measurement report mode definitions reference IEEE 802.11h figure 46m */ #define MEASURE_MODE_LATE 0x01 #define MEASURE_MODE_INCAPABLE 0x02 #define MEASURE_MODE_REFUSED 0x04 @@ -228,7 +219,7 @@ /*--------------------- Export Types ------------------------------*/ -// Information Element Types +/* Information Element types */ #pragma pack(1) typedef struct tagWLAN_IE { @@ -237,7 +228,7 @@ typedef struct tagWLAN_IE { } __attribute__ ((__packed__)) WLAN_IE, *PWLAN_IE; -// Service Set Identity (SSID) +/* Service Set IDentity (SSID) */ #pragma pack(1) typedef struct tagWLAN_IE_SSID { BYTE byElementID; @@ -246,7 +237,7 @@ typedef struct tagWLAN_IE_SSID { } __attribute__ ((__packed__)) WLAN_IE_SSID, *PWLAN_IE_SSID; -// Supported Rates +/* Supported Rates */ #pragma pack(1) typedef struct tagWLAN_IE_SUPP_RATES { BYTE byElementID; @@ -255,7 +246,7 @@ typedef struct tagWLAN_IE_SUPP_RATES { } __attribute__ ((__packed__)) WLAN_IE_SUPP_RATES, *PWLAN_IE_SUPP_RATES; -// FH Parameter Set +/* FH Parameter Set */ #pragma pack(1) typedef struct _WLAN_IE_FH_PARMS { BYTE byElementID; @@ -266,7 +257,7 @@ typedef struct _WLAN_IE_FH_PARMS { BYTE byHopIndex; } WLAN_IE_FH_PARMS, *PWLAN_IE_FH_PARMS; -// DS Parameter Set +/* DS Parameter Set */ #pragma pack(1) typedef struct tagWLAN_IE_DS_PARMS { BYTE byElementID; @@ -275,7 +266,7 @@ typedef struct tagWLAN_IE_DS_PARMS { } __attribute__ ((__packed__)) WLAN_IE_DS_PARMS, *PWLAN_IE_DS_PARMS; -// CF Parameter Set +/* CF Parameter Set */ #pragma pack(1) typedef struct tagWLAN_IE_CF_PARMS { BYTE byElementID; @@ -287,7 +278,7 @@ typedef struct tagWLAN_IE_CF_PARMS { } __attribute__ ((__packed__)) WLAN_IE_CF_PARMS, *PWLAN_IE_CF_PARMS; -// TIM +/* TIM */ #pragma pack(1) typedef struct tagWLAN_IE_TIM { BYTE byElementID; @@ -299,7 +290,7 @@ typedef struct tagWLAN_IE_TIM { } __attribute__ ((__packed__)) WLAN_IE_TIM, *PWLAN_IE_TIM; -// IBSS Parameter Set +/* IBSS Parameter Set */ #pragma pack(1) typedef struct tagWLAN_IE_IBSS_PARMS { BYTE byElementID; @@ -308,7 +299,7 @@ typedef struct tagWLAN_IE_IBSS_PARMS { } __attribute__ ((__packed__)) WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS; -// Challenge Text +/* Challenge Text */ #pragma pack(1) typedef struct tagWLAN_IE_CHALLENGE { BYTE byElementID; @@ -325,10 +316,10 @@ typedef struct tagWLAN_IE_RSN_EXT { WORD wVersion; BYTE abyMulticast[4]; WORD wPKCount; - struct { - BYTE abyOUI[4]; - } PKSList[1]; // the rest is variable so need to - // overlay ieauth structure + struct { + BYTE abyOUI[4]; + } PKSList[1]; + /* the rest is variable so need to overlay ieauth structure */ } WLAN_IE_RSN_EXT, *PWLAN_IE_RSN_EXT; #pragma pack(1) @@ -339,7 +330,7 @@ typedef struct tagWLAN_IE_RSN_AUTH { } AuthKSList[1]; } WLAN_IE_RSN_AUTH, *PWLAN_IE_RSN_AUTH; -// RSN Identity +/* RSN Identity */ #pragma pack(1) typedef struct tagWLAN_IE_RSN { BYTE byElementID; @@ -348,8 +339,7 @@ typedef struct tagWLAN_IE_RSN { BYTE abyRSN[WLAN_MIN_ARRAY]; } WLAN_IE_RSN, *PWLAN_IE_RSN; - -// CCX Identity DavidWang +/* CCX Identity DavidWang */ #pragma pack(1) typedef struct tagWLAN_IE_CCX { BYTE byElementID; @@ -371,9 +361,7 @@ BYTE len; BYTE abyCCXVer[5]; } WLAN_IE_CCX_Ver, *PWLAN_IE_CCX_Ver; - - -// ERP +/* ERP */ #pragma pack(1) typedef struct tagWLAN_IE_ERP { BYTE byElementID; @@ -505,10 +493,9 @@ typedef struct _WLAN_IE_IBSS_DFS { #pragma pack() +/* frame types */ - -// Frame Types -// prototype structure, all mgmt frame types will start with these members +/* prototype structure, all mgmt frame types will start with these members */ typedef struct tagWLAN_FR_MGMT { unsigned int uType; @@ -518,21 +505,21 @@ typedef struct tagWLAN_FR_MGMT { } WLAN_FR_MGMT, *PWLAN_FR_MGMT; -// Beacon frame +/* beacon frame */ typedef struct tagWLAN_FR_BEACON { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - // fixed fields - PQWORD pqwTimestamp; + /* fixed fields */ + u64 *pqwTimestamp; PWORD pwBeaconInterval; PWORD pwCapInfo; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; -// PWLAN_IE_FH_PARMS pFHParms; +/* PWLAN_IE_FH_PARMS pFHParms; */ PWLAN_IE_DS_PARMS pDSParms; PWLAN_IE_CF_PARMS pCFParms; PWLAN_IE_TIM pTIM; @@ -549,8 +536,7 @@ typedef struct tagWLAN_FR_BEACON { } WLAN_FR_BEACON, *PWLAN_FR_BEACON; - -// IBSS ATIM frame +/* IBSS ATIM frame */ typedef struct tagWLAN_FR_IBSSATIM { unsigned int uType; @@ -558,36 +544,36 @@ typedef struct tagWLAN_FR_IBSSATIM { PBYTE pBuf; PUWLAN_80211HDR pHdr; - // fixed fields - // info elements - // this frame type has a null body + /* fixed fields */ + /* info elements */ + /* this frame type has a null body */ } WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM; -// Disassociation +/* disassociation */ typedef struct tagWLAN_FR_DISASSOC { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwReason; - /*-- info elements ----------*/ + /* info elements */ } WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC; -// Association Request +/* association request */ typedef struct tagWLAN_FR_ASSOCREQ { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwCapInfo; PWORD pwListenInterval; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_RSN pRSN; @@ -601,24 +587,24 @@ typedef struct tagWLAN_FR_ASSOCREQ { } WLAN_FR_ASSOCREQ, *PWLAN_FR_ASSOCREQ; -// Association Response +/* association response */ typedef struct tagWLAN_FR_ASSOCRESP { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwCapInfo; PWORD pwStatus; PWORD pwAid; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_SUPP_RATES pExtSuppRates; } WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP; -// Reassociation Request +/* reassociation request */ typedef struct tagWLAN_FR_REASSOCREQ { unsigned int uType; @@ -626,12 +612,12 @@ typedef struct tagWLAN_FR_REASSOCREQ { PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwCapInfo; PWORD pwListenInterval; PIEEE_ADDR pAddrCurrAP; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_RSN pRSN; @@ -643,50 +629,50 @@ typedef struct tagWLAN_FR_REASSOCREQ { } WLAN_FR_REASSOCREQ, *PWLAN_FR_REASSOCREQ; -// Reassociation Response +/* reassociation response */ typedef struct tagWLAN_FR_REASSOCRESP { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwCapInfo; PWORD pwStatus; PWORD pwAid; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_SUPP_RATES pExtSuppRates; } WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP; -// Probe Request +/* probe request */ typedef struct tagWLAN_FR_PROBEREQ { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ - /*-- info elements ----------*/ + /* fixed fields */ + /* info elements */ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_SUPP_RATES pExtSuppRates; } WLAN_FR_PROBEREQ, *PWLAN_FR_PROBEREQ; -// Probe Response +/* probe response */ typedef struct tagWLAN_FR_PROBERESP { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ - PQWORD pqwTimestamp; + /* fixed fields */ + u64 *pqwTimestamp; PWORD pwBeaconInterval; PWORD pwCapInfo; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_DS_PARMS pDSParms; @@ -704,37 +690,38 @@ typedef struct tagWLAN_FR_PROBERESP { } WLAN_FR_PROBERESP, *PWLAN_FR_PROBERESP; -// Authentication +/* authentication */ typedef struct tagWLAN_FR_AUTHEN { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwAuthAlgorithm; PWORD pwAuthSequence; PWORD pwStatus; - /*-- info elements ----------*/ + /* info elements */ PWLAN_IE_CHALLENGE pChallenge; } WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN; -// Deauthentication +/* deauthentication */ typedef struct tagWLAN_FR_DEAUTHEN { unsigned int uType; unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; - /*-- fixed fields -----------*/ + /* fixed fields */ PWORD pwReason; - /*-- info elements ----------*/ + /* info elements */ } WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN; /*--------------------- Export Functions --------------------------*/ + void vMgrEncodeBeacon( PWLAN_FR_BEACON pFrame @@ -845,4 +832,4 @@ vMgrDecodeReassocResponse( PWLAN_FR_REASSOCRESP pFrame ); -#endif// __80211MGR_H__ +#endif /* __80211MGR_H__ */ diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c index f7a3b8f..fb6124d 100644 --- a/drivers/staging/vt6656/aes_ccmp.c +++ b/drivers/staging/vt6656/aes_ccmp.c @@ -231,7 +231,7 @@ void AESv128(BYTE *key, BYTE *data, BYTE *ciphertext) * */ -BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) +bool AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) { BYTE abyNonce[13]; BYTE MIC_IV[16]; @@ -249,7 +249,7 @@ BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) WORD wHLen = 22; /* 8 is IV, 8 is MIC, 4 is CRC */ WORD wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN; - BOOL bA4 = FALSE; + bool bA4 = false; BYTE byTmp; WORD wCnt; int ii, jj, kk; @@ -257,7 +257,7 @@ BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; if (WLAN_GET_FC_TODS(*(PWORD) pbyFrame) && WLAN_GET_FC_FROMDS(*(PWORD) pbyFrame)) { - bA4 = TRUE; + bA4 = true; pbyIV += 6; /* 6 is 802.11 address4 */ wHLen += 6; wPayloadSize -= 6; @@ -380,7 +380,7 @@ BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) /* => above is the packet dec-MIC */ if (!memcmp(abyMIC, abyTmp, 8)) - return TRUE; + return true; else - return FALSE; + return false; } diff --git a/drivers/staging/vt6656/aes_ccmp.h b/drivers/staging/vt6656/aes_ccmp.h index 353bd21..a2e2c4e 100644 --- a/drivers/staging/vt6656/aes_ccmp.h +++ b/drivers/staging/vt6656/aes_ccmp.h @@ -41,6 +41,6 @@ /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize); +bool AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize); #endif /* __AES_CCMP_H__ */ diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 3855015..a9f525e 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -690,7 +690,7 @@ s_vClearSQ3Value(PSDevice pDevice); * */ unsigned int -BBuGetFrameTime ( +BBuGetFrameTime( BYTE byPreambleType, BYTE byPktType, unsigned int cbFrameLength, @@ -756,26 +756,19 @@ BBuGetFrameTime ( * Return Value: none * */ -void -BBvCalculateParameter ( - PSDevice pDevice, - unsigned int cbFrameLength, - WORD wRate, - BYTE byPacketType, - PWORD pwPhyLen, - PBYTE pbyPhySrv, - PBYTE pbyPhySgn - ) +void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, + u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv, + u8 *pbyPhySgn) { - unsigned int cbBitCount; - unsigned int cbUsCount = 0; - unsigned int cbTmp; - BOOL bExtBit; - BYTE byPreambleType = pDevice->byPreambleType; - BOOL bCCK = pDevice->bCCK; + u32 cbBitCount; + u32 cbUsCount = 0; + u32 cbTmp; + int bExtBit; + u8 byPreambleType = pDevice->byPreambleType; + int bCCK = pDevice->bCCK; cbBitCount = cbFrameLength * 8; - bExtBit = FALSE; + bExtBit = false; switch (wRate) { case RATE_1M : @@ -792,7 +785,7 @@ BBvCalculateParameter ( break; case RATE_5M : - if (bCCK == FALSE) + if (bCCK == false) cbBitCount ++; cbUsCount = (cbBitCount * 10) / 55; cbTmp = (cbUsCount * 55) / 10; @@ -806,14 +799,14 @@ BBvCalculateParameter ( case RATE_11M : - if (bCCK == FALSE) + if (bCCK == false) cbBitCount ++; cbUsCount = cbBitCount / 11; cbTmp = cbUsCount * 11; if (cbTmp != cbBitCount) { cbUsCount ++; if ((cbBitCount - cbTmp) <= 3) - bExtBit = TRUE; + bExtBit = true; } if (byPreambleType == 1) *pbyPhySgn = 0x0b; @@ -929,8 +922,7 @@ BBvCalculateParameter ( * Return Value: none * */ -void -BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode) +void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) { switch (byAntennaMode) { case ANT_TXA: @@ -968,7 +960,7 @@ BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode) * */ -BOOL BBbVT3184Init(PSDevice pDevice) +int BBbVT3184Init(struct vnt_private *pDevice) { int ntStatus; WORD wLength; @@ -984,12 +976,12 @@ BOOL BBbVT3184Init(PSDevice pDevice) EEP_MAX_CONTEXT_SIZE, pDevice->abyEEPROM); if (ntStatus != STATUS_SUCCESS) { - return FALSE; + return false; } // if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04) -// return FALSE; +// return false; //zonetype initial pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; @@ -1105,7 +1097,7 @@ else { MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); //}} } else { - return TRUE; + return true; } memcpy(abyArray, pbyAddr, wLength); @@ -1144,7 +1136,7 @@ else { ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01); RFbRFTableDownload(pDevice); - return TRUE;//ntStatus; + return true;//ntStatus; } @@ -1161,7 +1153,7 @@ else { * Return Value: none * */ -void BBvLoopbackOn (PSDevice pDevice) +void BBvLoopbackOn(struct vnt_private *pDevice) { BYTE byData; @@ -1214,9 +1206,9 @@ void BBvLoopbackOn (PSDevice pDevice) * Return Value: none * */ -void BBvLoopbackOff (PSDevice pDevice) +void BBvLoopbackOff(struct vnt_private *pDevice) { - BYTE byData; + u8 byData; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, pDevice->byBBCRc9);//CR201 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, pDevice->byBBCR88);//CR136 @@ -1249,8 +1241,7 @@ void BBvLoopbackOff (PSDevice pDevice) * Return Value: none * */ -void -BBvSetShortSlotTime (PSDevice pDevice) +void BBvSetShortSlotTime(struct vnt_private *pDevice) { BYTE byBBVGA=0; @@ -1267,7 +1258,7 @@ BBvSetShortSlotTime (PSDevice pDevice) } -void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData) +void BBvSetVGAGainOffset(struct vnt_private *pDevice, BYTE byData) { ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData); @@ -1294,8 +1285,7 @@ void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData) * Return Value: none * */ -void -BBvSoftwareReset (PSDevice pDevice) +void BBvSoftwareReset(struct vnt_private *pDevice) { ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0x40); ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0); @@ -1315,22 +1305,20 @@ BBvSoftwareReset (PSDevice pDevice) * Return Value: none * */ -void -BBvSetDeepSleep (PSDevice pDevice) +void BBvSetDeepSleep(struct vnt_private *pDevice) { ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13 } -void -BBvExitDeepSleep (PSDevice pDevice) +void BBvExitDeepSleep(struct vnt_private *pDevice) { ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13 } -static unsigned long s_ulGetLowSQ3(PSDevice pDevice) +static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice) { int ii; unsigned long ulSQ3 = 0; @@ -1349,7 +1337,7 @@ static unsigned long s_ulGetLowSQ3(PSDevice pDevice) return ulSQ3; } -static unsigned long s_ulGetRatio(PSDevice pDevice) +static unsigned long s_ulGetRatio(struct vnt_private *pDevice) { int ii, jj; unsigned long ulRatio = 0; @@ -1377,9 +1365,7 @@ static unsigned long s_ulGetRatio(PSDevice pDevice) } -static -void -s_vClearSQ3Value (PSDevice pDevice) +static void s_vClearSQ3Value(struct vnt_private *pDevice) { int ii; pDevice->uDiversityCnt = 0; @@ -1406,8 +1392,8 @@ s_vClearSQ3Value (PSDevice pDevice) * */ -void -BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3) +void BBvAntennaDiversity(struct vnt_private *pDevice, + u8 byRxRate, u8 bySQ3) { pDevice->uDiversityCnt++; @@ -1541,9 +1527,8 @@ BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3) * -*/ -void TimerSQ3CallBack(void *hDeviceContext) +void TimerSQ3CallBack(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack..."); spin_lock_irq(&pDevice->lock); @@ -1579,9 +1564,8 @@ void TimerSQ3CallBack(void *hDeviceContext) * -*/ -void TimerSQ3Tmax3CallBack(void *hDeviceContext) +void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack..."); spin_lock_irq(&pDevice->lock); @@ -1607,10 +1591,7 @@ void TimerSQ3Tmax3CallBack(void *hDeviceContext) spin_unlock_irq(&pDevice->lock); } -void -BBvUpdatePreEDThreshold( - PSDevice pDevice, - BOOL bScanning) +void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) { diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 844d5a8..fba6160 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -42,31 +42,30 @@ #define PREAMBLE_LONG 0 #define PREAMBLE_SHORT 1 -// -// Registers in the BASEBAND -// +/* + * Registers in the BASEBAND + */ #define BB_MAX_CONTEXT_SIZE 256 -#define C_SIFS_A 16 // micro sec. +#define C_SIFS_A 16 /* usec */ #define C_SIFS_BG 10 -#define C_EIFS 80 // micro sec. +#define C_EIFS 80 /* usec */ - -#define C_SLOT_SHORT 9 // micro sec. +#define C_SLOT_SHORT 9 /* usec */ #define C_SLOT_LONG 20 -#define C_CWMIN_A 15 // slot time +#define C_CWMIN_A 15 /* slot time */ #define C_CWMIN_B 31 -#define C_CWMAX 1023 // slot time +#define C_CWMAX 1023 /* slot time */ -//0:11A 1:11B 2:11G +/* 0:11A 1:11B 2:11G */ #define BB_TYPE_11A 0 #define BB_TYPE_11B 1 #define BB_TYPE_11G 2 -//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) +/* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga (OFDM in BasicRate) */ #define PK_TYPE_11A 0 #define PK_TYPE_11B 1 #define PK_TYPE_11GB 2 @@ -104,33 +103,26 @@ BBuGetFrameTime( WORD wRate ); -void BBvCalculateParameter(PSDevice pDevice, - unsigned int cbFrameLength, - WORD wRate, - BYTE byPacketType, - PWORD pwPhyLen, - PBYTE pbyPhySrv, - PBYTE pbyPhySgn); - -// timer for antenna diversity - -void TimerSQ3CallBack(void *hDeviceContext); -void TimerSQ3Tmax3CallBack(void *hDeviceContext); - -void BBvAntennaDiversity(PSDevice pDevice, BYTE byRxRate, BYTE bySQ3); -void BBvLoopbackOn(PSDevice pDevice); -void BBvLoopbackOff(PSDevice pDevice); -void BBvSoftwareReset(PSDevice pDevice); - -void BBvSetShortSlotTime(PSDevice pDevice); -void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData); -void BBvSetAntennaMode(PSDevice pDevice, BYTE byAntennaMode); -BOOL BBbVT3184Init(PSDevice pDevice); -void BBvSetDeepSleep(PSDevice pDevice); -void BBvExitDeepSleep(PSDevice pDevice); -void BBvUpdatePreEDThreshold( - PSDevice pDevice, - BOOL bScanning - ); +void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, + u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv, + u8 *pbyPhySgn); + +/* timer for antenna diversity */ + +void TimerSQ3CallBack(struct vnt_private *); +void TimerSQ3Tmax3CallBack(struct vnt_private *); + +void BBvAntennaDiversity(struct vnt_private *, u8 byRxRate, u8 bySQ3); +void BBvLoopbackOn(struct vnt_private *); +void BBvLoopbackOff(struct vnt_private *); +void BBvSoftwareReset(struct vnt_private *); + +void BBvSetShortSlotTime(struct vnt_private *); +void BBvSetVGAGainOffset(struct vnt_private *, u8 byData); +void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode); +int BBbVT3184Init(struct vnt_private *); +void BBvSetDeepSleep(struct vnt_private *); +void BBvExitDeepSleep(struct vnt_private *); +void BBvUpdatePreEDThreshold(struct vnt_private *, int bScanning); #endif /* __BASEBAND_H__ */ diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 6a13941..e214fcf 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -91,9 +91,9 @@ const WORD awHWRetry1[5][5] = { /*--------------------- Static Functions --------------------------*/ -void s_vCheckSensitivity(void *hDeviceContext); -void s_vCheckPreEDThreshold(void *hDeviceContext); -void s_uCalculateLinkQual(void *hDeviceContext); +static void s_vCheckSensitivity(struct vnt_private *pDevice); +static void s_vCheckPreEDThreshold(struct vnt_private *pDevice); +static void s_uCalculateLinkQual(struct vnt_private *pDevice); /*--------------------- Export Variables --------------------------*/ @@ -114,20 +114,19 @@ void s_uCalculateLinkQual(void *hDeviceContext); * -*/ -PKnownBSS BSSpSearchBSSList(void *hDeviceContext, - PBYTE pbyDesireBSSID, - PBYTE pbyDesireSSID, - CARD_PHY_TYPE ePhyType) +PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice, + u8 *pbyDesireBSSID, u8 *pbyDesireSSID, + CARD_PHY_TYPE ePhyType) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PBYTE pbyBSSID = NULL; - PWLAN_IE_SSID pSSID = NULL; - PKnownBSS pCurrBSS = NULL; - PKnownBSS pSelect = NULL; - BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; - unsigned int ii = 0; - unsigned int jj = 0; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 *pbyBSSID = NULL; + PWLAN_IE_SSID pSSID = NULL; + PKnownBSS pCurrBSS = NULL; + PKnownBSS pSelect = NULL; + u8 ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + int ii = 0; + int jj = 0; + if (pbyDesireBSSID != NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID); @@ -142,15 +141,15 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext, } } - if ((pbyBSSID != NULL)&&(pDevice->bRoaming == FALSE)) { + if ((pbyBSSID != NULL)&&(pDevice->bRoaming == false)) { // match BSSID first for (ii = 0; ii <MAX_BSS_NUM; ii++) { pCurrBSS = &(pMgmt->sBSSList[ii]); - pCurrBSS->bSelected = FALSE; + pCurrBSS->bSelected = false; if ((pCurrBSS->bActive) && - (pCurrBSS->bSelected == FALSE)) { + (pCurrBSS->bSelected == false)) { if (!compare_ether_addr(pCurrBSS->abyBSSID, pbyBSSID)) { if (pSSID != NULL) { // compare ssid @@ -161,7 +160,7 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext, ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ) { - pCurrBSS->bSelected = TRUE; + pCurrBSS->bSelected = true; return(pCurrBSS); } } @@ -170,7 +169,7 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext, ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ) { - pCurrBSS->bSelected = TRUE; + pCurrBSS->bSelected = true; return(pCurrBSS); } } @@ -184,9 +183,9 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext, //2007-0721-01<Mark>by MikeLiu // if ((pCurrBSS->bActive) && - // (pCurrBSS->bSelected == FALSE)) { + // (pCurrBSS->bSelected == false)) { - pCurrBSS->bSelected = FALSE; + pCurrBSS->bSelected = false; if (pCurrBSS->bActive) { if (pSSID != NULL) { @@ -237,10 +236,9 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext, pDevice->bSameBSSMaxNum = jj; if (pSelect != NULL) { - pSelect->bSelected = TRUE; - if (pDevice->bRoaming == FALSE) { + pSelect->bSelected = true; + if (pDevice->bRoaming == false) { // Einsn Add @20070907 - memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ; } @@ -263,11 +261,10 @@ pDevice->bSameBSSMaxNum = jj; -*/ -void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID) +void BSSvClearBSSList(struct vnt_private *pDevice, int bKeepCurrBSSID) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (bKeepCurrBSSID) { @@ -277,12 +274,12 @@ void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID) //mike mark: there are two BSSID's in list. If that AP is in hidden ssid mode, one SSID is null, // but other's might not be obvious, so if it associate's with your STA, // you must keep the two of them!! - // bKeepCurrBSSID = FALSE; + // bKeepCurrBSSID = false; continue; } } - pMgmt->sBSSList[ii].bActive = FALSE; + pMgmt->sBSSList[ii].bActive = false; memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS)); } BSSvClearAnyBSSJoinRecord(pDevice); @@ -296,17 +293,15 @@ void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID) * search BSS list by BSSID & SSID if matched * * Return Value: - * TRUE if found. + * true if found. * -*/ -PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext, - PBYTE abyBSSID, - PWLAN_IE_SSID pSSID) +PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *pDevice, + u8 *abyBSSID, PWLAN_IE_SSID pSSID) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PKnownBSS pBSSList = NULL; - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PKnownBSS pBSSList = NULL; + int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSSList = &(pMgmt->sBSSList[ii]); @@ -333,36 +328,34 @@ PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext, * Insert a BSS set into known BSS list * * Return Value: - * TRUE if success. + * true if success. * -*/ -BOOL BSSbInsertToBSSList(void *hDeviceContext, - PBYTE abyBSSIDAddr, - QWORD qwTimestamp, - WORD wBeaconInterval, - WORD wCapInfo, - BYTE byCurrChannel, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - unsigned int uIELength, - PBYTE pbyIEs, - void *pRxPacketContext) +int BSSbInsertToBSSList(struct vnt_private *pDevice, + u8 *abyBSSIDAddr, + u64 qwTimestamp, + u16 wBeaconInterval, + u16 wCapInfo, + u8 byCurrChannel, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + u32 uIELength, + u8 *pbyIEs, + void *pRxPacketContext) { - - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; - PKnownBSS pBSSList = NULL; - unsigned int ii; - BOOL bParsingQuiet = FALSE; - + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_rx_mgmt *pRxPacket = + (struct vnt_rx_mgmt *)pRxPacketContext; + PKnownBSS pBSSList = NULL; + unsigned int ii; + bool bParsingQuiet = false; pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]); @@ -375,13 +368,12 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, if (ii == MAX_BSS_NUM){ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Get free KnowBSS node failed.\n"); - return FALSE; + return false; } // save the BSS info - pBSSList->bActive = TRUE; + pBSSList->bActive = true; memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN); - HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp)); - LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp)); + pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp); pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); pBSSList->wCapInfo = cpu_to_le16(wCapInfo); pBSSList->uClearCount = 0; @@ -412,7 +404,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; } else { - if (pBSSList->sERP.bERPExist == TRUE) { + if (pBSSList->sERP.bERPExist == true) { pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; } else { pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; @@ -428,7 +420,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { // assoc with BSS if (pBSSList == pMgmt->pCurrBSS) { - bParsingQuiet = TRUE; + bParsingQuiet = true; } } @@ -458,27 +450,27 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, } } - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == TRUE)) { + if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == true)) { PSKeyItem pTransmitKey = NULL; - BOOL bIs802_1x = FALSE; + bool bIs802_1x = false; for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii ++) { if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) { - bIs802_1x = TRUE; + bIs802_1x = true; break; } } - if ((bIs802_1x == TRUE) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && + if ((bIs802_1x == true) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) { bAdd_PMKID_Candidate((void *) pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj); - if ((pDevice->bLinkPass == TRUE) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) || - (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == TRUE)) { + if ((pDevice->bLinkPass == true) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { + if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) || + (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == true)) { pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList; pDevice->gsPMKIDCandidate.Version = 1; @@ -503,7 +495,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); - return TRUE; + return true; } @@ -513,43 +505,43 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext, * Update BSS set in known BSS list * * Return Value: - * TRUE if success. + * true if success. * -*/ // TODO: input structure modify -BOOL BSSbUpdateToBSSList(void *hDeviceContext, - QWORD qwTimestamp, - WORD wBeaconInterval, - WORD wCapInfo, - BYTE byCurrChannel, - BOOL bChannelHit, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - PKnownBSS pBSSList, - unsigned int uIELength, - PBYTE pbyIEs, - void *pRxPacketContext) +int BSSbUpdateToBSSList(struct vnt_private *pDevice, + u64 qwTimestamp, + u16 wBeaconInterval, + u16 wCapInfo, + u8 byCurrChannel, + int bChannelHit, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + PKnownBSS pBSSList, + u32 uIELength, + u8 *pbyIEs, + void *pRxPacketContext) { - int ii, jj; - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; - signed long ldBm, ldBmSum; - BOOL bParsingQuiet = FALSE; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_rx_mgmt *pRxPacket = + (struct vnt_rx_mgmt *)pRxPacketContext; + int ii, jj; + signed long ldBm, ldBmSum; + bool bParsingQuiet = false; if (pBSSList == NULL) - return FALSE; + return false; - HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp)); - LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp)); + pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp); + pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); pBSSList->wCapInfo = cpu_to_le16(wCapInfo); pBSSList->uClearCount = 0; @@ -574,7 +566,7 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext, if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; } else { - if (pBSSList->sERP.bERPExist == TRUE) { + if (pBSSList->sERP.bERPExist == true) { pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; } else { pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; @@ -591,7 +583,7 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext, (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { // assoc with BSS if (pBSSList == pMgmt->pCurrBSS) { - bParsingQuiet = TRUE; + bParsingQuiet = true; } } @@ -643,7 +635,7 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext, pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); - return TRUE; + return true; } @@ -660,13 +652,11 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext, * -*/ -BOOL BSSbIsSTAInNodeDB(void *hDeviceContext, - PBYTE abyDstAddr, - unsigned int *puNodeIndex) +int BSSbIsSTAInNodeDB(struct vnt_private *pDevice, + u8 *abyDstAddr, u32 *puNodeIndex) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + unsigned int ii; // Index = 0 reserved for AP Node for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { @@ -674,12 +664,12 @@ BOOL BSSbIsSTAInNodeDB(void *hDeviceContext, if (!compare_ether_addr(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) { *puNodeIndex = ii; - return TRUE; + return true; } } } - return FALSE; + return false; }; @@ -694,15 +684,14 @@ BOOL BSSbIsSTAInNodeDB(void *hDeviceContext, * None * -*/ -void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex) +void BSSvCreateOneNode(struct vnt_private *pDevice, u32 *puNodeIndex) { + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; + u32 BigestCount = 0; + u32 SelectIndex; + struct sk_buff *skb; - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; - unsigned int BigestCount = 0; - unsigned int SelectIndex; - struct sk_buff *skb; // Index = 0 reserved for AP Node (In STA mode) // Index = 0 reserved for Broadcast/MultiCast (In AP mode) SelectIndex = 1; @@ -733,7 +722,7 @@ void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex) } memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB)); - pMgmt->sNodeDBTable[*puNodeIndex].bActive = TRUE; + pMgmt->sNodeDBTable[*puNodeIndex].bActive = true; pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND; // for AP mode PS queue skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue); @@ -755,13 +744,11 @@ void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex) * -*/ -void BSSvRemoveOneNode(void *hDeviceContext, unsigned int uNodeIndex) +void BSSvRemoveOneNode(struct vnt_private *pDevice, u32 uNodeIndex) { - - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - struct sk_buff *skb; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; + struct sk_buff *skb; while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL) @@ -782,18 +769,15 @@ void BSSvRemoveOneNode(void *hDeviceContext, unsigned int uNodeIndex) * -*/ -void BSSvUpdateAPNode(void *hDeviceContext, - PWORD pwCapInfo, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates) +void BSSvUpdateAPNode(struct vnt_private *pDevice, u16 *pwCapInfo, + PWLAN_IE_SUPP_RATES pSuppRates, PWLAN_IE_SUPP_RATES pExtSuppRates) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int uRateLen = WLAN_RATES_MAXLEN; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 uRateLen = WLAN_RATES_MAXLEN; memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); - pMgmt->sNodeDBTable[0].bActive = TRUE; + pMgmt->sNodeDBTable[0].bActive = true; if (pDevice->byBBType == BB_TYPE_11B) { uRateLen = WLAN_RATES_MAXLEN_11B; } @@ -806,7 +790,7 @@ void BSSvUpdateAPNode(void *hDeviceContext, RATEvParseMaxRate((void *) pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - TRUE, + true, &(pMgmt->sNodeDBTable[0].wMaxBasicRate), &(pMgmt->sNodeDBTable[0].wMaxSuppRate), &(pMgmt->sNodeDBTable[0].wSuppRate), @@ -834,21 +818,20 @@ void BSSvUpdateAPNode(void *hDeviceContext, * -*/ -void BSSvAddMulticastNode(void *hDeviceContext) +void BSSvAddMulticastNode(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; if (!pDevice->bEnableHostWEP) memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[0].bActive = TRUE; - pMgmt->sNodeDBTable[0].bPSEnable = FALSE; + pMgmt->sNodeDBTable[0].bActive = true; + pMgmt->sNodeDBTable[0].bPSEnable = false; skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue); RATEvParseMaxRate((void *) pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - TRUE, + true, &(pMgmt->sNodeDBTable[0].wMaxBasicRate), &(pMgmt->sNodeDBTable[0].wMaxSuppRate), &(pMgmt->sNodeDBTable[0].wSuppRate), @@ -873,26 +856,25 @@ void BSSvAddMulticastNode(void *hDeviceContext) * -*/ -void BSSvSecondCallBack(void *hDeviceContext) +void BSSvSecondCallBack(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; - PWLAN_IE_SSID pItemSSID, pCurrSSID; - unsigned int uSleepySTACnt = 0; - unsigned int uNonShortSlotSTACnt = 0; - unsigned int uLongPreambleSTACnt = 0; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; + PWLAN_IE_SSID pItemSSID, pCurrSSID; + u32 uSleepySTACnt = 0; + u32 uNonShortSlotSTACnt = 0; + u32 uLongPreambleSTACnt = 0; spin_lock_irq(&pDevice->lock); pDevice->uAssocCount = 0; //Power Saving Mode Tx Burst - if ( pDevice->bEnablePSMode == TRUE ) { + if ( pDevice->bEnablePSMode == true ) { pDevice->ulPSModeWaitTx++; if ( pDevice->ulPSModeWaitTx >= 2 ) { pDevice->ulPSModeWaitTx = 0; - pDevice->bPSModeTxBurst = FALSE; + pDevice->bPSModeTxBurst = false; } } @@ -909,10 +891,10 @@ void BSSvSecondCallBack(void *hDeviceContext) if(pDevice->byReAssocCount > 0) { pDevice->byReAssocCount++; - if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != TRUE)) { //10 sec timeout + if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != true)) { //10 sec timeout printk("Re-association timeout!!!\n"); pDevice->byReAssocCount = 0; - // if(pDevice->bWPASuppWextEnabled == TRUE) + // if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; memset(&wrqu, 0, sizeof (wrqu)); @@ -921,13 +903,13 @@ if(pDevice->byReAssocCount > 0) { wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); } } - else if(pDevice->bLinkPass == TRUE) + else if(pDevice->bLinkPass == true) pDevice->byReAssocCount = 0; } pMgmt->eLastState = pMgmt->eCurrState ; - s_uCalculateLinkQual((void *)pDevice); + s_uCalculateLinkQual(pDevice); for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { @@ -1006,27 +988,27 @@ if(pDevice->byReAssocCount > 0) { if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) { if (!pDevice->bProtectMode) { MACvEnableProtectMD(pDevice); - pDevice->bProtectMode = TRUE; + pDevice->bProtectMode = true; } } else { if (pDevice->bProtectMode) { MACvDisableProtectMD(pDevice); - pDevice->bProtectMode = FALSE; + pDevice->bProtectMode = false; } } // on/off short slot time if (uNonShortSlotSTACnt > 0) { if (pDevice->bShortSlotTime) { - pDevice->bShortSlotTime = FALSE; + pDevice->bShortSlotTime = false; BBvSetShortSlotTime(pDevice); vUpdateIFS((void *)pDevice); } } else { if (!pDevice->bShortSlotTime) { - pDevice->bShortSlotTime = TRUE; + pDevice->bShortSlotTime = true; BBvSetShortSlotTime(pDevice); vUpdateIFS((void *)pDevice); } @@ -1037,13 +1019,13 @@ if(pDevice->byReAssocCount > 0) { if (uLongPreambleSTACnt > 0) { if (!pDevice->bBarkerPreambleMd) { MACvEnableBarkerPreambleMd(pDevice); - pDevice->bBarkerPreambleMd = TRUE; + pDevice->bBarkerPreambleMd = true; } } else { if (pDevice->bBarkerPreambleMd) { MACvDisableBarkerPreambleMd(pDevice); - pDevice->bBarkerPreambleMd = FALSE; + pDevice->bBarkerPreambleMd = false; } } @@ -1053,9 +1035,9 @@ if(pDevice->byReAssocCount > 0) { // Check if any STA in PS mode, enable DTIM multicast deliver if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { if (uSleepySTACnt > 0) - pMgmt->sNodeDBTable[0].bPSEnable = TRUE; + pMgmt->sNodeDBTable[0].bPSEnable = true; else - pMgmt->sNodeDBTable[0].bPSEnable = FALSE; + pMgmt->sNodeDBTable[0].bPSEnable = false; } pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; @@ -1067,8 +1049,8 @@ if(pDevice->byReAssocCount > 0) { if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS if (pDevice->bUpdateBBVGA) { - /* s_vCheckSensitivity((void *) pDevice); */ - s_vCheckPreEDThreshold((void *) pDevice); + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); } if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) && @@ -1080,14 +1062,14 @@ if(pDevice->byReAssocCount > 0) { } if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) { - pMgmt->sNodeDBTable[0].bActive = FALSE; + pMgmt->sNodeDBTable[0].bActive = false; pMgmt->eCurrMode = WMAC_MODE_STANDBY; pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); - pDevice->bRoaming = TRUE; - pDevice->bIsRoaming = FALSE; + pDevice->bRoaming = true; + pDevice->bIsRoaming = false; DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount); /* let wpa supplicant know AP may disconnect */ @@ -1102,10 +1084,10 @@ if(pDevice->byReAssocCount > 0) { } else if (pItemSSID->len != 0) { //Davidwang - if ((pDevice->bEnableRoaming == TRUE)&&(!(pMgmt->Cisco_cckm))) { + if ((pDevice->bEnableRoaming == true)&&(!(pMgmt->Cisco_cckm))) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bRoaming %d, !\n", pDevice->bRoaming ); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bIsRoaming %d, !\n", pDevice->bIsRoaming ); - if ((pDevice->bRoaming == TRUE)&&(pDevice->bIsRoaming == TRUE)){ + if ((pDevice->bRoaming == true)&&(pDevice->bIsRoaming == true)){ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fast Roaming ...\n"); BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); bScheduleCommand((void *) pDevice, @@ -1116,12 +1098,12 @@ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bIsRoaming %d, !\n", pDevice->bIsRoaming ); pMgmt->abyDesireSSID); pDevice->uAutoReConnectTime = 0; pDevice->uIsroamingTime = 0; - pDevice->bRoaming = FALSE; + pDevice->bRoaming = false; } - else if ((pDevice->bRoaming == FALSE)&&(pDevice->bIsRoaming == TRUE)) { + else if ((pDevice->bRoaming == false)&&(pDevice->bIsRoaming == true)) { pDevice->uIsroamingTime++; if (pDevice->uIsroamingTime >= 20) - pDevice->bIsRoaming = FALSE; + pDevice->bIsRoaming = false; } } @@ -1129,7 +1111,7 @@ else { if (pDevice->uAutoReConnectTime < 10) { pDevice->uAutoReConnectTime++; //network manager support need not do Roaming scan??? - if(pDevice->bWPASuppWextEnabled ==TRUE) + if(pDevice->bWPASuppWextEnabled ==true) pDevice->uAutoReConnectTime = 0; } else { @@ -1169,21 +1151,21 @@ else { if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { if (pDevice->bUpdateBBVGA) { - /* s_vCheckSensitivity((void *) pDevice); */ - s_vCheckPreEDThreshold((void *) pDevice); + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); } if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) { DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount); pMgmt->sNodeDBTable[0].uInActiveCount = 0; pMgmt->eCurrState = WMAC_STATE_STARTED; netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); } } } - if (pDevice->bLinkPass == TRUE) { + if (pDevice->bLinkPass == true) { if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); } @@ -1207,22 +1189,19 @@ else { * -*/ -void BSSvUpdateNodeTxCounter(void *hDeviceContext, - PSStatCounter pStatistic, - BYTE byTSR, - BYTE byPktNO) +void BSSvUpdateNodeTxCounter(struct vnt_private *pDevice, + PSStatCounter pStatistic, u8 byTSR, u8 byPktNO) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int uNodeIndex = 0; - BYTE byTxRetry; - WORD wRate; - WORD wFallBackRate = RATE_1M; - BYTE byFallBack; - unsigned int ii; - PBYTE pbyDestAddr; - BYTE byPktNum; - WORD wFIFOCtl; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 uNodeIndex = 0; + u8 byTxRetry; + u16 wRate; + u16 wFallBackRate = RATE_1M; + u8 byFallBack; + int ii; + u8 *pbyDestAddr; + u8 byPktNum; + u16 wFIFOCtl; byPktNum = (byPktNO & 0x0F) >> 4; byTxRetry = (byTSR & 0xF0) >> 4; @@ -1370,13 +1349,11 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext, * -*/ -void BSSvClearNodeDBTable(void *hDeviceContext, - unsigned int uStartIndex) +void BSSvClearNodeDBTable(struct vnt_private *pDevice, u32 uStartIndex) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - struct sk_buff *skb; - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct sk_buff *skb; + int ii; for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) { if (pMgmt->sNodeDBTable[ii].bActive) { @@ -1392,12 +1369,11 @@ void BSSvClearNodeDBTable(void *hDeviceContext, } }; -void s_vCheckSensitivity(void *hDeviceContext) +static void s_vCheckSensitivity(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PKnownBSS pBSSList = NULL; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ii; + PKnownBSS pBSSList = NULL; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { @@ -1424,7 +1400,7 @@ void s_vCheckSensitivity(void *hDeviceContext) if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { pDevice->uBBVGADiffCount++; if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) - bScheduleCommand((void *) pDevice, + bScheduleCommand(pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL); } else { @@ -1435,13 +1411,12 @@ void s_vCheckSensitivity(void *hDeviceContext) } } -void s_uCalculateLinkQual(void *hDeviceContext) +static void s_uCalculateLinkQual(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - unsigned long TxOkRatio, TxCnt; - unsigned long RxOkRatio, RxCnt; - unsigned long RssiRatio; - long ldBm; + unsigned long TxOkRatio, TxCnt; + unsigned long RxOkRatio, RxCnt; + unsigned long RssiRatio; + long ldBm; TxCnt = pDevice->scStatistic.TxNoRetryOkCount + pDevice->scStatistic.TxRetryOkCount + @@ -1451,7 +1426,7 @@ RxCnt = pDevice->scStatistic.RxFcsErrCnt + TxOkRatio = (TxCnt < 6) ? 4000:((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt); RxOkRatio = (RxCnt < 6) ? 2000:((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt); //decide link quality -if(pDevice->bLinkPass !=TRUE) +if(pDevice->bLinkPass !=true) { pDevice->scStatistic.LinkQuality = 0; pDevice->scStatistic.SignalStren = 0; @@ -1478,28 +1453,28 @@ else pDevice->scStatistic.TxRetryOkCount = 0; } -void BSSvClearAnyBSSJoinRecord(void *hDeviceContext) +void BSSvClearAnyBSSJoinRecord(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) - pMgmt->sBSSList[ii].bSelected = FALSE; + pMgmt->sBSSList[ii].bSelected = false; + + return; } -void s_vCheckPreEDThreshold(void *hDeviceContext) +static void s_vCheckPreEDThreshold(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PKnownBSS pBSSList = NULL; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + PKnownBSS pBSSList = NULL; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); if (pBSSList != NULL) { pDevice->byBBPreEDRSSI = (BYTE) (~(pBSSList->ldBmAverRange) + 1); - BBvUpdatePreEDThreshold(pDevice, FALSE); + BBvUpdatePreEDThreshold(pDevice, false); } } } diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h index 806cbf7..08091a0 100644 --- a/drivers/staging/vt6656/bssdb.h +++ b/drivers/staging/vt6656/bssdb.h @@ -79,20 +79,20 @@ // typedef struct tagSERPObject { - BOOL bERPExist; + bool bERPExist; BYTE byERP; } ERPObject, *PERPObject; typedef struct tagSRSNCapObject { - BOOL bRSNCapExist; + bool bRSNCapExist; WORD wRSNCap; } SRSNCapObject, *PSRSNCapObject; // BSS info(AP) typedef struct tagKnownBSS { // BSS info - BOOL bActive; + bool bActive; BYTE abyBSSID[WLAN_BSSID_LEN]; unsigned int uChannel; BYTE abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; @@ -110,10 +110,10 @@ typedef struct tagKnownBSS { signed long ldBmAverage[RSSI_STAT_COUNT]; signed long ldBmAverRange; //For any BSSID selection improvment - BOOL bSelected; + bool bSelected; //++ WPA informations - BOOL bWPAValid; + bool bWPAValid; BYTE byGKType; BYTE abyPKType[4]; WORD wPKCount; @@ -124,7 +124,7 @@ typedef struct tagKnownBSS { //-- //++ WPA2 informations - BOOL bWPA2Valid; + bool bWPA2Valid; BYTE byCSSGK; WORD wCSSPKCount; BYTE abyCSSPK[4]; @@ -141,8 +141,8 @@ typedef struct tagKnownBSS { unsigned int uClearCount; // BYTE abyIEs[WLAN_BEACON_FR_MAXLEN]; unsigned int uIELength; - QWORD qwBSSTimestamp; - QWORD qwLocalTSF; // local TSF timer + u64 qwBSSTimestamp; + u64 qwLocalTSF;/* local TSF timer */ CARD_PHY_TYPE eNetworkTypeInUse; @@ -167,14 +167,14 @@ typedef enum tagNODE_STATE { // STA node info typedef struct tagKnownNodeDB { // STA info - BOOL bActive; + bool bActive; BYTE abyMACAddr[WLAN_ADDR_LEN]; BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; WORD wTxDataRate; - BOOL bShortPreamble; - BOOL bERPExist; - BOOL bShortSlotTime; + bool bShortPreamble; + bool bERPExist; + bool bShortSlotTime; unsigned int uInActiveCount; WORD wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. WORD wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. @@ -188,15 +188,15 @@ typedef struct tagKnownNodeDB { WORD wListenInterval; WORD wAID; NODE_STATE eNodeState; - BOOL bPSEnable; - BOOL bRxPSPoll; + bool bPSEnable; + bool bRxPSPoll; BYTE byAuthSequence; unsigned long ulLastRxJiffer; BYTE bySuppRate; DWORD dwFlags; WORD wEnQueueCnt; - BOOL bOnFly; + bool bOnFly; unsigned long long KeyRSC; BYTE byKeyIndex; DWORD dwKeyIndex; @@ -207,7 +207,7 @@ typedef struct tagKnownNodeDB { BYTE abyWepKey[WLAN_WEPMAX_KEYLEN]; // // Auto rate fallback vars - BOOL bIsInFallback; + bool bIsInFallback; unsigned int uAverageRSSI; unsigned int uRateRecoveryTimeout; unsigned int uRatePollTimeout; @@ -225,80 +225,70 @@ typedef struct tagKnownNodeDB { /*--------------------- Export Functions --------------------------*/ -PKnownBSS BSSpSearchBSSList(void *hDeviceContext, - PBYTE pbyDesireBSSID, - PBYTE pbyDesireSSID, - CARD_PHY_TYPE ePhyType); - -PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext, - PBYTE abyBSSID, - PWLAN_IE_SSID pSSID); - -void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID); - -BOOL BSSbInsertToBSSList(void *hDeviceContext, - PBYTE abyBSSIDAddr, - QWORD qwTimestamp, - WORD wBeaconInterval, - WORD wCapInfo, - BYTE byCurrChannel, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - unsigned int uIELength, - PBYTE pbyIEs, - void *pRxPacketContext); - -BOOL BSSbUpdateToBSSList(void *hDeviceContext, - QWORD qwTimestamp, - WORD wBeaconInterval, - WORD wCapInfo, - BYTE byCurrChannel, - BOOL bChannelHit, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - PKnownBSS pBSSList, - unsigned int uIELength, - PBYTE pbyIEs, - void *pRxPacketContext); - -BOOL BSSbIsSTAInNodeDB(void *hDeviceContext, - PBYTE abyDstAddr, - unsigned int *puNodeIndex); - -void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex); - -void BSSvUpdateAPNode(void *hDeviceContext, - PWORD pwCapInfo, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pExtSuppRates); - -void BSSvSecondCallBack(void *hDeviceContext); - -void BSSvUpdateNodeTxCounter(void *hDeviceContext, - PSStatCounter pStatistic, - BYTE byTSR, - BYTE byPktNO); - -void BSSvRemoveOneNode(void *hDeviceContext, - unsigned int uNodeIndex); - -void BSSvAddMulticastNode(void *hDeviceContext); - -void BSSvClearNodeDBTable(void *hDeviceContext, - unsigned int uStartIndex); - -void BSSvClearAnyBSSJoinRecord(void *hDeviceContext); +PKnownBSS BSSpSearchBSSList(struct vnt_private *, u8 *pbyDesireBSSID, + u8 *pbyDesireSSID, CARD_PHY_TYPE ePhyType); + +PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *, u8 *abyBSSID, + PWLAN_IE_SSID pSSID); + +void BSSvClearBSSList(struct vnt_private *, int bKeepCurrBSSID); + +int BSSbInsertToBSSList(struct vnt_private *, + u8 *abyBSSIDAddr, + u64 qwTimestamp, + u16 wBeaconInterval, + u16 wCapInfo, + u8 byCurrChannel, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + u32 uIELength, + u8 *pbyIEs, + void *pRxPacketContext); + +int BSSbUpdateToBSSList(struct vnt_private *, + u64 qwTimestamp, + u16 wBeaconInterval, + u16 wCapInfo, + u8 byCurrChannel, + int bChannelHit, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + PKnownBSS pBSSList, + u32 uIELength, + u8 *pbyIEs, + void *pRxPacketContext); + +int BSSbIsSTAInNodeDB(struct vnt_private *, PBYTE abyDstAddr, + u32 *puNodeIndex); + +void BSSvCreateOneNode(struct vnt_private *, u32 *puNodeIndex); + +void BSSvUpdateAPNode(struct vnt_private *, u16 *pwCapInfo, + PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates); + +void BSSvSecondCallBack(struct vnt_private *); + +void BSSvUpdateNodeTxCounter(struct vnt_private *, PSStatCounter pStatistic, + u8 byTSR, u8 byPktNO); + +void BSSvRemoveOneNode(struct vnt_private *, u32 uNodeIndex); + +void BSSvAddMulticastNode(struct vnt_private *); + +void BSSvClearNodeDBTable(struct vnt_private *, u32 uStartIndex); + +void BSSvClearAnyBSSJoinRecord(struct vnt_private *); #endif /* __BSSDB_H__ */ diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 826520b..22918a1 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -45,6 +45,7 @@ * */ +#include "device.h" #include "tmacro.h" #include "card.h" #include "baseband.h" @@ -91,9 +92,8 @@ const WORD cwRXBCNTSFOff[MAX_RATE] = * Out: * none */ -void CARDbSetMediaChannel(void *pDeviceHandler, unsigned int uConnectionChannel) +void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel) { -PSDevice pDevice = (PSDevice) pDeviceHandler; if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38 if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL)) @@ -149,17 +149,17 @@ PSDevice pDevice = (PSDevice) pDeviceHandler; * Return Value: response Control frame rate * */ -static WORD swGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx) +static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - unsigned int ui = (unsigned int)wRateIdx; - while (ui > RATE_1M) { - if (pDevice->wBasicRate & ((WORD)1 << ui)) { - return (WORD)ui; - } - ui --; - } - return (WORD)RATE_1M; + u16 ui = wRateIdx; + + while (ui > RATE_1M) { + if (pDevice->wBasicRate & (1 << ui)) + return ui; + ui--; + } + + return RATE_1M; } /* @@ -175,28 +175,33 @@ static WORD swGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx) * Return Value: response Control frame rate * */ -static WORD swGetOFDMControlRate(void *pDeviceHandler, WORD wRateIdx) +static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - unsigned int ui = (unsigned int)wRateIdx; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate); - - if (!CARDbIsOFDMinBasicRate(pDevice)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); - if (wRateIdx > RATE_24M) - wRateIdx = RATE_24M; - return wRateIdx; - } - while (ui > RATE_11M) { - if (pDevice->wBasicRate & ((WORD)1 << ui)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate : %d\n", ui); - return (WORD)ui; - } - ui --; - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n"); - return (WORD)RATE_24M; + u16 ui = wRateIdx; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", + pDevice->wBasicRate); + + if (!CARDbIsOFDMinBasicRate(pDevice)) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); + if (wRateIdx > RATE_24M) + wRateIdx = RATE_24M; + return wRateIdx; + } + + while (ui > RATE_11M) { + if (pDevice->wBasicRate & (1 << ui)) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "swGetOFDMControlRate: %d\n", ui); + return ui; + } + ui--; + } + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n"); + + return RATE_24M; } /* @@ -325,16 +330,15 @@ CARDvCalculateOFDMRParameter ( * Return Value: None. * */ -void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType) +void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - BYTE abyServ[4] = {0,0,0,0}; // For CCK - BYTE abySignal[4] = {0,0,0,0}; - WORD awLen[4] = {0,0,0,0}; - BYTE abyTxRate[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM - BYTE abyRsvTime[9] = {0,0,0,0,0,0,0,0,0}; - BYTE abyData[34]; - int i; + u8 abyServ[4] = {0, 0, 0, 0}; /* For CCK */ + u8 abySignal[4] = {0, 0, 0, 0}; + u16 awLen[4] = {0, 0, 0, 0}; + u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ + u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + u8 abyData[34]; + int i; //RSPINF_b_1 BBvCalculateParameter(pDevice, @@ -476,12 +480,10 @@ void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType) * Return Value: None. * */ -void vUpdateIFS(void *pDeviceHandler) +void vUpdateIFS(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - //Set SIFS, DIFS, EIFS, SlotTime, CwMin - BYTE byMaxMin = 0; - BYTE byData[4]; + u8 byMaxMin = 0; + u8 byData[4]; if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a pDevice->uSlot = C_SLOT_SHORT; @@ -499,7 +501,7 @@ void vUpdateIFS(void *pDeviceHandler) } else {// PK_TYPE_11GA & PK_TYPE_11GB BYTE byRate = 0; - BOOL bOFDMRate = FALSE; + bool bOFDMRate = false; unsigned int ii = 0; PWLAN_IE_SUPP_RATES pItemRates = NULL; @@ -511,25 +513,26 @@ void vUpdateIFS(void *pDeviceHandler) } pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrSuppRates; + pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates; for (ii = 0; ii < pItemRates->len; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F); if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = TRUE; + bOFDMRate = true; break; } } - if (bOFDMRate == FALSE) { - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrExtSuppRates; + if (bOFDMRate == false) { + pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt + .abyCurrExtSuppRates; for (ii = 0; ii < pItemRates->len; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F); if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = TRUE; + bOFDMRate = true; break; } } } - if (bOFDMRate == TRUE) { + if (bOFDMRate == true) { pDevice->uCwMin = C_CWMIN_A; byMaxMin = 4; } else { @@ -561,11 +564,10 @@ void vUpdateIFS(void *pDeviceHandler) &byMaxMin); } -void CARDvUpdateBasicTopRate(void *pDeviceHandler) +void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M; -BYTE ii; + u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M; + u8 ii; //Determines the highest basic rate. for (ii = RATE_54M; ii >= RATE_6M; ii --) { @@ -597,13 +599,12 @@ BYTE ii; * Out: * none * - * Return Value: TRUE if succeeded; FALSE if failed. + * Return Value: true if succeeded; false if failed. * */ -void CARDbAddBasicRate(void *pDeviceHandler, WORD wRateIdx) +void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -WORD wRate = (WORD)(1<<wRateIdx); + u16 wRate = (1 << wRateIdx); pDevice->wBasicRate |= wRate; @@ -611,21 +612,19 @@ WORD wRate = (WORD)(1<<wRateIdx); CARDvUpdateBasicTopRate(pDevice); } -BOOL CARDbIsOFDMinBasicRate(void *pDeviceHandler) +int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -int ii; + int ii; for (ii = RATE_54M; ii >= RATE_6M; ii --) { if ((pDevice->wBasicRate) & ((WORD)(1<<ii))) - return TRUE; + return true; } - return FALSE; + return false; } -BYTE CARDbyGetPktType(void *pDeviceHandler) +u8 CARDbyGetPktType(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) pDeviceHandler; if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) { return (BYTE)pDevice->byBBType; @@ -654,28 +653,18 @@ BYTE CARDbyGetPktType(void *pDeviceHandler) * Return Value: TSF Offset value * */ -QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2) +u64 CARDqGetTSFOffset(BYTE byRxRate, u64 qwTSF1, u64 qwTSF2) { - QWORD qwTSFOffset; - WORD wRxBcnTSFOffst = 0; + u64 qwTSFOffset = 0; + WORD wRxBcnTSFOffst = 0; - HIDWORD(qwTSFOffset) = 0; - LODWORD(qwTSFOffset) = 0; + wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE]; - wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE]; - (qwTSF2).u.dwLowDword += (DWORD)(wRxBcnTSFOffst); - if ((qwTSF2).u.dwLowDword < (DWORD)(wRxBcnTSFOffst)) { - (qwTSF2).u.dwHighDword++; - } - LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2); - if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) { - // if borrow needed - HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ; - } - else { - HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2); - }; - return (qwTSFOffset); + qwTSF2 += (u64)wRxBcnTSFOffst; + + qwTSFOffset = qwTSF1 - qwTSF2; + + return qwTSFOffset; } @@ -695,33 +684,25 @@ QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2) * Return Value: none * */ -void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate, - QWORD qwBSSTimestamp, QWORD qwLocalTSF) +void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, + u64 qwBSSTimestamp, u64 qwLocalTSF) { + u64 qwTSFOffset = 0; + u8 pbyData[8]; - PSDevice pDevice = (PSDevice) pDeviceHandler; - QWORD qwTSFOffset; - DWORD dwTSFOffset1,dwTSFOffset2; - BYTE pbyData[8]; - - HIDWORD(qwTSFOffset) = 0; - LODWORD(qwTSFOffset) = 0; qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); // adjust TSF // HW's TSF add TSF Offset reg - dwTSFOffset1 = LODWORD(qwTSFOffset); - dwTSFOffset2 = HIDWORD(qwTSFOffset); - - pbyData[0] = (BYTE)dwTSFOffset1; - pbyData[1] = (BYTE)(dwTSFOffset1>>8); - pbyData[2] = (BYTE)(dwTSFOffset1>>16); - pbyData[3] = (BYTE)(dwTSFOffset1>>24); - pbyData[4] = (BYTE)dwTSFOffset2; - pbyData[5] = (BYTE)(dwTSFOffset2>>8); - pbyData[6] = (BYTE)(dwTSFOffset2>>16); - pbyData[7] = (BYTE)(dwTSFOffset2>>24); + pbyData[0] = (u8)qwTSFOffset; + pbyData[1] = (u8)(qwTSFOffset >> 8); + pbyData[2] = (u8)(qwTSFOffset >> 16); + pbyData[3] = (u8)(qwTSFOffset >> 24); + pbyData[4] = (u8)(qwTSFOffset >> 32); + pbyData[5] = (u8)(qwTSFOffset >> 40); + pbyData[6] = (u8)(qwTSFOffset >> 48); + pbyData[7] = (u8)(qwTSFOffset >> 56); CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SET_TSFTBTT, @@ -742,17 +723,15 @@ void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate, * Out: * qwCurrTSF - Current TSF counter * - * Return Value: TRUE if success; otherwise FALSE + * Return Value: true if success; otherwise false * */ -BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF) +bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - LODWORD(*pqwCurrTSF) = LODWORD(pDevice->qwCurrTSF); - HIDWORD(*pqwCurrTSF) = HIDWORD(pDevice->qwCurrTSF); + *pqwCurrTSF = pDevice->qwCurrTSF; - return(TRUE); + return true; } @@ -764,19 +743,17 @@ BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF) * In: * pDevice - The adapter to be read * - * Return Value: TRUE if success; otherwise FALSE + * Return Value: true if success; otherwise false * */ -BOOL CARDbClearCurrentTSF(void *pDeviceHandler) +bool CARDbClearCurrentTSF(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTRST); + MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); - LODWORD(pDevice->qwCurrTSF) = 0; - HIDWORD(pDevice->qwCurrTSF) = 0; + pDevice->qwCurrTSF = 0; - return(TRUE); + return true; } /* @@ -793,7 +770,7 @@ BOOL CARDbClearCurrentTSF(void *pDeviceHandler) * Return Value: TSF value of next Beacon * */ -QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval) +u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval) { unsigned int uLowNextTBTT; @@ -802,18 +779,19 @@ QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval) uBeaconInterval = wBeaconInterval * 1024; // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval - uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10; - uLowRemain = (uLowNextTBTT) % uBeaconInterval; - uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF)) - % uBeaconInterval; - uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval; - uLowRemain = uBeaconInterval - uLowRemain; + uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10; + uLowRemain = (uLowNextTBTT) % uBeaconInterval; + uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32)) + % uBeaconInterval; + uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval; + uLowRemain = uBeaconInterval - uLowRemain; // check if carry when add one beacon interval - if ((~uLowNextTBTT) < uLowRemain) - HIDWORD(qwTSF) ++ ; + if ((~uLowNextTBTT) < uLowRemain) + qwTSF = ((qwTSF >> 32) + 1) << 32; - LODWORD(qwTSF) = uLowNextTBTT + uLowRemain; + qwTSF = (qwTSF & 0xffffffff00000000UL) | + (u64)(uLowNextTBTT + uLowRemain); return (qwTSF); } @@ -833,32 +811,24 @@ QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval) * Return Value: none * */ -void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval) +void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, WORD wBeaconInterval) { + u64 qwNextTBTT = 0; + u8 pbyData[8]; - PSDevice pDevice = (PSDevice) pDeviceHandler; - QWORD qwNextTBTT; - DWORD dwLoTBTT,dwHiTBTT; - BYTE pbyData[8]; - - HIDWORD(qwNextTBTT) = 0; - LODWORD(qwNextTBTT) = 0; - CARDbClearCurrentTSF(pDevice); + CARDbClearCurrentTSF(pDevice); //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter - qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); + qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); // Set NextTBTT - dwLoTBTT = LODWORD(qwNextTBTT); - dwHiTBTT = HIDWORD(qwNextTBTT); - - pbyData[0] = (BYTE)dwLoTBTT; - pbyData[1] = (BYTE)(dwLoTBTT>>8); - pbyData[2] = (BYTE)(dwLoTBTT>>16); - pbyData[3] = (BYTE)(dwLoTBTT>>24); - pbyData[4] = (BYTE)dwHiTBTT; - pbyData[5] = (BYTE)(dwHiTBTT>>8); - pbyData[6] = (BYTE)(dwHiTBTT>>16); - pbyData[7] = (BYTE)(dwHiTBTT>>24); + pbyData[0] = (u8)qwNextTBTT; + pbyData[1] = (u8)(qwNextTBTT >> 8); + pbyData[2] = (u8)(qwNextTBTT >> 16); + pbyData[3] = (u8)(qwNextTBTT >> 24); + pbyData[4] = (u8)(qwNextTBTT >> 32); + pbyData[5] = (u8)(qwNextTBTT >> 40); + pbyData[6] = (u8)(qwNextTBTT >> 48); + pbyData[7] = (u8)(qwNextTBTT >> 56); CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SET_TSFTBTT, @@ -887,27 +857,23 @@ void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval) * Return Value: none * */ -void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF, - WORD wBeaconInterval) +void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, + u16 wBeaconInterval) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - DWORD dwLoTBTT,dwHiTBTT; - BYTE pbyData[8]; + u8 pbyData[8]; qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); // Set NextTBTT - dwLoTBTT = LODWORD(qwTSF); - dwHiTBTT = HIDWORD(qwTSF); - - pbyData[0] = (BYTE)dwLoTBTT; - pbyData[1] = (BYTE)(dwLoTBTT>>8); - pbyData[2] = (BYTE)(dwLoTBTT>>16); - pbyData[3] = (BYTE)(dwLoTBTT>>24); - pbyData[4] = (BYTE)dwHiTBTT; - pbyData[5] = (BYTE)(dwHiTBTT>>8); - pbyData[6] = (BYTE)(dwHiTBTT>>16); - pbyData[7] = (BYTE)(dwHiTBTT>>24); + + pbyData[0] = (u8)qwTSF; + pbyData[1] = (u8)(qwTSF >> 8); + pbyData[2] = (u8)(qwTSF >> 16); + pbyData[3] = (u8)(qwTSF >> 24); + pbyData[4] = (u8)(qwTSF >> 32); + pbyData[5] = (u8)(qwTSF >> 40); + pbyData[6] = (u8)(qwTSF >> 48); + pbyData[7] = (u8)(qwTSF >> 56); CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SET_TSFTBTT, @@ -918,7 +884,8 @@ void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF, ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF), (int)LODWORD(qwTSF)); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF); return; } @@ -932,18 +899,17 @@ void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF, * Out: * none * - * Return Value: TRUE if success; otherwise FALSE + * Return Value: true if success; otherwise false * */ -BOOL CARDbRadioPowerOff(void *pDeviceHandler) +int CARDbRadioPowerOff(struct vnt_private *pDevice) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -BOOL bResult = TRUE; + int bResult = true; - //if (pDevice->bRadioOff == TRUE) - // return TRUE; + //if (pDevice->bRadioOff == true) + // return true; - pDevice->bRadioOff = TRUE; + pDevice->bRadioOff = true; switch (pDevice->byRFType) { case RF_AL2230: @@ -973,23 +939,21 @@ BOOL bResult = TRUE; * Out: * none * - * Return Value: TRUE if success; otherwise FALSE + * Return Value: true if success; otherwise false * */ -BOOL CARDbRadioPowerOn(void *pDeviceHandler) +int CARDbRadioPowerOn(struct vnt_private *pDevice) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -BOOL bResult = TRUE; - + int bResult = true; - if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) { - return FALSE; + if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { + return false; } - //if (pDevice->bRadioOff == FALSE) - // return TRUE; + //if (pDevice->bRadioOff == false) + // return true; - pDevice->bRadioOff = FALSE; + pDevice->bRadioOff = false; BBvExitDeepSleep(pDevice); @@ -1009,9 +973,8 @@ BOOL bResult = TRUE; return bResult; } -void CARDvSetBSSMode(void *pDeviceHandler) +void CARDvSetBSSMode(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) pDeviceHandler; // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) ) @@ -1068,30 +1031,23 @@ void CARDvSetBSSMode(void *pDeviceHandler) * Return Value: none. * -*/ -BOOL -CARDbChannelSwitch ( - void *pDeviceHandler, - BYTE byMode, - BYTE byNewChannel, - BYTE byCount - ) +int CARDbChannelSwitch(struct vnt_private *pDevice, u8 byMode, + u8 byNewChannel, u8 byCount) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - BOOL bResult = TRUE; + int bResult = true; - if (byCount == 0) { - pDevice->sMgmtObj.uCurrChannel = byNewChannel; - CARDbSetMediaChannel(pDevice, byNewChannel); - - return bResult; - } + if (byCount == 0) { + pDevice->vnt_mgmt.uCurrChannel = byNewChannel; + CARDbSetMediaChannel(pDevice, byNewChannel); + return bResult; + } pDevice->byChannelSwitchCount = byCount; pDevice->byNewChannel = byNewChannel; - pDevice->bChannelSwitch = TRUE; + pDevice->bChannelSwitch = true; if (byMode == 1) { //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL); - pDevice->bStopDataPkt = TRUE; + pDevice->bStopDataPkt = true; } return bResult; } diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index 55962b1..5123bc7 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -28,7 +28,7 @@ #ifndef __CARD_H__ #define __CARD_H__ - +#include "device.h" #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ @@ -58,31 +58,28 @@ typedef enum _CARD_OP_MODE { /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ +struct vnt_private; -void CARDbSetMediaChannel(void *pDeviceHandler, - unsigned int uConnectionChannel); -void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType); -void vUpdateIFS(void *pDeviceHandler); -void CARDvUpdateBasicTopRate(void *pDeviceHandler); -void CARDbAddBasicRate(void *pDeviceHandler, WORD wRateIdx); -BOOL CARDbIsOFDMinBasicRate(void *pDeviceHandler); -void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate, - QWORD qwBSSTimestamp, QWORD qwLocalTSF); -BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF); -BOOL CARDbClearCurrentTSF(void *pDeviceHandler); -void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval); -void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF, +void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); +void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType); +void vUpdateIFS(struct vnt_private *pDevice); +void CARDvUpdateBasicTopRate(struct vnt_private *pDevice); +void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); +int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice); +void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, + u64 qwBSSTimestamp, u64 qwLocalTSF); +bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF); +bool CARDbClearCurrentTSF(struct vnt_private *pDevice); +void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, WORD wBeaconInterval); +void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, WORD wBeaconInterval); -QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval); -QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2); -BOOL CARDbRadioPowerOff(void *pDeviceHandler); -BOOL CARDbRadioPowerOn(void *pDeviceHandler); -BYTE CARDbyGetPktType(void *pDeviceHandler); -void CARDvSetBSSMode(void *pDeviceHandler); - -BOOL CARDbChannelSwitch(void *pDeviceHandler, - BYTE byMode, - BYTE byNewChannel, - BYTE byCount); +u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval); +u64 CARDqGetTSFOffset(BYTE byRxRate, u64 qwTSF1, u64 qwTSF2); +int CARDbRadioPowerOff(struct vnt_private *pDevice); +int CARDbRadioPowerOn(struct vnt_private *pDevice); +u8 CARDbyGetPktType(struct vnt_private *pDevice); +void CARDvSetBSSMode(struct vnt_private *pDevice); +int CARDbChannelSwitch(struct vnt_private *pDevice, u8 byMode, + u8 byNewChannel, u8 byCount); #endif /* __CARD_H__ */ diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index 6502176..4181e3e 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -50,63 +50,63 @@ static int msglevel = MSG_LEVEL_INFO; static SChannelTblElement sChannelTbl[CB_MAX_CHANNEL+1] = { - {0, 0, FALSE}, - {1, 2412, TRUE}, - {2, 2417, TRUE}, - {3, 2422, TRUE}, - {4, 2427, TRUE}, - {5, 2432, TRUE}, - {6, 2437, TRUE}, - {7, 2442, TRUE}, - {8, 2447, TRUE}, - {9, 2452, TRUE}, - {10, 2457, TRUE}, - {11, 2462, TRUE}, - {12, 2467, TRUE}, - {13, 2472, TRUE}, - {14, 2484, TRUE}, - {183, 4915, TRUE}, //15 - {184, 4920, TRUE}, //16 - {185, 4925, TRUE}, //17 - {187, 4935, TRUE}, //18 - {188, 4940, TRUE}, //19 - {189, 4945, TRUE}, //20 - {192, 4960, TRUE}, //21 - {196, 4980, TRUE}, //22 - {7, 5035, TRUE}, //23 - {8, 5040, TRUE}, //24 - {9, 5045, TRUE}, //25 - {11, 5055, TRUE}, //26 - {12, 5060, TRUE}, //27 - {16, 5080, TRUE}, //28 - {34, 5170, TRUE}, //29 - {36, 5180, TRUE}, //30 - {38, 5190, TRUE}, //31 - {40, 5200, TRUE}, //32 - {42, 5210, TRUE}, //33 - {44, 5220, TRUE}, //34 - {46, 5230, TRUE}, //35 - {48, 5240, TRUE}, //36 - {52, 5260, TRUE}, //37 - {56, 5280, TRUE}, //38 - {60, 5300, TRUE}, //39 - {64, 5320, TRUE}, //40 - {100, 5500, TRUE}, //41 - {104, 5520, TRUE}, //42 - {108, 5540, TRUE}, //43 - {112, 5560, TRUE}, //44 - {116, 5580, TRUE}, //45 - {120, 5600, TRUE}, //46 - {124, 5620, TRUE}, //47 - {128, 5640, TRUE}, //48 - {132, 5660, TRUE}, //49 - {136, 5680, TRUE}, //50 - {140, 5700, TRUE}, //51 - {149, 5745, TRUE}, //52 - {153, 5765, TRUE}, //53 - {157, 5785, TRUE}, //54 - {161, 5805, TRUE}, //55 - {165, 5825, TRUE} //56 + {0, 0, false}, + {1, 2412, true}, + {2, 2417, true}, + {3, 2422, true}, + {4, 2427, true}, + {5, 2432, true}, + {6, 2437, true}, + {7, 2442, true}, + {8, 2447, true}, + {9, 2452, true}, + {10, 2457, true}, + {11, 2462, true}, + {12, 2467, true}, + {13, 2472, true}, + {14, 2484, true}, + {183, 4915, true}, //15 + {184, 4920, true}, //16 + {185, 4925, true}, //17 + {187, 4935, true}, //18 + {188, 4940, true}, //19 + {189, 4945, true}, //20 + {192, 4960, true}, //21 + {196, 4980, true}, //22 + {7, 5035, true}, //23 + {8, 5040, true}, //24 + {9, 5045, true}, //25 + {11, 5055, true}, //26 + {12, 5060, true}, //27 + {16, 5080, true}, //28 + {34, 5170, true}, //29 + {36, 5180, true}, //30 + {38, 5190, true}, //31 + {40, 5200, true}, //32 + {42, 5210, true}, //33 + {44, 5220, true}, //34 + {46, 5230, true}, //35 + {48, 5240, true}, //36 + {52, 5260, true}, //37 + {56, 5280, true}, //38 + {60, 5300, true}, //39 + {64, 5320, true}, //40 + {100, 5500, true}, //41 + {104, 5520, true}, //42 + {108, 5540, true}, //43 + {112, 5560, true}, //44 + {116, 5580, true}, //45 + {120, 5600, true}, //46 + {124, 5620, true}, //47 + {128, 5640, true}, //48 + {132, 5660, true}, //49 + {136, 5680, true}, //50 + {140, 5700, true}, //51 + {149, 5745, true}, //52 + {153, 5765, true}, //53 + {157, 5785, true}, //54 + {161, 5805, true}, //55 + {165, 5825, true} //56 }; @@ -380,26 +380,26 @@ static struct * 15 = 4.9G channel 183 * 16 = 4.9G channel 184 * ..... - * Output: TRUE if the specified 5GHz band is allowed to be used. + * Output: true if the specified 5GHz band is allowed to be used. False otherwise. // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22) // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64, // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56) ************************************************************************/ -BOOL +bool ChannelValid(unsigned int CountryCode, unsigned int ChannelIndex) { - BOOL bValid; + bool bValid; - bValid = FALSE; + bValid = false; /* * If Channel Index is invalid, return invalid */ if ((ChannelIndex > CB_MAX_CHANNEL) || (ChannelIndex == 0)) { - bValid = FALSE; + bValid = false; goto exit; } @@ -422,48 +422,47 @@ exit: * 0x0000000000000003 means channel 1,2 are supported * 0x000000000000000F means channel 1,2,..15 are supported ************************************************************************/ -BOOL +bool CHvChannelGetList ( unsigned int uCountryCodeIdx, PBYTE pbyChannelTable ) { if (uCountryCodeIdx >= CCODE_MAX) { - return (FALSE); + return (false); } memcpy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL); - return (TRUE); + return (true); } -void CHvInitChannelTable(void *pDeviceHandler) +void CHvInitChannelTable(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - BOOL bMultiBand = FALSE; - unsigned int ii; + int bMultiBand = false; + int ii; for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) - sChannelTbl[ii].bValid = FALSE; + sChannelTbl[ii].bValid = false; switch (pDevice->byRFType) { case RF_AL2230: case RF_AL2230S: case RF_VT3226: case RF_VT3226D0: - bMultiBand = FALSE; + bMultiBand = false; break; case RF_AIROHA7230: case RF_VT3342A0: default : - bMultiBand = TRUE; + bMultiBand = true; break; } if ((pDevice->dwDiagRefCount != 0) || - (pDevice->b11hEable == TRUE)) { - if (bMultiBand == TRUE) { + (pDevice->b11hEable == true)) { + if (bMultiBand == true) { for (ii = 0; ii < CB_MAX_CHANNEL; ii++) { - sChannelTbl[ii+1].bValid = TRUE; + sChannelTbl[ii+1].bValid = true; //pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1]; //pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1]; } @@ -473,16 +472,16 @@ void CHvInitChannelTable(void *pDeviceHandler) } } else { for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { - sChannelTbl[ii+1].bValid = TRUE; + sChannelTbl[ii+1].bValid = true; //pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; //pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; } } } else if (pDevice->byZoneType <= CCODE_MAX) { - if (bMultiBand == TRUE) { + if (bMultiBand == true) { for (ii = 0; ii < CB_MAX_CHANNEL; ii++) { if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii+1].bValid = TRUE; + sChannelTbl[ii+1].bValid = true; //pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; //pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; } @@ -490,7 +489,7 @@ void CHvInitChannelTable(void *pDeviceHandler) } else { for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii+1].bValid = TRUE; + sChannelTbl[ii+1].bValid = true; //pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; //pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; } diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h index e7b3c12..9914dba 100644 --- a/drivers/staging/vt6656/channel.h +++ b/drivers/staging/vt6656/channel.h @@ -30,6 +30,7 @@ #ifndef _CHANNEL_H_ #define _CHANNEL_H_ +#include "device.h" #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ @@ -39,17 +40,17 @@ typedef struct tagSChannelTblElement { BYTE byChannelNumber; unsigned int uFrequency; - BOOL bValid; + bool bValid; } SChannelTblElement, *PSChannelTblElement; /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -BOOL ChannelValid(unsigned int CountryCode, unsigned int ChannelNum); -void CHvInitChannelTable(void *pDeviceHandler); +bool ChannelValid(unsigned int CountryCode, unsigned int ChannelNum); +void CHvInitChannelTable(struct vnt_private *pDevice); BYTE CHbyGetChannelMapping(BYTE byChannelNumber); -BOOL CHvChannelGetList(unsigned int uCountryCodeIdx, PBYTE pbyChannelTable); +bool CHvChannelGetList(unsigned int uCountryCodeIdx, PBYTE pbyChannelTable); #endif /* _CHANNEL_H_ */ diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 5d8c571..743ef5f 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -56,43 +56,34 @@ /*--------------------- Export Functions --------------------------*/ -void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, - BYTE byData) +void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, + u8 data) { - BYTE byData1; - byData1 = byData; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - byRegOfs, - byRegType, - 1, - &byData1); + + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg, + sizeof(u8), &data); + + return; } -void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, - PBYTE pbyData) +void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, + u8 *data) { - int ntStatus; - BYTE byData1; - ntStatus = CONTROLnsRequestIn(pDevice, - MESSAGE_TYPE_READ, - byRegOfs, - byRegType, - 1, - &byData1); - *pbyData = byData1; + CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + reg_off, reg, sizeof(u8), data); + return; } -void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, - BYTE byMask, BYTE byData) +void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, + u8 reg_mask, u8 data) { - BYTE pbyData[2]; - pbyData[0] = byData; - pbyData[1] = byMask; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - byRegType, - 2, - pbyData); + u8 reg_data[2]; + + reg_data[0] = data; + reg_data[1] = reg_mask; + + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off, + reg_type, ARRAY_SIZE(reg_data), reg_data); + + return; } diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index bbe610f..76ce024 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -51,28 +51,14 @@ /*--------------------- Export Functions --------------------------*/ -void ControlvWriteByte( - PSDevice pDevice, - BYTE byRegType, - BYTE byRegOfs, - BYTE byData - ); +void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, + u8 data); +void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, + u8 *data); -void ControlvReadByte( - PSDevice pDevice, - BYTE byRegType, - BYTE byRegOfs, - PBYTE pbyData - ); +void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, + u8 reg_mask, u8 data); -void ControlvMaskByte( - PSDevice pDevice, - BYTE byRegType, - BYTE byRegOfs, - BYTE byMask, - BYTE byData - ); - #endif /* __CONTROL_H__ */ diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c index 5c2719f..77464e8 100644 --- a/drivers/staging/vt6656/datarate.c +++ b/drivers/staging/vt6656/datarate.c @@ -54,7 +54,8 @@ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; + +/* static int msglevel = MSG_LEVEL_DEBUG; */ static int msglevel =MSG_LEVEL_INFO; const BYTE acbyIERate[MAX_RATE] = {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; @@ -71,7 +72,7 @@ void s_vResetCounter(PKnownNodeDB psNodeDBTable) { BYTE ii; - // clear statistic counter for auto_rate + /* clear statistics counter for auto_rate */ for (ii = 0; ii <= MAX_RATE; ii++) { psNodeDBTable->uTxOk[ii] = 0; psNodeDBTable->uTxFail[ii] = 0; @@ -105,8 +106,8 @@ DATARATEbyGetRateIdx ( { BYTE ii; - //Erase basicRate flag. - byRate = byRate & 0x7F;//0111 1111 + /* erase BasicRate flag */ + byRate = byRate & 0x7F; for (ii = 0; ii < MAX_RATE; ii ++) { if (acbyIERate[ii] == byRate) @@ -159,8 +160,8 @@ RATEwGetRateIdx( { WORD ii; - //Erase basicRate flag. - byRate = byRate & 0x7F;//0111 1111 + /* erase BasicRate flag */ + byRate = byRate & 0x7F; for (ii = 0; ii < MAX_RATE; ii ++) { if (acbyIERate[ii] == byRate) @@ -188,28 +189,19 @@ RATEwGetRateIdx( * Return Value: none * -*/ -void RATEvParseMaxRate( - void *pDeviceHandler, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pItemExtRates, - BOOL bUpdateBasicRate, - PWORD pwMaxBasicRate, - PWORD pwMaxSuppRate, - PWORD pwSuppRate, - PBYTE pbyTopCCKRate, - PBYTE pbyTopOFDMRate - ) -{ -PSDevice pDevice = (PSDevice) pDeviceHandler; -unsigned int ii; -BYTE byHighSuppRate = 0; -BYTE byRate = 0; -WORD wOldBasicRate = pDevice->wBasicRate; -unsigned int uRateLen; +void RATEvParseMaxRate(struct vnt_private *pDevice, + PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, + int bUpdateBasicRate, u16 *pwMaxBasicRate, u16 *pwMaxSuppRate, + u16 *pwSuppRate, u8 *pbyTopCCKRate, u8 *pbyTopOFDMRate) +{ + int ii; + u8 byHighSuppRate = 0, byRate = 0; + u16 wOldBasicRate = pDevice->wBasicRate; + u32 uRateLen; - if (pItemRates == NULL) - return; + if (pItemRates == NULL) + return; *pwSuppRate = 0; uRateLen = pItemRates->len; @@ -226,8 +218,11 @@ unsigned int uRateLen; for (ii = 0; ii < uRateLen; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]); if (WLAN_MGMT_IS_BASICRATE(byRate) && - (bUpdateBasicRate == TRUE)) { - // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate + (bUpdateBasicRate == true)) { + /* + * add to basic rate set, update pDevice->byTopCCKBasicRate and + * pDevice->byTopOFDMBasicRate + */ CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } @@ -248,9 +243,12 @@ unsigned int uRateLen; for (ii = 0; ii < uExtRateLen ; ii++) { byRate = (BYTE)(pItemExtRates->abyRates[ii]); - // select highest basic rate + /* select highest basic rate */ if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { - // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate + /* + * add to basic rate set, update pDevice->byTopCCKBasicRate and + * pDevice->byTopOFDMBasicRate + */ CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } @@ -260,9 +258,11 @@ unsigned int uRateLen; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); - //DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", RATEwGetRateIdx(byRate), byRate)); + + /* DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", + RATEwGetRateIdx(byRate), byRate)); */ } - } //if(pItemExtRates != NULL) + } if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) { @@ -301,27 +301,24 @@ unsigned int uRateLen; #define AUTORATE_TXCNT_THRESHOLD 20 #define AUTORATE_INC_THRESHOLD 30 -void -RATEvTxRateFallBack( - void *pDeviceHandler, - PKnownNodeDB psNodeDBTable - ) +void RATEvTxRateFallBack(struct vnt_private *pDevice, + PKnownNodeDB psNodeDBTable) { -PSDevice pDevice = (PSDevice) pDeviceHandler; -PSMgmtObject pMgmt = &(pDevice->sMgmtObj); -WORD wIdxDownRate = 0; -unsigned int ii; -BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}; -DWORD dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540}; -DWORD dwThroughput = 0; -WORD wIdxUpRate = 0; -DWORD dwTxDiff = 0; - - if (pMgmt->eScanState != WMAC_NO_SCANNING) { - // Don't do Fallback when scanning Channel - return; - } - psNodeDBTable->uTimeCount ++; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u16 wIdxDownRate = 0; + int ii; + int bAutoRate[MAX_RATE] = {true, true, true, true, false, false, true, + true, true, true, true, true}; + u32 dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, + 240, 360, 480, 540}; + u32 dwThroughput = 0; + u16 wIdxUpRate = 0; + u32 dwTxDiff = 0; + + if (pMgmt->eScanState != WMAC_NO_SCANNING) + return; /* Don't do Fallback when scanning Channel */ + + psNodeDBTable->uTimeCount++; if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE]) dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE]; @@ -338,11 +335,11 @@ DWORD dwTxDiff = 0; for (ii = 0; ii < MAX_RATE; ii++) { if (psNodeDBTable->wSuppRate & (0x0001<<ii)) { - if (bAutoRate[ii] == TRUE) { + if (bAutoRate[ii] == true) { wIdxUpRate = (WORD) ii; } } else { - bAutoRate[ii] = FALSE; + bAutoRate[ii] = false; } } @@ -364,7 +361,7 @@ DWORD dwTxDiff = 0; for (ii = psNodeDBTable->wTxDataRate; ii > 0;) { ii--; if ( (dwThroughputTbl[ii] > dwThroughput) && - (bAutoRate[ii]==TRUE) ) { + (bAutoRate[ii]==true) ) { dwThroughput = dwThroughputTbl[ii]; wIdxDownRate = (WORD) ii; } @@ -375,7 +372,7 @@ DWORD dwTxDiff = 0; (psNodeDBTable->uTxFail[MAX_RATE] * 4) ) { psNodeDBTable->wTxDataRate = wIdxUpRate; } - }else { // adhoc, if uTxOk(total) =0 & uTxFail(total) = 0 + } else { /* adhoc, if uTxOk(total) == 0 & uTxFail(total) == 0 */ if (psNodeDBTable->uTxFail[MAX_RATE] == 0) psNodeDBTable->wTxDataRate = wIdxUpRate; } diff --git a/drivers/staging/vt6656/datarate.h b/drivers/staging/vt6656/datarate.h index c6f5163..8dc55bd 100644 --- a/drivers/staging/vt6656/datarate.h +++ b/drivers/staging/vt6656/datarate.h @@ -29,18 +29,18 @@ #ifndef __DATARATE_H__ #define __DATARATE_H__ -/*--------------------- Export Definitions -------------------------*/ -#define FALLBACK_PKT_COLLECT_TR_H 50 // pkts -#define FALLBACK_PKT_COLLECT_TR_L 10 // pkts -#define FALLBACK_POLL_SECOND 5 // 5 sec -#define FALLBACK_RECOVER_SECOND 30 // 30 sec -#define FALLBACK_THRESHOLD 15 // percent -#define UPGRADE_THRESHOLD 5 // percent -#define UPGRADE_CNT_THRD 3 // times -#define RETRY_TIMES_THRD_H 2 // times -#define RETRY_TIMES_THRD_L 1 // times +/*--------------------- Export Definitions -------------------------*/ +#define FALLBACK_PKT_COLLECT_TR_H 50 /* pkts */ +#define FALLBACK_PKT_COLLECT_TR_L 10 /* pkts */ +#define FALLBACK_POLL_SECOND 5 /* 5 sec */ +#define FALLBACK_RECOVER_SECOND 30 /* 30 sec */ +#define FALLBACK_THRESHOLD 15 /* percent */ +#define UPGRADE_THRESHOLD 5 /* percent */ +#define UPGRADE_CNT_THRD 3 /* times */ +#define RETRY_TIMES_THRD_H 2 /* times */ +#define RETRY_TIMES_THRD_L 1 /* times */ #define RATE_1M 0 #define RATE_2M 1 @@ -69,24 +69,13 @@ -void -RATEvParseMaxRate( - void *pDeviceHandler, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pItemExtRates, - BOOL bUpdateBasicRate, - PWORD pwMaxBasicRate, - PWORD pwMaxSuppRate, - PWORD pwSuppRate, - PBYTE pbyTopCCKRate, - PBYTE pbyTopOFDMRate - ); +void RATEvParseMaxRate(struct vnt_private *, PWLAN_IE_SUPP_RATES pItemRates, + PWLAN_IE_SUPP_RATES pItemExtRates, int bUpdateBasicRate, + u16 *pwMaxBasicRate, u16 *pwMaxSuppRate, u16 *pwSuppRate, + u8 *pbyTopCCKRate, u8 *pbyTopOFDMRate); -void -RATEvTxRateFallBack( - void *pDeviceHandler, - PKnownNodeDB psNodeDBTable - ); +void RATEvTxRateFallBack(struct vnt_private *pDevice, + PKnownNodeDB psNodeDBTable); BYTE RATEuSetIE( diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 5007e98..0c0b614 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -36,92 +36,95 @@ #include "ttype.h" #include "tether.h" -// max transmit or receive buffer size -#define CB_MAX_BUF_SIZE 2900U // max buffer size - // NOTE: must be multiple of 4 +/* max transmit or receive buffer size */ +#define CB_MAX_BUF_SIZE 2900U /* NOTE: must be multiple of 4 */ -#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size -#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD +/* max TX buffer size */ +#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE +/* max RX buffer size when not use Multi-RD */ +#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE -#define CB_BEACON_BUF_SIZE 512U // default beacon buffer size +#define CB_BEACON_BUF_SIZE 512U /* default beacon buffer size */ #define MAX_TOTAL_SIZE_WITH_ALL_HEADERS CB_MAX_BUF_SIZE #define MAX_INTERRUPT_SIZE 32 -#define RX_BLOCKS 64 // form 0x60 to 0xA0 -#define TX_BLOCKS 32 // from 0xA0 to 0xC0 - -#define CB_MAX_RX_DESC 128 // max # of descriptor -#define CB_MIN_RX_DESC 16 // min # of rx descriptor -#define CB_MAX_TX_DESC 128 // max # of descriptor -#define CB_MIN_TX_DESC 16 // min # of tx descriptor - -#define CB_RD_NUM 64 // default # of RD -#define CB_TD_NUM 64 // default # of TD - -// -// Bits in the RSR register -// -#define RSR_ADDRBROAD 0x80 // 1000 0000 -#define RSR_ADDRMULTI 0x40 // 0100 0000 -#define RSR_ADDRUNI 0x00 // 0000 0000 -#define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type -#define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte) -#define RSR_BSSIDOK 0x08 // 0000 1000 -#define RSR_CRCOK 0x04 // 0000 0100 -#define RSR_BCNSSIDOK 0x02 // 0000 0010 -#define RSR_ADDROK 0x01 // 0000 0001 - -// -// Bits in the new RSR register -// -#define NEWRSR_DECRYPTOK 0x10 // 0001 0000 -#define NEWRSR_CFPIND 0x08 // 0000 1000 -#define NEWRSR_HWUTSF 0x04 // 0000 0100 -#define NEWRSR_BCNHITAID 0x02 // 0000 0010 -#define NEWRSR_BCNHITAID0 0x01 // 0000 0001 - -// -// Bits in the TSR register -// -#define TSR_RETRYTMO 0x08 // 0000 1000 -#define TSR_TMO 0x04 // 0000 0100 -#define TSR_ACKDATA 0x02 // 0000 0010 -#define TSR_VALID 0x01 // 0000 0001 +#define RX_BLOCKS 64 /* from 0x60 to 0xA0 */ +#define TX_BLOCKS 32 /* from 0xA0 to 0xC0 */ + +#define CB_MAX_RX_DESC 128 /* max # of descriptors */ +#define CB_MIN_RX_DESC 16 /* min # of RX descriptors */ +#define CB_MAX_TX_DESC 128 /* max # of descriptors */ +#define CB_MIN_TX_DESC 16 /* min # of TX descriptors */ + +#define CB_RD_NUM 64 /* default # of RD */ +#define CB_TD_NUM 64 /* default # of TD */ + +/* + * bits in the RSR register + */ +#define RSR_ADDRBROAD 0x80 +#define RSR_ADDRMULTI 0x40 +#define RSR_ADDRUNI 0x00 +#define RSR_IVLDTYP 0x20 /* invalid packet type */ +#define RSR_IVLDLEN 0x10 /* invalid len (> 2312 byte) */ +#define RSR_BSSIDOK 0x08 +#define RSR_CRCOK 0x04 +#define RSR_BCNSSIDOK 0x02 +#define RSR_ADDROK 0x01 + +/* + * bits in the new RSR register + */ +#define NEWRSR_DECRYPTOK 0x10 +#define NEWRSR_CFPIND 0x08 +#define NEWRSR_HWUTSF 0x04 +#define NEWRSR_BCNHITAID 0x02 +#define NEWRSR_BCNHITAID0 0x01 + +/* + * bits in the TSR register + */ +#define TSR_RETRYTMO 0x08 +#define TSR_TMO 0x04 +#define TSR_ACKDATA 0x02 +#define TSR_VALID 0x01 #define CB_PROTOCOL_RESERVED_SECTION 16 -// if retrys excess 15 times , tx will abort, and -// if tx fifo underflow, tx will fail -// we should try to resend it +/* + * if retries exceed 15 times, TX will abort, and + * if TX fifo underflow, TX will fail + * we should try to resend it + */ #define CB_MAX_TX_ABORT_RETRY 3 -#define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000 -#define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000 -#define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000 -#define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000 -#define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000 -#define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000 -#define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000 -#define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000 -#define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000 -#define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000 -#define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000 -#define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000 -#define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100 -#define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010 -#define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001 - -//WMAC definition Frag Control -#define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000 -#define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000 -#define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000 -#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000 -#define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011 -#define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010 -#define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001 -#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000 +#define FIFOCTL_AUTO_FB_1 0x1000 +#define FIFOCTL_AUTO_FB_0 0x0800 +#define FIFOCTL_GRPACK 0x0400 +#define FIFOCTL_11GA 0x0300 +#define FIFOCTL_11GB 0x0200 +#define FIFOCTL_11B 0x0100 +#define FIFOCTL_11A 0x0000 +#define FIFOCTL_RTS 0x0080 +#define FIFOCTL_ISDMA0 0x0040 +#define FIFOCTL_GENINT 0x0020 +#define FIFOCTL_TMOEN 0x0010 +#define FIFOCTL_LRETRY 0x0008 +#define FIFOCTL_CRCDIS 0x0004 +#define FIFOCTL_NEEDACK 0x0002 +#define FIFOCTL_LHEAD 0x0001 + +/* WMAC definition Frag Control */ +#define FRAGCTL_AES 0x0300 +#define FRAGCTL_TKIP 0x0200 +#define FRAGCTL_LEGACY 0x0100 +#define FRAGCTL_NONENCRYPT 0x0000 +#define FRAGCTL_ENDFRAG 0x0003 +#define FRAGCTL_MIDFRAG 0x0002 +#define FRAGCTL_STAFRAG 0x0001 +#define FRAGCTL_NONFRAG 0x0000 #define TYPE_TXDMA0 0 #define TYPE_AC0DMA 1 @@ -135,14 +138,14 @@ #define TYPE_RXDMA1 1 #define TYPE_MAXRD 2 -// TD_INFO flags control bit -#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb -#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap) -#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit +/* TD_INFO flags control bit */ +#define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */ +#define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb(hostap) */ +#define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */ -// -// RsvTime buffer header -// +/* + * RsvTime buffer header + */ typedef struct tagSRrvTime_gRTS { WORD wRTSTxRrvTime_ba; WORD wRTSTxRrvTime_aa; @@ -181,9 +184,9 @@ SRrvTime_atim, *PSRrvTime_atim; typedef const SRrvTime_atim *PCSRrvTime_atim; -// -// RTS buffer header -// +/* + * RTS buffer header + */ typedef struct tagSRTSData { WORD wFrameControl; WORD wDurationID; @@ -257,9 +260,9 @@ SRTS_a_FB, *PSRTS_a_FB; typedef const SRTS_a_FB *PCSRTS_a_FB; -// -// CTS buffer header -// +/* + * CTS buffer header + */ typedef struct tagSCTSData { WORD wFrameControl; WORD wDurationID; @@ -294,9 +297,9 @@ SCTS_FB, *PSCTS_FB; typedef const SCTS_FB *PCSCTS_FB; -// -// Tx FIFO header -// +/* + * TX FIFO header + */ typedef struct tagSTxBufHead { u32 adwTxKey[4]; WORD wFIFOCtl; @@ -314,9 +317,9 @@ typedef struct tagSTxShortBufHead { STxShortBufHead, *PSTxShortBufHead; typedef const STxShortBufHead *PCSTxShortBufHead; -// -// Tx data header -// +/* + * TX data header + */ typedef struct tagSTxDataHead_g { BYTE bySignalField_b; BYTE byServiceField_b; @@ -372,9 +375,9 @@ typedef struct tagSTxDataHead_a_FB { STxDataHead_a_FB, *PSTxDataHead_a_FB; typedef const STxDataHead_a_FB *PCSTxDataHead_a_FB; -// -// MICHDR data header -// +/* + * MICHDR data header + */ typedef struct tagSMICHDRHead { u32 adwHDR0[4]; u32 adwHDR1[4]; diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 25bf03a..6bba2e0 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -53,7 +53,7 @@ #undef DEVICE_ETHTOOL_IOCTL_SUPPORT #endif -//please copy below macro to driver_event.c for API +/* please copy below macro to driver_event.c for API */ #define RT_INSMOD_EVENT_FLAG 0x0101 #define RT_UPDEV_EVENT_FLAG 0x0102 #define RT_DISCONNECTED_EVENT_FLAG 0x0103 @@ -61,9 +61,9 @@ #define RT_DOWNDEV_EVENT_FLAG 0x0105 #define RT_RMMOD_EVENT_FLAG 0x0106 -// -// device specific -// +/* + * device specific + */ #include "device_cfg.h" #include "ttype.h" @@ -110,7 +110,7 @@ #define FB_RATE0 0 #define FB_RATE1 1 -// Antenna Mode +/* Antenna Mode */ #define ANT_A 0 #define ANT_B 1 #define ANT_DIVERSITY 2 @@ -125,7 +125,7 @@ #define MAXCHECKHANGCNT 4 -//Packet type +/* Packet type */ #define TX_PKT_UNI 0x00 #define TX_PKT_MULTI 0x01 #define TX_PKT_BROAD 0x02 @@ -137,7 +137,7 @@ #define RUN_AT(x) (jiffies+(x)) #endif -// DMA related +/* DMA related */ #define RESERV_AC0DMA 4 #define PRIVATE_Message 0 @@ -161,30 +161,30 @@ typedef enum __device_init_type { DEVICE_INIT_DXPL /* Dx to D0 power lost init */ } DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE; -//USB +/* USB */ -// -// Enum of context types for SendPacket -// +/* + * Enum of context types for SendPacket + */ typedef enum _CONTEXT_TYPE { CONTEXT_DATA_PACKET = 1, CONTEXT_MGMT_PACKET } CONTEXT_TYPE; -// RCB (Receive Control Block) +/* RCB (Receive Control Block) */ typedef struct _RCB { - void *Next; - signed long Ref; - void *pDevice; - struct urb *pUrb; - SRxMgmtPacket sMngPacket; - struct sk_buff* skb; - BOOL bBoolInUse; + void *Next; + signed long Ref; + void *pDevice; + struct urb *pUrb; + struct vnt_rx_mgmt sMngPacket; + struct sk_buff *skb; + int bBoolInUse; } RCB, *PRCB; -// used to track bulk out irps +/* used to track bulk out irps */ typedef struct _USB_SEND_CONTEXT { void *pDevice; struct sk_buff *pPacket; @@ -193,7 +193,7 @@ typedef struct _USB_SEND_CONTEXT { CONTEXT_TYPE Type; SEthernetHeader sEthHeader; void *Next; - BOOL bBoolInUse; + bool bBoolInUse; unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; } USB_SEND_CONTEXT, *PUSB_SEND_CONTEXT; @@ -207,17 +207,17 @@ typedef struct _DEFAULT_CONFIG { signed int eEncryptionStatus; } DEFAULT_CONFIG, *PDEFAULT_CONFIG; -// -// Structure to keep track of usb interrupt packets -// +/* + * Structure to keep track of USB interrupt packets + */ typedef struct { unsigned int uDataLen; PBYTE pDataBuf; -// struct urb *pUrb; - BOOL bInUse; + /* struct urb *pUrb; */ + bool bInUse; } INT_BUFFER, *PINT_BUFFER; -//0:11A 1:11B 2:11G +/* 0:11A 1:11B 2:11G */ typedef enum _VIA_BB_TYPE { BB_TYPE_11A = 0, @@ -225,7 +225,7 @@ typedef enum _VIA_BB_TYPE BB_TYPE_11G } VIA_BB_TYPE, *PVIA_BB_TYPE; -//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) +/* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga(OFDM in BasicRate) */ typedef enum _VIA_PKT_TYPE { PK_TYPE_11A = 0, @@ -234,7 +234,7 @@ typedef enum _VIA_PKT_TYPE PK_TYPE_11GA } VIA_PKT_TYPE, *PVIA_PKT_TYPE; -//++ NDIS related +/*++ NDIS related */ typedef enum __DEVICE_NDIS_STATUS { STATUS_SUCCESS = 0, @@ -245,10 +245,10 @@ typedef enum __DEVICE_NDIS_STATUS { #define MAX_BSSIDINFO_4_PMKID 16 #define MAX_PMKIDLIST 5 -//Flags for PMKID Candidate list structure +/* flags for PMKID Candidate list structure */ #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 -// PMKID Structures +/* PMKID Structures */ typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; @@ -272,13 +272,13 @@ typedef enum _NDIS_802_11_WEP_STATUS typedef enum _NDIS_802_11_STATUS_TYPE { - Ndis802_11StatusType_Authentication, - Ndis802_11StatusType_MediaStreamMode, - Ndis802_11StatusType_PMKID_CandidateList, - Ndis802_11StatusTypeMax // not a real type, defined as an upper bound + Ndis802_11StatusType_Authentication, + Ndis802_11StatusType_MediaStreamMode, + Ndis802_11StatusType_PMKID_CandidateList, + Ndis802_11StatusTypeMax, /* not a real type, defined as upper bound */ } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; -//Added new types for PMKID Candidate lists. +/* added new types for PMKID Candidate lists */ typedef struct _PMKID_CANDIDATE { NDIS_802_11_MAC_ADDRESS BSSID; unsigned long Flags; @@ -304,22 +304,17 @@ typedef struct tagSPMKIDCandidateEvent { PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST]; } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; -//-- - -//++ 802.11h related +/*++ 802.11h related */ #define MAX_QUIET_COUNT 8 typedef struct tagSQuietControl { - BOOL bEnable; + bool bEnable; DWORD dwStartTime; BYTE byPeriod; WORD wDuration; } SQuietControl, *PSQuietControl; -//-- - - -// The receive duplicate detection cache entry +/* The receive duplicate detection cache entry */ typedef struct tagSCacheEntry{ WORD wFmSequence; BYTE abyAddr2[ETH_ALEN]; @@ -329,13 +324,15 @@ typedef struct tagSCacheEntry{ typedef struct tagSCache{ /* The receive cache is updated circularly. The next entry to be written is * indexed by the "InPtr". -*/ + */ unsigned int uInPtr; /* Place to use next */ SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; } SCache, *PSCache; #define CB_MAX_RX_FRAG 64 -// DeFragment Control Block, used for collecting fragments prior to reassembly +/* + * DeFragment Control Block, used for collecting fragments prior to reassembly + */ typedef struct tagSDeFragControlBlock { WORD wSequence; @@ -345,27 +342,25 @@ typedef struct tagSDeFragControlBlock struct sk_buff* skb; PBYTE pbyRxBuffer; unsigned int cbFrameLength; - BOOL bInUse; + bool bInUse; } SDeFragControlBlock, *PSDeFragControlBlock; - - -//flags for options +/* flags for options */ #define DEVICE_FLAGS_UNPLUG 0x00000001UL #define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL #define DEVICE_FLAGS_OP_MODE 0x00000004UL #define DEVICE_FLAGS_PS_MODE 0x00000008UL #define DEVICE_FLAGS_80211h_MODE 0x00000010UL -//flags for driver status +/* flags for driver status */ #define DEVICE_FLAGS_OPENED 0x00010000UL #define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL -//flags for capbilities +/* flags for capabilities */ #define DEVICE_FLAGS_TX_ALIGN 0x01000000UL #define DEVICE_FLAGS_HAVE_CAM 0x02000000UL #define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL -//flags for MII status +/* flags for MII status */ #define DEVICE_LINK_FAIL 0x00000001UL #define DEVICE_SPEED_10 0x00000002UL #define DEVICE_SPEED_100 0x00000004UL @@ -373,14 +368,14 @@ typedef struct tagSDeFragControlBlock #define DEVICE_DUPLEX_FULL 0x00000010UL #define DEVICE_AUTONEG_ENABLE 0x00000020UL #define DEVICE_FORCED_BY_EEPROM 0x00000040UL -//for device_set_media_duplex +/* for device_set_media_duplex */ #define DEVICE_LINK_CHANGE 0x00000001UL typedef struct __device_opt { - int nRxDescs0; //Number of RX descriptors0 - int nTxDescs0; //Number of TX descriptors 0, 1, 2, 3 - int rts_thresh; //rts threshold + int nRxDescs0; /* number of RX descriptors 0 */ + int nTxDescs0; /* number of TX descriptors 0, 1, 2, 3 */ + int rts_thresh; /* RTS threshold */ int frag_thresh; int OpMode; int data_rate; @@ -392,429 +387,406 @@ typedef struct __device_opt { } OPTIONS, *POPTIONS; -typedef struct __device_info { +struct vnt_private { + /* netdev */ + struct usb_device *usb; + struct net_device *dev; + struct net_device_stats stats; -// netdev - struct usb_device* usb; - struct net_device* dev; - struct net_device_stats stats; + OPTIONS sOpts; + struct tasklet_struct CmdWorkItem; + struct tasklet_struct EventWorkItem; + struct tasklet_struct ReadWorkItem; + struct tasklet_struct RxMngWorkItem; - OPTIONS sOpts; + u32 rx_buf_sz; + int multicast_limit; + u8 byRxMode; - struct tasklet_struct CmdWorkItem; - struct tasklet_struct EventWorkItem; - struct tasklet_struct ReadWorkItem; - struct tasklet_struct RxMngWorkItem; + spinlock_t lock; - u32 rx_buf_sz; - int multicast_limit; - BYTE byRxMode; + u32 rx_bytes; - spinlock_t lock; + u8 byRevId; - u32 rx_bytes; + u32 flags; + unsigned long Flags; - BYTE byRevId; + SCache sDupRxCache; - u32 flags; - unsigned long Flags; + SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; + u32 cbDFCB; + u32 cbFreeDFCB; + u32 uCurrentDFCBIdx; - SCache sDupRxCache; - SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; - unsigned int cbDFCB; - unsigned int cbFreeDFCB; - unsigned int uCurrentDFCBIdx; + /* USB */ + struct urb *pControlURB; + struct urb *pInterruptURB; + struct usb_ctrlrequest sUsbCtlRequest; + u32 int_interval; - // +++USB - - struct urb *pControlURB; - struct urb *pInterruptURB; - struct usb_ctrlrequest sUsbCtlRequest; - - unsigned int int_interval; - // - // Variables to track resources for the BULK In Pipe - // - PRCB pRCBMem; - PRCB apRCB[CB_MAX_RX_DESC]; - unsigned int cbRD; - PRCB FirstRecvFreeList; - PRCB LastRecvFreeList; - unsigned int NumRecvFreeList; - PRCB FirstRecvMngList; - PRCB LastRecvMngList; - unsigned int NumRecvMngList; - BOOL bIsRxWorkItemQueued; - BOOL bIsRxMngWorkItemQueued; + /* Variables to track resources for the BULK In Pipe */ + PRCB pRCBMem; + PRCB apRCB[CB_MAX_RX_DESC]; + u32 cbRD; + PRCB FirstRecvFreeList; + PRCB LastRecvFreeList; + u32 NumRecvFreeList; + PRCB FirstRecvMngList; + PRCB LastRecvMngList; + u32 NumRecvMngList; + int bIsRxWorkItemQueued; + int bIsRxMngWorkItemQueued; unsigned long ulRcvRefCount; /* packets that have not returned back */ - // - // Variables to track resources for the BULK Out Pipe - // - - PUSB_SEND_CONTEXT apTD[CB_MAX_TX_DESC]; - unsigned int cbTD; - - // - // Variables to track resources for the Interrupt In Pipe - // - INT_BUFFER intBuf; - BOOL fKillEventPollingThread; - BOOL bEventAvailable; - - - //default config from file by user setting - DEFAULT_CONFIG config_file; - - - // - // Statistic for USB - // protect with spinlock - unsigned long ulBulkInPosted; - unsigned long ulBulkInError; - unsigned long ulBulkInContCRCError; - unsigned long ulBulkInBytesRead; - - unsigned long ulBulkOutPosted; - unsigned long ulBulkOutError; - unsigned long ulBulkOutContCRCError; - unsigned long ulBulkOutBytesWrite; - - unsigned long ulIntInPosted; - unsigned long ulIntInError; - unsigned long ulIntInContCRCError; - unsigned long ulIntInBytesRead; - - - // Version control - WORD wFirmwareVersion; - BYTE byLocalID; - BYTE byRFType; - BYTE byBBRxConf; - - - BYTE byZoneType; - BOOL bZoneRegExist; - - BYTE byOriginalZonetype; - - BOOL bLinkPass; // link status: OK or fail - BYTE abyCurrentNetAddr[ETH_ALEN]; - BYTE abyPermanentNetAddr[ETH_ALEN]; - // SW network address - /* u8 abySoftwareNetAddr[ETH_ALEN]; */ - BOOL bExistSWNetAddr; - - // Adapter statistics - SStatCounter scStatistic; - // 802.11 counter - SDot11Counters s802_11Counter; - - // - // Maintain statistical debug info. - // - unsigned long packetsReceived; - unsigned long packetsReceivedDropped; - unsigned long packetsReceivedOverflow; - unsigned long packetsSent; - unsigned long packetsSentDropped; - unsigned long SendContextsInUse; - unsigned long RcvBuffersInUse; - - - // 802.11 management - SMgmtObject sMgmtObj; - - QWORD qwCurrTSF; - unsigned int cbBulkInMax; - BOOL bPSRxBeacon; - - // 802.11 MAC specific - unsigned int uCurrRSSI; - BYTE byCurrSQ; - - - //Antenna Diversity - BOOL bTxRxAntInv; - DWORD dwRxAntennaSel; - DWORD dwTxAntennaSel; - BYTE byAntennaCount; - BYTE byRxAntennaMode; - BYTE byTxAntennaMode; - BYTE byRadioCtl; - BYTE bHWRadioOff; - - //SQ3 functions for antenna diversity - struct timer_list TimerSQ3Tmax1; - struct timer_list TimerSQ3Tmax2; - struct timer_list TimerSQ3Tmax3; - - BOOL bDiversityRegCtlON; - BOOL bDiversityEnable; - unsigned long ulDiversityNValue; - unsigned long ulDiversityMValue; - BYTE byTMax; - BYTE byTMax2; - BYTE byTMax3; - unsigned long ulSQ3TH; - - unsigned long uDiversityCnt; - BYTE byAntennaState; - unsigned long ulRatio_State0; - unsigned long ulRatio_State1; - unsigned long ulSQ3_State0; - unsigned long ulSQ3_State1; - - unsigned long aulSQ3Val[MAX_RATE]; - unsigned long aulPktNum[MAX_RATE]; + /* Variables to track resources for the BULK Out Pipe */ + PUSB_SEND_CONTEXT apTD[CB_MAX_TX_DESC]; + u32 cbTD; + + /* Variables to track resources for the Interrupt In Pipe */ + INT_BUFFER intBuf; + int fKillEventPollingThread; + int bEventAvailable; + + /* default config from file by user setting */ + DEFAULT_CONFIG config_file; + + + /* Statistic for USB */ + unsigned long ulBulkInPosted; + unsigned long ulBulkInError; + unsigned long ulBulkInContCRCError; + unsigned long ulBulkInBytesRead; + + unsigned long ulBulkOutPosted; + unsigned long ulBulkOutError; + unsigned long ulBulkOutContCRCError; + unsigned long ulBulkOutBytesWrite; + + unsigned long ulIntInPosted; + unsigned long ulIntInError; + unsigned long ulIntInContCRCError; + unsigned long ulIntInBytesRead; + + + /* Version control */ + u16 wFirmwareVersion; + u8 byLocalID; + u8 byRFType; + u8 byBBRxConf; + + + u8 byZoneType; + int bZoneRegExist; + + u8 byOriginalZonetype; + + int bLinkPass; /* link status: OK or fail */ + u8 abyCurrentNetAddr[ETH_ALEN]; + u8 abyPermanentNetAddr[ETH_ALEN]; + + int bExistSWNetAddr; + + /* Adapter statistics */ + SStatCounter scStatistic; + /* 802.11 counter */ + SDot11Counters s802_11Counter; + + /* Maintain statistical debug info. */ + unsigned long packetsReceived; + unsigned long packetsReceivedDropped; + unsigned long packetsReceivedOverflow; + unsigned long packetsSent; + unsigned long packetsSentDropped; + unsigned long SendContextsInUse; + unsigned long RcvBuffersInUse; + + /* 802.11 management */ + struct vnt_manager vnt_mgmt; + + u64 qwCurrTSF; + u32 cbBulkInMax; + int bPSRxBeacon; + + /* 802.11 MAC specific */ + u32 uCurrRSSI; + u8 byCurrSQ; + + /* Antenna Diversity */ + int bTxRxAntInv; + u32 dwRxAntennaSel; + u32 dwTxAntennaSel; + u8 byAntennaCount; + u8 byRxAntennaMode; + u8 byTxAntennaMode; + u8 byRadioCtl; + u8 bHWRadioOff; + + /* SQ3 functions for antenna diversity */ + struct timer_list TimerSQ3Tmax1; + struct timer_list TimerSQ3Tmax2; + struct timer_list TimerSQ3Tmax3; + + int bDiversityRegCtlON; + int bDiversityEnable; + unsigned long ulDiversityNValue; + unsigned long ulDiversityMValue; + u8 byTMax; + u8 byTMax2; + u8 byTMax3; + unsigned long ulSQ3TH; + + unsigned long uDiversityCnt; + u8 byAntennaState; + unsigned long ulRatio_State0; + unsigned long ulRatio_State1; + unsigned long ulSQ3_State0; + unsigned long ulSQ3_State1; + + unsigned long aulSQ3Val[MAX_RATE]; + unsigned long aulPktNum[MAX_RATE]; /* IFS & Cw */ - unsigned int uSIFS; /* Current SIFS */ - unsigned int uDIFS; /* Current DIFS */ - unsigned int uEIFS; /* Current EIFS */ - unsigned int uSlot; /* Current SlotTime */ - unsigned int uCwMin; /* Current CwMin */ - unsigned int uCwMax; /* CwMax is fixed on 1023 */ - - // PHY parameter - BYTE bySIFS; - BYTE byDIFS; - BYTE byEIFS; - BYTE bySlot; - BYTE byCWMaxMin; - - // Rate - VIA_BB_TYPE byBBType; //0: 11A, 1:11B, 2:11G - VIA_PKT_TYPE byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) - WORD wBasicRate; - BYTE byACKRate; - BYTE byTopOFDMBasicRate; - BYTE byTopCCKBasicRate; - - - DWORD dwAotoRateTxOkCnt; - DWORD dwAotoRateTxFailCnt; - DWORD dwErrorRateThreshold[13]; - DWORD dwTPTable[MAX_RATE]; - BYTE abyEEPROM[EEP_MAX_CONTEXT_SIZE]; //DWORD alignment - - BYTE byMinChannel; - BYTE byMaxChannel; - unsigned int uConnectionRate; - - BYTE byPreambleType; - BYTE byShortPreamble; - // CARD_PHY_TYPE - BYTE eConfigPHYMode; - - // For RF Power table - BYTE byCCKPwr; - BYTE byOFDMPwrG; - BYTE byOFDMPwrA; - BYTE byCurPwr; - BYTE abyCCKPwrTbl[14]; - BYTE abyOFDMPwrTbl[14]; - BYTE abyOFDMAPwrTbl[42]; - - WORD wCurrentRate; - WORD wRTSThreshold; - WORD wFragmentationThreshold; - BYTE byShortRetryLimit; - BYTE byLongRetryLimit; - CARD_OP_MODE eOPMode; - BOOL bBSSIDFilter; - WORD wMaxTransmitMSDULifetime; - BYTE abyBSSID[ETH_ALEN]; - BYTE abyDesireBSSID[ETH_ALEN]; - WORD wCTSDuration; // update while speed change - WORD wACKDuration; // update while speed change - WORD wRTSTransmitLen; // update while speed change - BYTE byRTSServiceField; // update while speed change - BYTE byRTSSignalField; // update while speed change - - DWORD dwMaxReceiveLifetime; // dot11MaxReceiveLifetime - - BOOL bCCK; - BOOL bEncryptionEnable; - BOOL bLongHeader; - BOOL bSoftwareGenCrcErr; - BOOL bShortSlotTime; - BOOL bProtectMode; - BOOL bNonERPPresent; - BOOL bBarkerPreambleMd; - - BYTE byERPFlag; - WORD wUseProtectCntDown; - - BOOL bRadioControlOff; - BOOL bRadioOff; - - // Power save - BOOL bEnablePSMode; - WORD wListenInterval; - BOOL bPWBitOn; - WMAC_POWER_MODE ePSMode; - unsigned long ulPSModeWaitTx; - BOOL bPSModeTxBurst; - - // Beacon releated - WORD wSeqCounter; - BOOL bBeaconBufReady; - BOOL bBeaconSent; - BOOL bFixRate; - BYTE byCurrentCh; - unsigned int uScanTime; - - CMD_STATE eCommandState; - - CMD_CODE eCommand; - BOOL bBeaconTx; - BYTE byScanBBType; - - BOOL bStopBeacon; - BOOL bStopDataPkt; - BOOL bStopTx0Pkt; - unsigned int uAutoReConnectTime; - unsigned int uIsroamingTime; - - // 802.11 counter - - CMD_ITEM eCmdQueue[CMD_Q_SIZE]; - unsigned int uCmdDequeueIdx; - unsigned int uCmdEnqueueIdx; - unsigned int cbFreeCmdQueue; - BOOL bCmdRunning; - BOOL bCmdClear; - BOOL bNeedRadioOFF; - - BOOL bEnableRoaming; - BOOL bIsRoaming; - BOOL bFastRoaming; - BYTE bSameBSSMaxNum; - BYTE bSameBSSCurNum; - BOOL bRoaming; - BOOL b11hEable; - unsigned long ulTxPower; - - // Encryption - NDIS_802_11_WEP_STATUS eEncryptionStatus; - BOOL bTransmitKey; - -//mike add :save old Encryption - NDIS_802_11_WEP_STATUS eOldEncryptionStatus; - - SKeyManagement sKey; - DWORD dwIVCounter; - - - RC4Ext SBox; - BYTE abyPRNG[WLAN_WEPMAX_KEYLEN+3]; - BYTE byKeyIndex; - - BOOL bAES; - - unsigned int uKeyLength; - BYTE abyKey[WLAN_WEP232_KEYLEN]; - - // for AP mode - unsigned int uAssocCount; - BOOL bMoreData; - - // QoS - BOOL bGrpAckPolicy; - - - BYTE byAutoFBCtrl; - - BOOL bTxMICFail; - BOOL bRxMICFail; - - - // For Update BaseBand VGA Gain Offset - BOOL bUpdateBBVGA; - unsigned int uBBVGADiffCount; - BYTE byBBVGANew; - BYTE byBBVGACurrent; - BYTE abyBBVGA[BB_VGA_LEVEL]; - signed long ldBmThreshold[BB_VGA_LEVEL]; - - BYTE byBBPreEDRSSI; - BYTE byBBPreEDIndex; - - - BOOL bRadioCmd; - DWORD dwDiagRefCount; - - // For FOE Tuning - BYTE byFOETuning; + u32 uSIFS; /* Current SIFS */ + u32 uDIFS; /* Current DIFS */ + u32 uEIFS; /* Current EIFS */ + u32 uSlot; /* Current SlotTime */ + u32 uCwMin; /* Current CwMin */ + u32 uCwMax; /* CwMax is fixed on 1023 */ + + /* PHY parameter */ + u8 bySIFS; + u8 byDIFS; + u8 byEIFS; + u8 bySlot; + u8 byCWMaxMin; + + /* Rate */ + VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */ + VIA_PKT_TYPE byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ + u16 wBasicRate; + u8 byACKRate; + u8 byTopOFDMBasicRate; + u8 byTopCCKBasicRate; + + + u32 dwAotoRateTxOkCnt; + u32 dwAotoRateTxFailCnt; + u32 dwErrorRateThreshold[13]; + u32 dwTPTable[MAX_RATE]; + u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ + + u8 byMinChannel; + u8 byMaxChannel; + u32 uConnectionRate; + + u8 byPreambleType; + u8 byShortPreamble; + /* CARD_PHY_TYPE */ + u8 eConfigPHYMode; + + /* For RF Power table */ + u8 byCCKPwr; + u8 byOFDMPwrG; + u8 byOFDMPwrA; + u8 byCurPwr; + u8 abyCCKPwrTbl[14]; + u8 abyOFDMPwrTbl[14]; + u8 abyOFDMAPwrTbl[42]; + + u16 wCurrentRate; + u16 wRTSThreshold; + u16 wFragmentationThreshold; + u8 byShortRetryLimit; + u8 byLongRetryLimit; + CARD_OP_MODE eOPMode; + int bBSSIDFilter; + u16 wMaxTransmitMSDULifetime; + u8 abyBSSID[ETH_ALEN]; + u8 abyDesireBSSID[ETH_ALEN]; + + u16 wCTSDuration; /* update while speed change */ + u16 wACKDuration; + u16 wRTSTransmitLen; + u8 byRTSServiceField; + u8 byRTSSignalField; + + u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ + + int bCCK; + int bEncryptionEnable; + int bLongHeader; + int bSoftwareGenCrcErr; + int bShortSlotTime; + int bProtectMode; + int bNonERPPresent; + int bBarkerPreambleMd; + + u8 byERPFlag; + u16 wUseProtectCntDown; + + int bRadioControlOff; + int bRadioOff; + + /* Power save */ + int bEnablePSMode; + u16 wListenInterval; + int bPWBitOn; + WMAC_POWER_MODE ePSMode; + unsigned long ulPSModeWaitTx; + int bPSModeTxBurst; + + /* Beacon releated */ + u16 wSeqCounter; + int bBeaconBufReady; + int bBeaconSent; + int bFixRate; + u8 byCurrentCh; + u32 uScanTime; + + CMD_STATE eCommandState; + + CMD_CODE eCommand; + int bBeaconTx; + u8 byScanBBType; + + int bStopBeacon; + int bStopDataPkt; + int bStopTx0Pkt; + u32 uAutoReConnectTime; + u32 uIsroamingTime; + + /* 802.11 counter */ + + CMD_ITEM eCmdQueue[CMD_Q_SIZE]; + u32 uCmdDequeueIdx; + u32 uCmdEnqueueIdx; + u32 cbFreeCmdQueue; + int bCmdRunning; + int bCmdClear; + int bNeedRadioOFF; + + int bEnableRoaming; + int bIsRoaming; + int bFastRoaming; + u8 bSameBSSMaxNum; + u8 bSameBSSCurNum; + int bRoaming; + int b11hEable; + unsigned long ulTxPower; + + /* Encryption */ + NDIS_802_11_WEP_STATUS eEncryptionStatus; + int bTransmitKey; + NDIS_802_11_WEP_STATUS eOldEncryptionStatus; + SKeyManagement sKey; + u32 dwIVCounter; + + + RC4Ext SBox; + u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3]; + u8 byKeyIndex; + + int bAES; + + u32 uKeyLength; + u8 abyKey[WLAN_WEP232_KEYLEN]; + + /* for AP mode */ + u32 uAssocCount; + int bMoreData; + + /* QoS */ + int bGrpAckPolicy; + + + u8 byAutoFBCtrl; + + int bTxMICFail; + int bRxMICFail; + + + /* For Update BaseBand VGA Gain Offset */ + int bUpdateBBVGA; + u32 uBBVGADiffCount; + u8 byBBVGANew; + u8 byBBVGACurrent; + u8 abyBBVGA[BB_VGA_LEVEL]; + signed long ldBmThreshold[BB_VGA_LEVEL]; + + u8 byBBPreEDRSSI; + u8 byBBPreEDIndex; + + + int bRadioCmd; + u32 dwDiagRefCount; + + /* For FOE Tuning */ + u8 byFOETuning; + + /* For Auto Power Tunning */ + u8 byAutoPwrTunning; + + /* BaseBand Loopback Use */ + u8 byBBCR4d; + u8 byBBCRc9; + u8 byBBCR88; + u8 byBBCR09; + + /* command timer */ + struct timer_list sTimerCommand; - // For Auto Power Tunning + struct timer_list sTimerTxData; + unsigned long nTxDataTimeCout; + int fTxDataInSleep; + int IsTxDataTrigger; - BYTE byAutoPwrTunning; + int fWPA_Authened; /*is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */ + u8 byReAssocCount; + u8 byLinkWaitCount; - // BaseBand Loopback Use - BYTE byBBCR4d; - BYTE byBBCRc9; - BYTE byBBCR88; - BYTE byBBCR09; + SEthernetHeader sTxEthHeader; + SEthernetHeader sRxEthHeader; + u8 abyBroadcastAddr[ETH_ALEN]; + u8 abySNAP_RFC1042[ETH_ALEN]; + u8 abySNAP_Bridgetunnel[ETH_ALEN]; - // command timer - struct timer_list sTimerCommand; + /* Pre-Authentication & PMK cache */ + SPMKID gsPMKID; + SPMKIDCandidateEvent gsPMKIDCandidate; - struct timer_list sTimerTxData; - unsigned long nTxDataTimeCout; - BOOL fTxDataInSleep; - BOOL IsTxDataTrigger; - BOOL fWPA_Authened; //is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? - BYTE byReAssocCount; //mike add:re-association retry times! - BYTE byLinkWaitCount; + /* for 802.11h */ + int b11hEnable; - SEthernetHeader sTxEthHeader; - SEthernetHeader sRxEthHeader; - BYTE abyBroadcastAddr[ETH_ALEN]; - BYTE abySNAP_RFC1042[ETH_ALEN]; - BYTE abySNAP_Bridgetunnel[ETH_ALEN]; + int bChannelSwitch; + u8 byNewChannel; + u8 byChannelSwitchCount; - // Pre-Authentication & PMK cache - SPMKID gsPMKID; - SPMKIDCandidateEvent gsPMKIDCandidate; + /* WPA supplicant daemon */ + int bWPADEVUp; + int bwextstep0; + int bwextstep1; + int bwextstep2; + int bwextstep3; + int bWPASuppWextEnabled; + /* user space daemon: hostapd, is used for HOSTAP */ + int bEnableHostapd; + int bEnable8021x; + int bEnableHostWEP; + struct net_device *apdev; + int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); - // for 802.11h - BOOL b11hEnable; - - BOOL bChannelSwitch; - BYTE byNewChannel; - BYTE byChannelSwitchCount; + u32 uChannel; - //WPA supplicant daemon - struct net_device *wpadev; - BOOL bWPADEVUp; - //-- + struct iw_statistics wstats; /* wireless stats */ - BOOL bwextstep0; - BOOL bwextstep1; - BOOL bwextstep2; - BOOL bwextstep3; - BOOL bWPASuppWextEnabled; + int bCommit; -#ifdef HOSTAP - // user space daemon: hostapd, is used for HOSTAP - BOOL bEnableHostapd; - BOOL bEnable8021x; - BOOL bEnableHostWEP; - struct net_device *apdev; - int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); -#endif - unsigned int uChannel; - - struct iw_statistics wstats; // wireless stats - BOOL bCommit; - -} DEVICE_INFO, *PSDevice; +}; @@ -871,9 +843,6 @@ typedef struct __device_info { /*--------------------- Export Functions --------------------------*/ -/* BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, - * unsigned int uNodeIndex); - */ -BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF); +int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); #endif diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h index a0b8216..62290d0 100644 --- a/drivers/staging/vt6656/device_cfg.h +++ b/drivers/staging/vt6656/device_cfg.h @@ -38,12 +38,12 @@ struct _version { unsigned char build; } version_t, *pversion_t; -#ifndef FALSE -#define FALSE (0) +#ifndef false +#define false (0) #endif -#ifndef TRUE -#define TRUE (!(FALSE)) +#ifndef true +#define true (!(false)) #endif #define VID_TABLE_SIZE 64 @@ -67,14 +67,14 @@ struct _version { #define DEVICE_VERSION "1.19_12" #endif -//config file +/* config file */ #include <linux/fs.h> #include <linux/fcntl.h> #ifndef CONFIG_PATH #define CONFIG_PATH "/etc/vntconfiguration.dat" #endif -//Max: 2378=2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR +/* Max: 2378 = 2312 Payload + 30HD + 4CRC + 2Padding + 4Len + 8TSF + 4RSR */ #define PKT_BUF_SZ 2390 #define MAX_UINTS 8 diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index e94f6a1..e83f95e 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -84,61 +84,23 @@ s_vGetDASA( PSEthernetHeader psEthHeader ); -static -void -s_vProcessRxMACHeader ( - PSDevice pDevice, - PBYTE pbyRxBufferAddr, - unsigned int cbPacketSize, - BOOL bIsWEP, - BOOL bExtIV, - unsigned int *pcbHeadSize - ); - -static BOOL s_bAPModeRxCtl( - PSDevice pDevice, - PBYTE pbyFrame, - signed int iSANodeIndex - ); - - - -static BOOL s_bAPModeRxData ( - PSDevice pDevice, - struct sk_buff *skb, - unsigned int FrameSize, - unsigned int cbHeaderOffset, - signed int iSANodeIndex, - signed int iDANodeIndex - ); +static void s_vProcessRxMACHeader(struct vnt_private *pDevice, + u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV, + u32 *pcbHeadSize); +static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, + s32 iSANodeIndex); -static BOOL s_bHandleRxEncryption( - PSDevice pDevice, - PBYTE pbyFrame, - unsigned int FrameSize, - PBYTE pbyRsr, - PBYTE pbyNewRsr, - PSKeyItem * pKeyOut, - int * pbExtIV, - PWORD pwRxTSC15_0, - PDWORD pdwRxTSC47_16 - ); - -static BOOL s_bHostWepRxEncryption( +static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, + u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex); - PSDevice pDevice, - PBYTE pbyFrame, - unsigned int FrameSize, - PBYTE pbyRsr, - BOOL bOnFly, - PSKeyItem pKey, - PBYTE pbyNewRsr, - int * pbExtIV, - PWORD pwRxTSC15_0, - PDWORD pdwRxTSC47_16 +static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, + u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, + s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); - ); +static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, + u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, + s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); /*--------------------- Export Variables --------------------------*/ @@ -159,22 +121,16 @@ static BOOL s_bHostWepRxEncryption( * Return Value: None * -*/ -static -void -s_vProcessRxMACHeader ( - PSDevice pDevice, - PBYTE pbyRxBufferAddr, - unsigned int cbPacketSize, - BOOL bIsWEP, - BOOL bExtIV, - unsigned int *pcbHeadSize - ) + +static void s_vProcessRxMACHeader(struct vnt_private *pDevice, + u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV, + u32 *pcbHeadSize) { - PBYTE pbyRxBuffer; - unsigned int cbHeaderSize = 0; - PWORD pwType; - PS802_11Header pMACHeader; - int ii; + u8 *pbyRxBuffer; + u32 cbHeaderSize = 0; + u16 *pwType; + PS802_11Header pMACHeader; + int ii; pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); @@ -310,56 +266,39 @@ s_vGetDASA ( } - - -BOOL -RXbBulkInProcessData ( - PSDevice pDevice, - PRCB pRCB, - unsigned long BytesToIndicate - ) +int RXbBulkInProcessData(struct vnt_private *pDevice, PRCB pRCB, + unsigned long BytesToIndicate) { - - struct net_device_stats* pStats=&pDevice->stats; - struct sk_buff* skb; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PSRxMgmtPacket pRxPacket = &(pMgmt->sRxPacket); - PS802_11Header p802_11Header; - PBYTE pbyRsr; - PBYTE pbyNewRsr; - PBYTE pbyRSSI; - PQWORD pqwTSFTime; - PBYTE pbyFrame; - BOOL bDeFragRx = FALSE; - unsigned int cbHeaderOffset; + struct net_device_stats *pStats = &pDevice->stats; + struct sk_buff *skb; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_rx_mgmt *pRxPacket = &pMgmt->sRxPacket; + PS802_11Header p802_11Header; + u8 *pbyRsr, *pbyNewRsr, *pbyRSSI, *pbyFrame; + u64 *pqwTSFTime; + u32 bDeFragRx = false; + u32 cbHeaderOffset, cbIVOffset; u32 FrameSize; - WORD wEtherType = 0; - signed int iSANodeIndex = -1; - signed int iDANodeIndex = -1; - unsigned int ii; - unsigned int cbIVOffset; - PBYTE pbyRxSts; - PBYTE pbyRxRate; - PBYTE pbySQ; - PBYTE pby3SQ; - unsigned int cbHeaderSize; - PSKeyItem pKey = NULL; - WORD wRxTSC15_0 = 0; - DWORD dwRxTSC47_16 = 0; - SKeyItem STempKey; - // 802.11h RPI - /* signed long ldBm = 0; */ - BOOL bIsWEP = FALSE; - BOOL bExtIV = FALSE; + u16 wEtherType = 0; + s32 iSANodeIndex = -1, iDANodeIndex = -1; + int ii; + u8 *pbyRxSts, *pbyRxRate, *pbySQ, *pby3SQ; + u32 cbHeaderSize; + PSKeyItem pKey = NULL; + u16 wRxTSC15_0 = 0; + u32 dwRxTSC47_16 = 0; + SKeyItem STempKey; + /* signed long ldBm = 0; */ + int bIsWEP = false; int bExtIV = false; u32 dwWbkStatus; - PRCB pRCBIndicate = pRCB; - PBYTE pbyDAddress; - PWORD pwPLCP_Length; - BYTE abyVaildRate[MAX_RATE] = {2,4,11,22,12,18,24,36,48,72,96,108}; - WORD wPLCPwithPadding; - PS802_11Header pMACHeader; - BOOL bRxeapol_key = FALSE; - + PRCB pRCBIndicate = pRCB; + u8 *pbyDAddress; + u16 *pwPLCP_Length; + u8 abyVaildRate[MAX_RATE] + = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108}; + u16 wPLCPwithPadding; + PS802_11Header pMACHeader; + int bRxeapol_key = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- RXbBulkInProcessData---\n"); @@ -373,13 +312,13 @@ RXbBulkInProcessData ( if (BytesToIndicate != FrameSize) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"------- WRONG Length 1\n"); - return FALSE; + return false; } if ((BytesToIndicate > 2372) || (BytesToIndicate <= 40)) { // Frame Size error drop this packet. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---------- WRONG Length 2\n"); - return FALSE; + return false; } pbyDAddress = (PBYTE)(skb->data); @@ -397,7 +336,7 @@ RXbBulkInProcessData ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Wrong PLCP Length %x\n", (int) *pwPLCP_Length); ASSERT(0); - return FALSE; + return false; } for ( ii=RATE_1M;ii<MAX_RATE;ii++) { if ( *pbyRxRate == abyVaildRate[ii] ) { @@ -406,12 +345,12 @@ RXbBulkInProcessData ( } if ( ii==MAX_RATE ) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Wrong RxRate %x\n",(int) *pbyRxRate); - return FALSE; + return false; } wPLCPwithPadding = ( (*pwPLCP_Length / 4) + ( (*pwPLCP_Length % 4) ? 1:0 ) ) *4; - pqwTSFTime = (PQWORD) (pbyDAddress + 8 + wPLCPwithPadding); + pqwTSFTime = (u64 *)(pbyDAddress + 8 + wPLCPwithPadding); if(pDevice->byBBType == BB_TYPE_11G) { pby3SQ = pbyDAddress + 8 + wPLCPwithPadding + 12; pbySQ = pby3SQ; @@ -455,12 +394,12 @@ RXbBulkInProcessData ( if (!is_multicast_ether_addr(pMACHeader->abyAddr1)) { if ( WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) pbyFrame) ) { pDevice->s802_11Counter.FrameDuplicateCount++; - return FALSE; + return false; } if (compare_ether_addr(pDevice->abyCurrentNetAddr, pMACHeader->abyAddr1)) { - return FALSE; + return false; } } @@ -470,7 +409,7 @@ RXbBulkInProcessData ( if (!compare_ether_addr((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr)) - return FALSE; + return false; if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { @@ -484,17 +423,17 @@ RXbBulkInProcessData ( } if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == TRUE) { - return FALSE; + if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == true) { + return false; } } if (IS_FC_WEP(pbyFrame)) { - BOOL bRxDecryOK = FALSE; + bool bRxDecryOK = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rx WEP pkt\n"); - bIsWEP = TRUE; + bIsWEP = true; if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) { pKey = &STempKey; pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite; @@ -546,11 +485,11 @@ RXbBulkInProcessData ( // pDevice->s802_11Counter.WEPICVErrorCount.QuadPart++; } } - return FALSE; + return false; } } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WEP Func Fail\n"); - return FALSE; + return false; } if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) FrameSize -= 8; // Message Integrity Code @@ -579,14 +518,14 @@ RXbBulkInProcessData ( pbyFrame = skb->data + 8; } else { - return FALSE; + return false; } } // // Management & Control frame Handle // - if ((IS_TYPE_DATA((pbyFrame))) == FALSE) { + if ((IS_TYPE_DATA((pbyFrame))) == false) { // Handle Control & Manage Frame if (IS_TYPE_MGMT((pbyFrame))) { @@ -598,8 +537,7 @@ RXbBulkInProcessData ( pRxPacket->cbMPDULen = FrameSize; pRxPacket->uRSSI = *pbyRSSI; pRxPacket->bySQ = *pbySQ; - HIDWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(HIDWORD(*pqwTSFTime)); - LODWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(LODWORD(*pqwTSFTime)); + pRxPacket->qwLocalTSF = cpu_to_le64(*pqwTSFTime); if (bIsWEP) { // strip IV pbyData1 = WLAN_HDR_A3_DATA_PTR(pbyFrame); @@ -617,7 +555,7 @@ RXbBulkInProcessData ( //Discard beacon packet which channel is 0 if ( (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) == WLAN_FSTYPE_BEACON) || (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) == WLAN_FSTYPE_PROBERESP) ) { - return FALSE; + return false; } } pRxPacket->byRxChannel = (*pbyRxSts) >> 2; @@ -635,7 +573,7 @@ RXbBulkInProcessData ( skb->protocol = htons(ETH_P_802_2); memset(skb->cb, 0, sizeof(skb->cb)); netif_rx(skb); - return TRUE; + return true; } // @@ -643,11 +581,11 @@ RXbBulkInProcessData ( // EnqueueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList, pRCBIndicate); pDevice->NumRecvMngList++; - if ( bDeFragRx == FALSE) { + if ( bDeFragRx == false) { pRCB->Ref++; } - if (pDevice->bIsRxMngWorkItemQueued == FALSE) { - pDevice->bIsRxMngWorkItemQueued = TRUE; + if (pDevice->bIsRxMngWorkItemQueued == false) { + pDevice->bIsRxMngWorkItemQueued = true; tasklet_schedule(&pDevice->RxMngWorkItem); } @@ -655,7 +593,7 @@ RXbBulkInProcessData ( else { // Control Frame }; - return FALSE; + return false; } else { if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { @@ -667,12 +605,12 @@ RXbBulkInProcessData ( pDevice->dev->name); } } - return FALSE; + return false; } } else { // discard DATA packet while not associate || BSSID error - if ((pDevice->bLinkPass == FALSE) || + if ((pDevice->bLinkPass == false) || !(*pbyRsr & RSR_BSSIDOK)) { if (bDeFragRx) { if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { @@ -680,7 +618,7 @@ RXbBulkInProcessData ( pDevice->dev->name); } } - return FALSE; + return false; } //mike add:station mode check eapol-key challenge---> { @@ -699,7 +637,7 @@ RXbBulkInProcessData ( if (wEtherType == ETH_P_PAE) { //Protocol Type in LLC-Header if(((Protocol_Version==1) ||(Protocol_Version==2)) && (Packet_Type==3)) { //802.1x OR eapol-key challenge frame receive - bRxeapol_key = TRUE; + bRxeapol_key = true; Descriptor_type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2]; Key_info = (skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2+1]<<8) |skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2+2] ; if(Descriptor_type==2) { //RSN @@ -726,8 +664,8 @@ RXbBulkInProcessData ( } } else { - if (pMgmt->bInTIMWake == TRUE) { - pMgmt->bInTIMWake = FALSE; + if (pMgmt->bInTIMWake == true) { + pMgmt->bInTIMWake = false; } } } @@ -735,7 +673,7 @@ RXbBulkInProcessData ( // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps if (pDevice->bDiversityEnable && (FrameSize>50) && (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && - (pDevice->bLinkPass == TRUE)) { + (pDevice->bLinkPass == true)) { BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); } @@ -764,7 +702,7 @@ RXbBulkInProcessData ( // ----------------------------------------------- - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == TRUE)){ + if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == true)){ BYTE abyMacHdr[24]; // Only 802.1x packet incoming allowed @@ -779,7 +717,7 @@ RXbBulkInProcessData ( if (wEtherType == ETH_P_PAE) { skb->dev = pDevice->apdev; - if (bIsWEP == TRUE) { + if (bIsWEP == true) { // strip IV header(8) memcpy(&abyMacHdr[0], (skb->data + 8), 24); memcpy((skb->data + 8 + cbIVOffset), &abyMacHdr[0], 24); @@ -793,12 +731,12 @@ RXbBulkInProcessData ( skb->protocol = htons(ETH_P_802_2); memset(skb->cb, 0, sizeof(skb->cb)); netif_rx(skb); - return TRUE; + return true; } // check if 802.1x authorized if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED)) - return FALSE; + return false; } @@ -852,9 +790,9 @@ RXbBulkInProcessData ( if ((cpu_to_le32(*pdwMIC_L) != dwLocalMIC_L) || (cpu_to_le32(*pdwMIC_R) != dwLocalMIC_R) || - (pDevice->bRxMICFail == TRUE)) { + (pDevice->bRxMICFail == true)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC comparison is fail!\n"); - pDevice->bRxMICFail = FALSE; + pDevice->bRxMICFail = false; //pDevice->s802_11Counter.TKIPLocalMICFailures.QuadPart++; pDevice->s802_11Counter.TKIPLocalMICFailures++; if (bDeFragRx) { @@ -864,7 +802,7 @@ RXbBulkInProcessData ( } } //send event to wpa_supplicant - //if(pDevice->bWPASuppWextEnabled == TRUE) + //if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; struct iw_michaelmicfailure ev; @@ -888,7 +826,7 @@ RXbBulkInProcessData ( } - return FALSE; + return false; } } @@ -910,11 +848,11 @@ RXbBulkInProcessData ( RSC = dwRxTSC47_16; RSC <<= 16; RSC += wRxTSC15_0; - memcpy(&(pKey->KeyRSC), &RSC, sizeof(QWORD)); + memcpy(&(pKey->KeyRSC), &RSC, sizeof(u64)); - if ( (pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) && - (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) { - // check RSC + if (pDevice->vnt_mgmt.eCurrMode == WMAC_MODE_ESS_STA && + pDevice->vnt_mgmt.eCurrState == WMAC_STATE_ASSOC) { + /* check RSC */ if ( (wRxTSC15_0 < wLocalTSC15_0) && (dwRxTSC47_16 <= dwLocalTSC47_16) && !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) { @@ -932,7 +870,7 @@ RXbBulkInProcessData ( pDevice->dev->name); } } - return FALSE; + return false; } } } @@ -945,7 +883,7 @@ RXbBulkInProcessData ( // Null data, framesize = 12 if (FrameSize < 12) - return FALSE; + return false; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { if (s_bAPModeRxData(pDevice, @@ -954,7 +892,7 @@ RXbBulkInProcessData ( cbHeaderOffset, iSANodeIndex, iDANodeIndex - ) == FALSE) { + ) == false) { if (bDeFragRx) { if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { @@ -962,7 +900,7 @@ RXbBulkInProcessData ( pDevice->dev->name); } } - return FALSE; + return false; } } @@ -980,22 +918,18 @@ RXbBulkInProcessData ( DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n", pDevice->dev->name); } - return FALSE; + return false; } - return TRUE; + return true; } - -static BOOL s_bAPModeRxCtl ( - PSDevice pDevice, - PBYTE pbyFrame, - signed int iSANodeIndex - ) +static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, + s32 iSANodeIndex) { - PS802_11Header p802_11Header; - CMD_STATUS Status; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PS802_11Header p802_11Header; + CMD_STATUS Status; if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { @@ -1017,7 +951,7 @@ static BOOL s_bAPModeRxCtl ( &Status ); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n"); - return TRUE; + return true; } if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) { // send deassoc notification @@ -1029,13 +963,13 @@ static BOOL s_bAPModeRxCtl ( &Status ); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n"); - return TRUE; + return true; } if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) { // delcare received ps-poll event if (IS_CTL_PSPOLL(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE; + pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; bScheduleCommand((void *) pDevice, WLAN_CMD_RX_PSPOLL, NULL); @@ -1045,8 +979,8 @@ static BOOL s_bAPModeRxCtl ( // check Data PS state // if PW bit off, send out all PS bufferring packets. if (!IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE; + pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; + pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; bScheduleCommand((void *) pDevice, WLAN_CMD_RX_PSPOLL, NULL); @@ -1056,15 +990,15 @@ static BOOL s_bAPModeRxCtl ( } else { if (IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = TRUE; + pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true; // Once if STA in PS state, enable multicast bufferring - pMgmt->sNodeDBTable[0].bPSEnable = TRUE; + pMgmt->sNodeDBTable[0].bPSEnable = true; } else { // clear all pending PS frame. if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE; + pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; + pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; bScheduleCommand((void *) pDevice, WLAN_CMD_RX_PSPOLL, NULL); @@ -1089,32 +1023,24 @@ static BOOL s_bAPModeRxCtl ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%pM\n", p802_11Header->abyAddr1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl ); - return TRUE; + return true; } } } - return FALSE; + return false; } -static BOOL s_bHandleRxEncryption ( - PSDevice pDevice, - PBYTE pbyFrame, - unsigned int FrameSize, - PBYTE pbyRsr, - PBYTE pbyNewRsr, - PSKeyItem * pKeyOut, - int * pbExtIV, - PWORD pwRxTSC15_0, - PDWORD pdwRxTSC47_16 - ) +static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, + u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, + s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) { - unsigned int PayloadLen = FrameSize; - PBYTE pbyIV; - BYTE byKeyIdx; - PSKeyItem pKey = NULL; - BYTE byDecMode = KEY_CTL_WEP; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 PayloadLen = FrameSize; + u8 *pbyIV; + u8 byKeyIdx; + PSKeyItem pKey = NULL; + u8 byDecMode = KEY_CTL_WEP; *pwRxTSC15_0 = 0; @@ -1139,7 +1065,7 @@ static BOOL s_bHandleRxEncryption ( (pMgmt->byCSSPK != KEY_CTL_NONE)) { // unicast pkt use pairwise key DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt\n"); - if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == TRUE) { + if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == true) { if (pMgmt->byCSSPK == KEY_CTL_TKIP) byDecMode = KEY_CTL_TKIP; else if (pMgmt->byCSSPK == KEY_CTL_CCMP) @@ -1173,24 +1099,24 @@ static BOOL s_bHandleRxEncryption ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey == NULL\n"); if (byDecMode == KEY_CTL_WEP) { // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass == TRUE) { + } else if (pDevice->bLinkPass == true) { // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; } - return FALSE; + return false; } if (byDecMode != pKey->byCipherSuite) { if (byDecMode == KEY_CTL_WEP) { // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass == TRUE) { + } else if (pDevice->bLinkPass == true) { // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; } *pKeyOut = NULL; - return FALSE; + return false; } if (byDecMode == KEY_CTL_WEP) { // handle WEP if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(&pKey->pvKeyTable))->bSoftWEP == TRUE)) { + (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true)) { // Software WEP // 1. 3253A // 2. WEP 256 @@ -1238,35 +1164,23 @@ static BOOL s_bHandleRxEncryption ( }// end of TKIP/AES if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = TRUE; - return TRUE; + *pbExtIV = true; + return true; } - -static BOOL s_bHostWepRxEncryption ( - PSDevice pDevice, - PBYTE pbyFrame, - unsigned int FrameSize, - PBYTE pbyRsr, - BOOL bOnFly, - PSKeyItem pKey, - PBYTE pbyNewRsr, - int * pbExtIV, - PWORD pwRxTSC15_0, - PDWORD pdwRxTSC47_16 - ) +static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, + u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, + s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int PayloadLen = FrameSize; - PBYTE pbyIV; - BYTE byKeyIdx; - BYTE byDecMode = KEY_CTL_WEP; - PS802_11Header pMACHeader; - - + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PS802_11Header pMACHeader; + u32 PayloadLen = FrameSize; + u8 *pbyIV; + u8 byKeyIdx; + u8 byDecMode = KEY_CTL_WEP; - *pwRxTSC15_0 = 0; - *pdwRxTSC47_16 = 0; + *pwRxTSC15_0 = 0; + *pdwRxTSC47_16 = 0; pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) && @@ -1289,18 +1203,18 @@ static BOOL s_bHostWepRxEncryption ( if (byDecMode != pKey->byCipherSuite) { if (byDecMode == KEY_CTL_WEP) { // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass == TRUE) { + } else if (pDevice->bLinkPass == true) { // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; } - return FALSE; + return false; } if (byDecMode == KEY_CTL_WEP) { // handle WEP DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP\n"); if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(&pKey->pvKeyTable))->bSoftWEP == TRUE) || - (bOnFly == FALSE)) { + (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) || + (bOnFly == false)) { // Software WEP // 1. 3253A // 2. WEP 256 @@ -1333,7 +1247,7 @@ static BOOL s_bHostWepRxEncryption ( if (byDecMode == KEY_CTL_TKIP) { - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == FALSE)) { + if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == false)) { // Software TKIP // 1. 3253 A // 2. NotOnFly @@ -1353,7 +1267,7 @@ static BOOL s_bHostWepRxEncryption ( } if (byDecMode == KEY_CTL_CCMP) { - if (bOnFly == FALSE) { + if (bOnFly == false) { // Software CCMP // NotOnFly DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n"); @@ -1369,33 +1283,23 @@ static BOOL s_bHostWepRxEncryption ( }// end of TKIP/AES if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = TRUE; - return TRUE; + *pbExtIV = true; + return true; } - - -static BOOL s_bAPModeRxData ( - PSDevice pDevice, - struct sk_buff *skb, - unsigned int FrameSize, - unsigned int cbHeaderOffset, - signed int iSANodeIndex, - signed int iDANodeIndex - ) - +static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, + u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BOOL bRelayAndForward = FALSE; - BOOL bRelayOnly = FALSE; - BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - WORD wAID; - + struct sk_buff *skbcpy; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int bRelayAndForward = false; + int bRelayOnly = false; + u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; + u16 wAID; - struct sk_buff* skbcpy = NULL; if (FrameSize > CB_MAX_BUF_SIZE) - return FALSE; + return false; // check DA if (is_multicast_ether_addr((PBYTE)(skb->data+cbHeaderOffset))) { if (pMgmt->sNodeDBTable[0].bPSEnable) { @@ -1417,7 +1321,7 @@ static BOOL s_bAPModeRxData ( } } else { - bRelayAndForward = TRUE; + bRelayAndForward = true; } } else { @@ -1437,10 +1341,10 @@ static BOOL s_bAPModeRxData ( pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n", iDANodeIndex, (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]); - return TRUE; + return true; } else { - bRelayOnly = TRUE; + bRelayOnly = true; } } } @@ -1457,23 +1361,22 @@ static BOOL s_bAPModeRxData ( } if (bRelayOnly) - return FALSE; + return false; } // none associate, don't forward if (pDevice->uAssocCount == 0) - return FALSE; + return false; - return TRUE; + return true; } -void RXvWorkItem(void *Context) +void RXvWorkItem(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) Context; - int ntStatus; - PRCB pRCB=NULL; + int ntStatus; + PRCB pRCB = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n"); spin_lock_irq(&pDevice->lock); @@ -1487,19 +1390,15 @@ void RXvWorkItem(void *Context) DequeueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList); ntStatus = PIPEnsBulkInUsbRead(pDevice, pRCB); } - pDevice->bIsRxWorkItemQueued = FALSE; + pDevice->bIsRxWorkItemQueued = false; spin_unlock_irq(&pDevice->lock); } -void -RXvFreeRCB( - PRCB pRCB, - BOOL bReAllocSkb - ) +void RXvFreeRCB(PRCB pRCB, int bReAllocSkb) { - PSDevice pDevice = (PSDevice)pRCB->pDevice; + struct vnt_private *pDevice = pRCB->pDevice; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->RXvFreeRCB\n"); @@ -1507,12 +1406,12 @@ RXvFreeRCB( ASSERT(!pRCB->Ref); // should be 0 ASSERT(pRCB->pDevice); // shouldn't be NULL - if (bReAllocSkb == FALSE) { + if (bReAllocSkb == false) { kfree_skb(pRCB->skb); - bReAllocSkb = TRUE; + bReAllocSkb = true; } - if (bReAllocSkb == TRUE) { + if (bReAllocSkb == true) { pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); // todo error handling if (pRCB->skb == NULL) { @@ -1529,21 +1428,20 @@ RXvFreeRCB( if ((pDevice->Flags & fMP_POST_READS) && MP_IS_READY(pDevice) && - (pDevice->bIsRxWorkItemQueued == FALSE) ) { + (pDevice->bIsRxWorkItemQueued == false) ) { - pDevice->bIsRxWorkItemQueued = TRUE; + pDevice->bIsRxWorkItemQueued = true; tasklet_schedule(&pDevice->ReadWorkItem); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----RXFreeRCB %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList); } -void RXvMngWorkItem(void *Context) +void RXvMngWorkItem(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice) Context; - PRCB pRCB=NULL; - PSRxMgmtPacket pRxPacket; - BOOL bReAllocSkb = FALSE; + PRCB pRCB = NULL; + struct vnt_rx_mgmt *pRxPacket; + int bReAllocSkb = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n"); @@ -1558,7 +1456,7 @@ void RXvMngWorkItem(void *Context) } ASSERT(pRCB);// cannot be NULL pRxPacket = &(pRCB->sMngPacket); - vMgrRxManagePacket((void *) pDevice, &(pDevice->sMgmtObj), pRxPacket); + vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket); pRCB->Ref--; if(pRCB->Ref == 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList); @@ -1568,7 +1466,7 @@ void RXvMngWorkItem(void *Context) } } - pDevice->bIsRxMngWorkItemQueued = FALSE; + pDevice->bIsRxMngWorkItemQueued = false; spin_unlock_irq(&pDevice->lock); } diff --git a/drivers/staging/vt6656/dpc.h b/drivers/staging/vt6656/dpc.h index d4fca43..786c523 100644 --- a/drivers/staging/vt6656/dpc.h +++ b/drivers/staging/vt6656/dpc.h @@ -45,17 +45,9 @@ void RXvWorkItem(void *Context); void RXvMngWorkItem(void *Context); -void -RXvFreeRCB( - PRCB pRCB, - BOOL bReAllocSkb - ); - -BOOL -RXbBulkInProcessData( - PSDevice pDevice, - PRCB pRCB, - unsigned long BytesToIndicate - ); +void RXvFreeRCB(PRCB pRCB, int bReAllocSkb); + +int RXbBulkInProcessData(struct vnt_private *, PRCB pRCB, + unsigned long BytesToIndicate); #endif /* __RXTX_H__ */ diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 8831ea0..4371a77 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -56,16 +56,13 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Export Functions --------------------------*/ -BOOL -FIRMWAREbDownload( - PSDevice pDevice - ) +int FIRMWAREbDownload(struct vnt_private *pDevice) { struct device *dev = &pDevice->usb->dev; const struct firmware *fw; int NdisStatus; void *pBuffer = NULL; - BOOL result = FALSE; + bool result = false; u16 wLength; int ii, rc; @@ -102,7 +99,7 @@ FIRMWAREbDownload( goto free_fw; } - result = TRUE; + result = true; free_fw: release_firmware(fw); @@ -114,12 +111,9 @@ out: } MODULE_FIRMWARE(FIRMWARE_NAME); -BOOL -FIRMWAREbBrach2Sram( - PSDevice pDevice - ) +int FIRMWAREbBrach2Sram(struct vnt_private *pDevice) { - int NdisStatus; + int NdisStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n"); @@ -132,17 +126,14 @@ FIRMWAREbBrach2Sram( ); if (NdisStatus != STATUS_SUCCESS) { - return (FALSE); + return (false); } else { - return (TRUE); + return (true); } } -BOOL -FIRMWAREbCheckVersion( - PSDevice pDevice - ) +int FIRMWAREbCheckVersion(struct vnt_private *pDevice) { int ntStatus; @@ -156,17 +147,17 @@ FIRMWAREbCheckVersion( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n", pDevice->wFirmwareVersion); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Invalid.\n"); - return FALSE; + return false; } if (pDevice->wFirmwareVersion == 0xFFFF) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"In Loader.\n"); - return FALSE; + return false; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n", pDevice->wFirmwareVersion); if (pDevice->wFirmwareVersion < FIRMWARE_VERSION) { // branch to loader for download new firmware FIRMWAREbBrach2Sram(pDevice); - return FALSE; + return false; } - return TRUE; + return true; } diff --git a/drivers/staging/vt6656/firmware.h b/drivers/staging/vt6656/firmware.h index b2f5b58..ebab3a6 100644 --- a/drivers/staging/vt6656/firmware.h +++ b/drivers/staging/vt6656/firmware.h @@ -41,19 +41,8 @@ /*--------------------- Export Functions --------------------------*/ -BOOL -FIRMWAREbDownload( - PSDevice pDevice - ); - -BOOL -FIRMWAREbBrach2Sram( - PSDevice pDevice - ); - -BOOL -FIRMWAREbCheckVersion( - PSDevice pDevice - ); +int FIRMWAREbDownload(struct vnt_private *); +int FIRMWAREbBrach2Sram(struct vnt_private *); +int FIRMWAREbCheckVersion(struct vnt_private *); #endif /* __FIRMWARE_H__ */ diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index 26a7d0e..bc5e9da 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c @@ -60,13 +60,13 @@ static int msglevel =MSG_LEVEL_INFO; * */ -static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked) +static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked) { - PSDevice apdev_priv; + struct vnt_private *apdev_priv; struct net_device *dev = pDevice->dev; int ret; const struct net_device_ops apdev_netdev_ops = { - .ndo_start_xmit = pDevice->tx_80211, + .ndo_start_xmit = pDevice->tx_80211, }; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name); @@ -120,7 +120,7 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked) * */ -static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked) +static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name); @@ -135,9 +135,9 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked) } kfree(pDevice->apdev); pDevice->apdev = NULL; - pDevice->bEnable8021x = FALSE; - pDevice->bEnableHostWEP = FALSE; - pDevice->bEncryptionEnable = FALSE; + pDevice->bEnable8021x = false; + pDevice->bEnableHostWEP = false; + pDevice->bEncryptionEnable = false; return 0; } @@ -157,7 +157,8 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked) * */ -int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) +int vt6656_hostap_set_hostapd(struct vnt_private *pDevice, + int val, int rtnl_locked) { if (val < 0 || val > 1) return -EINVAL; @@ -187,8 +188,8 @@ int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) * Return Value: * */ -static int hostap_remove_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) +static int hostap_remove_sta(struct vnt_private *pDevice, + struct viawget_hostapd_param *param) { unsigned int uNodeIndex; @@ -215,22 +216,21 @@ static int hostap_remove_sta(PSDevice pDevice, * Return Value: * */ -static int hostap_add_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) +static int hostap_add_sta(struct vnt_private *pDevice, + struct viawget_hostapd_param *param) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; unsigned int uNodeIndex; + if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) + BSSvCreateOneNode(pDevice, &uNodeIndex); - if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex); - } memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN); pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; // TODO listenInterval // pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1; - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = FALSE; + pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false; pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates; // set max tx rate @@ -275,10 +275,10 @@ static int hostap_add_sta(PSDevice pDevice, * */ -static int hostap_get_info_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) +static int hostap_get_info_sta(struct vnt_private *pDevice, + struct viawget_hostapd_param *param) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; unsigned int uNodeIndex; if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { @@ -308,10 +308,10 @@ static int hostap_get_info_sta(PSDevice pDevice, * Return Value: * */ -static int hostap_set_flags_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) +static int hostap_set_flags_sta(struct vnt_private *pDevice, + struct viawget_hostapd_param *param) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; unsigned int uNodeIndex; if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { @@ -342,10 +342,10 @@ static int hostap_set_flags_sta(PSDevice pDevice, * Return Value: * */ -static int hostap_set_generic_element(PSDevice pDevice, +static int hostap_set_generic_element(struct vnt_private *pDevice, struct viawget_hostapd_param *param) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; @@ -388,7 +388,7 @@ static int hostap_set_generic_element(PSDevice pDevice, * */ -static void hostap_flush_sta(PSDevice pDevice) +static void hostap_flush_sta(struct vnt_private *pDevice) { // reserved node index =0 for multicast node. BSSvClearNodeDBTable(pDevice, 1); @@ -410,21 +410,20 @@ static void hostap_flush_sta(PSDevice pDevice) * Return Value: * */ -static int hostap_set_encryption(PSDevice pDevice, - struct viawget_hostapd_param *param, - int param_len) +static int hostap_set_encryption(struct vnt_private *pDevice, + struct viawget_hostapd_param *param, int param_len) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DWORD dwKeyIndex = 0; - BYTE abyKey[MAX_KEY_LEN]; - BYTE abySeq[MAX_KEY_LEN]; - NDIS_802_11_KEY_RSC KeyRSC; - BYTE byKeyDecMode = KEY_CTL_WEP; - int ret = 0; - int iNodeIndex = -1; - int ii; - BOOL bKeyTableFull = FALSE; - WORD wKeyCtl = 0; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 dwKeyIndex = 0; + u8 abyKey[MAX_KEY_LEN]; + u8 abySeq[MAX_KEY_LEN]; + NDIS_802_11_KEY_RSC KeyRSC; + u8 byKeyDecMode = KEY_CTL_WEP; + int ret = 0; + s32 iNodeIndex = -1; + int ii; + int bKeyTableFull = false; + u16 wKeyCtl = 0; param->u.crypt.err = 0; @@ -445,7 +444,7 @@ static int hostap_set_encryption(PSDevice pDevice, iNodeIndex = 0; } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == FALSE) { + if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); return -EINVAL; @@ -456,15 +455,15 @@ static int hostap_set_encryption(PSDevice pDevice, if (param->u.crypt.alg == WPA_ALG_NONE) { - if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == TRUE) { + if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == true) { if (KeybRemoveKey( pDevice, &(pDevice->sKey), param->sta_addr, pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex - ) == FALSE) { + ) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybRemoveKey fail \n"); } - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; } pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0; pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0; @@ -493,13 +492,13 @@ static int hostap_set_encryption(PSDevice pDevice, dwKeyIndex = (DWORD)(param->u.crypt.idx); if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) { pDevice->byKeyIndex = (BYTE)dwKeyIndex; - pDevice->bTransmitKey = TRUE; + pDevice->bTransmitKey = true; dwKeyIndex |= (1 << 31); } if (param->u.crypt.alg == WPA_ALG_WEP) { - if ((pDevice->bEnable8021x == FALSE) || (iNodeIndex == 0)) { + if ((pDevice->bEnable8021x == false) || (iNodeIndex == 0)) { KeybSetDefaultKey( pDevice, &(pDevice->sKey), dwKeyIndex & ~(BIT30 | USE_KEYRSC), @@ -512,27 +511,25 @@ static int hostap_set_encryption(PSDevice pDevice, } else { // 8021x enable, individual key dwKeyIndex |= (1 << 30); // set pairwise key - if (KeybSetKey(pDevice, - &(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex & ~(USE_KEYRSC), - param->u.crypt.key_len, - (PQWORD) &(KeyRSC), - (PBYTE)abyKey, - KEY_CTL_WEP - ) == TRUE) { + if (KeybSetKey(pDevice, &(pDevice->sKey), + ¶m->sta_addr[0], + dwKeyIndex & ~(USE_KEYRSC), + param->u.crypt.key_len, + &KeyRSC, (PBYTE)abyKey, + KEY_CTL_WEP + ) == true) { - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; } else { // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE; - bKeyTableFull = TRUE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; + bKeyTableFull = true; } } pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = TRUE; + pDevice->bEncryptionEnable = true; pMgmt->byCSSPK = KEY_CTL_WEP; pMgmt->byCSSGK = KEY_CTL_WEP; pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP; @@ -574,11 +571,11 @@ static int hostap_set_encryption(PSDevice pDevice, &(pDevice->sKey), dwKeyIndex, param->u.crypt.key_len, - (PQWORD) &(KeyRSC), + &KeyRSC, abyKey, byKeyDecMode ); - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; } else { dwKeyIndex |= (1 << 30); // set pairwise key @@ -587,23 +584,23 @@ static int hostap_set_encryption(PSDevice pDevice, ¶m->sta_addr[0], dwKeyIndex, param->u.crypt.key_len, - (PQWORD) &(KeyRSC), + &KeyRSC, (PBYTE)abyKey, byKeyDecMode - ) == TRUE) { + ) == true) { - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; } else { // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE; - bKeyTableFull = TRUE; + pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; + bKeyTableFull = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Key Table Full\n"); } } - if (bKeyTableFull == TRUE) { + if (bKeyTableFull == true) { wKeyCtl &= 0x7F00; // clear all key control filed wKeyCtl |= (byKeyDecMode << 4); wKeyCtl |= (byKeyDecMode); @@ -625,7 +622,7 @@ static int hostap_set_encryption(PSDevice pDevice, ); // set wep key - pDevice->bEncryptionEnable = TRUE; + pDevice->bEncryptionEnable = true; pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode; pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; @@ -649,14 +646,14 @@ static int hostap_set_encryption(PSDevice pDevice, * Return Value: * */ -static int hostap_get_encryption(PSDevice pDevice, +static int hostap_get_encryption(struct vnt_private *pDevice, struct viawget_hostapd_param *param, int param_len) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ret = 0; - int ii; - int iNodeIndex =0; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ret = 0; + int ii; + s32 iNodeIndex = 0; param->u.crypt.err = 0; @@ -664,7 +661,7 @@ static int hostap_get_encryption(PSDevice pDevice, if (is_broadcast_ether_addr(param->sta_addr)) { iNodeIndex = 0; } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == FALSE) { + if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); return -EINVAL; @@ -694,7 +691,7 @@ static int hostap_get_encryption(PSDevice pDevice, * */ -int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p) +int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) { struct viawget_hostapd_param *param; int ret = 0; diff --git a/drivers/staging/vt6656/hostap.h b/drivers/staging/vt6656/hostap.h index b660aee..f5656cd 100644 --- a/drivers/staging/vt6656/hostap.h +++ b/drivers/staging/vt6656/hostap.h @@ -61,7 +61,7 @@ #define ARPHRD_IEEE80211 801 #endif -int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked); -int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p); +int vt6656_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked); +int vt6656_hostap_ioctl(struct vnt_private *, struct iw_point *p); #endif /* __HOSTAP_H__ */ diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index bba31ca..51990bd 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -75,23 +75,22 @@ static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */ * if we've gotten no data * -*/ -void INTvWorkItem(void *Context) +void INTvWorkItem(struct vnt_private *pDevice) { - PSDevice pDevice = Context; int ntStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); spin_lock_irq(&pDevice->lock); - if (pDevice->fKillEventPollingThread != TRUE) + if (pDevice->fKillEventPollingThread != true) ntStatus = PIPEnsInterruptRead(pDevice); spin_unlock_irq(&pDevice->lock); } -void INTnsProcessData(PSDevice pDevice) +void INTnsProcessData(struct vnt_private *pDevice) { PSINTData pINTData; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct net_device_stats *pStats = &pDevice->stats; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); @@ -147,12 +146,12 @@ void INTnsProcessData(PSDevice pDevice) if (pMgmt->byDTIMCount > 0) { pMgmt->byDTIMCount--; pMgmt->sNodeDBTable[0].bRxPSPoll = - FALSE; + false; } else if (pMgmt->byDTIMCount == 0) { /* check if multicast tx buffering */ pMgmt->byDTIMCount = pMgmt->byDTIMPeriod-1; - pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE; + pMgmt->sNodeDBTable[0].bRxPSPoll = true; if (pMgmt->sNodeDBTable[0].bPSEnable) bScheduleCommand((void *) pDevice, WLAN_CMD_RX_PSPOLL, @@ -162,9 +161,9 @@ void INTnsProcessData(PSDevice pDevice) WLAN_CMD_BECON_SEND, NULL); } /* if (pDevice->eOPMode == OP_MODE_AP) */ - pDevice->bBeaconSent = TRUE; + pDevice->bBeaconSent = true; } else { - pDevice->bBeaconSent = FALSE; + pDevice->bBeaconSent = false; } if (pINTData->byISR0 & ISR_TBTT) { if (pDevice->bEnablePSMode) @@ -179,8 +178,7 @@ void INTnsProcessData(PSDevice pDevice) NULL); } } - LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF; - HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF; + pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF); /*DBG_PRN_GRP01(("ISR0 = %02x , LoTsf = %08x, HiTsf = %08x\n", @@ -204,7 +202,7 @@ void INTnsProcessData(PSDevice pDevice) WLAN_CMD_RADIO, NULL); pDevice->intBuf.uDataLen = 0; - pDevice->intBuf.bInUse = FALSE; + pDevice->intBuf.bInUse = false; pStats->tx_packets = pDevice->scStatistic.ullTsrOK; pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes + diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index e0d2b07..27c725f 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -47,8 +47,7 @@ typedef struct tagSINTData { BYTE byTSR3; BYTE byPkt3; WORD wTime3; - u32 dwLoTSF; - u32 dwHiTSF; + u64 qwTSF; BYTE byISR0; BYTE byISR1; BYTE byRTSSuccess; @@ -65,7 +64,7 @@ SINTData, *PSINTData; /*--------------------- Export Functions --------------------------*/ -void INTvWorkItem(void *Context); -void INTnsProcessData(PSDevice pDevice); +void INTvWorkItem(struct vnt_private *); +void INTnsProcessData(struct vnt_private *); #endif /* __INT_H__ */ diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h index ae6e2d2..c354a77 100644 --- a/drivers/staging/vt6656/iocmd.h +++ b/drivers/staging/vt6656/iocmd.h @@ -122,8 +122,8 @@ typedef struct tagSCmdBSSJoin { u16 wBBPType; u8 ssid[SSID_MAXLEN + 2]; u32 uChannel; - BOOL bPSEnable; - BOOL bShareKeyAuth; + bool bPSEnable; + bool bShareKeyAuth; } __packed SCmdBSSJoin, *PSCmdBSSJoin; @@ -133,7 +133,7 @@ typedef struct tagSCmdBSSJoin { typedef struct tagSCmdZoneTypeSet { - BOOL bWrite; + bool bWrite; WZONETYPE ZoneType; } __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet; @@ -143,7 +143,7 @@ typedef struct tagSWPAResult { u8 proto; u8 key_mgmt; u8 eap_type; - BOOL authenticated; + bool authenticated; } __packed SWPAResult, *PSWPAResult; typedef struct tagSCmdStartAP { @@ -153,17 +153,17 @@ typedef struct tagSCmdStartAP { u8 ssid[SSID_MAXLEN + 2]; u32 uChannel; u32 uBeaconInt; - BOOL bShareKeyAuth; + bool bShareKeyAuth; u8 byBasicRate; } __packed SCmdStartAP, *PSCmdStartAP; typedef struct tagSCmdSetWEP { - BOOL bEnableWep; + bool bEnableWep; u8 byKeyIndex; u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; - BOOL bWepKeyAvailable[WEP_NKEYS]; + bool bWepKeyAvailable[WEP_NKEYS]; u32 auWepKeyLength[WEP_NKEYS]; } __packed SCmdSetWEP, *PSCmdSetWEP; @@ -176,7 +176,7 @@ typedef struct tagSBSSIDItem { u16 wBeaconInterval; u16 wCapInfo; u8 byNetType; - BOOL bWEPOn; + bool bWEPOn; u32 uRSSI; } __packed SBSSIDItem; @@ -197,12 +197,12 @@ typedef struct tagSNodeItem { u16 wInActiveCount; u16 wEnQueueCnt; u16 wFlags; - BOOL bPWBitOn; + bool bPWBitOn; u8 byKeyIndex; u16 wWepKeyLength; u8 abyWepKey[WEP_KEYMAXLEN]; // Auto rate fallback vars - BOOL bIsInFallback; + bool bIsInFallback; u32 uTxFailures; u32 uTxAttempts; u16 wFailureRatio; @@ -220,7 +220,7 @@ typedef struct tagSNodeList { typedef struct tagSCmdLinkStatus { - BOOL bLink; + bool bLink; u16 wBSSType; u8 byState; u8 abyBSSID[BSSID_LEN]; diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 52fce69..69971f3 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -55,7 +55,7 @@ static int msglevel = MSG_LEVEL_INFO; struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); long ldBm; pDevice->wstats.status = pDevice->eOPMode; @@ -91,9 +91,9 @@ int iwctl_giwname(struct net_device *dev, struct iw_request_info *info, int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_point *wrq = &wrqu->data; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_scan_req *req = (struct iw_scan_req *)extra; BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; PWLAN_IE_SSID pItemSSID = NULL; @@ -169,8 +169,8 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, int ii; int jj; int kk; - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; PKnownBSS pBSS; PWLAN_IE_SSID pItemSSID; PWLAN_IE_SUPP_RATES pSuppRates; @@ -309,7 +309,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_freq *wrq = &wrqu->freq; int rc = 0; @@ -348,9 +348,9 @@ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info, int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_freq *wrq = &wrqu->freq; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ\n"); @@ -379,9 +379,9 @@ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info, int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); __u32 *wmode = &wrqu->mode; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; int rc = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n"); @@ -400,7 +400,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = TRUE; + pDevice->bCommit = true; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n"); break; @@ -409,7 +409,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) { pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = TRUE; + pDevice->bCommit = true; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n"); break; @@ -422,7 +422,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { pMgmt->eConfigMode = WMAC_CONFIG_AP; if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = TRUE; + pDevice->bCommit = true; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n"); break; @@ -455,7 +455,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL); } else { - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; pMgmt->eCurrState = WMAC_STATE_IDLE; memset(pMgmt->abyCurrBSSID, 0, 6); } @@ -479,7 +479,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, spin_unlock_irq(&pDevice->lock); } - pDevice->bCommit = FALSE; + pDevice->bCommit = false; } @@ -492,9 +492,9 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, int iwctl_giwmode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); __u32 *wmode = &wrqu->mode; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE\n"); @@ -631,9 +631,9 @@ int iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct sockaddr *wrq = &wrqu->ap_addr; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; int rc = 0; BYTE ZeroBSSID[WLAN_BSSID_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -672,7 +672,7 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, } if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = TRUE; + pDevice->bCommit = true; } return rc; } @@ -683,9 +683,9 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct sockaddr *wrq = &wrqu->ap_addr; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP\n"); @@ -694,7 +694,7 @@ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); - if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) + if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) memset(wrq->sa_data, 0, 6); if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) @@ -713,8 +713,8 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq = &wrqu->data; struct sockaddr *sock; struct iw_quality *qual; - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &pDevice->sMgmtObj; + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; PKnownBSS pBSS = &pMgmt->sBSSList[0]; int ii; int jj; @@ -771,9 +771,9 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info, int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_point *wrq = &wrqu->essid; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; PWLAN_IE_SSID pItemSSID; if (pMgmt == NULL) @@ -784,7 +784,7 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n"); - pDevice->fWPA_Authened = FALSE; + pDevice->fWPA_Authened = false; // Check if we asked for `any' if (wrq->flags == 0) { // Just send an empty SSID list @@ -816,7 +816,7 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, // Wext wil order another command of siwap to link // with desired AP, so here need not associate?? - if (pDevice->bWPASuppWextEnabled == TRUE) { + if (pDevice->bWPASuppWextEnabled == true) { /*******search if in hidden ssid mode ****/ PKnownBSS pCurr = NULL; BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; @@ -867,7 +867,7 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, } if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = TRUE; + pDevice->bCommit = true; return 0; } @@ -878,9 +878,9 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_point *wrq = &wrqu->essid; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; PWLAN_IE_SSID pItemSSID; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID\n"); @@ -908,7 +908,7 @@ int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->bitrate; int rc = 0; u8 brate = 0; @@ -965,7 +965,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, if (wrq->fixed != 0) { // Fixed mode // One rate, fixed - pDevice->bFixRate = TRUE; + pDevice->bFixRate = true; if ((pDevice->byBBType == BB_TYPE_11B) && (brate > 3)) { pDevice->uConnectionRate = 3; } else { @@ -973,7 +973,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate); } } else { - pDevice->bFixRate = FALSE; + pDevice->bFixRate = false; pDevice->uConnectionRate = 13; } @@ -986,9 +986,9 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->bitrate; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE\n"); @@ -1024,8 +1024,8 @@ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, brate = abySupportedRates[pDevice->wCurrentRate]; wrq->value = brate * 500000; // If more than one rate, set auto - if (pDevice->bFixRate == TRUE) - wrq->fixed = TRUE; + if (pDevice->bFixRate == true) + wrq->fixed = true; } return 0; @@ -1037,7 +1037,7 @@ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->rts; if ((wrq->value < 0 || wrq->value > 2312) && !wrq->disabled) @@ -1057,7 +1057,7 @@ int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->rts; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS\n"); @@ -1073,7 +1073,7 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->frag; int rc = 0; int fthr = wrq->value; @@ -1097,7 +1097,7 @@ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->frag; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG\n"); @@ -1113,7 +1113,7 @@ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->retry; int rc = 0; @@ -1146,7 +1146,7 @@ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->retry; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY\n"); wrq->disabled = 0; // Can't be disabled @@ -1173,8 +1173,8 @@ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_point *wrq = &wrqu->encoding; u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX); int ii; @@ -1229,8 +1229,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, } pDevice->byKeyIndex = (BYTE)dwKeyIndex; pDevice->uKeyLength = wrq->length; - pDevice->bTransmitKey = TRUE; - pDevice->bEncryptionEnable = TRUE; + pDevice->bTransmitKey = true; + pDevice->bEncryptionEnable = true; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; // Do we want to just set the transmit key index? @@ -1244,8 +1244,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, // Read the flags if (wrq->flags & IW_ENCODE_DISABLED) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n"); - pMgmt->bShareKeyAlgorithm = FALSE; - pDevice->bEncryptionEnable = FALSE; + pMgmt->bShareKeyAlgorithm = false; + pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; if (pDevice->flags & DEVICE_FLAGS_OPENED) { spin_lock_irq(&pDevice->lock); @@ -1256,11 +1256,11 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, } if (wrq->flags & IW_ENCODE_RESTRICTED) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n"); - pMgmt->bShareKeyAlgorithm = TRUE; + pMgmt->bShareKeyAlgorithm = true; } if (wrq->flags & IW_ENCODE_OPEN) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n"); - pMgmt->bShareKeyAlgorithm = FALSE; + pMgmt->bShareKeyAlgorithm = false; } memset(pMgmt->abyDesireBSSID, 0xFF, 6); @@ -1271,8 +1271,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_point *wrq = &wrqu->encoding; char abyKey[WLAN_WEP232_KEYLEN]; @@ -1333,8 +1333,8 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_param *wrq = &wrqu->power; int rc = 0; @@ -1385,8 +1385,8 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_param *wrq = &wrqu->power; int mode = pDevice->ePSMode; @@ -1418,12 +1418,12 @@ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->sens; long ldBm; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n"); - if (pDevice->bLinkPass == TRUE) { + if (pDevice->bLinkPass == true) { RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; } else { @@ -1437,8 +1437,8 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_param *wrq = &wrqu->param; int ret = 0; static int wpa_version = 0; // must be static to save the last value, einsn liu @@ -1508,9 +1508,9 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, case IW_AUTH_80211_AUTH_ALG: PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n", wrq->value); if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM) - pMgmt->bShareKeyAlgorithm = FALSE; + pMgmt->bShareKeyAlgorithm = false; else if (wrq->value == IW_AUTH_ALG_SHARED_KEY) - pMgmt->bShareKeyAlgorithm = TRUE; + pMgmt->bShareKeyAlgorithm = true; break; case IW_AUTH_WPA_ENABLED: break; @@ -1521,11 +1521,11 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, break; case IW_AUTH_PRIVACY_INVOKED: pDevice->bEncryptionEnable = !!wrq->value; - if (pDevice->bEncryptionEnable == FALSE) { + if (pDevice->bEncryptionEnable == false) { wpa_version = 0; pairwise = 0; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - pMgmt->bShareKeyAlgorithm = FALSE; + pMgmt->bShareKeyAlgorithm = false; pMgmt->eAuthenMode = WMAC_AUTH_OPEN; PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n"); } @@ -1547,8 +1547,8 @@ int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info, int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_point *wrq = &wrqu->data; int ret = 0; @@ -1582,8 +1582,8 @@ out: // not completely ...not necessary in wpa_supplicant 0.5.8 int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_point *wrq = &wrqu->data; int ret = 0; int space = wrq->length; @@ -1608,8 +1608,8 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_point *wrq = &wrqu->encoding; struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; struct viawget_wpa_param *param=NULL; @@ -1697,28 +1697,28 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, /****this method is so foolish,but there is no other way??? */ if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { if (param->u.wpa_key.key_index ==0) { - pDevice->bwextstep0 = TRUE; + pDevice->bwextstep0 = true; } - if ((pDevice->bwextstep0 == TRUE) && (param->u.wpa_key.key_index == 1)) { - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = TRUE; + if ((pDevice->bwextstep0 == true) && (param->u.wpa_key.key_index == 1)) { + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = true; } - if ((pDevice->bwextstep1 == TRUE) && (param->u.wpa_key.key_index == 2)) { - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = TRUE; + if ((pDevice->bwextstep1 == true) && (param->u.wpa_key.key_index == 2)) { + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = true; } - if ((pDevice->bwextstep2 == TRUE) && (param->u.wpa_key.key_index == 3)) { - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = TRUE; + if ((pDevice->bwextstep2 == true) && (param->u.wpa_key.key_index == 3)) { + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = true; } } - if (pDevice->bwextstep3 == TRUE) { + if (pDevice->bwextstep3 == true) { PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n"); - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = FALSE; - pDevice->bWPASuppWextEnabled = TRUE; + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = false; + pDevice->bWPASuppWextEnabled = true; memset(pMgmt->abyDesireBSSID, 0xFF, 6); KeyvInitTable(pDevice, &pDevice->sKey); } @@ -1741,8 +1741,8 @@ int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info, int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct iw_mlme *mlme = (struct iw_mlme *)extra; int ret = 0; @@ -1758,7 +1758,7 @@ int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, switch (mlme->cmd){ case IW_MLME_DEAUTH: case IW_MLME_DISASSOC: - if (pDevice->bLinkPass == TRUE) { + if (pDevice->bLinkPass == true) { PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n"); bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index 8c78b86..416175e 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -60,26 +60,25 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Variables --------------------------*/ /*--------------------- Static Functions --------------------------*/ -static void s_vCheckKeyTableValid(void *pDeviceHandler, - PSKeyManagement pTable) +static void s_vCheckKeyTableValid(struct vnt_private *pDevice, + PSKeyManagement pTable) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i; - WORD wLength = 0; - BYTE pbyData[MAX_KEY_TABLE]; + int i; + u16 wLength = 0; + u8 pbyData[MAX_KEY_TABLE]; for (i=0;i<MAX_KEY_TABLE;i++) { - if ((pTable->KeyTable[i].bInUse == TRUE) && - (pTable->KeyTable[i].PairwiseKey.bKeyValid == FALSE) && - (pTable->KeyTable[i].GroupKey[0].bKeyValid == FALSE) && - (pTable->KeyTable[i].GroupKey[1].bKeyValid == FALSE) && - (pTable->KeyTable[i].GroupKey[2].bKeyValid == FALSE) && - (pTable->KeyTable[i].GroupKey[3].bKeyValid == FALSE) + if ((pTable->KeyTable[i].bInUse == true) && + (pTable->KeyTable[i].PairwiseKey.bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[0].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[1].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[2].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[3].bKeyValid == false) ) { - pTable->KeyTable[i].bInUse = FALSE; + pTable->KeyTable[i].bInUse = false; pTable->KeyTable[i].wKeyCtl = 0; - pTable->KeyTable[i].bSoftWEP = FALSE; + pTable->KeyTable[i].bSoftWEP = false; pbyData[wLength++] = (BYTE) i; //MACvDisableKeyEntry(pDevice, i); } @@ -112,27 +111,25 @@ static void s_vCheckKeyTableValid(void *pDeviceHandler, * Return Value: none * */ -void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable) +void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i; - int jj; - BYTE pbyData[MAX_KEY_TABLE+1]; + int i, jj; + u8 pbyData[MAX_KEY_TABLE+1]; spin_lock_irq(&pDevice->lock); for (i=0;i<MAX_KEY_TABLE;i++) { - pTable->KeyTable[i].bInUse = FALSE; - pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; + pTable->KeyTable[i].bInUse = false; + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; pTable->KeyTable[i].PairwiseKey.pvKeyTable = (void *)&pTable->KeyTable[i]; for (jj=0; jj < MAX_GROUP_KEY; jj++) { - pTable->KeyTable[i].GroupKey[jj].bKeyValid = FALSE; + pTable->KeyTable[i].GroupKey[jj].bKeyValid = false; pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (void *) &(pTable->KeyTable[i]); } pTable->KeyTable[i].wKeyCtl = 0; pTable->KeyTable[i].dwGTKeyIndex = 0; - pTable->KeyTable[i].bSoftWEP = FALSE; + pTable->KeyTable[i].bSoftWEP = false; pbyData[i] = (BYTE) i; } pbyData[i] = (BYTE) i; @@ -161,43 +158,43 @@ void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable) * Out: * pKey - Key return * - * Return Value: TRUE if found otherwise FALSE + * Return Value: true if found otherwise false * */ -BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex, - PSKeyItem *pKey) +int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex, + PSKeyItem *pKey) { - int i; + int i; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey()\n"); *pKey = NULL; for (i=0;i<MAX_KEY_TABLE;i++) { - if ((pTable->KeyTable[i].bInUse == TRUE) && + if ((pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if (dwKeyIndex == 0xFFFFFFFF) { - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) { + if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { *pKey = &(pTable->KeyTable[i].PairwiseKey); - return (TRUE); + return (true); } else { - return (FALSE); + return (false); } } else if (dwKeyIndex < MAX_GROUP_KEY) { - if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == TRUE) { + if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) { *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); - return (TRUE); + return (true); } else { - return (FALSE); + return (false); } } else { - return (FALSE); + return (false); } } } - return (FALSE); + return (false); } @@ -215,37 +212,28 @@ BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex, * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -BOOL KeybSetKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ) +int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u8 *pbyBSSID, u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i,j; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; + PSKeyItem pKey; + int i, j, ii; + u32 uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetKey: %X\n", dwKeyIndex); j = (MAX_KEY_TABLE-1); for (i=0;i<(MAX_KEY_TABLE-1);i++) { - if ((pTable->KeyTable[i].bInUse == FALSE) && + if ((pTable->KeyTable[i].bInUse == false) && (j == (MAX_KEY_TABLE-1))) { // found empty table j = i; } - if ((pTable->KeyTable[i].bInUse == TRUE) && + if ((pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { // found table already exist if ((dwKeyIndex & PAIRWISE_KEY) != 0) { @@ -257,7 +245,7 @@ BOOL KeybSetKey( } else { // Group key if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return (FALSE); + return (false); pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); if ((dwKeyIndex & TRANSMIT_KEY) != 0) { // Group transmit key @@ -273,7 +261,7 @@ BOOL KeybSetKey( } pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - pKey->bKeyValid = TRUE; + pKey->bKeyValid = true; pKey->uKeyLength = uKeyLength; pKey->dwKeyIndex = dwKeyIndex; pKey->byCipherSuite = byKeyDecMode; @@ -286,13 +274,11 @@ BOOL KeybSetKey( } MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey); - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } + if ((dwKeyIndex & USE_KEYRSC) == 0) + pKey->KeyRSC = 0; /* RSC set by NIC */ + else + pKey->KeyRSC = *KeyRSC; + pKey->dwTSC47_16 = 0; pKey->wTSC15_0 = 0; @@ -312,12 +298,12 @@ BOOL KeybSetKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ", pKey->dwKeyIndex); - return (TRUE); + return (true); } } if (j < (MAX_KEY_TABLE-1)) { memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN); - pTable->KeyTable[j].bInUse = TRUE; + pTable->KeyTable[j].bInUse = true; if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key pKey = &(pTable->KeyTable[j].PairwiseKey); @@ -327,7 +313,7 @@ BOOL KeybSetKey( } else { // Group key if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return (FALSE); + return (false); pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]); if ((dwKeyIndex & TRANSMIT_KEY) != 0) { // Group transmit key @@ -343,7 +329,7 @@ BOOL KeybSetKey( } pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly - pKey->bKeyValid = TRUE; + pKey->bKeyValid = true; pKey->uKeyLength = uKeyLength; pKey->dwKeyIndex = dwKeyIndex; pKey->byCipherSuite = byKeyDecMode; @@ -356,13 +342,11 @@ BOOL KeybSetKey( } MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey); - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } + if ((dwKeyIndex & USE_KEYRSC) == 0) + pKey->KeyRSC = 0; /* RSC set by NIC */ + else + pKey->KeyRSC = *KeyRSC; + pKey->dwTSC47_16 = 0; pKey->wTSC15_0 = 0; @@ -381,9 +365,9 @@ BOOL KeybSetKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ", pKey->dwKeyIndex); - return (TRUE); + return (true); } - return (FALSE); + return (false); } @@ -398,68 +382,64 @@ BOOL KeybSetKey( * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -BOOL KeybRemoveKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID, - DWORD dwKeyIndex - ) + +int KeybRemoveKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u8 *pbyBSSID, u32 dwKeyIndex) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i; - BOOL bReturnValue = FALSE; + int i; + int bReturnValue = false; if (is_broadcast_ether_addr(pbyBSSID)) { // delete all keys if ((dwKeyIndex & PAIRWISE_KEY) != 0) { for (i=0;i<MAX_KEY_TABLE;i++) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; } - bReturnValue = TRUE; + bReturnValue = true; } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { for (i=0;i<MAX_KEY_TABLE;i++) { - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE; + pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { // remove Group transmit key pTable->KeyTable[i].dwGTKeyIndex = 0; } } - bReturnValue = TRUE; + bReturnValue = true; } else { - bReturnValue = FALSE; + bReturnValue = false; } } else { for (i=0;i<MAX_KEY_TABLE;i++) { - if ( (pTable->KeyTable[i].bInUse == TRUE) && + if ( (pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; - bReturnValue = TRUE; + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; + bReturnValue = true; break; } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE; + pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { // remove Group transmit key pTable->KeyTable[i].dwGTKeyIndex = 0; } - bReturnValue = TRUE; + bReturnValue = true; break; } else { - bReturnValue = FALSE; + bReturnValue = false; break; } - } //pTable->KeyTable[i].bInUse == TRUE + } //pTable->KeyTable[i].bInUse == true } //for - bReturnValue = TRUE; + bReturnValue = true; } s_vCheckKeyTableValid(pDevice,pTable); @@ -479,31 +459,27 @@ BOOL KeybRemoveKey( * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -BOOL KeybRemoveAllKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID - ) +int KeybRemoveAllKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u8 *pbyBSSID) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i,u; + int i, u; for (i=0;i<MAX_KEY_TABLE;i++) { - if ((pTable->KeyTable[i].bInUse == TRUE) && + if ((pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; for (u = 0; u < MAX_GROUP_KEY; u++) - pTable->KeyTable[i].GroupKey[u].bKeyValid = FALSE; + pTable->KeyTable[i].GroupKey[u].bKeyValid = false; pTable->KeyTable[i].dwGTKeyIndex = 0; s_vCheckKeyTableValid(pDevice, pTable); - return (TRUE); + return (true); } } - return (FALSE); + return (false); } /* @@ -515,21 +491,17 @@ BOOL KeybRemoveAllKey( * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -void KeyvRemoveWEPKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex - ) +void KeyvRemoveWEPKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u32 dwKeyIndex) { - PSDevice pDevice = (PSDevice) pDeviceHandler; if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == TRUE) { + if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == true) { if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) { - pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = FALSE; + pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) { // remove Group transmit key pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0; @@ -541,9 +513,8 @@ void KeyvRemoveWEPKey( return; } -void KeyvRemoveAllWEPKey(void *pDeviceHandler, PSKeyManagement pTable) +void KeyvRemoveAllWEPKey(struct vnt_private *pDevice, PSKeyManagement pTable) { - PSDevice pDevice = (PSDevice) pDeviceHandler; int i; for (i = 0; i < MAX_GROUP_KEY; i++) @@ -560,22 +531,23 @@ void KeyvRemoveAllWEPKey(void *pDeviceHandler, PSKeyManagement pTable) * Out: * pKey - Key return * - * Return Value: TRUE if found otherwise FALSE + * Return Value: true if found otherwise false * */ -BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, - PSKeyItem *pKey) +int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType, + PSKeyItem *pKey) { - int i, ii; + int i, ii; + + *pKey = NULL; - *pKey = NULL; for (i = 0; i < MAX_KEY_TABLE; i++) { - if ((pTable->KeyTable[i].bInUse == TRUE) && + if ((pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if (dwKeyType == PAIRWISE_KEY) { - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) { + if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { *pKey = &(pTable->KeyTable[i].PairwiseKey); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); @@ -586,19 +558,19 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - return (TRUE); + return (true); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == FALSE\n"); - return (FALSE); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == false\n"); + return (false); } } // End of Type == PAIRWISE else { if (pTable->KeyTable[i].dwGTKeyIndex == 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n"); - return FALSE; + return false; } - if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == TRUE) { + if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == true) { *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); @@ -610,11 +582,11 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %X\n", pTable->KeyTable[i].dwGTKeyIndex); - return (TRUE); + return (true); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == FALSE\n"); - return (FALSE); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == false\n"); + return (false); } } // End of Type = GROUP } // BSSID match @@ -624,7 +596,7 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii)); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - return (FALSE); + return (false); } @@ -637,22 +609,23 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, * Out: * none * - * Return Value: TRUE if found otherwise FALSE + * Return Value: true if found otherwise false * */ -BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey) +int KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey) { - int i; + int i; + + *pKey = NULL; - *pKey = NULL; for (i=0;i<MAX_KEY_TABLE;i++) { - if ((pTable->KeyTable[i].bInUse == TRUE) && - (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE)) { + if ((pTable->KeyTable[i].bInUse == true) && + (pTable->KeyTable[i].PairwiseKey.bKeyValid == true)) { *pKey = &(pTable->KeyTable[i].PairwiseKey); - return (TRUE); + return (true); } } - return (FALSE); + return (false); } /* @@ -668,37 +641,31 @@ BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey) * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -BOOL KeybSetDefaultKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ) + +int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; + int ii; + PSKeyItem pKey; + u32 uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d\n", (int) dwKeyIndex, (int) uKeyLength); if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key - return (FALSE); + return (false); } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { - return (FALSE); + return (false); } if (uKeyLength > MAX_KEY_LEN) return false; - pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE; + pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true; for (ii = 0; ii < ETH_ALEN; ii++) pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; @@ -722,13 +689,13 @@ BOOL KeybSetDefaultKey( if ((uKeyLength == WLAN_WEP232_KEYLEN) && (byKeyDecMode == KEY_CTL_WEP)) { pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match - pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = TRUE; + pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true; } else { - if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == FALSE) + if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == false) pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match } - pKey->bKeyValid = TRUE; + pKey->bKeyValid = true; pKey->uKeyLength = uKeyLength; pKey->dwKeyIndex = dwKeyIndex; pKey->byCipherSuite = byKeyDecMode; @@ -742,12 +709,12 @@ BOOL KeybSetDefaultKey( MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD) pKey->abyKey); - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } + if ((dwKeyIndex & USE_KEYRSC) == 0) + pKey->KeyRSC = 0; /* RSC set by NIC */ + else + pKey->KeyRSC = *KeyRSC; + + pKey->dwTSC47_16 = 0; pKey->wTSC15_0 = 0; @@ -767,7 +734,7 @@ BOOL KeybSetDefaultKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n", pKey->dwKeyIndex); - return (TRUE); + return (true); } @@ -784,37 +751,30 @@ BOOL KeybSetDefaultKey( * Out: * none * - * Return Value: TRUE if success otherwise FALSE + * Return Value: true if success otherwise false * */ -BOOL KeybSetAllGroupKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ) + +int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable, + u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - int i; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; + int i, ii; + PSKeyItem pKey; + u32 uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %X\n", dwKeyIndex); if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key - return (FALSE); + return (false); } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { - return (FALSE); + return (false); } for (i=0; i < MAX_KEY_TABLE-1; i++) { - if (pTable->KeyTable[i].bInUse == TRUE) { + if (pTable->KeyTable[i].bInUse == true) { // found table already exist // Group key pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); @@ -833,7 +793,7 @@ BOOL KeybSetAllGroupKey( pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - pKey->bKeyValid = TRUE; + pKey->bKeyValid = true; pKey->uKeyLength = uKeyLength; pKey->dwKeyIndex = dwKeyIndex; pKey->byCipherSuite = byKeyDecMode; @@ -847,13 +807,11 @@ BOOL KeybSetAllGroupKey( MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD) pKey->abyKey); - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } + if ((dwKeyIndex & USE_KEYRSC) == 0) + pKey->KeyRSC = 0; /* RSC set by NIC */ + else + pKey->KeyRSC = *KeyRSC; + pKey->dwTSC47_16 = 0; pKey->wTSC15_0 = 0; @@ -870,7 +828,7 @@ BOOL KeybSetAllGroupKey( //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); - } // (pTable->KeyTable[i].bInUse == TRUE) + } // (pTable->KeyTable[i].bInUse == true) } - return (TRUE); + return (true); } diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h index bd35d39..7ecddcd 100644 --- a/drivers/staging/vt6656/key.h +++ b/drivers/staging/vt6656/key.h @@ -57,10 +57,10 @@ typedef struct tagSKeyItem { - BOOL bKeyValid; + bool bKeyValid; u32 uKeyLength; BYTE abyKey[MAX_KEY_LEN]; - QWORD KeyRSC; + u64 KeyRSC; DWORD dwTSC47_16; WORD wTSC15_0; BYTE byCipherSuite; @@ -76,9 +76,9 @@ typedef struct tagSKeyTable SKeyItem PairwiseKey; SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 DWORD dwGTKeyIndex; // GroupTransmitKey Index - BOOL bInUse; + bool bInUse; WORD wKeyCtl; - BOOL bSoftWEP; + bool bSoftWEP; BYTE byReserved1[6]; } SKeyTable, *PSKeyTable; //352 @@ -97,69 +97,37 @@ typedef struct tagSKeyManagement /*--------------------- Export Functions --------------------------*/ -void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable); - -BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex, - PSKeyItem *pKey); - -BOOL KeybSetKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ); - -BOOL KeybRemoveKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID, - DWORD dwKeyIndex - ); - -BOOL KeybRemoveAllKey( - void *pDeviceHandler, - PSKeyManagement pTable, - PBYTE pbyBSSID - ); - -void KeyvRemoveWEPKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex - ); - -void KeyvRemoveAllWEPKey( - void *pDeviceHandler, - PSKeyManagement pTable - ); - -BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType, - PSKeyItem *pKey); - -BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey); - -BOOL KeybSetDefaultKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ); - -BOOL KeybSetAllGroupKey( - void *pDeviceHandler, - PSKeyManagement pTable, - DWORD dwKeyIndex, - u32 uKeyLength, - PQWORD pKeyRSC, - PBYTE pbyKey, - BYTE byKeyDecMode - ); +void KeyvInitTable(struct vnt_private *, PSKeyManagement pTable); + +int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex, + PSKeyItem *pKey); + +int KeybSetKey(struct vnt_private *, PSKeyManagement pTable, u8 *pbyBSSID, + u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode); + +int KeybRemoveKey(struct vnt_private *, PSKeyManagement pTable, + u8 *pbyBSSID, u32 dwKeyIndex); + +int KeybRemoveAllKey(struct vnt_private *, PSKeyManagement pTable, + u8 *pbyBSSID); + +void KeyvRemoveWEPKey(struct vnt_private *, PSKeyManagement pTable, + u32 dwKeyIndex); + +void KeyvRemoveAllWEPKey(struct vnt_private *, PSKeyManagement pTable); + +int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType, + PSKeyItem *pKey); + +int KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey); + +int KeybSetDefaultKey(struct vnt_private *, PSKeyManagement pTable, + u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode); + +int KeybSetAllGroupKey(struct vnt_private *, PSKeyManagement pTable, + u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, + u8 byKeyDecMode); #endif /* __KEY_H__ */ diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 8fddc7b..76d307b 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -68,11 +68,11 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: none * */ -void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx) +void MACvSetMultiAddrByHash(struct vnt_private *pDevice, u8 byHashIdx) { - unsigned int uByteIdx; - BYTE byBitMask; - BYTE pbyData[2]; + u8 uByteIdx; + u8 byBitMask; + u8 pbyData[2]; // calculate byte position @@ -110,9 +110,9 @@ void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx) * Return Value: none * */ -void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData) +void MACvWriteMultiAddr(struct vnt_private *pDevice, u32 uByteIdx, u8 byData) { - BYTE byData1; + u8 byData1; byData1 = byData; CONTROLnsRequestOut(pDevice, @@ -135,7 +135,7 @@ void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData) * * */ -void MACbShutdown(PSDevice pDevice) +void MACbShutdown(struct vnt_private *pDevice) { CONTROLnsRequestOutAsyn(pDevice, MESSAGE_TYPE_MACSHUTDOWN, @@ -146,9 +146,9 @@ void MACbShutdown(PSDevice pDevice) ); } -void MACvSetBBType(PSDevice pDevice,BYTE byType) +void MACvSetBBType(struct vnt_private *pDevice, u8 byType) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = byType; @@ -163,9 +163,9 @@ BYTE pbyData[2]; ); } -void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData) +void MACvSetMISCFifo(struct vnt_private *pDevice, u16 wOffset, u32 dwData) { -BYTE pbyData[4]; + u8 pbyData[4]; if (wOffset > 273) return; @@ -197,10 +197,10 @@ BYTE pbyData[4]; * Return Value: none * */ -void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx) +void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx) { -WORD wOffset; -BYTE byData; + u16 wOffset; + u8 byData; byData = (BYTE) uEntryIdx; @@ -237,20 +237,18 @@ BYTE byData; * Return Value: none * */ -void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl, - unsigned int uEntryIdx, unsigned int uKeyIdx, - PBYTE pbyAddr, PDWORD pdwKey) +void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, + u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey) { -PBYTE pbyKey; -WORD wOffset; -DWORD dwData1,dwData2; -int ii; -BYTE pbyData[24]; - - if ( pDevice->byLocalID <= MAC_REVISION_A1 ) { - if ( pDevice->sMgmtObj.byCSSPK == KEY_CTL_CCMP ) - return; - } + u8 *pbyKey; + u16 wOffset; + u32 dwData1, dwData2; + int ii; + u8 pbyData[24]; + + if (pDevice->byLocalID <= MAC_REVISION_A1) + if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) + return; wOffset = MISCFIFO_KEYETRY0; wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); @@ -321,9 +319,9 @@ BYTE pbyData[24]; } -void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits) +void MACvRegBitsOff(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = 0; pbyData[1] = byBits; @@ -338,9 +336,9 @@ BYTE pbyData[2]; } -void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits) +void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = byBits; @@ -355,9 +353,9 @@ BYTE pbyData[2]; ); } -void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData) +void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = (BYTE)(wData & 0xff); @@ -373,9 +371,9 @@ BYTE pbyData[2]; } -void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr) +void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr) { -BYTE pbyData[6]; + u8 pbyData[6]; pbyData[0] = *((PBYTE)pbyEtherAddr); @@ -394,9 +392,9 @@ BYTE pbyData[6]; ); } -void MACvEnableProtectMD(PSDevice pDevice) +void MACvEnableProtectMD(struct vnt_private *pDevice) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = EnCFG_ProtectMd; @@ -411,9 +409,9 @@ BYTE pbyData[2]; ); } -void MACvDisableProtectMD(PSDevice pDevice) +void MACvDisableProtectMD(struct vnt_private *pDevice) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = 0; @@ -428,9 +426,9 @@ BYTE pbyData[2]; ); } -void MACvEnableBarkerPreambleMd(PSDevice pDevice) +void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = EnCFG_BarkerPream; @@ -445,9 +443,9 @@ BYTE pbyData[2]; ); } -void MACvDisableBarkerPreambleMd(PSDevice pDevice) +void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice) { -BYTE pbyData[2]; + u8 pbyData[2]; pbyData[0] = 0; @@ -463,12 +461,12 @@ BYTE pbyData[2]; } -void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval) +void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval) { -BYTE pbyData[2]; + u8 pbyData[2]; - pbyData[0] = (BYTE) (wInterval & 0xff); - pbyData[1] = (BYTE) (wInterval >> 8); + pbyData[0] = (u8)(wInterval & 0xff); + pbyData[1] = (u8)(wInterval >> 8); CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 147ac50..6e28500 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -420,24 +420,21 @@ /*--------------------- Export Functions --------------------------*/ -void MACvSetMultiAddrByHash(PSDevice pDevice, BYTE byHashIdx); -void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData); -void MACbShutdown(PSDevice pDevice); -void MACvSetBBType(PSDevice pDevice, BYTE byType); -void MACvSetMISCFifo(PSDevice pDevice, WORD wOffset, DWORD dwData); -void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx); -void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey); - -void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits); -void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits); -void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData); - -void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr); -void MACvEnableProtectMD(PSDevice pDevice); -void MACvDisableProtectMD(PSDevice pDevice); -void MACvEnableBarkerPreambleMd(PSDevice pDevice); -void MACvDisableBarkerPreambleMd(PSDevice pDevice); -void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval); +void MACvSetMultiAddrByHash(struct vnt_private *, u8); +void MACvWriteMultiAddr(struct vnt_private *, u32, u8); +void MACbShutdown(struct vnt_private *); +void MACvSetBBType(struct vnt_private *, u8); +void MACvSetMISCFifo(struct vnt_private *pDevice, u16, u32); +void MACvDisableKeyEntry(struct vnt_private *, u32); +void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u32 *); +void MACvRegBitsOff(struct vnt_private *, u8, u8); +void MACvRegBitsOn(struct vnt_private *, u8, u8); +void MACvWriteWord(struct vnt_private *, u8, u16); +void MACvWriteBSSIDAddress(struct vnt_private *, u8 *); +void MACvEnableProtectMD(struct vnt_private *); +void MACvDisableProtectMD(struct vnt_private *); +void MACvEnableBarkerPreambleMd(struct vnt_private *); +void MACvDisableBarkerPreambleMd(struct vnt_private *); +void MACvWriteBeaconInterval(struct vnt_private *, u16); #endif /* __MAC_H__ */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index f33086d..d5f53e1 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -73,15 +73,16 @@ #include "iowpa.h" /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; +/* static int msglevel = MSG_LEVEL_DEBUG; */ static int msglevel =MSG_LEVEL_INFO; -// -// Define module options -// +/* + * define module options + */ -// Version Information -#define DRIVER_AUTHOR "VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>" +/* version information */ +#define DRIVER_AUTHOR \ + "VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>" MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM); @@ -184,16 +185,16 @@ DEVICE_PARAM(BasebandType, "baseband type"); DEVICE_PARAM(b80211hEnable, "802.11h mode"); -// -// Static vars definitions -// +/* + * Static vars definitions + */ static struct usb_device_id vt6656_table[] = { {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)}, {} }; -// Frequency list (map channels to frequencies) +/* frequency list (map channels to frequencies) */ /* static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, @@ -225,26 +226,27 @@ static void device_set_multi(struct net_device *dev); static int device_close(struct net_device *dev); static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType); -static BOOL device_init_defrag_cb(PSDevice pDevice); -static void device_init_diversity_timer(PSDevice pDevice); +static int device_init_registers(struct vnt_private *pDevice, + DEVICE_INIT_TYPE InitType); +static bool device_init_defrag_cb(struct vnt_private *pDevice); +static void device_init_diversity_timer(struct vnt_private *pDevice); static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev); static int ethtool_ioctl(struct net_device *dev, void *useraddr); -static void device_free_tx_bufs(PSDevice pDevice); -static void device_free_rx_bufs(PSDevice pDevice); -static void device_free_int_bufs(PSDevice pDevice); -static void device_free_frag_bufs(PSDevice pDevice); -static BOOL device_alloc_bufs(PSDevice pDevice); - -static int Read_config_file(PSDevice pDevice); -static unsigned char *Config_FileOperation(PSDevice pDevice); +static void device_free_tx_bufs(struct vnt_private *pDevice); +static void device_free_rx_bufs(struct vnt_private *pDevice); +static void device_free_int_bufs(struct vnt_private *pDevice); +static void device_free_frag_bufs(struct vnt_private *pDevice); +static bool device_alloc_bufs(struct vnt_private *pDevice); + +static int Read_config_file(struct vnt_private *pDevice); +static unsigned char *Config_FileOperation(struct vnt_private *pDevice); static int Config_FileGetParameter(unsigned char *string, unsigned char *dest, unsigned char *source); -static void usb_device_reset(PSDevice pDevice); +static void usb_device_reset(struct vnt_private *pDevice); @@ -254,7 +256,7 @@ static void usb_device_reset(PSDevice pDevice); static void -device_set_options(PSDevice pDevice) { +device_set_options(struct vnt_private *pDevice) { BYTE abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; @@ -277,22 +279,22 @@ device_set_options(PSDevice pDevice) { pDevice->b11hEnable = X80211h_MODE_DEF; pDevice->eOPMode = OP_MODE_DEF; pDevice->uConnectionRate = DATA_RATE_DEF; - if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = TRUE; + if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true; pDevice->byBBType = BBP_TYPE_DEF; pDevice->byPacketType = pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; - pDevice->bUpdateBBVGA = TRUE; + pDevice->bUpdateBBVGA = true; pDevice->byFOETuning = 0; pDevice->byAutoPwrTunning = 0; pDevice->wCTSDuration = 0; pDevice->byPreambleType = 0; - pDevice->bExistSWNetAddr = FALSE; -// pDevice->bDiversityRegCtlON = TRUE; - pDevice->bDiversityRegCtlON = FALSE; + pDevice->bExistSWNetAddr = false; + /* pDevice->bDiversityRegCtlON = true; */ + pDevice->bDiversityRegCtlON = false; } -static void device_init_diversity_timer(PSDevice pDevice) +static void device_init_diversity_timer(struct vnt_private *pDevice) { init_timer(&pDevice->TimerSQ3Tmax1); pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice; @@ -313,25 +315,25 @@ static void device_init_diversity_timer(PSDevice pDevice) } -// -// Initialization of MAC & BBP registers -// +/* + * initialization of MAC & BBP registers + */ -static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) +static int device_init_registers(struct vnt_private *pDevice, + DEVICE_INIT_TYPE InitType) { - u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - BYTE byAntenna; - unsigned int ii; - CMD_CARD_INIT sInitCmd; - int ntStatus = STATUS_SUCCESS; - RSP_CARD_INIT sInitRsp; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BYTE byTmp; - BYTE byCalibTXIQ = 0; - BYTE byCalibTXDC = 0; - BYTE byCalibRXIQ = 0; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] + = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; + u8 byAntenna; + int ii; + CMD_CARD_INIT sInitCmd; + int ntStatus = STATUS_SUCCESS; + RSP_CARD_INIT sInitRsp; + u8 byTmp; + u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType); spin_lock_irq(&pDevice->lock); @@ -343,24 +345,24 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) ETH_ALEN); if ( !FIRMWAREbCheckVersion(pDevice) ) { - if (FIRMWAREbDownload(pDevice) == TRUE) { - if (FIRMWAREbBrach2Sram(pDevice) == FALSE) { + if (FIRMWAREbDownload(pDevice) == true) { + if (FIRMWAREbBrach2Sram(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbBrach2Sram fail \n"); spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbDownload fail \n"); spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } } if ( !BBbVT3184Init(pDevice) ) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail \n"); spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } } @@ -371,7 +373,7 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit; sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit; - //issue Card_init command to device + /* issue card_init command to device */ ntStatus = CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_CARDINIT, 0, @@ -382,7 +384,7 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if ( ntStatus != STATUS_SUCCESS ) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail \n"); spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } if (InitType == DEVICE_INIT_COLD) { @@ -391,10 +393,10 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n"); spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } - //Local ID for AES functions + /* local ID for AES functions */ ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, MAC_REG_LOCALID, @@ -404,15 +406,17 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if ( ntStatus != STATUS_SUCCESS ) { spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } - // Do MACbSoftwareReset in MACvInitialize - // force CCK - pDevice->bCCK = TRUE; - pDevice->bProtectMode = FALSE; //Only used in 11g type, sync with ERP IE - pDevice->bNonERPPresent = FALSE; - pDevice->bBarkerPreambleMd = FALSE; + /* do MACbSoftwareReset in MACvInitialize */ + + /* force CCK */ + pDevice->bCCK = true; + pDevice->bProtectMode = false; + /* only used in 11g type, sync with ERP IE */ + pDevice->bNonERPPresent = false; + pDevice->bBarkerPreambleMd = false; if ( pDevice->bFixRate ) { pDevice->wCurrentRate = (WORD) pDevice->uConnectionRate; } else { @@ -426,13 +430,14 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byTopOFDMBasicRate = RATE_24M; pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byRevId = 0; //Target to IF pin while programming to RF chip. + pDevice->byRevId = 0; + /* target to IF pin while programming to RF chip */ pDevice->byCurPwr = 0xFF; pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK]; pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG]; - // Load power Table - for (ii=0;ii<14;ii++) { + /* load power table */ + for (ii = 0; ii < 14; ii++) { pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL]; if (pDevice->abyCCKPwrTbl[ii] == 0) pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr; @@ -441,8 +446,10 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG; } - //original zonetype is USA,but customize zonetype is europe, - // then need recover 12,13 ,14 channel with 11 channel + /* + * original zonetype is USA, but custom zonetype is Europe, + * then need to recover 12, 13, 14 channels with 11 channel + */ if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) || (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&& (pDevice->byOriginalZonetype == ZoneType_USA)) { @@ -452,25 +459,24 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) } } - //{{ RobertYu: 20041124 - pDevice->byOFDMPwrA = 0x34; // same as RFbMA2829SelectChannel - // Load OFDM A Power Table - for (ii=0;ii<CB_MAX_CHANNEL_5G;ii++) { //RobertYu:20041224, bug using CB_MAX_CHANNEL + pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */ + + /* load OFDM A power table */ + for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) { pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL]; if (pDevice->abyOFDMAPwrTbl[ii] == 0) pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA; } - //}} RobertYu byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA]; if (byAntenna & EEP_ANTINV) - pDevice->bTxRxAntInv = TRUE; + pDevice->bTxRxAntInv = true; else - pDevice->bTxRxAntInv = FALSE; + pDevice->bTxRxAntInv = false; byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); - if (byAntenna == 0) // if not set default is All + if (byAntenna == 0) /* if not set default is both */ byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { @@ -478,29 +484,29 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byTxAntennaMode = ANT_B; pDevice->dwTxAntennaSel = 1; pDevice->dwRxAntennaSel = 1; - if (pDevice->bTxRxAntInv == TRUE) + if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; if (pDevice->bDiversityRegCtlON) - pDevice->bDiversityEnable = TRUE; + pDevice->bDiversityEnable = true; else - pDevice->bDiversityEnable = FALSE; + pDevice->bDiversityEnable = false; } else { - pDevice->bDiversityEnable = FALSE; + pDevice->bDiversityEnable = false; pDevice->byAntennaCount = 1; pDevice->dwTxAntennaSel = 0; pDevice->dwRxAntennaSel = 0; if (byAntenna & EEP_ANTENNA_AUX) { pDevice->byTxAntennaMode = ANT_A; - if (pDevice->bTxRxAntInv == TRUE) + if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_B; else pDevice->byRxAntennaMode = ANT_A; } else { pDevice->byTxAntennaMode = ANT_B; - if (pDevice->bTxRxAntInv == TRUE) + if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; @@ -512,35 +518,34 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byTMax2 = 4; pDevice->ulSQ3TH = 0; pDevice->byTMax3 = 64; - // ----------------------------------------------------------------- - //Get Auto Fall Back Type + /* get Auto Fall Back type */ pDevice->byAutoFBCtrl = AUTO_FB_0; - // Set SCAN Time + /* set SCAN Time */ pDevice->uScanTime = WLAN_SCAN_MINITIME; - // default Auto Mode - //pDevice->NetworkType = Ndis802_11Automode; + /* default Auto Mode */ + /* pDevice->NetworkType = Ndis802_11Automode; */ pDevice->eConfigPHYMode = PHY_TYPE_AUTO; pDevice->byBBType = BB_TYPE_11G; - // initialize BBP registers + /* initialize BBP registers */ pDevice->ulTxPower = 25; - // Get Channel range + /* get channel range */ pDevice->byMinChannel = 1; pDevice->byMaxChannel = CB_MAX_CHANNEL; - // Get RFType + /* get RFType */ pDevice->byRFType = sInitRsp.byRFType; if ((pDevice->byRFType & RF_EMU) != 0) { - // force change RevID for VT3253 emu - pDevice->byRevId = 0x80; + /* force change RevID for VT3253 emu */ + pDevice->byRevId = 0x80; } - // Load EEPROM calibrated vt3266 parameters + /* load vt3266 calibration parameters in EEPROM */ if (pDevice->byRFType == RF_VT3226D0) { if((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) && (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) { @@ -548,13 +553,32 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC]; byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ]; if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x03); // CR255, Set BB to support TX/RX IQ and DC compensation Mode - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFB, byCalibTXIQ); // CR251, TX I/Q Imbalance Calibration - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFC, byCalibTXDC); // CR252, TX DC-Offset Calibration - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFD, byCalibRXIQ); // CR253, RX I/Q Imbalance Calibration + /* CR255, enable TX/RX IQ and DC compensation mode */ + ControlvWriteByte(pDevice, + MESSAGE_REQUEST_BBREG, + 0xFF, + 0x03); + /* CR251, TX I/Q Imbalance Calibration */ + ControlvWriteByte(pDevice, + MESSAGE_REQUEST_BBREG, + 0xFB, + byCalibTXIQ); + /* CR252, TX DC-Offset Calibration */ + ControlvWriteByte(pDevice, + MESSAGE_REQUEST_BBREG, + 0xFC, + byCalibTXDC); + /* CR253, RX I/Q Imbalance Calibration */ + ControlvWriteByte(pDevice, + MESSAGE_REQUEST_BBREG, + 0xFD, + byCalibRXIQ); } else { - // turn off BB Calibration compensation - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x0); // CR255 + /* CR255, turn off BB Calibration compensation */ + ControlvWriteByte(pDevice, + MESSAGE_REQUEST_BBREG, + 0xFF, + 0x0); } } } @@ -563,26 +587,27 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pMgmt->uIBSSChannel = pDevice->uChannel; CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel); - // get Permanent network address + /* get permanent network address */ memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6); memcpy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, ETH_ALEN); - // if exist SW network address, use SW network address. - + /* if exist SW network address, use it */ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n", pDevice->abyCurrentNetAddr); } - // Set BB and packet type at the same time. - // Set Short Slot Time, xIFS, and RSPINF. + /* + * set BB and packet type at the same time + * set Short Slot Time, xIFS, and RSPINF + */ if (pDevice->byBBType == BB_TYPE_11A) { CARDbAddBasicRate(pDevice, RATE_6M); - pDevice->bShortSlotTime = TRUE; + pDevice->bShortSlotTime = true; } else { CARDbAddBasicRate(pDevice, RATE_1M); - pDevice->bShortSlotTime = FALSE; + pDevice->bShortSlotTime = false; } BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); @@ -594,7 +619,7 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) } pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL]; - pDevice->bHWRadioOff = FALSE; + pDevice->bHWRadioOff = false; if ( (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0 ) { ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, @@ -605,23 +630,23 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if ( ntStatus != STATUS_SUCCESS ) { spin_unlock_irq(&pDevice->lock); - return FALSE; + return false; } if ( (byTmp & GPIO3_DATA) == 0 ) { - pDevice->bHWRadioOff = TRUE; + pDevice->bHWRadioOff = true; MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD); } else { MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD); - pDevice->bHWRadioOff = FALSE; + pDevice->bHWRadioOff = false; } - } //EEP_RADIOCTL_ENABLE + } ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_TMLEN,0x38); ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL0,0x01); - if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) { + if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { CARDbRadioPowerOff(pDevice); } else { CARDbRadioPowerOn(pDevice); @@ -629,14 +654,14 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) spin_unlock_irq(&pDevice->lock); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n"); - return TRUE; + return true; } #ifdef CONFIG_PM /* Minimal support for suspend and resume */ static int vt6656_suspend(struct usb_interface *intf, pm_message_t message) { - PSDevice device = usb_get_intfdata(intf); + struct vnt_private *device = usb_get_intfdata(intf); if (!device || !device->dev) return -ENODEV; @@ -651,7 +676,7 @@ static int vt6656_suspend(struct usb_interface *intf, pm_message_t message) static int vt6656_resume(struct usb_interface *intf) { - PSDevice device = usb_get_intfdata(intf); + struct vnt_private *device = usb_get_intfdata(intf); if (!device || !device->dev) return -ENODEV; @@ -682,13 +707,13 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) struct usb_device *udev = interface_to_usbdev(intf); int rc = 0; struct net_device *netdev = NULL; - PSDevice pDevice = NULL; + struct vnt_private *pDevice; printk(KERN_NOTICE "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION); printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n"); udev = usb_get_dev(udev); - netdev = alloc_etherdev(sizeof(DEVICE_INFO)); + netdev = alloc_etherdev(sizeof(struct vnt_private)); if (!netdev) { printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n"); rc = -ENOMEM; @@ -696,7 +721,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) } pDevice = netdev_priv(netdev); - memset(pDevice, 0, sizeof(DEVICE_INFO)); + memset(pDevice, 0, sizeof(struct vnt_private)); pDevice->dev = netdev; pDevice->usb = udev; @@ -705,7 +730,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) spin_lock_init(&pDevice->lock); pDevice->tx_80211 = device_dma0_tx_80211; - pDevice->sMgmtObj.pAdapter = (void *) pDevice; + pDevice->vnt_mgmt.pAdapter = (void *) pDevice; netdev->netdev_ops = &device_netdev_ops; netdev->wireless_handlers = @@ -732,7 +757,7 @@ err_nomem: return rc; } -static void device_free_tx_bufs(PSDevice pDevice) +static void device_free_tx_bufs(struct vnt_private *pDevice) { PUSB_SEND_CONTEXT pTxContext; int ii; @@ -740,7 +765,7 @@ static void device_free_tx_bufs(PSDevice pDevice) for (ii = 0; ii < pDevice->cbTD; ii++) { pTxContext = pDevice->apTD[ii]; - //de-allocate URBs + /* deallocate URBs */ if (pTxContext->pUrb) { usb_kill_urb(pTxContext->pUrb); usb_free_urb(pTxContext->pUrb); @@ -751,7 +776,7 @@ static void device_free_tx_bufs(PSDevice pDevice) } -static void device_free_rx_bufs(PSDevice pDevice) +static void device_free_rx_bufs(struct vnt_private *pDevice) { PRCB pRCB; int ii; @@ -759,12 +784,12 @@ static void device_free_rx_bufs(PSDevice pDevice) for (ii = 0; ii < pDevice->cbRD; ii++) { pRCB = pDevice->apRCB[ii]; - //de-allocate URBs + /* deallocate URBs */ if (pRCB->pUrb) { usb_kill_urb(pRCB->pUrb); usb_free_urb(pRCB->pUrb); } - //de-allocate skb + /* deallocate skb */ if (pRCB->skb) dev_kfree_skb(pRCB->skb); } @@ -773,7 +798,7 @@ static void device_free_rx_bufs(PSDevice pDevice) return; } -static void usb_device_reset(PSDevice pDevice) +static void usb_device_reset(struct vnt_private *pDevice) { int status; status = usb_reset_device(pDevice->usb); @@ -782,14 +807,15 @@ static void usb_device_reset(PSDevice pDevice) return ; } -static void device_free_int_bufs(PSDevice pDevice) +static void device_free_int_bufs(struct vnt_private *pDevice) { kfree(pDevice->intBuf.pDataBuf); return; } -static BOOL device_alloc_bufs(PSDevice pDevice) { +static bool device_alloc_bufs(struct vnt_private *pDevice) +{ PUSB_SEND_CONTEXT pTxContext; PRCB pRCB; @@ -805,16 +831,16 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { } pDevice->apTD[ii] = pTxContext; pTxContext->pDevice = (void *) pDevice; - //allocate URBs + /* allocate URBs */ pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC); if (pTxContext->pUrb == NULL) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n"); goto free_tx; } - pTxContext->bBoolInUse = FALSE; + pTxContext->bBoolInUse = false; } - // allocate rcb mem + /* allocate RCB mem */ pDevice->pRCBMem = kzalloc((sizeof(RCB) * pDevice->cbRD), GFP_KERNEL); if (pDevice->pRCBMem == NULL) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name); @@ -833,7 +859,7 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { pDevice->apRCB[ii] = pRCB; pRCB->pDevice = (void *) pDevice; - //allocate URBs + /* allocate URBs */ pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC); if (pRCB->pUrb == NULL) { @@ -846,7 +872,7 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { goto free_rx_tx; } pRCB->skb->dev = pDevice->dev; - pRCB->bBoolInUse = FALSE; + pRCB->bBoolInUse = false; EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB); pDevice->NumRecvFreeList++; pRCB++; @@ -874,7 +900,7 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { goto free_rx_tx; } - return TRUE; + return true; free_rx_tx: device_free_rx_bufs(pDevice); @@ -882,15 +908,16 @@ free_rx_tx: free_tx: device_free_tx_bufs(pDevice); - return FALSE; + return false; } -static BOOL device_init_defrag_cb(PSDevice pDevice) { - int i; - PSDeFragControlBlock pDeF; +static bool device_init_defrag_cb(struct vnt_private *pDevice) +{ + int i; + PSDeFragControlBlock pDeF; /* Init the fragment ctl entries */ for (i = 0; i < CB_MAX_RX_FRAG; i++) { @@ -903,18 +930,19 @@ static BOOL device_init_defrag_cb(PSDevice pDevice) { } pDevice->cbDFCB = CB_MAX_RX_FRAG; pDevice->cbFreeDFCB = pDevice->cbDFCB; - return TRUE; + return true; free_frag: device_free_frag_bufs(pDevice); - return FALSE; + return false; } -static void device_free_frag_bufs(PSDevice pDevice) { - PSDeFragControlBlock pDeF; - int i; +static void device_free_frag_bufs(struct vnt_private *pDevice) +{ + PSDeFragControlBlock pDeF; + int i; for (i = 0; i < CB_MAX_RX_FRAG; i++) { @@ -927,36 +955,39 @@ static void device_free_frag_bufs(PSDevice pDevice) { -BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) { +int device_alloc_frag_buf(struct vnt_private *pDevice, + PSDeFragControlBlock pDeF) +{ pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); if (pDeF->skb == NULL) - return FALSE; + return false; ASSERT(pDeF->skb); pDeF->skb->dev = pDevice->dev; - return TRUE; + return true; } /*-----------------------------------------------------------------*/ -static int device_open(struct net_device *dev) { - PSDevice pDevice=(PSDevice) netdev_priv(dev); +static int device_open(struct net_device *dev) +{ + struct vnt_private *pDevice = netdev_priv(dev); - pDevice->fWPA_Authened = FALSE; + pDevice->fWPA_Authened = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n"); pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS; - if (device_alloc_bufs(pDevice) == FALSE) { + if (device_alloc_bufs(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n"); return -ENOMEM; } - if (device_init_defrag_cb(pDevice)== FALSE) { + if (device_init_defrag_cb(pDevice)== false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragment cb fail \n"); goto free_rx_tx; } @@ -967,25 +998,26 @@ static int device_open(struct net_device *dev) { MP_SET_FLAG(pDevice, fMP_POST_READS); MP_SET_FLAG(pDevice, fMP_POST_WRITES); - //read config file + /* read config file */ Read_config_file(pDevice); - if (device_init_registers(pDevice, DEVICE_INIT_COLD) == FALSE) { + if (device_init_registers(pDevice, DEVICE_INIT_COLD) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n"); goto free_all; } device_set_multi(pDevice->dev); - // Init for Key Management + /* init for key management */ KeyvInitTable(pDevice,&pDevice->sKey); - memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN); + memcpy(pDevice->vnt_mgmt.abyMACAddr, + pDevice->abyCurrentNetAddr, ETH_ALEN); memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN); - pDevice->bStopTx0Pkt = FALSE; - pDevice->bStopDataPkt = FALSE; - pDevice->bRoaming = FALSE; - pDevice->bIsRoaming = FALSE; - pDevice->bEnableRoaming = FALSE; + pDevice->bStopTx0Pkt = false; + pDevice->bStopDataPkt = false; + pDevice->bRoaming = false; + pDevice->bIsRoaming = false; + pDevice->bEnableRoaming = false; if (pDevice->bDiversityRegCtlON) { device_init_diversity_timer(pDevice); } @@ -994,27 +1026,27 @@ static int device_open(struct net_device *dev) { tasklet_init(&pDevice->RxMngWorkItem, (void *)RXvMngWorkItem, (unsigned long)pDevice); tasklet_init(&pDevice->ReadWorkItem, (void *)RXvWorkItem, (unsigned long)pDevice); tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice); - add_timer(&(pDevice->sMgmtObj.sTimerSecondCallback)); - pDevice->int_interval = 100; //Max 100 microframes. + add_timer(&pDevice->vnt_mgmt.sTimerSecondCallback); + pDevice->int_interval = 100; /* max 100 microframes */ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - pDevice->bIsRxWorkItemQueued = TRUE; - pDevice->fKillEventPollingThread = FALSE; - pDevice->bEventAvailable = FALSE; + pDevice->bIsRxWorkItemQueued = true; + pDevice->fKillEventPollingThread = false; + pDevice->bEventAvailable = false; - pDevice->bWPADEVUp = FALSE; - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = FALSE; - pDevice->bWPASuppWextEnabled = FALSE; + pDevice->bWPADEVUp = false; + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = false; + pDevice->bWPASuppWextEnabled = false; pDevice->byReAssocCount = 0; RXvWorkItem(pDevice); INTvWorkItem(pDevice); - // Patch: if WEP key already set by iwconfig but device not yet open - if ((pDevice->bEncryptionEnable == TRUE) && (pDevice->bTransmitKey == TRUE)) { + /* if WEP key already set by iwconfig but device not yet open */ + if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) { spin_lock_irq(&pDevice->lock); KeybSetDefaultKey( pDevice, &(pDevice->sKey), @@ -1028,14 +1060,10 @@ static int device_open(struct net_device *dev) { pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; } - if (pDevice->sMgmtObj.eConfigMode == WMAC_CONFIG_AP) { + if (pDevice->vnt_mgmt.eConfigMode == WMAC_CONFIG_AP) bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); - } - else { - //mike:mark@2008-11-10 - bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); - /* bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); */ - } + else + bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); netif_stop_queue(pDevice->dev); @@ -1061,13 +1089,13 @@ free_rx_tx: -static int device_close(struct net_device *dev) { - PSDevice pDevice=(PSDevice) netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - int uu; +static int device_close(struct net_device *dev) +{ + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int uu; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1 \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n"); if (pDevice == NULL) return -ENODEV; @@ -1078,22 +1106,22 @@ static int device_close(struct net_device *dev) { memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pMgmt->bShareKeyAlgorithm = FALSE; - pDevice->bEncryptionEnable = FALSE; + pMgmt->bShareKeyAlgorithm = false; + pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; spin_lock_irq(&pDevice->lock); for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice,uu); spin_unlock_irq(&pDevice->lock); - if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == FALSE) { + if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) { MACbShutdown(pDevice); } netif_stop_queue(pDevice->dev); MP_SET_FLAG(pDevice, fMP_DISCONNECTED); MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES); MP_CLEAR_FLAG(pDevice, fMP_POST_READS); - pDevice->fKillEventPollingThread = TRUE; + pDevice->fKillEventPollingThread = true; del_timer(&pDevice->sTimerCommand); del_timer(&pMgmt->sTimerSecondCallback); @@ -1108,11 +1136,11 @@ static int device_close(struct net_device *dev) { tasklet_kill(&pDevice->ReadWorkItem); tasklet_kill(&pDevice->EventWorkItem); - pDevice->bRoaming = FALSE; - pDevice->bIsRoaming = FALSE; - pDevice->bEnableRoaming = FALSE; - pDevice->bCmdRunning = FALSE; - pDevice->bLinkPass = FALSE; + pDevice->bRoaming = false; + pDevice->bIsRoaming = false; + pDevice->bEnableRoaming = false; + pDevice->bCmdRunning = false; + pDevice->bLinkPass = false; memset(pMgmt->abyCurrBSSID, 0, 6); pMgmt->eCurrState = WMAC_STATE_IDLE; @@ -1136,7 +1164,7 @@ static int device_close(struct net_device *dev) { static void vt6656_disconnect(struct usb_interface *intf) { - PSDevice device = usb_get_intfdata(intf); + struct vnt_private *device = usb_get_intfdata(intf); if (!device) return; @@ -1156,7 +1184,7 @@ static void vt6656_disconnect(struct usb_interface *intf) static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); spin_lock_irq(&pDevice->lock); @@ -1172,7 +1200,7 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) static int device_xmit(struct sk_buff *skb, struct net_device *dev) { - PSDevice pDevice = netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct net_device_stats *stats = &pDevice->stats; spin_lock_irq(&pDevice->lock); @@ -1217,7 +1245,7 @@ static inline u32 ether_crc(int length, unsigned char *data) return crc; } -//find out the start position of str2 from str1 +/* find out the start position of str2 from str1 */ static unsigned char *kstrstr(const unsigned char *str1, const unsigned char *str2) { int str1_len = strlen(str1); @@ -1246,37 +1274,37 @@ static int Config_FileGetParameter(unsigned char *string, strcat(buf1, "="); source+=strlen(buf1); -//find target string start point + /* find target string start point */ start_p = kstrstr(source,buf1); if (start_p == NULL) - return FALSE; + return false; -//check if current config line is marked by "#" ?? + /* check if current config line is marked by "#" */ for (ii = 1; ; ii++) { if (memcmp(start_p - ii, "\n", 1) == 0) break; if (memcmp(start_p - ii, "#", 1) == 0) - return FALSE; + return false; } -//find target string end point + /* find target string end point */ end_p = kstrstr(start_p,"\n"); - if (end_p == NULL) { //can't find "\n",but don't care - end_p=start_p+strlen(start_p); //no include "\n" - } + if (end_p == NULL) { /* can't find "\n", but don't care */ + end_p = start_p + strlen(start_p); /* no include "\n" */ + } memset(buf2,0,100); - memcpy(buf2,start_p,end_p-start_p); //get the target line + memcpy(buf2, start_p, end_p-start_p); /* get the target line */ buf2[end_p-start_p]='\0'; - //find value + /* find value */ start_p = kstrstr(buf2,"="); if (start_p == NULL) - return FALSE; + return false; memset(buf1,0,100); strcpy(buf1,start_p+1); - //except space + /* except space */ tmp_p = buf1; while(*tmp_p != 0x00) { if(*tmp_p==' ') @@ -1286,29 +1314,22 @@ static int Config_FileGetParameter(unsigned char *string, } memcpy(dest,tmp_p,strlen(tmp_p)); - return TRUE; + return true; } -//if read fail,return NULL,or return data pointer; -static unsigned char *Config_FileOperation(PSDevice pDevice) +/* if read fails, return NULL, or return data pointer */ +static unsigned char *Config_FileOperation(struct vnt_private *pDevice) { unsigned char *config_path = CONFIG_PATH; unsigned char *buffer = NULL; struct file *filp=NULL; mm_segment_t old_fs = get_fs(); - //int oldfsuid=0,oldfsgid=0; + int result = 0; set_fs (KERNEL_DS); - /* Can't do this anymore, so we rely on correct filesystem permissions: - //Make sure a caller can read or write power as root - oldfsuid=current->fsuid; - oldfsgid=current->fsgid; - current->fsuid = 0; - current->fsgid = 0; - */ - - //open file + + /* open file */ filp = filp_open(config_path, O_RDWR, 0); if (IS_ERR(filp)) { printk("Config_FileOperation file Not exist\n"); @@ -1341,11 +1362,6 @@ error1: error2: set_fs (old_fs); - /* - current->fsuid=oldfsuid; - current->fsgid=oldfsgid; - */ - if(result!=0) { kfree(buffer); buffer=NULL; @@ -1353,13 +1369,14 @@ if(result!=0) { return buffer; } -//return --->-1:fail; >=0:successful -static int Read_config_file(PSDevice pDevice) { - int result = 0; - unsigned char tmpbuffer[100]; - unsigned char *buffer = NULL; +/* return --->-1:fail; >=0:successful */ +static int Read_config_file(struct vnt_private *pDevice) +{ + int result = 0; + unsigned char tmpbuffer[100]; + unsigned char *buffer = NULL; - //init config setting + /* init config setting */ pDevice->config_file.ZoneType = -1; pDevice->config_file.eAuthenMode = -1; pDevice->config_file.eEncryptionStatus = -1; @@ -1370,10 +1387,10 @@ static int Read_config_file(PSDevice pDevice) { return result; } -//get zonetype +/* get zonetype */ { memset(tmpbuffer,0,sizeof(tmpbuffer)); - if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==TRUE) { + if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==true) { if(memcmp(tmpbuffer,"USA",3)==0) { pDevice->config_file.ZoneType=ZoneType_USA; } @@ -1389,15 +1406,15 @@ static int Read_config_file(PSDevice pDevice) { } } -//get other parameter +/* get other parameter */ { memset(tmpbuffer,0,sizeof(tmpbuffer)); - if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==TRUE) { + if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==true) { pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10); } memset(tmpbuffer,0,sizeof(tmpbuffer)); - if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==TRUE) { + if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==true) { pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10); } } @@ -1406,15 +1423,16 @@ static int Read_config_file(PSDevice pDevice) { return result; } -static void device_set_multi(struct net_device *dev) { - PSDevice pDevice = (PSDevice) netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - u32 mc_filter[2]; - int ii; - struct netdev_hw_addr *ha; - BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; - BYTE byTmpMode = 0; - int rc; +static void device_set_multi(struct net_device *dev) +{ + struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct netdev_hw_addr *ha; + u32 mc_filter[2]; + int ii; + u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 byTmpMode = 0; + int rc; spin_lock_irq(&pDevice->lock); @@ -1429,9 +1447,9 @@ static void device_set_multi(struct net_device *dev) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode); - if (dev->flags & IFF_PROMISC) { // Set promiscuous. + if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */ DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name); - // Unconditionally log net taps. + /* unconditionally log net taps */ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST); } else if ((netdev_mc_count(dev) > pDevice->multicast_limit) || @@ -1460,7 +1478,10 @@ static void device_set_multi(struct net_device *dev) { } if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - // If AP mode, don't enable RCR_UNICAST. Since hw only compare addr1 with local mac. + /* + * If AP mode, don't enable RCR_UNICAST since HW only compares + * addr1 with local MAC + */ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); pDevice->byRxMode &= ~(RCR_UNICAST); } @@ -1472,14 +1493,14 @@ static void device_set_multi(struct net_device *dev) { static struct net_device_stats *device_get_stats(struct net_device *dev) { - PSDevice pDevice=(PSDevice) netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); - return &pDevice->stats; + return &pDevice->stats; } static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - PSDevice pDevice = (PSDevice)netdev_priv(dev); + struct vnt_private *pDevice = netdev_priv(dev); struct iwreq *wrq = (struct iwreq *) rq; int rc = 0; @@ -1524,9 +1545,6 @@ static int ethtool_ioctl(struct net_device *dev, void *useraddr) return -EOPNOTSUPP; } - -/*------------------------------------------------------------------*/ - MODULE_DEVICE_TABLE(usb, vt6656_table); static struct usb_driver vt6656_driver = { diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index ab3a554..527c259f 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -70,12 +70,10 @@ static int msglevel = MSG_LEVEL_INFO; * */ -void PSvEnablePowerSaving(void *hDeviceContext, - WORD wListenInterval) +void PSvEnablePowerSaving(struct vnt_private *pDevice, u16 wListenInterval) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u16 wAID = pMgmt->wCurrAID | BIT14 | BIT15; /* set period of power up before TBTT */ MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT); @@ -116,13 +114,13 @@ void PSvEnablePowerSaving(void *hDeviceContext, pMgmt->wCountToWakeUp = 0; } - pDevice->bEnablePSMode = TRUE; + pDevice->bEnablePSMode = true; /* We don't send null pkt in ad hoc mode since beacon will handle this. */ if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) PSbSendNullPacket(pDevice); - pDevice->bPWBitOn = TRUE; + pDevice->bPWBitOn = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable...\n"); } @@ -136,10 +134,8 @@ void PSvEnablePowerSaving(void *hDeviceContext, * */ -void PSvDisablePowerSaving(void *hDeviceContext) +void PSvDisablePowerSaving(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - /* PSMgmtObject pMgmt = &(pDevice->sMgmtObj); */ /* disable power saving hw function */ CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, @@ -150,12 +146,12 @@ void PSvDisablePowerSaving(void *hDeviceContext) /* set always listen beacon */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN); - pDevice->bEnablePSMode = FALSE; + pDevice->bEnablePSMode = false; if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) PSbSendNullPacket(pDevice); - pDevice->bPWBitOn = FALSE; + pDevice->bPWBitOn = false; } /* @@ -164,38 +160,36 @@ void PSvDisablePowerSaving(void *hDeviceContext) * Consider to power down when no more packets to tx or rx. * * Return Value: - * TRUE, if power down success - * FALSE, if fail + * true, if power down success + * false, if fail */ -BOOL PSbConsiderPowerDown(void *hDeviceContext, - BOOL bCheckRxDMA, - BOOL bCheckCountToWakeUp) +int PSbConsiderPowerDown(struct vnt_private *pDevice, int bCheckRxDMA, + int bCheckCountToWakeUp) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BYTE byData; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 byData; /* check if already in Doze mode */ ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) - return TRUE; + return true; if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { /* check if in TIM wake period */ if (pMgmt->bInTIMWake) - return FALSE; + return false; } /* check scan state */ if (pDevice->bCmdRunning) - return FALSE; + return false; /* Tx Burst */ if (pDevice->bPSModeTxBurst) - return FALSE; + return false; /* Froce PSEN on */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN); @@ -203,16 +197,16 @@ BOOL PSbConsiderPowerDown(void *hDeviceContext, if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { if (bCheckCountToWakeUp && (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) { - return FALSE; + return false; } } - pDevice->bPSRxBeacon = TRUE; + pDevice->bPSRxBeacon = true; /* no Tx, no Rx isr, now go to Doze */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n"); - return TRUE; + return true; } /* @@ -225,15 +219,17 @@ BOOL PSbConsiderPowerDown(void *hDeviceContext, * */ -void PSvSendPSPOLL(void *hDeviceContext) +void PSvSendPSPOLL(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PSTxMgmtPacket pTxPacket = NULL; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_mgmt *pTxPacket = NULL; + + memset(pMgmt->pbyPSPacketPool, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_HDR_ADDR2_LEN); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyPSPacketPool; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); - memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN); - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16( ( WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) | @@ -263,24 +259,25 @@ void PSvSendPSPOLL(void *hDeviceContext) * */ -BOOL PSbSendNullPacket(void *hDeviceContext) +int PSbSendNullPacket(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSTxMgmtPacket pTxPacket = NULL; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_tx_mgmt *pTxPacket = NULL; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; u16 flags = 0; - if (pDevice->bLinkPass == FALSE) - return FALSE; + if (pDevice->bLinkPass == false) + return false; - if ((pDevice->bEnablePSMode == FALSE) && - (pDevice->fTxDataInSleep == FALSE)) { - return FALSE; + if ((pDevice->bEnablePSMode == false) && + (pDevice->fTxDataInSleep == false)) { + return false; } - memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN); - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + memset(pMgmt->pbyPSPacketPool, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_NULLDATA_FR_MAXLEN); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyPSPacketPool; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); flags = WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL); @@ -303,9 +300,9 @@ BOOL PSbSendNullPacket(void *hDeviceContext) /* log error if sending failed */ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n"); - return FALSE; + return false; } - return TRUE; + return true; } /* @@ -318,11 +315,10 @@ BOOL PSbSendNullPacket(void *hDeviceContext) * */ -BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext) +int PSbIsNextTBTTWakeUp(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BOOL bWakeUp = FALSE; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int bWakeUp = false; if (pMgmt->wListenInterval >= 2) { if (pMgmt->wCountToWakeUp == 0) @@ -333,8 +329,8 @@ BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext) if (pMgmt->wCountToWakeUp == 1) { /* Turn on wake up to listen next beacon */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN); - pDevice->bPSRxBeacon = FALSE; - bWakeUp = TRUE; + pDevice->bPSRxBeacon = false; + bWakeUp = true; } else if (!pDevice->bPSRxBeacon) { /* Listen until RxBeacon */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN); diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h index 41bffe5..879b10c 100644 --- a/drivers/staging/vt6656/power.h +++ b/drivers/staging/vt6656/power.h @@ -48,14 +48,12 @@ /* PSDevice pDevice */ /* PSDevice hDeviceContext */ -BOOL PSbConsiderPowerDown(void *hDeviceContext, - BOOL bCheckRxDMA, - BOOL bCheckCountToWakeUp); - -void PSvDisablePowerSaving(void *hDeviceContext); -void PSvEnablePowerSaving(void *hDeviceContext, WORD wListenInterval); -void PSvSendPSPOLL(void *hDeviceContext); -BOOL PSbSendNullPacket(void *hDeviceContext); -BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext); +int PSbConsiderPowerDown(struct vnt_private *, int bCheckRxDMA, + int bCheckCountToWakeUp); +void PSvDisablePowerSaving(struct vnt_private *); +void PSvEnablePowerSaving(struct vnt_private *, u16 wListenInterval); +void PSvSendPSPOLL(struct vnt_private *); +int PSbSendNullPacket(struct vnt_private *); +int PSbIsNextTBTTWakeUp(struct vnt_private *); #endif /* __POWER_H__ */ diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 74c0598..a415705 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -69,7 +69,7 @@ static int msglevel =MSG_LEVEL_INFO; -BYTE abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = { +u8 abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = { {0x03, 0xF7, 0x90}, {0x03, 0x33, 0x31}, {0x01, 0xB8, 0x02}, @@ -87,7 +87,7 @@ BYTE abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = { {0x00, 0x58, 0x0F} }; -BYTE abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = { +u8 abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = { {0x03, 0xF7, 0x90}, // channel = 1, Tf = 2412MHz {0x03, 0xF7, 0x90}, // channel = 2, Tf = 2417MHz {0x03, 0xE7, 0x90}, // channel = 3, Tf = 2422MHz @@ -104,7 +104,7 @@ BYTE abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = { {0x03, 0xE7, 0xC0} // channel = 14, Tf = 2412M }; -BYTE abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = { +u8 abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = { {0x03, 0x33, 0x31}, // channel = 1, Tf = 2412MHz {0x0B, 0x33, 0x31}, // channel = 2, Tf = 2417MHz {0x03, 0x33, 0x31}, // channel = 3, Tf = 2422MHz @@ -123,7 +123,7 @@ BYTE abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = { // 40MHz reference frequency // Need to Pull PLLON(PE3) low when writing channel registers through 3-wire. -BYTE abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = { +u8 abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = { {0x20, 0x37, 0x90}, // Channel1 // Need modify for 11a {0x13, 0x33, 0x31}, // Channel1 // Need modify for 11a {0x84, 0x1F, 0xF2}, // Need modify for 11a: 451FE2 @@ -146,7 +146,7 @@ BYTE abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = { {0x1A, 0xBA, 0x8F} // Need modify for 11a: 12BACF }; -BYTE abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = { +u8 abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = { {0x2F, 0xF5, 0x20}, // Channel184 // Need modify for 11b/g {0x00, 0x00, 0x01}, // Channel184 // Need modify for 11b/g {0x45, 0x1F, 0xE2}, // Need modify for 11b/g @@ -165,7 +165,7 @@ BYTE abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = { {0x12, 0xBA, 0xCF} // Need modify for 11b/g }; -BYTE abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = { +u8 abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = { {0x20, 0x37, 0x90}, // channel = 1, Tf = 2412MHz {0x20, 0x37, 0x90}, // channel = 2, Tf = 2417MHz {0x20, 0x37, 0x90}, // channel = 3, Tf = 2422MHz @@ -231,7 +231,7 @@ BYTE abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = { {0x2F, 0xF6, 0x10} // channel = 165, Tf = 5825MHz (56) }; -BYTE abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = { +u8 abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = { {0x13, 0x33, 0x31}, // channel = 1, Tf = 2412MHz {0x1B, 0x33, 0x31}, // channel = 2, Tf = 2417MHz {0x03, 0x33, 0x31}, // channel = 3, Tf = 2422MHz @@ -295,7 +295,7 @@ BYTE abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = { {0x02, 0xAA, 0xB1} // channel = 165, Tf = 5825MHz (56) }; -BYTE abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = { +u8 abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = { {0x7F, 0xD7, 0x84}, // channel = 1, Tf = 2412MHz {0x7F, 0xD7, 0x84}, // channel = 2, Tf = 2417MHz {0x7F, 0xD7, 0x84}, // channel = 3, Tf = 2422MHz @@ -360,7 +360,7 @@ BYTE abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = { }; ///{{RobertYu:20051111 -BYTE abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = { +u8 abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x02, 0x82, 0xA1}, {0x03, 0xC6, 0xA2}, @@ -374,7 +374,7 @@ BYTE abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = { {0x02, 0x00, 0x2A} }; -BYTE abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = { +u8 abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x03, 0x02, 0x21}, //RobertYu:20060327 {0x03, 0xC6, 0xA2}, @@ -389,7 +389,7 @@ BYTE abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = { }; -BYTE abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = { +u8 abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = { {0x01, 0x97, 0x83}, // channel = 1, Tf = 2412MHz {0x01, 0x97, 0x83}, // channel = 2, Tf = 2417MHz {0x01, 0x97, 0x93}, // channel = 3, Tf = 2422MHz @@ -406,7 +406,7 @@ BYTE abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = { {0x03, 0x37, 0xC3} // channel = 14, Tf = 2484MHz }; -BYTE abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = { +u8 abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = { {0x02, 0x66, 0x64}, // channel = 1, Tf = 2412MHz {0x03, 0x66, 0x64}, // channel = 2, Tf = 2417MHz {0x00, 0x66, 0x64}, // channel = 3, Tf = 2422MHz @@ -426,7 +426,7 @@ BYTE abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = { //{{RobertYu:20060502, TWIF 1.14, LO Current for 11b mode -DWORD dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = { +u32 dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = { 0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz 0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz 0x0235C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz @@ -446,7 +446,7 @@ DWORD dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = { //{{RobertYu:20060609 -BYTE abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { // 11b/g mode +u8 abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { /* 11b/g mode */ {0x03, 0xFF, 0x80}, //update for mode// {0x02, 0x08, 0x81}, {0x00, 0xC6, 0x02}, @@ -469,7 +469,7 @@ BYTE abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { // 11b/g mode // channel56, 5280MHz 0x00C402 for disable Frac // other channels 0x00C602 -BYTE abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = { +u8 abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = { {0x02, 0x05, 0x03}, // channel = 1, Tf = 2412MHz {0x01, 0x15, 0x03}, // channel = 2, Tf = 2417MHz {0x03, 0xC5, 0x03}, // channel = 3, Tf = 2422MHz @@ -535,7 +535,7 @@ BYTE abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = { {0x00, 0x06, 0x03} // channel = 165, Tf = 5825MHz (56), TBD }; -BYTE abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = { +u8 abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = { {0x01, 0x99, 0x94}, // channel = 1, Tf = 2412MHz {0x02, 0x44, 0x44}, // channel = 2, Tf = 2417MHz {0x02, 0xEE, 0xE4}, // channel = 3, Tf = 2422MHz @@ -606,7 +606,7 @@ BYTE abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = { * -*/ -const DWORD dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = { +const u32 dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = { 0x04040900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, 0x04041900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, 0x04042900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, @@ -682,7 +682,7 @@ const DWORD dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = { // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64, // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56) -const BYTE RFaby11aChannelIndex[200] = { +const u8 RFaby11aChannelIndex[200] = { // 1 2 3 4 5 6 7 8 9 10 00, 00, 00, 00, 00, 00, 23, 24, 25, 00, // 10 26, 27, 00, 00, 00, 28, 00, 00, 00, 00, // 20 @@ -719,27 +719,23 @@ const BYTE RFaby11aChannelIndex[200] = { * Out: * none * - * Return Value: TRUE if succeeded; FALSE if failed. + * Return Value: true if succeeded; false if failed. * */ -BOOL IFRFbWriteEmbedded (PSDevice pDevice, DWORD dwData) +int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) { - BYTE pbyData[4]; + u8 pbyData[4]; - pbyData[0] = (BYTE)dwData; - pbyData[1] = (BYTE)(dwData>>8); - pbyData[2] = (BYTE)(dwData>>16); - pbyData[3] = (BYTE)(dwData>>24); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_IFRF, - 0, - 0, - 4, - pbyData - ); + pbyData[0] = (u8)dwData; + pbyData[1] = (u8)(dwData >> 8); + pbyData[2] = (u8)(dwData >> 16); + pbyData[3] = (u8)(dwData >> 24); + + CONTROLnsRequestOut(pDevice, + MESSAGE_TYPE_WRITE_IFRF, 0, 0, 4, pbyData); - return TRUE; + return true; } @@ -753,21 +749,16 @@ BOOL IFRFbWriteEmbedded (PSDevice pDevice, DWORD dwData) * Out: * none * - * Return Value: TRUE if succeeded; FALSE if failed. + * Return Value: true if succeeded; false if failed. * */ -BOOL RFbSetPower ( - PSDevice pDevice, - unsigned int uRATE, - unsigned int uCH - ) +int RFbSetPower(struct vnt_private *pDevice, u32 uRATE, u32 uCH) { -BOOL bResult = TRUE; -BYTE byPwr = pDevice->byCCKPwr; + int bResult = true; + u8 byPwr = pDevice->byCCKPwr; - if (pDevice->dwDiagRefCount != 0) { - return TRUE; - } + if (pDevice->dwDiagRefCount) + return true; if (uCH == 0) return -EINVAL; @@ -810,19 +801,16 @@ BYTE byPwr = pDevice->byCCKPwr; * Out: * none * - * Return Value: TRUE if succeeded; FALSE if failed. + * Return Value: true if succeeded; false if failed. * */ -BOOL RFbRawSetPower ( - PSDevice pDevice, - BYTE byPwr, - unsigned int uRATE - ) + +int RFbRawSetPower(struct vnt_private *pDevice, u8 byPwr, u32 uRATE) { -BOOL bResult = TRUE; + int bResult = true; if (pDevice->byCurPwr == byPwr) - return TRUE; + return true; pDevice->byCurPwr = byPwr; @@ -830,7 +818,7 @@ BOOL bResult = TRUE; case RF_AL2230 : if (pDevice->byCurPwr >= AL2230_PWR_IDX_LEN) - return FALSE; + return false; bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[pDevice->byCurPwr]); if (uRATE <= RATE_11M) bResult &= IFRFbWriteEmbedded(pDevice, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); @@ -840,7 +828,7 @@ BOOL bResult = TRUE; case RF_AL2230S : if (pDevice->byCurPwr >= AL2230_PWR_IDX_LEN) - return FALSE; + return false; bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[pDevice->byCurPwr]); if (uRATE <= RATE_11M) { bResult &= IFRFbWriteEmbedded(pDevice, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); @@ -863,7 +851,7 @@ BOOL bResult = TRUE; bResult &= IFRFbWriteEmbedded(pDevice, 0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW); } - if (pDevice->byCurPwr > AL7230_PWR_IDX_LEN) return FALSE; + if (pDevice->byCurPwr > AL7230_PWR_IDX_LEN) return false; // 0x080F1B00 for 3 wire control TxGain(D10) and 0x31 as TX Gain value dwMax7230Pwr = 0x080C0B00 | ( (pDevice->byCurPwr) << 12 ) | @@ -879,7 +867,7 @@ BOOL bResult = TRUE; DWORD dwVT3226Pwr; if (pDevice->byCurPwr >= VT3226_PWR_IDX_LEN) - return FALSE; + return false; dwVT3226Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0x17 << 8 ) /* Reg7 */ | (BY_VT3226_REG_LEN << 3 ) | IFREGCTL_REGW; bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226Pwr); @@ -891,7 +879,7 @@ BOOL bResult = TRUE; DWORD dwVT3226Pwr; if (pDevice->byCurPwr >= VT3226_PWR_IDX_LEN) - return FALSE; + return false; if (uRATE <= RATE_11M) { @@ -900,14 +888,22 @@ BOOL bResult = TRUE; bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226Pwr); bResult &= IFRFbWriteEmbedded(pDevice, 0x03C6A200+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); - if (pDevice->sMgmtObj.eScanState != WMAC_NO_SCANNING) { - // scanning, the channel number is pDevice->uScanChannel - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uScanChannel); - bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uScanChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uCurrChannel); - bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uCurrChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate - } + if (pDevice->vnt_mgmt.eScanState != WMAC_NO_SCANNING) { + /* scanning, channel number is pDevice->uScanChannel */ + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + pDevice->vnt_mgmt.uScanChannel); + bResult &= IFRFbWriteEmbedded(pDevice, + dwVT3226D0LoCurrentTable[pDevice-> + vnt_mgmt.uScanChannel - 1]); + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + pDevice->vnt_mgmt.uCurrChannel); + bResult &= IFRFbWriteEmbedded(pDevice, + dwVT3226D0LoCurrentTable[pDevice-> + vnt_mgmt.uCurrChannel - 1]); + } bResult &= IFRFbWriteEmbedded(pDevice, 0x015C0800+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060420, ok now, new switching power (mini-pci can have bigger power consumption) } else { @@ -928,7 +924,7 @@ BOOL bResult = TRUE; DWORD dwVT3342Pwr; if (pDevice->byCurPwr >= VT3342_PWR_IDX_LEN) - return FALSE; + return false; dwVT3342Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0x27 << 8 ) /* Reg7 */ | (BY_VT3342_REG_LEN << 3 ) | IFREGCTL_REGW; @@ -957,17 +953,12 @@ BOOL bResult = TRUE; * Return Value: none * -*/ -void -RFvRSSITodBm ( - PSDevice pDevice, - BYTE byCurrRSSI, - long * pldBm - ) +void RFvRSSITodBm(struct vnt_private *pDevice, u8 byCurrRSSI, long *pldBm) { - BYTE byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03); - signed long b = (byCurrRSSI & 0x3F); - signed long a = 0; - BYTE abyAIROHARF[4] = {0, 18, 0, 40}; + u8 byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03); + signed long b = (byCurrRSSI & 0x3F); + signed long a = 0; + u8 abyAIROHARF[4] = {0, 18, 0, 40}; switch (pDevice->byRFType) { case RF_AL2230: @@ -987,15 +978,12 @@ RFvRSSITodBm ( -void -RFbRFTableDownload ( - PSDevice pDevice - ) +void RFbRFTableDownload(struct vnt_private *pDevice) { -WORD wLength1 = 0,wLength2 = 0 ,wLength3 = 0; -PBYTE pbyAddr1 = NULL,pbyAddr2 = NULL,pbyAddr3 = NULL; -WORD wLength,wValue; -BYTE abyArray[256]; + u16 wLength1 = 0, wLength2 = 0, wLength3 = 0; + u8 *pbyAddr1 = NULL, *pbyAddr2 = NULL, *pbyAddr3 = NULL; + u16 wLength, wValue; + u8 abyArray[256]; switch ( pDevice->byRFType ) { case RF_AL2230: @@ -1134,21 +1122,19 @@ BYTE abyArray[256]; } -// RobertYu:20060412, TWIF1.11 adjust LO Current for 11b mode -BOOL s_bVT3226D0_11bLoCurrentAdjust( - PSDevice pDevice, - BYTE byChannel, - BOOL b11bMode) +int s_bVT3226D0_11bLoCurrentAdjust(struct vnt_private *pDevice, u8 byChannel, + int b11bMode) { - BOOL bResult; + int bResult = true; - bResult = TRUE; - if( b11bMode ) - bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[byChannel-1]); - else - bResult &= IFRFbWriteEmbedded(pDevice, 0x016BC600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060412 + if (b11bMode) + bResult &= IFRFbWriteEmbedded(pDevice, + dwVT3226D0LoCurrentTable[byChannel-1]); + else + bResult &= IFRFbWriteEmbedded(pDevice, 0x016bc600 + + (BY_VT3226_REG_LEN << 3) + IFREGCTL_REGW); - return bResult; + return bResult; } diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 72eb27a..9f70cf7 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -60,25 +60,15 @@ /*--------------------- Export Classes ----------------------------*/ /*--------------------- Export Variables --------------------------*/ -extern const BYTE RFaby11aChannelIndex[200]; +extern const u8 RFaby11aChannelIndex[200]; /*--------------------- Export Functions --------------------------*/ -BOOL IFRFbWriteEmbedded(PSDevice pDevice, DWORD dwData); -BOOL RFbSetPower(PSDevice pDevice, unsigned int uRATE, unsigned int uCH); - -BOOL RFbRawSetPower( - PSDevice pDevice, - BYTE byPwr, - unsigned int uRATE - ); - -void RFvRSSITodBm(PSDevice pDevice, BYTE byCurrRSSI, long *pldBm); -void RFbRFTableDownload(PSDevice pDevice); - -BOOL s_bVT3226D0_11bLoCurrentAdjust( - PSDevice pDevice, - BYTE byChannel, - BOOL b11bMode - ); +int IFRFbWriteEmbedded(struct vnt_private *, u32 dwData); +int RFbSetPower(struct vnt_private *, u32 uRATE, u32 uCH); +int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE); +void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); +void RFbRFTableDownload(struct vnt_private *pDevice); +int s_bVT3226D0_11bLoCurrentAdjust(struct vnt_private *, u8 byChannel, + int b11bMode); #endif /* __RF_H__ */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 83c04e1..b939dcf 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -106,181 +106,71 @@ const WORD wFB_Opt1[2][5] = { /*--------------------- Static Functions --------------------------*/ -static -void -s_vSaveTxPktInfo( - PSDevice pDevice, - BYTE byPktNum, - PBYTE pbyDestAddr, - WORD wPktLength, - WORD wFIFOCtl -); - -static -void * -s_vGetFreeContext( - PSDevice pDevice - ); - - -static -void -s_vGenerateTxParameter( - PSDevice pDevice, - BYTE byPktType, - WORD wCurrentRate, - void *pTxBufHead, - void *pvRrvTime, - void *pvRTS, - void *pvCTS, - unsigned int cbFrameSize, - BOOL bNeedACK, - unsigned int uDMAIdx, - PSEthernetHeader psEthHeader - ); - - -static unsigned int s_uFillDataHead( - PSDevice pDevice, - BYTE byPktType, - WORD wCurrentRate, - void *pTxDataHead, - unsigned int cbFrameLength, - unsigned int uDMAIdx, - BOOL bNeedAck, - unsigned int uFragIdx, - unsigned int cbLastFragmentSize, - unsigned int uMACfragNum, - BYTE byFBOption - ); - - - - -static -void -s_vGenerateMACHeader ( - PSDevice pDevice, - PBYTE pbyBufferAddr, - WORD wDuration, - PSEthernetHeader psEthHeader, - BOOL bNeedEncrypt, - WORD wFragType, - unsigned int uDMAIdx, - unsigned int uFragIdx - ); - -static -void -s_vFillTxKey( - PSDevice pDevice, - PBYTE pbyBuf, - PBYTE pbyIVHead, - PSKeyItem pTransmitKey, - PBYTE pbyHdrBuf, - WORD wPayloadLen, - PBYTE pMICHDR - ); - -static -void -s_vSWencryption ( - PSDevice pDevice, - PSKeyItem pTransmitKey, - PBYTE pbyPayloadHead, - WORD wPayloadSize - ); - -static unsigned int s_uGetTxRsvTime( - PSDevice pDevice, - BYTE byPktType, - unsigned int cbFrameLength, - WORD wRate, - BOOL bNeedAck - ); - - -static unsigned int s_uGetRTSCTSRsvTime( - PSDevice pDevice, - BYTE byRTSRsvType, - BYTE byPktType, - unsigned int cbFrameLength, - WORD wCurrentRate - ); - -static -void -s_vFillCTSHead ( - PSDevice pDevice, - unsigned int uDMAIdx, - BYTE byPktType, - void *pvCTS, - unsigned int cbFrameLength, - BOOL bNeedAck, - BOOL bDisCRC, - WORD wCurrentRate, - BYTE byFBOption - ); - -static -void -s_vFillRTSHead( - PSDevice pDevice, - BYTE byPktType, - void *pvRTS, - unsigned int cbFrameLength, - BOOL bNeedAck, - BOOL bDisCRC, - PSEthernetHeader psEthHeader, - WORD wCurrentRate, - BYTE byFBOption - ); - -static unsigned int s_uGetDataDuration( - PSDevice pDevice, - BYTE byDurType, - unsigned int cbFrameLength, - BYTE byPktType, - WORD wRate, - BOOL bNeedAck, - unsigned int uFragIdx, - unsigned int cbLastFragmentSize, - unsigned int uMACfragNum, - BYTE byFBOption - ); - - -static -unsigned int -s_uGetRTSCTSDuration ( - PSDevice pDevice, - BYTE byDurType, - unsigned int cbFrameLength, - BYTE byPktType, - WORD wRate, - BOOL bNeedAck, - BYTE byFBOption - ); +static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum, + u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl); + +static void *s_vGetFreeContext(struct vnt_private *pDevice); + +static void s_vGenerateTxParameter(struct vnt_private *pDevice, + u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, + void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, + PSEthernetHeader psEthHeader); + +static u32 s_uFillDataHead(struct vnt_private *pDevice, + u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, + u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize, + u32 uMACfragNum, u8 byFBOption); + + +static void s_vGenerateMACHeader(struct vnt_private *pDevice, + u8 *pbyBufferAddr, u16 wDuration, PSEthernetHeader psEthHeader, + int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx); + +static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, + u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen, + u8 *pMICHDR); + +static void s_vSWencryption(struct vnt_private *pDevice, + PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize); + +static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, + u32 cbFrameLength, u16 wRate, int bNeedAck); + +static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, + u8 byPktType, u32 cbFrameLength, u16 wCurrentRate); + +static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, + u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, + int bDisCRC, u16 wCurrentRate, u8 byFBOption); + +static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, + void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, + PSEthernetHeader psEthHeader, u16 wCurrentRate, u8 byFBOption); + +static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, + u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, + u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum, + u8 byFBOption); + +static unsigned int s_uGetRTSCTSDuration(struct vnt_private *pDevice, + u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate, + int bNeedAck, u8 byFBOption); /*--------------------- Export Variables --------------------------*/ -static -void * -s_vGetFreeContext( - PSDevice pDevice - ) +static void *s_vGetFreeContext(struct vnt_private *pDevice) { - PUSB_SEND_CONTEXT pContext = NULL; - PUSB_SEND_CONTEXT pReturnContext = NULL; - unsigned int ii; + PUSB_SEND_CONTEXT pContext = NULL; + PUSB_SEND_CONTEXT pReturnContext = NULL; + int ii; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n"); for (ii = 0; ii < pDevice->cbTD; ii++) { pContext = pDevice->apTD[ii]; - if (pContext->bBoolInUse == FALSE) { - pContext->bBoolInUse = TRUE; + if (pContext->bBoolInUse == false) { + pContext->bBoolInUse = true; pReturnContext = pContext; break; } @@ -292,11 +182,10 @@ s_vGetFreeContext( } -static -void -s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLength, WORD wFIFOCtl) +static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum, + u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl) { - PSStatCounter pStatistic=&(pDevice->scStatistic); + PSStatCounter pStatistic = &pDevice->scStatistic; if (is_broadcast_ether_addr(pbyDestAddr)) pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD; @@ -312,24 +201,15 @@ s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLe ETH_ALEN); } -static -void -s_vFillTxKey ( - PSDevice pDevice, - PBYTE pbyBuf, - PBYTE pbyIVHead, - PSKeyItem pTransmitKey, - PBYTE pbyHdrBuf, - WORD wPayloadLen, - PBYTE pMICHDR - ) +static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, + u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, + u16 wPayloadLen, u8 *pMICHDR) { - PDWORD pdwIV = (PDWORD) pbyIVHead; - PDWORD pdwExtIV = (PDWORD) ((PBYTE)pbyIVHead+4); - WORD wValue; - PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; - DWORD dwRevIVCounter; - + u32 *pdwIV = (u32 *)pbyIVHead; + u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); + u16 wValue; + PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; + u32 dwRevIVCounter; //Fill TXKEY @@ -430,18 +310,12 @@ s_vFillTxKey ( } -static -void -s_vSWencryption ( - PSDevice pDevice, - PSKeyItem pTransmitKey, - PBYTE pbyPayloadHead, - WORD wPayloadSize - ) +static void s_vSWencryption(struct vnt_private *pDevice, + PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize) { - unsigned int cbICVlen = 4; - DWORD dwICV = 0xFFFFFFFFL; - PDWORD pdwICV; + u32 cbICVlen = 4; + u32 dwICV = 0xffffffff; + u32 *pdwICV; if (pTransmitKey == NULL) return; @@ -479,17 +353,10 @@ s_vSWencryption ( PK_TYPE_11GB 2 PK_TYPE_11GA 3 */ -static -unsigned int -s_uGetTxRsvTime ( - PSDevice pDevice, - BYTE byPktType, - unsigned int cbFrameLength, - WORD wRate, - BOOL bNeedAck - ) +static u32 s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, + u32 cbFrameLength, u16 wRate, int bNeedAck) { - unsigned int uDataTime, uAckTime; + u32 uDataTime, uAckTime; uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); if (byPktType == PK_TYPE_11B) {//llb,CCK mode @@ -507,17 +374,10 @@ s_uGetTxRsvTime ( } //byFreqType: 0=>5GHZ 1=>2.4GHZ -static -unsigned int -s_uGetRTSCTSRsvTime ( - PSDevice pDevice, - BYTE byRTSRsvType, - BYTE byPktType, - unsigned int cbFrameLength, - WORD wCurrentRate - ) +static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, + u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate) { - unsigned int uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; + u32 uRrvTime, uRTSTime, uCTSTime, uAckTime, uDataTime; uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; @@ -549,23 +409,13 @@ s_uGetRTSCTSRsvTime ( } //byFreqType 0: 5GHz, 1:2.4Ghz -static -unsigned int -s_uGetDataDuration ( - PSDevice pDevice, - BYTE byDurType, - unsigned int cbFrameLength, - BYTE byPktType, - WORD wRate, - BOOL bNeedAck, - unsigned int uFragIdx, - unsigned int cbLastFragmentSize, - unsigned int uMACfragNum, - BYTE byFBOption - ) +static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, + u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, + u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum, + u8 byFBOption) { - BOOL bLastFrag = 0; - unsigned int uAckTime = 0, uNextPktTime = 0; + int bLastFrag = 0; + u32 uAckTime = 0, uNextPktTime = 0; if (uFragIdx == (uMACfragNum-1)) { bLastFrag = 1; @@ -712,25 +562,17 @@ s_uGetDataDuration ( break; } - ASSERT(FALSE); + ASSERT(false); return 0; } //byFreqType: 0=>5GHZ 1=>2.4GHZ -static -unsigned int -s_uGetRTSCTSDuration ( - PSDevice pDevice, - BYTE byDurType, - unsigned int cbFrameLength, - BYTE byPktType, - WORD wRate, - BOOL bNeedAck, - BYTE byFBOption - ) +static u32 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, + u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, + u8 byFBOption) { - unsigned int uCTSTime = 0, uDurTime = 0; + u32 uCTSTime = 0, uDurTime = 0; switch (byDurType) { @@ -814,24 +656,10 @@ s_uGetRTSCTSDuration ( } - - - -static -unsigned int -s_uFillDataHead ( - PSDevice pDevice, - BYTE byPktType, - WORD wCurrentRate, - void *pTxDataHead, - unsigned int cbFrameLength, - unsigned int uDMAIdx, - BOOL bNeedAck, - unsigned int uFragIdx, - unsigned int cbLastFragmentSize, - unsigned int uMACfragNum, - BYTE byFBOption - ) +static u32 s_uFillDataHead(struct vnt_private *pDevice, + u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, + u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize, + u32 uMACfragNum, u8 byFBOption) { if (pTxDataHead == NULL) { @@ -959,25 +787,12 @@ s_uFillDataHead ( return 0; } - - - -static -void -s_vFillRTSHead ( - PSDevice pDevice, - BYTE byPktType, - void *pvRTS, - unsigned int cbFrameLength, - BOOL bNeedAck, - BOOL bDisCRC, - PSEthernetHeader psEthHeader, - WORD wCurrentRate, - BYTE byFBOption - ) +static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, + void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, + PSEthernetHeader psEthHeader, u16 wCurrentRate, u8 byFBOption) { - unsigned int uRTSFrameLen = 20; - WORD wLen = 0x0000; + u32 uRTSFrameLen = 20; + u16 wLen = 0; if (pvRTS == NULL) return; @@ -1190,22 +1005,12 @@ s_vFillRTSHead ( } } -static -void -s_vFillCTSHead ( - PSDevice pDevice, - unsigned int uDMAIdx, - BYTE byPktType, - void *pvCTS, - unsigned int cbFrameLength, - BOOL bNeedAck, - BOOL bDisCRC, - WORD wCurrentRate, - BYTE byFBOption - ) +static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, + u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, + int bDisCRC, u16 wCurrentRate, u8 byFBOption) { - unsigned int uCTSFrameLen = 14; - WORD wLen = 0x0000; + u32 uCTSFrameLen = 14; + u16 wLen = 0; if (pvCTS == NULL) { return; @@ -1290,27 +1095,15 @@ s_vFillCTSHead ( * -*/ -static -void -s_vGenerateTxParameter ( - PSDevice pDevice, - BYTE byPktType, - WORD wCurrentRate, - void *pTxBufHead, - void *pvRrvTime, - void *pvRTS, - void *pvCTS, - unsigned int cbFrameSize, - BOOL bNeedACK, - unsigned int uDMAIdx, - PSEthernetHeader psEthHeader - ) +static void s_vGenerateTxParameter(struct vnt_private *pDevice, + u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, + void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, + PSEthernetHeader psEthHeader) { - unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ - WORD wFifoCtl; - BOOL bDisCRC = FALSE; - BYTE byFBOption = AUTO_FB_NONE; -// WORD wCurrentRate = pDevice->wCurrentRate; + u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ + u16 wFifoCtl; + int bDisCRC = false; + u8 byFBOption = AUTO_FB_NONE; //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n"); PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead; @@ -1318,7 +1111,7 @@ s_vGenerateTxParameter ( wFifoCtl = pFifoHead->wFIFOCtl; if (wFifoCtl & FIFOCTL_CRCDIS) { - bDisCRC = TRUE; + bDisCRC = true; } if (wFifoCtl & FIFOCTL_AUTO_FB_0) { @@ -1407,55 +1200,40 @@ s_vGenerateTxParameter ( unsigned int cbFragmentSize,//Hdr+payoad+FCS */ - -BOOL -s_bPacketToWirelessUsb( - PSDevice pDevice, - BYTE byPktType, - PBYTE usbPacketBuf, - BOOL bNeedEncryption, - unsigned int uSkbPacketLen, - unsigned int uDMAIdx, - PSEthernetHeader psEthHeader, - PBYTE pPacket, - PSKeyItem pTransmitKey, - unsigned int uNodeIndex, - WORD wCurrentRate, - unsigned int *pcbHeaderLen, - unsigned int *pcbTotalLen - ) +static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, + u8 *usbPacketBuf, int bNeedEncryption, u32 uSkbPacketLen, u32 uDMAIdx, + PSEthernetHeader psEthHeader, u8 *pPacket, PSKeyItem pTransmitKey, + u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int cbFrameSize, cbFrameBodySize; - PTX_BUFFER pTxBufHead; - unsigned int cb802_1_H_len; - unsigned int cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, - cbMACHdLen = 0, cbFCSlen = 4; - unsigned int cbMICHDR = 0; - BOOL bNeedACK,bRTS; - PBYTE pbyType,pbyMacHdr,pbyIVHead,pbyPayloadHead,pbyTxBufferAddr; - BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - BYTE abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - unsigned int uDuration; - unsigned int cbHeaderLength = 0, uPadding = 0; - void *pvRrvTime; - PSMICHDRHead pMICHDR; - void *pvRTS; - void *pvCTS; - void *pvTxDataHd; - BYTE byFBOption = AUTO_FB_NONE,byFragType; - WORD wTxBufSize; - DWORD dwMICKey0,dwMICKey1,dwMIC_Priority,dwCRC; - PDWORD pdwMIC_L,pdwMIC_R; - BOOL bSoftWEP = FALSE; - - + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 cbFrameSize, cbFrameBodySize; + PTX_BUFFER pTxBufHead; + u32 cb802_1_H_len; + u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; + u32 cbFCSlen = 4, cbMICHDR = 0; + int bNeedACK, bRTS; + u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead, *pbyTxBufferAddr; + u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] + = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; + u32 uDuration; + u32 cbHeaderLength = 0, uPadding = 0; + void *pvRrvTime; + PSMICHDRHead pMICHDR; + void *pvRTS; + void *pvCTS; + void *pvTxDataHd; + u8 byFBOption = AUTO_FB_NONE, byFragType; + u16 wTxBufSize; + u32 dwMICKey0, dwMICKey1, dwMIC_Priority, dwCRC; + u32 *pdwMIC_L, *pdwMIC_R; + int bSoftWEP = false; + + pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; - - pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; if (bNeedEncryption && pTransmitKey->pvKeyTable) { - if (((PSKeyTable)&pTransmitKey->pvKeyTable)->bSoftWEP == TRUE) - bSoftWEP = TRUE; /* WEP 256 */ + if (((PSKeyTable)pTransmitKey->pvKeyTable)->bSoftWEP == true) + bSoftWEP = true; /* WEP 256 */ } pTxBufHead = (PTX_BUFFER) usbPacketBuf; @@ -1478,23 +1256,23 @@ s_bPacketToWirelessUsb( pTxBufHead->wFIFOCtl |= (WORD)(byPktType<<8); if (pDevice->dwDiagRefCount != 0) { - bNeedACK = FALSE; + bNeedACK = false; pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); } else { //if (pDevice->dwDiagRefCount != 0) { if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { if (is_multicast_ether_addr(psEthHeader->abyDstAddr)) { - bNeedACK = FALSE; + bNeedACK = false; pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); } else { - bNeedACK = TRUE; + bNeedACK = true; pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; } } else { // MSDUs in Infra mode always need ACK - bNeedACK = TRUE; + bNeedACK = true; pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; } } //if (pDevice->dwDiagRefCount != 0) { @@ -1518,7 +1296,7 @@ s_bPacketToWirelessUsb( pTxBufHead->wFragCtl |= (WORD)(cbMACHdLen << 10); //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; } @@ -1533,7 +1311,7 @@ s_bPacketToWirelessUsb( } } - if (bSoftWEP != TRUE) { + if (bSoftWEP != true) { if ((bNeedEncryption) && (pTransmitKey != NULL)) { //WEP enabled if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104 pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; @@ -1564,7 +1342,7 @@ s_bPacketToWirelessUsb( cbICVlen = 8;//MIC cbMICHDR = sizeof(SMICHDRHead); } - if (bSoftWEP == FALSE) { + if (bSoftWEP == false) { //MAC Header should be padding 0 to DW alignment. uPadding = 4 - (cbMACHdLen%4); uPadding %= 4; @@ -1573,10 +1351,10 @@ s_bPacketToWirelessUsb( cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; - if ( (bNeedACK == FALSE) ||(cbFrameSize < pDevice->wRTSThreshold) ) { - bRTS = FALSE; + if ( (bNeedACK == false) ||(cbFrameSize < pDevice->wRTSThreshold) ) { + bRTS = false; } else { - bRTS = TRUE; + bRTS = true; pTxBufHead->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY); } @@ -1584,7 +1362,7 @@ s_bPacketToWirelessUsb( wTxBufSize = sizeof(STxBufHead); if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet if (byFBOption == AUTO_FB_NONE) { - if (bRTS == TRUE) {//RTS_need + if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); pvRTS = (PSRTS_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); @@ -1602,7 +1380,7 @@ s_bPacketToWirelessUsb( } } else { // Auto Fall Back - if (bRTS == TRUE) {//RTS_need + if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); pvRTS = (PSRTS_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); @@ -1610,7 +1388,7 @@ s_bPacketToWirelessUsb( pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB)); cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB) + sizeof(STxDataHead_g_FB); } - else if (bRTS == FALSE) { //RTS_needless + else if (bRTS == false) { //RTS_needless pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); pvRTS = NULL; @@ -1622,7 +1400,7 @@ s_bPacketToWirelessUsb( } else {//802.11a/b packet if (byFBOption == AUTO_FB_NONE) { - if (bRTS == TRUE) {//RTS_need + if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); pvRTS = (PSRTS_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); @@ -1630,7 +1408,7 @@ s_bPacketToWirelessUsb( pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab)); cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab) + sizeof(STxDataHead_ab); } - else if (bRTS == FALSE) { //RTS_needless, no MICHDR + else if (bRTS == false) { //RTS_needless, no MICHDR pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); pvRTS = NULL; @@ -1640,7 +1418,7 @@ s_bPacketToWirelessUsb( } } else { // Auto Fall Back - if (bRTS == TRUE) {//RTS_need + if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); pvRTS = (PSRTS_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); @@ -1648,7 +1426,7 @@ s_bPacketToWirelessUsb( pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB)); cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB) + sizeof(STxDataHead_a_FB); } - else if (bRTS == FALSE) { //RTS_needless + else if (bRTS == false) { //RTS_needless pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); pvRTS = NULL; @@ -1684,7 +1462,7 @@ s_bPacketToWirelessUsb( s_vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncryption, byFragType, uDMAIdx, 0); - if (bNeedEncryption == TRUE) { + if (bNeedEncryption == true) { //Fill TXKEY s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR); @@ -1729,14 +1507,14 @@ s_bPacketToWirelessUsb( ASSERT(uLength == cbNdisBodySize); - if ((bNeedEncryption == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { + if ((bNeedEncryption == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { /////////////////////////////////////////////////////////////////// - if (pDevice->sMgmtObj.eAuthenMode == WMAC_AUTH_WPANONE) { - dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); - } + if (pDevice->vnt_mgmt.eAuthenMode == WMAC_AUTH_WPANONE) { + dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); + dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); + } else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); @@ -1769,10 +1547,10 @@ s_bPacketToWirelessUsb( MIC_vGetMIC(pdwMIC_L, pdwMIC_R); MIC_vUnInit(); - if (pDevice->bTxMICFail == TRUE) { + if (pDevice->bTxMICFail == true) { *pdwMIC_L = 0; *pdwMIC_R = 0; - pDevice->bTxMICFail = FALSE; + pDevice->bTxMICFail = false; } //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen); @@ -1780,17 +1558,17 @@ s_bPacketToWirelessUsb( } - if (bSoftWEP == TRUE) { + if (bSoftWEP == true) { s_vSWencryption(pDevice, pTransmitKey, (pbyPayloadHead), (WORD)(cbFrameBodySize + cbMIClen)); - } else if ( ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) && (bNeedEncryption == TRUE)) || - ((pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) && (bNeedEncryption == TRUE)) || - ((pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) && (bNeedEncryption == TRUE)) ) { + } else if ( ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) && (bNeedEncryption == true)) || + ((pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) && (bNeedEncryption == true)) || + ((pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) && (bNeedEncryption == true)) ) { cbFrameSize -= cbICVlen; } - if (pDevice->bSoftwareGenCrcErr == TRUE) { + if (pDevice->bSoftwareGenCrcErr == true) { unsigned int cbLen; PDWORD pdwCRC; @@ -1815,7 +1593,7 @@ s_bPacketToWirelessUsb( pTxBufHead->wFragCtl |= (WORD)byFragType; - return TRUE; + return true; } @@ -1839,19 +1617,11 @@ s_bPacketToWirelessUsb( * -*/ -void -s_vGenerateMACHeader ( - PSDevice pDevice, - PBYTE pbyBufferAddr, - WORD wDuration, - PSEthernetHeader psEthHeader, - BOOL bNeedEncrypt, - WORD wFragType, - unsigned int uDMAIdx, - unsigned int uFragIdx - ) +static void s_vGenerateMACHeader(struct vnt_private *pDevice, + u8 *pbyBufferAddr, u16 wDuration, PSEthernetHeader psEthHeader, + int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx) { - PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; + PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; memset(pMACHeader, 0, (sizeof(S802_11Header))); //- sizeof(pMACHeader->dwIV))); @@ -1936,43 +1706,29 @@ s_vGenerateMACHeader ( * Out: * none * - * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise FALSE + * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise false * -*/ -CMD_STATUS csMgmt_xmit( - PSDevice pDevice, - PSTxMgmtPacket pPacket - ) +CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, + struct vnt_tx_mgmt *pPacket) { - BYTE byPktType; - PBYTE pbyTxBufferAddr; - void *pvRTS; - PSCTS pCTS; - void *pvTxDataHd; - unsigned int uDuration; - unsigned int cbReqCount; - PS802_11Header pMACHeader; - unsigned int cbHeaderSize; - unsigned int cbFrameBodySize; - BOOL bNeedACK; - BOOL bIsPSPOLL = FALSE; - PSTxBufHead pTxBufHead; - unsigned int cbFrameSize; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int uPadding = 0; - WORD wTxBufSize; - unsigned int cbMacHdLen; - SEthernetHeader sEthHeader; - void *pvRrvTime; - void *pMICHDR; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - WORD wCurrentRate = RATE_1M; - PTX_BUFFER pTX_Buffer; - PUSB_SEND_CONTEXT pContext; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PTX_BUFFER pTX_Buffer; + PSTxBufHead pTxBufHead; + PUSB_SEND_CONTEXT pContext; + PS802_11Header pMACHeader; + PSCTS pCTS; + SEthernetHeader sEthHeader; + u8 byPktType, *pbyTxBufferAddr; + void *pvRTS, *pvTxDataHd, *pvRrvTime, *pMICHDR; + u32 uDuration, cbReqCount, cbHeaderSize, cbFrameBodySize, cbFrameSize; + int bNeedACK, bIsPSPOLL = false; + u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; + u32 uPadding = 0; + u16 wTxBufSize; + u32 cbMacHdLen; + u16 wCurrentRate = RATE_1M; @@ -2028,10 +1784,10 @@ CMD_STATUS csMgmt_xmit( pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) { - bNeedACK = FALSE; + bNeedACK = false; } else { - bNeedACK = TRUE; + bNeedACK = true; pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; }; @@ -2043,7 +1799,7 @@ CMD_STATUS csMgmt_xmit( //pDevice->byPreambleType = PREAMBLE_LONG; // probe-response don't retry //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { - // bNeedACK = FALSE; + // bNeedACK = false; // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); //} } @@ -2051,7 +1807,7 @@ CMD_STATUS csMgmt_xmit( pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = TRUE; + bIsPSPOLL = true; cbMacHdLen = WLAN_HDR_ADDR2_LEN; } else { cbMacHdLen = WLAN_HDR_ADDR3_LEN; @@ -2063,7 +1819,7 @@ CMD_STATUS csMgmt_xmit( // Notes: // Although spec says MMPDU can be fragmented; In most case, // no one will send a MMPDU under fragmentation. With RTS may occur. - pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP + pDevice->bAES = false; //Set FRAGCTL_WEPTYP if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { @@ -2084,7 +1840,7 @@ CMD_STATUS csMgmt_xmit( cbIVlen = 8;//RSN Header cbICVlen = 8;//MIC pTxBufHead->wFragCtl |= FRAGCTL_AES; - pDevice->bAES = TRUE; + pDevice->bAES = true; } //MAC Header should be padding 0 to DW alignment. uPadding = 4 - (cbMacHdLen%4); @@ -2094,7 +1850,7 @@ CMD_STATUS csMgmt_xmit( cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; } //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() @@ -2155,12 +1911,12 @@ CMD_STATUS csMgmt_xmit( pbyPayloadHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); do { if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && - (pDevice->bLinkPass == TRUE)) { + (pDevice->bLinkPass == true)) { pbyBSSID = pDevice->abyBSSID; // get pairwise key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) { + if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { // get group key - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) { + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); break; } @@ -2171,13 +1927,13 @@ CMD_STATUS csMgmt_xmit( } // get group key pbyBSSID = pDevice->abyBroadcastAddr; - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { pTransmitKey = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); } - } while(FALSE); + } while(false); //Fill TXKEY s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, (PBYTE)pMACHeader, (WORD)cbFrameBodySize, NULL); @@ -2231,26 +1987,22 @@ CMD_STATUS csMgmt_xmit( } -CMD_STATUS -csBeacon_xmit( - PSDevice pDevice, - PSTxMgmtPacket pPacket - ) +CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, + struct vnt_tx_mgmt *pPacket) { - - unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; - unsigned int cbHeaderSize = 0; - WORD wTxBufSize = sizeof(STxShortBufHead); - PSTxShortBufHead pTxBufHead; - PS802_11Header pMACHeader; - PSTxDataHead_ab pTxDataHead; - WORD wCurrentRate; - unsigned int cbFrameBodySize; - unsigned int cbReqCount; - PBEACON_BUFFER pTX_Buffer; - PBYTE pbyTxBufferAddr; - PUSB_SEND_CONTEXT pContext; - CMD_STATUS status; + u32 cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; + u32 cbHeaderSize = 0; + u16 wTxBufSize = sizeof(STxShortBufHead); + PSTxShortBufHead pTxBufHead; + PS802_11Header pMACHeader; + PSTxDataHead_ab pTxDataHead; + u16 wCurrentRate; + u32 cbFrameBodySize; + u32 cbReqCount; + PBEACON_BUFFER pTX_Buffer; + u8 *pbyTxBufferAddr; + PUSB_SEND_CONTEXT pContext; + CMD_STATUS status; pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); @@ -2277,7 +2029,7 @@ csBeacon_xmit( ); //Get Duration and TimeStampOff pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameSize, PK_TYPE_11A, - wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE)); + wCurrentRate, false, 0, 0, 1, AUTO_FB_NONE)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); } else { @@ -2290,7 +2042,7 @@ csBeacon_xmit( ); //Get Duration and TimeStampOff pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameSize, PK_TYPE_11B, - wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE)); + wCurrentRate, false, 0, 0, 1, AUTO_FB_NONE)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); } @@ -2321,56 +2073,38 @@ csBeacon_xmit( } - - - -void -vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { - - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BYTE byPktType; - PBYTE pbyTxBufferAddr; - void *pvRTS; - void *pvCTS; - void *pvTxDataHd; - unsigned int uDuration; - unsigned int cbReqCount; - PS802_11Header pMACHeader; - unsigned int cbHeaderSize; - unsigned int cbFrameBodySize; - BOOL bNeedACK; - BOOL bIsPSPOLL = FALSE; - PSTxBufHead pTxBufHead; - unsigned int cbFrameSize; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int uPadding = 0; - unsigned int cbMICHDR = 0; - unsigned int uLength = 0; - DWORD dwMICKey0, dwMICKey1; - DWORD dwMIC_Priority; - PDWORD pdwMIC_L; - PDWORD pdwMIC_R; - WORD wTxBufSize; - unsigned int cbMacHdLen; - SEthernetHeader sEthHeader; - void *pvRrvTime; - void *pMICHDR; - WORD wCurrentRate = RATE_1M; - PUWLAN_80211HDR p80211Header; - unsigned int uNodeIndex = 0; - BOOL bNodeExist = FALSE; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - PBYTE pbyIVHead; - PBYTE pbyPayloadHead; - PBYTE pbyMacHdr; - unsigned int cbExtSuppRate = 0; - PTX_BUFFER pTX_Buffer; - PUSB_SEND_CONTEXT pContext; -// PWLAN_IE pItem; +void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) +{ + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 byPktType; + u8 *pbyTxBufferAddr; + void *pvRTS, *pvCTS, *pvTxDataHd; + u32 uDuration, cbReqCount; + PS802_11Header pMACHeader; + u32 cbHeaderSize, cbFrameBodySize; + int bNeedACK, bIsPSPOLL = false; + PSTxBufHead pTxBufHead; + u32 cbFrameSize; + u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; + u32 uPadding = 0; + u32 cbMICHDR = 0, uLength = 0; + u32 dwMICKey0, dwMICKey1; + u32 dwMIC_Priority; + u32 *pdwMIC_L, *pdwMIC_R; + u16 wTxBufSize; + u32 cbMacHdLen; + SEthernetHeader sEthHeader; + void *pvRrvTime, *pMICHDR; + u32 wCurrentRate = RATE_1M; + PUWLAN_80211HDR p80211Header; + u32 uNodeIndex = 0; + int bNodeExist = false; + SKeyItem STempKey; + PSKeyItem pTransmitKey = NULL; + u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; + u32 cbExtSuppRate = 0; + PTX_BUFFER pTX_Buffer; + PUSB_SEND_CONTEXT pContext; pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; @@ -2435,18 +2169,18 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { - bNeedACK = FALSE; + bNeedACK = false; if (pDevice->bEnableHostWEP) { uNodeIndex = 0; - bNodeExist = TRUE; + bNodeExist = true; } } else { if (pDevice->bEnableHostWEP) { if (BSSbIsSTAInNodeDB(pDevice, (PBYTE)(p80211Header->sA3.abyAddr1), &uNodeIndex)) - bNodeExist = TRUE; + bNodeExist = true; } - bNeedACK = TRUE; + bNeedACK = true; pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; }; @@ -2459,7 +2193,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { // probe-response don't retry //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { - // bNeedACK = FALSE; + // bNeedACK = false; // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); //} } @@ -2467,7 +2201,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = TRUE; + bIsPSPOLL = true; cbMacHdLen = WLAN_HDR_ADDR2_LEN; } else { cbMacHdLen = WLAN_HDR_ADDR3_LEN; @@ -2496,7 +2230,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { // Notes: // Although spec says MMPDU can be fragmented; In most case, // no one will send a MMPDU under fragmentation. With RTS may occur. - pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP + pDevice->bAES = false; //Set FRAGCTL_WEPTYP if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { @@ -2519,7 +2253,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { cbICVlen = 8;//MIC cbMICHDR = sizeof(SMICHDRHead); pTxBufHead->wFragCtl |= FRAGCTL_AES; - pDevice->bAES = TRUE; + pDevice->bAES = true; } //MAC Header should be padding 0 to DW alignment. uPadding = 4 - (cbMacHdLen%4); @@ -2529,7 +2263,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; } //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() @@ -2646,10 +2380,10 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { MIC_vGetMIC(pdwMIC_L, pdwMIC_R); MIC_vUnInit(); - if (pDevice->bTxMICFail == TRUE) { + if (pDevice->bTxMICFail == true) { *pdwMIC_L = 0; *pdwMIC_R = 0; - pDevice->bTxMICFail = FALSE; + pDevice->bTxMICFail = false; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); @@ -2729,29 +2463,30 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { * Return Value: NULL */ -int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) +int nsDMA_tx_packet(struct vnt_private *pDevice, + u32 uDMAIdx, struct sk_buff *skb) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int BytesToWrite = 0, uHeaderLen = 0; - unsigned int uNodeIndex = 0; - BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - WORD wAID; - BYTE byPktType; - BOOL bNeedEncryption = FALSE; - PSKeyItem pTransmitKey = NULL; - SKeyItem STempKey; - unsigned int ii; - BOOL bTKIP_UseGTK = FALSE; - BOOL bNeedDeAuth = FALSE; - PBYTE pbyBSSID; - BOOL bNodeExist = FALSE; - PUSB_SEND_CONTEXT pContext; - BOOL fConvertedPacket; - PTX_BUFFER pTX_Buffer; - unsigned int status; - WORD wKeepRate = pDevice->wCurrentRate; - struct net_device_stats* pStats = &pDevice->stats; - BOOL bTxeapol_key = FALSE; + struct net_device_stats *pStats = &pDevice->stats; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 BytesToWrite = 0, uHeaderLen = 0; + u32 uNodeIndex = 0; + u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; + u16 wAID; + u8 byPktType; + int bNeedEncryption = false; + PSKeyItem pTransmitKey = NULL; + SKeyItem STempKey; + int ii; + int bTKIP_UseGTK = false; + int bNeedDeAuth = false; + u8 *pbyBSSID; + int bNodeExist = false; + PUSB_SEND_CONTEXT pContext; + bool fConvertedPacket; + PTX_BUFFER pTX_Buffer; + u32 status; + u16 wKeepRate = pDevice->wCurrentRate; + int bTxeapol_key = false; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { @@ -2763,7 +2498,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) if (is_multicast_ether_addr((PBYTE)(skb->data))) { uNodeIndex = 0; - bNodeExist = TRUE; + bNodeExist = true; if (pMgmt->sNodeDBTable[0].bPSEnable) { skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb); @@ -2808,11 +2543,11 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) }else { pDevice->byPreambleType = PREAMBLE_LONG; } - bNodeExist = TRUE; + bNodeExist = true; } } - if (bNodeExist == FALSE) { + if (bNodeExist == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Unknown STA not found in node DB \n"); dev_kfree_skb_irq(skb); return 0; @@ -2844,22 +2579,22 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) /* 802.1x OR eapol-key challenge frame transfer */ if (((Protocol_Version == 1) || (Protocol_Version == 2)) && (Packet_Type == 3)) { - bTxeapol_key = TRUE; + bTxeapol_key = true; if(!(Key_info & BIT3) && //WPA or RSN group-key challenge (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key if(Descriptor_type==254) { - pDevice->fWPA_Authened = TRUE; + pDevice->fWPA_Authened = true; PRINT_K("WPA "); } else { - pDevice->fWPA_Authened = TRUE; + pDevice->fWPA_Authened = true; PRINT_K("WPA2(re-keying) "); } PRINT_K("Authentication completed!!\n"); } else if((Key_info & BIT3) && (Descriptor_type==2) && //RSN pairwise-key challenge (Key_info & BIT8) && (Key_info & BIT9)) { - pDevice->fWPA_Authened = TRUE; + pDevice->fWPA_Authened = true; PRINT_K("WPA2 Authentication completed!!\n"); } } @@ -2867,18 +2602,18 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) } //mike add:station mode check eapol-key challenge<--- - if (pDevice->bEncryptionEnable == TRUE) { - bNeedEncryption = TRUE; + if (pDevice->bEncryptionEnable == true) { + bNeedEncryption = true; // get Transmit key do { if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { pbyBSSID = pDevice->abyBSSID; // get pairwise key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) { + if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { // get group key - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) { - bTKIP_UseGTK = TRUE; + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { + bTKIP_UseGTK = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); break; } @@ -2895,12 +2630,12 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"\n"); // get pairwise key - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) break; } // get group key pbyBSSID = pDevice->abyBroadcastAddr; - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { pTransmitKey = NULL; if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); @@ -2908,15 +2643,15 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) else DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"NOT IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); } else { - bTKIP_UseGTK = TRUE; + bTKIP_UseGTK = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); } - } while(FALSE); + } while(false); } if (pDevice->bEnableHostWEP) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex); - if (pDevice->bEncryptionEnable == TRUE) { + if (pDevice->bEncryptionEnable == true) { pTransmitKey = &STempKey; pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; @@ -3015,23 +2750,23 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) byPktType = PK_TYPE_11B; } - if (bNeedEncryption == TRUE) { + if (bNeedEncryption == true) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType)); if ((pDevice->sTxEthHeader.wType) == cpu_to_be16(ETH_P_PAE)) { - bNeedEncryption = FALSE; + bNeedEncryption = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType)); if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { if (pTransmitKey == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Don't Find TX KEY\n"); } else { - if (bTKIP_UseGTK == TRUE) { + if (bTKIP_UseGTK == true) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n"); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", pTransmitKey->dwKeyIndex); - bNeedEncryption = TRUE; + bNeedEncryption = true; } } } @@ -3041,7 +2776,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", pTransmitKey->dwKeyIndex); - bNeedEncryption = TRUE; + bNeedEncryption = true; } } } @@ -3049,7 +2784,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) if (pTransmitKey == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n"); - pContext->bBoolInUse = FALSE; + pContext->bBoolInUse = false; dev_kfree_skb_irq(skb); pStats->tx_dropped++; return STATUS_FAILURE; @@ -3065,18 +2800,18 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) &uHeaderLen, &BytesToWrite ); - if (fConvertedPacket == FALSE) { - pContext->bBoolInUse = FALSE; + if (fConvertedPacket == false) { + pContext->bBoolInUse = false; dev_kfree_skb_irq(skb); return STATUS_FAILURE; } - if ( pDevice->bEnablePSMode == TRUE ) { + if ( pDevice->bEnablePSMode == true ) { if ( !pDevice->bPSModeTxBurst ) { bScheduleCommand((void *) pDevice, WLAN_CMD_MAC_DISPOWERSAVING, NULL); - pDevice->bPSModeTxBurst = TRUE; + pDevice->bPSModeTxBurst = true; } } @@ -3092,14 +2827,14 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) status = PIPEnsSendBulkOut(pDevice,pContext); - if (bNeedDeAuth == TRUE) { + if (bNeedDeAuth == true) { WORD wReason = WLAN_MGMT_REASON_MIC_FAILURE; bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (PBYTE) &wReason); } if(status!=STATUS_PENDING) { - pContext->bBoolInUse = FALSE; + pContext->bBoolInUse = false; dev_kfree_skb_irq(skb); return STATUS_FAILURE; } @@ -3120,49 +2855,43 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) * pPacket - Pointer to rx packet * cbPacketSize - rx ethernet frame size * Out: - * TURE, FALSE + * TURE, false * - * Return Value: Return TRUE if packet is copy to dma1; otherwise FALSE + * Return Value: Return true if packet is copy to dma1; otherwise false */ - -BOOL -bRelayPacketSend ( - PSDevice pDevice, - PBYTE pbySkbData, - unsigned int uDataLen, - unsigned int uNodeIndex - ) +int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, + u32 uNodeIndex) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int BytesToWrite = 0, uHeaderLen = 0; - BYTE byPktType = PK_TYPE_11B; - BOOL bNeedEncryption = FALSE; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - PBYTE pbyBSSID; - PUSB_SEND_CONTEXT pContext; - BYTE byPktTyp; - BOOL fConvertedPacket; - PTX_BUFFER pTX_Buffer; - unsigned int status; - WORD wKeepRate = pDevice->wCurrentRate; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u32 BytesToWrite = 0, uHeaderLen = 0; + u8 byPktType = PK_TYPE_11B; + int bNeedEncryption = false; + SKeyItem STempKey; + PSKeyItem pTransmitKey = NULL; + u8 *pbyBSSID; + PUSB_SEND_CONTEXT pContext; + u8 byPktTyp; + int fConvertedPacket; + PTX_BUFFER pTX_Buffer; + u32 status; + u16 wKeepRate = pDevice->wCurrentRate; pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); if (NULL == pContext) { - return FALSE; + return false; } memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, ETH_HLEN); - if (pDevice->bEncryptionEnable == TRUE) { - bNeedEncryption = TRUE; + if (pDevice->bEncryptionEnable == true) { + bNeedEncryption = true; // get group key pbyBSSID = pDevice->abyBroadcastAddr; - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { + if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { pTransmitKey = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode); } else { @@ -3186,8 +2915,8 @@ bRelayPacketSend ( } if ( bNeedEncryption && (pTransmitKey == NULL) ) { - pContext->bBoolInUse = FALSE; - return FALSE; + pContext->bBoolInUse = false; + return false; } byPktTyp = (BYTE)pDevice->byPacketType; @@ -3235,9 +2964,9 @@ bRelayPacketSend ( &uHeaderLen, &BytesToWrite ); - if (fConvertedPacket == FALSE) { - pContext->bBoolInUse = FALSE; - return FALSE; + if (fConvertedPacket == false) { + pContext->bBoolInUse = false; + return false; } pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]); @@ -3252,6 +2981,6 @@ bRelayPacketSend ( status = PIPEnsSendBulkOut(pDevice,pContext); - return TRUE; + return true; } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index dd2198a..9f53702 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -665,30 +665,11 @@ typedef struct tagSBEACON_BUFFER /*--------------------- Export Functions --------------------------*/ -BOOL -bPacketToWirelessUsb( - PSDevice pDevice, - BYTE byPktType, - PBYTE usbPacketBuf, - BOOL bNeedEncrypt, - unsigned int cbPayloadSize, - unsigned int uDMAIdx, - PSEthernetHeader psEthHeader, - PBYTE pPacket, - PSKeyItem pTransmitKey, - unsigned int uNodeIndex, - WORD wCurrentRate, - unsigned int *pcbHeaderLen, - unsigned int *pcbTotalLen - ); - -void vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb); -int nsDMA_tx_packet(PSDevice pDevice, - unsigned int uDMAIdx, - struct sk_buff *skb); -CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); -CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); -BOOL bRelayPacketSend(PSDevice pDevice, PBYTE pbySkbData, - unsigned int uDataLen, unsigned int uNodeIndex); +void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); +int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb); +CMD_STATUS csMgmt_xmit(struct vnt_private *, struct vnt_tx_mgmt *); +CMD_STATUS csBeacon_xmit(struct vnt_private *, struct vnt_tx_mgmt *); +int bRelayPacketSend(struct vnt_private *, u8 *pbySkbData, u32 uDataLen, + u32 uNodeIndex); #endif /* __RXTX_H__ */ diff --git a/drivers/staging/vt6656/tether.c b/drivers/staging/vt6656/tether.c index 083b215..95286c4 100644 --- a/drivers/staging/vt6656/tether.c +++ b/drivers/staging/vt6656/tether.c @@ -93,16 +93,16 @@ BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr) * Out: * none * - * Return Value: TRUE if ok; FALSE if error. + * Return Value: true if ok; false if error. * */ -BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength) +bool ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength) { DWORD dwCRC; dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) - return FALSE; - return TRUE; + return false; + return true; } diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index 8c1f5d2..2f8f485 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -161,6 +161,6 @@ S802_11Header, *PS802_11Header; BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr); //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr); -BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength); +bool ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength); #endif /* __TETHER_H__ */ diff --git a/drivers/staging/vt6656/ttype.h b/drivers/staging/vt6656/ttype.h index dfbf747..d7b6489 100644 --- a/drivers/staging/vt6656/ttype.h +++ b/drivers/staging/vt6656/ttype.h @@ -33,33 +33,12 @@ /******* Common definitions and typedefs ***********************************/ -typedef int BOOL; - -#if !defined(TRUE) -#define TRUE 1 -#endif -#if !defined(FALSE) -#define FALSE 0 -#endif - /****** Simple typedefs ***************************************************/ typedef u8 BYTE; typedef u16 WORD; typedef u32 DWORD; -// QWORD is for those situation that we want -// an 8-byte-aligned 8 byte long structure -// which is NOT really a floating point number. -typedef union tagUQuadWord { - struct { - u32 dwLowDword; - u32 dwHighDword; - } u; - double DoNotUseThisField; -} UQuadWord; -typedef UQuadWord QWORD; // 64-bit - /****** Common pointer types ***********************************************/ typedef u32 ULONG_PTR; @@ -73,6 +52,4 @@ typedef WORD * PWORD; typedef DWORD * PDWORD; -typedef QWORD * PQWORD; - #endif /* __TTYPE_H__ */ diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index fc68518..00fd0f8 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -67,51 +67,18 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Variables --------------------------*/ /*--------------------- Static Functions --------------------------*/ -static -void -s_nsInterruptUsbIoCompleteRead( - struct urb *urb - ); - - -static -void -s_nsBulkInUsbIoCompleteRead( - struct urb *urb - ); - - -static -void -s_nsBulkOutIoCompleteWrite( - struct urb *urb - ); - - -static -void -s_nsControlInUsbIoCompleteRead( - struct urb *urb - ); - -static -void -s_nsControlInUsbIoCompleteWrite( - struct urb *urb - ); +static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); +static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); +static void s_nsBulkOutIoCompleteWrite(struct urb *urb); +static void s_nsControlInUsbIoCompleteRead(struct urb *urb); +static void s_nsControlInUsbIoCompleteWrite(struct urb *urb); /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -int PIPEnsControlOutAsyn( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ) +int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, + u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) { int ntStatus; @@ -147,17 +114,11 @@ int PIPEnsControlOutAsyn( return ntStatus; } -int PIPEnsControlOut( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ) +int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, + u16 wIndex, u16 wLength, u8 *pbyBuffer) { int ntStatus = 0; - int ii; + int ii; if (pDevice->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; @@ -165,6 +126,11 @@ int PIPEnsControlOut( if (pDevice->Flags & fMP_CONTROL_WRITES) return STATUS_FAILURE; + if (pDevice->Flags & fMP_CONTROL_READS) + return STATUS_FAILURE; + + MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); + pDevice->sUsbCtlRequest.bRequestType = 0x40; pDevice->sUsbCtlRequest.bRequest = byRequest; pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); @@ -179,12 +145,13 @@ int PIPEnsControlOut( ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission failed: %d\n", ntStatus); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "control send request submission failed: %d\n", + ntStatus); + MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); return STATUS_FAILURE; } - else { - MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); - } + spin_unlock_irq(&pDevice->lock); for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { @@ -206,17 +173,11 @@ int PIPEnsControlOut( return STATUS_SUCCESS; } -int PIPEnsControlIn( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ) +int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, + u16 wIndex, u16 wLength, u8 *pbyBuffer) { int ntStatus = 0; - int ii; + int ii; if (pDevice->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; @@ -224,6 +185,11 @@ int PIPEnsControlIn( if (pDevice->Flags & fMP_CONTROL_READS) return STATUS_FAILURE; + if (pDevice->Flags & fMP_CONTROL_WRITES) + return STATUS_FAILURE; + + MP_SET_FLAG(pDevice, fMP_CONTROL_READS); + pDevice->sUsbCtlRequest.bRequestType = 0xC0; pDevice->sUsbCtlRequest.bRequest = byRequest; pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); @@ -237,10 +203,11 @@ int PIPEnsControlIn( ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control request submission failed: %d\n", ntStatus); - }else { - MP_SET_FLAG(pDevice, fMP_CONTROL_READS); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "control request submission failed: %d\n", ntStatus); + MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + return STATUS_FAILURE; + } spin_unlock_irq(&pDevice->lock); for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { @@ -263,13 +230,9 @@ int PIPEnsControlIn( return ntStatus; } -static -void -s_nsControlInUsbIoCompleteWrite( - struct urb *urb - ) +static void s_nsControlInUsbIoCompleteWrite(struct urb *urb) { - PSDevice pDevice; + struct vnt_private *pDevice = (struct vnt_private *)urb->context; pDevice = urb->context; switch (urb->status) { @@ -304,15 +267,11 @@ s_nsControlInUsbIoCompleteWrite( * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -static -void -s_nsControlInUsbIoCompleteRead( - struct urb *urb - ) + +static void s_nsControlInUsbIoCompleteRead(struct urb *urb) { - PSDevice pDevice; + struct vnt_private *pDevice = (struct vnt_private *)urb->context; - pDevice = urb->context; switch (urb->status) { case 0: break; @@ -345,17 +304,18 @@ s_nsControlInUsbIoCompleteRead( * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -int PIPEnsInterruptRead(PSDevice pDevice) + +int PIPEnsInterruptRead(struct vnt_private *pDevice) { - int ntStatus = STATUS_FAILURE; + int ntStatus = STATUS_FAILURE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n"); - if(pDevice->intBuf.bInUse == TRUE){ + if(pDevice->intBuf.bInUse == true){ return (STATUS_FAILURE); } - pDevice->intBuf.bInUse = TRUE; -// pDevice->bEventAvailable = FALSE; + pDevice->intBuf.bInUse = true; +// pDevice->bEventAvailable = false; pDevice->ulIntInPosted++; // @@ -396,21 +356,16 @@ usb_fill_bulk_urb(pDevice->pInterruptURB, * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -static -void -s_nsInterruptUsbIoCompleteRead( - struct urb *urb - ) +static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) { - PSDevice pDevice; - int ntStatus; + struct vnt_private *pDevice = (struct vnt_private *)urb->context; + int ntStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n"); // // The context given to IoSetCompletionRoutine is the receive buffer object // - pDevice = (PSDevice)urb->context; // // We have a number of cases: @@ -428,7 +383,7 @@ s_nsInterruptUsbIoCompleteRead( // otherwise interrupt data handler will free int buffer after it handle it. if (( ntStatus != STATUS_SUCCESS )) { pDevice->ulBulkInError++; - pDevice->intBuf.bInUse = FALSE; + pDevice->intBuf.bInUse = false; // if (ntStatus == USBD_STATUS_CRC) { // pDevice->ulIntInContCRCError++; @@ -436,20 +391,20 @@ s_nsInterruptUsbIoCompleteRead( // if (ntStatus == STATUS_NOT_CONNECTED ) // { - pDevice->fKillEventPollingThread = TRUE; + pDevice->fKillEventPollingThread = true; // } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus ); } else { pDevice->ulIntInBytesRead += (unsigned long) urb->actual_length; pDevice->ulIntInContCRCError = 0; - pDevice->bEventAvailable = TRUE; + pDevice->bEventAvailable = true; INTnsProcessData(pDevice); } STAvUpdateUSBCounter(&pDevice->scStatistic.USB_InterruptStat, ntStatus); - if (pDevice->fKillEventPollingThread != TRUE) { + if (pDevice->fKillEventPollingThread != true) { usb_fill_bulk_urb(pDevice->pInterruptURB, pDevice->usb, usb_rcvbulkpipe(pDevice->usb, 1), @@ -483,10 +438,11 @@ s_nsInterruptUsbIoCompleteRead( * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB) + +int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, PRCB pRCB) { int ntStatus = 0; - struct urb *pUrb; + struct urb *pUrb; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); @@ -521,7 +477,7 @@ int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB) return STATUS_FAILURE ; } pRCB->Ref = 1; - pRCB->bBoolInUse= TRUE; + pRCB->bBoolInUse= true; return ntStatus; } @@ -543,19 +499,15 @@ int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB) * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -static -void -s_nsBulkInUsbIoCompleteRead( - struct urb *urb - ) +static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) { - PRCB pRCB = (PRCB)urb->context; - PSDevice pDevice = (PSDevice)pRCB->pDevice; - unsigned long bytesRead; - BOOL bIndicateReceive = FALSE; - BOOL bReAllocSkb = FALSE; - int status; + PRCB pRCB = (PRCB)urb->context; + struct vnt_private *pDevice = pRCB->pDevice; + unsigned long bytesRead; + int bIndicateReceive = false; + int bReAllocSkb = false; + int status; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); status = urb->status; @@ -576,7 +528,7 @@ s_nsBulkInUsbIoCompleteRead( // } } else { if (bytesRead) - bIndicateReceive = TRUE; + bIndicateReceive = true; pDevice->ulBulkInContCRCError = 0; pDevice->ulBulkInBytesRead += bytesRead; @@ -588,8 +540,8 @@ s_nsBulkInUsbIoCompleteRead( if (bIndicateReceive) { spin_lock(&pDevice->lock); - if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == TRUE) - bReAllocSkb = TRUE; + if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == true) + bReAllocSkb = true; spin_unlock(&pDevice->lock); } pRCB->Ref--; @@ -618,18 +570,15 @@ s_nsBulkInUsbIoCompleteRead( * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver * */ -int -PIPEnsSendBulkOut( - PSDevice pDevice, - PUSB_SEND_CONTEXT pContext - ) + +int PIPEnsSendBulkOut(struct vnt_private *pDevice, PUSB_SEND_CONTEXT pContext) { - int status; - struct urb *pUrb; + int status; + struct urb *pUrb; - pDevice->bPWBitOn = FALSE; + pDevice->bPWBitOn = false; /* if (pDevice->pPendingBulkOutContext != NULL) { @@ -661,13 +610,13 @@ PIPEnsSendBulkOut( if (status != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status); - pContext->bBoolInUse = FALSE; + pContext->bBoolInUse = false; return STATUS_FAILURE; } return STATUS_PENDING; } else { - pContext->bBoolInUse = FALSE; + pContext->bBoolInUse = false; return STATUS_RESOURCES; } } @@ -699,17 +648,14 @@ PIPEnsSendBulkOut( * (IofCompleteRequest) to stop working on the irp. * */ -static -void -s_nsBulkOutIoCompleteWrite( - struct urb *urb - ) + +static void s_nsBulkOutIoCompleteWrite(struct urb *urb) { - PSDevice pDevice; - int status; - CONTEXT_TYPE ContextType; - unsigned long ulBufLen; - PUSB_SEND_CONTEXT pContext; + struct vnt_private *pDevice; + int status; + CONTEXT_TYPE ContextType; + unsigned long ulBufLen; + PUSB_SEND_CONTEXT pContext; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); @@ -769,11 +715,11 @@ s_nsBulkOutIoCompleteWrite( } } - if (pDevice->bLinkPass == TRUE) { + if (pDevice->bLinkPass == true) { if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); } - pContext->bBoolInUse = FALSE; + pContext->bBoolInUse = false; return; } diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index b367347..b302355 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -41,35 +41,15 @@ /*--------------------- Export Functions --------------------------*/ -int PIPEnsControlOut( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ); - -int PIPEnsControlOutAsyn( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ); - -int PIPEnsControlIn( - PSDevice pDevice, - BYTE byRequest, - WORD wValue, - WORD wIndex, - WORD wLength, - PBYTE pbyBuffer - ); - -int PIPEnsInterruptRead(PSDevice pDevice); -int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB); -int PIPEnsSendBulkOut(PSDevice pDevice, PUSB_SEND_CONTEXT pContext); +int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue, + u16 wIndex, u16 wLength, u8 *pbyBuffer); +int PIPEnsControlOutAsyn(struct vnt_private *, u8 byRequest, + u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); +int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, + u16 wIndex, u16 wLength, u8 *pbyBuffer); + +int PIPEnsInterruptRead(struct vnt_private *); +int PIPEnsBulkInUsbRead(struct vnt_private *, PRCB pRCB); +int PIPEnsSendBulkOut(struct vnt_private *, PUSB_SEND_CONTEXT pContext); #endif /* __USBPIPE_H__ */ diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 22f6b41..4bb652b 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -68,33 +68,17 @@ static int msglevel =MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ -static -void -s_vProbeChannel( - PSDevice pDevice - ); +static void s_vProbeChannel(struct vnt_private *); +static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *, + struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -static -PSTxMgmtPacket -s_MgrMakeProbeRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pScanBSSID, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); +static int s_bCommandComplete(struct vnt_private *); -static -BOOL -s_bCommandComplete ( - PSDevice pDevice - ); - -static BOOL s_bClearBSSID_SCAN(void *hDeviceContext); +static int s_bClearBSSID_SCAN(struct vnt_private *); /*--------------------- Export Variables --------------------------*/ @@ -114,13 +98,10 @@ static BOOL s_bClearBSSID_SCAN(void *hDeviceContext); * */ -static -void -vAdHocBeaconStop(PSDevice pDevice) +static void vAdHocBeaconStop(struct vnt_private *pDevice) { - - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - BOOL bStop; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int bStop; /* * temporarily stop Beacon packet for AdHoc Server @@ -133,18 +114,18 @@ vAdHocBeaconStop(PSDevice pDevice) * or * (3.2) AdHoc channel is in A mode */ - bStop = FALSE; + bStop = false; if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState >= WMAC_STATE_STARTED)) { if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) { - bStop = TRUE; + bStop = true; } if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G) { - bStop = TRUE; + bStop = true; } } @@ -171,11 +152,9 @@ vAdHocBeaconStop(PSDevice pDevice) * Return Value: none * */ -static -void -vAdHocBeaconRestart(PSDevice pDevice) +static void vAdHocBeaconRestart(struct vnt_private *pDevice) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; /* * Restart Beacon packet for AdHoc Server @@ -204,22 +183,22 @@ vAdHocBeaconRestart(PSDevice pDevice) * -*/ -static -void -s_vProbeChannel( - PSDevice pDevice - ) +static void s_vProbeChannel(struct vnt_private *pDevice) { - //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M - BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; - BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; - //6M, 9M, 12M, 48M - BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - PBYTE pbyRate; - PSTxMgmtPacket pTxPacket; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_mgmt *pTxPacket; + u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, + 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; + /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/ + u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, + 4, 0x0C, 0x12, 0x18, 0x60}; + /* 6M, 9M, 12M, 48M*/ + u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, + 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; + u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, + 4, 0x02, 0x04, 0x0B, 0x16}; + u8 *pbyRate; + int ii; if (pDevice->byBBType == BB_TYPE_11A) { @@ -268,24 +247,19 @@ s_vProbeChannel( -*/ -PSTxMgmtPacket -s_MgrMakeProbeRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pScanBSSID, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - - ) +struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_PROBEREQ sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_PROBEREQ sFrame; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_PROBEREQ_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_PROBEREQ_FR_MAXLEN; vMgrEncodeProbeRequest(&sFrame); @@ -316,9 +290,8 @@ s_MgrMakeProbeRequest( return pTxPacket; } -void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond) +void vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond) { - PSDevice pDevice = (PSDevice)hDeviceContext; init_timer(&pDevice->sTimerCommand); @@ -331,23 +304,22 @@ void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond) return; } -void vRunCommand(void *hDeviceContext) +void vRunCommand(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PWLAN_IE_SSID pItemSSID; - PWLAN_IE_SSID pItemSSIDCurr; - CMD_STATUS Status; - unsigned int ii; - BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - struct sk_buff *skb; - BYTE byData; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PWLAN_IE_SSID pItemSSID; + PWLAN_IE_SSID pItemSSIDCurr; + CMD_STATUS Status; + struct sk_buff *skb; union iwreq_data wrqu; + int ii; + u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; + u8 byData; if (pDevice->dwDiagRefCount != 0) return; - if (pDevice->bCmdRunning != TRUE) + if (pDevice->bCmdRunning != true) return; spin_lock_irq(&pDevice->lock); @@ -357,7 +329,7 @@ void vRunCommand(void *hDeviceContext) case WLAN_CMD_SCAN_START: pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff == TRUE) { + if (pDevice->bRadioOff == true) { s_bCommandComplete(pDevice); spin_unlock_irq(&pDevice->lock); return; @@ -385,7 +357,7 @@ void vRunCommand(void *hDeviceContext) if (pDevice->bUpdateBBVGA) { BBvSetShortSlotTime(pDevice); BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); - BBvUpdatePreEDThreshold(pDevice, FALSE); + BBvUpdatePreEDThreshold(pDevice, false); } // Set channel back vAdHocBeaconRestart(pDevice); @@ -397,7 +369,7 @@ void vRunCommand(void *hDeviceContext) pDevice->byRxMode |= RCR_BSSID; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel); - pDevice->bStopDataPkt = FALSE; + pDevice->bStopDataPkt = false; s_bCommandComplete(pDevice); spin_unlock_irq(&pDevice->lock); return; @@ -423,7 +395,7 @@ void vRunCommand(void *hDeviceContext) pDevice->bLinkPass); */ pMgmt->eScanState = WMAC_IS_SCANNING; pDevice->byScanBBType = pDevice->byBBType; //lucas - pDevice->bStopDataPkt = TRUE; + pDevice->bStopDataPkt = true; // Turn off RCR_BSSID filter every time MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID); pDevice->byRxMode &= ~RCR_BSSID; @@ -447,7 +419,7 @@ void vRunCommand(void *hDeviceContext) if (pDevice->bUpdateBBVGA) { BBvSetShortSlotTime(pDevice); BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); - BBvUpdatePreEDThreshold(pDevice, TRUE); + BBvUpdatePreEDThreshold(pDevice, true); } pMgmt->uScanChannel++; @@ -461,7 +433,7 @@ void vRunCommand(void *hDeviceContext) pDevice->eCommandState = WLAN_CMD_SCAN_END; } - if ((pMgmt->b11hEnable == FALSE) || + if ((pMgmt->b11hEnable == false) || (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) { s_vProbeChannel(pDevice); spin_unlock_irq(&pDevice->lock); @@ -488,7 +460,7 @@ void vRunCommand(void *hDeviceContext) if (pDevice->bUpdateBBVGA) { BBvSetShortSlotTime(pDevice); BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); - BBvUpdatePreEDThreshold(pDevice, FALSE); + BBvUpdatePreEDThreshold(pDevice, false); } // Set channel back @@ -502,7 +474,7 @@ void vRunCommand(void *hDeviceContext) } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel); pMgmt->eScanState = WMAC_NO_SCANNING; - pDevice->bStopDataPkt = FALSE; + pDevice->bStopDataPkt = false; /*send scan event to wpa_Supplicant*/ PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n"); @@ -521,12 +493,12 @@ void vRunCommand(void *hDeviceContext) return; } else { - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = FALSE; - pDevice->bWPASuppWextEnabled = FALSE; - pDevice->fWPA_Authened = FALSE; + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = false; + pDevice->bWPASuppWextEnabled = false; + pDevice->fWPA_Authened = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n"); // reason = 8 : disassoc because sta has left @@ -535,18 +507,18 @@ void vRunCommand(void *hDeviceContext) pMgmt->abyCurrBSSID, (8), &Status); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); // unlock command busy pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; pItemSSID->len = 0; memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN); pMgmt->eCurrState = WMAC_STATE_IDLE; - pMgmt->sNodeDBTable[0].bActive = FALSE; -// pDevice->bBeaconBufReady = FALSE; + pMgmt->sNodeDBTable[0].bActive = false; +// pDevice->bBeaconBufReady = false; } netif_stop_queue(pDevice->dev); - if (pDevice->bNeedRadioOFF == TRUE) + if (pDevice->bNeedRadioOFF == true) CARDbRadioPowerOff(pDevice); s_bCommandComplete(pDevice); break; @@ -555,7 +527,7 @@ void vRunCommand(void *hDeviceContext) case WLAN_CMD_SSID_START: pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff == TRUE) { + if (pDevice->bRadioOff == true) { s_bCommandComplete(pDevice); spin_unlock_irq(&pDevice->lock); return; @@ -588,7 +560,7 @@ void vRunCommand(void *hDeviceContext) } } netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); } // set initial state @@ -625,9 +597,9 @@ void vRunCommand(void *hDeviceContext) if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); - pMgmt->sNodeDBTable[0].bActive = TRUE; + pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].uInActiveCount = 0; } else { @@ -658,7 +630,7 @@ void vRunCommand(void *hDeviceContext) BSSvAddMulticastNode(pDevice); s_bClearBSSID_SCAN(pDevice); /* - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); @@ -668,7 +640,7 @@ void vRunCommand(void *hDeviceContext) } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n"); - // if(pDevice->bWPASuppWextEnabled == TRUE) + // if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; memset(&wrqu, 0, sizeof (wrqu)); @@ -726,7 +698,7 @@ void vRunCommand(void *hDeviceContext) */ pDevice->byLinkWaitCount = 0; pDevice->byReAssocCount = 0; - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); s_bClearBSSID_SCAN(pDevice); @@ -734,20 +706,20 @@ void vRunCommand(void *hDeviceContext) netif_wake_queue(pDevice->dev); } - if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time + if(pDevice->IsTxDataTrigger != false) { //TxDataTimer is not triggered at the first time // printk("Re-initial TxDataTimer****\n"); del_timer(&pDevice->sTimerTxData); init_timer(&pDevice->sTimerTxData); pDevice->sTimerTxData.data = (unsigned long) pDevice; pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback - pDevice->fTxDataInSleep = FALSE; + pDevice->fTxDataInSleep = false; pDevice->nTxDataTimeCout = 0; } else { // printk("mike:-->First time trigger TimerTxData InSleep\n"); } - pDevice->IsTxDataTrigger = TRUE; + pDevice->IsTxDataTrigger = true; add_timer(&pDevice->sTimerTxData); } @@ -773,15 +745,15 @@ void vRunCommand(void *hDeviceContext) del_timer(&pMgmt->sTimerSecondCallback); pMgmt->eCurrState = WMAC_STATE_IDLE; pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); - if (pDevice->bEnableHostWEP == TRUE) + if (pDevice->bEnableHostWEP == true) BSSvClearNodeDBTable(pDevice, 1); else BSSvClearNodeDBTable(pDevice, 0); pDevice->uAssocCount = 0; pMgmt->eCurrState = WMAC_STATE_IDLE; - pDevice->bFixRate = FALSE; + pDevice->bFixRate = false; vMgrCreateOwnIBSS((void *) pDevice, &Status); if (Status != CMD_STATUS_SUCCESS) { @@ -796,7 +768,7 @@ void vRunCommand(void *hDeviceContext) if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); add_timer(&pMgmt->sTimerSecondCallback); } @@ -809,10 +781,10 @@ void vRunCommand(void *hDeviceContext) while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) { if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) { pMgmt->abyPSTxMap[0] &= ~byMask[0]; - pDevice->bMoreData = FALSE; + pDevice->bMoreData = false; } else { - pDevice->bMoreData = TRUE; + pDevice->bMoreData = true; } if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) { @@ -834,10 +806,10 @@ void vRunCommand(void *hDeviceContext) // clear tx map pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7]; - pDevice->bMoreData = FALSE; + pDevice->bMoreData = false; } else { - pDevice->bMoreData = TRUE; + pDevice->bMoreData = true; } if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) { @@ -856,7 +828,7 @@ void vRunCommand(void *hDeviceContext) ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7]; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii); } - pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE; + pMgmt->sNodeDBTable[ii].bRxPSPoll = false; } } @@ -866,7 +838,7 @@ void vRunCommand(void *hDeviceContext) case WLAN_CMD_RADIO_START: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n"); - // if (pDevice->bRadioCmd == TRUE) + // if (pDevice->bRadioCmd == true) // CARDbRadioPowerOn(pDevice); // else // CARDbRadioPowerOff(pDevice); @@ -894,31 +866,31 @@ void vRunCommand(void *hDeviceContext) pDevice->cbFreeCmdQueue = CMD_Q_SIZE; pDevice->uCmdDequeueIdx = 0; pDevice->uCmdEnqueueIdx = 0; - //0415pDevice->bCmdRunning = FALSE; - pDevice->bCmdClear = TRUE; - pDevice->bStopTx0Pkt = FALSE; - pDevice->bStopDataPkt = TRUE; + //0415pDevice->bCmdRunning = false; + pDevice->bCmdClear = true; + pDevice->bStopTx0Pkt = false; + pDevice->bStopDataPkt = true; pDevice->byKeyIndex = 0; - pDevice->bTransmitKey = FALSE; + pDevice->bTransmitKey = false; spin_unlock_irq(&pDevice->lock); KeyvInitTable(pDevice,&pDevice->sKey); spin_lock_irq(&pDevice->lock); pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; - if (pDevice->bLinkPass == TRUE) { + if (pDevice->bLinkPass == true) { // reason = 8 : disassoc because sta has left vMgrDisassocBeginSta((void *) pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; // unlock command busy pMgmt->eCurrState = WMAC_STATE_IDLE; - pMgmt->sNodeDBTable[0].bActive = FALSE; - // if(pDevice->bWPASuppWextEnabled == TRUE) + pMgmt->sNodeDBTable[0].bActive = false; + // if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; memset(&wrqu, 0, sizeof (wrqu)); @@ -927,11 +899,11 @@ void vRunCommand(void *hDeviceContext) wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); } } - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = FALSE; - pDevice->bWPASuppWextEnabled = FALSE; + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = false; + pDevice->bWPASuppWextEnabled = false; //clear current SSID pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; pItemSSID->len = 0; @@ -945,10 +917,10 @@ void vRunCommand(void *hDeviceContext) CARDbRadioPowerOff(pDevice); MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD); ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_OFF); - pDevice->bHWRadioOff = TRUE; + pDevice->bHWRadioOff = true; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n"); - pDevice->bHWRadioOff = FALSE; + pDevice->bHWRadioOff = false; CARDbRadioPowerOn(pDevice); MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD); ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_ON); @@ -961,11 +933,11 @@ void vRunCommand(void *hDeviceContext) case WLAN_CMD_CHANGE_BBSENSITIVITY_START: - pDevice->bStopDataPkt = TRUE; + pDevice->bStopDataPkt = true; pDevice->byBBVGACurrent = pDevice->byBBVGANew; BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent); - pDevice->bStopDataPkt = FALSE; + pDevice->bStopDataPkt = false; s_bCommandComplete(pDevice); break; @@ -990,13 +962,13 @@ void vRunCommand(void *hDeviceContext) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel); if ( pDevice->dwRxAntennaSel == 0) { pDevice->dwRxAntennaSel=1; - if (pDevice->bTxRxAntInv == TRUE) + if (pDevice->bTxRxAntInv == true) BBvSetAntennaMode(pDevice, ANT_RXA); else BBvSetAntennaMode(pDevice, ANT_RXB); } else { pDevice->dwRxAntennaSel=0; - if (pDevice->bTxRxAntInv == TRUE) + if (pDevice->bTxRxAntInv == true) BBvSetAntennaMode(pDevice, ANT_RXB); else BBvSetAntennaMode(pDevice, ANT_RXA); @@ -1027,9 +999,9 @@ void vRunCommand(void *hDeviceContext) case WLAN_CMD_11H_CHSW_START: CARDbSetMediaChannel(pDevice, pDevice->byNewChannel); - pDevice->bChannelSwitch = FALSE; + pDevice->bChannelSwitch = false; pMgmt->uCurrChannel = pDevice->byNewChannel; - pDevice->bStopDataPkt = FALSE; + pDevice->bStopDataPkt = false; s_bCommandComplete(pDevice); break; @@ -1043,24 +1015,19 @@ void vRunCommand(void *hDeviceContext) } -static -BOOL -s_bCommandComplete ( - PSDevice pDevice - ) +static int s_bCommandComplete(struct vnt_private *pDevice) { - PWLAN_IE_SSID pSSID; - BOOL bRadioCmd = FALSE; - //WORD wDeAuthenReason = 0; - BOOL bForceSCAN = TRUE; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PWLAN_IE_SSID pSSID; + int bRadioCmd = false; + int bForceSCAN = true; pDevice->eCommandState = WLAN_CMD_IDLE; if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) { //Command Queue Empty - pDevice->bCmdRunning = FALSE; - return TRUE; + pDevice->bCmdRunning = false; + return true; } else { pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd; @@ -1069,7 +1036,7 @@ s_bCommandComplete ( bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN; ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE); pDevice->cbFreeCmdQueue++; - pDevice->bCmdRunning = TRUE; + pDevice->bCmdRunning = true; switch ( pDevice->eCommand ) { case WLAN_CMD_BSSID_SCAN: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n"); @@ -1081,7 +1048,7 @@ s_bCommandComplete ( memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); } /* - if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) { + if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) { if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) && ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) { pDevice->eCommandState = WLAN_CMD_IDLE; @@ -1146,29 +1113,26 @@ s_bCommandComplete ( break; } - vCommandTimerWait((void *) pDevice, 0); + vCommandTimerWait(pDevice, 0); } - return TRUE; + return true; } -BOOL bScheduleCommand(void *hDeviceContext, - CMD_CODE eCommand, - PBYTE pbyItem0) +int bScheduleCommand(struct vnt_private *pDevice, + CMD_CODE eCommand, u8 *pbyItem0) { - PSDevice pDevice = (PSDevice)hDeviceContext; - if (pDevice->cbFreeCmdQueue == 0) { - return (FALSE); + return (false); } pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand; - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE; + pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true; memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); if (pbyItem0 != NULL) { switch (eCommand) { case WLAN_CMD_BSSID_SCAN: - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE; + pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false; memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); break; @@ -1199,12 +1163,12 @@ BOOL bScheduleCommand(void *hDeviceContext, ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE); pDevice->cbFreeCmdQueue--; - if (pDevice->bCmdRunning == FALSE) { + if (pDevice->bCmdRunning == false) { s_bCommandComplete(pDevice); } else { } - return (TRUE); + return (true); } @@ -1219,14 +1183,13 @@ BOOL bScheduleCommand(void *hDeviceContext, * Out: * none * - * Return Value: TRUE if success; otherwise FALSE + * Return Value: true if success; otherwise false * */ -static BOOL s_bClearBSSID_SCAN(void *hDeviceContext) +static int s_bClearBSSID_SCAN(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx; - unsigned int ii; + unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx; + unsigned int ii; if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) { for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) { @@ -1237,14 +1200,13 @@ static BOOL s_bClearBSSID_SCAN(void *hDeviceContext) break; } } - return TRUE; + return true; } //mike add:reset command timer -void vResetCommandTimer(void *hDeviceContext) +void vResetCommandTimer(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; //delete timer del_timer(&pDevice->sTimerCommand); @@ -1257,14 +1219,13 @@ void vResetCommandTimer(void *hDeviceContext) pDevice->uCmdDequeueIdx = 0; pDevice->uCmdEnqueueIdx = 0; pDevice->eCommandState = WLAN_CMD_IDLE; - pDevice->bCmdRunning = FALSE; - pDevice->bCmdClear = FALSE; + pDevice->bCmdRunning = false; + pDevice->bCmdClear = false; } -void BSSvSecondTxData(void *hDeviceContext) +void BSSvSecondTxData(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; pDevice->nTxDataTimeCout++; @@ -1278,13 +1239,13 @@ void BSSvSecondTxData(void *hDeviceContext) spin_lock_irq(&pDevice->lock); //is wap_supplicant running successful OR only open && sharekey mode! - if (((pDevice->bLinkPass == TRUE) && + if (((pDevice->bLinkPass == true) && (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking - (pDevice->fWPA_Authened == TRUE)) { //wpa linking + (pDevice->fWPA_Authened == true)) { //wpa linking // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__); - pDevice->fTxDataInSleep = TRUE; + pDevice->fTxDataInSleep = true; PSbSendNullPacket(pDevice); //send null packet - pDevice->fTxDataInSleep = FALSE; + pDevice->fTxDataInSleep = false; } spin_unlock_irq(&pDevice->lock); diff --git a/drivers/staging/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h index d24a79d..c40e6ba 100644 --- a/drivers/staging/vt6656/wcmd.h +++ b/drivers/staging/vt6656/wcmd.h @@ -28,7 +28,6 @@ #ifndef __WCMD_H__ #define __WCMD_H__ - #include "ttype.h" #include "80211hdr.h" #include "80211mgr.h" @@ -75,9 +74,9 @@ typedef enum tagCMD_STATUS { typedef struct tagCMD_ITEM { CMD_CODE eCmd; BYTE abyCmdDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - BOOL bNeedRadioOFF; - BOOL bRadioCmd; - BOOL bForceSCAN; + bool bNeedRadioOFF; + bool bRadioCmd; + bool bForceSCAN; WORD wDeAuthenReason; } CMD_ITEM, *PCMD_ITEM; @@ -112,14 +111,13 @@ typedef enum tagCMD_STATE { /*--------------------- Export Types ------------------------------*/ /*--------------------- Export Functions --------------------------*/ +struct vnt_private; -void vResetCommandTimer(void *hDeviceContext); +void vResetCommandTimer(struct vnt_private *); -BOOL bScheduleCommand(void *hDeviceContext, - CMD_CODE eCommand, - PBYTE pbyItem0); +int bScheduleCommand(struct vnt_private *, CMD_CODE eCommand, u8 *pbyItem0); -void vRunCommand(void *hDeviceContext); +void vRunCommand(struct vnt_private *); /* void @@ -128,6 +126,6 @@ WCMDvCommandThread( ); */ -void BSSvSecondTxData(void *hDeviceContext); +void BSSvSecondTxData(struct vnt_private *); #endif /* __WCMD_H__ */ diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c index 9249263..baa48a1 100644 --- a/drivers/staging/vt6656/wctl.c +++ b/drivers/staging/vt6656/wctl.c @@ -53,8 +53,8 @@ /* * Description: - * Scan Rx cache. Return TRUE if packet is duplicate, else - * inserts in receive cache and returns FALSE. + * Scan Rx cache. Return true if packet is duplicate, else + * inserts in receive cache and returns false. * * Parameters: * In: @@ -63,11 +63,11 @@ * Out: * none * - * Return Value: TRUE if packet duplicate; otherwise FALSE + * Return Value: true if packet duplicate; otherwise false * */ -BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) +bool WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) { unsigned int uIndex; unsigned int ii; @@ -84,7 +84,7 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) (LOBYTE(pCacheEntry->wFrameCtl) == LOBYTE(pMACHeader->wFrameCtl)) ) { /* Duplicate match */ - return TRUE; + return true; } ADD_ONE_WITH_WRAP_AROUND(uIndex, DUPLICATE_RX_CACHE_LENGTH); } @@ -95,7 +95,7 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN); pCacheEntry->wFrameCtl = pMACHeader->wFrameCtl; ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH); - return FALSE; + return false; } /* @@ -113,12 +113,13 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) * */ -unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader) +unsigned int WCTLuSearchDFCB(struct vnt_private *pDevice, + PS802_11Header pMACHeader) { unsigned int ii; for (ii = 0; ii < pDevice->cbDFCB; ii++) { - if ((pDevice->sRxDFCB[ii].bInUse == TRUE) && + if ((pDevice->sRxDFCB[ii].bInUse == true) && (!compare_ether_addr(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0])))) { return ii; @@ -141,17 +142,18 @@ unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader) * Return Value: index number in Defragment Database * */ -unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader) +unsigned int WCTLuInsertDFCB(struct vnt_private *pDevice, + PS802_11Header pMACHeader) { unsigned int ii; if (pDevice->cbFreeDFCB == 0) return(pDevice->cbDFCB); for (ii = 0; ii < pDevice->cbDFCB; ii++) { - if (pDevice->sRxDFCB[ii].bInUse == FALSE) { + if (pDevice->sRxDFCB[ii].bInUse == false) { pDevice->cbFreeDFCB--; pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime; - pDevice->sRxDFCB[ii].bInUse = TRUE; + pDevice->sRxDFCB[ii].bInUse = true; pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4); pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F); memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), @@ -177,16 +179,16 @@ unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader) * Out: * none * - * Return Value: TRUE if it is valid fragment packet and we have resource to defragment; otherwise FALSE + * Return Value: true if it is valid fragment packet and we have resource to defragment; otherwise false * */ -BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, - unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV) +bool WCTLbHandleFragment(struct vnt_private *pDevice, PS802_11Header pMACHeader, + unsigned int cbFrameLength, bool bWEP, bool bExtIV) { -unsigned int uHeaderSize; + unsigned int uHeaderSize; - if (bWEP == TRUE) { + if (bWEP == true) { uHeaderSize = 28; if (bExtIV) // ExtIV @@ -207,7 +209,7 @@ unsigned int uHeaderSize; else { pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader); if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) { - return(FALSE); + return(false); } } // reserve 8 byte to match MAC RX Buffer @@ -218,7 +220,7 @@ unsigned int uHeaderSize; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "First pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx); - return(FALSE); + return(false); } else { pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader); @@ -236,21 +238,21 @@ unsigned int uHeaderSize; else { // seq error or frag # error flush DFCB pDevice->cbFreeDFCB++; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE; - return(FALSE); + pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false; + return(false); } } else { - return(FALSE); + return(false); } if (IS_LAST_FRAGMENT_PKT(pMACHeader)) { //enq defragcontrolblock pDevice->cbFreeDFCB++; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = FALSE; + pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false; //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx); - return(TRUE); + return(true); } - return(FALSE); + return(false); } } diff --git a/drivers/staging/vt6656/wctl.h b/drivers/staging/vt6656/wctl.h index 7270af6..1b21e32e 100644 --- a/drivers/staging/vt6656/wctl.h +++ b/drivers/staging/vt6656/wctl.h @@ -96,10 +96,10 @@ /*--------------------- Export Functions --------------------------*/ -BOOL WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader); -BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, - unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV); -unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader); -unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader); +bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader); +bool WCTLbHandleFragment(struct vnt_private *, PS802_11Header pMACHeader, + unsigned int cbFrameLength, bool bWEP, bool bExtIV); +unsigned int WCTLuSearchDFCB(struct vnt_private *, PS802_11Header pMACHeader); +unsigned int WCTLuInsertDFCB(struct vnt_private *, PS802_11Header pMACHeader); #endif /* __WCTL_H__ */ diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 95ddc83..5dced0a 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -93,230 +93,101 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ -static BOOL ChannelExceedZoneType( - PSDevice pDevice, - BYTE byCurrChannel - ); +static int ChannelExceedZoneType(struct vnt_private *, u8 byCurrChannel); -// Association/diassociation functions -static -PSTxMgmtPacket -s_MgrMakeAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pDAddr, - WORD wCurrCapInfo, - WORD wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); +/* Association/diassociation functions */ +static struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *, + struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, + u16 wListenInterval, PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -static -void -s_vMgrRxAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex - ); +static void s_vMgrRxAssocRequest(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + u32 uNodeIndex); -static -PSTxMgmtPacket -s_MgrMakeReAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pDAddr, - WORD wCurrCapInfo, - WORD wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); +static struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *, + struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, + u16 wListenInterval, PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -static -void -s_vMgrRxAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - BOOL bReAssocType - ); +static void s_vMgrRxAssocResponse(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + int bReAssocType); -static -void -s_vMgrRxDisassociation( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ); +static void s_vMgrRxDisassociation(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); -// Authentication/deauthen functions -static -void -s_vMgrRxAuthenSequence_1( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ); +/* Authentication/deauthen functions */ +static void s_vMgrRxAuthenSequence_1(struct vnt_private *, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); -static -void -s_vMgrRxAuthenSequence_2( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ); +static void s_vMgrRxAuthenSequence_2(struct vnt_private *, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); -static -void -s_vMgrRxAuthenSequence_3( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ); +static void s_vMgrRxAuthenSequence_3(struct vnt_private *, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); -static -void -s_vMgrRxAuthenSequence_4( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ); +static void s_vMgrRxAuthenSequence_4(struct vnt_private *, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame); -static -void -s_vMgrRxAuthentication( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ); +static void s_vMgrRxAuthentication(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); -static -void -s_vMgrRxDeauthentication( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ); +static void s_vMgrRxDeauthentication(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); -// Scan functions -// probe request/response functions -static -void -s_vMgrRxProbeRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ); +/* Scan functions +* probe request/response functions */ -static -void -s_vMgrRxProbeResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ); +static void s_vMgrRxProbeRequest(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); -// beacon functions -static -void -s_vMgrRxBeacon( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - BOOL bInScan - ); +static void s_vMgrRxProbeResponse(struct vnt_private *, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket); -static -void -s_vMgrFormatTIM( - PSMgmtObject pMgmt, - PWLAN_IE_TIM pTIM - ); +/* beacon functions */ +static void s_vMgrRxBeacon(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + int bInScan); -static -PSTxMgmtPacket -s_MgrMakeBeacon( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wCurrBeaconPeriod, - unsigned int uCurrChannel, - WORD wCurrATIMWinodw, - PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); +static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM); +static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, + u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, + u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -// Association response -static -PSTxMgmtPacket -s_MgrMakeAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wAssocStatus, - WORD wAssocAID, - PBYTE pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); -// ReAssociation response -static -PSTxMgmtPacket -s_MgrMakeReAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wAssocStatus, - WORD wAssocAID, - PBYTE pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ); +/* Association response */ +static struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, + u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -// Probe response -static -PSTxMgmtPacket -s_MgrMakeProbeResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wCurrBeaconPeriod, - unsigned int uCurrChannel, - WORD wCurrATIMWinodw, - PBYTE pDstAddr, - PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - BYTE byPHYType - ); +/* ReAssociation response */ +static struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, + u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates); -// received status -static -void -s_vMgrLogStatus( - PSMgmtObject pMgmt, - WORD wStatus - ); +/* Probe response */ +static struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, + u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr, + PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType); +/* received status */ +static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus); -static -void -s_vMgrSynchBSS ( - PSDevice pDevice, - unsigned int uBSSMode, - PKnownBSS pCurr, - PCMD_STATUS pStatus - ); +static void s_vMgrSynchBSS(struct vnt_private *, u32 uBSSMode, + PKnownBSS pCurr, PCMD_STATUS pStatus); -static BOOL + +static bool s_bCipherMatch ( PKnownBSS pBSSNode, NDIS_802_11_ENCRYPTION_STATUS EncStatus, @@ -324,10 +195,7 @@ s_bCipherMatch ( PBYTE pbyCCSGK ); - static void Encyption_Rebuild( - PSDevice pDevice, - PKnownBSS pCurr - ); +static void Encyption_Rebuild(struct vnt_private *, PKnownBSS pCurr); /*--------------------- Export Variables --------------------------*/ @@ -343,11 +211,10 @@ s_bCipherMatch ( * -*/ -void vMgrObjectInit(void *hDeviceContext) +void vMgrObjectInit(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ii; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + int ii; pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; @@ -361,7 +228,7 @@ void vMgrObjectInit(void *hDeviceContext) pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; - BSSvClearBSSList((void *) pDevice, FALSE); + BSSvClearBSSList((void *) pDevice, false); init_timer(&pMgmt->sTimerSecondCallback); pMgmt->sTimerSecondCallback.data = (unsigned long)pDevice; @@ -377,16 +244,16 @@ void vMgrObjectInit(void *hDeviceContext) pDevice->sTimerTxData.data = (unsigned long)pDevice; pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback - pDevice->fTxDataInSleep = FALSE; - pDevice->IsTxDataTrigger = FALSE; + pDevice->fTxDataInSleep = false; + pDevice->IsTxDataTrigger = false; pDevice->nTxDataTimeCout = 0; pDevice->cbFreeCmdQueue = CMD_Q_SIZE; pDevice->uCmdDequeueIdx = 0; pDevice->uCmdEnqueueIdx = 0; pDevice->eCommandState = WLAN_CMD_IDLE; - pDevice->bCmdRunning = FALSE; - pDevice->bCmdClear = FALSE; + pDevice->bCmdRunning = false; + pDevice->bCmdClear = false; return; } @@ -402,12 +269,10 @@ void vMgrObjectInit(void *hDeviceContext) * -*/ -void vMgrAssocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus) +void vMgrAssocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSTxMgmtPacket pTxPacket; + struct vnt_tx_mgmt *pTxPacket; pMgmt->wCurrCapInfo = 0; @@ -426,7 +291,7 @@ void vMgrAssocBeginSta(void *hDeviceContext, // ERP Phy (802.11g) should support short preamble. if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (pDevice->bShortSlotTime == TRUE) + if (pDevice->bShortSlotTime == true) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { @@ -434,7 +299,7 @@ void vMgrAssocBeginSta(void *hDeviceContext, pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); } } - if (pMgmt->b11hEnable == TRUE) + if (pMgmt->b11hEnable == true) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); // build an assocreq frame and send it @@ -475,14 +340,10 @@ void vMgrAssocBeginSta(void *hDeviceContext, * -*/ -void vMgrReAssocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus) +void vMgrReAssocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSTxMgmtPacket pTxPacket; - - + struct vnt_tx_mgmt *pTxPacket; pMgmt->wCurrCapInfo = 0; pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); @@ -502,7 +363,7 @@ void vMgrReAssocBeginSta(void *hDeviceContext, // ERP Phy (802.11g) should support short preamble. if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (pDevice->bShortSlotTime == TRUE) + if (pDevice->bShortSlotTime == true) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { @@ -510,7 +371,7 @@ void vMgrReAssocBeginSta(void *hDeviceContext, pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); } } - if (pMgmt->b11hEnable == TRUE) + if (pMgmt->b11hEnable == true) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); @@ -551,19 +412,18 @@ void vMgrReAssocBeginSta(void *hDeviceContext, * -*/ -void vMgrDisassocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PBYTE abyDestAddress, - WORD wReason, - PCMD_STATUS pStatus) +void vMgrDisassocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason, + PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_DISASSOC sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_DISASSOC sFrame; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_DISASSOC_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; @@ -610,23 +470,18 @@ void vMgrDisassocBeginSta(void *hDeviceContext, * -*/ -static -void -s_vMgrRxAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex - ) +static void s_vMgrRxAssocRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + u32 uNodeIndex) { - WLAN_FR_ASSOCREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - WORD wAssocStatus = 0; - WORD wAssocAID = 0; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + WLAN_FR_ASSOCREQ sFrame; + CMD_STATUS Status; + struct vnt_tx_mgmt *pTxPacket; + u16 wAssocStatus = 0; + u16 wAssocAID = 0; + u32 uRateLen = WLAN_RATES_MAXLEN; + u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) @@ -650,7 +505,7 @@ s_vMgrRxAssocRequest( pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = - WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? TRUE : FALSE; + WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; // Todo: check sta basic rate, if ap can't support, set status code if (pDevice->byBBType == BB_TYPE_11B) { uRateLen = WLAN_RATES_MAXLEN_11B; @@ -672,7 +527,7 @@ s_vMgrRxAssocRequest( RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - FALSE, // do not change our basic rate + false, // do not change our basic rate &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), @@ -693,15 +548,15 @@ s_vMgrRxAssocRequest( wAssocAID = (WORD)uNodeIndex; // check if ERP support if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE; + pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { // B only STA join - pDevice->bProtectMode = TRUE; - pDevice->bNonERPPresent = TRUE; + pDevice->bProtectMode = true; + pDevice->bNonERPPresent = true; } - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == FALSE) { - pDevice->bBarkerPreambleMd = TRUE; + if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) { + pDevice->bBarkerPreambleMd = true; } DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID); @@ -766,23 +621,18 @@ s_vMgrRxAssocRequest( * -*/ -static -void -s_vMgrRxReAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex - ) +static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + u32 uNodeIndex) { - WLAN_FR_REASSOCREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - WORD wAssocStatus = 0; - WORD wAssocAID = 0; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + WLAN_FR_REASSOCREQ sFrame; + CMD_STATUS Status; + struct vnt_tx_mgmt *pTxPacket; + u16 wAssocStatus = 0; + u16 wAssocAID = 0; + u32 uRateLen = WLAN_RATES_MAXLEN; + u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) return; @@ -801,7 +651,7 @@ s_vMgrRxReAssocRequest( pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = - WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? TRUE : FALSE; + WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; // Todo: check sta basic rate, if ap can't support, set status code if (pDevice->byBBType == BB_TYPE_11B) { @@ -825,7 +675,7 @@ s_vMgrRxReAssocRequest( RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - FALSE, // do not change our basic rate + false, // do not change our basic rate &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), @@ -847,15 +697,15 @@ s_vMgrRxReAssocRequest( // if suppurt ERP if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE; + pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { // B only STA join - pDevice->bProtectMode = TRUE; - pDevice->bNonERPPresent = TRUE; + pDevice->bProtectMode = true; + pDevice->bNonERPPresent = true; } - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == FALSE) { - pDevice->bBarkerPreambleMd = TRUE; + if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == false) { + pDevice->bBarkerPreambleMd = true; } DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID); @@ -913,18 +763,13 @@ s_vMgrRxReAssocRequest( * -*/ -static -void -s_vMgrRxAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - BOOL bReAssocType - ) +static void s_vMgrRxAssocResponse(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + int bReAssocType) { - WLAN_FR_ASSOCRESP sFrame; - PWLAN_IE_SSID pItemSSID; - PBYTE pbyIEs; + WLAN_FR_ASSOCRESP sFrame; + PWLAN_IE_SSID pItemSSID; + u8 *pbyIEs; @@ -970,10 +815,10 @@ s_vMgrRxAssocResponse( sFrame.pExtSuppRates); pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID); - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); - //if(pDevice->bWPASuppWextEnabled == TRUE) + //if(pDevice->bWPASuppWextEnabled == true) { BYTE buf[512]; size_t len; @@ -1027,11 +872,11 @@ s_vMgrRxAssocResponse( } //need clear flags related to Networkmanager - pDevice->bwextstep0 = FALSE; - pDevice->bwextstep1 = FALSE; - pDevice->bwextstep2 = FALSE; - pDevice->bwextstep3 = FALSE; - pDevice->bWPASuppWextEnabled = FALSE; + pDevice->bwextstep0 = false; + pDevice->bwextstep1 = false; + pDevice->bwextstep2 = false; + pDevice->bwextstep3 = false; + pDevice->bWPASuppWextEnabled = false; if(pMgmt->eCurrState == WMAC_STATE_ASSOC) timer_expire(pDevice->sTimerCommand, 0); @@ -1050,17 +895,17 @@ if(pMgmt->eCurrState == WMAC_STATE_ASSOC) * -*/ -void vMgrAuthenBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus) +void vMgrAuthenBeginSta(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - WLAN_FR_AUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + WLAN_FR_AUTHEN sFrame; + struct vnt_tx_mgmt *pTxPacket = + (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_AUTHEN_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; vMgrEncodeAuthen(&sFrame); @@ -1103,20 +948,18 @@ void vMgrAuthenBeginSta(void *hDeviceContext, * -*/ -void vMgrDeAuthenBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PBYTE abyDestAddress, - WORD wReason, - PCMD_STATUS pStatus) +void vMgrDeAuthenBeginSta(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason, + PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - WLAN_FR_DEAUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; - - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DEAUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + WLAN_FR_DEAUTHEN sFrame; + struct vnt_tx_mgmt *pTxPacket = + (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_DEAUTHEN_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN; vMgrEncodeDeauthen(&sFrame); @@ -1156,15 +999,10 @@ void vMgrDeAuthenBeginSta(void *hDeviceContext, * -*/ -static -void -s_vMgrRxAuthentication( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ) +static void s_vMgrRxAuthentication(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) { - WLAN_FR_AUTHEN sFrame; + WLAN_FR_AUTHEN sFrame; // we better be an AP or a STA in AUTHPENDING otherwise ignore if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP || @@ -1214,25 +1052,21 @@ s_vMgrRxAuthentication( -*/ -static -void -s_vMgrRxAuthenSequence_1( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ) +static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) { - PSTxMgmtPacket pTxPacket = NULL; - unsigned int uNodeIndex; - WLAN_FR_AUTHEN sFrame; - PSKeyItem pTransmitKey; - - // Insert a Node entry - if (!BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) { - BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex); - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, pFrame->pHdr->sA3.abyAddr2, - WLAN_ADDR_LEN); - } + struct vnt_tx_mgmt *pTxPacket = NULL; + u32 uNodeIndex; + WLAN_FR_AUTHEN sFrame; + PSKeyItem pTransmitKey; + + /* Insert a Node entry */ + if (!BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, + &uNodeIndex)) { + BSSvCreateOneNode(pDevice, &uNodeIndex); + memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, + pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); + } if (pMgmt->bShareKeyAlgorithm) { pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN; @@ -1243,9 +1077,11 @@ s_vMgrRxAuthenSequence_1( } // send auth reply - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_AUTHEN_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure @@ -1285,7 +1121,7 @@ s_vMgrRxAuthenSequence_1( sFrame.pChallenge->len = WLAN_CHALLENGE_LEN; memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN); // get group key - if(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == TRUE) { + if(KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == true) { rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3); rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN); } @@ -1320,16 +1156,11 @@ s_vMgrRxAuthenSequence_1( * -*/ -static -void -s_vMgrRxAuthenSequence_2( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ) +static void s_vMgrRxAuthenSequence_2(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) { - WLAN_FR_AUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; + WLAN_FR_AUTHEN sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm)))) @@ -1355,9 +1186,13 @@ s_vMgrRxAuthenSequence_2( case WLAN_AUTH_ALG_SHAREDKEY: if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *) + pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_AUTHEN_FR_MAXLEN); + pTxPacket->p80211Header + = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure @@ -1421,18 +1256,13 @@ s_vMgrRxAuthenSequence_2( * -*/ -static -void -s_vMgrRxAuthenSequence_3( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ) +static void s_vMgrRxAuthenSequence_3(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) { - PSTxMgmtPacket pTxPacket = NULL; - unsigned int uStatusCode = 0 ; - unsigned int uNodeIndex = 0; - WLAN_FR_AUTHEN sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; + u32 uStatusCode = 0 ; + u32 uNodeIndex = 0; + WLAN_FR_AUTHEN sFrame; if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) { uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL; @@ -1462,9 +1292,11 @@ s_vMgrRxAuthenSequence_3( reply: // send auth reply - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_AUTHEN_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure @@ -1509,13 +1341,8 @@ reply: * None. * -*/ -static -void -s_vMgrRxAuthenSequence_4( - PSDevice pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame - ) +static void s_vMgrRxAuthenSequence_4(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame) { if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){ @@ -1547,17 +1374,12 @@ s_vMgrRxAuthenSequence_4( * -*/ -static -void -s_vMgrRxDisassociation( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ) +static void s_vMgrRxDisassociation(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) { - WLAN_FR_DISASSOC sFrame; - unsigned int uNodeIndex = 0; - CMD_STATUS CmdStatus; + WLAN_FR_DISASSOC sFrame; + u32 uNodeIndex = 0; + CMD_STATUS CmdStatus; if ( pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){ // if is acting an AP.. @@ -1577,24 +1399,24 @@ s_vMgrRxDisassociation( vMgrDecodeDisassociation(&sFrame); DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason))); - pDevice->fWPA_Authened = FALSE; + pDevice->fWPA_Authened = false; //TODO: do something let upper layer know or //try to send associate packet again because of inactivity timeout if (pMgmt->eCurrState == WMAC_STATE_ASSOC) { - pDevice->bLinkPass = FALSE; - pMgmt->sNodeDBTable[0].bActive = FALSE; + pDevice->bLinkPass = false; + pMgmt->sNodeDBTable[0].bActive = false; pDevice->byReAssocCount = 0; pMgmt->eCurrState = WMAC_STATE_AUTH; // jump back to the auth state! pDevice->eCommandState = WLAN_ASSOCIATE_WAIT; - vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus); + vMgrReAssocBeginSta(pDevice, pMgmt, &CmdStatus); if(CmdStatus == CMD_STATUS_PENDING) { pDevice->byReAssocCount ++; return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected! } } - // if(pDevice->bWPASuppWextEnabled == TRUE) + // if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; memset(&wrqu, 0, sizeof (wrqu)); @@ -1620,16 +1442,11 @@ s_vMgrRxDisassociation( * -*/ -static -void -s_vMgrRxDeauthentication( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ) +static void s_vMgrRxDeauthentication(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) { - WLAN_FR_DEAUTHEN sFrame; - unsigned int uNodeIndex = 0; + WLAN_FR_DEAUTHEN sFrame; + u32 uNodeIndex = 0; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){ @@ -1650,22 +1467,22 @@ s_vMgrRxDeauthentication( sFrame.len = pRxPacket->cbMPDULen; sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; vMgrDecodeDeauthen(&sFrame); - pDevice->fWPA_Authened = FALSE; + pDevice->fWPA_Authened = false; DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason)))); // TODO: update BSS list for specific BSSID if pre-authentication case if (!compare_ether_addr(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID)) { if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) { - pMgmt->sNodeDBTable[0].bActive = FALSE; + pMgmt->sNodeDBTable[0].bActive = false; pMgmt->eCurrMode = WMAC_MODE_STANDBY; pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = FALSE; + pDevice->bLinkPass = false; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); } } - // if(pDevice->bWPASuppWextEnabled == TRUE) + // if(pDevice->bWPASuppWextEnabled == true) { union iwreq_data wrqu; memset(&wrqu, 0, sizeof (wrqu)); @@ -1692,23 +1509,19 @@ s_vMgrRxDeauthentication( * True:exceed; * False:normal case -*/ -static BOOL -ChannelExceedZoneType( - PSDevice pDevice, - BYTE byCurrChannel - ) +static int ChannelExceedZoneType(struct vnt_private *pDevice, u8 byCurrChannel) { - BOOL exceed=FALSE; + int exceed = false; switch(pDevice->byZoneType) { case 0x00: //USA:1~11 if((byCurrChannel<1) ||(byCurrChannel>11)) - exceed = TRUE; + exceed = true; break; case 0x01: //Japan:1~13 case 0x02: //Europe:1~13 if((byCurrChannel<1) ||(byCurrChannel>13)) - exceed = TRUE; + exceed = true; break; default: //reserve for other zonetype break; @@ -1728,39 +1541,33 @@ ChannelExceedZoneType( * -*/ -static -void -s_vMgrRxBeacon( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - BOOL bInScan - ) +static void s_vMgrRxBeacon(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket, + int bInScan) { - - PKnownBSS pBSSList; - WLAN_FR_BEACON sFrame; - QWORD qwTSFOffset; - BOOL bIsBSSIDEqual = FALSE; - BOOL bIsSSIDEqual = FALSE; - BOOL bTSFLargeDiff = FALSE; - BOOL bTSFOffsetPostive = FALSE; - BOOL bUpdateTSF = FALSE; - BOOL bIsAPBeacon = FALSE; - BOOL bIsChannelEqual = FALSE; - unsigned int uLocateByteIndex; - BYTE byTIMBitOn = 0; - WORD wAIDNumber = 0; - unsigned int uNodeIndex; - QWORD qwTimestamp, qwLocalTSF; - QWORD qwCurrTSF; - WORD wStartIndex = 0; - WORD wAIDIndex = 0; - BYTE byCurrChannel = pRxPacket->byRxChannel; - ERPObject sERP; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - BOOL bChannelHit = FALSE; - BYTE byOldPreambleType; + PKnownBSS pBSSList; + WLAN_FR_BEACON sFrame; + u64 qwTSFOffset; + int bIsBSSIDEqual = false; + int bIsSSIDEqual = false; + int bTSFLargeDiff = false; + int bTSFOffsetPostive = false; + int bUpdateTSF = false; + int bIsAPBeacon = false; + int bIsChannelEqual = false; + u32 uLocateByteIndex; + u8 byTIMBitOn = 0; + u16 wAIDNumber = 0; + u32 uNodeIndex; + u64 qwTimestamp, qwLocalTSF; + u64 qwCurrTSF; + u16 wStartIndex = 0; + u16 wAIDIndex = 0; + u8 byCurrChannel = pRxPacket->byRxChannel; + ERPObject sERP; + u32 uRateLen = WLAN_RATES_MAXLEN; + int bChannelHit = false; + u8 byOldPreambleType; @@ -1787,31 +1594,31 @@ s_vMgrRxBeacon( { if (sFrame.pDSParms != NULL) { if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]) - bChannelHit = TRUE; + bChannelHit = true; byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]; } else { - bChannelHit = TRUE; + bChannelHit = true; } } else { if (sFrame.pDSParms != NULL) { if (byCurrChannel == sFrame.pDSParms->byCurrChannel) - bChannelHit = TRUE; + bChannelHit = true; byCurrChannel = sFrame.pDSParms->byCurrChannel; } else { - bChannelHit = TRUE; + bChannelHit = true; } } -if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) +if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) return; if (sFrame.pERP != NULL) { sERP.byERP = sFrame.pERP->byContext; - sERP.bERPExist = TRUE; + sERP.bERPExist = true; } else { - sERP.bERPExist = FALSE; + sERP.bERPExist = false; sERP.byERP = 0; } @@ -1866,7 +1673,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) } if(byCurrChannel == (BYTE)pMgmt->uCurrChannel) - bIsChannelEqual = TRUE; + bIsChannelEqual = true; if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { @@ -1895,7 +1702,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) pMgmt->abyCurrBSSID, WLAN_BSSID_LEN) == 0) { - bIsBSSIDEqual = TRUE; + bIsBSSIDEqual = true; pDevice->uCurrRSSI = pRxPacket->uRSSI; pDevice->byCurrSQ = pRxPacket->bySQ; if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) { @@ -1909,22 +1716,22 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, sFrame.pSSID->len ) == 0) { - bIsSSIDEqual = TRUE; + bIsSSIDEqual = true; } } - if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== TRUE) && - (bIsBSSIDEqual == TRUE) && - (bIsSSIDEqual == TRUE) && + if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== true) && + (bIsBSSIDEqual == true) && + (bIsSSIDEqual == true) && (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { // add state check to prevent reconnect fail since we'll receive Beacon - bIsAPBeacon = TRUE; + bIsAPBeacon = true; if (pBSSList != NULL) { // Sync ERP field - if ((pBSSList->sERP.bERPExist == TRUE) && (pDevice->byBBType == BB_TYPE_11G)) { + if ((pBSSList->sERP.bERPExist == true) && (pDevice->byBBType == BB_TYPE_11G)) { if ((pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010 pDevice->bProtectMode = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION); if (pDevice->bProtectMode) { @@ -1949,16 +1756,16 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) } // Sync Short Slot Time if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo) != pDevice->bShortSlotTime) { - BOOL bShortSlotTime; + bool bShortSlotTime; bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo); //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime)); //Kyle check if it is OK to set G. if (pDevice->byBBType == BB_TYPE_11A) { - bShortSlotTime = TRUE; + bShortSlotTime = true; } else if (pDevice->byBBType == BB_TYPE_11B) { - bShortSlotTime = FALSE; + bShortSlotTime = false; } if (bShortSlotTime != pDevice->bShortSlotTime) { pDevice->bShortSlotTime = bShortSlotTime; @@ -1994,7 +1801,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - TRUE, + true, &(pMgmt->sNodeDBTable[0].wMaxBasicRate), &(pMgmt->sNodeDBTable[0].wMaxSuppRate), &(pMgmt->sNodeDBTable[0].wSuppRate), @@ -2013,26 +1820,14 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) } } - HIDWORD(qwTimestamp) = cpu_to_le32(HIDWORD(*sFrame.pqwTimestamp)); - LODWORD(qwTimestamp) = cpu_to_le32(LODWORD(*sFrame.pqwTimestamp)); - HIDWORD(qwLocalTSF) = HIDWORD(pRxPacket->qwLocalTSF); - LODWORD(qwLocalTSF) = LODWORD(pRxPacket->qwLocalTSF); + qwTimestamp = cpu_to_le64(*sFrame.pqwTimestamp); + qwLocalTSF = pRxPacket->qwLocalTSF; // check if beacon TSF larger or small than our local TSF - if (HIDWORD(qwTimestamp) == HIDWORD(qwLocalTSF)) { - if (LODWORD(qwTimestamp) >= LODWORD(qwLocalTSF)) { - bTSFOffsetPostive = TRUE; - } - else { - bTSFOffsetPostive = FALSE; - } - } - else if (HIDWORD(qwTimestamp) > HIDWORD(qwLocalTSF)) { - bTSFOffsetPostive = TRUE; - } - else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) { - bTSFOffsetPostive = FALSE; - } + if (qwTimestamp >= qwLocalTSF) + bTSFOffsetPostive = true; + else + bTSFOffsetPostive = false; if (bTSFOffsetPostive) { qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF)); @@ -2041,23 +1836,21 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp)); } - if (HIDWORD(qwTSFOffset) != 0 || - (LODWORD(qwTSFOffset) > TRIVIAL_SYNC_DIFFERENCE )) { - bTSFLargeDiff = TRUE; - } + if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE) + bTSFLargeDiff = true; // if infra mode - if (bIsAPBeacon == TRUE) { + if (bIsAPBeacon == true) { // Infra mode: Local TSF always follow AP's TSF if Difference huge. if (bTSFLargeDiff) - bUpdateTSF = TRUE; + bUpdateTSF = true; - if ((pDevice->bEnablePSMode == TRUE) && (sFrame.pTIM)) { + if ((pDevice->bEnablePSMode == true) && (sFrame.pTIM)) { /* deal with DTIM, analysis TIM */ - pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? TRUE : FALSE ; + pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? true : false ; pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount; pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod; wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15); @@ -2072,36 +1865,33 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250] if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) { byTIMBitOn = (0x01) << ((wAIDNumber) % 8); - pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? TRUE : FALSE; + pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? true : false; } else { - pMgmt->bInTIM = FALSE; + pMgmt->bInTIM = false; }; } else { - pMgmt->bInTIM = FALSE; + pMgmt->bInTIM = false; }; if (pMgmt->bInTIM || (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) { - pMgmt->bInTIMWake = TRUE; - // send out ps-poll packet -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n"); - if (pMgmt->bInTIM) { - PSvSendPSPOLL((PSDevice)pDevice); -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n"); - } + pMgmt->bInTIMWake = true; + /* send out ps-poll packet */ + if (pMgmt->bInTIM) + PSvSendPSPOLL(pDevice); } else { - pMgmt->bInTIMWake = FALSE; + pMgmt->bInTIMWake = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Not In TIM..\n"); - if (pDevice->bPWBitOn == FALSE) { + if (pDevice->bPWBitOn == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Send Null Packet\n"); if (PSbSendNullPacket(pDevice)) - pDevice->bPWBitOn = TRUE; + pDevice->bPWBitOn = true; } - if(PSbConsiderPowerDown(pDevice, FALSE, FALSE)) { + if(PSbConsiderPowerDown(pDevice, false, false)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n"); } } @@ -2119,7 +1909,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) // adhoc mode:TSF updated only when beacon larger then local TSF if (bTSFLargeDiff && bTSFOffsetPostive && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) - bUpdateTSF = TRUE; + bUpdateTSF = true; // During dpc, already in spinlocked. if (BSSbIsSTAInNodeDB(pDevice, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) { @@ -2132,7 +1922,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, NULL, - TRUE, + true, &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), @@ -2144,8 +1934,8 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0; } else { - // Todo, initial Node content - BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex); + /* Todo, initial Node content */ + BSSvCreateOneNode(pDevice, &uNodeIndex); pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, @@ -2153,7 +1943,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, NULL, - TRUE, + true, &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), @@ -2167,7 +1957,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) /* pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE; + pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; */ } @@ -2175,12 +1965,12 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) if (pMgmt->eCurrState == WMAC_STATE_STARTED) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n"); pMgmt->eCurrState = WMAC_STATE_JOINTED; - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } - pMgmt->sNodeDBTable[0].bActive = TRUE; + pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].uInActiveCount = 0; } @@ -2256,26 +2046,22 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) * -*/ -void vMgrCreateOwnIBSS(void *hDeviceContext, - PCMD_STATUS pStatus) +void vMgrCreateOwnIBSS(struct vnt_private *pDevice, PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - WORD wMaxBasicRate; - WORD wMaxSuppRate; - BYTE byTopCCKBasicRate; - BYTE byTopOFDMBasicRate; - QWORD qwCurrTSF; - unsigned int ii; - BYTE abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60}; - BYTE abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96}; - BYTE abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - WORD wSuppRate; - + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u16 wMaxBasicRate; + u16 wMaxSuppRate; + u8 byTopCCKBasicRate; + u8 byTopOFDMBasicRate; + u64 qwCurrTSF = 0; + int ii; + u8 abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, + 0x12, 0x18, 0x60}; + u8 abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96}; + u8 abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; + u16 wSuppRate; - HIDWORD(qwCurrTSF) = 0; - LODWORD(qwCurrTSF) = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create Basic Service Set .......\n"); @@ -2366,16 +2152,16 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, TRUE, + (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, &byTopCCKBasicRate, &byTopOFDMBasicRate); if (pDevice->byBBType == BB_TYPE_11A) { - pDevice->bShortSlotTime = TRUE; + pDevice->bShortSlotTime = true; } else { - pDevice->bShortSlotTime = FALSE; + pDevice->bShortSlotTime = false; } BBvSetShortSlotTime(pDevice); // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called @@ -2420,12 +2206,12 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { // BSSID selected must be randomized as spec 11.1.3 - pMgmt->abyCurrBSSID[5] = (BYTE) (LODWORD(qwCurrTSF)& 0x000000ff); - pMgmt->abyCurrBSSID[4] = (BYTE)((LODWORD(qwCurrTSF)& 0x0000ff00) >> 8); - pMgmt->abyCurrBSSID[3] = (BYTE)((LODWORD(qwCurrTSF)& 0x00ff0000) >> 16); - pMgmt->abyCurrBSSID[2] = (BYTE)((LODWORD(qwCurrTSF)& 0x00000ff0) >> 4); - pMgmt->abyCurrBSSID[1] = (BYTE)((LODWORD(qwCurrTSF)& 0x000ff000) >> 12); - pMgmt->abyCurrBSSID[0] = (BYTE)((LODWORD(qwCurrTSF)& 0x0ff00000) >> 20); + pMgmt->abyCurrBSSID[5] = (u8)(qwCurrTSF & 0x000000ff); + pMgmt->abyCurrBSSID[4] = (u8)((qwCurrTSF & 0x0000ff00) >> 8); + pMgmt->abyCurrBSSID[3] = (u8)((qwCurrTSF & 0x00ff0000) >> 16); + pMgmt->abyCurrBSSID[2] = (u8)((qwCurrTSF & 0x00000ff0) >> 4); + pMgmt->abyCurrBSSID[1] = (u8)((qwCurrTSF & 0x000ff000) >> 12); + pMgmt->abyCurrBSSID[0] = (u8)((qwCurrTSF & 0x0ff00000) >> 20); pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0]; pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1]; pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2]; @@ -2446,7 +2232,7 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); pDevice->byRxMode |= RCR_BSSID; - pMgmt->bCurrBSSIDFilterOn = TRUE; + pMgmt->bCurrBSSIDFilterOn = true; // Set Capability Info pMgmt->wCurrCapInfo = 0; @@ -2511,26 +2297,25 @@ void vMgrCreateOwnIBSS(void *hDeviceContext, * -*/ -void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) +void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PKnownBSS pCurr = NULL; - unsigned int ii, uu; - PWLAN_IE_SUPP_RATES pItemRates = NULL; - PWLAN_IE_SUPP_RATES pItemExtRates = NULL; - PWLAN_IE_SSID pItemSSID; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - WORD wMaxBasicRate = RATE_1M; - WORD wMaxSuppRate = RATE_1M; - WORD wSuppRate; - BYTE byTopCCKBasicRate = RATE_1M; - BYTE byTopOFDMBasicRate = RATE_1M; - BOOL bShortSlotTime = FALSE; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + PKnownBSS pCurr = NULL; + int ii, uu; + PWLAN_IE_SUPP_RATES pItemRates = NULL; + PWLAN_IE_SUPP_RATES pItemExtRates = NULL; + PWLAN_IE_SSID pItemSSID; + u32 uRateLen = WLAN_RATES_MAXLEN; + u16 wMaxBasicRate = RATE_1M; + u16 wMaxSuppRate = RATE_1M; + u16 wSuppRate; + u8 byTopCCKBasicRate = RATE_1M; + u8 byTopOFDMBasicRate = RATE_1M; + u8 bShortSlotTime = false; for (ii = 0; ii < MAX_BSS_NUM; ii++) { - if (pMgmt->sBSSList[ii].bActive == TRUE) + if (pMgmt->sBSSList[ii].bActive == true) break; } @@ -2564,14 +2349,14 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) { /* if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) { + if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); // encryption mode error pMgmt->eCurrState = WMAC_STATE_IDLE; return; } } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) { + if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); // encryption mode error pMgmt->eCurrState = WMAC_STATE_IDLE; @@ -2581,7 +2366,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) */ } - //if(pDevice->bWPASuppWextEnabled == TRUE) + //if(pDevice->bWPASuppWextEnabled == true) Encyption_Rebuild(pDevice, pCurr); // Infrastructure BSS @@ -2637,7 +2422,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) } } - RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, TRUE, + RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, &byTopCCKBasicRate, &byTopOFDMBasicRate); vUpdateIFS(pDevice); @@ -2658,11 +2443,11 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) // Add current BSS to Candidate list // This should only work for WPA2 BSS, and WPA2 BSS check must be done before. if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { - BOOL bResult = bAdd_PMKID_Candidate((void *) pDevice, + bool bResult = bAdd_PMKID_Candidate((void *) pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate: 1(%d)\n", bResult); - if (bResult == FALSE) { + if (bResult == false) { vFlush_PMKID_Candidate((void *) pDevice); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vFlush_PMKID_Candidate: 4\n"); @@ -2712,10 +2497,10 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo)); if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo) != pDevice->bShortSlotTime) { if (pDevice->byBBType == BB_TYPE_11A) { - bShortSlotTime = TRUE; + bShortSlotTime = true; } else if (pDevice->byBBType == BB_TYPE_11B) { - bShortSlotTime = FALSE; + bShortSlotTime = false; } else { bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo); @@ -2742,7 +2527,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { /* - if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) { + if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) { // encryption mode error pMgmt->eCurrState = WMAC_STATE_IDLE; return; @@ -2750,7 +2535,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) */ } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { /* - if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == FALSE) { + if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) { // encryption mode error pMgmt->eCurrState = WMAC_STATE_IDLE; return; @@ -2783,7 +2568,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) // set basic rate RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - NULL, TRUE, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, + NULL, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, &byTopCCKBasicRate, &byTopOFDMBasicRate); vUpdateIFS(pDevice); pMgmt->wCurrCapInfo = pCurr->wCapInfo; @@ -2796,7 +2581,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) pMgmt->eCurrState = WMAC_STATE_STARTED; // Adopt BSS state in Adapter Device Object pDevice->eOPMode = OP_MODE_ADHOC; - pDevice->bLinkPass = TRUE; + pDevice->bLinkPass = true; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); @@ -2836,30 +2621,27 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus) * PCM_STATUS * -*/ -static -void -s_vMgrSynchBSS ( - PSDevice pDevice, - unsigned int uBSSMode, - PKnownBSS pCurr, - PCMD_STATUS pStatus - ) +static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, + PKnownBSS pCurr, PCMD_STATUS pStatus) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M - BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; - BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; - //6M, 9M, 12M, 48M - BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, + 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; + /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/ + u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, + 4, 0x0C, 0x12, 0x18, 0x60}; + /* 6M, 9M, 12M, 48M*/ + u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, + 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; + u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, + 4, 0x02, 0x04, 0x0B, 0x16}; *pStatus = CMD_STATUS_FAILURE; if (s_bCipherMatch(pCurr, pDevice->eEncryptionStatus, &(pMgmt->byCSSPK), - &(pMgmt->byCSSGK)) == FALSE) { + &(pMgmt->byCSSGK)) == false) { DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "s_bCipherMatch Fail .......\n"); return; } @@ -2872,12 +2654,12 @@ s_vMgrSynchBSS ( } // Init the BSS informations - pDevice->bCCK = TRUE; - pDevice->bProtectMode = FALSE; + pDevice->bCCK = true; + pDevice->bProtectMode = false; MACvDisableProtectMD(pDevice); - pDevice->bBarkerPreambleMd = FALSE; + pDevice->bBarkerPreambleMd = false; MACvDisableBarkerPreambleMd(pDevice); - pDevice->bNonERPPresent = FALSE; + pDevice->bNonERPPresent = false; pDevice->byPreambleType = 0; pDevice->wBasicRate = 0; // Set Basic Rate @@ -2907,7 +2689,7 @@ s_vMgrSynchBSS ( (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { pDevice->byBBType = BB_TYPE_11A; pMgmt->eCurrentPHYMode = PHY_TYPE_11A; - pDevice->bShortSlotTime = TRUE; + pDevice->bShortSlotTime = true; BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); } else { @@ -2919,7 +2701,7 @@ s_vMgrSynchBSS ( (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { pDevice->byBBType = BB_TYPE_11B; pMgmt->eCurrentPHYMode = PHY_TYPE_11B; - pDevice->bShortSlotTime = FALSE; + pDevice->bShortSlotTime = false; BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); } else { @@ -2930,12 +2712,12 @@ s_vMgrSynchBSS ( (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) { pDevice->byBBType = BB_TYPE_11G; pMgmt->eCurrentPHYMode = PHY_TYPE_11G; - pDevice->bShortSlotTime = TRUE; + pDevice->bShortSlotTime = true; BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); } else if (pDevice->eConfigPHYMode == PHY_TYPE_11B) { pDevice->byBBType = BB_TYPE_11B; - pDevice->bShortSlotTime = FALSE; + pDevice->bShortSlotTime = false; BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); } else { @@ -2947,7 +2729,7 @@ s_vMgrSynchBSS ( MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC); MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); pDevice->byRxMode |= RCR_BSSID; - pMgmt->bCurrBSSIDFilterOn = TRUE; + pMgmt->bCurrBSSIDFilterOn = true; } // set channel and clear NAV @@ -2971,7 +2753,7 @@ s_vMgrSynchBSS ( MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC); MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID); pDevice->byRxMode |= RCR_BSSID; - pMgmt->bCurrBSSIDFilterOn = TRUE; + pMgmt->bCurrBSSIDFilterOn = true; } if (pDevice->byBBType == BB_TYPE_11A) { @@ -2991,21 +2773,13 @@ s_vMgrSynchBSS ( return; }; - -//mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption -// ,need reset eAuthenMode and eEncryptionStatus - static void Encyption_Rebuild( - PSDevice pDevice, - PKnownBSS pCurr - ) +static void Encyption_Rebuild(struct vnt_private *pDevice, PKnownBSS pCurr) { - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - /* unsigned int ii, uSameBssidNum=0; */ + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - // if( uSameBssidNum>=2) { //we only check AP in hidden sssid mode - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || //networkmanager 0.7.0 does not give the pairwise-key selsection, - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { // so we need re-selsect it according to real pairwise-key info. - if(pCurr->bWPAValid == TRUE) { //WPA-PSK + if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || + (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { + if (pCurr->bWPAValid == true) { /*WPA-PSK */ pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; if(pCurr->abyPKType[0] == WPA_TKIP) { pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP @@ -3016,7 +2790,7 @@ s_vMgrSynchBSS ( PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n"); } } - else if(pCurr->bWPA2Valid == TRUE) { //WPA2-PSK + else if(pCurr->bWPA2Valid == true) { //WPA2-PSK pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) { pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP @@ -3044,20 +2818,15 @@ s_vMgrSynchBSS ( * -*/ -static -void -s_vMgrFormatTIM( - PSMgmtObject pMgmt, - PWLAN_IE_TIM pTIM - ) +static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM) { - BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - BYTE byMap; - unsigned int ii, jj; - BOOL bStartFound = FALSE; - BOOL bMulticast = FALSE; - WORD wStartIndex = 0; - WORD wEndIndex = 0; + u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; + u8 byMap; + int ii, jj; + int bStartFound = false; + int bMulticast = false; + u16 wStartIndex = 0; + u16 wEndIndex = 0; // Find size of partial virtual bitmap @@ -3067,13 +2836,13 @@ s_vMgrFormatTIM( // Mask out the broadcast bit which is indicated separately. bMulticast = (byMap & byMask[0]) != 0; if(bMulticast) { - pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE; + pMgmt->sNodeDBTable[0].bRxPSPoll = true; } byMap = 0; } if (byMap) { if (!bStartFound) { - bStartFound = TRUE; + bStartFound = true; wStartIndex = (WORD)ii; } wEndIndex = (WORD)ii; @@ -3119,30 +2888,23 @@ s_vMgrFormatTIM( * -*/ -static -PSTxMgmtPacket -s_MgrMakeBeacon( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wCurrBeaconPeriod, - unsigned int uCurrChannel, - WORD wCurrATIMWinodw, - PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ) +static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, + u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, + u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_BEACON sFrame; - BYTE abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_BEACON sFrame; + u8 abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - // prepare beacon frame - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + /* prepare beacon frame */ + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_BEACON_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure. sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_BEACON_FR_MAXLEN; @@ -3243,11 +3005,11 @@ s_MgrMakeBeacon( sFrame.pERP->byElementID = WLAN_EID_ERP; sFrame.pERP->len = 1; sFrame.pERP->byContext = 0; - if (pDevice->bProtectMode == TRUE) + if (pDevice->bProtectMode == true) sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; - if (pDevice->bNonERPPresent == TRUE) + if (pDevice->bNonERPPresent == true) sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; - if (pDevice->bBarkerPreambleMd == TRUE) + if (pDevice->bBarkerPreambleMd == true) sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; } if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { @@ -3259,7 +3021,7 @@ s_MgrMakeBeacon( ); } // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == TRUE)) { + if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { if (pMgmt->wWPAIELen != 0) { sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); @@ -3294,30 +3056,22 @@ s_MgrMakeBeacon( -PSTxMgmtPacket -s_MgrMakeProbeResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wCurrBeaconPeriod, - unsigned int uCurrChannel, - WORD wCurrATIMWinodw, - PBYTE pDstAddr, - PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - BYTE byPHYType - ) +struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod, + u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr, + PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_PROBERESP sFrame; - + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_PROBERESP sFrame; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_PROBERESP_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure. sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_PROBERESP_FR_MAXLEN; @@ -3377,11 +3131,11 @@ s_MgrMakeProbeResponse( sFrame.pERP->byElementID = WLAN_EID_ERP; sFrame.pERP->len = 1; sFrame.pERP->byContext = 0; - if (pDevice->bProtectMode == TRUE) + if (pDevice->bProtectMode == true) sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; - if (pDevice->bNonERPPresent == TRUE) + if (pDevice->bNonERPPresent == true) sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; - if (pDevice->bBarkerPreambleMd == TRUE) + if (pDevice->bBarkerPreambleMd == true) sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; } @@ -3395,7 +3149,7 @@ s_MgrMakeProbeResponse( } // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == TRUE)) { + if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { if (pMgmt->wWPAIELen != 0) { sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); @@ -3426,27 +3180,24 @@ s_MgrMakeProbeResponse( -*/ -PSTxMgmtPacket -s_MgrMakeAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pDAddr, - WORD wCurrCapInfo, - WORD wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ) +struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, + u16 wListenInterval, + PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_ASSOCREQ sFrame; - PBYTE pbyIEs; - PBYTE pbyRSN; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_ASSOCREQ sFrame; + u8 *pbyIEs; + u8 *pbyRSN; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_ASSOCREQ_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure. sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN; @@ -3625,7 +3376,7 @@ s_MgrMakeAssocRequest( sFrame.pRSN->len +=6; // RSN Capabilites - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) { + if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); } else { sFrame.pRSN->abyRSN[16] = 0; @@ -3633,7 +3384,7 @@ s_MgrMakeAssocRequest( } sFrame.pRSN->len +=2; - if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { + if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { // RSN PMKID pbyRSN = &sFrame.pRSN->abyRSN[18]; pwPMKID = (PWORD)pbyRSN; // Point to PMKID count @@ -3688,27 +3439,23 @@ s_MgrMakeAssocRequest( -*/ -PSTxMgmtPacket -s_MgrMakeReAssocRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PBYTE pDAddr, - WORD wCurrCapInfo, - WORD wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ) +struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo, + u16 wListenInterval, PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_REASSOCREQ sFrame; - PBYTE pbyIEs; - PBYTE pbyRSN; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_REASSOCREQ sFrame; + u8 *pbyIEs; + u8 *pbyRSN; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset( pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_REASSOCREQ_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); /* Setup the sFrame structure. */ sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN; @@ -3885,7 +3632,7 @@ s_MgrMakeReAssocRequest( sFrame.pRSN->len +=6; // RSN Capabilites - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) { + if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); } else { sFrame.pRSN->abyRSN[16] = 0; @@ -3893,7 +3640,7 @@ s_MgrMakeReAssocRequest( } sFrame.pRSN->len +=2; - if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { + if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { // RSN PMKID pbyRSN = &sFrame.pRSN->abyRSN[18]; pwPMKID = (PWORD)pbyRSN; // Point to PMKID count @@ -3942,25 +3689,20 @@ s_MgrMakeReAssocRequest( * -*/ -PSTxMgmtPacket -s_MgrMakeAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wAssocStatus, - WORD wAssocAID, - PBYTE pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ) +struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, + u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_ASSOCRESP sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_ASSOCRESP sFrame; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_ASSOCREQ_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; @@ -4016,25 +3758,20 @@ s_MgrMakeAssocResponse( -*/ -PSTxMgmtPacket -s_MgrMakeReAssocResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - WORD wCurrCapInfo, - WORD wAssocStatus, - WORD wAssocAID, - PBYTE pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - ) +struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus, + u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates) { - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_REASSOCRESP sFrame; + struct vnt_tx_mgmt *pTxPacket = NULL; + WLAN_FR_REASSOCRESP sFrame; - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool; + memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt) + + WLAN_ASSOCREQ_FR_MAXLEN); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + + sizeof(struct vnt_tx_mgmt)); // Setup the sFrame structure sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; @@ -4089,19 +3826,14 @@ s_MgrMakeReAssocResponse( * -*/ -static -void -s_vMgrRxProbeResponse( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ) +static void s_vMgrRxProbeResponse(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) { - PKnownBSS pBSSList = NULL; - WLAN_FR_PROBERESP sFrame; - BYTE byCurrChannel = pRxPacket->byRxChannel; - ERPObject sERP; - BOOL bChannelHit = TRUE; + PKnownBSS pBSSList = NULL; + WLAN_FR_PROBERESP sFrame; + u8 byCurrChannel = pRxPacket->byRxChannel; + ERPObject sERP; + int bChannelHit = true; memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP)); @@ -4132,31 +3864,31 @@ s_vMgrRxProbeResponse( if (sFrame.pDSParms) { if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]) - bChannelHit = TRUE; + bChannelHit = true; byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1]; } else { - bChannelHit = TRUE; + bChannelHit = true; } } else { if (sFrame.pDSParms) { if (byCurrChannel == sFrame.pDSParms->byCurrChannel) - bChannelHit = TRUE; + bChannelHit = true; byCurrChannel = sFrame.pDSParms->byCurrChannel; } else { - bChannelHit = TRUE; + bChannelHit = true; } } //RobertYu:20050201 -if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) +if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) return; if (sFrame.pERP) { sERP.byERP = sFrame.pERP->byContext; - sERP.bERPExist = TRUE; + sERP.bERPExist = true; } else { - sERP.bERPExist = FALSE; + sERP.bERPExist = false; sERP.byERP = 0; } @@ -4221,18 +3953,13 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) -*/ -static -void -s_vMgrRxProbeRequest( - PSDevice pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket - ) +static void s_vMgrRxProbeRequest(struct vnt_private *pDevice, + struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket) { - WLAN_FR_PROBEREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - BYTE byPHYType = BB_TYPE_11B; + WLAN_FR_PROBEREQ sFrame; + CMD_STATUS Status; + struct vnt_tx_mgmt *pTxPacket; + u8 byPHYType = BB_TYPE_11B; // STA in Ad-hoc mode: when latest TBTT beacon transmit success, // STA have to response this request. @@ -4307,15 +4034,13 @@ s_vMgrRxProbeRequest( * -*/ -void vMgrRxManagePacket(void *hDeviceContext, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket) +void vMgrRxManagePacket(struct vnt_private *pDevice, struct vnt_manager *pMgmt, + struct vnt_rx_mgmt *pRxPacket) { - PSDevice pDevice = (PSDevice)hDeviceContext; - BOOL bInScan = FALSE; - unsigned int uNodeIndex = 0; - NODE_STATE eNodeState = 0; - CMD_STATUS Status; + int bInScan = false; + u32 uNodeIndex = 0; + NODE_STATE eNodeState = 0; + CMD_STATUS Status; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { @@ -4348,7 +4073,7 @@ void vMgrRxManagePacket(void *hDeviceContext, case WLAN_FSTYPE_ASSOCRESP: // Frame Clase = 2 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp1\n"); - s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, FALSE); + s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, false); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp2\n"); break; @@ -4375,7 +4100,7 @@ void vMgrRxManagePacket(void *hDeviceContext, case WLAN_FSTYPE_REASSOCRESP: // Frame Clase = 2 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocresp\n"); - s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, TRUE); + s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, true); break; case WLAN_FSTYPE_PROBEREQ: @@ -4395,7 +4120,7 @@ void vMgrRxManagePacket(void *hDeviceContext, // Frame Clase = 0 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n"); if (pMgmt->eScanState != WMAC_NO_SCANNING) { - bInScan = TRUE; + bInScan = true; } s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan); break; @@ -4450,15 +4175,15 @@ void vMgrRxManagePacket(void *hDeviceContext, * Prepare beacon to send * * Return Value: - * TRUE if success; FALSE if failed. + * true if success; false if failed. * -*/ -BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, PSMgmtObject pMgmt) +int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, + struct vnt_manager *pMgmt) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PSTxMgmtPacket pTxPacket; + struct vnt_tx_mgmt *pTxPacket; -// pDevice->bBeaconBufReady = FALSE; +// pDevice->bBeaconBufReady = false; if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); } @@ -4481,12 +4206,12 @@ BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, PSMgmtObject pMgmt) if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->abyCurrBSSID[0] == 0)) - return FALSE; + return false; csBeacon_xmit(pDevice, pTxPacket); MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); - return TRUE; + return true; } @@ -4504,12 +4229,7 @@ BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, PSMgmtObject pMgmt) * none. * -*/ -static -void -s_vMgrLogStatus( - PSMgmtObject pMgmt, - WORD wStatus - ) +static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus) { switch( wStatus ){ case WLAN_MGMT_STATUS_UNSPEC_FAILURE: @@ -4574,21 +4294,19 @@ s_vMgrLogStatus( * -*/ -BOOL bAdd_PMKID_Candidate(void *hDeviceContext, - PBYTE pbyBSSID, - PSRSNCapObject psRSNCapObj) +int bAdd_PMKID_Candidate(struct vnt_private *pDevice, u8 *pbyBSSID, + PSRSNCapObject psRSNCapObj) { - PSDevice pDevice = (PSDevice)hDeviceContext; - PPMKID_CANDIDATE pCandidateList; - unsigned int ii = 0; + PPMKID_CANDIDATE pCandidateList; + int ii = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL)) - return FALSE; + return false; if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) - return FALSE; + return false; @@ -4596,7 +4314,7 @@ BOOL bAdd_PMKID_Candidate(void *hDeviceContext, for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { - if ((psRSNCapObj->bRSNCapExist == TRUE) + if ((psRSNCapObj->bRSNCapExist == true) && (psRSNCapObj->wRSNCap & BIT0)) { pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; @@ -4604,13 +4322,13 @@ BOOL bAdd_PMKID_Candidate(void *hDeviceContext, pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); } - return TRUE; + return true; } } // New Candidate pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; - if ((psRSNCapObj->bRSNCapExist == TRUE) && (psRSNCapObj->wRSNCap & BIT0)) { + if ((psRSNCapObj->bRSNCapExist == true) && (psRSNCapObj->wRSNCap & BIT0)) { pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; } else { pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); @@ -4618,7 +4336,7 @@ BOOL bAdd_PMKID_Candidate(void *hDeviceContext, memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); pDevice->gsPMKIDCandidate.NumCandidates++; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); - return TRUE; + return true; } /* @@ -4636,17 +4354,17 @@ BOOL bAdd_PMKID_Candidate(void *hDeviceContext, * -*/ -void vFlush_PMKID_Candidate(void *hDeviceContext) +void vFlush_PMKID_Candidate(struct vnt_private *pDevice) { - PSDevice pDevice = (PSDevice)hDeviceContext; + if (pDevice == NULL) + return; - if (pDevice == NULL) - return; + memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); - memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); + return; } -static BOOL +static bool s_bCipherMatch ( PKnownBSS pBSSNode, NDIS_802_11_ENCRYPTION_STATUS EncStatus, @@ -4659,7 +4377,7 @@ s_bCipherMatch ( int i; if (pBSSNode == NULL) - return FALSE; + return false; // check cap. of BSS if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && @@ -4669,7 +4387,7 @@ s_bCipherMatch ( } if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && - (pBSSNode->bWPA2Valid == TRUE) && + (pBSSNode->bWPA2Valid == true) && ((EncStatus == Ndis802_11Encryption3Enabled) || (EncStatus == Ndis802_11Encryption2Enabled))) { @@ -4704,7 +4422,7 @@ s_bCipherMatch ( } } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && - (pBSSNode->bWPAValid == TRUE) && + (pBSSNode->bWPAValid == true) && ((EncStatus == Ndis802_11Encryption2Enabled) || (EncStatus == Ndis802_11Encryption3Enabled))) { //WPA // check Group Key Cipher @@ -4746,9 +4464,9 @@ s_bCipherMatch ( (byCipherMask == 0)) { *pbyCCSGK = KEY_CTL_WEP; *pbyCCSPK = KEY_CTL_NONE; - return TRUE; + return true; } else { - return FALSE; + return false; } } else if (EncStatus == Ndis802_11Encryption2Enabled) { @@ -4756,45 +4474,45 @@ s_bCipherMatch ( (byCipherMask == 0)) { *pbyCCSGK = KEY_CTL_TKIP; *pbyCCSPK = KEY_CTL_NONE; - return TRUE; + return true; } else if ((byMulticastCipher == KEY_CTL_WEP) && ((byCipherMask & 0x02) != 0)) { *pbyCCSGK = KEY_CTL_WEP; *pbyCCSPK = KEY_CTL_TKIP; - return TRUE; + return true; } else if ((byMulticastCipher == KEY_CTL_TKIP) && ((byCipherMask & 0x02) != 0)) { *pbyCCSGK = KEY_CTL_TKIP; *pbyCCSPK = KEY_CTL_TKIP; - return TRUE; + return true; } else { - return FALSE; + return false; } } else if (EncStatus == Ndis802_11Encryption3Enabled) { if ((byMulticastCipher == KEY_CTL_CCMP) && (byCipherMask == 0)) { // When CCMP is enable, "Use group cipher suite" shall not be a valid option. - return FALSE; + return false; } else if ((byMulticastCipher == KEY_CTL_WEP) && ((byCipherMask & 0x04) != 0)) { *pbyCCSGK = KEY_CTL_WEP; *pbyCCSPK = KEY_CTL_CCMP; - return TRUE; + return true; } else if ((byMulticastCipher == KEY_CTL_TKIP) && ((byCipherMask & 0x04) != 0)) { *pbyCCSGK = KEY_CTL_TKIP; *pbyCCSPK = KEY_CTL_CCMP; - return TRUE; + return true; } else if ((byMulticastCipher == KEY_CTL_CCMP) && ((byCipherMask & 0x04) != 0)) { *pbyCCSGK = KEY_CTL_CCMP; *pbyCCSPK = KEY_CTL_CCMP; - return TRUE; + return true; } else { - return FALSE; + return false; } } - return TRUE; + return true; } diff --git a/drivers/staging/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h index 52b1b56..83aed45 100644 --- a/drivers/staging/vt6656/wmgr.h +++ b/drivers/staging/vt6656/wmgr.h @@ -218,216 +218,199 @@ typedef enum tagWMAC_POWER_MODE { -// Tx Management Packet descriptor -typedef struct tagSTxMgmtPacket { - - PUWLAN_80211HDR p80211Header; - unsigned int cbMPDULen; - unsigned int cbPayloadLen; - -} STxMgmtPacket, *PSTxMgmtPacket; - - -// Rx Management Packet descriptor -typedef struct tagSRxMgmtPacket { - - PUWLAN_80211HDR p80211Header; - QWORD qwLocalTSF; - unsigned int cbMPDULen; - unsigned int cbPayloadLen; - unsigned int uRSSI; - BYTE bySQ; - BYTE byRxRate; - BYTE byRxChannel; - -} SRxMgmtPacket, *PSRxMgmtPacket; - - - -typedef struct tagSMgmtObject -{ +/* Tx Management Packet descriptor */ +struct vnt_tx_mgmt { + PUWLAN_80211HDR p80211Header; + u32 cbMPDULen; + u32 cbPayloadLen; +}; + + +/* Rx Management Packet descriptor */ +struct vnt_rx_mgmt { + PUWLAN_80211HDR p80211Header; + u64 qwLocalTSF; + u32 cbMPDULen; + u32 cbPayloadLen; + u32 uRSSI; + u8 bySQ; + u8 byRxRate; + u8 byRxChannel; +}; + + +struct vnt_manager { void *pAdapter; - // MAC address - BYTE abyMACAddr[WLAN_ADDR_LEN]; - - // Configuration Mode - WMAC_CONFIG_MODE eConfigMode; // MAC pre-configed mode - - CARD_PHY_TYPE eCurrentPHYMode; - - - // Operation state variables - WMAC_CURRENT_MODE eCurrMode; // MAC current connection mode - WMAC_BSS_STATE eCurrState; // MAC current BSS state - WMAC_BSS_STATE eLastState; // MAC last BSS state - - PKnownBSS pCurrBSS; - BYTE byCSSGK; - BYTE byCSSPK; - -// BYTE abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; -// BYTE abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; - BOOL bCurrBSSIDFilterOn; - - // Current state vars - unsigned int uCurrChannel; - BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - BYTE abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - BYTE abyCurrBSSID[WLAN_BSSID_LEN]; - WORD wCurrCapInfo; - WORD wCurrAID; - unsigned int uRSSITrigger; - WORD wCurrATIMWindow; - WORD wCurrBeaconPeriod; - BOOL bIsDS; - BYTE byERPContext; - - CMD_STATE eCommandState; - unsigned int uScanChannel; - - // Desire joinning BSS vars - BYTE abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - BYTE abyDesireBSSID[WLAN_BSSID_LEN]; - -//restore BSS info for Ad-Hoc mode - BYTE abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - - // Adhoc or AP configuration vars - WORD wIBSSBeaconPeriod; - WORD wIBSSATIMWindow; - unsigned int uIBSSChannel; - BYTE abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - BYTE byAPBBType; - BYTE abyWPAIE[MAX_WPA_IE_LEN]; - WORD wWPAIELen; - - unsigned int uAssocCount; - BOOL bMoreData; - - // Scan state vars - WMAC_SCAN_STATE eScanState; - WMAC_SCAN_TYPE eScanType; - unsigned int uScanStartCh; - unsigned int uScanEndCh; - WORD wScanSteps; - unsigned int uScanBSSType; - // Desire scannig vars - BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - BYTE abyScanBSSID[WLAN_BSSID_LEN]; - - // Privacy - WMAC_AUTHENTICATION_MODE eAuthenMode; - BOOL bShareKeyAlgorithm; - BYTE abyChallenge[WLAN_CHALLENGE_LEN]; - BOOL bPrivacyInvoked; - - // Received beacon state vars - BOOL bInTIM; - BOOL bMulticastTIM; - BYTE byDTIMCount; - BYTE byDTIMPeriod; - - // Power saving state vars - WMAC_POWER_MODE ePSMode; - WORD wListenInterval; - WORD wCountToWakeUp; - BOOL bInTIMWake; - PBYTE pbyPSPacketPool; - BYTE byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN]; - BOOL bRxBeaconInTBTTWake; - BYTE abyPSTxMap[MAX_NODE_NUM + 1]; - - // management command related - unsigned int uCmdBusy; - unsigned int uCmdHostAPBusy; - - // management packet pool - PBYTE pbyMgmtPacketPool; - BYTE byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - - - // One second callback timer - struct timer_list sTimerSecondCallback; - - // Temporarily Rx Mgmt Packet Descriptor - SRxMgmtPacket sRxPacket; - - // link list of known bss's (scan results) - KnownBSS sBSSList[MAX_BSS_NUM]; - /* link list of same bss's */ - KnownBSS pSameBSS[6] ; - BOOL Cisco_cckm ; - BYTE Roam_dbm; - - // table list of known node - // sNodeDBList[0] is reserved for AP under Infra mode - // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode - KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1]; - - - // WPA2 PMKID Cache - SPMKIDCache gsPMKIDCache; - BOOL bRoaming; - - // rate fall back vars - - - - // associate info - SAssocInfo sAssocInfo; - - - // for 802.11h - BOOL b11hEnable; - BOOL bSwitchChannel; - BYTE byNewChannel; - PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep; - unsigned int uLengthOfRepEIDs; - BYTE abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - BYTE abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - BYTE abyIECountry[WLAN_A3FR_MAXLEN]; - BYTE abyIBSSDFSOwner[6]; - BYTE byIBSSDFSRecovery; - - struct sk_buff skb; - -} SMgmtObject, *PSMgmtObject; + /* MAC address */ + u8 abyMACAddr[WLAN_ADDR_LEN]; + + /* Configuration Mode */ + WMAC_CONFIG_MODE eConfigMode; /* MAC pre-configed mode */ + + CARD_PHY_TYPE eCurrentPHYMode; + + /* Operation state variables */ + WMAC_CURRENT_MODE eCurrMode; /* MAC current connection mode */ + WMAC_BSS_STATE eCurrState; /* MAC current BSS state */ + WMAC_BSS_STATE eLastState; /* MAC last BSS state */ + + PKnownBSS pCurrBSS; + u8 byCSSGK; + u8 byCSSPK; + + int bCurrBSSIDFilterOn; + + /* Current state vars */ + u32 uCurrChannel; + u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + u8 abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + u8 abyCurrBSSID[WLAN_BSSID_LEN]; + u16 wCurrCapInfo; + u16 wCurrAID; + u32 uRSSITrigger; + u16 wCurrATIMWindow; + u16 wCurrBeaconPeriod; + int bIsDS; + u8 byERPContext; + + CMD_STATE eCommandState; + u32 uScanChannel; + + /* Desire joinning BSS vars */ + u8 abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + u8 abyDesireBSSID[WLAN_BSSID_LEN]; + + /*restore BSS info for Ad-Hoc mode */ + u8 abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + + /* Adhoc or AP configuration vars */ + u16 wIBSSBeaconPeriod; + u16 wIBSSATIMWindow; + u32 uIBSSChannel; + u8 abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; + u8 byAPBBType; + u8 abyWPAIE[MAX_WPA_IE_LEN]; + u16 wWPAIELen; + + u32 uAssocCount; + int bMoreData; + + /* Scan state vars */ + WMAC_SCAN_STATE eScanState; + WMAC_SCAN_TYPE eScanType; + u32 uScanStartCh; + u32 uScanEndCh; + u16 wScanSteps; + u32 uScanBSSType; + /* Desire scannig vars */ + u8 abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; + u8 abyScanBSSID[WLAN_BSSID_LEN]; + + /* Privacy */ + WMAC_AUTHENTICATION_MODE eAuthenMode; + int bShareKeyAlgorithm; + u8 abyChallenge[WLAN_CHALLENGE_LEN]; + int bPrivacyInvoked; + + /* Received beacon state vars */ + int bInTIM; + int bMulticastTIM; + u8 byDTIMCount; + u8 byDTIMPeriod; + + /* Power saving state vars */ + WMAC_POWER_MODE ePSMode; + u16 wListenInterval; + u16 wCountToWakeUp; + int bInTIMWake; + u8 *pbyPSPacketPool; + u8 byPSPacketPool[sizeof(struct vnt_tx_mgmt) + + WLAN_NULLDATA_FR_MAXLEN]; + int bRxBeaconInTBTTWake; + u8 abyPSTxMap[MAX_NODE_NUM + 1]; + + /* management command related */ + u32 uCmdBusy; + u32 uCmdHostAPBusy; + + /* management packet pool */ + u8 *pbyMgmtPacketPool; + u8 byMgmtPacketPool[sizeof(struct vnt_tx_mgmt) + + WLAN_A3FR_MAXLEN]; + + + /* One second callback timer */ + struct timer_list sTimerSecondCallback; + + /* Temporarily Rx Mgmt Packet Descriptor */ + struct vnt_rx_mgmt sRxPacket; + + /* link list of known bss's (scan results) */ + KnownBSS sBSSList[MAX_BSS_NUM]; + /* link list of same bss's */ + KnownBSS pSameBSS[6]; + int Cisco_cckm; + u8 Roam_dbm; + + /* table list of known node */ + /* sNodeDBList[0] is reserved for AP under Infra mode */ + /* sNodeDBList[0] is reserved for Multicast under adhoc/AP mode */ + KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1]; + + /* WPA2 PMKID Cache */ + SPMKIDCache gsPMKIDCache; + int bRoaming; + + /* associate info */ + SAssocInfo sAssocInfo; + + /* for 802.11h */ + int b11hEnable; + int bSwitchChannel; + u8 byNewChannel; + PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep; + u32 uLengthOfRepEIDs; + u8 abyCurrentMSRReq[sizeof(struct vnt_tx_mgmt) + + WLAN_A3FR_MAXLEN]; + u8 abyCurrentMSRRep[sizeof(struct vnt_tx_mgmt) + + WLAN_A3FR_MAXLEN]; + u8 abyIECountry[WLAN_A3FR_MAXLEN]; + u8 abyIBSSDFSOwner[6]; + u8 byIBSSDFSRecovery; + + struct sk_buff skb; + +}; /*--------------------- Export Macros ------------------------------*/ /*--------------------- Export Functions --------------------------*/ -void vMgrObjectInit(void *hDeviceContext); +void vMgrObjectInit(struct vnt_private *pDevice); -void vMgrAssocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus); +void vMgrAssocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *, PCMD_STATUS pStatus); -void vMgrReAssocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus); +void vMgrReAssocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *, PCMD_STATUS pStatus); -void vMgrDisassocBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PBYTE abyDestAddress, - WORD wReason, - PCMD_STATUS pStatus); +void vMgrDisassocBeginSta(struct vnt_private *pDevice, + struct vnt_manager *, u8 *abyDestAddress, u16 wReason, + PCMD_STATUS pStatus); -void vMgrAuthenBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus); +void vMgrAuthenBeginSta(struct vnt_private *pDevice, + struct vnt_manager *, PCMD_STATUS pStatus); -void vMgrCreateOwnIBSS(void *hDeviceContext, - PCMD_STATUS pStatus); +void vMgrCreateOwnIBSS(struct vnt_private *pDevice, + PCMD_STATUS pStatus); -void vMgrJoinBSSBegin(void *hDeviceContext, - PCMD_STATUS pStatus); +void vMgrJoinBSSBegin(struct vnt_private *pDevice, + PCMD_STATUS pStatus); -void vMgrRxManagePacket(void *hDeviceContext, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket); +void vMgrRxManagePacket(struct vnt_private *pDevice, + struct vnt_manager *, struct vnt_rx_mgmt *); /* void @@ -437,19 +420,16 @@ vMgrScanBegin( ); */ -void vMgrDeAuthenBeginSta(void *hDeviceContext, - PSMgmtObject pMgmt, - PBYTE abyDestAddress, - WORD wReason, - PCMD_STATUS pStatus); +void vMgrDeAuthenBeginSta(struct vnt_private *pDevice, + struct vnt_manager *, u8 *abyDestAddress, u16 wReason, + PCMD_STATUS pStatus); -BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, - PSMgmtObject pMgmt); +int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, + struct vnt_manager *); -BOOL bAdd_PMKID_Candidate(void *hDeviceContext, - PBYTE pbyBSSID, - PSRSNCapObject psRSNCapObj); +int bAdd_PMKID_Candidate(struct vnt_private *pDevice, + u8 *pbyBSSID, PSRSNCapObject psRSNCapObj); -void vFlush_PMKID_Candidate(void *hDeviceContext); +void vFlush_PMKID_Candidate(struct vnt_private *pDevice); #endif /* __WMGR_H__ */ diff --git a/drivers/staging/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c index f6429a2..f037be3 100644 --- a/drivers/staging/vt6656/wpa.c +++ b/drivers/staging/vt6656/wpa.c @@ -83,9 +83,9 @@ WPA_ClearRSN( pBSSList->wAuthCount = 0; pBSSList->byDefaultK_as_PK = 0; pBSSList->byReplayIdx = 0; - pBSSList->sRSNCapObj.bRSNCapExist = FALSE; + pBSSList->sRSNCapObj.bRSNCapExist = false; pBSSList->sRSNCapObj.wRSNCap = 0; - pBSSList->bWPAValid = FALSE; + pBSSList->bWPAValid = false; } @@ -212,14 +212,14 @@ WPA_ParseRSN( pbyCaps = (PBYTE)pIE_RSN_Auth->AuthKSList[n].abyOUI; pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG; pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS); - pBSSList->sRSNCapObj.bRSNCapExist = TRUE; + pBSSList->sRSNCapObj.bRSNCapExist = true; pBSSList->sRSNCapObj.wRSNCap = *(PWORD)pbyCaps; //DBG_PRN_GRP14(("pbyCaps: %X\n", *pbyCaps)); //DBG_PRN_GRP14(("byDefaultK_as_PK: %X\n", pBSSList->byDefaultK_as_PK)); //DBG_PRN_GRP14(("byReplayIdx: %X\n", pBSSList->byReplayIdx)); } } - pBSSList->bWPAValid = TRUE; + pBSSList->bWPAValid = true; } } @@ -239,7 +239,7 @@ WPA_ParseRSN( * Return Value: none. * -*/ -BOOL +bool WPA_SearchRSN( BYTE byCmd, BYTE byEncrypt, @@ -249,14 +249,14 @@ WPA_SearchRSN( int ii; BYTE byPKType = WPA_NONE; - if (pBSSList->bWPAValid == FALSE) - return FALSE; + if (pBSSList->bWPAValid == false) + return false; switch(byCmd) { case 0: if (byEncrypt != pBSSList->byGKType) - return FALSE; + return false; if (pBSSList->wPKCount > 0) { for (ii = 0; ii < pBSSList->wPKCount; ii ++) { @@ -270,9 +270,9 @@ WPA_SearchRSN( byPKType = WPA_WEP104; } if (byEncrypt != byPKType) - return FALSE; + return false; } - return TRUE; + return true; // if (pBSSList->wAuthCount > 0) // for (ii=0; ii < pBSSList->wAuthCount; ii ++) // if (byAuth == pBSSList->abyAuthType[ii]) @@ -282,7 +282,7 @@ WPA_SearchRSN( default: break; } - return FALSE; + return false; } /*+ @@ -299,20 +299,20 @@ WPA_SearchRSN( * Return Value: none. * -*/ -BOOL +bool WPAb_Is_RSN( PWLAN_IE_RSN_EXT pRSN ) { if (pRSN == NULL) - return FALSE; + return false; if ((pRSN->len >= 6) && // oui1(4)+ver(2) (pRSN->byElementID == WLAN_EID_RSN_WPA) && !memcmp(pRSN->abyOUI, abyOUI01, 4) && (pRSN->wVersion == 1)) { - return TRUE; + return true; } else - return FALSE; + return false; } diff --git a/drivers/staging/vt6656/wpa.h b/drivers/staging/vt6656/wpa.h index 889489a..0369cbf 100644 --- a/drivers/staging/vt6656/wpa.h +++ b/drivers/staging/vt6656/wpa.h @@ -69,14 +69,14 @@ WPA_ParseRSN( PWLAN_IE_RSN_EXT pRSN ); -BOOL +bool WPA_SearchRSN( BYTE byCmd, BYTE byEncrypt, PKnownBSS pBSSList ); -BOOL +bool WPAb_Is_RSN( PWLAN_IE_RSN_EXT pRSN ); diff --git a/drivers/staging/vt6656/wpa2.c b/drivers/staging/vt6656/wpa2.c index 616e24d..a89456a 100644 --- a/drivers/staging/vt6656/wpa2.c +++ b/drivers/staging/vt6656/wpa2.c @@ -78,7 +78,7 @@ WPA2_ClearRSN ( { int ii; - pBSSNode->bWPA2Valid = FALSE; + pBSSNode->bWPA2Valid = false; pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP; for (ii=0; ii < 4; ii ++) @@ -87,7 +87,7 @@ WPA2_ClearRSN ( for (ii=0; ii < 4; ii ++) pBSSNode->abyAKMSSAuthType[ii] = WLAN_11i_AKMSS_802_1X; pBSSNode->wAKMSSAuthCount = 1; - pBSSNode->sRSNCapObj.bRSNCapExist = FALSE; + pBSSNode->sRSNCapObj.bRSNCapExist = false; pBSSNode->sRSNCapObj.wRSNCap = 0; } @@ -115,7 +115,7 @@ WPA2vParseRSN ( int i, j; WORD m = 0, n = 0; PBYTE pbyOUI; - BOOL bUseGK = FALSE; + bool bUseGK = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA2_ParseRSN: [%d]\n", pRSN->len); @@ -123,7 +123,7 @@ WPA2vParseRSN ( if (pRSN->len == 2) { // ver(2) if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) { - pBSSNode->bWPA2Valid = TRUE; + pBSSNode->bWPA2Valid = true; } return; } @@ -158,7 +158,7 @@ WPA2vParseRSN ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"802.11i CSS: %X\n", pBSSNode->byCSSGK); if (pRSN->len == 6) { - pBSSNode->bWPA2Valid = TRUE; + pBSSNode->bWPA2Valid = true; return; } @@ -172,7 +172,7 @@ WPA2vParseRSN ( if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i) if ( !memcmp(pbyOUI, abyOUIGK, 4)) { pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_USE_GROUP; - bUseGK = TRUE; + bUseGK = true; } else if ( !memcmp(pbyOUI, abyOUIWEP40, 4)) { // Invalid CSS, continue parsing } else if ( !memcmp(pbyOUI, abyOUITKIP, 4)) { @@ -194,7 +194,7 @@ WPA2vParseRSN ( break; } //for - if (bUseGK == TRUE) { + if (bUseGK == true) { if (j != 1) { // invalid CSS, This should be only PK CSS. return; @@ -236,12 +236,12 @@ WPA2vParseRSN ( n = *((PWORD) &(pRSN->abyRSN[6+4*m])); if (pRSN->len >= 12+4*m+4*n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2) - pBSSNode->sRSNCapObj.bRSNCapExist = TRUE; + pBSSNode->sRSNCapObj.bRSNCapExist = true; pBSSNode->sRSNCapObj.wRSNCap = *((PWORD) &(pRSN->abyRSN[8+4*m+4*n])); } } //ignore PMKID lists bcs only (Re)Assocrequest has this field - pBSSNode->bWPA2Valid = TRUE; + pBSSNode->bWPA2Valid = true; } } @@ -260,19 +260,16 @@ WPA2vParseRSN ( * Return Value: length of IEs. * -*/ -unsigned int -WPA2uSetIEs(void *pMgmtHandle, - PWLAN_IE_RSN pRSNIEs - ) +unsigned int WPA2uSetIEs(void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs) { - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - PBYTE pbyBuffer = NULL; - unsigned int ii = 0; - PWORD pwPMKID = NULL; + struct vnt_manager *pMgmt = (struct vnt_manager *)pMgmtHandle; + u8 *pbyBuffer = NULL; + int ii = 0; + u16 *pwPMKID = NULL; + + if (pRSNIEs == NULL) + return 0; - if (pRSNIEs == NULL) { - return(0); - } if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { @@ -328,7 +325,7 @@ WPA2uSetIEs(void *pMgmtHandle, pRSNIEs->len +=6; // RSN Capabilites - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == TRUE) { + if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { memcpy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); } else { pRSNIEs->abyRSN[16] = 0; @@ -337,7 +334,7 @@ WPA2uSetIEs(void *pMgmtHandle, pRSNIEs->len +=2; if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) && - (pMgmt->bRoaming == TRUE) && + (pMgmt->bRoaming == true) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { /* RSN PMKID, pointer to PMKID count */ pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index cc1d48b..53629b2 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -67,14 +67,14 @@ static int msglevel = MSG_LEVEL_INFO; * Return Value: * */ -int wpa_set_keys(PSDevice pDevice, void *ctx) +int wpa_set_keys(struct vnt_private *pDevice, void *ctx) { struct viawget_wpa_param *param = ctx; - PSMgmtObject pMgmt = &pDevice->sMgmtObj; + struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DWORD dwKeyIndex = 0; BYTE abyKey[MAX_KEY_LEN]; BYTE abySeq[MAX_KEY_LEN]; - QWORD KeyRSC; + u64 KeyRSC; BYTE byKeyDecMode = KEY_CTL_WEP; int ret = 0; int uu; @@ -87,9 +87,9 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) param->u.wpa_key.alg_name); if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - pDevice->bEncryptionEnable = FALSE; + pDevice->bEncryptionEnable = false; pDevice->byKeyIndex = 0; - pDevice->bTransmitKey = FALSE; + pDevice->bTransmitKey = false; for (uu=0; uu<MAX_KEY_TABLE; uu++) { MACvDisableKeyEntry(pDevice, uu); } @@ -109,7 +109,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) } else { if (param->u.wpa_key.set_tx) { pDevice->byKeyIndex = (BYTE)dwKeyIndex; - pDevice->bTransmitKey = TRUE; + pDevice->bTransmitKey = true; dwKeyIndex |= (1 << 31); } KeybSetDefaultKey( pDevice, @@ -123,7 +123,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) } pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = TRUE; + pDevice->bEncryptionEnable = true; return ret; } @@ -136,9 +136,9 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) if (param->u.wpa_key.seq_len > 0) { for (ii = 0 ; ii < param->u.wpa_key.seq_len ; ii++) { if (ii < 4) - LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8)); + KeyRSC |= (abySeq[ii] << (ii * 8)); else - HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8)); + KeyRSC |= (abySeq[ii] << ((ii-4) * 8)); } dwKeyIndex |= 1 << 29; } @@ -203,18 +203,18 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) if ((KeybSetAllGroupKey(pDevice, &(pDevice->sKey), dwKeyIndex, param->u.wpa_key.key_len, - (PQWORD) &(KeyRSC), + &KeyRSC, (PBYTE)abyKey, byKeyDecMode - ) == TRUE) && + ) == true) && (KeybSetDefaultKey(pDevice, &(pDevice->sKey), dwKeyIndex, param->u.wpa_key.key_len, - (PQWORD) &(KeyRSC), + &KeyRSC, (PBYTE)abyKey, byKeyDecMode - ) == TRUE) ) { + ) == true) ) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n"); } else { return -EINVAL; @@ -234,8 +234,8 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) } if (KeybSetKey(pDevice, &(pDevice->sKey), ¶m->addr[0], dwKeyIndex, param->u.wpa_key.key_len, - (PQWORD) &(KeyRSC), (PBYTE)abyKey, byKeyDecMode - ) == TRUE) { + &KeyRSC, (PBYTE)abyKey, byKeyDecMode + ) == true) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n"); } else { // Key Table Full @@ -251,9 +251,9 @@ int wpa_set_keys(PSDevice pDevice, void *ctx) } // BSSID not 0xffffffffffff if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) { pDevice->byKeyIndex = (BYTE)param->u.wpa_key.key_index; - pDevice->bTransmitKey = TRUE; + pDevice->bTransmitKey = true; } - pDevice->bEncryptionEnable = TRUE; + pDevice->bEncryptionEnable = true; return ret; } diff --git a/drivers/staging/vt6656/wpactl.h b/drivers/staging/vt6656/wpactl.h index b4ec6b0..2235ee9 100644 --- a/drivers/staging/vt6656/wpactl.h +++ b/drivers/staging/vt6656/wpactl.h @@ -52,6 +52,6 @@ typedef unsigned long long NDIS_802_11_KEY_RSC; /*--------------------- Export Functions --------------------------*/ -int wpa_set_keys(PSDevice pDevice, void *ctx); +int wpa_set_keys(struct vnt_private *, void *ctx); #endif /* __WPACL_H__ */ diff --git a/drivers/staging/winbond/Kconfig b/drivers/staging/winbond/Kconfig index a29f608..db5b053 100644 --- a/drivers/staging/winbond/Kconfig +++ b/drivers/staging/winbond/Kconfig @@ -8,4 +8,4 @@ config W35UND Hardware is present in some Kohjinsha subnotebooks, and in some stand-alone USB modules. Chipset name seems to be w89c35d. - Check http://code.google.com/p/winbondport/ for new version. + Check <http://code.google.com/p/winbondport/> for new version. diff --git a/drivers/staging/wlags49_h2/ap_h2.c b/drivers/staging/wlags49_h2/ap_h2.c index e524153..3a08d42 100644 --- a/drivers/staging/wlags49_h2/ap_h2.c +++ b/drivers/staging/wlags49_h2/ap_h2.c @@ -3256,7 +3256,7 @@ static const CFG_PROG_STRCT fw_image_code[] = { 0x0146, /* sizeof(fw_image_1_data), */ 0x00000060, /* Target address in NIC Memory */ 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ - (hcf_8 FAR *) fw_image_1_data + (hcf_8 *)fw_image_1_data }, { 8, @@ -3265,7 +3265,7 @@ static const CFG_PROG_STRCT fw_image_code[] = { 0x1918, /* sizeof(fw_image_2_data), */ 0x00000C16, /* Target address in NIC Memory */ 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ - (hcf_8 FAR *) fw_image_2_data + (hcf_8 *)fw_image_2_data }, { 8, @@ -3274,7 +3274,7 @@ static const CFG_PROG_STRCT fw_image_code[] = { 0x01bc, /* sizeof(fw_image_3_data), */ 0x001E252E, /* Target address in NIC Memory */ 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ - (hcf_8 FAR *) fw_image_3_data + (hcf_8 *)fw_image_3_data }, { 8, @@ -3283,7 +3283,7 @@ static const CFG_PROG_STRCT fw_image_code[] = { 0xab28, /* sizeof(fw_image_4_data), */ 0x001F4000, /* Target address in NIC Memory */ 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ - (hcf_8 FAR *) fw_image_4_data + (hcf_8 *)fw_image_4_data }, { 5, diff --git a/drivers/staging/wlags49_h2/ap_h25.c b/drivers/staging/wlags49_h2/ap_h25.c index f4491cb..d3a0faa 100644 --- a/drivers/staging/wlags49_h2/ap_h25.c +++ b/drivers/staging/wlags49_h2/ap_h25.c @@ -24,10 +24,10 @@ */ -#include "hcfcfg.h" // to get hcf_16 etc defined as well as - // possible settings which inluence mdd.h or dhf.h -#include "mdd.h" //to get COMP_ID_STA etc defined -#include "dhf.h" //used to be "fhfmem.h", to get memblock,plugrecord, +#include "hcfcfg.h" /* to get hcf_16 etc defined as well as */ + /* possible settings which inluence mdd.h or dhf.h */ +#include "mdd.h" /* to get COMP_ID_STA etc defined */ +#include "dhf.h" /* used to be fhfmem.h, to get memblock,plugrecord, */ static const hcf_8 fw_image_1_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -3996,59 +3996,59 @@ static const hcf_8 fw_image_4_data[] = { static const CFG_IDENTITY_STRCT fw_image_infoidentity[] = { { - sizeof( CFG_IDENTITY_STRCT ) / sizeof(hcf_16) - 1, + sizeof(CFG_IDENTITY_STRCT) / sizeof(hcf_16) - 1, CFG_FW_IDENTITY, COMP_ID_FW_AP, - 3, //Variant - 1, //Major - 24 //Minor + 3, /* Variant */ + 1, /* Major */ + 24 /* Minor */ }, - { 0000, 0000, 0000, 0000, 0000, 0000 } //endsentinel + { 0000, 0000, 0000, 0000, 0000, 0000 } /* endsentinel */ }; static const CFG_PROG_STRCT fw_image_code[] = { { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x0148, // sizeof(fw_image_1_data), - 0x00000060, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_1_data + CFG_PROG_VOLATILE, /* mode */ + 0x0148, /* sizeof(fw_image_1_data), */ + 0x00000060, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_1_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x2432, // sizeof(fw_image_2_data), - 0x00000C16, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_2_data + CFG_PROG_VOLATILE, /* mode */ + 0x2432, /* sizeof(fw_image_2_data), */ + 0x00000C16, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_2_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x194c, // sizeof(fw_image_3_data), - 0x001E3048, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_3_data + CFG_PROG_VOLATILE, /* mode */ + 0x194c, /* sizeof(fw_image_3_data), */ + 0x001E3048, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_3_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0xb7e4, // sizeof(fw_image_4_data), - 0x001F4000, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_4_data + CFG_PROG_VOLATILE, /* mode*/ + 0xb7e4, /* sizeof(fw_image_4_data),*/ + 0x001F4000, /* Target address in NIC Memory*/ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary*/ + (hcf_8 *)fw_image_4_data }, { 5, CFG_PROG, - CFG_PROG_STOP, // mode + CFG_PROG_STOP, /* mode*/ 0000, - 0x000F2101, // Start execution address + 0x000F2101, /* Start execution address*/ }, { 0000, 0000, 0000, 0000, 00000000, 0000, 00000000} }; @@ -4059,7 +4059,7 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_SUPL, COMP_ID_APF, { - { 4, 1, 1 } //variant, bottom, top + { 4, 1, 1 } /* variant, bottom, top*/ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -4067,8 +4067,8 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_MFI, { - { 7, 3, 3 }, //variant, bottom, top - { 8, 1, 1 } //variant, bottom, top + { 7, 3, 3 }, /* variant, bottom, top */ + { 8, 1, 1 } /* variant, bottom, top */ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -4076,18 +4076,18 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_CFI, { - { 4, 1, 2 } //variant, bottom, top + { 4, 1, 2 } /* variant, bottom, top */ } }, - { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } //endsentinel + { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } /* endsentinel */ }; memimage fw_image = { - "FUPU7D37dhfwci\001C", //signature, <format number>, C/Bin type + "FUPU7D37dhfwci\001C", /* signature, <format number>, C/Bin type */ (CFG_PROG_STRCT *) fw_image_code, 0x000F2101, - 00000000, //(dummy) pdaplug - 00000000, //(dummy) priplug + 00000000, /* (dummy) pdaplug */ + 00000000, /* (dummy) priplug */ (CFG_RANGE20_STRCT *) fw_image_infocompat, (CFG_IDENTITY_STRCT *) fw_image_infoidentity, }; diff --git a/drivers/staging/wlags49_h2/sta_h2.c b/drivers/staging/wlags49_h2/sta_h2.c index 00dffe2..19bed81 100644 --- a/drivers/staging/wlags49_h2/sta_h2.c +++ b/drivers/staging/wlags49_h2/sta_h2.c @@ -25,10 +25,10 @@ */ -#include "hcfcfg.h" // to get hcf_16 etc defined as well as - // possible settings which influence mdd.h or dhf.h -#include "mdd.h" //to get COMP_ID_STA etc defined -#include "dhf.h" //used to be "fhfmem.h", to get memblock,plugrecord, +#include "hcfcfg.h" /* to get hcf_16 etc defined as well as */ + /* possible settings which influence mdd.h or dhf.h */ +#include "mdd.h" /* to get COMP_ID_STA etc defined */ +#include "dhf.h" /* used to be fhfmem.h, to get memblock,plugrecord, */ static const hcf_8 fw_image_1_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -4381,59 +4381,59 @@ static const hcf_8 fw_image_4_data[] = { static const CFG_IDENTITY_STRCT fw_image_infoidentity[] = { { - sizeof( CFG_IDENTITY_STRCT ) / sizeof(hcf_16) - 1, + sizeof(CFG_IDENTITY_STRCT) / sizeof(hcf_16) - 1, CFG_FW_IDENTITY, COMP_ID_FW_STA, - 3, //Variant - 2, //Major - 36 //Minor + 3, /* Variant */ + 2, /* Major */ + 36 /* Minor */ }, - { 0000, 0000, 0000, 0000, 0000, 0000 } //endsentinel + { 0000, 0000, 0000, 0000, 0000, 0000 } /* endsentinel */ }; static const CFG_PROG_STRCT fw_image_code[] = { { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x0186, // sizeof(fw_image_1_data), - 0x00000060, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_1_data + CFG_PROG_VOLATILE, /* mode */ + 0x0186, /* sizeof(fw_image_1_data), */ + 0x00000060, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_1_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x2518, // sizeof(fw_image_2_data), - 0x00000C16, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_2_data + CFG_PROG_VOLATILE, /* mode */ + 0x2518, /* sizeof(fw_image_2_data), */ + 0x00000C16, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_2_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x3daa, // sizeof(fw_image_3_data), - 0x001E312E, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_3_data + CFG_PROG_VOLATILE, /* mode */ + 0x3daa, /* sizeof(fw_image_3_data), */ + 0x001E312E, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_3_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0xaa66, // sizeof(fw_image_4_data), - 0x001F4000, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_4_data + CFG_PROG_VOLATILE, /* mode */ + 0xaa66, /* sizeof(fw_image_4_data), */ + 0x001F4000, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 *)fw_image_4_data }, { 5, CFG_PROG, - CFG_PROG_STOP, // mode + CFG_PROG_STOP, /* mode */ 0000, - 0x000F368E, // Start execution address + 0x000F368E, /* Start execution address */ }, { 0000, 0000, 0000, 0000, 00000000, 0000, 00000000} }; @@ -4444,7 +4444,7 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_SUPL, COMP_ID_STA, { - { 2, 2, 5 } //variant, bottom, top + { 2, 2, 5 } /* variant, bottom, top */ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -4452,9 +4452,9 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_MFI, { - { 4, 6, 7 }, //variant, bottom, top - { 5, 6, 7 }, //variant, bottom, top - { 6, 6, 7 } //variant, bottom, top + { 4, 6, 7 }, /* variant, bottom, top */ + { 5, 6, 7 }, /* variant, bottom, top */ + { 6, 6, 7 } /* variant, bottom, top */ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -4462,18 +4462,18 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_CFI, { - { 2, 1, 2 } //variant, bottom, top + { 2, 1, 2 } /* variant, bottom, top */ } }, - { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } //endsentinel + { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } /* endsentinel */ }; memimage fw_image = { - "FUPU7D37dhfwci\001C", //signature, <format number>, C/Bin type + "FUPU7D37dhfwci\001C", /* signature, <format number>, C/Bin type */ (CFG_PROG_STRCT *) fw_image_code, 0x000F368E, - 00000000, //(dummy) pdaplug - 00000000, //(dummy) priplug + 00000000, /* (dummy) pdaplug */ + 00000000, /* (dummy) priplug */ (CFG_RANGE20_STRCT *) fw_image_infocompat, (CFG_IDENTITY_STRCT *) fw_image_infoidentity, }; diff --git a/drivers/staging/wlags49_h2/wl_enc.c b/drivers/staging/wlags49_h2/wl_enc.c index 4c6f776..51293d9 100644 --- a/drivers/staging/wlags49_h2/wl_enc.c +++ b/drivers/staging/wlags49_h2/wl_enc.c @@ -105,57 +105,57 @@ extern dbg_info_t *DbgInfo; * OK * ******************************************************************************/ -int wl_wep_code( char *szCrypt, char *szDest, void *Data, int nLen ) +int wl_wep_code(char *szCrypt, char *szDest, void *Data, int nLen) { - int i; - int t; - int k ; - char bits; - char *szData = (char *) Data; - /*------------------------------------------------------------------------*/ + int i; + int t; + int k ; + char bits; + char *szData = (char *) Data; + /*------------------------------------------------------------------------*/ - for( i = bits = 0 ; i < MACADDRESS_STR_LEN; i++ ) { - bits ^= szCrypt[i]; - bits += szCrypt[i]; - } + for (i = bits = 0; i < MACADDRESS_STR_LEN; i++) { + bits ^= szCrypt[i]; + bits += szCrypt[i]; + } - for( i = t = *szDest = 0; i < nLen; i++, t++ ) { - k = szData[i] ^ ( bits + i ); + for (i = t = *szDest = 0; i < nLen; i++, t++) { + k = szData[i] ^ (bits + i); - switch( i % 3 ) { + switch (i % 3) { - case 0 : + case 0: - szDest[t] = ((k & 0xFC) >> 2) + CH_START ; - szDest[t+1] = ((k & 0x03) << 4) + CH_START ; - szDest[t+2] = '\0'; + szDest[t] = ((k & 0xFC) >> 2) + CH_START ; + szDest[t+1] = ((k & 0x03) << 4) + CH_START ; + szDest[t+2] = '\0'; - break; + break; - case 1 : + case 1: - szDest[t] += (( k & 0xF0 ) >> 4 ); - szDest[t+1] = (( k & 0x0F ) << 2 ) + CH_START ; - szDest[t+2] = '\0'; + szDest[t] += ((k & 0xF0) >> 4); + szDest[t+1] = ((k & 0x0F) << 2) + CH_START ; + szDest[t+2] = '\0'; - break; + break; - case 2 : + case 2: - szDest[t] += (( k & 0xC0 ) >> 6 ); - szDest[t+1] = ( k & 0x3F ) + CH_START ; - szDest[t+2] = '\0'; - t++; + szDest[t] += ((k & 0xC0) >> 6); + szDest[t+1] = (k & 0x3F) + CH_START ; + szDest[t+2] = '\0'; + t++; - break; - } - } + break; + } + } - return( strlen( szDest )) ; + return strlen(szDest); } /*============================================================================*/ @@ -182,50 +182,50 @@ int wl_wep_code( char *szCrypt, char *szDest, void *Data, int nLen ) * OK * ******************************************************************************/ -int wl_wep_decode( char *szCrypt, void *Dest, char *szData ) +int wl_wep_decode(char *szCrypt, void *Dest, char *szData) { - int i; - int t; - int nLen; - char bits; - char *szDest = Dest; - /*------------------------------------------------------------------------*/ + int i; + int t; + int nLen; + char bits; + char *szDest = Dest; + /*------------------------------------------------------------------------*/ - for( i = bits = 0 ; i < 12; i++ ) { - bits ^= szCrypt[i] ; - bits += szCrypt[i] ; - } + for (i = bits = 0; i < 12; i++) { + bits ^= szCrypt[i] ; + bits += szCrypt[i] ; + } - nLen = ( strlen( szData ) * 3) / 4 ; + nLen = (strlen(szData) * 3) / 4 ; - for( i = t = 0; i < nLen; i++, t++ ) { - switch( i % 3 ) { - case 0 : + for (i = t = 0; i < nLen; i++, t++) { + switch (i % 3) { + case 0: - szDest[i] = ((( szData[t]-CH_START ) & 0x3f ) << 2 ) + - ((( szData[t+1]-CH_START ) & 0x30 ) >> 4 ); - break; + szDest[i] = (((szData[t] - CH_START) & 0x3f) << 2) + + (((szData[t+1] - CH_START) & 0x30) >> 4); + break; - case 1 : - szDest[i] = ((( szData[t]-CH_START ) & 0x0f ) << 4 ) + - ((( szData[t+1]-CH_START ) & 0x3c ) >> 2 ); - break; + case 1: + szDest[i] = (((szData[t] - CH_START) & 0x0f) << 4) + + (((szData[t+1] - CH_START) & 0x3c) >> 2); + break; - case 2 : - szDest[i] = ((( szData[t]-CH_START ) & 0x03 ) << 6 ) + - (( szData[t+1]-CH_START ) & 0x3f ); - t++; - break; - } + case 2: + szDest[i] = (((szData[t] - CH_START) & 0x03) << 6) + + ((szData[t+1] - CH_START) & 0x3f); + t++; + break; + } - szDest[i] ^= ( bits + i ) ; + szDest[i] ^= (bits + i); - } + } - return( i ) ; + return i; } /*============================================================================*/ diff --git a/drivers/staging/wlags49_h2/wl_netdev.h b/drivers/staging/wlags49_h2/wl_netdev.h index 61f040f..95bfbeb 100644 --- a/drivers/staging/wlags49_h2/wl_netdev.h +++ b/drivers/staging/wlags49_h2/wl_netdev.h @@ -68,87 +68,87 @@ /******************************************************************************* * function prototypes ******************************************************************************/ -int wl_init( struct net_device *dev ); +int wl_init(struct net_device *dev); -int wl_config( struct net_device *dev, struct ifmap *map ); +int wl_config(struct net_device *dev, struct ifmap *map); -struct net_device *wl_device_alloc( void ); +struct net_device *wl_device_alloc(void); -void wl_device_dealloc( struct net_device *dev ); +void wl_device_dealloc(struct net_device *dev); -int wl_open( struct net_device *dev ); +int wl_open(struct net_device *dev); -int wl_close( struct net_device *dev ); +int wl_close(struct net_device *dev); -int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd ); +int wl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -int wl_tx( struct sk_buff *skb, struct net_device *dev, int port ); +int wl_tx(struct sk_buff *skb, struct net_device *dev, int port); -int wl_send( struct wl_private *lp ); +int wl_send(struct wl_private *lp); -int wl_rx( struct net_device *dev ); +int wl_rx(struct net_device *dev); -void wl_tx_timeout( struct net_device *dev ); +void wl_tx_timeout(struct net_device *dev); -struct net_device_stats *wl_stats( struct net_device *dev ); +struct net_device_stats *wl_stats(struct net_device *dev); #ifdef ENABLE_DMA -int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port ); -int wl_rx_dma( struct net_device *dev ); +int wl_send_dma(struct wl_private *lp, struct sk_buff *skb, int port); +int wl_rx_dma(struct net_device *dev); #endif #ifdef NEW_MULTICAST -void wl_multicast( struct net_device *dev ); +void wl_multicast(struct net_device *dev); #else -void wl_multicast( struct net_device *dev, int num_addrs, void *addrs ); -#endif // NEW_MULTICAST +void wl_multicast(struct net_device *dev, int num_addrs, void *addrs); +#endif /* NEW_MULTICAST */ -int wl_tx_port0( struct sk_buff *skb, struct net_device *dev ); +int wl_tx_port0(struct sk_buff *skb, struct net_device *dev); #ifdef USE_WDS -int wl_tx_port1( struct sk_buff *skb, struct net_device *dev ); -int wl_tx_port2( struct sk_buff *skb, struct net_device *dev ); -int wl_tx_port3( struct sk_buff *skb, struct net_device *dev ); -int wl_tx_port4( struct sk_buff *skb, struct net_device *dev ); -int wl_tx_port5( struct sk_buff *skb, struct net_device *dev ); -int wl_tx_port6( struct sk_buff *skb, struct net_device *dev ); - -void wl_wds_device_alloc( struct wl_private *lp ); -void wl_wds_device_dealloc( struct wl_private *lp ); -void wl_wds_netif_start_queue( struct wl_private *lp ); -void wl_wds_netif_stop_queue( struct wl_private *lp ); -void wl_wds_netif_wake_queue( struct wl_private *lp ); -void wl_wds_netif_carrier_on( struct wl_private *lp ); -void wl_wds_netif_carrier_off( struct wl_private *lp ); +int wl_tx_port1(struct sk_buff *skb, struct net_device *dev); +int wl_tx_port2(struct sk_buff *skb, struct net_device *dev); +int wl_tx_port3(struct sk_buff *skb, struct net_device *dev); +int wl_tx_port4(struct sk_buff *skb, struct net_device *dev); +int wl_tx_port5(struct sk_buff *skb, struct net_device *dev); +int wl_tx_port6(struct sk_buff *skb, struct net_device *dev); + +void wl_wds_device_alloc(struct wl_private *lp); +void wl_wds_device_dealloc(struct wl_private *lp); +void wl_wds_netif_start_queue(struct wl_private *lp); +void wl_wds_netif_stop_queue(struct wl_private *lp); +void wl_wds_netif_wake_queue(struct wl_private *lp); +void wl_wds_netif_carrier_on(struct wl_private *lp); +void wl_wds_netif_carrier_off(struct wl_private *lp); #endif /* USE_WDS */ #ifdef USE_WDS -#define WL_WDS_DEVICE_ALLOC( ARG ) wl_wds_device_alloc( ARG ) -#define WL_WDS_DEVICE_DEALLOC( ARG ) wl_wds_device_dealloc( ARG ) -#define WL_WDS_NETIF_START_QUEUE( ARG ) wl_wds_netif_start_queue( ARG ) -#define WL_WDS_NETIF_STOP_QUEUE( ARG ) wl_wds_netif_stop_queue( ARG ) -#define WL_WDS_NETIF_WAKE_QUEUE( ARG ) wl_wds_netif_wake_queue( ARG ) -#define WL_WDS_NETIF_CARRIER_ON( ARG ) wl_wds_netif_carrier_on( ARG ) -#define WL_WDS_NETIF_CARRIER_OFF( ARG ) wl_wds_netif_carrier_off( ARG ) +#define WL_WDS_DEVICE_ALLOC(ARG) wl_wds_device_alloc(ARG) +#define WL_WDS_DEVICE_DEALLOC(ARG) wl_wds_device_dealloc(ARG) +#define WL_WDS_NETIF_START_QUEUE(ARG) wl_wds_netif_start_queue(ARG) +#define WL_WDS_NETIF_STOP_QUEUE(ARG) wl_wds_netif_stop_queue(ARG) +#define WL_WDS_NETIF_WAKE_QUEUE(ARG) wl_wds_netif_wake_queue(ARG) +#define WL_WDS_NETIF_CARRIER_ON(ARG) wl_wds_netif_carrier_on(ARG) +#define WL_WDS_NETIF_CARRIER_OFF(ARG) wl_wds_netif_carrier_off(ARG) #else -#define WL_WDS_DEVICE_ALLOC( ARG ) -#define WL_WDS_DEVICE_DEALLOC( ARG ) -#define WL_WDS_NETIF_START_QUEUE( ARG ) -#define WL_WDS_NETIF_STOP_QUEUE( ARG ) -#define WL_WDS_NETIF_WAKE_QUEUE( ARG ) -#define WL_WDS_NETIF_CARRIER_ON( ARG ) -#define WL_WDS_NETIF_CARRIER_OFF( ARG ) +#define WL_WDS_DEVICE_ALLOC(ARG) +#define WL_WDS_DEVICE_DEALLOC(ARG) +#define WL_WDS_NETIF_START_QUEUE(ARG) +#define WL_WDS_NETIF_STOP_QUEUE(ARG) +#define WL_WDS_NETIF_WAKE_QUEUE(ARG) +#define WL_WDS_NETIF_CARRIER_ON(ARG) +#define WL_WDS_NETIF_CARRIER_OFF(ARG) #endif /* USE_WDS */ -#endif // __WL_NETDEV_H__ +#endif /* __WL_NETDEV_H__ */ diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c index 87e1e41..c97e0e1 100644 --- a/drivers/staging/wlags49_h2/wl_priv.c +++ b/drivers/staging/wlags49_h2/wl_priv.c @@ -67,7 +67,7 @@ #include <linux/ioport.h> #include <linux/slab.h> #include <linux/delay.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <debug.h> #include <hcf.h> @@ -81,17 +81,17 @@ #include <wl_util.h> #include <wl_netdev.h> -int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ); -int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ); +int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp); +int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp); -int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ); -int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ); +int cfg_driver_info(struct uilreq *urq, struct wl_private *lp); +int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp); /******************************************************************************* @@ -99,7 +99,7 @@ int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ); ******************************************************************************/ #if DBG extern dbg_info_t *DbgInfo; -#endif // DBG +#endif /* DBG */ @@ -127,47 +127,47 @@ extern dbg_info_t *DbgInfo; * errno value otherwise * ******************************************************************************/ -int wvlan_uil( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil(struct uilreq *urq, struct wl_private *lp) { int ioctl_ret = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil"); + DBG_ENTER(DbgInfo); - switch( urq->command ) { - case UIL_FUN_CONNECT: + switch (urq->command) { + case UIL_FUN_CONNECT: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_CONNECT\n"); - ioctl_ret = wvlan_uil_connect( urq, lp ); + ioctl_ret = wvlan_uil_connect(urq, lp); break; - case UIL_FUN_DISCONNECT: + case UIL_FUN_DISCONNECT: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_DISCONNECT\n"); - ioctl_ret = wvlan_uil_disconnect( urq, lp ); + ioctl_ret = wvlan_uil_disconnect(urq, lp); break; - case UIL_FUN_ACTION: - DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_ACTION\n" ); - ioctl_ret = wvlan_uil_action( urq, lp ); + case UIL_FUN_ACTION: + DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_ACTION\n"); + ioctl_ret = wvlan_uil_action(urq, lp); break; - case UIL_FUN_SEND_DIAG_MSG: + case UIL_FUN_SEND_DIAG_MSG: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_SEND_DIAG_MSG\n"); - ioctl_ret = wvlan_uil_send_diag_msg( urq, lp ); + ioctl_ret = wvlan_uil_send_diag_msg(urq, lp); break; - case UIL_FUN_GET_INFO: + case UIL_FUN_GET_INFO: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_GET_INFO\n"); - ioctl_ret = wvlan_uil_get_info( urq, lp ); + ioctl_ret = wvlan_uil_get_info(urq, lp); break; - case UIL_FUN_PUT_INFO: + case UIL_FUN_PUT_INFO: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_PUT_INFO\n"); - ioctl_ret = wvlan_uil_put_info( urq, lp ); + ioctl_ret = wvlan_uil_put_info(urq, lp); break; default: - DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- UNSUPPORTED UIL CODE: 0x%X", urq->command ); + DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- UNSUPPORTED UIL CODE: 0x%X", urq->command); ioctl_ret = -EOPNOTSUPP; break; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ioctl_ret; -} // wvlan_uil +} /* wvlan_uil */ /*============================================================================*/ @@ -192,28 +192,28 @@ int wvlan_uil( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_connect" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_connect"); + DBG_ENTER(DbgInfo); - if( !( lp->flags & WVLAN2_UIL_CONNECTED )) { + if (!(lp->flags & WVLAN2_UIL_CONNECTED)) { lp->flags |= WVLAN2_UIL_CONNECTED; - urq->hcfCtx = &( lp->hcfCtx ); + urq->hcfCtx = &(lp->hcfCtx); urq->result = UIL_SUCCESS; } else { - DBG_WARNING( DbgInfo, "UIL_ERR_IN_USE\n" ); + DBG_WARNING(DbgInfo, "UIL_ERR_IN_USE\n"); urq->result = UIL_ERR_IN_USE; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_connect +} /* wvlan_uil_connect */ /*============================================================================*/ @@ -238,17 +238,17 @@ int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_disconnect" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_disconnect"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { if (lp->flags & WVLAN2_UIL_CONNECTED) { lp->flags &= ~WVLAN2_UIL_CONNECTED; /* @@ -262,13 +262,13 @@ int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ) urq->hcfCtx = NULL; urq->result = UIL_SUCCESS; } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_disconnect +} /* wvlan_uil_disconnect */ /*============================================================================*/ @@ -293,60 +293,60 @@ int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp) { int result = 0; ltv_t *ltv; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_action" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_action"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { /* Make sure there's an LTV in the request buffer */ ltv = (ltv_t *)urq->data; - if( ltv != NULL ) { + if (ltv != NULL) { /* Switch on the Type field of the LTV contained in the request buffer */ - switch( ltv->typ ) { + switch (ltv->typ) { case UIL_ACT_BLOCK: - DBG_TRACE( DbgInfo, "UIL_ACT_BLOCK\n" ); - result = wvlan_uil_block( urq, lp ); + DBG_TRACE(DbgInfo, "UIL_ACT_BLOCK\n"); + result = wvlan_uil_block(urq, lp); break; case UIL_ACT_UNBLOCK: - DBG_TRACE( DbgInfo, "UIL_ACT_UNBLOCK\n" ); - result = wvlan_uil_unblock( urq, lp ); + DBG_TRACE(DbgInfo, "UIL_ACT_UNBLOCK\n"); + result = wvlan_uil_unblock(urq, lp); break; case UIL_ACT_SCAN: - DBG_TRACE( DbgInfo, "UIL_ACT_SCAN\n" ); - urq->result = hcf_action( &( lp->hcfCtx ), MDD_ACT_SCAN ); + DBG_TRACE(DbgInfo, "UIL_ACT_SCAN\n"); + urq->result = hcf_action(&(lp->hcfCtx), MDD_ACT_SCAN); break; case UIL_ACT_APPLY: - DBG_TRACE( DbgInfo, "UIL_ACT_APPLY\n" ); - urq->result = wl_apply( lp ); + DBG_TRACE(DbgInfo, "UIL_ACT_APPLY\n"); + urq->result = wl_apply(lp); break; case UIL_ACT_RESET: - DBG_TRACE( DbgInfo, "UIL_ACT_RESET\n" ); - urq->result = wl_go( lp ); + DBG_TRACE(DbgInfo, "UIL_ACT_RESET\n"); + urq->result = wl_go(lp); break; default: - DBG_WARNING( DbgInfo, "Unknown action code: 0x%x\n", ltv->typ ); + DBG_WARNING(DbgInfo, "Unknown action code: 0x%x\n", ltv->typ); break; } } else { - DBG_ERROR( DbgInfo, "Bad LTV for this action\n" ); + DBG_ERROR(DbgInfo, "Bad LTV for this action\n"); urq->result = UIL_ERR_LEN; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_action +} /* wvlan_uil_action */ /*============================================================================*/ @@ -373,34 +373,34 @@ int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ) * ******************************************************************************/ -int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_block" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_block"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { - if( capable( CAP_NET_ADMIN )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { + if (capable(CAP_NET_ADMIN)) { lp->flags |= WVLAN2_UIL_BUSY; netif_stop_queue(lp->dev); - WL_WDS_NETIF_STOP_QUEUE( lp ); + WL_WDS_NETIF_STOP_QUEUE(lp); urq->result = UIL_SUCCESS; } else { - DBG_ERROR( DbgInfo, "EPERM\n" ); + DBG_ERROR(DbgInfo, "EPERM\n"); urq->result = UIL_FAILURE; result = -EPERM; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_block +} /* wvlan_uil_block */ /*============================================================================*/ @@ -425,35 +425,35 @@ int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_unblock" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_unblock"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { - if( capable( CAP_NET_ADMIN )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { + if (capable(CAP_NET_ADMIN)) { if (lp->flags & WVLAN2_UIL_BUSY) { lp->flags &= ~WVLAN2_UIL_BUSY; netif_wake_queue(lp->dev); - WL_WDS_NETIF_WAKE_QUEUE( lp ); + WL_WDS_NETIF_WAKE_QUEUE(lp); } } else { - DBG_ERROR( DbgInfo, "EPERM\n" ); + DBG_ERROR(DbgInfo, "EPERM\n"); urq->result = UIL_FAILURE; result = -EPERM; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_unblock +} /* wvlan_uil_unblock */ /*============================================================================*/ @@ -478,47 +478,47 @@ int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp) { int result = 0; DESC_STRCT Descp[1]; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_send_diag_msg" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_send_diag_msg"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { - if( capable( CAP_NET_ADMIN )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { + if (capable(CAP_NET_ADMIN)) { if ((urq->data != NULL) && (urq->len != 0)) { if (lp->hcfCtx.IFB_RscInd != 0) { u_char *data; - // Verify the user buffer + /* Verify the user buffer */ result = verify_area(VERIFY_READ, urq->data, urq->len); if (result != 0) { - DBG_ERROR( DbgInfo, "verify_area failed, result: %d\n", result ); + DBG_ERROR(DbgInfo, "verify_area failed, result: %d\n", result); urq->result = UIL_FAILURE; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } data = kmalloc(urq->len, GFP_KERNEL); if (data != NULL) { - memset( Descp, 0, sizeof( DESC_STRCT )); - memcpy( data, urq->data, urq->len ); + memset(Descp, 0, sizeof(DESC_STRCT)); + memcpy(data, urq->data, urq->len); Descp[0].buf_addr = (wci_bufp)data; Descp[0].BUF_CNT = urq->len; - Descp[0].next_desc_addr = 0; // terminate list + Descp[0].next_desc_addr = 0; /* terminate list */ - hcf_send_msg( &(lp->hcfCtx), &Descp[0], HCF_PORT_0 ); - kfree( data ); + hcf_send_msg(&(lp->hcfCtx), &Descp[0], HCF_PORT_0); + kfree(data); } else { - DBG_ERROR( DbgInfo, "ENOMEM\n" ); + DBG_ERROR(DbgInfo, "ENOMEM\n"); urq->result = UIL_FAILURE; result = -ENOMEM; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } @@ -530,18 +530,18 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ) urq->result = UIL_FAILURE; } } else { - DBG_ERROR( DbgInfo, "EPERM\n" ); + DBG_ERROR(DbgInfo, "EPERM\n"); urq->result = UIL_FAILURE; result = -EPERM; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_send_diag_msg +} /* wvlan_uil_send_diag_msg */ /*============================================================================*/ @@ -564,7 +564,7 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp) { int result = 0; ltv_t *pLtv; @@ -575,94 +575,94 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) hcf_16 hcfPort = HCF_PORT_0; #endif /* USE_WDS */ /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_put_info" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_put_info"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { - if( capable( CAP_NET_ADMIN )) { - if(( urq->data != NULL ) && ( urq->len != 0 )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { + if (capable(CAP_NET_ADMIN)) { + if ((urq->data != NULL) && (urq->len != 0)) { /* Make sure that we have at least a command and length to send. */ - if( urq->len < ( sizeof( hcf_16 ) * 2 )) { - urq->len = sizeof( lp->ltvRecord ); + if (urq->len < (sizeof(hcf_16) * 2)) { + urq->len = sizeof(lp->ltvRecord); urq->result = UIL_ERR_LEN; - DBG_ERROR( DbgInfo, "No Length/Type in LTV!!!\n" ); - DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" ); - DBG_LEAVE( DbgInfo ); + DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n"); + DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n"); + DBG_LEAVE(DbgInfo); return result; } /* Verify the user buffer */ - result = verify_area( VERIFY_READ, urq->data, urq->len ); - if( result != 0 ) { + result = verify_area(VERIFY_READ, urq->data, urq->len); + if (result != 0) { urq->result = UIL_FAILURE; - DBG_ERROR( DbgInfo, "verify_area(), VERIFY_READ FAILED\n" ); - DBG_LEAVE( DbgInfo ); + DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n"); + DBG_LEAVE(DbgInfo); return result; } /* Get only the command and length information. */ - copy_from_user( &( lp->ltvRecord ), urq->data, sizeof( hcf_16 ) * 2 ); + copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2); /* Make sure the incoming LTV record length is within the bounds of the IOCTL length */ - if((( lp->ltvRecord.len + 1 ) * sizeof( hcf_16 )) > urq->len ) { - urq->len = sizeof( lp->ltvRecord ); + if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) { + urq->len = sizeof(lp->ltvRecord); urq->result = UIL_ERR_LEN; - DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" ); - DBG_LEAVE( DbgInfo ); + DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n"); + DBG_LEAVE(DbgInfo); return result; } /* If the requested length is greater than the size of our local LTV record, try to allocate it from the kernel stack. Otherwise, we just use our local LTV record. */ - if( urq->len > sizeof( lp->ltvRecord )) { + if (urq->len > sizeof(lp->ltvRecord)) { pLtv = kmalloc(urq->len, GFP_KERNEL); if (pLtv != NULL) { ltvAllocated = TRUE; } else { - DBG_ERROR( DbgInfo, "Alloc FAILED\n" ); - urq->len = sizeof( lp->ltvRecord ); + DBG_ERROR(DbgInfo, "Alloc FAILED\n"); + urq->len = sizeof(lp->ltvRecord); urq->result = UIL_ERR_LEN; result = -ENOMEM; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } } else { - pLtv = &( lp->ltvRecord ); + pLtv = &(lp->ltvRecord); } /* Copy the data from the user's buffer into the local LTV record data area. */ - copy_from_user( pLtv, urq->data, urq->len ); + copy_from_user(pLtv, urq->data, urq->len); /* We need to snoop the commands to see if there is anything we need to store for the purposes of a reset or start/stop sequence. Perform endian translation as needed */ - switch( pLtv->typ ) { + switch (pLtv->typ) { case CFG_CNF_PORT_TYPE: lp->PortType = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_OWN_MAC_ADDR: /* TODO: determine if we are going to store anything based on this */ break; case CFG_CNF_OWN_CHANNEL: lp->Channel = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; /* CFG_CNF_OWN_SSID currently same as CNF_DESIRED_SSID. Do we need separate storage for this? */ - //case CFG_CNF_OWN_SSID: + /* case CFG_CNF_OWN_SSID: */ case CFG_CNF_OWN_ATIM_WINDOW: lp->atimWindow = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_SYSTEM_SCALE: lp->DistanceBetweenAPs = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); case CFG_CNF_MAX_DATA_LEN: /* TODO: determine if we are going to store anything based @@ -670,163 +670,163 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) break; case CFG_CNF_PM_ENABLED: lp->PMEnabled = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_MCAST_RX: lp->MulticastReceive = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_MAX_SLEEP_DURATION: lp->MaxSleepDuration = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_HOLDOVER_DURATION: lp->holdoverDuration = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_OWN_NAME: - memset( lp->StationName, 0, sizeof( lp->StationName )); - memcpy( (void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + memset(lp->StationName, 0, sizeof(lp->StationName)); + memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_LOAD_BALANCING: lp->loadBalancing = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_MEDIUM_DISTRIBUTION: lp->mediumDistribution = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #ifdef WARP case CFG_CNF_TX_POW_LVL: lp->txPowLevel = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; - //case CFG_CNF_SHORT_RETRY_LIMIT: // Short Retry Limit - //case 0xFC33: // Long Retry Limit - case CFG_SUPPORTED_RATE_SET_CNTL: // Supported Rate Set Control + /* case CFG_CNF_SHORT_RETRY_LIMIT: */ /* Short Retry Limit */ + /* case 0xFC33: */ /* Long Retry Limit */ + case CFG_SUPPORTED_RATE_SET_CNTL: /* Supported Rate Set Control */ lp->srsc[0] = pLtv->u.u16[0]; lp->srsc[1] = pLtv->u.u16[1]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); - pLtv->u.u16[1] = CNV_INT_TO_LITTLE( pLtv->u.u16[1] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); + pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]); break; - case CFG_BASIC_RATE_SET_CNTL: // Basic Rate Set Control + case CFG_BASIC_RATE_SET_CNTL: /* Basic Rate Set Control */ lp->brsc[0] = pLtv->u.u16[0]; lp->brsc[1] = pLtv->u.u16[1]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); - pLtv->u.u16[1] = CNV_INT_TO_LITTLE( pLtv->u.u16[1] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); + pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]); break; case CFG_CNF_CONNECTION_CNTL: lp->connectionControl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; - //case CFG_PROBE_DATA_RATE: -#endif // HERMES25 + /* case CFG_PROBE_DATA_RATE: */ +#endif /* HERMES25 */ -#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP - //;?should we restore this to allow smaller memory footprint +#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */ + /* ;?should we restore this to allow smaller memory footprint */ case CFG_CNF_OWN_DTIM_PERIOD: lp->DTIMPeriod = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #ifdef WARP - case CFG_CNF_OWN_BEACON_INTERVAL: // Own Beacon Interval + case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */ lp->ownBeaconInterval = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; -#endif // WARP - case CFG_COEXISTENSE_BEHAVIOUR: // Coexistence behavior +#endif /* WARP */ + case CFG_COEXISTENSE_BEHAVIOUR: /* Coexistence behavior */ lp->coexistence = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #ifdef USE_WDS case CFG_CNF_WDS_ADDR1: - memcpy( &lp->wds_port[0].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[0].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_1; break; case CFG_CNF_WDS_ADDR2: - memcpy( &lp->wds_port[1].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[1].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_2; break; case CFG_CNF_WDS_ADDR3: - memcpy( &lp->wds_port[2].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[2].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_3; break; case CFG_CNF_WDS_ADDR4: - memcpy( &lp->wds_port[3].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[3].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_4; break; case CFG_CNF_WDS_ADDR5: - memcpy( &lp->wds_port[4].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[4].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_5; break; case CFG_CNF_WDS_ADDR6: - memcpy( &lp->wds_port[5].wdsAddress, &pLtv->u.u8[0], ETH_ALEN ); + memcpy(&lp->wds_port[5].wdsAddress, &pLtv->u.u8[0], ETH_ALEN); hcfPort = HCF_PORT_6; break; #endif /* USE_WDS */ case CFG_CNF_MCAST_PM_BUF: lp->multicastPMBuffering = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_REJECT_ANY: lp->RejectAny = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #endif case CFG_CNF_ENCRYPTION: lp->EnableEncryption = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_CNF_AUTHENTICATION: lp->authentication = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; -#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP - //;?should we restore this to allow smaller memory footprint +#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */ + /* ;?should we restore this to allow smaller memory footprint */ - //case CFG_CNF_EXCL_UNENCRYPTED: - //lp->ExcludeUnencrypted = pLtv->u.u16[0]; - //pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); - //break; + /* case CFG_CNF_EXCL_UNENCRYPTED: + lp->ExcludeUnencrypted = pLtv->u.u16[0]; + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); + break; */ case CFG_CNF_MCAST_RATE: /* TODO: determine if we are going to store anything based on this */ break; case CFG_CNF_INTRA_BSS_RELAY: lp->intraBSSRelay = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #endif case CFG_CNF_MICRO_WAVE: /* TODO: determine if we are going to store anything based on this */ break; - //case CFG_CNF_LOAD_BALANCING: + /*case CFG_CNF_LOAD_BALANCING:*/ /* TODO: determine if we are going to store anything based on this */ - //break; - //case CFG_CNF_MEDIUM_DISTRIBUTION: + /* break; */ + /* case CFG_CNF_MEDIUM_DISTRIBUTION: */ /* TODO: determine if we are going to store anything based on this */ - //break; - //case CFG_CNF_RX_ALL_GROUP_ADDRESS: - // TODO: determine if we are going to store anything based on this - //break; - //case CFG_CNF_COUNTRY_INFO: + /* break; */ + /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */ + /* TODO: determine if we are going to store anything based on this */ + /* break; */ + /* case CFG_CNF_COUNTRY_INFO: */ /* TODO: determine if we are going to store anything based on this */ - //break; + /* break; */ case CFG_CNF_OWN_SSID: - //case CNF_DESIRED_SSID: + /* case CNF_DESIRED_SSID: */ case CFG_DESIRED_SSID: - memset( lp->NetworkName, 0, sizeof( lp->NetworkName )); - memcpy( (void *)lp->NetworkName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0] ); - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + memset(lp->NetworkName, 0, sizeof(lp->NetworkName)); + memcpy((void *)lp->NetworkName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); /* take care of the special network name "ANY" case */ - if(( strlen( &pLtv->u.u8[2] ) == 0 ) || - ( strcmp( &pLtv->u.u8[2], "ANY" ) == 0 ) || - ( strcmp( &pLtv->u.u8[2], "any" ) == 0 )) { + if ((strlen(&pLtv->u.u8[2]) == 0) || + (strcmp(&pLtv->u.u8[2], "ANY") == 0) || + (strcmp(&pLtv->u.u8[2], "any") == 0)) { /* set the SSID_STRCT llen field (u16[0]) to zero, and the effectually null the string u8[2] */ pLtv->u.u16[0] = 0; @@ -838,93 +838,93 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) break; case CFG_CREATE_IBSS: lp->CreateIBSS = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_RTS_THRH: lp->RTSThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_TX_RATE_CNTL: lp->TxRateControl[0] = pLtv->u.u16[0]; lp->TxRateControl[1] = pLtv->u.u16[1]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); - pLtv->u.u16[1] = CNV_INT_TO_LITTLE( pLtv->u.u16[1] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); + pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]); break; case CFG_PROMISCUOUS_MODE: /* TODO: determine if we are going to store anything based on this */ break; - //case CFG_WAKE_ON_LAN: + /* case CFG_WAKE_ON_LAN: */ /* TODO: determine if we are going to store anything based on this */ - //break; -#if 1 //;? #if (HCF_TYPE) & HCF_TYPE_AP - //;?should we restore this to allow smaller memory footprint + /* break; */ +#if 1 /* ;? #if (HCF_TYPE) & HCF_TYPE_AP */ + /* ;?should we restore this to allow smaller memory footprint */ case CFG_RTS_THRH0: lp->RTSThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_TX_RATE_CNTL0: -//;?no idea what this should be, get going so comment it out lp->TxRateControl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); +/*;?no idea what this should be, get going so comment it out lp->TxRateControl = pLtv->u.u16[0];*/ + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; #ifdef USE_WDS case CFG_RTS_THRH1: lp->wds_port[0].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_1; break; case CFG_RTS_THRH2: lp->wds_port[1].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_2; break; case CFG_RTS_THRH3: lp->wds_port[2].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_3; break; case CFG_RTS_THRH4: lp->wds_port[3].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_4; break; case CFG_RTS_THRH5: lp->wds_port[4].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_5; break; case CFG_RTS_THRH6: lp->wds_port[5].rtsThreshold = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_6; break; case CFG_TX_RATE_CNTL1: lp->wds_port[0].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_1; break; case CFG_TX_RATE_CNTL2: lp->wds_port[1].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_2; break; case CFG_TX_RATE_CNTL3: lp->wds_port[2].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_3; break; case CFG_TX_RATE_CNTL4: lp->wds_port[3].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_4; break; case CFG_TX_RATE_CNTL5: lp->wds_port[4].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_5; break; case CFG_TX_RATE_CNTL6: lp->wds_port[5].txRateCntl = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); hcfPort = HCF_PORT_6; break; #endif /* USE_WDS */ @@ -934,18 +934,18 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) { CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)pLtv; - pKeys->key[0].len = CNV_INT_TO_LITTLE( pKeys->key[0].len ); - pKeys->key[1].len = CNV_INT_TO_LITTLE( pKeys->key[1].len ); - pKeys->key[2].len = CNV_INT_TO_LITTLE( pKeys->key[2].len ); - pKeys->key[3].len = CNV_INT_TO_LITTLE( pKeys->key[3].len ); + pKeys->key[0].len = CNV_INT_TO_LITTLE(pKeys->key[0].len); + pKeys->key[1].len = CNV_INT_TO_LITTLE(pKeys->key[1].len); + pKeys->key[2].len = CNV_INT_TO_LITTLE(pKeys->key[2].len); + pKeys->key[3].len = CNV_INT_TO_LITTLE(pKeys->key[3].len); - memcpy( (void *)&(lp->DefaultKeys), (void *)pKeys, - sizeof( CFG_DEFAULT_KEYS_STRCT )); + memcpy((void *)&(lp->DefaultKeys), (void *)pKeys, + sizeof(CFG_DEFAULT_KEYS_STRCT)); } break; case CFG_TX_KEY_ID: lp->TransmitKeyID = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_SCAN_SSID: /* TODO: determine if we are going to store anything based on this */ @@ -956,7 +956,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) /* these RIDS are Info RIDs, and should they be allowed for puts??? */ case CFG_MAX_LOAD_TIME: case CFG_DL_BUF: - //case CFG_HSI_SUP_RANGE: + /* case CFG_HSI_SUP_RANGE: */ case CFG_NIC_SERIAL_NUMBER: case CFG_NIC_IDENTITY: case CFG_NIC_MFI_SUP_RANGE: @@ -982,35 +982,35 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) case CFG_CF_POLLABLE: case CFG_AUTHENTICATION_ALGORITHMS: case CFG_PRIVACY_OPT_IMPLEMENTED: - //case CFG_CURRENT_REMOTE_RATES: - //case CFG_CURRENT_USED_RATES: - //case CFG_CURRENT_SYSTEM_SCALE: - //case CFG_CURRENT_TX_RATE1: - //case CFG_CURRENT_TX_RATE2: - //case CFG_CURRENT_TX_RATE3: - //case CFG_CURRENT_TX_RATE4: - //case CFG_CURRENT_TX_RATE5: - //case CFG_CURRENT_TX_RATE6: + /* case CFG_CURRENT_REMOTE_RATES: */ + /* case CFG_CURRENT_USED_RATES: */ + /* case CFG_CURRENT_SYSTEM_SCALE: */ + /* case CFG_CURRENT_TX_RATE1: */ + /* case CFG_CURRENT_TX_RATE2: */ + /* case CFG_CURRENT_TX_RATE3: */ + /* case CFG_CURRENT_TX_RATE4: */ + /* case CFG_CURRENT_TX_RATE5: */ + /* case CFG_CURRENT_TX_RATE6: */ case CFG_NIC_MAC_ADDR: case CFG_PCF_INFO: - //case CFG_CURRENT_COUNTRY_INFO: + /* case CFG_CURRENT_COUNTRY_INFO: */ case CFG_PHY_TYPE: case CFG_CUR_CHANNEL: - //case CFG_CURRENT_POWER_STATE: - //case CFG_CCAMODE: + /* case CFG_CURRENT_POWER_STATE: */ + /* case CFG_CCAMODE: */ case CFG_SUPPORTED_DATA_RATES: break; case CFG_AP_MODE: -//;? lp->DownloadFirmware = ( pLtv->u.u16[0] ) + 1; - DBG_ERROR( DbgInfo, "set CFG_AP_MODE no longer supported\n" ); +/*;? lp->DownloadFirmware = (pLtv->u.u16[0]) + 1; */ + DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported\n"); break; case CFG_ENCRYPT_STRING: /* TODO: ENDIAN TRANSLATION HERE??? */ - memset( lp->szEncryption, 0, sizeof( lp->szEncryption )); - memcpy( (void *)lp->szEncryption, (void *)&pLtv->u.u8[0], - ( pLtv->len * sizeof( hcf_16 )) ); - wl_wep_decode( CRYPT_CODE, &sEncryption, - lp->szEncryption ); + memset(lp->szEncryption, 0, sizeof(lp->szEncryption)); + memcpy((void *)lp->szEncryption, (void *)&pLtv->u.u8[0], + (pLtv->len * sizeof(hcf_16))); + wl_wep_decode(CRYPT_CODE, &sEncryption, + lp->szEncryption); /* the Linux driver likes to use 1-4 for the key IDs, and then convert to 0-3 when sending to the card. The Windows code @@ -1022,34 +1022,34 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) lp->TransmitKeyID = sEncryption.wTxKeyID + 1; lp->EnableEncryption = sEncryption.wEnabled; - memcpy( &lp->DefaultKeys, &sEncryption.EncStr, - sizeof( CFG_DEFAULT_KEYS_STRCT )); + memcpy(&lp->DefaultKeys, &sEncryption.EncStr, + sizeof(CFG_DEFAULT_KEYS_STRCT)); break; /*case CFG_COUNTRY_STRING: - memset( lp->countryString, 0, sizeof( lp->countryString )); - memcpy( (void *)lp->countryString, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); + memset(lp->countryString, 0, sizeof(lp->countryString)); + memcpy((void *)lp->countryString, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); break; */ case CFG_DRIVER_ENABLE: lp->driverEnable = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_WOLAS_ENABLE: lp->wolasEnable = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_SET_WPA_AUTH_KEY_MGMT_SUITE: lp->AuthKeyMgmtSuite = pLtv->u.u16[0]; - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_DISASSOCIATE_ADDR: - pLtv->u.u16[ETH_ALEN / 2] = CNV_INT_TO_LITTLE( pLtv->u.u16[ETH_ALEN / 2] ); + pLtv->u.u16[ETH_ALEN / 2] = CNV_INT_TO_LITTLE(pLtv->u.u16[ETH_ALEN / 2]); break; case CFG_ADD_TKIP_DEFAULT_KEY: case CFG_REMOVE_TKIP_DEFAULT_KEY: /* Endian convert the Tx Key Information */ - pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] ); + pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); break; case CFG_ADD_TKIP_MAPPED_KEY: break; @@ -1066,7 +1066,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) being sent to the card, as they require a call to UIL_ACT_APPLY to take effect. Dynamic Entities will be sent immediately */ - switch( pLtv->typ ) { + switch (pLtv->typ) { case CFG_CNF_PORT_TYPE: case CFG_CNF_OWN_MAC_ADDR: case CFG_CNF_OWN_CHANNEL: @@ -1084,14 +1084,14 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) #ifdef WARP case CFG_CNF_TX_POW_LVL: case CFG_CNF_CONNECTION_CNTL: - //case CFG_PROBE_DATA_RATE: -#endif // HERMES25 -#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP - //;?should we restore this to allow smaller memory footprint + /*case CFG_PROBE_DATA_RATE: */ +#endif /* HERMES25 */ +#if 1 /*;? (HCF_TYPE) & HCF_TYPE_AP */ + /*;?should we restore this to allow smaller memory footprint */ case CFG_CNF_OWN_DTIM_PERIOD: #ifdef WARP - case CFG_CNF_OWN_BEACON_INTERVAL: // Own Beacon Interval -#endif // WARP + case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */ +#endif /* WARP */ #ifdef USE_WDS case CFG_CNF_WDS_ADDR1: case CFG_CNF_WDS_ADDR2: @@ -1106,8 +1106,8 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) case CFG_CNF_ENCRYPTION: case CFG_CNF_AUTHENTICATION: -#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP - //;?should we restore this to allow smaller memory footprint +#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */ + /* ;?should we restore this to allow smaller memory footprint */ case CFG_CNF_EXCL_UNENCRYPTED: case CFG_CNF_MCAST_RATE: @@ -1115,68 +1115,54 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) #endif case CFG_CNF_MICRO_WAVE: - //case CFG_CNF_LOAD_BALANCING: - //case CFG_CNF_MEDIUM_DISTRIBUTION: - //case CFG_CNF_RX_ALL_GROUP_ADDRESS: - //case CFG_CNF_COUNTRY_INFO: - //case CFG_COUNTRY_STRING: + /* case CFG_CNF_LOAD_BALANCING: */ + /* case CFG_CNF_MEDIUM_DISTRIBUTION: */ + /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */ + /* case CFG_CNF_COUNTRY_INFO: */ + /* case CFG_COUNTRY_STRING: */ case CFG_AP_MODE: case CFG_ENCRYPT_STRING: - //case CFG_DRIVER_ENABLE: + /* case CFG_DRIVER_ENABLE: */ case CFG_WOLAS_ENABLE: case CFG_MB_INFO: case CFG_IFB: break; /* Deal with this dynamic MSF RID, as it's required for WPA */ case CFG_DRIVER_ENABLE: - if( lp->driverEnable ) { - //hcf_cntl_port( &( lp->hcfCtx ), - // HCF_PORT_ENABLE | HCF_PORT_0 ); - // //hcf_cntl( &( lp->hcfCtx ), - // // HCF_PORT_ENABLE | HCF_PORT_0 ); - //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_ENABLE ); - // //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_CONNECT ); - - hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_ENABLE | HCF_PORT_0 ); - hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_CONNECT ); + if (lp->driverEnable) { + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_ENABLE | HCF_PORT_0); + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_CONNECT); } else { - //hcf_cntl_port( &( lp->hcfCtx ), - // HCF_PORT_DISABLE | HCF_PORT_0 ); - // //hcf_cntl( &( lp->hcfCtx ), - // // HCF_PORT_DISABLE | HCF_PORT_0 ); - //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISABLE ); - // //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISCONNECT ); - - hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISABLE | HCF_PORT_0 ); - hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISCONNECT ); + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISABLE | HCF_PORT_0); + hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISCONNECT); } break; default: - wl_act_int_off( lp ); + wl_act_int_off(lp); urq->result = hcf_put_info(&(lp->hcfCtx), (LTVP) pLtv); - wl_act_int_on( lp ); + wl_act_int_on(lp); break; } - if( ltvAllocated ) { - kfree( pLtv ); - } + if (ltvAllocated) + kfree(pLtv); } else { urq->result = UIL_FAILURE; } } else { - DBG_ERROR( DbgInfo, "EPERM\n" ); + DBG_ERROR(DbgInfo, "EPERM\n"); urq->result = UIL_FAILURE; result = -EPERM; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_put_info +} /* wvlan_uil_put_info */ + /*============================================================================*/ /******************************************************************************* @@ -1199,97 +1185,97 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) +int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp) { int result = 0; int i; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_uil_get_info" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_uil_get_info"); + DBG_ENTER(DbgInfo); - if( urq->hcfCtx == &( lp->hcfCtx )) { - if(( urq->data != NULL ) && ( urq->len != 0 )) { + if (urq->hcfCtx == &(lp->hcfCtx)) { + if ((urq->data != NULL) && (urq->len != 0)) { ltv_t *pLtv; bool_t ltvAllocated = FALSE; /* Make sure that we have at least a command and length */ - if( urq->len < ( sizeof( hcf_16 ) * 2 )) { - urq->len = sizeof( lp->ltvRecord ); - DBG_ERROR( DbgInfo, "No Length/Type in LTV!!!\n" ); - DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" ); + if (urq->len < (sizeof(hcf_16) * 2)) { + urq->len = sizeof(lp->ltvRecord); + DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n"); + DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n"); urq->result = UIL_ERR_LEN; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Verify the user's LTV record header. */ - result = verify_area( VERIFY_READ, urq->data, sizeof( hcf_16 ) * 2 ); - if( result != 0 ) { - DBG_ERROR( DbgInfo, "verify_area(), VERIFY_READ FAILED\n" ); + result = verify_area(VERIFY_READ, urq->data, sizeof(hcf_16) * 2); + if (result != 0) { + DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n"); urq->result = UIL_FAILURE; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Get only the command and length information. */ - result = copy_from_user( &( lp->ltvRecord ), urq->data, sizeof( hcf_16 ) * 2 ); + result = copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2); /* Make sure the incoming LTV record length is within the bounds of the IOCTL length. */ - if((( lp->ltvRecord.len + 1 ) * sizeof( hcf_16 )) > urq->len ) { - DBG_ERROR( DbgInfo, "Incoming LTV too big\n" ); - urq->len = sizeof( lp->ltvRecord ); + if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) { + DBG_ERROR(DbgInfo, "Incoming LTV too big\n"); + urq->len = sizeof(lp->ltvRecord); urq->result = UIL_ERR_LEN; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Determine if hcf_get_info() is needed or not */ - switch ( lp->ltvRecord.typ ) { + switch (lp->ltvRecord.typ) { case CFG_NIC_IDENTITY: - memcpy( &lp->ltvRecord.u.u8[0], &lp->NICIdentity, sizeof( lp->NICIdentity )); + memcpy(&lp->ltvRecord.u.u8[0], &lp->NICIdentity, sizeof(lp->NICIdentity)); break; case CFG_PRI_IDENTITY: - memcpy( &lp->ltvRecord.u.u8[0], &lp->PrimaryIdentity, sizeof( lp->PrimaryIdentity )); + memcpy(&lp->ltvRecord.u.u8[0], &lp->PrimaryIdentity, sizeof(lp->PrimaryIdentity)); break; case CFG_AP_MODE: - DBG_ERROR( DbgInfo, "set CFG_AP_MODE no longer supported, so is get useful ????\n" ); + DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported, so is get useful ????\n"); lp->ltvRecord.u.u16[0] = - CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_AP; + CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_AP; break; - //case CFG_DRV_INFO: + /* case CFG_DRV_INFO: */ case CFG_ENCRYPT_STRING: case CFG_COUNTRY_STRING: case CFG_DRIVER_ENABLE: case CFG_WOLAS_ENABLE: - // TODO: determine if we're going to support these + /* TODO: determine if we're going to support these */ urq->result = UIL_FAILURE; break; case CFG_DRV_INFO: - DBG_TRACE( DbgInfo, "Intercept CFG_DRV_INFO\n" ); - result = cfg_driver_info( urq, lp ); + DBG_TRACE(DbgInfo, "Intercept CFG_DRV_INFO\n"); + result = cfg_driver_info(urq, lp); break; case CFG_DRV_IDENTITY: - DBG_TRACE( DbgInfo, "Intercept CFG_DRV_IDENTITY\n" ); - result = cfg_driver_identity( urq, lp ); + DBG_TRACE(DbgInfo, "Intercept CFG_DRV_IDENTITY\n"); + result = cfg_driver_identity(urq, lp); break; case CFG_IFB: /* IFB can be a security hole */ - if( !capable( CAP_NET_ADMIN )) { + if (!capable(CAP_NET_ADMIN)) { result = -EPERM; break; } /* Else fall through to the default */ - case CFG_FW_IDENTITY: // For Hermes-1, this is cached + case CFG_FW_IDENTITY: /* For Hermes-1, this is cached */ default: /* Verify the user buffer */ - result = verify_area( VERIFY_WRITE, urq->data, urq->len ); - if( result != 0 ) { - DBG_ERROR( DbgInfo, "verify_area(), VERIFY_WRITE FAILED\n" ); + result = verify_area(VERIFY_WRITE, urq->data, urq->len); + if (result != 0) { + DBG_ERROR(DbgInfo, "verify_area(), VERIFY_WRITE FAILED\n"); urq->result = UIL_FAILURE; break; } @@ -1297,43 +1283,43 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) /* If the requested length is greater than the size of our local LTV record, try to allocate it from the kernel stack. Otherwise, we just use our local LTV record. */ - if( urq->len > sizeof( lp->ltvRecord )) { + if (urq->len > sizeof(lp->ltvRecord)) { pLtv = kmalloc(urq->len, GFP_KERNEL); if (pLtv != NULL) { ltvAllocated = TRUE; /* Copy the command/length information into the new buffer. */ - memcpy( pLtv, &( lp->ltvRecord ), sizeof( hcf_16 ) * 2 ); + memcpy(pLtv, &(lp->ltvRecord), sizeof(hcf_16) * 2); } else { - urq->len = sizeof( lp->ltvRecord ); + urq->len = sizeof(lp->ltvRecord); urq->result = UIL_ERR_LEN; - DBG_ERROR( DbgInfo, "kmalloc FAILED\n" ); - DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" ); + DBG_ERROR(DbgInfo, "kmalloc FAILED\n"); + DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n"); result = -ENOMEM; break; } } else { - pLtv = &( lp->ltvRecord ); + pLtv = &(lp->ltvRecord); } - wl_act_int_off( lp ); - urq->result = hcf_get_info( &( lp->hcfCtx ), (LTVP) pLtv ); - wl_act_int_on( lp ); + wl_act_int_off(lp); + urq->result = hcf_get_info(&(lp->hcfCtx), (LTVP) pLtv); + wl_act_int_on(lp); - // Copy the LTV into the user's buffer. - //copy_to_user( urq->data, pLtv, urq->len ); + /* Copy the LTV into the user's buffer. */ + /*copy_to_user(urq->data, pLtv, urq->len); */ - //if( ltvAllocated ) - //{ - // kfree( pLtv ); - //} + /*if(ltvAllocated) + { + kfree(pLtv); + }*/ - //urq->result = UIL_SUCCESS; + /* urq->result = UIL_SUCCESS; */ break; } /* Handle endian conversion of special fields */ - switch( lp->ltvRecord.typ ) { + switch (lp->ltvRecord.typ) { /* simple int gets just need the first hcf_16 byte flipped */ case CFG_CNF_PORT_TYPE: case CFG_CNF_OWN_CHANNEL: @@ -1357,14 +1343,14 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) #ifdef WARP case CFG_CNF_TX_POW_LVL: case CFG_CNF_CONNECTION_CNTL: - case CFG_CNF_OWN_BEACON_INTERVAL: // Own Beacon Interval - case CFG_COEXISTENSE_BEHAVIOUR: // Coexistence Behavior - //case CFG_CNF_RX_ALL_GROUP_ADDRESS: -#endif // HERMES25 + case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */ + case CFG_COEXISTENSE_BEHAVIOUR: /* Coexistence Behavior */ + /*case CFG_CNF_RX_ALL_GROUP_ADDRESS: */ +#endif /* HERMES25 */ case CFG_CREATE_IBSS: case CFG_RTS_THRH: case CFG_PROMISCUOUS_MODE: - //case CFG_WAKE_ON_LAN: + /*case CFG_WAKE_ON_LAN: */ case CFG_RTS_THRH0: case CFG_RTS_THRH1: case CFG_RTS_THRH2: @@ -1393,29 +1379,29 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) case CFG_MAX_RX_LIFETIME: case CFG_CF_POLLABLE: case CFG_PRIVACY_OPT_IMPLEMENTED: - //case CFG_CURRENT_REMOTE_RATES: - //case CFG_CURRENT_USED_RATES: - //case CFG_CURRENT_SYSTEM_SCALE: - //case CFG_CURRENT_TX_RATE1: - //case CFG_CURRENT_TX_RATE2: - //case CFG_CURRENT_TX_RATE3: - //case CFG_CURRENT_TX_RATE4: - //case CFG_CURRENT_TX_RATE5: - //case CFG_CURRENT_TX_RATE6: + /* case CFG_CURRENT_REMOTE_RATES: */ + /* case CFG_CURRENT_USED_RATES: */ + /* case CFG_CURRENT_SYSTEM_SCALE: */ + /* case CFG_CURRENT_TX_RATE1: */ + /* case CFG_CURRENT_TX_RATE2: */ + /* case CFG_CURRENT_TX_RATE3: */ + /* case CFG_CURRENT_TX_RATE4: */ + /* case CFG_CURRENT_TX_RATE5: */ + /* case CFG_CURRENT_TX_RATE6: */ case CFG_PHY_TYPE: case CFG_CUR_CHANNEL: - //case CFG_CURRENT_POWER_STATE: - //case CFG_CCAMODE: - // lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - // break; + /* case CFG_CURRENT_POWER_STATE: */ + /* case CFG_CCAMODE: */ + /* lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); */ + /* break; */ /* name string gets just need the first hcf_16 byte flipped (length of string) */ case CFG_CNF_OWN_SSID: case CFG_CNF_OWN_NAME: - //case CNF_DESIRED_SSID: + /* case CNF_DESIRED_SSID: */ case CFG_DESIRED_SSID: case CFG_SCAN_SSID: case CFG_CUR_SSID: - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); break; /* non-length counted strings need no byte flipping */ case CFG_CNF_OWN_MAC_ADDR: @@ -1432,14 +1418,14 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) case CFG_NIC_MAC_ADDR: case CFG_SUPPORTED_DATA_RATES: /* need to ensure we can treat this as a string */ break; - //case CFG_CNF_COUNTRY_INFO: /* special case, see page 75 of 022486, Rev C. */ - //case CFG_CURRENT_COUNTRY_INFO: /* special case, see page 101 of 022486, Rev C. */ + /* case CFG_CNF_COUNTRY_INFO: */ /* special case, see page 75 of 022486, Rev C. */ + /* case CFG_CURRENT_COUNTRY_INFO: */ /* special case, see page 101 of 022486, Rev C. */ /* - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] ); + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); + lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]); - for( i = 4; i < lp->ltvRecord.len; i++ ) { - lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[i] ); + for(i = 4; i < lp->ltvRecord.len; i++) { + lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]); } break; */ @@ -1448,57 +1434,56 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) { CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)&lp->ltvRecord.u.u8[0]; - pKeys[0].len = CNV_INT_TO_LITTLE( pKeys[0].len ); - pKeys[1].len = CNV_INT_TO_LITTLE( pKeys[1].len ); - pKeys[2].len = CNV_INT_TO_LITTLE( pKeys[2].len ); - pKeys[3].len = CNV_INT_TO_LITTLE( pKeys[3].len ); + pKeys[0].len = CNV_INT_TO_LITTLE(pKeys[0].len); + pKeys[1].len = CNV_INT_TO_LITTLE(pKeys[1].len); + pKeys[2].len = CNV_INT_TO_LITTLE(pKeys[2].len); + pKeys[3].len = CNV_INT_TO_LITTLE(pKeys[3].len); } break; case CFG_CNF_MCAST_RATE: case CFG_TX_RATE_CNTL: - case CFG_SUPPORTED_RATE_SET_CNTL: // Supported Rate Set Control - case CFG_BASIC_RATE_SET_CNTL: // Basic Rate Set Control - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] ); + case CFG_SUPPORTED_RATE_SET_CNTL: /* Supported Rate Set Control */ + case CFG_BASIC_RATE_SET_CNTL: /* Basic Rate Set Control */ + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); + lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]); break; case CFG_DL_BUF: case CFG_NIC_IDENTITY: case CFG_COMMS_QUALITY: case CFG_PCF_INFO: - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] ); - lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] ); + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); + lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]); + lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]); break; case CFG_FW_IDENTITY: - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] ); - lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] ); - lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] ); + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); + lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]); + lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]); + lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]); break; - //case CFG_HSI_SUP_RANGE: + /* case CFG_HSI_SUP_RANGE: */ case CFG_NIC_MFI_SUP_RANGE: case CFG_NIC_CFI_SUP_RANGE: case CFG_NIC_PROFILE: case CFG_FW_SUP_RANGE: - lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] ); - lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] ); - lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] ); - lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] ); - lp->ltvRecord.u.u16[4] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[4] ); + lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); + lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]); + lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]); + lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]); + lp->ltvRecord.u.u16[4] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[4]); break; case CFG_MFI_ACT_RANGES_STA: case CFG_CFI_ACT_RANGES_STA: case CFG_CUR_SCALE_THRH: case CFG_AUTHENTICATION_ALGORITHMS: - for( i = 0; i < ( lp->ltvRecord.len - 1 ); i++ ) { - lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[i] ); - } + for (i = 0; i < (lp->ltvRecord.len - 1); i++) + lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]); break; /* done at init time, and endian handled then */ case CFG_PRI_IDENTITY: break; case CFG_MB_INFO: - //wvlanEndianTranslateMailbox( pLtv ); + /* wvlanEndianTranslateMailbox(pLtv); */ break; /* MSF and HCF RIDS */ case CFG_IFB: @@ -1512,25 +1497,23 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) break; } - // Copy the LTV into the user's buffer. - copy_to_user( urq->data, &( lp->ltvRecord ), urq->len ); - - if( ltvAllocated ) { - kfree( &( lp->ltvRecord )); - } + /* Copy the LTV into the user's buffer. */ + copy_to_user(urq->data, &(lp->ltvRecord), urq->len); + if (ltvAllocated) + kfree(&(lp->ltvRecord)); urq->result = UIL_SUCCESS; } else { urq->result = UIL_FAILURE; } } else { - DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" ); + DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n"); urq->result = UIL_ERR_WRONG_IFB; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // wvlan_uil_get_info +} /* wvlan_uil_get_info */ /*============================================================================*/ @@ -1556,41 +1539,41 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ) +int cfg_driver_info(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "cfg_driver_info" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("cfg_driver_info"); + DBG_ENTER(DbgInfo); /* Make sure that user buffer can handle the driver information buffer */ - if( urq->len < sizeof( lp->driverInfo )) { - urq->len = sizeof( lp->driverInfo ); + if (urq->len < sizeof(lp->driverInfo)) { + urq->len = sizeof(lp->driverInfo); urq->result = UIL_ERR_LEN; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Verify the user buffer. */ - result = verify_area( VERIFY_WRITE, urq->data, sizeof( lp->driverInfo )); - if( result != 0 ) { + result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverInfo)); + if (result != 0) { urq->result = UIL_FAILURE; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } lp->driverInfo.card_stat = lp->hcfCtx.IFB_CardStat; - // Copy the driver information into the user's buffer. + /* Copy the driver information into the user's buffer. */ urq->result = UIL_SUCCESS; - copy_to_user( urq->data, &( lp->driverInfo ), sizeof( lp->driverInfo )); + copy_to_user(urq->data, &(lp->driverInfo), sizeof(lp->driverInfo)); - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // cfg_driver_info +} /* cfg_driver_info */ /*============================================================================*/ @@ -1615,39 +1598,39 @@ int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ) * UIL_ERR_xxx value otherwise * ******************************************************************************/ -int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ) +int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp) { int result = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_driver_identity" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_driver_identity"); + DBG_ENTER(DbgInfo); /* Make sure that user buffer can handle the driver identity structure. */ - if( urq->len < sizeof( lp->driverIdentity )) { - urq->len = sizeof( lp->driverIdentity ); + if (urq->len < sizeof(lp->driverIdentity)) { + urq->len = sizeof(lp->driverIdentity); urq->result = UIL_ERR_LEN; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Verify the user buffer. */ - result = verify_area( VERIFY_WRITE, urq->data, sizeof( lp->driverIdentity )); - if( result != 0 ) { + result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverIdentity)); + if (result != 0) { urq->result = UIL_FAILURE; - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; } /* Copy the driver identity into the user's buffer. */ urq->result = UIL_SUCCESS; - copy_to_user( urq->data, &( lp->driverIdentity ), sizeof( lp->driverIdentity )); + copy_to_user(urq->data, &(lp->driverIdentity), sizeof(lp->driverIdentity)); - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return result; -} // cfg_driver_identity +} /* cfg_driver_identity */ /*============================================================================*/ @@ -1684,27 +1667,27 @@ int wvlan_set_netname(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; int ret = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_set_netname" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_set_netname"); + DBG_ENTER(DbgInfo); - wl_lock(lp, &flags); + wl_lock(lp, &flags); - memset( lp->NetworkName, 0, sizeof( lp->NetworkName )); - memcpy( lp->NetworkName, extra, wrqu->data.length); + memset(lp->NetworkName, 0, sizeof(lp->NetworkName)); + memcpy(lp->NetworkName, extra, wrqu->data.length); /* Commit the adapter parameters */ wl_apply(lp); - wl_unlock(lp, &flags); + wl_unlock(lp, &flags); - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ret; -} // wvlan_set_netname +} /* wvlan_set_netname */ /*============================================================================*/ @@ -1734,41 +1717,41 @@ int wvlan_get_netname(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; - int ret = 0; - int status = -1; - wvName_t *pName; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; + int ret = 0; + int status = -1; + wvName_t *pName; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_get_netname" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_get_netname"); + DBG_ENTER(DbgInfo); - wl_lock(lp, &flags); + wl_lock(lp, &flags); - /* Get the current network name */ - lp->ltvRecord.len = 1 + ( sizeof( *pName ) / sizeof( hcf_16 )); - lp->ltvRecord.typ = CFG_CUR_SSID; + /* Get the current network name */ + lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16)); + lp->ltvRecord.typ = CFG_CUR_SSID; - status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); + status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord)); - if( status == HCF_SUCCESS ) { - pName = (wvName_t *)&( lp->ltvRecord.u.u32 ); + if (status == HCF_SUCCESS) { + pName = (wvName_t *)&(lp->ltvRecord.u.u32); memset(extra, '\0', HCF_MAX_NAME_LEN); wrqu->data.length = pName->length; - memcpy(extra, pName->name, pName->length); - } else { - ret = -EFAULT; + memcpy(extra, pName->name, pName->length); + } else { + ret = -EFAULT; } - wl_unlock(lp, &flags); + wl_unlock(lp, &flags); - DBG_LEAVE( DbgInfo ); - return ret; -} // wvlan_get_netname + DBG_LEAVE(DbgInfo); + return ret; +} /* wvlan_get_netname */ /*============================================================================*/ @@ -1798,28 +1781,28 @@ int wvlan_set_station_nickname(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; - int ret = 0; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; + int ret = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_set_station_nickname" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_set_station_nickname"); + DBG_ENTER(DbgInfo); - wl_lock(lp, &flags); + wl_lock(lp, &flags); - memset( lp->StationName, 0, sizeof( lp->StationName )); + memset(lp->StationName, 0, sizeof(lp->StationName)); - memcpy( lp->StationName, extra, wrqu->data.length); + memcpy(lp->StationName, extra, wrqu->data.length); - /* Commit the adapter parameters */ - wl_apply( lp ); - wl_unlock(lp, &flags); + /* Commit the adapter parameters */ + wl_apply(lp); + wl_unlock(lp, &flags); - DBG_LEAVE( DbgInfo ); - return ret; -} // wvlan_set_station_nickname + DBG_LEAVE(DbgInfo); + return ret; +} /* wvlan_set_station_nickname */ /*============================================================================*/ @@ -1849,41 +1832,41 @@ int wvlan_get_station_nickname(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; int ret = 0; int status = -1; wvName_t *pName; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_get_station_nickname" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_get_station_nickname"); + DBG_ENTER(DbgInfo); - wl_lock( lp, &flags ); + wl_lock(lp, &flags); - /* Get the current station name */ - lp->ltvRecord.len = 1 + ( sizeof( *pName ) / sizeof( hcf_16 )); - lp->ltvRecord.typ = CFG_CNF_OWN_NAME; + /* Get the current station name */ + lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16)); + lp->ltvRecord.typ = CFG_CNF_OWN_NAME; - status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); + status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord)); - if( status == HCF_SUCCESS ) { - pName = (wvName_t *)&( lp->ltvRecord.u.u32 ); + if (status == HCF_SUCCESS) { + pName = (wvName_t *)&(lp->ltvRecord.u.u32); memset(extra, '\0', HCF_MAX_NAME_LEN); wrqu->data.length = pName->length; memcpy(extra, pName->name, pName->length); - } else { - ret = -EFAULT; - } + } else { + ret = -EFAULT; + } - wl_unlock(lp, &flags); + wl_unlock(lp, &flags); -//out: - DBG_LEAVE( DbgInfo ); +/* out: */ + DBG_LEAVE(DbgInfo); return ret; -} // wvlan_get_station_nickname +} /* wvlan_get_station_nickname */ /*============================================================================*/ @@ -1913,37 +1896,37 @@ int wvlan_set_porttype(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; - int ret = 0; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; + int ret = 0; hcf_16 portType; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_set_porttype" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_set_porttype"); + DBG_ENTER(DbgInfo); - wl_lock(lp, &flags); + wl_lock(lp, &flags); - /* Validate the new value */ - portType = *((__u32 *)extra); + /* Validate the new value */ + portType = *((__u32 *)extra); - if( !(( portType == 1 ) || ( portType == 3 ))) { - ret = -EINVAL; + if (!((portType == 1) || (portType == 3))) { + ret = -EINVAL; goto out_unlock; - } + } - lp->PortType = portType; + lp->PortType = portType; - /* Commit the adapter parameters */ - wl_apply( lp ); + /* Commit the adapter parameters */ + wl_apply(lp); out_unlock: - wl_unlock(lp, &flags); + wl_unlock(lp, &flags); -//out: - DBG_LEAVE( DbgInfo ); - return ret; +/* out: */ + DBG_LEAVE(DbgInfo); + return ret; } /*============================================================================*/ @@ -1973,43 +1956,43 @@ int wvlan_get_porttype(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct wl_private *lp = wl_priv(dev); - unsigned long flags; - int ret = 0; - int status = -1; - hcf_16 *pPortType; - __u32 *pData = (__u32 *)extra; + struct wl_private *lp = wl_priv(dev); + unsigned long flags; + int ret = 0; + int status = -1; + hcf_16 *pPortType; + __u32 *pData = (__u32 *)extra; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_get_porttype" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_get_porttype"); + DBG_ENTER(DbgInfo); - wl_lock( lp, &flags ); + wl_lock(lp, &flags); - /* Get the current port type */ - lp->ltvRecord.len = 1 + ( sizeof( *pPortType ) / sizeof( hcf_16 )); - lp->ltvRecord.typ = CFG_CNF_PORT_TYPE; + /* Get the current port type */ + lp->ltvRecord.len = 1 + (sizeof(*pPortType) / sizeof(hcf_16)); + lp->ltvRecord.typ = CFG_CNF_PORT_TYPE; - status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); + status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord)); - if( status == HCF_SUCCESS ) { - pPortType = (hcf_16 *)&( lp->ltvRecord.u.u32 ); + if (status == HCF_SUCCESS) { + pPortType = (hcf_16 *)&(lp->ltvRecord.u.u32); - *pData = CNV_LITTLE_TO_INT( *pPortType ); - } else { - ret = -EFAULT; + *pData = CNV_LITTLE_TO_INT(*pPortType); + } else { + ret = -EFAULT; } - wl_unlock(lp, &flags); + wl_unlock(lp, &flags); -//out: - DBG_LEAVE( DbgInfo ); - return ret; -} // wvlan_get_porttype +/* out: */ + DBG_LEAVE(DbgInfo); + return ret; +} /* wvlan_get_porttype */ /*============================================================================*/ -#endif // WIRELESS_EXT +#endif /* WIRELESS_EXT */ @@ -2034,49 +2017,49 @@ int wvlan_get_porttype(struct net_device *dev, * errno value otherwise * ******************************************************************************/ -int wvlan_rts( struct rtsreq *rrq, __u32 io_base ) +int wvlan_rts(struct rtsreq *rrq, __u32 io_base) { int ioctl_ret = 0; /*------------------------------------------------------------------------*/ - DBG_FUNC( "wvlan_rts" ); - DBG_ENTER( DbgInfo ); + DBG_FUNC("wvlan_rts"); + DBG_ENTER(DbgInfo); - DBG_PRINT( "io_base: 0x%08x\n", io_base ); + DBG_PRINT("io_base: 0x%08x\n", io_base); - switch( rrq->typ ) { - case WL_IOCTL_RTS_READ: + switch (rrq->typ) { + case WL_IOCTL_RTS_READ: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_READ\n"); - rrq->data[0] = IN_PORT_WORD( io_base + rrq->reg ); - DBG_TRACE( DbgInfo, " reg 0x%04x ==> 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT( rrq->data[0] ) ); + rrq->data[0] = IN_PORT_WORD(io_base + rrq->reg); + DBG_TRACE(DbgInfo, " reg 0x%04x ==> 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0])); break; - case WL_IOCTL_RTS_WRITE: + case WL_IOCTL_RTS_WRITE: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_WRITE\n"); - OUT_PORT_WORD( io_base + rrq->reg, rrq->data[0] ); - DBG_TRACE( DbgInfo, " reg 0x%04x <== 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT( rrq->data[0] ) ); + OUT_PORT_WORD(io_base + rrq->reg, rrq->data[0]); + DBG_TRACE(DbgInfo, " reg 0x%04x <== 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0])); break; - case WL_IOCTL_RTS_BATCH_READ: + case WL_IOCTL_RTS_BATCH_READ: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_READ\n"); - IN_PORT_STRING_16( io_base + rrq->reg, rrq->data, rrq->len ); - DBG_TRACE( DbgInfo, " reg 0x%04x ==> %d bytes\n", rrq->reg, rrq->len * sizeof (__u16 ) ); + IN_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len); + DBG_TRACE(DbgInfo, " reg 0x%04x ==> %d bytes\n", rrq->reg, rrq->len * sizeof(__u16)); break; - case WL_IOCTL_RTS_BATCH_WRITE: + case WL_IOCTL_RTS_BATCH_WRITE: DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_WRITE\n"); - OUT_PORT_STRING_16( io_base + rrq->reg, rrq->data, rrq->len ); - DBG_TRACE( DbgInfo, " reg 0x%04x <== %d bytes\n", rrq->reg, rrq->len * sizeof (__u16) ); + OUT_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len); + DBG_TRACE(DbgInfo, " reg 0x%04x <== %d bytes\n", rrq->reg, rrq->len * sizeof(__u16)); break; default: - DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- UNSUPPORTED RTS CODE: 0x%X", rrq->typ ); + DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- UNSUPPORTED RTS CODE: 0x%X", rrq->typ); ioctl_ret = -EOPNOTSUPP; break; } - DBG_LEAVE( DbgInfo ); + DBG_LEAVE(DbgInfo); return ioctl_ret; -} // wvlan_rts +} /* wvlan_rts */ /*============================================================================*/ #endif /* USE_RTS */ diff --git a/drivers/staging/wlags49_h2/wl_priv.h b/drivers/staging/wlags49_h2/wl_priv.h index b647bfd..f35e794 100644 --- a/drivers/staging/wlags49_h2/wl_priv.h +++ b/drivers/staging/wlags49_h2/wl_priv.h @@ -70,52 +70,58 @@ #ifdef WIRELESS_EXT -int wvlan_set_netname( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_set_netname(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -int wvlan_get_netname( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_get_netname(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -int wvlan_set_station_nickname( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_set_station_nickname(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -int wvlan_get_station_nickname( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_get_station_nickname(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -int wvlan_set_porttype( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_set_porttype(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -int wvlan_get_porttype( struct net_device *, struct iw_request_info *, union iwreq_data *, char *extra ); +int wvlan_get_porttype(struct net_device *, struct iw_request_info *, + union iwreq_data *, char *extra); -#endif // WIRELESS_EXT +#endif /* WIRELESS_EXT */ #ifdef USE_UIL -int wvlan_uil( struct uilreq *urq, struct wl_private *lp ); +int wvlan_uil(struct uilreq *urq, struct wl_private *lp); -// int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ); -// int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ); +/* int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ); */ +/* int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ); */ -//int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ); -//int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ); +/* int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ); */ +/* int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ); */ -#endif // USE_UIL +#endif /* USE_UIL */ #ifdef USE_RTS -int wvlan_rts( struct rtsreq *rrq, __u32 io_base ); -int wvlan_rts_read( __u16 reg, __u16 *val, __u32 io_base ); -int wvlan_rts_write( __u16 reg, __u16 val, __u32 io_base ); -int wvlan_rts_batch_read( struct rtsreq *rrq, __u32 io_base ); -int wvlan_rts_batch_write( struct rtsreq *rrq, __u32 io_base ); +int wvlan_rts(struct rtsreq *rrq, __u32 io_base); +int wvlan_rts_read(__u16 reg, __u16 *val, __u32 io_base); +int wvlan_rts_write(__u16 reg, __u16 val, __u32 io_base); +int wvlan_rts_batch_read(struct rtsreq *rrq, __u32 io_base); +int wvlan_rts_batch_write(struct rtsreq *rrq, __u32 io_base); -#endif // USE_RTS +#endif /* USE_RTS */ -#endif // __WL_PRIV_H__ +#endif /* __WL_PRIV_H__ */ diff --git a/drivers/staging/wlags49_h2/wl_profile.h b/drivers/staging/wlags49_h2/wl_profile.h index f81df51..d615c83 100644 --- a/drivers/staging/wlags49_h2/wl_profile.h +++ b/drivers/staging/wlags49_h2/wl_profile.h @@ -73,15 +73,15 @@ /******************************************************************************* * function prototypes ******************************************************************************/ -void parse_config( struct net_device *dev ); +void parse_config(struct net_device *dev); -int readline( int filedesc, char *buffer ); +int readline(int filedesc, char *buffer); -void translate_option( char *buffer, struct wl_private *lp ); +void translate_option(char *buffer, struct wl_private *lp); -int parse_mac_address( char *value, u_char *byte_array ); +int parse_mac_address(char *value, u_char *byte_array); -void ParseConfigLine( char *pszLine, char **ppszLVal, char **ppszRVal ); +void ParseConfigLine(char *pszLine, char **ppszLVal, char **ppszRVal); -#endif // __WL_PROFILE_H__ +#endif /* __WL_PROFILE_H__ */ diff --git a/drivers/staging/wlags49_h2/wl_util.h b/drivers/staging/wlags49_h2/wl_util.h index 946b1b6..57bfd7f 100644 --- a/drivers/staging/wlags49_h2/wl_util.h +++ b/drivers/staging/wlags49_h2/wl_util.h @@ -65,32 +65,32 @@ /******************************************************************************* * function prototypes ******************************************************************************/ -int dbm( int value ); +int dbm(int value); -int is_valid_key_string( char *s ); +int is_valid_key_string(char *s); -void key_string2key( char *ks, KEY_STRCT *key ); +void key_string2key(char *ks, KEY_STRCT *key); -void wl_hcf_error( struct net_device *dev, int hcfStatus ); +void wl_hcf_error(struct net_device *dev, int hcfStatus); -void wl_endian_translate_event( ltv_t *pLtv ); +void wl_endian_translate_event(ltv_t *pLtv); -int wl_has_wep( IFBP ifbp ); +int wl_has_wep(IFBP ifbp); -hcf_8 wl_parse_ds_ie( PROBE_RESP *probe_rsp ); -hcf_8 * wl_parse_wpa_ie( PROBE_RESP *probe_rsp, hcf_16 *length ); -hcf_8 * wl_print_wpa_ie( hcf_8 *buffer, int length ); +hcf_8 wl_parse_ds_ie(PROBE_RESP *probe_rsp); +hcf_8 *wl_parse_wpa_ie(PROBE_RESP *probe_rsp, hcf_16 *length); +hcf_8 *wl_print_wpa_ie(hcf_8 *buffer, int length); int wl_get_tallies(struct wl_private *, CFG_HERMES_TALLIES_STRCT *); -int wl_is_a_valid_chan( int channel ); -int wl_is_a_valid_freq( long frequency ); -long wl_get_freq_from_chan( int channel ); -int wl_get_chan_from_freq( long frequency ); +int wl_is_a_valid_chan(int channel); +int wl_is_a_valid_freq(long frequency); +long wl_get_freq_from_chan(int channel); +int wl_get_chan_from_freq(long frequency); -void wl_process_link_status( struct wl_private *lp ); -void wl_process_probe_response( struct wl_private *lp ); -void wl_process_updated_record( struct wl_private *lp ); -void wl_process_assoc_status( struct wl_private *lp ); -void wl_process_security_status( struct wl_private *lp ); +void wl_process_link_status(struct wl_private *lp); +void wl_process_probe_response(struct wl_private *lp); +void wl_process_updated_record(struct wl_private *lp); +void wl_process_assoc_status(struct wl_private *lp); +void wl_process_security_status(struct wl_private *lp); -#endif // __WL_UTIL_H__ +#endif /* __WL_UTIL_H__ */ diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index f553366..c731ff2 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -796,8 +796,6 @@ static int wireless_get_bssid(struct net_device *dev, struct iw_request_info *in wl_act_int_off( lp ); - memset( &ap_addr->sa_data, 0, ETH_ALEN ); - ap_addr->sa_family = ARPHRD_ETHER; /* Assume AP mode here, which means the BSSID is our own MAC address. In diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 5631ad0..3dfa85c 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -59,6 +59,7 @@ #define HFA384x_FIRMWARE_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) #include <linux/if_ether.h> +#include <linux/usb.h> /*--- Mins & Maxs -----------------------------------*/ #define HFA384x_PORTID_MAX ((u16)7) @@ -81,8 +82,8 @@ #define HFA384x_WEPFLAGS_EXCLUDE ((u16)BIT(1)) #define HFA384x_WEPFLAGS_DISABLE_TXCRYPT ((u16)BIT(4)) #define HFA384x_WEPFLAGS_DISABLE_RXCRYPT ((u16)BIT(7)) -#define HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM ((u16)3) -#define HFA384x_PORTSTATUS_DISABLED ((u16)1) +#define HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM ((u16)3) +#define HFA384x_PORTSTATUS_DISABLED ((u16)1) #define HFA384x_RATEBIT_1 ((u16)1) #define HFA384x_RATEBIT_2 ((u16)2) #define HFA384x_RATEBIT_5dot5 ((u16)4) @@ -164,7 +165,7 @@ #define HFA384x_CMDCODE_DOWNLD ((u16)0x22) /*--- Debugging Commands -----------------------------*/ -#define HFA384x_CMDCODE_MONITOR ((u16)(0x38)) +#define HFA384x_CMDCODE_MONITOR ((u16)(0x38)) #define HFA384x_MONITOR_ENABLE ((u16)(0x0b)) #define HFA384x_MONITOR_DISABLE ((u16)(0x0f)) @@ -275,15 +276,15 @@ API ENHANCEMENTS (NOT ALREADY IMPLEMENTED) #define HFA384x_RID_CNFAUTHENTICATION ((u16)0xFC2A) #define HFA384x_RID_CNFROAMINGMODE ((u16)0xFC2D) #define HFA384x_RID_CNFAPBCNint ((u16)0xFC33) -#define HFA384x_RID_CNFDBMADJUST ((u16)0xFC46) -#define HFA384x_RID_CNFWPADATA ((u16)0xFC48) +#define HFA384x_RID_CNFDBMADJUST ((u16)0xFC46) +#define HFA384x_RID_CNFWPADATA ((u16)0xFC48) #define HFA384x_RID_CNFBASICRATES ((u16)0xFCB3) #define HFA384x_RID_CNFSUPPRATES ((u16)0xFCB4) #define HFA384x_RID_CNFPASSIVESCANCTRL ((u16)0xFCBA) -#define HFA384x_RID_TXPOWERMAX ((u16)0xFCBE) +#define HFA384x_RID_TXPOWERMAX ((u16)0xFCBE) #define HFA384x_RID_JOINREQUEST ((u16)0xFCE2) #define HFA384x_RID_AUTHENTICATESTA ((u16)0xFCE3) -#define HFA384x_RID_HOSTSCAN ((u16)0xFCE5) +#define HFA384x_RID_HOSTSCAN ((u16)0xFCE5) #define HFA384x_RID_CNFWEPDEFAULTKEY_LEN ((u16)6) #define HFA384x_RID_CNFWEP128DEFAULTKEY_LEN ((u16)14) @@ -311,7 +312,7 @@ PD Record codes #define HFA384x_PDR_HFA3861_IFRF ((u16)0x0204) #define HFA384x_PDR_HFA3861_CHCALSP ((u16)0x0300) #define HFA384x_PDR_HFA3861_CHCALI ((u16)0x0301) -#define HFA384x_PDR_MAX_TX_POWER ((u16)0x0302) +#define HFA384x_PDR_MAX_TX_POWER ((u16)0x0302) #define HFA384x_PDR_MASTER_CHAN_LIST ((u16)0x0303) #define HFA384x_PDR_3842_NIC_CONFIG ((u16)0x0400) #define HFA384x_PDR_USB_ID ((u16)0x0401) @@ -322,10 +323,10 @@ PD Record codes #define HFA384x_PDR_USB_POWER_TYPE ((u16)0x0407) #define HFA384x_PDR_USB_MAX_POWER ((u16)0x0409) #define HFA384x_PDR_USB_MANUFACTURER ((u16)0x0410) -#define HFA384x_PDR_USB_PRODUCT ((u16)0x0411) -#define HFA384x_PDR_ANT_DIVERSITY ((u16)0x0412) -#define HFA384x_PDR_HFO_DELAY ((u16)0x0413) -#define HFA384x_PDR_SCALE_THRESH ((u16)0x0414) +#define HFA384x_PDR_USB_PRODUCT ((u16)0x0411) +#define HFA384x_PDR_ANT_DIVERSITY ((u16)0x0412) +#define HFA384x_PDR_HFO_DELAY ((u16)0x0413) +#define HFA384x_PDR_SCALE_THRESH ((u16)0x0414) #define HFA384x_PDR_HFA3861_MANF_TESTSP ((u16)0x0900) #define HFA384x_PDR_HFA3861_MANF_TESTI ((u16)0x0901) @@ -383,7 +384,7 @@ typedef struct hfa384x_caplevel { /*-- Configuration Record: cnfAuthentication --*/ #define HFA384x_CNFAUTHENTICATION_OPENSYSTEM 0x0001 #define HFA384x_CNFAUTHENTICATION_SHAREDKEY 0x0002 -#define HFA384x_CNFAUTHENTICATION_LEAP 0x0004 +#define HFA384x_CNFAUTHENTICATION_LEAP 0x0004 /*-------------------------------------------------------------------- Configuration Record Structures: @@ -575,8 +576,8 @@ Information Types #define HFA384x_IT_AUTHREQ ((u16)0xF202UL) #define HFA384x_IT_PSUSERCNT ((u16)0xF203UL) #define HFA384x_IT_KEYIDCHANGED ((u16)0xF204UL) -#define HFA384x_IT_ASSOCREQ ((u16)0xF205UL) -#define HFA384x_IT_MICFAILURE ((u16)0xF206UL) +#define HFA384x_IT_ASSOCREQ ((u16)0xF205UL) +#define HFA384x_IT_MICFAILURE ((u16)0xF206UL) /*-------------------------------------------------------------------- Information Frames Structures diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 750330f..0039e08 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -351,6 +351,8 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, union p80211_hdr p80211_hdr; struct p80211_metawep p80211_wep; + p80211_wep.data = NULL; + if (skb == NULL) return NETDEV_TX_OK; diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 89bfd85..d22db43 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -415,11 +415,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) break; #define REQBASICRATE(N) \ - if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \ - req->basicrate ## N .data = item->supprates[(N)-1]; \ - req->basicrate ## N .status = \ - P80211ENUM_msgitem_status_data_ok; \ - } + do { \ + if ((count >= N) && DOT11_RATE5_ISBASIC_GET( \ + item->supprates[(N)-1])) { \ + req->basicrate ## N .data = item->supprates[(N)-1]; \ + req->basicrate ## N .status = \ + P80211ENUM_msgitem_status_data_ok; \ + } \ + } while (0) REQBASICRATE(1); REQBASICRATE(2); @@ -431,11 +434,13 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) REQBASICRATE(8); #define REQSUPPRATE(N) \ - if (count >= N) { \ - req->supprate ## N .data = item->supprates[(N)-1]; \ - req->supprate ## N .status = \ - P80211ENUM_msgitem_status_data_ok; \ - } + do { \ + if (count >= N) { \ + req->supprate ## N .data = item->supprates[(N)-1]; \ + req->supprate ## N .status = \ + P80211ENUM_msgitem_status_data_ok; \ + } \ + } while (0) REQSUPPRATE(1); REQSUPPRATE(2); @@ -1139,9 +1144,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - pr_debug - ("failed to enable port to presniff setting, result=%d\n", - result); + pr_debug("failed to enable port to presniff setting, result=%d\n", + result); goto failed; } } else { @@ -1181,18 +1185,16 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) hfa384x_drvr_stop(hw); result = hfa384x_drvr_start(hw); if (result) { - pr_debug - ("failed to restart the card for sniffing, result=%d\n", - result); + pr_debug("failed to restart the card for sniffing, result=%d\n", + result); goto failed; } } else { /* Disable the port */ result = hfa384x_drvr_disable(hw, 0); if (result) { - pr_debug - ("failed to enable port for sniffing, result=%d\n", - result); + pr_debug("failed to enable port for sniffing, result=%d\n", + result); goto failed; } } diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index e0f745d..801ac40 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -91,11 +91,10 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, unsigned short ModeIdIndex, index = 0; unsigned short RefreshRateTableIndex = 0; - unsigned short VRE, VBE, VRS, VBS, VDE, VT; - unsigned short HRE, HBE, HRS, HBS, HDE, HT; + unsigned short VRE, VBE, VRS, VDE; + unsigned short HRE, HBE, HRS, HDE; unsigned char sr_data, cr_data, cr_data2; - unsigned long cr_data3; - int A, B, C, D, E, F, temp, j; + int B, C, D, F, temp, j; InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); if (!XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr)) return 0; @@ -105,25 +104,13 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, sr_data = XGI_CRT1Table[index].CR[5]; - cr_data = XGI_CRT1Table[index].CR[0]; - - /* Horizontal total */ - HT = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8); - A = HT + 5; - - HDE = (XGI330_RefIndex[RefreshRateTableIndex].XRes >> 3) - 1; - E = HDE + 1; + HDE = (XGI330_RefIndex[RefreshRateTableIndex].XRes >> 3); cr_data = XGI_CRT1Table[index].CR[3]; /* Horizontal retrace (=sync) start */ HRS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0xC0) << 2); - F = HRS - E - 3; - - cr_data = XGI_CRT1Table[index].CR[1]; - - /* Horizontal blank start */ - HBS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x30) << 4); + F = HRS - HDE - 3; sr_data = XGI_CRT1Table[index].CR[6]; @@ -138,10 +125,10 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, /* Horizontal retrace (=sync) end */ HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); - temp = HBE - ((E - 1) & 255); + temp = HBE - ((HDE - 1) & 255); B = (temp > 0) ? temp : (temp + 256); - temp = HRE - ((E + F + 3) & 63); + temp = HRE - ((HDE + F + 3) & 63); C = (temp > 0) ? temp : (temp + 64); D = B - F - C; @@ -152,18 +139,9 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, sr_data = XGI_CRT1Table[index].CR[14]; - cr_data = XGI_CRT1Table[index].CR[8]; - cr_data2 = XGI_CRT1Table[index].CR[9]; - /* Vertical total */ - VT = (cr_data & 0xFF) | ((unsigned short) (cr_data2 & 0x01) << 8) - | ((unsigned short) (cr_data2 & 0x20) << 4) - | ((unsigned short) (sr_data & 0x01) << 10); - A = VT + 2; - - VDE = XGI330_RefIndex[RefreshRateTableIndex].YRes - 1; - E = VDE + 1; + VDE = XGI330_RefIndex[RefreshRateTableIndex].YRes; cr_data = XGI_CRT1Table[index].CR[10]; @@ -171,29 +149,20 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, VRS = (cr_data & 0xff) | ((unsigned short) (cr_data2 & 0x04) << 6) | ((unsigned short) (cr_data2 & 0x80) << 2) | ((unsigned short) (sr_data & 0x08) << 7); - F = VRS + 1 - E; - - cr_data = XGI_CRT1Table[index].CR[12]; - - cr_data3 = (XGI_CRT1Table[index].CR[14] & 0x80) << 5; - - /* Vertical blank start */ - VBS = (cr_data & 0xff) | ((unsigned short) (cr_data2 & 0x08) << 5) - | ((unsigned short) (cr_data3 & 0x20) << 4) - | ((unsigned short) (sr_data & 0x04) << 8); + F = VRS + 1 - VDE; cr_data = XGI_CRT1Table[index].CR[13]; /* Vertical blank end */ VBE = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x10) << 4); - temp = VBE - ((E - 1) & 511); + temp = VBE - ((VDE - 1) & 511); B = (temp > 0) ? temp : (temp + 512); cr_data = XGI_CRT1Table[index].CR[11]; /* Vertical retrace (=sync) end */ VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); - temp = VRE - ((E + F - 1) & 31); + temp = VRE - ((VDE + F - 1) & 31); C = (temp > 0) ? temp : (temp + 32); D = B - F - C; @@ -233,13 +202,14 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, return 1; } -static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) +void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) { XGI_Pr->P3c4 = BaseAddr + 0x14; XGI_Pr->P3d4 = BaseAddr + 0x24; XGI_Pr->P3c0 = BaseAddr + 0x10; XGI_Pr->P3ce = BaseAddr + 0x1e; XGI_Pr->P3c2 = BaseAddr + 0x12; + XGI_Pr->P3cc = BaseAddr + 0x1c; XGI_Pr->P3ca = BaseAddr + 0x1a; XGI_Pr->P3c6 = BaseAddr + 0x16; XGI_Pr->P3c7 = BaseAddr + 0x17; @@ -1160,22 +1130,10 @@ static int XGIfb_release(struct fb_info *info, int user) return 0; } +/* similar to sisfb_get_cmap_len */ static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var) { - int rc = 16; - - switch (var->bits_per_pixel) { - case 8: - rc = 256; - break; - case 16: - rc = 16; - break; - case 32: - rc = 16; - break; - } - return rc; + return (var->bits_per_pixel == 8) ? 256 : 16; } static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, @@ -1362,12 +1320,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) /* Adapt RGB settings */ XGIfb_bpp_to_var(xgifb_info, var); - /* Sanity check for offsets */ - if (var->xoffset < 0) - var->xoffset = 0; - if (var->yoffset < 0) - var->yoffset = 0; - if (!XGIfb_ypan) { if (var->xres != var->xres_virtual) var->xres_virtual = var->xres; @@ -1402,8 +1354,7 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var, return -EINVAL; if (var->vmode & FB_VMODE_YWRAP) { - if (var->yoffset < 0 || var->yoffset >= info->var.yres_virtual - || var->xoffset) + if (var->yoffset >= info->var.yres_virtual || var->xoffset) return -EINVAL; } else if (var->xoffset + info->var.xres > info->var.xres_virtual || var->yoffset + info->var.yres @@ -1838,7 +1789,7 @@ static int xgifb_probe(struct pci_dev *pdev, if (!XGIInitNew(pdev)) dev_err(&pdev->dev, "XGIInitNew() failed!\n"); - xgifb_info->mtrr = (unsigned int) 0; + xgifb_info->mtrr = -1; xgifb_info->hasVB = HASVB_NONE; if ((xgifb_info->chip == XG20) || @@ -1957,6 +1908,7 @@ static int xgifb_probe(struct pci_dev *pdev, if (xgifb_info->mode_idx < 0) { dev_err(&pdev->dev, "No supported video mode found\n"); + ret = -EINVAL; goto error_1; } diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 8054798..af50362 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -67,7 +67,7 @@ struct xgifb_video_info { unsigned long mmio_size; void __iomem *mmio_vbase; unsigned long vga_base; - unsigned long mtrr; + int mtrr; int video_bpp; int video_cmap_len; diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 2b791c1..df127e4 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -131,22 +131,6 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3c4, 0x30, XGI340_ECLKData[pVBInfo->ram_type].SR30); - - /* When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */ - /* Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, - * Set SR32 D[1:0] = 10b */ - if (HwDeviceExtension->jChipType == XG42) { - if ((pVBInfo->MCLKData[pVBInfo->ram_type].SR28 == 0x1C) && - (pVBInfo->MCLKData[pVBInfo->ram_type].SR29 == 0x01) && - (((XGI340_ECLKData[pVBInfo->ram_type].SR2E == 0x1C) && - (XGI340_ECLKData[pVBInfo->ram_type].SR2F == 0x01)) || - ((XGI340_ECLKData[pVBInfo->ram_type].SR2E == 0x22) && - (XGI340_ECLKData[pVBInfo->ram_type].SR2F == 0x01)))) - xgifb_reg_set(pVBInfo->P3c4, - 0x32, - ((unsigned char) xgifb_reg_get( - pVBInfo->P3c4, 0x32) & 0xFC) | 0x02); - } } static void XGINew_DDRII_Bootup_XG27( @@ -413,11 +397,24 @@ static void XGINew_DDR2_DefaultRegister( XGINew_DDR2_MRS_XG20(HwDeviceExtension, P3c4, pVBInfo); } +static void XGI_SetDRAM_Helper(unsigned long P3d4, u8 seed, u8 temp2, u8 reg, + u8 shift_factor, u8 mask1, u8 mask2) +{ + u8 j; + for (j = 0; j < 4; j++) { + temp2 |= (((seed >> (2 * j)) & 0x03) << shift_factor); + xgifb_reg_set(P3d4, reg, temp2); + xgifb_reg_get(P3d4, reg); + temp2 &= mask1; + temp2 += mask2; + } +} + static void XGINew_SetDRAMDefaultRegister340( struct xgi_hw_device_info *HwDeviceExtension, unsigned long Port, struct vb_device_info *pVBInfo) { - unsigned char temp, temp1, temp2, temp3, i, j, k; + unsigned char temp, temp1, temp2, temp3, j, k; unsigned long P3d4 = Port, P3c4 = Port - 0x10; @@ -426,54 +423,18 @@ static void XGINew_SetDRAMDefaultRegister340( xgifb_reg_set(P3d4, 0x69, pVBInfo->CR40[6][pVBInfo->ram_type]); xgifb_reg_set(P3d4, 0x6A, pVBInfo->CR40[7][pVBInfo->ram_type]); - temp2 = 0; - for (i = 0; i < 4; i++) { - /* CR6B DQS fine tune delay */ - temp = XGI340_CR6B[pVBInfo->ram_type][i]; - for (j = 0; j < 4; j++) { - temp1 = ((temp >> (2 * j)) & 0x03) << 2; - temp2 |= temp1; - xgifb_reg_set(P3d4, 0x6B, temp2); - /* Insert read command for delay */ - xgifb_reg_get(P3d4, 0x6B); - temp2 &= 0xF0; - temp2 += 0x10; - } - } + /* CR6B DQS fine tune delay */ + temp = 0xaa; + XGI_SetDRAM_Helper(P3d4, temp, 0, 0x6B, 2, 0xF0, 0x10); - temp2 = 0; - for (i = 0; i < 4; i++) { - /* CR6E DQM fine tune delay */ - temp = 0; - for (j = 0; j < 4; j++) { - temp1 = ((temp >> (2 * j)) & 0x03) << 2; - temp2 |= temp1; - xgifb_reg_set(P3d4, 0x6E, temp2); - /* Insert read command for delay */ - xgifb_reg_get(P3d4, 0x6E); - temp2 &= 0xF0; - temp2 += 0x10; - } - } + /* CR6E DQM fine tune delay */ + XGI_SetDRAM_Helper(P3d4, 0, 0, 0x6E, 2, 0xF0, 0x10); temp3 = 0; for (k = 0; k < 4; k++) { /* CR6E_D[1:0] select channel */ xgifb_reg_and_or(P3d4, 0x6E, 0xFC, temp3); - temp2 = 0; - for (i = 0; i < 8; i++) { - /* CR6F DQ fine tune delay */ - temp = 0; - for (j = 0; j < 4; j++) { - temp1 = (temp >> (2 * j)) & 0x03; - temp2 |= temp1; - xgifb_reg_set(P3d4, 0x6F, temp2); - /* Insert read command for delay */ - xgifb_reg_get(P3d4, 0x6F); - temp2 &= 0xF8; - temp2 += 0x08; - } - } + XGI_SetDRAM_Helper(P3d4, 0, 0, 0x6F, 0, 0xF8, 0x08); temp3 += 0x01; } @@ -486,15 +447,7 @@ static void XGINew_SetDRAMDefaultRegister340( temp2 = 0x80; /* CR89 terminator type select */ - temp = 0; - for (j = 0; j < 4; j++) { - temp1 = (temp >> (2 * j)) & 0x03; - temp2 |= temp1; - xgifb_reg_set(P3d4, 0x89, temp2); - xgifb_reg_get(P3d4, 0x89); /* Insert read command for delay */ - temp2 &= 0xF0; - temp2 += 0x10; - } + XGI_SetDRAM_Helper(P3d4, 0, temp2, 0x89, 0, 0xF0, 0x10); temp = 0; temp1 = temp & 0x03; @@ -1286,36 +1239,14 @@ unsigned char XGIInitNew(struct pci_dev *pdev) pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; - pVBInfo->BaseAddr = xgifb_info->vga_base; - if (pVBInfo->FBAddr == NULL) { dev_dbg(&pdev->dev, "pVBInfo->FBAddr == 0\n"); return 0; } - if (pVBInfo->BaseAddr == 0) { - dev_dbg(&pdev->dev, "pVBInfo->BaseAddr == 0\n"); - return 0; - } - outb(0x67, (pVBInfo->BaseAddr + 0x12)); /* 3c2 <- 67 ,ynlai */ - - pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; - pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; - pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; - pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; - pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; - pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; - pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; - pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; - pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; - pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; - pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; - pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; - pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; - pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; - pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; - pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; - pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; + XGIRegInit(pVBInfo, xgifb_info->vga_base); + + outb(0x67, pVBInfo->P3c2); if (HwDeviceExtension->jChipType < XG20) /* Run XGI_GetVBType before InitTo330Pointer */ @@ -1410,7 +1341,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00); xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00); /* chk if BCLK>=100MHz */ - temp1 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x7B); + temp1 = xgifb_reg_get(pVBInfo->P3d4, 0x7B); temp = (unsigned char) ((temp1 >> 4) & 0x0F); xgifb_reg_set(pVBInfo->Part1Port, diff --git a/drivers/staging/xgifb/vb_init.h b/drivers/staging/xgifb/vb_init.h index d548983..2457302 100644 --- a/drivers/staging/xgifb/vb_init.h +++ b/drivers/staging/xgifb/vb_init.h @@ -1,5 +1,6 @@ #ifndef _VBINIT_ #define _VBINIT_ extern unsigned char XGIInitNew(struct pci_dev *pdev); +extern void XGIRegInit(struct vb_device_info *, unsigned long); #endif diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index d723a25..dfa5303 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2,6 +2,7 @@ #include "XGIfb.h" #include "vb_def.h" +#include "vb_init.h" #include "vb_util.h" #include "vb_table.h" #include "vb_setmode.h" @@ -63,29 +64,15 @@ static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - unsigned char tempah, SRdata; - unsigned short i, modeflag; - - modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + unsigned char SRdata, i; xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ - tempah = XGI330_StandTable.SR[0]; - - i = XGI_SetCRT2ToLCDA; - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { - tempah |= 0x01; - } else if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { - if (pVBInfo->VBInfo & SetInSlaveMode) - tempah |= 0x01; - } - tempah |= 0x20; /* screen off */ - xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ - - for (i = 02; i <= 04; i++) { - /* Get SR2,3,4 from file */ - SRdata = XGI330_StandTable.SR[i - 1]; - xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ + for (i = 0; i < 4; i++) { + /* Get SR1,2,3,4 from file */ + /* SR1 is with screen off 0x20 */ + SRdata = XGI330_StandTable.SR[i]; + xgifb_reg_set(pVBInfo->P3c4, i+1, SRdata); /* Set SR 1 2 3 4 */ } } @@ -95,7 +82,7 @@ static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned char CRTCdata; unsigned short i; - CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); + CRTCdata = xgifb_reg_get(pVBInfo->P3d4, 0x11); CRTCdata &= 0x7f; xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ @@ -152,7 +139,7 @@ static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) } if (pVBInfo->ModeType > ModeVGA) { - GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); + GRdata = xgifb_reg_get(pVBInfo->P3ce, 0x05); GRdata &= 0xBF; /* 256 color disable */ xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); } @@ -300,7 +287,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, unsigned short i, j; /* unlock cr0-7 */ - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); + data = xgifb_reg_get(pVBInfo->P3d4, 0x11); data &= 0x7F; xgifb_reg_set(pVBInfo->P3d4, 0x11, data); @@ -317,7 +304,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); } - j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); + j = xgifb_reg_get(pVBInfo->P3c4, 0x0e); j &= 0x1F; data = pVBInfo->TimingH.data[7]; data &= 0xE0; @@ -325,17 +312,16 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); if (HwDeviceExtension->jChipType >= XG20) { - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); + data = xgifb_reg_get(pVBInfo->P3d4, 0x04); data = data - 1; xgifb_reg_set(pVBInfo->P3d4, 0x04, data); - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); + data = xgifb_reg_get(pVBInfo->P3d4, 0x05); data1 = data; data1 &= 0xE0; data &= 0x1F; if (data == 0) { pushax = data; - data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, - 0x0c); + data = xgifb_reg_get(pVBInfo->P3c4, 0x0c); data &= 0xFB; xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); data = pushax; @@ -343,7 +329,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, data = data - 1; data |= data1; xgifb_reg_set(pVBInfo->P3d4, 0x05, data); - data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); + data = xgifb_reg_get(pVBInfo->P3c4, 0x0e); data = data >> 5; data = data + 3; if (data > 7) @@ -375,7 +361,7 @@ static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); } - j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); + j = xgifb_reg_get(pVBInfo->P3c4, 0x0a); j &= 0xC0; data = pVBInfo->TimingV.data[6]; data &= 0x3F; @@ -391,7 +377,7 @@ static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, if (i) data |= 0x80; - j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); + j = xgifb_reg_get(pVBInfo->P3d4, 0x09); j &= 0x5F; data |= j; xgifb_reg_set(pVBInfo->P3d4, 0x09, data); @@ -409,7 +395,7 @@ static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; index = index & IndexMask; - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); + data = xgifb_reg_get(pVBInfo->P3d4, 0x11); data &= 0x7F; xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ @@ -640,10 +626,7 @@ static void xgifb_set_lcd(int chip_id, unsigned short RefreshRateTableIndex, unsigned short ModeNo) { - unsigned short Data, Temp; - unsigned short XGI_P3cc; - - XGI_P3cc = pVBInfo->P3cc; + unsigned short temp; xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); @@ -651,8 +634,8 @@ static void xgifb_set_lcd(int chip_id, xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); if (chip_id == XG27) { - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - if ((Temp & 0x03) == 0) { /* dual 12 */ + temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if ((temp & 0x03) == 0) { /* dual 12 */ xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); } @@ -661,8 +644,8 @@ static void xgifb_set_lcd(int chip_id, if (chip_id == XG27) { XGI_SetXG27FPBits(pVBInfo); } else { - Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); - if (Temp & 0x01) { + temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); + if (temp & 0x01) { /* 18 bits FP */ xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); @@ -674,11 +657,11 @@ static void xgifb_set_lcd(int chip_id, xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ - Data = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - if (Data & 0x4000) + temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + if (temp & 0x4000) /* Hsync polarity */ xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); - if (Data & 0x8000) + if (temp & 0x8000) /* Vsync polarity */ xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); } @@ -757,8 +740,8 @@ static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, tempax -= 1; tempbx -= 1; tempcx = tempax; - temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); + temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); + data = xgifb_reg_get(pVBInfo->P3d4, 0x11); data &= 0x7F; xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); @@ -775,7 +758,7 @@ static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, tempax |= 0x40; xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); - data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); + data = xgifb_reg_get(pVBInfo->P3d4, 0x07); data &= 0xFF; tempax = 0; @@ -876,62 +859,47 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { - unsigned short CRT2Index, VCLKIndex; - unsigned short modeflag, resinfo; + unsigned short VCLKIndex, modeflag; /* si+Ext_ResInfo */ modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; - CRT2Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - if (pVBInfo->IF_DEF_LVDS == 0) { - CRT2Index = CRT2Index >> 6; /* for LCD */ - if (pVBInfo->VBInfo & - (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ - if (pVBInfo->LCDResInfo != Panel_1024x768) - /* LCDXlat2VCLK */ - VCLKIndex = VCLK108_2_315 + 5; - else - VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ - } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { - if (pVBInfo->SetFlag & RPLLDIV2XO) - VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; - else - VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; + if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ + if (pVBInfo->LCDResInfo != Panel_1024x768) + /* LCDXlat2VCLK */ + VCLKIndex = VCLK108_2_315 + 5; + else + VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ + } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { + if (pVBInfo->SetFlag & RPLLDIV2XO) + VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; + else + VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; - if (pVBInfo->SetFlag & TVSimuMode) { - if (modeflag & Charx8Dot) { - VCLKIndex = TVCLKBASE_315_25 + - HiTVSimuVCLK; - } else { - VCLKIndex = TVCLKBASE_315_25 + - HiTVTextVCLK; - } + if (pVBInfo->SetFlag & TVSimuMode) { + if (modeflag & Charx8Dot) { + VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK; + } else { + VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK; } + } - /* 301lv */ - if (pVBInfo->VBType & VB_SIS301LV) { - if (pVBInfo->SetFlag & RPLLDIV2XO) - VCLKIndex = YPbPr525iVCLK_2; - else - VCLKIndex = YPbPr525iVCLK; - } - } else if (pVBInfo->VBInfo & SetCRT2ToTV) { + /* 301lv */ + if (pVBInfo->VBType & VB_SIS301LV) { if (pVBInfo->SetFlag & RPLLDIV2XO) - VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; + VCLKIndex = YPbPr525iVCLK_2; else - VCLKIndex = TVCLKBASE_315_25 + TVVCLK; - } else { /* for CRT2 */ - /* di+Ext_CRTVCLK */ - VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex]. - Ext_CRTVCLK; - VCLKIndex &= IndexMask; + VCLKIndex = YPbPr525iVCLK; } - } else if ((pVBInfo->LCDResInfo == Panel_800x600) || - (pVBInfo->LCDResInfo == Panel_320x480)) { /* LVDS */ - VCLKIndex = VCLK40; /* LVDSXlat1VCLK */ - } else { - VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */ + } else if (pVBInfo->VBInfo & SetCRT2ToTV) { + if (pVBInfo->SetFlag & RPLLDIV2XO) + VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; + else + VCLKIndex = TVCLKBASE_315_25 + TVVCLK; + } else { /* for CRT2 */ + /* di+Ext_CRTVCLK */ + VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; + VCLKIndex &= IndexMask; } return VCLKIndex; @@ -1103,10 +1071,8 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, data = 0x0048; } - data2 = data & 0x00FF; - xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); - data2 = (data & 0xFF00) >> 8; - xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); + xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data); + xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0); if (modeflag & HalfDCLK) xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); @@ -1389,14 +1355,10 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { - unsigned char index; unsigned short i; struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; - index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - index = index & IndexMask; - if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); @@ -1496,18 +1458,11 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, { unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; unsigned long temp, temp1, temp2, temp3, push3; - struct XGI_LCDDesStruct const *LCDPtr = NULL; struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - if (pVBInfo->LCDInfo & EnableScalingLCD) - LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, - ModeIdIndex, RefreshRateTableIndex, - pVBInfo); - else - LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, - ModeIdIndex, RefreshRateTableIndex, - pVBInfo); + LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, ModeIdIndex, + RefreshRateTableIndex, pVBInfo); XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); push1 = tempbx; @@ -1539,10 +1494,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, tempax = pVBInfo->HT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHDES; - else - tempbx = LCDPtr->LCDHDES; + tempbx = LCDPtr1->LCDHDES; tempcx = pVBInfo->HDE; tempbx = tempbx & 0x0fff; @@ -1563,10 +1515,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, tempax = pVBInfo->HT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDHRS; - else - tempbx = LCDPtr->LCDHRS; + tempbx = LCDPtr1->LCDHRS; tempcx = push2; @@ -1591,10 +1540,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, (unsigned short) (tempbx & 0xff)); tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVDES; - else - tempbx = LCDPtr->LCDVDES; + tempbx = LCDPtr1->LCDVDES; tempcx = pVBInfo->VDE; tempbx = tempbx & 0x0fff; @@ -1615,10 +1561,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, | tempbx)); tempax = pVBInfo->VT; - if (pVBInfo->LCDInfo & EnableScalingLCD) - tempbx = LCDPtr1->LCDVRS; - else - tempbx = LCDPtr->LCDVRS; + tempbx = LCDPtr1->LCDVRS; tempcx = push1; @@ -1835,14 +1778,7 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, } } /* {End of VB} */ - tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); - tempal = tempal >> 2; - tempal &= 0x03; - - /* for Dot8 Scaling LCD */ - if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) - tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ - + inb((pVBInfo->P3ca + 0x02)); tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; return tempal; } @@ -2050,40 +1986,28 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); - if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->VBType & - (VB_SIS302B | - VB_SIS301LV | - VB_SIS302LV | - VB_XGI301C)) { - if (temp & EnableDualEdge) { - tempbx |= SetCRT2ToDualEdge; - if (temp & SetToLCDA) - tempbx |= XGI_SetCRT2ToLCDA; - } + if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV | + VB_XGI301C)) { + if (temp & EnableDualEdge) { + tempbx |= SetCRT2ToDualEdge; + if (temp & SetToLCDA) + tempbx |= XGI_SetCRT2ToLCDA; } } if (pVBInfo->IF_DEF_YPbPr == 1) { - if (((pVBInfo->IF_DEF_LVDS == 0) && - ((pVBInfo->VBType & VB_SIS301LV) || - (pVBInfo->VBType & VB_SIS302LV) || - (pVBInfo->VBType & VB_XGI301C)))) { + if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) { if (temp & SetYPbPr) { if (pVBInfo->IF_DEF_HiVision == 1) { - /* shampoo add for new - * scratch */ - temp = xgifb_reg_get( - pVBInfo->P3d4, - 0x35); + /* shampoo add for new scratch */ + temp = xgifb_reg_get(pVBInfo->P3d4, + 0x35); temp &= YPbPrMode; tempbx |= SetCRT2ToHiVision; if (temp != YPbPrMode1080i) { - tempbx &= - (~SetCRT2ToHiVision); - tempbx |= - SetCRT2ToYPbPr525750; + tempbx &= (~SetCRT2ToHiVision); + tempbx |= SetCRT2ToYPbPr525750; } } } @@ -2092,19 +2016,15 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, tempax = push; /* restore CR31 */ - if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->IF_DEF_YPbPr == 1) { - if (pVBInfo->IF_DEF_HiVision == 1) - temp = 0x09FC; - else - temp = 0x097C; - } else if (pVBInfo->IF_DEF_HiVision == 1) { - temp = 0x01FC; - } else { - temp = 0x017C; - } - } else { /* 3rd party chip */ - temp = SetCRT2ToLCD; + if (pVBInfo->IF_DEF_YPbPr == 1) { + if (pVBInfo->IF_DEF_HiVision == 1) + temp = 0x09FC; + else + temp = 0x097C; + } else if (pVBInfo->IF_DEF_HiVision == 1) { + temp = 0x01FC; + } else { + temp = 0x017C; } if (!(tempbx & temp)) { @@ -2115,14 +2035,11 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, if (!(pVBInfo->VBType & VB_NoLCD)) { if (tempbx & XGI_SetCRT2ToLCDA) { if (tempbx & SetSimuScanMode) - tempbx &= (~(SetCRT2ToLCD | - SetCRT2ToRAMDAC | + tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchCRT2)); else - tempbx &= (~(SetCRT2ToLCD | - SetCRT2ToRAMDAC | - SetCRT2ToTV | - SwitchCRT2)); + tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | + SetCRT2ToTV | SwitchCRT2)); } } @@ -2131,49 +2048,38 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { if (pVBInfo->IF_DEF_CRT2Monitor == 1) { if (tempbx & SetCRT2ToRAMDAC) { - tempbx &= (0xFF00 | - SetCRT2ToRAMDAC | - SwitchCRT2 | - SetSimuScanMode); + tempbx &= (0xFF00 | SetCRT2ToRAMDAC | + SwitchCRT2 | SetSimuScanMode); tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); } } else { - tempbx &= (~(SetCRT2ToRAMDAC | - SetCRT2ToLCD | + tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)); } } if (!(pVBInfo->VBType & VB_NoLCD)) { if (tempbx & SetCRT2ToLCD) { - tempbx &= (0xFF00 | - SetCRT2ToLCD | - SwitchCRT2 | + tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 | SetSimuScanMode); tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); } } if (tempbx & SetCRT2ToSCART) { - tempbx &= (0xFF00 | - SetCRT2ToSCART | - SwitchCRT2 | + tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 | SetSimuScanMode); tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); } if (pVBInfo->IF_DEF_YPbPr == 1) { if (tempbx & SetCRT2ToYPbPr525750) - tempbx &= (0xFF00 | - SwitchCRT2 | - SetSimuScanMode); + tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode); } if (pVBInfo->IF_DEF_HiVision == 1) { if (tempbx & SetCRT2ToHiVision) - tempbx &= (0xFF00 | - SetCRT2ToHiVision | - SwitchCRT2 | + tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); } @@ -2183,19 +2089,15 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, } if (!(tempbx & DisableCRT2Display)) { - if ((!(tempbx & DriverMode)) || - (!(modeflag & CRT2Mode))) { + if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) { if (!(tempbx & XGI_SetCRT2ToLCDA)) - tempbx |= (SetInSlaveMode | - SetSimuScanMode); + tempbx |= (SetInSlaveMode | SetSimuScanMode); } /* LCD+TV can't support in slave mode * (Force LCDA+TV->LCDB) */ - if ((tempbx & SetInSlaveMode) && - (tempbx & XGI_SetCRT2ToLCDA)) { - tempbx ^= (SetCRT2ToLCD | - XGI_SetCRT2ToLCDA | + if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) { + tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA | SetCRT2ToDualEdge); pVBInfo->SetFlag |= ReserveTVOption; } @@ -2207,36 +2109,28 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; - - tempbx = 0; - resinfo = 0; + unsigned short tempbx = 0, resinfo = 0, modeflag, index1; if (pVBInfo->VBInfo & SetCRT2ToTV) { modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; - if (pVBInfo->VBInfo & SetCRT2ToTV) { - temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); - tempbx = temp; - if (tempbx & TVSetPAL) { - tempbx &= (SetCHTVOverScan | - TVSetPALM | - TVSetPALN | - TVSetPAL); - if (tempbx & TVSetPALM) - /* set to NTSC if PAL-M */ - tempbx &= ~TVSetPAL; - } else - tempbx &= (SetCHTVOverScan | - TVSetNTSCJ | - TVSetPAL); - } + tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); + if (tempbx & TVSetPAL) { + tempbx &= (SetCHTVOverScan | + TVSetPALM | + TVSetPALN | + TVSetPAL); + if (tempbx & TVSetPALM) + /* set to NTSC if PAL-M */ + tempbx &= ~TVSetPAL; + } else + tempbx &= (SetCHTVOverScan | + TVSetNTSCJ | + TVSetPAL); - if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->VBInfo & SetCRT2ToSCART) - tempbx |= TVSetPAL; - } + if (pVBInfo->VBInfo & SetCRT2ToSCART) + tempbx |= TVSetPAL; if (pVBInfo->IF_DEF_YPbPr == 1) { if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { @@ -2258,33 +2152,26 @@ static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, tempbx = tempbx | TVSetHiVision | TVSetPAL; } - if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ - if ((pVBInfo->VBInfo & SetInSlaveMode) && - (!(pVBInfo->VBInfo & SetNotSimuMode))) - tempbx |= TVSimuMode; + if ((pVBInfo->VBInfo & SetInSlaveMode) && + (!(pVBInfo->VBInfo & SetNotSimuMode))) + tempbx |= TVSimuMode; - if (!(tempbx & TVSetPAL) && - (modeflag > 13) && - (resinfo == 8)) /* NTSC 1024x768, */ - tempbx |= NTSC1024x768; + if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8)) + /* NTSC 1024x768, */ + tempbx |= NTSC1024x768; - tempbx |= RPLLDIV2XO; + tempbx |= RPLLDIV2XO; - if (pVBInfo->VBInfo & SetCRT2ToHiVision) { - if (pVBInfo->VBInfo & SetInSlaveMode) - tempbx &= (~RPLLDIV2XO); - } else if (tempbx & - (TVSetYPbPr525p | TVSetYPbPr750p)) { - tempbx &= (~RPLLDIV2XO); - } else if (!(pVBInfo->VBType & - (VB_SIS301B | - VB_SIS302B | - VB_SIS301LV | - VB_SIS302LV | - VB_XGI301C))) { - if (tempbx & TVSimuMode) - tempbx &= (~RPLLDIV2XO); - } + if (pVBInfo->VBInfo & SetCRT2ToHiVision) { + if (pVBInfo->VBInfo & SetInSlaveMode) + tempbx &= (~RPLLDIV2XO); + } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) { + tempbx &= (~RPLLDIV2XO); + } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | + VB_SIS301LV | VB_SIS302LV | + VB_XGI301C))) { + if (tempbx & TVSimuMode) + tempbx &= (~RPLLDIV2XO); } } pVBInfo->TVInfo = tempbx; @@ -2293,13 +2180,12 @@ static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; + unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex; pVBInfo->LCDResInfo = 0; pVBInfo->LCDTypeInfo = 0; pVBInfo->LCDInfo = 0; - modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo // */ resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ @@ -2346,23 +2232,18 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; - if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ - if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType - & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) { - tempbx |= SetLCDDualLink; - } - } + if (((pVBInfo->VBType & VB_SIS302LV) || + (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) + tempbx |= SetLCDDualLink; - if (pVBInfo->IF_DEF_LVDS == 0) { - if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo - & SetCRT2ToLCD) && (resinfo == 9) && - (!(tempbx & EnableScalingLCD))) - /* - * set to center in 1280x1024 LCDB - * for Panel_1400x1050 - */ - tempbx |= SetLCDtoNonExpanding; - } + if ((pVBInfo->LCDResInfo == Panel_1400x1050) && + (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) && + (!(tempbx & EnableScalingLCD))) + /* + * set to center in 1280x1024 LCDB + * for Panel_1400x1050 + */ + tempbx |= SetLCDtoNonExpanding; if (pVBInfo->VBInfo & SetInSlaveMode) { if (pVBInfo->VBInfo & SetNotSimuMode) @@ -2637,36 +2518,34 @@ static void XGI_GetCRT2ResInfo(unsigned short ModeNo, if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) goto exit; - if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->LCDResInfo == Panel_1600x1200) { - if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { - if (yres == 1024) - yres = 1056; - } + if (pVBInfo->LCDResInfo == Panel_1600x1200) { + if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { + if (yres == 1024) + yres = 1056; } + } - if (pVBInfo->LCDResInfo == Panel_1280x1024) { - if (yres == 400) - yres = 405; - else if (yres == 350) - yres = 360; + if (pVBInfo->LCDResInfo == Panel_1280x1024) { + if (yres == 400) + yres = 405; + else if (yres == 350) + yres = 360; - if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { - if (yres == 360) - yres = 375; - } + if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { + if (yres == 360) + yres = 375; } + } - if (pVBInfo->LCDResInfo == Panel_1024x768) { - if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { - if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { - if (yres == 350) - yres = 357; - else if (yres == 400) - yres = 420; - else if (yres == 480) - yres = 525; - } + if (pVBInfo->LCDResInfo == Panel_1024x768) { + if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { + if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { + if (yres == 350) + yres = 357; + else if (yres == 400) + yres = 420; + else if (yres == 480) + yres = 525; } } } @@ -2981,10 +2860,8 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo, temp = 0x6B; if (infoflag & InterlaceMode) temp = temp << 1; - return temp * colordepth; - } else { - return temp * colordepth; } + return temp * colordepth; } static void XGI_SetCRT2Offset(unsigned short ModeNo, @@ -3022,11 +2899,7 @@ static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { - unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; - - CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - CRT1Index &= IndexMask; - resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; + u8 tempcx; XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, pVBInfo); @@ -3045,11 +2918,10 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, - pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; + pushbx = 0, CRT1Index, modeflag; CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; CRT1Index &= IndexMask; - resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* bainy change table name */ @@ -3204,13 +3076,11 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, - modeflag, CRT1Index; + modeflag; /* si+Ext_ResInfo */ modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; - CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - CRT1Index &= IndexMask; if (!(pVBInfo->VBInfo & SetInSlaveMode)) return; @@ -3501,15 +3371,13 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, - modeflag, resinfo, crt2crtc; + modeflag; unsigned char const *TimingPoint; unsigned long longtemp, tempeax, tempebx, temp2, tempecx; /* si+Ext_ResInfo */ modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; - crt2crtc = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; tempax = 0; @@ -3918,8 +3786,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, } if (pVBInfo->TVInfo & TVSetPALM) { - tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, - 0x01); + tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01); tempax--; xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); @@ -3940,17 +3807,12 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { - unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, - tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; + unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah, + tempbh, tempch; struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; /* si+Ext_ResInfo */ - modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; - CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - CRT1Index &= IndexMask; - if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) return; @@ -3969,7 +3831,6 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ - push1 = tempbx; tempbx--; temp = tempbx & 0x00FF; xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); @@ -3977,7 +3838,6 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); tempcx = pVBInfo->VT - 1; - push2 = tempcx + 1; temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); temp = (tempcx & 0xFF00) >> 8; @@ -4459,10 +4319,6 @@ static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - unsigned short Pindex, Pdata; - - Pindex = pVBInfo->Part5Port; - Pdata = pVBInfo->Part5Port + 1; if (pVBInfo->ModeType == ModeVGA) { if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag | DisableCRT2Display))) { @@ -4538,7 +4394,7 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & (LCDPolarity << 8)) >> 8); temp &= LCDPolarity; - Miscdata = (unsigned char) inb(pVBInfo->P3cc); + Miscdata = inb(pVBInfo->P3cc); outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); @@ -4598,7 +4454,7 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; - temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); + temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ if (!(modeflag & Charx8Dot)) @@ -4737,43 +4593,21 @@ static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) } /* --------------------------------------------------------------------- */ -/* Function : XGI_DisableChISLCD */ -/* Input : */ -/* Output : 0 -> Not LCD Mode */ -/* Description : */ -/* --------------------------------------------------------------------- */ -static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) -{ - unsigned short tempbx, tempah; - - tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); - tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); - - if (tempbx & (EnableChA | DisableChA)) { - if (!(tempah & 0x08)) /* Chk LCDA Mode */ - return 0; - } - - if (!(tempbx & (EnableChB | DisableChB))) - return 0; - - if (tempah & 0x01) /* Chk LCDB Mode */ - return 1; - - return 0; -} - -/* --------------------------------------------------------------------- */ /* Function : XGI_EnableChISLCD */ /* Input : */ /* Output : 0 -> Not LCD mode */ -/* Description : */ +/* Description : if bool enable = true -> enable, else disable */ /* --------------------------------------------------------------------- */ -static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) +static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo, + bool enable) { unsigned short tempbx, tempah; - tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); + if (enable) + tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); + else + tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); + tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); if (tempbx & (EnableChA | DisableChA)) { @@ -4825,9 +4659,9 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { if (((pVBInfo->VBInfo & - (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) - || (XGI_DisableChISLCD(pVBInfo)) - || (XGI_IsLCDON(pVBInfo))) + (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) || + (XGI_EnableChISLCD(pVBInfo, false)) || + (XGI_IsLCDON(pVBInfo))) /* LVDS Driver power down */ xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); } @@ -5018,16 +4852,6 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) } xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); } - } else if (pVBInfo->IF_DEF_LVDS == 1) { - tempbl = 0; - tempbh = 0; - if (pVBInfo->VBInfo & SetCRT2ToLCD) { - tempah = XGI301LCDDelay; - tempah &= 0x0f; - tempah = tempah << 4; - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, - tempah); - } } } @@ -5118,12 +4942,8 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; - if (pVBInfo->VBType & - (VB_SIS301B | - VB_SIS302B | - VB_SIS301LV | - VB_SIS302LV | - VB_XGI301C)) { /* 301LV/302LV only */ + if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | + VB_SIS302LV | VB_XGI301C)) { if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { /* Set 301LV Capability */ @@ -5135,10 +4955,7 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), (unsigned short) ((tempcx & (EnableVBCLKDRVLOW | EnablePLLSPLOW)) >> 8)); - } - if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV - | VB_SIS302LV | VB_XGI301C)) { if (pVBInfo->VBInfo & SetCRT2ToLCD) XGI_SetLCDCap_B(tempcx, pVBInfo); else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) @@ -5510,13 +5327,10 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, - LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, - 0x01, 0x01 }; + const u8 LCDARefreshIndex[] = { + 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; - unsigned short RefreshRateTableIndex, i, modeflag, index, temp; - - modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + unsigned short RefreshRateTableIndex, i, index, temp; index = xgifb_reg_get(pVBInfo->P3d4, 0x33); index = index >> pVBInfo->SelectCRT2Rate; @@ -5531,15 +5345,8 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, if (pVBInfo->SetFlag & ProgrammingCRT2) { if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B - | VB_SIS301LV | VB_SIS302LV - | VB_XGI301C)) - /* 301b */ - temp = LCDARefreshIndex[ - pVBInfo->LCDResInfo & 0x0F]; - else - temp = LCDRefreshIndex[ - pVBInfo->LCDResInfo & 0x0F]; + temp = LCDARefreshIndex[ + pVBInfo->LCDResInfo & 0x07]; if (index > temp) index = temp; @@ -5617,9 +5424,8 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { - unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; + unsigned short ModeIdIndex, RefreshRateTableIndex; - tempbx = pVBInfo->VBInfo; pVBInfo->SetFlag |= ProgrammingCRT2; XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); pVBInfo->SelectCRT2Rate = 4; @@ -5658,32 +5464,31 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) unsigned char CR17, CR63, SR31; unsigned short temp; - unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; int i; xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); /* to fix XG42 single LCD sense to CRT+LCD */ xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); - xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( + xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( pVBInfo->P3d4, 0x53) | 0x02)); - SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); - CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); - SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); + SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31); + CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63); + SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01); xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); - CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); + CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17); xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); - SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); + SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F); xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); - SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); + SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07); xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); - SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); + SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06); xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); @@ -5712,10 +5517,8 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) outb(0x00, pVBInfo->P3c8); - for (i = 0; i < 256; i++) { - outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); - outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); - outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); + for (i = 0; i < 256 * 3; i++) { + outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */ } mdelay(1); @@ -5731,9 +5534,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) /* avoid display something, set BLACK DAC if not restore DAC */ outb(0x00, pVBInfo->P3c8); - for (i = 0; i < 256; i++) { - outb(0, (pVBInfo->P3c8 + 1)); - outb(0, (pVBInfo->P3c8 + 1)); + for (i = 0; i < 256 * 3; i++) { outb(0, (pVBInfo->P3c8 + 1)); } @@ -5741,7 +5542,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); - xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( + xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( pVBInfo->P3d4, 0x53) & 0xFD)); xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); } @@ -5755,13 +5556,10 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { if (!(pVBInfo->SetFlag & DisableChA)) { - if (pVBInfo->SetFlag & EnableChA) { + if ((pVBInfo->SetFlag & EnableChA) || + (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { /* Power on */ xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); - } else if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { - /* Power on */ - xgifb_reg_set(pVBInfo->Part1Port, - 0x1E, 0x20); } } @@ -5769,8 +5567,7 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC))) { - tempah = (unsigned char) xgifb_reg_get( - pVBInfo->P3c4, 0x32); + tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32); tempah &= 0xDF; if (pVBInfo->VBInfo & SetInSlaveMode) { if (!(pVBInfo->VBInfo & @@ -5780,8 +5577,8 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); - tempah = (unsigned char) xgifb_reg_get( - pVBInfo->Part1Port, 0x2E); + tempah = xgifb_reg_get(pVBInfo->Part1Port, + 0x2E); if (!(tempah & 0x80)) xgifb_reg_or(pVBInfo->Part1Port, @@ -5795,8 +5592,8 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, 0x20); /* shampoo 0129 */ if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { - if (!XGI_DisableChISLCD(pVBInfo)) { - if (XGI_EnableChISLCD(pVBInfo) || + if (!XGI_EnableChISLCD(pVBInfo, false)) { + if (XGI_EnableChISLCD(pVBInfo, true) || (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) /* LVDS PLL power on */ @@ -5854,8 +5651,7 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, /* enable CRT2 */ xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); - tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, - 0x2E); + tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); if (!(tempah & 0x80)) xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); @@ -5947,7 +5743,6 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, unsigned short ModeIdIndex; struct vb_device_info VBINF; struct vb_device_info *pVBInfo = &VBINF; - pVBInfo->BaseAddr = xgifb_info->vga_base; pVBInfo->IF_DEF_LVDS = 0; if (HwDeviceExtension->jChipType >= XG20) { @@ -5961,24 +5756,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, pVBInfo->IF_DEF_CRT2Monitor = 1; } - pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; - pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; - pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; - pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; - pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; - pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; - pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; - pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; - pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; - pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; - pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; - pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; - pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; - pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; - pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; - pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; - pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; - pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; + XGIRegInit(pVBInfo, xgifb_info->vga_base); /* for x86 Linux, XG21 LVDS */ if (HwDeviceExtension->jChipType == XG21) { @@ -6011,7 +5789,8 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); - if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) { + if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || + (!(pVBInfo->VBInfo & SwitchCRT2))) { XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); @@ -6019,24 +5798,11 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, XGI_SetLCDAGroup(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); } - } else if (!(pVBInfo->VBInfo & SwitchCRT2)) { - XGI_SetCRT1Group(xgifb_info, - HwDeviceExtension, ModeNo, - ModeIdIndex, pVBInfo); - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { - XGI_SetLCDAGroup(ModeNo, ModeIdIndex, - HwDeviceExtension, - pVBInfo); - } } if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { switch (HwDeviceExtension->ujVBChipID) { - case VB_CHIP_301: - XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, - pVBInfo); /*add for CRT2 */ - break; - + case VB_CHIP_301: /* fall through */ case VB_CHIP_302: XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, pVBInfo); /*add for CRT2 */ diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index acf6e7f..ae0c18b 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -156,10 +156,9 @@ struct vb_device_info { unsigned short SelectCRT2Rate; void __iomem *FBAddr; - unsigned long BaseAddr; - unsigned char const (*SR15)[8]; - unsigned char const (*CR40)[8]; + unsigned char const (*SR15)[3]; + unsigned char const (*CR40)[3]; struct SiS_MCLKData const *MCLKData; diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 39f528b..b4c05c8 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -4,114 +4,88 @@ static const struct SiS_MCLKData XGI340New_MCLKData[] = { {0x16, 0x01, 0x01, 166}, {0x19, 0x02, 0x01, 124}, {0x7C, 0x08, 0x01, 200}, - {0x79, 0x06, 0x01, 250}, - {0x29, 0x01, 0x81, 301}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166} }; static const struct SiS_MCLKData XGI27New_MCLKData[] = { {0x5c, 0x23, 0x01, 166}, {0x19, 0x02, 0x01, 124}, {0x7C, 0x08, 0x80, 200}, - {0x79, 0x06, 0x80, 250}, - {0x29, 0x01, 0x81, 300}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166} }; const struct XGI_ECLKDataStruct XGI340_ECLKData[] = { {0x5c, 0x23, 0x01, 166}, {0x55, 0x84, 0x01, 123}, {0x7C, 0x08, 0x01, 200}, - {0x79, 0x06, 0x01, 250}, - {0x29, 0x01, 0x81, 301}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166}, - {0x5c, 0x23, 0x01, 166} -}; - -static const unsigned char XG27_SR13[4][8] = { - {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */ - {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */ - {0x32, 0x32, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR18 */ - {0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00} /* SR1B */ -}; - -static const unsigned char XGI340_SR13[4][8] = { - {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */ - {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */ - {0x31, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR18 */ - {0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00} /* SR1B */ -}; - -static const unsigned char XGI340_cr41[24][8] = { - {0x20, 0x50, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */ - {0xc4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */ - {0xc4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */ - {0xb5, 0xa4, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x90, 0x90, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 5 CR68 */ - {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 6 CR69 */ - {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 7 CR6A */ - {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 8 CR6D */ - {0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 9 CR80 */ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 10 CR81 */ - {0x88, 0xa8, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 11 CR82 */ - {0x44, 0x44, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 12 CR85 */ - {0x48, 0x48, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 13 CR86 */ - {0x54, 0x54, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 14 CR90 */ - {0x54, 0x54, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 15 CR91 */ - {0x0a, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 16 CR92 */ - {0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 17 CR93 */ - {0x10, 0x10, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 18 CR94 */ - {0x11, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 19 CR95 */ - {0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 20 CR96 */ - {0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 21 CRC3 */ - {0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 22 CRC4 */ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /* 23 CRC5 */ -}; - -static const unsigned char XGI27_cr41[24][8] = { - {0x20, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */ - {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */ - {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */ - {0xB3, 0x13, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 3 CR40[7], - CR99[2:0], - CR45[3:0]*/ - {0xf0, 0xf5, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 4 CR59 */ - {0x90, 0x90, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 5 CR68 */ - {0x77, 0x67, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 6 CR69 */ - {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 7 CR6A */ - {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 8 CR6D */ - {0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 9 CR80 */ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 10 CR81 */ - {0x88, 0xcc, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 11 CR82 */ - {0x44, 0x88, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 12 CR85 */ - {0x48, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 13 CR86 */ - {0x54, 0x32, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 14 CR90 */ - {0x54, 0x33, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 15 CR91 */ - {0x0a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 16 CR92 */ - {0x44, 0x63, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 17 CR93 */ - {0x10, 0x14, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 18 CR94 */ - {0x11, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 19 CR95 */ - {0x05, 0x22, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 20 CR96 */ - {0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 21 CRC3 */ - {0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 22 CRC4 */ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /* 23 CRC5 */ -}; - -const unsigned char XGI340_CR6B[8][4] = { - {0xaa, 0xaa, 0xaa, 0xaa}, - {0xaa, 0xaa, 0xaa, 0xaa}, - {0xaa, 0xaa, 0xaa, 0xaa}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00} +}; + +static const unsigned char XG27_SR13[4][3] = { + {0x35, 0x45, 0xb1}, /* SR13 */ + {0x41, 0x51, 0x5c}, /* SR14 */ + {0x32, 0x32, 0x42}, /* SR18 */ + {0x03, 0x03, 0x03} /* SR1B */ +}; + +static const unsigned char XGI340_SR13[4][3] = { + {0x35, 0x45, 0xb1}, /* SR13 */ + {0x41, 0x51, 0x5c}, /* SR14 */ + {0x31, 0x42, 0x42}, /* SR18 */ + {0x03, 0x03, 0x03} /* SR1B */ +}; + +static const unsigned char XGI340_cr41[24][3] = { + {0x20, 0x50, 0x60}, /* 0 CR41 */ + {0xc4, 0x40, 0x84}, /* 1 CR8A */ + {0xc4, 0x40, 0x84}, /* 2 CR8B */ + {0xb5, 0xa4, 0xa4}, + {0xf0, 0xf0, 0xf0}, + {0x90, 0x90, 0x24}, /* 5 CR68 */ + {0x77, 0x77, 0x44}, /* 6 CR69 */ + {0x77, 0x77, 0x44}, /* 7 CR6A */ + {0xff, 0xff, 0xff}, /* 8 CR6D */ + {0x55, 0x55, 0x55}, /* 9 CR80 */ + {0x00, 0x00, 0x00}, /* 10 CR81 */ + {0x88, 0xa8, 0x48}, /* 11 CR82 */ + {0x44, 0x44, 0x77}, /* 12 CR85 */ + {0x48, 0x48, 0x88}, /* 13 CR86 */ + {0x54, 0x54, 0x44}, /* 14 CR90 */ + {0x54, 0x54, 0x44}, /* 15 CR91 */ + {0x0a, 0x0a, 0x07}, /* 16 CR92 */ + {0x44, 0x44, 0x44}, /* 17 CR93 */ + {0x10, 0x10, 0x0A}, /* 18 CR94 */ + {0x11, 0x11, 0x0a}, /* 19 CR95 */ + {0x05, 0x05, 0x05}, /* 20 CR96 */ + {0xf0, 0xf0, 0xf0}, /* 21 CRC3 */ + {0x05, 0x00, 0x02}, /* 22 CRC4 */ + {0x00, 0x00, 0x00} /* 23 CRC5 */ +}; + +static const unsigned char XGI27_cr41[24][3] = { + {0x20, 0x40, 0x60}, /* 0 CR41 */ + {0xC4, 0x40, 0x84}, /* 1 CR8A */ + {0xC4, 0x40, 0x84}, /* 2 CR8B */ + {0xB3, 0x13, 0xa4}, /* 3 CR40[7], + CR99[2:0], + CR45[3:0]*/ + {0xf0, 0xf5, 0xf0}, /* 4 CR59 */ + {0x90, 0x90, 0x24}, /* 5 CR68 */ + {0x77, 0x67, 0x44}, /* 6 CR69 */ + {0x77, 0x77, 0x44}, /* 7 CR6A */ + {0xff, 0xff, 0xff}, /* 8 CR6D */ + {0x55, 0x55, 0x55}, /* 9 CR80 */ + {0x00, 0x00, 0x00}, /* 10 CR81 */ + {0x88, 0xcc, 0x48}, /* 11 CR82 */ + {0x44, 0x88, 0x77}, /* 12 CR85 */ + {0x48, 0x88, 0x88}, /* 13 CR86 */ + {0x54, 0x32, 0x44}, /* 14 CR90 */ + {0x54, 0x33, 0x44}, /* 15 CR91 */ + {0x0a, 0x07, 0x07}, /* 16 CR92 */ + {0x44, 0x63, 0x44}, /* 17 CR93 */ + {0x10, 0x14, 0x0A}, /* 18 CR94 */ + {0x11, 0x0B, 0x0C}, /* 19 CR95 */ + {0x05, 0x22, 0x05}, /* 20 CR96 */ + {0xf0, 0xf0, 0x00}, /* 21 CRC3 */ + {0x05, 0x00, 0x02}, /* 22 CRC4 */ + {0x00, 0x00, 0x00} /* 23 CRC5 */ }; /* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */ @@ -195,7 +169,7 @@ const struct XGI_ExtStruct XGI330_EModeIDTable[] = { static const struct SiS_StandTable_S XGI330_StandTable = { /* ExtVGATable */ 0x00, 0x00, 0x00, 0x0000, - {0x01, 0x0f, 0x00, 0x0e}, + {0x21, 0x0f, 0x00, 0x0e}, /* 0x21 = 0x01 | (0x20 = screen off) */ 0x23, {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/drivers/staging/zcache/Kconfig b/drivers/staging/zcache/Kconfig index 4881839..7358270 100644 --- a/drivers/staging/zcache/Kconfig +++ b/drivers/staging/zcache/Kconfig @@ -1,6 +1,6 @@ config ZCACHE bool "Dynamic compression of swap pages and clean pagecache pages" - depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && ZSMALLOC=y + depends on CRYPTO=y && SWAP=y && CLEANCACHE && FRONTSWAP select CRYPTO_LZO default n help @@ -9,3 +9,35 @@ config ZCACHE compression and an in-kernel implementation of transcendent memory to store clean page cache pages and swap in RAM, providing a noticeable reduction in disk I/O. + +config RAMSTER + bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem" + depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE=y + depends on NET + # must ensure struct page is 8-byte aligned + select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT + default n + help + RAMster allows RAM on other machines in a cluster to be utilized + dynamically and symmetrically instead of swapping to a local swap + disk, thus improving performance on memory-constrained workloads + while minimizing total RAM across the cluster. RAMster, like + zcache2, compresses swap pages into local RAM, but then remotifies + the compressed pages to another node in the RAMster cluster. + +# Depends on not-yet-upstreamed mm patches to export end_swap_bio_write and +# __add_to_swap_cache, and implement __swap_writepage (which is swap_writepage +# without the frontswap call. When these are in-tree, the dependency on +# BROKEN can be removed +config ZCACHE_WRITEBACK + bool "Allow compressed swap pages to be writtenback to swap disk" + depends on ZCACHE=y && BROKEN + default n + help + Zcache caches compressed swap pages (and other data) in RAM which + often improves performance by avoiding I/O's due to swapping. + In some workloads with very long-lived large processes, it can + instead reduce performance. Writeback decompresses zcache-compressed + pages (in LRU order) when under memory pressure and writes them to + the backing swap disk to ameliorate this problem. Policy driving + writeback is still under development. diff --git a/drivers/staging/zcache/Makefile b/drivers/staging/zcache/Makefile index 60daa27..4711049 100644 --- a/drivers/staging/zcache/Makefile +++ b/drivers/staging/zcache/Makefile @@ -1,3 +1,6 @@ -zcache-y := zcache-main.o tmem.o +zcache-y := zcache-main.o tmem.o zbud.o +zcache-$(CONFIG_RAMSTER) += ramster/ramster.o ramster/r2net.o +zcache-$(CONFIG_RAMSTER) += ramster/nodemanager.o ramster/tcp.o +zcache-$(CONFIG_RAMSTER) += ramster/heartbeat.o ramster/masklog.o obj-$(CONFIG_ZCACHE) += zcache.o diff --git a/drivers/staging/zcache/TODO b/drivers/staging/zcache/TODO new file mode 100644 index 0000000..c1e26d4 --- /dev/null +++ b/drivers/staging/zcache/TODO @@ -0,0 +1,69 @@ + +** ZCACHE PLAN FOR PROMOTION FROM STAGING ** + +Last updated: Feb 13, 2013 + +PLAN STEPS + +1. merge zcache and ramster to eliminate horrible code duplication +2. converge on a predictable, writeback-capable allocator +3. use debugfs instead of sysfs (per akpm feedback in 2011) +4. zcache side of cleancache/mm WasActive patch +5. zcache side of frontswap exclusive gets +6. zcache must be able to writeback to physical swap disk + (per Andrea Arcangeli feedback in 2011) +7. implement adequate policy for writeback +8. frontswap/cleancache work to allow zcache to be loaded + as a module +9. get core mm developer to review +10. incorporate feedback from review +11. get review/acks from 1-2 additional mm developers +12. incorporate any feedback from additional mm reviews +13. propose location/file-naming in mm tree +14. repeat 9-13 as necessary until akpm is happy and merges + +STATUS/OWNERSHIP + +1. DONE as part of "new" zcache; in staging/zcache for 3.9 +2. DONE as part of "new" zcache (cf zbud.[ch]); in staging/zcache for 3.9 + (this was the core of the zcache1 vs zcache2 flail) +3. DONE as part of "new" zcache; in staging/zcache for 3.9 +4. DONE (w/caveats) as part of "new" zcache; per cleancache performance + feedback see https://lkml.org/lkml/2011/8/17/351, in + staging/zcache for 3.9; dependent on proposed mm patch, see + https://lkml.org/lkml/2012/1/25/300 +5. DONE as part of "new" zcache; performance tuning only, + in staging/zcache for 3.9; dependent on frontswap patch + merged in 3.7 (33c2a174) +6. DONE (w/caveats), prototyped as part of "new" zcache, had + bad memory leak; reimplemented to use sjennings clever tricks + and proposed mm patches with new version in staging/zcache + for 3.9, see https://lkml.org/lkml/2013/2/6/437; +7. PROTOTYPED as part of "new" zcache; in staging/zcache for 3.9; + needs more review (plan to discuss at LSF/MM 2013) +8. IN PROGRESS; owned by Konrad Wilk; v2 recently posted + http://lkml.org/lkml/2013/2/1/542 +9. IN PROGRESS; owned by Konrad Wilk; Mel Gorman provided + great feedback in August 2012 (unfortunately of "old" + zcache) +10. Konrad posted series of fixes (that now need rebasing) + https://lkml.org/lkml/2013/2/1/566 +11. NOT DONE; owned by Konrad Wilk +12. TBD (depends on quantity of feedback) +13. PROPOSED; one suggestion proposed by Dan; needs more ideas/feedback +14. TBD (depends on feedback) + +WHO NEEDS TO AGREE + +Not sure. Seth Jennings is now pursuing a separate but semi-parallel +track. Akpm clearly has to approve for any mm merge to happen. Minchan +Kim has interest but may be happy if/when zram is merged into mm. Konrad +Wilk may be maintainer if akpm decides compression is maintainable +separately from the rest of mm. (More LSF/MM 2013 discussion.) + +ZCACHE FUTURE NEW FUNCTIONALITY + +A. Support zsmalloc as an alternative high-density allocator + (See https://lkml.org/lkml/2013/1/23/511) +B. Support zero-filled pages more efficiently +C. Possibly support three zbuds per pageframe when space allows diff --git a/drivers/staging/ramster/ramster.h b/drivers/staging/zcache/ramster.h index 1b71aea..1b71aea 100644 --- a/drivers/staging/ramster/ramster.h +++ b/drivers/staging/zcache/ramster.h diff --git a/drivers/staging/ramster/ramster/heartbeat.c b/drivers/staging/zcache/ramster/heartbeat.c index 75d3fe8..75d3fe8 100644 --- a/drivers/staging/ramster/ramster/heartbeat.c +++ b/drivers/staging/zcache/ramster/heartbeat.c diff --git a/drivers/staging/ramster/ramster/heartbeat.h b/drivers/staging/zcache/ramster/heartbeat.h index 6cbc775..6cbc775 100644 --- a/drivers/staging/ramster/ramster/heartbeat.h +++ b/drivers/staging/zcache/ramster/heartbeat.h diff --git a/drivers/staging/ramster/ramster/masklog.c b/drivers/staging/zcache/ramster/masklog.c index 1261d85..1261d85 100644 --- a/drivers/staging/ramster/ramster/masklog.c +++ b/drivers/staging/zcache/ramster/masklog.c diff --git a/drivers/staging/ramster/ramster/masklog.h b/drivers/staging/zcache/ramster/masklog.h index 918ae11..918ae11 100644 --- a/drivers/staging/ramster/ramster/masklog.h +++ b/drivers/staging/zcache/ramster/masklog.h diff --git a/drivers/staging/ramster/ramster/nodemanager.c b/drivers/staging/zcache/ramster/nodemanager.c index c0f4815..c0f4815 100644 --- a/drivers/staging/ramster/ramster/nodemanager.c +++ b/drivers/staging/zcache/ramster/nodemanager.c diff --git a/drivers/staging/ramster/ramster/nodemanager.h b/drivers/staging/zcache/ramster/nodemanager.h index 41a04df..41a04df 100644 --- a/drivers/staging/ramster/ramster/nodemanager.h +++ b/drivers/staging/zcache/ramster/nodemanager.h diff --git a/drivers/staging/ramster/ramster/r2net.c b/drivers/staging/zcache/ramster/r2net.c index 34818dc..34818dc 100644 --- a/drivers/staging/ramster/ramster/r2net.c +++ b/drivers/staging/zcache/ramster/r2net.c diff --git a/drivers/staging/ramster/ramster/ramster.c b/drivers/staging/zcache/ramster/ramster.c index c06709f..bf96a1c 100644 --- a/drivers/staging/ramster/ramster/ramster.c +++ b/drivers/staging/zcache/ramster/ramster.c @@ -67,25 +67,25 @@ static int ramster_remote_target_nodenum __read_mostly = -1; static long ramster_flnodes; static atomic_t ramster_flnodes_atomic = ATOMIC_INIT(0); static unsigned long ramster_flnodes_max; -static long ramster_foreign_eph_pages; +static ssize_t ramster_foreign_eph_pages; static atomic_t ramster_foreign_eph_pages_atomic = ATOMIC_INIT(0); -static unsigned long ramster_foreign_eph_pages_max; -static long ramster_foreign_pers_pages; +static ssize_t ramster_foreign_eph_pages_max; +static ssize_t ramster_foreign_pers_pages; static atomic_t ramster_foreign_pers_pages_atomic = ATOMIC_INIT(0); -static unsigned long ramster_foreign_pers_pages_max; -static unsigned long ramster_eph_pages_remoted; -static unsigned long ramster_pers_pages_remoted; -static unsigned long ramster_eph_pages_remote_failed; -static unsigned long ramster_pers_pages_remote_failed; -static unsigned long ramster_remote_eph_pages_succ_get; -static unsigned long ramster_remote_pers_pages_succ_get; -static unsigned long ramster_remote_eph_pages_unsucc_get; -static unsigned long ramster_remote_pers_pages_unsucc_get; -static unsigned long ramster_pers_pages_remote_nomem; -static unsigned long ramster_remote_objects_flushed; -static unsigned long ramster_remote_object_flushes_failed; -static unsigned long ramster_remote_pages_flushed; -static unsigned long ramster_remote_page_flushes_failed; +static ssize_t ramster_foreign_pers_pages_max; +static ssize_t ramster_eph_pages_remoted; +static ssize_t ramster_pers_pages_remoted; +static ssize_t ramster_eph_pages_remote_failed; +static ssize_t ramster_pers_pages_remote_failed; +static ssize_t ramster_remote_eph_pages_succ_get; +static ssize_t ramster_remote_pers_pages_succ_get; +static ssize_t ramster_remote_eph_pages_unsucc_get; +static ssize_t ramster_remote_pers_pages_unsucc_get; +static ssize_t ramster_pers_pages_remote_nomem; +static ssize_t ramster_remote_objects_flushed; +static ssize_t ramster_remote_object_flushes_failed; +static ssize_t ramster_remote_pages_flushed; +static ssize_t ramster_remote_page_flushes_failed; /* FIXME frontswap selfshrinking knobs in debugfs? */ #ifdef CONFIG_DEBUG_FS diff --git a/drivers/staging/ramster/ramster/ramster.h b/drivers/staging/zcache/ramster/ramster.h index 12ae56f..12ae56f 100644 --- a/drivers/staging/ramster/ramster/ramster.h +++ b/drivers/staging/zcache/ramster/ramster.h diff --git a/drivers/staging/ramster/ramster/ramster_nodemanager.h b/drivers/staging/zcache/ramster/ramster_nodemanager.h index 49f879d..49f879d 100644 --- a/drivers/staging/ramster/ramster/ramster_nodemanager.h +++ b/drivers/staging/zcache/ramster/ramster_nodemanager.h diff --git a/drivers/staging/ramster/ramster/tcp.c b/drivers/staging/zcache/ramster/tcp.c index aa2a1a7..aa2a1a7 100644 --- a/drivers/staging/ramster/ramster/tcp.c +++ b/drivers/staging/zcache/ramster/tcp.c diff --git a/drivers/staging/ramster/ramster/tcp.h b/drivers/staging/zcache/ramster/tcp.h index 9d05833..9d05833 100644 --- a/drivers/staging/ramster/ramster/tcp.h +++ b/drivers/staging/zcache/ramster/tcp.h diff --git a/drivers/staging/ramster/ramster/tcp_internal.h b/drivers/staging/zcache/ramster/tcp_internal.h index 4d8cc9f..4d8cc9f 100644 --- a/drivers/staging/ramster/ramster/tcp_internal.h +++ b/drivers/staging/zcache/ramster/tcp_internal.h diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c index 56c8e60..a2b7e03 100644 --- a/drivers/staging/zcache/tmem.c +++ b/drivers/staging/zcache/tmem.c @@ -1,32 +1,43 @@ /* * In-kernel transcendent memory (generic implementation) * - * Copyright (c) 2009-2011, Dan Magenheimer, Oracle Corp. + * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. * - * The primary purpose of Transcendent Memory ("tmem") is to map object-oriented + * The primary purpose of Transcedent Memory ("tmem") is to map object-oriented * "handles" (triples containing a pool id, and object id, and an index), to * pages in a page-accessible memory (PAM). Tmem references the PAM pages via * an abstract "pampd" (PAM page-descriptor), which can be operated on by a * set of functions (pamops). Each pampd contains some representation of - * PAGE_SIZE bytes worth of data. Tmem must support potentially millions of - * pages and must be able to insert, find, and delete these pages at a - * potential frequency of thousands per second concurrently across many CPUs, - * (and, if used with KVM, across many vcpus across many guests). - * Tmem is tracked with a hierarchy of data structures, organized by - * the elements in a handle-tuple: pool_id, object_id, and page index. - * One or more "clients" (e.g. guests) each provide one or more tmem_pools. - * Each pool, contains a hash table of rb_trees of tmem_objs. Each - * tmem_obj contains a radix-tree-like tree of pointers, with intermediate - * nodes called tmem_objnodes. Each leaf pointer in this tree points to - * a pampd, which is accessible only through a small set of callbacks - * registered by the PAM implementation (see tmem_register_pamops). Tmem - * does all memory allocation via a set of callbacks registered by the tmem - * host implementation (e.g. see tmem_register_hostops). + * PAGE_SIZE bytes worth of data. For those familiar with key-value stores, + * the tmem handle is a three-level hierarchical key, and the value is always + * reconstituted (but not necessarily stored) as PAGE_SIZE bytes and is + * referenced in the datastore by the pampd. The hierarchy is required + * to ensure that certain invalidation functions can be performed efficiently + * (i.e. flush all indexes associated with this object_id, or + * flush all objects associated with this pool). + * + * Tmem must support potentially millions of pages and must be able to insert, + * find, and delete these pages at a potential frequency of thousands per + * second concurrently across many CPUs, (and, if used with KVM, across many + * vcpus across many guests). Tmem is tracked with a hierarchy of data + * structures, organized by the elements in the handle-tuple: pool_id, + * object_id, and page index. One or more "clients" (e.g. guests) each + * provide one or more tmem_pools. Each pool, contains a hash table of + * rb_trees of tmem_objs. Each tmem_obj contains a radix-tree-like tree + * of pointers, with intermediate nodes called tmem_objnodes. Each leaf + * pointer in this tree points to a pampd, which is accessible only through + * a small set of callbacks registered by the PAM implementation (see + * tmem_register_pamops). Tmem only needs to memory allocation for objs + * and objnodes and this is done via a set of callbacks that must be + * registered by the tmem host implementation (e.g. see tmem_register_hostops). */ #include <linux/list.h> #include <linux/spinlock.h> #include <linux/atomic.h> +#ifdef CONFIG_RAMSTER +#include <linux/delay.h> +#endif #include "tmem.h" @@ -51,7 +62,7 @@ void tmem_register_hostops(struct tmem_hostops *m) /* * A tmem host implementation must use this function to register - * callbacks for a page-accessible memory (PAM) implementation + * callbacks for a page-accessible memory (PAM) implementation. */ static struct tmem_pamops tmem_pamops; @@ -66,15 +77,22 @@ void tmem_register_pamops(struct tmem_pamops *m) * So an rb_tree is an ideal data structure to manage tmem_objs. But because * of the potentially huge number of tmem_objs, each pool manages a hashtable * of rb_trees to reduce search, insert, delete, and rebalancing time. - * Each hashbucket also has a lock to manage concurrent access. + * Each hashbucket also has a lock to manage concurrent access and no + * searches, inserts, or deletions can be performed unless the lock is held. + * As a result, care must be taken to ensure tmem routines are not called + * recursively; the vast majority of the time, a recursive call may work + * but a deadlock will occur a small fraction of the time due to the + * hashbucket lock. * - * The following routines manage tmem_objs. When any tmem_obj is accessed, - * the hashbucket lock must be held. + * The following routines manage tmem_objs. In all of these routines, + * the hashbucket lock is already held. */ -static struct tmem_obj -*__tmem_obj_find(struct tmem_hashbucket*hb, struct tmem_oid *oidp, - struct rb_node **parent, struct rb_node ***link) +/* Search for object==oid in pool, returns object if found. */ +static struct tmem_obj *__tmem_obj_find(struct tmem_hashbucket *hb, + struct tmem_oid *oidp, + struct rb_node **parent, + struct rb_node ***link) { struct rb_node *_parent = NULL, **rbnode; struct tmem_obj *obj = NULL; @@ -101,23 +119,20 @@ static struct tmem_obj *parent = _parent; if (link) *link = rbnode; - obj = NULL; out: return obj; } - -/* searches for object==oid in pool, returns locked object if found */ static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb, struct tmem_oid *oidp) { return __tmem_obj_find(hb, oidp, NULL, NULL); } -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *); +static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *, bool); -/* free an object that has no more pampds in it */ +/* Free an object that has no more pampds in it. */ static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb) { struct tmem_pool *pool; @@ -128,7 +143,7 @@ static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb) pool = obj->pool; BUG_ON(pool == NULL); if (obj->objnode_tree_root != NULL) /* may be "stump" with no leaves */ - tmem_pampd_destroy_all_in_obj(obj); + tmem_pampd_destroy_all_in_obj(obj, false); BUG_ON(obj->objnode_tree_root != NULL); BUG_ON((long)obj->objnode_count != 0); atomic_dec(&pool->obj_count); @@ -140,7 +155,7 @@ static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb) } /* - * initialize, and insert an tmem_object_root (called only if find failed) + * Initialize, and insert an tmem_object_root (called only if find failed). */ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, struct tmem_pool *pool, @@ -157,7 +172,10 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, obj->oid = *oidp; obj->objnode_count = 0; obj->pampd_count = 0; - (*tmem_pamops.new_obj)(obj); +#ifdef CONFIG_RAMSTER + if (tmem_pamops.new_obj != NULL) + (*tmem_pamops.new_obj)(obj); +#endif SET_SENTINEL(obj, OBJ); if (__tmem_obj_find(hb, oidp, &parent, &new)) @@ -172,7 +190,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, * "ephemeral" vs "persistent". These attributes apply to all tmem_objs * and all pampds that belong to a tmem_pool. A tmem_pool is created * or deleted relatively rarely (for example, when a filesystem is - * mounted or unmounted. + * mounted or unmounted). */ /* flush all data from a pool and, optionally, free it */ @@ -190,7 +208,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy) while (rbnode != NULL) { obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node); rbnode = rb_next(rbnode); - tmem_pampd_destroy_all_in_obj(obj); + tmem_pampd_destroy_all_in_obj(obj, true); tmem_obj_free(obj, hb); (*tmem_hostops.obj_free)(obj, pool); } @@ -276,7 +294,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode) } /* - * lookup index in object and return associated pampd (or NULL if not found) + * Lookup index in object and return associated pampd (or NULL if not found). */ static void **__tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) { @@ -318,8 +336,9 @@ static void *tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) return slot != NULL ? *slot : NULL; } +#ifdef CONFIG_RAMSTER static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index, - void *new_pampd) + void *new_pampd, bool no_free) { struct tmem_objnode **slot; void *ret = NULL; @@ -328,11 +347,14 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index, if ((slot != NULL) && (*slot != NULL)) { void *old_pampd = *(void **)slot; *(void **)slot = new_pampd; - (*tmem_pamops.free)(old_pampd, obj->pool, NULL, 0); + if (!no_free) + (*tmem_pamops.free)(old_pampd, obj->pool, + NULL, 0, false); ret = new_pampd; } return ret; } +#endif static int tmem_pampd_add_to_obj(struct tmem_obj *obj, uint32_t index, void *pampd) @@ -470,7 +492,7 @@ out: return slot; } -/* recursively walk the objnode_tree destroying pampds and objnodes */ +/* Recursively walk the objnode_tree destroying pampds and objnodes. */ static void tmem_objnode_node_destroy(struct tmem_obj *obj, struct tmem_objnode *objnode, unsigned int ht) @@ -484,7 +506,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj, if (ht == 1) { obj->pampd_count--; (*tmem_pamops.free)(objnode->slots[i], - obj->pool, NULL, 0); + obj->pool, NULL, 0, true); objnode->slots[i] = NULL; continue; } @@ -495,13 +517,15 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj, } } -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj) +static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj, + bool pool_destroy) { if (obj->objnode_tree_root == NULL) return; if (obj->objnode_tree_height == 0) { obj->pampd_count--; - (*tmem_pamops.free)(obj->objnode_tree_root, obj->pool, NULL, 0); + (*tmem_pamops.free)(obj->objnode_tree_root, + obj->pool, NULL, 0, true); } else { tmem_objnode_node_destroy(obj, obj->objnode_tree_root, obj->objnode_tree_height); @@ -509,7 +533,10 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj) obj->objnode_tree_height = 0; } obj->objnode_tree_root = NULL; - (*tmem_pamops.free_obj)(obj->pool, obj); +#ifdef CONFIG_RAMSTER + if (tmem_pamops.free_obj != NULL) + (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy); +#endif } /* @@ -522,17 +549,16 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj) */ /* - * "Put" a page, e.g. copy a page from the kernel into newly allocated - * PAM space (if such space is available). Tmem_put is complicated by - * a corner case: What if a page with matching handle already exists in - * tmem? To guarantee coherency, one of two actions is necessary: Either - * the data for the page must be overwritten, or the page must be - * "flushed" so that the data is not accessible to a subsequent "get". - * Since these "duplicate puts" are relatively rare, this implementation - * always flushes for simplicity. + * "Put" a page, e.g. associate the passed pampd with the passed handle. + * Tmem_put is complicated by a corner case: What if a page with matching + * handle already exists in tmem? To guarantee coherency, one of two + * actions is necessary: Either the data for the page must be overwritten, + * or the page must be "flushed" so that the data is not accessible to a + * subsequent "get". Since these "duplicate puts" are relatively rare, + * this implementation always flushes for simplicity. */ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - char *data, size_t size, bool raw, bool ephemeral) + bool raw, void *pampd_to_use) { struct tmem_obj *obj = NULL, *objfound = NULL, *objnew = NULL; void *pampd = NULL, *pampd_del = NULL; @@ -548,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, /* if found, is a dup put, flush the old one */ pampd_del = tmem_pampd_delete_from_obj(obj, index); BUG_ON(pampd_del != pampd); - (*tmem_pamops.free)(pampd, pool, oidp, index); + (*tmem_pamops.free)(pampd, pool, oidp, index, true); if (obj->pampd_count == 0) { objnew = obj; objfound = NULL; @@ -565,21 +591,19 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, } BUG_ON(obj == NULL); BUG_ON(((objnew != obj) && (objfound != obj)) || (objnew == objfound)); - pampd = (*tmem_pamops.create)(data, size, raw, ephemeral, - obj->pool, &obj->oid, index); - if (unlikely(pampd == NULL)) - goto free; + pampd = pampd_to_use; + BUG_ON(pampd_to_use == NULL); ret = tmem_pampd_add_to_obj(obj, index, pampd); if (unlikely(ret == -ENOMEM)) /* may have partially built objnode tree ("stump") */ goto delete_and_free; + (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool)); goto out; delete_and_free: (void)tmem_pampd_delete_from_obj(obj, index); -free: if (pampd) - (*tmem_pamops.free)(pampd, pool, NULL, 0); + (*tmem_pamops.free)(pampd, pool, NULL, 0, true); if (objnew) { tmem_obj_free(objnew, hb); (*tmem_hostops.obj_free)(objnew, pool); @@ -589,35 +613,160 @@ out: return ret; } +#ifdef CONFIG_RAMSTER +/* + * For ramster only: The following routines provide a two-step sequence + * to allow the caller to replace a pampd in the tmem data structures with + * another pampd. Here, we lookup the passed handle and, if found, return the + * associated pampd and object, leaving the hashbucket locked and returning + * a reference to it. The caller is expected to immediately call the + * matching tmem_localify_finish routine which will handles the replacement + * and unlocks the hashbucket. + */ +void *tmem_localify_get_pampd(struct tmem_pool *pool, struct tmem_oid *oidp, + uint32_t index, struct tmem_obj **ret_obj, + void **saved_hb) +{ + struct tmem_hashbucket *hb; + struct tmem_obj *obj = NULL; + void *pampd = NULL; + + hb = &pool->hashbucket[tmem_oid_hash(oidp)]; + spin_lock(&hb->lock); + obj = tmem_obj_find(hb, oidp); + if (likely(obj != NULL)) + pampd = tmem_pampd_lookup_in_obj(obj, index); + *ret_obj = obj; + *saved_hb = (void *)hb; + /* note, hashbucket remains locked */ + return pampd; +} + +void tmem_localify_finish(struct tmem_obj *obj, uint32_t index, + void *pampd, void *saved_hb, bool delete) +{ + struct tmem_hashbucket *hb = (struct tmem_hashbucket *)saved_hb; + + BUG_ON(!spin_is_locked(&hb->lock)); + if (pampd != NULL) { + BUG_ON(obj == NULL); + (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1); + (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool)); + } else if (delete) { + BUG_ON(obj == NULL); + (void)tmem_pampd_delete_from_obj(obj, index); + } + spin_unlock(&hb->lock); +} + +/* + * For ramster only. Helper function to support asynchronous tmem_get. + */ +static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb, + struct tmem_pool *pool, struct tmem_oid *oidp, + uint32_t index, bool free, char *data) +{ + void *old_pampd = *ppampd, *new_pampd = NULL; + bool intransit = false; + int ret = 0; + + if (!is_ephemeral(pool)) + new_pampd = (*tmem_pamops.repatriate_preload)( + old_pampd, pool, oidp, index, &intransit); + if (intransit) + ret = -EAGAIN; + else if (new_pampd != NULL) + *ppampd = new_pampd; + /* must release the hb->lock else repatriate can't sleep */ + spin_unlock(&hb->lock); + if (!intransit) + ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool, + oidp, index, free, data); + if (ret == -EAGAIN) { + /* rare I think, but should cond_resched()??? */ + usleep_range(10, 1000); + } else if (ret == -ENOTCONN || ret == -EHOSTDOWN) { + ret = -1; + } else if (ret != 0 && ret != -ENOENT) { + ret = -1; + } + /* note hb->lock has now been unlocked */ + return ret; +} + /* - * "Get" a page, e.g. if one can be found, copy the tmem page with the - * matching handle from PAM space to the kernel. By tmem definition, - * when a "get" is successful on an ephemeral page, the page is "flushed", - * and when a "get" is successful on a persistent page, the page is retained - * in tmem. Note that to preserve + * For ramster only. If a page in tmem matches the handle, replace the + * page so that any subsequent "get" gets the new page. Returns 0 if + * there was a page to replace, else returns -1. + */ +int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp, + uint32_t index, void *new_pampd) +{ + struct tmem_obj *obj; + int ret = -1; + struct tmem_hashbucket *hb; + + hb = &pool->hashbucket[tmem_oid_hash(oidp)]; + spin_lock(&hb->lock); + obj = tmem_obj_find(hb, oidp); + if (obj == NULL) + goto out; + new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0); + /* if we bug here, pamops wasn't properly set up for ramster */ + BUG_ON(tmem_pamops.replace_in_obj == NULL); + ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj); +out: + spin_unlock(&hb->lock); + return ret; +} +#endif + +/* + * "Get" a page, e.g. if a pampd can be found matching the passed handle, + * use a pamops callback to recreated the page from the pampd with the + * matching handle. By tmem definition, when a "get" is successful on + * an ephemeral page, the page is "flushed", and when a "get" is successful + * on a persistent page, the page is retained in tmem. Note that to preserve * coherency, "get" can never be skipped if tmem contains the data. * That is, if a get is done with a certain handle and fails, any * subsequent "get" must also fail (unless of course there is a * "put" done with the same handle). - */ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - char *data, size_t *size, bool raw, int get_and_free) + char *data, size_t *sizep, bool raw, int get_and_free) { struct tmem_obj *obj; - void *pampd; + void *pampd = NULL; bool ephemeral = is_ephemeral(pool); int ret = -1; struct tmem_hashbucket *hb; bool free = (get_and_free == 1) || ((get_and_free == 0) && ephemeral); bool lock_held = false; + void **ppampd; - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - lock_held = true; - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; + do { + hb = &pool->hashbucket[tmem_oid_hash(oidp)]; + spin_lock(&hb->lock); + lock_held = true; + obj = tmem_obj_find(hb, oidp); + if (obj == NULL) + goto out; + ppampd = __tmem_pampd_lookup_in_obj(obj, index); + if (ppampd == NULL) + goto out; +#ifdef CONFIG_RAMSTER + if ((tmem_pamops.is_remote != NULL) && + tmem_pamops.is_remote(*ppampd)) { + ret = tmem_repatriate(ppampd, hb, pool, oidp, + index, free, data); + /* tmem_repatriate releases hb->lock */ + lock_held = false; + *sizep = PAGE_SIZE; + if (ret != -EAGAIN) + goto out; + } +#endif + } while (ret == -EAGAIN); if (free) pampd = tmem_pampd_delete_from_obj(obj, index); else @@ -631,16 +780,12 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, obj = NULL; } } - if (tmem_pamops.is_remote(pampd)) { - lock_held = false; - spin_unlock(&hb->lock); - } if (free) ret = (*tmem_pamops.get_data_and_free)( - data, size, raw, pampd, pool, oidp, index); + data, sizep, raw, pampd, pool, oidp, index); else ret = (*tmem_pamops.get_data)( - data, size, raw, pampd, pool, oidp, index); + data, sizep, raw, pampd, pool, oidp, index); if (ret < 0) goto out; ret = 0; @@ -671,7 +816,7 @@ int tmem_flush_page(struct tmem_pool *pool, pampd = tmem_pampd_delete_from_obj(obj, index); if (pampd == NULL) goto out; - (*tmem_pamops.free)(pampd, pool, oidp, index); + (*tmem_pamops.free)(pampd, pool, oidp, index, true); if (obj->pampd_count == 0) { tmem_obj_free(obj, hb); (*tmem_hostops.obj_free)(obj, pool); @@ -684,30 +829,6 @@ out: } /* - * If a page in tmem matches the handle, replace the page so that any - * subsequent "get" gets the new page. Returns 0 if - * there was a page to replace, else returns -1. - */ -int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, void *new_pampd) -{ - struct tmem_obj *obj; - int ret = -1; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd); - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj); -out: - spin_unlock(&hb->lock); - return ret; -} - -/* * "Flush" all pages in tmem matching this oid. */ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp) @@ -721,7 +842,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp) obj = tmem_obj_find(hb, oidp); if (obj == NULL) goto out; - tmem_pampd_destroy_all_in_obj(obj); + tmem_pampd_destroy_all_in_obj(obj, false); tmem_obj_free(obj, hb); (*tmem_hostops.obj_free)(obj, pool); ret = 0; diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h index 0d4aa82..adbe5a8 100644 --- a/drivers/staging/zcache/tmem.h +++ b/drivers/staging/zcache/tmem.h @@ -3,7 +3,7 @@ * * Transcendent memory * - * Copyright (c) 2009-2011, Dan Magenheimer, Oracle Corp. + * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. */ #ifndef _TMEM_H_ @@ -15,12 +15,8 @@ #include <linux/atomic.h> /* - * These are pre-defined by the Xen<->Linux ABI + * These are defined by the Xen<->Linux ABI so should remain consistent */ -#define TMEM_PUT_PAGE 4 -#define TMEM_GET_PAGE 5 -#define TMEM_FLUSH_PAGE 6 -#define TMEM_FLUSH_OBJECT 7 #define TMEM_POOL_PERSIST 1 #define TMEM_POOL_SHARED 2 #define TMEM_POOL_PRECOMPRESSED 4 @@ -32,7 +28,7 @@ * sentinels have proven very useful for debugging but can be removed * or disabled before final merge. */ -#define SENTINELS +#undef SENTINELS #ifdef SENTINELS #define DECL_SENTINEL uint32_t sentinel; #define SET_SENTINEL(_x, _y) (_x->sentinel = _y##_SENTINEL) @@ -130,6 +126,34 @@ static inline unsigned tmem_oid_hash(struct tmem_oid *oidp) TMEM_HASH_BUCKET_BITS); } +#ifdef CONFIG_RAMSTER +struct tmem_xhandle { + uint8_t client_id; + uint8_t xh_data_cksum; + uint16_t xh_data_size; + uint16_t pool_id; + struct tmem_oid oid; + uint32_t index; + void *extra; +}; + +static inline struct tmem_xhandle tmem_xhandle_fill(uint16_t client_id, + struct tmem_pool *pool, + struct tmem_oid *oidp, + uint32_t index) +{ + struct tmem_xhandle xh; + xh.client_id = client_id; + xh.xh_data_cksum = (uint8_t)-1; + xh.xh_data_size = (uint16_t)-1; + xh.pool_id = pool->pool_id; + xh.oid = *oidp; + xh.index = index; + return xh; +} +#endif + + /* * A tmem_obj contains an identifier (oid), pointers to the parent * pool and the rb_tree to which it belongs, counters, and an ordered @@ -147,7 +171,15 @@ struct tmem_obj { unsigned int objnode_tree_height; unsigned long objnode_count; long pampd_count; +#ifdef CONFIG_RAMSTER + /* + * for current design of ramster, all pages belonging to + * an object reside on the same remotenode and extra is + * used to record the number of the remotenode so a + * flush-object operation can specify it + */ void *extra; /* for private use by pampd implementation */ +#endif DECL_SENTINEL }; @@ -165,20 +197,34 @@ struct tmem_objnode { unsigned int slots_in_use; }; +struct tmem_handle { + struct tmem_oid oid; /* 24 bytes */ + uint32_t index; + uint16_t pool_id; + uint16_t client_id; +}; + + /* pampd abstract datatype methods provided by the PAM implementation */ struct tmem_pamops { - void *(*create)(char *, size_t, bool, int, - struct tmem_pool *, struct tmem_oid *, uint32_t); + void (*create_finish)(void *, bool); int (*get_data)(char *, size_t *, bool, void *, struct tmem_pool *, struct tmem_oid *, uint32_t); int (*get_data_and_free)(char *, size_t *, bool, void *, struct tmem_pool *, struct tmem_oid *, uint32_t); - void (*free)(void *, struct tmem_pool *, struct tmem_oid *, uint32_t); - void (*free_obj)(struct tmem_pool *, struct tmem_obj *); - bool (*is_remote)(void *); + void (*free)(void *, struct tmem_pool *, + struct tmem_oid *, uint32_t, bool); +#ifdef CONFIG_RAMSTER void (*new_obj)(struct tmem_obj *); + void (*free_obj)(struct tmem_pool *, struct tmem_obj *, bool); + void *(*repatriate_preload)(void *, struct tmem_pool *, + struct tmem_oid *, uint32_t, bool *); + int (*repatriate)(void *, void *, struct tmem_pool *, + struct tmem_oid *, uint32_t, bool, void *); + bool (*is_remote)(void *); int (*replace_in_obj)(void *, struct tmem_obj *); +#endif }; extern void tmem_register_pamops(struct tmem_pamops *m); @@ -193,14 +239,21 @@ extern void tmem_register_hostops(struct tmem_hostops *m); /* core tmem accessor functions */ extern int tmem_put(struct tmem_pool *, struct tmem_oid *, uint32_t index, - char *, size_t, bool, bool); + bool, void *); extern int tmem_get(struct tmem_pool *, struct tmem_oid *, uint32_t index, char *, size_t *, bool, int); -extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index, - void *); extern int tmem_flush_page(struct tmem_pool *, struct tmem_oid *, uint32_t index); extern int tmem_flush_object(struct tmem_pool *, struct tmem_oid *); extern int tmem_destroy_pool(struct tmem_pool *); extern void tmem_new_pool(struct tmem_pool *, uint32_t); +#ifdef CONFIG_RAMSTER +extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index, + void *); +extern void *tmem_localify_get_pampd(struct tmem_pool *, struct tmem_oid *, + uint32_t index, struct tmem_obj **, + void **); +extern void tmem_localify_finish(struct tmem_obj *, uint32_t index, + void *, void *, bool); +#endif #endif /* _TMEM_H */ diff --git a/drivers/staging/ramster/zbud.c b/drivers/staging/zcache/zbud.c index a7c4361..328c397 100644 --- a/drivers/staging/ramster/zbud.c +++ b/drivers/staging/zcache/zbud.c @@ -103,8 +103,8 @@ struct zbudpage { struct { unsigned long space_for_flags; struct { - unsigned zbud0_size:12; - unsigned zbud1_size:12; + unsigned zbud0_size:PAGE_SHIFT; + unsigned zbud1_size:PAGE_SHIFT; unsigned unevictable:2; }; struct list_head budlist; @@ -112,6 +112,9 @@ struct zbudpage { }; }; }; +#if (PAGE_SHIFT * 2) + 2 > BITS_PER_LONG +#error "zbud won't work for this arch, PAGE_SIZE is too large" +#endif struct zbudref { union { @@ -278,26 +281,26 @@ static inline char *zbud_data(void *zbpg, * debugfs viewers, some of these should also be atomic_long_t, but * I don't know how to expose atomics via debugfs either... */ -static unsigned long zbud_eph_pageframes; -static unsigned long zbud_pers_pageframes; -static unsigned long zbud_eph_zpages; -static unsigned long zbud_pers_zpages; +static ssize_t zbud_eph_pageframes; +static ssize_t zbud_pers_pageframes; +static ssize_t zbud_eph_zpages; +static ssize_t zbud_pers_zpages; static u64 zbud_eph_zbytes; static u64 zbud_pers_zbytes; -static unsigned long zbud_eph_evicted_pageframes; -static unsigned long zbud_pers_evicted_pageframes; -static unsigned long zbud_eph_cumul_zpages; -static unsigned long zbud_pers_cumul_zpages; +static ssize_t zbud_eph_evicted_pageframes; +static ssize_t zbud_pers_evicted_pageframes; +static ssize_t zbud_eph_cumul_zpages; +static ssize_t zbud_pers_cumul_zpages; static u64 zbud_eph_cumul_zbytes; static u64 zbud_pers_cumul_zbytes; -static unsigned long zbud_eph_cumul_chunk_counts[NCHUNKS]; -static unsigned long zbud_pers_cumul_chunk_counts[NCHUNKS]; -static unsigned long zbud_eph_buddied_count; -static unsigned long zbud_pers_buddied_count; -static unsigned long zbud_eph_unbuddied_count; -static unsigned long zbud_pers_unbuddied_count; -static unsigned long zbud_eph_zombie_count; -static unsigned long zbud_pers_zombie_count; +static ssize_t zbud_eph_cumul_chunk_counts[NCHUNKS]; +static ssize_t zbud_pers_cumul_chunk_counts[NCHUNKS]; +static ssize_t zbud_eph_buddied_count; +static ssize_t zbud_pers_buddied_count; +static ssize_t zbud_eph_unbuddied_count; +static ssize_t zbud_pers_unbuddied_count; +static ssize_t zbud_eph_zombie_count; +static ssize_t zbud_pers_zombie_count; static atomic_t zbud_eph_zombie_atomic; static atomic_t zbud_pers_zombie_atomic; @@ -1044,7 +1047,7 @@ out: return ret; } -void __init zbud_init(void) +void zbud_init(void) { int i; diff --git a/drivers/staging/ramster/zbud.h b/drivers/staging/zcache/zbud.h index 891e8a7..891e8a7 100644 --- a/drivers/staging/ramster/zbud.h +++ b/drivers/staging/zcache/zbud.h diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index 52b43b7..328898e 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -1,23 +1,15 @@ /* * zcache.c * - * Copyright (c) 2010,2011, Dan Magenheimer, Oracle Corp. + * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. * Copyright (c) 2010,2011, Nitin Gupta * * Zcache provides an in-kernel "host implementation" for transcendent memory - * and, thus indirectly, for cleancache and frontswap. Zcache includes two - * page-accessible memory [1] interfaces, both utilizing the crypto compression - * API: - * 1) "compression buddies" ("zbud") is used for ephemeral pages - * 2) zsmalloc is used for persistent pages. - * Xvmalloc (based on the TLSF allocator) has very low fragmentation - * so maximizes space efficiency, while zbud allows pairs (and potentially, - * in the future, more than a pair of) compressed pages to be closely linked - * so that reclaiming can be done via the kernel's physical-page-oriented - * "shrinker" interface. - * - * [1] For a definition of page-accessible memory (aka PAM), see: - * http://marc.info/?l=linux-mm&m=127811271605009 + * ("tmem") and, thus indirectly, for cleancache and frontswap. Zcache uses + * lzo1x compression to improve density and an embedded allocator called + * "zbud" which "buddies" two compressed pages semi-optimally in each physical + * pageframe. Zbud is integrally tied into tmem to allow pageframes to + * be "reclaimed" efficiently. */ #include <linux/module.h> @@ -30,70 +22,62 @@ #include <linux/atomic.h> #include <linux/math64.h> #include <linux/crypto.h> -#include <linux/string.h> -#include <linux/idr.h> -#include "tmem.h" - -#include "../zsmalloc/zsmalloc.h" +#include <linux/swap.h> +#include <linux/swapops.h> +#include <linux/pagemap.h> +#include <linux/writeback.h> -#ifdef CONFIG_CLEANCACHE #include <linux/cleancache.h> -#endif -#ifdef CONFIG_FRONTSWAP #include <linux/frontswap.h> -#endif - -#if 0 -/* this is more aggressive but may cause other problems? */ -#define ZCACHE_GFP_MASK (GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN) +#include "tmem.h" +#include "zcache.h" +#include "zbud.h" +#include "ramster.h" +#ifdef CONFIG_RAMSTER +static int ramster_enabled; #else -#define ZCACHE_GFP_MASK \ - (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC) +#define ramster_enabled 0 #endif -#define MAX_CLIENTS 16 -#define LOCAL_CLIENT ((uint16_t)-1) - -MODULE_LICENSE("GPL"); - -struct zcache_client { - struct idr tmem_pools; - struct zs_pool *zspool; - bool allocated; - atomic_t refcount; -}; - -static struct zcache_client zcache_host; -static struct zcache_client zcache_clients[MAX_CLIENTS]; - -static inline uint16_t get_client_id_from_client(struct zcache_client *cli) +#ifndef __PG_WAS_ACTIVE +static inline bool PageWasActive(struct page *page) { - BUG_ON(cli == NULL); - if (cli == &zcache_host) - return LOCAL_CLIENT; - return cli - &zcache_clients[0]; + return true; } -static struct zcache_client *get_zcache_client(uint16_t cli_id) +static inline void SetPageWasActive(struct page *page) { - if (cli_id == LOCAL_CLIENT) - return &zcache_host; - - if ((unsigned int)cli_id < MAX_CLIENTS) - return &zcache_clients[cli_id]; - - return NULL; } +#endif -static inline bool is_local_client(struct zcache_client *cli) +#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS +static bool frontswap_has_exclusive_gets __read_mostly = true; +#else +static bool frontswap_has_exclusive_gets __read_mostly; +static inline void frontswap_tmem_exclusive_gets(bool b) { - return cli == &zcache_host; } +#endif + +/* enable (or fix code) when Seth's patches are accepted upstream */ +#define zcache_writeback_enabled 0 + +static int zcache_enabled __read_mostly; +static int disable_cleancache __read_mostly; +static int disable_frontswap __read_mostly; +static int disable_frontswap_ignore_nonactive __read_mostly; +static int disable_cleancache_ignore_nonactive __read_mostly; +static char *namestr __read_mostly = "zcache"; + +#define ZCACHE_GFP_MASK \ + (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC) + +MODULE_LICENSE("GPL"); /* crypto API for zcache */ #define ZCACHE_COMP_NAME_SZ CRYPTO_MAX_ALG_NAME -static char zcache_comp_name[ZCACHE_COMP_NAME_SZ]; -static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms; +static char zcache_comp_name[ZCACHE_COMP_NAME_SZ] __read_mostly; +static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms __read_mostly; enum comp_op { ZCACHE_COMPOP_COMPRESS, @@ -105,7 +89,7 @@ static inline int zcache_comp_op(enum comp_op op, u8 *dst, unsigned int *dlen) { struct crypto_comp *tfm; - int ret; + int ret = -1; BUG_ON(!zcache_comp_pcpu_tfms); tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu()); @@ -124,816 +108,247 @@ static inline int zcache_comp_op(enum comp_op op, return ret; } -/********** - * Compression buddies ("zbud") provides for packing two (or, possibly - * in the future, more) compressed ephemeral pages into a single "raw" - * (physical) page and tracking them with data structures so that - * the raw pages can be easily reclaimed. - * - * A zbud page ("zbpg") is an aligned page containing a list_head, - * a lock, and two "zbud headers". The remainder of the physical - * page is divided up into aligned 64-byte "chunks" which contain - * the compressed data for zero, one, or two zbuds. Each zbpg - * resides on: (1) an "unused list" if it has no zbuds; (2) a - * "buddied" list if it is fully populated with two zbuds; or - * (3) one of PAGE_SIZE/64 "unbuddied" lists indexed by how many chunks - * the one unbuddied zbud uses. The data inside a zbpg cannot be - * read or written unless the zbpg's lock is held. - */ - -#define ZBH_SENTINEL 0x43214321 -#define ZBPG_SENTINEL 0xdeadbeef - -#define ZBUD_MAX_BUDS 2 - -struct zbud_hdr { - uint16_t client_id; - uint16_t pool_id; - struct tmem_oid oid; - uint32_t index; - uint16_t size; /* compressed size in bytes, zero means unused */ - DECL_SENTINEL -}; - -struct zbud_page { - struct list_head bud_list; - spinlock_t lock; - struct zbud_hdr buddy[ZBUD_MAX_BUDS]; - DECL_SENTINEL - /* followed by NUM_CHUNK aligned CHUNK_SIZE-byte chunks */ -}; - -#define CHUNK_SHIFT 6 -#define CHUNK_SIZE (1 << CHUNK_SHIFT) -#define CHUNK_MASK (~(CHUNK_SIZE-1)) -#define NCHUNKS (((PAGE_SIZE - sizeof(struct zbud_page)) & \ - CHUNK_MASK) >> CHUNK_SHIFT) -#define MAX_CHUNK (NCHUNKS-1) - -static struct { - struct list_head list; - unsigned count; -} zbud_unbuddied[NCHUNKS]; -/* list N contains pages with N chunks USED and NCHUNKS-N unused */ -/* element 0 is never used but optimizing that isn't worth it */ -static unsigned long zbud_cumul_chunk_counts[NCHUNKS]; - -struct list_head zbud_buddied_list; -static unsigned long zcache_zbud_buddied_count; - -/* protects the buddied list and all unbuddied lists */ -static DEFINE_SPINLOCK(zbud_budlists_spinlock); - -static LIST_HEAD(zbpg_unused_list); -static unsigned long zcache_zbpg_unused_list_count; - -/* protects the unused page list */ -static DEFINE_SPINLOCK(zbpg_unused_list_spinlock); - -static atomic_t zcache_zbud_curr_raw_pages; -static atomic_t zcache_zbud_curr_zpages; -static unsigned long zcache_zbud_curr_zbytes; -static unsigned long zcache_zbud_cumul_zpages; -static unsigned long zcache_zbud_cumul_zbytes; -static unsigned long zcache_compress_poor; -static unsigned long zcache_mean_compress_poor; - -/* forward references */ -static void *zcache_get_free_page(void); -static void zcache_free_page(void *p); - -/* - * zbud helper functions - */ - -static inline unsigned zbud_max_buddy_size(void) -{ - return MAX_CHUNK << CHUNK_SHIFT; -} - -static inline unsigned zbud_size_to_chunks(unsigned size) -{ - BUG_ON(size == 0 || size > zbud_max_buddy_size()); - return (size + CHUNK_SIZE - 1) >> CHUNK_SHIFT; -} - -static inline int zbud_budnum(struct zbud_hdr *zh) -{ - unsigned offset = (unsigned long)zh & (PAGE_SIZE - 1); - struct zbud_page *zbpg = NULL; - unsigned budnum = -1U; - int i; - - for (i = 0; i < ZBUD_MAX_BUDS; i++) - if (offset == offsetof(typeof(*zbpg), buddy[i])) { - budnum = i; - break; - } - BUG_ON(budnum == -1U); - return budnum; -} - -static char *zbud_data(struct zbud_hdr *zh, unsigned size) -{ - struct zbud_page *zbpg; - char *p; - unsigned budnum; - - ASSERT_SENTINEL(zh, ZBH); - budnum = zbud_budnum(zh); - BUG_ON(size == 0 || size > zbud_max_buddy_size()); - zbpg = container_of(zh, struct zbud_page, buddy[budnum]); - ASSERT_SPINLOCK(&zbpg->lock); - p = (char *)zbpg; - if (budnum == 0) - p += ((sizeof(struct zbud_page) + CHUNK_SIZE - 1) & - CHUNK_MASK); - else if (budnum == 1) - p += PAGE_SIZE - ((size + CHUNK_SIZE - 1) & CHUNK_MASK); - return p; -} - -/* - * zbud raw page management - */ - -static struct zbud_page *zbud_alloc_raw_page(void) -{ - struct zbud_page *zbpg = NULL; - struct zbud_hdr *zh0, *zh1; - bool recycled = 0; - - /* if any pages on the zbpg list, use one */ - spin_lock(&zbpg_unused_list_spinlock); - if (!list_empty(&zbpg_unused_list)) { - zbpg = list_first_entry(&zbpg_unused_list, - struct zbud_page, bud_list); - list_del_init(&zbpg->bud_list); - zcache_zbpg_unused_list_count--; - recycled = 1; - } - spin_unlock(&zbpg_unused_list_spinlock); - if (zbpg == NULL) - /* none on zbpg list, try to get a kernel page */ - zbpg = zcache_get_free_page(); - if (likely(zbpg != NULL)) { - INIT_LIST_HEAD(&zbpg->bud_list); - zh0 = &zbpg->buddy[0]; zh1 = &zbpg->buddy[1]; - spin_lock_init(&zbpg->lock); - if (recycled) { - ASSERT_INVERTED_SENTINEL(zbpg, ZBPG); - SET_SENTINEL(zbpg, ZBPG); - BUG_ON(zh0->size != 0 || tmem_oid_valid(&zh0->oid)); - BUG_ON(zh1->size != 0 || tmem_oid_valid(&zh1->oid)); - } else { - atomic_inc(&zcache_zbud_curr_raw_pages); - INIT_LIST_HEAD(&zbpg->bud_list); - SET_SENTINEL(zbpg, ZBPG); - zh0->size = 0; zh1->size = 0; - tmem_oid_set_invalid(&zh0->oid); - tmem_oid_set_invalid(&zh1->oid); - } - } - return zbpg; -} - -static void zbud_free_raw_page(struct zbud_page *zbpg) -{ - struct zbud_hdr *zh0 = &zbpg->buddy[0], *zh1 = &zbpg->buddy[1]; - - ASSERT_SENTINEL(zbpg, ZBPG); - BUG_ON(!list_empty(&zbpg->bud_list)); - ASSERT_SPINLOCK(&zbpg->lock); - BUG_ON(zh0->size != 0 || tmem_oid_valid(&zh0->oid)); - BUG_ON(zh1->size != 0 || tmem_oid_valid(&zh1->oid)); - INVERT_SENTINEL(zbpg, ZBPG); - spin_unlock(&zbpg->lock); - spin_lock(&zbpg_unused_list_spinlock); - list_add(&zbpg->bud_list, &zbpg_unused_list); - zcache_zbpg_unused_list_count++; - spin_unlock(&zbpg_unused_list_spinlock); -} - -/* - * core zbud handling routines - */ - -static unsigned zbud_free(struct zbud_hdr *zh) -{ - unsigned size; - - ASSERT_SENTINEL(zh, ZBH); - BUG_ON(!tmem_oid_valid(&zh->oid)); - size = zh->size; - BUG_ON(zh->size == 0 || zh->size > zbud_max_buddy_size()); - zh->size = 0; - tmem_oid_set_invalid(&zh->oid); - INVERT_SENTINEL(zh, ZBH); - zcache_zbud_curr_zbytes -= size; - atomic_dec(&zcache_zbud_curr_zpages); - return size; -} - -static void zbud_free_and_delist(struct zbud_hdr *zh) -{ - unsigned chunks; - struct zbud_hdr *zh_other; - unsigned budnum = zbud_budnum(zh), size; - struct zbud_page *zbpg = - container_of(zh, struct zbud_page, buddy[budnum]); - - spin_lock(&zbud_budlists_spinlock); - spin_lock(&zbpg->lock); - if (list_empty(&zbpg->bud_list)) { - /* ignore zombie page... see zbud_evict_pages() */ - spin_unlock(&zbpg->lock); - spin_unlock(&zbud_budlists_spinlock); - return; - } - size = zbud_free(zh); - ASSERT_SPINLOCK(&zbpg->lock); - zh_other = &zbpg->buddy[(budnum == 0) ? 1 : 0]; - if (zh_other->size == 0) { /* was unbuddied: unlist and free */ - chunks = zbud_size_to_chunks(size) ; - BUG_ON(list_empty(&zbud_unbuddied[chunks].list)); - list_del_init(&zbpg->bud_list); - zbud_unbuddied[chunks].count--; - spin_unlock(&zbud_budlists_spinlock); - zbud_free_raw_page(zbpg); - } else { /* was buddied: move remaining buddy to unbuddied list */ - chunks = zbud_size_to_chunks(zh_other->size) ; - list_del_init(&zbpg->bud_list); - zcache_zbud_buddied_count--; - list_add_tail(&zbpg->bud_list, &zbud_unbuddied[chunks].list); - zbud_unbuddied[chunks].count++; - spin_unlock(&zbud_budlists_spinlock); - spin_unlock(&zbpg->lock); - } -} - -static struct zbud_hdr *zbud_create(uint16_t client_id, uint16_t pool_id, - struct tmem_oid *oid, - uint32_t index, struct page *page, - void *cdata, unsigned size) -{ - struct zbud_hdr *zh0, *zh1, *zh = NULL; - struct zbud_page *zbpg = NULL, *ztmp; - unsigned nchunks; - char *to; - int i, found_good_buddy = 0; - - nchunks = zbud_size_to_chunks(size) ; - for (i = MAX_CHUNK - nchunks + 1; i > 0; i--) { - spin_lock(&zbud_budlists_spinlock); - if (!list_empty(&zbud_unbuddied[i].list)) { - list_for_each_entry_safe(zbpg, ztmp, - &zbud_unbuddied[i].list, bud_list) { - if (spin_trylock(&zbpg->lock)) { - found_good_buddy = i; - goto found_unbuddied; - } - } - } - spin_unlock(&zbud_budlists_spinlock); - } - /* didn't find a good buddy, try allocating a new page */ - zbpg = zbud_alloc_raw_page(); - if (unlikely(zbpg == NULL)) - goto out; - /* ok, have a page, now compress the data before taking locks */ - spin_lock(&zbud_budlists_spinlock); - spin_lock(&zbpg->lock); - list_add_tail(&zbpg->bud_list, &zbud_unbuddied[nchunks].list); - zbud_unbuddied[nchunks].count++; - zh = &zbpg->buddy[0]; - goto init_zh; - -found_unbuddied: - ASSERT_SPINLOCK(&zbpg->lock); - zh0 = &zbpg->buddy[0]; zh1 = &zbpg->buddy[1]; - BUG_ON(!((zh0->size == 0) ^ (zh1->size == 0))); - if (zh0->size != 0) { /* buddy0 in use, buddy1 is vacant */ - ASSERT_SENTINEL(zh0, ZBH); - zh = zh1; - } else if (zh1->size != 0) { /* buddy1 in use, buddy0 is vacant */ - ASSERT_SENTINEL(zh1, ZBH); - zh = zh0; - } else - BUG(); - list_del_init(&zbpg->bud_list); - zbud_unbuddied[found_good_buddy].count--; - list_add_tail(&zbpg->bud_list, &zbud_buddied_list); - zcache_zbud_buddied_count++; - -init_zh: - SET_SENTINEL(zh, ZBH); - zh->size = size; - zh->index = index; - zh->oid = *oid; - zh->pool_id = pool_id; - zh->client_id = client_id; - to = zbud_data(zh, size); - memcpy(to, cdata, size); - spin_unlock(&zbpg->lock); - spin_unlock(&zbud_budlists_spinlock); - - zbud_cumul_chunk_counts[nchunks]++; - atomic_inc(&zcache_zbud_curr_zpages); - zcache_zbud_cumul_zpages++; - zcache_zbud_curr_zbytes += size; - zcache_zbud_cumul_zbytes += size; -out: - return zh; -} - -static int zbud_decompress(struct page *page, struct zbud_hdr *zh) -{ - struct zbud_page *zbpg; - unsigned budnum = zbud_budnum(zh); - unsigned int out_len = PAGE_SIZE; - char *to_va, *from_va; - unsigned size; - int ret = 0; - - zbpg = container_of(zh, struct zbud_page, buddy[budnum]); - spin_lock(&zbpg->lock); - if (list_empty(&zbpg->bud_list)) { - /* ignore zombie page... see zbud_evict_pages() */ - ret = -EINVAL; - goto out; - } - ASSERT_SENTINEL(zh, ZBH); - BUG_ON(zh->size == 0 || zh->size > zbud_max_buddy_size()); - to_va = kmap_atomic(page); - size = zh->size; - from_va = zbud_data(zh, size); - ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size, - to_va, &out_len); - BUG_ON(ret); - BUG_ON(out_len != PAGE_SIZE); - kunmap_atomic(to_va); -out: - spin_unlock(&zbpg->lock); - return ret; -} - /* - * The following routines handle shrinking of ephemeral pages by evicting - * pages "least valuable" first. + * policy parameters */ -static unsigned long zcache_evicted_raw_pages; -static unsigned long zcache_evicted_buddied_pages; -static unsigned long zcache_evicted_unbuddied_pages; - -static struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, - uint16_t poolid); -static void zcache_put_pool(struct tmem_pool *pool); - -/* - * Flush and free all zbuds in a zbpg, then free the pageframe - */ -static void zbud_evict_zbpg(struct zbud_page *zbpg) -{ - struct zbud_hdr *zh; - int i, j; - uint32_t pool_id[ZBUD_MAX_BUDS], client_id[ZBUD_MAX_BUDS]; - uint32_t index[ZBUD_MAX_BUDS]; - struct tmem_oid oid[ZBUD_MAX_BUDS]; - struct tmem_pool *pool; - - ASSERT_SPINLOCK(&zbpg->lock); - BUG_ON(!list_empty(&zbpg->bud_list)); - for (i = 0, j = 0; i < ZBUD_MAX_BUDS; i++) { - zh = &zbpg->buddy[i]; - if (zh->size) { - client_id[j] = zh->client_id; - pool_id[j] = zh->pool_id; - oid[j] = zh->oid; - index[j] = zh->index; - j++; - zbud_free(zh); - } - } - spin_unlock(&zbpg->lock); - for (i = 0; i < j; i++) { - pool = zcache_get_pool_by_id(client_id[i], pool_id[i]); - if (pool != NULL) { - tmem_flush_page(pool, &oid[i], index[i]); - zcache_put_pool(pool); - } - } - ASSERT_SENTINEL(zbpg, ZBPG); - spin_lock(&zbpg->lock); - zbud_free_raw_page(zbpg); -} - -/* - * Free nr pages. This code is funky because we want to hold the locks - * protecting various lists for as short a time as possible, and in some - * circumstances the list may change asynchronously when the list lock is - * not held. In some cases we also trylock not only to avoid waiting on a - * page in use by another cpu, but also to avoid potential deadlock due to - * lock inversion. - */ -static void zbud_evict_pages(int nr) -{ - struct zbud_page *zbpg; - int i; - - /* first try freeing any pages on unused list */ -retry_unused_list: - spin_lock_bh(&zbpg_unused_list_spinlock); - if (!list_empty(&zbpg_unused_list)) { - /* can't walk list here, since it may change when unlocked */ - zbpg = list_first_entry(&zbpg_unused_list, - struct zbud_page, bud_list); - list_del_init(&zbpg->bud_list); - zcache_zbpg_unused_list_count--; - atomic_dec(&zcache_zbud_curr_raw_pages); - spin_unlock_bh(&zbpg_unused_list_spinlock); - zcache_free_page(zbpg); - zcache_evicted_raw_pages++; - if (--nr <= 0) - goto out; - goto retry_unused_list; - } - spin_unlock_bh(&zbpg_unused_list_spinlock); - - /* now try freeing unbuddied pages, starting with least space avail */ - for (i = 0; i < MAX_CHUNK; i++) { -retry_unbud_list_i: - spin_lock_bh(&zbud_budlists_spinlock); - if (list_empty(&zbud_unbuddied[i].list)) { - spin_unlock_bh(&zbud_budlists_spinlock); - continue; - } - list_for_each_entry(zbpg, &zbud_unbuddied[i].list, bud_list) { - if (unlikely(!spin_trylock(&zbpg->lock))) - continue; - list_del_init(&zbpg->bud_list); - zbud_unbuddied[i].count--; - spin_unlock(&zbud_budlists_spinlock); - zcache_evicted_unbuddied_pages++; - /* want budlists unlocked when doing zbpg eviction */ - zbud_evict_zbpg(zbpg); - local_bh_enable(); - if (--nr <= 0) - goto out; - goto retry_unbud_list_i; - } - spin_unlock_bh(&zbud_budlists_spinlock); - } - - /* as a last resort, free buddied pages */ -retry_bud_list: - spin_lock_bh(&zbud_budlists_spinlock); - if (list_empty(&zbud_buddied_list)) { - spin_unlock_bh(&zbud_budlists_spinlock); - goto out; - } - list_for_each_entry(zbpg, &zbud_buddied_list, bud_list) { - if (unlikely(!spin_trylock(&zbpg->lock))) - continue; - list_del_init(&zbpg->bud_list); - zcache_zbud_buddied_count--; - spin_unlock(&zbud_budlists_spinlock); - zcache_evicted_buddied_pages++; - /* want budlists unlocked when doing zbpg eviction */ - zbud_evict_zbpg(zbpg); - local_bh_enable(); - if (--nr <= 0) - goto out; - goto retry_bud_list; - } - spin_unlock_bh(&zbud_budlists_spinlock); -out: - return; -} - -static void __init zbud_init(void) -{ - int i; - - INIT_LIST_HEAD(&zbud_buddied_list); - - for (i = 0; i < NCHUNKS; i++) - INIT_LIST_HEAD(&zbud_unbuddied[i].list); -} - -#ifdef CONFIG_SYSFS -/* - * These sysfs routines show a nice distribution of how many zbpg's are - * currently (and have ever been placed) in each unbuddied list. It's fun - * to watch but can probably go away before final merge. - */ -static int zbud_show_unbuddied_list_counts(char *buf) -{ - int i; - char *p = buf; - - for (i = 0; i < NCHUNKS; i++) - p += sprintf(p, "%u ", zbud_unbuddied[i].count); - return p - buf; -} - -static int zbud_show_cumul_chunk_counts(char *buf) -{ - unsigned long i, chunks = 0, total_chunks = 0, sum_total_chunks = 0; - unsigned long total_chunks_lte_21 = 0, total_chunks_lte_32 = 0; - unsigned long total_chunks_lte_42 = 0; - char *p = buf; - - for (i = 0; i < NCHUNKS; i++) { - p += sprintf(p, "%lu ", zbud_cumul_chunk_counts[i]); - chunks += zbud_cumul_chunk_counts[i]; - total_chunks += zbud_cumul_chunk_counts[i]; - sum_total_chunks += i * zbud_cumul_chunk_counts[i]; - if (i == 21) - total_chunks_lte_21 = total_chunks; - if (i == 32) - total_chunks_lte_32 = total_chunks; - if (i == 42) - total_chunks_lte_42 = total_chunks; - } - p += sprintf(p, "<=21:%lu <=32:%lu <=42:%lu, mean:%lu\n", - total_chunks_lte_21, total_chunks_lte_32, total_chunks_lte_42, - chunks == 0 ? 0 : sum_total_chunks / chunks); - return p - buf; -} -#endif - -/********** - * This "zv" PAM implementation combines the slab-based zsmalloc - * with the crypto compression API to maximize the amount of data that can - * be packed into a physical page. - * - * Zv represents a PAM page with the index and object (plus a "size" value - * necessary for decompression) immediately preceding the compressed data. - */ - -#define ZVH_SENTINEL 0x43214321 - -struct zv_hdr { - uint32_t pool_id; - struct tmem_oid oid; - uint32_t index; - size_t size; - DECL_SENTINEL -}; - -/* rudimentary policy limits */ -/* total number of persistent pages may not exceed this percentage */ -static unsigned int zv_page_count_policy_percent = 75; /* * byte count defining poor compression; pages with greater zsize will be * rejected */ -static unsigned int zv_max_zsize = (PAGE_SIZE / 8) * 7; +static unsigned int zbud_max_zsize __read_mostly = (PAGE_SIZE / 8) * 7; /* * byte count defining poor *mean* compression; pages with greater zsize * will be rejected until sufficient better-compressed pages are accepted * driving the mean below this threshold */ -static unsigned int zv_max_mean_zsize = (PAGE_SIZE / 8) * 5; - -static atomic_t zv_curr_dist_counts[NCHUNKS]; -static atomic_t zv_cumul_dist_counts[NCHUNKS]; +static unsigned int zbud_max_mean_zsize __read_mostly = (PAGE_SIZE / 8) * 5; -static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id, - struct tmem_oid *oid, uint32_t index, - void *cdata, unsigned clen) -{ - struct zv_hdr *zv; - u32 size = clen + sizeof(struct zv_hdr); - int chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT; - unsigned long handle = 0; - - BUG_ON(!irqs_disabled()); - BUG_ON(chunks >= NCHUNKS); - handle = zs_malloc(pool, size); - if (!handle) - goto out; - atomic_inc(&zv_curr_dist_counts[chunks]); - atomic_inc(&zv_cumul_dist_counts[chunks]); - zv = zs_map_object(pool, handle, ZS_MM_WO); - zv->index = index; - zv->oid = *oid; - zv->pool_id = pool_id; - zv->size = clen; - SET_SENTINEL(zv, ZVH); - memcpy((char *)zv + sizeof(struct zv_hdr), cdata, clen); - zs_unmap_object(pool, handle); -out: - return handle; -} - -static void zv_free(struct zs_pool *pool, unsigned long handle) -{ - unsigned long flags; - struct zv_hdr *zv; - uint16_t size; - int chunks; - - zv = zs_map_object(pool, handle, ZS_MM_RW); - ASSERT_SENTINEL(zv, ZVH); - size = zv->size + sizeof(struct zv_hdr); - INVERT_SENTINEL(zv, ZVH); - zs_unmap_object(pool, handle); - - chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT; - BUG_ON(chunks >= NCHUNKS); - atomic_dec(&zv_curr_dist_counts[chunks]); - - local_irq_save(flags); - zs_free(pool, handle); - local_irq_restore(flags); -} - -static void zv_decompress(struct page *page, unsigned long handle) -{ - unsigned int clen = PAGE_SIZE; - char *to_va; - int ret; - struct zv_hdr *zv; - - zv = zs_map_object(zcache_host.zspool, handle, ZS_MM_RO); - BUG_ON(zv->size == 0); - ASSERT_SENTINEL(zv, ZVH); - to_va = kmap_atomic(page); - ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, (char *)zv + sizeof(*zv), - zv->size, to_va, &clen); - kunmap_atomic(to_va); - zs_unmap_object(zcache_host.zspool, handle); - BUG_ON(ret); - BUG_ON(clen != PAGE_SIZE); -} - -#ifdef CONFIG_SYSFS /* - * show a distribution of compression stats for zv pages. + * for now, used named slabs so can easily track usage; later can + * either just use kmalloc, or perhaps add a slab-like allocator + * to more carefully manage total memory utilization */ +static struct kmem_cache *zcache_objnode_cache; +static struct kmem_cache *zcache_obj_cache; -static int zv_curr_dist_counts_show(char *buf) -{ - unsigned long i, n, chunks = 0, sum_total_chunks = 0; - char *p = buf; - - for (i = 0; i < NCHUNKS; i++) { - n = atomic_read(&zv_curr_dist_counts[i]); - p += sprintf(p, "%lu ", n); - chunks += n; - sum_total_chunks += i * n; - } - p += sprintf(p, "mean:%lu\n", - chunks == 0 ? 0 : sum_total_chunks / chunks); - return p - buf; -} - -static int zv_cumul_dist_counts_show(char *buf) -{ - unsigned long i, n, chunks = 0, sum_total_chunks = 0; - char *p = buf; - - for (i = 0; i < NCHUNKS; i++) { - n = atomic_read(&zv_cumul_dist_counts[i]); - p += sprintf(p, "%lu ", n); - chunks += n; - sum_total_chunks += i * n; - } - p += sprintf(p, "mean:%lu\n", - chunks == 0 ? 0 : sum_total_chunks / chunks); - return p - buf; -} +static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, }; -/* - * setting zv_max_zsize via sysfs causes all persistent (e.g. swap) - * pages that don't compress to less than this value (including metadata - * overhead) to be rejected. We don't allow the value to get too close - * to PAGE_SIZE. - */ -static ssize_t zv_max_zsize_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - return sprintf(buf, "%u\n", zv_max_zsize); +/* we try to keep these statistics SMP-consistent */ +static ssize_t zcache_obj_count; +static atomic_t zcache_obj_atomic = ATOMIC_INIT(0); +static ssize_t zcache_obj_count_max; +static ssize_t zcache_objnode_count; +static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0); +static ssize_t zcache_objnode_count_max; +static u64 zcache_eph_zbytes; +static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0); +static u64 zcache_eph_zbytes_max; +static u64 zcache_pers_zbytes; +static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0); +static u64 zcache_pers_zbytes_max; +static ssize_t zcache_eph_pageframes; +static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0); +static ssize_t zcache_eph_pageframes_max; +static ssize_t zcache_pers_pageframes; +static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0); +static ssize_t zcache_pers_pageframes_max; +static ssize_t zcache_pageframes_alloced; +static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0); +static ssize_t zcache_pageframes_freed; +static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0); +static ssize_t zcache_eph_zpages; +static ssize_t zcache_eph_zpages; +static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0); +static ssize_t zcache_eph_zpages_max; +static ssize_t zcache_pers_zpages; +static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0); +static ssize_t zcache_pers_zpages_max; + +/* but for the rest of these, counting races are ok */ +static ssize_t zcache_flush_total; +static ssize_t zcache_flush_found; +static ssize_t zcache_flobj_total; +static ssize_t zcache_flobj_found; +static ssize_t zcache_failed_eph_puts; +static ssize_t zcache_failed_pers_puts; +static ssize_t zcache_failed_getfreepages; +static ssize_t zcache_failed_alloc; +static ssize_t zcache_put_to_flush; +static ssize_t zcache_compress_poor; +static ssize_t zcache_mean_compress_poor; +static ssize_t zcache_eph_ate_tail; +static ssize_t zcache_eph_ate_tail_failed; +static ssize_t zcache_pers_ate_eph; +static ssize_t zcache_pers_ate_eph_failed; +static ssize_t zcache_evicted_eph_zpages; +static ssize_t zcache_evicted_eph_pageframes; +static ssize_t zcache_last_active_file_pageframes; +static ssize_t zcache_last_inactive_file_pageframes; +static ssize_t zcache_last_active_anon_pageframes; +static ssize_t zcache_last_inactive_anon_pageframes; +static ssize_t zcache_eph_nonactive_puts_ignored; +static ssize_t zcache_pers_nonactive_puts_ignored; +static ssize_t zcache_writtenback_pages; +static ssize_t zcache_outstanding_writeback_pages; + +#ifdef CONFIG_DEBUG_FS +#include <linux/debugfs.h> +#define zdfs debugfs_create_size_t +#define zdfs64 debugfs_create_u64 +static int zcache_debugfs_init(void) +{ + struct dentry *root = debugfs_create_dir("zcache", NULL); + if (root == NULL) + return -ENXIO; + + zdfs("obj_count", S_IRUGO, root, &zcache_obj_count); + zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max); + zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count); + zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max); + zdfs("flush_total", S_IRUGO, root, &zcache_flush_total); + zdfs("flush_found", S_IRUGO, root, &zcache_flush_found); + zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total); + zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found); + zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts); + zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts); + zdfs("failed_get_free_pages", S_IRUGO, root, + &zcache_failed_getfreepages); + zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc); + zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush); + zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor); + zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor); + zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail); + zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed); + zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph); + zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed); + zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages); + zdfs("evicted_eph_pageframes", S_IRUGO, root, + &zcache_evicted_eph_pageframes); + zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes); + zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max); + zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes); + zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max); + zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages); + zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max); + zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages); + zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max); + zdfs("last_active_file_pageframes", S_IRUGO, root, + &zcache_last_active_file_pageframes); + zdfs("last_inactive_file_pageframes", S_IRUGO, root, + &zcache_last_inactive_file_pageframes); + zdfs("last_active_anon_pageframes", S_IRUGO, root, + &zcache_last_active_anon_pageframes); + zdfs("last_inactive_anon_pageframes", S_IRUGO, root, + &zcache_last_inactive_anon_pageframes); + zdfs("eph_nonactive_puts_ignored", S_IRUGO, root, + &zcache_eph_nonactive_puts_ignored); + zdfs("pers_nonactive_puts_ignored", S_IRUGO, root, + &zcache_pers_nonactive_puts_ignored); + zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes); + zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max); + zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes); + zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max); + zdfs("outstanding_writeback_pages", S_IRUGO, root, + &zcache_outstanding_writeback_pages); + zdfs("writtenback_pages", S_IRUGO, root, &zcache_writtenback_pages); + return 0; } +#undef zdebugfs +#undef zdfs64 +#endif -static ssize_t zv_max_zsize_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - unsigned long val; - int err; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - err = kstrtoul(buf, 10, &val); - if (err || (val == 0) || (val > (PAGE_SIZE / 8) * 7)) - return -EINVAL; - zv_max_zsize = val; - return count; +#define ZCACHE_DEBUG +#ifdef ZCACHE_DEBUG +/* developers can call this in case of ooms, e.g. to find memory leaks */ +void zcache_dump(void) +{ + pr_info("zcache: obj_count=%zd\n", zcache_obj_count); + pr_info("zcache: obj_count_max=%zd\n", zcache_obj_count_max); + pr_info("zcache: objnode_count=%zd\n", zcache_objnode_count); + pr_info("zcache: objnode_count_max=%zd\n", zcache_objnode_count_max); + pr_info("zcache: flush_total=%zd\n", zcache_flush_total); + pr_info("zcache: flush_found=%zd\n", zcache_flush_found); + pr_info("zcache: flobj_total=%zd\n", zcache_flobj_total); + pr_info("zcache: flobj_found=%zd\n", zcache_flobj_found); + pr_info("zcache: failed_eph_puts=%zd\n", zcache_failed_eph_puts); + pr_info("zcache: failed_pers_puts=%zd\n", zcache_failed_pers_puts); + pr_info("zcache: failed_get_free_pages=%zd\n", + zcache_failed_getfreepages); + pr_info("zcache: failed_alloc=%zd\n", zcache_failed_alloc); + pr_info("zcache: put_to_flush=%zd\n", zcache_put_to_flush); + pr_info("zcache: compress_poor=%zd\n", zcache_compress_poor); + pr_info("zcache: mean_compress_poor=%zd\n", + zcache_mean_compress_poor); + pr_info("zcache: eph_ate_tail=%zd\n", zcache_eph_ate_tail); + pr_info("zcache: eph_ate_tail_failed=%zd\n", + zcache_eph_ate_tail_failed); + pr_info("zcache: pers_ate_eph=%zd\n", zcache_pers_ate_eph); + pr_info("zcache: pers_ate_eph_failed=%zd\n", + zcache_pers_ate_eph_failed); + pr_info("zcache: evicted_eph_zpages=%zd\n", zcache_evicted_eph_zpages); + pr_info("zcache: evicted_eph_pageframes=%zd\n", + zcache_evicted_eph_pageframes); + pr_info("zcache: eph_pageframes=%zd\n", zcache_eph_pageframes); + pr_info("zcache: eph_pageframes_max=%zd\n", zcache_eph_pageframes_max); + pr_info("zcache: pers_pageframes=%zd\n", zcache_pers_pageframes); + pr_info("zcache: pers_pageframes_max=%zd\n", + zcache_pers_pageframes_max); + pr_info("zcache: eph_zpages=%zd\n", zcache_eph_zpages); + pr_info("zcache: eph_zpages_max=%zd\n", zcache_eph_zpages_max); + pr_info("zcache: pers_zpages=%zd\n", zcache_pers_zpages); + pr_info("zcache: pers_zpages_max=%zd\n", zcache_pers_zpages_max); + pr_info("zcache: last_active_file_pageframes=%zd\n", + zcache_last_active_file_pageframes); + pr_info("zcache: last_inactive_file_pageframes=%zd\n", + zcache_last_inactive_file_pageframes); + pr_info("zcache: last_active_anon_pageframes=%zd\n", + zcache_last_active_anon_pageframes); + pr_info("zcache: last_inactive_anon_pageframes=%zd\n", + zcache_last_inactive_anon_pageframes); + pr_info("zcache: eph_nonactive_puts_ignored=%zd\n", + zcache_eph_nonactive_puts_ignored); + pr_info("zcache: pers_nonactive_puts_ignored=%zd\n", + zcache_pers_nonactive_puts_ignored); + pr_info("zcache: eph_zbytes=%llu\n", + zcache_eph_zbytes); + pr_info("zcache: eph_zbytes_max=%llu\n", + zcache_eph_zbytes_max); + pr_info("zcache: pers_zbytes=%llu\n", + zcache_pers_zbytes); + pr_info("zcache: pers_zbytes_max=%llu\n", + zcache_pers_zbytes_max); + pr_info("zcache: outstanding_writeback_pages=%zd\n", + zcache_outstanding_writeback_pages); + pr_info("zcache: writtenback_pages=%zd\n", zcache_writtenback_pages); } +#endif /* - * setting zv_max_mean_zsize via sysfs causes all persistent (e.g. swap) - * pages that don't compress to less than this value (including metadata - * overhead) to be rejected UNLESS the mean compression is also smaller - * than this value. In other words, we are load-balancing-by-zsize the - * accepted pages. Again, we don't allow the value to get too close - * to PAGE_SIZE. + * zcache core code starts here */ -static ssize_t zv_max_mean_zsize_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - return sprintf(buf, "%u\n", zv_max_mean_zsize); -} - -static ssize_t zv_max_mean_zsize_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - unsigned long val; - int err; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - err = kstrtoul(buf, 10, &val); - if (err || (val == 0) || (val > (PAGE_SIZE / 8) * 7)) - return -EINVAL; - zv_max_mean_zsize = val; - return count; -} +static struct zcache_client zcache_host; +static struct zcache_client zcache_clients[MAX_CLIENTS]; -/* - * setting zv_page_count_policy_percent via sysfs sets an upper bound of - * persistent (e.g. swap) pages that will be retained according to: - * (zv_page_count_policy_percent * totalram_pages) / 100) - * when that limit is reached, further puts will be rejected (until - * some pages have been flushed). Note that, due to compression, - * this number may exceed 100; it defaults to 75 and we set an - * arbitary limit of 150. A poor choice will almost certainly result - * in OOM's, so this value should only be changed prudently. - */ -static ssize_t zv_page_count_policy_percent_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) +static inline bool is_local_client(struct zcache_client *cli) { - return sprintf(buf, "%u\n", zv_page_count_policy_percent); + return cli == &zcache_host; } -static ssize_t zv_page_count_policy_percent_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) +static struct zcache_client *zcache_get_client_by_id(uint16_t cli_id) { - unsigned long val; - int err; + struct zcache_client *cli = &zcache_host; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - err = kstrtoul(buf, 10, &val); - if (err || (val == 0) || (val > 150)) - return -EINVAL; - zv_page_count_policy_percent = val; - return count; + if (cli_id != LOCAL_CLIENT) { + if (cli_id >= MAX_CLIENTS) + goto out; + cli = &zcache_clients[cli_id]; + } +out: + return cli; } -static struct kobj_attribute zcache_zv_max_zsize_attr = { - .attr = { .name = "zv_max_zsize", .mode = 0644 }, - .show = zv_max_zsize_show, - .store = zv_max_zsize_store, -}; - -static struct kobj_attribute zcache_zv_max_mean_zsize_attr = { - .attr = { .name = "zv_max_mean_zsize", .mode = 0644 }, - .show = zv_max_mean_zsize_show, - .store = zv_max_mean_zsize_store, -}; - -static struct kobj_attribute zcache_zv_page_count_policy_percent_attr = { - .attr = { .name = "zv_page_count_policy_percent", - .mode = 0644 }, - .show = zv_page_count_policy_percent_show, - .store = zv_page_count_policy_percent_store, -}; -#endif - -/* - * zcache core code starts here - */ - -/* useful stats not collected by cleancache or frontswap */ -static unsigned long zcache_flush_total; -static unsigned long zcache_flush_found; -static unsigned long zcache_flobj_total; -static unsigned long zcache_flobj_found; -static unsigned long zcache_failed_eph_puts; -static unsigned long zcache_failed_pers_puts; - /* * Tmem operations assume the poolid implies the invoking client. * Zcache only has one client (the kernel itself): LOCAL_CLIENT. @@ -941,24 +356,26 @@ static unsigned long zcache_failed_pers_puts; * of zcache would have one client per guest and each client might * have a poolid==N. */ -static struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid) +struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid) { struct tmem_pool *pool = NULL; struct zcache_client *cli = NULL; - cli = get_zcache_client(cli_id); - if (!cli) + cli = zcache_get_client_by_id(cli_id); + if (cli == NULL) goto out; - - atomic_inc(&cli->refcount); - pool = idr_find(&cli->tmem_pools, poolid); - if (pool != NULL) - atomic_inc(&pool->refcount); + if (!is_local_client(cli)) + atomic_inc(&cli->refcount); + if (poolid < MAX_POOLS_PER_CLIENT) { + pool = cli->tmem_pools[poolid]; + if (pool != NULL) + atomic_inc(&pool->refcount); + } out: return pool; } -static void zcache_put_pool(struct tmem_pool *pool) +void zcache_put_pool(struct tmem_pool *pool) { struct zcache_client *cli = NULL; @@ -966,7 +383,8 @@ static void zcache_put_pool(struct tmem_pool *pool) BUG(); cli = pool->client; atomic_dec(&pool->refcount); - atomic_dec(&cli->refcount); + if (!is_local_client(cli)) + atomic_dec(&cli->refcount); } int zcache_new_client(uint16_t cli_id) @@ -974,120 +392,17 @@ int zcache_new_client(uint16_t cli_id) struct zcache_client *cli; int ret = -1; - cli = get_zcache_client(cli_id); - + cli = zcache_get_client_by_id(cli_id); if (cli == NULL) goto out; if (cli->allocated) goto out; cli->allocated = 1; -#ifdef CONFIG_FRONTSWAP - cli->zspool = zs_create_pool("zcache", ZCACHE_GFP_MASK); - if (cli->zspool == NULL) - goto out; - idr_init(&cli->tmem_pools); -#endif - ret = 0; -out: - return ret; -} - -/* counters for debugging */ -static unsigned long zcache_failed_get_free_pages; -static unsigned long zcache_failed_alloc; -static unsigned long zcache_put_to_flush; - -/* - * for now, used named slabs so can easily track usage; later can - * either just use kmalloc, or perhaps add a slab-like allocator - * to more carefully manage total memory utilization - */ -static struct kmem_cache *zcache_objnode_cache; -static struct kmem_cache *zcache_obj_cache; -static atomic_t zcache_curr_obj_count = ATOMIC_INIT(0); -static unsigned long zcache_curr_obj_count_max; -static atomic_t zcache_curr_objnode_count = ATOMIC_INIT(0); -static unsigned long zcache_curr_objnode_count_max; - -/* - * to avoid memory allocation recursion (e.g. due to direct reclaim), we - * preload all necessary data structures so the hostops callbacks never - * actually do a malloc - */ -struct zcache_preload { - void *page; - struct tmem_obj *obj; - int nr; - struct tmem_objnode *objnodes[OBJNODE_TREE_MAX_PATH]; -}; -static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, }; - -static int zcache_do_preload(struct tmem_pool *pool) -{ - struct zcache_preload *kp; - struct tmem_objnode *objnode; - struct tmem_obj *obj; - void *page; - int ret = -ENOMEM; - - if (unlikely(zcache_objnode_cache == NULL)) - goto out; - if (unlikely(zcache_obj_cache == NULL)) - goto out; - - /* IRQ has already been disabled. */ - kp = &__get_cpu_var(zcache_preloads); - while (kp->nr < ARRAY_SIZE(kp->objnodes)) { - objnode = kmem_cache_alloc(zcache_objnode_cache, - ZCACHE_GFP_MASK); - if (unlikely(objnode == NULL)) { - zcache_failed_alloc++; - goto out; - } - - kp->objnodes[kp->nr++] = objnode; - } - - if (!kp->obj) { - obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); - if (unlikely(obj == NULL)) { - zcache_failed_alloc++; - goto out; - } - kp->obj = obj; - } - - if (!kp->page) { - page = (void *)__get_free_page(ZCACHE_GFP_MASK); - if (unlikely(page == NULL)) { - zcache_failed_get_free_pages++; - goto out; - } - kp->page = page; - } - ret = 0; out: return ret; } -static void *zcache_get_free_page(void) -{ - struct zcache_preload *kp; - void *page; - - kp = &__get_cpu_var(zcache_preloads); - page = kp->page; - BUG_ON(page == NULL); - kp->page = NULL; - return page; -} - -static void zcache_free_page(void *p) -{ - free_page((unsigned long)p); -} - /* * zcache implementation for tmem host ops */ @@ -1095,51 +410,53 @@ static void zcache_free_page(void *p) static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool) { struct tmem_objnode *objnode = NULL; - unsigned long count; struct zcache_preload *kp; + int i; kp = &__get_cpu_var(zcache_preloads); - if (kp->nr <= 0) - goto out; - objnode = kp->objnodes[kp->nr - 1]; + for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { + objnode = kp->objnodes[i]; + if (objnode != NULL) { + kp->objnodes[i] = NULL; + break; + } + } BUG_ON(objnode == NULL); - kp->objnodes[kp->nr - 1] = NULL; - kp->nr--; - count = atomic_inc_return(&zcache_curr_objnode_count); - if (count > zcache_curr_objnode_count_max) - zcache_curr_objnode_count_max = count; -out: + zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic); + if (zcache_objnode_count > zcache_objnode_count_max) + zcache_objnode_count_max = zcache_objnode_count; return objnode; } static void zcache_objnode_free(struct tmem_objnode *objnode, struct tmem_pool *pool) { - atomic_dec(&zcache_curr_objnode_count); - BUG_ON(atomic_read(&zcache_curr_objnode_count) < 0); + zcache_objnode_count = + atomic_dec_return(&zcache_objnode_atomic); + BUG_ON(zcache_objnode_count < 0); kmem_cache_free(zcache_objnode_cache, objnode); } static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool) { struct tmem_obj *obj = NULL; - unsigned long count; struct zcache_preload *kp; kp = &__get_cpu_var(zcache_preloads); obj = kp->obj; BUG_ON(obj == NULL); kp->obj = NULL; - count = atomic_inc_return(&zcache_curr_obj_count); - if (count > zcache_curr_obj_count_max) - zcache_curr_obj_count_max = count; + zcache_obj_count = atomic_inc_return(&zcache_obj_atomic); + if (zcache_obj_count > zcache_obj_count_max) + zcache_obj_count_max = zcache_obj_count; return obj; } static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool) { - atomic_dec(&zcache_curr_obj_count); - BUG_ON(atomic_read(&zcache_curr_obj_count) < 0); + zcache_obj_count = + atomic_dec_return(&zcache_obj_atomic); + BUG_ON(zcache_obj_count < 0); kmem_cache_free(zcache_obj_cache, obj); } @@ -1150,96 +467,302 @@ static struct tmem_hostops zcache_hostops = { .objnode_free = zcache_objnode_free, }; +static struct page *zcache_alloc_page(void) +{ + struct page *page = alloc_page(ZCACHE_GFP_MASK); + + if (page != NULL) + zcache_pageframes_alloced = + atomic_inc_return(&zcache_pageframes_alloced_atomic); + return page; +} + +static void zcache_free_page(struct page *page) +{ + long curr_pageframes; + static long max_pageframes, min_pageframes; + + if (page == NULL) + BUG(); + __free_page(page); + zcache_pageframes_freed = + atomic_inc_return(&zcache_pageframes_freed_atomic); + curr_pageframes = zcache_pageframes_alloced - + atomic_read(&zcache_pageframes_freed_atomic) - + atomic_read(&zcache_eph_pageframes_atomic) - + atomic_read(&zcache_pers_pageframes_atomic); + if (curr_pageframes > max_pageframes) + max_pageframes = curr_pageframes; + if (curr_pageframes < min_pageframes) + min_pageframes = curr_pageframes; +#ifdef ZCACHE_DEBUG + if (curr_pageframes > 2L || curr_pageframes < -2L) { + /* pr_info here */ + } +#endif +} + /* * zcache implementations for PAM page descriptor ops */ -static atomic_t zcache_curr_eph_pampd_count = ATOMIC_INIT(0); -static unsigned long zcache_curr_eph_pampd_count_max; -static atomic_t zcache_curr_pers_pampd_count = ATOMIC_INIT(0); -static unsigned long zcache_curr_pers_pampd_count_max; - /* forward reference */ -static int zcache_compress(struct page *from, void **out_va, unsigned *out_len); +static void zcache_compress(struct page *from, + void **out_va, unsigned *out_len); + +static struct page *zcache_evict_eph_pageframe(void); -static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph, - struct tmem_pool *pool, struct tmem_oid *oid, - uint32_t index) +static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, + struct tmem_handle *th) { - void *pampd = NULL, *cdata; - unsigned clen; - int ret; - unsigned long count; - struct page *page = (struct page *)(data); - struct zcache_client *cli = pool->client; - uint16_t client_id = get_client_id_from_client(cli); - unsigned long zv_mean_zsize; - unsigned long curr_pers_pampd_count; - u64 total_zsize; + void *pampd = NULL, *cdata = data; + unsigned clen = size; + struct page *page = (struct page *)(data), *newpage; - if (eph) { - ret = zcache_compress(page, &cdata, &clen); - if (ret == 0) - goto out; - if (clen == 0 || clen > zbud_max_buddy_size()) { + if (!raw) { + zcache_compress(page, &cdata, &clen); + if (clen > zbud_max_buddy_size()) { zcache_compress_poor++; goto out; } - pampd = (void *)zbud_create(client_id, pool->pool_id, oid, - index, page, cdata, clen); - if (pampd != NULL) { - count = atomic_inc_return(&zcache_curr_eph_pampd_count); - if (count > zcache_curr_eph_pampd_count_max) - zcache_curr_eph_pampd_count_max = count; - } } else { - curr_pers_pampd_count = - atomic_read(&zcache_curr_pers_pampd_count); - if (curr_pers_pampd_count > - (zv_page_count_policy_percent * totalram_pages) / 100) - goto out; - ret = zcache_compress(page, &cdata, &clen); - if (ret == 0) - goto out; - /* reject if compression is too poor */ - if (clen > zv_max_zsize) { - zcache_compress_poor++; + BUG_ON(clen > zbud_max_buddy_size()); + } + + /* look for space via an existing match first */ + pampd = (void *)zbud_match_prep(th, true, cdata, clen); + if (pampd != NULL) + goto got_pampd; + + /* no match, now we need to find (or free up) a full page */ + newpage = zcache_alloc_page(); + if (newpage != NULL) + goto create_in_new_page; + + zcache_failed_getfreepages++; + /* can't allocate a page, evict an ephemeral page via LRU */ + newpage = zcache_evict_eph_pageframe(); + if (newpage == NULL) { + zcache_eph_ate_tail_failed++; + goto out; + } + zcache_eph_ate_tail++; + +create_in_new_page: + pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage); + BUG_ON(pampd == NULL); + zcache_eph_pageframes = + atomic_inc_return(&zcache_eph_pageframes_atomic); + if (zcache_eph_pageframes > zcache_eph_pageframes_max) + zcache_eph_pageframes_max = zcache_eph_pageframes; + +got_pampd: + zcache_eph_zbytes = + atomic_long_add_return(clen, &zcache_eph_zbytes_atomic); + if (zcache_eph_zbytes > zcache_eph_zbytes_max) + zcache_eph_zbytes_max = zcache_eph_zbytes; + zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic); + if (zcache_eph_zpages > zcache_eph_zpages_max) + zcache_eph_zpages_max = zcache_eph_zpages; + if (ramster_enabled && raw) + ramster_count_foreign_pages(true, 1); +out: + return pampd; +} + +static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, + struct tmem_handle *th) +{ + void *pampd = NULL, *cdata = data; + unsigned clen = size; + struct page *page = (struct page *)(data), *newpage; + unsigned long zbud_mean_zsize; + unsigned long curr_pers_zpages, total_zsize; + + if (data == NULL) { + BUG_ON(!ramster_enabled); + goto create_pampd; + } + curr_pers_zpages = zcache_pers_zpages; +/* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ + if (!raw) + zcache_compress(page, &cdata, &clen); + /* reject if compression is too poor */ + if (clen > zbud_max_zsize) { + zcache_compress_poor++; + goto out; + } + /* reject if mean compression is too poor */ + if ((clen > zbud_max_mean_zsize) && (curr_pers_zpages > 0)) { + total_zsize = zcache_pers_zbytes; + if ((long)total_zsize < 0) + total_zsize = 0; + zbud_mean_zsize = div_u64(total_zsize, + curr_pers_zpages); + if (zbud_mean_zsize > zbud_max_mean_zsize) { + zcache_mean_compress_poor++; goto out; } - /* reject if mean compression is too poor */ - if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) { - total_zsize = zs_get_total_size_bytes(cli->zspool); - zv_mean_zsize = div_u64(total_zsize, - curr_pers_pampd_count); - if (zv_mean_zsize > zv_max_mean_zsize) { - zcache_mean_compress_poor++; + } + +create_pampd: + /* look for space via an existing match first */ + pampd = (void *)zbud_match_prep(th, false, cdata, clen); + if (pampd != NULL) + goto got_pampd; + + /* no match, now we need to find (or free up) a full page */ + newpage = zcache_alloc_page(); + if (newpage != NULL) + goto create_in_new_page; + /* + * FIXME do the following only if eph is oversized? + * if (zcache_eph_pageframes > + * (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) + + * global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE))) + */ + zcache_failed_getfreepages++; + /* can't allocate a page, evict an ephemeral page via LRU */ + newpage = zcache_evict_eph_pageframe(); + if (newpage == NULL) { + zcache_pers_ate_eph_failed++; + goto out; + } + zcache_pers_ate_eph++; + +create_in_new_page: + pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage); + BUG_ON(pampd == NULL); + zcache_pers_pageframes = + atomic_inc_return(&zcache_pers_pageframes_atomic); + if (zcache_pers_pageframes > zcache_pers_pageframes_max) + zcache_pers_pageframes_max = zcache_pers_pageframes; + +got_pampd: + zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic); + if (zcache_pers_zpages > zcache_pers_zpages_max) + zcache_pers_zpages_max = zcache_pers_zpages; + zcache_pers_zbytes = + atomic_long_add_return(clen, &zcache_pers_zbytes_atomic); + if (zcache_pers_zbytes > zcache_pers_zbytes_max) + zcache_pers_zbytes_max = zcache_pers_zbytes; + if (ramster_enabled && raw) + ramster_count_foreign_pages(false, 1); +out: + return pampd; +} + +/* + * This is called directly from zcache_put_page to pre-allocate space + * to store a zpage. + */ +void *zcache_pampd_create(char *data, unsigned int size, bool raw, + int eph, struct tmem_handle *th) +{ + void *pampd = NULL; + struct zcache_preload *kp; + struct tmem_objnode *objnode; + struct tmem_obj *obj; + int i; + + BUG_ON(!irqs_disabled()); + /* pre-allocate per-cpu metadata */ + BUG_ON(zcache_objnode_cache == NULL); + BUG_ON(zcache_obj_cache == NULL); + kp = &__get_cpu_var(zcache_preloads); + for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { + objnode = kp->objnodes[i]; + if (objnode == NULL) { + objnode = kmem_cache_alloc(zcache_objnode_cache, + ZCACHE_GFP_MASK); + if (unlikely(objnode == NULL)) { + zcache_failed_alloc++; goto out; } + kp->objnodes[i] = objnode; } - pampd = (void *)zv_create(cli->zspool, pool->pool_id, - oid, index, cdata, clen); - if (pampd == NULL) - goto out; - count = atomic_inc_return(&zcache_curr_pers_pampd_count); - if (count > zcache_curr_pers_pampd_count_max) - zcache_curr_pers_pampd_count_max = count; } + if (kp->obj == NULL) { + obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); + kp->obj = obj; + } + if (unlikely(kp->obj == NULL)) { + zcache_failed_alloc++; + goto out; + } + /* + * ok, have all the metadata pre-allocated, now do the data + * but since how we allocate the data is dependent on ephemeral + * or persistent, we split the call here to different sub-functions + */ + if (eph) + pampd = zcache_pampd_eph_create(data, size, raw, th); + else + pampd = zcache_pampd_pers_create(data, size, raw, th); out: return pampd; } /* + * This is a pamops called via tmem_put and is necessary to "finish" + * a pampd creation. + */ +void zcache_pampd_create_finish(void *pampd, bool eph) +{ + zbud_create_finish((struct zbudref *)pampd, eph); +} + +/* + * This is passed as a function parameter to zbud_decompress so that + * zbud need not be familiar with the details of crypto. It assumes that + * the bytes from_va and to_va through from_va+size-1 and to_va+size-1 are + * kmapped. It must be successful, else there is a logic bug somewhere. + */ +static void zcache_decompress(char *from_va, unsigned int size, char *to_va) +{ + int ret; + unsigned int outlen = PAGE_SIZE; + + ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size, + to_va, &outlen); + BUG_ON(ret); + BUG_ON(outlen != PAGE_SIZE); +} + +/* + * Decompress from the kernel va to a pageframe + */ +void zcache_decompress_to_page(char *from_va, unsigned int size, + struct page *to_page) +{ + char *to_va = kmap_atomic(to_page); + zcache_decompress(from_va, size, to_va); + kunmap_atomic(to_va); +} + +/* * fill the pageframe corresponding to the struct page with the data * from the passed pampd */ -static int zcache_pampd_get_data(char *data, size_t *bufsize, bool raw, +static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, void *pampd, struct tmem_pool *pool, struct tmem_oid *oid, uint32_t index) { - int ret = 0; - - BUG_ON(is_ephemeral(pool)); - zv_decompress((struct page *)(data), (unsigned long)pampd); + int ret; + bool eph = !is_persistent(pool); + + BUG_ON(preemptible()); + BUG_ON(eph); /* fix later if shared pools get implemented */ + BUG_ON(pampd_is_remote(pampd)); + if (raw) + ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, + sizep, eph); + else { + ret = zbud_decompress((struct page *)(data), + (struct zbudref *)pampd, false, + zcache_decompress); + *sizep = PAGE_SIZE; + } return ret; } @@ -1247,16 +770,50 @@ static int zcache_pampd_get_data(char *data, size_t *bufsize, bool raw, * fill the pageframe corresponding to the struct page with the data * from the passed pampd */ -static int zcache_pampd_get_data_and_free(char *data, size_t *bufsize, bool raw, +static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, void *pampd, struct tmem_pool *pool, struct tmem_oid *oid, uint32_t index) { - BUG_ON(!is_ephemeral(pool)); - if (zbud_decompress((struct page *)(data), pampd) < 0) - return -EINVAL; - zbud_free_and_delist((struct zbud_hdr *)pampd); - atomic_dec(&zcache_curr_eph_pampd_count); - return 0; + int ret; + bool eph = !is_persistent(pool); + struct page *page = NULL; + unsigned int zsize, zpages; + + BUG_ON(preemptible()); + BUG_ON(pampd_is_remote(pampd)); + if (raw) + ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, + sizep, eph); + else { + ret = zbud_decompress((struct page *)(data), + (struct zbudref *)pampd, eph, + zcache_decompress); + *sizep = PAGE_SIZE; + } + page = zbud_free_and_delist((struct zbudref *)pampd, eph, + &zsize, &zpages); + if (eph) { + if (page) + zcache_eph_pageframes = + atomic_dec_return(&zcache_eph_pageframes_atomic); + zcache_eph_zpages = + atomic_sub_return(zpages, &zcache_eph_zpages_atomic); + zcache_eph_zbytes = + atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic); + } else { + if (page) + zcache_pers_pageframes = + atomic_dec_return(&zcache_pers_pageframes_atomic); + zcache_pers_zpages = + atomic_sub_return(zpages, &zcache_pers_zpages_atomic); + zcache_pers_zbytes = + atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic); + } + if (!is_local_client(pool->client)) + ramster_count_foreign_pages(eph, -1); + if (page) + zcache_free_page(page); + return ret; } /* @@ -1264,48 +821,51 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *bufsize, bool raw, * pampd must no longer be pointed to from any tmem data structures! */ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index) + struct tmem_oid *oid, uint32_t index, bool acct) { - struct zcache_client *cli = pool->client; + struct page *page = NULL; + unsigned int zsize, zpages; + BUG_ON(preemptible()); + if (pampd_is_remote(pampd)) { + BUG_ON(!ramster_enabled); + pampd = ramster_pampd_free(pampd, pool, oid, index, acct); + if (pampd == NULL) + return; + } if (is_ephemeral(pool)) { - zbud_free_and_delist((struct zbud_hdr *)pampd); - atomic_dec(&zcache_curr_eph_pampd_count); - BUG_ON(atomic_read(&zcache_curr_eph_pampd_count) < 0); + page = zbud_free_and_delist((struct zbudref *)pampd, + true, &zsize, &zpages); + if (page) + zcache_eph_pageframes = + atomic_dec_return(&zcache_eph_pageframes_atomic); + zcache_eph_zpages = + atomic_sub_return(zpages, &zcache_eph_zpages_atomic); + zcache_eph_zbytes = + atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic); + /* FIXME CONFIG_RAMSTER... check acct parameter? */ } else { - zv_free(cli->zspool, (unsigned long)pampd); - atomic_dec(&zcache_curr_pers_pampd_count); - BUG_ON(atomic_read(&zcache_curr_pers_pampd_count) < 0); + page = zbud_free_and_delist((struct zbudref *)pampd, + false, &zsize, &zpages); + if (page) + zcache_pers_pageframes = + atomic_dec_return(&zcache_pers_pageframes_atomic); + zcache_pers_zpages = + atomic_sub_return(zpages, &zcache_pers_zpages_atomic); + zcache_pers_zbytes = + atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic); } -} - -static void zcache_pampd_free_obj(struct tmem_pool *pool, struct tmem_obj *obj) -{ -} - -static void zcache_pampd_new_obj(struct tmem_obj *obj) -{ -} - -static int zcache_pampd_replace_in_obj(void *pampd, struct tmem_obj *obj) -{ - return -1; -} - -static bool zcache_pampd_is_remote(void *pampd) -{ - return 0; + if (!is_local_client(pool->client)) + ramster_count_foreign_pages(is_ephemeral(pool), -1); + if (page) + zcache_free_page(page); } static struct tmem_pamops zcache_pamops = { - .create = zcache_pampd_create, + .create_finish = zcache_pampd_create_finish, .get_data = zcache_pampd_get_data, .get_data_and_free = zcache_pampd_get_data_and_free, .free = zcache_pampd_free, - .free_obj = zcache_pampd_free_obj, - .new_obj = zcache_pampd_new_obj, - .replace_in_obj = zcache_pampd_replace_in_obj, - .is_remote = zcache_pampd_is_remote, }; /* @@ -1315,15 +875,15 @@ static struct tmem_pamops zcache_pamops = { static DEFINE_PER_CPU(unsigned char *, zcache_dstmem); #define ZCACHE_DSTMEM_ORDER 1 -static int zcache_compress(struct page *from, void **out_va, unsigned *out_len) +static void zcache_compress(struct page *from, void **out_va, unsigned *out_len) { - int ret = 0; + int ret; unsigned char *dmem = __get_cpu_var(zcache_dstmem); char *from_va; BUG_ON(!irqs_disabled()); - if (unlikely(dmem == NULL)) - goto out; /* no buffer or no compressor so can't compress */ + /* no buffer or no compressor so can't compress */ + BUG_ON(dmem == NULL); *out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER; from_va = kmap_atomic(from); mb(); @@ -1332,9 +892,6 @@ static int zcache_compress(struct page *from, void **out_va, unsigned *out_len) BUG_ON(ret); *out_va = dmem; kunmap_atomic(from_va); - ret = 1; -out: - return ret; } static int zcache_comp_cpu_up(int cpu) @@ -1360,18 +917,21 @@ static void zcache_comp_cpu_down(int cpu) static int zcache_cpu_notifier(struct notifier_block *nb, unsigned long action, void *pcpu) { - int ret, cpu = (long)pcpu; + int ret, i, cpu = (long)pcpu; struct zcache_preload *kp; switch (action) { case CPU_UP_PREPARE: ret = zcache_comp_cpu_up(cpu); if (ret != NOTIFY_OK) { - pr_err("zcache: can't allocate compressor transform\n"); + pr_err("%s: can't allocate compressor xform\n", + namestr); return ret; } per_cpu(zcache_dstmem, cpu) = (void *)__get_free_pages( GFP_KERNEL | __GFP_REPEAT, ZCACHE_DSTMEM_ORDER); + if (ramster_enabled) + ramster_cpu_up(cpu); break; case CPU_DEAD: case CPU_UP_CANCELED: @@ -1380,20 +940,17 @@ static int zcache_cpu_notifier(struct notifier_block *nb, ZCACHE_DSTMEM_ORDER); per_cpu(zcache_dstmem, cpu) = NULL; kp = &per_cpu(zcache_preloads, cpu); - while (kp->nr) { - kmem_cache_free(zcache_objnode_cache, - kp->objnodes[kp->nr - 1]); - kp->objnodes[kp->nr - 1] = NULL; - kp->nr--; + for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { + if (kp->objnodes[i]) + kmem_cache_free(zcache_objnode_cache, + kp->objnodes[i]); } if (kp->obj) { kmem_cache_free(zcache_obj_cache, kp->obj); kp->obj = NULL; } - if (kp->page) { - free_page((unsigned long)kp->page); - kp->page = NULL; - } + if (ramster_enabled) + ramster_cpu_down(cpu); break; default: break; @@ -1405,116 +962,279 @@ static struct notifier_block zcache_cpu_notifier_block = { .notifier_call = zcache_cpu_notifier }; -#ifdef CONFIG_SYSFS -#define ZCACHE_SYSFS_RO(_name) \ - static ssize_t zcache_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return sprintf(buf, "%lu\n", zcache_##_name); \ - } \ - static struct kobj_attribute zcache_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = zcache_##_name##_show, \ - } +/* + * The following code interacts with the zbud eviction and zbud + * zombify code to access LRU pages + */ + +static struct page *zcache_evict_eph_pageframe(void) +{ + struct page *page; + unsigned int zsize = 0, zpages = 0; + + page = zbud_evict_pageframe_lru(&zsize, &zpages); + if (page == NULL) + goto out; + zcache_eph_zbytes = atomic_long_sub_return(zsize, + &zcache_eph_zbytes_atomic); + zcache_eph_zpages = atomic_sub_return(zpages, + &zcache_eph_zpages_atomic); + zcache_evicted_eph_zpages += zpages; + zcache_eph_pageframes = + atomic_dec_return(&zcache_eph_pageframes_atomic); + zcache_evicted_eph_pageframes++; +out: + return page; +} + +#ifdef CONFIG_ZCACHE_WRITEBACK + +static atomic_t zcache_outstanding_writeback_pages_atomic = ATOMIC_INIT(0); + +static void unswiz(struct tmem_oid oid, u32 index, + unsigned *type, pgoff_t *offset); + +/* + * Choose an LRU persistent pageframe and attempt to write it back to + * the backing swap disk by calling frontswap_writeback on both zpages. + * + * This is work-in-progress. + */ -#define ZCACHE_SYSFS_RO_ATOMIC(_name) \ - static ssize_t zcache_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return sprintf(buf, "%d\n", atomic_read(&zcache_##_name)); \ - } \ - static struct kobj_attribute zcache_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = zcache_##_name##_show, \ +static void zcache_end_swap_write(struct bio *bio, int err) +{ + end_swap_bio_write(bio, err); + zcache_outstanding_writeback_pages = + atomic_dec_return(&zcache_outstanding_writeback_pages_atomic); + zcache_writtenback_pages++; +} + +/* + * zcache_get_swap_cache_page + * + * This is an adaption of read_swap_cache_async() + * + * If success, page is returned in retpage + * Returns 0 if page was already in the swap cache, page is not locked + * Returns 1 if the new page needs to be populated, page is locked + */ +static int zcache_get_swap_cache_page(int type, pgoff_t offset, + struct page *new_page) +{ + struct page *found_page; + swp_entry_t entry = swp_entry(type, offset); + int err; + + BUG_ON(new_page == NULL); + do { + /* + * First check the swap cache. Since this is normally + * called after lookup_swap_cache() failed, re-calling + * that would confuse statistics. + */ + found_page = find_get_page(&swapper_space, entry.val); + if (found_page) + return 0; + + /* + * call radix_tree_preload() while we can wait. + */ + err = radix_tree_preload(GFP_KERNEL); + if (err) + break; + + /* + * Swap entry may have been freed since our caller observed it. + */ + err = swapcache_prepare(entry); + if (err == -EEXIST) { /* seems racy */ + radix_tree_preload_end(); + continue; + } + if (err) { /* swp entry is obsolete ? */ + radix_tree_preload_end(); + break; + } + + /* May fail (-ENOMEM) if radix-tree node allocation failed. */ + __set_page_locked(new_page); + SetPageSwapBacked(new_page); + err = __add_to_swap_cache(new_page, entry); + if (likely(!err)) { + radix_tree_preload_end(); + lru_cache_add_anon(new_page); + return 1; + } + radix_tree_preload_end(); + ClearPageSwapBacked(new_page); + __clear_page_locked(new_page); + /* + * add_to_swap_cache() doesn't return -EEXIST, so we can safely + * clear SWAP_HAS_CACHE flag. + */ + swapcache_free(entry, NULL); + /* FIXME: is it possible to get here without err==-ENOMEM? + * If not, we can dispense with the do loop, use goto retry */ + } while (err != -ENOMEM); + + return -ENOMEM; +} + +/* + * Given a frontswap zpage in zcache (identified by type/offset) and + * an empty page, put the page into the swap cache, use frontswap + * to get the page from zcache into the empty page, then give it + * to the swap subsystem to send to disk (carefully avoiding the + * possibility that frontswap might snatch it back). + * Returns < 0 if error, 0 if successful, and 1 if successful but + * the newpage passed in not needed and should be freed. + */ +static int zcache_frontswap_writeback_zpage(int type, pgoff_t offset, + struct page *newpage) +{ + struct page *page = newpage; + int ret; + struct writeback_control wbc = { + .sync_mode = WB_SYNC_NONE, + }; + + ret = zcache_get_swap_cache_page(type, offset, page); + if (ret < 0) + return ret; + else if (ret == 0) { + /* more uptodate page is already in swapcache */ + __frontswap_invalidate_page(type, offset); + return 1; } -#define ZCACHE_SYSFS_RO_CUSTOM(_name, _func) \ - static ssize_t zcache_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return _func(buf); \ - } \ - static struct kobj_attribute zcache_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = zcache_##_name##_show, \ + BUG_ON(!frontswap_has_exclusive_gets); /* load must also invalidate */ + /* FIXME: how is it possible to get here when page is unlocked? */ + __frontswap_load(page); + SetPageUptodate(page); /* above does SetPageDirty, is that enough? */ + + /* start writeback */ + SetPageReclaim(page); + /* + * Return value is ignored here because it doesn't change anything + * for us. Page is returned unlocked. + */ + (void)__swap_writepage(page, &wbc, zcache_end_swap_write); + page_cache_release(page); + zcache_outstanding_writeback_pages = + atomic_inc_return(&zcache_outstanding_writeback_pages_atomic); + + return 0; +} + +/* + * The following is still a magic number... we want to allow forward progress + * for writeback because it clears out needed RAM when under pressure, but + * we don't want to allow writeback to absorb and queue too many GFP_KERNEL + * pages if the swap device is very slow. + */ +#define ZCACHE_MAX_OUTSTANDING_WRITEBACK_PAGES 6400 + +/* + * Try to allocate two free pages, first using a non-aggressive alloc, + * then by evicting zcache ephemeral (clean pagecache) pages, and last + * by aggressive GFP_KERNEL alloc. We allow zbud to choose a pageframe + * consisting of 1-2 zbuds/zpages, then call the writeback_zpage helper + * function above for each. + */ +static int zcache_frontswap_writeback(void) +{ + struct tmem_handle th[2]; + int ret = 0; + int nzbuds, writeback_ret; + unsigned type; + struct page *znewpage1 = NULL, *znewpage2 = NULL; + struct page *evictpage1 = NULL, *evictpage2 = NULL; + struct page *newpage1 = NULL, *newpage2 = NULL; + struct page *page1 = NULL, *page2 = NULL; + pgoff_t offset; + + znewpage1 = alloc_page(ZCACHE_GFP_MASK); + znewpage2 = alloc_page(ZCACHE_GFP_MASK); + if (znewpage1 == NULL) + evictpage1 = zcache_evict_eph_pageframe(); + if (znewpage2 == NULL) + evictpage2 = zcache_evict_eph_pageframe(); + + if ((evictpage1 == NULL || evictpage2 == NULL) && + atomic_read(&zcache_outstanding_writeback_pages_atomic) > + ZCACHE_MAX_OUTSTANDING_WRITEBACK_PAGES) { + goto free_and_out; + } + if (znewpage1 == NULL && evictpage1 == NULL) + newpage1 = alloc_page(GFP_KERNEL); + if (znewpage2 == NULL && evictpage2 == NULL) + newpage2 = alloc_page(GFP_KERNEL); + if (newpage1 == NULL || newpage2 == NULL) + goto free_and_out; + + /* ok, we have two pageframes pre-allocated, get a pair of zbuds */ + nzbuds = zbud_make_zombie_lru(&th[0], NULL, NULL, false); + if (nzbuds == 0) { + ret = -ENOENT; + goto free_and_out; } -ZCACHE_SYSFS_RO(curr_obj_count_max); -ZCACHE_SYSFS_RO(curr_objnode_count_max); -ZCACHE_SYSFS_RO(flush_total); -ZCACHE_SYSFS_RO(flush_found); -ZCACHE_SYSFS_RO(flobj_total); -ZCACHE_SYSFS_RO(flobj_found); -ZCACHE_SYSFS_RO(failed_eph_puts); -ZCACHE_SYSFS_RO(failed_pers_puts); -ZCACHE_SYSFS_RO(zbud_curr_zbytes); -ZCACHE_SYSFS_RO(zbud_cumul_zpages); -ZCACHE_SYSFS_RO(zbud_cumul_zbytes); -ZCACHE_SYSFS_RO(zbud_buddied_count); -ZCACHE_SYSFS_RO(zbpg_unused_list_count); -ZCACHE_SYSFS_RO(evicted_raw_pages); -ZCACHE_SYSFS_RO(evicted_unbuddied_pages); -ZCACHE_SYSFS_RO(evicted_buddied_pages); -ZCACHE_SYSFS_RO(failed_get_free_pages); -ZCACHE_SYSFS_RO(failed_alloc); -ZCACHE_SYSFS_RO(put_to_flush); -ZCACHE_SYSFS_RO(compress_poor); -ZCACHE_SYSFS_RO(mean_compress_poor); -ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_raw_pages); -ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_zpages); -ZCACHE_SYSFS_RO_ATOMIC(curr_obj_count); -ZCACHE_SYSFS_RO_ATOMIC(curr_objnode_count); -ZCACHE_SYSFS_RO_CUSTOM(zbud_unbuddied_list_counts, - zbud_show_unbuddied_list_counts); -ZCACHE_SYSFS_RO_CUSTOM(zbud_cumul_chunk_counts, - zbud_show_cumul_chunk_counts); -ZCACHE_SYSFS_RO_CUSTOM(zv_curr_dist_counts, - zv_curr_dist_counts_show); -ZCACHE_SYSFS_RO_CUSTOM(zv_cumul_dist_counts, - zv_cumul_dist_counts_show); - -static struct attribute *zcache_attrs[] = { - &zcache_curr_obj_count_attr.attr, - &zcache_curr_obj_count_max_attr.attr, - &zcache_curr_objnode_count_attr.attr, - &zcache_curr_objnode_count_max_attr.attr, - &zcache_flush_total_attr.attr, - &zcache_flobj_total_attr.attr, - &zcache_flush_found_attr.attr, - &zcache_flobj_found_attr.attr, - &zcache_failed_eph_puts_attr.attr, - &zcache_failed_pers_puts_attr.attr, - &zcache_compress_poor_attr.attr, - &zcache_mean_compress_poor_attr.attr, - &zcache_zbud_curr_raw_pages_attr.attr, - &zcache_zbud_curr_zpages_attr.attr, - &zcache_zbud_curr_zbytes_attr.attr, - &zcache_zbud_cumul_zpages_attr.attr, - &zcache_zbud_cumul_zbytes_attr.attr, - &zcache_zbud_buddied_count_attr.attr, - &zcache_zbpg_unused_list_count_attr.attr, - &zcache_evicted_raw_pages_attr.attr, - &zcache_evicted_unbuddied_pages_attr.attr, - &zcache_evicted_buddied_pages_attr.attr, - &zcache_failed_get_free_pages_attr.attr, - &zcache_failed_alloc_attr.attr, - &zcache_put_to_flush_attr.attr, - &zcache_zbud_unbuddied_list_counts_attr.attr, - &zcache_zbud_cumul_chunk_counts_attr.attr, - &zcache_zv_curr_dist_counts_attr.attr, - &zcache_zv_cumul_dist_counts_attr.attr, - &zcache_zv_max_zsize_attr.attr, - &zcache_zv_max_mean_zsize_attr.attr, - &zcache_zv_page_count_policy_percent_attr.attr, - NULL, -}; + /* process the first zbud */ + unswiz(th[0].oid, th[0].index, &type, &offset); + page1 = (znewpage1 != NULL) ? znewpage1 : + ((newpage1 != NULL) ? newpage1 : evictpage1); + writeback_ret = zcache_frontswap_writeback_zpage(type, offset, page1); + if (writeback_ret < 0) { + ret = -ENOMEM; + goto free_and_out; + } + if (evictpage1 != NULL) + zcache_pageframes_freed = + atomic_inc_return(&zcache_pageframes_freed_atomic); + if (writeback_ret == 0) { + /* zcache_get_swap_cache_page will free, don't double free */ + znewpage1 = NULL; + newpage1 = NULL; + evictpage1 = NULL; + } + if (nzbuds < 2) + goto free_and_out; + + /* if there is a second zbud, process it */ + unswiz(th[1].oid, th[1].index, &type, &offset); + page2 = (znewpage2 != NULL) ? znewpage2 : + ((newpage2 != NULL) ? newpage2 : evictpage2); + writeback_ret = zcache_frontswap_writeback_zpage(type, offset, page2); + if (writeback_ret < 0) { + ret = -ENOMEM; + goto free_and_out; + } + if (evictpage2 != NULL) + zcache_pageframes_freed = + atomic_inc_return(&zcache_pageframes_freed_atomic); + if (writeback_ret == 0) { + znewpage2 = NULL; + newpage2 = NULL; + evictpage2 = NULL; + } -static struct attribute_group zcache_attr_group = { - .attrs = zcache_attrs, - .name = "zcache", -}; +free_and_out: + if (znewpage1 != NULL) + page_cache_release(znewpage1); + if (znewpage2 != NULL) + page_cache_release(znewpage2); + if (newpage1 != NULL) + page_cache_release(newpage1); + if (newpage2 != NULL) + page_cache_release(newpage2); + if (evictpage1 != NULL) + zcache_free_page(evictpage1); + if (evictpage2 != NULL) + zcache_free_page(evictpage2); + return ret; +} +#endif /* CONFIG_ZCACHE_WRITEBACK */ -#endif /* CONFIG_SYSFS */ /* * When zcache is disabled ("frozen"), pools can be created and destroyed, * but all puts (and thus all other operations that require memory allocation) @@ -1525,23 +1245,81 @@ static struct attribute_group zcache_attr_group = { static bool zcache_freeze; /* - * zcache shrinker interface (only useful for ephemeral pages, so zbud only) + * This zcache shrinker interface reduces the number of ephemeral pageframes + * used by zcache to approximately the same as the total number of LRU_FILE + * pageframes in use, and now also reduces the number of persistent pageframes + * used by zcache to approximately the same as the total number of LRU_ANON + * pageframes in use. FIXME POLICY: Probably the writeback should only occur + * if the eviction doesn't free enough pages. */ static int shrink_zcache_memory(struct shrinker *shrink, struct shrink_control *sc) { + static bool in_progress; int ret = -1; int nr = sc->nr_to_scan; - gfp_t gfp_mask = sc->gfp_mask; + int nr_evict = 0; + int nr_writeback = 0; + struct page *page; + int file_pageframes_inuse, anon_pageframes_inuse; + + if (nr <= 0) + goto skip_evict; + + /* don't allow more than one eviction thread at a time */ + if (in_progress) + goto skip_evict; + + in_progress = true; + + /* we are going to ignore nr, and target a different value */ + zcache_last_active_file_pageframes = + global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); + zcache_last_inactive_file_pageframes = + global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); + file_pageframes_inuse = zcache_last_active_file_pageframes + + zcache_last_inactive_file_pageframes; + if (zcache_eph_pageframes > file_pageframes_inuse) + nr_evict = zcache_eph_pageframes - file_pageframes_inuse; + else + nr_evict = 0; + while (nr_evict-- > 0) { + page = zcache_evict_eph_pageframe(); + if (page == NULL) + break; + zcache_free_page(page); + } - if (nr >= 0) { - if (!(gfp_mask & __GFP_FS)) - /* does this case really need to be skipped? */ - goto out; - zbud_evict_pages(nr); + zcache_last_active_anon_pageframes = + global_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON); + zcache_last_inactive_anon_pageframes = + global_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON); + anon_pageframes_inuse = zcache_last_active_anon_pageframes + + zcache_last_inactive_anon_pageframes; + if (zcache_pers_pageframes > anon_pageframes_inuse) + nr_writeback = zcache_pers_pageframes - anon_pageframes_inuse; + else + nr_writeback = 0; + while (nr_writeback-- > 0) { +#ifdef CONFIG_ZCACHE_WRITEBACK + int writeback_ret; + writeback_ret = zcache_frontswap_writeback(); + if (writeback_ret == -ENOMEM) +#endif + break; } - ret = (int)atomic_read(&zcache_zbud_curr_raw_pages); -out: + in_progress = false; + +skip_evict: + /* resample: has changed, but maybe not all the way yet */ + zcache_last_active_file_pageframes = + global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); + zcache_last_inactive_file_pageframes = + global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); + ret = zcache_eph_pageframes - zcache_last_active_file_pageframes + + zcache_last_inactive_file_pageframes; + if (ret < 0) + ret = 0; return ret; } @@ -1554,59 +1332,86 @@ static struct shrinker zcache_shrinker = { * zcache shims between cleancache/frontswap ops and tmem */ -static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, struct page *page) +/* FIXME rename these core routines to zcache_tmemput etc? */ +int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, + uint32_t index, void *page, + unsigned int size, bool raw, int ephemeral) { struct tmem_pool *pool; + struct tmem_handle th; int ret = -1; + void *pampd = NULL; BUG_ON(!irqs_disabled()); pool = zcache_get_pool_by_id(cli_id, pool_id); if (unlikely(pool == NULL)) goto out; - if (!zcache_freeze && zcache_do_preload(pool) == 0) { - /* preload does preempt_disable on success */ - ret = tmem_put(pool, oidp, index, (char *)(page), - PAGE_SIZE, 0, is_ephemeral(pool)); - if (ret < 0) { - if (is_ephemeral(pool)) + if (!zcache_freeze) { + ret = 0; + th.client_id = cli_id; + th.pool_id = pool_id; + th.oid = *oidp; + th.index = index; + pampd = zcache_pampd_create((char *)page, size, raw, + ephemeral, &th); + if (pampd == NULL) { + ret = -ENOMEM; + if (ephemeral) zcache_failed_eph_puts++; else zcache_failed_pers_puts++; + } else { + if (ramster_enabled) + ramster_do_preload_flnode(pool); + ret = tmem_put(pool, oidp, index, 0, pampd); + if (ret < 0) + BUG(); } + zcache_put_pool(pool); } else { zcache_put_to_flush++; + if (ramster_enabled) + ramster_do_preload_flnode(pool); if (atomic_read(&pool->obj_count) > 0) /* the put fails whether the flush succeeds or not */ (void)tmem_flush_page(pool, oidp, index); + zcache_put_pool(pool); } - - zcache_put_pool(pool); out: return ret; } -static int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, struct page *page) +int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp, + uint32_t index, void *page, + size_t *sizep, bool raw, int get_and_free) { struct tmem_pool *pool; int ret = -1; - unsigned long flags; - size_t size = PAGE_SIZE; + bool eph; - local_irq_save(flags); + if (!raw) { + BUG_ON(irqs_disabled()); + BUG_ON(in_softirq()); + } pool = zcache_get_pool_by_id(cli_id, pool_id); + eph = is_ephemeral(pool); if (likely(pool != NULL)) { if (atomic_read(&pool->obj_count) > 0) ret = tmem_get(pool, oidp, index, (char *)(page), - &size, 0, is_ephemeral(pool)); + sizep, raw, get_and_free); zcache_put_pool(pool); } - local_irq_restore(flags); + WARN_ONCE((!is_ephemeral(pool) && (ret != 0)), + "zcache_get fails on persistent pool, " + "bad things are very likely to happen soon\n"); +#ifdef RAMSTER_TESTING + if (ret != 0 && ret != -1 && !(ret == -EINVAL && is_ephemeral(pool))) + pr_err("TESTING zcache_get tmem_get returns ret=%d\n", ret); +#endif return ret; } -static int zcache_flush_page(int cli_id, int pool_id, +int zcache_flush_page(int cli_id, int pool_id, struct tmem_oid *oidp, uint32_t index) { struct tmem_pool *pool; @@ -1616,6 +1421,8 @@ static int zcache_flush_page(int cli_id, int pool_id, local_irq_save(flags); zcache_flush_total++; pool = zcache_get_pool_by_id(cli_id, pool_id); + if (ramster_enabled) + ramster_do_preload_flnode(pool); if (likely(pool != NULL)) { if (atomic_read(&pool->obj_count) > 0) ret = tmem_flush_page(pool, oidp, index); @@ -1627,7 +1434,7 @@ static int zcache_flush_page(int cli_id, int pool_id, return ret; } -static int zcache_flush_object(int cli_id, int pool_id, +int zcache_flush_object(int cli_id, int pool_id, struct tmem_oid *oidp) { struct tmem_pool *pool; @@ -1637,6 +1444,8 @@ static int zcache_flush_object(int cli_id, int pool_id, local_irq_save(flags); zcache_flobj_total++; pool = zcache_get_pool_by_id(cli_id, pool_id); + if (ramster_enabled) + ramster_do_preload_flnode(pool); if (likely(pool != NULL)) { if (atomic_read(&pool->obj_count) > 0) ret = tmem_flush_object(pool, oidp); @@ -1648,24 +1457,25 @@ static int zcache_flush_object(int cli_id, int pool_id, return ret; } -static int zcache_destroy_pool(int cli_id, int pool_id) +static int zcache_client_destroy_pool(int cli_id, int pool_id) { struct tmem_pool *pool = NULL; - struct zcache_client *cli; + struct zcache_client *cli = NULL; int ret = -1; if (pool_id < 0) goto out; - - cli = get_zcache_client(cli_id); + if (cli_id == LOCAL_CLIENT) + cli = &zcache_host; + else if ((unsigned int)cli_id < MAX_CLIENTS) + cli = &zcache_clients[cli_id]; if (cli == NULL) goto out; - atomic_inc(&cli->refcount); - pool = idr_find(&cli->tmem_pools, pool_id); + pool = cli->tmem_pools[pool_id]; if (pool == NULL) goto out; - idr_remove(&cli->tmem_pools, pool_id); + cli->tmem_pools[pool_id] = NULL; /* wait for pool activity on other cpus to quiesce */ while (atomic_read(&pool->refcount) != 0) ; @@ -1674,56 +1484,119 @@ static int zcache_destroy_pool(int cli_id, int pool_id) ret = tmem_destroy_pool(pool); local_bh_enable(); kfree(pool); - pr_info("zcache: destroyed pool id=%d, cli_id=%d\n", - pool_id, cli_id); + if (cli_id == LOCAL_CLIENT) + pr_info("%s: destroyed local pool id=%d\n", namestr, pool_id); + else + pr_info("%s: destroyed pool id=%d, client=%d\n", + namestr, pool_id, cli_id); out: return ret; } -static int zcache_new_pool(uint16_t cli_id, uint32_t flags) +int zcache_new_pool(uint16_t cli_id, uint32_t flags) { int poolid = -1; struct tmem_pool *pool; struct zcache_client *cli = NULL; - int r; - cli = get_zcache_client(cli_id); + if (cli_id == LOCAL_CLIENT) + cli = &zcache_host; + else if ((unsigned int)cli_id < MAX_CLIENTS) + cli = &zcache_clients[cli_id]; if (cli == NULL) goto out; - atomic_inc(&cli->refcount); pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); - if (pool == NULL) { - pr_info("zcache: pool creation failed: out of memory\n"); + if (pool == NULL) + goto out; + + for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++) + if (cli->tmem_pools[poolid] == NULL) + break; + if (poolid >= MAX_POOLS_PER_CLIENT) { + pr_info("%s: pool creation failed: max exceeded\n", namestr); + kfree(pool); + poolid = -1; goto out; } + atomic_set(&pool->refcount, 0); + pool->client = cli; + pool->pool_id = poolid; + tmem_new_pool(pool, flags); + cli->tmem_pools[poolid] = pool; + if (cli_id == LOCAL_CLIENT) + pr_info("%s: created %s local tmem pool, id=%d\n", namestr, + flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", + poolid); + else + pr_info("%s: created %s tmem pool, id=%d, client=%d\n", namestr, + flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", + poolid, cli_id); +out: + if (cli != NULL) + atomic_dec(&cli->refcount); + return poolid; +} - do { - r = idr_pre_get(&cli->tmem_pools, GFP_ATOMIC); - if (r != 1) { - kfree(pool); - pr_info("zcache: pool creation failed: out of memory\n"); +static int zcache_local_new_pool(uint32_t flags) +{ + return zcache_new_pool(LOCAL_CLIENT, flags); +} + +int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph) +{ + struct tmem_pool *pool; + struct zcache_client *cli; + uint32_t flags = eph ? 0 : TMEM_POOL_PERSIST; + int ret = -1; + + BUG_ON(!ramster_enabled); + if (cli_id == LOCAL_CLIENT) + goto out; + if (pool_id >= MAX_POOLS_PER_CLIENT) + goto out; + if (cli_id >= MAX_CLIENTS) + goto out; + + cli = &zcache_clients[cli_id]; + if ((eph && disable_cleancache) || (!eph && disable_frontswap)) { + pr_err("zcache_autocreate_pool: pool type disabled\n"); + goto out; + } + if (!cli->allocated) { + if (zcache_new_client(cli_id)) { + pr_err("zcache_autocreate_pool: can't create client\n"); goto out; } - r = idr_get_new(&cli->tmem_pools, pool, &poolid); - } while (r == -EAGAIN); - if (r) { - pr_info("zcache: pool creation failed: error %d\n", r); - kfree(pool); + cli = &zcache_clients[cli_id]; + } + atomic_inc(&cli->refcount); + pool = cli->tmem_pools[pool_id]; + if (pool != NULL) { + if (pool->persistent && eph) { + pr_err("zcache_autocreate_pool: type mismatch\n"); + goto out; + } + ret = 0; goto out; } + pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL); + if (pool == NULL) + goto out; atomic_set(&pool->refcount, 0); pool->client = cli; - pool->pool_id = poolid; + pool->pool_id = pool_id; tmem_new_pool(pool, flags); - pr_info("zcache: created %s tmem pool, id=%d, client=%d\n", - flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - poolid, cli_id); + cli->tmem_pools[pool_id] = pool; + pr_info("%s: AUTOcreated %s tmem poolid=%d, for remote client=%d\n", + namestr, flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", + pool_id, cli_id); + ret = 0; out: if (cli != NULL) atomic_dec(&cli->refcount); - return poolid; + return ret; } /********** @@ -1734,7 +1607,6 @@ out: * to translate in-kernel semantics to zcache semantics. */ -#ifdef CONFIG_CLEANCACHE static void zcache_cleancache_put_page(int pool_id, struct cleancache_filekey key, pgoff_t index, struct page *page) @@ -1742,8 +1614,13 @@ static void zcache_cleancache_put_page(int pool_id, u32 ind = (u32) index; struct tmem_oid oid = *(struct tmem_oid *)&key; + if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) { + zcache_eph_nonactive_puts_ignored++; + return; + } if (likely(ind == index)) - (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index, page); + (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index, + page, PAGE_SIZE, false, 1); } static int zcache_cleancache_get_page(int pool_id, @@ -1752,10 +1629,16 @@ static int zcache_cleancache_get_page(int pool_id, { u32 ind = (u32) index; struct tmem_oid oid = *(struct tmem_oid *)&key; + size_t size; int ret = -1; - if (likely(ind == index)) - ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index, page); + if (likely(ind == index)) { + ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index, + page, &size, false, 0); + BUG_ON(ret >= 0 && size != PAGE_SIZE); + if (ret == 0) + SetPageWasActive(page); + } return ret; } @@ -1781,7 +1664,7 @@ static void zcache_cleancache_flush_inode(int pool_id, static void zcache_cleancache_flush_fs(int pool_id) { if (pool_id >= 0) - (void)zcache_destroy_pool(LOCAL_CLIENT, pool_id); + (void)zcache_client_destroy_pool(LOCAL_CLIENT, pool_id); } static int zcache_cleancache_init_fs(size_t pagesize) @@ -1789,7 +1672,7 @@ static int zcache_cleancache_init_fs(size_t pagesize) BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid)); BUG_ON(pagesize != PAGE_SIZE); - return zcache_new_pool(LOCAL_CLIENT, 0); + return zcache_local_new_pool(0); } static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize) @@ -1798,7 +1681,7 @@ static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize) BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid)); BUG_ON(pagesize != PAGE_SIZE); - return zcache_new_pool(LOCAL_CLIENT, 0); + return zcache_local_new_pool(0); } static struct cleancache_ops zcache_cleancache_ops = { @@ -1818,17 +1701,15 @@ struct cleancache_ops zcache_cleancache_register_ops(void) return old_ops; } -#endif -#ifdef CONFIG_FRONTSWAP /* a single tmem poolid is used for all frontswap "types" (swapfiles) */ -static int zcache_frontswap_poolid = -1; +static int zcache_frontswap_poolid __read_mostly = -1; /* * Swizzling increases objects per swaptype, increasing tmem concurrency * for heavy swaploads. Later, larger nr_cpus -> larger SWIZ_BITS * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from - * frontswap_load(), but has side-effects. Hence using 8. + * frontswap_get_page(), but has side-effects. Hence using 8. */ #define SWIZ_BITS 8 #define SWIZ_MASK ((1 << SWIZ_BITS) - 1) @@ -1842,8 +1723,18 @@ static inline struct tmem_oid oswiz(unsigned type, u32 ind) return oid; } -static int zcache_frontswap_store(unsigned type, pgoff_t offset, - struct page *page) +#ifdef CONFIG_ZCACHE_WRITEBACK +static void unswiz(struct tmem_oid oid, u32 index, + unsigned *type, pgoff_t *offset) +{ + *type = (unsigned)(oid.oid[0] >> SWIZ_BITS); + *offset = (pgoff_t)((index << SWIZ_BITS) | + (oid.oid[0] & SWIZ_MASK)); +} +#endif + +static int zcache_frontswap_put_page(unsigned type, pgoff_t offset, + struct page *page) { u64 ind64 = (u64)offset; u32 ind = (u32)offset; @@ -1852,29 +1743,44 @@ static int zcache_frontswap_store(unsigned type, pgoff_t offset, unsigned long flags; BUG_ON(!PageLocked(page)); + if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) { + zcache_pers_nonactive_puts_ignored++; + ret = -ERANGE; + goto out; + } if (likely(ind64 == ind)) { local_irq_save(flags); ret = zcache_put_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), page); + &oid, iswiz(ind), + page, PAGE_SIZE, false, 0); local_irq_restore(flags); } +out: return ret; } /* returns 0 if the page was successfully gotten from frontswap, -1 if * was not present (should never happen!) */ -static int zcache_frontswap_load(unsigned type, pgoff_t offset, - struct page *page) +static int zcache_frontswap_get_page(unsigned type, pgoff_t offset, + struct page *page) { u64 ind64 = (u64)offset; u32 ind = (u32)offset; struct tmem_oid oid = oswiz(type, ind); - int ret = -1; + size_t size; + int ret = -1, get_and_free; + if (frontswap_has_exclusive_gets) + get_and_free = 1; + else + get_and_free = -1; BUG_ON(!PageLocked(page)); - if (likely(ind64 == ind)) + if (likely(ind64 == ind)) { ret = zcache_get_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), page); + &oid, iswiz(ind), + page, &size, false, get_and_free); + BUG_ON(ret >= 0 && size != PAGE_SIZE); + } return ret; } @@ -1908,12 +1814,12 @@ static void zcache_frontswap_init(unsigned ignored) /* a single tmem poolid is used for all frontswap "types" (swapfiles) */ if (zcache_frontswap_poolid < 0) zcache_frontswap_poolid = - zcache_new_pool(LOCAL_CLIENT, TMEM_POOL_PERSIST); + zcache_local_new_pool(TMEM_POOL_PERSIST); } static struct frontswap_ops zcache_frontswap_ops = { - .store = zcache_frontswap_store, - .load = zcache_frontswap_load, + .store = zcache_frontswap_put_page, + .load = zcache_frontswap_get_page, .invalidate_page = zcache_frontswap_flush_page, .invalidate_area = zcache_frontswap_flush_area, .init = zcache_frontswap_init @@ -1926,16 +1832,13 @@ struct frontswap_ops zcache_frontswap_register_ops(void) return old_ops; } -#endif /* * zcache initialization - * NOTE FOR NOW zcache MUST BE PROVIDED AS A KERNEL BOOT PARAMETER OR - * NOTHING HAPPENS! + * NOTE FOR NOW zcache or ramster MUST BE PROVIDED AS A KERNEL BOOT PARAMETER + * OR NOTHING HAPPENS! */ -static int zcache_enabled; - static int __init enable_zcache(char *s) { zcache_enabled = 1; @@ -1943,28 +1846,58 @@ static int __init enable_zcache(char *s) } __setup("zcache", enable_zcache); -/* allow independent dynamic disabling of cleancache and frontswap */ +static int __init enable_ramster(char *s) +{ + zcache_enabled = 1; +#ifdef CONFIG_RAMSTER + ramster_enabled = 1; +#endif + return 1; +} +__setup("ramster", enable_ramster); -static int use_cleancache = 1; +/* allow independent dynamic disabling of cleancache and frontswap */ static int __init no_cleancache(char *s) { - use_cleancache = 0; + disable_cleancache = 1; return 1; } __setup("nocleancache", no_cleancache); -static int use_frontswap = 1; - static int __init no_frontswap(char *s) { - use_frontswap = 0; + disable_frontswap = 1; return 1; } __setup("nofrontswap", no_frontswap); +static int __init no_frontswap_exclusive_gets(char *s) +{ + frontswap_has_exclusive_gets = false; + return 1; +} + +__setup("nofrontswapexclusivegets", no_frontswap_exclusive_gets); + +static int __init no_frontswap_ignore_nonactive(char *s) +{ + disable_frontswap_ignore_nonactive = 1; + return 1; +} + +__setup("nofrontswapignorenonactive", no_frontswap_ignore_nonactive); + +static int __init no_cleancache_ignore_nonactive(char *s) +{ + disable_cleancache_ignore_nonactive = 1; + return 1; +} + +__setup("nocleancacheignorenonactive", no_cleancache_ignore_nonactive); + static int __init enable_zcache_compressor(char *s) { strncpy(zcache_comp_name, s, ZCACHE_COMP_NAME_SZ); @@ -2007,14 +1940,13 @@ static int __init zcache_init(void) { int ret = 0; -#ifdef CONFIG_SYSFS - ret = sysfs_create_group(mm_kobj, &zcache_attr_group); - if (ret) { - pr_err("zcache: can't create sysfs\n"); - goto out; + if (ramster_enabled) { + namestr = "ramster"; + ramster_register_pamops(&zcache_pamops); } -#endif /* CONFIG_SYSFS */ - +#ifdef CONFIG_DEBUG_FS + zcache_debugfs_init(); +#endif if (zcache_enabled) { unsigned int cpu; @@ -2022,12 +1954,13 @@ static int __init zcache_init(void) tmem_register_pamops(&zcache_pamops); ret = register_cpu_notifier(&zcache_cpu_notifier_block); if (ret) { - pr_err("zcache: can't register cpu notifier\n"); + pr_err("%s: can't register cpu notifier\n", namestr); goto out; } ret = zcache_comp_init(); if (ret) { - pr_err("zcache: compressor initialization failed\n"); + pr_err("%s: compressor initialization failed\n", + namestr); goto out; } for_each_online_cpu(cpu) { @@ -2042,36 +1975,45 @@ static int __init zcache_init(void) sizeof(struct tmem_obj), 0, 0, NULL); ret = zcache_new_client(LOCAL_CLIENT); if (ret) { - pr_err("zcache: can't create client\n"); + pr_err("%s: can't create client\n", namestr); goto out; } - -#ifdef CONFIG_CLEANCACHE - if (zcache_enabled && use_cleancache) { + zbud_init(); + if (zcache_enabled && !disable_cleancache) { struct cleancache_ops old_ops; - zbud_init(); register_shrinker(&zcache_shrinker); old_ops = zcache_cleancache_register_ops(); - pr_info("zcache: cleancache enabled using kernel " - "transcendent memory and compression buddies\n"); + pr_info("%s: cleancache enabled using kernel transcendent " + "memory and compression buddies\n", namestr); +#ifdef ZCACHE_DEBUG + pr_info("%s: cleancache: ignorenonactive = %d\n", + namestr, !disable_cleancache_ignore_nonactive); +#endif if (old_ops.init_fs != NULL) - pr_warning("zcache: cleancache_ops overridden"); + pr_warn("%s: cleancache_ops overridden\n", namestr); } -#endif -#ifdef CONFIG_FRONTSWAP - if (zcache_enabled && use_frontswap) { + if (zcache_enabled && !disable_frontswap) { struct frontswap_ops old_ops; old_ops = zcache_frontswap_register_ops(); - pr_info("zcache: frontswap enabled using kernel " - "transcendent memory and zsmalloc\n"); + if (frontswap_has_exclusive_gets) + frontswap_tmem_exclusive_gets(true); + pr_info("%s: frontswap enabled using kernel transcendent " + "memory and compression buddies\n", namestr); +#ifdef ZCACHE_DEBUG + pr_info("%s: frontswap: excl gets = %d active only = %d\n", + namestr, frontswap_has_exclusive_gets, + !disable_frontswap_ignore_nonactive); +#endif if (old_ops.init != NULL) - pr_warning("zcache: frontswap_ops overridden"); + pr_warn("%s: frontswap_ops overridden\n", namestr); } -#endif + if (ramster_enabled) + ramster_init(!disable_cleancache, !disable_frontswap, + frontswap_has_exclusive_gets); out: return ret; } -module_init(zcache_init) +late_initcall(zcache_init); diff --git a/drivers/staging/ramster/zcache.h b/drivers/staging/zcache/zcache.h index 81722b3..81722b3 100644 --- a/drivers/staging/ramster/zcache.h +++ b/drivers/staging/zcache/zcache.h diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig index be5abe8..983314c 100644 --- a/drivers/staging/zram/Kconfig +++ b/drivers/staging/zram/Kconfig @@ -14,7 +14,7 @@ config ZRAM disks and maybe many more. See zram.txt for more information. - Project home: http://compcache.googlecode.com/ + Project home: <https://compcache.googlecode.com/> config ZRAM_DEBUG bool "Compressed RAM block device debug support" diff --git a/drivers/staging/zram/zram.txt b/drivers/staging/zram/zram.txt index 5f75d29..765d790 100644 --- a/drivers/staging/zram/zram.txt +++ b/drivers/staging/zram/zram.txt @@ -23,17 +23,17 @@ Following shows a typical sequence of steps for using zram. This creates 4 devices: /dev/zram{0,1,2,3} (num_devices parameter is optional. Default: 1) -2) Set Disksize (Optional): - Set disk size by writing the value to sysfs node 'disksize' - (in bytes). If disksize is not given, default value of 25% - of RAM is used. - - # Initialize /dev/zram0 with 50MB disksize - echo $((50*1024*1024)) > /sys/block/zram0/disksize - - NOTE: disksize cannot be changed if the disk contains any - data. So, for such a disk, you need to issue 'reset' (see below) - before you can change its disksize. +2) Set Disksize + Set disk size by writing the value to sysfs node 'disksize'. + The value can be either in bytes or you can use mem suffixes. + Examples: + # Initialize /dev/zram0 with 50MB disksize + echo $((50*1024*1024)) > /sys/block/zram0/disksize + + # Using mem suffixes + echo 256K > /sys/block/zram0/disksize + echo 512M > /sys/block/zram0/disksize + echo 1G > /sys/block/zram0/disksize 3) Activate: mkswap /dev/zram0 @@ -65,8 +65,9 @@ Following shows a typical sequence of steps for using zram. echo 1 > /sys/block/zram0/reset echo 1 > /sys/block/zram1/reset - (This frees all the memory allocated for the given device). - + This frees all the memory allocated for the given device and + resets the disksize to zero. You must set the disksize again + before reusing the device. Please report any problems at: - Mailing list: linux-mm-cc at laptop dot org diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index f2a73bd..5918fd7 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -40,17 +40,7 @@ static int zram_major; struct zram *zram_devices; /* Module params (documentation at end) */ -static unsigned int num_devices; - -static void zram_stat_inc(u32 *v) -{ - *v = *v + 1; -} - -static void zram_stat_dec(u32 *v) -{ - *v = *v - 1; -} +static unsigned int num_devices = 1; static void zram_stat64_add(struct zram *zram, u64 *v, u64 inc) { @@ -71,22 +61,22 @@ static void zram_stat64_inc(struct zram *zram, u64 *v) zram_stat64_add(zram, v, 1); } -static int zram_test_flag(struct zram *zram, u32 index, +static int zram_test_flag(struct zram_meta *meta, u32 index, enum zram_pageflags flag) { - return zram->table[index].flags & BIT(flag); + return meta->table[index].flags & BIT(flag); } -static void zram_set_flag(struct zram *zram, u32 index, +static void zram_set_flag(struct zram_meta *meta, u32 index, enum zram_pageflags flag) { - zram->table[index].flags |= BIT(flag); + meta->table[index].flags |= BIT(flag); } -static void zram_clear_flag(struct zram *zram, u32 index, +static void zram_clear_flag(struct zram_meta *meta, u32 index, enum zram_pageflags flag) { - zram->table[index].flags &= ~BIT(flag); + meta->table[index].flags &= ~BIT(flag); } static int page_zero_filled(void *ptr) @@ -104,66 +94,38 @@ static int page_zero_filled(void *ptr) return 1; } -static void zram_set_disksize(struct zram *zram, size_t totalram_bytes) -{ - if (!zram->disksize) { - pr_info( - "disk size not provided. You can use disksize_kb module " - "param to specify size.\nUsing default: (%u%% of RAM).\n", - default_disksize_perc_ram - ); - zram->disksize = default_disksize_perc_ram * - (totalram_bytes / 100); - } - - if (zram->disksize > 2 * (totalram_bytes)) { - pr_info( - "There is little point creating a zram of greater than " - "twice the size of memory since we expect a 2:1 compression " - "ratio. Note that zram uses about 0.1%% of the size of " - "the disk when not in use so a huge zram is " - "wasteful.\n" - "\tMemory Size: %zu kB\n" - "\tSize you selected: %llu kB\n" - "Continuing anyway ...\n", - totalram_bytes >> 10, zram->disksize - ); - } - - zram->disksize &= PAGE_MASK; -} - static void zram_free_page(struct zram *zram, size_t index) { - unsigned long handle = zram->table[index].handle; - u16 size = zram->table[index].size; + struct zram_meta *meta = zram->meta; + unsigned long handle = meta->table[index].handle; + u16 size = meta->table[index].size; if (unlikely(!handle)) { /* * No memory is allocated for zero filled pages. * Simply clear zero page flag. */ - if (zram_test_flag(zram, index, ZRAM_ZERO)) { - zram_clear_flag(zram, index, ZRAM_ZERO); - zram_stat_dec(&zram->stats.pages_zero); + if (zram_test_flag(meta, index, ZRAM_ZERO)) { + zram_clear_flag(meta, index, ZRAM_ZERO); + zram->stats.pages_zero--; } return; } if (unlikely(size > max_zpage_size)) - zram_stat_dec(&zram->stats.bad_compress); + zram->stats.bad_compress--; - zs_free(zram->mem_pool, handle); + zs_free(meta->mem_pool, handle); if (size <= PAGE_SIZE / 2) - zram_stat_dec(&zram->stats.good_compress); + zram->stats.good_compress--; zram_stat64_sub(zram, &zram->stats.compr_size, - zram->table[index].size); - zram_stat_dec(&zram->stats.pages_stored); + meta->table[index].size); + zram->stats.pages_stored--; - zram->table[index].handle = 0; - zram->table[index].size = 0; + meta->table[index].handle = 0; + meta->table[index].size = 0; } static void handle_zero_page(struct bio_vec *bvec) @@ -188,20 +150,21 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index) int ret = LZO_E_OK; size_t clen = PAGE_SIZE; unsigned char *cmem; - unsigned long handle = zram->table[index].handle; + struct zram_meta *meta = zram->meta; + unsigned long handle = meta->table[index].handle; - if (!handle || zram_test_flag(zram, index, ZRAM_ZERO)) { + if (!handle || zram_test_flag(meta, index, ZRAM_ZERO)) { memset(mem, 0, PAGE_SIZE); return 0; } - cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO); - if (zram->table[index].size == PAGE_SIZE) + cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO); + if (meta->table[index].size == PAGE_SIZE) memcpy(mem, cmem, PAGE_SIZE); else - ret = lzo1x_decompress_safe(cmem, zram->table[index].size, + ret = lzo1x_decompress_safe(cmem, meta->table[index].size, mem, &clen); - zs_unmap_object(zram->mem_pool, handle); + zs_unmap_object(meta->mem_pool, handle); /* Should NEVER happen. Return bio error if it does. */ if (unlikely(ret != LZO_E_OK)) { @@ -219,20 +182,21 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, int ret; struct page *page; unsigned char *user_mem, *uncmem = NULL; - + struct zram_meta *meta = zram->meta; page = bvec->bv_page; - if (unlikely(!zram->table[index].handle) || - zram_test_flag(zram, index, ZRAM_ZERO)) { + if (unlikely(!meta->table[index].handle) || + zram_test_flag(meta, index, ZRAM_ZERO)) { handle_zero_page(bvec); return 0; } - user_mem = kmap_atomic(page); if (is_partial_io(bvec)) /* Use a temporary buffer to decompress the page */ - uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL); - else + uncmem = kmalloc(PAGE_SIZE, GFP_NOIO); + + user_mem = kmap_atomic(page); + if (!is_partial_io(bvec)) uncmem = user_mem; if (!uncmem) { @@ -270,18 +234,18 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, unsigned long handle; struct page *page; unsigned char *user_mem, *cmem, *src, *uncmem = NULL; + struct zram_meta *meta = zram->meta; page = bvec->bv_page; - src = zram->compress_buffer; + src = meta->compress_buffer; if (is_partial_io(bvec)) { /* * This is a partial IO. We need to read the full page * before to write the changes. */ - uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL); + uncmem = kmalloc(PAGE_SIZE, GFP_NOIO); if (!uncmem) { - pr_info("Error allocating temp memory!\n"); ret = -ENOMEM; goto out; } @@ -294,8 +258,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, * System overwrites unused sectors. Free memory associated * with this sector now. */ - if (zram->table[index].handle || - zram_test_flag(zram, index, ZRAM_ZERO)) + if (meta->table[index].handle || + zram_test_flag(meta, index, ZRAM_ZERO)) zram_free_page(zram, index); user_mem = kmap_atomic(page); @@ -310,16 +274,17 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, } if (page_zero_filled(uncmem)) { - if (!is_partial_io(bvec)) - kunmap_atomic(user_mem); - zram_stat_inc(&zram->stats.pages_zero); - zram_set_flag(zram, index, ZRAM_ZERO); + kunmap_atomic(user_mem); + if (is_partial_io(bvec)) + kfree(uncmem); + zram->stats.pages_zero++; + zram_set_flag(meta, index, ZRAM_ZERO); ret = 0; goto out; } ret = lzo1x_1_compress(uncmem, PAGE_SIZE, src, &clen, - zram->compress_workmem); + meta->compress_workmem); if (!is_partial_io(bvec)) { kunmap_atomic(user_mem); @@ -333,21 +298,21 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, } if (unlikely(clen > max_zpage_size)) { - zram_stat_inc(&zram->stats.bad_compress); + zram->stats.bad_compress++; clen = PAGE_SIZE; src = NULL; if (is_partial_io(bvec)) src = uncmem; } - handle = zs_malloc(zram->mem_pool, clen); + handle = zs_malloc(meta->mem_pool, clen); if (!handle) { pr_info("Error allocating memory for compressed " "page: %u, size=%zu\n", index, clen); ret = -ENOMEM; goto out; } - cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_WO); + cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO); if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) src = kmap_atomic(page); @@ -355,16 +320,16 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) kunmap_atomic(src); - zs_unmap_object(zram->mem_pool, handle); + zs_unmap_object(meta->mem_pool, handle); - zram->table[index].handle = handle; - zram->table[index].size = clen; + meta->table[index].handle = handle; + meta->table[index].size = clen; /* Update stats */ zram_stat64_add(zram, &zram->stats.compr_size, clen); - zram_stat_inc(&zram->stats.pages_stored); + zram->stats.pages_stored++; if (clen <= PAGE_SIZE / 2) - zram_stat_inc(&zram->stats.good_compress); + zram->stats.good_compress++; out: if (is_partial_io(bvec)) @@ -479,16 +444,13 @@ static void zram_make_request(struct request_queue *queue, struct bio *bio) { struct zram *zram = queue->queuedata; - if (unlikely(!zram->init_done) && zram_init_device(zram)) - goto error; - down_read(&zram->init_lock); if (unlikely(!zram->init_done)) - goto error_unlock; + goto error; if (!valid_io_request(zram, bio)) { zram_stat64_inc(zram, &zram->stats.invalid_io); - goto error_unlock; + goto error; } __zram_make_request(zram, bio, bio_data_dir(bio)); @@ -496,44 +458,38 @@ static void zram_make_request(struct request_queue *queue, struct bio *bio) return; -error_unlock: - up_read(&zram->init_lock); error: + up_read(&zram->init_lock); bio_io_error(bio); } -void __zram_reset_device(struct zram *zram) +static void __zram_reset_device(struct zram *zram) { size_t index; + struct zram_meta *meta; - zram->init_done = 0; - - /* Free various per-device buffers */ - kfree(zram->compress_workmem); - free_pages((unsigned long)zram->compress_buffer, 1); + if (!zram->init_done) + return; - zram->compress_workmem = NULL; - zram->compress_buffer = NULL; + meta = zram->meta; + zram->init_done = 0; /* Free all pages that are still in this zram device */ for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) { - unsigned long handle = zram->table[index].handle; + unsigned long handle = meta->table[index].handle; if (!handle) continue; - zs_free(zram->mem_pool, handle); + zs_free(meta->mem_pool, handle); } - vfree(zram->table); - zram->table = NULL; - - zs_destroy_pool(zram->mem_pool); - zram->mem_pool = NULL; - + zram_meta_free(zram->meta); + zram->meta = NULL; /* Reset stats */ memset(&zram->stats, 0, sizeof(zram->stats)); zram->disksize = 0; + set_capacity(zram->disk, 0); } void zram_reset_device(struct zram *zram) @@ -543,69 +499,84 @@ void zram_reset_device(struct zram *zram) up_write(&zram->init_lock); } -int zram_init_device(struct zram *zram) +void zram_meta_free(struct zram_meta *meta) { - int ret; - size_t num_pages; - - down_write(&zram->init_lock); - - if (zram->init_done) { - up_write(&zram->init_lock); - return 0; - } + zs_destroy_pool(meta->mem_pool); + kfree(meta->compress_workmem); + free_pages((unsigned long)meta->compress_buffer, 1); + vfree(meta->table); + kfree(meta); +} - zram_set_disksize(zram, totalram_pages << PAGE_SHIFT); +struct zram_meta *zram_meta_alloc(u64 disksize) +{ + size_t num_pages; + struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); + if (!meta) + goto out; - zram->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); - if (!zram->compress_workmem) { - pr_err("Error allocating compressor working memory!\n"); - ret = -ENOMEM; - goto fail_no_table; - } + meta->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); + if (!meta->compress_workmem) + goto free_meta; - zram->compress_buffer = + meta->compress_buffer = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); - if (!zram->compress_buffer) { + if (!meta->compress_buffer) { pr_err("Error allocating compressor buffer space\n"); - ret = -ENOMEM; - goto fail_no_table; + goto free_workmem; } - num_pages = zram->disksize >> PAGE_SHIFT; - zram->table = vzalloc(num_pages * sizeof(*zram->table)); - if (!zram->table) { + num_pages = disksize >> PAGE_SHIFT; + meta->table = vzalloc(num_pages * sizeof(*meta->table)); + if (!meta->table) { pr_err("Error allocating zram address table\n"); - ret = -ENOMEM; - goto fail_no_table; + goto free_buffer; } - set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); + meta->mem_pool = zs_create_pool(GFP_NOIO | __GFP_HIGHMEM); + if (!meta->mem_pool) { + pr_err("Error creating memory pool\n"); + goto free_table; + } - /* zram devices sort of resembles non-rotational disks */ - queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); + return meta; - zram->mem_pool = zs_create_pool("zram", GFP_NOIO | __GFP_HIGHMEM); - if (!zram->mem_pool) { - pr_err("Error creating memory pool\n"); - ret = -ENOMEM; - goto fail; +free_table: + vfree(meta->table); +free_buffer: + free_pages((unsigned long)meta->compress_buffer, 1); +free_workmem: + kfree(meta->compress_workmem); +free_meta: + kfree(meta); + meta = NULL; +out: + return meta; +} + +void zram_init_device(struct zram *zram, struct zram_meta *meta) +{ + if (zram->disksize > 2 * (totalram_pages << PAGE_SHIFT)) { + pr_info( + "There is little point creating a zram of greater than " + "twice the size of memory since we expect a 2:1 compression " + "ratio. Note that zram uses about 0.1%% of the size of " + "the disk when not in use so a huge zram is " + "wasteful.\n" + "\tMemory Size: %lu kB\n" + "\tSize you selected: %llu kB\n" + "Continuing anyway ...\n", + (totalram_pages << PAGE_SHIFT) >> 10, zram->disksize >> 10 + ); } + /* zram devices sort of resembles non-rotational disks */ + queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); + + zram->meta = meta; zram->init_done = 1; - up_write(&zram->init_lock); pr_debug("Initialization done!\n"); - return 0; - -fail_no_table: - /* To prevent accessing table entries during cleanup */ - zram->disksize = 0; -fail: - __zram_reset_device(zram); - up_write(&zram->init_lock); - pr_err("Initialization failed: err=%d\n", ret); - return ret; } static void zram_slot_free_notify(struct block_device *bdev, @@ -724,13 +695,7 @@ static int __init zram_init(void) goto out; } - if (!num_devices) { - pr_info("num_devices not specified. Using default: 1\n"); - num_devices = 1; - } - /* Allocate the device array and initialize each one */ - pr_info("Creating %u devices ...\n", num_devices); zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); if (!zram_devices) { ret = -ENOMEM; @@ -743,6 +708,8 @@ static int __init zram_init(void) goto free_devices; } + pr_info("Created %u device(s) ...\n", num_devices); + return 0; free_devices: @@ -764,8 +731,7 @@ static void __exit zram_exit(void) zram = &zram_devices[i]; destroy_device(zram); - if (zram->init_done) - zram_reset_device(zram); + zram_reset_device(zram); } unregister_blkdev(zram_major, "zram"); diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index df2eec4..2d1a3f1 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -28,9 +28,6 @@ static const unsigned max_num_devices = 32; /*-- Configurable parameters */ -/* Default zram disk size: 25% of total RAM */ -static const unsigned default_disksize_perc_ram = 25; - /* * Pages that compress to size greater than this are stored * uncompressed in memory. @@ -86,11 +83,15 @@ struct zram_stats { u32 bad_compress; /* % of pages with compression ratio>=75% */ }; -struct zram { - struct zs_pool *mem_pool; +struct zram_meta { void *compress_workmem; void *compress_buffer; struct table *table; + struct zs_pool *mem_pool; +}; + +struct zram { + struct zram_meta *meta; spinlock_t stat64_lock; /* protect 64-bit stats */ struct rw_semaphore lock; /* protect compression buffers and table * against concurrent read and writes */ @@ -114,7 +115,9 @@ unsigned int zram_get_num_devices(void); extern struct attribute_group zram_disk_attr_group; #endif -extern int zram_init_device(struct zram *zram); -extern void __zram_reset_device(struct zram *zram); +extern void zram_reset_device(struct zram *zram); +extern struct zram_meta *zram_meta_alloc(u64 disksize); +extern void zram_meta_free(struct zram_meta *meta); +extern void zram_init_device(struct zram *zram, struct zram_meta *meta); #endif diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index de1eacf..e6a929d 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -56,21 +56,26 @@ static ssize_t disksize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { u64 disksize; + struct zram_meta *meta; struct zram *zram = dev_to_zram(dev); disksize = memparse(buf, NULL); if (!disksize) return -EINVAL; + disksize = PAGE_ALIGN(disksize); + meta = zram_meta_alloc(disksize); down_write(&zram->init_lock); if (zram->init_done) { up_write(&zram->init_lock); + zram_meta_free(meta); pr_info("Cannot change disksize for initialized device\n"); return -EBUSY; } - zram->disksize = PAGE_ALIGN(disksize); + zram->disksize = disksize; set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); + zram_init_device(zram, meta); up_write(&zram->init_lock); return len; @@ -110,11 +115,7 @@ static ssize_t reset_store(struct device *dev, if (bdev) fsync_bdev(bdev); - down_write(&zram->init_lock); - if (zram->init_done) - __zram_reset_device(zram); - up_write(&zram->init_lock); - + zram_reset_device(zram); return len; } @@ -185,9 +186,10 @@ static ssize_t mem_used_total_show(struct device *dev, { u64 val = 0; struct zram *zram = dev_to_zram(dev); + struct zram_meta *meta = zram->meta; if (zram->init_done) - val = zs_get_total_size_bytes(zram->mem_pool); + val = zs_get_total_size_bytes(meta->mem_pool); return sprintf(buf, "%llu\n", val); } diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c index 09a9d35..06f73a9 100644 --- a/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/drivers/staging/zsmalloc/zsmalloc-main.c @@ -141,7 +141,7 @@ * ZS_MIN_ALLOC_SIZE and ZS_SIZE_CLASS_DELTA must be multiple of ZS_ALIGN * (reason above) */ -#define ZS_SIZE_CLASS_DELTA 16 +#define ZS_SIZE_CLASS_DELTA (PAGE_SIZE >> 8) #define ZS_SIZE_CLASSES ((ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE) / \ ZS_SIZE_CLASS_DELTA + 1) @@ -207,7 +207,6 @@ struct zs_pool { struct size_class size_class[ZS_SIZE_CLASSES]; gfp_t flags; /* allocation flags used when growing pool */ - const char *name; }; /* @@ -222,11 +221,9 @@ struct zs_pool { /* * By default, zsmalloc uses a copy-based object mapping method to access * allocations that span two pages. However, if a particular architecture - * 1) Implements local_flush_tlb_kernel_range() and 2) Performs VM mapping - * faster than copying, then it should be added here so that - * USE_PGTABLE_MAPPING is defined. This causes zsmalloc to use page table - * mapping rather than copying - * for object mapping. + * performs VM mapping faster than copying, then it should be added here + * so that USE_PGTABLE_MAPPING is defined. This causes zsmalloc to use + * page table mapping rather than copying for object mapping. */ #if defined(CONFIG_ARM) #define USE_PGTABLE_MAPPING @@ -663,7 +660,7 @@ static inline void __zs_unmap_object(struct mapping_area *area, flush_cache_vunmap(addr, end); unmap_kernel_range_noflush(addr, PAGE_SIZE * 2); - local_flush_tlb_kernel_range(addr, end); + flush_tlb_kernel_range(addr, end); } #else /* USE_PGTABLE_MAPPING */ @@ -798,14 +795,21 @@ fail: return notifier_to_errno(ret); } -struct zs_pool *zs_create_pool(const char *name, gfp_t flags) +/** + * zs_create_pool - Creates an allocation pool to work from. + * @flags: allocation flags used to allocate pool metadata + * + * This function must be called before anything when using + * the zsmalloc allocator. + * + * On success, a pointer to the newly created pool is returned, + * otherwise NULL. + */ +struct zs_pool *zs_create_pool(gfp_t flags) { int i, ovhd_size; struct zs_pool *pool; - if (!name) - return NULL; - ovhd_size = roundup(sizeof(*pool), PAGE_SIZE); pool = kzalloc(ovhd_size, GFP_KERNEL); if (!pool) @@ -828,7 +832,6 @@ struct zs_pool *zs_create_pool(const char *name, gfp_t flags) } pool->flags = flags; - pool->name = name; return pool; } diff --git a/drivers/staging/zsmalloc/zsmalloc.h b/drivers/staging/zsmalloc/zsmalloc.h index de2e8bf..46dbd05 100644 --- a/drivers/staging/zsmalloc/zsmalloc.h +++ b/drivers/staging/zsmalloc/zsmalloc.h @@ -28,7 +28,7 @@ enum zs_mapmode { struct zs_pool; -struct zs_pool *zs_create_pool(const char *name, gfp_t flags); +struct zs_pool *zs_create_pool(gfp_t flags); void zs_destroy_pool(struct zs_pool *pool); unsigned long zs_malloc(struct zs_pool *pool, size_t size); |