Jason Davila pleaded guilty to two criminal charges: that he conspired to commit robbery in violation of the Hobbs Act, 18 U.S.C. § 1951, and that he possessed a firearm in connection with both the planned robbery and a drug trafficking crime, in violation of 18 U.S.C. § 924(c)(1)(A). The indictment charged the drug offense as a separate substantive count, which was dismissed as part of a plea bargain. The judge sentenced Davila to consecutive sentences of 6 months’ imprisonment under the Hobbs Act and 60 months’ imprisonment under § 924(c). He did not appeal.
But after the Supreme Court held in Johnson v. United States, — U.S. -, 135 S.Ct. 2551, 192 L.Ed.2d 569 (2015), that the residual clause of the Armed Career Criminal Act, 18 U.S.C. *731§ 924(e), is unconstitutionally vague, Davi-la filed this collateral attack under. 28 U.S.C. § 2256. He contends that conspiracy to commit a robbery could be deemed a crime of violence only under the residual clause in § 924(c)(3)(B)- and that this clause should be held unconstitutional under Johnson’s reasoning. This court recently reached that conclusion about the validity of § 924(c)(3)(B). See United States v. Cardena, No. 12-3680, 842 F.3d 959, 995-96, 2016 WL 6819696 (7th Cir. Nov. 18, 2016). Anticipating the possibility of that outcome — and without deciding whether a Hobbs Act conspiracy is a crime of violence under the elements clause in § 924(c)(3)(A) — the district judge held that Davila’s conviction is valid no matter how conspiracy to rob is classified. The indictment charged Davila with possessing the gun in connection with both that planned robbery and a completed drug deal, and the latter is a “drug trafficking crime” under § 924(c)(2). The district court accordingly declined to disturb the conviction or sentence,
Davila’s appellate brief assumes that a conviction under § 924(c) is proper only if there is also a conviction for a qualifying predicate offense — either a “drug trafficking crime” or a “crime of violence”. As he pleaded guilty to the Hobbs Act count but not the drug count, he submits that the drug deal cannot be considered ' under § 924(c). This approach treats § 924(c) as a sentence-enhancement statute, and a judge can’t enhance a sentence unless there has been a conviction for an underlying offense.
The Armed Career Criminal Act is a sentence-enhancement statute, but § 924(c) is not. It defines a stand-alone crime. Section 924(c)(1)(A) provides that
any person who, during and in relation to any crime of violence or drug trafficking crime (including a crime of violence or drug trafficking crime that provides for an enhanced punishment if committed by the use' of a deadly or dangerous weapon or device) for which the person may be prosecuted in a court of the United States, uses or carries a firearm, or who, in furtherance of any such crime, possesses a firearm, shall, in addition to the punishment provided- for such crime of violence or. drug trafficking crime ... be sentenced to a term of imprisonment of not less than 5 years[.]
This requires a minimum sentence of five years if the firearm is possessed during and in relation to a drug offense or crime of violence “for which the person may be prosecuted” (emphasis added); it does not require a prosecution for or conviction of that other offense. See United States v. Moore, 763 F.3d 900, 908 (7th Cir. 2014); Young v. United States, 124 F.3d 794, 800 (7th Cir. 1997). When stating the factual basis of his plea, Davila admitted to a substantive drug offense that made him eligible for conviction under § 924(c), no matter how the Hobbs Act conspiracy is best classified (a subject that we do not address).
Davila contends that even if a § 924(c) conviction is possible without a conviction on a predicate offense, he understood the § 924(c) count of the indictment to allege only that he possessed the gun during and in relation to a crime of violence. Yet the § 924(c) count is short (about half of a double-spaced page) and mentions the Hobbs Act and drug offenses within a single sentence. The plea colloquy also covered the relation between his gun and drugs.
There is a deeper problem with Davila’s challenge to his conviction under § 924(c): He pleaded guilty. He' did not fight the charge and contend that the residual clause is invalid or that conviction of a drug charge is essential to a § 924(c) *732conviction. He gave up those and other possible arguments as part of a plea bargain, .which conferred benefits including the dismissal of two other serious charges (the substantive drug count and a felon-in-possession count). Davila cannot keep those benefits while avoiding the criminal responsibility to which he admitted.
The Supreme Court has held many times that a plea of guilty is all that is necessary for a conviction:
[W]hen the judgment of conviction upon a guilty plea has become final and the offender seeks to reopen the proceeding, the inquiry is ordinarily confined to whether the underlying plea was both counseled and voluntary. If the answer is in the affirmative then the conviction and the plea, as a general rule, foreclose the collateral attack. There are exceptions where on the face of the record the court had no power to enter the conviction or impose the sentence. ■
United States v. Broce, 488 U.S. 563, 569, 109 S.Ct. 757, 102 L.Ed.2d 927 (1989). Davila’s plea was counseled, and he does not contend that it was involuntary. His brief tells us that he does not want the plea set aside and the prosecution restarted. That leaves the question whether the court had “power to enter the conviction” — in other words, subject-matter jurisdiction. A later passage in Broce contemplates the possibility that a plea might be invalid if the very act of initiating a criminal prosecution violated the Constitution, see id. at 574-75, 109 S.Ct. 757, but Davila does not contend that there was any problem with this prosecution’s initiation. He argues only that he is entitled to the benefit of the later decision in Johnson,
The district court had subject-matter jurisdiction under 18 U.S.C. § 3231. See United States v. Martin, 147 F.3d 529 (7th Cir. 1998). This leads Davila to contend that, whenever a constitutional problem crops up in a case that had been resolved by a guilty plea, the district court retroactively loses jurisdiction despite § 3231. That position runs headlong into Broce, for the Court there held that a guilty plea prevents collateral relief even on the , assumption that the conviction violated the Double Jeopardy Clause of the Fifth Amendment.
Broce is hardly the only holding to that effect. The Court observed, 488 U.S. at 571-72, 109 S.Ct. 757, that in Brady v. United States, 397 U.S. 742, 90 S.Ct. 1463, 25 L.Ed.2d 747 (1970), it had rejected the contention that a constitutional flaw revealed by post-plea developments permits a court to set aside a plea. Brady had been charged with capital kidnapping and pleaded guilty to a lesser charge to avoid the risk of the death penalty. Nine years after Brady entered that plea, United States v. Jackson, 390 U.S. 570, 88 S.Ct. 1209, 20 L.Ed.2d 138 (1968), held that the Constitution precluded the death-penalty system established by the statute under which Brady had been charged. But this did Brady no good because “a voluntary plea of guilty intelligently made .in the light of the then applicable law does not become vulnerable because later judicial decisions indicate that the plea rested on a faulty premise,” Brady, 397 U.S. at 757, 90 S.Ct. 1463, quoted in Broce, 488 U.S. at 672, 109 S.Ct. 757. What was true for Brady and Broce is true for Davila as well.
Johnson did not order the prosecution dismissed for lack of subject-matter jurisdiction. Instead the Supreme Court ruled in Johnson’s favor on the merits. Likewise we decided .Cardena on the merits. Unless a suit is laughably frivolous at the outset, a decision that the plaintiff loses because the law favors the defense leads to a decision on the merits, not a dismissal for lack of subject-matter jurisdiction. See Bell v. *733Hood, 327 U.S. 678, 66 S.Ct. 773, 90 L.Ed. 939 (1946). So Davila loses for two independent reasons: first, conviction of a drug crime is not essential to a conviction under § 924(c) for possessing a gun.during and in relation to a drug offense; second, Davila’s guilty plea forecloses a collateral attack based on Johnson or any other development that does not concern subject-matter jurisdiction or imply that the very institution of the criminal charge violated the Constitution.
Affirmed.