* [PATCH 0/2 net-next] net: dsa: add private context accessor
@ 2014-04-28 18:14 Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 1/2] net: dsa: add ds_to_priv Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Florian Fainelli @ 2014-04-28 18:14 UTC (permalink / raw)
To: netdev; +Cc: davem, buytenh, Florian Fainelli
Lennert, David,
This patchset adds a private context accessors instead of doing the
(void *)(ds + 1) trick in DSA drivers that require the use of a private
context.
Florian Fainelli (2):
net: dsa: add ds_to_priv
net: dsa: update DSA drivers to use ds_to_priv
drivers/net/dsa/mv88e6123_61_65.c | 2 +-
drivers/net/dsa/mv88e6131.c | 4 ++--
drivers/net/dsa/mv88e6xxx.c | 12 ++++++------
include/net/dsa.h | 5 +++++
4 files changed, 14 insertions(+), 9 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 1/2] net: dsa: add ds_to_priv
2014-04-28 18:14 [PATCH 0/2 net-next] net: dsa: add private context accessor Florian Fainelli
@ 2014-04-28 18:14 ` Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 2/2] net: dsa: update DSA drivers to use ds_to_priv Florian Fainelli
2014-04-30 17:31 ` [PATCH 0/2 net-next] net: dsa: add private context accessor David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2014-04-28 18:14 UTC (permalink / raw)
To: netdev; +Cc: davem, buytenh, Florian Fainelli
DSA drivers have a trick which consists in allocating "priv_size" more
bytes to account for the DSA driver private context. Add a helper
function to access that private context instead of open-coding it in
drivers with (void *)(ds + 1).
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/net/dsa.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7828ebf99ee1..6efce384451e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -181,6 +181,11 @@ struct dsa_switch_driver {
void register_switch_driver(struct dsa_switch_driver *type);
void unregister_switch_driver(struct dsa_switch_driver *type);
+static inline void *ds_to_priv(struct dsa_switch *ds)
+{
+ return (void *)(ds + 1);
+}
+
/*
* The original DSA tag format and some other tag formats have no
* ethertype, which means that we need to add a little hack to the
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] net: dsa: update DSA drivers to use ds_to_priv
2014-04-28 18:14 [PATCH 0/2 net-next] net: dsa: add private context accessor Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 1/2] net: dsa: add ds_to_priv Florian Fainelli
@ 2014-04-28 18:14 ` Florian Fainelli
2014-04-30 17:31 ` [PATCH 0/2 net-next] net: dsa: add private context accessor David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2014-04-28 18:14 UTC (permalink / raw)
To: netdev; +Cc: davem, buytenh, Florian Fainelli
Use the helper function to retrieve the driver private context instead of
using (void *)(ds + 1).
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/dsa/mv88e6123_61_65.c | 2 +-
drivers/net/dsa/mv88e6131.c | 4 ++--
drivers/net/dsa/mv88e6xxx.c | 12 ++++++------
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c
index 41ee5b6ae917..69c42513dd72 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -289,7 +289,7 @@ static int mv88e6123_61_65_setup_port(struct dsa_switch *ds, int p)
static int mv88e6123_61_65_setup(struct dsa_switch *ds)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int i;
int ret;
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index dadfafba64e9..953bc6a49e59 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -155,7 +155,7 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
static int mv88e6131_setup_port(struct dsa_switch *ds, int p)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int addr = REG_PORT(p);
u16 val;
@@ -274,7 +274,7 @@ static int mv88e6131_setup_port(struct dsa_switch *ds, int p)
static int mv88e6131_setup(struct dsa_switch *ds)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int i;
int ret;
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 17314ed9456d..9ce2146346b6 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -74,7 +74,7 @@ int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg)
int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
mutex_lock(&ps->smi_mutex);
@@ -118,7 +118,7 @@ int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr,
int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
mutex_lock(&ps->smi_mutex);
@@ -256,7 +256,7 @@ static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps)
static int mv88e6xxx_ppu_access_get(struct dsa_switch *ds)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
mutex_lock(&ps->ppu_mutex);
@@ -283,7 +283,7 @@ static int mv88e6xxx_ppu_access_get(struct dsa_switch *ds)
static void mv88e6xxx_ppu_access_put(struct dsa_switch *ds)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
/* Schedule a timer to re-enable the PHY polling unit. */
mod_timer(&ps->ppu_timer, jiffies + msecs_to_jiffies(10));
@@ -292,7 +292,7 @@ static void mv88e6xxx_ppu_access_put(struct dsa_switch *ds)
void mv88e6xxx_ppu_state_init(struct dsa_switch *ds)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
mutex_init(&ps->ppu_mutex);
INIT_WORK(&ps->ppu_work, mv88e6xxx_ppu_reenable_work);
@@ -463,7 +463,7 @@ void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
int nr_stats, struct mv88e6xxx_hw_stat *stats,
int port, uint64_t *data)
{
- struct mv88e6xxx_priv_state *ps = (void *)(ds + 1);
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
int i;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2 net-next] net: dsa: add private context accessor
2014-04-28 18:14 [PATCH 0/2 net-next] net: dsa: add private context accessor Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 1/2] net: dsa: add ds_to_priv Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 2/2] net: dsa: update DSA drivers to use ds_to_priv Florian Fainelli
@ 2014-04-30 17:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-30 17:31 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev, buytenh
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 28 Apr 2014 11:14:26 -0700
> This patchset adds a private context accessors instead of doing the
> (void *)(ds + 1) trick in DSA drivers that require the use of a private
> context.
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-30 17:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-28 18:14 [PATCH 0/2 net-next] net: dsa: add private context accessor Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 1/2] net: dsa: add ds_to_priv Florian Fainelli
2014-04-28 18:14 ` [PATCH net-next 2/2] net: dsa: update DSA drivers to use ds_to_priv Florian Fainelli
2014-04-30 17:31 ` [PATCH 0/2 net-next] net: dsa: add private context accessor David Miller
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).