aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2011-11-15 23:53:35 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-24 15:18:05 -0500
commit9b98d60679711753e548be15c6bef5239db6ed64 (patch)
tree3257eeabc23c4f39deff7c8ecf09a53fe465ec9d /drivers/staging
parent1ff1d88e862948ae5bfe490248c023ff8ac2855d (diff)
[media] staging: lirc_serial: Fix bogus error codes
Device not found? ENODEV, not EINVAL. Write to read-only device? EPERM, not EBADF. Invalid argument? EINVAL, not ENOSYS. Unsupported ioctl? ENOIOCTLCMD, not ENOSYS. Another function returned an error code? Use that, don't replace it. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/lirc/lirc_serial.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c
index befe6267d7cb..6f5257e68724 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -773,7 +773,7 @@ static int hardware_init_port(void)
773 /* we fail, there's nothing here */ 773 /* we fail, there's nothing here */
774 printk(KERN_ERR LIRC_DRIVER_NAME ": port existence test " 774 printk(KERN_ERR LIRC_DRIVER_NAME ": port existence test "
775 "failed, cannot continue\n"); 775 "failed, cannot continue\n");
776 return -EINVAL; 776 return -ENODEV;
777 } 777 }
778 778
779 779
@@ -879,10 +879,9 @@ static int __devinit lirc_serial_probe(struct platform_device *dev)
879 goto exit_free_irq; 879 goto exit_free_irq;
880 } 880 }
881 881
882 if (hardware_init_port() < 0) { 882 result = hardware_init_port();
883 result = -EINVAL; 883 if (result < 0)
884 goto exit_release_region; 884 goto exit_release_region;
885 }
886 885
887 /* Initialize pulse/space widths */ 886 /* Initialize pulse/space widths */
888 init_timing_params(duty_cycle, freq); 887 init_timing_params(duty_cycle, freq);
@@ -980,7 +979,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
980 int *wbuf; 979 int *wbuf;
981 980
982 if (!(hardware[type].features & LIRC_CAN_SEND_PULSE)) 981 if (!(hardware[type].features & LIRC_CAN_SEND_PULSE))
983 return -EBADF; 982 return -EPERM;
984 983
985 count = n / sizeof(int); 984 count = n / sizeof(int);
986 if (n % sizeof(int) || count % 2 == 0) 985 if (n % sizeof(int) || count % 2 == 0)
@@ -1031,11 +1030,11 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1031 return result; 1030 return result;
1032 /* only LIRC_MODE_PULSE supported */ 1031 /* only LIRC_MODE_PULSE supported */
1033 if (value != LIRC_MODE_PULSE) 1032 if (value != LIRC_MODE_PULSE)
1034 return -ENOSYS; 1033 return -EINVAL;
1035 break; 1034 break;
1036 1035
1037 case LIRC_GET_LENGTH: 1036 case LIRC_GET_LENGTH:
1038 return -ENOSYS; 1037 return -ENOIOCTLCMD;
1039 break; 1038 break;
1040 1039
1041 case LIRC_SET_SEND_DUTY_CYCLE: 1040 case LIRC_SET_SEND_DUTY_CYCLE:
@@ -1126,9 +1125,11 @@ static void lirc_serial_exit(void);
1126static int lirc_serial_resume(struct platform_device *dev) 1125static int lirc_serial_resume(struct platform_device *dev)
1127{ 1126{
1128 unsigned long flags; 1127 unsigned long flags;
1128 int result;
1129 1129
1130 if (hardware_init_port() < 0) 1130 result = hardware_init_port();
1131 return -EINVAL; 1131 if (result < 0)
1132 return result;
1132 1133
1133 spin_lock_irqsave(&hardware[type].lock, flags); 1134 spin_lock_irqsave(&hardware[type].lock, flags);
1134 /* Enable Interrupt */ 1135 /* Enable Interrupt */
@@ -1161,7 +1162,7 @@ static int __init lirc_serial_init(void)
1161 /* Init read buffer. */ 1162 /* Init read buffer. */
1162 result = lirc_buffer_init(&rbuf, sizeof(int), RBUF_LEN); 1163 result = lirc_buffer_init(&rbuf, sizeof(int), RBUF_LEN);
1163 if (result < 0) 1164 if (result < 0)
1164 return -ENOMEM; 1165 return result;
1165 1166
1166 result = platform_driver_register(&lirc_serial_driver); 1167 result = platform_driver_register(&lirc_serial_driver);
1167 if (result) { 1168 if (result) {
@@ -1247,7 +1248,7 @@ static int __init lirc_serial_init_module(void)
1247 printk(KERN_ERR LIRC_DRIVER_NAME 1248 printk(KERN_ERR LIRC_DRIVER_NAME
1248 ": register_chrdev failed!\n"); 1249 ": register_chrdev failed!\n");
1249 lirc_serial_exit(); 1250 lirc_serial_exit();
1250 return -EIO; 1251 return driver.minor;
1251 } 1252 }
1252 return 0; 1253 return 0;
1253} 1254}