use resource managed devm_iio_device_register
Subsystems (4)
cover use resource managed devm_iio_device_register
This patchset replaces the use of iio_device_register with
the resource managed function devm_iio_device_register when the remove function only unregisters the device. Since an iio_dev registered with this function is automatically unregistered on driver detach there is no need for the remove function and therefore it is removed.
Ioana Ciornei (3):
staging: iio: cdc: use devm_iio_device_register instead
iio_device_register
staging: iio: light: use devm_iio_device_register instead
iio_device_register
staging: iio: resolver: replace iio_device_register by
devm_iio_device_register
drivers/staging/iio/cdc/ad7150.c | 12 +----------- drivers/staging/iio/cdc/ad7152.c | 12 +----------- drivers/staging/iio/cdc/ad7746.c | 12 +----------- drivers/staging/iio/light/isl29028.c | 11 +---------- drivers/staging/iio/light/tsl2583.c | 12 ++---------- drivers/staging/iio/resolver/ad2s90.c | 10 +--------- 6 files changed, 7 insertions(+), 62 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/3 staging: iio: cdc: use devm_iio_device_register instead iio_device_register
Replace iio_device_register with resource managed devm_iio_device_register in order to ease the error path. Also delete de remove function since there is no need after this change.
--- drivers/staging/iio/cdc/ad7150.c | 12 +----------- drivers/staging/iio/cdc/ad7152.c | 12 +----------- drivers/staging/iio/cdc/ad7746.c | 12 +----------- 3 files changed, 3 insertions(+), 33 deletions(-)
drivers/staging/iio/cdc/ad7150.c +1 -11
@@ -636,7 +636,7 @@ static int ad7150_probe(struct i2c_client *client,return ret; } - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret)return ret;
@@ -646,15 +646,6 @@ static int ad7150_probe(struct i2c_client *client,return 0 ; } -static int ad7150_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); - -return 0 ; -} -static const struct i2c_device_id ad7150_id[] = { {"ad7150" ,0 }, {"ad7151" ,0 },
@@ -669,7 +660,6 @@ static struct i2c_driver ad7150_driver = { .name = "ad7150", }, .probe = ad7150_probe, - .remove = ad7150_remove, .id_table = ad7150_id, };module_i2c_driver (ad7150_driver);
drivers/staging/iio/cdc/ad7152.c +1 -11
@@ -502,7 +502,7 @@ static int ad7152_probe(struct i2c_client *client, indio_dev->num_channels =ARRAY_SIZE (ad7152_channels); indio_dev->modes =INDIO_DIRECT_MODE ; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret)return ret;
@@ -511,15 +511,6 @@ static int ad7152_probe(struct i2c_client *client,return 0 ; } -static int ad7152_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); - -return 0 ; -} -static const struct i2c_device_id ad7152_id[] = { {"ad7152" ,0 }, {"ad7153" ,1 },
@@ -533,7 +524,6 @@ static struct i2c_driver ad7152_driver = { .name = KBUILD_MODNAME, }, .probe = ad7152_probe, - .remove = ad7152_remove, .id_table = ad7152_id, };module_i2c_driver (ad7152_driver);
drivers/staging/iio/cdc/ad7746.c +1 -11
@@ -749,7 +749,7 @@ static int ad7746_probe(struct i2c_client *client,if (ret <0 )return ret; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret)return ret;
@@ -758,15 +758,6 @@ static int ad7746_probe(struct i2c_client *client,return 0 ; } -static int ad7746_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); - -return 0 ; -} -static const struct i2c_device_id ad7746_id[] = { {"ad7745" ,7745 }, {"ad7746" ,7746 },
@@ -781,7 +772,6 @@ static struct i2c_driver ad7746_driver = { .name = KBUILD_MODNAME, }, .probe = ad7746_probe, - .remove = ad7746_remove, .id_table = ad7746_id, };module_i2c_driver (ad7746_driver);
Signature · 1 line
2.1.4
PATCH 2/3 staging: iio: light: use devm_iio_device_register instead iio_device_register
In reply to Ioana CiorneiReplace iio_device_register with resource managed devm_iio_device_register in order to ease the error path. Also delete de remove function since there is no need after this change.
--- drivers/staging/iio/light/isl29028.c | 11 +---------- drivers/staging/iio/light/tsl2583.c | 12 ++---------- 2 files changed, 3 insertions(+), 20 deletions(-)
drivers/staging/iio/light/isl29028.c +1 -10
@@ -513,7 +513,7 @@ static int isl29028_probe(struct i2c_client *client, indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->modes =INDIO_DIRECT_MODE ; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret <0 ) {dev_err (chip->dev,"iio registration fails with error %d\n" , ret);
@@ -522,14 +522,6 @@ static int isl29028_probe(struct i2c_client *client,return 0 ; } -static int isl29028_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); -return 0 ; -} -static const struct i2c_device_id isl29028_id[] = { {"isl29028" ,0 }, {}
@@ -550,7 +542,6 @@ static struct i2c_driver isl29028_driver = { .of_match_table = isl29028_of_match, }, .probe = isl29028_probe, - .remove = isl29028_remove, .id_table = isl29028_id, };
drivers/staging/iio/light/tsl2583.c +2 -10
@@ -862,7 +862,7 @@ static int taos_probe(struct i2c_client *clientp, indio_dev->dev.parent = &clientp->dev; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->name = chip->client->name; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret) {dev_err (&clientp->dev,"iio registration failed\n" );return ret;
@@ -917,13 +917,6 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);#define TAOS_PM_OPS NULL#endif -static int taos_remove (struct i2c_client *client) -{ -iio_device_unregister (i2c_get_clientdata (client)); - -return 0 ; -} -static struct i2c_device_id taos_idtable[] = { {"tsl2580" ,0 }, {"tsl2581" ,1 },
@@ -939,8 +932,7 @@ static struct i2c_driver taos_driver = { .pm = TAOS_PM_OPS, }, .id_table = taos_idtable, - .probe = taos_probe, - .remove = taos_remove, + .probe = taos_probe };module_i2c_driver (taos_driver);
Signature · 1 line
2.1.4
PATCH 3/3 staging: iio: resolver: replace iio_device_register by devm_iio_device_register
In reply to Ioana CiorneiUse devm_iio_device_register instead of iio_device_register when the remove function is only used to call iio_device_unregister.
Function devm_iio_device_register implicitly calls unregister so there is wqno need to specifically call it
--- drivers/staging/iio/resolver/ad2s90.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/staging/iio/resolver/ad2s90.c +1 -9
@@ -79,7 +79,7 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels =1 ; indio_dev->name =spi_get_device_id (spi)->name; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret)return ret;
@@ -91,13 +91,6 @@ static int ad2s90_probe(struct spi_device *spi)return 0 ; } -static int ad2s90_remove (struct spi_device *spi) -{ -iio_device_unregister (spi_get_drvdata (spi)); - -return 0 ; -} -static const struct spi_device_id ad2s90_id[] = { {"ad2s90" }, {}
@@ -110,7 +103,6 @@ static struct spi_driver ad2s90_driver = { .owner = THIS_MODULE, }, .probe = ad2s90_probe, - .remove = ad2s90_remove, .id_table = ad2s90_id, };module_spi_driver (ad2s90_driver);
Signature · 1 line
2.1.4
Re: [Outreachy kernel] [PATCH 2/3] staging: iio: light: use devm_iio_device_register instead iio_device_register
In reply to Ioana CiorneiQuoted 3 lines · Ioana Ciornei
Replace
iio_device_registerwith resource manageddevm_iio_device_registerin order to ease the error path. Also delete de remove function since there is no need after this change.
de->the
Quoted 70 lines
Signed-off-by Ioana Ciornei <[email protected]>--- drivers/staging/iio/light/isl29028.c | 11 +---------- drivers/staging/iio/light/tsl2583.c | 12 ++---------- 2 files changed, 3 insertions(+), 20 deletions(-)drivers/staging/iio/light/isl29028.c +1
-10@@ -513,7 +513,7 @@ static int isl29028_probe(struct i2c_client *client, indio_dev->name = id->name; indio_dev->dev.parent = &client->dev; indio_dev->modes =INDIO_DIRECT_MODE ; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret <0 ) {dev_err (chip->dev,"iio registration fails with error %d\n" , ret);@@ -522,14 +522,6 @@ static int isl29028_probe(struct i2c_client *client,return 0 ; } -static int isl29028_remove (struct i2c_client *client) -{ -struct iio_dev *indio_dev =i2c_get_clientdata (client); - -iio_device_unregister (indio_dev); -return 0 ; -} -static const struct i2c_device_id isl29028_id[] = { {"isl29028" ,0 }, {}@@ -550,7 +542,6 @@ static struct i2c_driver isl29028_driver = { .of_match_table = isl29028_of_match, }, .probe = isl29028_probe, - .remove = isl29028_remove, .id_table = isl29028_id, };drivers/staging/iio/light/tsl2583.c +1
-8@@ -862,7 +862,7 @@ static int taos_probe(struct i2c_client *clientp, indio_dev->dev.parent = &clientp->dev; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->name = chip->client->name; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret) {dev_err (&clientp->dev,"iio registration failed\n" );return ret;@@ -917,13 +917,6 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);#define TAOS_PM_OPS NULL#endif -static int taos_remove (struct i2c_client *client) -{ -iio_device_unregister (i2c_get_clientdata (client)); - -return 0 ; -} -static struct i2c_device_id taos_idtable[] = { {"tsl2580" ,0 }, {"tsl2581" ,1 },
drivers/staging/iio/light/tsl2583.c static struct i2c_driver taos_driver = { · line 936
Quoted 7 lines
drivers/staging/iio/light/tsl2583.c +1
-2@@ -939,8 +932,7 @@ static struct i2c_driver taos_driver = { .pm = TAOS_PM_OPS, }, .id_table = taos_idtable, - .probe = taos_probe, - .remove = taos_remove, + .probe = taos_probe };
You removed (may be accidentally) comma after taos_probe. Please fix this.
Quoted 11 lines
drivers/staging/iio/light/tsl2583.c +0
-1module_i2c_driver (taos_driver); --2.1.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/803a5566a6126da8fb21617fcc852665bc4dd625.1443729484.git.ciorneiioana%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Signature · 1 line
Vaishali
Re: [Outreachy kernel] [PATCH 3/3] staging: iio: resolver: replace iio_device_register by devm_iio_device_register
In reply to Ioana CiorneiQuoted 4 lines · Ioana Ciornei
Use
devm_iio_device_registerinstead ofiio_device_registerwhen the remove function is only used to calliio_device_unregister.
Functiondevm_iio_device_registerimplicitly calls unregister so there is wqno need to specifically call it
wqno->no
Here, commit log looks confusing to me. Yes, it is good to use devm_iio_register only when remove function is calling iio_device_unregister. But that is not the reason why you should use resource managed function. Probably you need to write the clear reason of why you should replace current code with devm_iio_register.
Quoted 49 lines
Signed-off-by Ioana Ciornei <[email protected]>--- drivers/staging/iio/resolver/ad2s90.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/staging/iio/resolver/ad2s90.c +1
-10@@ -79,7 +79,7 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels =1 ; indio_dev->name =spi_get_device_id (spi)->name; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (indio_dev->dev.parent, indio_dev);if (ret)return ret;@@ -91,13 +91,6 @@ static int ad2s90_probe(struct spi_device *spi)return 0 ; } -static int ad2s90_remove (struct spi_device *spi) -{ -iio_device_unregister (spi_get_drvdata (spi)); - -return 0 ; -} -static const struct spi_device_id ad2s90_id[] = { {"ad2s90" }, {}@@ -110,7 +103,6 @@ static struct spi_driver ad2s90_driver = { .owner = THIS_MODULE, }, .probe = ad2s90_probe, - .remove = ad2s90_remove, .id_table = ad2s90_id, };module_spi_driver (ad2s90_driver); --2.1.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/41516ac4f917514f14dc5f8469a52aa8b6081818.1443729484.git.ciorneiioana%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Signature · 1 line
Vaishali
Quoted 15 lines · Ioana Ciornei
This patchset replaces the use of
iio_device_registerwith
the resource managed functiondevm_iio_device_registerwhen the remove function only unregisters the device. Since aniio_devregistered with this function is automatically unregistered on driver detach there is no need for the remove function and therefore it is removed.Ioana Ciornei (3):
staging: iio: cdc: usedevm_iio_device_registerinstead
iio_device_register
staging: iio: light: usedevm_iio_device_registerinstead
iio_device_register
staging: iio: resolver: replaceiio_device_registerby
devm_iio_device_register
Quoted 7 lines
drivers/staging/iio/cdc/ad7150.c | 12 +----------- drivers/staging/iio/cdc/ad7152.c | 12 +----------- drivers/staging/iio/cdc/ad7746.c | 12 +----------- drivers/staging/iio/light/isl29028.c | 11 +---------- drivers/staging/iio/light/tsl2583.c | 12 ++---------- drivers/staging/iio/resolver/ad2s90.c | 10 +--------- 6 files changed, 7 insertions(+), 62 deletions(-)
Hi,
Other than the changes I suggested, technically whole series looks good to me.
Thanks
Quoted 9 lines
--
2.1.4--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1443729484.git.ciorneiioana%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Signature · 1 line
Vaishali