diff mbox series

[1/2] usb: musb: Simplify cable state handling

Message ID 20210604080536.12185-1-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series [1/2] usb: musb: Simplify cable state handling | expand

Commit Message

Tony Lindgren June 4, 2021, 8:05 a.m. UTC
Simplify cable state handling a bit to leave out duplicated code.
We are just scheduling work and showing state info if a recheck is
needed. No intended functional changes.

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andreas Kemnade <andreas@kemnade.info>
Cc: Bhushan Shah <bshah@kde.org>
Cc: Drew Fustini <drew@beagleboard.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

Comments

Greg Kroah-Hartman June 9, 2021, 9:26 a.m. UTC | #1
On Fri, Jun 04, 2021 at 11:05:35AM +0300, Tony Lindgren wrote:
> Simplify cable state handling a bit to leave out duplicated code.
> We are just scheduling work and showing state info if a recheck is
> needed. No intended functional changes.
> 
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Andreas Kemnade <andreas@kemnade.info>
> Cc: Bhushan Shah <bshah@kde.org>
> Cc: Drew Fustini <drew@beagleboard.org>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++------------------
>  1 file changed, 20 insertions(+), 20 deletions(-)

Does not apply to my usb-next branch, what tree/branch did you make this
against?

thanks,

greg k-h
Tony Lindgren June 9, 2021, noon UTC | #2
* Greg Kroah-Hartman <gregkh@linuxfoundation.org> [210609 09:26]:
> On Fri, Jun 04, 2021 at 11:05:35AM +0300, Tony Lindgren wrote:
> > Simplify cable state handling a bit to leave out duplicated code.
> > We are just scheduling work and showing state info if a recheck is
> > needed. No intended functional changes.
> > 
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Andreas Kemnade <andreas@kemnade.info>
> > Cc: Bhushan Shah <bshah@kde.org>
> > Cc: Drew Fustini <drew@beagleboard.org>
> > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++------------------
> >  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> Does not apply to my usb-next branch, what tree/branch did you make this
> against?

This was against Linux next last week, I'll take a look and
repost.

Regards,

Tony
Tony Lindgren June 11, 2021, 5:17 a.m. UTC | #3
* Tony Lindgren <tony@atomide.com> [210609 12:00]:
> * Greg Kroah-Hartman <gregkh@linuxfoundation.org> [210609 09:26]:
> > On Fri, Jun 04, 2021 at 11:05:35AM +0300, Tony Lindgren wrote:
> > > Simplify cable state handling a bit to leave out duplicated code.
> > > We are just scheduling work and showing state info if a recheck is
> > > needed. No intended functional changes.
> > > 
> > > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > Cc: Andreas Kemnade <andreas@kemnade.info>
> > > Cc: Bhushan Shah <bshah@kde.org>
> > > Cc: Drew Fustini <drew@beagleboard.org>
> > > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > ---
> > >  drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++------------------
> > >  1 file changed, 20 insertions(+), 20 deletions(-)
> > 
> > Does not apply to my usb-next branch, what tree/branch did you make this
> > against?
> 
> This was against Linux next last week, I'll take a look and
> repost.

Looks like the issue applying these patches is caused by commit
b65ba0c362be ("usb: musb: fix MUSB_QUIRK_B_DISCONNECT_99 handling")
that is in usb-linus but not in usb-next.

Probably best to merge usb-linus to usb-next and then these patches
apply no problem and a merge conflict is avoided?

Let me know if you still want me to repost against usb-next, I can
do that no problem if you prefer that :)

Regards,

Tony
Greg Kroah-Hartman June 14, 2021, 8:26 a.m. UTC | #4
On Fri, Jun 11, 2021 at 08:17:40AM +0300, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [210609 12:00]:
> > * Greg Kroah-Hartman <gregkh@linuxfoundation.org> [210609 09:26]:
> > > On Fri, Jun 04, 2021 at 11:05:35AM +0300, Tony Lindgren wrote:
> > > > Simplify cable state handling a bit to leave out duplicated code.
> > > > We are just scheduling work and showing state info if a recheck is
> > > > needed. No intended functional changes.
> > > > 
> > > > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > > Cc: Andreas Kemnade <andreas@kemnade.info>
> > > > Cc: Bhushan Shah <bshah@kde.org>
> > > > Cc: Drew Fustini <drew@beagleboard.org>
> > > > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > ---
> > > >  drivers/usb/musb/musb_core.c | 40 ++++++++++++++++++------------------
> > > >  1 file changed, 20 insertions(+), 20 deletions(-)
> > > 
> > > Does not apply to my usb-next branch, what tree/branch did you make this
> > > against?
> > 
> > This was against Linux next last week, I'll take a look and
> > repost.
> 
> Looks like the issue applying these patches is caused by commit
> b65ba0c362be ("usb: musb: fix MUSB_QUIRK_B_DISCONNECT_99 handling")
> that is in usb-linus but not in usb-next.
> 
> Probably best to merge usb-linus to usb-next and then these patches
> apply no problem and a merge conflict is avoided?
> 
> Let me know if you still want me to repost against usb-next, I can
> do that no problem if you prefer that :)

Now that I have merged usb-linus into usb-next, I can take these,
thanks.

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1984,6 +1984,20 @@  ATTRIBUTE_GROUPS(musb);
 #define MUSB_QUIRK_A_DISCONNECT_19	((3 << MUSB_DEVCTL_VBUS_SHIFT) | \
 					 MUSB_DEVCTL_SESSION)
 
+static bool musb_state_needs_recheck(struct musb *musb, const char *desc)
+{
+	if (musb->quirk_retries && !musb->flush_irq_work) {
+		musb_dbg(musb, desc);
+		schedule_delayed_work(&musb->irq_work,
+				      msecs_to_jiffies(1000));
+		musb->quirk_retries--;
+
+		return true;
+	}
+
+	return false;
+}
+
 /*
  * Check the musb devctl session bit to determine if we want to
  * allow PM runtime for the device. In general, we want to keep things
@@ -2004,32 +2018,18 @@  static void musb_pm_runtime_check_session(struct musb *musb)
 		MUSB_DEVCTL_HR;
 	switch (devctl & ~s) {
 	case MUSB_QUIRK_B_DISCONNECT_99:
-		if (musb->quirk_retries && !musb->flush_irq_work) {
-			musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n");
-			schedule_delayed_work(&musb->irq_work,
-					      msecs_to_jiffies(1000));
-			musb->quirk_retries--;
-		}
+		musb_state_needs_recheck(musb,
+			"Poll devctl in case of suspend after disconnect\n");
 		break;
 	case MUSB_QUIRK_B_INVALID_VBUS_91:
-		if (musb->quirk_retries && !musb->flush_irq_work) {
-			musb_dbg(musb,
-				 "Poll devctl on invalid vbus, assume no session");
-			schedule_delayed_work(&musb->irq_work,
-					      msecs_to_jiffies(1000));
-			musb->quirk_retries--;
+		if (musb_state_needs_recheck(musb,
+				"Poll devctl on invalid vbus, assume no session"))
 			return;
-		}
 		fallthrough;
 	case MUSB_QUIRK_A_DISCONNECT_19:
-		if (musb->quirk_retries && !musb->flush_irq_work) {
-			musb_dbg(musb,
-				 "Poll devctl on possible host mode disconnect");
-			schedule_delayed_work(&musb->irq_work,
-					      msecs_to_jiffies(1000));
-			musb->quirk_retries--;
+		if (musb_state_needs_recheck(musb,
+				"Poll devctl on possible host mode disconnect"))
 			return;
-		}
 		if (!musb->session)
 			break;
 		musb_dbg(musb, "Allow PM on possible host mode disconnect");