All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nirbhay Sharma <nirbhay.lkd@gmail.com>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: linux1394-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	david.hunter.linux@gmail.com,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Nirbhay Sharma <nirbhay.lkd@gmail.com>
Subject: [PATCH] firewire: Replace ENOSYS with appropriate error codes
Date: Mon, 17 Nov 2025 16:39:01 +0530	[thread overview]
Message-ID: <20251117110901.686828-1-nirbhay.lkd@gmail.com> (raw)

ENOSYS is reserved for "invalid syscall number" and should not be used
for other error conditions. Replace incorrect usages with more
appropriate error codes:

- In sbp2.c: Use -EOPNOTSUPP for unsupported operation (re-adding
  logical units via SCSI stack).

- In ohci.c: Use -EINVAL for invalid ISO context types in switch
  statements, and -EOPNOTSUPP for unsupported Pinnacle MovieBoard
  hardware.

- In core-cdev.c: Use -EACCES for access policy violations when
  operations are restricted to local nodes' device files.

Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com>
---
 drivers/firewire/core-cdev.c | 6 +++---
 drivers/firewire/ohci.c      | 8 ++++----
 drivers/firewire/sbp2.c      | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 49dc1612c691..a62ac2f02c49 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -935,7 +935,7 @@ static int ioctl_add_descriptor(struct client *client, union ioctl_arg *arg)
 
 	/* Access policy: Allow this ioctl only on local nodes' device files. */
 	if (!client->device->is_local)
-		return -ENOSYS;
+		return -EACCES;
 
 	if (a->length > 256)
 		return -EINVAL;
@@ -1628,7 +1628,7 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
 
 	/* Access policy: Allow this ioctl only on local nodes' device files. */
 	if (!client->device->is_local)
-		return -ENOSYS;
+		return -EACCES;
 
 	e = kzalloc(sizeof(*e) + sizeof(a->data), GFP_KERNEL);
 	if (e == NULL)
@@ -1676,7 +1676,7 @@ static int ioctl_receive_phy_packets(struct client *client, union ioctl_arg *arg
 
 	/* Access policy: Allow this ioctl only on local nodes' device files. */
 	if (!client->device->is_local)
-		return -ENOSYS;
+		return -EACCES;
 
 	// NOTE: This can be without irq when we can guarantee that __fw_send_request() for local
 	// destination never runs in any type of IRQ context.
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 030aed5453a1..15aec93b42fb 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -2918,7 +2918,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card,
 
 		default:
 			index = -1;
-			ret = -ENOSYS;
+			ret = -EINVAL;
 		}
 
 		if (index < 0)
@@ -3370,7 +3370,7 @@ static int ohci_queue_iso(struct fw_iso_context *base,
 	case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
 		return queue_iso_buffer_fill(ctx, packet, buffer, payload);
 	default:
-		return -ENOSYS;
+		return -EINVAL;
 	}
 }
 
@@ -3401,7 +3401,7 @@ static int ohci_flush_iso_completions(struct fw_iso_context *base)
 				flush_ir_buffer_fill(ctx);
 			break;
 		default:
-			ret = -ENOSYS;
+			ret = -EINVAL;
 		}
 
 		clear_bit_unlock(0, &ctx->flushing_completions);
@@ -3485,7 +3485,7 @@ static int pci_probe(struct pci_dev *dev,
 
 	if (dev->vendor == PCI_VENDOR_ID_PINNACLE_SYSTEMS) {
 		dev_err(&dev->dev, "Pinnacle MovieBoard is not yet supported\n");
-		return -ENOSYS;
+		return -EOPNOTSUPP;
 	}
 
 	ohci = devres_alloc(release_ohci, sizeof(*ohci), GFP_KERNEL);
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 1a19828114cf..2e17402466e2 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1496,7 +1496,7 @@ static int sbp2_scsi_sdev_init(struct scsi_device *sdev)
 
 	/* (Re-)Adding logical units via the SCSI stack is not supported. */
 	if (!lu)
-		return -ENOSYS;
+		return -EOPNOTSUPP;
 
 	sdev->allow_restart = 1;
 
-- 
2.48.1


             reply	other threads:[~2025-11-17 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 11:09 Nirbhay Sharma [this message]
2025-11-17 11:31 ` [PATCH] firewire: Replace ENOSYS with appropriate error codes Takashi Sakamoto
2025-11-19  4:51   ` Nirbhay Sharma

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=20251117110901.686828-1-nirbhay.lkd@gmail.com \
    --to=nirbhay.lkd@gmail.com \
    --cc=david.hunter.linux@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=o-takashi@sakamocchi.jp \
    --cc=skhan@linuxfoundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.