Commit d2ca24ee authored by David S. Miller's avatar David S. Miller

Merge branch 'ixp4xxx_hss-cleanups'

Peng Li says:

====================
net: ixp4xx_hss: clean up some code style issues

This patchset clean up some code style issues.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f1dcdc07 e0bd2764
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
#define PKT_HDLC_CRC_32 0x2 /* default = CRC-16 */ #define PKT_HDLC_CRC_32 0x2 /* default = CRC-16 */
#define PKT_HDLC_MSB_ENDIAN 0x4 /* default = LE */ #define PKT_HDLC_MSB_ENDIAN 0x4 /* default = LE */
/* hss_config, PCRs */ /* hss_config, PCRs */
/* Frame sync sampling, default = active low */ /* Frame sync sampling, default = active low */
#define PCR_FRM_SYNC_ACTIVE_HIGH 0x40000000 #define PCR_FRM_SYNC_ACTIVE_HIGH 0x40000000
...@@ -150,26 +149,24 @@ ...@@ -150,26 +149,24 @@
/* HSS number, default = 0 (first) */ /* HSS number, default = 0 (first) */
#define CCR_SECOND_HSS 0x01000000 #define CCR_SECOND_HSS 0x01000000
/* hss_config, clkCR: main:10, num:10, denom:12 */ /* hss_config, clkCR: main:10, num:10, denom:12 */
#define CLK42X_SPEED_EXP ((0x3FF << 22) | ( 2 << 12) | 15) /*65 KHz*/ #define CLK42X_SPEED_EXP ((0x3FF << 22) | (2 << 12) | 15) /*65 KHz*/
#define CLK42X_SPEED_512KHZ (( 130 << 22) | ( 2 << 12) | 15) #define CLK42X_SPEED_512KHZ ((130 << 22) | (2 << 12) | 15)
#define CLK42X_SPEED_1536KHZ (( 43 << 22) | ( 18 << 12) | 47) #define CLK42X_SPEED_1536KHZ ((43 << 22) | (18 << 12) | 47)
#define CLK42X_SPEED_1544KHZ (( 43 << 22) | ( 33 << 12) | 192) #define CLK42X_SPEED_1544KHZ ((43 << 22) | (33 << 12) | 192)
#define CLK42X_SPEED_2048KHZ (( 32 << 22) | ( 34 << 12) | 63) #define CLK42X_SPEED_2048KHZ ((32 << 22) | (34 << 12) | 63)
#define CLK42X_SPEED_4096KHZ (( 16 << 22) | ( 34 << 12) | 127) #define CLK42X_SPEED_4096KHZ ((16 << 22) | (34 << 12) | 127)
#define CLK42X_SPEED_8192KHZ (( 8 << 22) | ( 34 << 12) | 255) #define CLK42X_SPEED_8192KHZ ((8 << 22) | (34 << 12) | 255)
#define CLK46X_SPEED_512KHZ (( 130 << 22) | ( 24 << 12) | 127) #define CLK46X_SPEED_512KHZ ((130 << 22) | (24 << 12) | 127)
#define CLK46X_SPEED_1536KHZ (( 43 << 22) | (152 << 12) | 383) #define CLK46X_SPEED_1536KHZ ((43 << 22) | (152 << 12) | 383)
#define CLK46X_SPEED_1544KHZ (( 43 << 22) | ( 66 << 12) | 385) #define CLK46X_SPEED_1544KHZ ((43 << 22) | (66 << 12) | 385)
#define CLK46X_SPEED_2048KHZ (( 32 << 22) | (280 << 12) | 511) #define CLK46X_SPEED_2048KHZ ((32 << 22) | (280 << 12) | 511)
#define CLK46X_SPEED_4096KHZ (( 16 << 22) | (280 << 12) | 1023) #define CLK46X_SPEED_4096KHZ ((16 << 22) | (280 << 12) | 1023)
#define CLK46X_SPEED_8192KHZ (( 8 << 22) | (280 << 12) | 2047) #define CLK46X_SPEED_8192KHZ ((8 << 22) | (280 << 12) | 2047)
/* /* HSS_CONFIG_CLOCK_CR register consists of 3 parts:
* HSS_CONFIG_CLOCK_CR register consists of 3 parts:
* A (10 bits), B (10 bits) and C (12 bits). * A (10 bits), B (10 bits) and C (12 bits).
* IXP42x HSS clock generator operation (verified with an oscilloscope): * IXP42x HSS clock generator operation (verified with an oscilloscope):
* Each clock bit takes 7.5 ns (1 / 133.xx MHz). * Each clock bit takes 7.5 ns (1 / 133.xx MHz).
...@@ -208,7 +205,6 @@ ...@@ -208,7 +205,6 @@
#define HSS_CONFIG_TX_LUT 0x18 /* channel look-up tables */ #define HSS_CONFIG_TX_LUT 0x18 /* channel look-up tables */
#define HSS_CONFIG_RX_LUT 0x38 #define HSS_CONFIG_RX_LUT 0x38
/* NPE command codes */ /* NPE command codes */
/* writes the ConfigWord value to the location specified by offset */ /* writes the ConfigWord value to the location specified by offset */
#define PORT_CONFIG_WRITE 0x40 #define PORT_CONFIG_WRITE 0x40
...@@ -220,7 +216,8 @@ ...@@ -220,7 +216,8 @@
#define PORT_ERROR_READ 0x42 #define PORT_ERROR_READ 0x42
/* triggers the NPE to reset internal status and enable the HssPacketized /* triggers the NPE to reset internal status and enable the HssPacketized
operation for the flow specified by pPipe */ * operation for the flow specified by pPipe
*/
#define PKT_PIPE_FLOW_ENABLE 0x50 #define PKT_PIPE_FLOW_ENABLE 0x50
#define PKT_PIPE_FLOW_DISABLE 0x51 #define PKT_PIPE_FLOW_DISABLE 0x51
#define PKT_NUM_PIPES_WRITE 0x52 #define PKT_NUM_PIPES_WRITE 0x52
...@@ -235,12 +232,12 @@ ...@@ -235,12 +232,12 @@
#define ERR_HDLC_ALIGN 2 /* HDLC alignment error */ #define ERR_HDLC_ALIGN 2 /* HDLC alignment error */
#define ERR_HDLC_FCS 3 /* HDLC Frame Check Sum error */ #define ERR_HDLC_FCS 3 /* HDLC Frame Check Sum error */
#define ERR_RXFREE_Q_EMPTY 4 /* RX-free queue became empty while receiving #define ERR_RXFREE_Q_EMPTY 4 /* RX-free queue became empty while receiving
this packet (if buf_len < pkt_len) */ * this packet (if buf_len < pkt_len)
*/
#define ERR_HDLC_TOO_LONG 5 /* HDLC frame size too long */ #define ERR_HDLC_TOO_LONG 5 /* HDLC frame size too long */
#define ERR_HDLC_ABORT 6 /* abort sequence received */ #define ERR_HDLC_ABORT 6 /* abort sequence received */
#define ERR_DISCONNECTING 7 /* disconnect is in progress */ #define ERR_DISCONNECTING 7 /* disconnect is in progress */
#ifdef __ARMEB__ #ifdef __ARMEB__
typedef struct sk_buff buffer_t; typedef struct sk_buff buffer_t;
#define free_buffer dev_kfree_skb #define free_buffer dev_kfree_skb
...@@ -308,7 +305,6 @@ struct desc { ...@@ -308,7 +305,6 @@ struct desc {
u32 __reserved1[4]; u32 __reserved1[4];
}; };
#define rx_desc_phys(port, n) ((port)->desc_tab_phys + \ #define rx_desc_phys(port, n) ((port)->desc_tab_phys + \
(n) * sizeof(struct desc)) (n) * sizeof(struct desc))
#define rx_desc_ptr(port, n) (&(port)->desc_tab[n]) #define rx_desc_ptr(port, n) (&(port)->desc_tab[n])
...@@ -327,7 +323,7 @@ static DEFINE_SPINLOCK(npe_lock); ...@@ -327,7 +323,7 @@ static DEFINE_SPINLOCK(npe_lock);
static const struct { static const struct {
int tx, txdone, rx, rxfree; int tx, txdone, rx, rxfree;
}queue_ids[2] = {{HSS0_PKT_TX0_QUEUE, HSS0_PKT_TXDONE_QUEUE, HSS0_PKT_RX_QUEUE, } queue_ids[2] = {{HSS0_PKT_TX0_QUEUE, HSS0_PKT_TXDONE_QUEUE, HSS0_PKT_RX_QUEUE,
HSS0_PKT_RXFREE0_QUEUE}, HSS0_PKT_RXFREE0_QUEUE},
{HSS1_PKT_TX0_QUEUE, HSS1_PKT_TXDONE_QUEUE, HSS1_PKT_RX_QUEUE, {HSS1_PKT_TX0_QUEUE, HSS1_PKT_TXDONE_QUEUE, HSS1_PKT_RX_QUEUE,
HSS1_PKT_RXFREE0_QUEUE}, HSS1_PKT_RXFREE0_QUEUE},
...@@ -337,7 +333,7 @@ static const struct { ...@@ -337,7 +333,7 @@ static const struct {
* utility functions * utility functions
****************************************************************************/ ****************************************************************************/
static inline struct port* dev_to_port(struct net_device *dev) static inline struct port *dev_to_port(struct net_device *dev)
{ {
return dev_to_hdlc(dev)->priv; return dev_to_hdlc(dev)->priv;
} }
...@@ -346,6 +342,7 @@ static inline struct port* dev_to_port(struct net_device *dev) ...@@ -346,6 +342,7 @@ static inline struct port* dev_to_port(struct net_device *dev)
static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt) static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt)
{ {
int i; int i;
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
dest[i] = swab32(src[i]); dest[i] = swab32(src[i]);
} }
...@@ -355,9 +352,10 @@ static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt) ...@@ -355,9 +352,10 @@ static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt)
* HSS access * HSS access
****************************************************************************/ ****************************************************************************/
static void hss_npe_send(struct port *port, struct msg *msg, const char* what) static void hss_npe_send(struct port *port, struct msg *msg, const char *what)
{ {
u32 *val = (u32*)msg; u32 *val = (u32 *)msg;
if (npe_send_message(port->npe, msg, what)) { if (npe_send_message(port->npe, msg, what)) {
pr_crit("HSS-%i: unable to send command [%08X:%08X] to %s\n", pr_crit("HSS-%i: unable to send command [%08X:%08X] to %s\n",
port->id, val[0], val[1], npe_name(port->npe)); port->id, val[0], val[1], npe_name(port->npe));
...@@ -513,10 +511,12 @@ static int hss_load_firmware(struct port *port) ...@@ -513,10 +511,12 @@ static int hss_load_firmware(struct port *port)
if (port->initialized) if (port->initialized)
return 0; return 0;
if (!npe_running(port->npe) && if (!npe_running(port->npe)) {
(err = npe_load_firmware(port->npe, npe_name(port->npe), err = npe_load_firmware(port->npe, npe_name(port->npe),
port->dev))) port->dev);
return err; if (err)
return err;
}
/* HDLC mode configuration */ /* HDLC mode configuration */
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
...@@ -567,7 +567,6 @@ static inline void debug_pkt(struct net_device *dev, const char *func, ...@@ -567,7 +567,6 @@ static inline void debug_pkt(struct net_device *dev, const char *func,
#endif #endif
} }
static inline void debug_desc(u32 phys, struct desc *desc) static inline void debug_desc(u32 phys, struct desc *desc)
{ {
#if DEBUG_DESC #if DEBUG_DESC
...@@ -583,7 +582,8 @@ static inline int queue_get_desc(unsigned int queue, struct port *port, ...@@ -583,7 +582,8 @@ static inline int queue_get_desc(unsigned int queue, struct port *port,
u32 phys, tab_phys, n_desc; u32 phys, tab_phys, n_desc;
struct desc *tab; struct desc *tab;
if (!(phys = qmgr_get_entry(queue))) phys = qmgr_get_entry(queue);
if (!phys)
return -1; return -1;
BUG_ON(phys & 0x1F); BUG_ON(phys & 0x1F);
...@@ -603,10 +603,10 @@ static inline void queue_put_desc(unsigned int queue, u32 phys, ...@@ -603,10 +603,10 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
BUG_ON(phys & 0x1F); BUG_ON(phys & 0x1F);
qmgr_put_entry(queue, phys); qmgr_put_entry(queue, phys);
/* Don't check for queue overflow here, we've allocated sufficient /* Don't check for queue overflow here, we've allocated sufficient
length and queues >= 32 don't support this check anyway. */ * length and queues >= 32 don't support this check anyway.
*/
} }
static inline void dma_unmap_tx(struct port *port, struct desc *desc) static inline void dma_unmap_tx(struct port *port, struct desc *desc)
{ {
#ifdef __ARMEB__ #ifdef __ARMEB__
...@@ -619,7 +619,6 @@ static inline void dma_unmap_tx(struct port *port, struct desc *desc) ...@@ -619,7 +619,6 @@ static inline void dma_unmap_tx(struct port *port, struct desc *desc)
#endif #endif
} }
static void hss_hdlc_set_carrier(void *pdev, int carrier) static void hss_hdlc_set_carrier(void *pdev, int carrier)
{ {
struct net_device *netdev = pdev; struct net_device *netdev = pdev;
...@@ -670,7 +669,8 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget) ...@@ -670,7 +669,8 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget)
u32 phys; u32 phys;
#endif #endif
if ((n = queue_get_desc(rxq, port, 0)) < 0) { n = queue_get_desc(rxq, port, 0);
if (n < 0) {
#if DEBUG_RX #if DEBUG_RX
printk(KERN_DEBUG "%s: hss_hdlc_poll" printk(KERN_DEBUG "%s: hss_hdlc_poll"
" napi_complete\n", dev->name); " napi_complete\n", dev->name);
...@@ -705,7 +705,8 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget) ...@@ -705,7 +705,8 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget)
switch (desc->status) { switch (desc->status) {
case 0: case 0:
#ifdef __ARMEB__ #ifdef __ARMEB__
if ((skb = netdev_alloc_skb(dev, RX_SIZE)) != NULL) { skb = netdev_alloc_skb(dev, RX_SIZE);
if (skb) {
phys = dma_map_single(&dev->dev, skb->data, phys = dma_map_single(&dev->dev, skb->data,
RX_SIZE, RX_SIZE,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
...@@ -784,7 +785,6 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget) ...@@ -784,7 +785,6 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget)
return received; /* not all work done */ return received; /* not all work done */
} }
static void hss_hdlc_txdone_irq(void *pdev) static void hss_hdlc_txdone_irq(void *pdev)
{ {
struct net_device *dev = pdev; struct net_device *dev = pdev;
...@@ -854,7 +854,8 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -854,7 +854,8 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
#else #else
offset = (int)skb->data & 3; /* keep 32-bit alignment */ offset = (int)skb->data & 3; /* keep 32-bit alignment */
bytes = ALIGN(offset + len, 4); bytes = ALIGN(offset + len, 4);
if (!(mem = kmalloc(bytes, GFP_ATOMIC))) { mem = kmalloc(bytes, GFP_ATOMIC);
if (!mem) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
dev->stats.tx_dropped++; dev->stats.tx_dropped++;
return NETDEV_TX_OK; return NETDEV_TX_OK;
...@@ -910,7 +911,6 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -910,7 +911,6 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
static int request_hdlc_queues(struct port *port) static int request_hdlc_queues(struct port *port)
{ {
int err; int err;
...@@ -974,8 +974,9 @@ static int init_hdlc_queues(struct port *port) ...@@ -974,8 +974,9 @@ static int init_hdlc_queues(struct port *port)
return -ENOMEM; return -ENOMEM;
} }
if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
&port->desc_tab_phys))) &port->desc_tab_phys);
if (!port->desc_tab)
return -ENOMEM; return -ENOMEM;
memset(port->desc_tab, 0, POOL_ALLOC_SIZE); memset(port->desc_tab, 0, POOL_ALLOC_SIZE);
memset(port->rx_buff_tab, 0, sizeof(port->rx_buff_tab)); /* tables */ memset(port->rx_buff_tab, 0, sizeof(port->rx_buff_tab)); /* tables */
...@@ -987,11 +988,13 @@ static int init_hdlc_queues(struct port *port) ...@@ -987,11 +988,13 @@ static int init_hdlc_queues(struct port *port)
buffer_t *buff; buffer_t *buff;
void *data; void *data;
#ifdef __ARMEB__ #ifdef __ARMEB__
if (!(buff = netdev_alloc_skb(port->netdev, RX_SIZE))) buff = netdev_alloc_skb(port->netdev, RX_SIZE);
if (!buff)
return -ENOMEM; return -ENOMEM;
data = buff->data; data = buff->data;
#else #else
if (!(buff = kmalloc(RX_SIZE, GFP_KERNEL))) buff = kmalloc(RX_SIZE, GFP_KERNEL);
if (!buff)
return -ENOMEM; return -ENOMEM;
data = buff; data = buff;
#endif #endif
...@@ -1016,6 +1019,7 @@ static void destroy_hdlc_queues(struct port *port) ...@@ -1016,6 +1019,7 @@ static void destroy_hdlc_queues(struct port *port)
for (i = 0; i < RX_DESCS; i++) { for (i = 0; i < RX_DESCS; i++) {
struct desc *desc = rx_desc_ptr(port, i); struct desc *desc = rx_desc_ptr(port, i);
buffer_t *buff = port->rx_buff_tab[i]; buffer_t *buff = port->rx_buff_tab[i];
if (buff) { if (buff) {
dma_unmap_single(&port->netdev->dev, dma_unmap_single(&port->netdev->dev,
desc->data, RX_SIZE, desc->data, RX_SIZE,
...@@ -1026,6 +1030,7 @@ static void destroy_hdlc_queues(struct port *port) ...@@ -1026,6 +1030,7 @@ static void destroy_hdlc_queues(struct port *port)
for (i = 0; i < TX_DESCS; i++) { for (i = 0; i < TX_DESCS; i++) {
struct desc *desc = tx_desc_ptr(port, i); struct desc *desc = tx_desc_ptr(port, i);
buffer_t *buff = port->tx_buff_tab[i]; buffer_t *buff = port->tx_buff_tab[i];
if (buff) { if (buff) {
dma_unmap_tx(port, desc); dma_unmap_tx(port, desc);
free_buffer(buff); free_buffer(buff);
...@@ -1047,23 +1052,29 @@ static int hss_hdlc_open(struct net_device *dev) ...@@ -1047,23 +1052,29 @@ static int hss_hdlc_open(struct net_device *dev)
unsigned long flags; unsigned long flags;
int i, err = 0; int i, err = 0;
if ((err = hdlc_open(dev))) err = hdlc_open(dev);
if (err)
return err; return err;
if ((err = hss_load_firmware(port))) err = hss_load_firmware(port);
if (err)
goto err_hdlc_close; goto err_hdlc_close;
if ((err = request_hdlc_queues(port))) err = request_hdlc_queues(port);
if (err)
goto err_hdlc_close; goto err_hdlc_close;
if ((err = init_hdlc_queues(port))) err = init_hdlc_queues(port);
if (err)
goto err_destroy_queues; goto err_destroy_queues;
spin_lock_irqsave(&npe_lock, flags); spin_lock_irqsave(&npe_lock, flags);
if (port->plat->open) if (port->plat->open) {
if ((err = port->plat->open(port->id, dev, err = port->plat->open(port->id, dev, hss_hdlc_set_carrier);
hss_hdlc_set_carrier))) if (err)
goto err_unlock; goto err_unlock;
}
spin_unlock_irqrestore(&npe_lock, flags); spin_unlock_irqrestore(&npe_lock, flags);
/* Populate queues with buffers, no failure after this point */ /* Populate queues with buffers, no failure after this point */
...@@ -1160,7 +1171,6 @@ static int hss_hdlc_close(struct net_device *dev) ...@@ -1160,7 +1171,6 @@ static int hss_hdlc_close(struct net_device *dev)
return 0; return 0;
} }
static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding, static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding,
unsigned short parity) unsigned short parity)
{ {
...@@ -1169,7 +1179,7 @@ static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding, ...@@ -1169,7 +1179,7 @@ static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding,
if (encoding != ENCODING_NRZ) if (encoding != ENCODING_NRZ)
return -EINVAL; return -EINVAL;
switch(parity) { switch (parity) {
case PARITY_CRC16_PR1_CCITT: case PARITY_CRC16_PR1_CCITT:
port->hdlc_cfg = 0; port->hdlc_cfg = 0;
return 0; return 0;
...@@ -1224,6 +1234,7 @@ static void find_best_clock(u32 timer_freq, u32 rate, u32 *best, u32 *reg) ...@@ -1224,6 +1234,7 @@ static void find_best_clock(u32 timer_freq, u32 rate, u32 *best, u32 *reg)
for (b = 0; b < 0x400; b++) { for (b = 0; b < 0x400; b++) {
u64 c = (b + 1) * (u64)rate; u64 c = (b + 1) * (u64)rate;
do_div(c, timer_freq - rate * a); do_div(c, timer_freq - rate * a);
c--; c--;
if (c >= 0xFFF) { /* 12-bit - no need to check more 'b's */ if (c >= 0xFFF) { /* 12-bit - no need to check more 'b's */
...@@ -1255,7 +1266,7 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -1255,7 +1266,7 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV) if (cmd != SIOCWANDEV)
return hdlc_ioctl(dev, ifr, cmd); return hdlc_ioctl(dev, ifr, cmd);
switch(ifr->ifr_settings.type) { switch (ifr->ifr_settings.type) {
case IF_GET_IFACE: case IF_GET_IFACE:
ifr->ifr_settings.type = IF_IFACE_V35; ifr->ifr_settings.type = IF_IFACE_V35;
if (ifr->ifr_settings.size < size) { if (ifr->ifr_settings.size < size) {
...@@ -1272,7 +1283,7 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -1272,7 +1283,7 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case IF_IFACE_SYNC_SERIAL: case IF_IFACE_SYNC_SERIAL:
case IF_IFACE_V35: case IF_IFACE_V35:
if(!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if (copy_from_user(&new_line, line, size)) if (copy_from_user(&new_line, line, size))
return -EFAULT; return -EFAULT;
...@@ -1288,11 +1299,11 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -1288,11 +1299,11 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return -EINVAL; return -EINVAL;
port->clock_type = clk; /* Update settings */ port->clock_type = clk; /* Update settings */
if (clk == CLOCK_INT) if (clk == CLOCK_INT) {
find_best_clock(port->plat->timer_freq, find_best_clock(port->plat->timer_freq,
new_line.clock_rate, new_line.clock_rate,
&port->clock_rate, &port->clock_reg); &port->clock_rate, &port->clock_reg);
else { } else {
port->clock_rate = 0; port->clock_rate = 0;
port->clock_reg = CLK42X_SPEED_2048KHZ; port->clock_reg = CLK42X_SPEED_2048KHZ;
} }
...@@ -1334,15 +1345,19 @@ static int hss_init_one(struct platform_device *pdev) ...@@ -1334,15 +1345,19 @@ static int hss_init_one(struct platform_device *pdev)
hdlc_device *hdlc; hdlc_device *hdlc;
int err; int err;
if ((port = kzalloc(sizeof(*port), GFP_KERNEL)) == NULL) port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM; return -ENOMEM;
if ((port->npe = npe_request(0)) == NULL) { port->npe = npe_request(0);
if (!port->npe) {
err = -ENODEV; err = -ENODEV;
goto err_free; goto err_free;
} }
if ((port->netdev = dev = alloc_hdlcdev(port)) == NULL) { dev = alloc_hdlcdev(port);
port->netdev = alloc_hdlcdev(port);
if (!port->netdev) {
err = -ENOMEM; err = -ENOMEM;
goto err_plat; goto err_plat;
} }
...@@ -1361,7 +1376,8 @@ static int hss_init_one(struct platform_device *pdev) ...@@ -1361,7 +1376,8 @@ static int hss_init_one(struct platform_device *pdev)
port->plat = pdev->dev.platform_data; port->plat = pdev->dev.platform_data;
netif_napi_add(dev, &port->napi, hss_hdlc_poll, NAPI_WEIGHT); netif_napi_add(dev, &port->napi, hss_hdlc_poll, NAPI_WEIGHT);
if ((err = register_hdlc_device(dev))) err = register_hdlc_device(dev);
if (err)
goto err_free_netdev; goto err_free_netdev;
platform_set_drvdata(pdev, port); platform_set_drvdata(pdev, port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment