Re: XVME 6300 with TSI148 bridge on 64 bit Debian (Linux 3.2.57) vme_user issue

2014-11-18 Thread Maurice Moss
Hi Martyn,

Any update on this from your side?

Cheers!

On Mon, Nov 10, 2014 at 10:22 AM, Maurice Moss eightplusc...@gmail.com wrote:
 Hi Martyn,

 Thanks for your reply. I have pasted the code below. It is very much
 similar to your test code from the forum.

 Thanks!

 #define _XOPEN_SOURCE 500
 #define u32 unsigned int
 #include stdio.h
 #include stdlib.h
 #include sys/ioctl.h
 #include sys/types.h
 #include sys/stat.h
 #include fcntl.h
 #include unistd.h
 #include vme_user.h
 int main(int argc, char *argv[])
 {
 int fd;
 int i;
 int retval;
 int readSize = 2;
 unsigned char data[readSize];

 struct vme_master master;

 printf(Simple VME User Module Test\n);

 fd = open(/dev/bus/vme/m0, O_RDONLY);
 if (fd == -1) {
 perror(ERROR: Opening window device file);
 return 1;
 }

 printf (opened the file\n);
 master.enable = 1;
 //master.vme_addr = 0x114000;
 master.vme_addr = 0x114000;
 master.size = 0x1;
 master.aspace = 0x2; // VME_A24
 master.cycle = 0x2000 | 0x8000;// user/data access
 master.dwidth = 0x2; // 16 bit word access

 retval = ioctl(fd, VME_SET_MASTER, master);
 if (retval != 0) {
 printf(retval=%d\n, retval);
 perror(ERROR: Failed to configure window);
 return 1;
 }

 printf (set the master\n);
 /*
  * Reading first 512 bytes
  */
 for (i=0; ireadSize; i++) {
 data[i] = 0;
 }

 retval = pread(fd, data, readSize, 0x03c);
 if (retval  readSize) {
 printf(WARNING: Only read %d bytes, retval);
 }

 for(i=0; iretval; i++) {
 if (i % 8 == 0) {
 printf(\n%4.4x: , i);
 }
 printf(%2.2x , data[i]);
 }
 printf(\n);

 close(fd);

 return 0;
 }

 On Mon, Nov 10, 2014 at 4:07 AM, Welch, Martyn (GE Intelligent
 Platforms) martyn.we...@ge.com wrote:
 Hi Maurice,

 Would you be able to point to a complete piece of test code that exhibits 
 this failure?

 Martyn Welch
 Lead Software Engineer
 GE Intelligent Platforms
 Embedded Systems

 T +44 (0) 1327 322748
 F +44 (0) 1327 322817
 E martyn.we...@ge.com

 Tove Valley Business Park
 Towcester, Northants, NN12 6PF, United Kingdom
 GE Intelligent Platforms Ltd

 GE imagination at work

 GE Intelligent Platforms Ltd, registered in England and Wales (3828642) at 
 100 Barbirolli Square, Manchester, M2 3AB, VAT GB 927 5591 89


 -Original Message-
 From: Maurice Moss [mailto:eightplusc...@gmail.com]
 Sent: 08 November 2014 00:33
 To: Welch, Martyn (GE Intelligent Platforms)
 Cc: Manohar Vanga; dan.carpen...@oracle.com; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: XVME 6300 with TSI148 bridge on 64 bit Debian (Linux 3.2.57)
 vme_user issue

 Hi Manohar/Dan,

 Any idea regarding this?

 Cheers,
 Maurice

 On Mon, Nov 3, 2014 at 5:25 PM, Maurice Moss eightplusc...@gmail.com
 wrote:
  Hi Martyn,
 
  Thanks for your help from previous emails.  I managed to talk to my
  board using a VME-USB board. Now I am back to working with an SBC, and
  I have a different setup this time around, let me describe it:
 
  1. SBC in slot 0 of a VME64 chassis (with 2 slots), and the bottom one
  being a slot for an SBC.  The SBC is has a Universe-II and when I load
  the kernel module manually, everything seems fine, and I see this in
  dmesg:
  [   76.192738] vme_ca91cx42 :02:04.0: enabling device (0140 - 0143)
  [   76.192893] vme_ca91cx42 :02:04.0: Board is the VME system
 controller
  [   76.192902] vme_ca91cx42 :02:04.0: Slot ID is 0
  [   76.192907] vme_ca91cx42 :02:04.0: CR/CSR Offset: 0
  [   76.192911] vme_ca91cx42 :02:04.0: Slot number is unset, not
  configuring CR/CSR space
  [   76.195956] vme_ca91cx42 :02:04.0: CR/CSR configuration failed.
 
  I don't intend to use CR/CSR feature.  The linux kernel I am running
  is 3.13, the board is essentially this:
  http://www.onestopsystems.com/documents/OSS-PCIe-KIT-6400.pdf
 
  2. Now I would like to talk to a passive Slave board in slot 1 (I am
  not sure about this numbering, basically the board in the other slot).
  This slave board essentially talks only A24 and D16 in
  user/super/data.  It's address space internally begins at 0x114000. In
  my test code, I essentially have the following:
 
  master.enable = 1;
  //master.vme_addr = 0x114000;
  master.vme_addr = 0x114000;
  master.size = 0x1;
  master.aspace = 0x2; // VME_A24
  master.cycle = 0x2000 | 0x8000;// user/data access
  master.dwidth = 0x2; // 16 bit word access
  retval = ioctl(fd, VME_SET_MASTER, master);
 
  The call doesn't fail, and when I make a pread, all I get are 0xff s
  on 

Re: [PATCH] staging: lustre: mdc: use __FMODE_EXEC macro

2014-11-18 Thread Greg KH
On Mon, Nov 17, 2014 at 04:23:08PM -0800, Juston wrote:
 On Tue, 2014-11-18 at 01:46 +0300, Dan Carpenter wrote:
  On Mon, Nov 17, 2014 at 02:23:48PM -0800, Juston Li wrote:
   FMODE_EXEC is type fmode_t but is used in operations
   with integers which leads to sparse warnings:
   drivers/staging/lustre/lustre/mdc/mdc_lib.c:198:21: warning: restricted 
   fmode_t degrades to integer
   drivers/staging/lustre/lustre/mdc/mdc_locks.c:300:49: warning: restricted 
   fmode_t degrades to integer
   
   Fix by using __FMODE_EXEC macro defined in fs.h.
   
   Note the same warnings occurs with other fmode flags
   here but they don't have a corresponding int macro.
   
  
  When are FMODE_EXEC and __FMODE_EXEC not defined?  I think they're
  always defined.  I don't understand the point of these ifdefs.  I guess
  maybe they are for compatability with obsolete kernels?
  
  regards,
  dan carpenter
  
 Seems to be the case. Looked at some old commits (2.6.17) and found
 FMODE_EXEC was mainlined to allow lustre to be installed on a vanilla
 kernel.
 Since you pointed it out, if we are dealing with compatability with 
 obselete kernels, __FMODE_EXEC was added later in 2.6.38. Wondering
 if I should address the case where FMODE_EXEC is defined but 
 __FMODE_EXEC isn't since I currently only check __FMODE_EXEC.

Just fix it up to work the the current kernel version, no need to
support anything else in this codebase.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/11] staging: unisys: virthba: Remove blank lines before/after braces

2014-11-18 Thread Ken Depro
This patch removes unnecessary blank lines either before opening braces or
after closing braces, as reported by the checkpatch script.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 4affc19..d326ea1 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -989,7 +989,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
sgl = scsi_sglist(scsicmd);
 
for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) {
-
cmdrsp-scsi.gpi_list[i].address = sg_phys(sg);
cmdrsp-scsi.gpi_list[i].length = sg-length;
if ((i != 0)  (sg-offset != 0))
@@ -1207,7 +1206,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
bufind += sg[i].length;
}
} else {
-
vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
for ( ; vdisk-next; vdisk = vdisk-next) {
if ((scsidev-channel != vdisk-channel) ||
@@ -1655,7 +1653,6 @@ virthba_mod_init(void)
POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error,
 POSTCODE_SEVERITY_ERR);
} else {
-
/* create the debugfs directories and entries */
virthba_debugfs_dir = debugfs_create_dir(virthba, NULL);
debugfs_create_file(info, S_IRUSR, virthba_debugfs_dir,
@@ -1746,7 +1743,6 @@ virthba_mod_exit(void)
 
debugfs_remove_recursive(virthba_debugfs_dir);
LOGINF(Leaving virthba_mod_exit\n);
-
 }
 
 /* specify function to be run at module insertion time */
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/11] staging: unisys: virthba: Fix CamelCase variables

2014-11-18 Thread Ken Depro
This patch fixes the improper CamelCase usage for variables, reported by the
checkpatch script.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |  122 +++---
 1 file changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 758a39e..a71ca37 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -107,7 +107,7 @@ static void virthba_slave_destroy(struct scsi_device 
*scsidev);
 static int process_incoming_rsps(void *);
 static int virthba_serverup(struct virtpci_dev *virtpcidev);
 static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state);
-static void doDiskAddRemove(struct work_struct *work);
+static void do_disk_add_remove(struct work_struct *work);
 static void virthba_serverdown_complete(struct work_struct *work);
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
size_t len, loff_t *offset);
@@ -119,7 +119,7 @@ static ssize_t enable_ints_write(struct file *file,
 /*/
 
 static int rsltq_wait_usecs = 4000;/* Default 4ms */
-static unsigned int MaxBuffLen;
+static unsigned int max_buff_len;
 
 /* Module options */
 static char *virthba_options = NONE;
@@ -193,7 +193,7 @@ struct virthba_info {
struct virtdisk_info head;
 };
 
-/* Work Data for DARWorkQ */
+/* Work Data for dar_work_queue */
 struct diskaddremove {
u8 add; /* 0-remove, 1-add */
struct Scsi_Host *shost; /* Scsi Host for this virthba instance */
@@ -244,7 +244,7 @@ static const struct file_operations 
debugfs_enable_ints_fops = {
 
 #define VIRTHBASOPENMAX 1
 /* array of open devices maintained by open() and close(); */
-static struct virthba_devices_open VirtHbasOpen[VIRTHBASOPENMAX];
+static struct virthba_devices_open virthbas_open[VIRTHBASOPENMAX];
 static struct dentry *virthba_debugfs_dir;
 
 /*/
@@ -318,30 +318,30 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
return sent;
 }
 
-/* DARWorkQ (Disk Add/Remove) */
-static struct work_struct DARWorkQ;
-static struct diskaddremove *DARWorkQHead;
-static spinlock_t DARWorkQLock;
-static unsigned short DARWorkQSched;
+/* dar_work_queue (Disk Add/Remove) */
+static struct work_struct dar_work_queue;
+static struct diskaddremove *dar_work_queue_head;
+static spinlock_t dar_work_queue_lock;
+static unsigned short dar_work_queue_sched;
 #define QUEUE_DISKADDREMOVE(dar) { \
-   spin_lock_irqsave(DARWorkQLock, flags); \
-   if (!DARWorkQHead) { \
-   DARWorkQHead = dar; \
+   spin_lock_irqsave(dar_work_queue_lock, flags); \
+   if (!dar_work_queue_head) { \
+   dar_work_queue_head = dar; \
dar-next = NULL; \
} \
else { \
-   dar-next = DARWorkQHead; \
-   DARWorkQHead = dar; \
+   dar-next = dar_work_queue_head; \
+   dar_work_queue_head = dar; \
} \
-   if (!DARWorkQSched) { \
-   schedule_work(DARWorkQ); \
-   DARWorkQSched = 1; \
+   if (!dar_work_queue_sched) { \
+   schedule_work(dar_work_queue); \
+   dar_work_queue_sched = 1; \
} \
-   spin_unlock_irqrestore(DARWorkQLock, flags); \
+   spin_unlock_irqrestore(dar_work_queue_lock, flags); \
 }
 
 static inline void
-SendDiskAddRemove(struct diskaddremove *dar)
+send_disk_add_remove(struct diskaddremove *dar)
 {
struct scsi_device *sdev;
int error;
@@ -365,31 +365,31 @@ SendDiskAddRemove(struct diskaddremove *dar)
 }
 
 /*/
-/* DARWorkQ Handler Thread   */
+/* dar_work_queue Handler Thread */
 /*/
 static void
-doDiskAddRemove(struct work_struct *work)
+do_disk_add_remove(struct work_struct *work)
 {
struct diskaddremove *dar;
struct diskaddremove *tmphead;
int i = 0;
unsigned long flags;
 
-   spin_lock_irqsave(DARWorkQLock, flags);
-   tmphead = DARWorkQHead;
-   DARWorkQHead = NULL;
-   DARWorkQSched = 0;
-   spin_unlock_irqrestore(DARWorkQLock, flags);
+   spin_lock_irqsave(dar_work_queue_lock, flags);
+   tmphead = dar_work_queue_head;
+   dar_work_queue_head = NULL;
+   dar_work_queue_sched = 0;
+   spin_unlock_irqrestore(dar_work_queue_lock, flags);
while (tmphead) {
dar = tmphead;
tmphead = dar-next;
-   SendDiskAddRemove(dar);
+   send_disk_add_remove(dar);
i++;
}
 }
 
 /*/
-/* Routine to add entry to DARWorkQ  

[PATCH 04/11] staging: unisys: virthba: Fix logical continuation checks

2014-11-18 Thread Ken Depro
This patch fixes checkpatch checks where the logical operator should be at the
end of the line above, not beginning the next line.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |   38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index deeb1e8..4affc19 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -429,8 +429,8 @@ virthba_ISR(int irq, void *dev_id)
virthbainfo-interrupts_rcvd++;
pchhdr = virthbainfo-chinfo.queueinfo-chan;
if (((readq(pchhdr-features)
-  ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0)
-((readq(pchhdr-features) 
+  ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) 
+((readq(pchhdr-features) 
 ULTRA_IO_DRIVER_DISABLES_INTS) !=
0)) {
virthbainfo-interrupts_disabled++;
@@ -807,9 +807,9 @@ virthba_abort_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd-device;
for (vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
 vdisk-next; vdisk = vdisk-next) {
-   if ((scsidev-channel == vdisk-channel)
-(scsidev-id == vdisk-id)
-(scsidev-lun == vdisk-lun)) {
+   if ((scsidev-channel == vdisk-channel) 
+   (scsidev-id == vdisk-id) 
+   (scsidev-lun == vdisk-lun)) {
if (atomic_read(vdisk-error_count) 
VIRTHBA_ERROR_COUNT) {
atomic_inc(vdisk-error_count);
@@ -833,9 +833,9 @@ virthba_bus_reset_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd-device;
for (vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
 vdisk-next; vdisk = vdisk-next) {
-   if ((scsidev-channel == vdisk-channel)
-(scsidev-id == vdisk-id)
-(scsidev-lun == vdisk-lun)) {
+   if ((scsidev-channel == vdisk-channel) 
+   (scsidev-id == vdisk-id) 
+   (scsidev-lun == vdisk-lun)) {
if (atomic_read(vdisk-error_count) 
VIRTHBA_ERROR_COUNT) {
atomic_inc(vdisk-error_count);
@@ -859,9 +859,9 @@ virthba_device_reset_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd-device;
for (vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
 vdisk-next; vdisk = vdisk-next) {
-   if ((scsidev-channel == vdisk-channel)
-(scsidev-id == vdisk-id)
-(scsidev-lun == vdisk-lun)) {
+   if ((scsidev-channel == vdisk-channel) 
+   (scsidev-id == vdisk-id) 
+   (scsidev-lun == vdisk-lun)) {
if (atomic_read(vdisk-error_count) 
VIRTHBA_ERROR_COUNT) {
atomic_inc(vdisk-error_count);
@@ -1131,9 +1131,9 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
/* Okay see what our error_count is here */
for (vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
 vdisk-next; vdisk = vdisk-next) {
-   if ((scsidev-channel != vdisk-channel)
-   || (scsidev-id != vdisk-id)
-   || (scsidev-lun != vdisk-lun))
+   if ((scsidev-channel != vdisk-channel) ||
+   (scsidev-id != vdisk-id) ||
+   (scsidev-lun != vdisk-lun))
continue;
 
if (atomic_read(vdisk-error_count)  VIRTHBA_ERROR_COUNT) {
@@ -1169,8 +1169,8 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
struct virtdisk_info *vdisk;
 
scsidev = scsicmd-device;
-   if ((cmdrsp-scsi.cmnd[0] == INQUIRY)
-(cmdrsp-scsi.bufflen = MIN_INQUIRY_RESULT_LEN)) {
+   if ((cmdrsp-scsi.cmnd[0] == INQUIRY) 
+   (cmdrsp-scsi.bufflen = MIN_INQUIRY_RESULT_LEN)) {
if (cmdrsp-scsi.no_disk_result == 0)
return;
 
@@ -1210,9 +1210,9 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
 
vdisk = ((struct virthba_info *)scsidev-host-hostdata)-head;
for ( ; vdisk-next; vdisk = vdisk-next) {
-   if ((scsidev-channel != vdisk-channel)
-   || (scsidev-id != vdisk-id)
-   || (scsidev-lun != vdisk-lun))
+   if ((scsidev-channel != vdisk-channel) ||
+   (scsidev-id != vdisk-id) ||
+   (scsidev-lun != vdisk-lun))
continue;
 
   

[PATCH 07/11] staging: unisys: virthba: Change alloc calls to use var name instead of type

2014-11-18 Thread Ken Depro
This patch changes a couple of kzalloc calls to pass the variable name to the
call, rather than the variable struct type.  This is a result of checks
generated during the checkpatch script.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 363b5eb..49225ec 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -397,7 +397,7 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
struct diskaddremove *dar;
unsigned long flags;
 
-   dar = kzalloc(sizeof(struct diskaddremove), GFP_ATOMIC);
+   dar = kzalloc(sizeof(*dar), GFP_ATOMIC);
if (dar) {
dar-add = cmdrsp-disknotify.add;
dar-shost = shost;
@@ -1060,7 +1060,7 @@ virthba_slave_alloc(struct scsi_device *scsidev)
(vdisk-next-lun == scsidev-lun))
return 0;
}
-   tmpvdisk = kzalloc(sizeof(struct virtdisk_info), GFP_ATOMIC);
+   tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC);
if (!tmpvdisk) {/* error allocating */
LOGERR(Could not allocate memory for disk\n);
return 0;
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/11] staging: unisys: virthba: Fix checkpatch issues in virthba

2014-11-18 Thread Ken Depro
This series fixes various issues in the virthba.c file that were reported by
the checkpatch script.

Ken Depro (11):
  staging: unisys: virthba: Remove unneeded spaces after casts
  staging: unisys: virthba: Fix CamelCase variables
  staging: unisys: virthba: Fix open parenthesis alignment checks
  staging: unisys: virthba: Fix logical continuation checks
  staging: unisys: virthba: Remove blank lines before/after braces
  staging: unisys: virthba: Fix missing braces at end of if-else
statements
  staging: unisys: virthba: Change alloc calls to use var name instead
of type
  staging: unisys: virthba: Fix a couple checkpatch problems
  staging: unisys: virthba: Fix else not useful after return warning
  staging: unisys: virthba: Fix warnings regarding lines over 80
characters
  staging: unisys: virthba: Fix a couple open parenthesis alignment
issues

 drivers/staging/unisys/virthba/virthba.c |  399 +++---
 1 file changed, 203 insertions(+), 196 deletions(-)

-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/11] staging: unisys: virthba: Fix open parenthesis alignment checks

2014-11-18 Thread Ken Depro
This patch fixes the alignment should match open parenthesis checks from the
checkpatch script.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |   74 +++---
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index a71ca37..deeb1e8 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -110,9 +110,9 @@ static int virthba_serverdown(struct virtpci_dev 
*virtpcidev, u32 state);
 static void do_disk_add_remove(struct work_struct *work);
 static void virthba_serverdown_complete(struct work_struct *work);
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-   size_t len, loff_t *offset);
+size_t len, loff_t *offset);
 static ssize_t enable_ints_write(struct file *file,
-   const char __user *buffer, size_t count, loff_t *ppos);
+const char __user *buffer, size_t count, 
loff_t *ppos);
 
 /*/
 /* Globals   */
@@ -262,7 +262,7 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char 
cmdtype, void *new)
insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
if (insert_location == (int)vhbainfo-nextinsert) {
LOGERR(Queue should be full. insert_location%d  
Unable to find open slot for pending commands.\n,
-insert_location);
+  insert_location);
spin_unlock_irqrestore(vhbainfo-privlock, flags);
return -1;
}
@@ -300,13 +300,13 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
 
if (del = MAX_PENDING_REQUESTS) {
LOGERR(Invalid queue position %lu given to delete. 
MAX_PENDING_REQUESTS %d\n,
-(unsigned long)del, MAX_PENDING_REQUESTS);
+  (unsigned long)del, MAX_PENDING_REQUESTS);
} else {
spin_lock_irqsave(vhbainfo-privlock, flags);
 
if (vhbainfo-pending[del].sent == NULL)
LOGERR(Deleting already cleared queue entry at 
%lu.\n,
-(unsigned long)del);
+  (unsigned long)del);
 
sent = vhbainfo-pending[del].sent;
 
@@ -356,8 +356,8 @@ send_disk_add_remove(struct diskaddremove *dar)
dar-lun);
if (error)
LOGERR(Failed scsi_add_device: 
host_no=%d[chan=%d:id=%d:lun=%d]\n,
-dar-shost-host_no, dar-channel, dar-id,
-dar-lun);
+  dar-shost-host_no, dar-channel, dar-id,
+  dar-lun);
} else
LOGERR(Failed scsi_device_lookup:[chan=%d:id=%d:lun=%d]\n,
   dar-channel, dar-id, dar-lun);
@@ -407,8 +407,8 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
QUEUE_DISKADDREMOVE(dar);
} else {
LOGERR(kmalloc failed for dar. 
host_no=%d[chan=%d:id=%d:lun=%d]\n,
-shost-host_no, cmdrsp-disknotify.channel,
-cmdrsp-disknotify.id, cmdrsp-disknotify.lun);
+  shost-host_no, cmdrsp-disknotify.channel,
+  cmdrsp-disknotify.id, cmdrsp-disknotify.lun);
}
 }
 
@@ -501,11 +501,11 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
 * the max-channel value.
 */
LOGINF(virtpcidev-scsi.max.max_channel=%u, max_id=%u, max_lun=%u, 
cmd_per_lun=%u, max_io_size=%u\n,
-(unsigned)virtpcidev-scsi.max.max_channel - 1,
-(unsigned)virtpcidev-scsi.max.max_id,
-(unsigned)virtpcidev-scsi.max.max_lun,
-(unsigned)virtpcidev-scsi.max.cmd_per_lun,
-(unsigned)virtpcidev-scsi.max.max_io_size);
+  (unsigned)virtpcidev-scsi.max.max_channel - 1,
+  (unsigned)virtpcidev-scsi.max.max_id,
+  (unsigned)virtpcidev-scsi.max.max_lun,
+  (unsigned)virtpcidev-scsi.max.cmd_per_lun,
+  (unsigned)virtpcidev-scsi.max.max_io_size);
scsihost-max_channel = (unsigned)virtpcidev-scsi.max.max_channel;
scsihost-max_id = (unsigned)virtpcidev-scsi.max.max_id;
scsihost-max_lun = (unsigned)virtpcidev-scsi.max.max_lun;
@@ -517,12 +517,12 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
if (scsihost-sg_tablesize  MAX_PHYS_INFO)
scsihost-sg_tablesize = MAX_PHYS_INFO;
LOGINF(scsihost-max_channel=%u, max_id=%u, max_lun=%llu, 
cmd_per_lun=%u, 

[PATCH 01/11] staging: unisys: virthba: Remove unneeded spaces after casts

2014-11-18 Thread Ken Depro
This patch removes all unnecessary spaces after casts, as reported by the
checkpatch script.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |  130 +++---
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index d7a629b..758a39e 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -260,7 +260,7 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char 
cmdtype, void *new)
insert_location = vhbainfo-nextinsert;
while (vhbainfo-pending[insert_location].sent != NULL) {
insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
-   if (insert_location == (int) vhbainfo-nextinsert) {
+   if (insert_location == (int)vhbainfo-nextinsert) {
LOGERR(Queue should be full. insert_location%d  
Unable to find open slot for pending commands.\n,
 insert_location);
spin_unlock_irqrestore(vhbainfo-privlock, flags);
@@ -289,7 +289,7 @@ add_scsipending_entry_with_wait(struct virthba_info 
*vhbainfo, char cmdtype,
insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
}
 
-   return (unsigned int) insert_location;
+   return (unsigned int)insert_location;
 }
 
 static void *
@@ -300,13 +300,13 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
 
if (del = MAX_PENDING_REQUESTS) {
LOGERR(Invalid queue position %lu given to delete. 
MAX_PENDING_REQUESTS %d\n,
-(unsigned long) del, MAX_PENDING_REQUESTS);
+(unsigned long)del, MAX_PENDING_REQUESTS);
} else {
spin_lock_irqsave(vhbainfo-privlock, flags);
 
if (vhbainfo-pending[del].sent == NULL)
LOGERR(Deleting already cleared queue entry at 
%lu.\n,
-(unsigned long) del);
+(unsigned long)del);
 
sent = vhbainfo-pending[del].sent;
 
@@ -418,7 +418,7 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
 static irqreturn_t
 virthba_ISR(int irq, void *dev_id)
 {
-   struct virthba_info *virthbainfo = (struct virthba_info *) dev_id;
+   struct virthba_info *virthbainfo = (struct virthba_info *)dev_id;
struct channel_header __iomem *pChannelHeader;
struct signal_queue_header __iomem *pqhdr;
u64 mask;
@@ -442,7 +442,7 @@ virthba_ISR(int irq, void *dev_id)
return IRQ_NONE;
}
pqhdr = (struct signal_queue_header __iomem *)
-   ((char __iomem *) pChannelHeader +
+   ((char __iomem *)pChannelHeader +
 readq(pChannelHeader-ch_space_offset)) + IOCHAN_FROM_IOPART;
writeq(readq(pqhdr-num_irq_received) + 1,
   pqhdr-num_irq_received);
@@ -501,19 +501,19 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
 * the max-channel value.
 */
LOGINF(virtpcidev-scsi.max.max_channel=%u, max_id=%u, max_lun=%u, 
cmd_per_lun=%u, max_io_size=%u\n,
-(unsigned) virtpcidev-scsi.max.max_channel - 1,
-(unsigned) virtpcidev-scsi.max.max_id,
-(unsigned) virtpcidev-scsi.max.max_lun,
-(unsigned) virtpcidev-scsi.max.cmd_per_lun,
-(unsigned) virtpcidev-scsi.max.max_io_size);
-   scsihost-max_channel = (unsigned) virtpcidev-scsi.max.max_channel;
-   scsihost-max_id = (unsigned) virtpcidev-scsi.max.max_id;
-   scsihost-max_lun = (unsigned) virtpcidev-scsi.max.max_lun;
-   scsihost-cmd_per_lun = (unsigned) virtpcidev-scsi.max.cmd_per_lun;
+(unsigned)virtpcidev-scsi.max.max_channel - 1,
+(unsigned)virtpcidev-scsi.max.max_id,
+(unsigned)virtpcidev-scsi.max.max_lun,
+(unsigned)virtpcidev-scsi.max.cmd_per_lun,
+(unsigned)virtpcidev-scsi.max.max_io_size);
+   scsihost-max_channel = (unsigned)virtpcidev-scsi.max.max_channel;
+   scsihost-max_id = (unsigned)virtpcidev-scsi.max.max_id;
+   scsihost-max_lun = (unsigned)virtpcidev-scsi.max.max_lun;
+   scsihost-cmd_per_lun = (unsigned)virtpcidev-scsi.max.cmd_per_lun;
scsihost-max_sectors =
-   (unsigned short) (virtpcidev-scsi.max.max_io_size  9);
+   (unsigned short)(virtpcidev-scsi.max.max_io_size  9);
scsihost-sg_tablesize =
-   (unsigned short) (virtpcidev-scsi.max.max_io_size / PAGE_SIZE);
+   (unsigned short)(virtpcidev-scsi.max.max_io_size / PAGE_SIZE);
if (scsihost-sg_tablesize  MAX_PHYS_INFO)
scsihost-sg_tablesize = MAX_PHYS_INFO;
LOGINF(scsihost-max_channel=%u, max_id=%u, max_lun=%llu, 
cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n,

[PATCH 11/11] staging: unisys: virthba: Fix a couple open parenthesis alignment issues

2014-11-18 Thread Ken Depro
This patch fixes a couple checkpatch checks where alignment of the parameters
did not match the open parenthesis of the function.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index e746c03..debb5e6 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1295,7 +1295,8 @@ drain_queue(struct virthba_info *virthbainfo, struct 
chaninfo *dc,
 * deletion
 */
scsicmd = del_scsipending_entry(virthbainfo,
-   (uintptr_t)cmdrsp-scsi.scsicmd);
+   (uintptr_t)
+cmdrsp-scsi.scsicmd);
if (!scsicmd)
break;
/* complete the orig cmd */
@@ -1314,7 +1315,8 @@ drain_queue(struct virthba_info *virthbainfo, struct 
chaninfo *dc,
process_disk_notify(shost, cmdrsp);
} else if (cmdrsp-cmdtype == CMD_VDISKMGMT_TYPE) {
if (!del_scsipending_entry(virthbainfo,
-  (uintptr_t)cmdrsp-vdiskmgmt.scsicmd))
+  (uintptr_t)
+   cmdrsp-vdiskmgmt.scsicmd))
break;
complete_vdiskmgmt_command(cmdrsp);
} else {
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/11] staging: unisys: virthba: Fix warnings regarding lines over 80 characters

2014-11-18 Thread Ken Depro
This patch fixes warnings generated by checkpatch script regarding lines over
80 characters long.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |   40 --
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index c9110a8..e746c03 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -85,7 +85,8 @@ static int virthba_host_reset_handler(struct scsi_cmnd 
*scsicmd);
 static const char *virthba_get_info(struct Scsi_Host *shp);
 static int virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
 static int virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
-void (*virthba_cmnd_done)(struct scsi_cmnd 
*));
+void (*virthba_cmnd_done)
+  (struct scsi_cmnd *));
 
 static const struct x86_cpu_id unisys_spar_ids[] = {
{ X86_VENDOR_INTEL, 6, 62, X86_FEATURE_ANY },
@@ -112,7 +113,8 @@ static void virthba_serverdown_complete(struct work_struct 
*work);
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
 size_t len, loff_t *offset);
 static ssize_t enable_ints_write(struct file *file,
-const char __user *buffer, size_t count, 
loff_t *ppos);
+const char __user *buffer, size_t count,
+loff_t *ppos);
 
 /*/
 /* Globals   */
@@ -284,7 +286,7 @@ add_scsipending_entry_with_wait(struct virthba_info 
*vhbainfo, char cmdtype,
int insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
 
while (insert_location == -1) {
-   LOGERR(Failed to find empty queue slot.  Waiting to try 
again\n);
+   LOGERR(Failed to find empty queue slot; will try again\n);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(10));
insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
@@ -306,7 +308,7 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
spin_lock_irqsave(vhbainfo-privlock, flags);
 
if (vhbainfo-pending[del].sent == NULL)
-   LOGERR(Deleting already cleared queue entry at 
%lu.\n,
+   LOGERR(Deleting prior cleared queue entry @ %lu\n,
   (unsigned long)del);
 
sent = vhbainfo-pending[del].sent;
@@ -407,7 +409,7 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
dar-lun = cmdrsp-disknotify.lun;
QUEUE_DISKADDREMOVE(dar);
} else {
-   LOGERR(kmalloc failed for dar. 
host_no=%d[chan=%d:id=%d:lun=%d]\n,
+   LOGERR(dar kzalloc failed. host_no=%d[chan=%d:id=%d:lun=%d]\n,
   shost-host_no, cmdrsp-disknotify.channel,
   cmdrsp-disknotify.id, cmdrsp-disknotify.lun);
}
@@ -522,8 +524,8 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct 
pci_device_id *id)
   scsihost-cmd_per_lun, scsihost-max_sectors,
   scsihost-sg_tablesize);
LOGINF(scsihost-can_queue=%u, scsihost-cmd_per_lun=%u, 
max_sectors=%hu, sg_tablesize=%hu\n,
-  scsihost-can_queue, scsihost-cmd_per_lun, 
scsihost-max_sectors,
-  scsihost-sg_tablesize);
+  scsihost-can_queue, scsihost-cmd_per_lun,
+  scsihost-max_sectors, scsihost-sg_tablesize);
 
DBGINF(calling scsi_add_host\n);
 
@@ -616,7 +618,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct 
pci_device_id *id)
rsp = request_irq(virthbainfo-interrupt_vector, handler, IRQF_SHARED,
  scsihost-hostt-name, virthbainfo);
if (rsp != 0) {
-   LOGERR(request_irq(%d) uislib_virthba_ISR request failed with 
rsp=%d\n,
+   LOGERR(req_irq(%d) uislib_virthba_ISR req failed; rsp=%d\n,
   virthbainfo-interrupt_vector, rsp);
virthbainfo-interrupt_vector = -1;
POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
@@ -993,12 +995,12 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
cmdrsp-scsi.gpi_list[i].address = sg_phys(sg);
cmdrsp-scsi.gpi_list[i].length = sg-length;
if ((i != 0)  (sg-offset != 0))
-   LOGINF(Offset on a sg_entry other than zero 
=%d.\n,
+   LOGINF(Offset on sg_entry not 0=%d\n,
   sg-offset);
}
 
if (sg_failed) {
-  

[PATCH 06/11] staging: unisys: virthba: Fix missing braces at end of if-else statements

2014-11-18 Thread Ken Depro
This patch fixes checkpatch warnings that resulted from the else portion of
if-else statements missing braces, so that it conforms with the rest of the
statement.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index d326ea1..363b5eb 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1314,8 +1314,9 @@ drain_queue(struct virthba_info *virthbainfo, struct 
chaninfo *dc,
   (uintptr_t)cmdrsp-vdiskmgmt.scsicmd))
break;
complete_vdiskmgmt_command(cmdrsp);
-   } else
+   } else {
LOGERR(Invalid cmdtype %d\n, cmdrsp-cmdtype);
+   }
/* cmdrsp is now available for reuse */
}
 }
@@ -1597,8 +1598,9 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 
state)
} else if (virthbainfo-serverchangingstate) {
LOGERR(Server already processing change state message\n);
return 0;
-   } else
+   } else {
LOGERR(Server already down, but another server down message 
received.);
+   }
 
return 1;
 }
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/11] staging: unisys: virthba: Fix else not useful after return warning

2014-11-18 Thread Ken Depro
This patch fixes a warning generated during the checkpatch script that stated
else not useful after return.  I modified the code to return a designated
status at the end of the function, and replaced the return statement in the
else if to set the status accordingly.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index dd361cd..c9110a8 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1584,6 +1584,8 @@ virthba_serverdown_complete(struct work_struct *work)
 static int
 virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state)
 {
+   int stat = 1;
+
struct virthba_info *virthbainfo =
(struct virthba_info *)((struct Scsi_Host *)virtpcidev-scsi.
 scsihost)-hostdata;
@@ -1598,12 +1600,12 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 
state)
   virthbainfo-serverdown_completion);
} else if (virthbainfo-serverchangingstate) {
LOGERR(Server already processing change state message\n);
-   return 0;
+   stat = 0;
} else {
LOGERR(Server already down, but another server down message 
received.);
}
 
-   return 1;
+   return stat;
 }
 
 /*/
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/11] staging: unisys: virthba: Fix a couple checkpatch problems

2014-11-18 Thread Ken Depro
This patch fixes a couple small issues reported by the checkpatch script:
  Adds a blank line after a struct definition.
  Removes unnecessary parentheses surrounding a struct member.

Signed-off-by: Ken Depro kenneth.de...@unisys.com
---
 drivers/staging/unisys/virthba/virthba.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 49225ec..dd361cd 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -165,6 +165,7 @@ struct virtdisk_info {
atomic_t error_count;
struct virtdisk_info *next;
 };
+
 /* Each Scsi_Host has a host_data area that contains this struct. */
 struct virthba_info {
struct Scsi_Host *scsihost;
@@ -1534,7 +1535,7 @@ virthba_serverdown_complete(struct work_struct *work)
/* Fail Commands that weren't completed */
spin_lock_irqsave(virthbainfo-privlock, flags);
for (i = 0; i  MAX_PENDING_REQUESTS; i++) {
-   pendingdel = (virthbainfo-pending[i]);
+   pendingdel = virthbainfo-pending[i];
switch (pendingdel-cmdtype) {
case CMD_SCSI_TYPE:
scsicmd = (struct scsi_cmnd *)pendingdel-sent;
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/9] staging: panel: Call init function directly

2014-11-18 Thread Mariusz Gorski
Remove useless function and let the kernel call the actual
init function directly.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 3dd318a..0d3f09e 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -,7 +,7 @@ static struct parport_driver panel_driver = {
 };
 
 /* init function */
-static int panel_init(void)
+static int __init panel_init_module(void)
 {
/* for backwards compatibility */
if (keypad_type  0)
@@ -2334,11 +2334,6 @@ static int panel_init(void)
return 0;
 }
 
-static int __init panel_init_module(void)
-{
-   return panel_init();
-}
-
 static void __exit panel_cleanup_module(void)
 {
unregister_reboot_notifier(panel_notifier);
-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/9] staging: panel: Make two more module params read-only

2014-11-18 Thread Mariusz Gorski
Make keypad_type and lcd_type module params read-only.
This step also starts making it more clear what is
the precedence of device params coming from different
sources (device profile, runtime module param values etc).

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 71 ++-
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 7f2f5f8..5b4f0a4 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -229,6 +229,9 @@ static struct {
bool enabled;
 } lcd;
 
+/* Needed only for init */
+static int selected_lcd_type = NOT_SET;
+
 /* contains the LCD config state */
 static unsigned long int lcd_flags;
 /* contains the LCD X offset */
@@ -1417,7 +1420,7 @@ static void panel_lcd_print(const char *s)
 /* initialize the LCD driver */
 static void lcd_init(void)
 {
-   switch (lcd_type) {
+   switch (selected_lcd_type) {
case LCD_TYPE_OLD:
/* parallel mode, 8 bits */
if (IS_NOT_SET(lcd_proto))
@@ -2235,28 +2238,21 @@ static struct parport_driver panel_driver = {
 /* init function */
 static int __init panel_init_module(void)
 {
-   /* for backwards compatibility */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = keypad_enabled;
-
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = lcd_enabled;
+   int selected_keypad_type = NOT_SET;
 
/* take care of an eventual profile */
switch (profile) {
case PANEL_PROFILE_CUSTOM:
/* custom profile */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = DEFAULT_KEYPAD_TYPE;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = DEFAULT_LCD_TYPE;
+   selected_keypad_type = DEFAULT_KEYPAD_TYPE;
+   selected_lcd_type = DEFAULT_LCD_TYPE;
break;
case PANEL_PROFILE_OLD:
/* 8 bits, 2*16, old keypad */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = KEYPAD_TYPE_OLD;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = LCD_TYPE_OLD;
+   selected_keypad_type = KEYPAD_TYPE_OLD;
+   selected_lcd_type = LCD_TYPE_OLD;
+
+   /* TODO: This two are a little hacky, sort it out later */
if (IS_NOT_SET(lcd_width))
lcd_width = 16;
if (IS_NOT_SET(lcd_hwidth))
@@ -2264,38 +2260,45 @@ static int __init panel_init_module(void)
break;
case PANEL_PROFILE_NEW:
/* serial, 2*16, new keypad */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = KEYPAD_TYPE_NEW;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = LCD_TYPE_KS0074;
+   selected_keypad_type = KEYPAD_TYPE_NEW;
+   selected_lcd_type = LCD_TYPE_KS0074;
break;
case PANEL_PROFILE_HANTRONIX:
/* 8 bits, 2*16 hantronix-like, no keypad */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = KEYPAD_TYPE_NONE;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = LCD_TYPE_HANTRONIX;
+   selected_keypad_type = KEYPAD_TYPE_NONE;
+   selected_lcd_type = LCD_TYPE_HANTRONIX;
break;
case PANEL_PROFILE_NEXCOM:
/* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = KEYPAD_TYPE_NEXCOM;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = LCD_TYPE_NEXCOM;
+   selected_keypad_type = KEYPAD_TYPE_NEXCOM;
+   selected_lcd_type = LCD_TYPE_NEXCOM;
break;
case PANEL_PROFILE_LARGE:
/* 8 bits, 2*40, old keypad */
-   if (IS_NOT_SET(keypad_type))
-   keypad_type = KEYPAD_TYPE_OLD;
-   if (IS_NOT_SET(lcd_type))
-   lcd_type = LCD_TYPE_OLD;
+   selected_keypad_type = KEYPAD_TYPE_OLD;
+   selected_lcd_type = LCD_TYPE_OLD;
break;
}
 
-   lcd.enabled = (lcd_type  0);
-   keypad.enabled = (keypad_type  0);
+   /*
+* Overwrite selection with module param values (both keypad and lcd),
+* where the deprecated params have lower prio.
+*/
+   if (keypad_enabled  -1)
+   selected_keypad_type = keypad_enabled;
+   if (keypad_type  -1)
+   selected_keypad_type = keypad_type;
+
+   keypad.enabled = (selected_keypad_type  0);
+
+   if (lcd_enabled  -1)
+   selected_lcd_type = lcd_enabled;
+   if (lcd_type  -1)
+   selected_lcd_type = lcd_type;
+
+   lcd.enabled 

[PATCH 5/9] staging: panel: Start making module params read-only

2014-11-18 Thread Mariusz Gorski
Start decoupling module params from the actual device state,
both for lcd and keypad, by keeping the params read-only
and moving the device state to related structs.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 35 +--
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 97fc4ca..7f2f5f8 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -214,6 +214,10 @@ static pmask_t phys_prev;
 static char inputs_stable;
 
 /* these variables are specific to the keypad */
+static struct {
+   bool enabled;
+} keypad;
+
 static char keypad_buffer[KEYPAD_BUFFER];
 static int keypad_buflen;
 static int keypad_start;
@@ -221,6 +225,9 @@ static char keypressed;
 static wait_queue_head_t keypad_read_wait;
 
 /* lcd-specific variables */
+static struct {
+   bool enabled;
+} lcd;
 
 /* contains the LCD config state */
 static unsigned long int lcd_flags;
@@ -1395,7 +1402,7 @@ static void panel_lcd_print(const char *s)
const char *tmp = s;
int count = strlen(s);
 
-   if (lcd_enabled  lcd_initialized) {
+   if (lcd.enabled  lcd_initialized) {
for (; count--  0; tmp++) {
if (!in_interrupt()  (((count + 1)  0x1f) == 0))
/* let's be a little nice with other processes
@@ -1925,7 +1932,7 @@ static void panel_process_inputs(void)
 
 static void panel_scan_timer(void)
 {
-   if (keypad_enabled  keypad_initialized) {
+   if (keypad.enabled  keypad_initialized) {
if (spin_trylock_irq(pprt_lock)) {
phys_scan_contacts();
 
@@ -1937,7 +1944,7 @@ static void panel_scan_timer(void)
panel_process_inputs();
}
 
-   if (lcd_enabled  lcd_initialized) {
+   if (lcd.enabled  lcd_initialized) {
if (keypressed) {
if (light_tempo == 0  ((lcd_flags  LCD_FLAG_L) == 0))
lcd_backlight(1);
@@ -2116,7 +2123,7 @@ static void keypad_init(void)
 static int panel_notify_sys(struct notifier_block *this, unsigned long code,
void *unused)
 {
-   if (lcd_enabled  lcd_initialized) {
+   if (lcd.enabled  lcd_initialized) {
switch (code) {
case SYS_DOWN:
panel_lcd_print
@@ -2172,13 +2179,13 @@ static void panel_attach(struct parport *port)
/* must init LCD first, just in case an IRQ from the keypad is
 * generated at keypad init
 */
-   if (lcd_enabled) {
+   if (lcd.enabled) {
lcd_init();
if (misc_register(lcd_dev))
goto err_unreg_device;
}
 
-   if (keypad_enabled) {
+   if (keypad.enabled) {
keypad_init();
if (misc_register(keypad_dev))
goto err_lcd_unreg;
@@ -2186,7 +2193,7 @@ static void panel_attach(struct parport *port)
return;
 
 err_lcd_unreg:
-   if (lcd_enabled)
+   if (lcd.enabled)
misc_deregister(lcd_dev);
 err_unreg_device:
parport_unregister_device(pprt);
@@ -2204,12 +2211,12 @@ static void panel_detach(struct parport *port)
return;
}
 
-   if (keypad_enabled  keypad_initialized) {
+   if (keypad.enabled  keypad_initialized) {
misc_deregister(keypad_dev);
keypad_initialized = 0;
}
 
-   if (lcd_enabled  lcd_initialized) {
+   if (lcd.enabled  lcd_initialized) {
misc_deregister(lcd_dev);
lcd_initialized = 0;
}
@@ -2285,8 +2292,8 @@ static int __init panel_init_module(void)
break;
}
 
-   lcd_enabled = (lcd_type  0);
-   keypad_enabled = (keypad_type  0);
+   lcd.enabled = (lcd_type  0);
+   keypad.enabled = (keypad_type  0);
 
switch (keypad_type) {
case KEYPAD_TYPE_OLD:
@@ -2311,7 +2318,7 @@ static int __init panel_init_module(void)
return -EIO;
}
 
-   if (!lcd_enabled  !keypad_enabled) {
+   if (!lcd.enabled  !keypad.enabled) {
/* no device enabled, let's release the parport */
if (pprt) {
parport_release(pprt);
@@ -2346,12 +2353,12 @@ static void __exit panel_cleanup_module(void)
del_timer_sync(scan_timer);
 
if (pprt != NULL) {
-   if (keypad_enabled) {
+   if (keypad.enabled) {
misc_deregister(keypad_dev);
keypad_initialized = 0;
}
 
-   if (lcd_enabled) {
+   if (lcd.enabled) {
panel_lcd_print(\x0cLCD driver  PANEL_VERSION
\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-);
  

[PATCH 4/9] staging: panel: Use a macro for checking module params state

2014-11-18 Thread Mariusz Gorski
Avoid values comparison and use a macro instead that checks
whether module param has been set by the user to some value
at loading time.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 88 ++-
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 1b4a211..97fc4ca 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -135,6 +135,8 @@
 
 #define NOT_SET-1
 
+#define IS_NOT_SET(x)  (x == NOT_SET)
+
 /* macros to simplify use of the parallel port */
 #define r_ctr(x)(parport_read_control((x)-port))
 #define r_dtr(x)(parport_read_data((x)-port))
@@ -1411,29 +1413,29 @@ static void lcd_init(void)
switch (lcd_type) {
case LCD_TYPE_OLD:
/* parallel mode, 8 bits */
-   if (lcd_proto  0)
+   if (IS_NOT_SET(lcd_proto))
lcd_proto = LCD_PROTO_PARALLEL;
-   if (lcd_charset  0)
+   if (IS_NOT_SET(lcd_charset))
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == PIN_NOT_SET)
lcd_rs_pin = PIN_AUTOLF;
 
-   if (lcd_width  0)
+   if (IS_NOT_SET(lcd_width))
lcd_width = 40;
-   if (lcd_bwidth  0)
+   if (IS_NOT_SET(lcd_bwidth))
lcd_bwidth = 40;
-   if (lcd_hwidth  0)
+   if (IS_NOT_SET(lcd_hwidth))
lcd_hwidth = 64;
-   if (lcd_height  0)
+   if (IS_NOT_SET(lcd_height))
lcd_height = 2;
break;
case LCD_TYPE_KS0074:
/* serial mode, ks0074 */
-   if (lcd_proto  0)
+   if (IS_NOT_SET(lcd_proto))
lcd_proto = LCD_PROTO_SERIAL;
-   if (lcd_charset  0)
+   if (IS_NOT_SET(lcd_charset))
lcd_charset = LCD_CHARSET_KS0074;
if (lcd_bl_pin == PIN_NOT_SET)
lcd_bl_pin = PIN_AUTOLF;
@@ -1442,20 +1444,20 @@ static void lcd_init(void)
if (lcd_da_pin == PIN_NOT_SET)
lcd_da_pin = PIN_D0;
 
-   if (lcd_width  0)
+   if (IS_NOT_SET(lcd_width))
lcd_width = 16;
-   if (lcd_bwidth  0)
+   if (IS_NOT_SET(lcd_bwidth))
lcd_bwidth = 40;
-   if (lcd_hwidth  0)
+   if (IS_NOT_SET(lcd_hwidth))
lcd_hwidth = 16;
-   if (lcd_height  0)
+   if (IS_NOT_SET(lcd_height))
lcd_height = 2;
break;
case LCD_TYPE_NEXCOM:
/* parallel mode, 8 bits, generic */
-   if (lcd_proto  0)
+   if (IS_NOT_SET(lcd_proto))
lcd_proto = LCD_PROTO_PARALLEL;
-   if (lcd_charset  0)
+   if (IS_NOT_SET(lcd_charset))
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_AUTOLF;
@@ -1464,42 +1466,42 @@ static void lcd_init(void)
if (lcd_rw_pin == PIN_NOT_SET)
lcd_rw_pin = PIN_INITP;
 
-   if (lcd_width  0)
+   if (IS_NOT_SET(lcd_width))
lcd_width = 16;
-   if (lcd_bwidth  0)
+   if (IS_NOT_SET(lcd_bwidth))
lcd_bwidth = 40;
-   if (lcd_hwidth  0)
+   if (IS_NOT_SET(lcd_hwidth))
lcd_hwidth = 64;
-   if (lcd_height  0)
+   if (IS_NOT_SET(lcd_height))
lcd_height = 2;
break;
case LCD_TYPE_CUSTOM:
/* customer-defined */
-   if (lcd_proto  0)
+   if (IS_NOT_SET(lcd_proto))
lcd_proto = DEFAULT_LCD_PROTO;
-   if (lcd_charset  0)
+   if (IS_NOT_SET(lcd_charset))
lcd_charset = DEFAULT_LCD_CHARSET;
/* default geometry will be set later */
break;
case LCD_TYPE_HANTRONIX:
/* parallel mode, 8 bits, hantronix-like */
default:
-   if (lcd_proto  0)
+   if (IS_NOT_SET(lcd_proto))
lcd_proto = LCD_PROTO_PARALLEL;
-   if (lcd_charset  0)
+   if (IS_NOT_SET(lcd_charset))
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == 

[PATCH 0/9] staging: panel: Refactor panel initialization

2014-11-18 Thread Mariusz Gorski
This set of patches focuses on making current initialization
process easier to understand - especially it tries to emphasize
what are the priorities of the params coming from different
sources (Kconfig values, device profiles and module param values
set on loading). I paid attention not to change to behaviour of
the code itself (at least for now), so all hacky places are kept.

Mariusz Gorski (9):
  staging: panel: Set default parport module param value
  staging: panel: Call init function directly
  staging: panel: Remove magic numbers
  staging: panel: Use a macro for checking module params state
  staging: panel: Start making module params read-only
  staging: panel: Make two more module params read-only
  staging: panel: Refactor LCD init code
  staging: panel: Remove more magic number comparison
  staging: panel: Move LCD-related state into struct lcd

 drivers/staging/panel/panel.c | 672 ++
 1 file changed, 357 insertions(+), 315 deletions(-)

-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/9] staging: panel: Remove more magic number comparison

2014-11-18 Thread Mariusz Gorski
Use a macro instead of magic number comparison for checking
whether a module param value has been set.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index ee48bca..268ad2e 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -136,6 +136,7 @@
 #define NOT_SET-1
 
 #define IS_NOT_SET(x)  (x == NOT_SET)
+#define IS_SET(x)  (x  NOT_SET)
 
 /* macros to simplify use of the parallel port */
 #define r_ctr(x)(parport_read_control((x)-port))
@@ -1496,17 +1497,17 @@ static void lcd_init(void)
}
 
/* Overwrite with module params set on loading */
-   if (lcd_height  -1)
+   if (IS_SET(lcd_height))
lcd.height = lcd_height;
-   if (lcd_width  -1)
+   if (IS_SET(lcd_width))
lcd.width = lcd_width;
-   if (lcd_bwidth  -1)
+   if (IS_SET(lcd_bwidth))
lcd.bwidth = lcd_bwidth;
-   if (lcd_hwidth  -1)
+   if (IS_SET(lcd_hwidth))
lcd.hwidth = lcd_hwidth;
-   if (lcd_charset  -1)
+   if (IS_SET(lcd_charset))
lcd.charset = lcd_charset;
-   if (lcd_proto  -1)
+   if (IS_SET(lcd_proto))
lcd.proto = lcd_proto;
if (lcd_e_pin != PIN_NOT_SET)
lcd.pins.e = lcd_e_pin;
@@ -2306,16 +2307,16 @@ static int __init panel_init_module(void)
 * Overwrite selection with module param values (both keypad and lcd),
 * where the deprecated params have lower prio.
 */
-   if (keypad_enabled  -1)
+   if (IS_SET(keypad_enabled))
selected_keypad_type = keypad_enabled;
-   if (keypad_type  -1)
+   if (IS_SET(keypad_type))
selected_keypad_type = keypad_type;
 
keypad.enabled = (selected_keypad_type  0);
 
-   if (lcd_enabled  -1)
+   if (IS_SET(lcd_enabled))
selected_lcd_type = lcd_enabled;
-   if (lcd_type  -1)
+   if (IS_SET(lcd_type))
selected_lcd_type = lcd_type;
 
lcd.enabled = (selected_lcd_type  0);
-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 9/9] staging: panel: Move LCD-related state into struct lcd

2014-11-18 Thread Mariusz Gorski
Move more or less all LCD-related state into struct lcd
in order to get better cohesion; use bool instead of int
where it makes sense.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 255 ++
 1 file changed, 134 insertions(+), 121 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 268ad2e..7a11871 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -228,12 +228,20 @@ static wait_queue_head_t keypad_read_wait;
 /* lcd-specific variables */
 static struct {
bool enabled;
+   bool initialized;
+   bool must_clear;
+
+   /* TODO: use bool here? */
+   char left_shift;
+
int height;
int width;
int bwidth;
int hwidth;
int charset;
int proto;
+   int light_tempo;
+
/* TODO: use union here? */
struct {
int e;
@@ -243,22 +251,26 @@ static struct {
int da;
int bl;
} pins;
+
+   /* contains the LCD config state */
+   unsigned long int flags;
+
+   /* Contains the LCD X and Y offset */
+   struct {
+   unsigned long int x;
+   unsigned long int y;
+   } addr;
+
+   /* Current escape sequence and it's length or -1 if outside */
+   struct {
+   char buf[LCD_ESCAPE_LEN + 1];
+   int len;
+   } esc_seq;
 } lcd;
 
 /* Needed only for init */
 static int selected_lcd_type = NOT_SET;
 
-/* contains the LCD config state */
-static unsigned long int lcd_flags;
-/* contains the LCD X offset */
-static unsigned long int lcd_addr_x;
-/* contains the LCD Y offset */
-static unsigned long int lcd_addr_y;
-/* current escape sequence, 0 terminated */
-static char lcd_escape[LCD_ESCAPE_LEN + 1];
-/* not in escape state. =0 = escape cmd len */
-static int lcd_escape_len = -1;
-
 /*
  * Bit masks to convert LCD signals to parallel port outputs.
  * _d_ are values for data port, _c_ are for control port.
@@ -441,13 +453,8 @@ static atomic_t keypad_available = ATOMIC_INIT(1);
 
 static struct pardevice *pprt;
 
-static int lcd_initialized;
 static int keypad_initialized;
 
-static int light_tempo;
-
-static char lcd_must_clear;
-static char lcd_left_shift;
 static char init_in_progress;
 
 static void (*lcd_write_cmd)(int);
@@ -883,23 +890,23 @@ static void lcd_write_data_tilcd(int data)
 static void lcd_gotoxy(void)
 {
lcd_write_cmd(0x80  /* set DDRAM address */
- | (lcd_addr_y ? lcd.hwidth : 0)
+ | (lcd.addr.y ? lcd.hwidth : 0)
  /* we force the cursor to stay at the end of the
 line if it wants to go farther */
- | ((lcd_addr_x  lcd.bwidth) ? lcd_addr_x 
+ | ((lcd.addr.x  lcd.bwidth) ? lcd.addr.x 
 (lcd.hwidth - 1) : lcd.bwidth - 1));
 }
 
 static void lcd_print(char c)
 {
-   if (lcd_addr_x  lcd.bwidth) {
+   if (lcd.addr.x  lcd.bwidth) {
if (lcd_char_conv != NULL)
c = lcd_char_conv[(unsigned char)c];
lcd_write_data(c);
-   lcd_addr_x++;
+   lcd.addr.x++;
}
/* prevents the cursor from wrapping onto the next line */
-   if (lcd_addr_x == lcd.bwidth)
+   if (lcd.addr.x == lcd.bwidth)
lcd_gotoxy();
 }
 
@@ -908,8 +915,8 @@ static void lcd_clear_fast_s(void)
 {
int pos;
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
@@ -921,8 +928,8 @@ static void lcd_clear_fast_s(void)
}
spin_unlock_irq(pprt_lock);
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 }
 
@@ -931,8 +938,8 @@ static void lcd_clear_fast_p8(void)
 {
int pos;
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
@@ -959,8 +966,8 @@ static void lcd_clear_fast_p8(void)
}
spin_unlock_irq(pprt_lock);
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 }
 
@@ -969,8 +976,8 @@ static void lcd_clear_fast_tilcd(void)
 {
int pos;
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
@@ -982,8 +989,8 @@ static void lcd_clear_fast_tilcd(void)
 
spin_unlock_irq(pprt_lock);
 
-   lcd_addr_x = 0;
-   lcd_addr_y = 0;
+   lcd.addr.x = 0;
+   lcd.addr.y = 0;
lcd_gotoxy();
 }
 
@@ -991,15 +998,15 @@ static void lcd_clear_fast_tilcd(void)
 static void lcd_clear_display(void)
 {

[PATCH 1/9] staging: panel: Set default parport module param value

2014-11-18 Thread Mariusz Gorski
Set default parport module param value to DEFAULT_PARPORT so that
a if-block can be avoided.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index c6eeddf..3dd318a 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -429,7 +429,7 @@ static struct timer_list scan_timer;
 
 MODULE_DESCRIPTION(Generic parallel port LCD/Keypad driver);
 
-static int parport = -1;
+static int parport = DEFAULT_PARPORT;
 module_param(parport, int, );
 MODULE_PARM_DESC(parport, Parallel port index (0=lpt1, 1=lpt2, ...));
 
@@ -2231,9 +2231,6 @@ static int panel_init(void)
if (lcd_type  0)
lcd_type = lcd_enabled;
 
-   if (parport  0)
-   parport = DEFAULT_PARPORT;
-
/* take care of an eventual profile */
switch (profile) {
case PANEL_PROFILE_CUSTOM:
-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/9] staging: panel: Remove magic numbers

2014-11-18 Thread Mariusz Gorski
Get rid of magic numbers indicating that the value of a module param
is not set. Use a defined value instead.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 0d3f09e..1b4a211 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -133,6 +133,8 @@
 #define LCD_ESCAPE_LEN 24  /* max chars for LCD escape command */
 #define LCD_ESCAPE_CHAR27  /* use char 27 for escape command */
 
+#define NOT_SET-1
+
 /* macros to simplify use of the parallel port */
 #define r_ctr(x)(parport_read_control((x)-port))
 #define r_dtr(x)(parport_read_data((x)-port))
@@ -439,37 +441,37 @@ MODULE_PARM_DESC(profile,
 1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; 
 4=16x2 nexcom; default=40x2, old kp);
 
-static int keypad_type = -1;
+static int keypad_type = NOT_SET;
 module_param(keypad_type, int, );
 MODULE_PARM_DESC(keypad_type,
 Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 
keys);
 
-static int lcd_type = -1;
+static int lcd_type = NOT_SET;
 module_param(lcd_type, int, );
 MODULE_PARM_DESC(lcd_type,
 LCD type: 0=none, 1=old //, 2=serial ks0074, 3=hantronix //, 
4=nexcom //, 5=compiled-in);
 
-static int lcd_height = -1;
+static int lcd_height = NOT_SET;
 module_param(lcd_height, int, );
 MODULE_PARM_DESC(lcd_height, Number of lines on the LCD);
 
-static int lcd_width = -1;
+static int lcd_width = NOT_SET;
 module_param(lcd_width, int, );
 MODULE_PARM_DESC(lcd_width, Number of columns on the LCD);
 
-static int lcd_bwidth = -1;/* internal buffer width (usually 40) */
+static int lcd_bwidth = NOT_SET;   /* internal buffer width (usually 40) */
 module_param(lcd_bwidth, int, );
 MODULE_PARM_DESC(lcd_bwidth, Internal LCD line width (40));
 
-static int lcd_hwidth = -1;/* hardware buffer width (usually 64) */
+static int lcd_hwidth = NOT_SET;   /* hardware buffer width (usually 64) */
 module_param(lcd_hwidth, int, );
 MODULE_PARM_DESC(lcd_hwidth, LCD line hardware address (64));
 
-static int lcd_charset = -1;
+static int lcd_charset = NOT_SET;
 module_param(lcd_charset, int, );
 MODULE_PARM_DESC(lcd_charset, LCD character set: 0=standard, 1=KS0074);
 
-static int lcd_proto = -1;
+static int lcd_proto = NOT_SET;
 module_param(lcd_proto, int, );
 MODULE_PARM_DESC(lcd_proto,
 LCD communication: 0=parallel (//), 1=serial, 2=TI LCD 
Interface);
@@ -515,11 +517,11 @@ MODULE_PARM_DESC(lcd_bl_pin,
 
 /* Deprecated module parameters - consider not using them anymore */
 
-static int lcd_enabled = -1;
+static int lcd_enabled = NOT_SET;
 module_param(lcd_enabled, int, );
 MODULE_PARM_DESC(lcd_enabled, Deprecated option, use lcd_type instead);
 
-static int keypad_enabled = -1;
+static int keypad_enabled = NOT_SET;
 module_param(keypad_enabled, int, );
 MODULE_PARM_DESC(keypad_enabled, Deprecated option, use keypad_type instead);
 
-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/9] staging: panel: Refactor LCD init code

2014-11-18 Thread Mariusz Gorski
Rework lcd_init method to make it a little bit more clear about
the precedence of the params, move LCD geometry and pins layout
to the LCD struct and thus make the LCD-related module params
effectively read-only.

Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
---
 drivers/staging/panel/panel.c | 304 ++
 1 file changed, 163 insertions(+), 141 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 5b4f0a4..ee48bca 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -227,6 +227,21 @@ static wait_queue_head_t keypad_read_wait;
 /* lcd-specific variables */
 static struct {
bool enabled;
+   int height;
+   int width;
+   int bwidth;
+   int hwidth;
+   int charset;
+   int proto;
+   /* TODO: use union here? */
+   struct {
+   int e;
+   int rs;
+   int rw;
+   int cl;
+   int da;
+   int bl;
+   } pins;
 } lcd;
 
 /* Needed only for init */
@@ -768,7 +783,7 @@ static void lcd_send_serial(int byte)
 /* turn the backlight on or off */
 static void lcd_backlight(int on)
 {
-   if (lcd_bl_pin == PIN_NONE)
+   if (lcd.pins.bl == PIN_NONE)
return;
 
/* The backlight is activated by setting the AUTOFEED line to +5V  */
@@ -867,23 +882,23 @@ static void lcd_write_data_tilcd(int data)
 static void lcd_gotoxy(void)
 {
lcd_write_cmd(0x80  /* set DDRAM address */
- | (lcd_addr_y ? lcd_hwidth : 0)
+ | (lcd_addr_y ? lcd.hwidth : 0)
  /* we force the cursor to stay at the end of the
 line if it wants to go farther */
- | ((lcd_addr_x  lcd_bwidth) ? lcd_addr_x 
-(lcd_hwidth - 1) : lcd_bwidth - 1));
+ | ((lcd_addr_x  lcd.bwidth) ? lcd_addr_x 
+(lcd.hwidth - 1) : lcd.bwidth - 1));
 }
 
 static void lcd_print(char c)
 {
-   if (lcd_addr_x  lcd_bwidth) {
+   if (lcd_addr_x  lcd.bwidth) {
if (lcd_char_conv != NULL)
c = lcd_char_conv[(unsigned char)c];
lcd_write_data(c);
lcd_addr_x++;
}
/* prevents the cursor from wrapping onto the next line */
-   if (lcd_addr_x == lcd_bwidth)
+   if (lcd_addr_x == lcd.bwidth)
lcd_gotoxy();
 }
 
@@ -897,7 +912,7 @@ static void lcd_clear_fast_s(void)
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
-   for (pos = 0; pos  lcd_height * lcd_hwidth; pos++) {
+   for (pos = 0; pos  lcd.height * lcd.hwidth; pos++) {
lcd_send_serial(0x5F);  /* R/W=W, RS=1 */
lcd_send_serial(' '  0x0F);
lcd_send_serial((' '  4)  0x0F);
@@ -920,7 +935,7 @@ static void lcd_clear_fast_p8(void)
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
-   for (pos = 0; pos  lcd_height * lcd_hwidth; pos++) {
+   for (pos = 0; pos  lcd.height * lcd.hwidth; pos++) {
/* present the data to the data port */
w_dtr(pprt, ' ');
 
@@ -958,7 +973,7 @@ static void lcd_clear_fast_tilcd(void)
lcd_gotoxy();
 
spin_lock_irq(pprt_lock);
-   for (pos = 0; pos  lcd_height * lcd_hwidth; pos++) {
+   for (pos = 0; pos  lcd.height * lcd.hwidth; pos++) {
/* present the data to the data port */
w_dtr(pprt, ' ');
udelay(60);
@@ -983,7 +998,7 @@ static void lcd_clear_display(void)
 
 static void lcd_init_display(void)
 {
-   lcd_flags = ((lcd_height  1) ? LCD_FLAG_N : 0)
+   lcd_flags = ((lcd.height  1) ? LCD_FLAG_N : 0)
| LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B;
 
long_sleep(20); /* wait 20 ms after power-up for the paranoid */
@@ -1097,17 +1112,17 @@ static inline int handle_lcd_special_code(void)
case 'l':   /* Shift Cursor Left */
if (lcd_addr_x  0) {
/* back one char if not at end of line */
-   if (lcd_addr_x  lcd_bwidth)
+   if (lcd_addr_x  lcd.bwidth)
lcd_write_cmd(0x10);
lcd_addr_x--;
}
processed = 1;
break;
case 'r':   /* shift cursor right */
-   if (lcd_addr_x  lcd_width) {
+   if (lcd_addr_x  lcd.width) {
/* allow the cursor to pass the end of the line */
if (lcd_addr_x 
-   (lcd_bwidth - 1))
+   (lcd.bwidth - 1))
lcd_write_cmd(0x14);
lcd_addr_x++;
}
@@ -1126,7 +1141,7 @@ static inline int handle_lcd_special_code(void)
case 'k': { /* kill end of line */
  

Re: [PATCH 1/9] staging: panel: Set default parport module param value

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:06PM +0100, Mariusz Gorski wrote:
 Set default parport module param value to DEFAULT_PARPORT so that
 a if-block can be avoided.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/9] staging: panel: Remove magic numbers

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:08PM +0100, Mariusz Gorski wrote:
 Get rid of magic numbers indicating that the value of a module param
 is not set. Use a defined value instead.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/9] staging: panel: Call init function directly

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:07PM +0100, Mariusz Gorski wrote:
 Remove useless function and let the kernel call the actual
 init function directly.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/9] staging: panel: Use a macro for checking module params state

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:09PM +0100, Mariusz Gorski wrote:
 Avoid values comparison and use a macro instead that checks
 whether module param has been set by the user to some value
 at loading time.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
 ---
  drivers/staging/panel/panel.c | 88 
 ++-
  1 file changed, 45 insertions(+), 43 deletions(-)
 
 diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
 index 1b4a211..97fc4ca 100644
 --- a/drivers/staging/panel/panel.c
 +++ b/drivers/staging/panel/panel.c
 @@ -135,6 +135,8 @@
  
  #define NOT_SET  -1
  
 +#define IS_NOT_SET(x)(x == NOT_SET)
 +
  /* macros to simplify use of the parallel port */
  #define r_ctr(x)(parport_read_control((x)-port))
  #define r_dtr(x)(parport_read_data((x)-port))
 @@ -1411,29 +1413,29 @@ static void lcd_init(void)
   switch (lcd_type) {
   case LCD_TYPE_OLD:
   /* parallel mode, 8 bits */
 - if (lcd_proto  0)
 + if (IS_NOT_SET(lcd_proto))
   lcd_proto = LCD_PROTO_PARALLEL;
 - if (lcd_charset  0)
 + if (IS_NOT_SET(lcd_charset))
   lcd_charset = LCD_CHARSET_NORMAL;
   if (lcd_e_pin == PIN_NOT_SET)
   lcd_e_pin = PIN_STROBE;
   if (lcd_rs_pin == PIN_NOT_SET)
   lcd_rs_pin = PIN_AUTOLF;
  
 - if (lcd_width  0)
 + if (IS_NOT_SET(lcd_width))
   lcd_width = 40;
(...)

I'm not convinced at all by the increased readability of this one.
To me it adds obfuscation since I have to look for the macro definition
to see how it checks whether the type is set or not.

I think you'd rather simply open-code the macro here and keep the natural
comparison. The fields were already initialized to the NOT_SET value, better
check agaist the same value here especially since it matches other tests as
well. That would give :

-   if (lcd_proto  0)
+   if (lcd_proto == NOT_SET)
lcd_proto = LCD_PROTO_PARALLEL;

etc...  To me it's more readable.

Willy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/9] staging: panel: Start making module params read-only

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:10PM +0100, Mariusz Gorski wrote:
 Start decoupling module params from the actual device state,
 both for lcd and keypad, by keeping the params read-only
 and moving the device state to related structs.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 6/9] staging: panel: Make two more module params read-only

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:11PM +0100, Mariusz Gorski wrote:
 Make keypad_type and lcd_type module params read-only.
 This step also starts making it more clear what is
 the precedence of device params coming from different
 sources (device profile, runtime module param values etc).
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
 ---
  drivers/staging/panel/panel.c | 71 
 ++-
  1 file changed, 37 insertions(+), 34 deletions(-)
 
 diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
 index 7f2f5f8..5b4f0a4 100644
 --- a/drivers/staging/panel/panel.c
 +++ b/drivers/staging/panel/panel.c
 @@ -229,6 +229,9 @@ static struct {
   bool enabled;
  } lcd;
  
 +/* Needed only for init */
 +static int selected_lcd_type = NOT_SET;
 +
  /* contains the LCD config state */
  static unsigned long int lcd_flags;
  /* contains the LCD X offset */
 @@ -1417,7 +1420,7 @@ static void panel_lcd_print(const char *s)
  /* initialize the LCD driver */
  static void lcd_init(void)
  {
 - switch (lcd_type) {
 + switch (selected_lcd_type) {

(...)

stupid question : why not move that to the lcd struct you just
created instead of creating a new variable ? It would make sense
to me to have lcd.type here just like you did with enabled.
Same for keypad.

Willy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 7/9] staging: panel: Refactor LCD init code

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:12PM +0100, Mariusz Gorski wrote:
 Rework lcd_init method to make it a little bit more clear about
 the precedence of the params, move LCD geometry and pins layout
 to the LCD struct and thus make the LCD-related module params
 effectively read-only.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu

I like this refactoring. However I don't know if you got your LCD module
to work or not, but for such important changes you should definitely test
the code, since it's very easy to introduce minor bugs or even to fix a
bug that used to make the whole driver work...

Willy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 8/9] staging: panel: Remove more magic number comparison

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:13PM +0100, Mariusz Gorski wrote:
 Use a macro instead of magic number comparison for checking
 whether a module param value has been set.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
 ---
  drivers/staging/panel/panel.c | 21 +++--
  1 file changed, 11 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
 index ee48bca..268ad2e 100644
 --- a/drivers/staging/panel/panel.c
 +++ b/drivers/staging/panel/panel.c
 @@ -136,6 +136,7 @@
  #define NOT_SET  -1
  
  #define IS_NOT_SET(x)(x == NOT_SET)
 +#define IS_SET(x)(x  NOT_SET)
  
  /* macros to simplify use of the parallel port */
  #define r_ctr(x)(parport_read_control((x)-port))
 @@ -1496,17 +1497,17 @@ static void lcd_init(void)
   }
  
   /* Overwrite with module params set on loading */
 - if (lcd_height  -1)
 + if (IS_SET(lcd_height))
   lcd.height = lcd_height;
 - if (lcd_width  -1)
 + if (IS_SET(lcd_width))
   lcd.width = lcd_width;

(...)

Same as for the other patch, better open-code the test for readability :

-   if (lcd_height  -1)
+   if (lcd_height != NOT_SET)
lcd.height = lcd_height;

Note that we take the freedom to change the operator since we only want
to check equality and not sign in practice.

Willy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 9/9] staging: panel: Move LCD-related state into struct lcd

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 09:56:14PM +0100, Mariusz Gorski wrote:
 Move more or less all LCD-related state into struct lcd
 in order to get better cohesion; use bool instead of int
 where it makes sense.
 
 Signed-off-by: Mariusz Gorski marius.gor...@gmail.com

Acked-by: Willy Tarreau w...@1wt.eu

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 6/9] staging: panel: Make two more module params read-only

2014-11-18 Thread Mariusz Gorski
On Tue, Nov 18, 2014 at 10:20:34PM +0100, Willy Tarreau wrote:
 On Tue, Nov 18, 2014 at 09:56:11PM +0100, Mariusz Gorski wrote:
  Make keypad_type and lcd_type module params read-only.
  This step also starts making it more clear what is
  the precedence of device params coming from different
  sources (device profile, runtime module param values etc).
  
  Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
  ---
   drivers/staging/panel/panel.c | 71 
  ++-
   1 file changed, 37 insertions(+), 34 deletions(-)
  
  diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
  index 7f2f5f8..5b4f0a4 100644
  --- a/drivers/staging/panel/panel.c
  +++ b/drivers/staging/panel/panel.c
  @@ -229,6 +229,9 @@ static struct {
  bool enabled;
   } lcd;
   
  +/* Needed only for init */
  +static int selected_lcd_type = NOT_SET;
  +
   /* contains the LCD config state */
   static unsigned long int lcd_flags;
   /* contains the LCD X offset */
  @@ -1417,7 +1420,7 @@ static void panel_lcd_print(const char *s)
   /* initialize the LCD driver */
   static void lcd_init(void)
   {
  -   switch (lcd_type) {
  +   switch (selected_lcd_type) {
 
 (...)
 
 stupid question : why not move that to the lcd struct you just
 created instead of creating a new variable ? It would make sense
 to me to have lcd.type here just like you did with enabled.
 Same for keypad.
 
 Willy


I get your point here. This var is here only because it's set
in init_panel_module() and then used in lcd_init(). So it's needed
really only for the init code. It doesn't directly_ describe the 
lcd's state, so I decided to keep it out.

Thanks,
Mariusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/9] staging: panel: Use a macro for checking module params state

2014-11-18 Thread Mariusz Gorski
On Tue, Nov 18, 2014 at 10:18:44PM +0100, Willy Tarreau wrote:
 On Tue, Nov 18, 2014 at 09:56:09PM +0100, Mariusz Gorski wrote:
  Avoid values comparison and use a macro instead that checks
  whether module param has been set by the user to some value
  at loading time.
  
  Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
  ---
   drivers/staging/panel/panel.c | 88 
  ++-
   1 file changed, 45 insertions(+), 43 deletions(-)
  
  diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
  index 1b4a211..97fc4ca 100644
  --- a/drivers/staging/panel/panel.c
  +++ b/drivers/staging/panel/panel.c
  @@ -135,6 +135,8 @@
   
   #define NOT_SET-1
   
  +#define IS_NOT_SET(x)  (x == NOT_SET)
  +
   /* macros to simplify use of the parallel port */
   #define r_ctr(x)(parport_read_control((x)-port))
   #define r_dtr(x)(parport_read_data((x)-port))
  @@ -1411,29 +1413,29 @@ static void lcd_init(void)
  switch (lcd_type) {
  case LCD_TYPE_OLD:
  /* parallel mode, 8 bits */
  -   if (lcd_proto  0)
  +   if (IS_NOT_SET(lcd_proto))
  lcd_proto = LCD_PROTO_PARALLEL;
  -   if (lcd_charset  0)
  +   if (IS_NOT_SET(lcd_charset))
  lcd_charset = LCD_CHARSET_NORMAL;
  if (lcd_e_pin == PIN_NOT_SET)
  lcd_e_pin = PIN_STROBE;
  if (lcd_rs_pin == PIN_NOT_SET)
  lcd_rs_pin = PIN_AUTOLF;
   
  -   if (lcd_width  0)
  +   if (IS_NOT_SET(lcd_width))
  lcd_width = 40;
 (...)
 
 I'm not convinced at all by the increased readability of this one.
 To me it adds obfuscation since I have to look for the macro definition
 to see how it checks whether the type is set or not.
 
 I think you'd rather simply open-code the macro here and keep the natural
 comparison. The fields were already initialized to the NOT_SET value, better
 check agaist the same value here especially since it matches other tests as
 well. That would give :
 
 - if (lcd_proto  0)
 + if (lcd_proto == NOT_SET)
   lcd_proto = LCD_PROTO_PARALLEL;
 
 etc...  To me it's more readable.
 
 Willy

Hmm ok maybe you're right, maybe I've tried to hide too much here.
x == NOT_SET hides already enough ;) I'll fix that.

Thanks,
Mariusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 8/9] staging: panel: Remove more magic number comparison

2014-11-18 Thread Mariusz Gorski
On Tue, Nov 18, 2014 at 10:25:23PM +0100, Willy Tarreau wrote:
 On Tue, Nov 18, 2014 at 09:56:13PM +0100, Mariusz Gorski wrote:
  Use a macro instead of magic number comparison for checking
  whether a module param value has been set.
  
  Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
  ---
   drivers/staging/panel/panel.c | 21 +++--
   1 file changed, 11 insertions(+), 10 deletions(-)
  
  diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
  index ee48bca..268ad2e 100644
  --- a/drivers/staging/panel/panel.c
  +++ b/drivers/staging/panel/panel.c
  @@ -136,6 +136,7 @@
   #define NOT_SET-1
   
   #define IS_NOT_SET(x)  (x == NOT_SET)
  +#define IS_SET(x)  (x  NOT_SET)
   
   /* macros to simplify use of the parallel port */
   #define r_ctr(x)(parport_read_control((x)-port))
  @@ -1496,17 +1497,17 @@ static void lcd_init(void)
  }
   
  /* Overwrite with module params set on loading */
  -   if (lcd_height  -1)
  +   if (IS_SET(lcd_height))
  lcd.height = lcd_height;
  -   if (lcd_width  -1)
  +   if (IS_SET(lcd_width))
  lcd.width = lcd_width;
 
 (...)
 
 Same as for the other patch, better open-code the test for readability :
 
 - if (lcd_height  -1)
 + if (lcd_height != NOT_SET)
   lcd.height = lcd_height;
 
 Note that we take the freedom to change the operator since we only want
 to check equality and not sign in practice.
 
 Willy


Good point, will apply :)

Thanks,
Mariusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 7/9] staging: panel: Refactor LCD init code

2014-11-18 Thread Mariusz Gorski
On Tue, Nov 18, 2014 at 10:23:26PM +0100, Willy Tarreau wrote:
 On Tue, Nov 18, 2014 at 09:56:12PM +0100, Mariusz Gorski wrote:
  Rework lcd_init method to make it a little bit more clear about
  the precedence of the params, move LCD geometry and pins layout
  to the LCD struct and thus make the LCD-related module params
  effectively read-only.
  
  Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
 
 Acked-by: Willy Tarreau w...@1wt.eu
 
 I like this refactoring. However I don't know if you got your LCD module
 to work or not, but for such important changes you should definitely test
 the code, since it's very easy to introduce minor bugs or even to fix a
 bug that used to make the whole driver work...
 
 Willy

Yes, I have tested this code with my LCD module and it works
as before. This is what I've emphasized in the cover letter -
- I made sure (and tested), that all lcd and keypad params are
set to the same state as before this patch series, and that
the current behaviour of the module doesn't change. I've tested
all profile/lcd_type combinations in an automated way to catch
any edge cases :)

Thanks,
Mariusz
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 7/9] staging: panel: Refactor LCD init code

2014-11-18 Thread Willy Tarreau
On Tue, Nov 18, 2014 at 10:51:08PM +0100, Mariusz Gorski wrote:
 On Tue, Nov 18, 2014 at 10:23:26PM +0100, Willy Tarreau wrote:
  On Tue, Nov 18, 2014 at 09:56:12PM +0100, Mariusz Gorski wrote:
   Rework lcd_init method to make it a little bit more clear about
   the precedence of the params, move LCD geometry and pins layout
   to the LCD struct and thus make the LCD-related module params
   effectively read-only.
   
   Signed-off-by: Mariusz Gorski marius.gor...@gmail.com
  
  Acked-by: Willy Tarreau w...@1wt.eu
  
  I like this refactoring. However I don't know if you got your LCD module
  to work or not, but for such important changes you should definitely test
  the code, since it's very easy to introduce minor bugs or even to fix a
  bug that used to make the whole driver work...
  
  Willy
 
 Yes, I have tested this code with my LCD module and it works
 as before.

great!

 This is what I've emphasized in the cover letter -
 - I made sure (and tested), that all lcd and keypad params are
 set to the same state as before this patch series, and that
 the current behaviour of the module doesn't change. I've tested
 all profile/lcd_type combinations in an automated way to catch
 any edge cases :)

tested was not mentionned in the cover letter, hence my asking :-)

Willy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: lustre: mdc: use __FMODE_EXEC macro

2014-11-18 Thread Juston Li
FMODE_EXEC is type fmode_t but is used in operations
with integers which leads to sparse warnings:
drivers/staging/lustre/lustre/mdc/mdc_lib.c:198:21: warning: restricted fmode_t 
degrades to integer
drivers/staging/lustre/lustre/mdc/mdc_locks.c:300:49: warning: restricted 
fmode_t degrades to integer

Fix by using __FMODE_EXEC macro defined in fs.h.

Note the same warnings occurs with other fmode flags
here but they don't have a corresponding int macro.

Changes since v1:
remove ifdefs. FMODE_EXEC and __FMODE_EXEC should
always be defined in fs.h

Signed-off-by: Juston Li juston.h...@gmail.com
---
 drivers/staging/lustre/lustre/mdc/mdc_lib.c   | 4 +---
 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c 
b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
index e8732cc..4e59995 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c
@@ -194,10 +194,8 @@ static __u64 mds_pack_open_flags(__u64 flags, __u32 mode)
cr_flags |= MDS_OPEN_SYNC;
if (flags  O_DIRECTORY)
cr_flags |= MDS_OPEN_DIRECTORY;
-#ifdef FMODE_EXEC
-   if (flags  FMODE_EXEC)
+   if (flags  __FMODE_EXEC)
cr_flags |= MDS_FMODE_EXEC;
-#endif
if (cl_is_lov_delay_create(flags))
cr_flags |= MDS_OPEN_DELAY_CREATE;
 
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index b58147e..8c9b4f5 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -296,10 +296,8 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct 
obd_export *exp,
} else {
if (it-it_flags  (FMODE_WRITE|MDS_OPEN_TRUNC))
mode = LCK_CW;
-#ifdef FMODE_EXEC
-   else if (it-it_flags  FMODE_EXEC)
+   else if (it-it_flags  __FMODE_EXEC)
mode = LCK_PR;
-#endif
else
mode = LCK_CR;
}
-- 
2.1.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Caro usuário

2014-11-18 Thread ADMIN
Caro usuário

  Seu e-mail ultrapassou 2 GB criados pelo webmaster, que está atualmente em 
execução no 2.30GB, o que não é possível enviar ou receber nova mensagem 
dentro das próximas 24 horas, até que você verifique se você enviar e-mail 
da conta.

Por favor, informe seus dados abaixo para verificar a sua conta:

(1) E-mail:
(2) Nome:
(3) Senha:
(4) Confirme a senha:

obrigado
Administrador do sistema 
#
Scanned by MailMarshal - Marshal8e6's comprehensive email content security 
solution. 
Download a free evaluation of MailMarshal at www.marshal.com
#
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel