From: Yusuf Caglar Akyuz <cag...@bilkon-kontrol.com.tr> In addition to fixing checkpatch warnings, this patch also changes clock names used in the driver to current DaVinci tree names.
Signed-off-by: Yusuf Caglar Akyuz <cag...@bilkon-kontrol.com.tr> --- arch/arm/mach-davinci/Kconfig | 2 +- arch/arm/mach-davinci/include/mach/pwm.h | 9 +---- arch/arm/mach-davinci/pwm.c | 59 +++++++++++++++--------------- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index 6fa04db..844dac5 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -135,7 +135,7 @@ config DAVINCI_PWM depends on ARCH_DAVINCI default n help - DaVinci PWM Driver ported from 2.6.10 tree. This driver supports dm644x, + DaVinci PWM Driver ported from 2.6.10 tree. This driver supports dm644x, dm355 and dm646x SoCs. endmenu diff --git a/arch/arm/mach-davinci/include/mach/pwm.h b/arch/arm/mach-davinci/include/mach/pwm.h index cab37f9..0cf5835 100644 --- a/arch/arm/mach-davinci/include/mach/pwm.h +++ b/arch/arm/mach-davinci/include/mach/pwm.h @@ -33,7 +33,7 @@ /**************************************************************************\ * Register Overlay Structure \**************************************************************************/ -typedef struct { +struct davinci_pwmregs { unsigned int pid; unsigned int pcr; unsigned int cfg; @@ -41,12 +41,7 @@ typedef struct { unsigned int rpt; unsigned int per; unsigned int ph1d; -} davinci_pwmregs; - -/**************************************************************************\ -* Overlay structure typedef definition -\**************************************************************************/ -typedef volatile davinci_pwmregs *davinci_pwmregsovly; +}; #define PWM_MINORS 3 #define DM646X_PWM_MINORS 2 diff --git a/arch/arm/mach-davinci/pwm.c b/arch/arm/mach-davinci/pwm.c index f9aa5f4..c0d885e 100644 --- a/arch/arm/mach-davinci/pwm.c +++ b/arch/arm/mach-davinci/pwm.c @@ -44,22 +44,22 @@ struct pwm_davinci_device { char name[20]; int intr_complete; dev_t devno; - davinci_pwmregsovly regs; + struct davinci_pwmregs *regs; wait_queue_head_t intr_wait; struct clk *pwm_clk; int running; }; -char *dm644x_name[] = { "PWM0_CLK", "PWM1_CLK", "PWM2_CLK" }; -char *dm646x_name[] = { "PWM0_CLK", "PWM1_CLK" }; -char *dm355_name[] = { "PWM0_CLK", "PWM1_CLK", "PWM2_CLK", "PWM3_CLK" }; +char *dm644x_name[] = { "pwm0", "pwm1", "pwm2" }; +char *dm646x_name[] = { "pwm0", "pwm1" }; +char *dm355_name[] = { "pwm0", "pwm1", "pwm2", "pwm3" }; /* Instance of the private WDT device structure */ static struct pwm_davinci_device *pwm_dev_array[DAVINCI_PWM_MINORS]; static DEFINE_SPINLOCK(pwm_dev_array_lock); -static unsigned int pwm_major = 0; -static unsigned int pwm_minor_start = 0; +static unsigned int pwm_major; +static unsigned int pwm_minor_start; static unsigned int pwm_minor_count = DM644X_PWM_MINORS; static unsigned int pwm_device_count = 1; @@ -256,7 +256,7 @@ static void pwm_platform_release(struct device *device) /* this function does nothing */ } -static struct file_operations pwm_fops = { +const static struct file_operations pwm_fops = { .owner = THIS_MODULE, .llseek = pwm_llseek, .open = pwm_open, @@ -264,7 +264,7 @@ static struct file_operations pwm_fops = { .ioctl = pwm_ioctl, }; -static struct class *pwm_class = NULL; +static struct class *pwm_class; static struct platform_device pwm_device[] = { [0] = { @@ -339,7 +339,7 @@ static irqreturn_t pwm_isr(int irq, void *dev_id) return IRQ_HANDLED; } -#define PWM_FREQ 0x10000 / 48 +#define PWM_FREQ (0x10000 / 48) static ssize_t pwm_show(struct device *d, struct device_attribute *a, char *buf) @@ -347,8 +347,9 @@ pwm_show(struct device *d, struct device_attribute *a, char *buf) struct pwm_davinci_device *pwm_dev; pwm_dev = pwm_dev_get_by_minor(to_platform_device(d)->id); - - return sprintf(buf, "%s\n", pwm_dev->running == 1 ? "running" : "stopped"); + + return sprintf(buf, "%s\n", pwm_dev->running == 1 ? + "running" : "stopped"); } static ssize_t pwm_start(struct device *d, struct device_attribute *a, const char *buf @@ -356,21 +357,21 @@ pwm_start(struct device *d, struct device_attribute *a, const char *buf { struct pwm_davinci_device *pwm_dev; - if(count < 1) + if (count < 1) return count; - + pwm_dev = pwm_dev_get_by_minor(to_platform_device(d)->id); - if(buf[0] == '1' && pwm_dev->running == 0) { + if (buf[0] == '1' && pwm_dev->running == 0) { /* sample configuration */ pwm_dev->regs->per = PWM_FREQ; pwm_dev->regs->ph1d = 0x0; - pwm_dev->regs->cfg |= 0x2; + pwm_dev->regs->cfg |= 0x2; pwm_dev->intr_complete = 0; pwm_dev->running = 1; pwm_dev->regs->start = 0x1; } - if(buf[0] == '0' && pwm_dev->running == 1) { + if (buf[0] == '0' && pwm_dev->running == 1) { pwm_dev->regs->cfg &= 0xFFFFFFFC; pwm_dev->running = 0; } @@ -385,26 +386,26 @@ duty_read(struct device *d, struct device_attribute *a, char *buf) struct pwm_davinci_device *pwm_dev; pwm_dev = pwm_dev_get_by_minor(to_platform_device(d)->id); - + return sprintf(buf, "%d\n", pwm_dev->regs->ph1d); } static ssize_t duty_write(struct device *d, struct device_attribute *a, const char *buf , size_t count) { - struct pwm_davinci_device *pwm_dev; + struct pwm_davinci_device *pwm_dev; int val = 0; pwm_dev = pwm_dev_get_by_minor(to_platform_device(d)->id); - - if(count == 1) + + if (count == 1) val = (buf[0] - 48); - if(count == 2) + if (count == 2) val = (buf[0] - 48) * 10 + (buf[1] - 48); - if(count == 3) + if (count == 3) val = (buf[0] - 48) * 100 + (buf[1] - 48) * 10 + (buf[2] - 48); - - if(val < 256) + + if (val < 256) pwm_dev->regs->ph1d = val * (PWM_FREQ / 256); else pwm_dev->regs->ph1d = PWM_FREQ; @@ -450,8 +451,8 @@ static int __init pwm_init(void) /* Register the driver in the kernel */ result = alloc_chrdev_region(&devno, 0, size, DRIVER_NAME); if (result < 0) { - printk("DaVinciPWM: Module intialization failed.\ - could not register character device\n"); + printk(KERN_ERR "DaVinciPWM: Module intialization failed.\ + could not register character device\n"); return -ENODEV; } pwm_major = MAJOR(devno); @@ -524,7 +525,7 @@ static int __init pwm_init(void) } if (result < 0) { - printk("Cannot initialize IRQ \n"); + printk(KERN_ERR "Cannot initialize IRQ \n"); platform_device_unregister(&pwm_device[j]); driver_unregister(&pwm_driver[j]); kfree(pwm_dev_array[j]); @@ -533,13 +534,13 @@ static int __init pwm_init(void) pwm_dev_array[j]->pwm_clk = clk_get(NULL, *(name + j)); if (IS_ERR(pwm_dev_array[j]->pwm_clk)) { - printk("Cannot get clock\n"); + printk(KERN_ERR "Cannot get clock\n"); return -1; } clk_enable(pwm_dev_array[j]->pwm_clk); pwm_dev_array[j]->regs = - (davinci_pwmregsovly) IO_ADDRESS(DAVINCI_PWM0_BASE + + (struct davinci_pwmregs *) IO_ADDRESS(DAVINCI_PWM0_BASE + j * 0x400); pwm_dev_array[j]->running = 0; create_sysfs_entries(&pwm_device[j].dev); -- 1.5.6 _______________________________________________ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source