* [PATCH 1/2] staging: fieldbus: anybus-s: keep device bus id in bus endianness
@ 2019-04-30 15:25 Sven Van Asbroeck
2019-04-30 15:25 ` [PATCH 2/2] staging: fieldbus: anybus-s: rename bus id field to avoid confusion Sven Van Asbroeck
0 siblings, 1 reply; 2+ messages in thread
From: Sven Van Asbroeck @ 2019-04-30 15:25 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Al Viro, Nicholas Mc Guire
"Normal" bus structures such as USB or PCI keep device bus ids
in bus endinanness, and driver bus ids in host endianness.
Endianness conversion happens each time bus_match() is called.
Modify anybus-s to conform to this pattern. As a pleasant side-
effect, sparse warnings will now disappear.
This was suggested by Al Viro.
Link: https://lkml.org/lkml/2019/4/30/834
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
---
drivers/staging/fieldbus/anybuss/anybuss-client.h | 2 +-
drivers/staging/fieldbus/anybuss/host.c | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/fieldbus/anybuss/anybuss-client.h b/drivers/staging/fieldbus/anybuss/anybuss-client.h
index 2e48fb8f0209..dce60f86c16f 100644
--- a/drivers/staging/fieldbus/anybuss/anybuss-client.h
+++ b/drivers/staging/fieldbus/anybuss/anybuss-client.h
@@ -17,7 +17,7 @@ struct anybuss_host;
struct anybuss_client {
struct device dev;
struct anybuss_host *host;
- u16 fieldbus_type;
+ __be16 fieldbus_type;
/*
* these can be optionally set by the client to receive event
* notifications from the host.
diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index a64fe03b61fa..33a241dbec52 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1173,7 +1173,7 @@ static int anybus_bus_match(struct device *dev,
struct anybuss_client *adev =
to_anybuss_client(dev);
- return adrv->fieldbus_type == adev->fieldbus_type;
+ return adrv->fieldbus_type == be16_to_cpu(adev->fieldbus_type);
}
static int anybus_bus_probe(struct device *dev)
@@ -1264,7 +1264,7 @@ anybuss_host_common_probe(struct device *dev,
{
int ret, i;
u8 val[4];
- u16 fieldbus_type;
+ __be16 fieldbus_type;
struct anybuss_host *cd;
cd = devm_kzalloc(dev, sizeof(*cd), GFP_KERNEL);
@@ -1347,8 +1347,7 @@ anybuss_host_common_probe(struct device *dev,
add_device_randomness(&val, 4);
regmap_bulk_read(cd->regmap, REG_FIELDBUS_TYPE, &fieldbus_type,
sizeof(fieldbus_type));
- fieldbus_type = be16_to_cpu(fieldbus_type);
- dev_info(dev, "Fieldbus type: %04X", fieldbus_type);
+ dev_info(dev, "Fieldbus type: %04X", be16_to_cpu(fieldbus_type));
regmap_bulk_read(cd->regmap, REG_MODULE_SW_V, val, 2);
dev_info(dev, "Module SW version: %02X%02X",
val[0], val[1]);
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] staging: fieldbus: anybus-s: rename bus id field to avoid confusion
2019-04-30 15:25 [PATCH 1/2] staging: fieldbus: anybus-s: keep device bus id in bus endianness Sven Van Asbroeck
@ 2019-04-30 15:25 ` Sven Van Asbroeck
0 siblings, 0 replies; 2+ messages in thread
From: Sven Van Asbroeck @ 2019-04-30 15:25 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Al Viro, Nicholas Mc Guire
Rename the anybus-s bus id from fieldbus_type to anybus_id, to
avoid confusion with an identically named variable in the
fieldbus_dev framework.
Although this value is called fieldbus_type in the anybus-s docs,
it acts like a bus id, so the name change is appropriate.
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
---
drivers/staging/fieldbus/anybuss/anybuss-client.h | 4 ++--
drivers/staging/fieldbus/anybuss/hms-profinet.c | 2 +-
drivers/staging/fieldbus/anybuss/host.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/fieldbus/anybuss/anybuss-client.h b/drivers/staging/fieldbus/anybuss/anybuss-client.h
index dce60f86c16f..0c4b6a1ffe10 100644
--- a/drivers/staging/fieldbus/anybuss/anybuss-client.h
+++ b/drivers/staging/fieldbus/anybuss/anybuss-client.h
@@ -17,7 +17,7 @@ struct anybuss_host;
struct anybuss_client {
struct device dev;
struct anybuss_host *host;
- __be16 fieldbus_type;
+ __be16 anybus_id;
/*
* these can be optionally set by the client to receive event
* notifications from the host.
@@ -30,7 +30,7 @@ struct anybuss_client_driver {
struct device_driver driver;
int (*probe)(struct anybuss_client *adev);
int (*remove)(struct anybuss_client *adev);
- u16 fieldbus_type;
+ u16 anybus_id;
};
int anybuss_client_driver_register(struct anybuss_client_driver *drv);
diff --git a/drivers/staging/fieldbus/anybuss/hms-profinet.c b/drivers/staging/fieldbus/anybuss/hms-profinet.c
index c5db648aa65f..5446843e35f4 100644
--- a/drivers/staging/fieldbus/anybuss/hms-profinet.c
+++ b/drivers/staging/fieldbus/anybuss/hms-profinet.c
@@ -208,7 +208,7 @@ static struct anybuss_client_driver profinet_driver = {
.name = "hms-profinet",
.owner = THIS_MODULE,
},
- .fieldbus_type = 0x0089,
+ .anybus_id = 0x0089,
};
static int __init profinet_init(void)
diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index 33a241dbec52..f69dc4930457 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1173,7 +1173,7 @@ static int anybus_bus_match(struct device *dev,
struct anybuss_client *adev =
to_anybuss_client(dev);
- return adrv->fieldbus_type == be16_to_cpu(adev->fieldbus_type);
+ return adrv->anybus_id == be16_to_cpu(adev->anybus_id);
}
static int anybus_bus_probe(struct device *dev)
@@ -1371,7 +1371,7 @@ anybuss_host_common_probe(struct device *dev,
ret = -ENOMEM;
goto err_kthread;
}
- cd->client->fieldbus_type = fieldbus_type;
+ cd->client->anybus_id = fieldbus_type;
cd->client->host = cd;
cd->client->dev.bus = &anybus_bus;
cd->client->dev.parent = dev;
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-30 15:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 15:25 [PATCH 1/2] staging: fieldbus: anybus-s: keep device bus id in bus endianness Sven Van Asbroeck
2019-04-30 15:25 ` [PATCH 2/2] staging: fieldbus: anybus-s: rename bus id field to avoid confusion Sven Van Asbroeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®