diff mbox series

[2/5] spi: lpspi: add NULL check when probe device

Message ID 20200714075251.12777-3-xiaoning.wang@nxp.com (mailing list archive)
State Superseded
Headers show
Series Some bug fix for lpspi | expand

Commit Message

Clark Wang July 14, 2020, 7:52 a.m. UTC
Add a NULL check for device node and lpspi_platform_info when lpspi
device probe.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Mark Brown July 21, 2020, 11:44 p.m. UTC | #1
On Tue, Jul 14, 2020 at 03:52:48PM +0800, Clark Wang wrote:
> Add a NULL check for device node and lpspi_platform_info when lpspi
> device probe.

This has build problems, I guess there's been a context change that's
caused issues along with causing the later patches to not apply:

/mnt/kernel/drivers/spi/spi-fsl-lpspi.c: In function 'fsl_lpspi_probe':
/mnt/kernel/drivers/spi/spi-fsl-lpspi.c:824:7: error: 'np' undeclared (first use in this function); did you mean 'up'?
  if (!np && !lpspi_platform_info) {
       ^~
       up
/mnt/kernel/drivers/spi/spi-fsl-lpspi.c:824:7: note: each undeclared identifier is reported only once for each function it appears in
/mnt/kernel/drivers/spi/spi-fsl-lpspi.c:824:14: error: 'lpspi_platform_info' undeclared (first use in this function); did you mean 'spi_board_info'?
  if (!np && !lpspi_platform_info) {
              ^~~~~~~~~~~~~~~~~~~
              spi_board_info
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index a1555bbc5e5a..ca43d93adf30 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -841,6 +841,11 @@  static int fsl_lpspi_probe(struct platform_device *pdev)
 	u32 temp;
 	bool is_slave;
 
+	if (!np && !lpspi_platform_info) {
+		dev_err(&pdev->dev, "can't get the platform data\n");
+		return -EINVAL;
+	}
+
 	is_slave = of_property_read_bool((&pdev->dev)->of_node, "spi-slave");
 	if (is_slave)
 		controller = spi_alloc_slave(&pdev->dev,