memstick: rtsx: finish request faster if no card exist
cover memstick: rtsx: finish request faster if no card exist
From: Micky Ching <[email protected]>
This pathset include some misc coding update.
- dump register using compact format.
This prevent dump a lot of lines register dump when some error occurs.
- finish request if no card exist
check card exist before sending any request, When card removed, request can returned much faster.
- move suspend/resume to pm ops
Move suspend/resume pm ops instead of driver.suspend/drivers.resume, we tested in some case if we put it in driver.suspend/drivers.resume, the function will not called.
Micky Ching (3):
memstick: rtsx: dump register using compact format
memstick: rtsx: finish request if no card exist
memstick: rtsx: move suspend/resume to pm ops
drivers/memstick/host/rtsx_pci_ms.c | 89 ++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 40 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 memstick: rtsx: dump register using compact format
From: Micky Ching <[email protected]>
Using more compact format for dump register when error occurs, this is useful to read debug log and reduce log length.
--- drivers/memstick/host/rtsx_pci_ms.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/memstick/host/rtsx_pci_ms.c +20 -17
@@ -54,26 +54,29 @@ static inline void ms_clear_error(struct realtek_pci_ms *host) }#ifdef DEBUG +static void dump_reg_range (struct realtek_pci_ms *host,u16 start,u16 end) +{ +u16 len = end - start +1 ; +int i; +u8 data[8 ]; + +for (i =0 ; i < len; i +=8 ) { +int j; +int n =min (8 , len - i); + +memset (&data,0 ,sizeof (data)); +for (j =0 ; j < n; j++) +rtsx_pci_read_register (host->pcr, start + i + j, + data + j); +dev_dbg (ms_dev (host),"0x%04X(%d): %8ph\n" , + start + i, n, data); + } +}static void ms_print_debug_regs (struct realtek_pci_ms *host) { -struct rtsx_pcr *pcr = host->pcr; -u16 i; -u8 *ptr; - -/* Print MS host internal registers */ -rtsx_pci_init_cmd (pcr); -for (i =0xFD40 ; i <=0xFD44 ; i++) -rtsx_pci_add_cmd (pcr,READ_REG_CMD , i,0 ,0 ); -for (i =0xFD52 ; i <=0xFD69 ; i++) -rtsx_pci_add_cmd (pcr,READ_REG_CMD , i,0 ,0 ); -rtsx_pci_send_cmd (pcr,100 ); - - ptr =rtsx_pci_get_cmd_data (pcr); -for (i =0xFD40 ; i <=0xFD44 ; i++) -dev_dbg (ms_dev (host),"0x%04X: 0x%02x\n" , i, *(ptr++)); -for (i =0xFD52 ; i <=0xFD69 ; i++) -dev_dbg (ms_dev (host),"0x%04X: 0x%02x\n" , i, *(ptr++)); +dump_reg_range (host,0xFD40 ,0xFD44 ); +dump_reg_range (host,0xFD52 ,0xFD69 ); }#else
Signature · 1 line
1.9.1
PATCH 2/3 memstick: rtsx: finish request if no card exist
In reply to [email protected]From: Micky Ching <[email protected]>
Check card exist before start request, this method can make card remove faster. If we found the card is not exist, just return error-code, not sending request can save much time.
--- drivers/memstick/host/rtsx_pci_ms.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/memstick/host/rtsx_pci_ms.c +18 -9
@@ -85,6 +85,11 @@ static void ms_print_debug_regs(struct realtek_pci_ms *host)#endif +static inline int ms_get_cd_int (struct realtek_pci_ms *host) +{ +return rtsx_pci_readl (host->pcr,RTSX_BIPR ) &MS_EXIST ; +} +static int ms_power_on (struct realtek_pci_ms *host) {struct rtsx_pcr *pcr = host->pcr;
@@ -409,6 +414,9 @@ static void rtsx_pci_ms_handle_req(struct work_struct *work)struct memstick_host *msh = host->msh;int rc; +if (host->req) +return ; +mutex_lock (&pcr->pcr_mutex);rtsx_pci_start_run (pcr);
@@ -419,15 +427,16 @@ static void rtsx_pci_ms_handle_req(struct work_struct *work)rtsx_pci_write_register (pcr,CARD_SHARE_MODE ,CARD_SHARE_MASK ,CARD_SHARE_48_MS ); -if (!host->req) { -do { - rc =memstick_next_req (msh, &host->req); -dev_dbg (ms_dev (host),"next req %d\n" , rc); - -if (!rc) - host->req->error =rtsx_pci_ms_issue_cmd (host); - }while (!rc); - } +while (true) { + rc =memstick_next_req (msh, &host->req); +dev_dbg (ms_dev (host),"next req %d\n" , rc); +if (rc) +break ; +if (!ms_get_cd_int (host)) + host->req->error = -ENOMEDIUM ; +else + host->req->error =rtsx_pci_ms_issue_cmd (host); + };mutex_unlock (&pcr->pcr_mutex); }
Signature · 1 line
1.9.1
PATCH 3/3 memstick: rtsx: move suspend/resume to pm ops
In reply to [email protected]From: Micky Ching <[email protected]>
Move suspend/resume function to pm ops, make it consistence with rtsx_usb_ms.c driver.
--- drivers/memstick/host/rtsx_pci_ms.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/memstick/host/rtsx_pci_ms.c +11 -14
@@ -22,6 +22,7 @@#include <linux/module.h> #include <linux/highmem.h> #include <linux/delay.h> +#include <linux/pm.h> #include <linux/platform_device.h> #include <linux/memstick.h> #include <linux/mfd/rtsx_pci.h>
@@ -514,11 +515,11 @@ static int rtsx_pci_ms_set_param(struct memstick_host *msh,return 0 ; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP -static int rtsx_pci_ms_suspend (struct platform_device *pdev,pm_message_t state) +static int rtsx_pci_ms_suspend (struct device *dev) { -struct realtek_pci_ms *host =platform_get_drvdata (pdev); +struct realtek_pci_ms *host =dev_get_drvdata (dev);struct memstick_host *msh = host->msh;dev_dbg (ms_dev (host),"--> %s\n" , __func__);
@@ -527,9 +528,9 @@ static int rtsx_pci_ms_suspend(struct platform_device *pdev, pm_message_t state)return 0 ; } -static int rtsx_pci_ms_resume (struct platform_device *pdev) +static int rtsx_pci_ms_resume (struct device *dev) { -struct realtek_pci_ms *host =platform_get_drvdata (pdev); +struct realtek_pci_ms *host =dev_get_drvdata (dev);struct memstick_host *msh = host->msh;dev_dbg (ms_dev (host),"--> %s\n" , __func__);
@@ -537,13 +538,7 @@ static int rtsx_pci_ms_resume(struct platform_device *pdev)memstick_resume_host (msh); return 0; } - -#else /* CONFIG_PM */ - -#define rtsx_pci_ms_suspend NULL -#define rtsx_pci_ms_resume NULL - -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static void rtsx_pci_ms_card_event (struct platform_device *pdev) {
@@ -641,6 +636,9 @@ static int rtsx_pci_ms_drv_remove(struct platform_device *pdev)return 0 ; } +static SIMPLE_DEV_PM_OPS(rtsx_pci_ms_pm_ops, + rtsx_pci_ms_suspend, rtsx_pci_ms_resume); +static struct platform_device_id rtsx_pci_ms_ids[] = { { .name =DRV_NAME_RTSX_PCI_MS ,
@@ -654,10 +652,9 @@ static struct platform_driver rtsx_pci_ms_driver = { .probe = rtsx_pci_ms_drv_probe, .remove = rtsx_pci_ms_drv_remove, .id_table = rtsx_pci_ms_ids, - .suspend = rtsx_pci_ms_suspend, - .resume = rtsx_pci_ms_resume, .driver = { .name = DRV_NAME_RTSX_PCI_MS, + .pm = &rtsx_pci_ms_pm_ops, }, };module_platform_driver (rtsx_pci_ms_driver);
Signature · 1 line
1.9.1