diff options
85 files changed, 798 insertions, 1755 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index a3774a71ec26..2f06d40fe07d 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -275,7 +275,7 @@ What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available What: /sys/.../iio:deviceX/out_voltageX_scale_available What: /sys/.../iio:deviceX/out_altvoltageX_scale_available What: /sys/.../iio:deviceX/in_capacitance_scale_available -KernelVersion: 2.635 +KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: If a discrete set of scale values is available, they diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index ec653fb51d0b..4fe0ead84213 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -51,25 +51,19 @@ static ssize_t iio_trigger_read_name(struct device *dev, static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL); -/** - * iio_trigger_register_sysfs() - create a device for this trigger - * @trig_info: the trigger - * - * Also adds any control attribute registered by the trigger driver - **/ -static int iio_trigger_register_sysfs(struct iio_trigger *trig_info) -{ - return sysfs_add_file_to_group(&trig_info->dev.kobj, - &dev_attr_name.attr, - NULL); -} +static struct attribute *iio_trig_dev_attrs[] = { + &dev_attr_name.attr, + NULL, +}; -static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info) -{ - sysfs_remove_file_from_group(&trig_info->dev.kobj, - &dev_attr_name.attr, - NULL); -} +static struct attribute_group iio_trig_attr_group = { + .attrs = iio_trig_dev_attrs, +}; + +static const struct attribute_group *iio_trig_attr_groups[] = { + &iio_trig_attr_group, + NULL +}; int iio_trigger_register(struct iio_trigger *trig_info) { @@ -88,10 +82,6 @@ int iio_trigger_register(struct iio_trigger *trig_info) if (ret) goto error_unregister_id; - ret = iio_trigger_register_sysfs(trig_info); - if (ret) - goto error_device_del; - /* Add to list of available triggers held by the IIO core */ mutex_lock(&iio_trigger_list_lock); list_add_tail(&trig_info->list, &iio_trigger_list); @@ -99,8 +89,6 @@ int iio_trigger_register(struct iio_trigger *trig_info) return 0; -error_device_del: - device_del(&trig_info->dev); error_unregister_id: ida_simple_remove(&iio_trigger_ida, trig_info->id); error_ret: @@ -114,7 +102,6 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) list_del(&trig_info->list); mutex_unlock(&iio_trigger_list_lock); - iio_trigger_unregister_sysfs(trig_info); ida_simple_remove(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ device_unregister(&trig_info->dev); @@ -234,7 +221,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig, return ret; } -static int iio_trigger_dettach_poll_func(struct iio_trigger *trig, +static int iio_trigger_detach_poll_func(struct iio_trigger *trig, struct iio_poll_func *pf) { int ret = 0; @@ -406,6 +393,7 @@ static void iio_trig_release(struct device *device) static struct device_type iio_trig_type = { .release = iio_trig_release, + .groups = iio_trig_attr_groups, }; static void iio_trig_subirqmask(struct irq_data *d) @@ -502,7 +490,7 @@ EXPORT_SYMBOL(iio_triggered_buffer_postenable); int iio_triggered_buffer_predisable(struct iio_dev *indio_dev) { - return iio_trigger_dettach_poll_func(indio_dev->trig, + return iio_trigger_detach_poll_func(indio_dev->trig, indio_dev->pollfunc); } EXPORT_SYMBOL(iio_triggered_buffer_predisable); diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c index 510d79639217..f63c1d3aeb64 100644 --- a/drivers/staging/asus_oled/asus_oled.c +++ b/drivers/staging/asus_oled/asus_oled.c @@ -782,20 +782,20 @@ static int __init asus_oled_init(void) oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME); if (IS_ERR(oled_class)) { - printk(KERN_ERR "Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n"); + pr_err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n"); return PTR_ERR(oled_class); } retval = class_create_file(oled_class, &class_attr_version.attr); if (retval) { - printk(KERN_ERR "Error creating class version file\n"); + pr_err("Error creating class version file\n"); goto error; } retval = usb_register(&oled_driver); if (retval) { - printk(KERN_ERR "usb_register failed. Error number %d\n", retval); + pr_err("usb_register failed. Error number %d\n", retval); goto error; } diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 9c8c9b14e8d4..b54ec974477f 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -4,7 +4,6 @@ * Management. ************************************************************/ -/* #define CONN_MSG */ #include "headers.h" enum E_CLASSIFIER_ACTION { diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h index 420382d1cacf..8018a189f817 100644 --- a/drivers/staging/bcm/Debug.h +++ b/drivers/staging/bcm/Debug.h @@ -42,10 +42,6 @@ #define ARP_REQ (TX<<5) #define ARP_RESP (TX<<6) -// dhcp.c -//#define DHCP TX -//#define DHCP_REQ (DHCP<<7) - // Leakybucket.c #define TOKEN_COUNTS (TX<<8) #define CHECK_TOKENS (TX<<9) @@ -147,7 +143,6 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ #define HOST_MIBS (OTHERS << 28) #define CONN_MSG (CMHOST << 29) -//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c /*-----------------END SUBTYPEs------------------------------------------*/ diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h index b5ca6f6a1cb2..46f5f0feea88 100644 --- a/drivers/staging/bcm/Macros.h +++ b/drivers/staging/bcm/Macros.h @@ -6,7 +6,6 @@ #define TX_TIMER_PERIOD 10 /*10 msec*/ #define MAX_CLASSIFIERS 100 -/* #define MAX_CLASSIFIERS_PER_SF 20 */ #define MAX_TARGET_DSX_BUFFERS 24 #define MAX_CNTRL_PKTS 100 diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index c36fd763310d..9a60d4cd2184 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -402,30 +402,6 @@ INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer) return Status; } -#if 0 -/***************************************************************** -* Function - SendStatisticsPointerRequest() -* -* Description - This function builds and forwards the Statistics -* Pointer Request control Packet. -* -* Parameters - Adapter : Pointer to Adapter structure. -* - pstStatisticsPtrRequest : Pointer to link request. -* -* Returns - None. -*****************************************************************/ -static VOID SendStatisticsPointerRequest(struct bcm_mini_adapter *Adapter, struct bcm_link_request *pstStatisticsPtrRequest) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>"); - pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS; - pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG); /* minimum 4 bytes */ - pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ; - CopyBufferToControlPacket(Adapter, pstStatisticsPtrRequest); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<====="); - return; -} -#endif - /****************************************************************** * Function - LinkMessage() * @@ -1217,45 +1193,6 @@ static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) } } -#if 0 -static unsigned char *ReadMacAddrEEPROM(struct bcm_mini_adapter *Adapter, ulong dwAddress) -{ - int status = 0, i = 0; - unsigned int temp = 0; - unsigned char *pucmacaddr = kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL); - int bytes; - - if (!pucmacaddr) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n"); - return NULL; - } - - dwAddress |= 0x5b000000; - status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, (PUINT)&dwAddress, sizeof(UINT)); - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n"); - kfree(pucmacaddr); - pucmacaddr = NULL; - goto OUT; - } - - for (i = 0; i < MAC_ADDRESS_SIZE; i++) { - bytes = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp, sizeof(temp)); - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n"); - kfree(pucmacaddr); - pucmacaddr = NULL; - goto OUT; - } - pucmacaddr[i] = temp & 0xff; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "%x\n", pucmacaddr[i]); - } -OUT: - return pucmacaddr; -} -#endif - static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount) { UINT uiIndex = 0; @@ -1269,9 +1206,6 @@ static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount) } } -#define CACHE_ADDRESS_MASK 0x80000000 -#define UNCACHE_ADDRESS_MASK 0xa0000000 - int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize) { return Adapter->interface_rdm(Adapter->pvInterfaceAdapter, diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h index eed4cfc6e538..6016fc502d2d 100644 --- a/drivers/staging/bcm/PHSDefines.h +++ b/drivers/staging/bcm/PHSDefines.h @@ -27,7 +27,6 @@ #define PHS_BUFFER_SIZE 1532 -//#define MAX_PHS_LENGTHS 100 #define MAX_PHSRULE_PER_SF 20 #define MAX_SERVICEFLOWS 17 diff --git a/drivers/staging/csr/csr_util.h b/drivers/staging/csr/csr_util.h index ce39c7e8dab7..5cd6cb4f22ca 100644 --- a/drivers/staging/csr/csr_util.h +++ b/drivers/staging/csr/csr_util.h @@ -47,17 +47,10 @@ void CsrUInt32ToHex(CsrUint32 number, CsrCharString *str); #define CsrMemCmp(s1, s2, n) ((CsrInt32) memcmp((s1), (s2), (n))) #define CsrStrCmp(s1, s2) ((CsrInt32) strcmp((s1), (s2))) #define CsrStrNCmp(s1, s2, n) ((CsrInt32) strncmp((s1), (s2), (n))) -/*#define CsrMemChr memchr*/ #define CsrStrChr strchr -/*#define CsrStrCSpn strcspn*/ -/*#define CsrStrPBrk strpbrk*/ -/*#define CsrStrRChr strrchr*/ -/*#define CsrStrSpn strspn*/ #define CsrStrStr strstr -/*#define CsrStrTok strtok*/ #define CsrMemSet memset #define CsrStrLen strlen -/*#define CsrVsnprintf(s, n, format, arg) ((CsrInt32) vsnprintf((s), (n), (format), (arg)))*/ #else /* !CSR_USE_STDC_LIB */ void *CsrMemCpy(void *dest, const void *src, CsrSize count); void *CsrMemMove(void *dest, const void *src, CsrSize count); diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/drivers/staging/csr/csr_wifi_hip_card_sdio.c index 91976b824a4e..5a86ff90253d 100644 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio.c +++ b/drivers/staging/csr/csr_wifi_hip_card_sdio.c @@ -36,9 +36,6 @@ #define MAILBOX2_TIMEOUT 5 /* in millisecs */ #define MAILBOX2_ATTEMPTS 10 /* 50ms */ -#define MAILBOX2_RESET_ATTEMPTS 10 -#define MAILBOX2_RESET_TIMEOUT 5 /* in millisecs */ - #define RESET_SETTLE_DELAY 25 /* in millisecs */ static CsrResult card_init_slots(card_t *card); diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.c b/drivers/staging/csr/csr_wifi_hip_chiphelper.c index 0e2477ff4dd0..a3148d87609a 100644 --- a/drivers/staging/csr/csr_wifi_hip_chiphelper.c +++ b/drivers/staging/csr/csr_wifi_hip_chiphelper.c @@ -630,7 +630,7 @@ ChipDescript* ChipHelper_GetVersionUniFi(CsrUint16 ver) } -ChipDescript* ChipHelper_Null() +ChipDescript *ChipHelper_Null(void) { return &chip_device_desc_null; } diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c index fbe86301816c..4be6d9533cd0 100644 --- a/drivers/staging/csr/drv.c +++ b/drivers/staging/csr/drv.c @@ -63,7 +63,6 @@ int coredump_max = CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS; int run_bh_once = -1; /* Set for scheduled interrupt mode, -1 = default */ int bh_priority = -1; #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -#define UNIFI_LOG_HIP_SIGNALS_FILTER_SIGNAL (1 << 0) #define UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA (1 << 1) #define UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP (1 << 2) int log_hip_signals = 0; diff --git a/drivers/staging/csr/firmware.c b/drivers/staging/csr/firmware.c index 03da0d5c247a..98e27d6f440e 100644 --- a/drivers/staging/csr/firmware.c +++ b/drivers/staging/csr/firmware.c @@ -220,7 +220,6 @@ unifi_fw_read(void *ospriv, void *arg, CsrUint32 offset, void *buf, CsrUint32 le -#define UNIFIHELPER_INIT_MODE_SMEEMB 0 #define UNIFIHELPER_INIT_MODE_SMEUSER 2 #define UNIFIHELPER_INIT_MODE_NATIVE 1 diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c index 790d5d77375f..ed767eccbb32 100644 --- a/drivers/staging/csr/mlme.c +++ b/drivers/staging/csr/mlme.c @@ -15,11 +15,6 @@ #include "csr_wifi_hip_unifi.h" #include "unifi_priv.h" - -/* The additional time taken by the UniFi to do a scan per channel */ -#define SCAN_STARTUP_TIME 300 /* in millisecs */ - - /* * --------------------------------------------------------------------------- * unifi_mlme_wait_for_reply diff --git a/drivers/staging/csr/monitor.c b/drivers/staging/csr/monitor.c index 7648d2bbad43..628782ad641e 100644 --- a/drivers/staging/csr/monitor.c +++ b/drivers/staging/csr/monitor.c @@ -51,13 +51,6 @@ uf_start_sniff(unifi_priv_t *priv) req->Channel = priv->wext_conf.channel; req->ChannelStartingFactor = 0; -#if 0 - printk("SniffJoin: Ifindex=%d, Channel=%d, ChannelStartingFactor=%d\n", - req->Ifindex, - req->Channel, - req->ChannelStartingFactor); -#endif - signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SNIFFJOIN_REQUEST_ID; r = unifi_mlme_blocking_request(priv, pcli, &signal, NULL, timeout); @@ -198,11 +191,6 @@ netrx_radiotap(unifi_priv_t *priv, unifi_rt->rt_antenna = ind->AntennaId; -#if 0 - printk("skb datalen=%d\n", skb->len); - dump(skb->data, 48); -#endif - skb->dev = dev; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) skb->mac_header = skb->data; @@ -254,9 +242,7 @@ netrx_prism(unifi_priv_t *priv, unsigned char *ptr; unsigned char *base; int ind_data_len = skb_orig->len - 2 - ETH_HLEN; -#define WLANCAP_MAGIC_COOKIE_BASE 0x80211000 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001 -#define WLANCAP_MAGIC_COOKIE_V2 0x80211002 struct avs_header_v1 { uint32 version; uint32 length; @@ -282,24 +268,6 @@ netrx_prism(unifi_priv_t *priv, return; } -#if 0 - printk("MA-SINFFDATA.ind: DataLen=%d bytes, TSF %02X %02X %02X %02X %02X %02X %02X %02X, Rate=%d, Antenna=%d\n", - ind->Data.DataLength, - ind->Timestamp.x[0], - ind->Timestamp.x[1], - ind->Timestamp.x[2], - ind->Timestamp.x[3], - ind->Timestamp.x[4], - ind->Timestamp.x[5], - ind->Timestamp.x[6], - ind->Timestamp.x[7], - ind->Rate, - ind->Antenna); - - printk("payload, len %d\n", length); - dump((unsigned char *)payload, 32); -#endif - /* * Allocate a SKB for the received data packet, including radiotap * header. @@ -341,11 +309,6 @@ netrx_prism(unifi_priv_t *priv, avs->encoding = htonl(0); /* unknown */ -#if 0 - printk("skb datalen=%d\n", skb->len); - dump(skb->data, 48); -#endif - skb->dev = dev; skb->mac.raw = skb->data; skb->pkt_type = PACKET_OTHERHOST; @@ -402,33 +365,11 @@ ma_sniffdata_ind(void *ospriv, } skb->len = bulkdata->d[0].data_length; -#if 0 - printk("MA-SNIFFDATA.ind: DataLen=%d bytes, TSF %02X %02X %02X %02X %02X %02X %02X %02X, Rate=%d, Antenna=%d\n", - ind->Data.DataLength, - ind->Timestamp.x[0], - ind->Timestamp.x[1], - ind->Timestamp.x[2], - ind->Timestamp.x[3], - ind->Timestamp.x[4], - ind->Timestamp.x[5], - ind->Timestamp.x[6], - ind->Timestamp.x[7], - ind->Rate, - ind->AntennaId); - - printk("payload, len %lu\n", bulkdata->d[0].data_length); - if (bulkdata->d[0].os_data_ptr && (bulkdata->d[0].data_length >= 32)) { - dump((unsigned char *)bulkdata->d[0].os_data_ptr, 32); - } -#endif /* We only process data packets if the interface is open */ if (unlikely(!netif_running(dev))) { priv->stats.rx_dropped++; priv->wext_conf.wireless_stats.discard.misc++; -#if 0 - printk("Dropping packet while interface is not up.\n"); -#endif dev_kfree_skb(skb); return; } diff --git a/drivers/staging/csr/netdev.c b/drivers/staging/csr/netdev.c index cf19f1116c2e..55149df5e347 100644 --- a/drivers/staging/csr/netdev.c +++ b/drivers/staging/csr/netdev.c @@ -70,11 +70,6 @@ */ #define ALLOW_Q_PAUSE -#define ieee2host16(n) __le16_to_cpu(n) -#define ieee2host32(n) __le32_to_cpu(n) -#define host2ieee16(n) __cpu_to_le16(n) -#define host2ieee32(n) __cpu_to_le32(n) - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) #ifdef UNIFI_NET_NAME #define UF_ALLOC_NETDEV(_dev, _size, _name, _setup, _num_of_queues) \ diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c index 9c3aa7494604..5f38f9dbb986 100644 --- a/drivers/staging/csr/sme_sys.c +++ b/drivers/staging/csr/sme_sys.c @@ -1572,7 +1572,6 @@ void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) r = _sys_packet_req(priv, &signal, mareq->subscriptionHandle, mareq->frameLength, mareq->frame, snap_protocol); -#define MAX_RETRY 2 if (r && mareq->cfmRequested) { CsrWifiRouterMaPacketCfmSend(msg->source,interfaceTag, diff --git a/drivers/staging/csr/unifi_native.h b/drivers/staging/csr/unifi_native.h index a480c9e2435b..a73b38e5e480 100644 --- a/drivers/staging/csr/unifi_native.h +++ b/drivers/staging/csr/unifi_native.h @@ -242,25 +242,6 @@ void uf_native_process_udi_signal(ul_client_t *pcli, const u8 *packed_signal, int packed_signal_len, const bulk_data_param_t *bulkdata, int dir); -#if 0 -/* - * Choose one of these if available in linux/if_arp.h: - * #define UNIFI_SNIFF_ARPHRD ARPHRD_IEEE80211_RADIOTAP - * #define UNIFI_SNIFF_ARPHRD ARPHRD_IEEE80211_PRISM - * - * Radiotap is the newer standard for softmac WLAN devices, it works with - * Wireshark but not Ethereal (due to a bug in the Ethereal dissector). - * Prism is an older (less desirable) format but it does work with Ethereal. - */ -#ifdef ARPHRD_IEEE80211_RADIOTAP -#define UNIFI_SNIFF_ARPHRD ARPHRD_IEEE80211_RADIOTAP -#else -#ifdef ARPHRD_IEEE80211_PRISM -#define UNIFI_SNIFF_ARPHRD ARPHRD_IEEE80211_PRISM -#endif -#endif -#endif - #ifdef UNIFI_SNIFF_ARPHRD /* * monitor.c diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c index 6e7cbbf70c88..5ad1d5f8167e 100644 --- a/drivers/staging/csr/unifi_sme.c +++ b/drivers/staging/csr/unifi_sme.c @@ -78,12 +78,6 @@ sme_log_event(ul_client_t *pcli, CsrResult result = CSR_RESULT_SUCCESS; int r; - /* Following bits are encoded in hostTag These are there to ensure that hostTags are unique*/ -#define CSR_SME_DATA 0x00000000 /* Frames Sent by SME */ -#define CSR_PAL_DATA 0X10000000 /* Frames Sent by PAL-D*/ -#define CSR_NME_DATA 0x20000000 /* Frames Sent by NME*/ -#define APPLICATION_DATA 0x30000000 /* Frames Sent by Application*/ - func_enter(); /* Just a sanity check */ if ((signal == NULL) || (signal_len <= 0)) { diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 8f3fc5f85ec9..ac6897b593c9 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -5445,24 +5445,4 @@ static struct pci_driver et131x_driver = { .driver.pm = ET131X_PM_OPS, }; -/** - * et131x_init_module - The "main" entry point called on driver initialization - * - * Returns 0 on success, errno on failure (as defined in errno.h) - */ -static int __init et131x_init_module(void) -{ - return pci_register_driver(&et131x_driver); -} - -/** - * et131x_cleanup_module - The entry point called on driver cleanup - */ -static void __exit et131x_cleanup_module(void) -{ - pci_unregister_driver(&et131x_driver); -} - -module_init(et131x_init_module); -module_exit(et131x_cleanup_module); - +module_pci_driver(et131x_driver); diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index c4a8a0a26eb5..86a680c09ba2 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -97,11 +97,10 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); - if (info->AsicID == ELECTRABUZZ_ID) { + if (info->AsicID == ELECTRABUZZ_ID) return (ft1000_read_reg(dev, FT1000_REG_UFIFO_STAT) - 16); - } else { + else return (ft1000_read_reg(dev, FT1000_REG_MAG_UFSR) - 16); - } } //--------------------------------------------------------------------------- @@ -116,7 +115,7 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev) // value - value of dpram // //--------------------------------------------------------------------------- -u16 ft1000_read_dpram(struct net_device * dev, int offset) +u16 ft1000_read_dpram(struct net_device *dev, int offset) { struct ft1000_info *info = netdev_priv(dev); unsigned long flags; @@ -1997,42 +1996,43 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); // Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type - while (inttype) { - if (inttype & ISR_DOORBELL_PEND) { - ft1000_parse_dpram_msg(dev); - } + while (inttype) { + if (inttype & ISR_DOORBELL_PEND) + ft1000_parse_dpram_msg(dev); - if (inttype & ISR_RCV) { - DEBUG(1, "Data in FIFO\n"); + if (inttype & ISR_RCV) { + DEBUG(1, "Data in FIFO\n"); - cnt = 0; - do { - // Check if we have packets in the Downlink FIFO - if (info->AsicID == ELECTRABUZZ_ID) { - tempword = - ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT); - } else { - tempword = - ft1000_read_reg(dev, FT1000_REG_MAG_DFSR); - } - if (tempword & 0x1f) { - ft1000_copy_up_pkt(dev); - } else { - break; - } - cnt++; - } while (cnt < MAX_RCV_LOOP); + cnt = 0; + do { + // Check if we have packets in the Downlink FIFO + if (info->AsicID == ELECTRABUZZ_ID) { + tempword = + ft1000_read_reg(dev, + FT1000_REG_DFIFO_STAT); + } else { + tempword = + ft1000_read_reg(dev, + FT1000_REG_MAG_DFSR); + } + if (tempword & 0x1f) { + ft1000_copy_up_pkt(dev); + } else { + break; + } + cnt++; + } while (cnt < MAX_RCV_LOOP); + } + // clear interrupts + tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); + DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword); + ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); + + // Read interrupt type + inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR); + DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype); } - // clear interrupts - tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); - DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword); - ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); - - // Read interrupt type - inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR); - DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype); - } ft1000_enable_interrupts(dev); return IRQ_HANDLED; } diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 71aaad31270b..72727c6b9e2e 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c @@ -34,16 +34,14 @@ #define PUTX_TO_PAGE(len, page, message, size, var) \ len += snprintf(page+len, PAGE_SIZE - len, message); \ - for(i = 0; i < (size - 1); i++) \ - { \ + for(i = 0; i < (size - 1); i++) { \ len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ } \ len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i]) #define PUTD_TO_PAGE(len, page, message, size, var) \ len += snprintf(page+len, PAGE_SIZE - len, message); \ - for(i = 0; i < (size - 1); i++) \ - { \ + for(i = 0; i < (size - 1); i++) { \ len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \ } \ len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i]) @@ -55,8 +53,8 @@ static int ft1000ReadProc(char *page, char **start, off_t off, int len; int i; struct ft1000_info *info; - char *status[] = - { "Idle (Disconnect)", "Searching", "Active (Connected)", + char *status[] = { + "Idle (Disconnect)", "Searching", "Active (Connected)", "Waiting for L2", "Sleep", "No Coverage", "", "" }; char *signal[] = { "", "*", "**", "***", "****" }; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 19db23fe73ca..6d911fda47fb 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -167,7 +167,7 @@ int ft1000_create_dev(struct ft1000_device *dev) goto fail; } - dir = debugfs_create_dir(info->DeviceName, 0); + dir = debugfs_create_dir(info->DeviceName, NULL); if (IS_ERR(dir)) { result = PTR_ERR(dir); goto debug_dir_fail; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index bfead67436fe..e8c4a4e5ac6d 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -37,9 +37,9 @@ static struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE(usb, id_table); static bool gPollingfailed = FALSE; -int ft1000_poll_thread(void *arg) +static int ft1000_poll_thread(void *arg) { - int ret = STATUS_SUCCESS; + int ret; while (!kthread_should_stop()) { msleep(10); @@ -237,7 +237,7 @@ static void ft1000_disconnect(struct usb_interface *interface) ft1000_destroy_dev(pft1000info->pFt1000Dev->net); unregister_netdev(pft1000info->pFt1000Dev->net); DEBUG - ("ft1000_disconnect: network device unregisterd\n"); + ("ft1000_disconnect: network device unregistered\n"); free_netdev(pft1000info->pFt1000Dev->net); } diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c index 4326e9e764c9..3a9b00087403 100644 --- a/drivers/staging/iio/Documentation/iio_event_monitor.c +++ b/drivers/staging/iio/Documentation/iio_event_monitor.c @@ -68,6 +68,12 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Z] = "z", [IIO_MOD_LIGHT_BOTH] = "both", [IIO_MOD_LIGHT_IR] = "ir", + [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)", + [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2", + [IIO_MOD_LIGHT_CLEAR] = "clear", + [IIO_MOD_LIGHT_RED] = "red", + [IIO_MOD_LIGHT_GREEN] = "green", + [IIO_MOD_LIGHT_BLUE] = "blue", }; static bool event_is_known(struct iio_event_data *event) @@ -106,6 +112,12 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_Z: case IIO_MOD_LIGHT_BOTH: case IIO_MOD_LIGHT_IR: + case IIO_MOD_ROOT_SUM_SQUARED_X_Y: + case IIO_MOD_SUM_SQUARED_X_Y_Z: + case IIO_MOD_LIGHT_CLEAR: + case IIO_MOD_LIGHT_RED: + case IIO_MOD_LIGHT_GREEN: + case IIO_MOD_LIGHT_BLUE: break; default: return false; diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index 5244fa0dfd2f..cf32ae099cd6 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -453,7 +453,7 @@ inline int find_type_by_name(const char *name, const char *type) dp = opendir(iio_dir); if (dp == NULL) { - printf("No industrialio devices available"); + printf("No industrialio devices available\n"); return -ENODEV; } diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index f87992cd1acc..4157596ea3b0 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -711,6 +711,7 @@ static int __devinit adt7410_probe(struct i2c_client *client, struct iio_dev *indio_dev; int ret = 0; unsigned long *adt7410_platform_data = client->dev.platform_data; + unsigned long local_pdata[] = {0, 0}; indio_dev = iio_device_alloc(sizeof(*chip)); if (indio_dev == NULL) { @@ -728,6 +729,9 @@ static int __devinit adt7410_probe(struct i2c_client *client, indio_dev->info = &adt7410_info; indio_dev->modes = INDIO_DIRECT_MODE; + if (!adt7410_platform_data) + adt7410_platform_data = local_pdata; + /* CT critcal temperature event. line 0 */ if (client->irq) { ret = request_threaded_irq(client->irq, @@ -753,13 +757,15 @@ static int __devinit adt7410_probe(struct i2c_client *client, goto error_unreg_ct_irq; } - if (client->irq && adt7410_platform_data[0]) { + ret = adt7410_i2c_read_byte(chip, ADT7410_CONFIG, &chip->config); + if (ret) { + ret = -EIO; + goto error_unreg_int_irq; + } - ret = adt7410_i2c_read_byte(chip, ADT7410_CONFIG, &chip->config); - if (ret) { - ret = -EIO; - goto error_unreg_int_irq; - } + chip->config |= ADT7410_RESOLUTION; + + if (client->irq && adt7410_platform_data[0]) { /* set irq polarity low level */ chip->config &= ~ADT7410_CT_POLARITY; @@ -768,12 +774,12 @@ static int __devinit adt7410_probe(struct i2c_client *client, chip->config |= ADT7410_INT_POLARITY; else chip->config &= ~ADT7410_INT_POLARITY; + } - ret = adt7410_i2c_write_byte(chip, ADT7410_CONFIG, chip->config); - if (ret) { - ret = -EIO; - goto error_unreg_int_irq; - } + ret = adt7410_i2c_write_byte(chip, ADT7410_CONFIG, chip->config); + if (ret) { + ret = -EIO; + goto error_unreg_int_irq; } ret = iio_device_register(indio_dev); if (ret) diff --git a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c index d77b21f1eb2d..919cb95236fc 100644 --- a/drivers/staging/phison/phison.c +++ b/drivers/staging/phison/phison.c @@ -87,18 +87,7 @@ static struct pci_driver phison_pci_driver = { #endif }; -static int __init phison_ide_init(void) -{ - return pci_register_driver(&phison_pci_driver); -} - -static void __exit phison_ide_exit(void) -{ - pci_unregister_driver(&phison_pci_driver); -} - -module_init(phison_ide_init); -module_exit(phison_ide_exit); +module_pci_driver(phison_pci_driver); MODULE_AUTHOR("Evan Ko"); MODULE_DESCRIPTION("PCIE driver module for PHISON PS5000 E-BOX"); diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index b9474a8aefc0..3cc9a489e4e8 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c @@ -137,11 +137,10 @@ static int sd_check_data0_status(struct rtsx_chip *chip) { u8 stat; - if (CHECK_PID(chip, 0x5209)) { + if (CHECK_PID(chip, 0x5209)) RTSX_READ_REG(chip, REG_SD_BUS_STAT, &stat); - } else { + else RTSX_READ_REG(chip, REG_SD_STAT1, &stat); - } if (!(stat & SD_DAT0_STATUS)) { sd_set_err_code(chip, SD_BUSY); @@ -188,9 +187,9 @@ RTY_SEND_CMD: SD_TRANSFER_END | SD_STAT_IDLE, SD_TRANSFER_END | SD_STAT_IDLE); if (rsp_type == SD_RSP_TYPE_R2) { - for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; reg_addr++) { + for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; reg_addr++) rtsx_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); - } + stat_idx = 16; } else if (rsp_type != SD_RSP_TYPE_R0) { for (reg_addr = REG_SD_CMD0; reg_addr <= REG_SD_CMD4; reg_addr++) { diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c index e87fe81f6bb3..cd778b3a02b2 100644 --- a/drivers/staging/sbe-2t3e3/module.c +++ b/drivers/staging/sbe-2t3e3/module.c @@ -194,17 +194,6 @@ static struct pci_driver t3e3_pci_driver = { .remove = t3e3_remove_card, }; -static int __init t3e3_init_module(void) -{ - return pci_register_driver(&t3e3_pci_driver); -} - -static void __exit t3e3_cleanup_module(void) -{ - pci_unregister_driver(&t3e3_pci_driver); -} - -module_init(t3e3_init_module); -module_exit(t3e3_cleanup_module); +module_pci_driver(t3e3_pci_driver); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, t3e3_pci_tbl); diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c index 270fcb811b80..205d0df20e2e 100644 --- a/drivers/staging/sep/sep_main.c +++ b/drivers/staging/sep/sep_main.c @@ -4492,30 +4492,5 @@ static struct pci_driver sep_pci_driver = { .remove = sep_remove }; -/** - * sep_init - init function - * - * Module load time. Register the PCI device driver. - */ - -static int __init sep_init(void) -{ - return pci_register_driver(&sep_pci_driver); -} - - -/** - * sep_exit - called to unload driver - * - * Unregister the driver The device will perform all the cleanup required. - */ -static void __exit sep_exit(void) -{ - pci_unregister_driver(&sep_pci_driver); -} - - -module_init(sep_init); -module_exit(sep_exit); - +module_pci_driver(sep_pci_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index d2b82a78d2af..56829fc032ff 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -3196,7 +3196,6 @@ static void __devexit slic_entry_remove(struct pci_dev *pcidev) struct sliccard *card; struct mcast_address *mcaddr, *mlist; - ASSERT(adapter); slic_adapter_freeresources(adapter); slic_unmap_mmio_space(adapter); unregister_netdev(dev); @@ -3235,6 +3234,7 @@ static void __devexit slic_entry_remove(struct pci_dev *pcidev) } free_netdev(dev); pci_release_regions(pcidev); + pci_disable_device(pcidev); } static int slic_entry_halt(struct net_device *dev) @@ -3746,8 +3746,7 @@ static u32 slic_card_locate(struct adapter *adapter) rdhostid_offset = SLIC_RDHOSTID_1GB; break; default: - ASSERT(0); - break; + return -ENODEV; } hostid_reg = diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c index e3511ecd0980..73951963c018 100644 --- a/drivers/staging/sm7xxfb/sm7xxfb.c +++ b/drivers/staging/sm7xxfb/sm7xxfb.c @@ -808,8 +808,10 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev, sfb = smtc_alloc_fb_info(pdev, name); - if (!sfb) + if (!sfb) { + err = -ENOMEM; goto failed_free; + } sfb->chip_id = ent->device; sprintf(name, "sm%Xfb", sfb->chip_id); @@ -1058,18 +1060,7 @@ static struct pci_driver smtcfb_driver = { .driver.pm = SM7XX_PM_OPS, }; -static int __init smtcfb_init(void) -{ - return pci_register_driver(&smtcfb_driver); -} - -static void __exit smtcfb_exit(void) -{ - pci_unregister_driver(&smtcfb_driver); -} - -module_init(smtcfb_init); -module_exit(smtcfb_exit); +module_pci_driver(smtcfb_driver); MODULE_AUTHOR("Siliconmotion "); MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards"); diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c index c2119433f333..ca01734d13c5 100644 --- a/drivers/staging/speakup/i18n.c +++ b/drivers/staging/speakup/i18n.c @@ -71,7 +71,7 @@ static char *speakup_default_msgs[MSG_LAST_INDEX] = { [MSG_CTL_SHIFT] = "shift", [MSG_CTL_ALTGR] = "altgr", [MSG_CTL_CONTROL] = "control", - [MSG_CTL_ALT] = "ault", + [MSG_CTL_ALT] = "alt", [MSG_CTL_LSHIFT] = "l shift", [MSG_CTL_SPEAKUP] = "speakup", [MSG_CTL_LCONTROL] = "l control", diff --git a/drivers/staging/speakup/speakup_acnt.h b/drivers/staging/speakup/speakup_acnt.h index 2d883654ffcc..6376fca9e0e1 100644 --- a/drivers/staging/speakup/speakup_acnt.h +++ b/drivers/staging/speakup/speakup_acnt.h @@ -12,5 +12,5 @@ to accept a byte of data. */ #define SYNTH_QUIET 'S' /* synth is not speaking */ #define SYNTH_FULL 'F' /* synth is full. */ -#define SYNTH_ALMOST_EMPTY 'M' /* synth has les than 2 seconds of text left */ +#define SYNTH_ALMOST_EMPTY 'M' /* synth has less than 2 seconds of text left */ #define SYNTH_SPEAKING 's' /* synth is speaking and has a fare way to go */ diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c index de25527decf6..a09a0c9975df 100644 --- a/drivers/staging/speakup/speakup_decpc.c +++ b/drivers/staging/speakup/speakup_decpc.c @@ -66,7 +66,7 @@ #define CMD_null 0x0000 /* post status */ #define CMD_control 0x1000 /* hard control command */ #define CTRL_mask 0x0F00 /* mask off control nibble */ -#define CTRL_data 0x00FF /* madk to get data byte */ +#define CTRL_data 0x00FF /* mask to get data byte */ #define CTRL_null 0x0000 /* null control */ #define CTRL_vol_up 0x0100 /* increase volume */ #define CTRL_vol_down 0x0200 /* decrease volume */ diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 331eae788700..df9533798095 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -64,7 +64,7 @@ EXPORT_SYMBOL_GPL(serial_synth_probe); /* Main loop of the progression thread: keep eating from the buffer * and push to the serial port, waiting as needed * - * For devices that have a "full" notification mecanism, the driver can + * For devices that have a "full" notification mechanism, the driver can * adapt the loop the way they prefer. */ void spk_do_catch_up(struct spk_synth *synth) diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h index f55283b86410..c4d2349260ea 100644 --- a/drivers/staging/vt6655/80211hdr.h +++ b/drivers/staging/vt6655/80211hdr.h @@ -80,7 +80,6 @@ #define WLAN_HDR_ADDR4_LEN 30 #define WLAN_IEHDR_LEN 2 #define WLAN_SSID_MAXLEN 32 -/*#define WLAN_RATES_MAXLEN 255*/ #define WLAN_RATES_MAXLEN 16 #define WLAN_RATES_MAXLEN_11B 4 #define WLAN_RSN_MAXLEN 32 @@ -106,7 +105,6 @@ #define WLAN_WEP40_KEYLEN 5 #define WLAN_WEP104_KEYLEN 13 #define WLAN_WEP232_KEYLEN 29 -/*#define WLAN_WEPMAX_KEYLEN 29*/ #define WLAN_WEPMAX_KEYLEN 32 #define WLAN_CHALLENGE_IE_MAXLEN 255 #define WLAN_CHALLENGE_IE_LEN 130 diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 1e1c6e34f786..e7b93a21e3b2 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -60,8 +60,6 @@ //static int msglevel =MSG_LEVEL_DEBUG; static int msglevel =MSG_LEVEL_INFO; -//#define PLICE_DEBUG - /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 8294bdbb7b51..be2d68909490 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -46,36 +46,6 @@ // Baseband RF pair definition in eeprom (Bits 6..0) // -/* -#define RATE_1M 0 -#define RATE_2M 1 -#define RATE_5M 2 -#define RATE_11M 3 -#define RATE_6M 4 -#define RATE_9M 5 -#define RATE_12M 6 -#define RATE_18M 7 -#define RATE_24M 8 -#define RATE_36M 9 -#define RATE_48M 10 -#define RATE_54M 11 -#define RATE_AUTO 12 -#define MAX_RATE 12 - - -//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) -#define PK_TYPE_11A 0 -#define PK_TYPE_11B 1 -#define PK_TYPE_11GB 2 -#define PK_TYPE_11GA 3 -*/ - - #define PREAMBLE_LONG 0 #define PREAMBLE_SHORT 1 diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index f4f108f72afd..fcffa4f0f4e3 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -58,7 +58,6 @@ #include "wpa2.h" #include "iowpa.h" -//#define PLICE_DEBUG /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 138897a79325..084a1a5566ad 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -152,10 +152,6 @@ #define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000 #define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000 -//#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100 -//#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000 -//#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100 -//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000 #define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011 #define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010 #define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001 @@ -184,10 +180,6 @@ #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_AC3 0x000C // 0000 0000 0000 1100 -//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000 -//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100 -//#define FRAGCTL_AC0 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 @@ -195,8 +187,6 @@ #endif // #ifdef __BIG_ENDIAN -//#define TYPE_AC0DMA 0 -//#define TYPE_TXDMA0 1 #define TYPE_TXDMA0 0 #define TYPE_AC0DMA 1 #define TYPE_ATIMDMA 2 @@ -215,7 +205,6 @@ #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 -//#define TD_FLAGS_NETIF_SKB 0x04 /*--------------------- Export Types ------------------------------*/ diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 780205c0a88b..c5e6b98d3e4e 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -69,10 +69,6 @@ #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #endif -//2008-4-14<add> by chester for led issue -//#define FOR_LED_ON_NOTEBOOK -// - // // device specific @@ -91,12 +87,6 @@ #include "key.h" #include "mac.h" -//PLICE_DEBUG-> -//#define THREAD - -//#define TASK_LET -//PLICE_DEBUG<- - /*--------------------- Export Definitions -------------------------*/ @@ -105,11 +95,6 @@ #define MAX_MULTICAST_ADDRESS_NUM 32 #define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) - -//#define OP_MODE_INFRASTRUCTURE 0 -//#define OP_MODE_ADHOC 1 -//#define OP_MODE_AP 2 - #define DUPLICATE_RX_CACHE_LENGTH 5 #define NUM_KEY_ENTRY 11 diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 3e8283c2dc73..89d1c22695a0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -87,12 +87,10 @@ #include <linux/kthread.h> #include <linux/slab.h> -//#define DEBUG /*--------------------- Static Definitions -------------------------*/ //static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; -//#define PLICE_DEBUG // // Define module options // @@ -100,10 +98,8 @@ MODULE_AUTHOR("VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver"); -//PLICE_DEBUG -> static int mlme_kill; //static struct task_struct * mlme_task; -//PLICE_DEBUG <- #define DEVICE_PARAM(N,D) /* @@ -1086,15 +1082,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) device_free_info(pDevice); return -ENODEV; } -//2008-07-21-01<Add>by MikeLiu -//register wpadev -#if 0 - if(wpa_set_wpadev(pDevice, 1)!=0) { - printk("Fail to Register WPADEV?\n"); - unregister_netdev(pDevice->dev); - free_netdev(dev); - } -#endif device_print_info(pDevice); pci_set_drvdata(pcid, pDevice); return 0; @@ -1948,15 +1935,6 @@ device_init_rd0_ring(pDevice); -#if 0 - pDevice->MLMEThr_pid = kernel_thread(MlmeThread, pDevice, CLONE_VM); - if (pDevice->MLMEThr_pid <0 ) - { - printk("unable start thread MlmeThread\n"); - return -1; - } -#endif - //printk("thread id is %d\n",pDevice->MLMEThr_pid); //printk("Create thread time is %x\n",jiffies); //wait_for_completion(&pDevice->notify); @@ -2493,21 +2471,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { &(pDevice->byTopCCKBasicRate), &(pDevice->byTopOFDMBasicRate)); -#if 0 -printk("auto rate:Rate : %d,AckRate:%d,TopCCKRate:%d,TopOFDMRate:%d\n", -pDevice->wCurrentRate,pDevice->byACKRate, -pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate); - -#endif - -#if 0 - - pDevice->wCurrentRate = 11; - pDevice->byACKRate = 8; - pDevice->byTopCCKBasicRate = 3; - pDevice->byTopOFDMBasicRate = 8; -#endif - } } diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index c0fab4bc8702..e8a71ba4b92c 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -55,7 +55,6 @@ #include "iowpa.h" #include "aes_ccmp.h" -//#define PLICE_DEBUG /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 773502702203..6ac6f452b261 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -40,14 +40,8 @@ #define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024 #define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0 -#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1 -#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2 #define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3 -#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4 #define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5 -#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6 -#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7 - /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 87288db21785..77aad7f5ae76 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -84,24 +84,6 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) pDevice->wstats.status = pDevice->eOPMode; #ifdef Calcu_LinkQual - #if 0 - if(pDevice->byBBType == BB_TYPE_11B) { - if(pDevice->byCurrSQ > 120) - pDevice->scStatistic.LinkQuality = 100; - else - pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120; - } - else if(pDevice->byBBType == BB_TYPE_11G) { - if(pDevice->byCurrSQ < 20) - pDevice->scStatistic.LinkQuality = 100; - else if(pDevice->byCurrSQ >96) - pDevice->scStatistic.LinkQuality = 0; - else - pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76; - } - if(pDevice->bLinkPass !=true) - pDevice->scStatistic.LinkQuality = 0; - #endif if(pDevice->scStatistic.LinkQuality > 100) pDevice->scStatistic.LinkQuality = 100; pDevice->wstats.qual.qual =(unsigned char) pDevice->scStatistic.LinkQuality; @@ -2004,24 +1986,6 @@ param->u.wpa_key.key = (u8 *)key_array; param->u.wpa_key.seq = (u8 *)seq; param->u.wpa_key.seq_len = seq_len; -#if 0 -printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name); -printk(KERN_DEBUG "param->addr=%pM\n", param->addr); -printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx); -printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index); -printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len); -printk("param->u.wpa_key.key ="); -for(ii=0;ii<param->u.wpa_key.key_len;ii++) - printk("%02x:",param->u.wpa_key.key[ii]); - printk("\n"); -printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len); -printk("param->u.wpa_key.seq ="); -for(ii=0;ii<param->u.wpa_key.seq_len;ii++) - printk("%02x:",param->u.wpa_key.seq[ii]); - printk("\n"); - -printk("...........\n"); -#endif //****set if current action is Network Manager count?? //****this method is so foolish,but there is no other way??? if(param->u.wpa_key.alg_name == WPA_ALG_NONE) { diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index b96d27ee2540..e3ccfee90268 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -292,19 +292,11 @@ // #define EnCFG_BarkerPream 0x00020000 #define EnCFG_NXTBTTCFPSTR 0x00010000 -//#define EnCFG_TXLMT3UPDATE 0x00008000 -//#define EnCFG_TXLMT2UPDATE 0x00004000 -//#define EnCFG_TXLMT1UPDATE 0x00002000 -//#define EnCFG_TXLMT3EN 0x00001000 -//#define EnCFG_TXLMT2EN 0x00000800 -//#define EnCFG_TXLMT1EN 0x00000400 #define EnCFG_BcnSusClr 0x00000200 #define EnCFG_BcnSusInd 0x00000100 -//#define EnCFG_CWOFF1 0x00000080 #define EnCFG_CFP_ProtectEn 0x00000040 #define EnCFG_ProtectMd 0x00000020 #define EnCFG_HwParCFP 0x00000010 -//#define EnCFG_QOS 0x00000008 #define EnCFG_CFNULRSP 0x00000004 #define EnCFG_BBType_MASK 0x00000003 #define EnCFG_BBType_g 0x00000002 @@ -392,14 +384,6 @@ #define IMR_RADARDETECT 0x10000000 // #define IMR_MEASUREEND 0x08000000 // #define IMR_SOFTTIMER1 0x00200000 // -//#define IMR_SYNCFLUSHOK 0x00100000 // -//#define IMR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000 -//#define IMR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000 -//#define IMR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000 -//#define IMR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000 -//#define IMR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000 -//#define IMR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000 -//#define IMR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000 #define IMR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000 #define IMR_RXNOBUF 0x00000800 // #define IMR_MIBNEARFULL 0x00000400 // @@ -424,14 +408,6 @@ #define ISR_RADARDETECT 0x10000000 // #define ISR_MEASUREEND 0x08000000 // #define ISR_SOFTTIMER1 0x00200000 // -//#define ISR_SYNCFLUSHOK 0x00100000 //0001 0000 0000 0000 0000 0000 -//#define ISR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000 -//#define ISR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000 -//#define ISR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000 -//#define ISR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000 -//#define ISR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000 -//#define ISR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000 -//#define ISR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000 #define ISR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000 #define ISR_RXNOBUF 0x00000800 //0000 0000 0000 1000 0000 0000 #define ISR_MIBNEARFULL 0x00000400 //0000 0000 0000 0100 0000 0000 diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 009f3a4d29f6..5cd697a2bc77 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -98,7 +98,6 @@ typedef struct tagSMib2Counter { } SMib2Counter, *PSMib2Counter; // Value in the ifType entry -//#define ETHERNETCSMACD 6 // #define WIRELESSLANIEEE80211b 6 // // Value in the ifAdminStatus/ifOperStatus entry @@ -210,7 +209,6 @@ typedef struct tagSISRCounters { #define UNDER_CREATION 3 // #define INVALID 4 // -//#define MAX_RATE 12 // // statistic counter // diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index b8ec783e55e0..aa696650b86c 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -41,52 +41,16 @@ //static int msglevel =MSG_LEVEL_INFO; -#define BY_RF2959_REG_LEN 23 //24bits -#define CB_RF2959_INIT_SEQ 15 -#define SWITCH_CHANNEL_DELAY_RF2959 200 //us -#define RF2959_PWR_IDX_LEN 32 - -#define BY_MA2825_REG_LEN 23 //24bit -#define CB_MA2825_INIT_SEQ 13 -#define SWITCH_CHANNEL_DELAY_MA2825 200 //us -#define MA2825_PWR_IDX_LEN 31 - #define BY_AL2230_REG_LEN 23 //24bit #define CB_AL2230_INIT_SEQ 15 #define SWITCH_CHANNEL_DELAY_AL2230 200 //us #define AL2230_PWR_IDX_LEN 64 -#define BY_UW2451_REG_LEN 23 -#define CB_UW2451_INIT_SEQ 6 -#define SWITCH_CHANNEL_DELAY_UW2451 200 //us -#define UW2451_PWR_IDX_LEN 25 - -//{{ RobertYu: 20041118 -#define BY_MA2829_REG_LEN 23 //24bit -#define CB_MA2829_INIT_SEQ 13 -#define SWITCH_CHANNEL_DELAY_MA2829 200 //us -#define MA2829_PWR_IDX_LEN 64 -//}} RobertYu - -//{{ RobertYu:20050103 #define BY_AL7230_REG_LEN 23 //24bit #define CB_AL7230_INIT_SEQ 16 #define SWITCH_CHANNEL_DELAY_AL7230 200 //us #define AL7230_PWR_IDX_LEN 64 -//}} RobertYu - -//{{ RobertYu: 20041210 -#define BY_UW2452_REG_LEN 23 -#define CB_UW2452_INIT_SEQ 5 //RoberYu:20050113, Rev0.2 Programming Guide(remove R3, so 6-->5) -#define SWITCH_CHANNEL_DELAY_UW2452 100 //us -#define UW2452_PWR_IDX_LEN 64 -//}} RobertYu - -#define BY_VT3226_REG_LEN 23 -#define CB_VT3226_INIT_SEQ 12 -#define SWITCH_CHANNEL_DELAY_VT3226 200 //us -#define VT3226_PWR_IDX_LEN 16 /*--------------------- Static Classes ----------------------------*/ @@ -1067,48 +1031,6 @@ unsigned char byPwrdBm = 0; break; } -#if 0 - - // 802.11h TPC - if (pDevice->bLinkPass == true) { - // do not over local constraint - if (byPwrdBm > pDevice->abyLocalPwr[uCH]) { - pDevice->byCurPwrdBm = pDevice->abyLocalPwr[uCH]; - byDec = byPwrdBm - pDevice->abyLocalPwr[uCH]; - if (pDevice->byRFType == RF_UW2452) { - byDec *= 3; - } else { - byDec <<= 1; - } - if (byPwr > byDec) { - byPwr -= byDec; - } else { - byPwr = 0; - } - } else { - pDevice->byCurPwrdBm = byPwrdBm; - } - } else { - // do not over regulatory constraint - if (byPwrdBm > pDevice->abyRegPwr[uCH]) { - pDevice->byCurPwrdBm = pDevice->abyRegPwr[uCH]; - byDec = byPwrdBm - pDevice->abyRegPwr[uCH]; - if (pDevice->byRFType == RF_UW2452) { - byDec *= 3; - } else { - byDec <<= 1; - } - if (byPwr > byDec) { - byPwr -= byDec; - } else { - byPwr = 0; - } - } else { - pDevice->byCurPwrdBm = byPwrdBm; - } - } -#endif - // if (pDevice->byLocalID <= REV_ID_VT3253_B1) { if (pDevice->byCurPwr == byPwr) { return true; diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index 1f8d82e13041..73f09693ee7a 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -41,7 +41,6 @@ #define RF_MAXIMAG 0x02 #define RF_AIROHA 0x03 -//#define RF_GCT5103 0x04 #define RF_UW2451 0x05 #define RF_MAXIMG 0x06 #define RF_MAXIM2829 0x07 // RobertYu: 20041118 diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 787d885deee9..6a68f97d9a32 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -90,8 +90,6 @@ #define TYPE_CTL_ACK 0xd400 -//#define WEP_IV_MASK 0xFFFFFF00 - #else //if LITTLE_ENDIAN // // wType field in the SEthernetHeader @@ -143,7 +141,6 @@ #define TYPE_CTL_ACK 0x00d4 -//#define WEP_IV_MASK 0x00FFFFFF #endif //#ifdef __BIG_ENDIAN diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 0491d0b52c85..d645ecd89417 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -38,8 +38,6 @@ #include "wmgr.h" #include "datarate.h" -//#define PLICE_DEBUG - /*--------------------- Static Definitions -------------------------*/ //static int msglevel =MSG_LEVEL_DEBUG; //static int msglevel =MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index bab3b0116ccc..7b5b99c8cf14 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -684,18 +684,6 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS return; } pDevice->byLinkWaitCount = 0; - #if 0 - #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - // if(pDevice->bWPASuppWextEnabled == true) - { - union iwreq_data wrqu; - memset(&wrqu, 0, sizeof (wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } - #endif - #endif s_bCommandComplete(pDevice); break; @@ -748,18 +736,6 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS return; } pDevice->byLinkWaitCount = 0; - #if 0 - #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - // if(pDevice->bWPASuppWextEnabled == true) - { - union iwreq_data wrqu; - memset(&wrqu, 0, sizeof (wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } - #endif - #endif s_bCommandComplete(pDevice); break; diff --git a/drivers/staging/vt6656/80211hdr.h b/drivers/staging/vt6656/80211hdr.h index 15c6ef1a635c..b87d5434077a 100644 --- a/drivers/staging/vt6656/80211hdr.h +++ b/drivers/staging/vt6656/80211hdr.h @@ -78,7 +78,6 @@ #define WLAN_HDR_ADDR4_LEN 30 #define WLAN_IEHDR_LEN 2 #define WLAN_SSID_MAXLEN 32 -/* #define WLAN_RATES_MAXLEN 255 */ #define WLAN_RATES_MAXLEN 16 #define WLAN_RATES_MAXLEN_11B 4 #define WLAN_RSN_MAXLEN 32 @@ -104,7 +103,6 @@ #define WLAN_WEP40_KEYLEN 5 #define WLAN_WEP104_KEYLEN 13 #define WLAN_WEP232_KEYLEN 29 -/* #define WLAN_WEPMAX_KEYLEN 29 */ #define WLAN_WEPMAX_KEYLEN 32 #define WLAN_CHALLENGE_IE_MAXLEN 255 #define WLAN_CHALLENGE_IE_LEN 130 diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h index a8f97ebb659b..6b2ec390e775 100644 --- a/drivers/staging/vt6656/bssdb.h +++ b/drivers/staging/vt6656/bssdb.h @@ -64,8 +64,6 @@ // send and receive non-IEEE 802.1X frames #define WLAN_STA_AUTHORIZED BIT5 -//#define MAX_RATE 12 - #define MAX_WPA_IE_LEN 64 diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 9d09e9fd8e18..e3ddc0b55317 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -66,7 +66,6 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Definitions -------------------------*/ -#define CB_TXPOWER_LEVEL 6 /*--------------------- Static Classes ----------------------------*/ diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index 9cf71a3d8801..55962b198831 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -52,7 +52,6 @@ typedef enum _CARD_OP_MODE { } CARD_OP_MODE, *PCARD_OP_MODE; #define CB_MAX_CHANNEL_24G 14 -/* #define CB_MAX_CHANNEL_5G 24 */ #define CB_MAX_CHANNEL_5G 42 /* add channel9(5045MHz), 41==>42 */ #define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G) diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index 99e054d2d601..650217607858 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -368,8 +368,6 @@ static struct /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */ }; -#define NUM_RULES ARRAY_SIZE(ChannelRuleTab) - /*--------------------- Export function -------------------------*/ /************************************************************************ * Country Channel Valid diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 767112b3c4a9..b68b2ec96eaa 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -36,8 +36,6 @@ #include "ttype.h" #include "tether.h" -/*--------------------- Export Definitions -------------------------*/ - // max transmit or receive buffer size #define CB_MAX_BUF_SIZE 2900U // max buffer size // NOTE: must be multiple of 4 @@ -120,17 +118,11 @@ #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_AC3 0x000C // 0000 0000 0000 1100 -//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000 -//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100 -//#define FRAGCTL_AC0 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 TYPE_AC0DMA 0 -//#define TYPE_TXDMA0 1 #define TYPE_TXDMA0 0 #define TYPE_AC0DMA 1 #define TYPE_ATIMDMA 2 @@ -147,9 +139,6 @@ #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 -//#define TD_FLAGS_NETIF_SKB 0x04 - -/*--------------------- Export Types ------------------------------*/ // // RsvTime buffer header @@ -268,7 +257,6 @@ SRTS_a_FB, *PSRTS_a_FB; typedef const SRTS_a_FB *PCSRTS_a_FB; - // // CTS buffer header // @@ -421,12 +409,5 @@ typedef struct tagSKeyEntry { DWORD dwKey4[4]; } __attribute__ ((__packed__)) SKeyEntry; -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ #endif /* __DESC_H__ */ diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f1496ec5dc72..171dd68cf5b2 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -106,10 +106,6 @@ #define MAX_MULTICAST_ADDRESS_NUM 32 #define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) -//#define OP_MODE_INFRASTRUCTURE 0 -//#define OP_MODE_ADHOC 1 -//#define OP_MODE_AP 2 - #define DUPLICATE_RX_CACHE_LENGTH 5 #define NUM_KEY_ENTRY 11 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index 51b5adf36577..682002a5b8d7 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c @@ -41,31 +41,11 @@ #define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024 #define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0 -#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1 -#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2 #define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3 -#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4 #define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5 -#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6 -#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7 - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel =MSG_LEVEL_INFO; -/*--------------------- Static Functions --------------------------*/ - - - - -/*--------------------- Export Variables --------------------------*/ - - /* * Description: * register net_device (AP) for hostap deamon @@ -314,37 +294,6 @@ static int hostap_get_info_sta(PSDevice pDevice, return 0; } -/* - * Description: - * reset txexec - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * TURE, FALSE - * - * Return Value: - * - */ -/* -static int hostap_reset_txexc_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) -{ - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0; - } - else { - return -ENOENT; - } - - return 0; -} -*/ /* * Description: @@ -479,12 +428,6 @@ static int hostap_set_encryption(PSDevice pDevice, param->u.crypt.err = 0; -/* - if (param_len != - (int) ((char *) param->u.crypt.key - (char *) param) + - param->u.crypt.key_len) - return -EINVAL; -*/ if (param->u.crypt.alg > WPA_ALG_CCMP) return -EINVAL; @@ -814,12 +757,6 @@ int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p) ret = hostap_get_info_sta(pDevice, param); ap_ioctl = 1; break; -/* - case VIAWGET_HOSTAPD_RESET_TXEXC_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n"); - ret = hostap_reset_txexc_sta(pDevice, param); - break; -*/ case VIAWGET_HOSTAPD_SET_FLAGS_STA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n"); ret = hostap_set_flags_sta(pDevice, param); diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index dc240962c59c..8b9894b1146a 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -104,7 +104,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, PSMgmtObject pMgmt = &(pDevice->sMgmtObj); struct iw_scan_req *req = (struct iw_scan_req *)extra; BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - PWLAN_IE_SSID pItemSSID=NULL; + PWLAN_IE_SSID pItemSSID = NULL; if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) return -EINVAL; @@ -140,9 +140,9 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, if (pItemSSID->abySSID[req->essid_len - 1] == '\0') { if (req->essid_len > 0) pItemSSID->len = req->essid_len - 1; - } - else + } else { pItemSSID->len = req->essid_len; + } pMgmt->eScanType = WMAC_SCAN_PASSIVE; PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID, ((PWLAN_IE_SSID)abyScanSSID)->len); @@ -203,7 +203,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN); - current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); // ADD ssid memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWESSID; @@ -244,7 +244,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, iwe.u.qual.level = ldBm; iwe.u.qual.noise = 0; - if (-ldBm<50) + if (-ldBm < 50) iwe.u.qual.qual = 100; else if (-ldBm > 90) iwe.u.qual.qual = 0; @@ -577,9 +577,9 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, PRINT_K(" SIOCSIWAP \n"); - if (wrq->sa_family != ARPHRD_ETHER) + if (wrq->sa_family != ARPHRD_ETHER) { rc = -EINVAL; - else { + } else { memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); // mike: add if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) || @@ -882,8 +882,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, pDevice->uConnectionRate = brate; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate); } - } - else { + } else { pDevice->bFixRate = FALSE; pDevice->uConnectionRate = 13; } @@ -965,7 +964,6 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, wrq->value = pDevice->wRTSThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; - return 0; } @@ -1004,7 +1002,6 @@ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, wrq->value = pDevice->wFragmentationThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; - return 0; } @@ -1098,10 +1095,9 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, // Send the key to the card if (wrq->length > 0) { - - if (wrq->length == WLAN_WEP232_KEYLEN) { + if (wrq->length == WLAN_WEP232_KEYLEN) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n"); - } else if (wrq->length == WLAN_WEP104_KEYLEN) { + } else if (wrq->length == WLAN_WEP104_KEYLEN) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n"); } else if (wrq->length == WLAN_WEP40_KEYLEN) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex); @@ -1120,8 +1116,7 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, dwKeyIndex | (1 << 31), wrq->length, NULL, pDevice->abyKey, - KEY_CTL_WEP - ); + KEY_CTL_WEP); spin_unlock_irq(&pDevice->lock); } pDevice->byKeyIndex = (BYTE)dwKeyIndex; @@ -1205,7 +1200,7 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, wrq->length = 0; if ((index == 0) && (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled || - pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){ // get wpa pairwise key + pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) { // get wpa pairwise key if (KeybGetKey(&(pDevice->sKey), pMgmt->abyCurrBSSID, 0xffffffff, &pKey)) { wrq->length = pKey->uKeyLength; memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); @@ -1360,11 +1355,10 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED) break; if (pairwise == IW_AUTH_CIPHER_NONE) { - if (wrq->value == IW_AUTH_CIPHER_CCMP) { + if (wrq->value == IW_AUTH_CIPHER_CCMP) pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - }else { + else pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } } break; case IW_AUTH_KEY_MGMT: @@ -1446,7 +1440,7 @@ int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info, goto out; } pMgmt->wWPAIELen = wrq->length; - }else { + } else { memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN); pMgmt->wWPAIELen = 0; } @@ -1470,8 +1464,9 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) { ret = -EFAULT; } - } else + } else { ret = -E2BIG; + } } return ret; } @@ -1624,8 +1619,7 @@ int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, case IW_MLME_DISASSOC: if (pDevice->bLinkPass == TRUE) { PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n"); - bScheduleCommand((void *)pDevice, - WLAN_CMD_DISASSOCIATE, + bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); } break; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 5048341518c3..b06fd5b723fa 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -205,11 +205,6 @@ static const long frequency_list[] = { }; -#ifndef IW_ENCODE_NOKEY -#define IW_ENCODE_NOKEY 0x0800 -#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) -#endif - static const struct iw_handler_def iwctl_handler_def; */ diff --git a/drivers/staging/vt6656/mib.h b/drivers/staging/vt6656/mib.h index a89cca0c5ecf..82d69a9cc209 100644 --- a/drivers/staging/vt6656/mib.h +++ b/drivers/staging/vt6656/mib.h @@ -113,7 +113,6 @@ typedef struct tagSMib2Counter { } SMib2Counter, *PSMib2Counter; // Value in the ifType entry -//#define ETHERNETCSMACD 6 // #define WIRELESSLANIEEE80211b 6 // // Value in the ifAdminStatus/ifOperStatus entry diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9b64b102f55c..bb464527fc1b 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -73,8 +73,6 @@ static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ /*--------------------- Static Definitions -------------------------*/ -#define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send - // packet size >= 256 -> direct send const WORD wTimeStampOff[2][MAX_RATE] = { {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index 4ec05237469b..8c1f5d253f88 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -72,7 +72,6 @@ #define TYPE_CTL_ACK 0xd400 -//#define WEP_IV_MASK 0xFFFFFF00 #else //if LITTLE_ENDIAN // @@ -111,7 +110,6 @@ #define TYPE_CTL_ACK 0x00d4 -//#define WEP_IV_MASK 0x00FFFFFF #endif //#ifdef __BIG_ENDIAN diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index c612ab58f389..609e8fa10b98 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -52,9 +52,6 @@ //endpoint 2: read bulk //endpoint 3: write bulk -//RequestType: -//#define REQUEST_OUT (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) // 0x40 -//#define REQUEST_IN (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ) //0xc0 //static int msglevel =MSG_LEVEL_DEBUG; static int msglevel =MSG_LEVEL_INFO; diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index be6bb7d0971e..c033da408a58 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -68,9 +68,6 @@ static int XGIfb_crt2type = -1; /* PR: Tv plug type (for overriding autodetection) */ static int XGIfb_tvplug = -1; -/* TW: For ioctl XGIFB_GET_INFO */ -/* XGIfb_info XGIfbinfo; */ - #define MD_XGI315 1 /* mode table */ @@ -230,17 +227,6 @@ static const struct _XGI_vrate { {0, 0, 0, 0} }; -static const struct _chswtable { - int subsysVendor; - int subsysCard; - char *vendorName; - char *cardName; -} mychswtable[] = { - { 0x1631, 0x1002, "Mitachi", "0x1002" }, - { 0, 0, "" , "" } -}; - -/* Eden Chen */ static const struct _XGI_TV_filter { u8 filter[9][4]; } XGI_TV_filter[] = { diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index fe9061d37ce8..64ffd70eb7dc 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -36,72 +36,18 @@ static void dumpVGAReg(void) u8 i, reg; xgifb_reg_set(XGISR, 0x05, 0x86); - /* - xgifb_reg_set(XGISR, 0x08, 0x4f); - xgifb_reg_set(XGISR, 0x0f, 0x20); - xgifb_reg_set(XGISR, 0x11, 0x4f); - xgifb_reg_set(XGISR, 0x13, 0x45); - xgifb_reg_set(XGISR, 0x14, 0x51); - xgifb_reg_set(XGISR, 0x1e, 0x41); - xgifb_reg_set(XGISR, 0x1f, 0x0); - xgifb_reg_set(XGISR, 0x20, 0xa1); - xgifb_reg_set(XGISR, 0x22, 0xfb); - xgifb_reg_set(XGISR, 0x26, 0x22); - xgifb_reg_set(XGISR, 0x3e, 0x07); - */ - - /* xgifb_reg_set(XGICR, 0x19, 0x00); */ - /* xgifb_reg_set(XGICR, 0x1a, 0x3C); */ - /* xgifb_reg_set(XGICR, 0x22, 0xff); */ - /* xgifb_reg_set(XGICR, 0x3D, 0x10); */ - - /* xgifb_reg_set(XGICR, 0x4a, 0xf3); */ - - /* xgifb_reg_set(XGICR, 0x57, 0x0); */ - /* xgifb_reg_set(XGICR, 0x7a, 0x2c); */ - - /* xgifb_reg_set(XGICR, 0x82, 0xcc); */ - /* xgifb_reg_set(XGICR, 0x8c, 0x0); */ - /* - xgifb_reg_set(XGICR, 0x99, 0x1); - xgifb_reg_set(XGICR, 0x41, 0x40); - */ for (i = 0; i < 0x4f; i++) { reg = xgifb_reg_get(XGISR, i); - pr_debug("\no 3c4 %x", i); - pr_debug("\ni 3c5 => %x", reg); + pr_debug("o 3c4 %x\n", i); + pr_debug("i 3c5 => %x\n", reg); } for (i = 0; i < 0xF0; i++) { reg = xgifb_reg_get(XGICR, i); - pr_debug("\no 3d4 %x", i); - pr_debug("\ni 3d5 => %x", reg); + pr_debug("o 3d4 %x\n", i); + pr_debug("i 3d5 => %x\n", reg); } - /* - xgifb_reg_set(XGIPART1,0x2F,1); - for (i=1; i < 0x50; i++) { - reg = xgifb_reg_get(XGIPART1, i); - pr_debug("\no d004 %x", i); - pr_debug("\ni d005 => %x", reg); - } - - for (i=0; i < 0x50; i++) { - reg = xgifb_reg_get(XGIPART2, i); - pr_debug("\no d010 %x", i); - pr_debug("\ni d011 => %x", reg); - } - for (i=0; i < 0x50; i++) { - reg = xgifb_reg_get(XGIPART3, i); - pr_debug("\no d012 %x",i); - pr_debug("\ni d013 => %x",reg); - } - for (i=0; i < 0x50; i++) { - reg = xgifb_reg_get(XGIPART4, i); - pr_debug("\no d014 %x",i); - pr_debug("\ni d015 => %x",reg); - } - */ } #else static inline void dumpVGAReg(void) @@ -215,15 +161,6 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, | ((unsigned short) (sr_data & 0x01) << 10); A = VT + 2; - /* cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[10]; */ - - /* Vertical display enable end */ - /* - VDE = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x02) << 7) | - ((unsigned short) (cr_data2 & 0x40) << 3) | - ((unsigned short) (sr_data & 0x02) << 9); - */ VDE = XGI_Pr->RefIndex[RefreshRateTableIndex].YRes - 1; E = VDE + 1; @@ -325,28 +262,19 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) static int XGIfb_GetXG21DefaultLVDSModeIdx(struct xgifb_video_info *xgifb_info) { + int i = 0; - int found_mode = 0; - int XGIfb_mode_idx = 0; - - found_mode = 0; - while ((XGIbios_mode[XGIfb_mode_idx].mode_no != 0) - && (XGIbios_mode[XGIfb_mode_idx].xres - <= xgifb_info->lvds_data.LVDSHDE)) { - if ((XGIbios_mode[XGIfb_mode_idx].xres - == xgifb_info->lvds_data.LVDSHDE) - && (XGIbios_mode[XGIfb_mode_idx].yres - == xgifb_info->lvds_data.LVDSVDE) - && (XGIbios_mode[XGIfb_mode_idx].bpp == 8)) { - found_mode = 1; - break; + while ((XGIbios_mode[i].mode_no != 0) + && (XGIbios_mode[i].xres <= xgifb_info->lvds_data.LVDSHDE)) { + if ((XGIbios_mode[i].xres == xgifb_info->lvds_data.LVDSHDE) + && (XGIbios_mode[i].yres == xgifb_info->lvds_data.LVDSVDE) + && (XGIbios_mode[i].bpp == 8)) { + return i; } - XGIfb_mode_idx++; + i++; } - if (!found_mode) - XGIfb_mode_idx = -1; - return XGIfb_mode_idx; + return -1; } static void XGIfb_search_mode(struct xgifb_video_info *xgifb_info, @@ -377,7 +305,7 @@ invalid_mode: static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info, unsigned int vesamode) { - int i = 0, j = 0; + int i = 0; if (vesamode == 0) goto invalid; @@ -388,15 +316,13 @@ static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info, if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) || (XGIbios_mode[i].vesa_mode_no_2 == vesamode)) { xgifb_info->mode_idx = i; - j = 1; - break; + return; } i++; } invalid: - if (!j) - pr_info("Invalid VESA mode 0x%x'\n", vesamode); + pr_info("Invalid VESA mode 0x%x'\n", vesamode); } static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) @@ -590,7 +516,7 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) if (XGIbios_mode[myindex].yres != 576) return -1; } - /* TW: LVDS/CHRONTEL does not support 720 */ + /* LVDS/CHRONTEL does not support 720 */ if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL || xgifb_info->hasVB == HASVB_CHRONTEL) { return -1; @@ -654,7 +580,7 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, break; } else if (XGIfb_vrate[i].refresh > rate) { if ((XGIfb_vrate[i].refresh - rate) <= 3) { - pr_debug("XGIfb: Adjusting rate from %d up to %d\n", + pr_debug("Adjusting rate from %d up to %d\n", rate, XGIfb_vrate[i].refresh); xgifb_info->rate_idx = XGIfb_vrate[i].idx; @@ -663,8 +589,9 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, } else if (((rate - XGIfb_vrate[i - 1].refresh) <= 2) && (XGIfb_vrate[i].idx != 1)) { - pr_debug("XGIfb: Adjusting rate from %d down to %d\n", - rate, XGIfb_vrate[i-1].refresh); + pr_debug("Adjusting rate from %d down to %d\n", + rate, + XGIfb_vrate[i-1].refresh); xgifb_info->rate_idx = XGIfb_vrate[i - 1].idx; xgifb_info->refresh_rate = @@ -672,7 +599,7 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, } break; } else if ((rate - XGIfb_vrate[i].refresh) <= 2) { - pr_debug("XGIfb: Adjusting rate from %d down to %d\n", + pr_debug("Adjusting rate from %d down to %d\n", rate, XGIfb_vrate[i].refresh); xgifb_info->rate_idx = XGIfb_vrate[i].idx; break; @@ -794,26 +721,25 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) { u8 reg; unsigned char doit = 1; - /* - xgifb_reg_set(XGISR,IND_SIS_PASSWORD,SIS_PASSWORD); - xgifb_reg_set(XGICR, 0x13, 0x00); - xgifb_reg_and_or(XGISR,0x0E, 0xF0, 0x01); - *test* - */ + if (xgifb_info->video_bpp == 8) { - /* TW: We can't switch off CRT1 on LVDS/Chrontel - * in 8bpp Modes */ + /* + * We can't switch off CRT1 on LVDS/Chrontel + * in 8bpp Modes + */ if ((xgifb_info->hasVB == HASVB_LVDS) || (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) { doit = 0; } - /* TW: We can't switch off CRT1 on 301B-DH - * in 8bpp Modes if using LCD */ + /* + * We can't switch off CRT1 on 301B-DH + * in 8bpp Modes if using LCD + */ if (xgifb_info->display2 == XGIFB_DISP_LCD) doit = 0; } - /* TW: We can't switch off CRT1 if bridge is in slave mode */ + /* We can't switch off CRT1 if bridge is in slave mode */ if (xgifb_info->hasVB != HASVB_NONE) { reg = xgifb_reg_get(XGIPART1, 0x00); @@ -1038,7 +964,6 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, unsigned int drate = 0, hrate = 0; int found_mode = 0; int old_mode; - /* unsigned char reg, reg1; */ info->var.xres_virtual = var->xres_virtual; info->var.yres_virtual = var->yres_virtual; @@ -1048,13 +973,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, vtotal <<= 1; else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) vtotal <<= 2; - else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - /* vtotal <<= 1; */ - /* var->yres <<= 1; */ - } if (!htotal || !vtotal) { - pr_debug("XGIfb: Invalid 'var' information\n"); + pr_debug("Invalid 'var' information\n"); return -EINVAL; } pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n", var->pixclock, htotal, vtotal); @@ -1130,7 +1051,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, XGIfb_post_setmode(xgifb_info); - pr_debug("XGIfb: Set new mode: %dx%dx%d-%d\n", + pr_debug("Set new mode: %dx%dx%d-%d\n", XGIbios_mode[xgifb_info->mode_idx].xres, XGIbios_mode[xgifb_info->mode_idx].yres, XGIbios_mode[xgifb_info->mode_idx].bpp, @@ -1176,7 +1097,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, break; default: xgifb_info->video_cmap_len = 16; - pr_err("Unsupported depth %d", + pr_err("Unsupported depth %d\n", xgifb_info->video_bpp); break; } @@ -1370,7 +1291,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) + var->vsync_len; if (!(htotal) || !(vtotal)) { - pr_debug("XGIfb: no valid timing data\n"); + pr_debug("No valid timing data\n"); return -EINVAL; } @@ -1388,16 +1309,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) xgifb_info->refresh_rate = 60; } - /* - if ((var->pixclock) && (htotal)) { - drate = 1E12 / var->pixclock; - hrate = drate / htotal; - refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5); - } else { - refresh_rate = 60; - } - */ - /* TW: Calculation wrong for 1024x600 - force it to 60Hz */ + /* Calculation wrong for 1024x600 - force it to 60Hz */ if ((var->xres == 1024) && (var->yres == 600)) refresh_rate = 60; @@ -1446,8 +1358,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) } } - /* TW: TODO: Check the refresh rate */ - /* Adapt RGB settings */ XGIfb_bpp_to_var(xgifb_info, var); @@ -1462,16 +1372,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) var->xres_virtual = var->xres; if (var->yres != var->yres_virtual) var->yres_virtual = var->yres; - } /* else { */ - /* TW: Now patch yres_virtual if we use panning */ - /* May I do this? */ - /* var->yres_virtual = xgifb_info->heapstart / - (var->xres * (var->bits_per_pixel >> 3)); */ - /* if (var->yres_virtual <= var->yres) { */ - /* TW: Paranoia check */ - /* var->yres_virtual = var->yres; */ - /* } */ - /* } */ + } /* Truncate offsets to maximum if too high */ if (var->xoffset > var->xres_virtual - var->xres) @@ -1553,7 +1454,6 @@ static struct fb_ops XGIfb_ops = { .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, - /* .fb_mmap = XGIfb_mmap, */ }; /* ---------------- Chip generation dependent routines ---------------- */ @@ -1630,9 +1530,6 @@ static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info) } xgifb_info->video_size = xgifb_info->video_size * ChannelNum; - /* PLiad fixed for benchmarking and fb set */ - /* xgifb_info->video_size = 0x200000; */ /* 1024x768x16 */ - /* xgifb_info->video_size = 0x1000000; */ /* benchmark */ pr_info("SR14=%x DramSzie %x ChannelNum %x\n", reg, @@ -1647,16 +1544,6 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) xgifb_info->TV_plug = xgifb_info->TV_type = 0; - switch (xgifb_info->hasVB) { - case HASVB_LVDS_CHRONTEL: - case HASVB_CHRONTEL: - break; - case HASVB_301: - case HASVB_302: - /* XGI_Sense30x(); */ /* Yi-Lin TV Sense? */ - break; - } - cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32); if ((cr32 & SIS_CRT1) && !XGIfb_crt1off) @@ -1680,7 +1567,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) } if (XGIfb_tvplug != -1) - /* PR/TW: Override with option */ + /* Override with option */ xgifb_info->TV_plug = XGIfb_tvplug; else if (cr32 & SIS_VB_HIVISION) { xgifb_info->TV_type = TVMODE_HIVISION; @@ -1700,7 +1587,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) xgifb_info->TV_type = TVMODE_NTSC; } - /* TW: Copy forceCRT1 option to CRT1off if option is given */ + /* Copy forceCRT1 option to CRT1off if option is given */ if (XGIfb_forcecrt1 != -1) { if (XGIfb_forcecrt1) XGIfb_crt1off = 0; @@ -1752,7 +1639,7 @@ static int __init xgifb_optval(char *fullopt, int validx) unsigned long lres; if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) { - pr_err("xgifb: invalid value for option: %s\n", fullopt); + pr_err("Invalid value for option: %s\n", fullopt); return 0; } return lres; @@ -1765,7 +1652,7 @@ static int __init XGIfb_setup(char *options) if (!options || !*options) return 0; - pr_info("xgifb: options: %s\n", options); + pr_info("Options: %s\n", options); while ((this_opt = strsep(&options, ",")) != NULL) { @@ -1794,7 +1681,7 @@ static int __init XGIfb_setup(char *options) XGIfb_search_tvstd(this_opt + 7); } else if (!strncmp(this_opt, "dstn", 4)) { enable_dstn = 1; - /* TW: DSTN overrules forcecrt2type */ + /* DSTN overrules forcecrt2type */ XGIfb_crt2type = XGIFB_DISP_LCD; } else if (!strncmp(this_opt, "noypan", 6)) { XGIfb_ypan = 0; @@ -1858,7 +1745,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD); if (reg1 != 0xa1) { /*I/O error */ - dev_err(&pdev->dev, "I/O error!!!"); + dev_err(&pdev->dev, "I/O error\n"); ret = -EIO; goto error_disable; } @@ -1908,7 +1795,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, if (!request_mem_region(xgifb_info->video_base, xgifb_info->video_size, "XGIfb FB")) { - dev_err(&pdev->dev, "unable request memory size %x\n", + dev_err(&pdev->dev, "Unable request memory size %x\n", xgifb_info->video_size); dev_err(&pdev->dev, "Fatal error: Unable to reserve frame buffer memory. " @@ -1981,13 +1868,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, dev_info(&pdev->dev, "XGI301LV bridge detected (revision 0x%02x)\n", reg); - } - /* else if (reg >= 0xB0) { - hw_info->ujVBChipID = VB_CHIP_301B; - reg1 = xgifb_reg_get(XGIPART4, 0x23); - pr_debug("XGIfb: XGI301B bridge detected\n"); - } */ - else { + } else { hw_info->ujVBChipID = VB_CHIP_301; dev_info(&pdev->dev, "XGI301 bridge detected\n"); } @@ -2049,36 +1930,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } } - if ((hw_info->ujVBChipID == VB_CHIP_302B) || - (hw_info->ujVBChipID == VB_CHIP_301LV) || - (hw_info->ujVBChipID == VB_CHIP_302LV)) { - int tmp; - tmp = xgifb_reg_get(XGICR, 0x34); - if (tmp <= 0x13) { - /* Currently on LCDA? - *(Some BIOSes leave CR38) */ - tmp = xgifb_reg_get(XGICR, 0x38); - if ((tmp & 0x03) == 0x03) { - /* XGI_Pr.XGI_UseLCDA = 1; */ - } else { - /* Currently on LCDA? - *(Some newer BIOSes set D0 in CR35) */ - tmp = xgifb_reg_get(XGICR, 0x35); - if (tmp & 0x01) { - /* XGI_Pr.XGI_UseLCDA = 1; */ - } else { - tmp = xgifb_reg_get(XGICR, - 0x30); - if (tmp & 0x20) { - tmp = xgifb_reg_get( - XGIPART1, 0x13); - } - } - } - } - - } - xgifb_info->mode_idx = -1; if (mode) @@ -2100,11 +1951,11 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, } if (xgifb_info->mode_idx < 0) { - dev_err(&pdev->dev, "no supported video mode found\n"); + dev_err(&pdev->dev, "No supported video mode found\n"); goto error_1; } - /* yilin set default refresh rate */ + /* set default refresh rate */ xgifb_info->refresh_rate = refresh_rate; if (xgifb_info->refresh_rate == 0) xgifb_info->refresh_rate = 60; @@ -2212,7 +2063,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1); if (xgifb_info->mtrr >= 0) - dev_info(&pdev->dev, "added MTRR\n"); + dev_info(&pdev->dev, "Added MTRR\n"); #endif if (register_framebuffer(fb_info) < 0) { diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h index 741bba351cff..80547983759b 100644 --- a/drivers/staging/xgifb/XGIfb.h +++ b/drivers/staging/xgifb/XGIfb.h @@ -30,13 +30,13 @@ enum xgi_tvtype { TVMODE_NTSC = 0, TVMODE_PAL, TVMODE_HIVISION, - TVTYPE_PALM, /* vicki@030226 */ - TVTYPE_PALN, /* vicki@030226 */ - TVTYPE_NTSCJ, /* vicki@030226 */ + TVTYPE_PALM, + TVTYPE_PALN, + TVTYPE_NTSCJ, TVMODE_TOTAL }; -enum xgi_tv_plug { /* vicki@030226 */ +enum xgi_tv_plug { TVPLUG_UNKNOWN = 0, TVPLUG_COMPOSITE = 1, TVPLUG_SVIDEO = 2, diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 5b987a68ee9f..69078d933a47 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -1,5 +1,3 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h - * ,v 1.4 2000/12/02 01:16:17 dawes Exp $*/ #ifndef _VB_DEF_ #define _VB_DEF_ #include "../../video/sis/initdef.h" @@ -12,7 +10,6 @@ #define SetCHTVOverScan 0x8000 #define Panel_320x480 0x07 /*fstn*/ -/* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */ #define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */ #define Panel_1024x768x75 0x22 #define Panel_1280x1024x75 0x23 diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 7c555a7725fe..80dba6a425ba 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -1,4 +1,4 @@ -#include <linux/delay.h> /* udelay */ +#include <linux/delay.h> #include <linux/vmalloc.h> #include "XGIfb.h" @@ -132,10 +132,8 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, 0x30, pVBInfo->ECLKData[pVBInfo->ram_type].SR30); - /* [Vicent] 2004/07/07, - * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */ - /* [Hsuan] 2004/08/20, - * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, + /* 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) && @@ -160,7 +158,6 @@ static void XGINew_DDRII_Bootup_XG27( XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); /* Set Double Frequency */ - /* xgifb_reg_set(P3d4, 0x97, 0x11); *//* CR97 */ xgifb_reg_set(P3d4, 0x97, pVBInfo->XGINew_CR97); /* CR97 */ udelay(200); @@ -192,7 +189,6 @@ static void XGINew_DDRII_Bootup_XG27( udelay(30); xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */ xgifb_reg_set(P3c4, 0x16, 0x80); /* Set SR16 */ - /* udelay(15); */ xgifb_reg_set(P3c4, 0x1B, 0x04); /* Set SR1B */ udelay(60); @@ -252,7 +248,6 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(P3c4, 0x16, 0x05); xgifb_reg_set(P3c4, 0x16, 0x85); - /* xgifb_reg_set(P3c4, 0x18, 0x52); */ /* MRS1 */ xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */ xgifb_reg_set(P3c4, 0x19, 0x02); xgifb_reg_set(P3c4, 0x16, 0x05); @@ -264,7 +259,6 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(P3c4, 0x1B, 0x00); /* SR1B */ udelay(100); - /* xgifb_reg_set(P3c4 ,0x18, 0x52); */ /* MRS2 */ xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */ xgifb_reg_set(P3c4, 0x19, 0x00); xgifb_reg_set(P3c4, 0x16, 0x05); @@ -290,14 +284,12 @@ static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4, xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ - /* xgifb_reg_set(P3c4, 0x18, 0x31); */ xgifb_reg_set(P3c4, 0x19, 0x01); xgifb_reg_set(P3c4, 0x16, 0x03); xgifb_reg_set(P3c4, 0x16, 0x83); mdelay(1); xgifb_reg_set(P3c4, 0x1B, 0x03); udelay(500); - /* xgifb_reg_set(P3c4, 0x18, 0x31); */ xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */ @@ -546,7 +538,6 @@ static void XGINew_SetDRAMDefaultRegister340( xgifb_reg_set(P3d4, 0x87, 0x00); /* CR87 */ xgifb_reg_set(P3d4, 0xCF, XG40_CRCF); /* CRCF */ if (pVBInfo->ram_type) { - /* xgifb_reg_set(P3c4, 0x17, 0xC0); */ /* SR17 DDRII */ xgifb_reg_set(P3c4, 0x17, 0x80); /* SR17 DDRII */ if (HwDeviceExtension->jChipType == XG27) xgifb_reg_set(P3c4, 0x17, 0x02); /* SR17 DDRII */ @@ -597,19 +588,12 @@ static unsigned short XGINew_SetDRAMSize20Reg( memsize = data >> 4; - /* [2004/03/25] Vicent, Fix DRAM Sizing Error */ + /* Fix DRAM Sizing Error */ xgifb_reg_set(pVBInfo->P3c4, 0x14, (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | (data & 0xF0)); udelay(15); - - /* data |= pVBInfo->ram_channel << 2; */ - /* data |= (pVBInfo->ram_bus / 64) << 1; */ - /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ - - /* should delay */ - /* XGINew_SetDRAMModeRegister340(pVBInfo); */ } return memsize; } @@ -628,8 +612,7 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr, writel(Position, fbaddr + Position); } - udelay(500); /* [Vicent] 2004/04/16. - Fix #1759 Memory Size error in Multi-Adapter. */ + udelay(500); /* Fix #1759 Memory Size error in Multi-Adapter. */ Position = 0; @@ -925,9 +908,6 @@ static void XGINew_SetDRAMSize_340(struct xgifb_video_info *xgifb_info, xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data & 0xDF)); XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); - /* data = xgifb_reg_get(pVBInfo->P3c4, 0x1); */ - /* data |= 0x20 ; */ - /* xgifb_reg_set(pVBInfo->P3c4, 0x01, data); *//* Turn OFF Display */ XGINew_DDRSizing340(HwDeviceExtension, pVBInfo); data = xgifb_reg_get(pVBInfo->P3c4, 0x21); /* enable read cache */ @@ -971,7 +951,7 @@ static void xgifb_read_vbios(struct pci_dev *pdev, pVBInfo->IF_DEF_LVDS = 0; vbios = xgifb_copy_rom(pdev, &vbios_size); if (vbios == NULL) { - dev_err(&pdev->dev, "video BIOS not available\n"); + dev_err(&pdev->dev, "Video BIOS not available\n"); return; } if (vbios_size <= 0x65) @@ -1026,7 +1006,7 @@ static void xgifb_read_vbios(struct pci_dev *pdev, pVBInfo->IF_DEF_LVDS = 1; return; error: - dev_err(&pdev->dev, "video BIOS corrupted\n"); + dev_err(&pdev->dev, "Video BIOS corrupted\n"); vfree(vbios); } @@ -1062,9 +1042,8 @@ static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, if (tempbx & tempcx) { CR3CData = xgifb_reg_get(pVBInfo->P3d4, 0x3c); - if (!(CR3CData & DisplayDeviceFromCMOS)) { + if (!(CR3CData & DisplayDeviceFromCMOS)) tempcx = 0x1FF0; - } } else { tempcx = 0x1FF0; } @@ -1205,13 +1184,11 @@ static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension, { unsigned char Temp; -#if 1 if (pVBInfo->IF_DEF_LVDS) { /* For XG21 LVDS */ xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense); /* LVDS on chip */ xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); } else { -#endif /* Enable GPIOA/B read */ xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03); Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0xC0; @@ -1234,9 +1211,7 @@ static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension, /* Disable read GPIOF */ xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); } -#if 1 } -#endif } static void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension, @@ -1308,16 +1283,11 @@ unsigned char XGIInitNew(struct pci_dev *pdev) struct vb_device_info VBINF; struct vb_device_info *pVBInfo = &VBINF; unsigned char i, temp = 0, temp1; - /* VBIOSVersion[5]; */ - - /* unsigned long j, k; */ pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; pVBInfo->BaseAddr = xgifb_info->vga_base; - /* Newdebugcode(0x99); */ - if (pVBInfo->FBAddr == NULL) { dev_dbg(&pdev->dev, "pVBInfo->FBAddr == 0\n"); return 0; @@ -1331,10 +1301,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev) pVBInfo->ISXPDOS = 0; - /* VBIOSVersion[4] = 0x0; */ - - /* 09/07/99 modify by domao */ - pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; @@ -1353,7 +1319,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; - if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) /* Run XGI_GetVBType before InitTo330Pointer */ XGI_GetVBType(pVBInfo); @@ -1361,7 +1327,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_read_vbios(pdev, pVBInfo); - /* 1.Openkey */ + /* Openkey */ xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); /* GetXG21Sense (GPIO) */ @@ -1371,7 +1337,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) if (HwDeviceExtension->jChipType == XG27) XGINew_GetXG27Sense(HwDeviceExtension, pVBInfo); - /* 2.Reset Extended register */ + /* Reset Extended register */ for (i = 0x06; i < 0x20; i++) xgifb_reg_set(pVBInfo->P3c4, i, 0); @@ -1379,31 +1345,20 @@ unsigned char XGIInitNew(struct pci_dev *pdev) for (i = 0x21; i <= 0x27; i++) xgifb_reg_set(pVBInfo->P3c4, i, 0); - /* for(i = 0x06; i <= 0x27; i++) */ - /* xgifb_reg_set(pVBInfo->P3c4, i, 0); */ - for (i = 0x31; i <= 0x3B; i++) xgifb_reg_set(pVBInfo->P3c4, i, 0); - /* [Hsuan] 2004/08/20 Auto over driver for XG42 */ + /* Auto over driver for XG42 */ if (HwDeviceExtension->jChipType == XG42) xgifb_reg_set(pVBInfo->P3c4, 0x3B, 0xC0); - /* for (i = 0x30; i <= 0x3F; i++) */ - /* xgifb_reg_set(pVBInfo->P3d4, i, 0); */ - for (i = 0x79; i <= 0x7C; i++) - xgifb_reg_set(pVBInfo->P3d4, i, 0); /* shampoo 0208 */ + xgifb_reg_set(pVBInfo->P3d4, i, 0); if (HwDeviceExtension->jChipType >= XG20) xgifb_reg_set(pVBInfo->P3d4, 0x97, pVBInfo->XGINew_CR97); - /* 3.SetMemoryClock - - pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); - */ - - /* 4.SetDefExt1Regs begin */ + /* SetDefExt1Regs begin */ xgifb_reg_set(pVBInfo->P3c4, 0x07, XGI330_SR07); if (HwDeviceExtension->jChipType == XG27) { xgifb_reg_set(pVBInfo->P3c4, 0x40, XG27_SR40); @@ -1411,62 +1366,16 @@ unsigned char XGIInitNew(struct pci_dev *pdev) } xgifb_reg_set(pVBInfo->P3c4, 0x11, 0x0F); xgifb_reg_set(pVBInfo->P3c4, 0x1F, XGI330_SR1F); - /* xgifb_reg_set(pVBInfo->P3c4, 0x20, 0x20); */ - /* alan, 2001/6/26 Frame buffer can read/write SR20 */ + /* Frame buffer can read/write SR20 */ xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0); - /* Hsuan, 2006/01/01 H/W request for slow corner chip */ + /* H/W request for slow corner chip */ xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70); - if (HwDeviceExtension->jChipType == XG27) /* Alan 12/07/2006 */ + if (HwDeviceExtension->jChipType == XG27) xgifb_reg_set(pVBInfo->P3c4, 0x36, XG27_SR36); - /* SR11 = 0x0F; */ - /* xgifb_reg_set(pVBInfo->P3c4, 0x11, SR11); */ - - if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) { u32 Temp; - /* Set AGP Rate */ - /* - temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B); - temp1 &= 0x02; - if (temp1 == 0x02) { - outl(0x80000000, 0xcf8); - ChipsetID = inl(0x0cfc); - outl(0x8000002C, 0xcf8); - VendorID = inl(0x0cfc); - VendorID &= 0x0000FFFF; - outl(0x8001002C, 0xcf8); - GraphicVendorID = inl(0x0cfc); - GraphicVendorID &= 0x0000FFFF; - - if (ChipsetID == 0x7301039) - xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x09); - - ChipsetID &= 0x0000FFFF; - - if ((ChipsetID == 0x700E) || - (ChipsetID == 0x1022) || - (ChipsetID == 0x1106) || - (ChipsetID == 0x10DE)) { - if (ChipsetID == 0x1106) { - if ((VendorID == 0x1019) && - (GraphicVendorID == 0x1019)) - xgifb_reg_set(pVBInfo->P3d4, - 0x5F, - 0x0D); - else - xgifb_reg_set(pVBInfo->P3d4, - 0x5F, - 0x0B); - } else { - xgifb_reg_set(pVBInfo->P3d4, - 0x5F, - 0x0B); - } - } - } - */ - /* Set AGP customize registers (in SetDefAGPRegs) Start */ for (i = 0x47; i <= 0x4C; i++) xgifb_reg_set(pVBInfo->P3d4, @@ -1482,12 +1391,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_reg_set(pVBInfo->P3d4, i, pVBInfo->AGPReg[8 + i - 0x74]); - /* Set AGP customize registers (in SetDefAGPRegs) End */ - /* [Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */ - /* outl(0x80000000, 0xcf8); */ - /* ChipsetID = inl(0x0cfc); */ - /* if (ChipsetID == 0x25308086) */ - /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */ pci_read_config_dword(pdev, 0x50, &Temp); Temp >>= 20; @@ -1502,10 +1405,10 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_reg_set(pVBInfo->P3c4, 0x24, XGI330_SR24); xgifb_reg_set(pVBInfo->P3c4, 0x25, XGI330_SR25); - if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) { /* Set VB */ XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); - /* alan, disable VideoCapture */ + /* disable VideoCapture */ xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00); xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00); /* chk if BCLK>=100MHz */ @@ -1535,10 +1438,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) } xgifb_reg_set(pVBInfo->P3c4, 0x33, XGI330_SR33); - /* - SetPowerConsume (HwDeviceExtension, pVBInfo->P3c4); */ - - if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) { if (XGI_BridgeIsOn(pVBInfo) == 1) { if (pVBInfo->IF_DEF_LVDS == 0) { xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1C); @@ -1557,7 +1457,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev) XGI_SenseCRT1(pVBInfo); - /* XGINew_DetectMonitor(HwDeviceExtension); */ if (HwDeviceExtension->jChipType == XG21) { xgifb_reg_and_or(pVBInfo->P3d4, @@ -1585,32 +1484,9 @@ unsigned char XGIInitNew(struct pci_dev *pdev) XGINew_SetDRAMSize_340(xgifb_info, HwDeviceExtension, pVBInfo); - /* SetDefExt2Regs begin */ - /* - AGP = 1; - temp = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x3A); - temp &= 0x30; - if (temp == 0x30) - AGP = 0; - - if (AGP == 0) - pVBInfo->SR21 &= 0xEF; - - xgifb_reg_set(pVBInfo->P3c4, 0x21, pVBInfo->SR21); - if (AGP == 1) - pVBInfo->SR22 &= 0x20; - xgifb_reg_set(pVBInfo->P3c4, 0x22, pVBInfo->SR22); - */ - /* base = 0x80000000; */ - /* OutPortLong(0xcf8, base); */ - /* Temp = (InPortLong(0xcfc) & 0xFFFF); */ - /* if (Temp == 0x1039) { */ xgifb_reg_set(pVBInfo->P3c4, 0x22, (unsigned char) ((pVBInfo->SR22) & 0xFE)); - /* } else { */ - /* xgifb_reg_set(pVBInfo->P3c4, 0x22, pVBInfo->SR22); */ - /* } */ xgifb_reg_set(pVBInfo->P3c4, 0x21, pVBInfo->SR21); diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 479362eacb4f..e81149fc66e3 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -161,18 +161,15 @@ static void XGI_SetATTRegs(unsigned short ModeNo, for (i = 0; i <= 0x13; i++) { ARdata = pVBInfo->StandTable->ATTR[i]; - if (modeflag & Charx8Dot) { /* ifndef Dot9 */ - if (i == 0x13) { - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { + + if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ + if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { + ARdata = 0; + } else { + if ((pVBInfo->VBInfo & + (SetCRT2ToTV | SetCRT2ToLCD)) && + (pVBInfo->VBInfo & SetInSlaveMode)) ARdata = 0; - } else { - if (pVBInfo->VBInfo & (SetCRT2ToTV - | SetCRT2ToLCD)) { - if (pVBInfo->VBInfo & - SetInSlaveMode) - ARdata = 0; - } - } } } @@ -253,48 +250,30 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { tempax |= SupportLCD; - if (pVBInfo->LCDResInfo != Panel_1280x1024) { - if (pVBInfo->LCDResInfo != Panel_1280x960) { - if (pVBInfo->LCDInfo & - LCDNonExpanding) { - if (resinfo >= 9) { - tempax = 0; - return 0; - } - } - } - } + if (pVBInfo->LCDResInfo != Panel_1280x1024 && + pVBInfo->LCDResInfo != Panel_1280x960 && + (pVBInfo->LCDInfo & LCDNonExpanding) && + resinfo >= 9) + return 0; } if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ if ((pVBInfo->VBType & VB_SIS301LV) && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { tempax |= SupportYPbPr750p; - if (pVBInfo->VBInfo & SetInSlaveMode) { - if (resinfo == 4) - return 0; - - if (resinfo == 3) - return 0; - - if (resinfo > 7) - return 0; - } + if ((pVBInfo->VBInfo & SetInSlaveMode) && + ((resinfo == 3) || + (resinfo == 4) || + (resinfo > 7))) + return 0; } else { tempax |= SupportHiVision; - if (pVBInfo->VBInfo & SetInSlaveMode) { - if (resinfo == 4) - return 0; - - if (resinfo == 3) { - if (pVBInfo->SetFlag - & TVSimuMode) - return 0; - } - - if (resinfo > 7) + if ((pVBInfo->VBInfo & SetInSlaveMode) && + ((resinfo == 4) || + (resinfo == 3 && + (pVBInfo->SetFlag & TVSimuMode)) || + (resinfo > 7))) return 0; - } } } else { if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | @@ -304,23 +283,18 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, SetCRT2ToHiVision)) { tempax |= SupportTV; - if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B - | VB_SIS301LV | VB_SIS302LV - | VB_XGI301C)) { + if (pVBInfo->VBType & (VB_SIS301B | + VB_SIS302B | + VB_SIS301LV | + VB_SIS302LV | + VB_XGI301C)) tempax |= SupportTV1024; - } - if (!(pVBInfo->VBInfo & TVSetPAL)) { - if (modeflag & NoSupportSimuTV) { - if (pVBInfo->VBInfo & - SetInSlaveMode) { - if (!(pVBInfo->VBInfo & - SetNotSimuMode)) { - return 0; - } - } - } - } + if (!(pVBInfo->VBInfo & TVSetPAL) && + (modeflag & NoSupportSimuTV) && + (pVBInfo->VBInfo & SetInSlaveMode) && + (!(pVBInfo->VBInfo & SetNotSimuMode))) + return 0; } } } else { /* for LVDS */ @@ -971,23 +945,26 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, if (pVBInfo->IF_DEF_LVDS == 0) { CRT2Index = CRT2Index >> 6; /* for LCD */ - if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ + if (pVBInfo->VBInfo & + (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ if (pVBInfo->LCDResInfo != Panel_1024x768) - VCLKIndex = VCLK108_2_315 + 5; /* LCDXlat2VCLK */ + /* LCDXlat2VCLK */ + VCLKIndex = VCLK108_2_315 + 5; else VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { - if (pVBInfo->SetFlag & RPLLDIV2XO) { + if (pVBInfo->SetFlag & RPLLDIV2XO) VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; - } else { + else VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; - } if (pVBInfo->SetFlag & TVSimuMode) { if (modeflag & Charx8Dot) { - VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK; + VCLKIndex = TVCLKBASE_315_25 + + HiTVSimuVCLK; } else { - VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK; + VCLKIndex = TVCLKBASE_315_25 + + HiTVTextVCLK; } } @@ -1004,11 +981,10 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, VCLKIndex = YPbPr525iVCLK; } } else if (pVBInfo->VBInfo & SetCRT2ToTV) { - if (pVBInfo->SetFlag & RPLLDIV2XO) { + if (pVBInfo->SetFlag & RPLLDIV2XO) VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; - } else { + else VCLKIndex = TVCLKBASE_315_25 + TVVCLK; - } } else { /* for CRT2 */ /* di+Ext_CRTVCLK */ VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex]. @@ -1020,7 +996,8 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, (pVBInfo->LCDResInfo == Panel_320x480)) VCLKIndex = VCLK40; /* LVDSXlat1VCLK */ else - VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */ + VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, + LVDSXlat3VCLK */ } return VCLKIndex; @@ -1859,7 +1836,6 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, i++; } - /* 07/05/22 */ if (table == 0x04) { switch (tempdi[i].DATAPTR) { case 0: @@ -1955,7 +1931,8 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->HDE = 1024; pVBInfo->VDE = 768; } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || - (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { + (pVBInfo->LCDResInfo == + Panel_1280x1024x75)) { pVBInfo->HDE = 1280; pVBInfo->VDE = 1024; } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { @@ -2412,7 +2389,8 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, if (pVBInfo->TVInfo & TVSimuMode) { tempal = TVCLKBASE_315 + HiTVSimuVCLK; if (!(modeflag & Charx8Dot)) - tempal = TVCLKBASE_315 + HiTVTextVCLK; + tempal = TVCLKBASE_315 + + HiTVTextVCLK; } return tempal; @@ -2458,8 +2436,8 @@ static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, { if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { - if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag - & ProgrammingCRT2)) { + if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && + (pVBInfo->SetFlag & ProgrammingCRT2)) { *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; *di_1 = XGI_VBVCLKData[tempal].SR2C; } @@ -2519,7 +2497,7 @@ static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, temp &= 0x0f; if (!(temp == 0x08)) { - /* Check ChannelA by Part1_13 [2003/10/03] */ + /* Check ChannelA */ tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); if (tempax & 0x04) tempcl = tempcl | ActiveLCD; @@ -2586,42 +2564,45 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo) { unsigned short flag, tempbx, tempah; - if (pVBInfo->IF_DEF_LVDS == 0) { - tempbx = VB_SIS302B; - flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); - if (flag != 0x02) { - tempbx = VB_SIS301; - flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); - if (flag >= 0xB0) { - tempbx = VB_SIS301B; - if (flag >= 0xC0) { - tempbx = VB_XGI301C; - if (flag >= 0xD0) { - tempbx = VB_SIS301LV; - if (flag >= 0xE0) { - tempbx = VB_SIS302LV; - tempah = xgifb_reg_get( - pVBInfo->Part4Port, - 0x39); - if (tempah != 0xFF) - tempbx = - VB_XGI301C; - } - } - } + if (pVBInfo->IF_DEF_LVDS != 0) + return; - if (tempbx & (VB_SIS301B | VB_SIS302B)) { - flag = xgifb_reg_get( - pVBInfo->Part4Port, - 0x23); + tempbx = VB_SIS302B; + flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); + if (flag == 0x02) + goto finish; - if (!(flag & 0x02)) - tempbx = tempbx | VB_NoLCD; - } - } - } - pVBInfo->VBType = tempbx; + tempbx = VB_SIS301; + flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); + if (flag < 0xB0) + goto finish; + + tempbx = VB_SIS301B; + if (flag < 0xC0) + goto bigger_than_0xB0; + + tempbx = VB_XGI301C; + if (flag < 0xD0) + goto bigger_than_0xB0; + + tempbx = VB_SIS301LV; + if (flag < 0xE0) + goto bigger_than_0xB0; + + tempbx = VB_SIS302LV; + tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); + if (tempah != 0xFF) + tempbx = VB_XGI301C; + +bigger_than_0xB0: + if (tempbx & (VB_SIS301B | VB_SIS302B)) { + flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); + if (!(flag & 0x02)) + tempbx = tempbx | VB_NoLCD; } + +finish: + pVBInfo->VBType = tempbx; } static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, @@ -2635,187 +2616,183 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->ModeType = modeflag & ModeTypeMask; tempbx = 0; - if (pVBInfo->VBType & 0xFFFF) { - /* Check Display Device */ - temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); - tempbx = tempbx | temp; - temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); - push = temp; - push = push << 8; - tempax = temp << 8; - tempbx = tempbx | tempax; - temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA - | SetInSlaveMode | DisableCRT2Display); - temp = 0xFFFF ^ temp; - tempbx &= temp; - - temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); + if (!(pVBInfo->VBType & 0xFFFF)) + return; - if (pVBInfo->IF_DEF_LCDA == 1) { - - if ((HwDeviceExtension->jChipType >= XG20) || - (HwDeviceExtension->jChipType >= XG40)) { - 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; - } - } + /* Check Display Device */ + temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); + tempbx = tempbx | temp; + temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); + push = temp; + push = push << 8; + tempax = temp << 8; + tempbx = tempbx | tempax; + temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA + | SetInSlaveMode | DisableCRT2Display); + temp = 0xFFFF ^ temp; + tempbx &= temp; + + temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); + + if (pVBInfo->IF_DEF_LCDA == 1) { + + if (((HwDeviceExtension->jChipType >= XG20) || + (HwDeviceExtension->jChipType >= XG40)) && + (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->IF_DEF_YPbPr == 1) { - /* [Billy] 07/05/04 */ - if (((pVBInfo->IF_DEF_LVDS == 0) && - ((pVBInfo->VBType & VB_SIS301LV) || - (pVBInfo->VBType & VB_SIS302LV) || - (pVBInfo->VBType & VB_XGI301C)))) { - if (temp & SetYPbPr) { - if (pVBInfo->IF_DEF_HiVision == 1) { - /* shampoo add for new - * scratch */ - temp = xgifb_reg_get( - pVBInfo->P3d4, - 0x35); - temp &= YPbPrMode; - tempbx |= SetCRT2ToHiVision; - - if (temp != YPbPrMode1080i) { - tempbx &= - (~SetCRT2ToHiVision); - tempbx |= - SetCRT2ToYPbPr525750; - } + 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 (temp & SetYPbPr) { + if (pVBInfo->IF_DEF_HiVision == 1) { + /* shampoo add for new + * scratch */ + temp = xgifb_reg_get( + pVBInfo->P3d4, + 0x35); + temp &= YPbPrMode; + tempbx |= SetCRT2ToHiVision; + + if (temp != YPbPrMode1080i) { + tempbx &= + (~SetCRT2ToHiVision); + tempbx |= + SetCRT2ToYPbPr525750; } } } } + } - tempax = push; /* restore CR31 */ + 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 { /* 3nd party chip */ - temp = SetCRT2ToLCD; - } - - if (!(tempbx & temp)) { - tempax |= DisableCRT2Display; - tempbx = 0; - } - - if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ - if (!(pVBInfo->VBType & VB_NoLCD)) { - if (tempbx & XGI_SetCRT2ToLCDA) { - if (tempbx & SetSimuScanMode) - tempbx &= (~(SetCRT2ToLCD | - SetCRT2ToRAMDAC | - SwitchCRT2)); - else - tempbx &= (~(SetCRT2ToLCD | - SetCRT2ToRAMDAC | - SetCRT2ToTV | - SwitchCRT2)); - } - } + 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 { /* 3nd party chip */ + temp = SetCRT2ToLCD; + } - /* shampoo add */ - /* for driver abnormal */ - if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { - if (pVBInfo->IF_DEF_CRT2Monitor == 1) { - if (tempbx & SetCRT2ToRAMDAC) { - tempbx &= (0xFF00 | - SetCRT2ToRAMDAC | - SwitchCRT2 | - SetSimuScanMode); - tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); - } - } else { - tempbx &= (~(SetCRT2ToRAMDAC | - SetCRT2ToLCD | - SetCRT2ToTV)); + if (!(tempbx & temp)) { + tempax |= DisableCRT2Display; + tempbx = 0; + } + + if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ + if (!(pVBInfo->VBType & VB_NoLCD)) { + if (tempbx & XGI_SetCRT2ToLCDA) { + if (tempbx & SetSimuScanMode) + tempbx &= (~(SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SwitchCRT2)); + else + tempbx &= (~(SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SetCRT2ToTV | + SwitchCRT2)); } } + } - if (!(pVBInfo->VBType & VB_NoLCD)) { - if (tempbx & SetCRT2ToLCD) { + /* shampoo add */ + /* for driver abnormal */ + if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + if (pVBInfo->IF_DEF_CRT2Monitor == 1) { + if (tempbx & SetCRT2ToRAMDAC) { tempbx &= (0xFF00 | - SetCRT2ToLCD | + SetCRT2ToRAMDAC | SwitchCRT2 | SetSimuScanMode); tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); } + } else { + tempbx &= (~(SetCRT2ToRAMDAC | + SetCRT2ToLCD | + SetCRT2ToTV)); } + } - if (tempbx & SetCRT2ToSCART) { + if (!(pVBInfo->VBType & VB_NoLCD)) { + if (tempbx & SetCRT2ToLCD) { tempbx &= (0xFF00 | - SetCRT2ToSCART | + SetCRT2ToLCD | SwitchCRT2 | SetSimuScanMode); tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); } + } - if (pVBInfo->IF_DEF_YPbPr == 1) { - if (tempbx & SetCRT2ToYPbPr525750) - tempbx &= (0xFF00 | - SwitchCRT2 | - SetSimuScanMode); - } + if (tempbx & SetCRT2ToSCART) { + tempbx &= (0xFF00 | + SetCRT2ToSCART | + SwitchCRT2 | + SetSimuScanMode); + tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); + } - if (pVBInfo->IF_DEF_HiVision == 1) { - if (tempbx & SetCRT2ToHiVision) - tempbx &= (0xFF00 | - SetCRT2ToHiVision | - SwitchCRT2 | - SetSimuScanMode); - } + if (pVBInfo->IF_DEF_YPbPr == 1) { + if (tempbx & SetCRT2ToYPbPr525750) + tempbx &= (0xFF00 | + SwitchCRT2 | + SetSimuScanMode); + } - if (tempax & DisableCRT2Display) { /* Set Display Device Info */ - if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) - tempbx = DisableCRT2Display; - } + if (pVBInfo->IF_DEF_HiVision == 1) { + if (tempbx & SetCRT2ToHiVision) + tempbx &= (0xFF00 | + SetCRT2ToHiVision | + SwitchCRT2 | + SetSimuScanMode); + } - if (!(tempbx & DisableCRT2Display)) { - if ((!(tempbx & DriverMode)) || - (!(modeflag & CRT2Mode))) { - if (pVBInfo->IF_DEF_LCDA == 1) { - if (!(tempbx & XGI_SetCRT2ToLCDA)) - tempbx |= (SetInSlaveMode | - SetSimuScanMode); - } - } + if (tempax & DisableCRT2Display) { /* Set Display Device Info */ + if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) + tempbx = DisableCRT2Display; + } - /* LCD+TV can't support in slave mode - * (Force LCDA+TV->LCDB) */ - if ((tempbx & SetInSlaveMode) && - (tempbx & XGI_SetCRT2ToLCDA)) { - tempbx ^= (SetCRT2ToLCD | - XGI_SetCRT2ToLCDA | - SetCRT2ToDualEdge); - pVBInfo->SetFlag |= ReserveTVOption; + if (!(tempbx & DisableCRT2Display)) { + if ((!(tempbx & DriverMode)) || + (!(modeflag & CRT2Mode))) { + if (pVBInfo->IF_DEF_LCDA == 1) { + if (!(tempbx & XGI_SetCRT2ToLCDA)) + 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 | + SetCRT2ToDualEdge); + pVBInfo->SetFlag |= ReserveTVOption; + } } pVBInfo->VBInfo = tempbx; @@ -2927,7 +2904,7 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, if (tempbx == 0) tempbx = Panel_1024x768; /* default */ - /* LCD75 [2003/8/22] Vicent */ + /* LCD75 */ if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { if (pVBInfo->VBInfo & DriverMode) { tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); @@ -2976,7 +2953,10 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) && (!(tempbx & EnableScalingLCD))) - /* set to center in 1280x1024 LCDB for Panel_1400x1050 */ + /* + * set to center in 1280x1024 LCDB + * for Panel_1400x1050 + */ tempbx |= SetLCDtoNonExpanding; } @@ -3291,46 +3271,47 @@ static void XGI_GetCRT2ResInfo(unsigned short ModeNo, if (modeflag & DoubleScanMode) yres *= 2; - if (pVBInfo->VBInfo & SetCRT2ToLCD) { - if (pVBInfo->IF_DEF_LVDS == 0) { - if (pVBInfo->LCDResInfo == Panel_1600x1200) { - if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { - if (yres == 1024) - yres = 1056; - } + 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_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; } } } - - if (xres == 720) - xres = 640; } + if (xres == 720) + xres = 640; + +exit: pVBInfo->VGAHDE = xres; pVBInfo->HDE = xres; pVBInfo->VGAVDE = yres; @@ -4066,24 +4047,16 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, } if (pVBInfo->VBInfo & SetCRT2ToHiVision) { - if (pVBInfo->VBType & VB_SIS301LV) { - if (pVBInfo->TVInfo & TVSetHiVision) { - tempbx -= 10; - } else { - if (pVBInfo->TVInfo & TVSimuMode) { - if (pVBInfo->TVInfo & TVSetPAL) { - if (pVBInfo->VBType & - VB_SIS301LV) { - if (!(pVBInfo->TVInfo & - (TVSetYPbPr525p | - TVSetYPbPr750p | - TVSetHiVision))) - tempbx += 40; - } else { - tempbx += 40; - } - } - } + if ((pVBInfo->VBType & VB_SIS301LV) && + !(pVBInfo->TVInfo & TVSetHiVision)) { + if ((pVBInfo->TVInfo & TVSimuMode) && + (pVBInfo->TVInfo & TVSetPAL)) { + if (!(pVBInfo->VBType & VB_SIS301LV) || + !(pVBInfo->TVInfo & + (TVSetYPbPr525p | + TVSetYPbPr750p | + TVSetHiVision))) + tempbx += 40; } } else { tempbx -= 10; @@ -4591,7 +4564,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, } } - /* [ycchen] 01/14/03 Modify for 301C PALM Support */ + /* Modify for 301C PALM Support */ if (pVBInfo->VBType & VB_XGI301C) { if (pVBInfo->TVInfo & TVSetPALM) xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, @@ -5486,7 +5459,8 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { tempah = 0x7F; /* Disable Channel A */ - if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) + if (!(pVBInfo->VBInfo & + XGI_SetCRT2ToLCDA)) /* Disable Channel B */ tempah = 0xBF; @@ -5505,9 +5479,10 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { - if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) - || (XGI_DisableChISLCD(pVBInfo)) - || (XGI_IsLCDON(pVBInfo))) + if (((pVBInfo->VBInfo & + (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) + || (XGI_DisableChISLCD(pVBInfo)) + || (XGI_IsLCDON(pVBInfo))) /* LVDS Driver power down */ xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); } @@ -5673,7 +5648,8 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) if (pVBInfo->VBInfo & SetCRT2ToDualEdge) tempbl = tempbl >> 4; - if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { + if (pVBInfo->VBInfo & + (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { tempbh = XGI301LCDDelay; if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) @@ -5690,7 +5666,8 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) tempah |= tempbl; } - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */ + if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { + /* Channel A */ tempah &= 0x0F; tempah |= tempbh; } @@ -6025,60 +6002,49 @@ static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, tempah = 0x08; tempbl = 0xf0; - if (pVBInfo->VBInfo & DisableCRT2Display) { - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); - } else { - tempah = 0x00; - tempbl = 0xff; + if (pVBInfo->VBInfo & DisableCRT2Display) + goto reg_and_or; - if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV - | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { - if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && - (!(pVBInfo->VBInfo & SetSimuScanMode))) { - tempbl &= 0xf7; - tempah |= 0x01; - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, - tempbl, tempah); - } else { - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { - tempbl &= 0xf7; - tempah |= 0x01; - } + tempah = 0x00; + tempbl = 0xff; - if (pVBInfo->VBInfo & - (SetCRT2ToRAMDAC | - SetCRT2ToTV | - SetCRT2ToLCD)) { - tempbl &= 0xf8; - tempah = 0x01; + if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | + SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) + goto reg_and_or; - if (!(pVBInfo->VBInfo & SetInSlaveMode)) - tempah |= 0x02; + if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && + (!(pVBInfo->VBInfo & SetSimuScanMode))) { + tempbl &= 0xf7; + tempah |= 0x01; + goto reg_and_or; + } - if (!(pVBInfo->VBInfo & - SetCRT2ToRAMDAC)) { - tempah = tempah ^ 0x05; - if (!(pVBInfo->VBInfo & - SetCRT2ToLCD)) - tempah = tempah ^ 0x01; - } + if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { + tempbl &= 0xf7; + tempah |= 0x01; + } - if (!(pVBInfo->VBInfo & - SetCRT2ToDualEdge)) - tempah |= 0x08; - xgifb_reg_and_or(pVBInfo->Part1Port, - 0x2e, tempbl, tempah); - } else { - xgifb_reg_and_or(pVBInfo->Part1Port, - 0x2e, tempbl, tempah); - } - } - } else { - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, - tempah); - } + if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) + goto reg_and_or; + + tempbl &= 0xf8; + tempah = 0x01; + + if (!(pVBInfo->VBInfo & SetInSlaveMode)) + tempah |= 0x02; + + if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { + tempah = tempah ^ 0x05; + if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) + tempah = tempah ^ 0x01; } + if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) + tempah |= 0x08; + +reg_and_or: + xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); + if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { tempah &= (~0x08); @@ -6245,8 +6211,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { index++; } - /* Alan 10/19/2007; - * do the similar adjustment like XGISearchCRT1Rate() */ + /* do the similar adjustment like XGISearchCRT1Rate() */ if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { index++; @@ -6354,7 +6319,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) int i; xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); - /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */ + /* 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( pVBInfo->P3d4, 0x53) | 0x02)); @@ -6419,7 +6384,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) else xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); - /* alan, avoid display something, set BLACK DAC if not restore DAC */ + /* avoid display something, set BLACK DAC if not restore DAC */ outb(0x00, pVBInfo->P3c8); for (i = 0; i < 256; i++) { @@ -6432,7 +6397,6 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); - /* [2004/05/11] Vicent */ xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( pVBInfo->P3d4, 0x53) & 0xFD)); xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); @@ -6509,32 +6473,24 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, if (!(pVBInfo->VBInfo & DisableCRT2Display)) { tempah = 0xc0; - if (!(pVBInfo->VBInfo & SetSimuScanMode)) { - if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { - if (pVBInfo->VBInfo & - SetCRT2ToDualEdge) { - tempah = tempah & 0x40; - if (pVBInfo->VBInfo & - XGI_SetCRT2ToLCDA) - tempah = tempah ^ 0xC0; - - if (pVBInfo->SetFlag & - DisableChB) - tempah &= 0xBF; - - if (pVBInfo->SetFlag & - DisableChA) - tempah &= 0x7F; - - if (pVBInfo->SetFlag & - EnableChB) - tempah |= 0x40; - - if (pVBInfo->SetFlag & - EnableChA) - tempah |= 0x80; - } - } + if (!(pVBInfo->VBInfo & SetSimuScanMode) && + (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && + (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { + tempah = tempah & 0x40; + if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) + tempah = tempah ^ 0xC0; + + if (pVBInfo->SetFlag & DisableChB) + tempah &= 0xBF; + + if (pVBInfo->SetFlag & DisableChA) + tempah &= 0x7F; + + if (pVBInfo->SetFlag & EnableChB) + tempah |= 0x40; + + if (pVBInfo->SetFlag & EnableChA) + tempah |= 0x80; } } @@ -6653,7 +6609,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, pVBInfo->IF_DEF_LVDS = 0; pVBInfo->IF_DEF_LCDA = 1; - if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType >= XG20) { pVBInfo->IF_DEF_YPbPr = 0; pVBInfo->IF_DEF_HiVision = 0; pVBInfo->IF_DEF_CRT2Monitor = 0; @@ -6695,7 +6651,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, } } - if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) XGI_GetVBType(pVBInfo); InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); @@ -6703,12 +6659,12 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, ModeNo = ModeNo & 0x7F; xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); - if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ + if (HwDeviceExtension->jChipType < XG20) XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); - if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) { XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); @@ -6779,9 +6735,8 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); - if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ + if (HwDeviceExtension->jChipType < XG20) XGI_LockCRT2(HwDeviceExtension, pVBInfo); - } return 1; } diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h index aea760ad4ae2..22c8eb9810d6 100644 --- a/drivers/staging/xgifb/vb_struct.h +++ b/drivers/staging/xgifb/vb_struct.h @@ -28,7 +28,6 @@ struct XGI_Ext2Struct { unsigned char ModeID; unsigned short XRes; unsigned short YRes; - /* unsigned short ROM_OFFSET; */ }; struct XGI_ECLKDataStruct { @@ -167,7 +166,6 @@ struct vb_device_info { unsigned short LCDHRS, LCDVRS, LCDHDES, LCDVDES; unsigned short ModeType; - /* ,IF_DEF_FSTN; add for dstn */ unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN; unsigned short IF_DEF_CRT2Monitor; unsigned short IF_DEF_LCDA, IF_DEF_YPbPr; @@ -225,7 +223,6 @@ struct vb_device_info { struct SiS_StandTable_S *StandTable; struct XGI_ExtStruct *EModeIDTable; struct XGI_Ext2Struct *RefIndex; - /* XGINew_CRT1TableStruct *CRT1Table; */ struct XGI_CRT1TableStruct *XGINEWUB_CRT1Table; struct SiS_VCLKData *VCLKData; struct SiS_VBVCLKData *VBVCLKData; diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h index 75da7c3e1baf..1c168461411d 100644 --- a/drivers/staging/xgifb/vb_table.h +++ b/drivers/staging/xgifb/vb_table.h @@ -1,6 +1,5 @@ #ifndef _VB_TABLE_ #define _VB_TABLE_ -/* yilin modify for xgi20 */ static struct SiS_MCLKData XGI340New_MCLKData[] = { {0x16, 0x01, 0x01, 166}, {0x19, 0x02, 0x01, 124}, @@ -23,7 +22,6 @@ static struct SiS_MCLKData XGI27New_MCLKData[] = { {0x5c, 0x23, 0x01, 166} }; -/* yilin modify for xgi20 */ static struct XGI_ECLKDataStruct XGI340_ECLKData[] = { {0x5c, 0x23, 0x01, 166}, {0x55, 0x84, 0x01, 123}, @@ -424,13 +422,9 @@ static struct SiS_LCDData XGI_StLCD1024x768Data[] = { }; static struct SiS_LCDData XGI_ExtLCD1024x768Data[] = { - /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */ {42, 25, 1536, 419, 1344, 806}, - /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */ {48, 25, 1536, 369, 1344, 806}, - /* { 32, 15,1008, 505,1344, 806}, // alan 09/12/2003 */ {42, 25, 1536, 419, 1344, 806}, - /* { 32, 15,1008, 514,1344, 806}, // alan 09/12/2003 */ {48, 25, 1536, 369, 1344, 806}, {12, 5, 896, 500, 1344, 806}, {42, 25, 1024, 625, 1344, 806}, @@ -504,14 +498,10 @@ static struct SiS_LCDData xgifb_lcd_1400x1050[] = { }; static struct SiS_LCDData XGI_ExtLCD1600x1200Data[] = { - {4, 1, 1620, 420, 2160, 1250}, /* { 3,1,2160,425,2160,1250 }, - // 00 (320x200,320x400, - // 640x200,640x400) - // // alan 10/14/2003 */ + {4, 1, 1620, 420, 2160, 1250}, /* 00 (320x200,320x400, + 640x200,640x400)*/ {27, 7, 1920, 375, 2160, 1250}, /* 01 (320x350,640x350) */ - {4, 1, 1620, 420, 2160, 1250}, /* { 3,1,2160,425,2160,1250 }, - // 02 (360x400,720x400) - // // alan 10/14/2003 */ + {4, 1, 1620, 420, 2160, 1250}, /* 02 (360x400,720x400)*/ {27, 7, 1920, 375, 2160, 1250}, /* 03 (720x350) */ {27, 4, 800, 500, 2160, 1250}, /* 04 (640x480x60Hz) */ {4, 1, 1080, 625, 2160, 1250}, /* 05 (800x600x60Hz) */ @@ -615,8 +605,7 @@ static struct SiS_LCDData XGI_NoScalingDatax75[] = { {1, 1, 1056, 625, 1056, 625}, /* ; 05 (800x600x75Hz) */ {1, 1, 1312, 800, 1312, 800}, /* ; 06 (1024x768x75Hz) */ {1, 1, 1688, 1066, 1688, 1066}, /* ; 07 (1280x1024x75Hz) */ - {1, 1, 1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz) - ;;[ycchen] 12/19/02 */ + {1, 1, 1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz)*/ {1, 1, 2160, 1250, 2160, 1250}, /* ; 09 (1600x1200x75Hz) */ {1, 1, 1688, 806, 1688, 806} /* ; 0A (1280x768x75Hz) */ }; @@ -823,8 +812,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] = { {9, 849, 627, 600, 128, 4}, /* 05 (800x600x60Hz) */ {9, 1057, 805, 770, 0136, 6}, /* 06 (1024x768x60Hz) */ {9, 1337, 0, 1025, 112, 3}, /* 07 (1280x1024x60Hz) */ - {9, 1457, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz) }, - //;[ycchen] 12/19/02 */ + {9, 1457, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)*/ {9, 1673, 0, 1201, 192, 3}, /* 09 (1600x1200x60Hz) */ {9, 1337, 0, 771, 112, 6} /* 0A (1280x768x60Hz) */ }; @@ -910,8 +898,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = { {9, 825, 0, 601, 80, 3}, /* ; 05 (800x600x75Hz) */ {9, 1049, 0, 769, 96, 3}, /* ; 06 (1024x768x75Hz) */ {9, 1305, 0, 1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */ - {9, 1457, 0, 1051, 112, 3}, /* ; 08 (1400x1050x60Hz) - ;;[ycchen] 12/19/02 */ + {9, 1457, 0, 1051, 112, 3}, /* ; 08 (1400x1050x60Hz)*/ {9, 1673, 0, 1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */ {9, 1337, 0, 771, 112, 6} /* ; 0A (1280x768x60Hz) */ }; @@ -1308,7 +1295,7 @@ static struct SiS_LVDSData XGI_LVDSNoScalingData[] = { {1056, 628, 1056, 628}, /* 05 (800x600x60Hz) */ {1344, 806, 1344, 806}, /* 06 (1024x768x60Hz) */ {1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz) */ - {1688, 1066, 1688, 1066}, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */ + {1688, 1066, 1688, 1066}, /* 08 (1400x1050x60Hz) */ {2160, 1250, 2160, 1250}, /* 09 (1600x1200x60Hz) */ {1688, 806, 1688, 806} /* 0A (1280x768x60Hz) */ }; @@ -1469,8 +1456,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[] = { {0, 840, 627, 600, 128, 4}, /* 05 (800x600x60Hz) */ {0, 1048, 805, 770, 136, 6}, /* 06 (1024x768x60Hz) */ {0, 1328, 0, 1025, 112, 3}, /* 07 (1280x1024x60Hz) */ - {0, 1438, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz) - ;;[ycchen] 12/19/02 */ + {0, 1438, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)*/ {0, 1664, 0, 1201, 192, 3}, /* 09 (1600x1200x60Hz) */ {0, 1328, 0, 0771, 112, 6} /* 0A (1280x768x60Hz) */ }; @@ -1518,7 +1504,7 @@ static struct SiS_LVDSData XGI_LVDS1280x1024Des_1x75[] = { }; /* The Display setting for DE Mode Panel */ -/* [ycchen] 02/18/03 Set DE as default */ +/* Set DE as default */ static struct SiS_LVDSData XGI_LVDS1280x1024Des_2x75[] = { {1368, 976, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */ {1368, 976, 729, 688}, /* ; 01 (320x350,640x350) */ @@ -1541,8 +1527,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = { {0, 816, 0, 601, 80, 3}, /* ; 05 (800x600x75Hz) */ {0, 1040, 0, 769, 96, 3}, /* ; 06 (1024x768x75Hz) */ {0, 1296, 0, 1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */ - {0, 1448, 0, 1051, 112, 3}, /* ; 08 (1400x1050x75Hz) - ;;[ycchen] 12/19/02 */ + {0, 1448, 0, 1051, 112, 3}, /* ; 08 (1400x1050x75Hz) */ {0, 1664, 0, 1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */ {0, 1328, 0, 771, 112, 6} /* ; 0A (1280x768x75Hz) */ }; @@ -1853,9 +1838,12 @@ static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] = { {Panel_1024x768x75, 0x0019, 0x0001, 12}, /* XGI_ExtLCD1024x768x75Data */ {Panel_1024x768x75, 0x0019, 0x0000, 13}, /* XGI_StLCD1024x768x75Data */ {Panel_1024x768x75, 0x0018, 0x0010, 14}, /* XGI_CetLCD1024x768x75Data */ - {Panel_1280x1024x75, 0x0019, 0x0001, 15}, /* XGI_ExtLCD1280x1024x75Data*/ - {Panel_1280x1024x75, 0x0019, 0x0000, 16}, /* XGI_StLCD1280x1024x75Data */ - {Panel_1280x1024x75, 0x0018, 0x0010, 17}, /* XGI_CetLCD1280x1024x75Data*/ + /* XGI_ExtLCD1280x1024x75Data */ + {Panel_1280x1024x75, 0x0019, 0x0001, 15}, + /* XGI_StLCD1280x1024x75Data */ + {Panel_1280x1024x75, 0x0019, 0x0000, 16}, + /* XGI_CetLCD1280x1024x75Data */ + {Panel_1280x1024x75, 0x0018, 0x0010, 17}, {PanelRef75Hz, 0x0008, 0x0008, 18}, /* XGI_NoScalingDatax75 */ {0xFF, 0x0000, 0x0000, 0} /* End of table */ }; @@ -1874,9 +1862,12 @@ static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] = { {Panel_1600x1200, 0x0019, 0x0001, 10}, /* XGI_ExtLCDDes1600x1200Data */ {Panel_1600x1200, 0x0019, 0x0000, 11}, /* XGI_StLCDDes1600x1200Data */ {PanelRef60Hz, 0x0008, 0x0008, 12}, /* XGI_NoScalingDesData */ - {Panel_1024x768x75, 0x0019, 0x0001, 13}, /*XGI_ExtLCDDes1024x768x75Data*/ - {Panel_1024x768x75, 0x0019, 0x0000, 14}, /* XGI_StLCDDes1024x768x75Data*/ - {Panel_1024x768x75, 0x0018, 0x0010, 15}, /*XGI_CetLCDDes1024x768x75Data*/ + /* XGI_ExtLCDDes1024x768x75Data */ + {Panel_1024x768x75, 0x0019, 0x0001, 13}, + /* XGI_StLCDDes1024x768x75Data */ + {Panel_1024x768x75, 0x0019, 0x0000, 14}, + /* XGI_CetLCDDes1024x768x75Data */ + {Panel_1024x768x75, 0x0018, 0x0010, 15}, /* XGI_ExtLCDDes1280x1024x75Data */ {Panel_1280x1024x75, 0x0019, 0x0001, 16}, /* XGI_StLCDDes1280x1024x75Data */ @@ -1913,8 +1904,10 @@ static struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] = { {PanelRef60Hz, 0x0008, 0x0008, 7}, /* XGI_LVDSNoScalingData */ {Panel_1024x768x75, 0x0018, 0x0000, 8}, /* XGI_LVDS1024x768Data_1x75 */ {Panel_1024x768x75, 0x0018, 0x0010, 9}, /* XGI_LVDS1024x768Data_2x75 */ - {Panel_1280x1024x75, 0x0018, 0x0000, 10}, /* XGI_LVDS1280x1024Data_1x75*/ - {Panel_1280x1024x75, 0x0018, 0x0010, 11}, /*XGI_LVDS1280x1024Data_2x75*/ + /* XGI_LVDS1280x1024Data_1x75 */ + {Panel_1280x1024x75, 0x0018, 0x0000, 10}, + /* XGI_LVDS1280x1024Data_2x75 */ + {Panel_1280x1024x75, 0x0018, 0x0010, 11}, {PanelRef75Hz, 0x0008, 0x0008, 12}, /* XGI_LVDSNoScalingDatax75 */ {0xFF, 0x0000, 0x0000, 0} }; @@ -1932,8 +1925,10 @@ static struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] = { {Panel_1024x768x75, 0x0018, 0x0000, 9}, /* XGI_LVDS1024x768Des_1x75 */ {Panel_1024x768x75, 0x0618, 0x0410, 10}, /* XGI_LVDS1024x768Des_3x75 */ {Panel_1024x768x75, 0x0018, 0x0010, 11}, /* XGI_LVDS1024x768Des_2x75 */ - {Panel_1280x1024x75, 0x0018, 0x0000, 12}, /* XGI_LVDS1280x1024Des_1x75 */ - {Panel_1280x1024x75, 0x0018, 0x0010, 13}, /* XGI_LVDS1280x1024Des_2x75 */ + /* XGI_LVDS1280x1024Des_1x75 */ + {Panel_1280x1024x75, 0x0018, 0x0000, 12}, + /* XGI_LVDS1280x1024Des_2x75 */ + {Panel_1280x1024x75, 0x0018, 0x0010, 13}, {PanelRef75Hz, 0x0008, 0x0008, 14}, /* XGI_LVDSNoScalingDesDatax75 */ {0xFF, 0x0000, 0x0000, 0} }; diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h index 7fc07194eea2..ddf7776c295b 100644 --- a/drivers/staging/xgifb/vgatypes.h +++ b/drivers/staging/xgifb/vgatypes.h @@ -21,40 +21,6 @@ enum XGI_VB_CHIP_TYPE { }; #endif - -#define XGI_LCD_TYPE -/* Since the merge with video/sis the LCD_TYPEs are used from - drivers/video/sis/sis.h . Nevertheless we keep this (for the moment) for - future reference until the code is merged completely and we are sure - nothing of this should be added to the sis.h header */ -#ifndef XGI_LCD_TYPE -enum XGI_LCD_TYPE { - LCD_INVALID = 0, - LCD_320x480, /* FSTN, DSTN */ - LCD_640x480, - LCD_640x480_2, /* FSTN, DSTN */ - LCD_640x480_3, /* FSTN, DSTN */ - LCD_800x600, - LCD_848x480, - LCD_1024x600, - LCD_1024x768, - LCD_1152x768, - LCD_1152x864, - LCD_1280x720, - LCD_1280x768, - LCD_1280x800, - LCD_1280x960, - LCD_1280x1024, - LCD_1400x1050, - LCD_1600x1200, - LCD_1680x1050, - LCD_1920x1440, - LCD_2048x1536, - LCD_CUSTOM, - LCD_UNKNOWN -}; -#endif - struct xgi_hw_device_info { unsigned long ulExternalChip; /* NO VB or other video bridge*/ /* if ujVBChipID = VB_CHIP_UNKNOWN, */ diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c index 1ca66ea9b281..eaa90213457b 100644 --- a/drivers/staging/zcache/tmem.c +++ b/drivers/staging/zcache/tmem.c @@ -72,33 +72,49 @@ void tmem_register_pamops(struct tmem_pamops *m) * the hashbucket lock must be held. */ -/* 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) +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 *rbnode; - struct tmem_obj *obj; - - rbnode = hb->obj_rb_root.rb_node; - while (rbnode) { - BUG_ON(RB_EMPTY_NODE(rbnode)); - obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node); + 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; + rbnode = &(*rbnode)->rb_left; break; case 1: - rbnode = rbnode->rb_right; + rbnode = &(*rbnode)->rb_right; break; } } + + if (parent) + *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 *); /* free an object that has no more pampds in it */ @@ -131,8 +147,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, struct tmem_oid *oidp) { struct rb_root *root = &hb->obj_rb_root; - struct rb_node **new = &(root->rb_node), *parent = NULL; - struct tmem_obj *this; + struct rb_node **new = NULL, *parent = NULL; BUG_ON(pool == NULL); atomic_inc(&pool->obj_count); @@ -144,22 +159,10 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, obj->pampd_count = 0; (*tmem_pamops.new_obj)(obj); SET_SENTINEL(obj, OBJ); - while (*new) { - BUG_ON(RB_EMPTY_NODE(*new)); - this = rb_entry(*new, struct tmem_obj, rb_tree_node); - parent = *new; - switch (tmem_oid_compare(oidp, &this->oid)) { - case 0: - BUG(); /* already present; should never happen! */ - break; - case -1: - new = &(*new)->rb_left; - break; - case 1: - new = &(*new)->rb_right; - break; - } - } + + 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); } diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index c9e08bbeb519..c214977b4ab4 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -36,9 +36,6 @@ #include "../zsmalloc/zsmalloc.h" -#if (!defined(CONFIG_CLEANCACHE) && !defined(CONFIG_FRONTSWAP)) -#error "zcache is useless without CONFIG_CLEANCACHE or CONFIG_FRONTSWAP" -#endif #ifdef CONFIG_CLEANCACHE #include <linux/cleancache.h> #endif @@ -77,6 +74,17 @@ static inline uint16_t get_client_id_from_client(struct zcache_client *cli) return cli - &zcache_clients[0]; } +static struct zcache_client *get_zcache_client(uint16_t cli_id) +{ + if (cli_id == LOCAL_CLIENT) + return &zcache_host; + + if ((unsigned int)cli_id < MAX_CLIENTS) + return &zcache_clients[cli_id]; + + return NULL; +} + static inline bool is_local_client(struct zcache_client *cli) { return cli == &zcache_host; @@ -109,6 +117,8 @@ static inline int zcache_comp_op(enum comp_op op, case ZCACHE_COMPOP_DECOMPRESS: ret = crypto_comp_decompress(tfm, src, slen, dst, dlen); break; + default: + ret = -EINVAL; } put_cpu(); return ret; @@ -601,16 +611,14 @@ out: return; } -static void zbud_init(void) +static void __init zbud_init(void) { int i; INIT_LIST_HEAD(&zbud_buddied_list); - zcache_zbud_buddied_count = 0; - for (i = 0; i < NCHUNKS; i++) { + + for (i = 0; i < NCHUNKS; i++) INIT_LIST_HEAD(&zbud_unbuddied[i].list); - zbud_unbuddied[i].count = 0; - } } #ifdef CONFIG_SYSFS @@ -708,7 +716,7 @@ static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id, goto out; atomic_inc(&zv_curr_dist_counts[chunks]); atomic_inc(&zv_cumul_dist_counts[chunks]); - zv = zs_map_object(pool, handle); + zv = zs_map_object(pool, handle, ZS_MM_WO); zv->index = index; zv->oid = *oid; zv->pool_id = pool_id; @@ -727,7 +735,7 @@ static void zv_free(struct zs_pool *pool, unsigned long handle) uint16_t size; int chunks; - zv = zs_map_object(pool, handle); + zv = zs_map_object(pool, handle, ZS_MM_RW); ASSERT_SENTINEL(zv, ZVH); size = zv->size + sizeof(struct zv_hdr); INVERT_SENTINEL(zv, ZVH); @@ -749,7 +757,7 @@ static void zv_decompress(struct page *page, unsigned long handle) int ret; struct zv_hdr *zv; - zv = zs_map_object(zcache_host.zspool, handle); + 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); @@ -938,16 +946,11 @@ static 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; - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else { - if (cli_id >= MAX_CLIENTS) - goto out; - cli = &zcache_clients[cli_id]; - if (cli == NULL) - goto out; - atomic_inc(&cli->refcount); - } + cli = get_zcache_client(cli_id); + if (!cli) + goto out; + + atomic_inc(&cli->refcount); pool = idr_find(&cli->tmem_pools, poolid); if (pool != NULL) atomic_inc(&pool->refcount); @@ -968,13 +971,11 @@ static void zcache_put_pool(struct tmem_pool *pool) int zcache_new_client(uint16_t cli_id) { - struct zcache_client *cli = NULL; + struct zcache_client *cli; int ret = -1; - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; + cli = get_zcache_client(cli_id); + if (cli == NULL) goto out; if (cli->allocated) @@ -1033,45 +1034,38 @@ static int zcache_do_preload(struct tmem_pool *pool) goto out; if (unlikely(zcache_obj_cache == NULL)) goto out; - preempt_disable(); + + /* IRQ has already been disabled. */ kp = &__get_cpu_var(zcache_preloads); while (kp->nr < ARRAY_SIZE(kp->objnodes)) { - preempt_enable_no_resched(); objnode = kmem_cache_alloc(zcache_objnode_cache, ZCACHE_GFP_MASK); if (unlikely(objnode == NULL)) { zcache_failed_alloc++; goto out; } - preempt_disable(); - kp = &__get_cpu_var(zcache_preloads); - if (kp->nr < ARRAY_SIZE(kp->objnodes)) - kp->objnodes[kp->nr++] = objnode; - else - kmem_cache_free(zcache_objnode_cache, objnode); + + kp->objnodes[kp->nr++] = objnode; } - preempt_enable_no_resched(); - obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); - if (unlikely(obj == NULL)) { - zcache_failed_alloc++; - goto out; + + 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; } - page = (void *)__get_free_page(ZCACHE_GFP_MASK); - if (unlikely(page == NULL)) { - zcache_failed_get_free_pages++; - kmem_cache_free(zcache_obj_cache, obj); - goto out; + + 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; } - preempt_disable(); - kp = &__get_cpu_var(zcache_preloads); - if (kp->obj == NULL) - kp->obj = obj; - else - kmem_cache_free(zcache_obj_cache, obj); - if (kp->page == NULL) - kp->page = page; - else - free_page((unsigned long)page); + ret = 0; out: return ret; @@ -1581,15 +1575,14 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, else zcache_failed_pers_puts++; } - zcache_put_pool(pool); - preempt_enable_no_resched(); } else { zcache_put_to_flush++; 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; } @@ -1659,17 +1652,16 @@ static int zcache_flush_object(int cli_id, int pool_id, static int zcache_destroy_pool(int cli_id, int pool_id) { struct tmem_pool *pool = NULL; - struct zcache_client *cli = NULL; + struct zcache_client *cli; 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]; + + cli = get_zcache_client(cli_id); if (cli == NULL) goto out; + atomic_inc(&cli->refcount); pool = idr_find(&cli->tmem_pools, pool_id); if (pool == NULL) @@ -1696,12 +1688,10 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags) struct zcache_client *cli = NULL; int r; - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; + cli = get_zcache_client(cli_id); if (cli == NULL) goto out; + atomic_inc(&cli->refcount); pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); if (pool == NULL) { @@ -1985,7 +1975,7 @@ static int __init enable_zcache_compressor(char *s) __setup("zcache=", enable_zcache_compressor); -static int zcache_comp_init(void) +static int __init zcache_comp_init(void) { int ret = 0; @@ -2025,7 +2015,7 @@ static int __init zcache_init(void) goto out; } #endif /* CONFIG_SYSFS */ -#if defined(CONFIG_CLEANCACHE) || defined(CONFIG_FRONTSWAP) + if (zcache_enabled) { unsigned int cpu; @@ -2056,7 +2046,7 @@ static int __init zcache_init(void) pr_err("zcache: can't create client\n"); goto out; } -#endif + #ifdef CONFIG_CLEANCACHE if (zcache_enabled && use_cleancache) { struct cleancache_ops old_ops; diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 706cb625aae9..653b074035f7 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -220,7 +220,8 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, uncmem = user_mem; clen = PAGE_SIZE; - cmem = zs_map_object(zram->mem_pool, zram->table[index].handle); + cmem = zs_map_object(zram->mem_pool, zram->table[index].handle, + ZS_MM_RO); ret = lzo1x_decompress_safe(cmem, zram->table[index].size, uncmem, &clen); @@ -258,7 +259,7 @@ static int zram_read_before_write(struct zram *zram, char *mem, u32 index) return 0; } - cmem = zs_map_object(zram->mem_pool, handle); + cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO); ret = lzo1x_decompress_safe(cmem, zram->table[index].size, mem, &clen); zs_unmap_object(zram->mem_pool, handle); @@ -351,7 +352,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, ret = -ENOMEM; goto out; } - cmem = zs_map_object(zram->mem_pool, handle); + cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_WO); memcpy(cmem, src, clen); diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig index a5ab7200626f..908456565796 100644 --- a/drivers/staging/zsmalloc/Kconfig +++ b/drivers/staging/zsmalloc/Kconfig @@ -1,9 +1,5 @@ config ZSMALLOC tristate "Memory allocator for compressed pages" - # X86 dependency is because of the use of __flush_tlb_one and set_pte - # in zsmalloc-main.c. - # TODO: convert these to portable functions - depends on X86 default n help zsmalloc is a slab-based memory allocator designed to store diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c index 10b0d6000260..8b0bcb626a7f 100644 --- a/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/drivers/staging/zsmalloc/zsmalloc-main.c @@ -470,6 +470,51 @@ static struct page *find_get_zspage(struct size_class *class) return page; } +static void zs_copy_map_object(char *buf, struct page *firstpage, + int off, int size) +{ + struct page *pages[2]; + int sizes[2]; + void *addr; + + pages[0] = firstpage; + pages[1] = get_next_page(firstpage); + BUG_ON(!pages[1]); + + sizes[0] = PAGE_SIZE - off; + sizes[1] = size - sizes[0]; + + /* copy object to per-cpu buffer */ + addr = kmap_atomic(pages[0]); + memcpy(buf, addr + off, sizes[0]); + kunmap_atomic(addr); + addr = kmap_atomic(pages[1]); + memcpy(buf + sizes[0], addr, sizes[1]); + kunmap_atomic(addr); +} + +static void zs_copy_unmap_object(char *buf, struct page *firstpage, + int off, int size) +{ + struct page *pages[2]; + int sizes[2]; + void *addr; + + pages[0] = firstpage; + pages[1] = get_next_page(firstpage); + BUG_ON(!pages[1]); + + sizes[0] = PAGE_SIZE - off; + sizes[1] = size - sizes[0]; + + /* copy per-cpu buffer to object */ + addr = kmap_atomic(pages[0]); + memcpy(addr + off, buf, sizes[0]); + kunmap_atomic(addr); + addr = kmap_atomic(pages[1]); + memcpy(addr, buf + sizes[0], sizes[1]); + kunmap_atomic(addr); +} static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action, void *pcpu) @@ -480,18 +525,23 @@ static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action, switch (action) { case CPU_UP_PREPARE: area = &per_cpu(zs_map_area, cpu); - if (area->vm) - break; - area->vm = alloc_vm_area(2 * PAGE_SIZE, area->vm_ptes); - if (!area->vm) - return notifier_from_errno(-ENOMEM); + /* + * Make sure we don't leak memory if a cpu UP notification + * and zs_init() race and both call zs_cpu_up() on the same cpu + */ + if (area->vm_buf) + return 0; + area->vm_buf = (char *)__get_free_page(GFP_KERNEL); + if (!area->vm_buf) + return -ENOMEM; + return 0; break; case CPU_DEAD: case CPU_UP_CANCELED: area = &per_cpu(zs_map_area, cpu); - if (area->vm) - free_vm_area(area->vm); - area->vm = NULL; + if (area->vm_buf) + free_page((unsigned long)area->vm_buf); + area->vm_buf = NULL; break; } @@ -691,9 +741,15 @@ EXPORT_SYMBOL_GPL(zs_free); * * Before using an object allocated from zs_malloc, it must be mapped using * this function. When done with the object, it must be unmapped using - * zs_unmap_object + * zs_unmap_object. + * + * Only one object can be mapped per cpu at a time. There is no protection + * against nested mappings. + * + * This function returns with preemption and page faults disabled. */ -void *zs_map_object(struct zs_pool *pool, unsigned long handle) +void *zs_map_object(struct zs_pool *pool, unsigned long handle, + enum zs_mapmode mm) { struct page *page; unsigned long obj_idx, off; @@ -714,22 +770,16 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle) if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ area->vm_addr = kmap_atomic(page); - } else { - /* this object spans two pages */ - struct page *nextp; - - nextp = get_next_page(page); - BUG_ON(!nextp); - - - set_pte(area->vm_ptes[0], mk_pte(page, PAGE_KERNEL)); - set_pte(area->vm_ptes[1], mk_pte(nextp, PAGE_KERNEL)); - - /* We pre-allocated VM area so mapping can never fail */ - area->vm_addr = area->vm->addr; + return area->vm_addr + off; } - return area->vm_addr + off; + /* disable page faults to match kmap_atomic() return conditions */ + pagefault_disable(); + + if (mm != ZS_MM_WO) + zs_copy_map_object(area->vm_buf, page, off, class->size); + area->vm_addr = NULL; + return area->vm_buf; } EXPORT_SYMBOL_GPL(zs_map_object); @@ -743,6 +793,17 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) struct size_class *class; struct mapping_area *area; + area = &__get_cpu_var(zs_map_area); + /* single-page object fastpath */ + if (area->vm_addr) { + kunmap_atomic(area->vm_addr); + goto out; + } + + /* no write fastpath */ + if (area->vm_mm == ZS_MM_RO) + goto pfenable; + BUG_ON(!handle); obj_handle_to_location(handle, &page, &obj_idx); @@ -750,15 +811,12 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) class = &pool->size_class[class_idx]; off = obj_idx_to_offset(page, obj_idx, class->size); - area = &__get_cpu_var(zs_map_area); - if (off + class->size <= PAGE_SIZE) { - kunmap_atomic(area->vm_addr); - } else { - set_pte(area->vm_ptes[0], __pte(0)); - set_pte(area->vm_ptes[1], __pte(0)); - __flush_tlb_one((unsigned long)area->vm_addr); - __flush_tlb_one((unsigned long)area->vm_addr + PAGE_SIZE); - } + zs_copy_unmap_object(area->vm_buf, page, off, class->size); + +pfenable: + /* enable page faults to match kunmap_atomic() return conditions */ + pagefault_enable(); +out: put_cpu_var(zs_map_area); } EXPORT_SYMBOL_GPL(zs_unmap_object); diff --git a/drivers/staging/zsmalloc/zsmalloc.h b/drivers/staging/zsmalloc/zsmalloc.h index 485cbb1a5ac8..de2e8bfbcc06 100644 --- a/drivers/staging/zsmalloc/zsmalloc.h +++ b/drivers/staging/zsmalloc/zsmalloc.h @@ -15,6 +15,17 @@ #include <linux/types.h> +/* + * zsmalloc mapping modes + * + * NOTE: These only make a difference when a mapped object spans pages +*/ +enum zs_mapmode { + ZS_MM_RW, /* normal read-write mapping */ + ZS_MM_RO, /* read-only (no copy-out at unmap time) */ + ZS_MM_WO /* write-only (no copy-in at map time) */ +}; + struct zs_pool; struct zs_pool *zs_create_pool(const char *name, gfp_t flags); @@ -23,7 +34,8 @@ void zs_destroy_pool(struct zs_pool *pool); unsigned long zs_malloc(struct zs_pool *pool, size_t size); void zs_free(struct zs_pool *pool, unsigned long obj); -void *zs_map_object(struct zs_pool *pool, unsigned long handle); +void *zs_map_object(struct zs_pool *pool, unsigned long handle, + enum zs_mapmode mm); void zs_unmap_object(struct zs_pool *pool, unsigned long handle); u64 zs_get_total_size_bytes(struct zs_pool *pool); diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h index 6fd32a9e0315..528051767733 100644 --- a/drivers/staging/zsmalloc/zsmalloc_int.h +++ b/drivers/staging/zsmalloc/zsmalloc_int.h @@ -110,9 +110,9 @@ enum fullness_group { static const int fullness_threshold_frac = 4; struct mapping_area { - struct vm_struct *vm; - pte_t *vm_ptes[2]; - char *vm_addr; + char *vm_buf; /* copy buffer for objects that span pages */ + char *vm_addr; /* address of kmap_atomic()'ed pages */ + enum zs_mapmode vm_mm; /* mapping mode */ }; struct size_class { diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index ad4fb1af0f7d..2a2b6b4d8d05 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h @@ -85,7 +85,7 @@ struct iio_buffer { /** * iio_buffer_init() - Initialize the buffer structure - * @buffer: buffer to be initialized + * @buffer: buffer to be initialized **/ void iio_buffer_init(struct iio_buffer *buffer); @@ -107,8 +107,9 @@ int iio_scan_mask_query(struct iio_dev *indio_dev, /** * iio_scan_mask_set() - set particular bit in the scan mask - * @buffer: the buffer whose scan mask we are interested in - * @bit: the bit to be set. + * @indio_dev IIO device structure + * @buffer: the buffer whose scan mask we are interested in + * @bit: the bit to be set. **/ int iio_scan_mask_set(struct iio_dev *indio_dev, struct iio_buffer *buffer, int bit); @@ -116,8 +117,8 @@ int iio_scan_mask_set(struct iio_dev *indio_dev, /** * iio_push_to_buffer() - push to a registered buffer. * @buffer: IIO buffer structure for device - * @scan: Full scan. - * @timestamp: + * @data: the data to push to the buffer + * @timestamp: timestamp to associate with the data */ int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data, s64 timestamp); @@ -126,7 +127,9 @@ int iio_update_demux(struct iio_dev *indio_dev); /** * iio_buffer_register() - register the buffer with IIO core - * @indio_dev: device with the buffer to be registered + * @indio_dev: device with the buffer to be registered + * @channels: the channel descriptions used to construct buffer + * @num_channels: the number of channels **/ int iio_buffer_register(struct iio_dev *indio_dev, const struct iio_chan_spec *channels, @@ -134,7 +137,7 @@ int iio_buffer_register(struct iio_dev *indio_dev, /** * iio_buffer_unregister() - unregister the buffer from IIO core - * @indio_dev: the device with the buffer to be unregistered + * @indio_dev: the device with the buffer to be unregistered **/ void iio_buffer_unregister(struct iio_dev *indio_dev); |