staging: pi433: fix logging and naming issues
cover staging: pi433: fix logging and naming issues
These patches fix messages logging and device naming issues when probing for new radio module.
Those two changes are send as one patchset since both modify the same part of code (second patch depends on first one)
Marcin Ciupak (2):
staging: pi433: fix (NULL device *) in log message
staging: pi433: fix naming when more than one radio is used
drivers/staging/pi433/pi433_if.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
Signature · 1 line
2.15.0
PATCH 1/2 staging: pi433: fix (NULL device *) in log message
(NULL device *) is printed in log message in pi433_probe and pi433_get_minor functions due to device->dev being used prior to call to device_create function.
--- drivers/staging/pi433/pi433_if.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/staging/pi433/pi433_if.c +13 -13
@@ -1051,7 +1051,7 @@ static int pi433_get_minor(struct pi433_device *device) device->minor = retval; retval =0 ; }else if (retval == -ENOSPC ) { -dev_err (device->dev,"too many pi433 devices\n" ); +dev_err (&device->spi->dev,"too many pi433 devices\n" ); retval = -EINVAL ; }mutex_unlock (&minor_lock);
@@ -1159,19 +1159,10 @@ static int pi433_probe(struct spi_device *spi)SET_CHECKED (rf69_set_output_power_level (spi,13 ));SET_CHECKED (rf69_set_antenna_impedance (spi, fiftyOhm)); -/* start tx thread */ - device->tx_task_struct =kthread_run (pi433_tx_thread, - device, -"pi433_tx_task" ); -if (IS_ERR (device->tx_task_struct)) { -dev_dbg (device->dev,"start of send thread failed" ); - goto send_thread_failed; - } -/* determ minor number */ retval =pi433_get_minor (device);if (retval) { -dev_dbg (device->dev,"get of minor number failed" ); +dev_dbg (&spi->dev,"get of minor number failed" ); goto minor_failed; }
@@ -1194,6 +1185,15 @@ static int pi433_probe(struct spi_device *spi) device->minor); } +/* start tx thread */ + device->tx_task_struct =kthread_run (pi433_tx_thread, + device, +"pi433_tx_task" ); +if (IS_ERR (device->tx_task_struct)) { +dev_dbg (device->dev,"start of send thread failed" ); + goto send_thread_failed; + } +/* create cdev */ device->cdev =cdev_alloc (); device->cdev->owner =THIS_MODULE ;
@@ -1210,12 +1210,12 @@ static int pi433_probe(struct spi_device *spi)return 0 ; cdev_failed: +kthread_stop (device->tx_task_struct); +send_thread_failed:device_destroy (pi433_class, device->devt); device_create_failed:pi433_free_minor (device); minor_failed: -kthread_stop (device->tx_task_struct); -send_thread_failed:free_GPIOs (device); GPIO_failed:kfree (device);
Signature · 1 line
2.15.0
PATCH 2/2 staging: pi433: fix naming when more than one radio is used
In reply to Marcin CiupakWhen using more than one hardware radio module pi433_probe fails as the same name is used for all modules. Create unique name by adding minor number to the device name.
--- drivers/staging/pi433/pi433_if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/pi433/pi433_if.c +4 -2
@@ -1172,7 +1172,8 @@ static int pi433_probe(struct spi_device *spi) &spi->dev, device->devt, device, - "pi433"); +"pi433.%d" , + device->minor);if (IS_ERR (device->dev)) {pr_err ("pi433: device register failed\n" ); retval =PTR_ERR (device->dev);
@@ -1188,7 +1189,8 @@ static int pi433_probe(struct spi_device *spi)/* start tx thread */ device->tx_task_struct =kthread_run (pi433_tx_thread, device, -"pi433_tx_task" ); +"pi433.%d_tx_task" , + device->minor);if (IS_ERR (device->tx_task_struct)) {dev_dbg (device->dev,"start of send thread failed" ); goto send_thread_failed;
Signature · 1 line
2.15.0