From: Stafford Horne <shorne@gmail.com> To: Mateusz Holenko <mholenko@antmicro.com> Cc: Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jslaby@suse.com>, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, Karol Gugala <kgugala@antmicro.com>, Mauro Carvalho Chehab <mchehab+samsung@kernel.org>, "David S. Miller" <davem@davemloft.net>, "Paul E. McKenney" <paulmck@linux.ibm.com>, Filip Kokosinski <fkokosinski@antmicro.com>, Pawel Czarnecki <pczarnecki@internships.antmicro.com>, Joel Stanley <joel@jms.id.au>, Jonathan Cameron <Jonathan.Cameron@huawei.com>, Maxime Ripard <mripard@kernel.org>, Shawn Guo <shawnguo@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Sam Ravnborg <sam@ravnborg.org>, Icenowy Zheng <icenowy@aosc.io>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, linux-kernel@vger.kernel.org, "Gabriel L. Somlo" <gsomlo@gmail.com> Subject: Re: [PATCH v10 3/5] drivers/soc/litex: add LiteX SoC Controller driver Date: Fri, 11 Sep 2020 09:57:40 +0900 Message-ID: <20200911005740.GN3562056@lianli.shorne-pla.net> (raw) In-Reply-To: <20200812143324.2394375-3-mholenko@antmicro.com> On Wed, Aug 12, 2020 at 02:34:34PM +0200, Mateusz Holenko wrote: > From: Pawel Czarnecki <pczarnecki@internships.antmicro.com> > > This commit adds driver for the FPGA-based LiteX SoC > Controller from LiteX SoC builder. > > Co-developed-by: Mateusz Holenko <mholenko@antmicro.com> > Signed-off-by: Mateusz Holenko <mholenko@antmicro.com> > Signed-off-by: Pawel Czarnecki <pczarnecki@internships.antmicro.com> > --- ... > +static int litex_check_csr_access(void __iomem *reg_addr) > +{ > + unsigned long reg; > + > + reg = litex_get_reg(reg_addr + SCRATCH_REG_OFF, SCRATCH_REG_SIZE); > + > + if (reg != SCRATCH_REG_VALUE) { > + panic("Scratch register read error! Expected: 0x%x but got: 0x%lx", > + SCRATCH_REG_VALUE, reg); > + return -EINVAL; > + } > + > + litex_set_reg(reg_addr + SCRATCH_REG_OFF, > + SCRATCH_REG_SIZE, SCRATCH_TEST_VALUE); > + reg = litex_get_reg(reg_addr + SCRATCH_REG_OFF, SCRATCH_REG_SIZE); > + > + if (reg != SCRATCH_TEST_VALUE) { > + panic("Scratch register write error! Expected: 0x%x but got: 0x%lx", > + SCRATCH_TEST_VALUE, reg); > + return -EINVAL; > + } > + > + /* restore original value of the SCRATCH register */ > + litex_set_reg(reg_addr + SCRATCH_REG_OFF, > + SCRATCH_REG_SIZE, SCRATCH_REG_VALUE); > + > + /* Set flag for other drivers */ What does this comment mean? > + pr_info("LiteX SoC Controller driver initialized"); > + > + return 0; > +} > + > +struct litex_soc_ctrl_device { > + void __iomem *base; > +}; > + > +static const struct of_device_id litex_soc_ctrl_of_match[] = { > + {.compatible = "litex,soc-controller"}, > + {}, > +}; > + > +MODULE_DEVICE_TABLE(of, litex_soc_ctrl_of_match); > + > +static int litex_soc_ctrl_probe(struct platform_device *pdev) > +{ > + int result; > + struct device *dev; > + struct device_node *node; > + struct litex_soc_ctrl_device *soc_ctrl_dev; > + > + dev = &pdev->dev; > + node = dev->of_node; > + if (!node) > + return -ENODEV; > + > + soc_ctrl_dev = devm_kzalloc(dev, sizeof(*soc_ctrl_dev), GFP_KERNEL); > + if (!soc_ctrl_dev) > + return -ENOMEM; > + > + soc_ctrl_dev->base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(soc_ctrl_dev->base)) > + return PTR_ERR(soc_ctrl_dev->base); > + > + result = litex_check_csr_access(soc_ctrl_dev->base); > + if (result) { > + // LiteX CSRs access is broken which means that > + // none of LiteX drivers will most probably > + // operate correctly The comment format here with // is not usually used in the kernel, but its not forbidded. Could you use the /* */ multiline style? > + BUG(); Instead of stopping the system with BUG, could we just do: return litex_check_csr_access(soc_ctrl_dev->base); We already have failure for NODEV/NOMEM so might as well not call BUG() here too. > + } > + > + return 0; > +} > + Other than that it looks ok to me. -Stafford
next prev parent reply index Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-12 12:33 [PATCH v10 0/5] LiteX SoC controller and LiteUART serial driver Mateusz Holenko 2020-08-12 12:34 ` [PATCH v10 1/5] dt-bindings: vendor: add vendor prefix for LiteX Mateusz Holenko 2020-08-12 12:34 ` [PATCH v10 2/5] dt-bindings: soc: document LiteX SoC Controller bindings Mateusz Holenko 2020-08-12 12:34 ` [PATCH v10 3/5] drivers/soc/litex: add LiteX SoC Controller driver Mateusz Holenko 2020-09-11 0:57 ` Stafford Horne [this message] 2020-09-14 10:33 ` Mateusz Holenko 2020-09-14 13:24 ` Stafford Horne 2020-09-15 12:58 ` Mateusz Holenko 2020-08-12 12:34 ` [PATCH v10 4/5] dt-bindings: serial: document LiteUART bindings Mateusz Holenko 2020-08-12 12:35 ` [PATCH v10 5/5] drivers/tty/serial: add LiteUART driver Mateusz Holenko 2020-08-28 8:18 ` Greg Kroah-Hartman 2020-09-11 1:00 ` [PATCH v10 0/5] LiteX SoC controller and LiteUART serial driver Stafford Horne
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=20200911005740.GN3562056@lianli.shorne-pla.net \ --to=shorne@gmail.com \ --cc=Jonathan.Cameron@huawei.com \ --cc=davem@davemloft.net \ --cc=devicetree@vger.kernel.org \ --cc=fkokosinski@antmicro.com \ --cc=gregkh@linuxfoundation.org \ --cc=gsomlo@gmail.com \ --cc=heiko@sntech.de \ --cc=icenowy@aosc.io \ --cc=joel@jms.id.au \ --cc=jslaby@suse.com \ --cc=kgugala@antmicro.com \ --cc=laurent.pinchart@ideasonboard.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-serial@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mchehab+samsung@kernel.org \ --cc=mholenko@antmicro.com \ --cc=mripard@kernel.org \ --cc=paulmck@linux.ibm.com \ --cc=pczarnecki@internships.antmicro.com \ --cc=robh+dt@kernel.org \ --cc=sam@ravnborg.org \ --cc=shawnguo@kernel.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
Linux-Serial Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \ linux-serial@vger.kernel.org public-inbox-index linux-serial Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial AGPL code for this site: git clone https://public-inbox.org/public-inbox.git