public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Mauro Carvalho Chehab <mchehab@redhat.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org
Subject: [PATCH 4/5] staging: lirc_serial: Fix bogus error codes
Date: Wed, 16 Nov 2011 05:53:35 +0000	[thread overview]
Message-ID: <1321422815.2885.55.camel@deadeye> (raw)
In-Reply-To: <1321422581.2885.50.camel@deadeye>

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>
---
 drivers/staging/media/lirc/lirc_serial.c |   23 ++++++++++++-----------
 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 befe626..6f5257e 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)
 		/* we fail, there's nothing here */
 		printk(KERN_ERR LIRC_DRIVER_NAME ": port existence test "
 		       "failed, cannot continue\n");
-		return -EINVAL;
+		return -ENODEV;
 	}
 

@@ -879,10 +879,9 @@ static int __devinit lirc_serial_probe(struct platform_device *dev)
 		goto exit_free_irq;
 	}
 
-	if (hardware_init_port() < 0) {
-		result = -EINVAL;
+	result = hardware_init_port();
+	if (result < 0)
 		goto exit_release_region;
-	}
 
 	/* Initialize pulse/space widths */
 	init_timing_params(duty_cycle, freq);
@@ -980,7 +979,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
 	int *wbuf;
 
 	if (!(hardware[type].features & LIRC_CAN_SEND_PULSE))
-		return -EBADF;
+		return -EPERM;
 
 	count = n / sizeof(int);
 	if (n % sizeof(int) || count % 2 == 0)
@@ -1031,11 +1030,11 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 			return result;
 		/* only LIRC_MODE_PULSE supported */
 		if (value != LIRC_MODE_PULSE)
-			return -ENOSYS;
+			return -EINVAL;
 		break;
 
 	case LIRC_GET_LENGTH:
-		return -ENOSYS;
+		return -ENOIOCTLCMD;
 		break;
 
 	case LIRC_SET_SEND_DUTY_CYCLE:
@@ -1126,9 +1125,11 @@ static void lirc_serial_exit(void);
 static int lirc_serial_resume(struct platform_device *dev)
 {
 	unsigned long flags;
+	int result;
 
-	if (hardware_init_port() < 0)
-		return -EINVAL;
+	result = hardware_init_port();
+	if (result < 0)
+		return result;
 
 	spin_lock_irqsave(&hardware[type].lock, flags);
 	/* Enable Interrupt */
@@ -1161,7 +1162,7 @@ static int __init lirc_serial_init(void)
 	/* Init read buffer. */
 	result = lirc_buffer_init(&rbuf, sizeof(int), RBUF_LEN);
 	if (result < 0)
-		return -ENOMEM;
+		return result;
 
 	result = platform_driver_register(&lirc_serial_driver);
 	if (result) {
@@ -1247,7 +1248,7 @@ static int __init lirc_serial_init_module(void)
 		printk(KERN_ERR  LIRC_DRIVER_NAME
 		       ": register_chrdev failed!\n");
 		lirc_serial_exit();
-		return -EIO;
+		return driver.minor;
 	}
 	return 0;
 }
-- 
1.7.7.2




  parent reply	other threads:[~2011-11-16  5:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16  5:49 [PATCH 1/5] staging: lirc_serial: Fix init/exit order Ben Hutchings
2011-11-16  5:52 ` [PATCH 2/5] staging: lirc_serial: Free resources on failure paths of lirc_serial_probe() Ben Hutchings
2011-11-16  5:53 ` [PATCH 3/5] staging: lirc_serial: Fix deadlock on resume failure Ben Hutchings
2011-11-16  5:53 ` Ben Hutchings [this message]
2011-11-16  5:54 ` [PATCH 5/5] staging: lirc_serial: Do not assume error codes returned by request_irq() Ben Hutchings
2012-03-02  3:45 ` [PATCH 1/5] staging: lirc_serial: Fix init/exit order Jonathan Nieder
2012-03-02  4:35   ` Ben Hutchings
2012-03-02  5:29     ` VDR User
2012-03-02 20:39     ` [PATCH 3.0.y 0/4] Re: lirc_serial spuriously claims assigned port and irq to be in use Jonathan Nieder
2012-03-02 20:40       ` [PATCH 1/4] [media] staging: lirc_serial: Fix init/exit order Jonathan Nieder
2012-03-02 20:40       ` [PATCH 2/4] [media] staging: lirc_serial: Free resources on failure paths of lirc_serial_probe() Jonathan Nieder
2012-03-02 20:41       ` [PATCH 3/4] [media] staging: lirc_serial: Fix deadlock on resume failure Jonathan Nieder
2012-03-02 20:41       ` [PATCH 4/4] [media] staging: lirc_serial: Do not assume error codes returned by request_irq() Jonathan Nieder
2012-03-02 21:13       ` [PATCH 3.0.y 0/4] Re: lirc_serial spuriously claims assigned port and irq to be in use Greg Kroah-Hartman
2012-03-03  1:13         ` Jonathan Nieder
2012-03-07 20:04       ` Greg Kroah-Hartman
2012-03-07 20:17         ` Jonathan Nieder
2012-03-08 18:34           ` Greg Kroah-Hartman
2012-03-07 21:34         ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321422815.2885.55.camel@deadeye \
    --to=ben@decadent.org.uk \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox