nfc: Various cleanups around device_id arrays
cover nfc: Various cleanups around device_id arrays
Hello,
this series's objective is to convert device_id arrays of various different device types to named initialisation. It contains a few cleanups left and right that I spotted while working on these changes.
The follow up change is to replace .driver_data by an anonymous union, see
https://lore.kernel.org/all/[email protected]/
for the idea.
The changes here are not strictly necessary for my quest, but they align the device_id structures to how they look and will look for other subsystems.
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (12):
nfc: Drop __maybe_unused from acpi_device_id tables
nfc: Drop unused assignment of acpi_device_id driver data
nfc: Initialize acpi_device_id arrays using member names
nfc: Unify style of acpi_device_id arrays
nfc: pn544: Drop empty line between i2c_device_id array and
MODULE_DEVICE_TABLE()
nfc: Initialize mei_cl_device_idarrays using member names
nfc: Drop __maybe_unused from of_device_id tables
nfc: Unify style of of_device_id arrays
nfc: Drop unused assignment of spi_device_id driver data
nfc: Initialize spi_device_idarrays using member names
nfc: Unify style of spi_device_id arrays
nfc: Unify style of usb_device_id arrays
drivers/nfc/fdp/i2c.c | 4 ++-- drivers/nfc/microread/mei.c | 10 ++++++---- drivers/nfc/nfcmrvl/i2c.c | 6 +++--- drivers/nfc/nfcmrvl/spi.c | 8 ++++---- drivers/nfc/nfcmrvl/usb.c | 1 - drivers/nfc/nxp-nci/i2c.c | 10 +++++----- drivers/nfc/pn533/i2c.c | 10 +++++----- drivers/nfc/pn533/uart.c | 4 ++-- drivers/nfc/pn544/i2c.c | 14 ++++++-------- drivers/nfc/pn544/mei.c | 10 ++++++---- drivers/nfc/port100.c | 4 ++-- drivers/nfc/s3fwrn5/i2c.c | 6 +++--- drivers/nfc/s3fwrn5/uart.c | 4 ++-- drivers/nfc/st-nci/i2c.c | 18 +++++++++--------- drivers/nfc/st-nci/spi.c | 18 +++++++++--------- drivers/nfc/st21nfca/i2c.c | 14 +++++++------- drivers/nfc/st95hf/core.c | 8 ++++---- drivers/nfc/trf7970a.c | 12 +++++------- 18 files changed, 80 insertions(+), 81 deletions(-)
base-commit: 6eb8711ece2ce27e52e327a5b7a628ed39b97f45
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 1/12 nfc: Drop __maybe_unused from acpi_device_id tables
Referencing these arrays in MODULE_DEVICE_TABLE() is enough to convince the compiler that they are used even if the drivers are built-in (since 5ab23c7923a1 ("modpost: Create modalias for builtin modules"). So the __maybe_unused marking can be removed without introducing a compiler warning.
--- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/nfc/pn544/i2c.c +1 -1
@@ -50,7 +50,7 @@ static const struct i2c_device_id pn544_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, pn544_hci_i2c_id_table); -static const struct acpi_device_id pn544_hci_i2c_acpi_match[]__maybe_unused = { +static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = { {"NXP5440" ,0 }, {} };
drivers/nfc/st-nci/i2c.c +1 -1
@@ -262,7 +262,7 @@ static const struct i2c_device_id st_nci_i2c_id_table[] = { };MODULE_DEVICE_TABLE (i2c, st_nci_i2c_id_table); -static const struct acpi_device_id st_nci_i2c_acpi_match[]__maybe_unused = { +static const struct acpi_device_id st_nci_i2c_acpi_match[] = { {"SMO2101" }, {"SMO2102" }, {}
drivers/nfc/st-nci/spi.c +1 -1
@@ -277,7 +277,7 @@ static struct spi_device_id st_nci_spi_id_table[] = { };MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table); -static const struct acpi_device_id st_nci_spi_acpi_match[]__maybe_unused = { +static const struct acpi_device_id st_nci_spi_acpi_match[] = { {"SMO2101" ,0 }, {} };
drivers/nfc/st21nfca/i2c.c +1 -1
@@ -577,7 +577,7 @@ static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = { };MODULE_DEVICE_TABLE (i2c, st21nfca_hci_i2c_id_table); -static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[]__maybe_unused = { +static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { {"SMO2100" ,0 }, {} };
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 2/12 nfc: Drop unused assignment of acpi_device_id driver data
In reply to Uwe Kleine-König (The Capable Hub)The drivers explicitly set the .driver_data member of struct acpi_device_id to zero without relying on that value. Drop these unused assignments.
This patch doesn't modify the compiled arrays, only their representation in source form benefits.
--- drivers/nfc/fdp/i2c.c | 2 +- drivers/nfc/pn544/i2c.c | 3 +-- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-)
drivers/nfc/fdp/i2c.c +1 -1
@@ -349,7 +349,7 @@ static void fdp_nci_i2c_remove(struct i2c_client *client) }static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = { - {"INT339A" ,0 }, + {"INT339A" }, {} };MODULE_DEVICE_TABLE (acpi, fdp_nci_i2c_acpi_match);
drivers/nfc/pn544/i2c.c +1 -2
@@ -51,10 +51,9 @@ static const struct i2c_device_id pn544_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, pn544_hci_i2c_id_table);static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = { - {"NXP5440" ,0 }, + {"NXP5440" }, {} }; -MODULE_DEVICE_TABLE (acpi, pn544_hci_i2c_acpi_match);#define PN544_HCI_I2C_DRIVER_NAME "pn544_hci_i2c"
drivers/nfc/st-nci/spi.c +1 -1
@@ -278,7 +278,7 @@ static struct spi_device_id st_nci_spi_id_table[] = {MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);static const struct acpi_device_id st_nci_spi_acpi_match[] = { - {"SMO2101" ,0 }, + {"SMO2101" }, {} };MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);
drivers/nfc/st21nfca/i2c.c +1 -1
@@ -578,7 +578,7 @@ static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, st21nfca_hci_i2c_id_table);static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { - {"SMO2100" ,0 }, + {"SMO2100" }, {} };MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match);
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 3/12 nfc: Initialize acpi_device_id arrays using member names
In reply to Uwe Kleine-König (The Capable Hub)While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition.
The mentioned robustness is relevant for a planned change to struct acpi_device_id that replaces .driver_data by an anonymous union.
This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds.
--- drivers/nfc/fdp/i2c.c | 2 +- drivers/nfc/nxp-nci/i2c.c | 6 +++--- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 4 ++-- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)
drivers/nfc/fdp/i2c.c +1 -1
@@ -349,7 +349,7 @@ static void fdp_nci_i2c_remove(struct i2c_client *client) }static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = { - {"INT339A" }, + { .id ="INT339A" }, {} };MODULE_DEVICE_TABLE (acpi, fdp_nci_i2c_acpi_match);
drivers/nfc/nxp-nci/i2c.c +3 -3
@@ -362,9 +362,9 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);#ifdef CONFIG_ACPI static const struct acpi_device_id acpi_id[] = { - {"NXP1001" }, - {"NXP1002" }, - {"NXP7471" }, + { .id ="NXP1001" }, + { .id ="NXP1002" }, + { .id ="NXP7471" }, { } };MODULE_DEVICE_TABLE (acpi, acpi_id);
drivers/nfc/pn544/i2c.c +1 -1
@@ -51,7 +51,7 @@ static const struct i2c_device_id pn544_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, pn544_hci_i2c_id_table);static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = { - {"NXP5440" }, + { .id ="NXP5440" }, {} };MODULE_DEVICE_TABLE (acpi, pn544_hci_i2c_acpi_match);
drivers/nfc/st-nci/i2c.c +2 -2
@@ -263,8 +263,8 @@ static const struct i2c_device_id st_nci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, st_nci_i2c_id_table);static const struct acpi_device_id st_nci_i2c_acpi_match[] = { - {"SMO2101" }, - {"SMO2102" }, + { .id ="SMO2101" }, + { .id ="SMO2102" }, {} };MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match);
drivers/nfc/st-nci/spi.c +1 -1
@@ -278,7 +278,7 @@ static struct spi_device_id st_nci_spi_id_table[] = {MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);static const struct acpi_device_id st_nci_spi_acpi_match[] = { - {"SMO2101" }, + { .id ="SMO2101" }, {} };MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);
drivers/nfc/st21nfca/i2c.c +1 -1
@@ -578,7 +578,7 @@ static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, st21nfca_hci_i2c_id_table);static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { - {"SMO2100" }, + { .id ="SMO2100" }, {} };MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match);
Signature · 1 line
2.55.0.11.g153666a7d9bb
Re: [PATCH v1 03/12] nfc: Initialize acpi_device_id arrays using member names
Quoted 5 lines · Uwe Kleine-König (The Capable Hub)
While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition.
Quoted 8 lines
The mentioned robustness is relevant for a planned change to struct
acpi_device_idthat replaces .driver_data by an anonymous union.This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>
Nice clarity improvement.
Quoted 96 lines
--- drivers/nfc/fdp/i2c.c | 2 +- drivers/nfc/nxp-nci/i2c.c | 6 +++--- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 4 ++-- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)drivers/nfc/fdp/i2c.c +1
-1@@ -349,7 +349,7 @@ static void fdp_nci_i2c_remove(struct i2c_client *client) }static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = { - {"INT339A" }, + { .id ="INT339A" }, {} };MODULE_DEVICE_TABLE (acpi, fdp_nci_i2c_acpi_match);drivers/nfc/nxp-nci/i2c.c +3
-3@@ -362,9 +362,9 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);#ifdef CONFIG_ACPI static const struct acpi_device_id acpi_id[] = { - {"NXP1001" }, - {"NXP1002" }, - {"NXP7471" }, + { .id ="NXP1001" }, + { .id ="NXP1002" }, + { .id ="NXP7471" }, { } };MODULE_DEVICE_TABLE (acpi, acpi_id);drivers/nfc/pn544/i2c.c +1
-1@@ -51,7 +51,7 @@ static const struct i2c_device_id pn544_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, pn544_hci_i2c_id_table);static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = { - {"NXP5440" }, + { .id ="NXP5440" }, {} };MODULE_DEVICE_TABLE (acpi, pn544_hci_i2c_acpi_match);drivers/nfc/st-nci/i2c.c +2
-2@@ -263,8 +263,8 @@ static const struct i2c_device_id st_nci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, st_nci_i2c_id_table);static const struct acpi_device_id st_nci_i2c_acpi_match[] = { - {"SMO2101" }, - {"SMO2102" }, + { .id ="SMO2101" }, + { .id ="SMO2102" }, {} };MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match);drivers/nfc/st-nci/spi.c +1
-1@@ -278,7 +278,7 @@ static struct spi_device_id st_nci_spi_id_table[] = {MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);static const struct acpi_device_id st_nci_spi_acpi_match[] = { - {"SMO2101" }, + { .id ="SMO2101" }, {} };MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);drivers/nfc/st21nfca/i2c.c +1
-2@@ -578,7 +578,7 @@ static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, st21nfca_hci_i2c_id_table);static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { - {"SMO2100" }, + { .id ="SMO2100" }, {} };MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match); --2.55.0.11.g153666a7d9bb
PATCH 4/12 nfc: Unify style of acpi_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Unify the style of the list terminator in acpi_device_id arrays, that is use a single space between { and }. This is the most common and generally recommended style for these.
--- drivers/nfc/fdp/i2c.c | 2 +- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/nfc/fdp/i2c.c +1 -1
@@ -350,7 +350,7 @@ static void fdp_nci_i2c_remove(struct i2c_client *client)static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = { { .id ="INT339A" }, - {} + { } };MODULE_DEVICE_TABLE (acpi, fdp_nci_i2c_acpi_match);
drivers/nfc/pn544/i2c.c +1 -1
@@ -52,7 +52,7 @@ MODULE_DEVICE_TABLE(i2c, pn544_hci_i2c_id_table);static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = { { .id ="NXP5440" }, - {} + { } };MODULE_DEVICE_TABLE (acpi, pn544_hci_i2c_acpi_match);
drivers/nfc/st-nci/i2c.c +1 -1
@@ -265,7 +265,7 @@ MODULE_DEVICE_TABLE(i2c, st_nci_i2c_id_table);static const struct acpi_device_id st_nci_i2c_acpi_match[] = { { .id ="SMO2101" }, { .id ="SMO2102" }, - {} + { } };MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match);
drivers/nfc/st-nci/spi.c +1 -1
@@ -279,7 +279,7 @@ MODULE_DEVICE_TABLE(spi, st_nci_spi_id_table);static const struct acpi_device_id st_nci_spi_acpi_match[] = { { .id ="SMO2101" }, - {} + { } };MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);
drivers/nfc/st21nfca/i2c.c +1 -1
@@ -579,7 +579,7 @@ MODULE_DEVICE_TABLE(i2c, st21nfca_hci_i2c_id_table);static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { { .id ="SMO2100" }, - {} + { } };MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match);
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 5/12 nfc: pn544: Drop empty line between i2c_device_id array and MODULE_DEVICE_TABLE()
In reply to Uwe Kleine-König (The Capable Hub)Usually there is no empty line between a module device table and the respective MODULE_DEVICE_TABLE():
$ git grep -h -B1 ^MODULE_DEVICE_TABLE v7.1-rc1 | sort | uniq -c | sort -n ... 1388 8129 }; 9784 --
(The -- is part of grep output to separate the matches with their context from each other, that's not the most usual line before MODULE_DEVICE_TABLE(...).)
--- drivers/nfc/pn544/i2c.c | 1 - 1 file changed, 1 deletion(-)
drivers/nfc/pn544/i2c.c +0 -1
@@ -47,7 +47,6 @@ static const struct i2c_device_id pn544_hci_i2c_id_table[] = { { .name = "pn544" }, { } }; -MODULE_DEVICE_TABLE (i2c, pn544_hci_i2c_id_table);static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = {
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 6/12 nfc: Initialize mei_cl_device_idarrays using member names
In reply to Uwe Kleine-König (The Capable Hub)While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition.
The mentioned robustness is relevant for a planned change to struct mei_cl_device_id that replaces .driver_data by an anonymous union.
This patch doesn't modify the compiled arrays, only their representation in source form benefits.
--- drivers/nfc/microread/mei.c | 10 ++++++---- drivers/nfc/pn544/mei.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/nfc/microread/mei.c +6 -4
@@ -48,10 +48,12 @@ static void microread_mei_remove(struct mei_cl_device *cldev) }static struct mei_cl_device_id microread_mei_tbl[] = { - {MICROREAD_DRIVER_NAME ,MEI_NFC_UUID ,MEI_CL_VERSION_ANY }, - -/* required last entry */ - { } + { + .name =MICROREAD_DRIVER_NAME , + .uuid =MEI_NFC_UUID , + .version =MEI_CL_VERSION_ANY , + }, + {/* required last entry */ } };MODULE_DEVICE_TABLE (mei, microread_mei_tbl);
drivers/nfc/pn544/mei.c +6 -4
@@ -47,10 +47,12 @@ static void pn544_mei_remove(struct mei_cl_device *cldev) }static struct mei_cl_device_id pn544_mei_tbl[] = { - {PN544_DRIVER_NAME ,MEI_NFC_UUID ,MEI_CL_VERSION_ANY }, - -/* required last entry */ - { } + { + .name =PN544_DRIVER_NAME , + .uuid =MEI_NFC_UUID , + .version =MEI_CL_VERSION_ANY , + }, + {/* required last entry */ } };MODULE_DEVICE_TABLE (mei, pn544_mei_tbl);
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 7/12 nfc: Drop __maybe_unused from of_device_id tables
In reply to Uwe Kleine-König (The Capable Hub)Referencing these arrays in MODULE_DEVICE_TABLE() is enough to convince the compiler that they are used even if the drivers are built-in (since 5ab23c7923a1 ("modpost: Create modalias for builtin modules"). So the __maybe_unused marking can be removed without introducing a compiler warning.
--- drivers/nfc/nfcmrvl/i2c.c | 2 +- drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/pn533/i2c.c | 2 +- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/s3fwrn5/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)
drivers/nfc/nfcmrvl/i2c.c +1 -1
@@ -245,7 +245,7 @@ static void nfcmrvl_i2c_remove(struct i2c_client *client) } -static const struct of_device_id of_nfcmrvl_i2c_match[]__maybe_unused = { +static const struct of_device_id of_nfcmrvl_i2c_match[] = { { .compatible ="marvell,nfc-i2c" , }, {}, };
drivers/nfc/nfcmrvl/spi.c +1 -1
@@ -181,7 +181,7 @@ static void nfcmrvl_spi_remove(struct spi_device *spi)nfcmrvl_nci_unregister_dev (drv_data->priv); } -static const struct of_device_id of_nfcmrvl_spi_match[]__maybe_unused = { +static const struct of_device_id of_nfcmrvl_spi_match[] = { { .compatible ="marvell,nfc-spi" , }, {}, };
drivers/nfc/pn533/i2c.c +1 -1
@@ -236,7 +236,7 @@ static void pn533_i2c_remove(struct i2c_client *client)pn53x_common_clean (phy->priv); } -static const struct of_device_id of_pn533_i2c_match[]__maybe_unused = { +static const struct of_device_id of_pn533_i2c_match[] = { { .compatible ="nxp,pn532" , },/* * NOTE: The use of the compatibles with the trailing "...-i2c" is
drivers/nfc/pn544/i2c.c +1 -1
@@ -937,7 +937,7 @@ static void pn544_hci_i2c_remove(struct i2c_client *client)pn544_hci_i2c_disable (phy); } -static const struct of_device_id of_pn544_i2c_match[]__maybe_unused = { +static const struct of_device_id of_pn544_i2c_match[] = { { .compatible ="nxp,pn544-i2c" , }, {}, };
drivers/nfc/s3fwrn5/i2c.c +1 -1
@@ -210,7 +210,7 @@ static const struct i2c_device_id s3fwrn5_i2c_id_table[] = { };MODULE_DEVICE_TABLE (i2c, s3fwrn5_i2c_id_table); -static const struct of_device_id of_s3fwrn5_i2c_match[]__maybe_unused = { +static const struct of_device_id of_s3fwrn5_i2c_match[] = { { .compatible ="samsung,s3fwrn5-i2c" , }, {} };
drivers/nfc/st-nci/i2c.c +1 -1
@@ -269,7 +269,7 @@ static const struct acpi_device_id st_nci_i2c_acpi_match[] = { };MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match); -static const struct of_device_id of_st_nci_i2c_match[]__maybe_unused = { +static const struct of_device_id of_st_nci_i2c_match[] = { { .compatible ="st,st21nfcb-i2c" , }, { .compatible ="st,st21nfcb_i2c" , }, { .compatible ="st,st21nfcc-i2c" , },
drivers/nfc/st-nci/spi.c +1 -1
@@ -283,7 +283,7 @@ static const struct acpi_device_id st_nci_spi_acpi_match[] = { };MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match); -static const struct of_device_id of_st_nci_spi_match[]__maybe_unused = { +static const struct of_device_id of_st_nci_spi_match[] = { { .compatible ="st,st21nfcb-spi" , }, {} };
drivers/nfc/st21nfca/i2c.c +1 -1
@@ -583,7 +583,7 @@ static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { };MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match); -static const struct of_device_id of_st21nfca_i2c_match[]__maybe_unused = { +static const struct of_device_id of_st21nfca_i2c_match[] = { { .compatible ="st,st21nfca-i2c" , }, { .compatible ="st,st21nfca_i2c" , }, {}
drivers/nfc/st95hf/core.c +1 -1
@@ -1054,7 +1054,7 @@ static const struct spi_device_id st95hf_id[] = { };MODULE_DEVICE_TABLE (spi, st95hf_id); -static const struct of_device_id st95hf_spi_of_match[]__maybe_unused = { +static const struct of_device_id st95hf_spi_of_match[] = { { .compatible ="st,st95hf" }, {}, };
drivers/nfc/trf7970a.c +1 -1
@@ -2303,7 +2303,7 @@ static const struct dev_pm_ops trf7970a_pm_ops = { trf7970a_pm_runtime_resume, NULL) }; -static const struct of_device_id trf7970a_of_match[]__maybe_unused = { +static const struct of_device_id trf7970a_of_match[] = { {.compatible ="ti,trf7970a" ,}, {}, };
Signature · 1 line
2.55.0.11.g153666a7d9bb
Krzysztof Kozlowski
maintainerRe: [PATCH v1 07/12] nfc: Drop __maybe_unused from of_device_id tables
Quoted 25 lines · Uwe Kleine-König (The Capable Hub)
Referencing these arrays in
MODULE_DEVICE_TABLE()is enough to convince the compiler that they are used even if the drivers are built-in (since5ab23c7923a1("modpost: Create modalias for builtin modules"). So the__maybe_unusedmarking can be removed without introducing a compiler warning.Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- drivers/nfc/nfcmrvl/i2c.c | 2 +- drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/pn533/i2c.c | 2 +- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/s3fwrn5/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)drivers/nfc/nfcmrvl/i2c.c +0
-0
drivers/nfc/nfcmrvl/i2c.c static void nfcmrvl_i2c_remove(struct i2c_client *client) · line 250
Quoted 7 lines
drivers/nfc/nfcmrvl/i2c.c +1
-1@@ -245,7 +245,7 @@ static void nfcmrvl_i2c_remove(struct i2c_client *client) } -static const struct of_device_id of_nfcmrvl_i2c_match[]__maybe_unused = { +static const struct of_device_id of_nfcmrvl_i2c_match[] = { { .compatible ="marvell,nfc-i2c" , }, {},
This (and probably others) should re-introduce warnings on !MODULE and !OF builds (and other cases).
Best regards,
Krzysztof
Re: [PATCH v1 07/12] nfc: Drop __maybe_unused from of_device_id tables
Quoted 29 lines · Krzysztof Kozlowski
Quoted 28 lines · Uwe Kleine-König (The Capable Hub)
Referencing these arrays in
MODULE_DEVICE_TABLE()is enough to convince the compiler that they are used even if the drivers are built-in (since5ab23c7923a1("modpost: Create modalias for builtin modules"). So the__maybe_unusedmarking can be removed without introducing a compiler warning.Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- drivers/nfc/nfcmrvl/i2c.c | 2 +- drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/pn533/i2c.c | 2 +- drivers/nfc/pn544/i2c.c | 2 +- drivers/nfc/s3fwrn5/i2c.c | 2 +- drivers/nfc/st-nci/i2c.c | 2 +- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st21nfca/i2c.c | 2 +- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)drivers/nfc/nfcmrvl/i2c.c +0
-0@@ -245,7 +245,7 @@ static void nfcmrvl_i2c_remove(struct i2c_client *client) }
Quoted 7 lines
drivers/nfc/nfcmrvl/i2c.c static void nfcmrvl_i2c_remove(struct i2c_client *client) · line 250
Quoted 4 lines
drivers/nfc/nfcmrvl/i2c.c +1
-1-static const struct of_device_id of_nfcmrvl_i2c_match[]__maybe_unused = { +static const struct of_device_id of_nfcmrvl_i2c_match[] = { { .compatible ="marvell,nfc-i2c" , }, {},This (and probably others) should re-introduce warnings on !MODULE and !OF builds (and other cases).
With an x86_64 allnoconfig and just the things enabled to make this driver build (i.e. I2C and a few NFC related switches, but neither OF nor MODULES) the driver builds fine even with W=1. If I drop MODULE_DEVICE_TABLE() the warning appears. So unless proven otherwise I claim the commit log and the patch are correct.
Best regards
Uwe
PATCH 8/12 nfc: Unify style of of_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)The most common style treewide is:
- A single space in the list terminator and no trailing ,
- No comma after a named initializers iff the closing } is on the same line
Adapt the of_device_id arrays accordingly.
--- drivers/nfc/nfcmrvl/i2c.c | 4 ++-- drivers/nfc/nfcmrvl/spi.c | 4 ++-- drivers/nfc/nxp-nci/i2c.c | 4 ++-- drivers/nfc/pn533/i2c.c | 8 ++++---- drivers/nfc/pn533/uart.c | 4 ++-- drivers/nfc/pn544/i2c.c | 4 ++-- drivers/nfc/s3fwrn5/i2c.c | 4 ++-- drivers/nfc/s3fwrn5/uart.c | 4 ++-- drivers/nfc/st-nci/i2c.c | 8 ++++---- drivers/nfc/st-nci/spi.c | 4 ++-- drivers/nfc/st21nfca/i2c.c | 6 +++--- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 5 ++--- 13 files changed, 30 insertions(+), 31 deletions(-)
drivers/nfc/nfcmrvl/i2c.c +2 -2
@@ -246,8 +246,8 @@ static void nfcmrvl_i2c_remove(struct i2c_client *client)static const struct of_device_id of_nfcmrvl_i2c_match[] = { - { .compatible ="marvell,nfc-i2c" , }, - {}, + { .compatible ="marvell,nfc-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_nfcmrvl_i2c_match);
drivers/nfc/nfcmrvl/spi.c +2 -2
@@ -182,8 +182,8 @@ static void nfcmrvl_spi_remove(struct spi_device *spi) }static const struct of_device_id of_nfcmrvl_spi_match[] = { - { .compatible ="marvell,nfc-spi" , }, - {}, + { .compatible ="marvell,nfc-spi" }, + { } };MODULE_DEVICE_TABLE (of, of_nfcmrvl_spi_match);
drivers/nfc/nxp-nci/i2c.c +2 -2
@@ -355,8 +355,8 @@ static const struct i2c_device_id nxp_nci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, nxp_nci_i2c_id_table);static const struct of_device_id of_nxp_nci_i2c_match[] = { - { .compatible ="nxp,nxp-nci-i2c" , }, - {} + { .compatible ="nxp,nxp-nci-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_nxp_nci_i2c_match);
drivers/nfc/pn533/i2c.c +4 -4
@@ -237,14 +237,14 @@ static void pn533_i2c_remove(struct i2c_client *client) }static const struct of_device_id of_pn533_i2c_match[] = { - { .compatible ="nxp,pn532" , }, + { .compatible ="nxp,pn532" },/* * NOTE: The use of the compatibles with the trailing "...-i2c" is * deprecated and will be removed. */ - { .compatible ="nxp,pn533-i2c" , }, - { .compatible ="nxp,pn532-i2c" , }, - {}, + { .compatible ="nxp,pn533-i2c" }, + { .compatible ="nxp,pn532-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_pn533_i2c_match);
drivers/nfc/pn533/uart.c +2 -2
@@ -238,8 +238,8 @@ static const struct serdev_device_ops pn532_serdev_ops = { };static const struct of_device_id pn532_uart_of_match[] = { - { .compatible ="nxp,pn532" , }, - {}, + { .compatible ="nxp,pn532" }, + { } };MODULE_DEVICE_TABLE (of, pn532_uart_of_match);
drivers/nfc/pn544/i2c.c +2 -2
@@ -938,8 +938,8 @@ static void pn544_hci_i2c_remove(struct i2c_client *client) }static const struct of_device_id of_pn544_i2c_match[] = { - { .compatible ="nxp,pn544-i2c" , }, - {}, + { .compatible ="nxp,pn544-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_pn544_i2c_match);
drivers/nfc/s3fwrn5/i2c.c +2 -2
@@ -211,8 +211,8 @@ static const struct i2c_device_id s3fwrn5_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, s3fwrn5_i2c_id_table);static const struct of_device_id of_s3fwrn5_i2c_match[] = { - { .compatible ="samsung,s3fwrn5-i2c" , }, - {} + { .compatible ="samsung,s3fwrn5-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_s3fwrn5_i2c_match);
drivers/nfc/s3fwrn5/uart.c +2 -2
@@ -85,8 +85,8 @@ static const struct serdev_device_ops s3fwrn82_serdev_ops = { };static const struct of_device_id s3fwrn82_uart_of_match[] = { - { .compatible ="samsung,s3fwrn82" , }, - {}, + { .compatible ="samsung,s3fwrn82" }, + { } };MODULE_DEVICE_TABLE (of, s3fwrn82_uart_of_match);
drivers/nfc/st-nci/i2c.c +4 -4
@@ -270,10 +270,10 @@ static const struct acpi_device_id st_nci_i2c_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match);static const struct of_device_id of_st_nci_i2c_match[] = { - { .compatible ="st,st21nfcb-i2c" , }, - { .compatible ="st,st21nfcb_i2c" , }, - { .compatible ="st,st21nfcc-i2c" , }, - {} + { .compatible ="st,st21nfcb-i2c" }, + { .compatible ="st,st21nfcb_i2c" }, + { .compatible ="st,st21nfcc-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_st_nci_i2c_match);
drivers/nfc/st-nci/spi.c +2 -2
@@ -284,8 +284,8 @@ static const struct acpi_device_id st_nci_spi_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);static const struct of_device_id of_st_nci_spi_match[] = { - { .compatible ="st,st21nfcb-spi" , }, - {} + { .compatible ="st,st21nfcb-spi" }, + { } };MODULE_DEVICE_TABLE (of, of_st_nci_spi_match);
drivers/nfc/st21nfca/i2c.c +3 -3
@@ -584,9 +584,9 @@ static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match);static const struct of_device_id of_st21nfca_i2c_match[] = { - { .compatible ="st,st21nfca-i2c" , }, - { .compatible ="st,st21nfca_i2c" , }, - {} + { .compatible ="st,st21nfca-i2c" }, + { .compatible ="st,st21nfca_i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_st21nfca_i2c_match);
drivers/nfc/st95hf/core.c +1 -1
@@ -1056,7 +1056,7 @@ MODULE_DEVICE_TABLE(spi, st95hf_id);static const struct of_device_id st95hf_spi_of_match[] = { { .compatible ="st,st95hf" }, - {}, + { } };MODULE_DEVICE_TABLE (of, st95hf_spi_of_match);
drivers/nfc/trf7970a.c +2 -3
@@ -2304,10 +2304,9 @@ static const struct dev_pm_ops trf7970a_pm_ops = { };static const struct of_device_id trf7970a_of_match[] = { - {.compatible ="ti,trf7970a" ,}, - {}, + { .compatible ="ti,trf7970a" }, + { } }; -MODULE_DEVICE_TABLE (of, trf7970a_of_match);static const struct spi_device_id trf7970a_id_table[] = {
Signature · 1 line
2.55.0.11.g153666a7d9bb
Re: [PATCH v1 08/12] nfc: Unify style of of_device_id arrays
Quoted 9 lines · Uwe Kleine-König (The Capable Hub)
The most common style treewide is:
- A single space in the list terminator and no trailing ,
- No comma after a named initializers iff the closing } is on the same lineAdapt the
of_device_idarrays accordingly.Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>
Quoted 228 lines
--- drivers/nfc/nfcmrvl/i2c.c | 4 ++-- drivers/nfc/nfcmrvl/spi.c | 4 ++-- drivers/nfc/nxp-nci/i2c.c | 4 ++-- drivers/nfc/pn533/i2c.c | 8 ++++---- drivers/nfc/pn533/uart.c | 4 ++-- drivers/nfc/pn544/i2c.c | 4 ++-- drivers/nfc/s3fwrn5/i2c.c | 4 ++-- drivers/nfc/s3fwrn5/uart.c | 4 ++-- drivers/nfc/st-nci/i2c.c | 8 ++++---- drivers/nfc/st-nci/spi.c | 4 ++-- drivers/nfc/st21nfca/i2c.c | 6 +++--- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 5 ++--- 13 files changed, 30 insertions(+), 31 deletions(-)drivers/nfc/nfcmrvl/i2c.c +2
-2@@ -246,8 +246,8 @@ static void nfcmrvl_i2c_remove(struct i2c_client *client)static const struct of_device_id of_nfcmrvl_i2c_match[] = { - { .compatible ="marvell,nfc-i2c" , }, - {}, + { .compatible ="marvell,nfc-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_nfcmrvl_i2c_match);drivers/nfc/nfcmrvl/spi.c +2
-2@@ -182,8 +182,8 @@ static void nfcmrvl_spi_remove(struct spi_device *spi) }static const struct of_device_id of_nfcmrvl_spi_match[] = { - { .compatible ="marvell,nfc-spi" , }, - {}, + { .compatible ="marvell,nfc-spi" }, + { } };MODULE_DEVICE_TABLE (of, of_nfcmrvl_spi_match);drivers/nfc/nxp-nci/i2c.c +2
-2@@ -355,8 +355,8 @@ static const struct i2c_device_id nxp_nci_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, nxp_nci_i2c_id_table);static const struct of_device_id of_nxp_nci_i2c_match[] = { - { .compatible ="nxp,nxp-nci-i2c" , }, - {} + { .compatible ="nxp,nxp-nci-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_nxp_nci_i2c_match);drivers/nfc/pn533/i2c.c +4
-4@@ -237,14 +237,14 @@ static void pn533_i2c_remove(struct i2c_client *client) }static const struct of_device_id of_pn533_i2c_match[] = { - { .compatible ="nxp,pn532" , }, + { .compatible ="nxp,pn532" },/* * NOTE: The use of the compatibles with the trailing "...-i2c" is * deprecated and will be removed. */ - { .compatible ="nxp,pn533-i2c" , }, - { .compatible ="nxp,pn532-i2c" , }, - {}, + { .compatible ="nxp,pn533-i2c" }, + { .compatible ="nxp,pn532-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_pn533_i2c_match);drivers/nfc/pn533/uart.c +2
-2@@ -238,8 +238,8 @@ static const struct serdev_device_ops pn532_serdev_ops = { };static const struct of_device_id pn532_uart_of_match[] = { - { .compatible ="nxp,pn532" , }, - {}, + { .compatible ="nxp,pn532" }, + { } };MODULE_DEVICE_TABLE (of, pn532_uart_of_match);drivers/nfc/pn544/i2c.c +2
-2@@ -938,8 +938,8 @@ static void pn544_hci_i2c_remove(struct i2c_client *client) }static const struct of_device_id of_pn544_i2c_match[] = { - { .compatible ="nxp,pn544-i2c" , }, - {}, + { .compatible ="nxp,pn544-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_pn544_i2c_match);drivers/nfc/s3fwrn5/i2c.c +2
-2@@ -211,8 +211,8 @@ static const struct i2c_device_id s3fwrn5_i2c_id_table[] = {MODULE_DEVICE_TABLE (i2c, s3fwrn5_i2c_id_table);static const struct of_device_id of_s3fwrn5_i2c_match[] = { - { .compatible ="samsung,s3fwrn5-i2c" , }, - {} + { .compatible ="samsung,s3fwrn5-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_s3fwrn5_i2c_match);drivers/nfc/s3fwrn5/uart.c +2
-2@@ -85,8 +85,8 @@ static const struct serdev_device_ops s3fwrn82_serdev_ops = { };static const struct of_device_id s3fwrn82_uart_of_match[] = { - { .compatible ="samsung,s3fwrn82" , }, - {}, + { .compatible ="samsung,s3fwrn82" }, + { } };MODULE_DEVICE_TABLE (of, s3fwrn82_uart_of_match);drivers/nfc/st-nci/i2c.c +4
-4@@ -270,10 +270,10 @@ static const struct acpi_device_id st_nci_i2c_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st_nci_i2c_acpi_match);static const struct of_device_id of_st_nci_i2c_match[] = { - { .compatible ="st,st21nfcb-i2c" , }, - { .compatible ="st,st21nfcb_i2c" , }, - { .compatible ="st,st21nfcc-i2c" , }, - {} + { .compatible ="st,st21nfcb-i2c" }, + { .compatible ="st,st21nfcb_i2c" }, + { .compatible ="st,st21nfcc-i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_st_nci_i2c_match);drivers/nfc/st-nci/spi.c +2
-2@@ -284,8 +284,8 @@ static const struct acpi_device_id st_nci_spi_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st_nci_spi_acpi_match);static const struct of_device_id of_st_nci_spi_match[] = { - { .compatible ="st,st21nfcb-spi" , }, - {} + { .compatible ="st,st21nfcb-spi" }, + { } };MODULE_DEVICE_TABLE (of, of_st_nci_spi_match);drivers/nfc/st21nfca/i2c.c +3
-3@@ -584,9 +584,9 @@ static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, st21nfca_hci_i2c_acpi_match);static const struct of_device_id of_st21nfca_i2c_match[] = { - { .compatible ="st,st21nfca-i2c" , }, - { .compatible ="st,st21nfca_i2c" , }, - {} + { .compatible ="st,st21nfca-i2c" }, + { .compatible ="st,st21nfca_i2c" }, + { } };MODULE_DEVICE_TABLE (of, of_st21nfca_i2c_match);drivers/nfc/st95hf/core.c +1
-1@@ -1056,7 +1056,7 @@ MODULE_DEVICE_TABLE(spi, st95hf_id);static const struct of_device_id st95hf_spi_of_match[] = { { .compatible ="st,st95hf" }, - {}, + { } };MODULE_DEVICE_TABLE (of, st95hf_spi_of_match);drivers/nfc/trf7970a.c +2
-4@@ -2304,10 +2304,9 @@ static const struct dev_pm_ops trf7970a_pm_ops = { };static const struct of_device_id trf7970a_of_match[] = { - {.compatible ="ti,trf7970a" ,}, - {}, + { .compatible ="ti,trf7970a" }, + { } }; -MODULE_DEVICE_TABLE (of, trf7970a_of_match);static const struct spi_device_id trf7970a_id_table[] = { --2.55.0.11.g153666a7d9bb
PATCH 9/12 nfc: Drop unused assignment of spi_device_id driver data
In reply to Uwe Kleine-König (The Capable Hub)The drivers explicitly set the .driver_data member of struct spi_device_id to zero without relying on that value. Drop these unused assignments.
This patch doesn't modify the compiled arrays, only their representation in source form benefits.
--- drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/st-nci/spi.c | 4 ++-- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/nfc/nfcmrvl/spi.c +1 -1
@@ -188,7 +188,7 @@ static const struct of_device_id of_nfcmrvl_spi_match[] = {MODULE_DEVICE_TABLE (of, of_nfcmrvl_spi_match);static const struct spi_device_id nfcmrvl_spi_id_table[] = { - {"nfcmrvl_spi" ,0 }, + {"nfcmrvl_spi" }, { } };MODULE_DEVICE_TABLE (spi, nfcmrvl_spi_id_table);
drivers/nfc/st-nci/spi.c +2 -2
@@ -271,8 +271,8 @@ static void st_nci_spi_remove(struct spi_device *dev) }static struct spi_device_id st_nci_spi_id_table[] = { - {ST_NCI_SPI_DRIVER_NAME ,0 }, - {"st21nfcb-spi" ,0 }, + {ST_NCI_SPI_DRIVER_NAME }, + {"st21nfcb-spi" }, {} };MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);
drivers/nfc/st95hf/core.c +1 -1
@@ -1049,7 +1049,7 @@ static const struct nfc_digital_ops st95hf_nfc_digital_ops = { };static const struct spi_device_id st95hf_id[] = { - {"st95hf" ,0 }, + {"st95hf" }, {} };MODULE_DEVICE_TABLE (spi, st95hf_id);
drivers/nfc/trf7970a.c +1 -1
@@ -2310,7 +2310,7 @@ static const struct of_device_id trf7970a_of_match[] = {MODULE_DEVICE_TABLE (of, trf7970a_of_match);static const struct spi_device_id trf7970a_id_table[] = { - {"trf7970a" ,0 }, + {"trf7970a" }, {} };
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 10/12 nfc: Initialize spi_device_idarrays using member names
In reply to Uwe Kleine-König (The Capable Hub)While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition.
The mentioned robustness is relevant for a planned change to struct spi_device_id that replaces .driver_data by an anonymous union.
This patch doesn't modify the compiled arrays, only their representation in source form benefits.
--- drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/st-nci/spi.c | 4 ++-- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/nfc/nfcmrvl/spi.c +1 -1
@@ -188,7 +188,7 @@ static const struct of_device_id of_nfcmrvl_spi_match[] = {MODULE_DEVICE_TABLE (of, of_nfcmrvl_spi_match);static const struct spi_device_id nfcmrvl_spi_id_table[] = { - {"nfcmrvl_spi" }, + { .name ="nfcmrvl_spi" }, { } };MODULE_DEVICE_TABLE (spi, nfcmrvl_spi_id_table);
drivers/nfc/st-nci/spi.c +2 -2
@@ -271,8 +271,8 @@ static void st_nci_spi_remove(struct spi_device *dev) }static struct spi_device_id st_nci_spi_id_table[] = { - {ST_NCI_SPI_DRIVER_NAME }, - {"st21nfcb-spi" }, + { .name =ST_NCI_SPI_DRIVER_NAME }, + { .name ="st21nfcb-spi" }, {} };MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);
drivers/nfc/st95hf/core.c +1 -1
@@ -1049,7 +1049,7 @@ static const struct nfc_digital_ops st95hf_nfc_digital_ops = { };static const struct spi_device_id st95hf_id[] = { - {"st95hf" }, + { .name ="st95hf" }, {} };MODULE_DEVICE_TABLE (spi, st95hf_id);
drivers/nfc/trf7970a.c +1 -1
@@ -2310,7 +2310,7 @@ static const struct of_device_id trf7970a_of_match[] = {MODULE_DEVICE_TABLE (of, trf7970a_of_match);static const struct spi_device_id trf7970a_id_table[] = { - {"trf7970a" }, + { .name ="trf7970a" }, {} };
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 11/12 nfc: Unify style of spi_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Unify the style of the list terminator in spi_device_id arrays, that is use a single space between { and }. This is the most common and generally recommended style for these.
--- drivers/nfc/st-nci/spi.c | 2 +- drivers/nfc/st95hf/core.c | 2 +- drivers/nfc/trf7970a.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-)
drivers/nfc/st-nci/spi.c +1 -1
@@ -273,7 +273,7 @@ static void st_nci_spi_remove(struct spi_device *dev)static struct spi_device_id st_nci_spi_id_table[] = { { .name =ST_NCI_SPI_DRIVER_NAME }, { .name ="st21nfcb-spi" }, - {} + { } };MODULE_DEVICE_TABLE (spi, st_nci_spi_id_table);
drivers/nfc/st95hf/core.c +1 -1
@@ -1050,7 +1050,7 @@ static const struct nfc_digital_ops st95hf_nfc_digital_ops = {static const struct spi_device_id st95hf_id[] = { { .name ="st95hf" }, - {} + { } };MODULE_DEVICE_TABLE (spi, st95hf_id);
drivers/nfc/trf7970a.c +1 -2
@@ -2311,9 +2311,8 @@ MODULE_DEVICE_TABLE(of, trf7970a_of_match);static const struct spi_device_id trf7970a_id_table[] = { { .name ="trf7970a" }, - {} + { } }; -MODULE_DEVICE_TABLE (spi, trf7970a_id_table);static struct spi_driver trf7970a_spi_driver = {
Signature · 1 line
2.55.0.11.g153666a7d9bb
PATCH 12/12 nfc: Unify style of usb_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)The usual coding style is to skip the comma after a initializer iff the closing } is on the same line. Also there is usually no empty line between the array and the MODULE_DEVICE_TABLE() macro.
Adapt two drivers accordingly to match this common style.
--- drivers/nfc/nfcmrvl/usb.c | 1 - drivers/nfc/port100.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/nfc/nfcmrvl/usb.c +0 -1
@@ -17,7 +17,6 @@ static struct usb_device_id nfcmrvl_table[] = { USB_CLASS_VENDOR_SPEC, 4, 1) }, { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, nfcmrvl_table);#define NFCMRVL_USB_BULK_RUNNING 1
drivers/nfc/port100.c +2 -2
@@ -1480,8 +1480,8 @@ static const struct nfc_digital_ops port100_digital_ops = { };static const struct usb_device_id port100_table[] = { - {USB_DEVICE (SONY_VENDOR_ID ,RCS380S_PRODUCT_ID ), }, - {USB_DEVICE (SONY_VENDOR_ID ,RCS380P_PRODUCT_ID ), }, + {USB_DEVICE (SONY_VENDOR_ID ,RCS380S_PRODUCT_ID ) }, + {USB_DEVICE (SONY_VENDOR_ID ,RCS380P_PRODUCT_ID ) }, { } };MODULE_DEVICE_TABLE (usb, port100_table);
Signature · 1 line
2.55.0.11.g153666a7d9bb