From: Radek Pupák Date: Tue, 15 Jul 2008 17:49:41 +0000 (+0200) Subject: removing some unused imports, useless variables, change orientation of X and Y axes X-Git-Url: http://rtime.felk.cvut.cz/gitweb/mx1ts.git/commitdiff_plain/585905c62049116e6f9d02c37487ff07ad0bdbe2 removing some unused imports, useless variables, change orientation of X and Y axes --- diff --git a/mx1_ts-driver.c b/mx1_ts-driver.c index a6e7609..d121bec 100644 --- a/mx1_ts-driver.c +++ b/mx1_ts-driver.c @@ -19,41 +19,14 @@ #include -#include -#include -#include #include #include -#include #include -#include -#include -#include -#include -#include - #include -#include -#include - -#include //bonus XXX - +#include #include - -/* - * originaly from - * linux/drivers/misc/mx1ts.h - * - * Copyright (C) 2003 Blue Mug, Inc. for Motorola, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - */ - /* Interrupt numbers */ #define ASP_COMPARE_IRQ 5 #define ASP_PENDATA_IRQ 33 @@ -61,6 +34,7 @@ /* Analog signal processor (ASP) control registers */ #define ASP_BASE_ADDR 0x00215000 +#define ASP_MEM_LENGTH 0x38 #define ASP_ACNTLCR (0x10) /* Control register */ #define ASP_PSMPLRG (0x14) /* Pen A/D sampe rate control */ @@ -159,14 +133,15 @@ struct mx1ts { struct input_dev *ts_idev; struct resource pamet; - int irq; + int irq_touch; + int irq_pen_up; wait_queue_head_t ts_wait; struct task_struct *ts_task; unsigned int irq_pending; - unsigned int ts_restart:1; - unsigned int adcsync:1; +/* unsigned int ts_restart:1; + unsigned int adcsync:1;*/ void __iomem* mx1ts_mem; u16 x_res; @@ -177,7 +152,7 @@ struct mx1ts { u16 cal_auto_zero; u16 cal_range_x; u16 cal_range_y; - unsigned int stav; + /*unsigned int stav; */ u8 auto_calibration; u8 is_open; @@ -187,7 +162,7 @@ struct mx1ts { static inline void mx1ts_reg_set_mask(struct mx1ts *mts , unsigned int reg, u32 mask) { u32 val; - val = __raw_readl(mts->mx1ts_mem+reg); + val = __raw_readl(mts->mx1ts_mem+reg); /* TODO zvazit pouziti ioread32 */ val |= mask; __raw_writel(val, mts->mx1ts_mem+reg ); } @@ -203,14 +178,13 @@ static inline void mx1ts_reg_clear_mask(struct mx1ts *mts , unsigned int reg, u3 static inline void mx1ts_reg_write(struct mx1ts *mts, unsigned int reg, unsigned int val) { __raw_writel(val, mts->mx1ts_mem+reg); - printk(KERN_DEBUG "mx1_touchscreen: writing into : %p value %x\n",mts->mx1ts_mem+reg, val); + /*printk(KERN_DEBUG "mx1_touchscreen: writing into : %p value %x\n",mts->mx1ts_mem+reg, val);*/ } static inline unsigned int mx1ts_reg_read(struct mx1ts *mts, unsigned int reg) { unsigned int out; - out = __raw_readl( mts->mx1ts_mem + reg ); /*printk(KERN_DEBUG "mx1_touchscreen: reading from %p : %d \n",mts->mx1ts_mem + reg, out);*/ @@ -228,7 +202,6 @@ static inline void mx1ts_flush_fifo(struct mx1ts *mts) static void mx1ts_enable_auto_sample(struct mx1ts *mts) { unsigned int value; - mx1ts_flush_fifo(mts); value = mx1ts_reg_read(mts, ASP_ACNTLCR); @@ -434,8 +407,7 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) mx1_cal_range_x = 1; mx1_cal_range_y = 1; - /*printk(KERN_DEBUG "mx1_touchscreen mx1ts_pendata_irq \n");*/ -/* printk(KERN_DEBUG "mx1_touchscreen: mx1_pendata_irq interrupt recived from struct %p\n", mts);*/ + /*printk(KERN_DEBUG "mx1_touchscreen: mx1_pendata_irq interrupt recived from struct %p\n", mts);*/ if (mx1ts_reg_read(mts, ASP_ISTATR) & ASP_PUIS) { /*pen up interupt pending*/ mx1ts_reg_set_mask(mts, ASP_ISTATR, ASP_PUIS); /*clearing pen up interupt*/ @@ -502,9 +474,9 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) pen_y = mx1ts_reg_read(mts, ASP_PADFIFO); pen_u = mx1ts_reg_read(mts, ASP_PADFIFO); - pen_x = (u32)(((pen_x - auto_zero) << 16) / + pen_x = mts->x_res - (u32)(((pen_x - auto_zero) << 16) / mts->cal_range_x); - pen_y = (u32)(((pen_y - auto_zero) << 16) / + pen_y = mts->y_res - (u32)(((pen_y - auto_zero) << 16) / mts->cal_range_y); if(mts->is_open) @@ -568,16 +540,17 @@ static int mx1ts_on(struct mx1ts *mts) /*TODO doplnit pri chybach*/ { int ret = 0; - if(!request_mem_region(ASP_BASE_ADDR, 0x38 , "mx1ts")) { + if(!request_mem_region(ASP_BASE_ADDR, ASP_MEM_LENGTH , "mx1ts")) { printk(KERN_ERR "mx1 touchscreen: request_mem_region \tFAILED\n"); - return -1; + return -ENOMEM; } printk(KERN_DEBUG "mx1 touchscreen: request_mem_region \tOK\n"); - mts->mx1ts_mem = ioremap ( ASP_BASE_ADDR, 0x38); + mts->mx1ts_mem = ioremap ( ASP_BASE_ADDR, ASP_MEM_LENGTH); if(!mts->mx1ts_mem) { + release_mem_region(ASP_BASE_ADDR, ASP_MEM_LENGTH); printk(KERN_ERR "mx1 touchscreen: ioremap \tFAILED\n"); return -1; } @@ -624,7 +597,7 @@ static int mx1ts_probe(struct platform_device *dev) { struct mx1ts *mts; struct input_dev *idev; - int error, x_res, y_res; + int error; /* TODO jak poznat ze zarizeni je pritomne ? */ @@ -636,8 +609,12 @@ static int mx1ts_probe(struct platform_device *dev) goto err_free_devs; return error; } - - mx1ts_on(mts); /* remaping registers, reseting device */ + error = mx1ts_on(mts); + if(error<0) { /* remaping registers, reseting device */ + printk(KERN_ERR "mx1 touchscreen: failed mx1ts_on - remaping registers, reseting device\n"); + goto err_free_devs; + return error; + } mts->ts_idev = idev; init_waitqueue_head(&mts->ts_wait); @@ -647,10 +624,10 @@ static int mx1ts_probe(struct platform_device *dev) idev->dev.parent = &dev->dev; idev->name = "MX1 touchscreen interface"; - idev->phys = "mx1ts/input0"; //dodano + idev->phys = "mx1ts/input0"; idev->id.vendor = (unsigned int) 345; /*mx1ts_reg_read(mx1_ts, AC97_VENDOR_ID1);*/ - idev->id.product = (unsigned int) 354; /*id;*/ - idev->id.version = 0x0100; //dodano + idev->id.product = (unsigned int) 354; + idev->id.version = 0x0100; idev->id.bustype = BUS_HOST; idev->open = mx1ts_open; idev->close = mx1ts_close; @@ -659,12 +636,12 @@ static int mx1ts_probe(struct platform_device *dev) printk(KERN_DEBUG "mx1ts: setting idev struct \tOK\n"); - x_res = 60000; /*TODO neni mozne zmerit ? */ - y_res = 60000; - printk(KERN_DEBUG "mx1ts: x/y = %d/%d\n", x_res, y_res); + mts->x_res = 60000; /*TODO neni mozne zmerit ? */ + mts->y_res = 60000; + printk(KERN_DEBUG "mx1ts: x/y = %d/%d\n", mts->x_res, mts->y_res); - input_set_abs_params(idev, ABS_X, 0, x_res, 0, 0); - input_set_abs_params(idev, ABS_Y, 0, y_res, 0, 0); + input_set_abs_params(idev, ABS_X, 0, mts->x_res, 0, 0); + input_set_abs_params(idev, ABS_Y, 0, mts->y_res, 0, 0); input_set_abs_params(idev, ABS_PRESSURE, 0, 1, 0, 0); error = input_register_device(idev); @@ -679,7 +656,7 @@ static int mx1ts_probe(struct platform_device *dev) err_free_devs: printk(KERN_ERR "mx1 touchscreen: error in device probe \n"); - /*input_free_device(idev);*/ + input_free_device(idev); kfree(mts); return error; @@ -702,7 +679,7 @@ static int mx1ts_remove(struct platform_device *dev) input_unregister_device(mts->ts_idev); printk(KERN_INFO "mx1 touchscreen: Unregister device \tOK\n"); iounmap(mts->mx1ts_mem); - release_mem_region(ASP_BASE_ADDR, 0x38); + release_mem_region(ASP_BASE_ADDR, ASP_MEM_LENGTH); kfree(mts); @@ -717,8 +694,6 @@ static int mx1ts_resume(struct platform_device *dev) return 0; } -/* inicializace ovladace a driveru (insmod, rmmmod ) */ - static struct platform_driver mx1ts_driver = { .probe = mx1ts_probe, .remove = mx1ts_remove, @@ -798,16 +773,9 @@ static void __exit mx1ts_exit(void) return; } -//module_param(adcsync, bool, 0444); +//module_param(adcsync, bool, 0444); /* priklad parametru modulu*/ //MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin."); -//module_param(ts_delay, int, 0444); -//MODULE_PARM_DESC(ts_delay, "Delay between panel setup and position read. Default = 55us."); - -//module_param(ts_delay_pressure, int, 0444); -//MODULE_PARM_DESC(ts_delay_pressure, -// "delay between panel setup and pressure read. Default = 0us."); - module_init(mx1ts_init); module_exit(mx1ts_exit);