Thread (10 messages) 10 messages, 3 authors, 2018-06-14

[PATCH v7 3/6] mfd: at91-usart: added mfd driver for usart

From: alexandre.belloni@bootlin.com (Alexandre Belloni)
Date: 2018-06-14 08:32:29
Also in: linux-devicetree, linux-serial, linux-spi, lkml

On 14/06/2018 11:22:25+0300, Radu Pirea wrote:
On 06/14/2018 10:58 AM, Ludovic Desroches wrote:
quoted
quoted
+static int at91_usart_mode_probe(struct platform_device *pdev)
+{
+	struct mfd_cell cell;
+	u32 opmode = AT91_USART_MODE_SERIAL;
+
+	device_property_read_u32(&pdev->dev, "atmel,usart-mode", &opmode);
+
+	switch (opmode) {
+	case AT91_USART_MODE_SPI:
+		cell = at91_usart_spi_subdev;
+		break;
+	case AT91_USART_MODE_SERIAL:
+		cell = at91_usart_serial_subdev;
+		break;
+	default:
+		break;
If there is an invalid opmode from the DT, you will pass a non initialized cell
to mfd_add_device().

Regards

Ludovic
Hi Ludovic,

Tnx. That's true. How is better to do if atmel,usart-mode has an invalid
value? To initialize cell with at91_usart_serial_subdev or to print an error
message and return -EINVAL?
Returning an error is probably the correct choice because it means the
DT has an invalid value (something was done and is wrong).

-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help