mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] parport: fix inverted daisy selection result check
@ 2026-06-24  1:36 Yang Shao
  2026-07-27  7:00 ` Yang Shao
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Shao @ 2026-06-24  1:36 UTC (permalink / raw)
  To: sudipm.mukherjee
  Cc: marko.kohtala, akpm, linux-kernel, kernel, Yang Shao, stable

parport_daisy_select() returns a boolean success result. It returns 1
when the requested daisy-chain device acknowledges the CPP selection
command and 0 otherwise.

Commit 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return
value fix") changed the helper from returning the raw
PARPORT_STATUS_ERROR bit to returning its logical negation. Selection
success therefore changed from a zero return value to a nonzero return
value, but parport_claim() retained the old zero-is-success test.

As a result, a successful selection does not update port->daisy, while
an unsuccessful selection can be recorded as the currently selected
daisy address. parport_open() later checks port->daisy to determine
whether the requested device was successfully selected, so this can
reject an existing device or accept a device address that was not
selected.

Test the return value directly and update port->daisy only after a
successful selection.

Fixes: 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return value fix")
Cc: stable@vger.kernel.org
Signed-off-by: Yang Shao <shaoyang@uniontech.com>
---
 drivers/parport/share.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index c4c5869..2888005 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -1025,8 +1025,8 @@ int parport_claim(struct pardevice *dev)
 	/* If it's a daisy chain device, select it. */
 	if (dev->daisy >= 0) {
 		/* This could be lazier. */
-		if (!parport_daisy_select(port, dev->daisy,
-					   IEEE1284_MODE_COMPAT))
+		if (parport_daisy_select(port, dev->daisy,
+					 IEEE1284_MODE_COMPAT))
 			port->daisy = dev->daisy;
 	}
 #endif /* IEEE1284.3 support */
--
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] parport: fix inverted daisy selection result check
  2026-06-24  1:36 [PATCH] parport: fix inverted daisy selection result check Yang Shao
@ 2026-07-27  7:00 ` Yang Shao
  2026-07-27 13:59   ` Marko Kohtala
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Shao @ 2026-07-27  7:00 UTC (permalink / raw)
  To: shaoyang
  Cc: akpm, kernel, linux-kernel, marko.kohtala, stable, sudipm.mukherjee

parport_daisy_select() returns a boolean success result. It returns 1
when the requested daisy-chain device acknowledges the CPP selection
command and 0 otherwise.

Commit 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return
value fix") changed the helper from returning the raw
PARPORT_STATUS_ERROR bit to returning its logical negation. Selection
success therefore changed from a zero return value to a nonzero return
value, but parport_claim() retained the old zero-is-success test.

As a result, a successful selection does not update port->daisy, while
an unsuccessful selection can be recorded as the currently selected
daisy address. parport_open() later checks port->daisy to determine
whether the requested device was successfully selected, so this can
reject an existing device or accept a device address that was not
selected.

Test the return value directly and update port->daisy only after a
successful selection.

Fixes: 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return value fix")
Cc: stable@vger.kernel.org
Signed-off-by: Yang Shao <shaoyang@uniontech.com>
---
 drivers/parport/share.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index c4c5869..2888005 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -1025,8 +1025,8 @@ int parport_claim(struct pardevice *dev)
 	/* If it's a daisy chain device, select it. */
 	if (dev->daisy >= 0) {
 		/* This could be lazier. */
-		if (!parport_daisy_select(port, dev->daisy,
-					   IEEE1284_MODE_COMPAT))
+		if (parport_daisy_select(port, dev->daisy,
+					 IEEE1284_MODE_COMPAT))
 			port->daisy = dev->daisy;
 	}
 #endif /* IEEE1284.3 support */
--
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] parport: fix inverted daisy selection result check
  2026-07-27  7:00 ` Yang Shao
@ 2026-07-27 13:59   ` Marko Kohtala
  0 siblings, 0 replies; 3+ messages in thread
From: Marko Kohtala @ 2026-07-27 13:59 UTC (permalink / raw)
  To: Yang Shao
  Cc: akpm, kernel, linux-kernel, stable, sudipm.mukherjee, linux-parport

Hi.

My guess from this 20 year old commit 7c9cc3be1094 of mine is that I
had thought the response nError signal was read at the wrong time. The
return value was not intended to change when it was read at the
correct time, but it was inverted to keep it the same.

I don't have the IEEE 1284 specifications and datasheet available.
Here is what I think is happening: The parport_frob_control
PARPORT_CONTROL_STROBE bit is inverted into the bus signal. The
parport_read_status PARPORT_STATUS_ERROR bit is not inverted and shows
directly the bus signal. After the wake up sequence of aa, 55, 00, ff,
the PARPORT_STATUS_ERROR is verified to be 1. Again, after the 0x87 it
is verified to be 1. After the nStrobe signal goes low, the nError is
read for acknowledgement while nStrobe is still low. The command is
most likely acknowledged with a different PARPORT_STATUS_ERROR value
of 0, so the return value of parport_daisy_select is now 1 for a
success. I probably had a setup where parport_daisy_select had
returned PARPORT_STATUS_ERROR in the same situation due to reading the
bit after nStrobe was back up.

I only had one daisy chain device. It is possible the return value of
parport_daisy_select was changed and I did not notice the difference.

I think one could consider returning the parport_daisy_select return
value to the original value rather than spread the change further.
It's been like this for 20 years, so there could be some other work
depending on this.

I see the linux-parport@lists.infradead.org is not in the recipients.
They might have an opinion on this.

Marko


ma 27.7.2026 klo 10.01 Yang Shao (shaoyang@uniontech.com) kirjoitti:
>
> parport_daisy_select() returns a boolean success result. It returns 1
> when the requested daisy-chain device acknowledges the CPP selection
> command and 0 otherwise.
>
> Commit 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return
> value fix") changed the helper from returning the raw
> PARPORT_STATUS_ERROR bit to returning its logical negation. Selection
> success therefore changed from a zero return value to a nonzero return
> value, but parport_claim() retained the old zero-is-success test.
>
> As a result, a successful selection does not update port->daisy, while
> an unsuccessful selection can be recorded as the currently selected
> daisy address. parport_open() later checks port->daisy to determine
> whether the requested device was successfully selected, so this can
> reject an existing device or accept a device address that was not
> selected.
>
> Test the return value directly and update port->daisy only after a
> successful selection.
>
> Fixes: 7c9cc3be1094 ("[PATCH] parport: parport_daisy_select return value fix")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yang Shao <shaoyang@uniontech.com>
> ---
>  drivers/parport/share.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/parport/share.c b/drivers/parport/share.c
> index c4c5869..2888005 100644
> --- a/drivers/parport/share.c
> +++ b/drivers/parport/share.c
> @@ -1025,8 +1025,8 @@ int parport_claim(struct pardevice *dev)
>         /* If it's a daisy chain device, select it. */
>         if (dev->daisy >= 0) {
>                 /* This could be lazier. */
> -               if (!parport_daisy_select(port, dev->daisy,
> -                                          IEEE1284_MODE_COMPAT))
> +               if (parport_daisy_select(port, dev->daisy,
> +                                        IEEE1284_MODE_COMPAT))
>                         port->daisy = dev->daisy;
>         }
>  #endif /* IEEE1284.3 support */
> --
> 2.47.3
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-27 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-24  1:36 [PATCH] parport: fix inverted daisy selection result check Yang Shao
2026-07-27  7:00 ` Yang Shao
2026-07-27 13:59   ` Marko Kohtala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®