* [RFC PATCH v2] can: sja1000: use common prefix for all sja1000 defines
@ 2013-04-13 19:35 Oliver Hartkopp
2013-04-16 10:40 ` Marc Kleine-Budde
0 siblings, 1 reply; 18+ messages in thread
From: Oliver Hartkopp @ 2013-04-13 19:35 UTC (permalink / raw)
To: Marc Kleine-Budde, Wolfgang Grandegger; +Cc: linux-can@vger.kernel.org
This is a follow up patch to:
f901b6b can: sja1000: fix define conflict on SH
That patch fixed a define conflict between the SH architecture and the sja1000
driver, by addind a prefix to one macro only. This patch consistently renames
the prefix of the SJA1000 controller registers from "REG_" to "SJA1000_".
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
Hello Marc,
to not miss the current net-next window, here's a well formatted patch for my
REG_ rename proposal. It renames the formerly register defines from REG_ to
SJA1000_ and leaves the content definitions of the registers as-is.
This is because of all content definitions would have to be changed in
sja1000.h AND include/linux/can/platform/sja1000.h to have a consistent
naming scheme.
Regards,
Oliver
ems_pci.c | 6 +-
ems_pcmcia.c | 6 +-
kvaser_pci.c | 4 -
peak_pci.c | 2
peak_pcmcia.c | 8 +--
plx_pci.c | 12 ++---
sja1000.c | 126 +++++++++++++++++++++++++++++-----------------------------
sja1000.h | 68 +++++++++++++++----------------
8 files changed, 117 insertions(+), 115 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 36d298d..3752342 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -168,12 +168,12 @@ static inline int ems_pci_check_chan(const struct sja1000_priv *priv)
unsigned char res;
/* Make sure SJA1000 is in reset mode */
- priv->write_reg(priv, REG_MOD, 1);
+ priv->write_reg(priv, SJA1000_MOD, 1);
- priv->write_reg(priv, REG_CDR, CDR_PELICAN);
+ priv->write_reg(priv, SJA1000_CDR, CDR_PELICAN);
/* read reset-values */
- res = priv->read_reg(priv, REG_CDR);
+ res = priv->read_reg(priv, SJA1000_CDR);
if (res == CDR_PELICAN)
return 1;
diff --git a/drivers/net/can/sja1000/ems_pcmcia.c b/drivers/net/can/sja1000/ems_pcmcia.c
index 5c2f3fb..a3aa681 100644
--- a/drivers/net/can/sja1000/ems_pcmcia.c
+++ b/drivers/net/can/sja1000/ems_pcmcia.c
@@ -126,11 +126,11 @@ static irqreturn_t ems_pcmcia_interrupt(int irq, void *dev_id)
static inline int ems_pcmcia_check_chan(struct sja1000_priv *priv)
{
/* Make sure SJA1000 is in reset mode */
- ems_pcmcia_write_reg(priv, REG_MOD, 1);
- ems_pcmcia_write_reg(priv, REG_CDR, CDR_PELICAN);
+ ems_pcmcia_write_reg(priv, SJA1000_MOD, 1);
+ ems_pcmcia_write_reg(priv, SJA1000_CDR, CDR_PELICAN);
/* read reset-values */
- if (ems_pcmcia_read_reg(priv, REG_CDR) == CDR_PELICAN)
+ if (ems_pcmcia_read_reg(priv, SJA1000_CDR) == CDR_PELICAN)
return 1;
return 0;
diff --git a/drivers/net/can/sja1000/kvaser_pci.c b/drivers/net/can/sja1000/kvaser_pci.c
index 37b0381..217585b 100644
--- a/drivers/net/can/sja1000/kvaser_pci.c
+++ b/drivers/net/can/sja1000/kvaser_pci.c
@@ -159,9 +159,9 @@ static int number_of_sja1000_chip(void __iomem *base_addr)
for (i = 0; i < MAX_NO_OF_CHANNELS; i++) {
/* reset chip */
iowrite8(MOD_RM, base_addr +
- (i * KVASER_PCI_PORT_BYTES) + REG_MOD);
+ (i * KVASER_PCI_PORT_BYTES) + SJA1000_MOD);
status = ioread8(base_addr +
- (i * KVASER_PCI_PORT_BYTES) + REG_MOD);
+ (i * KVASER_PCI_PORT_BYTES) + SJA1000_MOD);
/* check reset bit */
if (!(status & MOD_RM))
break;
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index d1e7f10..6b6f0ad 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -402,7 +402,7 @@ static void peak_pciec_write_reg(const struct sja1000_priv *priv,
int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE;
/* sja1000 register changes control the leds state */
- if (port == REG_MOD)
+ if (port == SJA1000_MOD)
switch (val) {
case MOD_RM:
/* Reset Mode: set led on */
diff --git a/drivers/net/can/sja1000/peak_pcmcia.c b/drivers/net/can/sja1000/peak_pcmcia.c
index 1a7020b..977901a 100644
--- a/drivers/net/can/sja1000/peak_pcmcia.c
+++ b/drivers/net/can/sja1000/peak_pcmcia.c
@@ -196,7 +196,7 @@ static void pcan_write_canreg(const struct sja1000_priv *priv, int port, u8 v)
int c = (priv->reg_base - card->ioport_addr) / PCC_CHAN_SIZE;
/* sja1000 register changes control the leds state */
- if (port == REG_MOD)
+ if (port == SJA1000_MOD)
switch (v) {
case MOD_RM:
/* Reset Mode: set led on */
@@ -509,11 +509,11 @@ static void pcan_free_channels(struct pcan_pccard *card)
static inline int pcan_channel_present(struct sja1000_priv *priv)
{
/* make sure SJA1000 is in reset mode */
- pcan_write_canreg(priv, REG_MOD, 1);
- pcan_write_canreg(priv, REG_CDR, CDR_PELICAN);
+ pcan_write_canreg(priv, SJA1000_MOD, 1);
+ pcan_write_canreg(priv, SJA1000_CDR, CDR_PELICAN);
/* read reset-values */
- if (pcan_read_canreg(priv, REG_CDR) == CDR_PELICAN)
+ if (pcan_read_canreg(priv, SJA1000_CDR) == CDR_PELICAN)
return 1;
return 0;
diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c
index 3c18d7d..c52c1e9 100644
--- a/drivers/net/can/sja1000/plx_pci.c
+++ b/drivers/net/can/sja1000/plx_pci.c
@@ -348,20 +348,20 @@ static inline int plx_pci_check_sja1000(const struct sja1000_priv *priv)
*/
if ((priv->read_reg(priv, REG_CR) & REG_CR_BASICCAN_INITIAL_MASK) ==
REG_CR_BASICCAN_INITIAL &&
- (priv->read_reg(priv, SJA1000_REG_SR) == REG_SR_BASICCAN_INITIAL) &&
- (priv->read_reg(priv, REG_IR) == REG_IR_BASICCAN_INITIAL))
+ (priv->read_reg(priv, SJA1000_SR) == REG_SR_BASICCAN_INITIAL) &&
+ (priv->read_reg(priv, SJA1000_IR) == REG_IR_BASICCAN_INITIAL))
flag = 1;
/* Bring the SJA1000 into the PeliCAN mode*/
- priv->write_reg(priv, REG_CDR, CDR_PELICAN);
+ priv->write_reg(priv, SJA1000_CDR, CDR_PELICAN);
/*
* Check registers after reset in the PeliCAN mode.
* See states on p. 23 of the Datasheet.
*/
- if (priv->read_reg(priv, REG_MOD) == REG_MOD_PELICAN_INITIAL &&
- priv->read_reg(priv, SJA1000_REG_SR) == REG_SR_PELICAN_INITIAL &&
- priv->read_reg(priv, REG_IR) == REG_IR_PELICAN_INITIAL)
+ if (priv->read_reg(priv, SJA1000_MOD) == REG_MOD_PELICAN_INITIAL &&
+ priv->read_reg(priv, SJA1000_SR) == REG_SR_PELICAN_INITIAL &&
+ priv->read_reg(priv, SJA1000_IR) == REG_IR_PELICAN_INITIAL)
return flag;
return 0;
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index e4df307..7164a99 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -91,14 +91,14 @@ static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val)
* the write_reg() operation - especially on SMP systems.
*/
spin_lock_irqsave(&priv->cmdreg_lock, flags);
- priv->write_reg(priv, REG_CMR, val);
- priv->read_reg(priv, SJA1000_REG_SR);
+ priv->write_reg(priv, SJA1000_CMR, val);
+ priv->read_reg(priv, SJA1000_SR);
spin_unlock_irqrestore(&priv->cmdreg_lock, flags);
}
static int sja1000_is_absent(struct sja1000_priv *priv)
{
- return (priv->read_reg(priv, REG_MOD) == 0xFF);
+ return (priv->read_reg(priv, SJA1000_MOD) == 0xFF);
}
static int sja1000_probe_chip(struct net_device *dev)
@@ -116,11 +116,11 @@ static int sja1000_probe_chip(struct net_device *dev)
static void set_reset_mode(struct net_device *dev)
{
struct sja1000_priv *priv = netdev_priv(dev);
- unsigned char status = priv->read_reg(priv, REG_MOD);
+ unsigned char status = priv->read_reg(priv, SJA1000_MOD);
int i;
/* disable interrupts */
- priv->write_reg(priv, REG_IER, IRQ_OFF);
+ priv->write_reg(priv, SJA1000_IER, IRQ_OFF);
for (i = 0; i < 100; i++) {
/* check reset bit */
@@ -129,9 +129,10 @@ static void set_reset_mode(struct net_device *dev)
return;
}
- priv->write_reg(priv, REG_MOD, MOD_RM); /* reset chip */
+ /* reset chip */
+ priv->write_reg(priv, SJA1000_MOD, MOD_RM);
udelay(10);
- status = priv->read_reg(priv, REG_MOD);
+ status = priv->read_reg(priv, SJA1000_MOD);
}
netdev_err(dev, "setting SJA1000 into reset mode failed!\n");
@@ -140,7 +141,7 @@ static void set_reset_mode(struct net_device *dev)
static void set_normal_mode(struct net_device *dev)
{
struct sja1000_priv *priv = netdev_priv(dev);
- unsigned char status = priv->read_reg(priv, REG_MOD);
+ unsigned char status = priv->read_reg(priv, SJA1000_MOD);
int i;
for (i = 0; i < 100; i++) {
@@ -149,22 +150,22 @@ static void set_normal_mode(struct net_device *dev)
priv->can.state = CAN_STATE_ERROR_ACTIVE;
/* enable interrupts */
if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
- priv->write_reg(priv, REG_IER, IRQ_ALL);
+ priv->write_reg(priv, SJA1000_IER, IRQ_ALL);
else
- priv->write_reg(priv, REG_IER,
+ priv->write_reg(priv, SJA1000_IER,
IRQ_ALL & ~IRQ_BEI);
return;
}
/* set chip to normal mode */
if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
- priv->write_reg(priv, REG_MOD, MOD_LOM);
+ priv->write_reg(priv, SJA1000_MOD, MOD_LOM);
else
- priv->write_reg(priv, REG_MOD, 0x00);
+ priv->write_reg(priv, SJA1000_MOD, 0x00);
udelay(10);
- status = priv->read_reg(priv, REG_MOD);
+ status = priv->read_reg(priv, SJA1000_MOD);
}
netdev_err(dev, "setting SJA1000 into normal mode failed!\n");
@@ -179,9 +180,9 @@ static void sja1000_start(struct net_device *dev)
set_reset_mode(dev);
/* Clear error counters and error code capture */
- priv->write_reg(priv, REG_TXERR, 0x0);
- priv->write_reg(priv, REG_RXERR, 0x0);
- priv->read_reg(priv, REG_ECC);
+ priv->write_reg(priv, SJA1000_TXERR, 0x0);
+ priv->write_reg(priv, SJA1000_RXERR, 0x0);
+ priv->read_reg(priv, SJA1000_ECC);
/* leave reset mode */
set_normal_mode(dev);
@@ -217,8 +218,8 @@ static int sja1000_set_bittiming(struct net_device *dev)
netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
- priv->write_reg(priv, REG_BTR0, btr0);
- priv->write_reg(priv, REG_BTR1, btr1);
+ priv->write_reg(priv, SJA1000_BTR0, btr0);
+ priv->write_reg(priv, SJA1000_BTR1, btr1);
return 0;
}
@@ -228,8 +229,8 @@ static int sja1000_get_berr_counter(const struct net_device *dev,
{
struct sja1000_priv *priv = netdev_priv(dev);
- bec->txerr = priv->read_reg(priv, REG_TXERR);
- bec->rxerr = priv->read_reg(priv, REG_RXERR);
+ bec->txerr = priv->read_reg(priv, SJA1000_TXERR);
+ bec->rxerr = priv->read_reg(priv, SJA1000_RXERR);
return 0;
}
@@ -247,20 +248,20 @@ static void chipset_init(struct net_device *dev)
struct sja1000_priv *priv = netdev_priv(dev);
/* set clock divider and output control register */
- priv->write_reg(priv, REG_CDR, priv->cdr | CDR_PELICAN);
+ priv->write_reg(priv, SJA1000_CDR, priv->cdr | CDR_PELICAN);
/* set acceptance filter (accept all) */
- priv->write_reg(priv, REG_ACCC0, 0x00);
- priv->write_reg(priv, REG_ACCC1, 0x00);
- priv->write_reg(priv, REG_ACCC2, 0x00);
- priv->write_reg(priv, REG_ACCC3, 0x00);
+ priv->write_reg(priv, SJA1000_ACCC0, 0x00);
+ priv->write_reg(priv, SJA1000_ACCC1, 0x00);
+ priv->write_reg(priv, SJA1000_ACCC2, 0x00);
+ priv->write_reg(priv, SJA1000_ACCC3, 0x00);
- priv->write_reg(priv, REG_ACCM0, 0xFF);
- priv->write_reg(priv, REG_ACCM1, 0xFF);
- priv->write_reg(priv, REG_ACCM2, 0xFF);
- priv->write_reg(priv, REG_ACCM3, 0xFF);
+ priv->write_reg(priv, SJA1000_ACCM0, 0xFF);
+ priv->write_reg(priv, SJA1000_ACCM1, 0xFF);
+ priv->write_reg(priv, SJA1000_ACCM2, 0xFF);
+ priv->write_reg(priv, SJA1000_ACCM3, 0xFF);
- priv->write_reg(priv, REG_OCR, priv->ocr | OCR_MODE_NORMAL);
+ priv->write_reg(priv, SJA1000_OCR, priv->ocr | OCR_MODE_NORMAL);
}
/*
@@ -289,21 +290,21 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
id = cf->can_id;
if (id & CAN_RTR_FLAG)
- fi |= FI_RTR;
+ fi |= SJA1000_FI_RTR;
if (id & CAN_EFF_FLAG) {
- fi |= FI_FF;
- dreg = EFF_BUF;
- priv->write_reg(priv, REG_FI, fi);
- priv->write_reg(priv, REG_ID1, (id & 0x1fe00000) >> (5 + 16));
- priv->write_reg(priv, REG_ID2, (id & 0x001fe000) >> (5 + 8));
- priv->write_reg(priv, REG_ID3, (id & 0x00001fe0) >> 5);
- priv->write_reg(priv, REG_ID4, (id & 0x0000001f) << 3);
+ fi |= SJA1000_FI_FF;
+ dreg = SJA1000_EFF_BUF;
+ priv->write_reg(priv, SJA1000_FI, fi);
+ priv->write_reg(priv, SJA1000_ID1, (id & 0x1fe00000) >> 21);
+ priv->write_reg(priv, SJA1000_ID2, (id & 0x001fe000) >> 13);
+ priv->write_reg(priv, SJA1000_ID3, (id & 0x00001fe0) >> 5);
+ priv->write_reg(priv, SJA1000_ID4, (id & 0x0000001f) << 3);
} else {
- dreg = SFF_BUF;
- priv->write_reg(priv, REG_FI, fi);
- priv->write_reg(priv, REG_ID1, (id & 0x000007f8) >> 3);
- priv->write_reg(priv, REG_ID2, (id & 0x00000007) << 5);
+ dreg = SJA1000_SFF_BUF;
+ priv->write_reg(priv, SJA1000_FI, fi);
+ priv->write_reg(priv, SJA1000_ID1, (id & 0x000007f8) >> 3);
+ priv->write_reg(priv, SJA1000_ID2, (id & 0x00000007) << 5);
}
for (i = 0; i < dlc; i++)
@@ -335,25 +336,25 @@ static void sja1000_rx(struct net_device *dev)
if (skb == NULL)
return;
- fi = priv->read_reg(priv, REG_FI);
+ fi = priv->read_reg(priv, SJA1000_FI);
- if (fi & FI_FF) {
+ if (fi & SJA1000_FI_FF) {
/* extended frame format (EFF) */
- dreg = EFF_BUF;
- id = (priv->read_reg(priv, REG_ID1) << (5 + 16))
- | (priv->read_reg(priv, REG_ID2) << (5 + 8))
- | (priv->read_reg(priv, REG_ID3) << 5)
- | (priv->read_reg(priv, REG_ID4) >> 3);
+ dreg = SJA1000_EFF_BUF;
+ id = (priv->read_reg(priv, SJA1000_ID1) << 21)
+ | (priv->read_reg(priv, SJA1000_ID2) << 13)
+ | (priv->read_reg(priv, SJA1000_ID3) << 5)
+ | (priv->read_reg(priv, SJA1000_ID4) >> 3);
id |= CAN_EFF_FLAG;
} else {
/* standard frame format (SFF) */
- dreg = SFF_BUF;
- id = (priv->read_reg(priv, REG_ID1) << 3)
- | (priv->read_reg(priv, REG_ID2) >> 5);
+ dreg = SJA1000_SFF_BUF;
+ id = (priv->read_reg(priv, SJA1000_ID1) << 3)
+ | (priv->read_reg(priv, SJA1000_ID2) >> 5);
}
cf->can_dlc = get_can_dlc(fi & 0x0F);
- if (fi & FI_RTR) {
+ if (fi & SJA1000_FI_RTR) {
id |= CAN_RTR_FLAG;
} else {
for (i = 0; i < cf->can_dlc; i++)
@@ -414,7 +415,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
priv->can.can_stats.bus_error++;
stats->rx_errors++;
- ecc = priv->read_reg(priv, REG_ECC);
+ ecc = priv->read_reg(priv, SJA1000_ECC);
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
@@ -448,7 +449,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
if (isrc & IRQ_ALI) {
/* arbitration lost interrupt */
netdev_dbg(dev, "arbitration lost interrupt\n");
- alc = priv->read_reg(priv, REG_ALC);
+ alc = priv->read_reg(priv, SJA1000_ALC);
priv->can.can_stats.arbitration_lost++;
stats->tx_errors++;
cf->can_id |= CAN_ERR_LOSTARB;
@@ -457,8 +458,8 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING ||
state == CAN_STATE_ERROR_PASSIVE)) {
- uint8_t rxerr = priv->read_reg(priv, REG_RXERR);
- uint8_t txerr = priv->read_reg(priv, REG_TXERR);
+ uint8_t rxerr = priv->read_reg(priv, SJA1000_RXERR);
+ uint8_t txerr = priv->read_reg(priv, SJA1000_TXERR);
cf->can_id |= CAN_ERR_CRTL;
if (state == CAN_STATE_ERROR_WARNING) {
priv->can.can_stats.error_warning++;
@@ -494,15 +495,16 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
int n = 0;
/* Shared interrupts and IRQ off? */
- if (priv->read_reg(priv, REG_IER) == IRQ_OFF)
+ if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF)
return IRQ_NONE;
if (priv->pre_irq)
priv->pre_irq(priv);
- while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
+ while ((isrc = priv->read_reg(priv, SJA1000_IR)) &&
+ (n < SJA1000_MAX_IRQ)) {
n++;
- status = priv->read_reg(priv, SJA1000_REG_SR);
+ status = priv->read_reg(priv, SJA1000_SR);
/* check for absent controller due to hw unplug */
if (status == 0xFF && sja1000_is_absent(priv))
return IRQ_NONE;
@@ -519,7 +521,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
} else {
/* transmission complete */
stats->tx_bytes +=
- priv->read_reg(priv, REG_FI) & 0xf;
+ priv->read_reg(priv, SJA1000_FI) & 0xf;
stats->tx_packets++;
can_get_echo_skb(dev, 0);
}
@@ -530,7 +532,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
/* receive interrupt */
while (status & SR_RBS) {
sja1000_rx(dev);
- status = priv->read_reg(priv, SJA1000_REG_SR);
+ status = priv->read_reg(priv, SJA1000_SR);
/* check for absent controller */
if (status == 0xFF && sja1000_is_absent(priv))
return IRQ_NONE;
diff --git a/drivers/net/can/sja1000/sja1000.h b/drivers/net/can/sja1000/sja1000.h
index aa48e05..fcb9aef 100644
--- a/drivers/net/can/sja1000/sja1000.h
+++ b/drivers/net/can/sja1000/sja1000.h
@@ -54,46 +54,46 @@
#define SJA1000_MAX_IRQ 20 /* max. number of interrupts handled in ISR */
/* SJA1000 registers - manual section 6.4 (Pelican Mode) */
-#define REG_MOD 0x00
-#define REG_CMR 0x01
-#define SJA1000_REG_SR 0x02
-#define REG_IR 0x03
-#define REG_IER 0x04
-#define REG_ALC 0x0B
-#define REG_ECC 0x0C
-#define REG_EWL 0x0D
-#define REG_RXERR 0x0E
-#define REG_TXERR 0x0F
-#define REG_ACCC0 0x10
-#define REG_ACCC1 0x11
-#define REG_ACCC2 0x12
-#define REG_ACCC3 0x13
-#define REG_ACCM0 0x14
-#define REG_ACCM1 0x15
-#define REG_ACCM2 0x16
-#define REG_ACCM3 0x17
-#define REG_RMC 0x1D
-#define REG_RBSA 0x1E
+#define SJA1000_MOD 0x00
+#define SJA1000_CMR 0x01
+#define SJA1000_SR 0x02
+#define SJA1000_IR 0x03
+#define SJA1000_IER 0x04
+#define SJA1000_ALC 0x0B
+#define SJA1000_ECC 0x0C
+#define SJA1000_EWL 0x0D
+#define SJA1000_RXERR 0x0E
+#define SJA1000_TXERR 0x0F
+#define SJA1000_ACCC0 0x10
+#define SJA1000_ACCC1 0x11
+#define SJA1000_ACCC2 0x12
+#define SJA1000_ACCC3 0x13
+#define SJA1000_ACCM0 0x14
+#define SJA1000_ACCM1 0x15
+#define SJA1000_ACCM2 0x16
+#define SJA1000_ACCM3 0x17
+#define SJA1000_RMC 0x1D
+#define SJA1000_RBSA 0x1E
/* Common registers - manual section 6.5 */
-#define REG_BTR0 0x06
-#define REG_BTR1 0x07
-#define REG_OCR 0x08
-#define REG_CDR 0x1F
+#define SJA1000_BTR0 0x06
+#define SJA1000_BTR1 0x07
+#define SJA1000_OCR 0x08
+#define SJA1000_CDR 0x1F
-#define REG_FI 0x10
-#define SFF_BUF 0x13
-#define EFF_BUF 0x15
+#define SJA1000_FI 0x10
+#define SJA1000_SFF_BUF 0x13
+#define SJA1000_EFF_BUF 0x15
-#define FI_FF 0x80
-#define FI_RTR 0x40
+#define SJA1000_FI_FF 0x80
+#define SJA1000_FI_RTR 0x40
-#define REG_ID1 0x11
-#define REG_ID2 0x12
-#define REG_ID3 0x13
-#define REG_ID4 0x14
+#define SJA1000_ID1 0x11
+#define SJA1000_ID2 0x12
+#define SJA1000_ID3 0x13
+#define SJA1000_ID4 0x14
-#define CAN_RAM 0x20
+#define SJA1000_CAN_RAM 0x20
/* mode register */
#define MOD_RM 0x01
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH v2] can: sja1000: use common prefix for all sja1000 defines
2013-04-13 19:35 [RFC PATCH v2] can: sja1000: use common prefix for all sja1000 defines Oliver Hartkopp
@ 2013-04-16 10:40 ` Marc Kleine-Budde
2013-04-24 9:06 ` Is there any way of getting the CAN interfaces list, from any C program? Stephane Grosjean
0 siblings, 1 reply; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-16 10:40 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: Wolfgang Grandegger, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]
On 04/13/2013 09:35 PM, Oliver Hartkopp wrote:
> This is a follow up patch to:
>
> f901b6b can: sja1000: fix define conflict on SH
>
> That patch fixed a define conflict between the SH architecture and the sja1000
> driver, by addind a prefix to one macro only. This patch consistently renames
> the prefix of the SJA1000 controller registers from "REG_" to "SJA1000_".
>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
>
> ---
>
> Hello Marc,
>
> to not miss the current net-next window, here's a well formatted patch for my
> REG_ rename proposal. It renames the formerly register defines from REG_ to
> SJA1000_ and leaves the content definitions of the registers as-is.
> This is because of all content definitions would have to be changed in
> sja1000.h AND include/linux/can/platform/sja1000.h to have a consistent
> naming scheme.
Looks good, I've fixed the indention in
drivers/net/can/sja1000/sja1000.h. I'll send a pull request to David soon.
Thanks, Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Is there any way of getting the CAN interfaces list, from any C program?
2013-04-16 10:40 ` Marc Kleine-Budde
@ 2013-04-24 9:06 ` Stephane Grosjean
2013-04-24 14:49 ` Kurt Van Dijck
2013-04-24 21:02 ` François
0 siblings, 2 replies; 18+ messages in thread
From: Stephane Grosjean @ 2013-04-24 9:06 UTC (permalink / raw)
To: linux-can@vger.kernel.org
Hi linux-can members,
I currently wonder whether it exists any way of getting the list of the
installed CAN interfaces, from a C program?
I mean, getting the network interfaces list is available using
ioctl(SIOCGIFCONF).
But AFAIK, this (only) returns the IP interfaces found in the system,
even using a socket CAN file descriptor.
And, I would also like to avoid some pipe/fork/grep/sed in this C
program too ;-)
Thanks for your help and best regards,
Stéphane
--
PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt
HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391
Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329, info@peak-system.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-24 9:06 ` Is there any way of getting the CAN interfaces list, from any C program? Stephane Grosjean
@ 2013-04-24 14:49 ` Kurt Van Dijck
2013-04-25 6:41 ` Wolfgang Grandegger
2013-04-24 21:02 ` François
1 sibling, 1 reply; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-24 14:49 UTC (permalink / raw)
To: Stephane Grosjean; +Cc: linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]
Hi Stephane,
I have written this some time ago, not using it actually.
I tried a modular approach, don't know if its usefull.
PS: I used attachments.
Kurt
On Wed, Apr 24, 2013 at 11:06:24AM +0200, Stephane Grosjean wrote:
> Hi linux-can members,
>
> I currently wonder whether it exists any way of getting the list of
> the installed CAN interfaces, from a C program?
> I mean, getting the network interfaces list is available using
> ioctl(SIOCGIFCONF).
> But AFAIK, this (only) returns the IP interfaces found in the
> system, even using a socket CAN file descriptor.
> And, I would also like to avoid some pipe/fork/grep/sed in this C
> program too ;-)
>
> Thanks for your help and best regards,
>
> Stéphane
> --
> PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
> Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA
> Darmstadt HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.:
> DE39305391 Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329,
> info@peak-system.com
> ----
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
[-- Attachment #2: enumif.c --]
[-- Type: text/x-csrc, Size: 3149 bytes --]
#ifdef linux
#if linux
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <linux/rtnetlink.h>
#include <linux/netlink.h>
#include "enumif.h"
static struct {
int sock;
int seq;
} s = {
.sock = -1,
};
__attribute__((destructor))
void enumif_cleanup(void)
{
if (s.sock >= 0) {
close(s.sock);
s.sock = -1;
}
}
static int enumif_open(void)
{
int fd;
struct sockaddr_nl local = {
.nl_family = AF_NETLINK,
.nl_groups = 0,
};
if (s.sock >= 0)
return s.sock;
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (fd < 0) {
perror("Cannot open netlink socket");
return -1;
}
if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) {
perror("Cannot bind netlink socket");
return -1;
}
s.sock = fd;
s.seq = 0;
return fd;
}
static inline int enumif_send_request(int sk)
{
struct {
struct nlmsghdr n;
struct rtgenmsg g;
} req = {
.n = {
.nlmsg_len = sizeof(req),
.nlmsg_type = RTM_GETLINK,
.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_MATCH,
.nlmsg_pid = 0,
.nlmsg_seq = ++s.seq,
},
.g.rtgen_family = AF_PACKET,
};
return send(sk, &req, sizeof(req), 0);
}
static void parse_rtattr(struct rtattr **tb, int max,
struct rtattr *rta, int len)
{
memset(tb, 0, sizeof(*tb) * max);
while (RTA_OK(rta, len)) {
if (rta->rta_type <= max) {
tb[rta->rta_type] = rta;
}
rta = RTA_NEXT(rta, len);
}
}
int enumif(void (*fn)(const char *name, int ifindex, int type, int flags, int state))
{
int ret, n_if = 0;
size_t msglen;
struct nlmsghdr *h;
struct sockaddr_nl peer;
char cbuf[128];
char buf[1024 * 16];
struct iovec iov = {
.iov_base = buf,
.iov_len = sizeof(buf),
};
struct msghdr msg = {
.msg_name = (void *)&peer,
.msg_namelen = sizeof(peer),
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_control = &cbuf,
.msg_controllen = sizeof(cbuf),
.msg_flags = 0,
};
struct ifinfomsg *ifi;
struct rtattr *tb[IFLA_MAX + 1];
if (enumif_open() < 0)
return -1;
if (enumif_send_request(s.sock) < 0) {
perror("Cannot send dump request");
return -1;
}
while (1) {
iov.iov_len = sizeof(buf);
ret = recvmsg(s.sock, &msg, 0);
if (ret < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
perror("netlink receive error");
return -1;
}
if (ret == 0) {
errno = 0;
perror("netlink EOF?");
return -1;
}
msglen = ret;
for (h = (void *)buf; NLMSG_OK(h, msglen);
h = NLMSG_NEXT(h, msglen)) {
if (h->nlmsg_type == NLMSG_DONE)
goto done;
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
fprintf(stderr,
"ERROR truncated\n");
} else {
errno = -err->error;
perror("RTNETLINK answers");
}
return -1;
}
++n_if;
ifi = NLMSG_DATA(h);
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), IFLA_PAYLOAD(h));
fn(RTA_DATA(tb[IFLA_IFNAME]), ifi->ifi_index, ifi->ifi_type,
ifi->ifi_flags,
*(unsigned char *)RTA_DATA(tb[IFLA_OPERSTATE]));
}
}
done:
return 0;
}
#endif
#endif
[-- Attachment #3: enumif.h --]
[-- Type: text/x-chdr, Size: 245 bytes --]
#ifndef _enumif_h_
#define _enumif_h_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef linux
#if linux
extern int enumif(void (*fn)(const char *name, int ifindex, int type, int flags, int state));
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
[-- Attachment #4: enumif-test.c --]
[-- Type: text/x-csrc, Size: 3001 bytes --]
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include "enumif.h"
struct lookup {
int i;
const char *a;
};
#define __PF(f,n) { ARPHRD_##f, #n },
static const struct lookup iftypes[] = {
{ 0, "generic", },
__PF(ETHER,ether)
__PF(EETHER,eether)
__PF(AX25,ax25)
__PF(PRONET,pronet)
__PF(CHAOS,chaos)
__PF(IEEE802,ieee802)
__PF(ARCNET,arcnet)
__PF(APPLETLK,atalk)
__PF(DLCI,dlci)
__PF(ATM,atm)
__PF(METRICOM,metricom)
__PF(IEEE1394,ieee1394)
__PF(INFINIBAND,infiniband)
__PF(SLIP,slip)
__PF(CSLIP,cslip)
__PF(SLIP6,slip6)
__PF(CSLIP6,cslip6)
__PF(RSRVD,rsrvd)
__PF(ADAPT,adapt)
__PF(ROSE,rose)
__PF(X25,x25)
__PF(HWX25,hwx25)
__PF(CAN,can)
__PF(PPP,ppp)
__PF(HDLC,hdlc)
__PF(LAPB,lapb)
__PF(DDCMP,ddcmp)
__PF(RAWHDLC,rawhdlc)
__PF(TUNNEL,ipip)
__PF(TUNNEL6,tunnel6)
__PF(FRAD,frad)
__PF(SKIP,skip)
__PF(LOOPBACK,loopback)
__PF(LOCALTLK,ltalk)
__PF(FDDI,fddi)
__PF(BIF,bif)
__PF(SIT,sit)
__PF(IPDDP,ip/ddp)
__PF(IPGRE,gre)
__PF(PIMREG,pimreg)
__PF(HIPPI,hippi)
__PF(ASH,ash)
__PF(ECONET,econet)
__PF(IRDA,irda)
__PF(FCPP,fcpp)
__PF(FCAL,fcal)
__PF(FCPL,fcpl)
__PF(FCFABRIC,fcfb0)
__PF(FCFABRIC+1,fcfb1)
__PF(FCFABRIC+2,fcfb2)
__PF(FCFABRIC+3,fcfb3)
__PF(FCFABRIC+4,fcfb4)
__PF(FCFABRIC+5,fcfb5)
__PF(FCFABRIC+6,fcfb6)
__PF(FCFABRIC+7,fcfb7)
__PF(FCFABRIC+8,fcfb8)
__PF(FCFABRIC+9,fcfb9)
__PF(FCFABRIC+10,fcfb10)
__PF(FCFABRIC+11,fcfb11)
__PF(FCFABRIC+12,fcfb12)
__PF(IEEE802_TR,tr)
__PF(IEEE80211,ieee802.11)
__PF(IEEE80211_PRISM,ieee802.11/prism)
__PF(IEEE80211_RADIOTAP,ieee802.11/radiotap)
#ifdef ARPHD_IEEE802154
__PF(IEEE802154, ieee802.15.4)
#endif
#ifdef ARPHD_PHONET
__PF(PHONET, phonet)
#endif
#ifdef ARPHD_PIPE
__PF(PHONET_PIPE, phonet_pipe)
#endif
__PF(NONE, none)
__PF(VOID,void)
{ },
};
#define __IF(f) { IFF_##f, #f, }
static const struct lookup ifflags[] = {
__IF(LOOPBACK),
__IF(BROADCAST),
__IF(POINTOPOINT),
__IF(MULTICAST),
__IF(NOARP),
__IF(ALLMULTI),
__IF(PROMISC),
__IF(MASTER),
__IF(SLAVE),
__IF(DEBUG),
__IF(DYNAMIC),
__IF(AUTOMEDIA),
__IF(PORTSEL),
__IF(NOTRAILERS),
__IF(UP),
__IF(LOWER_UP),
__IF(DORMANT),
__IF(ECHO),
{},
};
static const char *statestrs[] = {
"UNKNOWN", "NOTPRESENT", "DOWN", "LOWERLAYERDOWN",
"TESTING", "DORMANT", "UP"
};
static void ifcallback(const char *name, int index, int type, int flags, int state)
{
const struct lookup *lp;
char typestr[16];
sprintf(typestr, "%i", type);
for (lp = iftypes; lp->a; ++lp)
if (lp->i == type)
break;
printf("%i: %s\t{%s}", index, name, lp->a ?: typestr);
printf(" <");
/* from iproute2 */
if ((flags & IFF_UP) && !(flags & IFF_RUNNING))
printf("%s%s", "NO-CARRIER", flags ? "," : "");
flags &= ~IFF_RUNNING;
for (lp = ifflags; lp->a; ++lp) {
if (flags & lp->i) {
flags &= ~lp->i;
printf("%s%s", lp->a, flags ? "," : "");
}
}
if (flags)
printf("%x", flags);
printf("> %s\n", statestrs[state]);
}
int main(int argc, char *argv[])
{
enumif(ifcallback);
return 0;
}
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-24 9:06 ` Is there any way of getting the CAN interfaces list, from any C program? Stephane Grosjean
2013-04-24 14:49 ` Kurt Van Dijck
@ 2013-04-24 21:02 ` François
2013-04-24 21:27 ` Marc Kleine-Budde
2013-04-25 8:04 ` Kurt Van Dijck
1 sibling, 2 replies; 18+ messages in thread
From: François @ 2013-04-24 21:02 UTC (permalink / raw)
To: Stephane Grosjean; +Cc: linux-can@vger.kernel.org
Stephane,
This is what i have done in a open source project i have started, a web
can analyzer called ewecan (https://bitbucket.org/Mongo/ewecan):
It parses /sys/class/net but unfortunately, as noted in comments, it
cannot make the difference between up or down interfaces.
/* Get a list of available socketcan interfaces and return them in
a string as a JS array like ["can0", "can1", "vcan"]
Returned string must be freed after use
BUG : it also returns interfaces that are present but down !
*/
char *cmd_listitf(void)
{
char *buf = malloc(255);
if(!buf)
return NULL;
/* looking for socketcan interfaces in /sys */
DIR *fdir = opendir("/sys/class/net");
if(fdir == NULL){
perror("opendir");
free(buf);
return NULL;
}
struct dirent *fic;
int firstdone = 0;
buf[0] = '[';
buf[1] = '\0';
while(1){
fic = readdir(fdir);
if(fic == NULL)
break;
if(!strstr(fic->d_name, "can"))
continue;
/* if the new string does not fit in buf, stop here */
if((strlen(fic->d_name) + strlen(buf) + 4) >= 255)
break;
if(firstdone)
strcat(buf, ",");
strcat(buf, "\"");
strcat(buf, fic->d_name);
strcat(buf, "\"");
firstdone = 1;
}
strcat(buf, "]");
closedir(fdir);
return buf;
}
Hope it can help !
Regards
--
François Beaulier
www.ingelibre.fr
Le 24/04/2013 11:06, Stephane Grosjean a écrit :
> Hi linux-can members,
>
> I currently wonder whether it exists any way of getting the list of
> the installed CAN interfaces, from a C program?
> I mean, getting the network interfaces list is available using
> ioctl(SIOCGIFCONF).
> But AFAIK, this (only) returns the IP interfaces found in the system,
> even using a socket CAN file descriptor.
> And, I would also like to avoid some pipe/fork/grep/sed in this C
> program too ;-)
>
> Thanks for your help and best regards,
>
> Stéphane
> --
> PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
> Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt
> HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391
> Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329, info@peak-system.com
> ----
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-24 21:02 ` François
@ 2013-04-24 21:27 ` Marc Kleine-Budde
2013-04-25 8:04 ` Kurt Van Dijck
1 sibling, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-24 21:27 UTC (permalink / raw)
To: François; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 932 bytes --]
On 04/24/2013 11:02 PM, François wrote:
> Stephane,
>
> This is what i have done in a open source project i have started, a web
> can analyzer called ewecan (https://bitbucket.org/Mongo/ewecan):
> It parses /sys/class/net but unfortunately, as noted in comments, it
> cannot make the difference between up or down interfaces.
>
> /* Get a list of available socketcan interfaces and return them in
> a string as a JS array like ["can0", "can1", "vcan"]
> Returned string must be freed after use
> BUG : it also returns interfaces that are present but down !
> */
Whan happens if I rename my ethernet interface to "can0"?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-24 14:49 ` Kurt Van Dijck
@ 2013-04-25 6:41 ` Wolfgang Grandegger
2013-04-25 7:07 ` Marc Kleine-Budde
2013-04-25 7:24 ` Kurt Van Dijck
0 siblings, 2 replies; 18+ messages in thread
From: Wolfgang Grandegger @ 2013-04-25 6:41 UTC (permalink / raw)
To: Stephane Grosjean, linux-can@vger.kernel.org
Hi Kurt,
On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
> Hi Stephane,
>
> I have written this some time ago, not using it actually.
> I tried a modular approach, don't know if its usefull.
>
> PS: I used attachments.
~/enumif$ ./enumif
1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
6: can1 {can} <NOARP,ECHO> DOWN
7: can2 {can} <NOARP,ECHO> DOWN
8: can3 {can} <NOARP,ECHO> DOWN
9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
Cool! We know that "ip link" does list all network interfaces but the
code doing the job is not really strength-forward. I think this would be
a nice enhancement of the can-utils.
Wolfgang.
>
> Kurt
>
> On Wed, Apr 24, 2013 at 11:06:24AM +0200, Stephane Grosjean wrote:
>> Hi linux-can members,
>>
>> I currently wonder whether it exists any way of getting the list of
>> the installed CAN interfaces, from a C program?
>> I mean, getting the network interfaces list is available using
>> ioctl(SIOCGIFCONF).
>> But AFAIK, this (only) returns the IP interfaces found in the
>> system, even using a socket CAN file descriptor.
>> And, I would also like to avoid some pipe/fork/grep/sed in this C
>> program too ;-)
>>
>> Thanks for your help and best regards,
>>
>> Stéphane
>> --
>> PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
>> Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA
>> Darmstadt HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.:
>> DE39305391 Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329,
>> info@peak-system.com
>> ----
>> To unsubscribe from this list: send the line "unsubscribe linux-can" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 6:41 ` Wolfgang Grandegger
@ 2013-04-25 7:07 ` Marc Kleine-Budde
2013-04-25 7:35 ` Marc Kleine-Budde
2013-04-25 7:24 ` Kurt Van Dijck
1 sibling, 1 reply; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-25 7:07 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
On 04/25/2013 08:41 AM, Wolfgang Grandegger wrote:
> Hi Kurt,
>
> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
>> Hi Stephane,
>>
>> I have written this some time ago, not using it actually.
>> I tried a modular approach, don't know if its usefull.
>>
>> PS: I used attachments.
>
> ~/enumif$ ./enumif
> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
> 6: can1 {can} <NOARP,ECHO> DOWN
> 7: can2 {can} <NOARP,ECHO> DOWN
> 8: can3 {can} <NOARP,ECHO> DOWN
> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
>
> Cool! We know that "ip link" does list all network interfaces but the
> code doing the job is not really strength-forward. I think this would be
> a nice enhancement of the can-utils.
Good idea, Stephane, can you license the code under a permissive license
like LGPL or BSD?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 6:41 ` Wolfgang Grandegger
2013-04-25 7:07 ` Marc Kleine-Budde
@ 2013-04-25 7:24 ` Kurt Van Dijck
2013-04-25 7:43 ` Wolfgang Grandegger
1 sibling, 1 reply; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 7:24 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
On Thu, Apr 25, 2013 at 08:41:16AM +0200, Wolfgang Grandegger wrote:
> Hi Kurt,
>
> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
> > Hi Stephane,
> >
> > I have written this some time ago, not using it actually.
> > I tried a modular approach, don't know if its usefull.
> >
> > PS: I used attachments.
>
> ~/enumif$ ./enumif
> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
> 6: can1 {can} <NOARP,ECHO> DOWN
> 7: can2 {can} <NOARP,ECHO> DOWN
> 8: can3 {can} <NOARP,ECHO> DOWN
> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
>
> Cool! We know that "ip link" does list all network interfaces but the
> code doing the job is not really strength-forward. I think this would be
> a nice enhancement of the can-utils.
would it make sense to maintain the split into enumif-test.c and enumif.c,
so for example Stephane could just link to libenumif.a?
Kurt
>
> Wolfgang.
>
> >
> > Kurt
> >
> > On Wed, Apr 24, 2013 at 11:06:24AM +0200, Stephane Grosjean wrote:
> >> Hi linux-can members,
> >>
> >> I currently wonder whether it exists any way of getting the list of
> >> the installed CAN interfaces, from a C program?
> >> I mean, getting the network interfaces list is available using
> >> ioctl(SIOCGIFCONF).
> >> But AFAIK, this (only) returns the IP interfaces found in the
> >> system, even using a socket CAN file descriptor.
> >> And, I would also like to avoid some pipe/fork/grep/sed in this C
> >> program too ;-)
> >>
> >> Thanks for your help and best regards,
> >>
> >> Stéphane
> >> --
> >> PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
> >> Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA
> >> Darmstadt HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.:
> >> DE39305391 Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329,
> >> info@peak-system.com
> >> ----
> >> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 7:07 ` Marc Kleine-Budde
@ 2013-04-25 7:35 ` Marc Kleine-Budde
2013-04-25 9:15 ` Kurt Van Dijck
0 siblings, 1 reply; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-25 7:35 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: Stephane Grosjean, linux-can@vger.kernel.org, Kurt Van Dijck
[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]
On 04/25/2013 09:07 AM, Marc Kleine-Budde wrote:
> On 04/25/2013 08:41 AM, Wolfgang Grandegger wrote:
>> Hi Kurt,
>>
>> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
>>> Hi Stephane,
>>>
>>> I have written this some time ago, not using it actually.
>>> I tried a modular approach, don't know if its usefull.
>>>
>>> PS: I used attachments.
>>
>> ~/enumif$ ./enumif
>> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
>> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
>> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
>> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
>> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
>> 6: can1 {can} <NOARP,ECHO> DOWN
>> 7: can2 {can} <NOARP,ECHO> DOWN
>> 8: can3 {can} <NOARP,ECHO> DOWN
>> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
>>
>> Cool! We know that "ip link" does list all network interfaces but the
>> code doing the job is not really strength-forward. I think this would be
>> a nice enhancement of the can-utils.
>
> Good idea, Stephane, can you license the code under a permissive license
> like LGPL or BSD?
Errr...sorry. It's Kurt, who posted that code. Kurt, can you give the
code a nice license? :)
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 7:24 ` Kurt Van Dijck
@ 2013-04-25 7:43 ` Wolfgang Grandegger
2013-04-25 9:14 ` Kurt Van Dijck
0 siblings, 1 reply; 18+ messages in thread
From: Wolfgang Grandegger @ 2013-04-25 7:43 UTC (permalink / raw)
To: Stephane Grosjean, linux-can@vger.kernel.org
On 04/25/2013 09:24 AM, Kurt Van Dijck wrote:
> On Thu, Apr 25, 2013 at 08:41:16AM +0200, Wolfgang Grandegger wrote:
>> Hi Kurt,
>>
>> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
>>> Hi Stephane,
>>>
>>> I have written this some time ago, not using it actually.
>>> I tried a modular approach, don't know if its usefull.
>>>
>>> PS: I used attachments.
>>
>> ~/enumif$ ./enumif
>> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
>> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
>> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
>> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
>> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
>> 6: can1 {can} <NOARP,ECHO> DOWN
>> 7: can2 {can} <NOARP,ECHO> DOWN
>> 8: can3 {can} <NOARP,ECHO> DOWN
>> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
>>
>> Cool! We know that "ip link" does list all network interfaces but the
>> code doing the job is not really strength-forward. I think this would be
>> a nice enhancement of the can-utils.
>
> would it make sense to maintain the split into enumif-test.c and enumif.c,
> so for example Stephane could just link to libenumif.a?
Well, a better place might be libsocketcan then. In general it would be
nice to host libsocketcan (maybe as liblinuxcan) at
https://gitorious.org/linux-can as well.
Wolfgang.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-24 21:02 ` François
2013-04-24 21:27 ` Marc Kleine-Budde
@ 2013-04-25 8:04 ` Kurt Van Dijck
1 sibling, 0 replies; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 8:04 UTC (permalink / raw)
To: François; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
man if_nameindex
if_nameindex does a similar thing :-)
And does not return the type of interface neither.
Kurt
On Wed, Apr 24, 2013 at 11:02:09PM +0200, François wrote:
> Stephane,
>
> This is what i have done in a open source project i have started, a
> web can analyzer called ewecan (https://bitbucket.org/Mongo/ewecan):
> It parses /sys/class/net but unfortunately, as noted in comments, it
> cannot make the difference between up or down interfaces.
>
> /* Get a list of available socketcan interfaces and return them in
> a string as a JS array like ["can0", "can1", "vcan"]
> Returned string must be freed after use
> BUG : it also returns interfaces that are present but down !
> */
> char *cmd_listitf(void)
> {
> char *buf = malloc(255);
> if(!buf)
> return NULL;
> /* looking for socketcan interfaces in /sys */
> DIR *fdir = opendir("/sys/class/net");
> if(fdir == NULL){
> perror("opendir");
> free(buf);
> return NULL;
> }
> struct dirent *fic;
> int firstdone = 0;
> buf[0] = '[';
> buf[1] = '\0';
> while(1){
> fic = readdir(fdir);
> if(fic == NULL)
> break;
> if(!strstr(fic->d_name, "can"))
> continue;
> /* if the new string does not fit in buf, stop here */
> if((strlen(fic->d_name) + strlen(buf) + 4) >= 255)
> break;
> if(firstdone)
> strcat(buf, ",");
> strcat(buf, "\"");
> strcat(buf, fic->d_name);
> strcat(buf, "\"");
> firstdone = 1;
> }
> strcat(buf, "]");
> closedir(fdir);
> return buf;
> }
>
> Hope it can help !
>
> Regards
>
> --
> François Beaulier
> www.ingelibre.fr
>
> Le 24/04/2013 11:06, Stephane Grosjean a écrit :
> >Hi linux-can members,
> >
> >I currently wonder whether it exists any way of getting the list
> >of the installed CAN interfaces, from a C program?
> >I mean, getting the network interfaces list is available using
> >ioctl(SIOCGIFCONF).
> >But AFAIK, this (only) returns the IP interfaces found in the
> >system, even using a socket CAN file descriptor.
> >And, I would also like to avoid some pipe/fork/grep/sed in this C
> >program too ;-)
> >
> >Thanks for your help and best regards,
> >
> >Stéphane
> >--
> >PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt
> >Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA
> >Darmstadt HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078,
> >WEE-Reg.-Nr.: DE39305391 Tel.+49 (0)6151-817320 / Fax:+49
> >(0)6151-817329, info@peak-system.com
> >----
> >To unsubscribe from this list: send the line "unsubscribe linux-can" in
> >the body of a message to majordomo@vger.kernel.org
> >More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 7:43 ` Wolfgang Grandegger
@ 2013-04-25 9:14 ` Kurt Van Dijck
2013-04-25 9:23 ` Marc Kleine-Budde
0 siblings, 1 reply; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 9:14 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Stephane Grosjean, linux-can@vger.kernel.org
I was just thinking that it has not that much to do with CAN altogether,
and may deserve a seperate git tree.
I'm just rewriting the code a bit to work without callback, and be more like
if_nameindex().
I'll post something later on...
Kurt
On Thu, Apr 25, 2013 at 09:43:20AM +0200, Wolfgang Grandegger wrote:
> On 04/25/2013 09:24 AM, Kurt Van Dijck wrote:
> > On Thu, Apr 25, 2013 at 08:41:16AM +0200, Wolfgang Grandegger wrote:
> >> Hi Kurt,
> >>
> >> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
> >>> Hi Stephane,
> >>>
> >>> I have written this some time ago, not using it actually.
> >>> I tried a modular approach, don't know if its usefull.
> >>>
> >>> PS: I used attachments.
> >>
> >> ~/enumif$ ./enumif
> >> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
> >> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
> >> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
> >> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
> >> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
> >> 6: can1 {can} <NOARP,ECHO> DOWN
> >> 7: can2 {can} <NOARP,ECHO> DOWN
> >> 8: can3 {can} <NOARP,ECHO> DOWN
> >> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
> >>
> >> Cool! We know that "ip link" does list all network interfaces but the
> >> code doing the job is not really strength-forward. I think this would be
> >> a nice enhancement of the can-utils.
> >
> > would it make sense to maintain the split into enumif-test.c and enumif.c,
> > so for example Stephane could just link to libenumif.a?
>
> Well, a better place might be libsocketcan then. In general it would be
> nice to host libsocketcan (maybe as liblinuxcan) at
> https://gitorious.org/linux-can as well.
>
> Wolfgang.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 7:35 ` Marc Kleine-Budde
@ 2013-04-25 9:15 ` Kurt Van Dijck
2013-04-25 9:20 ` Marc Kleine-Budde
0 siblings, 1 reply; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 9:15 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Wolfgang Grandegger, Stephane Grosjean, linux-can@vger.kernel.org
On Thu, Apr 25, 2013 at 09:35:35AM +0200, Marc Kleine-Budde wrote:
> On 04/25/2013 09:07 AM, Marc Kleine-Budde wrote:
> > On 04/25/2013 08:41 AM, Wolfgang Grandegger wrote:
> >> Hi Kurt,
> >>
> >> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
> >>> Hi Stephane,
> >>>
> >>> I have written this some time ago, not using it actually.
> >>> I tried a modular approach, don't know if its usefull.
> >>>
> >>> PS: I used attachments.
> >>
> >> ~/enumif$ ./enumif
> >> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
> >> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
> >> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
> >> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
> >> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
> >> 6: can1 {can} <NOARP,ECHO> DOWN
> >> 7: can2 {can} <NOARP,ECHO> DOWN
> >> 8: can3 {can} <NOARP,ECHO> DOWN
> >> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
> >>
> >> Cool! We know that "ip link" does list all network interfaces but the
> >> code doing the job is not really strength-forward. I think this would be
> >> a nice enhancement of the can-utils.
> >
> > Good idea, Stephane, can you license the code under a permissive license
> > like LGPL or BSD?
>
> Errr...sorry. It's Kurt, who posted that code.
> Kurt, can you give the code a nice license? :)
What is needed for LGPL or BSD?
Is there a short overview available?
Kurt
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 9:15 ` Kurt Van Dijck
@ 2013-04-25 9:20 ` Marc Kleine-Budde
0 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-25 9:20 UTC (permalink / raw)
To: Wolfgang Grandegger, Stephane Grosjean, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]
On 04/25/2013 11:15 AM, Kurt Van Dijck wrote:
> On Thu, Apr 25, 2013 at 09:35:35AM +0200, Marc Kleine-Budde wrote:
>> On 04/25/2013 09:07 AM, Marc Kleine-Budde wrote:
>>> On 04/25/2013 08:41 AM, Wolfgang Grandegger wrote:
>>>> Hi Kurt,
>>>>
>>>> On 04/24/2013 04:49 PM, Kurt Van Dijck wrote:
>>>>> Hi Stephane,
>>>>>
>>>>> I have written this some time ago, not using it actually.
>>>>> I tried a modular approach, don't know if its usefull.
>>>>>
>>>>> PS: I used attachments.
>>>>
>>>> ~/enumif$ ./enumif
>>>> 1: lo {loopback} <LOOPBACK,UP,LOWER_UP> UNKNOWN
>>>> 2: eth0 {ether} <BROADCAST,MULTICAST> DOWN
>>>> 3: eth1 {ether} <BROADCAST,MULTICAST,UP,LOWER_UP> UNKNOWN
>>>> 4: eth3 {ether} <NO-CARRIER,BROADCAST,MULTICAST,UP> DOWN
>>>> 5: can0 {can} <NOARP,UP,LOWER_UP,ECHO> UNKNOWN
>>>> 6: can1 {can} <NOARP,ECHO> DOWN
>>>> 7: can2 {can} <NOARP,ECHO> DOWN
>>>> 8: can3 {can} <NOARP,ECHO> DOWN
>>>> 9: pan0 {ether} <BROADCAST,MULTICAST> DOWN
>>>>
>>>> Cool! We know that "ip link" does list all network interfaces but the
>>>> code doing the job is not really strength-forward. I think this would be
>>>> a nice enhancement of the can-utils.
>>>
>>> Good idea, Stephane, can you license the code under a permissive license
>>> like LGPL or BSD?
>>
>> Errr...sorry. It's Kurt, who posted that code.
>
>> Kurt, can you give the code a nice license? :)
> What is needed for LGPL or BSD?
> Is there a short overview available?
If the code is LGPL we can include it in the libsocketcan. You are
allowed to link the library against your closed source application
(without to license under GPL). Any changes you make to the library have
to be made available as source code.
IANAL,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 9:14 ` Kurt Van Dijck
@ 2013-04-25 9:23 ` Marc Kleine-Budde
2013-04-25 9:42 ` Kurt Van Dijck
0 siblings, 1 reply; 18+ messages in thread
From: Marc Kleine-Budde @ 2013-04-25 9:23 UTC (permalink / raw)
To: Wolfgang Grandegger, Stephane Grosjean, linux-can@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 713 bytes --]
On 04/25/2013 11:14 AM, Kurt Van Dijck wrote:
> I was just thinking that it has not that much to do with CAN altogether,
> and may deserve a seperate git tree.
>
> I'm just rewriting the code a bit to work without callback, and be more like
> if_nameindex().
Would be cool if the functions follows the same semantics as
if_nameindex(), i.e. it could be named canif_nameindex() and just return
CAN interfaces, not all.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 9:23 ` Marc Kleine-Budde
@ 2013-04-25 9:42 ` Kurt Van Dijck
2013-04-25 21:08 ` Kurt Van Dijck
0 siblings, 1 reply; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 9:42 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Wolfgang Grandegger, Stephane Grosjean, linux-can@vger.kernel.org
On Thu, Apr 25, 2013 at 11:23:42AM +0200, Marc Kleine-Budde wrote:
> On 04/25/2013 11:14 AM, Kurt Van Dijck wrote:
> > I was just thinking that it has not that much to do with CAN altogether,
> > and may deserve a seperate git tree.
> >
> > I'm just rewriting the code a bit to work without callback, and be more like
> > if_nameindex().
>
> Would be cool if the functions follows the same semantics as
> if_nameindex(), i.e. it could be named canif_nameindex() and just return
> CAN interfaces, not all.
and such function belongs to libsocketcan, indeed. sounds like a plan.
>
> Marc
> --
> Pengutronix e.K. | Marc Kleine-Budde |
> Industrial Linux Solutions | Phone: +49-231-2826-924 |
> Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
>
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Is there any way of getting the CAN interfaces list, from any C program?
2013-04-25 9:42 ` Kurt Van Dijck
@ 2013-04-25 21:08 ` Kurt Van Dijck
0 siblings, 0 replies; 18+ messages in thread
From: Kurt Van Dijck @ 2013-04-25 21:08 UTC (permalink / raw)
To: Marc Kleine-Budde, Wolfgang Grandegger, Stephane Grosjean,
linux-can@vger.kernel.org
On Thu, Apr 25, 2013 at 11:42:35AM +0200, Kurt Van Dijck wrote:
> On Thu, Apr 25, 2013 at 11:23:42AM +0200, Marc Kleine-Budde wrote:
> > On 04/25/2013 11:14 AM, Kurt Van Dijck wrote:
> > > I was just thinking that it has not that much to do with CAN altogether,
> > > and may deserve a seperate git tree.
> > >
> > > I'm just rewriting the code a bit to work without callback, and be more like
> > > if_nameindex().
> >
> > Would be cool if the functions follows the same semantics as
> > if_nameindex(), i.e. it could be named canif_nameindex() and just return
> > CAN interfaces, not all.
> and such function belongs to libsocketcan, indeed. sounds like a plan.
I realized I don't want to put much effort in making the code
more dedicated to one task and struggle with the struct definition
that if_nameindex uses (no status info).
So, I sanitized my version a bit, and
I just released libenumif on git://github.com/kurt-vd/enumif.git
This one allows to find:
* all can interfaces
* all active can interfaces.
* ...
Since it's LGPL'd, one can use it as is,
or use the code to build a canif_nameindex().
Kind regards,
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2013-04-25 21:08 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-13 19:35 [RFC PATCH v2] can: sja1000: use common prefix for all sja1000 defines Oliver Hartkopp
2013-04-16 10:40 ` Marc Kleine-Budde
2013-04-24 9:06 ` Is there any way of getting the CAN interfaces list, from any C program? Stephane Grosjean
2013-04-24 14:49 ` Kurt Van Dijck
2013-04-25 6:41 ` Wolfgang Grandegger
2013-04-25 7:07 ` Marc Kleine-Budde
2013-04-25 7:35 ` Marc Kleine-Budde
2013-04-25 9:15 ` Kurt Van Dijck
2013-04-25 9:20 ` Marc Kleine-Budde
2013-04-25 7:24 ` Kurt Van Dijck
2013-04-25 7:43 ` Wolfgang Grandegger
2013-04-25 9:14 ` Kurt Van Dijck
2013-04-25 9:23 ` Marc Kleine-Budde
2013-04-25 9:42 ` Kurt Van Dijck
2013-04-25 21:08 ` Kurt Van Dijck
2013-04-24 21:02 ` François
2013-04-24 21:27 ` Marc Kleine-Budde
2013-04-25 8:04 ` Kurt Van Dijck
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).