Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1422198 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2016-06-14 20:40 +0200 |
| Last post | 2016-06-14 23:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 net-next v2 08/12] net: dsa: mv88e6xxx: read switch ID from info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-06-14 20:40 +0200
Re: [PATCH v2 net-next v2 08/12] net: dsa: mv88e6xxx: read switch ID from info Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-06-14 21:00 +0200
Re: [PATCH v2 net-next v2 08/12] net: dsa: mv88e6xxx: read switch ID from info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-06-14 23:10 +0200
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-06-14 20:40 +0200 |
| Subject | [PATCH v2 net-next v2 08/12] net: dsa: mv88e6xxx: read switch ID from info |
| Message-ID | <rK1pM-88-29@gated-at.bofh.it> |
Retrieve the info structure of the compatible of device in the new probe
function, in order to know how to access the switch ID register.
That way, a compatible info can be used to describe how to access the
switch registers on models with different registers layout or addressing
modes.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 8c39dd0..8ac9f9a 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -21,6 +21,7 @@
#include <linux/list.h>
#include <linux/mdio.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/of_mdio.h>
#include <linux/netdevice.h>
#include <linux/gpio/consumer.h>
@@ -3745,6 +3746,8 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
{
struct device *dev = &mdiodev->dev;
struct device_node *np = dev->of_node;
+ const struct of_device_id *of_id;
+ const struct mv88e6xxx_info *info;
struct mv88e6xxx_priv_state *ps;
int id, prod_num, rev;
u32 eeprom_len;
@@ -3759,7 +3762,13 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
ps->sw_addr = mdiodev->addr;
mutex_init(&ps->smi_mutex);
- id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
+ of_id = of_match_node(mv88e6xxx_of_id_table, np);
+ if (!of_id)
+ return -EINVAL;
+
+ info = (const struct mv88e6xxx_info *)of_id->data;
+
+ id = mv88e6xxx_reg_read(ps, info->port_base_addr, PORT_SWITCH_ID);
if (id < 0)
return id;
--
2.8.3
[toc] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2016-06-14 21:00 +0200 |
| Subject | Re: [PATCH v2 net-next v2 08/12] net: dsa: mv88e6xxx: read switch ID from info |
| Message-ID | <rK1J7-fP-15@gated-at.bofh.it> |
| In reply to | #1422198 |
Hello.
On 06/14/2016 09:31 PM, Vivien Didelot wrote:
> Retrieve the info structure of the compatible of device in the new probe
> function, in order to know how to access the switch ID register.
>
> That way, a compatible info can be used to describe how to access the
> switch registers on models with different registers layout or addressing
> modes.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
> drivers/net/dsa/mv88e6xxx.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 8c39dd0..8ac9f9a 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
[...]
> @@ -3745,6 +3746,8 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
> {
> struct device *dev = &mdiodev->dev;
> struct device_node *np = dev->of_node;
> + const struct of_device_id *of_id;
> + const struct mv88e6xxx_info *info;
> struct mv88e6xxx_priv_state *ps;
> int id, prod_num, rev;
> u32 eeprom_len;
> @@ -3759,7 +3762,13 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
> ps->sw_addr = mdiodev->addr;
> mutex_init(&ps->smi_mutex);
>
> - id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
> + of_id = of_match_node(mv88e6xxx_of_id_table, np);
You could use of_device_get_match_data() here.
> + if (!of_id)
> + return -EINVAL;
> +
> + info = (const struct mv88e6xxx_info *)of_id->data;
Pointer casts from 'void *' are automatic.
[...]
MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2016-06-14 23:10 +0200 |
| Message-ID | <rK3KV-1Jw-1@gated-at.bofh.it> |
| In reply to | #1422226 |
Hi,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> writes:
>> - id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
>> + of_id = of_match_node(mv88e6xxx_of_id_table, np);
>
> You could use of_device_get_match_data() here.
>
>> + if (!of_id)
>> + return -EINVAL;
>> +
>> + info = (const struct mv88e6xxx_info *)of_id->data;
>
> Pointer casts from 'void *' are automatic.
I applied your comments and also squashed patches 7 and 8 together.
I'll respin a v3 soon unless there are other comments.
Thanks,
Vivien
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web