Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1446643
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl |
| Date | 2016-07-19 20:20 +0200 |
| Message-ID | <rWHMC-7oq-37@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <rWFB9-5U4-39@gated-at.bofh.it> <rWFKO-6cr-29@gated-at.bofh.it> <rWFUt-6fE-5@gated-at.bofh.it> <rWG4a-6iH-23@gated-at.bofh.it> <rWHMC-7oq-15@gated-at.bofh.it> |
| Organization | Free Electrons |
On Tue, 19 Jul 2016 11:11:54 -0700 Andrey Smirnov <andrew.smirnov@gmail.com> wrote: > On Tue, Jul 19, 2016 at 9:22 AM, Richard Weinberger <richard@nod.at> wrote: > > Am 19.07.2016 um 18:12 schrieb Boris Brezillon: > >>>> Not sure a BUG_ON() is worst than a NULL-pointer exception ;-). > >>> > >>> When this really just triggers a NULL-pointer exception, we don't need a BUG_ON or WARN_ON at > >>> all since the kernel can tell anyway what went wrong. > >> > >> Hm, that's not entirely true, depending on your debug options you don't > >> have all the information to guess which line triggered the NULL pointer > >> exception, and this makes it harder to debug. > >> And I agree with Andrey here, it's better to complain at registration > >> time than letting the controller register all its NAND devices and > >> generate exceptions when the NAND is really used. > >> > >> BTW, I don't quite understand the rational behind BUG_ON() eradication. > >> I agree that they should not be used when the driver can recover from a > >> specific failure, but that's not really the case here (some NAND > >> controller drivers don't check nand_scan_tail() or nand_scan() return > >> code). > > > > I've been told that new code (except core code) should not BUG()/_ON(). > > > >> The best solution would probably be to patch all those drivers and then > >> return an error when one of the mandatory hooks is missing, but in the > >> meantime I don't see any problem in adding BUG_ON() calls. > > > > Yes, definitely. > > I don't have any preferences as far BUG_ON/WARN_ON are concerned and > am more than happy to change one for another. > > The reason I came up with that patch is that I stumbled on that > segfault (by not providing custom select_chip() and not setting up > cmd_ctrl()) and it took me good 20 minutes to figure out the nature of > the problem, whereas, IMHO, having a BUG/WARN statement at the would > have been more self-documenting/explanatory. > > What if I modify the patch to change nand_set_default's signature to > return a error code, add corresponding checking in > nand_get_flash_type()/nand_scan_ident() and replace BUG_ON with > WARN_ON? Would it be more agreeable solution? Agreed.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 17:50 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 18:00 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 18:10 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 18:20 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 18:30 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Andrey Smirnov <andrew.smirnov@gmail.com> - 2016-07-19 20:20 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 20:20 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 20:30 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Andrey Smirnov <andrew.smirnov@gmail.com> - 2016-07-19 20:40 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 20:20 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 20:50 +0200
Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 21:40 +0200
csiph-web