* [PATCH 0/2] nfc: pn533: Constify ops-structs
@ 2021-10-06 22:47 Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 1/2] nfc: pn533: Constify serdev_device_ops Rikard Falkeborn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-10-06 22:47 UTC (permalink / raw)
To: Krzysztof Kozlowski, Jakub Kicinski, David S. Miller
Cc: netdev, linux-kernel, linux-nfc, Rikard Falkeborn
Constify a couple of ops-structs. This allows the compiler to put the
static structs in read-only memory.
Rikard Falkeborn (2):
nfc: pn533: Constify serdev_device_ops
nfc: pn533: Constify pn533_phy_ops
drivers/nfc/pn533/i2c.c | 2 +-
drivers/nfc/pn533/pn533.c | 2 +-
drivers/nfc/pn533/pn533.h | 4 ++--
drivers/nfc/pn533/uart.c | 4 ++--
drivers/nfc/pn533/usb.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] nfc: pn533: Constify serdev_device_ops
2021-10-06 22:47 [PATCH 0/2] nfc: pn533: Constify ops-structs Rikard Falkeborn
@ 2021-10-06 22:47 ` Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 2/2] nfc: pn533: Constify pn533_phy_ops Rikard Falkeborn
2021-10-07 12:40 ` [PATCH 0/2] nfc: pn533: Constify ops-structs patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-10-06 22:47 UTC (permalink / raw)
To: Krzysztof Kozlowski, Jakub Kicinski, David S. Miller
Cc: netdev, linux-kernel, linux-nfc, Rikard Falkeborn
The only usage of pn532_serdev_ops is to pass its address to
serdev_device_set_client_ops(), which takes a pointer to const
serdev_device_ops as argument. Make it const to allow the compiler to
put it in read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/nfc/pn533/uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/pn533/uart.c b/drivers/nfc/pn533/uart.c
index 7bdaf8263070..77bb073f031a 100644
--- a/drivers/nfc/pn533/uart.c
+++ b/drivers/nfc/pn533/uart.c
@@ -224,7 +224,7 @@ static int pn532_receive_buf(struct serdev_device *serdev,
return i;
}
-static struct serdev_device_ops pn532_serdev_ops = {
+static const struct serdev_device_ops pn532_serdev_ops = {
.receive_buf = pn532_receive_buf,
.write_wakeup = serdev_device_write_wakeup,
};
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] nfc: pn533: Constify pn533_phy_ops
2021-10-06 22:47 [PATCH 0/2] nfc: pn533: Constify ops-structs Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 1/2] nfc: pn533: Constify serdev_device_ops Rikard Falkeborn
@ 2021-10-06 22:47 ` Rikard Falkeborn
2021-10-07 12:40 ` [PATCH 0/2] nfc: pn533: Constify ops-structs patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-10-06 22:47 UTC (permalink / raw)
To: Krzysztof Kozlowski, Jakub Kicinski, David S. Miller
Cc: netdev, linux-kernel, linux-nfc, Rikard Falkeborn
Neither the driver or the core modifies the pn533_phy_ops struct, so
make them const to allow the compiler to put the static structs in
read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/nfc/pn533/i2c.c | 2 +-
drivers/nfc/pn533/pn533.c | 2 +-
drivers/nfc/pn533/pn533.h | 4 ++--
drivers/nfc/pn533/uart.c | 2 +-
drivers/nfc/pn533/usb.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c
index f5610b6b9894..673eb5e9b887 100644
--- a/drivers/nfc/pn533/i2c.c
+++ b/drivers/nfc/pn533/i2c.c
@@ -156,7 +156,7 @@ static irqreturn_t pn533_i2c_irq_thread_fn(int irq, void *data)
return IRQ_HANDLED;
}
-static struct pn533_phy_ops i2c_phy_ops = {
+static const struct pn533_phy_ops i2c_phy_ops = {
.send_frame = pn533_i2c_send_frame,
.send_ack = pn533_i2c_send_ack,
.abort_cmd = pn533_i2c_abort_cmd,
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index da180335422c..787bcbd290f7 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2733,7 +2733,7 @@ EXPORT_SYMBOL_GPL(pn533_finalize_setup);
struct pn533 *pn53x_common_init(u32 device_type,
enum pn533_protocol_type protocol_type,
void *phy,
- struct pn533_phy_ops *phy_ops,
+ const struct pn533_phy_ops *phy_ops,
struct pn533_frame_ops *fops,
struct device *dev)
{
diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h
index 5f94f38a2a08..09e35b8693f5 100644
--- a/drivers/nfc/pn533/pn533.h
+++ b/drivers/nfc/pn533/pn533.h
@@ -177,7 +177,7 @@ struct pn533 {
struct device *dev;
void *phy;
- struct pn533_phy_ops *phy_ops;
+ const struct pn533_phy_ops *phy_ops;
};
typedef int (*pn533_send_async_complete_t) (struct pn533 *dev, void *arg,
@@ -232,7 +232,7 @@ struct pn533_phy_ops {
struct pn533 *pn53x_common_init(u32 device_type,
enum pn533_protocol_type protocol_type,
void *phy,
- struct pn533_phy_ops *phy_ops,
+ const struct pn533_phy_ops *phy_ops,
struct pn533_frame_ops *fops,
struct device *dev);
diff --git a/drivers/nfc/pn533/uart.c b/drivers/nfc/pn533/uart.c
index 77bb073f031a..2caf997f9bc9 100644
--- a/drivers/nfc/pn533/uart.c
+++ b/drivers/nfc/pn533/uart.c
@@ -123,7 +123,7 @@ static int pn532_dev_down(struct pn533 *dev)
return 0;
}
-static struct pn533_phy_ops uart_phy_ops = {
+static const struct pn533_phy_ops uart_phy_ops = {
.send_frame = pn532_uart_send_frame,
.send_ack = pn532_uart_send_ack,
.abort_cmd = pn532_uart_abort_cmd,
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index bd7f7478d189..6f71ac72012e 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -429,7 +429,7 @@ static void pn533_send_complete(struct urb *urb)
}
}
-static struct pn533_phy_ops usb_phy_ops = {
+static const struct pn533_phy_ops usb_phy_ops = {
.send_frame = pn533_usb_send_frame,
.send_ack = pn533_usb_send_ack,
.abort_cmd = pn533_usb_abort_cmd,
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] nfc: pn533: Constify ops-structs
2021-10-06 22:47 [PATCH 0/2] nfc: pn533: Constify ops-structs Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 1/2] nfc: pn533: Constify serdev_device_ops Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 2/2] nfc: pn533: Constify pn533_phy_ops Rikard Falkeborn
@ 2021-10-07 12:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-07 12:40 UTC (permalink / raw)
To: Rikard Falkeborn
Cc: krzysztof.kozlowski, kuba, davem, netdev, linux-kernel, linux-nfc
Hello:
This series was applied to netdev/net-next.git (refs/heads/master)
by David S. Miller <davem@davemloft.net>:
On Thu, 7 Oct 2021 00:47:36 +0200 you wrote:
> Constify a couple of ops-structs. This allows the compiler to put the
> static structs in read-only memory.
>
> Rikard Falkeborn (2):
> nfc: pn533: Constify serdev_device_ops
> nfc: pn533: Constify pn533_phy_ops
>
> [...]
Here is the summary with links:
- [1/2] nfc: pn533: Constify serdev_device_ops
https://git.kernel.org/netdev/net-next/c/be5f60d8b6f9
- [2/2] nfc: pn533: Constify pn533_phy_ops
https://git.kernel.org/netdev/net-next/c/bc642817b6d9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-07 12:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 22:47 [PATCH 0/2] nfc: pn533: Constify ops-structs Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 1/2] nfc: pn533: Constify serdev_device_ops Rikard Falkeborn
2021-10-06 22:47 ` [PATCH 2/2] nfc: pn533: Constify pn533_phy_ops Rikard Falkeborn
2021-10-07 12:40 ` [PATCH 0/2] nfc: pn533: Constify ops-structs patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).