diff options
Diffstat (limited to 'drivers/staging')
342 files changed, 10269 insertions, 11539 deletions
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 2ab0c20..3a8f210 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -424,7 +424,7 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait) if (!status) return POLLIN; - else if (status < 0) + if (status < 0) return POLLERR; return 0; } diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index d57fade..d1cf6a1 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -686,13 +686,6 @@ static bool __comedi_is_subdevice_running(struct comedi_subdevice *s) return comedi_is_runflags_running(runflags); } -static bool comedi_is_subdevice_idle(struct comedi_subdevice *s) -{ - unsigned runflags = comedi_get_subdevice_runflags(s); - - return !(runflags & COMEDI_SRF_BUSY_MASK); -} - bool comedi_can_auto_free_spriv(struct comedi_subdevice *s) { unsigned runflags = __comedi_get_subdevice_runflags(s); @@ -1111,6 +1104,9 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, struct comedi_bufinfo bi; struct comedi_subdevice *s; struct comedi_async *async; + unsigned int runflags; + int retval = 0; + bool become_nonbusy = false; if (copy_from_user(&bi, arg, sizeof(bi))) return -EFAULT; @@ -1122,48 +1118,56 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, async = s->async; - if (!async) { - dev_dbg(dev->class_dev, - "subdevice does not have async capability\n"); - bi.buf_write_ptr = 0; - bi.buf_read_ptr = 0; - bi.buf_write_count = 0; - bi.buf_read_count = 0; - bi.bytes_read = 0; - bi.bytes_written = 0; - goto copyback; - } - if (!s->busy) { - bi.bytes_read = 0; - bi.bytes_written = 0; - goto copyback_position; - } - if (s->busy != file) - return -EACCES; - - if (bi.bytes_read && !(async->cmd.flags & CMDF_WRITE)) { - bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read); - comedi_buf_read_free(s, bi.bytes_read); + if (!async || s->busy != file) + return -EINVAL; - if (comedi_is_subdevice_idle(s) && - comedi_buf_read_n_available(s) == 0) { - do_become_nonbusy(dev, s); + runflags = comedi_get_subdevice_runflags(s); + if (!(async->cmd.flags & CMDF_WRITE)) { + /* command was set up in "read" direction */ + if (bi.bytes_read) { + comedi_buf_read_alloc(s, bi.bytes_read); + bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read); } + /* + * If nothing left to read, and command has stopped, and + * {"read" position not updated or command stopped normally}, + * then become non-busy. + */ + if (comedi_buf_read_n_available(s) == 0 && + !comedi_is_runflags_running(runflags) && + (bi.bytes_read == 0 || + !comedi_is_runflags_in_error(runflags))) { + become_nonbusy = true; + if (comedi_is_runflags_in_error(runflags)) + retval = -EPIPE; + } + bi.bytes_written = 0; + } else { + /* command was set up in "write" direction */ + if (!comedi_is_runflags_running(runflags)) { + bi.bytes_written = 0; + become_nonbusy = true; + if (comedi_is_runflags_in_error(runflags)) + retval = -EPIPE; + } else if (bi.bytes_written) { + comedi_buf_write_alloc(s, bi.bytes_written); + bi.bytes_written = + comedi_buf_write_free(s, bi.bytes_written); + } + bi.bytes_read = 0; } - if (bi.bytes_written && (async->cmd.flags & CMDF_WRITE)) { - bi.bytes_written = - comedi_buf_write_alloc(s, bi.bytes_written); - comedi_buf_write_free(s, bi.bytes_written); - } - -copyback_position: bi.buf_write_count = async->buf_write_count; bi.buf_write_ptr = async->buf_write_ptr; bi.buf_read_count = async->buf_read_count; bi.buf_read_ptr = async->buf_read_ptr; -copyback: + if (become_nonbusy) + do_become_nonbusy(dev, s); + + if (retval) + return retval; + if (copy_to_user(arg, &bi, sizeof(bi))) return -EFAULT; diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 995096c..b6af3eb 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -496,7 +496,7 @@ static int apci3xxx_ai_ns_to_timer(struct comedi_device *dev, switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - timer = (*ns + base / 2) / base; + timer = DIV_ROUND_CLOSEST(*ns, base); break; case CMDF_ROUND_DOWN: timer = *ns / base; diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 4b39f69..d1fe88a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -637,7 +637,7 @@ static unsigned int pci230_divide_ns(uint64_t ns, unsigned int timebase, switch (flags & CMDF_ROUND_MASK) { default: case CMDF_ROUND_NEAREST: - div += (rem + (timebase / 2)) / timebase; + div += DIV_ROUND_CLOSEST(rem, timebase); break; case CMDF_ROUND_DOWN: break; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index d33b8fe..e918d42 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1376,7 +1376,7 @@ static int set_ai_fifo_segment_length(struct comedi_device *dev, num_entries = fifo->max_segment_length; /* 1 == 256 entries, 2 == 512 entries, etc */ - num_increments = (num_entries + increment_size / 2) / increment_size; + num_increments = DIV_ROUND_CLOSEST(num_entries, increment_size); bits = (~(num_increments - 1)) & fifo->fifo_size_reg_mask; devpriv->fifo_size_bits &= ~fifo->fifo_size_reg_mask; @@ -2004,7 +2004,7 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags) break; case CMDF_ROUND_NEAREST: default: - divisor = (ns + TIMER_BASE / 2) / TIMER_BASE; + divisor = DIV_ROUND_CLOSEST(ns, TIMER_BASE); break; } return divisor; diff --git a/drivers/staging/comedi/drivers/comedi_isadma.c b/drivers/staging/comedi/drivers/comedi_isadma.c index 6ba71d1..68ef9b1 100644 --- a/drivers/staging/comedi/drivers/comedi_isadma.c +++ b/drivers/staging/comedi/drivers/comedi_isadma.c @@ -132,8 +132,7 @@ unsigned int comedi_isadma_poll(struct comedi_isadma *dma) result = result1; if (result >= desc->size || result == 0) return 0; - else - return desc->size - result; + return desc->size - result; } EXPORT_SYMBOL_GPL(comedi_isadma_poll); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 5a536a0..6c26e09 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -371,7 +371,7 @@ static unsigned int dt282x_ns_to_timer(unsigned int *ns, unsigned int flags) switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - divider = (*ns + base / 2) / base; + divider = DIV_ROUND_CLOSEST(*ns, base); break; case CMDF_ROUND_DOWN: divider = (*ns) / base; diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index ab7a332..19e0b7b 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -361,7 +361,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec, switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - divider = (*nanosec + base / 2) / base; + divider = DIV_ROUND_CLOSEST(*nanosec, base); break; case CMDF_ROUND_DOWN: divider = (*nanosec) / base; diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index ac79099..67b9f22 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -525,7 +525,7 @@ static int ni_pcidio_ns_to_timer(int *nanosec, unsigned int flags) switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - divider = (*nanosec + base / 2) / base; + divider = DIV_ROUND_CLOSEST(*nanosec, base); break; case CMDF_ROUND_DOWN: divider = (*nanosec) / base; diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index a1f624f..d38673c 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -21,7 +21,6 @@ #include <linux/ioport.h> #include <linux/slab.h> #include <linux/errno.h> -#include <linux/init.h> #include <linux/list.h> #include <linux/interrupt.h> #include <linux/proc_fs.h> diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 3bcbabf..6c9cdd2 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -130,7 +130,8 @@ static int fbtft_request_gpios(struct fbtft_par *par) while (gpio->name[0]) { flags = FBTFT_GPIO_NO_MATCH; /* if driver provides match function, try it first, - if no match use our own */ + * if no match use our own + */ if (par->fbtftops.request_gpios_match) flags = par->fbtftops.request_gpios_match(par, gpio); if (flags == FBTFT_GPIO_NO_MATCH) @@ -518,8 +519,7 @@ static ssize_t fbtft_fb_write(struct fb_info *info, const char __user *buf, "%s: count=%zd, ppos=%llu\n", __func__, count, *ppos); res = fb_sys_write(info, buf, count, ppos); - /* TODO: only mark changed area - update all for now */ + /* TODO: only mark changed area update all for now */ par->fbtftops.mkdirty(info, -1, 0); return res; diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig index c498ac6..1f95933 100644 --- a/drivers/staging/fsl-mc/bus/Kconfig +++ b/drivers/staging/fsl-mc/bus/Kconfig @@ -7,7 +7,7 @@ # config FSL_MC_BUS - tristate "Freescale Management Complex (MC) bus driver" + bool "Freescale Management Complex (MC) bus driver" depends on OF && ARM64 select GENERIC_MSI_IRQ_DOMAIN help diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c b/drivers/staging/fsl-mc/bus/mc-allocator.c index c5fa628..86f8543 100644 --- a/drivers/staging/fsl-mc/bus/mc-allocator.c +++ b/drivers/staging/fsl-mc/bus/mc-allocator.c @@ -756,7 +756,7 @@ int __init fsl_mc_allocator_driver_init(void) return fsl_mc_driver_register(&fsl_mc_allocator_driver); } -void __exit fsl_mc_allocator_driver_exit(void) +void fsl_mc_allocator_driver_exit(void) { fsl_mc_driver_unregister(&fsl_mc_allocator_driver); } diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index 9317561..5958e0f 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -248,8 +248,7 @@ static bool fsl_mc_is_root_dprc(struct device *dev) fsl_mc_get_root_dprc(dev, &root_dprc_dev); if (!root_dprc_dev) return false; - else - return dev == root_dprc_dev; + return dev == root_dprc_dev; } static int get_dprc_icid(struct fsl_mc_io *mc_io, @@ -795,7 +794,6 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table); static struct platform_driver fsl_mc_bus_driver = { .driver = { .name = "fsl_mc_bus", - .owner = THIS_MODULE, .pm = NULL, .of_match_table = fsl_mc_bus_match_table, }, diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index be72a44..ee5f1d2 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -123,7 +123,7 @@ void dprc_driver_exit(void); int __init fsl_mc_allocator_driver_init(void); -void __exit fsl_mc_allocator_driver_exit(void); +void fsl_mc_allocator_driver_exit(void); int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus, enum fsl_mc_pool_type pool_type, diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index 8c99f91..9fc476f 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -261,7 +261,7 @@ int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev) struct list_head send_list; int ret = 0; - tcph = (struct tcphdr *)iph + iph->ihl*4; + tcph = (struct tcphdr *)iph + iph->ihl * 4; if (ethh->h_proto == cpu_to_be16(ETH_P_IP)) { if (qcb->qos_list_cnt && !qos_free_list.cnt) { @@ -342,17 +342,17 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) if (sub_cmd_evt == QOS_REPORT) { spin_lock_irqsave(&qcb->qos_lock, flags); for (i = 0; i < qcb->qos_list_cnt; i++) { - sfid = ((buf[(i*5) + 6] << 24) & 0xff000000); - sfid += ((buf[(i*5) + 7] << 16) & 0xff0000); - sfid += ((buf[(i*5) + 8] << 8) & 0xff00); - sfid += (buf[(i*5) + 9]); + sfid = ((buf[(i * 5) + 6] << 24) & 0xff000000); + sfid += ((buf[(i * 5) + 7] << 16) & 0xff0000); + sfid += ((buf[(i * 5) + 8] << 8) & 0xff00); + sfid += (buf[(i * 5) + 9]); index = get_csr(qcb, sfid, 0); if (index == -1) { spin_unlock_irqrestore(&qcb->qos_lock, flags); netdev_err(nic->netdev, "QoS ERROR: No SF\n"); return; } - qcb->csr[index].qos_buf_count = buf[(i*5) + 10]; + qcb->csr[index].qos_buf_count = buf[(i * 5) + 10]; } extract_qos_list(nic, &send_list); diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index 1f5a087..9449418 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -33,10 +33,10 @@ #define SDU_TX_BUF_SIZE 2048 #define TX_BUF_SIZE 2048 #define TX_CHUNK_SIZE (2048 - TYPE_A_HEADER_SIZE) -#define RX_BUF_SIZE (25*1024) +#define RX_BUF_SIZE (25 * 1024) #define TX_HZ 2000 -#define TX_INTERVAL (NSEC_PER_SEC/TX_HZ) +#define TX_INTERVAL (NSEC_PER_SEC / TX_HZ) static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx) { diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index 7f035b1..f81129d 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -29,7 +29,7 @@ MODULE_DEVICE_TABLE(usb, id_table); #define TX_BUF_SIZE 2048 #if defined(CONFIG_WIMAX_GDM72XX_WIMAX2) -#define RX_BUF_SIZE (128*1024) /* For packet aggregation */ +#define RX_BUF_SIZE (128 * 1024) /* For packet aggregation */ #else #define RX_BUF_SIZE 2048 #endif diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 1b3da2b..2ee6a39 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -26,11 +26,11 @@ #include "netlink_k.h" #define gdm_wimax_send(n, d, l) \ - (n->phy_dev->send_func)(n->phy_dev->priv_dev, d, l, NULL, NULL) + n->phy_dev->send_func(n->phy_dev->priv_dev, d, l, NULL, NULL) #define gdm_wimax_send_with_cb(n, d, l, c, b) \ - (n->phy_dev->send_func)(n->phy_dev->priv_dev, d, l, c, b) + n->phy_dev->send_func(n->phy_dev->priv_dev, d, l, c, b) #define gdm_wimax_rcv_with_cb(n, c, b) \ - (n->phy_dev->rcv_func)(n->phy_dev->priv_dev, c, b) + n->phy_dev->rcv_func(n->phy_dev->priv_dev, c, b) #define EVT_MAX_SIZE 2048 @@ -98,21 +98,14 @@ static struct evt_entry *get_event_entry(void) return e; } -static void put_event_entry(struct evt_entry *e) -{ - BUG_ON(!e); - - list_add_tail(&e->list, &wm_event.freeq); -} - static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg, int len) { struct nic *nic = netdev_priv(dev); u8 *buf = msg; - u16 hci_cmd = (buf[0]<<8) | buf[1]; - u16 hci_len = (buf[2]<<8) | buf[3]; + u16 hci_cmd = (buf[0] << 8) | buf[1]; + u16 hci_len = (buf[2] << 8) | buf[3]; netdev_dbg(dev, "H=>D: 0x%04x(%d)\n", hci_cmd, hci_len); @@ -137,7 +130,7 @@ static void __gdm_wimax_event_send(struct work_struct *work) spin_lock_irqsave(&wm_event.evt_lock, flags); list_del(&e->list); - put_event_entry(e); + list_add_tail(&e->list, &wm_event.freeq); } spin_unlock_irqrestore(&wm_event.evt_lock, flags); @@ -193,8 +186,8 @@ static int gdm_wimax_event_send(struct net_device *dev, char *buf, int size) struct evt_entry *e; unsigned long flags; - u16 hci_cmd = ((u8)buf[0]<<8) | (u8)buf[1]; - u16 hci_len = ((u8)buf[2]<<8) | (u8)buf[3]; + u16 hci_cmd = ((u8)buf[0] << 8) | (u8)buf[1]; + u16 hci_len = ((u8)buf[2] << 8) | (u8)buf[3]; netdev_dbg(dev, "D=>H: 0x%04x(%d)\n", hci_cmd, hci_len); @@ -328,7 +321,8 @@ static void gdm_wimax_ind_if_updown(struct net_device *dev, int if_up) hci->length = cpu_to_be16(sizeof(up_down)); hci->data[0] = up_down; - gdm_wimax_event_send(dev, (char *)hci, HCI_HEADER_SIZE+sizeof(up_down)); + gdm_wimax_event_send(dev, (char *)hci, HCI_HEADER_SIZE + + sizeof(up_down)); } static int gdm_wimax_open(struct net_device *dev) @@ -512,7 +506,7 @@ static void gdm_wimax_prepare_device(struct net_device *dev) hci->cmd_evt = cpu_to_be16(WIMAX_GET_INFO); hci->data[len++] = TLV_T(T_MAC_ADDRESS); hci->length = cpu_to_be16(len); - gdm_wimax_send(nic, hci, HCI_HEADER_SIZE+len); + gdm_wimax_send(nic, hci, HCI_HEADER_SIZE + len); val = T_CAPABILITY_WIMAX | T_CAPABILITY_MULTI_CS; #if defined(CONFIG_WIMAX_GDM72XX_QOS) @@ -531,7 +525,7 @@ static void gdm_wimax_prepare_device(struct net_device *dev) memcpy(&hci->data[len], &val_be32, TLV_L(T_CAPABILITY)); len += TLV_L(T_CAPABILITY); hci->length = cpu_to_be16(len); - gdm_wimax_send(nic, hci, HCI_HEADER_SIZE+len); + gdm_wimax_send(nic, hci, HCI_HEADER_SIZE + len); netdev_info(dev, "GDM WiMax Set CAPABILITY: 0x%08X\n", val); } @@ -544,10 +538,10 @@ static int gdm_wimax_hci_get_tlv(u8 *buf, u8 *T, u16 *L, u8 **V) *T = buf[0]; if (buf[1] == 0x82) { *L = be16_to_cpu(__U82U16(&buf[2])); - next_pos = 1/*type*/+3/*len*/; + next_pos = 1/*type*/ + 3/*len*/; } else { *L = buf[1]; - next_pos = 1/*type*/+1/*len*/; + next_pos = 1/*type*/ + 1/*len*/; } *V = &buf[next_pos]; diff --git a/drivers/staging/gdm72xx/hci.h b/drivers/staging/gdm72xx/hci.h index ab903d4..b40d5c3 100644 --- a/drivers/staging/gdm72xx/hci.h +++ b/drivers/staging/gdm72xx/hci.h @@ -17,7 +17,7 @@ #define HCI_HEADER_SIZE 4 #define HCI_VALUE_OFFS (HCI_HEADER_SIZE) #define HCI_MAX_PACKET 2048 -#define HCI_MAX_PARAM (HCI_MAX_PACKET-HCI_HEADER_SIZE) +#define HCI_MAX_PARAM (HCI_MAX_PACKET - HCI_HEADER_SIZE) #define HCI_MAX_TLV 32 /* CMD-EVT */ diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c index cf0b47c..783770b 100644 --- a/drivers/staging/gdm72xx/netlink_k.c +++ b/drivers/staging/gdm72xx/netlink_k.c @@ -29,8 +29,8 @@ #define ND_NLMSG_SPACE(len) (nlmsg_total_size(len) + ND_IFINDEX_LEN) #define ND_NLMSG_DATA(nlh) \ ((void *)((char *)nlmsg_data(nlh) + ND_IFINDEX_LEN)) -#define ND_NLMSG_S_LEN(len) (len+ND_IFINDEX_LEN) -#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len-ND_IFINDEX_LEN) +#define ND_NLMSG_S_LEN(len) (len + ND_IFINDEX_LEN) +#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len - ND_IFINDEX_LEN) #define ND_NLMSG_IFIDX(nlh) nlmsg_data(nlh) #define ND_MAX_MSG_LEN 8096 @@ -143,7 +143,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) NETLINK_CB(skb).portid = 0; NETLINK_CB(skb).dst_group = 0; - ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC); + ret = netlink_broadcast(sock, skb, 0, group + 1, GFP_ATOMIC); if (!ret) return len; diff --git a/drivers/staging/gdm72xx/sdio_boot.c b/drivers/staging/gdm72xx/sdio_boot.c index ba94b5f..5e9b38f 100644 --- a/drivers/staging/gdm72xx/sdio_boot.c +++ b/drivers/staging/gdm72xx/sdio_boot.c @@ -96,7 +96,7 @@ static int download_image(struct sdio_func *func, const char *img_name) buf[1] = (len >> 8) & 0xff; buf[2] = (len >> 16) & 0xff; - memcpy(buf+TYPE_A_HEADER_SIZE, firm->data + pos, len); + memcpy(buf + TYPE_A_HEADER_SIZE, firm->data + pos, len); ret = sdio_memcpy_toio(func, 0, buf, len + TYPE_A_HEADER_SIZE); if (ret < 0) { dev_err(&func->dev, diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 3082987..99a5c07 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -292,8 +292,8 @@ static int em_download_image(struct usb_device *usbdev, const char *img_name, return -ENOMEM; } - strcpy(buf+pad_size, type_string); - ret = gdm_wibro_send(usbdev, buf, strlen(type_string)+pad_size); + strcpy(buf + pad_size, type_string); + ret = gdm_wibro_send(usbdev, buf, strlen(type_string) + pad_size); if (ret < 0) goto out; @@ -310,8 +310,8 @@ static int em_download_image(struct usb_device *usbdev, const char *img_name, else len = img_len; /* the last chunk of data */ - memcpy(buf+pad_size, firm->data + pos, len); - ret = gdm_wibro_send(usbdev, buf, len+pad_size); + memcpy(buf + pad_size, firm->data + pos, len); + ret = gdm_wibro_send(usbdev, buf, len + pad_size); if (ret < 0) goto out; @@ -319,7 +319,7 @@ static int em_download_image(struct usb_device *usbdev, const char *img_name, img_len -= DOWNLOAD_CHUCK; pos += DOWNLOAD_CHUCK; - ret = em_wait_ack(usbdev, ((len+pad_size) % 512 == 0)); + ret = em_wait_ack(usbdev, ((len + pad_size) % 512 == 0)); if (ret < 0) goto out; } diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 891dfaa..364fdcd 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -63,7 +63,7 @@ struct goldfish_audio { #define AUDIO_READ(data, addr) (readl(data->reg_base + addr)) #define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr)) #define AUDIO_WRITE64(data, addr, addr2, x) \ - (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base+addr2)) + (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base + addr2)) /* * temporary variable used between goldfish_audio_probe() and diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index 5c4f61c..76d60ee 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -27,6 +27,7 @@ #include <linux/mutex.h> #include <linux/goldfish.h> #include <asm/div64.h> +#include <linux/dma-mapping.h> #include "goldfish_nand_reg.h" @@ -99,11 +100,11 @@ static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr) { loff_t ofs = instr->addr; u32 len = instr->len; - u32 rem; + s32 rem; if (ofs + len > mtd->size) goto invalid_arg; - rem = do_div(ofs, mtd->writesize); + ofs = div_s64_rem(ofs, mtd->writesize, &rem); if (rem) goto invalid_arg; ofs *= (mtd->writesize + mtd->oobsize); @@ -132,7 +133,7 @@ invalid_arg: static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs, struct mtd_oob_ops *ops) { - u32 rem; + s32 rem; if (ofs + ops->len > mtd->size) goto invalid_arg; @@ -141,7 +142,7 @@ static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs, if (ops->ooblen + ops->ooboffs > mtd->oobsize) goto invalid_arg; - rem = do_div(ofs, mtd->writesize); + ofs = div_s64_rem(ofs, mtd->writesize, &rem); if (rem) goto invalid_arg; ofs *= (mtd->writesize + mtd->oobsize); @@ -164,7 +165,7 @@ invalid_arg: static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs, struct mtd_oob_ops *ops) { - u32 rem; + s32 rem; if (ofs + ops->len > mtd->size) goto invalid_arg; @@ -173,7 +174,7 @@ static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs, if (ops->ooblen + ops->ooboffs > mtd->oobsize) goto invalid_arg; - rem = do_div(ofs, mtd->writesize); + ofs = div_s64_rem(ofs, mtd->writesize, &rem); if (rem) goto invalid_arg; ofs *= (mtd->writesize + mtd->oobsize); @@ -196,12 +197,12 @@ invalid_arg: static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { - u32 rem; + s32 rem; if (from + len > mtd->size) goto invalid_arg; - rem = do_div(from, mtd->writesize); + from = div_s64_rem(from, mtd->writesize, &rem); if (rem) goto invalid_arg; from *= (mtd->writesize + mtd->oobsize); @@ -218,12 +219,12 @@ invalid_arg: static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { - u32 rem; + s32 rem; if (to + len > mtd->size) goto invalid_arg; - rem = do_div(to, mtd->writesize); + to = div_s64_rem(to, mtd->writesize, &rem); if (rem) goto invalid_arg; to *= (mtd->writesize + mtd->oobsize); @@ -239,12 +240,12 @@ invalid_arg: static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) { - u32 rem; + s32 rem; if (ofs >= mtd->size) goto invalid_arg; - rem = do_div(ofs, mtd->erasesize); + ofs = div_s64_rem(ofs, mtd->writesize, &rem); if (rem) goto invalid_arg; ofs *= mtd->erasesize / mtd->writesize; @@ -260,12 +261,12 @@ invalid_arg: static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) { - u32 rem; + s32 rem; if (ofs >= mtd->size) goto invalid_arg; - rem = do_div(ofs, mtd->erasesize); + ofs = div_s64_rem(ofs, mtd->writesize, &rem); if (rem) goto invalid_arg; ofs *= mtd->erasesize / mtd->writesize; @@ -284,17 +285,18 @@ invalid_arg: static int nand_setup_cmd_params(struct platform_device *pdev, struct goldfish_nand *nand) { - u64 paddr; + dma_addr_t dma_handle; unsigned char __iomem *base = nand->base; - nand->cmd_params = devm_kzalloc(&pdev->dev, - sizeof(struct cmd_params), GFP_KERNEL); - if (!nand->cmd_params) + nand->cmd_params = dmam_alloc_coherent(&pdev->dev, + sizeof(struct cmd_params), + &dma_handle, GFP_KERNEL); + if (!nand->cmd_params) { + dev_err(&pdev->dev, "allocate buffer failed\n"); return -ENOMEM; - - paddr = __pa(nand->cmd_params); - writel((u32)(paddr >> 32), base + NAND_CMD_PARAMS_ADDR_HIGH); - writel((u32)paddr, base + NAND_CMD_PARAMS_ADDR_LOW); + } + writel((u32)((u64)dma_handle >> 32), base + NAND_CMD_PARAMS_ADDR_HIGH); + writel((u32)dma_handle, base + NAND_CMD_PARAMS_ADDR_LOW); return 0; } @@ -319,7 +321,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev, mtd->oobavail = mtd->oobsize; mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) / (mtd->writesize + mtd->oobsize) * mtd->writesize; - do_div(mtd->size, mtd->writesize + mtd->oobsize); + mtd->size = div_s64(mtd->size, mtd->writesize + mtd->oobsize); mtd->size *= mtd->writesize; dev_dbg(&pdev->dev, "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n", diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 02e930c..a8f533a 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -216,8 +216,7 @@ static int sca3000_read_ctrl_reg(struct sca3000_state *st, ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_CTRL_DATA, 1); if (ret) goto error_ret; - else - return st->rx[0]; + return st->rx[0]; error_ret: return ret; } diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 1920dc60..d1cb9b9 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -99,8 +99,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r, ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_BUF_COUNT, 1); if (ret) goto error_ret; - else - num_available = st->rx[0]; + num_available = st->rx[0]; /* * num_available is the total number of samples available * i.e. number of time points * number of channels. diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 2226051..ac3735c 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -296,14 +296,14 @@ static inline ssize_t ad7816_set_oti(struct device *dev, dev_err(dev, "Invalid oti channel id %d.\n", chip->channel_id); return -EINVAL; } else if (chip->channel_id == 0) { - if (ret || value < AD7816_BOUND_VALUE_MIN || + if (value < AD7816_BOUND_VALUE_MIN || value > AD7816_BOUND_VALUE_MAX) return -EINVAL; data = (u8)(value - AD7816_BOUND_VALUE_MIN + AD7816_BOUND_VALUE_BASE); } else { - if (ret || value < AD7816_BOUND_VALUE_BASE || value > 255) + if (value < AD7816_BOUND_VALUE_BASE || value > 255) return -EINVAL; data = (u8)value; diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 26a5412..76d9f74 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -183,7 +183,7 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode) /* Set mode */ status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, - mode << COMMMAND1_OPMODE_SHIFT); + mode << COMMMAND1_OPMODE_SHIFT); if (status) { dev_err(dev, "Error in setting operating mode err %d\n", status); @@ -241,7 +241,7 @@ static int isl29018_read_ir(struct isl29018_chip *chip, int *ir) } static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, - int *near_ir) + int *near_ir) { int status; int prox_data = -1; @@ -250,15 +250,15 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, /* Do proximity sensing with required scheme */ status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII, - COMMANDII_SCHEME_MASK, - scheme << COMMANDII_SCHEME_SHIFT); + COMMANDII_SCHEME_MASK, + scheme << COMMANDII_SCHEME_SHIFT); if (status) { dev_err(dev, "Error in setting operating mode\n"); return status; } prox_data = isl29018_read_sensor_input(chip, - COMMMAND1_OPMODE_PROX_ONCE); + COMMMAND1_OPMODE_PROX_ONCE); if (prox_data < 0) return prox_data; @@ -281,7 +281,7 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme, } static ssize_t show_scale_available(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct isl29018_chip *chip = iio_priv(indio_dev); @@ -298,7 +298,7 @@ static ssize_t show_scale_available(struct device *dev, } static ssize_t show_int_time_available(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct isl29018_chip *chip = iio_priv(indio_dev); @@ -315,18 +315,22 @@ static ssize_t show_int_time_available(struct device *dev, /* proximity scheme */ static ssize_t show_prox_infrared_suppression(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct isl29018_chip *chip = iio_priv(indio_dev); - /* return the "proximity scheme" i.e. if the chip does on chip - infrared suppression (1 means perform on chip suppression) */ + /* + * return the "proximity scheme" i.e. if the chip does on chip + * infrared suppression (1 means perform on chip suppression) + */ return sprintf(buf, "%d\n", chip->prox_scheme); } static ssize_t store_prox_infrared_suppression(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct isl29018_chip *chip = iio_priv(indio_dev); @@ -339,8 +343,10 @@ static ssize_t store_prox_infrared_suppression(struct device *dev, return -EINVAL; } - /* get the "proximity scheme" i.e. if the chip does on chip - infrared suppression (1 means perform on chip suppression) */ + /* + * get the "proximity scheme" i.e. if the chip does on chip + * infrared suppression (1 means perform on chip suppression) + */ mutex_lock(&chip->lock); chip->prox_scheme = val; mutex_unlock(&chip->lock); @@ -414,7 +420,8 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, break; case IIO_PROXIMITY: ret = isl29018_read_proximity_ir(chip, - chip->prox_scheme, val); + chip->prox_scheme, + val); break; default: break; @@ -702,13 +709,13 @@ static const char *isl29018_match_acpi_device(struct device *dev, int *data) if (!id) return NULL; - *data = (int) id->driver_data; + *data = (int)id->driver_data; return dev_name(dev); } static int isl29018_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct isl29018_chip *chip; struct iio_dev *indio_dev; diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c index e1bca9c..6e2ba45 100644 --- a/drivers/staging/iio/light/isl29028.c +++ b/drivers/staging/iio/light/isl29028.c @@ -81,7 +81,7 @@ struct isl29028_chip { }; static int isl29028_set_proxim_sampling(struct isl29028_chip *chip, - unsigned int sampling) + unsigned int sampling) { static unsigned int prox_period[] = {800, 400, 200, 100, 75, 50, 12, 0}; int sel; @@ -103,7 +103,7 @@ static int isl29028_enable_proximity(struct isl29028_chip *chip, bool enable) if (enable) val = CONFIGURE_PROX_EN; ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, - CONFIGURE_PROX_EN_MASK, val); + CONFIGURE_PROX_EN_MASK, val); if (ret < 0) return ret; @@ -122,24 +122,27 @@ static int isl29028_set_als_scale(struct isl29028_chip *chip, int lux_scale) } static int isl29028_set_als_ir_mode(struct isl29028_chip *chip, - enum als_ir_mode mode) + enum als_ir_mode mode) { int ret = 0; switch (mode) { case MODE_ALS: ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, - CONFIGURE_ALS_IR_MODE_MASK, CONFIGURE_ALS_IR_MODE_ALS); + CONFIGURE_ALS_IR_MODE_MASK, + CONFIGURE_ALS_IR_MODE_ALS); if (ret < 0) return ret; ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, - CONFIGURE_ALS_RANGE_MASK, CONFIGURE_ALS_RANGE_HIGH_LUX); + CONFIGURE_ALS_RANGE_MASK, + CONFIGURE_ALS_RANGE_HIGH_LUX); break; case MODE_IR: ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, - CONFIGURE_ALS_IR_MODE_MASK, CONFIGURE_ALS_IR_MODE_IR); + CONFIGURE_ALS_IR_MODE_MASK, + CONFIGURE_ALS_IR_MODE_IR); break; case MODE_NONE: @@ -152,7 +155,7 @@ static int isl29028_set_als_ir_mode(struct isl29028_chip *chip, /* Enable the ALS/IR */ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, - CONFIGURE_ALS_EN_MASK, CONFIGURE_ALS_EN); + CONFIGURE_ALS_EN_MASK, CONFIGURE_ALS_EN); if (ret < 0) return ret; @@ -193,7 +196,7 @@ static int isl29028_read_proxim(struct isl29028_chip *chip, int *prox) ret = regmap_read(chip->regmap, ISL29028_REG_PROX_DATA, &data); if (ret < 0) { dev_err(chip->dev, "Error in reading register %d, error %d\n", - ISL29028_REG_PROX_DATA, ret); + ISL29028_REG_PROX_DATA, ret); return ret; } *prox = data; @@ -264,7 +267,8 @@ static int isl29028_ir_get(struct isl29028_chip *chip, int *ir_data) /* Channel IO */ static int isl29028_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, int val, int val2, long mask) + struct iio_chan_spec const *chan, + int val, int val2, long mask) { struct isl29028_chip *chip = iio_priv(indio_dev); int ret = -EINVAL; @@ -323,7 +327,8 @@ static int isl29028_write_raw(struct iio_dev *indio_dev, } static int isl29028_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, int *val, int *val2, long mask) + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) { struct isl29028_chip *chip = iio_priv(indio_dev); int ret = -EINVAL; @@ -476,7 +481,7 @@ static const struct regmap_config isl29028_regmap_config = { }; static int isl29028_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct isl29028_chip *chip; struct iio_dev *indio_dev; diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 3100d96..05b4ad4 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -240,8 +240,10 @@ static int taos_get_lux(struct iio_dev *indio_dev) } } - /* clear status, really interrupt status (interrupts are off), but - * we use the bit anyway - don't forget 0x80 - this is a command*/ + /* + * clear status, really interrupt status (interrupts are off), but + * we use the bit anyway - don't forget 0x80 - this is a command + */ ret = i2c_smbus_write_byte(chip->client, (TSL258X_CMD_REG | TSL258X_CMD_SPL_FN | TSL258X_CMD_ALS_INT_CLR)); @@ -265,13 +267,14 @@ static int taos_get_lux(struct iio_dev *indio_dev) if (!ch0) { /* have no data, so return LAST VALUE */ - ret = chip->als_cur_info.lux = 0; + ret = 0; + chip->als_cur_info.lux = 0; goto out_unlock; } /* calculate ratio */ ratio = (ch1 << 15) / ch0; /* convert to unscaled lux using the pointer to the table */ - for (p = (struct taos_lux *) taos_device_lux; + for (p = (struct taos_lux *)taos_device_lux; p->ratio != 0 && p->ratio < ratio; p++) ; @@ -290,7 +293,8 @@ static int taos_get_lux(struct iio_dev *indio_dev) /* note: lux is 31 bit max at this point */ if (ch1lux > ch0lux) { dev_dbg(&chip->client->dev, "No Data - Return last value\n"); - ret = chip->als_cur_info.lux = 0; + ret = 0; + chip->als_cur_info.lux = 0; goto out_unlock; } @@ -378,7 +382,7 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) dev_err(&chip->client->dev, "taos_als_calibrate failed to get lux\n"); return lux_val; } - gain_trim_val = (unsigned int) (((chip->taos_settings.als_cal_target) + gain_trim_val = (unsigned int)(((chip->taos_settings.als_cal_target) * chip->taos_settings.als_gain_trim) / lux_val); if ((gain_trim_val < 250) || (gain_trim_val > 4000)) { @@ -387,9 +391,9 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) gain_trim_val); return -ENODATA; } - chip->taos_settings.als_gain_trim = (int) gain_trim_val; + chip->taos_settings.als_gain_trim = (int)gain_trim_val; - return (int) gain_trim_val; + return (int)gain_trim_val; } /* @@ -429,8 +433,10 @@ static int taos_chip_on(struct iio_dev *indio_dev) chip->als_saturation = als_count * 922; /* 90% of full scale */ chip->als_time_scale = (als_time + 25) / 50; - /* TSL258x Specific power-on / adc enable sequence - * Power on the device 1st. */ + /* + * TSL258x Specific power-on / adc enable sequence + * Power on the device 1st. + */ utmp = TSL258X_CNTL_PWR_ON; ret = i2c_smbus_write_byte_data(chip->client, TSL258X_CMD_REG | TSL258X_CNTRL, utmp); @@ -439,8 +445,10 @@ static int taos_chip_on(struct iio_dev *indio_dev) return ret; } - /* Use the following shadow copy for our delay before enabling ADC. - * Write all the registers. */ + /* + * Use the following shadow copy for our delay before enabling ADC. + * Write all the registers. + */ for (i = 0, uP = chip->taos_config; i < TSL258X_REG_MAX; i++) { ret = i2c_smbus_write_byte_data(chip->client, TSL258X_CMD_REG + i, @@ -453,8 +461,10 @@ static int taos_chip_on(struct iio_dev *indio_dev) } usleep_range(3000, 3500); - /* NOW enable the ADC - * initialize the desired mode of operation */ + /* + * NOW enable the ADC + * initialize the desired mode of operation + */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; ret = i2c_smbus_write_byte_data(chip->client, TSL258X_CMD_REG | TSL258X_CNTRL, @@ -482,7 +492,7 @@ static int taos_chip_off(struct iio_dev *indio_dev) /* Sysfs Interface Functions */ static ssize_t taos_power_state_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -491,7 +501,8 @@ static ssize_t taos_power_state_show(struct device *dev, } static ssize_t taos_power_state_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); int value; @@ -508,7 +519,7 @@ static ssize_t taos_power_state_store(struct device *dev, } static ssize_t taos_gain_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -533,7 +544,8 @@ static ssize_t taos_gain_show(struct device *dev, } static ssize_t taos_gain_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -564,13 +576,14 @@ static ssize_t taos_gain_store(struct device *dev, } static ssize_t taos_gain_available_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return sprintf(buf, "%s\n", "1 8 16 111"); } static ssize_t taos_als_time_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -579,7 +592,8 @@ static ssize_t taos_als_time_show(struct device *dev, } static ssize_t taos_als_time_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -600,14 +614,15 @@ static ssize_t taos_als_time_store(struct device *dev, } static ssize_t taos_als_time_available_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return sprintf(buf, "%s\n", "50 100 150 200 250 300 350 400 450 500 550 600 650"); } static ssize_t taos_als_trim_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -616,7 +631,8 @@ static ssize_t taos_als_trim_show(struct device *dev, } static ssize_t taos_als_trim_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -632,7 +648,8 @@ static ssize_t taos_als_trim_store(struct device *dev, } static ssize_t taos_als_cal_target_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -641,7 +658,8 @@ static ssize_t taos_als_cal_target_show(struct device *dev, } static ssize_t taos_als_cal_target_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -657,7 +675,7 @@ static ssize_t taos_als_cal_target_store(struct device *dev, } static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { int ret; @@ -669,7 +687,8 @@ static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr, } static ssize_t taos_do_calibrate(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); int value; @@ -684,7 +703,7 @@ static ssize_t taos_do_calibrate(struct device *dev, } static ssize_t taos_luxtable_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { int i; int offset = 0; @@ -695,8 +714,10 @@ static ssize_t taos_luxtable_show(struct device *dev, taos_device_lux[i].ch0, taos_device_lux[i].ch1); if (taos_device_lux[i].ratio == 0) { - /* We just printed the first "0" entry. - * Now get rid of the extra "," and break. */ + /* + * We just printed the first "0" entry. + * Now get rid of the extra "," and break. + */ offset--; break; } @@ -707,11 +728,12 @@ static ssize_t taos_luxtable_show(struct device *dev, } static ssize_t taos_luxtable_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); - int value[ARRAY_SIZE(taos_device_lux)*3 + 1]; + int value[ARRAY_SIZE(taos_device_lux) * 3 + 1]; int n; get_options(buf, ARRAY_SIZE(value), value); @@ -809,7 +831,7 @@ static int taos_probe(struct i2c_client *clientp, struct iio_dev *indio_dev; if (!i2c_check_functionality(clientp->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { + I2C_FUNC_SMBUS_BYTE_DATA)) { dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n"); return -EOPNOTSUPP; } @@ -846,7 +868,7 @@ static int taos_probe(struct i2c_client *clientp, if (!taos_tsl258x_device(buf)) { dev_info(&clientp->dev, - "i2c device found but does not match expected id in taos_probe()\n"); + "i2c device found but does not match expected id in taos_probe()\n"); return -EINVAL; } diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 595e711..82b2d88 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -31,7 +31,7 @@ /* input clock on serial interface */ #define AD2S1200_HZ 8192000 /* clock period in nano second */ -#define AD2S1200_TSCLK (1000000000/AD2S1200_HZ) +#define AD2S1200_TSCLK (1000000000 / AD2S1200_HZ) struct ad2s1200_state { struct mutex lock; @@ -42,10 +42,10 @@ struct ad2s1200_state { }; static int ad2s1200_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) { int ret = 0; s16 vel; @@ -113,7 +113,7 @@ static int ad2s1200_probe(struct spi_device *spi) DRV_NAME); if (ret) { dev_err(&spi->dev, "request gpio pin %d failed\n", - pins[pn]); + pins[pn]); return ret; } } diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index d97aa28..6b99263 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -67,7 +67,7 @@ /* default input clock on serial interface */ #define AD2S1210_DEF_CLKIN 8192000 /* clock period in nano second */ -#define AD2S1210_DEF_TCK (1000000000/AD2S1210_DEF_CLKIN) +#define AD2S1210_DEF_TCK (1000000000 / AD2S1210_DEF_CLKIN) #define AD2S1210_DEF_EXCIT 10000 enum ad2s1210_mode { @@ -98,6 +98,7 @@ static const int ad2s1210_mode_vals[4][2] = { [MOD_VEL] = { 0, 1 }, [MOD_CONFIG] = { 1, 0 }, }; + static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, struct ad2s1210_state *st) { @@ -123,7 +124,7 @@ static int ad2s1210_config_write(struct ad2s1210_state *st, u8 data) /* read value from one of the registers */ static int ad2s1210_config_read(struct ad2s1210_state *st, - unsigned char address) + unsigned char address) { struct spi_transfer xfer = { .len = 2, @@ -176,9 +177,9 @@ static const int ad2s1210_res_pins[4][2] = { static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st) { gpio_set_value(st->pdata->res[0], - ad2s1210_res_pins[(st->resolution - 10)/2][0]); + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); gpio_set_value(st->pdata->res[1], - ad2s1210_res_pins[(st->resolution - 10)/2][1]); + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -282,8 +283,8 @@ static ssize_t ad2s1210_show_control(struct device *dev, } static ssize_t ad2s1210_store_control(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char udata; @@ -318,9 +319,9 @@ static ssize_t ad2s1210_store_control(struct device *dev, data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else + } else { ad2s1210_set_resolution_pin(st); - + } ret = len; st->hysteresis = !!(data & AD2S1210_ENABLE_HYSTERESIS); @@ -330,7 +331,8 @@ error_ret: } static ssize_t ad2s1210_show_resolution(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); @@ -338,8 +340,8 @@ static ssize_t ad2s1210_show_resolution(struct device *dev, } static ssize_t ad2s1210_store_resolution(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char data; @@ -379,8 +381,9 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else + } else { ad2s1210_set_resolution_pin(st); + } ret = len; error_ret: mutex_unlock(&st->lock); @@ -389,7 +392,7 @@ error_ret: /* read the fault register since last sample */ static ssize_t ad2s1210_show_fault(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); int ret; @@ -441,7 +444,8 @@ static ssize_t ad2s1210_show_reg(struct device *dev, } static ssize_t ad2s1210_store_reg(struct device *dev, - struct device_attribute *attr, const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); unsigned char data; @@ -497,7 +501,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_ANGL: - pos = be16_to_cpup((__be16 *) st->rx); + pos = be16_to_cpup((__be16 *)st->rx); if (st->hysteresis) pos >>= 16 - st->resolution; *val = pos; @@ -505,7 +509,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, break; case IIO_ANGL_VEL: negative = st->rx[0] & 0x80; - vel = be16_to_cpup((__be16 *) st->rx); + vel = be16_to_cpup((__be16 *)st->rx); vel >>= 16 - st->resolution; if (vel & 0x8000) { negative = (0xffff >> st->resolution) << st->resolution; @@ -560,7 +564,6 @@ static IIO_DEVICE_ATTR(lot_low_thrd, S_IRUGO | S_IWUSR, ad2s1210_show_reg, ad2s1210_store_reg, AD2S1210_REG_LOT_LOW_THRD); - static const struct iio_chan_spec ad2s1210_channels[] = { { .type = IIO_ANGL, @@ -672,7 +675,7 @@ static int ad2s1210_probe(struct spi_device *spi) struct ad2s1210_state *st; int ret; - if (spi->dev.platform_data == NULL) + if (!spi->dev.platform_data) return -EINVAL; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index dc9b88f..5c598c8 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -51,8 +51,6 @@ #define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \ ((hexnum) >> 8 & 0xf)) -#define LUSTRE_SRV_LNET_PID LUSTRE_LNET_PID - #include <linux/list.h> /* need both kernel and user-land acceptor */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index 1530b04..9e62c59 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index e4463ad..f788631 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -41,11 +41,16 @@ #ifndef __LIBCFS_IOCTL_H__ #define __LIBCFS_IOCTL_H__ -#define LIBCFS_IOCTL_VERSION 0x0001000a +#define LIBCFS_IOCTL_VERSION 0x0001000a +#define LIBCFS_IOCTL_VERSION2 0x0001000b -struct libcfs_ioctl_data { +struct libcfs_ioctl_hdr { __u32 ioc_len; __u32 ioc_version; +}; + +struct libcfs_ioctl_data { + struct libcfs_ioctl_hdr ioc_hdr; __u64 ioc_nid; __u64 ioc_u64[1]; @@ -70,11 +75,6 @@ struct libcfs_ioctl_data { #define ioc_priority ioc_u32[0] -struct libcfs_ioctl_hdr { - __u32 ioc_len; - __u32 ioc_version; -}; - struct libcfs_debug_ioctl_data { struct libcfs_ioctl_hdr hdr; unsigned int subs; @@ -90,7 +90,7 @@ do { \ struct libcfs_ioctl_handler { struct list_head item; - int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_data *data); + int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr); }; #define DECLARE_IOCTL_HANDLER(ident, func) \ @@ -112,9 +112,6 @@ struct libcfs_ioctl_handler { /* lnet ioctls */ #define IOC_LIBCFS_GET_NI _IOWR('e', 50, long) #define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long) -#define IOC_LIBCFS_ADD_ROUTE _IOWR('e', 52, long) -#define IOC_LIBCFS_DEL_ROUTE _IOWR('e', 53, long) -#define IOC_LIBCFS_GET_ROUTE _IOWR('e', 54, long) #define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, long) #define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, long) /* #define IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, long) */ @@ -137,7 +134,25 @@ struct libcfs_ioctl_handler { #define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, long) #define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, long) -#define IOC_LIBCFS_MAX_NR 80 +/* + * DLC Specific IOCTL numbers. + * In order to maintain backward compatibility with any possible external + * tools which might be accessing the IOCTL numbers, a new group of IOCTL + * number have been allocated. + */ +#define IOCTL_CONFIG_SIZE struct lnet_ioctl_config_data +#define IOC_LIBCFS_ADD_ROUTE _IOWR(IOC_LIBCFS_TYPE, 81, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_DEL_ROUTE _IOWR(IOC_LIBCFS_TYPE, 82, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_GET_ROUTE _IOWR(IOC_LIBCFS_TYPE, 83, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_ADD_NET _IOWR(IOC_LIBCFS_TYPE, 84, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_DEL_NET _IOWR(IOC_LIBCFS_TYPE, 85, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_GET_NET _IOWR(IOC_LIBCFS_TYPE, 86, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_CONFIG_RTR _IOWR(IOC_LIBCFS_TYPE, 87, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_ADD_BUF _IOWR(IOC_LIBCFS_TYPE, 88, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_GET_BUF _IOWR(IOC_LIBCFS_TYPE, 89, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_GET_PEER_INFO _IOWR(IOC_LIBCFS_TYPE, 90, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, IOCTL_CONFIG_SIZE) +#define IOC_LIBCFS_MAX_NR 91 static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data) { @@ -148,9 +163,9 @@ static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data) return len; } -static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) +static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) { - if (data->ioc_len > (1<<30)) { + if (data->ioc_hdr.ioc_len > (1 << 30)) { CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n"); return 1; } @@ -186,7 +201,7 @@ static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n"); return 1; } - if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_len) { + if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) { CERROR("LIBCFS ioctl: packlen != ioc_len\n"); return 1; } @@ -206,7 +221,9 @@ static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand); int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand); -int libcfs_ioctl_getdata(char *buf, char *end, void __user *arg); +int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg, + __u32 *buf_len); int libcfs_ioctl_popdata(void __user *arg, void *buf, int size); +int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data); #endif /* __LIBCFS_IOCTL_H__ */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index aac5900..d94b266 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -118,9 +118,6 @@ do { \ #define CDEBUG_STACK() (0L) #endif /* __x86_64__ */ -/* initial pid */ -#define LUSTRE_LNET_PID 12345 - #define __current_nesting_level() (0) /** diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h index 520209f..c04979a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/lnet/lib-dlc.h b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h new file mode 100644 index 0000000..84a19e9 --- /dev/null +++ b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h @@ -0,0 +1,122 @@ +/* + * LGPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * + * LGPL HEADER END + * + */ +/* + * Copyright (c) 2014, Intel Corporation. + */ +/* + * Author: Amir Shehata <amir.shehata@intel.com> + */ + +#ifndef LNET_DLC_H +#define LNET_DLC_H + +#include "../libcfs/libcfs_ioctl.h" +#include "types.h" + +#define MAX_NUM_SHOW_ENTRIES 32 +#define LNET_MAX_STR_LEN 128 +#define LNET_MAX_SHOW_NUM_CPT 128 +#define LNET_UNDEFINED_HOPS ((__u32) -1) + +struct lnet_ioctl_net_config { + char ni_interfaces[LNET_MAX_INTERFACES][LNET_MAX_STR_LEN]; + __u32 ni_status; + __u32 ni_cpts[LNET_MAX_SHOW_NUM_CPT]; +}; + +#define LNET_TINY_BUF_IDX 0 +#define LNET_SMALL_BUF_IDX 1 +#define LNET_LARGE_BUF_IDX 2 + +/* # different router buffer pools */ +#define LNET_NRBPOOLS (LNET_LARGE_BUF_IDX + 1) + +struct lnet_ioctl_pool_cfg { + struct { + __u32 pl_npages; + __u32 pl_nbuffers; + __u32 pl_credits; + __u32 pl_mincredits; + } pl_pools[LNET_NRBPOOLS]; + __u32 pl_routing; +}; + +struct lnet_ioctl_config_data { + struct libcfs_ioctl_hdr cfg_hdr; + + __u32 cfg_net; + __u32 cfg_count; + __u64 cfg_nid; + __u32 cfg_ncpts; + + union { + struct { + __u32 rtr_hop; + __u32 rtr_priority; + __u32 rtr_flags; + } cfg_route; + struct { + char net_intf[LNET_MAX_STR_LEN]; + __s32 net_peer_timeout; + __s32 net_peer_tx_credits; + __s32 net_peer_rtr_credits; + __s32 net_max_tx_credits; + __u32 net_cksum_algo; + __u32 net_pad; + } cfg_net; + struct { + __u32 buf_enable; + __s32 buf_tiny; + __s32 buf_small; + __s32 buf_large; + } cfg_buffers; + } cfg_config_u; + + char cfg_bulk[0]; +}; + +struct lnet_ioctl_peer { + struct libcfs_ioctl_hdr pr_hdr; + __u32 pr_count; + __u32 pr_pad; + __u64 pr_nid; + + union { + struct { + char cr_aliveness[LNET_MAX_STR_LEN]; + __u32 cr_refcount; + __u32 cr_ni_peer_tx_credits; + __u32 cr_peer_tx_credits; + __u32 cr_peer_rtr_credits; + __u32 cr_peer_min_rtr_credits; + __u32 cr_peer_tx_qnob; + __u32 cr_ncpt; + } pr_peer_credits; + } pr_lnd_u; +}; + +struct lnet_ioctl_lnet_stats { + struct libcfs_ioctl_hdr st_hdr; + struct lnet_counters st_cntrs; +}; + +#endif /* LNET_DLC_H */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index b0f80b4..a5f1aec 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -39,6 +39,7 @@ #include "api.h" #include "lnet.h" #include "lib-types.h" +#include "lib-dlc.h" extern lnet_t the_lnet; /* THE network */ @@ -64,6 +65,19 @@ extern lnet_t the_lnet; /* THE network */ /** exclusive lock */ #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX +static inline int lnet_is_route_alive(lnet_route_t *route) +{ + /* gateway is down */ + if (!route->lr_gateway->lp_alive) + return 0; + /* no NI status, assume it's alive */ + if ((route->lr_gateway->lp_ping_feats & + LNET_PING_FEAT_NI_STATUS) == 0) + return 1; + /* has NI status, check # down NIs */ + return route->lr_downis == 0; +} + static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh) { return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE && @@ -408,6 +422,8 @@ lnet_ni_decref(lnet_ni_t *ni) } void lnet_ni_free(lnet_ni_t *ni); +lnet_ni_t * +lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist); static inline int lnet_nid2peerhash(lnet_nid_t nid) @@ -432,6 +448,8 @@ lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt); lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt); lnet_ni_t *lnet_net2ni(__u32 net); +extern int portal_rotor; + int lnet_init(void); void lnet_fini(void); @@ -445,11 +463,26 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid); void lnet_destroy_routes(void); int lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, __u32 *alive, __u32 *priority); +int lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid, + int *peer_timeout, int *peer_tx_credits, + int *peer_rtr_cr, int *max_tx_credits, + struct lnet_ioctl_net_config *net_config); +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg); + void lnet_router_debugfs_init(void); void lnet_router_debugfs_fini(void); int lnet_rtrpools_alloc(int im_a_router); -void lnet_rtrpools_free(void); +void lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages); +int lnet_rtrpools_adjust(int tiny, int small, int large); +int lnet_rtrpools_enable(void); +void lnet_rtrpools_disable(void); +void lnet_rtrpools_free(int keep_pools); lnet_remotenet_t *lnet_find_net_locked(__u32 net); +int lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets, + __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr, + __s32 credits); +int lnet_dyn_del_ni(__u32 net); +int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason); int lnet_islocalnid(lnet_nid_t nid); int lnet_islocalnet(__u32 net); @@ -468,6 +501,8 @@ void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, int lnet_send(lnet_nid_t nid, lnet_msg_t *msg, lnet_nid_t rtr_nid); void lnet_return_tx_credits_locked(lnet_msg_t *msg); void lnet_return_rx_credits_locked(lnet_msg_t *msg); +void lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp); +void lnet_drop_routed_msgs_locked(struct list_head *list, int cpt); /* portals functions */ /* portals attributes */ @@ -662,20 +697,24 @@ void lnet_router_checker_stop(void); void lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net); void lnet_swap_pinginfo(lnet_ping_info_t *info); -int lnet_ping_target_init(void); -void lnet_ping_target_fini(void); - int lnet_parse_ip2nets(char **networksp, char *ip2nets); int lnet_parse_routes(char *route_str, int *im_a_router); int lnet_parse_networks(struct list_head *nilist, char *networks); +int lnet_net_unique(__u32 net, struct list_head *nilist); int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt); lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid); -void lnet_peer_tables_cleanup(void); +void lnet_peer_tables_cleanup(lnet_ni_t *ni); void lnet_peer_tables_destroy(void); int lnet_peer_tables_create(void); void lnet_debug_peer(lnet_nid_t nid); +int lnet_get_peer_info(__u32 peer_index, __u64 *nid, + char alivness[LNET_MAX_STR_LEN], + __u32 *cpt_iter, __u32 *refcount, + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits, + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis, + __u32 *peer_tx_qnob); static inline void lnet_peer_set_alive(lnet_peer_t *lp) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index d769c35..07b8db1 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -38,7 +38,6 @@ #include <linux/kthread.h> #include <linux/uio.h> #include <linux/types.h> -#include <net/sock.h> #include "types.h" @@ -285,6 +284,7 @@ typedef struct lnet_ni { #define LNET_PING_FEAT_INVAL (0) /* no feature */ #define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */ #define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */ +#define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */ #define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \ LNET_PING_FEAT_NI_STATUS) @@ -351,6 +351,8 @@ typedef struct lnet_peer { struct lnet_peer_table { int pt_version; /* /proc validity stamp */ int pt_number; /* # peers extant */ + /* # zombies to go to deathrow (and not there yet) */ + int pt_zombies; struct list_head pt_deathrow; /* zombie peers */ struct list_head *pt_hash; /* NID->peer hash */ }; @@ -394,7 +396,10 @@ typedef struct { struct list_head rbp_msgs; /* messages blocking for a buffer */ int rbp_npages; /* # pages in each buffer */ - int rbp_nbuffers; /* # buffers */ + /* requested number of buffers */ + int rbp_req_nbuffers; + /* # buffers actually allocated */ + int rbp_nbuffers; int rbp_credits; /* # free buffers / blocked messages */ int rbp_mincredits; /* low water mark */ @@ -408,7 +413,12 @@ typedef struct { #define LNET_PEER_HASHSIZE 503 /* prime! */ -#define LNET_NRBPOOLS 3 /* # different router buffer pools */ +#define LNET_TINY_BUF_IDX 0 +#define LNET_SMALL_BUF_IDX 1 +#define LNET_LARGE_BUF_IDX 2 + +/* # different router buffer pools */ +#define LNET_NRBPOOLS (LNET_LARGE_BUF_IDX + 1) enum { /* Didn't match anything */ @@ -569,8 +579,6 @@ typedef struct { /* dying LND instances */ struct list_head ln_nis_zombie; lnet_ni_t *ln_loni; /* the loopback NI */ - /* NI to wait for events in */ - lnet_ni_t *ln_eq_waitni; /* remote networks with routes to them */ struct list_head *ln_remote_nets_hash; @@ -600,8 +608,6 @@ typedef struct { struct mutex ln_api_mutex; struct mutex ln_lnd_mutex; - int ln_init; /* lnet_init() - called? */ /* Have I called LNetNIInit myself? */ int ln_niinit_self; /* LNetNIInit/LNetNIFini counter */ @@ -616,12 +622,24 @@ typedef struct { /* registered LNDs */ struct list_head ln_lnds; - /* space for network names */ - char *ln_network_tokens; - int ln_network_tokens_nob; /* test protocol compatibility flags */ int ln_testprotocompat; + /* + * 0 - load the NIs from the mod params + * 1 - do not load the NIs from the mod params + * Reverse logic to ensure that other calls to LNetNIInit + * need no change + */ + bool ln_nis_from_mod_params; + + /* + * waitq for router checker. As long as there are no routes in + * the list, the router checker will sleep on this queue. when + * routes are added the thread will wake up + */ + wait_queue_head_t ln_rc_waitq; + } lnet_t; #endif diff --git a/drivers/staging/lustre/include/linux/lnet/lnetctl.h b/drivers/staging/lustre/include/linux/lnet/lnetctl.h index bdd69b2..4b64f62 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetctl.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetctl.h @@ -10,10 +10,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * * header for lnet ioctl */ #ifndef _LNETCTL_H_ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 2e7b5ca..98570b3 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -339,8 +339,6 @@ int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid) return -ENOMEM; } - memset(peer, 0, sizeof(*peer)); /* zero flags etc */ - peer->ibp_ni = ni; peer->ibp_nid = nid; peer->ibp_error = 0; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 49d716d..854814c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1842,7 +1842,10 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) unsigned long now = cfs_time_current(); ksock_peer_t *peer = NULL; rwlock_t *glock = &ksocknal_data.ksnd_global_lock; - lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID}; + lnet_process_id_t id = { + .nid = nid, + .pid = LNET_PID_LUSTRE, + }; read_lock(glock); @@ -2187,7 +2190,7 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) case IOC_LIBCFS_ADD_PEER: id.nid = data->ioc_nid; - id.pid = LUSTRE_SRV_LNET_PID; + id.pid = LNET_PID_LUSTRE; return ksocknal_add_peer(ni, id, data->ioc_u32[0], /* IP */ data->ioc_u32[1]); /* port */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index a4117ad..a176544 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -19,10 +19,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * */ #ifndef _SOCKLND_SOCKLND_H_ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 02da02d..efb7169 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -19,9 +19,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "socklnd.h" diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c index 77ce597..6329cbe 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c @@ -14,9 +14,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "socklnd.h" diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 70910ed..976a072 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -19,9 +19,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "socklnd.h" diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index e5f24ff..1452bb3 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -36,6 +36,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include <linux/completion.h> +#include <net/sock.h> #include "../../include/linux/lnet/lib-lnet.h" static int accept_port = 988; @@ -46,7 +47,9 @@ static struct { int pta_shutdown; struct socket *pta_sock; struct completion pta_signal; -} lnet_acceptor_state; +} lnet_acceptor_state = { + .pta_shutdown = 1 +}; int lnet_acceptor_port(void) @@ -204,8 +207,6 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, } EXPORT_SYMBOL(lnet_connect); -/* Below is the code common for both kernel and MT user-space */ - static int lnet_accept(struct socket *sock, __u32 magic) { @@ -439,10 +440,15 @@ accept2secure(const char *acc, long *sec) int lnet_acceptor_start(void) { + struct task_struct *task; int rc; long rc2; long secure; + /* if acceptor is already running return immediately */ + if (!lnet_acceptor_state.pta_shutdown) + return 0; + LASSERT(!lnet_acceptor_state.pta_sock); rc = lnet_acceptor_get_tunables(); @@ -457,10 +463,10 @@ lnet_acceptor_start(void) if (!lnet_count_acceptor_nis()) /* not required */ return 0; - rc2 = PTR_ERR(kthread_run(lnet_acceptor, - (void *)(ulong_ptr_t)secure, - "acceptor_%03ld", secure)); - if (IS_ERR_VALUE(rc2)) { + task = kthread_run(lnet_acceptor, (void *)(ulong_ptr_t)secure, + "acceptor_%03ld", secure); + if (IS_ERR(task)) { + rc2 = PTR_ERR(task); CERROR("Can't start acceptor thread: %ld\n", rc2); return -ESRCH; @@ -483,11 +489,17 @@ lnet_acceptor_start(void) void lnet_acceptor_stop(void) { - if (!lnet_acceptor_state.pta_sock) /* not running */ + struct sock *sk; + + if (lnet_acceptor_state.pta_shutdown) /* not running */ return; lnet_acceptor_state.pta_shutdown = 1; - wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk)); + + sk = lnet_acceptor_state.pta_sock->sk; + + /* awake any sleepers using safe method */ + sk->sk_state_change(sk); /* block until acceptor signals exit */ wait_for_completion(&lnet_acceptor_state.pta_signal); diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 58b30f1..3ecc96a 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -39,6 +39,7 @@ #include <linux/ktime.h> #include "../../include/linux/lnet/lib-lnet.h" +#include "../../include/linux/lnet/lib-dlc.h" #define D_LNI D_CONSOLE @@ -97,6 +98,7 @@ lnet_init_locks(void) { spin_lock_init(&the_lnet.ln_eq_wait_lock); init_waitqueue_head(&the_lnet.ln_eq_waitq); + init_waitqueue_head(&the_lnet.ln_rc_waitq); mutex_init(&the_lnet.ln_lnd_mutex); mutex_init(&the_lnet.ln_api_mutex); } @@ -289,7 +291,6 @@ lnet_register_lnd(lnd_t *lnd) { mutex_lock(&the_lnet.ln_lnd_mutex); - LASSERT(the_lnet.ln_init); LASSERT(libcfs_isknown_lnd(lnd->lnd_type)); LASSERT(!lnet_find_lnd_by_type(lnd->lnd_type)); @@ -307,7 +308,6 @@ lnet_unregister_lnd(lnd_t *lnd) { mutex_lock(&the_lnet.ln_lnd_mutex); - LASSERT(the_lnet.ln_init); LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd); LASSERT(!lnd->lnd_refcount); @@ -524,7 +524,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh) list_add(&lh->lh_hash_chain, &rec->rec_lh_hash[hash]); } -int lnet_unprepare(void); +static int lnet_unprepare(void); static int lnet_prepare(lnet_pid_t requested_pid) @@ -533,6 +533,11 @@ lnet_prepare(lnet_pid_t requested_pid) struct lnet_res_container **recs; int rc = 0; + if (requested_pid == LNET_PID_ANY) { + /* Don't instantiate LNET just for me */ + return -ENETDOWN; + } + LASSERT(!the_lnet.ln_refcount); the_lnet.ln_routing = 0; @@ -605,7 +610,7 @@ lnet_prepare(lnet_pid_t requested_pid) return rc; } -int +static int lnet_unprepare(void) { /* @@ -638,7 +643,7 @@ lnet_unprepare(void) lnet_msg_containers_destroy(); lnet_peer_tables_destroy(); - lnet_rtrpools_free(); + lnet_rtrpools_free(0); if (the_lnet.ln_counters) { cfs_percpt_free(the_lnet.ln_counters); @@ -819,82 +824,267 @@ lnet_count_acceptor_nis(void) return count; } -static int -lnet_ni_tq_credits(lnet_ni_t *ni) +static lnet_ping_info_t * +lnet_ping_info_create(int num_ni) { - int credits; + lnet_ping_info_t *ping_info; + unsigned int infosz; - LASSERT(ni->ni_ncpts >= 1); + infosz = offsetof(lnet_ping_info_t, pi_ni[num_ni]); + LIBCFS_ALLOC(ping_info, infosz); + if (!ping_info) { + CERROR("Can't allocate ping info[%d]\n", num_ni); + return NULL; + } - if (ni->ni_ncpts == 1) - return ni->ni_maxtxcredits; + ping_info->pi_nnis = num_ni; + ping_info->pi_pid = the_lnet.ln_pid; + ping_info->pi_magic = LNET_PROTO_PING_MAGIC; + ping_info->pi_features = LNET_PING_FEAT_NI_STATUS; - credits = ni->ni_maxtxcredits / ni->ni_ncpts; - credits = max(credits, 8 * ni->ni_peertxcredits); - credits = min(credits, ni->ni_maxtxcredits); + return ping_info; +} - return credits; +static inline int +lnet_get_ni_count(void) +{ + struct lnet_ni *ni; + int count = 0; + + lnet_net_lock(0); + + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) + count++; + + lnet_net_unlock(0); + + return count; +} + +static inline void +lnet_ping_info_free(lnet_ping_info_t *pinfo) +{ + LIBCFS_FREE(pinfo, + offsetof(lnet_ping_info_t, + pi_ni[pinfo->pi_nnis])); } static void -lnet_shutdown_lndnis(void) +lnet_ping_info_destroy(void) { - int i; - int islo; - lnet_ni_t *ni; + struct lnet_ni *ni; - /* NB called holding the global mutex */ + lnet_net_lock(LNET_LOCK_EX); - /* All quiet on the API front */ - LASSERT(!the_lnet.ln_shutdown); - LASSERT(!the_lnet.ln_refcount); - LASSERT(list_empty(&the_lnet.ln_nis_zombie)); + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { + lnet_ni_lock(ni); + ni->ni_status = NULL; + lnet_ni_unlock(ni); + } - lnet_net_lock(LNET_LOCK_EX); - the_lnet.ln_shutdown = 1; /* flag shutdown */ + lnet_ping_info_free(the_lnet.ln_ping_info); + the_lnet.ln_ping_info = NULL; - /* Unlink NIs from the global table */ - while (!list_empty(&the_lnet.ln_nis)) { - ni = list_entry(the_lnet.ln_nis.next, - lnet_ni_t, ni_list); - /* move it to zombie list and nobody can find it anymore */ - list_move(&ni->ni_list, &the_lnet.ln_nis_zombie); - lnet_ni_decref_locked(ni, 0); /* drop ln_nis' ref */ + lnet_net_unlock(LNET_LOCK_EX); +} - if (!list_empty(&ni->ni_cptlist)) { - list_del_init(&ni->ni_cptlist); - lnet_ni_decref_locked(ni, 0); +static void +lnet_ping_event_handler(lnet_event_t *event) +{ + lnet_ping_info_t *pinfo = event->md.user_ptr; + + if (event->unlinked) + pinfo->pi_features = LNET_PING_FEAT_INVAL; +} + +static int +lnet_ping_info_setup(lnet_ping_info_t **ppinfo, lnet_handle_md_t *md_handle, + int ni_count, bool set_eq) +{ + lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; + lnet_handle_me_t me_handle; + lnet_md_t md = { NULL }; + int rc, rc2; + + if (set_eq) { + rc = LNetEQAlloc(0, lnet_ping_event_handler, + &the_lnet.ln_ping_target_eq); + if (rc) { + CERROR("Can't allocate ping EQ: %d\n", rc); + return rc; } } - /* Drop the cached eqwait NI. */ - if (the_lnet.ln_eq_waitni) { - lnet_ni_decref_locked(the_lnet.ln_eq_waitni, 0); - the_lnet.ln_eq_waitni = NULL; + *ppinfo = lnet_ping_info_create(ni_count); + if (!*ppinfo) { + rc = -ENOMEM; + goto failed_0; } - /* Drop the cached loopback NI. */ - if (the_lnet.ln_loni) { - lnet_ni_decref_locked(the_lnet.ln_loni, 0); - the_lnet.ln_loni = NULL; + rc = LNetMEAttach(LNET_RESERVED_PORTAL, id, + LNET_PROTO_PING_MATCHBITS, 0, + LNET_UNLINK, LNET_INS_AFTER, + &me_handle); + if (rc) { + CERROR("Can't create ping ME: %d\n", rc); + goto failed_1; } - lnet_net_unlock(LNET_LOCK_EX); + /* initialize md content */ + md.start = *ppinfo; + md.length = offsetof(lnet_ping_info_t, + pi_ni[(*ppinfo)->pi_nnis]); + md.threshold = LNET_MD_THRESH_INF; + md.max_size = 0; + md.options = LNET_MD_OP_GET | LNET_MD_TRUNCATE | + LNET_MD_MANAGE_REMOTE; + md.user_ptr = NULL; + md.eq_handle = the_lnet.ln_ping_target_eq; + md.user_ptr = *ppinfo; - /* - * Clear lazy portals and drop delayed messages which hold refs - * on their lnet_msg_t::msg_rxpeer - */ - for (i = 0; i < the_lnet.ln_nportals; i++) - LNetClearLazyPortal(i); + rc = LNetMDAttach(me_handle, md, LNET_RETAIN, md_handle); + if (rc) { + CERROR("Can't attach ping MD: %d\n", rc); + goto failed_2; + } - /* - * Clear the peer table and wait for all peers to go (they hold refs on - * their NIs) - */ - lnet_peer_tables_cleanup(); + return 0; +failed_2: + rc2 = LNetMEUnlink(me_handle); + LASSERT(!rc2); +failed_1: + lnet_ping_info_free(*ppinfo); + *ppinfo = NULL; +failed_0: + if (set_eq) + LNetEQFree(the_lnet.ln_ping_target_eq); + return rc; +} + +static void +lnet_ping_md_unlink(lnet_ping_info_t *pinfo, lnet_handle_md_t *md_handle) +{ + sigset_t blocked = cfs_block_allsigs(); + + LNetMDUnlink(*md_handle); + LNetInvalidateHandle(md_handle); + + /* NB md could be busy; this just starts the unlink */ + while (pinfo->pi_features != LNET_PING_FEAT_INVAL) { + CDEBUG(D_NET, "Still waiting for ping MD to unlink\n"); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(cfs_time_seconds(1)); + } + + cfs_restore_sigs(blocked); +} + +static void +lnet_ping_info_install_locked(lnet_ping_info_t *ping_info) +{ + lnet_ni_status_t *ns; + lnet_ni_t *ni; + int i = 0; + + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { + LASSERT(i < ping_info->pi_nnis); + + ns = &ping_info->pi_ni[i]; + + ns->ns_nid = ni->ni_nid; + + lnet_ni_lock(ni); + ns->ns_status = (ni->ni_status) ? + ni->ni_status->ns_status : LNET_NI_STATUS_UP; + ni->ni_status = ns; + lnet_ni_unlock(ni); + + i++; + } +} + +static void +lnet_ping_target_update(lnet_ping_info_t *pinfo, lnet_handle_md_t md_handle) +{ + lnet_ping_info_t *old_pinfo = NULL; + lnet_handle_md_t old_md; + + /* switch the NIs to point to the new ping info created */ lnet_net_lock(LNET_LOCK_EX); + + if (!the_lnet.ln_routing) + pinfo->pi_features |= LNET_PING_FEAT_RTE_DISABLED; + lnet_ping_info_install_locked(pinfo); + + if (the_lnet.ln_ping_info) { + old_pinfo = the_lnet.ln_ping_info; + old_md = the_lnet.ln_ping_target_md; + } + the_lnet.ln_ping_target_md = md_handle; + the_lnet.ln_ping_info = pinfo; + + lnet_net_unlock(LNET_LOCK_EX); + + if (old_pinfo) { + /* unlink the old ping info */ + lnet_ping_md_unlink(old_pinfo, &old_md); + lnet_ping_info_free(old_pinfo); + } +} + +static void +lnet_ping_target_fini(void) +{ + int rc; + + lnet_ping_md_unlink(the_lnet.ln_ping_info, + &the_lnet.ln_ping_target_md); + + rc = LNetEQFree(the_lnet.ln_ping_target_eq); + LASSERT(!rc); + + lnet_ping_info_destroy(); +} + +static int +lnet_ni_tq_credits(lnet_ni_t *ni) +{ + int credits; + + LASSERT(ni->ni_ncpts >= 1); + + if (ni->ni_ncpts == 1) + return ni->ni_maxtxcredits; + + credits = ni->ni_maxtxcredits / ni->ni_ncpts; + credits = max(credits, 8 * ni->ni_peertxcredits); + credits = min(credits, ni->ni_maxtxcredits); + + return credits; +} + +static void +lnet_ni_unlink_locked(lnet_ni_t *ni) +{ + if (!list_empty(&ni->ni_cptlist)) { + list_del_init(&ni->ni_cptlist); + lnet_ni_decref_locked(ni, 0); + } + + /* move it to zombie list and nobody can find it anymore */ + LASSERT(!list_empty(&ni->ni_list)); + list_move(&ni->ni_list, &the_lnet.ln_nis_zombie); + lnet_ni_decref_locked(ni, 0); /* drop ln_nis' ref */ +} + +static void +lnet_clear_zombies_nis_locked(void) +{ + int i; + int islo; + lnet_ni_t *ni; + /* * Now wait for the NI's I just nuked to show up on ln_zombie_nis * and shut them down in guaranteed thread context @@ -949,165 +1139,255 @@ lnet_shutdown_lndnis(void) lnet_net_lock(LNET_LOCK_EX); } +} + +static void +lnet_shutdown_lndnis(void) +{ + lnet_ni_t *ni; + int i; + + /* NB called holding the global mutex */ + + /* All quiet on the API front */ + LASSERT(!the_lnet.ln_shutdown); + LASSERT(!the_lnet.ln_refcount); + LASSERT(list_empty(&the_lnet.ln_nis_zombie)); + + lnet_net_lock(LNET_LOCK_EX); + the_lnet.ln_shutdown = 1; /* flag shutdown */ + + /* Unlink NIs from the global table */ + while (!list_empty(&the_lnet.ln_nis)) { + ni = list_entry(the_lnet.ln_nis.next, + lnet_ni_t, ni_list); + lnet_ni_unlink_locked(ni); + } + + /* Drop the cached loopback NI. */ + if (the_lnet.ln_loni) { + lnet_ni_decref_locked(the_lnet.ln_loni, 0); + the_lnet.ln_loni = NULL; + } + + lnet_net_unlock(LNET_LOCK_EX); + + /* + * Clear lazy portals and drop delayed messages which hold refs + * on their lnet_msg_t::msg_rxpeer + */ + for (i = 0; i < the_lnet.ln_nportals; i++) + LNetClearLazyPortal(i); + /* + * Clear the peer table and wait for all peers to go (they hold refs on + * their NIs) + */ + lnet_peer_tables_cleanup(NULL); + + lnet_net_lock(LNET_LOCK_EX); + + lnet_clear_zombies_nis_locked(); the_lnet.ln_shutdown = 0; lnet_net_unlock(LNET_LOCK_EX); +} - if (the_lnet.ln_network_tokens) { - LIBCFS_FREE(the_lnet.ln_network_tokens, - the_lnet.ln_network_tokens_nob); - the_lnet.ln_network_tokens = NULL; - } +/* shutdown down the NI and release refcount */ +static void +lnet_shutdown_lndni(struct lnet_ni *ni) +{ + int i; + + lnet_net_lock(LNET_LOCK_EX); + lnet_ni_unlink_locked(ni); + lnet_net_unlock(LNET_LOCK_EX); + + /* clear messages for this NI on the lazy portal */ + for (i = 0; i < the_lnet.ln_nportals; i++) + lnet_clear_lazy_portal(ni, i, "Shutting down NI"); + + /* Do peer table cleanup for this ni */ + lnet_peer_tables_cleanup(ni); + + lnet_net_lock(LNET_LOCK_EX); + lnet_clear_zombies_nis_locked(); + lnet_net_unlock(LNET_LOCK_EX); } static int -lnet_startup_lndnis(void) +lnet_startup_lndni(struct lnet_ni *ni, __s32 peer_timeout, + __s32 peer_cr, __s32 peer_buf_cr, __s32 credits) { + int rc = -EINVAL; + int lnd_type; lnd_t *lnd; - struct lnet_ni *ni; struct lnet_tx_queue *tq; - struct list_head nilist; int i; - int rc = 0; - __u32 lnd_type; - int nicount = 0; - char *nets = lnet_get_networks(); - INIT_LIST_HEAD(&nilist); + lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); - if (!nets) - goto failed; + LASSERT(libcfs_isknown_lnd(lnd_type)); - rc = lnet_parse_networks(&nilist, nets); - if (rc) - goto failed; + if (lnd_type == CIBLND || lnd_type == OPENIBLND || + lnd_type == IIBLND || lnd_type == VIBLND) { + CERROR("LND %s obsoleted\n", libcfs_lnd2str(lnd_type)); + goto failed0; + } - while (!list_empty(&nilist)) { - ni = list_entry(nilist.next, lnet_ni_t, ni_list); - lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); + /* Make sure this new NI is unique. */ + lnet_net_lock(LNET_LOCK_EX); + rc = lnet_net_unique(LNET_NIDNET(ni->ni_nid), &the_lnet.ln_nis); + lnet_net_unlock(LNET_LOCK_EX); + if (!rc) { + if (lnd_type == LOLND) { + lnet_ni_free(ni); + return 0; + } - LASSERT(libcfs_isknown_lnd(lnd_type)); + CERROR("Net %s is not unique\n", + libcfs_net2str(LNET_NIDNET(ni->ni_nid))); + rc = -EEXIST; + goto failed0; + } - if (lnd_type == CIBLND || - lnd_type == OPENIBLND || - lnd_type == IIBLND || - lnd_type == VIBLND) { - CERROR("LND %s obsoleted\n", - libcfs_lnd2str(lnd_type)); - goto failed; - } + mutex_lock(&the_lnet.ln_lnd_mutex); + lnd = lnet_find_lnd_by_type(lnd_type); + if (!lnd) { + mutex_unlock(&the_lnet.ln_lnd_mutex); + rc = request_module("%s", libcfs_lnd2modname(lnd_type)); mutex_lock(&the_lnet.ln_lnd_mutex); - lnd = lnet_find_lnd_by_type(lnd_type); + lnd = lnet_find_lnd_by_type(lnd_type); if (!lnd) { mutex_unlock(&the_lnet.ln_lnd_mutex); - rc = request_module("%s", - libcfs_lnd2modname(lnd_type)); - mutex_lock(&the_lnet.ln_lnd_mutex); - - lnd = lnet_find_lnd_by_type(lnd_type); - if (!lnd) { - mutex_unlock(&the_lnet.ln_lnd_mutex); - CERROR("Can't load LND %s, module %s, rc=%d\n", - libcfs_lnd2str(lnd_type), - libcfs_lnd2modname(lnd_type), rc); - goto failed; - } + CERROR("Can't load LND %s, module %s, rc=%d\n", + libcfs_lnd2str(lnd_type), + libcfs_lnd2modname(lnd_type), rc); + rc = -EINVAL; + goto failed0; } + } - lnet_net_lock(LNET_LOCK_EX); - lnd->lnd_refcount++; - lnet_net_unlock(LNET_LOCK_EX); - - ni->ni_lnd = lnd; - - rc = lnd->lnd_startup(ni); - - mutex_unlock(&the_lnet.ln_lnd_mutex); + lnet_net_lock(LNET_LOCK_EX); + lnd->lnd_refcount++; + lnet_net_unlock(LNET_LOCK_EX); - if (rc) { - LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n", - rc, libcfs_lnd2str(lnd->lnd_type)); - lnet_net_lock(LNET_LOCK_EX); - lnd->lnd_refcount--; - lnet_net_unlock(LNET_LOCK_EX); - goto failed; - } + ni->ni_lnd = lnd; - LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query); + rc = lnd->lnd_startup(ni); - list_del(&ni->ni_list); + mutex_unlock(&the_lnet.ln_lnd_mutex); + if (rc) { + LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n", + rc, libcfs_lnd2str(lnd->lnd_type)); lnet_net_lock(LNET_LOCK_EX); - /* refcount for ln_nis */ - lnet_ni_addref_locked(ni, 0); - list_add_tail(&ni->ni_list, &the_lnet.ln_nis); - if (ni->ni_cpts) { - list_add_tail(&ni->ni_cptlist, - &the_lnet.ln_nis_cpt); - lnet_ni_addref_locked(ni, 0); - } - + lnd->lnd_refcount--; lnet_net_unlock(LNET_LOCK_EX); + goto failed0; + } - if (lnd->lnd_type == LOLND) { - lnet_ni_addref(ni); - LASSERT(!the_lnet.ln_loni); - the_lnet.ln_loni = ni; - continue; - } + /* + * If given some LND tunable parameters, parse those now to + * override the values in the NI structure. + */ + if (peer_buf_cr >= 0) + ni->ni_peerrtrcredits = peer_buf_cr; + if (peer_timeout >= 0) + ni->ni_peertimeout = peer_timeout; + /* + * TODO + * Note: For now, don't allow the user to change + * peertxcredits as this number is used in the + * IB LND to control queue depth. + * if (peer_cr != -1) + * ni->ni_peertxcredits = peer_cr; + */ + if (credits >= 0) + ni->ni_maxtxcredits = credits; - if (!ni->ni_peertxcredits || !ni->ni_maxtxcredits) { - LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n", - libcfs_lnd2str(lnd->lnd_type), - !ni->ni_peertxcredits ? - "" : "per-peer "); - goto failed; - } + LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query); - cfs_percpt_for_each(tq, i, ni->ni_tx_queues) { - tq->tq_credits_min = - tq->tq_credits_max = - tq->tq_credits = lnet_ni_tq_credits(ni); - } + lnet_net_lock(LNET_LOCK_EX); + /* refcount for ln_nis */ + lnet_ni_addref_locked(ni, 0); + list_add_tail(&ni->ni_list, &the_lnet.ln_nis); + if (ni->ni_cpts) { + lnet_ni_addref_locked(ni, 0); + list_add_tail(&ni->ni_cptlist, &the_lnet.ln_nis_cpt); + } - CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n", - libcfs_nid2str(ni->ni_nid), ni->ni_peertxcredits, - lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER, - ni->ni_peerrtrcredits, ni->ni_peertimeout); + lnet_net_unlock(LNET_LOCK_EX); - nicount++; + if (lnd->lnd_type == LOLND) { + lnet_ni_addref(ni); + LASSERT(!the_lnet.ln_loni); + the_lnet.ln_loni = ni; + return 0; } - if (the_lnet.ln_eq_waitni && nicount > 1) { - lnd_type = the_lnet.ln_eq_waitni->ni_lnd->lnd_type; - LCONSOLE_ERROR_MSG(0x109, "LND %s can only run single-network\n", - libcfs_lnd2str(lnd_type)); - goto failed; + if (!ni->ni_peertxcredits || !ni->ni_maxtxcredits) { + LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n", + libcfs_lnd2str(lnd->lnd_type), + !ni->ni_peertxcredits ? + "" : "per-peer "); + /* + * shutdown the NI since if we get here then it must've already + * been started + */ + lnet_shutdown_lndni(ni); + return -EINVAL; + } + + cfs_percpt_for_each(tq, i, ni->ni_tx_queues) { + tq->tq_credits_min = + tq->tq_credits_max = + tq->tq_credits = lnet_ni_tq_credits(ni); } + CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n", + libcfs_nid2str(ni->ni_nid), ni->ni_peertxcredits, + lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER, + ni->ni_peerrtrcredits, ni->ni_peertimeout); + return 0; +failed0: + lnet_ni_free(ni); + return rc; +} - failed: - lnet_shutdown_lndnis(); +static int +lnet_startup_lndnis(struct list_head *nilist) +{ + struct lnet_ni *ni; + int rc; + int ni_count = 0; - while (!list_empty(&nilist)) { - ni = list_entry(nilist.next, lnet_ni_t, ni_list); + while (!list_empty(nilist)) { + ni = list_entry(nilist->next, lnet_ni_t, ni_list); list_del(&ni->ni_list); - lnet_ni_free(ni); + rc = lnet_startup_lndni(ni, -1, -1, -1, -1); + + if (rc < 0) + goto failed; + + ni_count++; } - return -ENETDOWN; + return ni_count; +failed: + lnet_shutdown_lndnis(); + + return rc; } /** * Initialize LNet library. * - * Only userspace program needs to call this function - it's automatically - * called in the kernel at module loading time. Caller has to call lnet_fini() - * after a call to lnet_init(), if and only if the latter returned 0. It must - * be called exactly once. + * Automatically called at module loading time. Caller has to call + * lnet_exit() after a call to lnet_init(), if and only if the + * latter returned 0. It must be called exactly once. * * \return 0 on success, and -ve on failures. */ @@ -1117,7 +1397,6 @@ lnet_init(void) int rc; lnet_assert_wire_constants(); - LASSERT(!the_lnet.ln_init); memset(&the_lnet, 0, sizeof(the_lnet)); @@ -1143,7 +1422,6 @@ lnet_init(void) } the_lnet.ln_refcount = 0; - the_lnet.ln_init = 1; LNetInvalidateHandle(&the_lnet.ln_rc_eqh); INIT_LIST_HEAD(&the_lnet.ln_lnds); INIT_LIST_HEAD(&the_lnet.ln_rcd_zombie); @@ -1173,30 +1451,23 @@ lnet_init(void) /** * Finalize LNet library. * - * Only userspace program needs to call this function. It can be called - * at most once. - * * \pre lnet_init() called with success. * \pre All LNet users called LNetNIFini() for matching LNetNIInit() calls. */ void lnet_fini(void) { - LASSERT(the_lnet.ln_init); LASSERT(!the_lnet.ln_refcount); while (!list_empty(&the_lnet.ln_lnds)) lnet_unregister_lnd(list_entry(the_lnet.ln_lnds.next, lnd_t, lnd_list)); lnet_destroy_locks(); - - the_lnet.ln_init = 0; } /** * Set LNet PID and start LNet interfaces, routing, and forwarding. * - * Userspace program should call this after a successful call to lnet_init(). * Users must call this function at least once before any other functions. * For each successful call there must be a corresponding call to * LNetNIFini(). For subsequent calls to LNetNIInit(), \a requested_pid is @@ -1214,79 +1485,113 @@ LNetNIInit(lnet_pid_t requested_pid) { int im_a_router = 0; int rc; + int ni_count; + lnet_ping_info_t *pinfo; + lnet_handle_md_t md_handle; + struct list_head net_head; + + INIT_LIST_HEAD(&net_head); mutex_lock(&the_lnet.ln_api_mutex); - LASSERT(the_lnet.ln_init); CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount); if (the_lnet.ln_refcount > 0) { rc = the_lnet.ln_refcount++; - goto out; + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; } - if (requested_pid == LNET_PID_ANY) { - /* Don't instantiate LNET just for me */ - rc = -ENETDOWN; - goto failed0; + rc = lnet_prepare(requested_pid); + if (rc) { + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; } - rc = lnet_prepare(requested_pid); - if (rc) - goto failed0; + /* Add in the loopback network */ + if (!lnet_ni_alloc(LNET_MKNET(LOLND, 0), NULL, &net_head)) { + rc = -ENOMEM; + goto err_empty_list; + } - rc = lnet_startup_lndnis(); - if (rc) - goto failed1; + /* + * If LNet is being initialized via DLC it is possible + * that the user requests not to load module parameters (ones which + * are supported by DLC) on initialization. Therefore, make sure not + * to load networks, routes and forwarding from module parameters + * in this case. On cleanup in case of failure only clean up + * routes if it has been loaded + */ + if (!the_lnet.ln_nis_from_mod_params) { + rc = lnet_parse_networks(&net_head, lnet_get_networks()); + if (rc < 0) + goto err_empty_list; + } - rc = lnet_parse_routes(lnet_get_routes(), &im_a_router); - if (rc) - goto failed2; + ni_count = lnet_startup_lndnis(&net_head); + if (ni_count < 0) { + rc = ni_count; + goto err_empty_list; + } - rc = lnet_check_routes(); - if (rc) - goto failed2; + if (!the_lnet.ln_nis_from_mod_params) { + rc = lnet_parse_routes(lnet_get_routes(), &im_a_router); + if (rc) + goto err_shutdown_lndnis; - rc = lnet_rtrpools_alloc(im_a_router); - if (rc) - goto failed2; + rc = lnet_check_routes(); + if (rc) + goto err_destory_routes; + + rc = lnet_rtrpools_alloc(im_a_router); + if (rc) + goto err_destory_routes; + } rc = lnet_acceptor_start(); if (rc) - goto failed2; + goto err_destory_routes; the_lnet.ln_refcount = 1; /* Now I may use my own API functions... */ - /* - * NB router checker needs the_lnet.ln_ping_info in - * lnet_router_checker -> lnet_update_ni_status_locked - */ - rc = lnet_ping_target_init(); + rc = lnet_ping_info_setup(&pinfo, &md_handle, ni_count, true); if (rc) - goto failed3; + goto err_acceptor_stop; + + lnet_ping_target_update(pinfo, md_handle); rc = lnet_router_checker_start(); if (rc) - goto failed4; + goto err_stop_ping; lnet_router_debugfs_init(); - goto out; - failed4: + mutex_unlock(&the_lnet.ln_api_mutex); + + return 0; + +err_stop_ping: lnet_ping_target_fini(); - failed3: +err_acceptor_stop: the_lnet.ln_refcount = 0; lnet_acceptor_stop(); - failed2: - lnet_destroy_routes(); +err_destory_routes: + if (!the_lnet.ln_nis_from_mod_params) + lnet_destroy_routes(); +err_shutdown_lndnis: lnet_shutdown_lndnis(); - failed1: +err_empty_list: lnet_unprepare(); - failed0: LASSERT(rc < 0); - out: mutex_unlock(&the_lnet.ln_api_mutex); + while (!list_empty(&net_head)) { + struct lnet_ni *ni; + + ni = list_entry(net_head.next, struct lnet_ni, ni_list); + list_del_init(&ni->ni_list); + lnet_ni_free(ni); + } return rc; } EXPORT_SYMBOL(LNetNIInit); @@ -1305,7 +1610,6 @@ LNetNIFini(void) { mutex_lock(&the_lnet.ln_api_mutex); - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (the_lnet.ln_refcount != 1) { @@ -1332,6 +1636,220 @@ LNetNIFini(void) EXPORT_SYMBOL(LNetNIFini); /** + * Grabs the ni data from the ni structure and fills the out + * parameters + * + * \param[in] ni network interface structure + * \param[out] cpt_count the number of cpts the ni is on + * \param[out] nid Network Interface ID + * \param[out] peer_timeout NI peer timeout + * \param[out] peer_tx_crdits NI peer transmit credits + * \param[out] peer_rtr_credits NI peer router credits + * \param[out] max_tx_credits NI max transmit credit + * \param[out] net_config Network configuration + */ +static void +lnet_fill_ni_info(struct lnet_ni *ni, __u32 *cpt_count, __u64 *nid, + int *peer_timeout, int *peer_tx_credits, + int *peer_rtr_credits, int *max_tx_credits, + struct lnet_ioctl_net_config *net_config) +{ + int i; + + if (!ni) + return; + + if (!net_config) + return; + + BUILD_BUG_ON(ARRAY_SIZE(ni->ni_interfaces) != + ARRAY_SIZE(net_config->ni_interfaces)); + + for (i = 0; i < ARRAY_SIZE(ni->ni_interfaces); i++) { + if (!ni->ni_interfaces[i]) + break; + + strncpy(net_config->ni_interfaces[i], + ni->ni_interfaces[i], + sizeof(net_config->ni_interfaces[i])); + } + + *nid = ni->ni_nid; + *peer_timeout = ni->ni_peertimeout; + *peer_tx_credits = ni->ni_peertxcredits; + *peer_rtr_credits = ni->ni_peerrtrcredits; + *max_tx_credits = ni->ni_maxtxcredits; + + net_config->ni_status = ni->ni_status->ns_status; + + if (ni->ni_cpts) { + int num_cpts = min(ni->ni_ncpts, LNET_MAX_SHOW_NUM_CPT); + + for (i = 0; i < num_cpts; i++) + net_config->ni_cpts[i] = ni->ni_cpts[i]; + + *cpt_count = num_cpts; + } +} + +int +lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid, int *peer_timeout, + int *peer_tx_credits, int *peer_rtr_credits, + int *max_tx_credits, + struct lnet_ioctl_net_config *net_config) +{ + struct lnet_ni *ni; + struct list_head *tmp; + int cpt, i = 0; + int rc = -ENOENT; + + cpt = lnet_net_lock_current(); + + list_for_each(tmp, &the_lnet.ln_nis) { + if (i++ != idx) + continue; + + ni = list_entry(tmp, lnet_ni_t, ni_list); + lnet_ni_lock(ni); + lnet_fill_ni_info(ni, cpt_count, nid, peer_timeout, + peer_tx_credits, peer_rtr_credits, + max_tx_credits, net_config); + lnet_ni_unlock(ni); + rc = 0; + break; + } + + lnet_net_unlock(cpt); + return rc; +} + +int +lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets, + __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr, + __s32 credits) +{ + lnet_ping_info_t *pinfo; + lnet_handle_md_t md_handle; + struct lnet_ni *ni; + struct list_head net_head; + lnet_remotenet_t *rnet; + int rc; + + INIT_LIST_HEAD(&net_head); + + /* Create a ni structure for the network string */ + rc = lnet_parse_networks(&net_head, nets); + if (rc <= 0) + return !rc ? -EINVAL : rc; + + mutex_lock(&the_lnet.ln_api_mutex); + + if (rc > 1) { + rc = -EINVAL; /* only add one interface per call */ + goto failed0; + } + + ni = list_entry(net_head.next, struct lnet_ni, ni_list); + + lnet_net_lock(LNET_LOCK_EX); + rnet = lnet_find_net_locked(LNET_NIDNET(ni->ni_nid)); + lnet_net_unlock(LNET_LOCK_EX); + /* + * make sure that the net added doesn't invalidate the current + * configuration LNet is keeping + */ + if (rnet) { + CERROR("Adding net %s will invalidate routing configuration\n", + nets); + rc = -EUSERS; + goto failed0; + } + + rc = lnet_ping_info_setup(&pinfo, &md_handle, 1 + lnet_get_ni_count(), + false); + if (rc) + goto failed0; + + list_del_init(&ni->ni_list); + + rc = lnet_startup_lndni(ni, peer_timeout, peer_cr, + peer_buf_cr, credits); + if (rc) + goto failed1; + + if (ni->ni_lnd->lnd_accept) { + rc = lnet_acceptor_start(); + if (rc < 0) { + /* shutdown the ni that we just started */ + CERROR("Failed to start up acceptor thread\n"); + lnet_shutdown_lndni(ni); + goto failed1; + } + } + + lnet_ping_target_update(pinfo, md_handle); + mutex_unlock(&the_lnet.ln_api_mutex); + + return 0; + +failed1: + lnet_ping_md_unlink(pinfo, &md_handle); + lnet_ping_info_free(pinfo); +failed0: + mutex_unlock(&the_lnet.ln_api_mutex); + while (!list_empty(&net_head)) { + ni = list_entry(net_head.next, struct lnet_ni, ni_list); + list_del_init(&ni->ni_list); + lnet_ni_free(ni); + } + return rc; +} + +int +lnet_dyn_del_ni(__u32 net) +{ + lnet_ni_t *ni; + lnet_ping_info_t *pinfo; + lnet_handle_md_t md_handle; + int rc; + + /* don't allow userspace to shutdown the LOLND */ + if (LNET_NETTYP(net) == LOLND) + return -EINVAL; + + mutex_lock(&the_lnet.ln_api_mutex); + /* create and link a new ping info, before removing the old one */ + rc = lnet_ping_info_setup(&pinfo, &md_handle, + lnet_get_ni_count() - 1, false); + if (rc) + goto out; + + ni = lnet_net2ni(net); + if (!ni) { + rc = -EINVAL; + goto failed; + } + + /* decrement the reference counter taken by lnet_net2ni() */ + lnet_ni_decref_locked(ni, 0); + + lnet_shutdown_lndni(ni); + + if (!lnet_count_acceptor_nis()) + lnet_acceptor_stop(); + + lnet_ping_target_update(pinfo, md_handle); + goto out; +failed: + lnet_ping_md_unlink(pinfo, &md_handle); + lnet_ping_info_free(pinfo); +out: + mutex_unlock(&the_lnet.ln_api_mutex); + + return rc; +} + +/** * LNet ioctl handler. * */ @@ -1339,14 +1857,12 @@ int LNetCtl(unsigned int cmd, void *arg) { struct libcfs_ioctl_data *data = arg; + struct lnet_ioctl_config_data *config; lnet_process_id_t id = {0}; lnet_ni_t *ni; int rc; unsigned long secs_passed; - LASSERT(the_lnet.ln_init); - LASSERT(the_lnet.ln_refcount > 0); - switch (cmd) { case IOC_LIBCFS_GET_NI: rc = LNetGetId(data->ioc_count, &id); @@ -1357,18 +1873,143 @@ LNetCtl(unsigned int cmd, void *arg) return lnet_fail_nid(data->ioc_nid, data->ioc_count); case IOC_LIBCFS_ADD_ROUTE: - rc = lnet_add_route(data->ioc_net, data->ioc_count, - data->ioc_nid, data->ioc_priority); - return (rc) ? rc : lnet_check_routes(); + config = arg; + + if (config->cfg_hdr.ioc_len < sizeof(*config)) + return -EINVAL; + + mutex_lock(&the_lnet.ln_api_mutex); + rc = lnet_add_route(config->cfg_net, + config->cfg_config_u.cfg_route.rtr_hop, + config->cfg_nid, + config->cfg_config_u.cfg_route.rtr_priority); + if (!rc) { + rc = lnet_check_routes(); + if (rc) + lnet_del_route(config->cfg_net, + config->cfg_nid); + } + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; case IOC_LIBCFS_DEL_ROUTE: - return lnet_del_route(data->ioc_net, data->ioc_nid); + config = arg; + + if (config->cfg_hdr.ioc_len < sizeof(*config)) + return -EINVAL; + + mutex_lock(&the_lnet.ln_api_mutex); + rc = lnet_del_route(config->cfg_net, config->cfg_nid); + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; case IOC_LIBCFS_GET_ROUTE: - return lnet_get_route(data->ioc_count, - &data->ioc_net, &data->ioc_count, - &data->ioc_nid, &data->ioc_flags, - &data->ioc_priority); + config = arg; + + if (config->cfg_hdr.ioc_len < sizeof(*config)) + return -EINVAL; + + return lnet_get_route(config->cfg_count, + &config->cfg_net, + &config->cfg_config_u.cfg_route.rtr_hop, + &config->cfg_nid, + &config->cfg_config_u.cfg_route.rtr_flags, + &config->cfg_config_u.cfg_route.rtr_priority); + + case IOC_LIBCFS_GET_NET: { + struct lnet_ioctl_net_config *net_config; + size_t total = sizeof(*config) + sizeof(*net_config); + + config = arg; + + if (config->cfg_hdr.ioc_len < total) + return -EINVAL; + + net_config = (struct lnet_ioctl_net_config *) + config->cfg_bulk; + if (!net_config) + return -EINVAL; + + return lnet_get_net_config(config->cfg_count, + &config->cfg_ncpts, + &config->cfg_nid, + &config->cfg_config_u.cfg_net.net_peer_timeout, + &config->cfg_config_u.cfg_net.net_peer_tx_credits, + &config->cfg_config_u.cfg_net.net_peer_rtr_credits, + &config->cfg_config_u.cfg_net.net_max_tx_credits, + net_config); + } + + case IOC_LIBCFS_GET_LNET_STATS: { + struct lnet_ioctl_lnet_stats *lnet_stats = arg; + + if (lnet_stats->st_hdr.ioc_len < sizeof(*lnet_stats)) + return -EINVAL; + + lnet_counters_get(&lnet_stats->st_cntrs); + return 0; + } + + case IOC_LIBCFS_CONFIG_RTR: + config = arg; + + if (config->cfg_hdr.ioc_len < sizeof(*config)) + return -EINVAL; + + mutex_lock(&the_lnet.ln_api_mutex); + if (config->cfg_config_u.cfg_buffers.buf_enable) { + rc = lnet_rtrpools_enable(); + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; + } + lnet_rtrpools_disable(); + mutex_unlock(&the_lnet.ln_api_mutex); + return 0; + + case IOC_LIBCFS_ADD_BUF: + config = arg; + + if (config->cfg_hdr.ioc_len < sizeof(*config)) + return -EINVAL; + + mutex_lock(&the_lnet.ln_api_mutex); + rc = lnet_rtrpools_adjust(config->cfg_config_u.cfg_buffers.buf_tiny, + config->cfg_config_u.cfg_buffers.buf_small, + config->cfg_config_u.cfg_buffers.buf_large); + mutex_unlock(&the_lnet.ln_api_mutex); + return rc; + + case IOC_LIBCFS_GET_BUF: { + struct lnet_ioctl_pool_cfg *pool_cfg; + size_t total = sizeof(*config) + sizeof(*pool_cfg); + + config = arg; + + if (config->cfg_hdr.ioc_len < total) + return -EINVAL; + + pool_cfg = (struct lnet_ioctl_pool_cfg *)config->cfg_bulk; + return lnet_get_rtr_pool_cfg(config->cfg_count, pool_cfg); + } + + case IOC_LIBCFS_GET_PEER_INFO: { + struct lnet_ioctl_peer *peer_info = arg; + + if (peer_info->pr_hdr.ioc_len < sizeof(*peer_info)) + return -EINVAL; + + return lnet_get_peer_info(peer_info->pr_count, + &peer_info->pr_nid, + peer_info->pr_lnd_u.pr_peer_credits.cr_aliveness, + &peer_info->pr_lnd_u.pr_peer_credits.cr_ncpt, + &peer_info->pr_lnd_u.pr_peer_credits.cr_refcount, + &peer_info->pr_lnd_u.pr_peer_credits.cr_ni_peer_tx_credits, + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_credits, + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_rtr_credits, + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_min_rtr_credits, + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob); + } + case IOC_LIBCFS_NOTIFY_ROUTER: secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]); return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, @@ -1441,8 +2082,6 @@ LNetGetId(unsigned int index, lnet_process_id_t *id) int cpt; int rc = -ENOENT; - LASSERT(the_lnet.ln_init); - /* LNetNI initilization failed? */ if (!the_lnet.ln_refcount) return rc; @@ -1477,192 +2116,6 @@ LNetSnprintHandle(char *str, int len, lnet_handle_any_t h) } EXPORT_SYMBOL(LNetSnprintHandle); -static int -lnet_create_ping_info(void) -{ - int i; - int n; - int rc; - unsigned int infosz; - lnet_ni_t *ni; - lnet_process_id_t id; - lnet_ping_info_t *pinfo; - - for (n = 0; ; n++) { - rc = LNetGetId(n, &id); - if (rc == -ENOENT) - break; - - LASSERT(!rc); - } - - infosz = offsetof(lnet_ping_info_t, pi_ni[n]); - LIBCFS_ALLOC(pinfo, infosz); - if (!pinfo) { - CERROR("Can't allocate ping info[%d]\n", n); - return -ENOMEM; - } - - pinfo->pi_nnis = n; - pinfo->pi_pid = the_lnet.ln_pid; - pinfo->pi_magic = LNET_PROTO_PING_MAGIC; - pinfo->pi_features = LNET_PING_FEAT_NI_STATUS; - - for (i = 0; i < n; i++) { - lnet_ni_status_t *ns = &pinfo->pi_ni[i]; - - rc = LNetGetId(i, &id); - LASSERT(!rc); - - ns->ns_nid = id.nid; - ns->ns_status = LNET_NI_STATUS_UP; - - lnet_net_lock(0); - - ni = lnet_nid2ni_locked(id.nid, 0); - LASSERT(ni); - - lnet_ni_lock(ni); - LASSERT(!ni->ni_status); - ni->ni_status = ns; - lnet_ni_unlock(ni); - - lnet_ni_decref_locked(ni, 0); - lnet_net_unlock(0); - } - - the_lnet.ln_ping_info = pinfo; - return 0; -} - -static void -lnet_destroy_ping_info(void) -{ - struct lnet_ni *ni; - - lnet_net_lock(0); - - list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { - lnet_ni_lock(ni); - ni->ni_status = NULL; - lnet_ni_unlock(ni); - } - - lnet_net_unlock(0); - - LIBCFS_FREE(the_lnet.ln_ping_info, - offsetof(lnet_ping_info_t, - pi_ni[the_lnet.ln_ping_info->pi_nnis])); - the_lnet.ln_ping_info = NULL; -} - -int -lnet_ping_target_init(void) -{ - lnet_md_t md = { NULL }; - lnet_handle_me_t meh; - lnet_process_id_t id; - int rc; - int rc2; - int infosz; - - rc = lnet_create_ping_info(); - if (rc) - return rc; - - /* - * We can have a tiny EQ since we only need to see the unlink event on - * teardown, which by definition is the last one! - */ - rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &the_lnet.ln_ping_target_eq); - if (rc) { - CERROR("Can't allocate ping EQ: %d\n", rc); - goto failed_0; - } - - memset(&id, 0, sizeof(lnet_process_id_t)); - id.nid = LNET_NID_ANY; - id.pid = LNET_PID_ANY; - - rc = LNetMEAttach(LNET_RESERVED_PORTAL, id, - LNET_PROTO_PING_MATCHBITS, 0, - LNET_UNLINK, LNET_INS_AFTER, - &meh); - if (rc) { - CERROR("Can't create ping ME: %d\n", rc); - goto failed_1; - } - - /* initialize md content */ - infosz = offsetof(lnet_ping_info_t, - pi_ni[the_lnet.ln_ping_info->pi_nnis]); - md.start = the_lnet.ln_ping_info; - md.length = infosz; - md.threshold = LNET_MD_THRESH_INF; - md.max_size = 0; - md.options = LNET_MD_OP_GET | LNET_MD_TRUNCATE | - LNET_MD_MANAGE_REMOTE; - md.user_ptr = NULL; - md.eq_handle = the_lnet.ln_ping_target_eq; - - rc = LNetMDAttach(meh, md, - LNET_RETAIN, - &the_lnet.ln_ping_target_md); - if (rc) { - CERROR("Can't attach ping MD: %d\n", rc); - goto failed_2; - } - - return 0; - - failed_2: - rc2 = LNetMEUnlink(meh); - LASSERT(!rc2); - failed_1: - rc2 = LNetEQFree(the_lnet.ln_ping_target_eq); - LASSERT(!rc2); - failed_0: - lnet_destroy_ping_info(); - return rc; -} - -void -lnet_ping_target_fini(void) -{ - lnet_event_t event; - int rc; - int which; - int timeout_ms = 1000; - sigset_t blocked = cfs_block_allsigs(); - - LNetMDUnlink(the_lnet.ln_ping_target_md); - /* NB md could be busy; this just starts the unlink */ - - for (;;) { - rc = LNetEQPoll(&the_lnet.ln_ping_target_eq, 1, - timeout_ms, &event, &which); - - /* I expect overflow... */ - LASSERT(rc >= 0 || rc == -EOVERFLOW); - - if (!rc) { - /* timed out: provide a diagnostic */ - CWARN("Still waiting for ping MD to unlink\n"); - timeout_ms *= 2; - continue; - } - - /* Got a valid event */ - if (event.unlinked) - break; - } - - rc = LNetEQFree(the_lnet.ln_ping_target_eq); - LASSERT(!rc); - lnet_destroy_ping_info(); - cfs_restore_sigs(blocked); -} - static int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, int n_ids) { @@ -1674,7 +2127,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, int unlinked = 0; int replied = 0; const int a_long_time = 60000; /* mS */ - int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); + int infosz; lnet_ping_info_t *info; lnet_process_id_t tmpid; int i; @@ -1683,6 +2136,8 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, int rc2; sigset_t blocked; + infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); + if (n_ids <= 0 || id.nid == LNET_NID_ANY || timeout_ms > 500000 || /* arbitrary limit! */ @@ -1690,7 +2145,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, return -EINVAL; if (id.pid == LNET_PID_ANY) - id.pid = LUSTRE_SRV_LNET_PID; + id.pid = LNET_PID_LUSTRE; LIBCFS_ALLOC(info, infosz); if (!info) diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index e817eb3..8c80625 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -77,7 +77,7 @@ lnet_issep(char c) } } -static int +int lnet_net_unique(__u32 net, struct list_head *nilist) { struct list_head *tmp; @@ -96,6 +96,8 @@ lnet_net_unique(__u32 net, struct list_head *nilist) void lnet_ni_free(struct lnet_ni *ni) { + int i; + if (ni->ni_refs) cfs_percpt_free(ni->ni_refs); @@ -105,10 +107,14 @@ lnet_ni_free(struct lnet_ni *ni) if (ni->ni_cpts) cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts); + for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++) { + LIBCFS_FREE(ni->ni_interfaces[i], + strlen(ni->ni_interfaces[i]) + 1); + } LIBCFS_FREE(ni, sizeof(*ni)); } -static lnet_ni_t * +lnet_ni_t * lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) { struct lnet_tx_queue *tq; @@ -178,13 +184,19 @@ int lnet_parse_networks(struct list_head *nilist, char *networks) { struct cfs_expr_list *el = NULL; - int tokensize = strlen(networks) + 1; + int tokensize; char *tokens; char *str; char *tmp; struct lnet_ni *ni; __u32 net; int nnets = 0; + struct list_head *temp_node; + + if (!networks) { + CERROR("networks string is undefined\n"); + return -EINVAL; + } if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) { /* _WAY_ conservative */ @@ -193,23 +205,18 @@ lnet_parse_networks(struct list_head *nilist, char *networks) return -EINVAL; } + tokensize = strlen(networks) + 1; + LIBCFS_ALLOC(tokens, tokensize); if (!tokens) { CERROR("Can't allocate net tokens\n"); return -ENOMEM; } - the_lnet.ln_network_tokens = tokens; - the_lnet.ln_network_tokens_nob = tokensize; memcpy(tokens, networks, tokensize); tmp = tokens; str = tokens; - /* Add in the loopback network */ - ni = lnet_ni_alloc(LNET_MKNET(LOLND, 0), NULL, nilist); - if (!ni) - goto failed; - while (str && *str) { char *comma = strchr(str, ','); char *bracket = strchr(str, '('); @@ -283,7 +290,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks) goto failed_syntax; } - nnets++; ni = lnet_ni_alloc(net, el, nilist); if (!ni) goto failed; @@ -321,7 +327,23 @@ lnet_parse_networks(struct list_head *nilist, char *networks) goto failed; } - ni->ni_interfaces[niface++] = iface; + /* + * Allocate a separate piece of memory and copy + * into it the string, so we don't have + * a depencency on the tokens string. This way we + * can free the tokens at the end of the function. + * The newly allocated ni_interfaces[] can be + * freed when freeing the NI + */ + LIBCFS_ALLOC(ni->ni_interfaces[niface], + strlen(iface) + 1); + if (!ni->ni_interfaces[niface]) { + CERROR("Can't allocate net interface name\n"); + goto failed; + } + strncpy(ni->ni_interfaces[niface], iface, + strlen(iface)); + niface++; iface = comma; } while (iface); @@ -345,8 +367,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks) } } - LASSERT(!list_empty(nilist)); - return 0; + list_for_each(temp_node, nilist) + nnets++; + + LIBCFS_FREE(tokens, tokensize); + return nnets; failed_syntax: lnet_syntax("networks", networks, (int)(tmp - tokens), strlen(tmp)); @@ -362,7 +387,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks) cfs_expr_list_free(el); LIBCFS_FREE(tokens, tokensize); - the_lnet.ln_network_tokens = NULL; return -EINVAL; } @@ -745,7 +769,7 @@ lnet_parse_route(char *str, int *im_a_router) } rc = lnet_add_route(net, hops, nid, priority); - if (rc) { + if (rc && rc != -EEXIST && rc != -EHOSTUNREACH) { CERROR("Can't create route to %s via %s\n", libcfs_net2str(net), libcfs_nid2str(nid)); diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index b8f248e..042e974 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -72,7 +72,6 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, { lnet_eq_t *eq; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); /* @@ -167,7 +166,6 @@ LNetEQFree(lnet_handle_eq_t eqh) int size = 0; int i; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); lnet_res_lock(LNET_LOCK_EX); @@ -383,7 +381,6 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, int rc; int i; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (neq < 1) diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index f26bb03..c74514f 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -281,7 +281,6 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, int cpt; int rc; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (lnet_md_validate(&umd)) @@ -360,7 +359,6 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) int cpt; int rc; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (lnet_md_validate(&umd)) @@ -435,7 +433,6 @@ LNetMDUnlink(lnet_handle_md_t mdh) lnet_libmd_t *md; int cpt; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); cpt = lnet_cpt_of_cookie(mdh.cookie); diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 3c59c88..e671aed 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -83,7 +83,6 @@ LNetMEAttach(unsigned int portal, struct lnet_me *me; struct list_head *head; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if ((int)portal >= the_lnet.ln_nportals) @@ -156,7 +155,6 @@ LNetMEInsert(lnet_handle_me_t current_meh, struct lnet_portal *ptl; int cpt; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (pos == LNET_INS_LOCAL) @@ -233,7 +231,6 @@ LNetMEUnlink(lnet_handle_me_t meh) lnet_event_t ev; int cpt; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); cpt = lnet_cpt_of_cookie(meh.cookie); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 8f16913..7bc3e91 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -42,6 +42,11 @@ #include "../../include/linux/lnet/lib-lnet.h" +/** lnet message has credit and can be submitted to lnd for send/receive */ +#define LNET_CREDIT_OK 0 +/** lnet message is waiting for credit */ +#define LNET_CREDIT_WAIT 1 + static int local_nid_dist_zero = 1; module_param(local_nid_dist_zero, int, 0444); MODULE_PARM_DESC(local_nid_dist_zero, "Reserved"); @@ -54,8 +59,6 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) struct list_head *next; struct list_head cull; - LASSERT(the_lnet.ln_init); - /* NB: use lnet_net_lock(0) to serialize operations on test peers */ if (threshold) { /* Adding a new entry */ @@ -786,10 +789,10 @@ lnet_peer_alive_locked(lnet_peer_t *lp) * lnet_send() is going to lnet_net_unlock immediately after this, so * it sets do_send FALSE and I don't do the unlock/send/lock bit. * - * \retval 0 If \a msg sent or OK to send. - * \retval EAGAIN If \a msg blocked for credit. - * \retval EHOSTUNREACH If the next hop of the message appears dead. - * \retval ECANCELED If the MD of the message has been unlinked. + * \retval LNET_CREDIT_OK If \a msg sent or OK to send. + * \retval LNET_CREDIT_WAIT If \a msg blocked for credit. + * \retval -EHOSTUNREACH If the next hop of the message appears dead. + * \retval -ECANCELED If the MD of the message has been unlinked. */ static int lnet_post_send_locked(lnet_msg_t *msg, int do_send) @@ -817,7 +820,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) lnet_finalize(ni, msg, -EHOSTUNREACH); lnet_net_lock(cpt); - return EHOSTUNREACH; + return -EHOSTUNREACH; } if (msg->msg_md && @@ -830,7 +833,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) lnet_finalize(ni, msg, -ECANCELED); lnet_net_lock(cpt); - return ECANCELED; + return -ECANCELED; } if (!msg->msg_peertxcredit) { @@ -847,7 +850,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) if (lp->lp_txcredits < 0) { msg->msg_tx_delayed = 1; list_add_tail(&msg->msg_list, &lp->lp_txq); - return EAGAIN; + return LNET_CREDIT_WAIT; } } @@ -864,7 +867,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) if (tq->tq_credits < 0) { msg->msg_tx_delayed = 1; list_add_tail(&msg->msg_list, &tq->tq_delayed); - return EAGAIN; + return LNET_CREDIT_WAIT; } } @@ -873,7 +876,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) lnet_ni_send(ni, msg); lnet_net_lock(cpt); } - return 0; + return LNET_CREDIT_OK; } static lnet_rtrbufpool_t * @@ -901,8 +904,9 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) { /* * lnet_parse is going to lnet_net_unlock immediately after this, so it - * sets do_recv FALSE and I don't do the unlock/send/lock bit. I - * return EAGAIN if msg blocked and 0 if received or OK to receive + * sets do_recv FALSE and I don't do the unlock/send/lock bit. + * I return LNET_CREDIT_WAIT if msg blocked and LNET_CREDIT_OK if + * received or OK to receive */ lnet_peer_t *lp = msg->msg_rxpeer; lnet_rtrbufpool_t *rbp; @@ -932,16 +936,13 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) LASSERT(msg->msg_rx_ready_delay); msg->msg_rx_delayed = 1; list_add_tail(&msg->msg_list, &lp->lp_rtrq); - return EAGAIN; + return LNET_CREDIT_WAIT; } } rbp = lnet_msg2bufpool(msg); if (!msg->msg_rtrcredit) { - LASSERT((rbp->rbp_credits < 0) == - !list_empty(&rbp->rbp_msgs)); - msg->msg_rtrcredit = 1; rbp->rbp_credits--; if (rbp->rbp_credits < rbp->rbp_mincredits) @@ -952,7 +953,7 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) LASSERT(msg->msg_rx_ready_delay); msg->msg_rx_delayed = 1; list_add_tail(&msg->msg_list, &rbp->rbp_msgs); - return EAGAIN; + return LNET_CREDIT_WAIT; } } @@ -971,7 +972,7 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) 0, msg->msg_len, msg->msg_len); lnet_net_lock(cpt); } - return 0; + return LNET_CREDIT_OK; } void @@ -1033,6 +1034,43 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg) } void +lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp) +{ + lnet_msg_t *msg; + + if (list_empty(&rbp->rbp_msgs)) + return; + msg = list_entry(rbp->rbp_msgs.next, + lnet_msg_t, msg_list); + list_del(&msg->msg_list); + + (void)lnet_post_routed_recv_locked(msg, 1); +} + +void +lnet_drop_routed_msgs_locked(struct list_head *list, int cpt) +{ + struct list_head drop; + lnet_msg_t *msg; + lnet_msg_t *tmp; + + INIT_LIST_HEAD(&drop); + + list_splice_init(list, &drop); + + lnet_net_unlock(cpt); + + list_for_each_entry_safe(msg, tmp, &drop, msg_list) { + lnet_ni_recv(msg->msg_rxpeer->lp_ni, msg->msg_private, NULL, + 0, 0, 0, msg->msg_hdr.payload_length); + list_del_init(&msg->msg_list); + lnet_finalize(NULL, msg, -ECANCELED); + } + + lnet_net_lock(cpt); +} + +void lnet_return_rx_credits_locked(lnet_msg_t *msg) { lnet_peer_t *rxpeer = msg->msg_rxpeer; @@ -1052,27 +1090,42 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg) rb = list_entry(msg->msg_kiov, lnet_rtrbuf_t, rb_kiov[0]); rbp = rb->rb_pool; - LASSERT(rbp == lnet_msg2bufpool(msg)); msg->msg_kiov = NULL; msg->msg_rtrcredit = 0; - LASSERT((rbp->rbp_credits < 0) == - !list_empty(&rbp->rbp_msgs)); + LASSERT(rbp == lnet_msg2bufpool(msg)); + LASSERT((rbp->rbp_credits > 0) == !list_empty(&rbp->rbp_bufs)); - list_add(&rb->rb_list, &rbp->rbp_bufs); - rbp->rbp_credits++; - if (rbp->rbp_credits <= 0) { - msg2 = list_entry(rbp->rbp_msgs.next, - lnet_msg_t, msg_list); - list_del(&msg2->msg_list); + /* + * If routing is now turned off, we just drop this buffer and + * don't bother trying to return credits. + */ + if (!the_lnet.ln_routing) { + lnet_destroy_rtrbuf(rb, rbp->rbp_npages); + goto routing_off; + } - (void) lnet_post_routed_recv_locked(msg2, 1); + /* + * It is possible that a user has lowered the desired number of + * buffers in this pool. Make sure we never put back + * more buffers than the stated number. + */ + if (unlikely(rbp->rbp_credits >= rbp->rbp_req_nbuffers)) { + /* Discard this buffer so we don't have too many. */ + lnet_destroy_rtrbuf(rb, rbp->rbp_npages); + rbp->rbp_nbuffers--; + } else { + list_add(&rb->rb_list, &rbp->rbp_bufs); + rbp->rbp_credits++; + if (rbp->rbp_credits <= 0) + lnet_schedule_blocked_locked(rbp); } } +routing_off: if (msg->msg_peerrtrcredit) { /* give back peer router credits */ msg->msg_peerrtrcredit = 0; @@ -1081,7 +1134,14 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg) !list_empty(&rxpeer->lp_rtrq)); rxpeer->lp_rtrcredits++; - if (rxpeer->lp_rtrcredits <= 0) { + /* + * drop all messages which are queued to be routed on that + * peer. + */ + if (!the_lnet.ln_routing) { + lnet_drop_routed_msgs_locked(&rxpeer->lp_rtrq, + msg->msg_rx_cpt); + } else if (rxpeer->lp_rtrcredits <= 0) { msg2 = list_entry(rxpeer->lp_rtrq.next, lnet_msg_t, msg_list); list_del(&msg2->msg_list); @@ -1135,9 +1195,9 @@ static lnet_peer_t * lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) { lnet_remotenet_t *rnet; - lnet_route_t *rtr; - lnet_route_t *rtr_best; - lnet_route_t *rtr_last; + lnet_route_t *route; + lnet_route_t *best_route; + lnet_route_t *last_route; struct lnet_peer *lp_best; struct lnet_peer *lp; int rc; @@ -1151,14 +1211,12 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) return NULL; lp_best = NULL; - rtr_best = NULL; - rtr_last = NULL; - list_for_each_entry(rtr, &rnet->lrn_routes, lr_list) { - lp = rtr->lr_gateway; - - if (!lp->lp_alive || /* gateway is down */ - ((lp->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) && - rtr->lr_downis)) /* NI to target is down */ + best_route = NULL; + last_route = NULL; + list_for_each_entry(route, &rnet->lrn_routes, lr_list) { + lp = route->lr_gateway; + + if (!lnet_is_route_alive(route)) continue; if (ni && lp->lp_ni != ni) @@ -1168,21 +1226,21 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) return lp; if (!lp_best) { - rtr_best = rtr; - rtr_last = rtr; + best_route = route; + last_route = route; lp_best = lp; continue; } /* no protection on below fields, but it's harmless */ - if (rtr_last->lr_seq - rtr->lr_seq < 0) - rtr_last = rtr; + if (last_route->lr_seq - route->lr_seq < 0) + last_route = route; - rc = lnet_compare_routes(rtr, rtr_best); + rc = lnet_compare_routes(route, best_route); if (rc < 0) continue; - rtr_best = rtr; + best_route = route; lp_best = lp; } @@ -1191,8 +1249,8 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) * so we can round-robin all routers, it's race and inaccurate but * harmless and functional */ - if (rtr_best) - rtr_best->lr_seq = rtr_last->lr_seq + 1; + if (best_route) + best_route->lr_seq = last_route->lr_seq + 1; return lp_best; } @@ -1348,7 +1406,7 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) msg->msg_target_is_router = 1; msg->msg_target.nid = lp->lp_nid; - msg->msg_target.pid = LUSTRE_SRV_LNET_PID; + msg->msg_target.pid = LNET_PID_LUSTRE; } /* 'lp' is our best choice of peer */ @@ -1362,13 +1420,13 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) rc = lnet_post_send_locked(msg, 0); lnet_net_unlock(cpt); - if (rc == EHOSTUNREACH || rc == ECANCELED) - return -rc; + if (rc < 0) + return rc; - if (!rc) + if (rc == LNET_CREDIT_OK) lnet_ni_send(src_ni, msg); - return 0; /* !rc or EAGAIN */ + return 0; /* rc == LNET_CREDIT_OK or LNET_CREDIT_WAIT */ } static void @@ -1632,11 +1690,19 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) return 0; } +/** + * \retval LNET_CREDIT_OK If \a msg is forwarded + * \retval LNET_CREDIT_WAIT If \a msg is blocked because w/o buffer + * \retval -ve error code + */ static int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg) { int rc = 0; + if (!the_lnet.ln_routing) + return -ECANCELED; + if (msg->msg_rxpeer->lp_rtrcredits <= 0 || lnet_msg2bufpool(msg)->rbp_credits <= 0) { if (!ni->ni_lnd->lnd_eager_recv) { @@ -1790,9 +1856,8 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, if (the_lnet.ln_routing && ni->ni_last_alive != ktime_get_real_seconds()) { - lnet_ni_lock(ni); - /* NB: so far here is the only place to set NI status to "up */ + lnet_ni_lock(ni); ni->ni_last_alive = ktime_get_real_seconds(); if (ni->ni_status && ni->ni_status->ns_status == LNET_NI_STATUS_DOWN) @@ -1923,7 +1988,8 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, if (rc < 0) goto free_drop; - if (!rc) { + + if (rc == LNET_CREDIT_OK) { lnet_ni_recv(ni, msg->msg_private, msg, 0, 0, payload_length, payload_length); } @@ -2095,7 +2161,6 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack, int cpt; int rc; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */ @@ -2189,17 +2254,17 @@ lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg) LASSERT(!getmsg->msg_target_is_router); LASSERT(!getmsg->msg_routing); - cpt = lnet_cpt_of_cookie(getmd->md_lh.lh_cookie); - lnet_res_lock(cpt); - - LASSERT(getmd->md_refcount > 0); - if (!msg) { CERROR("%s: Dropping REPLY from %s: can't allocate msg\n", libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id)); goto drop; } + cpt = lnet_cpt_of_cookie(getmd->md_lh.lh_cookie); + lnet_res_lock(cpt); + + LASSERT(getmd->md_refcount > 0); + if (!getmd->md_threshold) { CERROR("%s: Dropping REPLY from %s for inactive MD %p\n", libcfs_nid2str(ni->ni_nid), libcfs_id2str(peer_id), @@ -2300,7 +2365,6 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh, int cpt; int rc; - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */ @@ -2400,7 +2464,6 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) * keep order 0 free for 0@lo and order 1 free for a local NID * match */ - LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); cpt = lnet_net_lock_current(); diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 749e76a..c372390 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -571,35 +571,17 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container) sizeof(*container->msc_finalizers)); container->msc_finalizers = NULL; } -#ifdef LNET_USE_LIB_FREELIST - lnet_freelist_fini(&container->msc_freelist); -#endif container->msc_init = 0; } int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt) { - int rc; - container->msc_init = 1; INIT_LIST_HEAD(&container->msc_active); INIT_LIST_HEAD(&container->msc_finalizing); -#ifdef LNET_USE_LIB_FREELIST - memset(&container->msc_freelist, 0, sizeof(lnet_freelist_t)); - - rc = lnet_freelist_init(&container->msc_freelist, - LNET_FL_MAX_MSGS, sizeof(lnet_msg_t)); - if (rc) { - CERROR("Failed to init freelist for message container\n"); - lnet_msg_container_cleanup(container); - return rc; - } -#else - rc = 0; -#endif /* number of CPUs */ container->msc_nfinalizers = cfs_cpt_weight(lnet_cpt_table(), cpt); @@ -613,7 +595,7 @@ lnet_msg_container_setup(struct lnet_msg_container *container, int cpt) return -ENOMEM; } - return rc; + return 0; } void diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 0cdeea9..0281c6a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* @@ -902,17 +897,8 @@ LNetSetLazyPortal(int portal) } EXPORT_SYMBOL(LNetSetLazyPortal); -/** - * Turn off the lazy portal attribute. Delayed requests on the portal, - * if any, will be all dropped when this function returns. - * - * \param portal Index of the portal to disable the lazy attribute on. - * - * \retval 0 On success. - * \retval -EINVAL If \a portal is not a valid index. - */ int -LNetClearLazyPortal(int portal) +lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason) { struct lnet_portal *ptl; LIST_HEAD(zombies); @@ -931,21 +917,48 @@ LNetClearLazyPortal(int portal) return 0; } - if (the_lnet.ln_shutdown) - CWARN("Active lazy portal %d on exit\n", portal); - else - CDEBUG(D_NET, "clearing portal %d lazy\n", portal); + if (ni) { + struct lnet_msg *msg, *tmp; + + /* grab all messages which are on the NI passed in */ + list_for_each_entry_safe(msg, tmp, &ptl->ptl_msg_delayed, + msg_list) { + if (msg->msg_rxpeer->lp_ni == ni) + list_move(&msg->msg_list, &zombies); + } + } else { + if (the_lnet.ln_shutdown) + CWARN("Active lazy portal %d on exit\n", portal); + else + CDEBUG(D_NET, "clearing portal %d lazy\n", portal); - /* grab all the blocked messages atomically */ - list_splice_init(&ptl->ptl_msg_delayed, &zombies); + /* grab all the blocked messages atomically */ + list_splice_init(&ptl->ptl_msg_delayed, &zombies); - lnet_ptl_unsetopt(ptl, LNET_PTL_LAZY); + lnet_ptl_unsetopt(ptl, LNET_PTL_LAZY); + } lnet_ptl_unlock(ptl); lnet_res_unlock(LNET_LOCK_EX); - lnet_drop_delayed_msg_list(&zombies, "Clearing lazy portal attr"); + lnet_drop_delayed_msg_list(&zombies, reason); return 0; } + +/** + * Turn off the lazy portal attribute. Delayed requests on the portal, + * if any, will be all dropped when this function returns. + * + * \param portal Index of the portal to disable the lazy attribute on. + * + * \retval 0 On success. + * \retval -EINVAL If \a portal is not a valid index. + */ +int +LNetClearLazyPortal(int portal) +{ + return lnet_clear_lazy_portal(NULL, portal, + "Clearing lazy portal attr"); +} EXPORT_SYMBOL(LNetClearLazyPortal); diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 53dd0bd..88905d5 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -514,7 +514,6 @@ lnet_sock_listen(struct socket **sockp, __u32 local_ip, int local_port, sock_release(*sockp); return rc; } -EXPORT_SYMBOL(lnet_sock_listen); int lnet_sock_accept(struct socket **newsockp, struct socket *sock) @@ -558,7 +557,6 @@ failed: sock_release(newsock); return rc; } -EXPORT_SYMBOL(lnet_sock_accept); int lnet_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip, @@ -596,4 +594,3 @@ lnet_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip, sock_release(*sockp); return rc; } -EXPORT_SYMBOL(lnet_sock_connect); diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index cd37303..e12fe37 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -36,6 +36,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" +#include "../../include/linux/lnet/lib-dlc.h" static int config_on_load; module_param(config_on_load, int, 0444); @@ -52,13 +53,21 @@ lnet_configure(void *arg) mutex_lock(&lnet_config_mutex); if (!the_lnet.ln_niinit_self) { - rc = LNetNIInit(LUSTRE_SRV_LNET_PID); + rc = try_module_get(THIS_MODULE); + + if (rc != 1) + goto out; + + rc = LNetNIInit(LNET_PID_LUSTRE); if (rc >= 0) { the_lnet.ln_niinit_self = 1; rc = 0; + } else { + module_put(THIS_MODULE); } } +out: mutex_unlock(&lnet_config_mutex); return rc; } @@ -73,6 +82,7 @@ lnet_unconfigure(void) if (the_lnet.ln_niinit_self) { the_lnet.ln_niinit_self = 0; LNetNIFini(); + module_put(THIS_MODULE); } mutex_lock(&the_lnet.ln_api_mutex); @@ -84,17 +94,80 @@ lnet_unconfigure(void) } static int -lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) +lnet_dyn_configure(struct libcfs_ioctl_hdr *hdr) +{ + struct lnet_ioctl_config_data *conf = + (struct lnet_ioctl_config_data *)hdr; + int rc; + + if (conf->cfg_hdr.ioc_len < sizeof(*conf)) + return -EINVAL; + + mutex_lock(&lnet_config_mutex); + if (!the_lnet.ln_niinit_self) { + rc = -EINVAL; + goto out_unlock; + } + rc = lnet_dyn_add_ni(LNET_PID_LUSTRE, + conf->cfg_config_u.cfg_net.net_intf, + conf->cfg_config_u.cfg_net.net_peer_timeout, + conf->cfg_config_u.cfg_net.net_peer_tx_credits, + conf->cfg_config_u.cfg_net.net_peer_rtr_credits, + conf->cfg_config_u.cfg_net.net_max_tx_credits); +out_unlock: + mutex_unlock(&lnet_config_mutex); + + return rc; +} + +static int +lnet_dyn_unconfigure(struct libcfs_ioctl_hdr *hdr) +{ + struct lnet_ioctl_config_data *conf = + (struct lnet_ioctl_config_data *)hdr; + int rc; + + if (conf->cfg_hdr.ioc_len < sizeof(*conf)) + return -EINVAL; + + mutex_lock(&lnet_config_mutex); + if (!the_lnet.ln_niinit_self) { + rc = -EINVAL; + goto out_unlock; + } + rc = lnet_dyn_del_ni(conf->cfg_net); +out_unlock: + mutex_unlock(&lnet_config_mutex); + + return rc; +} + +static int +lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) { int rc; switch (cmd) { - case IOC_LIBCFS_CONFIGURE: + case IOC_LIBCFS_CONFIGURE: { + struct libcfs_ioctl_data *data = + (struct libcfs_ioctl_data *)hdr; + + if (data->ioc_hdr.ioc_len < sizeof(*data)) + return -EINVAL; + + the_lnet.ln_nis_from_mod_params = data->ioc_flags; return lnet_configure(NULL); + } case IOC_LIBCFS_UNCONFIGURE: return lnet_unconfigure(); + case IOC_LIBCFS_ADD_NET: + return lnet_dyn_configure(hdr); + + case IOC_LIBCFS_DEL_NET: + return lnet_dyn_unconfigure(hdr); + default: /* * Passing LNET_PID_ANY only gives me a ref if the net is up @@ -103,7 +176,7 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) */ rc = LNetNIInit(LNET_PID_ANY); if (rc >= 0) { - rc = LNetCtl(cmd, data); + rc = LNetCtl(cmd, hdr); LNetNIFini(); } return rc; diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 00086ee..19c80c9 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" +#include "../../include/linux/lnet/lib-dlc.h" int lnet_peer_tables_create(void) @@ -103,62 +104,116 @@ lnet_peer_tables_destroy(void) the_lnet.ln_peer_tables = NULL; } +static void +lnet_peer_table_cleanup_locked(lnet_ni_t *ni, struct lnet_peer_table *ptable) +{ + int i; + lnet_peer_t *lp; + lnet_peer_t *tmp; + + for (i = 0; i < LNET_PEER_HASH_SIZE; i++) { + list_for_each_entry_safe(lp, tmp, &ptable->pt_hash[i], + lp_hashlist) { + if (ni && ni != lp->lp_ni) + continue; + list_del_init(&lp->lp_hashlist); + /* Lose hash table's ref */ + ptable->pt_zombies++; + lnet_peer_decref_locked(lp); + } + } +} + +static void +lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable, + int cpt_locked) +{ + int i; + + for (i = 3; ptable->pt_zombies; i++) { + lnet_net_unlock(cpt_locked); + + if (is_power_of_2(i)) { + CDEBUG(D_WARNING, + "Waiting for %d zombies on peer table\n", + ptable->pt_zombies); + } + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(cfs_time_seconds(1) >> 1); + lnet_net_lock(cpt_locked); + } +} + +static void +lnet_peer_table_del_rtrs_locked(lnet_ni_t *ni, struct lnet_peer_table *ptable, + int cpt_locked) +{ + lnet_peer_t *lp; + lnet_peer_t *tmp; + lnet_nid_t lp_nid; + int i; + + for (i = 0; i < LNET_PEER_HASH_SIZE; i++) { + list_for_each_entry_safe(lp, tmp, &ptable->pt_hash[i], + lp_hashlist) { + if (ni != lp->lp_ni) + continue; + + if (!lp->lp_rtr_refcount) + continue; + + lp_nid = lp->lp_nid; + + lnet_net_unlock(cpt_locked); + lnet_del_route(LNET_NIDNET(LNET_NID_ANY), lp_nid); + lnet_net_lock(cpt_locked); + } + } +} + void -lnet_peer_tables_cleanup(void) +lnet_peer_tables_cleanup(lnet_ni_t *ni) { struct lnet_peer_table *ptable; + struct list_head deathrow; + lnet_peer_t *lp; int i; - int j; - LASSERT(the_lnet.ln_shutdown); /* i.e. no new peers */ + INIT_LIST_HEAD(&deathrow); + LASSERT(the_lnet.ln_shutdown || ni); + /* + * If just deleting the peers for a NI, get rid of any routes these + * peers are gateways for. + */ cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { lnet_net_lock(i); - - for (j = 0; j < LNET_PEER_HASH_SIZE; j++) { - struct list_head *peers = &ptable->pt_hash[j]; - - while (!list_empty(peers)) { - lnet_peer_t *lp = list_entry(peers->next, - lnet_peer_t, - lp_hashlist); - list_del_init(&lp->lp_hashlist); - /* lose hash table's ref */ - lnet_peer_decref_locked(lp); - } - } - + lnet_peer_table_del_rtrs_locked(ni, ptable, i); lnet_net_unlock(i); } + /* + * Start the process of moving the applicable peers to + * deathrow. + */ cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { - LIST_HEAD(deathrow); - lnet_peer_t *lp; - lnet_net_lock(i); + lnet_peer_table_cleanup_locked(ni, ptable); + lnet_net_unlock(i); + } - for (j = 3; ptable->pt_number; j++) { - lnet_net_unlock(i); - - if (!(j & (j - 1))) { - CDEBUG(D_WARNING, - "Waiting for %d peers on peer table\n", - ptable->pt_number); - } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(cfs_time_seconds(1) / 2); - lnet_net_lock(i); - } + /* Cleanup all entries on deathrow. */ + cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { + lnet_net_lock(i); + lnet_peer_table_deathrow_wait_locked(ptable, i); list_splice_init(&ptable->pt_deathrow, &deathrow); - lnet_net_unlock(i); + } - while (!list_empty(&deathrow)) { - lp = list_entry(deathrow.next, - lnet_peer_t, lp_hashlist); - list_del(&lp->lp_hashlist); - LIBCFS_FREE(lp, sizeof(*lp)); - } + while (!list_empty(&deathrow)) { + lp = list_entry(deathrow.next, lnet_peer_t, lp_hashlist); + list_del(&lp->lp_hashlist); + LIBCFS_FREE(lp, sizeof(*lp)); } } @@ -181,6 +236,8 @@ lnet_destroy_peer_locked(lnet_peer_t *lp) lp->lp_ni = NULL; list_add(&lp->lp_hashlist, &ptable->pt_deathrow); + LASSERT(ptable->pt_zombies > 0); + ptable->pt_zombies--; } lnet_peer_t * @@ -336,3 +393,65 @@ lnet_debug_peer(lnet_nid_t nid) lnet_net_unlock(cpt); } + +int +lnet_get_peer_info(__u32 peer_index, __u64 *nid, + char aliveness[LNET_MAX_STR_LEN], + __u32 *cpt_iter, __u32 *refcount, + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits, + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credits, + __u32 *peer_tx_qnob) +{ + struct lnet_peer_table *peer_table; + lnet_peer_t *lp; + bool found = false; + int lncpt, j; + + /* get the number of CPTs */ + lncpt = cfs_percpt_number(the_lnet.ln_peer_tables); + + /* + * if the cpt number to be examined is >= the number of cpts in + * the system then indicate that there are no more cpts to examin + */ + if (*cpt_iter >= lncpt) + return -ENOENT; + + /* get the current table */ + peer_table = the_lnet.ln_peer_tables[*cpt_iter]; + /* if the ptable is NULL then there are no more cpts to examine */ + if (!peer_table) + return -ENOENT; + + lnet_net_lock(*cpt_iter); + + for (j = 0; j < LNET_PEER_HASH_SIZE && !found; j++) { + struct list_head *peers = &peer_table->pt_hash[j]; + + list_for_each_entry(lp, peers, lp_hashlist) { + if (peer_index-- > 0) + continue; + + snprintf(aliveness, LNET_MAX_STR_LEN, "NA"); + if (lnet_isrouter(lp) || + lnet_peer_aliveness_enabled(lp)) + snprintf(aliveness, LNET_MAX_STR_LEN, + lp->lp_alive ? "up" : "down"); + + *nid = lp->lp_nid; + *refcount = lp->lp_refcount; + *ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits; + *peer_tx_credits = lp->lp_txcredits; + *peer_rtr_credits = lp->lp_rtrcredits; + *peer_min_rtr_credits = lp->lp_mintxcredits; + *peer_tx_qnob = lp->lp_txqnob; + + found = true; + } + } + lnet_net_unlock(*cpt_iter); + + *cpt_iter = lncpt; + + return found ? 0 : -ENOENT; +} diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 735a8f2..5e8b0ba 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * */ #define DEBUG_SUBSYSTEM S_LNET @@ -28,8 +24,11 @@ #define LNET_NRB_TINY (LNET_NRB_TINY_MIN * 4) #define LNET_NRB_SMALL_MIN 4096 /* min value for each CPT */ #define LNET_NRB_SMALL (LNET_NRB_SMALL_MIN * 4) +#define LNET_NRB_SMALL_PAGES 1 #define LNET_NRB_LARGE_MIN 256 /* min value for each CPT */ #define LNET_NRB_LARGE (LNET_NRB_LARGE_MIN * 4) +#define LNET_NRB_LARGE_PAGES ((LNET_MTU + PAGE_CACHE_SIZE - 1) >> \ + PAGE_CACHE_SHIFT) static char *forwarding = ""; module_param(forwarding, charp, 0444); @@ -318,7 +317,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, return -EINVAL; if (lnet_islocalnet(net)) /* it's a local network */ - return 0; /* ignore the route entry */ + return -EEXIST; /* Assume net, route, all new */ LIBCFS_ALLOC(route, sizeof(*route)); @@ -349,7 +348,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, LIBCFS_FREE(rnet, sizeof(*rnet)); if (rc == -EHOSTUNREACH) /* gateway is not on a local net */ - return 0; /* ignore the route entry */ + return rc; /* ignore the route entry */ CERROR("Error %d creating route %s %d %s\n", rc, libcfs_net2str(net), hops, libcfs_nid2str(gateway)); @@ -396,14 +395,20 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, /* -1 for notify or !add_route */ lnet_peer_decref_locked(route->lr_gateway); lnet_net_unlock(LNET_LOCK_EX); + rc = 0; - if (!add_route) + if (!add_route) { + rc = -EEXIST; LIBCFS_FREE(route, sizeof(*route)); + } if (rnet != rnet2) LIBCFS_FREE(rnet, sizeof(*rnet)); - return 0; + /* indicate to startup the router checker if configured */ + wake_up(&the_lnet.ln_rc_waitq); + + return rc; } int @@ -543,6 +548,38 @@ lnet_destroy_routes(void) lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY); } +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) +{ + int i, rc = -ENOENT, j; + + if (!the_lnet.ln_rtrpools) + return rc; + + for (i = 0; i < LNET_NRBPOOLS; i++) { + lnet_rtrbufpool_t *rbp; + + lnet_net_lock(LNET_LOCK_EX); + cfs_percpt_for_each(rbp, j, the_lnet.ln_rtrpools) { + if (i++ != idx) + continue; + + pool_cfg->pl_pools[i].pl_npages = rbp[i].rbp_npages; + pool_cfg->pl_pools[i].pl_nbuffers = rbp[i].rbp_nbuffers; + pool_cfg->pl_pools[i].pl_credits = rbp[i].rbp_credits; + pool_cfg->pl_pools[i].pl_mincredits = rbp[i].rbp_mincredits; + rc = 0; + break; + } + lnet_net_unlock(LNET_LOCK_EX); + } + + lnet_net_lock(LNET_LOCK_EX); + pool_cfg->pl_routing = the_lnet.ln_routing; + lnet_net_unlock(LNET_LOCK_EX); + + return rc; +} + int lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, __u32 *alive, __u32 *priority) @@ -570,7 +607,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, *hops = route->lr_hops; *priority = route->lr_priority; *gateway = route->lr_gateway->lp_nid; - *alive = route->lr_gateway->lp_alive; + *alive = lnet_is_route_alive(route); lnet_net_unlock(cpt); return 0; } @@ -608,7 +645,7 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) { lnet_ping_info_t *info = rcd->rcd_pinginfo; struct lnet_peer *gw = rcd->rcd_gateway; - lnet_route_t *rtr; + lnet_route_t *rte; if (!gw->lp_alive) return; @@ -634,12 +671,16 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) if (!(gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS)) return; /* can't carry NI status info */ - list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) { - int ptl_status = LNET_NI_STATUS_INVALID; + list_for_each_entry(rte, &gw->lp_routes, lr_gwlist) { int down = 0; int up = 0; int i; + if (gw->lp_ping_feats & LNET_PING_FEAT_RTE_DISABLED) { + rte->lr_downis = 1; + continue; + } + for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) { lnet_ni_status_t *stat = &info->pi_ni[i]; lnet_nid_t nid = stat->ns_nid; @@ -655,24 +696,15 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) continue; if (stat->ns_status == LNET_NI_STATUS_DOWN) { - if (LNET_NETTYP(LNET_NIDNET(nid)) != PTLLND) - down++; - else if (ptl_status != LNET_NI_STATUS_UP) - ptl_status = LNET_NI_STATUS_DOWN; + down++; continue; } if (stat->ns_status == LNET_NI_STATUS_UP) { - if (LNET_NIDNET(nid) == rtr->lr_net) { + if (LNET_NIDNET(nid) == rte->lr_net) { up = 1; break; } - /* - * ptl NIs are considered down only when - * they're all down - */ - if (LNET_NETTYP(LNET_NIDNET(nid)) == PTLLND) - ptl_status = LNET_NI_STATUS_UP; continue; } @@ -683,10 +715,10 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) } if (up) { /* ignore downed NIs if NI for dest network is up */ - rtr->lr_downis = 0; + rte->lr_downis = 0; continue; } - rtr->lr_downis = down + (ptl_status == LNET_NI_STATUS_DOWN); + rte->lr_downis = down; } } @@ -985,7 +1017,7 @@ lnet_ping_router_locked(lnet_peer_t *rtr) lnet_handle_md_t mdh; id.nid = rtr->lp_nid; - id.pid = LUSTRE_SRV_LNET_PID; + id.pid = LNET_PID_LUSTRE; CDEBUG(D_NET, "Check: %s\n", libcfs_id2str(id)); rtr->lp_ping_notsent = 1; @@ -1014,8 +1046,9 @@ lnet_ping_router_locked(lnet_peer_t *rtr) int lnet_router_checker_start(void) { + struct task_struct *task; int rc; - int eqsz; + int eqsz = 0; LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN); @@ -1025,28 +1058,18 @@ lnet_router_checker_start(void) return -EINVAL; } - if (!the_lnet.ln_routing && - live_router_check_interval <= 0 && - dead_router_check_interval <= 0) - return 0; - sema_init(&the_lnet.ln_rc_signal, 0); - /* - * EQ size doesn't matter; the callback is guaranteed to get every - * event - */ - eqsz = 0; - rc = LNetEQAlloc(eqsz, lnet_router_checker_event, - &the_lnet.ln_rc_eqh); + + rc = LNetEQAlloc(0, lnet_router_checker_event, &the_lnet.ln_rc_eqh); if (rc) { CERROR("Can't allocate EQ(%d): %d\n", eqsz, rc); return -ENOMEM; } the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING; - rc = PTR_ERR(kthread_run(lnet_router_checker, - NULL, "router_checker")); - if (IS_ERR_VALUE(rc)) { + task = kthread_run(lnet_router_checker, NULL, "router_checker"); + if (IS_ERR(task)) { + rc = PTR_ERR(task); CERROR("Can't start router checker thread: %d\n", rc); /* block until event callback signals exit */ down(&the_lnet.ln_rc_signal); @@ -1078,6 +1101,8 @@ lnet_router_checker_stop(void) LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); the_lnet.ln_rc_state = LNET_RC_STATE_STOPPING; + /* wakeup the RC thread if it's sleeping */ + wake_up(&the_lnet.ln_rc_waitq); /* block until event callback signals exit */ down(&the_lnet.ln_rc_signal); @@ -1168,6 +1193,33 @@ lnet_prune_rc_data(int wait_unlink) lnet_net_unlock(LNET_LOCK_EX); } +/* + * This function is called to check if the RC should block indefinitely. + * It's called from lnet_router_checker() as well as being passed to + * wait_event_interruptible() to avoid the lost wake_up problem. + * + * When it's called from wait_event_interruptible() it is necessary to + * also not sleep if the rc state is not running to avoid a deadlock + * when the system is shutting down + */ +static inline bool +lnet_router_checker_active(void) +{ + if (the_lnet.ln_rc_state != LNET_RC_STATE_RUNNING) + return true; + + /* + * Router Checker thread needs to run when routing is enabled in + * order to call lnet_update_ni_status_locked() + */ + if (the_lnet.ln_routing) + return true; + + return !list_empty(&the_lnet.ln_routers) && + (live_router_check_interval > 0 || + dead_router_check_interval > 0); +} + static int lnet_router_checker(void *arg) { @@ -1176,8 +1228,6 @@ lnet_router_checker(void *arg) cfs_block_allsigs(); - LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); - while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) { __u64 version; int cpt; @@ -1221,12 +1271,20 @@ rescan: * because kernel counts # active tasks as nr_running * + nr_uninterruptible. */ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(cfs_time_seconds(1)); + /* + * if there are any routes then wakeup every second. If + * there are no routes then sleep indefinitely until woken + * up by a user adding a route + */ + if (!lnet_router_checker_active()) + wait_event_interruptible(the_lnet.ln_rc_waitq, + lnet_router_checker_active()); + else + wait_event_interruptible_timeout(the_lnet.ln_rc_waitq, + false, + cfs_time_seconds(1)); } - LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING); - lnet_prune_rc_data(1); /* wait for UNLINK */ the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; @@ -1235,7 +1293,7 @@ rescan: return 0; } -static void +void lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) { int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); @@ -1282,67 +1340,119 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) } static void -lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp) +lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp, int cpt) { int npages = rbp->rbp_npages; - int nbuffers = 0; + struct list_head tmp; lnet_rtrbuf_t *rb; if (!rbp->rbp_nbuffers) /* not initialized or already freed */ return; - LASSERT(list_empty(&rbp->rbp_msgs)); - LASSERT(rbp->rbp_credits == rbp->rbp_nbuffers); + INIT_LIST_HEAD(&tmp); - while (!list_empty(&rbp->rbp_bufs)) { - LASSERT(rbp->rbp_credits > 0); + lnet_net_lock(cpt); + lnet_drop_routed_msgs_locked(&rbp->rbp_msgs, cpt); + list_splice_init(&rbp->rbp_bufs, &tmp); + rbp->rbp_req_nbuffers = 0; + rbp->rbp_nbuffers = 0; + rbp->rbp_credits = 0; + rbp->rbp_mincredits = 0; + lnet_net_unlock(cpt); - rb = list_entry(rbp->rbp_bufs.next, - lnet_rtrbuf_t, rb_list); + /* Free buffers on the free list. */ + while (!list_empty(&tmp)) { + rb = list_entry(tmp.next, lnet_rtrbuf_t, rb_list); list_del(&rb->rb_list); lnet_destroy_rtrbuf(rb, npages); - nbuffers++; } - - LASSERT(rbp->rbp_nbuffers == nbuffers); - LASSERT(rbp->rbp_credits == nbuffers); - - rbp->rbp_nbuffers = 0; - rbp->rbp_credits = 0; } static int -lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) +lnet_rtrpool_adjust_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) { + struct list_head rb_list; lnet_rtrbuf_t *rb; - int i; + int num_rb; + int num_buffers = 0; + int old_req_nbufs; + int npages = rbp->rbp_npages; - if (rbp->rbp_nbuffers) { - LASSERT(rbp->rbp_nbuffers == nbufs); + lnet_net_lock(cpt); + /* + * If we are called for less buffers than already in the pool, we + * just lower the req_nbuffers number and excess buffers will be + * thrown away as they are returned to the free list. Credits + * then get adjusted as well. + * If we already have enough buffers allocated to serve the + * increase requested, then we can treat that the same way as we + * do the decrease. + */ + num_rb = nbufs - rbp->rbp_nbuffers; + if (nbufs <= rbp->rbp_req_nbuffers || num_rb <= 0) { + rbp->rbp_req_nbuffers = nbufs; + lnet_net_unlock(cpt); return 0; } + /* + * store the older value of rbp_req_nbuffers and then set it to + * the new request to prevent lnet_return_rx_credits_locked() from + * freeing buffers that we need to keep around + */ + old_req_nbufs = rbp->rbp_req_nbuffers; + rbp->rbp_req_nbuffers = nbufs; + lnet_net_unlock(cpt); - for (i = 0; i < nbufs; i++) { - rb = lnet_new_rtrbuf(rbp, cpt); + INIT_LIST_HEAD(&rb_list); + /* + * allocate the buffers on a local list first. If all buffers are + * allocated successfully then join this list to the rbp buffer + * list. If not then free all allocated buffers. + */ + while (num_rb-- > 0) { + rb = lnet_new_rtrbuf(rbp, cpt); if (!rb) { - CERROR("Failed to allocate %d router bufs of %d pages\n", - nbufs, rbp->rbp_npages); - return -ENOMEM; - } + CERROR("Failed to allocate %d route bufs of %d pages\n", + nbufs, npages); + + lnet_net_lock(cpt); + rbp->rbp_req_nbuffers = old_req_nbufs; + lnet_net_unlock(cpt); - rbp->rbp_nbuffers++; - rbp->rbp_credits++; - rbp->rbp_mincredits++; - list_add(&rb->rb_list, &rbp->rbp_bufs); + goto failed; + } - /* No allocation "under fire" */ - /* Otherwise we'd need code to schedule blocked msgs etc */ - LASSERT(!the_lnet.ln_routing); + list_add(&rb->rb_list, &rb_list); + num_buffers++; } - LASSERT(rbp->rbp_credits == nbufs); + lnet_net_lock(cpt); + + list_splice_tail(&rb_list, &rbp->rbp_bufs); + rbp->rbp_nbuffers += num_buffers; + rbp->rbp_credits += num_buffers; + rbp->rbp_mincredits = rbp->rbp_credits; + /* + * We need to schedule blocked msg using the newly + * added buffers. + */ + while (!list_empty(&rbp->rbp_bufs) && + !list_empty(&rbp->rbp_msgs)) + lnet_schedule_blocked_locked(rbp); + + lnet_net_unlock(cpt); + return 0; + +failed: + while (!list_empty(&rb_list)) { + rb = list_entry(rb_list.next, lnet_rtrbuf_t, rb_list); + list_del(&rb->rb_list); + lnet_destroy_rtrbuf(rb, npages); + } + + return -ENOMEM; } static void @@ -1357,7 +1467,7 @@ lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages) } void -lnet_rtrpools_free(void) +lnet_rtrpools_free(int keep_pools) { lnet_rtrbufpool_t *rtrp; int i; @@ -1366,17 +1476,19 @@ lnet_rtrpools_free(void) return; cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { - lnet_rtrpool_free_bufs(&rtrp[0]); - lnet_rtrpool_free_bufs(&rtrp[1]); - lnet_rtrpool_free_bufs(&rtrp[2]); + lnet_rtrpool_free_bufs(&rtrp[LNET_TINY_BUF_IDX], i); + lnet_rtrpool_free_bufs(&rtrp[LNET_SMALL_BUF_IDX], i); + lnet_rtrpool_free_bufs(&rtrp[LNET_LARGE_BUF_IDX], i); } - cfs_percpt_free(the_lnet.ln_rtrpools); - the_lnet.ln_rtrpools = NULL; + if (!keep_pools) { + cfs_percpt_free(the_lnet.ln_rtrpools); + the_lnet.ln_rtrpools = NULL; + } } static int -lnet_nrb_tiny_calculate(int npages) +lnet_nrb_tiny_calculate(void) { int nrbs = LNET_NRB_TINY; @@ -1395,7 +1507,7 @@ lnet_nrb_tiny_calculate(int npages) } static int -lnet_nrb_small_calculate(int npages) +lnet_nrb_small_calculate(void) { int nrbs = LNET_NRB_SMALL; @@ -1414,7 +1526,7 @@ lnet_nrb_small_calculate(int npages) } static int -lnet_nrb_large_calculate(int npages) +lnet_nrb_large_calculate(void) { int nrbs = LNET_NRB_LARGE; @@ -1436,16 +1548,12 @@ int lnet_rtrpools_alloc(int im_a_router) { lnet_rtrbufpool_t *rtrp; - int large_pages; - int small_pages = 1; int nrb_tiny; int nrb_small; int nrb_large; int rc; int i; - large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (!strcmp(forwarding, "")) { /* not set either way */ if (!im_a_router) @@ -1460,15 +1568,15 @@ lnet_rtrpools_alloc(int im_a_router) return -EINVAL; } - nrb_tiny = lnet_nrb_tiny_calculate(0); + nrb_tiny = lnet_nrb_tiny_calculate(); if (nrb_tiny < 0) return -EINVAL; - nrb_small = lnet_nrb_small_calculate(small_pages); + nrb_small = lnet_nrb_small_calculate(); if (nrb_small < 0) return -EINVAL; - nrb_large = lnet_nrb_large_calculate(large_pages); + nrb_large = lnet_nrb_large_calculate(); if (nrb_large < 0) return -EINVAL; @@ -1482,18 +1590,23 @@ lnet_rtrpools_alloc(int im_a_router) } cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { - lnet_rtrpool_init(&rtrp[0], 0); - rc = lnet_rtrpool_alloc_bufs(&rtrp[0], nrb_tiny, i); + lnet_rtrpool_init(&rtrp[LNET_TINY_BUF_IDX], 0); + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_TINY_BUF_IDX], + nrb_tiny, i); if (rc) goto failed; - lnet_rtrpool_init(&rtrp[1], small_pages); - rc = lnet_rtrpool_alloc_bufs(&rtrp[1], nrb_small, i); + lnet_rtrpool_init(&rtrp[LNET_SMALL_BUF_IDX], + LNET_NRB_SMALL_PAGES); + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_SMALL_BUF_IDX], + nrb_small, i); if (rc) goto failed; - lnet_rtrpool_init(&rtrp[2], large_pages); - rc = lnet_rtrpool_alloc_bufs(&rtrp[2], nrb_large, i); + lnet_rtrpool_init(&rtrp[LNET_LARGE_BUF_IDX], + LNET_NRB_LARGE_PAGES); + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_LARGE_BUF_IDX], + nrb_large, i); if (rc) goto failed; } @@ -1505,10 +1618,118 @@ lnet_rtrpools_alloc(int im_a_router) return 0; failed: - lnet_rtrpools_free(); + lnet_rtrpools_free(0); return rc; } +static int +lnet_rtrpools_adjust_helper(int tiny, int small, int large) +{ + int nrb = 0; + int rc = 0; + int i; + lnet_rtrbufpool_t *rtrp; + + /* + * If the provided values for each buffer pool are different than the + * configured values, we need to take action. + */ + if (tiny >= 0) { + tiny_router_buffers = tiny; + nrb = lnet_nrb_tiny_calculate(); + cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_TINY_BUF_IDX], + nrb, i); + if (rc) + return rc; + } + } + if (small >= 0) { + small_router_buffers = small; + nrb = lnet_nrb_small_calculate(); + cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_SMALL_BUF_IDX], + nrb, i); + if (rc) + return rc; + } + } + if (large >= 0) { + large_router_buffers = large; + nrb = lnet_nrb_large_calculate(); + cfs_percpt_for_each(rtrp, i, the_lnet.ln_rtrpools) { + rc = lnet_rtrpool_adjust_bufs(&rtrp[LNET_LARGE_BUF_IDX], + nrb, i); + if (rc) + return rc; + } + } + + return 0; +} + +int +lnet_rtrpools_adjust(int tiny, int small, int large) +{ + /* + * this function doesn't revert the changes if adding new buffers + * failed. It's up to the user space caller to revert the + * changes. + */ + if (!the_lnet.ln_routing) + return 0; + + return lnet_rtrpools_adjust_helper(tiny, small, large); +} + +int +lnet_rtrpools_enable(void) +{ + int rc; + + if (the_lnet.ln_routing) + return 0; + + if (!the_lnet.ln_rtrpools) + /* + * If routing is turned off, and we have never + * initialized the pools before, just call the + * standard buffer pool allocation routine as + * if we are just configuring this for the first + * time. + */ + return lnet_rtrpools_alloc(1); + + rc = lnet_rtrpools_adjust_helper(0, 0, 0); + if (rc) + return rc; + + lnet_net_lock(LNET_LOCK_EX); + the_lnet.ln_routing = 1; + + the_lnet.ln_ping_info->pi_features &= ~LNET_PING_FEAT_RTE_DISABLED; + lnet_net_unlock(LNET_LOCK_EX); + + return 0; +} + +void +lnet_rtrpools_disable(void) +{ + if (!the_lnet.ln_routing) + return; + + lnet_net_lock(LNET_LOCK_EX); + the_lnet.ln_routing = 0; + the_lnet.ln_ping_info->pi_features |= LNET_PING_FEAT_RTE_DISABLED; + + tiny_router_buffers = 0; + small_router_buffers = 0; + large_router_buffers = 0; + lnet_net_unlock(LNET_LOCK_EX); + lnet_rtrpools_free(1); +} + int lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) { diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index a7aaf0c..fc643df 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Portals; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * */ #define DEBUG_SUBSYSTEM S_LNET @@ -242,7 +238,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, unsigned int hops = route->lr_hops; unsigned int priority = route->lr_priority; lnet_nid_t nid = route->lr_gateway->lp_nid; - int alive = route->lr_gateway->lp_alive; + int alive = lnet_is_route_alive(route); s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4u %8u %7s %s\n", @@ -804,8 +800,6 @@ static struct lnet_portal_rotors portal_rotors[] = { }, }; -extern int portal_rotor; - static int __proc_lnet_portal_rotor(void *data, int write, loff_t pos, void __user *buffer, int nob) { diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 210e24e..90b7771 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -801,15 +801,20 @@ out: } int -lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data) +lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) { char *buf; - int opc = data->ioc_u32[0]; + struct libcfs_ioctl_data *data; + int opc; int rc; if (cmd != IOC_LIBCFS_LNETST) return -EINVAL; + data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); + + opc = data->ioc_u32[0]; + if (data->ioc_plen1 > PAGE_CACHE_SIZE) return -EINVAL; diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 54fb1ab..e8ca1bf 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -58,7 +58,7 @@ do { \ (p)->nle_nnode++; \ } while (0) -lstcon_session_t console_session; +struct lstcon_session console_session; static void lstcon_node_get(lstcon_node_t *nd) @@ -1693,8 +1693,6 @@ lstcon_new_session_id(lst_sid_t *sid) sid->ses_stamp = cfs_time_current(); } -extern srpc_service_t lstcon_acceptor_service; - int lstcon_session_new(char *name, int key, unsigned feats, int timeout, int force, lst_sid_t __user *sid_up) @@ -1973,7 +1971,7 @@ out: return rc; } -srpc_service_t lstcon_acceptor_service; +static srpc_service_t lstcon_acceptor_service; static void lstcon_init_acceptor_service(void) { /* initialize selftest console acceptor service table */ @@ -1983,7 +1981,7 @@ static void lstcon_init_acceptor_service(void) lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX; } -extern int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data); +extern int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr); static DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry); @@ -1994,7 +1992,7 @@ lstcon_console_init(void) int i; int rc; - memset(&console_session, 0, sizeof(lstcon_session_t)); + memset(&console_session, 0, sizeof(struct lstcon_session)); console_session.ses_id = LST_INVALID_SID; console_session.ses_state = LST_SESSION_NONE; diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index 5651b08..c9d1081 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -135,7 +135,7 @@ typedef struct lstcon_test { #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */ -typedef struct { +struct lstcon_session { struct mutex ses_mutex; /* only 1 thread in session */ lst_sid_t ses_id; /* global session id */ int ses_key; /* local session key */ @@ -165,9 +165,9 @@ typedef struct { spinlock_t ses_rpc_lock; /* serialize */ atomic_t ses_rpc_counter; /* # of initialized RPCs */ struct list_head ses_rpc_freelist; /* idle console rpc */ -} lstcon_session_t; /* session descriptor */ +}; /* session descriptor */ -extern lstcon_session_t console_session; +extern struct lstcon_session console_session; static inline lstcon_trans_stat_t * lstcon_trans_stat(void) @@ -184,7 +184,6 @@ lstcon_id2hash(lnet_process_id_t id, struct list_head *hash) } int lstcon_console_init(void); -int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data); int lstcon_console_fini(void); int lstcon_session_match(lst_sid_t sid); int lstcon_session_new(char *name, int key, unsigned version, diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 7eca046..3bbc720 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -1629,16 +1629,6 @@ static srpc_service_t sfw_services[] = { } }; -extern sfw_test_client_ops_t ping_test_client; -extern srpc_service_t ping_test_service; -extern void ping_init_test_client(void); -extern void ping_init_test_service(void); - -extern sfw_test_client_ops_t brw_test_client; -extern srpc_service_t brw_test_service; -extern void brw_init_test_client(void); -extern void brw_init_test_service(void); - int sfw_startup(void) { diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index c4bf442..cbb7884 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -37,6 +37,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "selftest.h" +#include "console.h" enum { LST_INIT_NONE = 0, @@ -47,9 +48,6 @@ enum { LST_INIT_CONSOLE }; -extern int lstcon_console_init(void); -extern int lstcon_console_fini(void); - static int lst_init_step = LST_INIT_NONE; struct cfs_wi_sched *lst_sched_serial; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index f95fd9b..1b76933 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -1097,7 +1097,7 @@ srpc_client_rpc_expired(void *data) spin_unlock(&srpc_data.rpc_glock); } -inline void +static void srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc) { stt_timer_t *timer = &rpc->crpc_timer; @@ -1612,7 +1612,7 @@ srpc_startup(void) srpc_data.rpc_state = SRPC_STATE_NONE; - rc = LNetNIInit(LUSTRE_SRV_LNET_PID); + rc = LNetNIInit(LNET_PID_LUSTRE); if (rc < 0) { CERROR("LNetNIInit() has failed: %d\n", rc); return rc; diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index ff8f38d..70400aa 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -68,7 +68,7 @@ static int seq_client_rpc(struct lu_client_seq *seq, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, LUSTRE_MDS_VERSION, SEQ_QUERY); - if (req == NULL) + if (!req) return -ENOMEM; /* Init operation code */ @@ -95,7 +95,8 @@ static int seq_client_rpc(struct lu_client_seq *seq, * precreating objects on this OST), and it will send the * request to MDT0 here, so we can not keep resending the * request here, otherwise if MDT0 is failed(umounted), - * it can not release the export of MDT0 */ + * it can not release the export of MDT0 + */ if (seq->lcs_type == LUSTRE_SEQ_DATA) req->rq_no_delay = req->rq_no_resend = 1; debug_mask = D_CONSOLE; @@ -152,7 +153,8 @@ static int seq_client_alloc_meta(const struct lu_env *env, /* If meta server return -EINPROGRESS or EAGAIN, * it means meta server might not be ready to * allocate super sequence from sequence controller - * (MDT0)yet */ + * (MDT0)yet + */ rc = seq_client_rpc(seq, &seq->lcs_space, SEQ_ALLOC_META, "meta"); } while (rc == -EINPROGRESS || rc == -EAGAIN); @@ -226,8 +228,8 @@ int seq_client_alloc_fid(const struct lu_env *env, wait_queue_t link; int rc; - LASSERT(seq != NULL); - LASSERT(fid != NULL); + LASSERT(seq); + LASSERT(fid); init_waitqueue_entry(&link, current); mutex_lock(&seq->lcs_mutex); @@ -292,7 +294,7 @@ void seq_client_flush(struct lu_client_seq *seq) { wait_queue_t link; - LASSERT(seq != NULL); + LASSERT(seq); init_waitqueue_entry(&link, current); mutex_lock(&seq->lcs_mutex); @@ -375,8 +377,8 @@ static int seq_client_init(struct lu_client_seq *seq, { int rc; - LASSERT(seq != NULL); - LASSERT(prefix != NULL); + LASSERT(seq); + LASSERT(prefix); seq->lcs_type = type; @@ -438,7 +440,7 @@ int client_fid_fini(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; - if (cli->cl_seq != NULL) { + if (cli->cl_seq) { seq_client_fini(cli->cl_seq); kfree(cli->cl_seq); cli->cl_seq = NULL; diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 0320b6e..1f0e786 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -66,7 +66,7 @@ ldebugfs_fid_write_common(const char __user *buffer, size_t count, int rc; char kernbuf[MAX_FID_RANGE_STRLEN]; - LASSERT(range != NULL); + LASSERT(range); if (count >= sizeof(kernbuf)) return -EINVAL; @@ -104,7 +104,6 @@ ldebugfs_fid_space_seq_write(struct file *file, int rc; seq = ((struct seq_file *)file->private_data)->private; - LASSERT(seq != NULL); mutex_lock(&seq->lcs_mutex); rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space); @@ -124,8 +123,6 @@ ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; - LASSERT(seq != NULL); - mutex_lock(&seq->lcs_mutex); seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space)); mutex_unlock(&seq->lcs_mutex); @@ -143,7 +140,6 @@ ldebugfs_fid_width_seq_write(struct file *file, int rc, val; seq = ((struct seq_file *)file->private_data)->private; - LASSERT(seq != NULL); rc = lprocfs_write_helper(buffer, count, &val); if (rc) @@ -172,8 +168,6 @@ ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; - LASSERT(seq != NULL); - mutex_lock(&seq->lcs_mutex); seq_printf(m, "%llu\n", seq->lcs_width); mutex_unlock(&seq->lcs_mutex); @@ -186,8 +180,6 @@ ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; - LASSERT(seq != NULL); - mutex_lock(&seq->lcs_mutex); seq_printf(m, DFID "\n", PFID(&seq->lcs_fid)); mutex_unlock(&seq->lcs_mutex); @@ -201,9 +193,7 @@ ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused) struct lu_client_seq *seq = (struct lu_client_seq *)m->private; struct client_obd *cli; - LASSERT(seq != NULL); - - if (seq->lcs_exp != NULL) { + if (seq->lcs_exp) { cli = &seq->lcs_exp->exp_obd->u.cli; seq_printf(m, "%s\n", cli->cl_target_uuid.uuid); } diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index d9459e5..2b09b76 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -65,7 +65,7 @@ struct fld_cache *fld_cache_init(const char *name, { struct fld_cache *cache; - LASSERT(name != NULL); + LASSERT(name); LASSERT(cache_threshold < cache_size); cache = kzalloc(sizeof(*cache), GFP_NOFS); @@ -100,7 +100,7 @@ void fld_cache_fini(struct fld_cache *cache) { __u64 pct; - LASSERT(cache != NULL); + LASSERT(cache); fld_cache_flush(cache); if (cache->fci_stat.fst_count > 0) { @@ -183,7 +183,8 @@ restart_fixup: } /* we could have overlap over next - * range too. better restart. */ + * range too. better restart. + */ goto restart_fixup; } @@ -218,8 +219,6 @@ static int fld_cache_shrink(struct fld_cache *cache) struct list_head *curr; int num = 0; - LASSERT(cache != NULL); - if (cache->fci_cache_count < cache->fci_cache_size) return 0; @@ -304,7 +303,8 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, const u32 mdt = range->lsr_index; /* this is overlap case, these case are checking overlapping with - * prev range only. fixup will handle overlapping with next range. */ + * prev range only. fixup will handle overlapping with next range. + */ if (f_curr->fce_range.lsr_index == mdt) { f_curr->fce_range.lsr_start = min(f_curr->fce_range.lsr_start, @@ -319,7 +319,8 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, } else if (new_start <= f_curr->fce_range.lsr_start && f_curr->fce_range.lsr_end <= new_end) { /* case 1: new range completely overshadowed existing range. - * e.g. whole range migrated. update fld cache entry */ + * e.g. whole range migrated. update fld cache entry + */ f_curr->fce_range = *range; kfree(f_new); @@ -414,7 +415,7 @@ static int fld_cache_insert_nolock(struct fld_cache *cache, } } - if (prev == NULL) + if (!prev) prev = head; CDEBUG(D_INFO, "insert range "DRANGE"\n", PRANGE(&f_new->fce_range)); @@ -499,7 +500,7 @@ int fld_cache_lookup(struct fld_cache *cache, cache->fci_stat.fst_count++; list_for_each_entry(flde, head, fce_list) { if (flde->fce_range.lsr_start > seq) { - if (prev != NULL) + if (prev) *range = prev->fce_range; break; } diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 12eb164..e8a3caf 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -58,22 +58,16 @@ struct fld_stats { __u64 fst_inflight; }; -typedef int (*fld_hash_func_t) (struct lu_client_fld *, __u64); - -typedef struct lu_fld_target * -(*fld_scan_func_t) (struct lu_client_fld *, __u64); - struct lu_fld_hash { const char *fh_name; - fld_hash_func_t fh_hash_func; - fld_scan_func_t fh_scan_func; + int (*fh_hash_func)(struct lu_client_fld *, __u64); + struct lu_fld_target *(*fh_scan_func)(struct lu_client_fld *, __u64); }; struct fld_cache_entry { struct list_head fce_lru; struct list_head fce_list; - /** - * fld cache entries are sorted on range->lsr_start field. */ + /** fld cache entries are sorted on range->lsr_start field. */ struct lu_seq_range fce_range; }; @@ -84,32 +78,25 @@ struct fld_cache { */ rwlock_t fci_lock; - /** - * Cache shrink threshold */ + /** Cache shrink threshold */ int fci_threshold; - /** - * Preferred number of cached entries */ + /** Preferred number of cached entries */ int fci_cache_size; - /** - * Current number of cached entries. Protected by \a fci_lock */ + /** Current number of cached entries. Protected by \a fci_lock */ int fci_cache_count; - /** - * LRU list fld entries. */ + /** LRU list fld entries. */ struct list_head fci_lru; - /** - * sorted fld entries. */ + /** sorted fld entries. */ struct list_head fci_entries_head; - /** - * Cache statistics. */ + /** Cache statistics. */ struct fld_stats fci_stat; - /** - * Cache name used for debug and messages. */ + /** Cache name used for debug and messages. */ char fci_name[LUSTRE_MDT_MAXNAMELEN]; unsigned int fci_no_shrink:1; }; @@ -169,7 +156,7 @@ struct fld_cache_entry static inline const char * fld_target_name(struct lu_fld_target *tar) { - if (tar->ft_srv != NULL) + if (tar->ft_srv) return tar->ft_srv->lsf_name; return (const char *)tar->ft_exp->exp_obd->obd_name; diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index d92c01b..b50a57b 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -58,7 +58,8 @@ #include "fld_internal.h" /* TODO: these 3 functions are copies of flow-control code from mdc_lib.c - * It should be common thing. The same about mdc RPC lock */ + * It should be common thing. The same about mdc RPC lock + */ static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; @@ -124,7 +125,8 @@ fld_rrb_scan(struct lu_client_fld *fld, u64 seq) * it should go to index 0 directly, instead of calculating * hash again, and also if other MDTs is not being connected, * the fld lookup requests(for seq on MDT0) should not be - * blocked because of other MDTs */ + * blocked because of other MDTs + */ if (fid_seq_is_norm(seq)) hash = fld_rrb_hash(fld, seq); else @@ -139,7 +141,8 @@ again: if (hash != 0) { /* It is possible the remote target(MDT) are not connected to * with client yet, so we will refer this to MDT0, which should - * be connected during mount */ + * be connected during mount + */ hash = 0; goto again; } @@ -148,9 +151,9 @@ again: fld->lcf_name, hash, seq, fld->lcf_count); list_for_each_entry(target, &fld->lcf_targets, ft_chain) { - const char *srv_name = target->ft_srv != NULL ? + const char *srv_name = target->ft_srv ? target->ft_srv->lsf_name : "<null>"; - const char *exp_name = target->ft_exp != NULL ? + const char *exp_name = target->ft_exp ? (char *)target->ft_exp->exp_obd->obd_uuid.uuid : "<null>"; @@ -183,13 +186,13 @@ fld_client_get_target(struct lu_client_fld *fld, u64 seq) { struct lu_fld_target *target; - LASSERT(fld->lcf_hash != NULL); + LASSERT(fld->lcf_hash); spin_lock(&fld->lcf_lock); target = fld->lcf_hash->fh_scan_func(fld, seq); spin_unlock(&fld->lcf_lock); - if (target != NULL) { + if (target) { CDEBUG(D_INFO, "%s: Found target (idx %llu) by seq %#llx\n", fld->lcf_name, target->ft_idx, seq); } @@ -207,10 +210,10 @@ int fld_client_add_target(struct lu_client_fld *fld, const char *name; struct lu_fld_target *target, *tmp; - LASSERT(tar != NULL); + LASSERT(tar); name = fld_target_name(tar); - LASSERT(name != NULL); - LASSERT(tar->ft_srv != NULL || tar->ft_exp != NULL); + LASSERT(name); + LASSERT(tar->ft_srv || tar->ft_exp); if (fld->lcf_flags != LUSTRE_FLD_INIT) { CERROR("%s: Attempt to add target %s (idx %llu) on fly - skip it\n", @@ -236,7 +239,7 @@ int fld_client_add_target(struct lu_client_fld *fld, } target->ft_exp = tar->ft_exp; - if (target->ft_exp != NULL) + if (target->ft_exp) class_export_get(target->ft_exp); target->ft_srv = tar->ft_srv; target->ft_idx = tar->ft_idx; @@ -264,7 +267,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) list_del(&target->ft_chain); spin_unlock(&fld->lcf_lock); - if (target->ft_exp != NULL) + if (target->ft_exp) class_export_put(target->ft_exp); kfree(target); @@ -326,8 +329,6 @@ int fld_client_init(struct lu_client_fld *fld, int cache_size, cache_threshold; int rc; - LASSERT(fld != NULL); - snprintf(fld->lcf_name, sizeof(fld->lcf_name), "cli-%s", prefix); @@ -379,13 +380,13 @@ void fld_client_fini(struct lu_client_fld *fld) &fld->lcf_targets, ft_chain) { fld->lcf_count--; list_del(&target->ft_chain); - if (target->ft_exp != NULL) + if (target->ft_exp) class_export_put(target->ft_exp); kfree(target); } spin_unlock(&fld->lcf_lock); - if (fld->lcf_cache != NULL) { + if (fld->lcf_cache) { if (!IS_ERR(fld->lcf_cache)) fld_cache_fini(fld->lcf_cache); fld->lcf_cache = NULL; @@ -402,12 +403,12 @@ int fld_client_rpc(struct obd_export *exp, int rc; struct obd_import *imp; - LASSERT(exp != NULL); + LASSERT(exp); imp = class_exp2cliimp(exp); req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY, LUSTRE_MDS_VERSION, FLD_QUERY); - if (req == NULL) + if (!req) return -ENOMEM; op = req_capsule_client_get(&req->rq_pill, &RMF_FLD_OPC); @@ -436,7 +437,7 @@ int fld_client_rpc(struct obd_export *exp, goto out_req; prange = req_capsule_server_get(&req->rq_pill, &RMF_FLD_MDFLD); - if (prange == NULL) { + if (!prange) { rc = -EFAULT; goto out_req; } @@ -463,7 +464,7 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, /* Can not find it in the cache */ target = fld_client_get_target(fld, seq); - LASSERT(target != NULL); + LASSERT(target); CDEBUG(D_INFO, "%s: Lookup fld entry (seq: %#llx) on target %s (idx %llu)\n", fld->lcf_name, seq, fld_target_name(target), target->ft_idx); diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index 41ceaa8..da31281 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -60,8 +60,6 @@ fld_debugfs_targets_seq_show(struct seq_file *m, void *unused) struct lu_client_fld *fld = (struct lu_client_fld *)m->private; struct lu_fld_target *target; - LASSERT(fld != NULL); - spin_lock(&fld->lcf_lock); list_for_each_entry(target, &fld->lcf_targets, ft_chain) @@ -76,8 +74,6 @@ fld_debugfs_hash_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; - LASSERT(fld != NULL); - spin_lock(&fld->lcf_lock); seq_printf(m, "%s\n", fld->lcf_hash->fh_name); spin_unlock(&fld->lcf_lock); @@ -102,9 +98,8 @@ fld_debugfs_hash_seq_write(struct file *file, return -EFAULT; fld = ((struct seq_file *)file->private_data)->private; - LASSERT(fld != NULL); - for (i = 0; fld_hash[i].fh_name != NULL; i++) { + for (i = 0; fld_hash[i].fh_name; i++) { if (count != strlen(fld_hash[i].fh_name)) continue; @@ -114,7 +109,7 @@ fld_debugfs_hash_seq_write(struct file *file, } } - if (hash != NULL) { + if (hash) { spin_lock(&fld->lcf_lock); fld->lcf_hash = hash; spin_unlock(&fld->lcf_lock); @@ -132,8 +127,6 @@ fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer, { struct lu_client_fld *fld = file->private_data; - LASSERT(fld != NULL); - fld_cache_flush(fld->lcf_cache); CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name); diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index bd7acc2..2a77ea2f8 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -157,7 +157,8 @@ struct cl_device { }; /** \addtogroup cl_object cl_object - * @{ */ + * @{ + */ /** * "Data attributes" of cl_object. Data attributes can be updated * independently for a sub-object, and top-object's attributes are calculated @@ -288,13 +289,14 @@ struct cl_object_conf { enum { /** configure layout, set up a new stripe, must be called while - * holding layout lock. */ + * holding layout lock. + */ OBJECT_CONF_SET = 0, /** invalidate the current stripe configuration due to losing - * layout lock. */ + * layout lock. + */ OBJECT_CONF_INVALIDATE = 1, - /** wait for old layout to go away so that new layout can be - * set up. */ + /** wait for old layout to go away so that new layout can be set up. */ OBJECT_CONF_WAIT = 2 }; @@ -393,7 +395,8 @@ struct cl_object_operations { */ struct cl_object_header { /** Standard lu_object_header. cl_object::co_lu::lo_header points - * here. */ + * here. + */ struct lu_object_header coh_lu; /** \name locks * \todo XXX move locks below to the separate cache-lines, they are @@ -464,7 +467,8 @@ struct cl_object_header { #define CL_PAGE_EOF ((pgoff_t)~0ull) /** \addtogroup cl_page cl_page - * @{ */ + * @{ + */ /** \struct cl_page * Layered client page. @@ -687,12 +691,14 @@ enum cl_page_state { enum cl_page_type { /** Host page, the page is from the host inode which the cl_page - * belongs to. */ + * belongs to. + */ CPT_CACHEABLE = 1, /** Transient page, the transient cl_page is used to bind a cl_page * to vmpage which is not belonging to the same object of cl_page. - * it is used in DirectIO, lockless IO and liblustre. */ + * it is used in DirectIO, lockless IO and liblustre. + */ CPT_TRANSIENT, }; @@ -728,7 +734,8 @@ struct cl_page { /** Parent page, NULL for top-level page. Immutable after creation. */ struct cl_page *cp_parent; /** Lower-layer page. NULL for bottommost page. Immutable after - * creation. */ + * creation. + */ struct cl_page *cp_child; /** * Page state. This field is const to avoid accidental update, it is @@ -1126,7 +1133,8 @@ static inline int __page_in_use(const struct cl_page *page, int refc) /** @} cl_page */ /** \addtogroup cl_lock cl_lock - * @{ */ + * @{ + */ /** \struct cl_lock * * Extent locking on the client. @@ -1641,7 +1649,8 @@ struct cl_lock { struct cl_lock_slice { struct cl_lock *cls_lock; /** Object slice corresponding to this lock slice. Immutable after - * creation. */ + * creation. + */ struct cl_object *cls_obj; const struct cl_lock_operations *cls_ops; /** Linkage into cl_lock::cll_layers. Immutable after creation. */ @@ -1885,7 +1894,8 @@ struct cl_2queue { /** @} cl_page_list */ /** \addtogroup cl_io cl_io - * @{ */ + * @{ + */ /** \struct cl_io * I/O * @@ -2284,7 +2294,8 @@ enum cl_fsync_mode { /** discard all of dirty pages in a specific file range */ CL_FSYNC_DISCARD = 2, /** start writeback and make sure they have reached storage before - * return. OST_SYNC RPC must be issued and finished */ + * return. OST_SYNC RPC must be issued and finished + */ CL_FSYNC_ALL = 3 }; @@ -2403,7 +2414,8 @@ struct cl_io { /** @} cl_io */ /** \addtogroup cl_req cl_req - * @{ */ + * @{ + */ /** \struct cl_req * Transfer. * @@ -2582,7 +2594,8 @@ enum cache_stats_item { /** how many entities are in the cache right now */ CS_total, /** how many entities in the cache are actively used (and cannot be - * evicted) right now */ + * evicted) right now + */ CS_busy, /** how many entities were created at all */ CS_create, @@ -2613,7 +2626,7 @@ struct cl_site { * Statistical counters. Atomics do not scale, something better like * per-cpu counters is needed. * - * These are exported as /proc/fs/lustre/llite/.../site + * These are exported as /sys/kernel/debug/lustre/llite/.../site * * When interpreting keep in mind that both sub-locks (and sub-pages) * and top-locks (and top-pages) are accounted here. @@ -2653,7 +2666,7 @@ static inline int lu_device_is_cl(const struct lu_device *d) static inline struct cl_device *lu2cl_dev(const struct lu_device *d) { - LASSERT(d == NULL || IS_ERR(d) || lu_device_is_cl(d)); + LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d)); return container_of0(d, struct cl_device, cd_lu_dev); } @@ -2664,7 +2677,7 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d) static inline struct cl_object *lu2cl(const struct lu_object *o) { - LASSERT(o == NULL || IS_ERR(o) || lu_device_is_cl(o->lo_dev)); + LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev)); return container_of0(o, struct cl_object, co_lu); } @@ -2681,7 +2694,7 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj) static inline struct cl_device *cl_object_device(const struct cl_object *o) { - LASSERT(o == NULL || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev)); + LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev)); return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev); } @@ -2725,7 +2738,8 @@ void cl_req_slice_add(struct cl_req *req, struct cl_req_slice *slice, /** @} helpers */ /** \defgroup cl_object cl_object - * @{ */ + * @{ + */ struct cl_object *cl_object_top (struct cl_object *o); struct cl_object *cl_object_find(const struct lu_env *env, struct cl_device *cd, const struct lu_fid *fid, @@ -2770,7 +2784,8 @@ static inline void *cl_object_page_slice(struct cl_object *clob, /** @} cl_object */ /** \defgroup cl_page cl_page - * @{ */ + * @{ + */ enum { CLP_GANG_OKAY = 0, CLP_GANG_RESCHED, @@ -2888,7 +2903,8 @@ void cl_lock_descr_print(const struct lu_env *env, void *cookie, /** @} cl_page */ /** \defgroup cl_lock cl_lock - * @{ */ + * @{ + */ struct cl_lock *cl_lock_hold(const struct lu_env *env, const struct cl_io *io, const struct cl_lock_descr *need, @@ -2966,7 +2982,8 @@ int cl_lock_enqueue_wait(const struct lu_env *env, struct cl_lock *lock, * * cl_use_try() NONE cl_lock_operations::clo_use() CLS_HELD * - * @{ */ + * @{ + */ int cl_wait (const struct lu_env *env, struct cl_lock *lock); void cl_unuse (const struct lu_env *env, struct cl_lock *lock); @@ -3019,7 +3036,8 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock); /** @} cl_lock */ /** \defgroup cl_io cl_io - * @{ */ + * @{ + */ int cl_io_init (const struct lu_env *env, struct cl_io *io, enum cl_io_type iot, struct cl_object *obj); @@ -3094,7 +3112,8 @@ do { \ /** @} cl_io */ /** \defgroup cl_page_list cl_page_list - * @{ */ + * @{ + */ /** * Last page in the page list. @@ -3137,7 +3156,8 @@ void cl_2queue_init_page(struct cl_2queue *queue, struct cl_page *page); /** @} cl_page_list */ /** \defgroup cl_req cl_req - * @{ */ + * @{ + */ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, enum cl_req_type crt, int nr_objects); @@ -3214,7 +3234,8 @@ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret); * - cl_env_reexit(cl_env_reenter had to be called priorly) * * \see lu_env, lu_context, lu_context_key - * @{ */ + * @{ + */ struct cl_env_nest { int cen_refcheck; diff --git a/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index 36e7a67..5d839a9 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/drivers/staging/lustre/lustre/include/lclient.h @@ -127,7 +127,7 @@ static inline struct ccc_thread_info *ccc_env_info(const struct lu_env *env) struct ccc_thread_info *info; info = lu_context_key_get(&env->le_ctx, &ccc_key); - LASSERT(info != NULL); + LASSERT(info); return info; } @@ -156,7 +156,7 @@ static inline struct ccc_session *ccc_env_session(const struct lu_env *env) struct ccc_session *ses; ses = lu_context_key_get(env->le_ses, &ccc_session_key); - LASSERT(ses != NULL); + LASSERT(ses); return ses; } @@ -383,7 +383,8 @@ void cl_put_grouplock(struct ccc_grouplock *cg); * * NB: If you find you have to use these interfaces for your new code, please * think about it again. These interfaces may be removed in the future for - * better layering. */ + * better layering. + */ struct lov_stripe_md *lov_lsm_get(struct cl_object *clobj); void lov_lsm_put(struct cl_object *clobj, struct lov_stripe_md *lsm); int lov_read_and_clear_async_rc(struct cl_object *clob); diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 468bc28..3907bf4 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -57,23 +57,23 @@ struct ll_iattr { #define CLIENT_OBD_LIST_LOCK_DEBUG 1 -typedef struct { +struct client_obd_lock { spinlock_t lock; unsigned long time; struct task_struct *task; const char *func; int line; -} client_obd_lock_t; +}; -static inline void __client_obd_list_lock(client_obd_lock_t *lock, +static inline void __client_obd_list_lock(struct client_obd_lock *lock, const char *func, int line) { unsigned long cur = jiffies; while (1) { if (spin_trylock(&lock->lock)) { - LASSERT(lock->task == NULL); + LASSERT(!lock->task); lock->task = current; lock->func = func; lock->line = line; @@ -85,7 +85,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, time_before(lock->time + 5 * HZ, jiffies)) { struct task_struct *task = lock->task; - if (task == NULL) + if (!task) continue; LCONSOLE_WARN("%s:%d: lock %p was acquired by <%s:%d:%s:%d> for %lu seconds.\n", @@ -106,20 +106,20 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, #define client_obd_list_lock(lock) \ __client_obd_list_lock(lock, __func__, __LINE__) -static inline void client_obd_list_unlock(client_obd_lock_t *lock) +static inline void client_obd_list_unlock(struct client_obd_lock *lock) { - LASSERT(lock->task != NULL); + LASSERT(lock->task); lock->task = NULL; lock->time = jiffies; spin_unlock(&lock->lock); } -static inline void client_obd_list_lock_init(client_obd_lock_t *lock) +static inline void client_obd_list_lock_init(struct client_obd_lock *lock) { spin_lock_init(&lock->lock); } -static inline void client_obd_list_lock_done(client_obd_lock_t *lock) +static inline void client_obd_list_lock_done(struct client_obd_lock *lock) {} #endif /* __LINUX_OBD_H */ diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index fb13094..0d98111 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -54,7 +54,7 @@ struct lprocfs_vars { struct file_operations *fops; void *data; /** - * /proc file mode. + * sysfs file mode. */ umode_t proc_mode; }; @@ -175,7 +175,8 @@ struct lprocfs_percpu { enum lprocfs_stats_flags { LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */ LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu - * area and need locking */ + * area and need locking + */ LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */ }; @@ -196,7 +197,8 @@ struct lprocfs_stats { unsigned short ls_biggest_alloc_num; enum lprocfs_stats_flags ls_flags; /* Lock used when there are no percpu stats areas; For percpu stats, - * it is used to protect ls_biggest_alloc_num change */ + * it is used to protect ls_biggest_alloc_num change + */ spinlock_t ls_lock; /* has ls_num of counter headers */ @@ -274,20 +276,7 @@ static inline int opcode_offset(__u32 opc) OPC_RANGE(OST)); } else if (opc < FLD_LAST_OPC) { /* FLD opcode */ - return (opc - FLD_FIRST_OPC + - OPC_RANGE(SEC) + - OPC_RANGE(SEQ) + - OPC_RANGE(QUOTA) + - OPC_RANGE(LLOG) + - OPC_RANGE(OBD) + - OPC_RANGE(MGS) + - OPC_RANGE(LDLM) + - OPC_RANGE(MDS) + - OPC_RANGE(OST)); - } else if (opc < UPDATE_LAST_OPC) { - /* update opcode */ - return (opc - UPDATE_FIRST_OPC + - OPC_RANGE(FLD) + + return (opc - FLD_FIRST_OPC + OPC_RANGE(SEC) + OPC_RANGE(SEQ) + OPC_RANGE(QUOTA) + @@ -312,8 +301,7 @@ static inline int opcode_offset(__u32 opc) OPC_RANGE(SEC) + \ OPC_RANGE(SEQ) + \ OPC_RANGE(SEC) + \ - OPC_RANGE(FLD) + \ - OPC_RANGE(UPDATE)) + OPC_RANGE(FLD)) #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \ OPC_RANGE(EXTRA)) @@ -407,7 +395,7 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc, } else { unsigned int cpuid = get_cpu(); - if (unlikely(stats->ls_percpu[cpuid] == NULL)) { + if (unlikely(!stats->ls_percpu[cpuid])) { rc = lprocfs_stats_alloc_one(stats, cpuid); if (rc < 0) { put_cpu(); @@ -521,11 +509,11 @@ static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, unsigned long flags = 0; __u64 ret = 0; - LASSERT(stats != NULL); + LASSERT(stats); num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); for (i = 0; i < num_cpu; i++) { - if (stats->ls_percpu[i] == NULL) + if (!stats->ls_percpu[i]) continue; ret += lprocfs_read_helper( lprocfs_stats_counter_get(stats, i, idx), @@ -625,9 +613,10 @@ int lprocfs_single_release(struct inode *, struct file *); int lprocfs_seq_release(struct inode *, struct file *); /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only - proc entries; otherwise, you will define name##_seq_write function also for - a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, - call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */ + * proc entries; otherwise, you will define name##_seq_write function also for + * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, + * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); + */ #define __LPROC_SEQ_FOPS(name, custom_seq_write) \ static int name##_single_open(struct inode *inode, struct file *file) \ { \ diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 0b22e5e..b5088b1 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -164,11 +164,12 @@ struct lu_device_operations { /** * For lu_object_conf flags */ -typedef enum { +enum loc_flags { /* This is a new object to be allocated, or the file - * corresponding to the object does not exists. */ + * corresponding to the object does not exists. + */ LOC_F_NEW = 0x00000001, -} loc_flags_t; +}; /** * Object configuration, describing particulars of object being created. On @@ -179,7 +180,7 @@ struct lu_object_conf { /** * Some hints for obj find and alloc. */ - loc_flags_t loc_flags; + enum loc_flags loc_flags; }; /** @@ -392,7 +393,7 @@ struct lu_device_type_operations { static inline int lu_device_is_md(const struct lu_device *d) { - return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD); + return ergo(d, d->ld_type->ldt_tags & LU_DEVICE_MD); } /** @@ -895,7 +896,8 @@ enum lu_xattr_flags { /** @} helpers */ /** \name lu_context - * @{ */ + * @{ + */ /** For lu_context health-checks */ enum lu_context_state { @@ -1119,7 +1121,7 @@ struct lu_context_key { CLASSERT(PAGE_CACHE_SIZE >= sizeof (*value)); \ \ value = kzalloc(sizeof(*value), GFP_NOFS); \ - if (value == NULL) \ + if (!value) \ value = ERR_PTR(-ENOMEM); \ \ return value; \ @@ -1174,7 +1176,7 @@ void lu_context_key_revive (struct lu_context_key *key); do { \ LU_CONTEXT_KEY_INIT(key); \ key = va_arg(args, struct lu_context_key *); \ - } while (key != NULL); \ + } while (key); \ va_end(args); \ } diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index 97cd157..f7dfd83 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/drivers/staging/lustre/lustre/include/lu_ref.h @@ -17,10 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * */ #ifndef __LUSTRE_LU_REF_H diff --git a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h index 09088f4..07d45de 100644 --- a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h +++ b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h @@ -47,9 +47,11 @@ struct ll_fiemap_extent { __u64 fe_logical; /* logical offset in bytes for the start of - * the extent from the beginning of the file */ + * the extent from the beginning of the file + */ __u64 fe_physical; /* physical offset in bytes for the start - * of the extent from the beginning of the disk */ + * of the extent from the beginning of the disk + */ __u64 fe_length; /* length in bytes for this extent */ __u64 fe_reserved64[2]; __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ @@ -59,9 +61,11 @@ struct ll_fiemap_extent { struct ll_user_fiemap { __u64 fm_start; /* logical offset (inclusive) at - * which to start mapping (in) */ + * which to start mapping (in) + */ __u64 fm_length; /* logical length of mapping which - * userspace wants (in) */ + * userspace wants (in) + */ __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */ __u32 fm_mapped_extents;/* number of extents that were mapped (out) */ __u32 fm_extent_count; /* size of fm_extents array (in) */ @@ -71,28 +75,38 @@ struct ll_user_fiemap { #define FIEMAP_MAX_OFFSET (~0ULL) -#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */ -#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */ - -#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ -#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ -#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. - * Sets EXTENT_UNKNOWN. */ -#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read - * while fs is unmounted */ -#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. - * Sets EXTENT_NO_DIRECT. */ +#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before + * map + */ +#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute + * tree + */ +#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ +#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ +#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. + * Sets EXTENT_UNKNOWN. + */ +#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read + * while fs is unmounted + */ +#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. + * Sets EXTENT_NO_DIRECT. + */ #define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be - * block aligned. */ + * block aligned. + */ #define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata. * Sets EXTENT_NOT_ALIGNED.*/ -#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block. - * Sets EXTENT_NOT_ALIGNED.*/ -#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but - * no data (i.e. zero). */ -#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively +#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block. + * Sets EXTENT_NOT_ALIGNED. + */ +#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but + * no data (i.e. zero). + */ +#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively * support extents. Result - * merged for efficiency. */ + * merged for efficiency. + */ static inline size_t fiemap_count_to_size(size_t extent_count) { @@ -114,7 +128,8 @@ static inline unsigned fiemap_size_to_count(size_t array_size) /* Lustre specific flags - use a high bit, don't conflict with upstream flag */ #define FIEMAP_EXTENT_NO_DIRECT 0x40000000 /* Data mapping undefined */ -#define FIEMAP_EXTENT_NET 0x80000000 /* Data stored remotely. - * Sets NO_DIRECT flag */ +#define FIEMAP_EXTENT_NET 0x80000000 /* Data stored remotely. + * Sets NO_DIRECT flag + */ #endif /* _LUSTRE_FIEMAP_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_build_version.h b/drivers/staging/lustre/lustre/include/lustre/lustre_build_version.h deleted file mode 100644 index 93a3d7d..0000000 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_build_version.h +++ /dev/null @@ -1,2 +0,0 @@ -#define BUILD_VERSION "v2_3_64_0-g6e62c21-CHANGED-3.9.0" -#define LUSTRE_RELEASE 3.9.0_g6e62c21 diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b064b58..284affb 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -113,25 +113,25 @@ #define CONNMGR_REQUEST_PORTAL 1 #define CONNMGR_REPLY_PORTAL 2 -//#define OSC_REQUEST_PORTAL 3 +/*#define OSC_REQUEST_PORTAL 3 */ #define OSC_REPLY_PORTAL 4 -//#define OSC_BULK_PORTAL 5 +/*#define OSC_BULK_PORTAL 5 */ #define OST_IO_PORTAL 6 #define OST_CREATE_PORTAL 7 #define OST_BULK_PORTAL 8 -//#define MDC_REQUEST_PORTAL 9 +/*#define MDC_REQUEST_PORTAL 9 */ #define MDC_REPLY_PORTAL 10 -//#define MDC_BULK_PORTAL 11 +/*#define MDC_BULK_PORTAL 11 */ #define MDS_REQUEST_PORTAL 12 -//#define MDS_REPLY_PORTAL 13 +/*#define MDS_REPLY_PORTAL 13 */ #define MDS_BULK_PORTAL 14 #define LDLM_CB_REQUEST_PORTAL 15 #define LDLM_CB_REPLY_PORTAL 16 #define LDLM_CANCEL_REQUEST_PORTAL 17 #define LDLM_CANCEL_REPLY_PORTAL 18 -//#define PTLBD_REQUEST_PORTAL 19 -//#define PTLBD_REPLY_PORTAL 20 -//#define PTLBD_BULK_PORTAL 21 +/*#define PTLBD_REQUEST_PORTAL 19 */ +/*#define PTLBD_REPLY_PORTAL 20 */ +/*#define PTLBD_BULK_PORTAL 21 */ #define MDS_SETATTR_PORTAL 22 #define MDS_READPAGE_PORTAL 23 #define OUT_PORTAL 24 @@ -146,7 +146,9 @@ #define SEQ_CONTROLLER_PORTAL 32 #define MGS_BULK_PORTAL 33 -/* Portal 63 is reserved for the Cray Inc DVS - nic@cray.com, roe@cray.com, n8851@cray.com */ +/* Portal 63 is reserved for the Cray Inc DVS - nic@cray.com, roe@cray.com, + * n8851@cray.com + */ /* packet types */ #define PTL_RPC_MSG_REQUEST 4711 @@ -295,7 +297,8 @@ static inline int range_compare_loc(const struct lu_seq_range *r1, fld_range_is_mdt(range) ? "mdt" : "ost" /** \defgroup lu_fid lu_fid - * @{ */ + * @{ + */ /** * Flags for lustre_mdt_attrs::lma_compat and lustre_mdt_attrs::lma_incompat. @@ -307,7 +310,8 @@ enum lma_compat { LMAC_SOM = 0x00000002, LMAC_NOT_IN_OI = 0x00000004, /* the object does NOT need OI mapping */ LMAC_FID_ON_OST = 0x00000008, /* For OST-object, its OI mapping is - * under /O/<seq>/d<x>. */ + * under /O/<seq>/d<x>. + */ }; /** @@ -319,7 +323,8 @@ enum lma_incompat { LMAI_RELEASED = 0x00000001, /* file is released */ LMAI_AGENT = 0x00000002, /* agent inode */ LMAI_REMOTE_PARENT = 0x00000004, /* the parent of the object - is on the remote MDT */ + * is on the remote MDT + */ }; #define LMA_INCOMPAT_SUPP (LMAI_AGENT | LMAI_REMOTE_PARENT) @@ -395,12 +400,14 @@ enum fid_seq { FID_SEQ_LOCAL_FILE = 0x200000001ULL, FID_SEQ_DOT_LUSTRE = 0x200000002ULL, /* sequence is used for local named objects FIDs generated - * by local_object_storage library */ + * by local_object_storage library + */ FID_SEQ_LOCAL_NAME = 0x200000003ULL, /* Because current FLD will only cache the fid sequence, instead * of oid on the client side, if the FID needs to be exposed to * clients sides, it needs to make sure all of fids under one - * sequence will be located in one MDT. */ + * sequence will be located in one MDT. + */ FID_SEQ_SPECIAL = 0x200000004ULL, FID_SEQ_QUOTA = 0x200000005ULL, FID_SEQ_QUOTA_GLB = 0x200000006ULL, @@ -601,7 +608,8 @@ static inline void ostid_set_seq(struct ost_id *oi, __u64 seq) oi->oi_fid.f_seq = seq; /* Note: if f_oid + f_ver is zero, we need init it * to be 1, otherwise, ostid_seq will treat this - * as old ostid (oi_seq == 0) */ + * as old ostid (oi_seq == 0) + */ if (oi->oi_fid.f_oid == 0 && oi->oi_fid.f_ver == 0) oi->oi_fid.f_oid = LUSTRE_FID_INIT_OID; } @@ -689,11 +697,12 @@ static inline int ostid_to_fid(struct lu_fid *fid, struct ost_id *ostid, * that we map into the IDIF namespace. It allows up to 2^48 * objects per OST, as this is the object namespace that has * been in production for years. This can handle create rates - * of 1M objects/s/OST for 9 years, or combinations thereof. */ + * of 1M objects/s/OST for 9 years, or combinations thereof. + */ if (ostid_id(ostid) >= IDIF_MAX_OID) { - CERROR("bad MDT0 id, "DOSTID" ost_idx:%u\n", - POSTID(ostid), ost_idx); - return -EBADF; + CERROR("bad MDT0 id, " DOSTID " ost_idx:%u\n", + POSTID(ostid), ost_idx); + return -EBADF; } fid->f_seq = fid_idif_seq(ostid_id(ostid), ost_idx); /* truncate to 32 bits by assignment */ @@ -704,7 +713,8 @@ static inline int ostid_to_fid(struct lu_fid *fid, struct ost_id *ostid, /* This is either an IDIF object, which identifies objects across * all OSTs, or a regular FID. The IDIF namespace maps legacy * OST objects into the FID namespace. In both cases, we just - * pass the FID through, no conversion needed. */ + * pass the FID through, no conversion needed. + */ if (ostid->oi_fid.f_ver != 0) { CERROR("bad MDT0 id, "DOSTID" ost_idx:%u\n", POSTID(ostid), ost_idx); @@ -807,7 +817,7 @@ static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) static inline int fid_is_sane(const struct lu_fid *fid) { - return fid != NULL && + return fid && ((fid_seq(fid) >= FID_SEQ_START && fid_ver(fid) == 0) || fid_is_igif(fid) || fid_is_idif(fid) || fid_seq_is_rsvd(fid_seq(fid))); @@ -868,7 +878,8 @@ static inline void ostid_le_to_cpu(const struct ost_id *src_oi, /** @} lu_fid */ /** \defgroup lu_dir lu_dir - * @{ */ + * @{ + */ /** * Enumeration of possible directory entry attributes. @@ -880,24 +891,8 @@ enum lu_dirent_attrs { LUDA_FID = 0x0001, LUDA_TYPE = 0x0002, LUDA_64BITHASH = 0x0004, - - /* The following attrs are used for MDT internal only, - * not visible to client */ - - /* Verify the dirent consistency */ - LUDA_VERIFY = 0x8000, - /* Only check but not repair the dirent inconsistency */ - LUDA_VERIFY_DRYRUN = 0x4000, - /* The dirent has been repaired, or to be repaired (dryrun). */ - LUDA_REPAIR = 0x2000, - /* The system is upgraded, has beed or to be repaired (dryrun). */ - LUDA_UPGRADE = 0x1000, - /* Ignore this record, go to next directly. */ - LUDA_IGNORE = 0x0800, }; -#define LU_DIRENT_ATTRS_MASK 0xf800 - /** * Layout of readdir pages, as transmitted on wire. */ @@ -1128,7 +1123,8 @@ struct ptlrpc_body_v2 { __u32 pb_conn_cnt; __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ __u32 pb_service_time; /* for rep, actual service time, also used for - net_latency of req */ + * net_latency of req + */ __u32 pb_limit; __u64 pb_slv; /* VBR: pre-versions */ @@ -1174,7 +1170,8 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); /* #define MSG_AT_SUPPORT 0x0008 * This was used in early prototypes of adaptive timeouts, and while there * shouldn't be any users of that code there also isn't a need for using this - * bits. Defer usage until at least 1.10 to avoid potential conflict. */ + * bits. Defer usage until at least 1.10 to avoid potential conflict. + */ #define MSG_DELAY_REPLAY 0x0010 #define MSG_VERSION_REPLAY 0x0020 #define MSG_REQ_REPLAY_DONE 0x0040 @@ -1187,7 +1184,7 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); #define MSG_CONNECT_RECOVERING 0x00000001 #define MSG_CONNECT_RECONNECT 0x00000002 #define MSG_CONNECT_REPLAYABLE 0x00000004 -//#define MSG_CONNECT_PEER 0x8 +/*#define MSG_CONNECT_PEER 0x8 */ #define MSG_CONNECT_LIBCLIENT 0x00000010 #define MSG_CONNECT_INITIAL 0x00000020 #define MSG_CONNECT_ASYNC 0x00000040 @@ -1195,60 +1192,65 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); #define MSG_CONNECT_TRANSNO 0x00000100 /* report transno */ /* Connect flags */ -#define OBD_CONNECT_RDONLY 0x1ULL /*client has read-only access*/ -#define OBD_CONNECT_INDEX 0x2ULL /*connect specific LOV idx */ -#define OBD_CONNECT_MDS 0x4ULL /*connect from MDT to OST */ -#define OBD_CONNECT_GRANT 0x8ULL /*OSC gets grant at connect */ -#define OBD_CONNECT_SRVLOCK 0x10ULL /*server takes locks for cli */ -#define OBD_CONNECT_VERSION 0x20ULL /*Lustre versions in ocd */ -#define OBD_CONNECT_REQPORTAL 0x40ULL /*Separate non-IO req portal */ -#define OBD_CONNECT_ACL 0x80ULL /*access control lists */ -#define OBD_CONNECT_XATTR 0x100ULL /*client use extended attr */ +#define OBD_CONNECT_RDONLY 0x1ULL /*client has read-only access*/ +#define OBD_CONNECT_INDEX 0x2ULL /*connect specific LOV idx */ +#define OBD_CONNECT_MDS 0x4ULL /*connect from MDT to OST */ +#define OBD_CONNECT_GRANT 0x8ULL /*OSC gets grant at connect */ +#define OBD_CONNECT_SRVLOCK 0x10ULL /*server takes locks for cli */ +#define OBD_CONNECT_VERSION 0x20ULL /*Lustre versions in ocd */ +#define OBD_CONNECT_REQPORTAL 0x40ULL /*Separate non-IO req portal */ +#define OBD_CONNECT_ACL 0x80ULL /*access control lists */ +#define OBD_CONNECT_XATTR 0x100ULL /*client use extended attr */ #define OBD_CONNECT_CROW 0x200ULL /*MDS+OST create obj on write*/ -#define OBD_CONNECT_TRUNCLOCK 0x400ULL /*locks on server for punch */ -#define OBD_CONNECT_TRANSNO 0x800ULL /*replay sends init transno */ -#define OBD_CONNECT_IBITS 0x1000ULL /*support for inodebits locks*/ +#define OBD_CONNECT_TRUNCLOCK 0x400ULL /*locks on server for punch */ +#define OBD_CONNECT_TRANSNO 0x800ULL /*replay sends init transno */ +#define OBD_CONNECT_IBITS 0x1000ULL /*support for inodebits locks*/ #define OBD_CONNECT_JOIN 0x2000ULL /*files can be concatenated. *We do not support JOIN FILE *anymore, reserve this flags *just for preventing such bit - *to be reused.*/ -#define OBD_CONNECT_ATTRFID 0x4000ULL /*Server can GetAttr By Fid*/ -#define OBD_CONNECT_NODEVOH 0x8000ULL /*No open hndl on specl nodes*/ -#define OBD_CONNECT_RMT_CLIENT 0x10000ULL /*Remote client */ + *to be reused. + */ +#define OBD_CONNECT_ATTRFID 0x4000ULL /*Server can GetAttr By Fid*/ +#define OBD_CONNECT_NODEVOH 0x8000ULL /*No open hndl on specl nodes*/ +#define OBD_CONNECT_RMT_CLIENT 0x10000ULL /*Remote client */ #define OBD_CONNECT_RMT_CLIENT_FORCE 0x20000ULL /*Remote client by force */ -#define OBD_CONNECT_BRW_SIZE 0x40000ULL /*Max bytes per rpc */ -#define OBD_CONNECT_QUOTA64 0x80000ULL /*Not used since 2.4 */ -#define OBD_CONNECT_MDS_CAPA 0x100000ULL /*MDS capability */ -#define OBD_CONNECT_OSS_CAPA 0x200000ULL /*OSS capability */ -#define OBD_CONNECT_CANCELSET 0x400000ULL /*Early batched cancels. */ -#define OBD_CONNECT_SOM 0x800000ULL /*Size on MDS */ -#define OBD_CONNECT_AT 0x1000000ULL /*client uses AT */ +#define OBD_CONNECT_BRW_SIZE 0x40000ULL /*Max bytes per rpc */ +#define OBD_CONNECT_QUOTA64 0x80000ULL /*Not used since 2.4 */ +#define OBD_CONNECT_MDS_CAPA 0x100000ULL /*MDS capability */ +#define OBD_CONNECT_OSS_CAPA 0x200000ULL /*OSS capability */ +#define OBD_CONNECT_CANCELSET 0x400000ULL /*Early batched cancels. */ +#define OBD_CONNECT_SOM 0x800000ULL /*Size on MDS */ +#define OBD_CONNECT_AT 0x1000000ULL /*client uses AT */ #define OBD_CONNECT_LRU_RESIZE 0x2000000ULL /*LRU resize feature. */ -#define OBD_CONNECT_MDS_MDS 0x4000000ULL /*MDS-MDS connection */ +#define OBD_CONNECT_MDS_MDS 0x4000000ULL /*MDS-MDS connection */ #define OBD_CONNECT_REAL 0x8000000ULL /*real connection */ #define OBD_CONNECT_CHANGE_QS 0x10000000ULL /*Not used since 2.4 */ -#define OBD_CONNECT_CKSUM 0x20000000ULL /*support several cksum algos*/ -#define OBD_CONNECT_FID 0x40000000ULL /*FID is supported by server */ -#define OBD_CONNECT_VBR 0x80000000ULL /*version based recovery */ -#define OBD_CONNECT_LOV_V3 0x100000000ULL /*client supports LOV v3 EA */ +#define OBD_CONNECT_CKSUM 0x20000000ULL /*support several cksum algos*/ +#define OBD_CONNECT_FID 0x40000000ULL /*FID is supported by server */ +#define OBD_CONNECT_VBR 0x80000000ULL /*version based recovery */ +#define OBD_CONNECT_LOV_V3 0x100000000ULL /*client supports LOV v3 EA */ #define OBD_CONNECT_GRANT_SHRINK 0x200000000ULL /* support grant shrink */ #define OBD_CONNECT_SKIP_ORPHAN 0x400000000ULL /* don't reuse orphan objids */ #define OBD_CONNECT_MAX_EASIZE 0x800000000ULL /* preserved for large EA */ #define OBD_CONNECT_FULL20 0x1000000000ULL /* it is 2.0 client */ #define OBD_CONNECT_LAYOUTLOCK 0x2000000000ULL /* client uses layout lock */ #define OBD_CONNECT_64BITHASH 0x4000000000ULL /* client supports 64-bits - * directory hash */ + * directory hash + */ #define OBD_CONNECT_MAXBYTES 0x8000000000ULL /* max stripe size */ #define OBD_CONNECT_IMP_RECOV 0x10000000000ULL /* imp recovery support */ #define OBD_CONNECT_JOBSTATS 0x20000000000ULL /* jobid in ptlrpc_body */ #define OBD_CONNECT_UMASK 0x40000000000ULL /* create uses client umask */ #define OBD_CONNECT_EINPROGRESS 0x80000000000ULL /* client handles -EINPROGRESS - * RPC error properly */ + * RPC error properly + */ #define OBD_CONNECT_GRANT_PARAM 0x100000000000ULL/* extra grant params used for - * finer space reservation */ + * finer space reservation + */ #define OBD_CONNECT_FLOCK_OWNER 0x200000000000ULL /* for the fixed 1.8 - * policy and 2.x server */ + * policy and 2.x server + */ #define OBD_CONNECT_LVB_TYPE 0x400000000000ULL /* variable type of LVB */ #define OBD_CONNECT_NANOSEC_TIME 0x800000000000ULL /* nanosecond timestamps */ #define OBD_CONNECT_LIGHTWEIGHT 0x1000000000000ULL/* lightweight connection */ @@ -1264,61 +1266,19 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); * submit a small patch against EVERY branch that ONLY adds the new flag, * updates obd_connect_names[] for lprocfs_rd_connect_flags(), adds the * flag to check_obd_connect_data(), and updates wiretests accordingly, so it - * can be approved and landed easily to reserve the flag for future use. */ + * can be approved and landed easily to reserve the flag for future use. + */ /* The MNE_SWAB flag is overloading the MDS_MDS bit only for the MGS * connection. It is a temporary bug fix for Imperative Recovery interop * between 2.2 and 2.3 x86/ppc nodes, and can be removed when interop for - * 2.2 clients/servers is no longer needed. LU-1252/LU-1644. */ + * 2.2 clients/servers is no longer needed. LU-1252/LU-1644. + */ #define OBD_CONNECT_MNE_SWAB OBD_CONNECT_MDS_MDS #define OCD_HAS_FLAG(ocd, flg) \ (!!((ocd)->ocd_connect_flags & OBD_CONNECT_##flg)) -#define LRU_RESIZE_CONNECT_FLAG OBD_CONNECT_LRU_RESIZE - -#define MDT_CONNECT_SUPPORTED (OBD_CONNECT_RDONLY | OBD_CONNECT_VERSION | \ - OBD_CONNECT_ACL | OBD_CONNECT_XATTR | \ - OBD_CONNECT_IBITS | \ - OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID | \ - OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \ - OBD_CONNECT_RMT_CLIENT | \ - OBD_CONNECT_RMT_CLIENT_FORCE | \ - OBD_CONNECT_BRW_SIZE | OBD_CONNECT_MDS_CAPA | \ - OBD_CONNECT_OSS_CAPA | OBD_CONNECT_MDS_MDS | \ - OBD_CONNECT_FID | LRU_RESIZE_CONNECT_FLAG | \ - OBD_CONNECT_VBR | OBD_CONNECT_LOV_V3 | \ - OBD_CONNECT_SOM | OBD_CONNECT_FULL20 | \ - OBD_CONNECT_64BITHASH | OBD_CONNECT_JOBSTATS | \ - OBD_CONNECT_EINPROGRESS | \ - OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_UMASK | \ - OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK |\ - OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE |\ - OBD_CONNECT_FLOCK_DEAD | \ - OBD_CONNECT_DISP_STRIPE) - -#define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \ - OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \ - OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \ - OBD_CONNECT_BRW_SIZE | OBD_CONNECT_OSS_CAPA | \ - OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \ - LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_CKSUM | \ - OBD_CONNECT_RMT_CLIENT | \ - OBD_CONNECT_RMT_CLIENT_FORCE | OBD_CONNECT_VBR | \ - OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN | \ - OBD_CONNECT_GRANT_SHRINK | OBD_CONNECT_FULL20 | \ - OBD_CONNECT_64BITHASH | OBD_CONNECT_MAXBYTES | \ - OBD_CONNECT_MAX_EASIZE | \ - OBD_CONNECT_EINPROGRESS | \ - OBD_CONNECT_JOBSTATS | \ - OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_LVB_TYPE|\ - OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_FID | \ - OBD_CONNECT_PINGLESS) -#define ECHO_CONNECT_SUPPORTED (0) -#define MGS_CONNECT_SUPPORTED (OBD_CONNECT_VERSION | OBD_CONNECT_AT | \ - OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV | \ - OBD_CONNECT_MNE_SWAB | OBD_CONNECT_PINGLESS) - /* Features required for this version of the client to work with server */ #define CLIENT_CONNECT_MDT_REQD (OBD_CONNECT_IBITS | OBD_CONNECT_FID | \ OBD_CONNECT_FULL20) @@ -1334,7 +1294,8 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); /* This structure is used for both request and reply. * * If we eventually have separate connect data for different types, which we - * almost certainly will, then perhaps we stick a union in here. */ + * almost certainly will, then perhaps we stick a union in here. + */ struct obd_connect_data_v1 { __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */ __u32 ocd_version; /* lustre release version number */ @@ -1364,7 +1325,7 @@ struct obd_connect_data { __u8 ocd_blocksize; /* log2 of the backend filesystem blocksize */ __u8 ocd_inodespace; /* log2 of the per-inode space consumption */ __u16 ocd_grant_extent; /* per-extent grant overhead, in 1K blocks */ - __u32 ocd_unused; /* also fix lustre_swab_connect */ + __u32 ocd_unused; /* also fix lustre_swab_connect */ __u64 ocd_transno; /* first transno from client to be replayed */ __u32 ocd_group; /* MDS group on OST */ __u32 ocd_cksum_types; /* supported checksum algorithms */ @@ -1374,7 +1335,8 @@ struct obd_connect_data { /* Fields after ocd_maxbytes are only accessible by the receiver * if the corresponding flag in ocd_connect_flags is set. Accessing * any field after ocd_maxbytes on the receiver without a valid flag - * may result in out-of-bound memory access and kernel oops. */ + * may result in out-of-bound memory access and kernel oops. + */ __u64 padding1; /* added 2.1.0. also fix lustre_swab_connect */ __u64 padding2; /* added 2.1.0. also fix lustre_swab_connect */ __u64 padding3; /* added 2.1.0. also fix lustre_swab_connect */ @@ -1398,7 +1360,8 @@ struct obd_connect_data { * with senior engineers before starting to use a new field. Then, submit * a small patch against EVERY branch that ONLY adds the new field along with * the matching OBD_CONNECT flag, so that can be approved and landed easily to - * reserve the flag for future use. */ + * reserve the flag for future use. + */ void lustre_swab_connect(struct obd_connect_data *ocd); @@ -1408,18 +1371,18 @@ void lustre_swab_connect(struct obd_connect_data *ocd); * Please update DECLARE_CKSUM_NAME/OBD_CKSUM_ALL in obd.h when adding a new * algorithm and also the OBD_FL_CKSUM* flags. */ -typedef enum { +enum cksum_type { OBD_CKSUM_CRC32 = 0x00000001, OBD_CKSUM_ADLER = 0x00000002, OBD_CKSUM_CRC32C = 0x00000004, -} cksum_type_t; +}; /* * OST requests: OBDO & OBD request records */ /* opcodes */ -typedef enum { +enum ost_cmd { OST_REPLY = 0, /* reply ? */ OST_GETATTR = 1, OST_SETATTR = 2, @@ -1440,14 +1403,14 @@ typedef enum { OST_QUOTACTL = 19, OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */ OST_LAST_OPC -} ost_cmd_t; +}; #define OST_FIRST_OPC OST_REPLY enum obdo_flags { OBD_FL_INLINEDATA = 0x00000001, OBD_FL_OBDMDEXISTS = 0x00000002, OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ - OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ + OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */ OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ @@ -1461,14 +1424,16 @@ enum obdo_flags { OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ - OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. + OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. * XXX: obsoleted - reserved for old - * clients prior than 2.2 */ + * clients prior than 2.2 + */ OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */ OBD_FL_NOSPC_BLK = 0x00100000, /* no more block space on OST */ /* Note that while these checksum values are currently separate bits, - * in 2.x we can actually allow all values from 1-31 if we wanted. */ + * in 2.x we can actually allow all values from 1-31 if we wanted. + */ OBD_FL_CKSUM_ALL = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER | OBD_FL_CKSUM_CRC32C, @@ -1657,7 +1622,7 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) } } -#define OBD_MD_FLID (0x00000001ULL) /* object ID */ +#define OBD_MD_FLID (0x00000001ULL) /* object ID */ #define OBD_MD_FLATIME (0x00000002ULL) /* access time */ #define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */ #define OBD_MD_FLCTIME (0x00000008ULL) /* change time */ @@ -1683,22 +1648,23 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) #define OBD_MD_FLGROUP (0x01000000ULL) /* group */ #define OBD_MD_FLFID (0x02000000ULL) /* ->ost write inline fid */ #define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write with ioepoch */ - /* ->mds if epoch opens or closes */ + /* ->mds if epoch opens or closes + */ #define OBD_MD_FLGRANT (0x08000000ULL) /* ost preallocation space grant */ #define OBD_MD_FLDIREA (0x10000000ULL) /* dir's extended attribute data */ #define OBD_MD_FLUSRQUOTA (0x20000000ULL) /* over quota flags sent from ost */ #define OBD_MD_FLGRPQUOTA (0x40000000ULL) /* over quota flags sent from ost */ #define OBD_MD_FLMODEASIZE (0x80000000ULL) /* EA size will be changed */ -#define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */ +#define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */ #define OBD_MD_REINT (0x0000000200000000ULL) /* reintegrate oa */ -#define OBD_MD_MEA (0x0000000400000000ULL) /* CMD split EA */ +#define OBD_MD_MEA (0x0000000400000000ULL) /* CMD split EA */ #define OBD_MD_TSTATE (0x0000000800000000ULL) /* transient state field */ #define OBD_MD_FLXATTR (0x0000001000000000ULL) /* xattr */ #define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */ #define OBD_MD_FLXATTRRM (0x0000004000000000ULL) /* xattr remove */ -#define OBD_MD_FLACL (0x0000008000000000ULL) /* ACL */ +#define OBD_MD_FLACL (0x0000008000000000ULL) /* ACL */ #define OBD_MD_FLRMTPERM (0x0000010000000000ULL) /* remote permission */ #define OBD_MD_FLMDSCAPA (0x0000020000000000ULL) /* MDS capability */ #define OBD_MD_FLOSSCAPA (0x0000040000000000ULL) /* OSS capability */ @@ -1707,7 +1673,8 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) #define OBD_MD_FLGETATTRLOCK (0x0000200000000000ULL) /* Get IOEpoch attributes * under lock; for xattr * requests means the - * client holds the lock */ + * client holds the lock + */ #define OBD_MD_FLOBJCOUNT (0x0000400000000000ULL) /* for multiple destroy */ #define OBD_MD_FLRMTLSETFACL (0x0001000000000000ULL) /* lfs lsetfacl case */ @@ -1727,7 +1694,8 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) #define OBD_MD_FLXATTRALL (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS) /* don't forget obdo_fid which is way down at the bottom so it can - * come after the definition of llog_cookie */ + * come after the definition of llog_cookie + */ enum hss_valid { HSS_SETMASK = 0x01, @@ -1749,19 +1717,20 @@ void lustre_swab_obd_statfs(struct obd_statfs *os); /* ost_body.data values for OST_BRW */ -#define OBD_BRW_READ 0x01 -#define OBD_BRW_WRITE 0x02 -#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE) -#define OBD_BRW_SYNC 0x08 /* this page is a part of synchronous +#define OBD_BRW_READ 0x01 +#define OBD_BRW_WRITE 0x02 +#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE) +#define OBD_BRW_SYNC 0x08 /* this page is a part of synchronous * transfer and is not accounted in - * the grant. */ -#define OBD_BRW_CHECK 0x10 + * the grant. + */ +#define OBD_BRW_CHECK 0x10 #define OBD_BRW_FROM_GRANT 0x20 /* the osc manages this under llite */ -#define OBD_BRW_GRANTED 0x40 /* the ost manages this */ -#define OBD_BRW_NOCACHE 0x80 /* this page is a part of non-cached IO */ -#define OBD_BRW_NOQUOTA 0x100 -#define OBD_BRW_SRVLOCK 0x200 /* Client holds no lock over this page */ -#define OBD_BRW_ASYNC 0x400 /* Server may delay commit to disk */ +#define OBD_BRW_GRANTED 0x40 /* the ost manages this */ +#define OBD_BRW_NOCACHE 0x80 /* this page is a part of non-cached IO */ +#define OBD_BRW_NOQUOTA 0x100 +#define OBD_BRW_SRVLOCK 0x200 /* Client holds no lock over this page */ +#define OBD_BRW_ASYNC 0x400 /* Server may delay commit to disk */ #define OBD_BRW_MEMALLOC 0x800 /* Client runs in the "kswapd" context */ #define OBD_BRW_OVER_USRQUOTA 0x1000 /* Running out of user quota */ #define OBD_BRW_OVER_GRPQUOTA 0x2000 /* Running out of group quota */ @@ -1775,7 +1744,8 @@ struct obd_ioobj { struct ost_id ioo_oid; /* object ID, if multi-obj BRW */ __u32 ioo_max_brw; /* low 16 bits were o_mode before 2.4, * now (PTLRPC_BULK_OPS_COUNT - 1) in - * high 16 bits in 2.4 and later */ + * high 16 bits in 2.4 and later + */ __u32 ioo_bufcnt; /* number of niobufs for this object */ }; @@ -1799,7 +1769,8 @@ void lustre_swab_niobuf_remote(struct niobuf_remote *nbr); /* lock value block communicated between the filter and llite */ /* OST_LVB_ERR_INIT is needed because the return code in rc is - * negative, i.e. because ((MASK + rc) & MASK) != MASK. */ + * negative, i.e. because ((MASK + rc) & MASK) != MASK. + */ #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL #define OST_LVB_IS_ERR(blocks) \ @@ -1836,23 +1807,12 @@ void lustre_swab_ost_lvb(struct ost_lvb *lvb); * lquota data structures */ -#ifndef QUOTABLOCK_BITS -#define QUOTABLOCK_BITS 10 -#endif - -#ifndef QUOTABLOCK_SIZE -#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) -#endif - -#ifndef toqb -#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS) -#endif - /* The lquota_id structure is an union of all the possible identifier types that * can be used with quota, this includes: * - 64-bit user ID * - 64-bit group ID - * - a FID which can be used for per-directory quota in the future */ + * - a FID which can be used for per-directory quota in the future + */ union lquota_id { struct lu_fid qid_fid; /* FID for per-directory quota */ __u64 qid_uid; /* user identifier */ @@ -1889,89 +1849,6 @@ do { \ Q_COPY(out, in, qc_dqblk); \ } while (0) -/* Body of quota request used for quota acquire/release RPCs between quota - * master (aka QMT) and slaves (ak QSD). */ -struct quota_body { - struct lu_fid qb_fid; /* FID of global index packing the pool ID - * and type (data or metadata) as well as - * the quota type (user or group). */ - union lquota_id qb_id; /* uid or gid or directory FID */ - __u32 qb_flags; /* see below */ - __u32 qb_padding; - __u64 qb_count; /* acquire/release count (kbytes/inodes) */ - __u64 qb_usage; /* current slave usage (kbytes/inodes) */ - __u64 qb_slv_ver; /* slave index file version */ - struct lustre_handle qb_lockh; /* per-ID lock handle */ - struct lustre_handle qb_glb_lockh; /* global lock handle */ - __u64 qb_padding1[4]; -}; - -/* When the quota_body is used in the reply of quota global intent - * lock (IT_QUOTA_CONN) reply, qb_fid contains slave index file FID. */ -#define qb_slv_fid qb_fid -/* qb_usage is the current qunit (in kbytes/inodes) when quota_body is used in - * quota reply */ -#define qb_qunit qb_usage - -#define QUOTA_DQACQ_FL_ACQ 0x1 /* acquire quota */ -#define QUOTA_DQACQ_FL_PREACQ 0x2 /* pre-acquire */ -#define QUOTA_DQACQ_FL_REL 0x4 /* release quota */ -#define QUOTA_DQACQ_FL_REPORT 0x8 /* report usage */ - -void lustre_swab_quota_body(struct quota_body *b); - -/* Quota types currently supported */ -enum { - LQUOTA_TYPE_USR = 0x00, /* maps to USRQUOTA */ - LQUOTA_TYPE_GRP = 0x01, /* maps to GRPQUOTA */ - LQUOTA_TYPE_MAX -}; - -/* There are 2 different resource types on which a quota limit can be enforced: - * - inodes on the MDTs - * - blocks on the OSTs */ -enum { - LQUOTA_RES_MD = 0x01, /* skip 0 to avoid null oid in FID */ - LQUOTA_RES_DT = 0x02, - LQUOTA_LAST_RES, - LQUOTA_FIRST_RES = LQUOTA_RES_MD -}; - -#define LQUOTA_NR_RES (LQUOTA_LAST_RES - LQUOTA_FIRST_RES + 1) - -/* - * Space accounting support - * Format of an accounting record, providing disk usage information for a given - * user or group - */ -struct lquota_acct_rec { /* 16 bytes */ - __u64 bspace; /* current space in use */ - __u64 ispace; /* current # inodes in use */ -}; - -/* - * Global quota index support - * Format of a global record, providing global quota settings for a given quota - * identifier - */ -struct lquota_glb_rec { /* 32 bytes */ - __u64 qbr_hardlimit; /* quota hard limit, in #inodes or kbytes */ - __u64 qbr_softlimit; /* quota soft limit, in #inodes or kbytes */ - __u64 qbr_time; /* grace time, in seconds */ - __u64 qbr_granted; /* how much is granted to slaves, in #inodes or - * kbytes */ -}; - -/* - * Slave index support - * Format of a slave record, recording how much space is granted to a given - * slave - */ -struct lquota_slv_rec { /* 8 bytes */ - __u64 qsr_granted; /* space granted to the slave for the key=ID, - * in #inodes or kbytes */ -}; - /* Data structures associated with the quota locks */ /* Glimpse descriptor used for the index & per-ID quota locks */ @@ -1985,9 +1862,6 @@ struct ldlm_gl_lquota_desc { __u64 gl_pad2; }; -#define gl_qunit gl_hardlimit /* current qunit value used when - * glimpsing per-ID quota locks */ - /* quota glimpse flags */ #define LQUOTA_FL_EDQUOT 0x1 /* user/group out of quota space on QMT */ @@ -2002,15 +1876,12 @@ struct lquota_lvb { void lustre_swab_lquota_lvb(struct lquota_lvb *lvb); -/* LVB used with global quota lock */ -#define lvb_glb_ver lvb_id_may_rel /* current version of the global index */ - /* op codes */ -typedef enum { +enum quota_cmd { QUOTA_DQACQ = 601, QUOTA_DQREL = 602, QUOTA_LAST_OPC -} quota_cmd_t; +}; #define QUOTA_FIRST_OPC QUOTA_DQACQ /* @@ -2018,7 +1889,7 @@ typedef enum { */ /* opcodes */ -typedef enum { +enum mds_cmd { MDS_GETATTR = 33, MDS_GETATTR_NAME = 34, MDS_CLOSE = 35, @@ -2049,23 +1920,15 @@ typedef enum { MDS_HSM_CT_UNREGISTER = 60, MDS_SWAP_LAYOUTS = 61, MDS_LAST_OPC -} mds_cmd_t; +}; #define MDS_FIRST_OPC MDS_GETATTR -/* opcodes for object update */ -typedef enum { - UPDATE_OBJ = 1000, - UPDATE_LAST_OPC -} update_cmd_t; - -#define UPDATE_FIRST_OPC UPDATE_OBJ - /* * Do not exceed 63 */ -typedef enum { +enum mdt_reint_cmd { REINT_SETATTR = 1, REINT_CREATE = 2, REINT_LINK = 3, @@ -2074,9 +1937,9 @@ typedef enum { REINT_OPEN = 6, REINT_SETXATTR = 7, REINT_RMENTRY = 8, -// REINT_WRITE = 9, +/* REINT_WRITE = 9, */ REINT_MAX -} mds_reint_t, mdt_reint_t; +}; void lustre_swab_generic_32s(__u32 *val); @@ -2097,7 +1960,8 @@ void lustre_swab_generic_32s(__u32 *val); /* INODE LOCK PARTS */ #define MDS_INODELOCK_LOOKUP 0x000001 /* For namespace, dentry etc, and also * was used to protect permission (mode, - * owner, group etc) before 2.4. */ + * owner, group etc) before 2.4. + */ #define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */ #define MDS_INODELOCK_OPEN 0x000004 /* For opened files */ #define MDS_INODELOCK_LAYOUT 0x000008 /* for layout */ @@ -2110,7 +1974,8 @@ void lustre_swab_generic_32s(__u32 *val); * For local directory, MDT will always grant UPDATE_LOCK|PERM_LOCK together. * For Remote directory, the master MDT, where the remote directory is, will * grant UPDATE_LOCK|PERM_LOCK, and the remote MDT, where the name entry is, - * will grant LOOKUP_LOCK. */ + * will grant LOOKUP_LOCK. + */ #define MDS_INODELOCK_PERM 0x000010 #define MDS_INODELOCK_XATTR 0x000020 /* extended attributes */ @@ -2120,7 +1985,8 @@ void lustre_swab_generic_32s(__u32 *val); /* NOTE: until Lustre 1.8.7/2.1.1 the fid_ver() was packed into name[2], * but was moved into name[1] along with the OID to avoid consuming the - * name[2,3] fields that need to be used for the quota id (also a FID). */ + * name[2,3] fields that need to be used for the quota id (also a FID). + */ enum { LUSTRE_RES_ID_SEQ_OFF = 0, LUSTRE_RES_ID_VER_OID_OFF = 1, @@ -2156,7 +2022,8 @@ enum md_op_flags { #define LUSTRE_BFLAG_UNCOMMITTED_WRITES 0x1 /* these should be identical to their EXT4_*_FL counterparts, they are - * redefined here only to avoid dragging in fs/ext4/ext4.h */ + * redefined here only to avoid dragging in fs/ext4/ext4.h + */ #define LUSTRE_SYNC_FL 0x00000008 /* Synchronous updates */ #define LUSTRE_IMMUTABLE_FL 0x00000010 /* Immutable file */ #define LUSTRE_APPEND_FL 0x00000020 /* writes to file may only append */ @@ -2168,15 +2035,14 @@ enum md_op_flags { * protocol equivalents of LDISKFS_*_FL values stored on disk, while * the S_* flags are kernel-internal values that change between kernel * versions. These flags are set/cleared via FSFILT_IOC_{GET,SET}_FLAGS. - * See b=16526 for a full history. */ + * See b=16526 for a full history. + */ static inline int ll_ext_to_inode_flags(int flags) { return (((flags & LUSTRE_SYNC_FL) ? S_SYNC : 0) | ((flags & LUSTRE_NOATIME_FL) ? S_NOATIME : 0) | ((flags & LUSTRE_APPEND_FL) ? S_APPEND : 0) | -#if defined(S_DIRSYNC) ((flags & LUSTRE_DIRSYNC_FL) ? S_DIRSYNC : 0) | -#endif ((flags & LUSTRE_IMMUTABLE_FL) ? S_IMMUTABLE : 0)); } @@ -2185,9 +2051,7 @@ static inline int ll_inode_to_ext_flags(int iflags) return (((iflags & S_SYNC) ? LUSTRE_SYNC_FL : 0) | ((iflags & S_NOATIME) ? LUSTRE_NOATIME_FL : 0) | ((iflags & S_APPEND) ? LUSTRE_APPEND_FL : 0) | -#if defined(S_DIRSYNC) ((iflags & S_DIRSYNC) ? LUSTRE_DIRSYNC_FL : 0) | -#endif ((iflags & S_IMMUTABLE) ? LUSTRE_IMMUTABLE_FL : 0)); } @@ -2207,9 +2071,10 @@ struct mdt_body { __s64 ctime; __u64 blocks; /* XID, in the case of MDS_READPAGE */ __u64 ioepoch; - __u64 t_state; /* transient file state defined in - * enum md_transient_state - * was "ino" until 2.4.0 */ + __u64 t_state; /* transient file state defined in + * enum md_transient_state + * was "ino" until 2.4.0 + */ __u32 fsuid; __u32 fsgid; __u32 capability; @@ -2219,7 +2084,7 @@ struct mdt_body { __u32 flags; /* from vfs for pin/unpin, LUSTRE_BFLAG close */ __u32 rdev; __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */ - __u32 unused2; /* was "generation" until 2.4.0 */ + __u32 unused2; /* was "generation" until 2.4.0 */ __u32 suppgid; __u32 eadatasize; __u32 aclsize; @@ -2256,7 +2121,8 @@ enum { }; /* inode access permission for remote user, the inode info are omitted, - * for client knows them. */ + * for client knows them. + */ struct mdt_remote_perm { __u32 rp_uid; __u32 rp_gid; @@ -2306,13 +2172,13 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa); * since the client and MDS may run different kernels (see bug 13828) * Therefore, we should only use MDS_ATTR_* attributes for sa_valid. */ -#define MDS_ATTR_MODE 0x1ULL /* = 1 */ -#define MDS_ATTR_UID 0x2ULL /* = 2 */ -#define MDS_ATTR_GID 0x4ULL /* = 4 */ -#define MDS_ATTR_SIZE 0x8ULL /* = 8 */ -#define MDS_ATTR_ATIME 0x10ULL /* = 16 */ -#define MDS_ATTR_MTIME 0x20ULL /* = 32 */ -#define MDS_ATTR_CTIME 0x40ULL /* = 64 */ +#define MDS_ATTR_MODE 0x1ULL /* = 1 */ +#define MDS_ATTR_UID 0x2ULL /* = 2 */ +#define MDS_ATTR_GID 0x4ULL /* = 4 */ +#define MDS_ATTR_SIZE 0x8ULL /* = 8 */ +#define MDS_ATTR_ATIME 0x10ULL /* = 16 */ +#define MDS_ATTR_MTIME 0x20ULL /* = 32 */ +#define MDS_ATTR_CTIME 0x40ULL /* = 64 */ #define MDS_ATTR_ATIME_SET 0x80ULL /* = 128 */ #define MDS_ATTR_MTIME_SET 0x100ULL /* = 256 */ #define MDS_ATTR_FORCE 0x200ULL /* = 512, Not a change, but a change it */ @@ -2320,14 +2186,11 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa); #define MDS_ATTR_KILL_SUID 0x800ULL /* = 2048 */ #define MDS_ATTR_KILL_SGID 0x1000ULL /* = 4096 */ #define MDS_ATTR_CTIME_SET 0x2000ULL /* = 8192 */ -#define MDS_ATTR_FROM_OPEN 0x4000ULL /* = 16384, called from open path, ie O_TRUNC */ +#define MDS_ATTR_FROM_OPEN 0x4000ULL /* = 16384, called from open path, + * ie O_TRUNC + */ #define MDS_ATTR_BLOCKS 0x8000ULL /* = 32768 */ -#ifndef FMODE_READ -#define FMODE_READ 00000001 -#define FMODE_WRITE 00000002 -#endif - #define MDS_FMODE_CLOSED 00000000 #define MDS_FMODE_EXEC 00000004 /* IO Epoch is opened on a closed file. */ @@ -2354,9 +2217,10 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa); * We do not support JOIN FILE * anymore, reserve this flags * just for preventing such bit - * to be reused. */ + * to be reused. + */ -#define MDS_OPEN_LOCK 04000000000 /* This open requires open lock */ +#define MDS_OPEN_LOCK 04000000000 /* This open requires open lock */ #define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */ #define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */ #define MDS_OPEN_NORESTORE 0100000000000ULL /* Do not restore file at open */ @@ -2409,7 +2273,8 @@ struct mdt_rec_create { __u32 cr_bias; /* use of helpers set/get_mrc_cr_flags() is needed to access * 64 bits cr_flags [cr_flags_l, cr_flags_h], this is done to - * extend cr_flags size without breaking 1.8 compat */ + * extend cr_flags size without breaking 1.8 compat + */ __u32 cr_flags_l; /* for use with open, low 32 bits */ __u32 cr_flags_h; /* for use with open, high 32 bits */ __u32 cr_umask; /* umask for create */ @@ -2630,7 +2495,8 @@ enum seq_op { #define LOV_MAX_UUID_BUFFER_SIZE 8192 /* The size of the buffer the lov/mdc reserves for the * array of UUIDs returned by the MDS. With the current - * protocol, this will limit the max number of OSTs per LOV */ + * protocol, this will limit the max number of OSTs per LOV + */ #define LOV_DESC_MAGIC 0xB0CCDE5C #define LOV_DESC_QOS_MAXAGE_DEFAULT 5 /* Seconds */ @@ -2639,13 +2505,13 @@ enum seq_op { /* LOV settings descriptor (should only contain static info) */ struct lov_desc { __u32 ld_tgt_count; /* how many OBD's */ - __u32 ld_active_tgt_count; /* how many active */ - __u32 ld_default_stripe_count; /* how many objects are used */ - __u32 ld_pattern; /* default PATTERN_RAID0 */ - __u64 ld_default_stripe_size; /* in bytes */ - __u64 ld_default_stripe_offset; /* in bytes */ + __u32 ld_active_tgt_count; /* how many active */ + __u32 ld_default_stripe_count; /* how many objects are used */ + __u32 ld_pattern; /* default PATTERN_RAID0 */ + __u64 ld_default_stripe_size; /* in bytes */ + __u64 ld_default_stripe_offset; /* in bytes */ __u32 ld_padding_0; /* unused */ - __u32 ld_qos_maxage; /* in second */ + __u32 ld_qos_maxage; /* in second */ __u32 ld_padding_1; /* also fix lustre_swab_lov_desc */ __u32 ld_padding_2; /* also fix lustre_swab_lov_desc */ struct obd_uuid ld_uuid; @@ -2659,7 +2525,7 @@ void lustre_swab_lov_desc(struct lov_desc *ld); * LDLM requests: */ /* opcodes -- MUST be distinct from OST/MDS opcodes */ -typedef enum { +enum ldlm_cmd { LDLM_ENQUEUE = 101, LDLM_CONVERT = 102, LDLM_CANCEL = 103, @@ -2668,7 +2534,7 @@ typedef enum { LDLM_GL_CALLBACK = 106, LDLM_SET_INFO = 107, LDLM_LAST_OPC -} ldlm_cmd_t; +}; #define LDLM_FIRST_OPC LDLM_ENQUEUE #define RES_NAME_SIZE 4 @@ -2687,7 +2553,7 @@ static inline int ldlm_res_eq(const struct ldlm_res_id *res0, } /* lock types */ -typedef enum { +enum ldlm_mode { LCK_MINMODE = 0, LCK_EX = 1, LCK_PW = 2, @@ -2698,17 +2564,17 @@ typedef enum { LCK_GROUP = 64, LCK_COS = 128, LCK_MAXMODE -} ldlm_mode_t; +}; #define LCK_MODE_NUM 8 -typedef enum { +enum ldlm_type { LDLM_PLAIN = 10, LDLM_EXTENT = 11, LDLM_FLOCK = 12, LDLM_IBITS = 13, LDLM_MAX_TYPE -} ldlm_type_t; +}; #define LDLM_MIN_TYPE LDLM_PLAIN @@ -2747,7 +2613,8 @@ struct ldlm_flock_wire { * the first fields of the ldlm_flock structure because there is only * one ldlm_swab routine to process the ldlm_policy_data_t union. if * this ever changes we will need to swab the union differently based - * on the resource type. */ + * on the resource type. + */ typedef union { struct ldlm_extent l_extent; @@ -2768,15 +2635,15 @@ struct ldlm_intent { void lustre_swab_ldlm_intent(struct ldlm_intent *i); struct ldlm_resource_desc { - ldlm_type_t lr_type; + enum ldlm_type lr_type; __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ struct ldlm_res_id lr_name; }; struct ldlm_lock_desc { struct ldlm_resource_desc l_resource; - ldlm_mode_t l_req_mode; - ldlm_mode_t l_granted_mode; + enum ldlm_mode l_req_mode; + enum ldlm_mode l_granted_mode; ldlm_wire_policy_data_t l_policy_data; }; @@ -2793,7 +2660,8 @@ struct ldlm_request { void lustre_swab_ldlm_request(struct ldlm_request *rq); /* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. - * Otherwise, 2 are available. */ + * Otherwise, 2 are available. + */ #define ldlm_request_bufsize(count, type) \ ({ \ int _avail = LDLM_LOCKREQ_HANDLES; \ @@ -2820,7 +2688,7 @@ void lustre_swab_ldlm_reply(struct ldlm_reply *r); /* * Opcodes for mountconf (mgs and mgc) */ -typedef enum { +enum mgs_cmd { MGS_CONNECT = 250, MGS_DISCONNECT, MGS_EXCEPTION, /* node died, etc. */ @@ -2829,7 +2697,7 @@ typedef enum { MGS_SET_INFO, MGS_CONFIG_READ, MGS_LAST_OPC -} mgs_cmd_t; +}; #define MGS_FIRST_OPC MGS_CONNECT #define MGS_PARAM_MAXLEN 1024 @@ -2918,13 +2786,13 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size); * Opcodes for multiple servers. */ -typedef enum { +enum obd_cmd { OBD_PING = 400, OBD_LOG_CANCEL, OBD_QC_CALLBACK, OBD_IDX_READ, OBD_LAST_OPC -} obd_cmd_t; +}; #define OBD_FIRST_OPC OBD_PING /* catalog of log objects */ @@ -2933,7 +2801,7 @@ typedef enum { struct llog_logid { struct ost_id lgl_oi; __u32 lgl_ogen; -} __attribute__((packed)); +} __packed; /** Records written to the CATALOGS list */ #define CATLIST "CATALOGS" @@ -2942,7 +2810,7 @@ struct llog_catid { __u32 lci_padding1; __u32 lci_padding2; __u32 lci_padding3; -} __attribute__((packed)); +} __packed; /* Log data record types - there is no specific reason that these need to * be related to the RPC opcodes, but no reason not to (may be handy later?) @@ -2950,7 +2818,7 @@ struct llog_catid { #define LLOG_OP_MAGIC 0x10600000 #define LLOG_OP_MASK 0xfff00000 -typedef enum { +enum llog_op_type { LLOG_PAD_MAGIC = LLOG_OP_MAGIC | 0x00000, OST_SZ_REC = LLOG_OP_MAGIC | 0x00f00, /* OST_RAID1_REC = LLOG_OP_MAGIC | 0x01000, never used */ @@ -2970,7 +2838,7 @@ typedef enum { HSM_AGENT_REC = LLOG_OP_MAGIC | 0x80000, LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539, LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b, -} llog_op_type; +}; #define LLOG_REC_HDR_NEEDS_SWABBING(r) \ (((r)->lrh_type & __swab32(LLOG_OP_MASK)) == __swab32(LLOG_OP_MAGIC)) @@ -3006,7 +2874,7 @@ struct llog_logid_rec { __u64 lid_padding2; __u64 lid_padding3; struct llog_rec_tail lid_tail; -} __attribute__((packed)); +} __packed; struct llog_unlink_rec { struct llog_rec_hdr lur_hdr; @@ -3014,7 +2882,7 @@ struct llog_unlink_rec { __u32 lur_oseq; __u32 lur_count; struct llog_rec_tail lur_tail; -} __attribute__((packed)); +} __packed; struct llog_unlink64_rec { struct llog_rec_hdr lur_hdr; @@ -3024,7 +2892,7 @@ struct llog_unlink64_rec { __u64 lur_padding2; __u64 lur_padding3; struct llog_rec_tail lur_tail; -} __attribute__((packed)); +} __packed; struct llog_setattr64_rec { struct llog_rec_hdr lsr_hdr; @@ -3035,7 +2903,7 @@ struct llog_setattr64_rec { __u32 lsr_gid_h; __u64 lsr_padding; struct llog_rec_tail lsr_tail; -} __attribute__((packed)); +} __packed; struct llog_size_change_rec { struct llog_rec_hdr lsc_hdr; @@ -3045,16 +2913,7 @@ struct llog_size_change_rec { __u64 lsc_padding2; __u64 lsc_padding3; struct llog_rec_tail lsc_tail; -} __attribute__((packed)); - -#define CHANGELOG_MAGIC 0xca103000 - -/** \a changelog_rec_type's that can't be masked */ -#define CHANGELOG_MINMASK (1 << CL_MARK) -/** bits covering all \a changelog_rec_type's */ -#define CHANGELOG_ALLMASK 0XFFFFFFFF -/** default \a changelog_rec_type mask */ -#define CHANGELOG_DEFMASK CHANGELOG_ALLMASK & ~(1 << CL_ATIME | 1 << CL_CLOSE) +} __packed; /* changelog llog name, needed by client replicators */ #define CHANGELOG_CATALOG "changelog_catalog" @@ -3062,22 +2921,20 @@ struct llog_size_change_rec { struct changelog_setinfo { __u64 cs_recno; __u32 cs_id; -} __attribute__((packed)); +} __packed; /** changelog record */ struct llog_changelog_rec { struct llog_rec_hdr cr_hdr; struct changelog_rec cr; struct llog_rec_tail cr_tail; /**< for_sizezof_only */ -} __attribute__((packed)); +} __packed; struct llog_changelog_ext_rec { struct llog_rec_hdr cr_hdr; struct changelog_ext_rec cr; struct llog_rec_tail cr_tail; /**< for_sizezof_only */ -} __attribute__((packed)); - -#define CHANGELOG_USER_PREFIX "cl" +} __packed; struct llog_changelog_user_rec { struct llog_rec_hdr cur_hdr; @@ -3085,7 +2942,7 @@ struct llog_changelog_user_rec { __u32 cur_padding; __u64 cur_endrec; struct llog_rec_tail cur_tail; -} __attribute__((packed)); +} __packed; enum agent_req_status { ARS_WAITING, @@ -3123,21 +2980,22 @@ struct llog_agent_req_rec { struct llog_rec_hdr arr_hdr; /**< record header */ __u32 arr_status; /**< status of the request */ /* must match enum - * agent_req_status */ + * agent_req_status + */ __u32 arr_archive_id; /**< backend archive number */ __u64 arr_flags; /**< req flags */ - __u64 arr_compound_id; /**< compound cookie */ + __u64 arr_compound_id;/**< compound cookie */ __u64 arr_req_create; /**< req. creation time */ __u64 arr_req_change; /**< req. status change time */ struct hsm_action_item arr_hai; /**< req. to the agent */ - struct llog_rec_tail arr_tail; /**< record tail for_sizezof_only */ -} __attribute__((packed)); + struct llog_rec_tail arr_tail; /**< record tail for_sizezof_only */ +} __packed; /* Old llog gen for compatibility */ struct llog_gen { __u64 mnt_cnt; __u64 conn_cnt; -} __attribute__((packed)); +} __packed; struct llog_gen_rec { struct llog_rec_hdr lgr_hdr; @@ -3175,19 +3033,21 @@ struct llog_log_hdr { __u32 llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23]; __u32 llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)]; struct llog_rec_tail llh_tail; -} __attribute__((packed)); +} __packed; #define LLOG_BITMAP_SIZE(llh) (__u32)((llh->llh_hdr.lrh_len - \ llh->llh_bitmap_offset - \ sizeof(llh->llh_tail)) * 8) -/** log cookies are used to reference a specific log file and a record therein */ +/** log cookies are used to reference a specific log file and a record + * therein + */ struct llog_cookie { struct llog_logid lgc_lgl; __u32 lgc_subsys; __u32 lgc_index; __u32 lgc_padding; -} __attribute__((packed)); +} __packed; /** llog protocol */ enum llogd_rpc_ops { @@ -3196,7 +3056,7 @@ enum llogd_rpc_ops { LLOG_ORIGIN_HANDLE_READ_HEADER = 503, LLOG_ORIGIN_HANDLE_WRITE_REC = 504, LLOG_ORIGIN_HANDLE_CLOSE = 505, - LLOG_ORIGIN_CONNECT = 506, + LLOG_ORIGIN_CONNECT = 506, LLOG_CATINFO = 507, /* deprecated */ LLOG_ORIGIN_HANDLE_PREV_BLOCK = 508, LLOG_ORIGIN_HANDLE_DESTROY = 509, /* for destroy llog object*/ @@ -3212,13 +3072,13 @@ struct llogd_body { __u32 lgd_saved_index; __u32 lgd_len; __u64 lgd_cur_offset; -} __attribute__((packed)); +} __packed; struct llogd_conn_body { struct llog_gen lgdc_gen; struct llog_logid lgdc_logid; __u32 lgdc_ctxt_idx; -} __attribute__((packed)); +} __packed; /* Note: 64-bit types are 64-bit aligned in structure */ struct obdo { @@ -3245,17 +3105,18 @@ struct obdo { __u64 o_ioepoch; /* epoch in ost writes */ __u32 o_stripe_idx; /* holds stripe idx */ __u32 o_parent_ver; - struct lustre_handle o_handle; /* brw: lock handle to prolong - * locks */ - struct llog_cookie o_lcookie; /* destroy: unlink cookie from - * MDS */ + struct lustre_handle o_handle; /* brw: lock handle to prolong locks + */ + struct llog_cookie o_lcookie; /* destroy: unlink cookie from MDS + */ __u32 o_uid_h; __u32 o_gid_h; __u64 o_data_version; /* getattr: sum of iversion for * each stripe. * brw: grant space consumed on - * the client for the write */ + * the client for the write + */ __u64 o_padding_4; __u64 o_padding_5; __u64 o_padding_6; @@ -3273,13 +3134,14 @@ static inline void lustre_set_wire_obdo(struct obd_connect_data *ocd, { *wobdo = *lobdo; wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - if (ocd == NULL) + if (!ocd) return; if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { /* Currently OBD_FL_OSTID will only be used when 2.4 echo - * client communicate with pre-2.4 server */ + * client communicate with pre-2.4 server + */ wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); } @@ -3292,7 +3154,7 @@ static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd, __u32 local_flags = 0; if (lobdo->o_valid & OBD_MD_FLFLAGS) - local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; + local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; *lobdo = *wobdo; if (local_flags != 0) { @@ -3300,7 +3162,7 @@ static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd, lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; lobdo->o_flags |= local_flags; } - if (ocd == NULL) + if (!ocd) return; if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && @@ -3349,100 +3211,14 @@ void dump_ioo(struct obd_ioobj *nb); void dump_ost_body(struct ost_body *ob); void dump_rcs(__u32 *rc); -#define IDX_INFO_MAGIC 0x3D37CC37 - -/* Index file transfer through the network. The server serializes the index into - * a byte stream which is sent to the client via a bulk transfer */ -struct idx_info { - __u32 ii_magic; - - /* reply: see idx_info_flags below */ - __u32 ii_flags; - - /* request & reply: number of lu_idxpage (to be) transferred */ - __u16 ii_count; - __u16 ii_pad0; - - /* request: requested attributes passed down to the iterator API */ - __u32 ii_attrs; - - /* request & reply: index file identifier (FID) */ - struct lu_fid ii_fid; - - /* reply: version of the index file before starting to walk the index. - * Please note that the version can be modified at any time during the - * transfer */ - __u64 ii_version; - - /* request: hash to start with: - * reply: hash of the first entry of the first lu_idxpage and hash - * of the entry to read next if any */ - __u64 ii_hash_start; - __u64 ii_hash_end; - - /* reply: size of keys in lu_idxpages, minimal one if II_FL_VARKEY is - * set */ - __u16 ii_keysize; - - /* reply: size of records in lu_idxpages, minimal one if II_FL_VARREC - * is set */ - __u16 ii_recsize; - - __u32 ii_pad1; - __u64 ii_pad2; - __u64 ii_pad3; -}; - -void lustre_swab_idx_info(struct idx_info *ii); - -#define II_END_OFF MDS_DIR_END_OFF /* all entries have been read */ - -/* List of flags used in idx_info::ii_flags */ -enum idx_info_flags { - II_FL_NOHASH = 1 << 0, /* client doesn't care about hash value */ - II_FL_VARKEY = 1 << 1, /* keys can be of variable size */ - II_FL_VARREC = 1 << 2, /* records can be of variable size */ - II_FL_NONUNQ = 1 << 3, /* index supports non-unique keys */ -}; - -#define LIP_MAGIC 0x8A6D6B6C - -/* 4KB (= LU_PAGE_SIZE) container gathering key/record pairs */ -struct lu_idxpage { - /* 16-byte header */ - __u32 lip_magic; - __u16 lip_flags; - __u16 lip_nr; /* number of entries in the container */ - __u64 lip_pad0; /* additional padding for future use */ - - /* key/record pairs are stored in the remaining 4080 bytes. - * depending upon the flags in idx_info::ii_flags, each key/record - * pair might be preceded by: - * - a hash value - * - the key size (II_FL_VARKEY is set) - * - the record size (II_FL_VARREC is set) - * - * For the time being, we only support fixed-size key & record. */ - char lip_entries[0]; -}; - -#define LIP_HDR_SIZE (offsetof(struct lu_idxpage, lip_entries)) - -/* Gather all possible type associated with a 4KB container */ -union lu_page { - struct lu_dirpage lp_dir; /* for MDS_READPAGE */ - struct lu_idxpage lp_idx; /* for OBD_IDX_READ */ - char lp_array[LU_PAGE_SIZE]; -}; - /* security opcodes */ -typedef enum { +enum sec_cmd { SEC_CTX_INIT = 801, SEC_CTX_INIT_CONT = 802, SEC_CTX_FINI = 803, SEC_LAST_OPC, SEC_FIRST_OPC = SEC_CTX_INIT -} sec_cmd_t; +}; /* * capa related definitions @@ -3451,7 +3227,8 @@ typedef enum { #define CAPA_HMAC_KEY_MAX_LEN 56 /* NB take care when changing the sequence of elements this struct, - * because the offset info is used in find_capa() */ + * because the offset info is used in find_capa() + */ struct lustre_capa { struct lu_fid lc_fid; /** fid */ __u64 lc_opc; /** operations allowed */ @@ -3463,7 +3240,7 @@ struct lustre_capa { /* FIXME: y2038 time_t overflow: */ __u32 lc_expiry; /** expiry time (sec) */ __u8 lc_hmac[CAPA_HMAC_MAX_LEN]; /** HMAC */ -} __attribute__((packed)); +} __packed; void lustre_swab_lustre_capa(struct lustre_capa *c); @@ -3497,7 +3274,7 @@ struct lustre_capa_key { __u32 lk_keyid; /**< key# */ __u32 lk_padding; __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ -} __attribute__((packed)); +} __packed; /** The link ea holds 1 \a link_ea_entry for each hardlink */ #define LINK_EA_MAGIC 0x11EAF1DFUL @@ -3518,7 +3295,7 @@ struct link_ea_entry { unsigned char lee_reclen[2]; unsigned char lee_parent_fid[sizeof(struct lu_fid)]; char lee_name[0]; -} __attribute__((packed)); +} __packed; /** fid2path request/reply structure */ struct getinfo_fid2path { @@ -3527,7 +3304,7 @@ struct getinfo_fid2path { __u32 gf_linkno; __u32 gf_pathlen; char gf_path[0]; -} __attribute__((packed)); +} __packed; void lustre_swab_fid2path (struct getinfo_fid2path *gf); @@ -3558,7 +3335,7 @@ void lustre_swab_layout_intent(struct layout_intent *li); */ struct hsm_progress_kernel { /* Field taken from struct hsm_progress */ - lustre_fid hpk_fid; + struct lu_fid hpk_fid; __u64 hpk_cookie; struct hsm_extent hpk_extent; __u16 hpk_flags; @@ -3567,7 +3344,7 @@ struct hsm_progress_kernel { /* Additional fields */ __u64 hpk_data_version; __u64 hpk_padding2; -} __attribute__((packed)); +} __packed; void lustre_swab_hsm_user_state(struct hsm_user_state *hus); void lustre_swab_hsm_current_action(struct hsm_current_action *action); @@ -3576,92 +3353,6 @@ void lustre_swab_hsm_user_state(struct hsm_user_state *hus); void lustre_swab_hsm_user_item(struct hsm_user_item *hui); void lustre_swab_hsm_request(struct hsm_request *hr); -/** - * These are object update opcode under UPDATE_OBJ, which is currently - * being used by cross-ref operations between MDT. - * - * During the cross-ref operation, the Master MDT, which the client send the - * request to, will disassembly the operation into object updates, then OSP - * will send these updates to the remote MDT to be executed. - * - * Update request format - * magic: UPDATE_BUFFER_MAGIC_V1 - * Count: How many updates in the req. - * bufs[0] : following are packets of object. - * update[0]: - * type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * update[1]: - * type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * .......... - * update[7]: type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * Current 8 maxim updates per object update request. - * - ******************************************************************* - * update reply format: - * - * ur_version: UPDATE_REPLY_V1 - * ur_count: The count of the reply, which is usually equal - * to the number of updates in the request. - * ur_lens: The reply lengths of each object update. - * - * replies: 1st update reply [4bytes_ret: other body] - * 2nd update reply [4bytes_ret: other body] - * ..... - * nth update reply [4bytes_ret: other body] - * - * For each reply of the update, the format would be - * result(4 bytes):Other stuff - */ - -#define UPDATE_MAX_OPS 10 -#define UPDATE_BUFFER_MAGIC_V1 0xBDDE0001 -#define UPDATE_BUFFER_MAGIC UPDATE_BUFFER_MAGIC_V1 -#define UPDATE_BUF_COUNT 8 -enum object_update_op { - OBJ_CREATE = 1, - OBJ_DESTROY = 2, - OBJ_REF_ADD = 3, - OBJ_REF_DEL = 4, - OBJ_ATTR_SET = 5, - OBJ_ATTR_GET = 6, - OBJ_XATTR_SET = 7, - OBJ_XATTR_GET = 8, - OBJ_INDEX_LOOKUP = 9, - OBJ_INDEX_INSERT = 10, - OBJ_INDEX_DELETE = 11, - OBJ_LAST -}; - -struct update { - __u32 u_type; - __u32 u_batchid; - struct lu_fid u_fid; - __u32 u_lens[UPDATE_BUF_COUNT]; - __u32 u_bufs[0]; -}; - -struct update_buf { - __u32 ub_magic; - __u32 ub_count; - __u32 ub_bufs[0]; -}; - -#define UPDATE_REPLY_V1 0x00BD0001 -struct update_reply { - __u32 ur_version; - __u32 ur_count; - __u32 ur_lens[0]; -}; - -void lustre_swab_update_buf(struct update_buf *ub); -void lustre_swab_update_reply_buf(struct update_reply *ur); - /** layout swap request structure * fid1 and fid2 are in mdt_body */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 2b4dd65..2e9f025 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -85,9 +85,8 @@ struct obd_statfs { __u32 os_namelen; __u64 os_maxbytes; __u32 os_state; /**< obd_statfs_state OS_STATE_* flag */ - __u32 os_fprecreated; /* objs available now to the caller */ - /* used in QoS code to find preferred - * OSTs */ + __u32 os_fprecreated; /* objs available now to the caller */ + /* used in QoS code to find preferred OSTs */ __u32 os_spare2; __u32 os_spare3; __u32 os_spare4; @@ -135,8 +134,9 @@ struct filter_fid_old { /* Userspace should treat lu_fid as opaque, and only use the following methods * to print or parse them. Other functions (e.g. compare, swab) could be moved - * here from lustre_idl.h if needed. */ -typedef struct lu_fid lustre_fid; + * here from lustre_idl.h if needed. + */ +struct lu_fid; /** * Following struct for object attributes, that will be kept inode's EA. @@ -266,7 +266,8 @@ struct ost_id { /* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular * files, but are unlikely to be used in practice and are not harmful if * used incorrectly. O_NOCTTY and FASYNC are only meaningful for character - * devices and are safe for use on new files (See LU-812, LU-4209). */ + * devices and are safe for use on new files (See LU-812, LU-4209). + */ #define O_LOV_DELAY_CREATE (O_NOCTTY | FASYNC) #define LL_FILE_IGNORE_LOCK 0x00000001 @@ -302,7 +303,8 @@ struct ost_id { * The limit of 12 pages is somewhat arbitrary, but is a reasonably large * allocation that is sufficient for the current generation of systems. * - * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1) */ + * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1) + */ #define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ #define LOV_ALL_STRIPES 0xffff /* only valid for directories */ #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */ @@ -323,9 +325,11 @@ struct lov_user_md_v1 { /* LOV EA user data (host-endian) */ __u16 lmm_stripe_count; /* num stripes in use for this object */ union { __u16 lmm_stripe_offset; /* starting stripe offset in - * lmm_objects, use when writing */ + * lmm_objects, use when writing + */ __u16 lmm_layout_gen; /* layout generation number - * used when reading */ + * used when reading + */ }; struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ } __attribute__((packed, __may_alias__)); @@ -338,9 +342,11 @@ struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ __u16 lmm_stripe_count; /* num stripes in use for this object */ union { __u16 lmm_stripe_offset; /* starting stripe offset in - * lmm_objects, use when writing */ + * lmm_objects, use when writing + */ __u16 lmm_layout_gen; /* layout generation number - * used when reading */ + * used when reading + */ }; char lmm_pool_name[LOV_MAXPOOLNAME]; /* pool name */ struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ @@ -444,7 +450,8 @@ static inline char *obd_uuid2str(const struct obd_uuid *uuid) { if (uuid->uuid[sizeof(*uuid) - 1] != '\0') { /* Obviously not safe, but for printfs, no real harm done... - we're always null-terminated, even in a race. */ + * we're always null-terminated, even in a race. + */ static char temp[sizeof(*uuid)]; memcpy(temp, uuid->uuid, sizeof(*uuid) - 1); @@ -455,8 +462,9 @@ static inline char *obd_uuid2str(const struct obd_uuid *uuid) } /* Extract fsname from uuid (or target name) of a target - e.g. (myfs-OST0007_UUID -> myfs) - see also deuuidify. */ + * e.g. (myfs-OST0007_UUID -> myfs) + * see also deuuidify. + */ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) { char *p; @@ -465,11 +473,12 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) buf[buflen - 1] = '\0'; p = strrchr(buf, '-'); if (p) - *p = '\0'; + *p = '\0'; } /* printf display format - e.g. printf("file FID is "DFID"\n", PFID(fid)); */ + * e.g. printf("file FID is "DFID"\n", PFID(fid)); + */ #define FID_NOBRACE_LEN 40 #define FID_LEN (FID_NOBRACE_LEN + 2) #define DFID_NOBRACE "%#llx:0x%x:0x%x" @@ -480,7 +489,8 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) (fid)->f_ver /* scanf input parse format -- strip '[' first. - e.g. sscanf(fidstr, SFID, RFID(&fid)); */ + * e.g. sscanf(fidstr, SFID, RFID(&fid)); + */ #define SFID "0x%llx:0x%x:0x%x" #define RFID(fid) \ &((fid)->f_seq), \ @@ -566,9 +576,9 @@ enum { /* hdr + MDT index */ #define LUSTRE_VOLATILE_IDX LUSTRE_VOLATILE_HDR":%.4X:" -typedef enum lustre_quota_version { +enum lustre_quota_version { LUSTRE_QUOTA_V2 = 1 -} lustre_quota_version_t; +}; /* XXX: same as if_dqinfo struct in kernel */ struct obd_dqinfo { @@ -698,7 +708,8 @@ static inline const char *changelog_type2str(int type) #define CLF_HSM_LAST 15 /* Remove bits higher than _h, then extract the value - * between _h and _l by shifting lower weigth to bit 0. */ + * between _h and _l by shifting lower weigth to bit 0. + */ #define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \ >> (CLF_HSM_LAST - _h + _l)) @@ -761,10 +772,10 @@ struct changelog_rec { __u64 cr_prev; /**< last index for this target fid */ __u64 cr_time; union { - lustre_fid cr_tfid; /**< target fid */ + struct lu_fid cr_tfid; /**< target fid */ __u32 cr_markerflags; /**< CL_MARK flags */ }; - lustre_fid cr_pfid; /**< parent fid */ + struct lu_fid cr_pfid; /**< parent fid */ char cr_name[0]; /**< last element */ } __packed; @@ -775,18 +786,19 @@ struct changelog_rec { struct changelog_ext_rec { __u16 cr_namelen; __u16 cr_flags; /**< (flags & CLF_FLAGMASK) | - CLF_EXT_VERSION */ + * CLF_EXT_VERSION + */ __u32 cr_type; /**< \a changelog_rec_type */ __u64 cr_index; /**< changelog record number */ __u64 cr_prev; /**< last index for this target fid */ __u64 cr_time; union { - lustre_fid cr_tfid; /**< target fid */ + struct lu_fid cr_tfid; /**< target fid */ __u32 cr_markerflags; /**< CL_MARK flags */ }; - lustre_fid cr_pfid; /**< target parent fid */ - lustre_fid cr_sfid; /**< source fid, or zero */ - lustre_fid cr_spfid; /**< source parent fid, or zero */ + struct lu_fid cr_pfid; /**< target parent fid */ + struct lu_fid cr_sfid; /**< source fid, or zero */ + struct lu_fid cr_spfid; /**< source parent fid, or zero */ char cr_name[0]; /**< last element */ } __packed; @@ -835,7 +847,8 @@ struct ioc_data_version { }; #define LL_DV_NOFLUSH 0x01 /* Do not take READ EXTENT LOCK before sampling - version. Dirty caches are left unchanged. */ + * version. Dirty caches are left unchanged. + */ #ifndef offsetof # define offsetof(typ, memb) ((unsigned long)((char *)&(((typ *)0)->memb))) @@ -976,8 +989,8 @@ struct hsm_request { }; struct hsm_user_item { - lustre_fid hui_fid; - struct hsm_extent hui_extent; + struct lu_fid hui_fid; + struct hsm_extent hui_extent; } __packed; struct hsm_user_request { @@ -1046,8 +1059,8 @@ static inline char *hsm_copytool_action2name(enum hsm_copytool_action a) struct hsm_action_item { __u32 hai_len; /* valid size of this struct */ __u32 hai_action; /* hsm_copytool_action, but use known size */ - lustre_fid hai_fid; /* Lustre FID to operated on */ - lustre_fid hai_dfid; /* fid used for data access */ + struct lu_fid hai_fid; /* Lustre FID to operated on */ + struct lu_fid hai_dfid; /* fid used for data access */ struct hsm_extent hai_extent; /* byte range to operate on */ __u64 hai_cookie; /* action cookie from coordinator */ __u64 hai_gid; /* grouplock id */ @@ -1095,7 +1108,8 @@ struct hsm_action_list { __u32 padding1; char hal_fsname[0]; /* null-terminated */ /* struct hsm_action_item[hal_count] follows, aligned on 8-byte - boundaries. See hai_zero */ + * boundaries. See hai_zero + */ } __packed; #ifndef HAVE_CFS_SIZE_ROUND @@ -1157,7 +1171,7 @@ struct hsm_user_import { #define HP_FLAG_RETRY 0x02 struct hsm_progress { - lustre_fid hp_fid; + struct lu_fid hp_fid; __u64 hp_cookie; struct hsm_extent hp_extent; __u16 hp_flags; diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index d30d8b0..23ae832 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -55,7 +55,8 @@ /** If the LCFG_REQUIRED bit is set in a configuration command, * then the client is required to understand this parameter * in order to mount the filesystem. If it does not understand - * a REQUIRED command the client mount will fail. */ + * a REQUIRED command the client mount will fail. + */ #define LCFG_REQUIRED 0x0001000 enum lcfg_command_type { @@ -87,9 +88,11 @@ enum lcfg_command_type { LCFG_POOL_DEL = 0x00ce023, /**< destroy an ost pool name */ LCFG_SET_LDLM_TIMEOUT = 0x00ce030, /**< set ldlm_timeout */ LCFG_PRE_CLEANUP = 0x00cf031, /**< call type-specific pre - * cleanup cleanup */ + * cleanup cleanup + */ LCFG_SET_PARAM = 0x00ce032, /**< use set_param syntax to set - *a proc parameters */ + * a proc parameters + */ }; struct lustre_cfg_bufs { @@ -128,7 +131,7 @@ static inline void lustre_cfg_bufs_set(struct lustre_cfg_bufs *bufs, { if (index >= LUSTRE_CFG_MAX_BUFCOUNT) return; - if (bufs == NULL) + if (!bufs) return; if (bufs->lcfg_bufcount <= index) @@ -158,7 +161,6 @@ static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, int index) int offset; int bufcount; - LASSERT (lcfg != NULL); LASSERT (index >= 0); bufcount = lcfg->lcfg_bufcount; @@ -191,7 +193,7 @@ static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, int index) return NULL; s = lustre_cfg_buf(lcfg, index); - if (s == NULL) + if (!s) return NULL; /* diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 7c6933f..95fd360 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -65,7 +65,8 @@ /****************** mount command *********************/ /* The lmd is only used internally by Lustre; mount simply passes - everything as string options */ + * everything as string options + */ #define LMD_MAGIC 0xbdacbd03 #define LMD_PARAMS_MAXLEN 4096 @@ -79,23 +80,26 @@ struct lustre_mount_data { int lmd_recovery_time_soft; int lmd_recovery_time_hard; char *lmd_dev; /* device name */ - char *lmd_profile; /* client only */ + char *lmd_profile; /* client only */ char *lmd_mgssec; /* sptlrpc flavor to mgs */ - char *lmd_opts; /* lustre mount options (as opposed to - _device_ mount options) */ + char *lmd_opts; /* lustre mount options (as opposed to + * _device_ mount options) + */ char *lmd_params; /* lustre params */ - __u32 *lmd_exclude; /* array of OSTs to ignore */ - char *lmd_mgs; /* MGS nid */ - char *lmd_osd_type; /* OSD type */ + __u32 *lmd_exclude; /* array of OSTs to ignore */ + char *lmd_mgs; /* MGS nid */ + char *lmd_osd_type; /* OSD type */ }; #define LMD_FLG_SERVER 0x0001 /* Mounting a server */ #define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ #define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ #define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, - no other services */ -#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing - existing MGS services */ + * no other services + */ +#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, + * reusing existing MGS services + */ #define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ #define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ #define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ @@ -116,231 +120,6 @@ struct lustre_mount_data { #define LR_EXPIRE_INTERVALS 16 /**< number of intervals to track transno */ #define ENOENT_VERSION 1 /** 'virtual' version of non-existent object */ -#define LR_SERVER_SIZE 512 -#define LR_CLIENT_START 8192 -#define LR_CLIENT_SIZE 128 -#if LR_CLIENT_START < LR_SERVER_SIZE -#error "Can't have LR_CLIENT_START < LR_SERVER_SIZE" -#endif - -/* - * This limit is arbitrary (131072 clients on x86), but it is convenient to use - * 2^n * PAGE_CACHE_SIZE * 8 for the number of bits that fit an order-n allocation. - * If we need more than 131072 clients (order-2 allocation on x86) then this - * should become an array of single-page pointers that are allocated on demand. - */ -#if (128 * 1024UL) > (PAGE_CACHE_SIZE * 8) -#define LR_MAX_CLIENTS (128 * 1024UL) -#else -#define LR_MAX_CLIENTS (PAGE_CACHE_SIZE * 8) -#endif - -/** COMPAT_146: this is an OST (temporary) */ -#define OBD_COMPAT_OST 0x00000002 -/** COMPAT_146: this is an MDT (temporary) */ -#define OBD_COMPAT_MDT 0x00000004 -/** 2.0 server, interop flag to show server version is changed */ -#define OBD_COMPAT_20 0x00000008 - -/** MDS handles LOV_OBJID file */ -#define OBD_ROCOMPAT_LOVOBJID 0x00000001 - -/** OST handles group subdirs */ -#define OBD_INCOMPAT_GROUPS 0x00000001 -/** this is an OST */ -#define OBD_INCOMPAT_OST 0x00000002 -/** this is an MDT */ -#define OBD_INCOMPAT_MDT 0x00000004 -/** common last_rvcd format */ -#define OBD_INCOMPAT_COMMON_LR 0x00000008 -/** FID is enabled */ -#define OBD_INCOMPAT_FID 0x00000010 -/** Size-on-MDS is enabled */ -#define OBD_INCOMPAT_SOM 0x00000020 -/** filesystem using iam format to store directory entries */ -#define OBD_INCOMPAT_IAM_DIR 0x00000040 -/** LMA attribute contains per-inode incompatible flags */ -#define OBD_INCOMPAT_LMA 0x00000080 -/** lmm_stripe_count has been shrunk from __u32 to __u16 and the remaining 16 - * bits are now used to store a generation. Once we start changing the layout - * and bumping the generation, old versions expecting a 32-bit lmm_stripe_count - * will be confused by interpreting stripe_count | gen << 16 as the actual - * stripe count */ -#define OBD_INCOMPAT_LMM_VER 0x00000100 -/** multiple OI files for MDT */ -#define OBD_INCOMPAT_MULTI_OI 0x00000200 - -/* Data stored per server at the head of the last_rcvd file. In le32 order. - This should be common to filter_internal.h, lustre_mds.h */ -struct lr_server_data { - __u8 lsd_uuid[40]; /* server UUID */ - __u64 lsd_last_transno; /* last completed transaction ID */ - __u64 lsd_compat14; /* reserved - compat with old last_rcvd */ - __u64 lsd_mount_count; /* incarnation number */ - __u32 lsd_feature_compat; /* compatible feature flags */ - __u32 lsd_feature_rocompat;/* read-only compatible feature flags */ - __u32 lsd_feature_incompat;/* incompatible feature flags */ - __u32 lsd_server_size; /* size of server data area */ - __u32 lsd_client_start; /* start of per-client data area */ - __u16 lsd_client_size; /* size of per-client data area */ - __u16 lsd_subdir_count; /* number of subdirectories for objects */ - __u64 lsd_catalog_oid; /* recovery catalog object id */ - __u32 lsd_catalog_ogen; /* recovery catalog inode generation */ - __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */ - __u32 lsd_osd_index; /* index number of OST in LOV */ - __u32 lsd_padding1; /* was lsd_mdt_index, unused in 2.4.0 */ - __u32 lsd_start_epoch; /* VBR: start epoch from last boot */ - /** transaction values since lsd_trans_table_time */ - __u64 lsd_trans_table[LR_EXPIRE_INTERVALS]; - /** start point of transno table below */ - __u32 lsd_trans_table_time; /* time of first slot in table above */ - __u32 lsd_expire_intervals; /* LR_EXPIRE_INTERVALS */ - __u8 lsd_padding[LR_SERVER_SIZE - 288]; -}; - -/* Data stored per client in the last_rcvd file. In le32 order. */ -struct lsd_client_data { - __u8 lcd_uuid[40]; /* client UUID */ - __u64 lcd_last_transno; /* last completed transaction ID */ - __u64 lcd_last_xid; /* xid for the last transaction */ - __u32 lcd_last_result; /* result from last RPC */ - __u32 lcd_last_data; /* per-op data (disposition for open &c.) */ - /* for MDS_CLOSE requests */ - __u64 lcd_last_close_transno; /* last completed transaction ID */ - __u64 lcd_last_close_xid; /* xid for the last transaction */ - __u32 lcd_last_close_result; /* result from last RPC */ - __u32 lcd_last_close_data; /* per-op data */ - /* VBR: last versions */ - __u64 lcd_pre_versions[4]; - __u32 lcd_last_epoch; - /** orphans handling for delayed export rely on that */ - __u32 lcd_first_epoch; - __u8 lcd_padding[LR_CLIENT_SIZE - 128]; -}; - -/* bug20354: the lcd_uuid for export of clients may be wrong */ -static inline void check_lcd(char *obd_name, int index, - struct lsd_client_data *lcd) -{ - int length = sizeof(lcd->lcd_uuid); - - if (strnlen((char *)lcd->lcd_uuid, length) == length) { - lcd->lcd_uuid[length - 1] = '\0'; - - LCONSOLE_ERROR("the client UUID (%s) on %s for exports stored in last_rcvd(index = %d) is bad!\n", - lcd->lcd_uuid, obd_name, index); - } -} - -/* last_rcvd handling */ -static inline void lsd_le_to_cpu(struct lr_server_data *buf, - struct lr_server_data *lsd) -{ - int i; - - memcpy(lsd->lsd_uuid, buf->lsd_uuid, sizeof(lsd->lsd_uuid)); - lsd->lsd_last_transno = le64_to_cpu(buf->lsd_last_transno); - lsd->lsd_compat14 = le64_to_cpu(buf->lsd_compat14); - lsd->lsd_mount_count = le64_to_cpu(buf->lsd_mount_count); - lsd->lsd_feature_compat = le32_to_cpu(buf->lsd_feature_compat); - lsd->lsd_feature_rocompat = le32_to_cpu(buf->lsd_feature_rocompat); - lsd->lsd_feature_incompat = le32_to_cpu(buf->lsd_feature_incompat); - lsd->lsd_server_size = le32_to_cpu(buf->lsd_server_size); - lsd->lsd_client_start = le32_to_cpu(buf->lsd_client_start); - lsd->lsd_client_size = le16_to_cpu(buf->lsd_client_size); - lsd->lsd_subdir_count = le16_to_cpu(buf->lsd_subdir_count); - lsd->lsd_catalog_oid = le64_to_cpu(buf->lsd_catalog_oid); - lsd->lsd_catalog_ogen = le32_to_cpu(buf->lsd_catalog_ogen); - memcpy(lsd->lsd_peeruuid, buf->lsd_peeruuid, sizeof(lsd->lsd_peeruuid)); - lsd->lsd_osd_index = le32_to_cpu(buf->lsd_osd_index); - lsd->lsd_padding1 = le32_to_cpu(buf->lsd_padding1); - lsd->lsd_start_epoch = le32_to_cpu(buf->lsd_start_epoch); - for (i = 0; i < LR_EXPIRE_INTERVALS; i++) - lsd->lsd_trans_table[i] = le64_to_cpu(buf->lsd_trans_table[i]); - lsd->lsd_trans_table_time = le32_to_cpu(buf->lsd_trans_table_time); - lsd->lsd_expire_intervals = le32_to_cpu(buf->lsd_expire_intervals); -} - -static inline void lsd_cpu_to_le(struct lr_server_data *lsd, - struct lr_server_data *buf) -{ - int i; - - memcpy(buf->lsd_uuid, lsd->lsd_uuid, sizeof(buf->lsd_uuid)); - buf->lsd_last_transno = cpu_to_le64(lsd->lsd_last_transno); - buf->lsd_compat14 = cpu_to_le64(lsd->lsd_compat14); - buf->lsd_mount_count = cpu_to_le64(lsd->lsd_mount_count); - buf->lsd_feature_compat = cpu_to_le32(lsd->lsd_feature_compat); - buf->lsd_feature_rocompat = cpu_to_le32(lsd->lsd_feature_rocompat); - buf->lsd_feature_incompat = cpu_to_le32(lsd->lsd_feature_incompat); - buf->lsd_server_size = cpu_to_le32(lsd->lsd_server_size); - buf->lsd_client_start = cpu_to_le32(lsd->lsd_client_start); - buf->lsd_client_size = cpu_to_le16(lsd->lsd_client_size); - buf->lsd_subdir_count = cpu_to_le16(lsd->lsd_subdir_count); - buf->lsd_catalog_oid = cpu_to_le64(lsd->lsd_catalog_oid); - buf->lsd_catalog_ogen = cpu_to_le32(lsd->lsd_catalog_ogen); - memcpy(buf->lsd_peeruuid, lsd->lsd_peeruuid, sizeof(buf->lsd_peeruuid)); - buf->lsd_osd_index = cpu_to_le32(lsd->lsd_osd_index); - buf->lsd_padding1 = cpu_to_le32(lsd->lsd_padding1); - buf->lsd_start_epoch = cpu_to_le32(lsd->lsd_start_epoch); - for (i = 0; i < LR_EXPIRE_INTERVALS; i++) - buf->lsd_trans_table[i] = cpu_to_le64(lsd->lsd_trans_table[i]); - buf->lsd_trans_table_time = cpu_to_le32(lsd->lsd_trans_table_time); - buf->lsd_expire_intervals = cpu_to_le32(lsd->lsd_expire_intervals); -} - -static inline void lcd_le_to_cpu(struct lsd_client_data *buf, - struct lsd_client_data *lcd) -{ - memcpy(lcd->lcd_uuid, buf->lcd_uuid, sizeof (lcd->lcd_uuid)); - lcd->lcd_last_transno = le64_to_cpu(buf->lcd_last_transno); - lcd->lcd_last_xid = le64_to_cpu(buf->lcd_last_xid); - lcd->lcd_last_result = le32_to_cpu(buf->lcd_last_result); - lcd->lcd_last_data = le32_to_cpu(buf->lcd_last_data); - lcd->lcd_last_close_transno = le64_to_cpu(buf->lcd_last_close_transno); - lcd->lcd_last_close_xid = le64_to_cpu(buf->lcd_last_close_xid); - lcd->lcd_last_close_result = le32_to_cpu(buf->lcd_last_close_result); - lcd->lcd_last_close_data = le32_to_cpu(buf->lcd_last_close_data); - lcd->lcd_pre_versions[0] = le64_to_cpu(buf->lcd_pre_versions[0]); - lcd->lcd_pre_versions[1] = le64_to_cpu(buf->lcd_pre_versions[1]); - lcd->lcd_pre_versions[2] = le64_to_cpu(buf->lcd_pre_versions[2]); - lcd->lcd_pre_versions[3] = le64_to_cpu(buf->lcd_pre_versions[3]); - lcd->lcd_last_epoch = le32_to_cpu(buf->lcd_last_epoch); - lcd->lcd_first_epoch = le32_to_cpu(buf->lcd_first_epoch); -} - -static inline void lcd_cpu_to_le(struct lsd_client_data *lcd, - struct lsd_client_data *buf) -{ - memcpy(buf->lcd_uuid, lcd->lcd_uuid, sizeof (lcd->lcd_uuid)); - buf->lcd_last_transno = cpu_to_le64(lcd->lcd_last_transno); - buf->lcd_last_xid = cpu_to_le64(lcd->lcd_last_xid); - buf->lcd_last_result = cpu_to_le32(lcd->lcd_last_result); - buf->lcd_last_data = cpu_to_le32(lcd->lcd_last_data); - buf->lcd_last_close_transno = cpu_to_le64(lcd->lcd_last_close_transno); - buf->lcd_last_close_xid = cpu_to_le64(lcd->lcd_last_close_xid); - buf->lcd_last_close_result = cpu_to_le32(lcd->lcd_last_close_result); - buf->lcd_last_close_data = cpu_to_le32(lcd->lcd_last_close_data); - buf->lcd_pre_versions[0] = cpu_to_le64(lcd->lcd_pre_versions[0]); - buf->lcd_pre_versions[1] = cpu_to_le64(lcd->lcd_pre_versions[1]); - buf->lcd_pre_versions[2] = cpu_to_le64(lcd->lcd_pre_versions[2]); - buf->lcd_pre_versions[3] = cpu_to_le64(lcd->lcd_pre_versions[3]); - buf->lcd_last_epoch = cpu_to_le32(lcd->lcd_last_epoch); - buf->lcd_first_epoch = cpu_to_le32(lcd->lcd_first_epoch); -} - -static inline __u64 lcd_last_transno(struct lsd_client_data *lcd) -{ - return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ? - lcd->lcd_last_transno : lcd->lcd_last_close_transno); -} - -static inline __u64 lcd_last_xid(struct lsd_client_data *lcd) -{ - return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ? - lcd->lcd_last_xid : lcd->lcd_last_close_xid); -} - /****************** superblock additional info *********************/ struct ll_sb_info; @@ -360,7 +139,8 @@ struct lustre_sb_info { char lsi_osd_type[16]; char lsi_fstype[16]; struct backing_dev_info lsi_bdi; /* each client mountpoint needs - own backing_dev_info */ + * own backing_dev_info + */ }; #define LSI_UMOUNT_FAILOVER 0x00200000 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 9b319f1..144b5af 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -69,7 +69,7 @@ struct obd_device; /** * LDLM non-error return states */ -typedef enum { +enum ldlm_error { ELDLM_OK = 0, ELDLM_LOCK_CHANGED = 300, @@ -80,7 +80,7 @@ typedef enum { ELDLM_NAMESPACE_EXISTS = 400, ELDLM_BAD_NAMESPACE = 401 -} ldlm_error_t; +}; /** * LDLM namespace type. @@ -145,14 +145,15 @@ typedef enum { #define LCK_COMPAT_COS (LCK_COS) /** @} Lock Compatibility Matrix */ -extern ldlm_mode_t lck_compat_array[]; +extern enum ldlm_mode lck_compat_array[]; -static inline void lockmode_verify(ldlm_mode_t mode) +static inline void lockmode_verify(enum ldlm_mode mode) { LASSERT(mode > LCK_MINMODE && mode < LCK_MAXMODE); } -static inline int lockmode_compat(ldlm_mode_t exist_mode, ldlm_mode_t new_mode) +static inline int lockmode_compat(enum ldlm_mode exist_mode, + enum ldlm_mode new_mode) { return (lck_compat_array[exist_mode] & new_mode); } @@ -249,7 +250,8 @@ struct ldlm_pool { /** Current biggest client lock volume. Protected by pl_lock. */ __u64 pl_client_lock_volume; /** Lock volume factor. SLV on client is calculated as following: - * server_slv * lock_volume_factor. */ + * server_slv * lock_volume_factor. + */ atomic_t pl_lock_volume_factor; /** Time when last SLV from server was obtained. */ time64_t pl_recalc_time; @@ -295,10 +297,10 @@ struct ldlm_valblock_ops { * LDLM pools related, type of lock pool in the namespace. * Greedy means release cached locks aggressively */ -typedef enum { +enum ldlm_appetite { LDLM_NAMESPACE_GREEDY = 1 << 0, LDLM_NAMESPACE_MODEST = 1 << 1 -} ldlm_appetite_t; +}; struct ldlm_ns_bucket { /** back pointer to namespace */ @@ -317,7 +319,7 @@ enum { LDLM_NSS_LAST }; -typedef enum { +enum ldlm_ns_type { /** invalid type */ LDLM_NS_TYPE_UNKNOWN = 0, /** mdc namespace */ @@ -332,7 +334,7 @@ typedef enum { LDLM_NS_TYPE_MGC, /** mgs namespace */ LDLM_NS_TYPE_MGT, -} ldlm_ns_type_t; +}; /** * LDLM Namespace. @@ -373,7 +375,7 @@ struct ldlm_namespace { /** * Namespace connect flags supported by server (may be changed via - * /proc, LRU resize may be disabled/enabled). + * sysfs, LRU resize may be disabled/enabled). */ __u64 ns_connect_flags; @@ -439,7 +441,7 @@ struct ldlm_namespace { /** LDLM pool structure for this namespace */ struct ldlm_pool ns_pool; /** Definition of how eagerly unused locks will be released from LRU */ - ldlm_appetite_t ns_appetite; + enum ldlm_appetite ns_appetite; /** Limit of parallel AST RPC count. */ unsigned ns_max_parallel_ast; @@ -465,7 +467,6 @@ struct ldlm_namespace { */ static inline int ns_connect_cancelset(struct ldlm_namespace *ns) { - LASSERT(ns != NULL); return !!(ns->ns_connect_flags & OBD_CONNECT_CANCELSET); } @@ -474,14 +475,12 @@ static inline int ns_connect_cancelset(struct ldlm_namespace *ns) */ static inline int ns_connect_lru_resize(struct ldlm_namespace *ns) { - LASSERT(ns != NULL); return !!(ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE); } static inline void ns_register_cancel(struct ldlm_namespace *ns, ldlm_cancel_for_recovery arg) { - LASSERT(ns != NULL); ns->ns_cancel_for_recovery = arg; } @@ -503,7 +502,8 @@ struct ldlm_glimpse_work { struct list_head gl_list; /* linkage to other gl work structs */ __u32 gl_flags;/* see LDLM_GL_WORK_* below */ union ldlm_gl_desc *gl_desc; /* glimpse descriptor to be packed in - * glimpse callback request */ + * glimpse callback request + */ }; /** The ldlm_glimpse_work is allocated on the stack and should not be freed. */ @@ -512,8 +512,9 @@ struct ldlm_glimpse_work { /** Interval node data for each LDLM_EXTENT lock. */ struct ldlm_interval { struct interval_node li_node; /* node for tree management */ - struct list_head li_group; /* the locks which have the same - * policy - group of the policy */ + struct list_head li_group; /* the locks which have the same + * policy - group of the policy + */ }; #define to_ldlm_interval(n) container_of(n, struct ldlm_interval, li_node) @@ -527,7 +528,7 @@ struct ldlm_interval { struct ldlm_interval_tree { /** Tree size. */ int lit_size; - ldlm_mode_t lit_mode; /* lock mode */ + enum ldlm_mode lit_mode; /* lock mode */ struct interval_node *lit_root; /* actual ldlm_interval */ }; @@ -535,12 +536,13 @@ struct ldlm_interval_tree { #define LUSTRE_TRACKS_LOCK_EXP_REFS (0) /** Cancel flags. */ -typedef enum { +enum ldlm_cancel_flags { LCF_ASYNC = 0x1, /* Cancel locks asynchronously. */ LCF_LOCAL = 0x2, /* Cancel locks locally, not notifing server */ LCF_BL_AST = 0x4, /* Cancel locks marked as LDLM_FL_BL_AST - * in the same RPC */ -} ldlm_cancel_flags_t; + * in the same RPC + */ +}; struct ldlm_flock { __u64 start; @@ -559,7 +561,7 @@ typedef union { struct ldlm_inodebits l_inodebits; } ldlm_policy_data_t; -void ldlm_convert_policy_to_local(struct obd_export *exp, ldlm_type_t type, +void ldlm_convert_policy_to_local(struct obd_export *exp, enum ldlm_type type, const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); @@ -637,11 +639,11 @@ struct ldlm_lock { * Requested mode. * Protected by lr_lock. */ - ldlm_mode_t l_req_mode; + enum ldlm_mode l_req_mode; /** * Granted mode, also protected by lr_lock. */ - ldlm_mode_t l_granted_mode; + enum ldlm_mode l_granted_mode; /** Lock completion handler pointer. Called when lock is granted. */ ldlm_completion_callback l_completion_ast; /** @@ -841,20 +843,19 @@ struct ldlm_resource { /** * protected by lr_lock - * @{ */ + * @{ + */ /** List of locks in granted state */ struct list_head lr_granted; /** * List of locks that could not be granted due to conflicts and - * that are waiting for conflicts to go away */ + * that are waiting for conflicts to go away + */ struct list_head lr_waiting; /** @} */ - /* XXX No longer needed? Remove ASAP */ - ldlm_mode_t lr_most_restr; - /** Type of locks this resource can hold. Only one type per resource. */ - ldlm_type_t lr_type; /* LDLM_{PLAIN,EXTENT,FLOCK,IBITS} */ + enum ldlm_type lr_type; /* LDLM_{PLAIN,EXTENT,FLOCK,IBITS} */ /** Resource name */ struct ldlm_res_id lr_name; @@ -921,7 +922,7 @@ static inline int ldlm_lvbo_init(struct ldlm_resource *res) { struct ldlm_namespace *ns = ldlm_res_to_ns(res); - if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_init != NULL) + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) return ns->ns_lvbo->lvbo_init(res); return 0; @@ -931,7 +932,7 @@ static inline int ldlm_lvbo_size(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - if (ns->ns_lvbo != NULL && ns->ns_lvbo->lvbo_size != NULL) + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_size) return ns->ns_lvbo->lvbo_size(lock); return 0; @@ -941,10 +942,9 @@ static inline int ldlm_lvbo_fill(struct ldlm_lock *lock, void *buf, int len) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - if (ns->ns_lvbo != NULL) { - LASSERT(ns->ns_lvbo->lvbo_fill != NULL); + if (ns->ns_lvbo) return ns->ns_lvbo->lvbo_fill(lock, buf, len); - } + return 0; } @@ -1015,7 +1015,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, /** Non-rate-limited lock printing function for debugging purposes. */ #define LDLM_DEBUG(lock, fmt, a...) do { \ - if (likely(lock != NULL)) { \ + if (likely(lock)) { \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_DLMTRACE, NULL); \ ldlm_lock_debug(&msgdata, D_DLMTRACE, NULL, lock, \ "### " fmt, ##a); \ @@ -1025,7 +1025,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, } while (0) typedef int (*ldlm_processing_policy)(struct ldlm_lock *lock, __u64 *flags, - int first_enq, ldlm_error_t *err, + int first_enq, enum ldlm_error *err, struct list_head *work_list); /** @@ -1042,7 +1042,8 @@ typedef int (*ldlm_res_iterator_t)(struct ldlm_resource *, void *); * * LDLM provides for a way to iterate through every lock on a resource or * namespace or every resource in a namespace. - * @{ */ + * @{ + */ int ldlm_resource_iterate(struct ldlm_namespace *, const struct ldlm_res_id *, ldlm_iterator_t iter, void *data); /** @} ldlm_iterator */ @@ -1091,7 +1092,7 @@ ldlm_handle2lock_long(const struct lustre_handle *h, __u64 flags) struct ldlm_lock *lock; lock = __ldlm_handle2lock(h, flags); - if (lock != NULL) + if (lock) LDLM_LOCK_REF_DEL(lock); return lock; } @@ -1111,7 +1112,7 @@ static inline int ldlm_res_lvbo_update(struct ldlm_resource *res, return 0; } -int ldlm_error2errno(ldlm_error_t error); +int ldlm_error2errno(enum ldlm_error error); #if LUSTRE_TRACKS_LOCK_EXP_REFS void ldlm_dump_export_locks(struct obd_export *exp); @@ -1168,12 +1169,13 @@ void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode); void ldlm_lock_fail_match_locked(struct ldlm_lock *lock); void ldlm_lock_allow_match(struct ldlm_lock *lock); void ldlm_lock_allow_match_locked(struct ldlm_lock *lock); -ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, - const struct ldlm_res_id *, ldlm_type_t type, - ldlm_policy_data_t *, ldlm_mode_t mode, - struct lustre_handle *, int unref); -ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, - __u64 *bits); +enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, + const struct ldlm_res_id *, + enum ldlm_type type, ldlm_policy_data_t *, + enum ldlm_mode mode, struct lustre_handle *, + int unref); +enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, + __u64 *bits); void ldlm_lock_cancel(struct ldlm_lock *lock); void ldlm_lock_dump_handle(int level, struct lustre_handle *); void ldlm_unlink_lock_skiplist(struct ldlm_lock *req); @@ -1181,8 +1183,8 @@ void ldlm_unlink_lock_skiplist(struct ldlm_lock *req); /* resource.c */ struct ldlm_namespace * ldlm_namespace_new(struct obd_device *obd, char *name, - ldlm_side_t client, ldlm_appetite_t apt, - ldlm_ns_type_t ns_type); + ldlm_side_t client, enum ldlm_appetite apt, + enum ldlm_ns_type ns_type); int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); @@ -1193,7 +1195,7 @@ void ldlm_debugfs_cleanup(void); struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, const struct ldlm_res_id *, - ldlm_type_t type, int create); + enum ldlm_type type, int create); int ldlm_resource_putref(struct ldlm_resource *res); void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, @@ -1219,7 +1221,8 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, * These AST handlers are typically used for server-side local locks and are * also used by client-side lock handlers to perform minimum level base * processing. - * @{ */ + * @{ + */ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data); int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data); /** @} ldlm_local_ast */ @@ -1227,7 +1230,8 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data); /** \defgroup ldlm_cli_api API to operate on locks from actual LDLM users. * These are typically used by client and server (*_local versions) * to obtain and release locks. - * @{ */ + * @{ + */ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, struct ldlm_enqueue_info *einfo, const struct ldlm_res_id *res_id, @@ -1244,29 +1248,32 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct list_head *cancels, int count); int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, - ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode, + enum ldlm_type type, __u8 with_policy, + enum ldlm_mode mode, __u64 *flags, void *lvb, __u32 lvb_len, struct lustre_handle *lockh, int rc); int ldlm_cli_update_pool(struct ptlrpc_request *req); int ldlm_cli_cancel(struct lustre_handle *lockh, - ldlm_cancel_flags_t cancel_flags); + enum ldlm_cancel_flags cancel_flags); int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *, - ldlm_cancel_flags_t flags, void *opaque); + enum ldlm_cancel_flags flags, void *opaque); int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, ldlm_policy_data_t *policy, - ldlm_mode_t mode, - ldlm_cancel_flags_t flags, + enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque); int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, ldlm_policy_data_t *policy, - ldlm_mode_t mode, __u64 lock_flags, - ldlm_cancel_flags_t cancel_flags, void *opaque); + enum ldlm_mode mode, __u64 lock_flags, + enum ldlm_cancel_flags cancel_flags, + void *opaque); int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, - ldlm_cancel_flags_t flags); + enum ldlm_cancel_flags flags); int ldlm_cli_cancel_list(struct list_head *head, int count, - struct ptlrpc_request *req, ldlm_cancel_flags_t flags); + struct ptlrpc_request *req, + enum ldlm_cancel_flags flags); /** @} ldlm_cli_api */ /* mds/handler.c */ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index 0d3ed87..7f2ba2f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -57,7 +57,8 @@ /** * Server placed lock on granted list, or a recovering client wants the - * lock added to the granted list, no questions asked. */ + * lock added to the granted list, no questions asked. + */ #define LDLM_FL_BLOCK_GRANTED 0x0000000000000002ULL /* bit 1 */ #define ldlm_is_block_granted(_l) LDLM_TEST_FLAG((_l), 1ULL << 1) #define ldlm_set_block_granted(_l) LDLM_SET_FLAG((_l), 1ULL << 1) @@ -65,7 +66,8 @@ /** * Server placed lock on conv list, or a recovering client wants the lock - * added to the conv list, no questions asked. */ + * added to the conv list, no questions asked. + */ #define LDLM_FL_BLOCK_CONV 0x0000000000000004ULL /* bit 2 */ #define ldlm_is_block_conv(_l) LDLM_TEST_FLAG((_l), 1ULL << 2) #define ldlm_set_block_conv(_l) LDLM_SET_FLAG((_l), 1ULL << 2) @@ -73,7 +75,8 @@ /** * Server placed lock on wait list, or a recovering client wants the lock - * added to the wait list, no questions asked. */ + * added to the wait list, no questions asked. + */ #define LDLM_FL_BLOCK_WAIT 0x0000000000000008ULL /* bit 3 */ #define ldlm_is_block_wait(_l) LDLM_TEST_FLAG((_l), 1ULL << 3) #define ldlm_set_block_wait(_l) LDLM_SET_FLAG((_l), 1ULL << 3) @@ -87,7 +90,8 @@ /** * Lock is being replayed. This could probably be implied by the fact that - * one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */ + * one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. + */ #define LDLM_FL_REPLAY 0x0000000000000100ULL /* bit 8 */ #define ldlm_is_replay(_l) LDLM_TEST_FLAG((_l), 1ULL << 8) #define ldlm_set_replay(_l) LDLM_SET_FLAG((_l), 1ULL << 8) @@ -125,7 +129,8 @@ /** * Server told not to wait if blocked. For AGL, OST will not send glimpse - * callback. */ + * callback. + */ #define LDLM_FL_BLOCK_NOWAIT 0x0000000000040000ULL /* bit 18 */ #define ldlm_is_block_nowait(_l) LDLM_TEST_FLAG((_l), 1ULL << 18) #define ldlm_set_block_nowait(_l) LDLM_SET_FLAG((_l), 1ULL << 18) @@ -141,7 +146,8 @@ * Immediately cancel such locks when they block some other locks. Send * cancel notification to original lock holder, but expect no reply. This * is for clients (like liblustre) that cannot be expected to reliably - * response to blocking AST. */ + * response to blocking AST. + */ #define LDLM_FL_CANCEL_ON_BLOCK 0x0000000000800000ULL /* bit 23 */ #define ldlm_is_cancel_on_block(_l) LDLM_TEST_FLAG((_l), 1ULL << 23) #define ldlm_set_cancel_on_block(_l) LDLM_SET_FLAG((_l), 1ULL << 23) @@ -164,7 +170,8 @@ /** * Used for marking lock as a target for -EINTR while cp_ast sleep emulation - * + race with upcoming bl_ast. */ + * + race with upcoming bl_ast. + */ #define LDLM_FL_FAIL_LOC 0x0000000100000000ULL /* bit 32 */ #define ldlm_is_fail_loc(_l) LDLM_TEST_FLAG((_l), 1ULL << 32) #define ldlm_set_fail_loc(_l) LDLM_SET_FLAG((_l), 1ULL << 32) @@ -172,7 +179,8 @@ /** * Used while processing the unused list to know that we have already - * handled this lock and decided to skip it. */ + * handled this lock and decided to skip it. + */ #define LDLM_FL_SKIPPED 0x0000000200000000ULL /* bit 33 */ #define ldlm_is_skipped(_l) LDLM_TEST_FLAG((_l), 1ULL << 33) #define ldlm_set_skipped(_l) LDLM_SET_FLAG((_l), 1ULL << 33) @@ -231,7 +239,8 @@ * The proper fix is to do the granting inside of the completion AST, * which can be replaced with a LVB-aware wrapping function for OSC locks. * That change is pretty high-risk, though, and would need a lot more - * testing. */ + * testing. + */ #define LDLM_FL_LVB_READY 0x0000020000000000ULL /* bit 41 */ #define ldlm_is_lvb_ready(_l) LDLM_TEST_FLAG((_l), 1ULL << 41) #define ldlm_set_lvb_ready(_l) LDLM_SET_FLAG((_l), 1ULL << 41) @@ -243,7 +252,8 @@ * dirty pages. It can remain on the granted list during this whole time. * Threads racing to update the KMS after performing their writeback need * to know to exclude each other's locks from the calculation as they walk - * the granted list. */ + * the granted list. + */ #define LDLM_FL_KMS_IGNORE 0x0000040000000000ULL /* bit 42 */ #define ldlm_is_kms_ignore(_l) LDLM_TEST_FLAG((_l), 1ULL << 42) #define ldlm_set_kms_ignore(_l) LDLM_SET_FLAG((_l), 1ULL << 42) @@ -263,7 +273,8 @@ /** * optimization hint: LDLM can run blocking callback from current context - * w/o involving separate thread. in order to decrease cs rate */ + * w/o involving separate thread. in order to decrease cs rate + */ #define LDLM_FL_ATOMIC_CB 0x0000200000000000ULL /* bit 45 */ #define ldlm_is_atomic_cb(_l) LDLM_TEST_FLAG((_l), 1ULL << 45) #define ldlm_set_atomic_cb(_l) LDLM_SET_FLAG((_l), 1ULL << 45) @@ -280,7 +291,8 @@ * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock cache is * dropped to let ldlm_callback_handler() return EINVAL to the server. It * is used when ELC RPC is already prepared and is waiting for rpc_lock, - * too late to send a separate CANCEL RPC. */ + * too late to send a separate CANCEL RPC. + */ #define LDLM_FL_BL_AST 0x0000400000000000ULL /* bit 46 */ #define ldlm_is_bl_ast(_l) LDLM_TEST_FLAG((_l), 1ULL << 46) #define ldlm_set_bl_ast(_l) LDLM_SET_FLAG((_l), 1ULL << 46) @@ -295,7 +307,8 @@ /** * Don't put lock into the LRU list, so that it is not canceled due * to aging. Used by MGC locks, they are cancelled only at unmount or - * by callback. */ + * by callback. + */ #define LDLM_FL_NO_LRU 0x0001000000000000ULL /* bit 48 */ #define ldlm_is_no_lru(_l) LDLM_TEST_FLAG((_l), 1ULL << 48) #define ldlm_set_no_lru(_l) LDLM_SET_FLAG((_l), 1ULL << 48) @@ -304,7 +317,8 @@ /** * Set for locks that failed and where the server has been notified. * - * Protected by lock and resource locks. */ + * Protected by lock and resource locks. + */ #define LDLM_FL_FAIL_NOTIFIED 0x0002000000000000ULL /* bit 49 */ #define ldlm_is_fail_notified(_l) LDLM_TEST_FLAG((_l), 1ULL << 49) #define ldlm_set_fail_notified(_l) LDLM_SET_FLAG((_l), 1ULL << 49) @@ -315,7 +329,8 @@ * be destroyed when last reference to them is released. Set by * ldlm_lock_destroy_internal(). * - * Protected by lock and resource locks. */ + * Protected by lock and resource locks. + */ #define LDLM_FL_DESTROYED 0x0004000000000000ULL /* bit 50 */ #define ldlm_is_destroyed(_l) LDLM_TEST_FLAG((_l), 1ULL << 50) #define ldlm_set_destroyed(_l) LDLM_SET_FLAG((_l), 1ULL << 50) @@ -333,7 +348,8 @@ * NB: compared with check_res_locked(), checking this bit is cheaper. * Also, spin_is_locked() is deprecated for kernel code; one reason is * because it works only for SMP so user needs to add extra macros like - * LASSERT_SPIN_LOCKED for uniprocessor kernels. */ + * LASSERT_SPIN_LOCKED for uniprocessor kernels. + */ #define LDLM_FL_RES_LOCKED 0x0010000000000000ULL /* bit 52 */ #define ldlm_is_res_locked(_l) LDLM_TEST_FLAG((_l), 1ULL << 52) #define ldlm_set_res_locked(_l) LDLM_SET_FLAG((_l), 1ULL << 52) @@ -343,7 +359,8 @@ * It's set once we call ldlm_add_waiting_lock_res_locked() to start the * lock-timeout timer and it will never be reset. * - * Protected by lock and resource locks. */ + * Protected by lock and resource locks. + */ #define LDLM_FL_WAITED 0x0020000000000000ULL /* bit 53 */ #define ldlm_is_waited(_l) LDLM_TEST_FLAG((_l), 1ULL << 53) #define ldlm_set_waited(_l) LDLM_SET_FLAG((_l), 1ULL << 53) @@ -365,10 +382,10 @@ #define LDLM_TEST_FLAG(_l, _b) (((_l)->l_flags & (_b)) != 0) /** set a ldlm_lock flag bit */ -#define LDLM_SET_FLAG(_l, _b) (((_l)->l_flags |= (_b)) +#define LDLM_SET_FLAG(_l, _b) ((_l)->l_flags |= (_b)) /** clear a ldlm_lock flag bit */ -#define LDLM_CLEAR_FLAG(_l, _b) (((_l)->l_flags &= ~(_b)) +#define LDLM_CLEAR_FLAG(_l, _b) ((_l)->l_flags &= ~(_b)) /** Mask of flags inherited from parent lock when doing intents. */ #define LDLM_INHERIT_FLAGS LDLM_FL_INHERIT_MASK diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index a030a98f..3014d27 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -50,62 +50,6 @@ #include "lustre/lustre_idl.h" #include "lustre_dlm.h" -struct mds_client_data; -struct mdt_client_data; -struct mds_idmap_table; -struct mdt_idmap_table; - -/** - * Target-specific export data - */ -struct tg_export_data { - /** Protects led_lcd below */ - struct mutex ted_lcd_lock; - /** Per-client data for each export */ - struct lsd_client_data *ted_lcd; - /** Offset of record in last_rcvd file */ - loff_t ted_lr_off; - /** Client index in last_rcvd file */ - int ted_lr_idx; -}; - -/** - * MDT-specific export data - */ -struct mdt_export_data { - struct tg_export_data med_ted; - /** List of all files opened by client on this MDT */ - struct list_head med_open_head; - spinlock_t med_open_lock; /* med_open_head, mfd_list */ - /** Bitmask of all ibit locks this MDT understands */ - __u64 med_ibits_known; - struct mutex med_idmap_mutex; - struct lustre_idmap_table *med_idmap; -}; - -struct ec_export_data { /* echo client */ - struct list_head eced_locks; -}; - -/* In-memory access to client data from OST struct */ -/** Filter (oss-side) specific import data */ -struct filter_export_data { - struct tg_export_data fed_ted; - spinlock_t fed_lock; /**< protects fed_mod_list */ - long fed_dirty; /* in bytes */ - long fed_grant; /* in bytes */ - struct list_head fed_mod_list; /* files being modified */ - int fed_mod_count;/* items in fed_writing list */ - long fed_pending; /* bytes just being written */ - __u32 fed_group; - __u8 fed_pagesize; /* log2 of client page size */ -}; - -struct mgs_export_data { - struct list_head med_clients; /* mgc fs client via this exp */ - spinlock_t med_lock; /* protect med_clients */ -}; - enum obd_option { OBD_OPT_FORCE = 0x0001, OBD_OPT_FAILOVER = 0x0002, @@ -179,7 +123,8 @@ struct obd_export { */ spinlock_t exp_lock; /** Compatibility flags for this export are embedded into - * exp_connect_data */ + * exp_connect_data + */ struct obd_connect_data exp_connect_data; enum obd_option exp_flags; unsigned long exp_failed:1, @@ -200,22 +145,8 @@ struct obd_export { /** blocking dlm lock list, protected by exp_bl_list_lock */ struct list_head exp_bl_list; spinlock_t exp_bl_list_lock; - - /** Target specific data */ - union { - struct tg_export_data eu_target_data; - struct mdt_export_data eu_mdt_data; - struct filter_export_data eu_filter_data; - struct ec_export_data eu_ec_data; - struct mgs_export_data eu_mgs_data; - } u; }; -#define exp_target_data u.eu_target_data -#define exp_mdt_data u.eu_mdt_data -#define exp_filter_data u.eu_filter_data -#define exp_ec_data u.eu_ec_data - static inline __u64 *exp_connect_flags_ptr(struct obd_export *exp) { return &exp->exp_connect_data.ocd_connect_flags; @@ -228,7 +159,6 @@ static inline __u64 exp_connect_flags(struct obd_export *exp) static inline int exp_max_brw_size(struct obd_export *exp) { - LASSERT(exp != NULL); if (exp_connect_flags(exp) & OBD_CONNECT_BRW_SIZE) return exp->exp_connect_data.ocd_brw_size; @@ -242,19 +172,16 @@ static inline int exp_connect_multibulk(struct obd_export *exp) static inline int exp_connect_cancelset(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_CANCELSET); } static inline int exp_connect_lru_resize(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_LRU_RESIZE); } static inline int exp_connect_rmtclient(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_RMT_CLIENT); } @@ -268,14 +195,11 @@ static inline int client_is_remote(struct obd_export *exp) static inline int exp_connect_vbr(struct obd_export *exp) { - LASSERT(exp != NULL); - LASSERT(exp->exp_connection); return !!(exp_connect_flags(exp) & OBD_CONNECT_VBR); } static inline int exp_connect_som(struct obd_export *exp) { - LASSERT(exp != NULL); return !!(exp_connect_flags(exp) & OBD_CONNECT_SOM); } @@ -288,7 +212,6 @@ static inline int imp_connect_lru_resize(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE); } @@ -300,7 +223,6 @@ static inline int exp_connect_layout(struct obd_export *exp) static inline bool exp_connect_lvb_type(struct obd_export *exp) { - LASSERT(exp != NULL); if (exp_connect_flags(exp) & OBD_CONNECT_LVB_TYPE) return true; else @@ -311,7 +233,6 @@ static inline bool imp_connect_lvb_type(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; if (ocd->ocd_connect_flags & OBD_CONNECT_LVB_TYPE) return true; @@ -331,7 +252,6 @@ static inline bool imp_connect_disp_stripe(struct obd_import *imp) { struct obd_connect_data *ocd; - LASSERT(imp != NULL); ocd = &imp->imp_connect_data; return ocd->ocd_connect_flags & OBD_CONNECT_DISP_STRIPE; } diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 9b1a9c6..ab91879 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -251,7 +251,8 @@ static inline void lu_local_name_obj_fid(struct lu_fid *fid, __u32 oid) /* For new FS (>= 2.4), the root FID will be changed to * [FID_SEQ_ROOT:1:0], for existing FS, (upgraded to 2.4), - * the root FID will still be IGIF */ + * the root FID will still be IGIF + */ static inline int fid_is_root(const struct lu_fid *fid) { return unlikely((fid_seq(fid) == FID_SEQ_ROOT && @@ -294,7 +295,8 @@ static inline int fid_is_namespace_visible(const struct lu_fid *fid) const __u64 seq = fid_seq(fid); /* Here, we cannot distinguish whether the normal FID is for OST - * object or not. It is caller's duty to check more if needed. */ + * object or not. It is caller's duty to check more if needed. + */ return (!fid_is_last_id(fid) && (fid_seq_is_norm(seq) || fid_seq_is_igif(seq))) || fid_is_root(fid) || fid_is_dot_lustre(fid); @@ -516,7 +518,8 @@ static inline int ostid_res_name_eq(struct ost_id *oi, struct ldlm_res_id *name) { /* Note: it is just a trick here to save some effort, probably the - * correct way would be turn them into the FID and compare */ + * correct way would be turn them into the FID and compare + */ if (fid_seq_is_mdt0(ostid_seq(oi))) { return name->name[LUSTRE_RES_ID_SEQ_OFF] == ostid_id(oi) && name->name[LUSTRE_RES_ID_VER_OID_OFF] == ostid_seq(oi); @@ -589,12 +592,14 @@ static inline __u64 fid_flatten(const struct lu_fid *fid) static inline __u32 fid_hash(const struct lu_fid *f, int bits) { /* all objects with same id and different versions will belong to same - * collisions list. */ + * collisions list. + */ return hash_long(fid_flatten(f), bits); } /** - * map fid to 32 bit value for ino on 32bit systems. */ + * map fid to 32 bit value for ino on 32bit systems. + */ static inline __u32 fid_flatten32(const struct lu_fid *fid) { __u32 ino; @@ -611,7 +616,8 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid) * that inodes generated at about the same time have a reduced chance * of collisions. This will give a period of 2^12 = 1024 unique clients * (from SEQ) and up to min(LUSTRE_SEQ_MAX_WIDTH, 2^20) = 128k objects - * (from OID), or up to 128M inodes without collisions for new files. */ + * (from OID), or up to 128M inodes without collisions for new files. + */ ino = ((seq & 0x000fffffULL) << 12) + ((seq >> 8) & 0xfffff000) + (seq >> (64 - (40-8)) & 0xffffff00) + (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 8); diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 5511626..4cf2b0e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -71,50 +71,41 @@ struct lu_fld_target { struct lu_server_fld { /** * super sequence controller export, needed to forward fld - * lookup request. */ + * lookup request. + */ struct obd_export *lsf_control_exp; - /** - * Client FLD cache. */ + /** Client FLD cache. */ struct fld_cache *lsf_cache; - /** - * Protect index modifications */ + /** Protect index modifications */ struct mutex lsf_lock; - /** - * Fld service name in form "fld-srv-lustre-MDTXXX" */ + /** Fld service name in form "fld-srv-lustre-MDTXXX" */ char lsf_name[LUSTRE_MDT_MAXNAMELEN]; }; struct lu_client_fld { - /** - * Client side debugfs entry. */ + /** Client side debugfs entry. */ struct dentry *lcf_debugfs_entry; - /** - * List of exports client FLD knows about. */ + /** List of exports client FLD knows about. */ struct list_head lcf_targets; - /** - * Current hash to be used to chose an export. */ + /** Current hash to be used to chose an export. */ struct lu_fld_hash *lcf_hash; - /** - * Exports count. */ + /** Exports count. */ int lcf_count; - /** - * Lock protecting exports list and fld_hash. */ + /** Lock protecting exports list and fld_hash. */ spinlock_t lcf_lock; - /** - * Client FLD cache. */ + /** Client FLD cache. */ struct fld_cache *lcf_cache; - /** - * Client fld debugfs entry name. */ + /** Client fld debugfs entry name. */ char lcf_name[LUSTRE_MDT_MAXNAMELEN]; int lcf_flags; diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index f39780a..27f169d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -65,7 +65,8 @@ struct portals_handle_ops { * * Now you're able to assign the results of cookie2handle directly to an * ldlm_lock. If it's not at the top, you'll want to use container_of() - * to compute the start of the structure based on the handle field. */ + * to compute the start of the structure based on the handle field. + */ struct portals_handle { struct list_head h_link; __u64 h_cookie; diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 4e4230e..dac2d84 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -292,7 +292,8 @@ struct obd_import { /* need IR MNE swab */ imp_need_mne_swab:1, /* import must be reconnected instead of - * chose new connection */ + * chosing new connection + */ imp_force_reconnect:1, /* import has tried to connect with server */ imp_connect_tried:1; diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index cfccf7c..f2223d5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -387,7 +387,8 @@ static inline void obd_ioctl_freedata(char *buf, int len) */ /* Until such time as we get_info the per-stripe maximum from the OST, - * we define this to be 2T - 4k, which is the ext3 maxbytes. */ + * we define this to be 2T - 4k, which is the ext3 maxbytes. + */ #define LUSTRE_STRIPE_MAXBYTES 0x1fffffff000ULL /* Special values for remove LOV EA from disk */ @@ -540,7 +541,7 @@ do { \ l_add_wait(&wq, &__wait); \ \ /* Block all signals (just the non-fatal ones if no timeout). */ \ - if (info->lwi_on_signal != NULL && (__timeout == 0 || __allow_intr)) \ + if (info->lwi_on_signal && (__timeout == 0 || __allow_intr)) \ __blocked = cfs_block_sigsinv(LUSTRE_FATAL_SIGS); \ else \ __blocked = cfs_block_sigsinv(0); \ @@ -562,13 +563,13 @@ do { \ __timeout = cfs_time_sub(__timeout, \ cfs_time_sub(interval, remaining));\ if (__timeout == 0) { \ - if (info->lwi_on_timeout == NULL || \ + if (!info->lwi_on_timeout || \ info->lwi_on_timeout(info->lwi_cb_data)) { \ ret = -ETIMEDOUT; \ break; \ } \ /* Take signals after the timeout expires. */ \ - if (info->lwi_on_signal != NULL) \ + if (info->lwi_on_signal) \ (void)cfs_block_sigsinv(LUSTRE_FATAL_SIGS);\ } \ } \ @@ -578,7 +579,7 @@ do { \ if (condition) \ break; \ if (cfs_signal_pending()) { \ - if (info->lwi_on_signal != NULL && \ + if (info->lwi_on_signal && \ (__timeout == 0 || __allow_intr)) { \ if (info->lwi_on_signal != LWI_ON_SIGNAL_NOOP) \ info->lwi_on_signal(info->lwi_cb_data);\ diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index e4fc8b5..49618e1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -241,7 +241,8 @@ struct llog_ctxt { struct obd_llog_group *loc_olg; /* group containing that ctxt */ struct obd_export *loc_exp; /* parent "disk" export (e.g. MDS) */ struct obd_import *loc_imp; /* to use in RPC's: can be backward - pointing import */ + * pointing import + */ struct llog_operations *loc_logops; struct llog_handle *loc_handle; struct mutex loc_mutex; /* protect loc_imp */ @@ -255,7 +256,7 @@ struct llog_ctxt { static inline int llog_handle2ops(struct llog_handle *loghandle, struct llog_operations **lop) { - if (loghandle == NULL || loghandle->lgh_logops == NULL) + if (!loghandle || !loghandle->lgh_logops) return -EINVAL; *lop = loghandle->lgh_logops; @@ -272,7 +273,7 @@ static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt) static inline void llog_ctxt_put(struct llog_ctxt *ctxt) { - if (ctxt == NULL) + if (!ctxt) return; LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, @@ -294,7 +295,7 @@ static inline int llog_group_set_ctxt(struct obd_llog_group *olg, LASSERT(index >= 0 && index < LLOG_MAX_CTXTS); spin_lock(&olg->olg_lock); - if (olg->olg_ctxts[index] != NULL) { + if (olg->olg_ctxts[index]) { spin_unlock(&olg->olg_lock); return -EEXIST; } @@ -311,7 +312,7 @@ static inline struct llog_ctxt *llog_group_get_ctxt(struct obd_llog_group *olg, LASSERT(index >= 0 && index < LLOG_MAX_CTXTS); spin_lock(&olg->olg_lock); - if (olg->olg_ctxts[index] == NULL) + if (!olg->olg_ctxts[index]) ctxt = NULL; else ctxt = llog_ctxt_get(olg->olg_ctxts[index]); @@ -335,7 +336,7 @@ static inline struct llog_ctxt *llog_get_context(struct obd_device *obd, static inline int llog_group_ctxt_null(struct obd_llog_group *olg, int index) { - return (olg->olg_ctxts[index] == NULL); + return (!olg->olg_ctxts[index]); } static inline int llog_ctxt_null(struct obd_device *obd, int index) @@ -354,7 +355,7 @@ static inline int llog_next_block(const struct lu_env *env, rc = llog_handle2ops(loghandle, &lop); if (rc) return rc; - if (lop->lop_next_block == NULL) + if (!lop->lop_next_block) return -EOPNOTSUPP; rc = lop->lop_next_block(env, loghandle, cur_idx, next_idx, diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 3da3733..df94f9f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -81,8 +81,8 @@ static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck) static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || - it->it_op == IT_LAYOUT)) + if (it && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; /* This would normally block until the existing request finishes. @@ -90,7 +90,8 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, * done, then set rpcl_it to MDC_FAKE_RPCL_IT. Once that is set * it will only be cleared when all fake requests are finished. * Only when all fake requests are finished can normal requests - * be sent, to ensure they are recoverable again. */ + * be sent, to ensure they are recoverable again. + */ again: mutex_lock(&lck->rpcl_mutex); @@ -105,22 +106,23 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, * just turned off but there are still requests in progress. * Wait until they finish. It doesn't need to be efficient * in this extremely rare case, just have low overhead in - * the common case when it isn't true. */ + * the common case when it isn't true. + */ while (unlikely(lck->rpcl_it == MDC_FAKE_RPCL_IT)) { mutex_unlock(&lck->rpcl_mutex); schedule_timeout(cfs_time_seconds(1) / 4); goto again; } - LASSERT(lck->rpcl_it == NULL); + LASSERT(!lck->rpcl_it); lck->rpcl_it = it; } static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || - it->it_op == IT_LAYOUT)) + if (it && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; if (lck->rpcl_it == MDC_FAKE_RPCL_IT) { /* OBD_FAIL_MDC_RPCS_SEM */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index d834ddd..ac08b25 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -76,7 +76,8 @@ * In order for the client and server to properly negotiate the maximum * possible transfer size, PTLRPC_BULK_OPS_COUNT must be a power-of-two * value. The client is free to limit the actual RPC size for any bulk - * transfer via cl_max_pages_per_rpc to some non-power-of-two value. */ + * transfer via cl_max_pages_per_rpc to some non-power-of-two value. + */ #define PTLRPC_BULK_OPS_BITS 2 #define PTLRPC_BULK_OPS_COUNT (1U << PTLRPC_BULK_OPS_BITS) /** @@ -85,7 +86,8 @@ * protocol limitation on the maximum RPC size that can be used by any * RPC sent to that server in the future. Instead, the server should * use the negotiated per-client ocd_brw_size to determine the bulk - * RPC count. */ + * RPC count. + */ #define PTLRPC_BULK_OPS_MASK (~((__u64)PTLRPC_BULK_OPS_COUNT - 1)) /** @@ -419,16 +421,18 @@ struct ptlrpc_reply_state { /** A spinlock to protect the reply state flags */ spinlock_t rs_lock; /** Reply state flags */ - unsigned long rs_difficult:1; /* ACK/commit stuff */ + unsigned long rs_difficult:1; /* ACK/commit stuff */ unsigned long rs_no_ack:1; /* no ACK, even for - difficult requests */ + * difficult requests + */ unsigned long rs_scheduled:1; /* being handled? */ unsigned long rs_scheduled_ever:1;/* any schedule attempts? */ unsigned long rs_handled:1; /* been handled yet? */ unsigned long rs_on_net:1; /* reply_out_callback pending? */ unsigned long rs_prealloc:1; /* rs from prealloc list */ unsigned long rs_committed:1;/* the transaction was committed - * and the rs was dispatched */ + * and the rs was dispatched + */ /** Size of the state */ int rs_size; /** opcode */ @@ -463,7 +467,7 @@ struct ptlrpc_reply_state { /** Handles of locks awaiting client reply ACK */ struct lustre_handle rs_locks[RS_MAX_LOCKS]; /** Lock modes of locks in \a rs_locks */ - ldlm_mode_t rs_modes[RS_MAX_LOCKS]; + enum ldlm_mode rs_modes[RS_MAX_LOCKS]; }; struct ptlrpc_thread; @@ -1181,7 +1185,7 @@ struct nrs_fifo_req { * purpose of this object is to hold references to the request's resources * for the lifetime of the request, and to hold properties that policies use * use for determining the request's scheduling priority. - * */ + */ struct ptlrpc_nrs_request { /** * The request's resource hierarchy. @@ -1321,15 +1325,17 @@ struct ptlrpc_request { /* do not resend request on -EINPROGRESS */ rq_no_retry_einprogress:1, /* allow the req to be sent if the import is in recovery - * status */ + * status + */ rq_allow_replay:1; unsigned int rq_nr_resend; enum rq_phase rq_phase; /* one of RQ_PHASE_* */ enum rq_phase rq_next_phase; /* one of RQ_PHASE_* to be used next */ - atomic_t rq_refcount;/* client-side refcount for SENT race, - server-side refcount for multiple replies */ + atomic_t rq_refcount; /* client-side refcount for SENT race, + * server-side refcount for multiple replies + */ /** Portal to which this request would be sent */ short rq_request_portal; /* XXX FIXME bug 249 */ @@ -1363,7 +1369,8 @@ struct ptlrpc_request { /** * security and encryption data - * @{ */ + * @{ + */ struct ptlrpc_cli_ctx *rq_cli_ctx; /**< client's half ctx */ struct ptlrpc_svc_ctx *rq_svc_ctx; /**< server's half ctx */ struct list_head rq_ctx_chain; /**< link to waited ctx */ @@ -1477,7 +1484,8 @@ struct ptlrpc_request { /** when request must finish. volatile * so that servers' early reply updates to the deadline aren't - * kept in per-cpu cache */ + * kept in per-cpu cache + */ volatile time64_t rq_deadline; /** when req reply unlink must finish. */ time64_t rq_reply_deadline; @@ -1518,7 +1526,7 @@ struct ptlrpc_request { static inline int ptlrpc_req_interpret(const struct lu_env *env, struct ptlrpc_request *req, int rc) { - if (req->rq_interpret_reply != NULL) { + if (req->rq_interpret_reply) { req->rq_status = req->rq_interpret_reply(env, req, &req->rq_async_args, rc); @@ -1678,7 +1686,8 @@ do { \ /** * This is the debug print function you need to use to print request structure * content into lustre debug log. - * for most callers (level is a constant) this is resolved at compile time */ + * for most callers (level is a constant) this is resolved at compile time + */ #define DEBUG_REQ(level, req, fmt, args...) \ do { \ if ((level) & (D_ERROR | D_WARNING)) { \ @@ -1947,7 +1956,7 @@ struct ptlrpc_service_ops { * or general metadata service for MDS. */ struct ptlrpc_service { - /** serialize /proc operations */ + /** serialize sysfs operations */ spinlock_t srv_lock; /** most often accessed fields */ /** chain thru all services */ @@ -2101,7 +2110,8 @@ struct ptlrpc_service_part { /** NRS head for regular requests */ struct ptlrpc_nrs scp_nrs_reg; /** NRS head for HP requests; this is only valid for services that can - * handle HP requests */ + * handle HP requests + */ struct ptlrpc_nrs *scp_nrs_hp; /** AT stuff */ @@ -2141,8 +2151,8 @@ struct ptlrpc_service_part { #define ptlrpc_service_for_each_part(part, i, svc) \ for (i = 0; \ i < (svc)->srv_ncpts && \ - (svc)->srv_parts != NULL && \ - ((part) = (svc)->srv_parts[i]) != NULL; i++) + (svc)->srv_parts && \ + ((part) = (svc)->srv_parts[i]); i++) /** * Declaration of ptlrpcd control structure @@ -2259,7 +2269,6 @@ static inline bool nrs_policy_compat_all(const struct ptlrpc_service *svc, static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc, const struct ptlrpc_nrs_pol_desc *desc) { - LASSERT(desc->pd_compat_svc_name != NULL); return strcmp(svc->srv_name, desc->pd_compat_svc_name) == 0; } @@ -2303,7 +2312,6 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req) struct ptlrpc_bulk_desc *desc; int rc; - LASSERT(req != NULL); desc = req->rq_bulk; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && @@ -2462,7 +2470,8 @@ struct ptlrpc_service_thr_conf { /* "soft" limit for total threads number */ unsigned int tc_nthrs_max; /* user specified threads number, it will be validated due to - * other members of this structure. */ + * other members of this structure. + */ unsigned int tc_nthrs_user; /* set NUMA node affinity for service threads */ unsigned int tc_cpu_affinity; @@ -2726,7 +2735,7 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req) static inline void ptlrpc_client_wake_req(struct ptlrpc_request *req) { - if (req->rq_set == NULL) + if (!req->rq_set) wake_up(&req->rq_reply_waitq); else wake_up(&req->rq_set->set_waitq); @@ -2750,7 +2759,7 @@ ptlrpc_rs_decref(struct ptlrpc_reply_state *rs) /* Should only be called once per req */ static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req) { - if (req->rq_reply_state == NULL) + if (!req->rq_reply_state) return; /* shouldn't occur */ ptlrpc_rs_decref(req->rq_reply_state); req->rq_reply_state = NULL; @@ -2807,7 +2816,6 @@ ptlrpc_server_get_timeout(struct ptlrpc_service_part *svcpt) static inline struct ptlrpc_service * ptlrpc_req2svc(struct ptlrpc_request *req) { - LASSERT(req->rq_rqbd != NULL); return req->rq_rqbd->rqbd_svcpt->scp_service; } diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index 46a662f..b5128e4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -130,7 +130,6 @@ void req_layout_fini(void); extern struct req_format RQF_OBD_PING; extern struct req_format RQF_OBD_SET_INFO; extern struct req_format RQF_SEC_CTX; -extern struct req_format RQF_OBD_IDX_READ; /* MGS req_format */ extern struct req_format RQF_MGS_TARGET_REG; extern struct req_format RQF_MGS_SET_INFO; @@ -146,7 +145,6 @@ extern struct req_format RQF_MDS_GETSTATUS; extern struct req_format RQF_MDS_SYNC; extern struct req_format RQF_MDS_GETXATTR; extern struct req_format RQF_MDS_GETATTR; -extern struct req_format RQF_UPDATE_OBJ; /* * This is format of direct (non-intent) MDS_GETATTR_NAME request. @@ -177,7 +175,6 @@ extern struct req_format RQF_MDS_REINT_SETXATTR; extern struct req_format RQF_MDS_QUOTACHECK; extern struct req_format RQF_MDS_QUOTACTL; extern struct req_format RQF_QC_CALLBACK; -extern struct req_format RQF_QUOTA_DQACQ; extern struct req_format RQF_MDS_SWAP_LAYOUTS; /* MDS hsm formats */ extern struct req_format RQF_MDS_HSM_STATE_GET; @@ -220,7 +217,6 @@ extern struct req_format RQF_LDLM_INTENT_OPEN; extern struct req_format RQF_LDLM_INTENT_CREATE; extern struct req_format RQF_LDLM_INTENT_UNLINK; extern struct req_format RQF_LDLM_INTENT_GETXATTR; -extern struct req_format RQF_LDLM_INTENT_QUOTA; extern struct req_format RQF_LDLM_CANCEL; extern struct req_format RQF_LDLM_CALLBACK; extern struct req_format RQF_LDLM_CP_CALLBACK; @@ -252,7 +248,6 @@ extern struct req_msg_field RMF_SETINFO_KEY; extern struct req_msg_field RMF_GETINFO_VAL; extern struct req_msg_field RMF_GETINFO_VALLEN; extern struct req_msg_field RMF_GETINFO_KEY; -extern struct req_msg_field RMF_IDX_INFO; extern struct req_msg_field RMF_CLOSE_DATA; /* @@ -277,7 +272,6 @@ extern struct req_msg_field RMF_CAPA1; extern struct req_msg_field RMF_CAPA2; extern struct req_msg_field RMF_OBD_QUOTACHECK; extern struct req_msg_field RMF_OBD_QUOTACTL; -extern struct req_msg_field RMF_QUOTA_BODY; extern struct req_msg_field RMF_STRING; extern struct req_msg_field RMF_SWAP_LAYOUTS; extern struct req_msg_field RMF_MDS_HSM_PROGRESS; @@ -322,9 +316,6 @@ extern struct req_msg_field RMF_MGS_CONFIG_RES; /* generic uint32 */ extern struct req_msg_field RMF_U32; -/* OBJ update format */ -extern struct req_msg_field RMF_UPDATE; -extern struct req_msg_field RMF_UPDATE_REPLY; /** @} req_layout */ #endif /* _LUSTRE_REQ_LAYOUT_H__ */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index f00d9a2..e63366b 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -90,7 +90,8 @@ struct lov_stripe_md { pid_t lsm_lock_owner; /* debugging */ /* maximum possible file size, might change as OSTs status changes, - * e.g. disconnected, deactivated */ + * e.g. disconnected, deactivated + */ __u64 lsm_maxbytes; struct { /* Public members. */ @@ -123,7 +124,7 @@ static inline bool lsm_is_released(struct lov_stripe_md *lsm) static inline bool lsm_has_objects(struct lov_stripe_md *lsm) { - if (lsm == NULL) + if (!lsm) return false; if (lsm_is_released(lsm)) return false; @@ -159,7 +160,8 @@ struct obd_info { /* An update callback which is called to update some data on upper * level. E.g. it is used for update lsm->lsm_oinfo at every received * request in osc level for enqueue requests. It is also possible to - * update some caller data from LOV layer if needed. */ + * update some caller data from LOV layer if needed. + */ obd_enqueue_update_f oi_cb_up; }; @@ -216,7 +218,6 @@ struct timeout_item { }; #define OSC_MAX_RIF_DEFAULT 8 -#define MDS_OSC_MAX_RIF_DEFAULT 50 #define OSC_MAX_RIF_MAX 256 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4) #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */ @@ -241,7 +242,8 @@ struct client_obd { struct obd_import *cl_import; /* ptlrpc connection state */ int cl_conn_count; /* max_mds_easize is purely a performance thing so we don't have to - * call obd_size_diskmd() all the time. */ + * call obd_size_diskmd() all the time. + */ int cl_default_mds_easize; int cl_max_mds_easize; int cl_default_mds_cookiesize; @@ -261,7 +263,8 @@ struct client_obd { /* since we allocate grant by blocks, we don't know how many grant will * be used to add a page into cache. As a solution, we reserve maximum * grant before trying to dirty a page and unreserve the rest. - * See osc_{reserve|unreserve}_grant for details. */ + * See osc_{reserve|unreserve}_grant for details. + */ long cl_reserved_grant; struct list_head cl_cache_waiters; /* waiting for cache/grant */ unsigned long cl_next_shrink_grant; /* jiffies */ @@ -269,14 +272,16 @@ struct client_obd { int cl_grant_shrink_interval; /* seconds */ /* A chunk is an optimal size used by osc_extent to determine - * the extent size. A chunk is max(PAGE_CACHE_SIZE, OST block size) */ + * the extent size. A chunk is max(PAGE_CACHE_SIZE, OST block size) + */ int cl_chunkbits; int cl_chunk; int cl_extent_tax; /* extent overhead, by bytes */ /* keep track of objects that have lois that contain pages which * have been queued for async brw. this lock also protects the - * lists of osc_client_pages that hang off of the loi */ + * lists of osc_client_pages that hang off of the loi + */ /* * ->cl_loi_list_lock protects consistency of * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and @@ -295,14 +300,14 @@ struct client_obd { * NB by Jinshan: though field names are still _loi_, but actually * osc_object{}s are in the list. */ - client_obd_lock_t cl_loi_list_lock; + struct client_obd_lock cl_loi_list_lock; struct list_head cl_loi_ready_list; struct list_head cl_loi_hp_ready_list; struct list_head cl_loi_write_list; struct list_head cl_loi_read_list; int cl_r_in_flight; int cl_w_in_flight; - /* just a sum of the loi/lop pending numbers to be exported by /proc */ + /* just a sum of the loi/lop pending numbers to be exported by sysfs */ atomic_t cl_pending_w_pages; atomic_t cl_pending_r_pages; __u32 cl_max_pages_per_rpc; @@ -322,7 +327,7 @@ struct client_obd { atomic_t cl_lru_shrinkers; atomic_t cl_lru_in_list; struct list_head cl_lru_list; /* lru page list */ - client_obd_lock_t cl_lru_list_lock; /* page list protector */ + struct client_obd_lock cl_lru_list_lock; /* page list protector */ /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ atomic_t cl_destroy_in_flight; @@ -340,7 +345,7 @@ struct client_obd { /* supported checksum types that are worked out at connect time */ __u32 cl_supp_cksum_types; /* checksum algorithm to be used */ - cksum_type_t cl_cksum_type; + enum cksum_type cl_cksum_type; /* also protected by the poorly named _loi_list_lock lock above */ struct osc_async_rc cl_ar; @@ -380,8 +385,7 @@ struct echo_client_obd { /* Generic subset of OSTs */ struct ost_pool { - __u32 *op_array; /* array of index of - lov_obd->lov_tgts */ + __u32 *op_array; /* array of index of lov_obd->lov_tgts */ unsigned int op_count; /* number of OSTs in the array */ unsigned int op_size; /* allocated size of lp_array */ struct rw_semaphore op_rw_sem; /* to protect ost_pool use */ @@ -414,14 +418,16 @@ struct lov_qos { struct lov_qos_rr lq_rr; /* round robin qos data */ unsigned long lq_dirty:1, /* recalc qos data */ lq_same_space:1,/* the ost's all have approx. - the same space avail */ + * the same space avail + */ lq_reset:1, /* zero current penalties */ lq_statfs_in_progress:1; /* statfs op in progress */ /* qos statfs data */ struct lov_statfs_data *lq_statfs_data; - wait_queue_head_t lq_statfs_waitq; /* waitqueue to notify statfs - * requests completion */ + wait_queue_head_t lq_statfs_waitq; /* waitqueue to notify statfs + * requests completion + */ }; struct lov_tgt_desc { @@ -449,16 +455,16 @@ struct pool_desc { struct lov_qos_rr pool_rr; /* round robin qos */ struct hlist_node pool_hash; /* access by poolname */ struct list_head pool_list; /* serial access */ - struct dentry *pool_debugfs_entry; /* file in /proc */ + struct dentry *pool_debugfs_entry; /* file in debugfs */ struct obd_device *pool_lobd; /* obd of the lov/lod to which - * this pool belongs */ + * this pool belongs + */ }; struct lov_obd { struct lov_desc desc; struct lov_tgt_desc **lov_tgts; /* sparse array */ - struct ost_pool lov_packed; /* all OSTs in a packed - array */ + struct ost_pool lov_packed; /* all OSTs in a packed array */ struct mutex lov_lock; struct obd_connect_data lov_ocd; atomic_t lov_refcount; @@ -595,34 +601,6 @@ struct obd_trans_info { struct obd_uuid *oti_ost_uuid; }; -static inline void oti_init(struct obd_trans_info *oti, - struct ptlrpc_request *req) -{ - if (oti == NULL) - return; - memset(oti, 0, sizeof(*oti)); - - if (req == NULL) - return; - - oti->oti_xid = req->rq_xid; - /** VBR: take versions from request */ - if (req->rq_reqmsg != NULL && - lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg); - - oti->oti_pre_version = pre_version ? pre_version[0] : 0; - oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg); - } - - /** called from mds_create_objects */ - if (req->rq_repmsg != NULL) - oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg); - oti->oti_thread = req->rq_svc_thread; - if (req->rq_reqmsg != NULL) - oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg); -} - static inline void oti_alloc_cookies(struct obd_trans_info *oti, int num_cookies) { @@ -727,21 +705,23 @@ struct obd_device { unsigned long obd_attached:1, /* finished attach */ obd_set_up:1, /* finished setup */ obd_version_recov:1, /* obd uses version checking */ - obd_replayable:1, /* recovery is enabled; inform clients */ - obd_no_transno:1, /* no committed-transno notification */ + obd_replayable:1,/* recovery is enabled; inform clients */ + obd_no_transno:1, /* no committed-transno notification */ obd_no_recov:1, /* fail instead of retry messages */ obd_stopping:1, /* started cleanup */ obd_starting:1, /* started setup */ obd_force:1, /* cleanup with > 0 obd refcount */ - obd_fail:1, /* cleanup with failover */ - obd_async_recov:1, /* allow asynchronous orphan cleanup */ + obd_fail:1, /* cleanup with failover */ + obd_async_recov:1, /* allow asynchronous orphan cleanup */ obd_no_conn:1, /* deny new connections */ obd_inactive:1, /* device active/inactive - * (for /proc/status only!!) */ + * (for sysfs status only!!) + */ obd_no_ir:1, /* no imperative recovery. */ obd_process_conf:1; /* device is processing mgs config */ /* use separate field as it is set in interrupt to don't mess with - * protection of other bits using _bh lock */ + * protection of other bits using _bh lock + */ unsigned long obd_recovery_expired:1; /* uuid-export hash body */ struct cfs_hash *obd_uuid_hash; @@ -934,7 +914,8 @@ struct md_op_data { __u32 op_npages; /* used to transfer info between the stacks of MD client - * see enum op_cli_flags */ + * see enum op_cli_flags + */ __u32 op_cli_flags; /* File object data version for HSM release, on client */ @@ -986,7 +967,8 @@ struct obd_ops { /* connect to the target device with given connection * data. @ocd->ocd_connect_flags is modified to reflect flags actually * granted by the target, which are guaranteed to be a subset of flags - * asked for. If @ocd == NULL, use default parameters. */ + * asked for. If @ocd == NULL, use default parameters. + */ int (*connect)(const struct lu_env *env, struct obd_export **exp, struct obd_device *src, struct obd_uuid *cluuid, struct obd_connect_data *ocd, @@ -1082,7 +1064,8 @@ struct obd_ops { /* * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. - * Also, add a wrapper function in include/linux/obd_class.h. */ + * Also, add a wrapper function in include/linux/obd_class.h. + */ }; enum { @@ -1188,14 +1171,14 @@ struct md_ops { struct obd_client_handle *); int (*set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *); - ldlm_mode_t (*lock_match)(struct obd_export *, __u64, - const struct lu_fid *, ldlm_type_t, - ldlm_policy_data_t *, ldlm_mode_t, - struct lustre_handle *); + enum ldlm_mode (*lock_match)(struct obd_export *, __u64, + const struct lu_fid *, enum ldlm_type, + ldlm_policy_data_t *, enum ldlm_mode, + struct lustre_handle *); int (*cancel_unused)(struct obd_export *, const struct lu_fid *, - ldlm_policy_data_t *, ldlm_mode_t, - ldlm_cancel_flags_t flags, void *opaque); + ldlm_policy_data_t *, enum ldlm_mode, + enum ldlm_cancel_flags flags, void *opaque); int (*get_remote_perm)(struct obd_export *, const struct lu_fid *, __u32, struct ptlrpc_request **); @@ -1252,7 +1235,7 @@ static inline struct md_open_data *obd_mod_alloc(void) struct md_open_data *mod; mod = kzalloc(sizeof(*mod), GFP_NOFS); - if (mod == NULL) + if (!mod) return NULL; atomic_set(&mod->mod_refcount, 1); return mod; @@ -1299,7 +1282,7 @@ static inline bool filename_is_volatile(const char *name, int namelen, int *idx) return false; /* caller does not care of idx */ - if (idx == NULL) + if (!idx) return true; /* volatile file, the MDT can be set from name */ @@ -1326,7 +1309,8 @@ static inline bool filename_is_volatile(const char *name, int namelen, int *idx) return true; bad_format: /* bad format of mdt idx, we cannot return an error - * to caller so we use hash algo */ + * to caller so we use hash algo + */ CERROR("Bad volatile file name format: %s\n", name + LUSTRE_VOLATILE_HDR_LEN); return false; @@ -1334,7 +1318,6 @@ bad_format: static inline int cli_brw_size(struct obd_device *obd) { - LASSERT(obd != NULL); return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; } diff --git a/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h index 01db604..637fa22 100644 --- a/drivers/staging/lustre/lustre/include/obd_cksum.h +++ b/drivers/staging/lustre/lustre/include/obd_cksum.h @@ -37,7 +37,7 @@ #include "../../include/linux/libcfs/libcfs.h" #include "lustre/lustre_idl.h" -static inline unsigned char cksum_obd2cfs(cksum_type_t cksum_type) +static inline unsigned char cksum_obd2cfs(enum cksum_type cksum_type) { switch (cksum_type) { case OBD_CKSUM_CRC32: @@ -63,8 +63,9 @@ static inline unsigned char cksum_obd2cfs(cksum_type_t cksum_type) * In case of an unsupported types/flags we fall back to ADLER * because that is supported by all clients since 1.8 * - * In case multiple algorithms are supported the best one is used. */ -static inline u32 cksum_type_pack(cksum_type_t cksum_type) + * In case multiple algorithms are supported the best one is used. + */ +static inline u32 cksum_type_pack(enum cksum_type cksum_type) { unsigned int performance = 0, tmp; u32 flag = OBD_FL_CKSUM_ADLER; @@ -98,7 +99,7 @@ static inline u32 cksum_type_pack(cksum_type_t cksum_type) return flag; } -static inline cksum_type_t cksum_type_unpack(u32 o_flags) +static inline enum cksum_type cksum_type_unpack(u32 o_flags) { switch (o_flags & OBD_FL_CKSUM_ALL) { case OBD_FL_CKSUM_CRC32C: @@ -116,9 +117,9 @@ static inline cksum_type_t cksum_type_unpack(u32 o_flags) * 1.8 supported ADLER it is base and not depend on hw * Client uses all available local algos */ -static inline cksum_type_t cksum_types_supported_client(void) +static inline enum cksum_type cksum_types_supported_client(void) { - cksum_type_t ret = OBD_CKSUM_ADLER; + enum cksum_type ret = OBD_CKSUM_ADLER; CDEBUG(D_INFO, "Crypto hash speed: crc %d, crc32c %d, adler %d\n", cfs_crypto_hash_speed(cksum_obd2cfs(OBD_CKSUM_CRC32)), @@ -139,14 +140,16 @@ static inline cksum_type_t cksum_types_supported_client(void) * Currently, calling cksum_type_pack() with a mask will return the fastest * checksum type due to its benchmarking at libcfs module load. * Caution is advised, however, since what is fastest on a single client may - * not be the fastest or most efficient algorithm on the server. */ -static inline cksum_type_t cksum_type_select(cksum_type_t cksum_types) + * not be the fastest or most efficient algorithm on the server. + */ +static inline enum cksum_type cksum_type_select(enum cksum_type cksum_types) { return cksum_type_unpack(cksum_type_pack(cksum_types)); } /* Checksum algorithm names. Must be defined in the same order as the - * OBD_CKSUM_* flags. */ + * OBD_CKSUM_* flags. + */ #define DECLARE_CKSUM_NAME char *cksum_name[] = {"crc32", "adler", "crc32c"} #endif /* __OBD_H */ diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 4f631e6..8515218 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -45,18 +45,22 @@ #include "lprocfs_status.h" #define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay - * and resends for avoid deadlocks */ + * and resends for avoid deadlocks + */ #define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update - * obd_osfs_age */ + * obd_osfs_age + */ #define OBD_STATFS_PTLRPCD 0x0004 /* requests will be sent via ptlrpcd * instead of a specific set. This * means that we cannot rely on the set * interpret routine to be called. * lov_statfs_fini() must thus be called - * by the request interpret routine */ + * by the request interpret routine + */ #define OBD_STATFS_FOR_MDT0 0x0008 /* The statfs is only for retrieving - * information from MDT0. */ -#define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */ + * information from MDT0. + */ +#define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */ /* OBD Device Declarations */ extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; @@ -160,8 +164,9 @@ struct config_llog_data { struct mutex cld_lock; int cld_type; unsigned int cld_stopping:1, /* we were told to stop - * watching */ - cld_lostlock:1; /* lock not requeued */ + * watching + */ + cld_lostlock:1; /* lock not requeued */ char cld_logname[0]; }; @@ -275,7 +280,8 @@ void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid); #define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op /* Ensure obd_setup: used for cleanup which must be called - while obd is stopping */ + * while obd is stopping + */ static inline int obd_check_dev(struct obd_device *obd) { if (!obd) { @@ -306,7 +312,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) / sizeof(((struct obd_ops *)(0))->iocontrol)) #define OBD_COUNTER_INCREMENT(obdx, op) \ - if ((obdx)->obd_stats != NULL) { \ + if ((obdx)->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((obdx)->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ @@ -315,7 +321,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) } #define EXP_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ + if ((export)->exp_obd->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ OBD_COUNTER_OFFSET(op); \ @@ -329,7 +335,7 @@ static inline int obd_check_dev_active(struct obd_device *obd) / sizeof(((struct md_ops *)(0))->getstatus)) #define MD_COUNTER_INCREMENT(obdx, op) \ - if ((obd)->md_stats != NULL) { \ + if ((obd)->md_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((obdx)->md_cntr_base) + \ MD_COUNTER_OFFSET(op); \ @@ -338,24 +344,24 @@ static inline int obd_check_dev_active(struct obd_device *obd) } #define EXP_MD_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ + if ((export)->exp_obd->obd_stats) { \ unsigned int coffset; \ coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ MD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ - if ((export)->exp_md_stats != NULL) \ + if ((export)->exp_md_stats) \ lprocfs_counter_incr( \ (export)->exp_md_stats, coffset); \ } #define EXP_CHECK_MD_OP(exp, op) \ do { \ - if ((exp) == NULL) { \ + if (!(exp)) { \ CERROR("obd_" #op ": NULL export\n"); \ return -ENODEV; \ } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ + if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ return -EOPNOTSUPP; \ } \ @@ -379,11 +385,11 @@ do { \ #define EXP_CHECK_DT_OP(exp, op) \ do { \ - if ((exp) == NULL) { \ + if (!(exp)) { \ CERROR("obd_" #op ": NULL export\n"); \ return -ENODEV; \ } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ + if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ return -EOPNOTSUPP; \ } \ @@ -467,7 +473,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) DECLARE_LU_VARS(ldt, d); ldt = obd->obd_type->typ_lu; - if (ldt != NULL) { + if (ldt) { struct lu_context session_ctx; struct lu_env env; @@ -509,7 +515,7 @@ static inline int obd_precleanup(struct obd_device *obd, return rc; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { if (cleanup_stage == OBD_CLEANUP_EXPORTS) { struct lu_env env; @@ -538,7 +544,7 @@ static inline int obd_cleanup(struct obd_device *obd) ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { struct lu_env env; rc = lu_env_init(&env, ldt->ldt_ctx_tags); @@ -558,7 +564,8 @@ static inline int obd_cleanup(struct obd_device *obd) static inline void obd_cleanup_client_import(struct obd_device *obd) { /* If we set up but never connected, the - client import will not have been cleaned. */ + * client import will not have been cleaned. + */ down_write(&obd->u.cli.cl_sem); if (obd->u.cli.cl_import) { struct obd_import *imp; @@ -586,7 +593,7 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) obd->obd_process_conf = 1; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { + if (ldt && d) { struct lu_env env; rc = lu_env_init(&env, ldt->ldt_ctx_tags); @@ -674,7 +681,7 @@ static inline int obd_alloc_memmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt) { LASSERT(mem_tgt); - LASSERT(*mem_tgt == NULL); + LASSERT(!*mem_tgt); return obd_unpackmd(exp, mem_tgt, NULL, 0); } @@ -767,7 +774,7 @@ static inline int obd_setattr_rqset(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, setattr_async); set = ptlrpc_prep_set(); - if (set == NULL) + if (!set) return -ENOMEM; rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); @@ -778,7 +785,8 @@ static inline int obd_setattr_rqset(struct obd_export *exp, } /* This adds all the requests into @set if @set != NULL, otherwise - all requests are sent asynchronously without waiting for response. */ + * all requests are sent asynchronously without waiting for response. + */ static inline int obd_setattr_async(struct obd_export *exp, struct obd_info *oinfo, struct obd_trans_info *oti, @@ -848,7 +856,8 @@ static inline int obd_connect(const struct lu_env *env, { int rc; __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition - * check */ + * check + */ rc = obd_check_dev_active(obd); if (rc) @@ -858,7 +867,7 @@ static inline int obd_connect(const struct lu_env *env, rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); /* check that only subset is granted */ - LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == + LASSERT(ergo(data, (data->ocd_connect_flags & ocf) == data->ocd_connect_flags)); return rc; } @@ -871,8 +880,7 @@ static inline int obd_reconnect(const struct lu_env *env, void *localdata) { int rc; - __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition - * check */ + __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ rc = obd_check_dev_active(obd); if (rc) @@ -882,8 +890,7 @@ static inline int obd_reconnect(const struct lu_env *env, rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); /* check that only subset is granted */ - LASSERT(ergo(d != NULL, - (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); + LASSERT(ergo(d, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); return rc; } @@ -998,7 +1005,7 @@ static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && + if ((exp)->exp_obd && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); return rc; @@ -1006,7 +1013,7 @@ static inline int obd_init_export(struct obd_export *exp) static inline int obd_destroy_export(struct obd_export *exp) { - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && + if ((exp)->exp_obd && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); return 0; @@ -1014,7 +1021,8 @@ static inline int obd_destroy_export(struct obd_export *exp) /* @max_age is the oldest time in jiffies that we accept using a cached data. * If the cache is older than @max_age we will get a new value from the - * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ + * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. + */ static inline int obd_statfs_async(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, @@ -1023,7 +1031,7 @@ static inline int obd_statfs_async(struct obd_export *exp, int rc = 0; struct obd_device *obd; - if (exp == NULL || exp->exp_obd == NULL) + if (!exp || !exp->exp_obd) return -EINVAL; obd = exp->exp_obd; @@ -1059,7 +1067,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, int rc = 0; set = ptlrpc_prep_set(); - if (set == NULL) + if (!set) return -ENOMEM; oinfo.oi_osfs = osfs; @@ -1073,7 +1081,8 @@ static inline int obd_statfs_rqset(struct obd_export *exp, /* @max_age is the oldest time in jiffies that we accept using a cached data. * If the cache is older than @max_age we will get a new value from the - * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ + * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. + */ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) @@ -1081,7 +1090,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, int rc = 0; struct obd_device *obd = exp->exp_obd; - if (obd == NULL) + if (!obd) return -EINVAL; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); @@ -1205,9 +1214,10 @@ static inline int obd_notify(struct obd_device *obd, return rc; /* the check for async_recov is a complete hack - I'm hereby - overloading the meaning to also mean "this was called from - mds_postsetup". I know that my mds is able to handle notifies - by this point, and it needs to get them to execute mds_postrecov. */ + * overloading the meaning to also mean "this was called from + * mds_postsetup". I know that my mds is able to handle notifies + * by this point, and it needs to get them to execute mds_postrecov. + */ if (!obd->obd_set_up && !obd->obd_async_recov) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); return -EINVAL; @@ -1241,7 +1251,7 @@ static inline int obd_notify_observer(struct obd_device *observer, * Also, call non-obd listener, if any */ onu = &observer->obd_upcall; - if (onu->onu_upcall != NULL) + if (onu->onu_upcall) rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner, NULL); else @@ -1287,7 +1297,7 @@ static inline int obd_health_check(const struct lu_env *env, int rc; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ - if (obd == NULL || !OBT(obd)) { + if (!obd || !OBT(obd)) { CERROR("cleaned up obd\n"); return -EOPNOTSUPP; } @@ -1318,57 +1328,6 @@ static inline int obd_register_observer(struct obd_device *obd, return 0; } -#if 0 -static inline int obd_register_page_removal_cb(struct obd_export *exp, - obd_page_removal_cb_t cb, - obd_pin_extent_cb pin_cb) -{ - int rc; - - OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0); - OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); - - rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb); - return rc; -} - -static inline int obd_unregister_page_removal_cb(struct obd_export *exp, - obd_page_removal_cb_t cb) -{ - int rc; - - OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0); - OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); - - rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb); - return rc; -} - -static inline int obd_register_lock_cancel_cb(struct obd_export *exp, - obd_lock_cancel_cb cb) -{ - int rc; - - OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0); - OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); - - rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb); - return rc; -} - -static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, - obd_lock_cancel_cb cb) -{ - int rc; - - OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0); - OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); - - rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb); - return rc; -} -#endif - /* metadata helpers */ static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid) { @@ -1657,8 +1616,8 @@ static inline int md_set_lock_data(struct obd_export *exp, static inline int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, ldlm_policy_data_t *policy, - ldlm_mode_t mode, - ldlm_cancel_flags_t flags, + enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque) { int rc; @@ -1671,12 +1630,12 @@ static inline int md_cancel_unused(struct obd_export *exp, return rc; } -static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, - const struct lu_fid *fid, - ldlm_type_t type, - ldlm_policy_data_t *policy, - ldlm_mode_t mode, - struct lustre_handle *lockh) +static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, + enum ldlm_type type, + ldlm_policy_data_t *policy, + enum ldlm_mode mode, + struct lustre_handle *lockh) { EXP_CHECK_MD_OP(exp, lock_match); EXP_MD_COUNTER_INCREMENT(exp, lock_match); @@ -1759,7 +1718,8 @@ struct lwp_register_item { /* I'm as embarrassed about this as you are. * * <shaver> // XXX do not look into _superhack with remaining eye - * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ + * <shaver> // XXX if this were any uglier, I'd get my own show on MTV + */ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); /* obd_mount.c */ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index d031437..225262fa 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -47,7 +47,8 @@ extern unsigned int obd_debug_peer_on_timeout; extern unsigned int obd_dump_on_timeout; extern unsigned int obd_dump_on_eviction; /* obd_timeout should only be used for recovery, not for - networking / disk / timings affected by load (use Adaptive Timeouts) */ + * networking / disk / timings affected by load (use Adaptive Timeouts) + */ extern unsigned int obd_timeout; /* seconds */ extern unsigned int obd_timeout_set; extern unsigned int at_min; @@ -104,18 +105,21 @@ extern char obd_jobid_var[]; * failover targets the client only pings one server at a time, and pings * can be lost on a loaded network. Since eviction has serious consequences, * and there's no urgent need to evict a client just because it's idle, we - * should be very conservative here. */ + * should be very conservative here. + */ #define PING_EVICT_TIMEOUT (PING_INTERVAL * 6) #define DISK_TIMEOUT 50 /* Beyond this we warn about disk speed */ #define CONNECTION_SWITCH_MIN 5U /* Connection switching rate limiter */ - /* Max connect interval for nonresponsive servers; ~50s to avoid building up - connect requests in the LND queues, but within obd_timeout so we don't - miss the recovery window */ +/* Max connect interval for nonresponsive servers; ~50s to avoid building up + * connect requests in the LND queues, but within obd_timeout so we don't + * miss the recovery window + */ #define CONNECTION_SWITCH_MAX min(50U, max(CONNECTION_SWITCH_MIN, obd_timeout)) #define CONNECTION_SWITCH_INC 5 /* Connection timeout backoff */ /* In general this should be low to have quick detection of a system - running on a backup server. (If it's too low, import_select_connection - will increase the timeout anyhow.) */ + * running on a backup server. (If it's too low, import_select_connection + * will increase the timeout anyhow.) + */ #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN, obd_timeout/20) /* The max delay between connects is SWITCH_MAX + SWITCH_INC + INITIAL */ #define RECONNECT_DELAY_MAX (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC + \ @@ -507,7 +511,6 @@ extern char obd_jobid_var[]; do { \ struct portals_handle *__h = (handle); \ \ - LASSERT(handle != NULL); \ __h->h_cookie = (unsigned long)(ptr); \ __h->h_size = (size); \ call_rcu(&__h->h_rcu, class_handle_free_cb); \ diff --git a/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index 8533a1e..c4e8a08 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/drivers/staging/lustre/lustre/lclient/glimpse.c @@ -109,7 +109,8 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, * if there were no conflicting locks. If there * were conflicting locks, enqueuing or waiting * fails with -ENAVAIL, but valid inode - * attributes are returned anyway. */ + * attributes are returned anyway. + */ *descr = whole_file; descr->cld_obj = clob; descr->cld_mode = CLM_PHANTOM; diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 4dfeb4e..30651f2 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -117,7 +117,7 @@ void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key) struct ccc_thread_info *info; info = kmem_cache_alloc(ccc_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -136,7 +136,7 @@ void *ccc_session_key_init(const struct lu_context *ctx, struct ccc_session *session; session = kmem_cache_alloc(ccc_session_kmem, GFP_NOFS | __GFP_ZERO); - if (session == NULL) + if (!session) session = ERR_PTR(-ENOMEM); return session; } @@ -173,7 +173,7 @@ int ccc_device_init(const struct lu_env *env, struct lu_device *d, vdv = lu2ccc_dev(d); vdv->cdv_next = lu2cl_dev(next); - LASSERT(d->ld_site != NULL && next->ld_type != NULL); + LASSERT(d->ld_site && next->ld_type); next->ld_site = d->ld_site; rc = next->ld_type->ldt_ops->ldto_device_init( env, next, next->ld_type->ldt_name, NULL); @@ -211,12 +211,12 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, vdv->cdv_cl.cd_ops = clops; site = kzalloc(sizeof(*site), GFP_NOFS); - if (site != NULL) { + if (site) { rc = cl_site_init(site, &vdv->cdv_cl); if (rc == 0) rc = lu_site_init_finish(&site->cs_lu); else { - LASSERT(lud->ld_site == NULL); + LASSERT(!lud->ld_site); CERROR("Cannot init lu_site, rc %d.\n", rc); kfree(site); } @@ -236,7 +236,7 @@ struct lu_device *ccc_device_free(const struct lu_env *env, struct cl_site *site = lu2cl_site(d->ld_site); struct lu_device *next = cl2lu_dev(vdv->cdv_next); - if (d->ld_site != NULL) { + if (d->ld_site) { cl_site_fini(site); kfree(site); } @@ -252,7 +252,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev, int result; vrq = kmem_cache_alloc(ccc_req_kmem, GFP_NOFS | __GFP_ZERO); - if (vrq != NULL) { + if (vrq) { cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops); result = 0; } else @@ -304,7 +304,7 @@ out_kmem: void ccc_global_fini(struct lu_device_type *device_type) { - if (ccc_inode_fini_env != NULL) { + if (ccc_inode_fini_env) { cl_env_put(ccc_inode_fini_env, &dummy_refcheck); ccc_inode_fini_env = NULL; } @@ -328,7 +328,7 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env, struct lu_object *obj; vob = kmem_cache_alloc(ccc_object_kmem, GFP_NOFS | __GFP_ZERO); - if (vob != NULL) { + if (vob) { struct cl_object_header *hdr; obj = ccc2lu(vob); @@ -365,7 +365,7 @@ int ccc_object_init(const struct lu_env *env, struct lu_object *obj, under = &dev->cdv_next->cd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); - if (below != NULL) { + if (below) { const struct cl_object_conf *cconf; cconf = lu2cl_conf(conf); @@ -397,7 +397,7 @@ int ccc_lock_init(const struct lu_env *env, CLOBINVRNT(env, obj, ccc_object_invariant(obj)); clk = kmem_cache_alloc(ccc_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (clk != NULL) { + if (clk) { cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops); result = 0; } else @@ -613,7 +613,8 @@ void ccc_lock_state(const struct lu_env *env, * stale i_size when doing appending writes and effectively * cancel the result of the truncate. Getting the * ll_inode_size_lock() after the enqueue maintains the DLM - * -> ll_inode_size_lock() acquiring order. */ + * -> ll_inode_size_lock() acquiring order. + */ if (lock->cll_descr.cld_start == 0 && lock->cll_descr.cld_end == CL_PAGE_EOF) cl_merge_lvb(env, inode); @@ -660,7 +661,7 @@ void ccc_io_update_iov(const struct lu_env *env, { size_t size = io->u.ci_rw.crw_count; - if (!cl_is_normalio(env, io) || cio->cui_iter == NULL) + if (!cl_is_normalio(env, io) || !cio->cui_iter) return; iov_iter_truncate(cio->cui_iter, size); @@ -749,12 +750,13 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, */ ccc_object_size_unlock(obj); result = cl_glimpse_lock(env, io, inode, obj, 0); - if (result == 0 && exceed != NULL) { + if (result == 0 && exceed) { /* If objective page index exceed end-of-file * page index, return directly. Do not expect * kernel will check such case correctly. * linux-2.6.18-128.1.1 miss to do that. - * --bug 17336 */ + * --bug 17336 + */ loff_t size = cl_isize_read(inode); loff_t cur_index = start >> PAGE_CACHE_SHIFT; loff_t size_index = (size - 1) >> @@ -884,7 +886,8 @@ again: if (attr->ia_valid & ATTR_FILE) /* populate the file descriptor for ftruncate to honor - * group lock - see LU-787 */ + * group lock - see LU-787 + */ cio->cui_fd = cl_iattr2fd(inode, attr); result = cl_io_loop(env, io); @@ -896,7 +899,8 @@ again: goto again; /* HSM import case: file is released, cannot be restored * no need to fail except if restore registration failed - * with -ENODATA */ + * with -ENODATA + */ if (result == -ENODATA && io->ci_restore_needed && io->ci_result != -ENODATA) result = 0; @@ -1022,11 +1026,12 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) fid = &lli->lli_fid; LASSERT(fid_is_sane(fid)); - if (lli->lli_clob == NULL) { + if (!lli->lli_clob) { /* clob is slave of inode, empty lli_clob means for new inode, * there is no clob in cache with the given fid, so it is * unnecessary to perform lookup-alloc-lookup-insert, just - * alloc and insert directly. */ + * alloc and insert directly. + */ LASSERT(inode->i_state & I_NEW); conf.coc_lu.loc_flags = LOC_F_NEW; clob = cl_object_find(env, lu2cl_dev(site->ls_top_dev), @@ -1098,7 +1103,7 @@ void cl_inode_fini(struct inode *inode) int refcheck; int emergency; - if (clob != NULL) { + if (clob) { void *cookie; cookie = cl_env_reenter(); @@ -1106,7 +1111,7 @@ void cl_inode_fini(struct inode *inode) emergency = IS_ERR(env); if (emergency) { mutex_lock(&ccc_inode_fini_guard); - LASSERT(ccc_inode_fini_env != NULL); + LASSERT(ccc_inode_fini_env); cl_env_implant(ccc_inode_fini_env, &refcheck); env = ccc_inode_fini_env; } @@ -1151,7 +1156,8 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent) } /** - * build inode number from passed @fid */ + * build inode number from passed @fid + */ __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) { if (BITS_PER_LONG == 32 || api32) @@ -1162,7 +1168,8 @@ __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) /** * build inode generation from passed @fid. If our FID overflows the 32-bit - * inode number then return a non-zero generation to distinguish them. */ + * inode number then return a non-zero generation to distinguish them. + */ __u32 cl_fid_build_gen(const struct lu_fid *fid) { __u32 gen; @@ -1183,7 +1190,8 @@ __u32 cl_fid_build_gen(const struct lu_fid *fid) * have to wait for the refcount to become zero to destroy the older layout. * * Notice that the lsm returned by this function may not be valid unless called - * inside layout lock - MDS_INODELOCK_LAYOUT. */ + * inside layout lock - MDS_INODELOCK_LAYOUT. + */ struct lov_stripe_md *ccc_inode_lsm_get(struct inode *inode) { return lov_lsm_get(cl_i2info(inode)->lli_clob); diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index 8389a0e..d80bcedd 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -48,7 +48,8 @@ /* Initialize the default and maximum LOV EA and cookie sizes. This allows * us to make MDS RPCs with large enough reply buffers to hold the * maximum-sized (= maximum striped) EA and cookie without having to - * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */ + * calculate this (via a call into the LOV + OSCs) each time we make an RPC. + */ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) { struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC_V3 }; @@ -74,7 +75,8 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) cookiesize = stripes * sizeof(struct llog_cookie); /* default cookiesize is 0 because from 2.4 server doesn't send - * llog cookies to client. */ + * llog cookies to client. + */ CDEBUG(D_HA, "updating def/max_easize: %d/%d def/max_cookiesize: 0/%d\n", def_easize, easize, cookiesize); diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index a2ea8e5..3230606 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -49,13 +49,11 @@ enum { static inline int node_is_left_child(struct interval_node *node) { - LASSERT(node->in_parent != NULL); return node == node->in_parent->in_left; } static inline int node_is_right_child(struct interval_node *node) { - LASSERT(node->in_parent != NULL); return node == node->in_parent->in_right; } @@ -135,7 +133,8 @@ static void __rotate_change_maxhigh(struct interval_node *node, /* The left rotation "pivots" around the link from node to node->right, and * - node will be linked to node->right's left child, and - * - node->right's left child will be linked to node's right child. */ + * - node->right's left child will be linked to node's right child. + */ static void __rotate_left(struct interval_node *node, struct interval_node **root) { @@ -164,7 +163,8 @@ static void __rotate_left(struct interval_node *node, /* The right rotation "pivots" around the link from node to node->left, and * - node will be linked to node->left's right child, and - * - node->left's right child will be linked to node's left child. */ + * - node->left's right child will be linked to node's left child. + */ static void __rotate_right(struct interval_node *node, struct interval_node **root) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 9c70f31..222cb62 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -62,7 +62,8 @@ * is the "highest lock". This function returns the new KMS value. * Caller must hold lr_lock already. * - * NB: A lock on [x,y] protects a KMS of up to y + 1 bytes! */ + * NB: A lock on [x,y] protects a KMS of up to y + 1 bytes! + */ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) { struct ldlm_resource *res = lock->l_resource; @@ -72,7 +73,8 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) /* don't let another thread in ldlm_extent_shift_kms race in * just after we finish and take our lock into account in its - * calculation of the kms */ + * calculation of the kms + */ lock->l_flags |= LDLM_FL_KMS_IGNORE; list_for_each(tmp, &res->lr_granted) { @@ -85,7 +87,8 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) return old_kms; /* This extent _has_ to be smaller than old_kms (checked above) - * so kms can only ever be smaller or the same as old_kms. */ + * so kms can only ever be smaller or the same as old_kms. + */ if (lck->l_policy_data.l_extent.end + 1 > kms) kms = lck->l_policy_data.l_extent.end + 1; } @@ -113,7 +116,7 @@ struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock) LASSERT(lock->l_resource->lr_type == LDLM_EXTENT); node = kmem_cache_alloc(ldlm_interval_slab, GFP_NOFS | __GFP_ZERO); - if (node == NULL) + if (!node) return NULL; INIT_LIST_HEAD(&node->li_group); @@ -134,7 +137,7 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l) { struct ldlm_interval *n = l->l_tree_node; - if (n == NULL) + if (!n) return NULL; LASSERT(!list_empty(&n->li_group)); @@ -144,7 +147,7 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l) return list_empty(&n->li_group) ? n : NULL; } -static inline int lock_mode_to_index(ldlm_mode_t mode) +static inline int lock_mode_to_index(enum ldlm_mode mode) { int index; @@ -168,7 +171,7 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, LASSERT(lock->l_granted_mode == lock->l_req_mode); node = lock->l_tree_node; - LASSERT(node != NULL); + LASSERT(node); LASSERT(!interval_is_intree(&node->li_node)); idx = lock_mode_to_index(lock->l_granted_mode); @@ -185,14 +188,14 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_interval *tmp; tmp = ldlm_interval_detach(lock); - LASSERT(tmp != NULL); ldlm_interval_free(tmp); ldlm_interval_attach(to_ldlm_interval(found), lock); } res->lr_itree[idx].lit_size++; /* even though we use interval tree to manage the extent lock, we also - * add the locks into grant list, for debug purpose, .. */ + * add the locks into grant list, for debug purpose, .. + */ ldlm_resource_add_lock(res, &res->lr_granted, lock); } @@ -211,7 +214,7 @@ void ldlm_extent_unlink_lock(struct ldlm_lock *lock) LASSERT(lock->l_granted_mode == 1 << idx); tree = &res->lr_itree[idx]; - LASSERT(tree->lit_root != NULL); /* assure the tree is not null */ + LASSERT(tree->lit_root); /* assure the tree is not null */ tree->lit_size--; node = ldlm_interval_detach(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 4310154..b88b786 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -92,7 +92,7 @@ ldlm_flocks_overlap(struct ldlm_lock *lock, struct ldlm_lock *new) } static inline void -ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) +ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode, __u64 flags) { LDLM_DEBUG(lock, "ldlm_flock_destroy(mode: %d, flags: 0x%llx)", mode, flags); @@ -107,7 +107,8 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_CBPENDING; /* when reaching here, it is under lock_res_and_lock(). Thus, - need call the nolock version of ldlm_lock_decref_internal*/ + * need call the nolock version of ldlm_lock_decref_internal + */ ldlm_lock_decref_internal_nolock(lock, mode); } @@ -133,7 +134,7 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) * would be collected and ASTs sent. */ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, - int first_enq, ldlm_error_t *err, + int first_enq, enum ldlm_error *err, struct list_head *work_list) { struct ldlm_resource *res = req->l_resource; @@ -143,7 +144,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, struct ldlm_lock *lock = NULL; struct ldlm_lock *new = req; struct ldlm_lock *new2 = NULL; - ldlm_mode_t mode = req->l_req_mode; + enum ldlm_mode mode = req->l_req_mode; int added = (mode == LCK_NL); int overlaps = 0; int splitted = 0; @@ -159,13 +160,15 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, *err = ELDLM_OK; /* No blocking ASTs are sent to the clients for - * Posix file & record locks */ + * Posix file & record locks + */ req->l_blocking_ast = NULL; reprocess: if ((*flags == LDLM_FL_WAIT_NOREPROC) || (mode == LCK_NL)) { /* This loop determines where this processes locks start - * in the resource lr_granted list. */ + * in the resource lr_granted list. + */ list_for_each(tmp, &res->lr_granted) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -180,7 +183,8 @@ reprocess: lockmode_verify(mode); /* This loop determines if there are existing locks - * that conflict with the new lock request. */ + * that conflict with the new lock request. + */ list_for_each(tmp, &res->lr_granted) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -238,8 +242,8 @@ reprocess: } /* Scan the locks owned by this process that overlap this request. - * We may have to merge or split existing locks. */ - + * We may have to merge or split existing locks. + */ if (!ownlocks) ownlocks = &res->lr_granted; @@ -253,7 +257,8 @@ reprocess: /* If the modes are the same then we need to process * locks that overlap OR adjoin the new lock. The extra * logic condition is necessary to deal with arithmetic - * overflow and underflow. */ + * overflow and underflow. + */ if ((new->l_policy_data.l_flock.start > (lock->l_policy_data.l_flock.end + 1)) && (lock->l_policy_data.l_flock.end != @@ -327,11 +332,13 @@ reprocess: * with the request but this would complicate the reply * processing since updates to req get reflected in the * reply. The client side replays the lock request so - * it must see the original lock data in the reply. */ + * it must see the original lock data in the reply. + */ /* XXX - if ldlm_lock_new() can sleep we should * release the lr_lock, allocate the new lock, - * and restart processing this lock. */ + * and restart processing this lock. + */ if (!new2) { unlock_res_and_lock(req); new2 = ldlm_lock_create(ns, &res->lr_name, LDLM_FLOCK, @@ -361,7 +368,7 @@ reprocess: lock->l_policy_data.l_flock.start = new->l_policy_data.l_flock.end + 1; new2->l_conn_export = lock->l_conn_export; - if (lock->l_export != NULL) { + if (lock->l_export) { new2->l_export = class_export_lock_get(lock->l_export, new2); if (new2->l_export->exp_lock_hash && @@ -381,7 +388,7 @@ reprocess: } /* if new2 is created but never used, destroy it*/ - if (splitted == 0 && new2 != NULL) + if (splitted == 0 && new2) ldlm_lock_destroy_nolock(new2); /* At this point we're granting the lock request. */ @@ -396,7 +403,8 @@ reprocess: if (*flags != LDLM_FL_WAIT_NOREPROC) { /* The only one possible case for client-side calls flock * policy function is ldlm_flock_completion_ast inside which - * carries LDLM_FL_WAIT_NOREPROC flag. */ + * carries LDLM_FL_WAIT_NOREPROC flag. + */ CERROR("Illegal parameter for client-side-only module.\n"); LBUG(); } @@ -404,7 +412,8 @@ reprocess: /* In case we're reprocessing the requested lock we can't destroy * it until after calling ldlm_add_ast_work_item() above so that laawi() * can bump the reference count on \a req. Otherwise \a req - * could be freed before the completion AST can be sent. */ + * could be freed before the completion AST can be sent. + */ if (added) ldlm_flock_destroy(req, mode, *flags); @@ -449,7 +458,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct obd_import *imp = NULL; struct ldlm_flock_wait_data fwd; struct l_wait_info lwi; - ldlm_error_t err; + enum ldlm_error err; int rc = 0; CDEBUG(D_DLMTRACE, "flags: 0x%llx data: %p getlk: %p\n", @@ -458,12 +467,12 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) /* Import invalidation. We need to actually release the lock * references being held, so that it can go away. No point in * holding the lock even if app still believes it has it, since - * server already dropped it anyway. Only for granted locks too. */ + * server already dropped it anyway. Only for granted locks too. + */ if ((lock->l_flags & (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) == (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) { if (lock->l_req_mode == lock->l_granted_mode && - lock->l_granted_mode != LCK_NL && - data == NULL) + lock->l_granted_mode != LCK_NL && !data) ldlm_lock_decref_internal(lock, lock->l_req_mode); /* Need to wake up the waiter if we were evicted */ @@ -475,7 +484,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { - if (data == NULL) + if (!data) /* mds granted the lock in the reply */ goto granted; /* CP AST RPC: lock get granted, wake it up */ @@ -488,10 +497,10 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) obd = class_exp2obd(lock->l_conn_export); /* if this is a local lock, there is no import */ - if (obd != NULL) + if (obd) imp = obd->u.cli.cl_import; - if (imp != NULL) { + if (imp) { spin_lock(&imp->imp_lock); fwd.fwd_generation = imp->imp_generation; spin_unlock(&imp->imp_lock); @@ -540,7 +549,8 @@ granted: } else if (flags & LDLM_FL_TEST_LOCK) { /* fcntl(F_GETLK) request */ /* The old mode was saved in getlk->fl_type so that if the mode - * in the lock changes we can decref the appropriate refcount.*/ + * in the lock changes we can decref the appropriate refcount. + */ ldlm_flock_destroy(lock, getlk->fl_type, LDLM_FL_WAIT_NOREPROC); switch (lock->l_granted_mode) { case LCK_PR: @@ -559,7 +569,8 @@ granted: __u64 noreproc = LDLM_FL_WAIT_NOREPROC; /* We need to reprocess the lock to do merges or splits - * with existing locks owned by this process. */ + * with existing locks owned by this process. + */ ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); } unlock_res_and_lock(lock); @@ -576,7 +587,8 @@ void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; /* Compat code, old clients had no idea about owner field and * relied solely on pid for ownership. Introduced in LU-104, 2.1, - * April 2011 */ + * April 2011 + */ lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 849cc98..e21373e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -96,14 +96,15 @@ enum { LDLM_CANCEL_SHRINK = 1 << 2, /* Cancel locks from shrinker. */ LDLM_CANCEL_LRUR = 1 << 3, /* Cancel locks from lru resize. */ LDLM_CANCEL_NO_WAIT = 1 << 4 /* Cancel locks w/o blocking (neither - * sending nor waiting for any rpcs) */ + * sending nor waiting for any rpcs) + */ }; int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, - ldlm_cancel_flags_t sync, int flags); + enum ldlm_cancel_flags sync, int flags); int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, int count, int max, - ldlm_cancel_flags_t cancel_flags, int flags); + enum ldlm_cancel_flags cancel_flags, int flags); extern int ldlm_enqueue_min; /* ldlm_resource.c */ @@ -133,11 +134,11 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, enum req_location loc, void *data, int size); struct ldlm_lock * ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *, - ldlm_type_t type, ldlm_mode_t, + enum ldlm_type type, enum ldlm_mode mode, const struct ldlm_callback_suite *cbs, void *data, __u32 lvb_len, enum lvb_type lvb_type); -ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *, struct ldlm_lock **, - void *cookie, __u64 *flags); +enum ldlm_error ldlm_lock_enqueue(struct ldlm_namespace *, struct ldlm_lock **, + void *cookie, __u64 *flags); void ldlm_lock_addref_internal(struct ldlm_lock *, __u32 mode); void ldlm_lock_addref_internal_nolock(struct ldlm_lock *, __u32 mode); void ldlm_lock_decref_internal(struct ldlm_lock *, __u32 mode); @@ -154,7 +155,7 @@ int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, - ldlm_cancel_flags_t cancel_flags); + enum ldlm_cancel_flags cancel_flags); void ldlm_handle_bl_callback(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 3c8d441..b586d5a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -219,7 +219,8 @@ EXPORT_SYMBOL(client_import_find_conn); void client_destroy_import(struct obd_import *imp) { /* Drop security policy instance after all RPCs have finished/aborted - * to let all busy contexts be released. */ + * to let all busy contexts be released. + */ class_import_get(imp); class_destroy_import(imp); sptlrpc_import_sec_put(imp); @@ -227,29 +228,6 @@ void client_destroy_import(struct obd_import *imp) } EXPORT_SYMBOL(client_destroy_import); -/** - * Check whether or not the OSC is on MDT. - * In the config log, - * osc on MDT - * setup 0:{fsname}-OSTxxxx-osc[-MDTxxxx] 1:lustre-OST0000_UUID 2:NID - * osc on client - * setup 0:{fsname}-OSTxxxx-osc 1:lustre-OST0000_UUID 2:NID - * - **/ -static int osc_on_mdt(char *obdname) -{ - char *ptr; - - ptr = strrchr(obdname, '-'); - if (ptr == NULL) - return 0; - - if (strncmp(ptr + 1, "MDT", 3) == 0) - return 1; - - return 0; -} - /* Configure an RPC client OBD device. * * lcfg parameters: @@ -264,11 +242,12 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) struct obd_uuid server_uuid; int rq_portal, rp_portal, connect_op; char *name = obddev->obd_type->typ_name; - ldlm_ns_type_t ns_type = LDLM_NS_TYPE_UNKNOWN; + enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN; int rc; /* In a more perfect world, we would hang a ptlrpc_client off of - * obd_type and just use the values from there. */ + * obd_type and just use the values from there. + */ if (!strcmp(name, LUSTRE_OSC_NAME)) { rq_portal = OST_REQUEST_PORTAL; rp_portal = OSC_REPLY_PORTAL; @@ -284,22 +263,6 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_sp_me = LUSTRE_SP_CLI; cli->cl_sp_to = LUSTRE_SP_MDT; ns_type = LDLM_NS_TYPE_MDC; - } else if (!strcmp(name, LUSTRE_OSP_NAME)) { - if (strstr(lustre_cfg_buf(lcfg, 1), "OST") == NULL) { - /* OSP_on_MDT for other MDTs */ - connect_op = MDS_CONNECT; - cli->cl_sp_to = LUSTRE_SP_MDT; - ns_type = LDLM_NS_TYPE_MDC; - rq_portal = OUT_PORTAL; - } else { - /* OSP on MDT for OST */ - connect_op = OST_CONNECT; - cli->cl_sp_to = LUSTRE_SP_OST; - ns_type = LDLM_NS_TYPE_OSC; - rq_portal = OST_REQUEST_PORTAL; - } - rp_portal = OSC_REPLY_PORTAL; - cli->cl_sp_me = LUSTRE_SP_CLI; } else if (!strcmp(name, LUSTRE_MGC_NAME)) { rq_portal = MGS_REQUEST_PORTAL; rp_portal = MGC_REPLY_PORTAL; @@ -387,7 +350,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) /* This value may be reduced at connect time in * ptlrpc_connect_interpret() . We initialize it to only * 1MB until we know what the performance looks like. - * In the future this should likely be increased. LU-1431 */ + * In the future this should likely be increased. LU-1431 + */ cli->cl_max_pages_per_rpc = min_t(int, PTLRPC_MAX_BRW_PAGES, LNET_MTU >> PAGE_CACHE_SHIFT); @@ -400,10 +364,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) { cli->cl_max_rpcs_in_flight = 4; } else { - if (osc_on_mdt(obddev->obd_name)) - cli->cl_max_rpcs_in_flight = MDS_OSC_MAX_RIF_DEFAULT; - else - cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT; + cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT; } rc = ldlm_get_ref(); if (rc) { @@ -415,7 +376,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) &obddev->obd_ldlm_client); imp = class_new_import(obddev); - if (imp == NULL) { + if (!imp) { rc = -ENOENT; goto err_ldlm; } @@ -451,7 +412,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) LDLM_NAMESPACE_CLIENT, LDLM_NAMESPACE_GREEDY, ns_type); - if (obddev->obd_namespace == NULL) { + if (!obddev->obd_namespace) { CERROR("Unable to create client namespace - %s\n", obddev->obd_name); rc = -ENOMEM; @@ -477,7 +438,7 @@ int client_obd_cleanup(struct obd_device *obddev) ldlm_namespace_free_post(obddev->obd_namespace); obddev->obd_namespace = NULL; - LASSERT(obddev->u.cli.cl_import == NULL); + LASSERT(!obddev->u.cli.cl_import); ldlm_put_ref(); return 0; @@ -528,7 +489,7 @@ int client_connect_import(const struct lu_env *env, LASSERT(imp->imp_state == LUSTRE_IMP_DISCON); goto out_ldlm; } - LASSERT(*exp != NULL && (*exp)->exp_connection); + LASSERT(*exp && (*exp)->exp_connection); if (data) { LASSERTF((ocd->ocd_connect_flags & data->ocd_connect_flags) == @@ -587,17 +548,19 @@ int client_disconnect_export(struct obd_export *exp) /* Mark import deactivated now, so we don't try to reconnect if any * of the cleanup RPCs fails (e.g. LDLM cancel, etc). We don't - * fully deactivate the import, or that would drop all requests. */ + * fully deactivate the import, or that would drop all requests. + */ spin_lock(&imp->imp_lock); imp->imp_deactive = 1; spin_unlock(&imp->imp_lock); /* Some non-replayable imports (MDS's OSCs) are pinged, so just * delete it regardless. (It's safe to delete an import that was - * never added.) */ + * never added.) + */ (void)ptlrpc_pinger_del_import(imp); - if (obd->obd_namespace != NULL) { + if (obd->obd_namespace) { /* obd_force == local only */ ldlm_cli_cancel_unused(obd->obd_namespace, NULL, obd->obd_force ? LCF_LOCAL : 0, NULL); @@ -606,7 +569,8 @@ int client_disconnect_export(struct obd_export *exp) } /* There's no need to hold sem while disconnecting an import, - * and it may actually cause deadlock in GSS. */ + * and it may actually cause deadlock in GSS. + */ up_write(&cli->cl_sem); rc = ptlrpc_disconnect_import(imp, 0); down_write(&cli->cl_sem); @@ -615,7 +579,8 @@ int client_disconnect_export(struct obd_export *exp) out_disconnect: /* Use server style - class_disconnect should be always called for - * o_disconnect. */ + * o_disconnect. + */ err = class_disconnect(exp); if (!rc && err) rc = err; @@ -634,7 +599,8 @@ int target_pack_pool_reply(struct ptlrpc_request *req) struct obd_device *obd; /* Check that we still have all structures alive as this may - * be some late RPC at shutdown time. */ + * be some late RPC at shutdown time. + */ if (unlikely(!req->rq_export || !req->rq_export->exp_obd || !exp_connect_lru_resize(req->rq_export))) { lustre_msg_set_slv(req->rq_repmsg, 0); @@ -684,14 +650,14 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) svcpt = req->rq_rqbd->rqbd_svcpt; rs = req->rq_reply_state; - if (rs == NULL || !rs->rs_difficult) { + if (!rs || !rs->rs_difficult) { /* no notifiers */ target_send_reply_msg(req, rc, fail_id); return; } /* must be an export if locks saved */ - LASSERT(req->rq_export != NULL); + LASSERT(req->rq_export); /* req/reply consistent */ LASSERT(rs->rs_svcpt == svcpt); @@ -700,7 +666,7 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) LASSERT(!rs->rs_scheduled_ever); LASSERT(!rs->rs_handled); LASSERT(!rs->rs_on_net); - LASSERT(rs->rs_export == NULL); + LASSERT(!rs->rs_export); LASSERT(list_empty(&rs->rs_obd_list)); LASSERT(list_empty(&rs->rs_exp_list)); @@ -739,7 +705,8 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) * reply ref until ptlrpc_handle_rs() is done * with the reply state (if the send was successful, there * would have been +1 ref for the net, which - * reply_out_callback leaves alone) */ + * reply_out_callback leaves alone) + */ rs->rs_on_net = 0; ptlrpc_rs_addref(rs); } @@ -760,7 +727,7 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) } EXPORT_SYMBOL(target_send_reply); -ldlm_mode_t lck_compat_array[] = { +enum ldlm_mode lck_compat_array[] = { [LCK_EX] = LCK_COMPAT_EX, [LCK_PW] = LCK_COMPAT_PW, [LCK_PR] = LCK_COMPAT_PR, @@ -775,7 +742,7 @@ ldlm_mode_t lck_compat_array[] = { * Rather arbitrary mapping from LDLM error codes to errno values. This should * not escape to the user level. */ -int ldlm_error2errno(ldlm_error_t error) +int ldlm_error2errno(enum ldlm_error error) { int result; @@ -803,7 +770,7 @@ int ldlm_error2errno(ldlm_error_t error) break; default: if (((int)error) < 0) /* cast to signed type */ - result = error; /* as ldlm_error_t can be unsigned */ + result = error; /* as enum ldlm_error can be unsigned */ else { CERROR("Invalid DLM result code: %d\n", error); result = -EPROTO; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index cf9ec0c..98975ef 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -91,7 +91,7 @@ static ldlm_policy_local_to_wire_t ldlm_policy_local_to_wire[] = { /** * Converts lock policy from local format to on the wire lock_desc format */ -static void ldlm_convert_policy_to_wire(ldlm_type_t type, +static void ldlm_convert_policy_to_wire(enum ldlm_type type, const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy) { @@ -105,7 +105,7 @@ static void ldlm_convert_policy_to_wire(ldlm_type_t type, /** * Converts lock policy from on the wire lock_desc format to local format */ -void ldlm_convert_policy_to_local(struct obd_export *exp, ldlm_type_t type, +void ldlm_convert_policy_to_local(struct obd_export *exp, enum ldlm_type type, const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy) { @@ -326,9 +326,11 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock) if (lock->l_export && lock->l_export->exp_lock_hash) { /* NB: it's safe to call cfs_hash_del() even lock isn't - * in exp_lock_hash. */ + * in exp_lock_hash. + */ /* In the function below, .hs_keycmp resolves to - * ldlm_export_lock_keycmp() */ + * ldlm_export_lock_keycmp() + */ /* coverity[overrun-buffer-val] */ cfs_hash_del(lock->l_export->exp_lock_hash, &lock->l_remote_handle, &lock->l_exp_hash); @@ -337,16 +339,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock) ldlm_lock_remove_from_lru(lock); class_handle_unhash(&lock->l_handle); -#if 0 - /* Wake anyone waiting for this lock */ - /* FIXME: I should probably add yet another flag, instead of using - * l_export to only call this on clients */ - if (lock->l_export) - class_export_put(lock->l_export); - lock->l_export = NULL; - if (lock->l_export && lock->l_completion_ast) - lock->l_completion_ast(lock, 0); -#endif return 1; } @@ -412,11 +404,10 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) { struct ldlm_lock *lock; - if (resource == NULL) - LBUG(); + LASSERT(resource); lock = kmem_cache_alloc(ldlm_lock_slab, GFP_NOFS | __GFP_ZERO); - if (lock == NULL) + if (!lock) return NULL; spin_lock_init(&lock->l_lock); @@ -485,7 +476,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, unlock_res_and_lock(lock); newres = ldlm_resource_get(ns, NULL, new_resid, type, 1); - if (newres == NULL) + if (!newres) return -ENOMEM; lu_ref_add(&newres->lr_reference, "lock", lock); @@ -547,11 +538,12 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(handle); lock = class_handle2object(handle->cookie); - if (lock == NULL) + if (!lock) return NULL; /* It's unlikely but possible that someone marked the lock as - * destroyed after we did handle2object on it */ + * destroyed after we did handle2object on it + */ if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED) == 0)) { lu_ref_add(&lock->l_reference, "handle", current); return lock; @@ -559,7 +551,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, lock_res_and_lock(lock); - LASSERT(lock->l_resource != NULL); + LASSERT(lock->l_resource); lu_ref_add_atomic(&lock->l_reference, "handle", current); if (unlikely(lock->l_flags & LDLM_FL_DESTROYED)) { @@ -611,13 +603,14 @@ static void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, LDLM_DEBUG(lock, "lock incompatible; sending blocking AST."); lock->l_flags |= LDLM_FL_AST_SENT; /* If the enqueuing client said so, tell the AST recipient to - * discard dirty data, rather than writing back. */ + * discard dirty data, rather than writing back. + */ if (new->l_flags & LDLM_FL_AST_DISCARD_DATA) lock->l_flags |= LDLM_FL_DISCARD_DATA; LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, work_list); LDLM_LOCK_GET(lock); - LASSERT(lock->l_blocking_lock == NULL); + LASSERT(!lock->l_blocking_lock); lock->l_blocking_lock = LDLM_LOCK_GET(new); } } @@ -664,7 +657,7 @@ void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode) struct ldlm_lock *lock; lock = ldlm_handle2lock(lockh); - LASSERT(lock != NULL); + LASSERT(lock); ldlm_lock_addref_internal(lock, mode); LDLM_LOCK_PUT(lock); } @@ -708,7 +701,7 @@ int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode) result = -EAGAIN; lock = ldlm_handle2lock(lockh); - if (lock != NULL) { + if (lock) { lock_res_and_lock(lock); if (lock->l_readers != 0 || lock->l_writers != 0 || !(lock->l_flags & LDLM_FL_CBPENDING)) { @@ -780,7 +773,8 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) if (lock->l_flags & LDLM_FL_LOCAL && !lock->l_readers && !lock->l_writers) { /* If this is a local lock on a server namespace and this was - * the last reference, cancel the lock. */ + * the last reference, cancel the lock. + */ CDEBUG(D_INFO, "forcing cancel of local lock\n"); lock->l_flags |= LDLM_FL_CBPENDING; } @@ -788,7 +782,8 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) if (!lock->l_readers && !lock->l_writers && (lock->l_flags & LDLM_FL_CBPENDING)) { /* If we received a blocked AST and this was the last reference, - * run the callback. */ + * run the callback. + */ LDLM_DEBUG(lock, "final decref done on cbpending lock"); @@ -809,7 +804,8 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) LDLM_DEBUG(lock, "add lock into lru list"); /* If this is a client-side namespace and this was the last - * reference, put it on the LRU. */ + * reference, put it on the LRU. + */ ldlm_lock_add_to_lru(lock); unlock_res_and_lock(lock); @@ -818,7 +814,8 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) /* Call ldlm_cancel_lru() only if EARLY_CANCEL and LRU RESIZE * are not supported by the server, otherwise, it is done on - * enqueue. */ + * enqueue. + */ if (!exp_connect_cancelset(lock->l_conn_export) && !ns_connect_lru_resize(ns)) ldlm_cancel_lru(ns, 0, LCF_ASYNC, 0); @@ -835,7 +832,7 @@ void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); - LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie); + LASSERTF(lock, "Non-existing lock: %#llx\n", lockh->cookie); ldlm_lock_decref_internal(lock, mode); LDLM_LOCK_PUT(lock); } @@ -852,7 +849,7 @@ void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); - LASSERT(lock != NULL); + LASSERT(lock); LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]); lock_res_and_lock(lock); @@ -921,7 +918,8 @@ static void search_granted_lock(struct list_head *queue, if (lock->l_policy_data.l_inodebits.bits == req->l_policy_data.l_inodebits.bits) { /* insert point is last lock of - * the policy group */ + * the policy group + */ prev->res_link = &policy_end->l_res_link; prev->mode_link = @@ -942,7 +940,8 @@ static void search_granted_lock(struct list_head *queue, } /* loop over policy groups within the mode group */ /* insert point is last lock of the mode group, - * new policy group is started */ + * new policy group is started + */ prev->res_link = &mode_end->l_res_link; prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; @@ -954,7 +953,8 @@ static void search_granted_lock(struct list_head *queue, } /* insert point is last lock on the queue, - * new mode group and new policy group are started */ + * new mode group and new policy group are started + */ prev->res_link = queue->prev; prev->mode_link = &req->l_sl_mode; prev->policy_link = &req->l_sl_policy; @@ -1034,10 +1034,7 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) else ldlm_resource_add_lock(res, &res->lr_granted, lock); - if (lock->l_granted_mode < res->lr_most_restr) - res->lr_most_restr = lock->l_granted_mode; - - if (work_list && lock->l_completion_ast != NULL) + if (work_list && lock->l_completion_ast) ldlm_add_ast_work_item(lock, NULL, work_list); ldlm_pool_add(&ldlm_res_to_ns(res)->ns_pool, lock); @@ -1050,7 +1047,7 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) * comment above ldlm_lock_match */ static struct ldlm_lock *search_queue(struct list_head *queue, - ldlm_mode_t *mode, + enum ldlm_mode *mode, ldlm_policy_data_t *policy, struct ldlm_lock *old_lock, __u64 flags, int unref) @@ -1059,7 +1056,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue, struct list_head *tmp; list_for_each(tmp, queue) { - ldlm_mode_t match; + enum ldlm_mode match; lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -1067,7 +1064,8 @@ static struct ldlm_lock *search_queue(struct list_head *queue, break; /* Check if this lock can be matched. - * Used by LU-2919(exclusive open) for open lease lock */ + * Used by LU-2919(exclusive open) for open lease lock + */ if (ldlm_is_excl(lock)) continue; @@ -1076,7 +1074,8 @@ static struct ldlm_lock *search_queue(struct list_head *queue, * if it passes in CBPENDING and the lock still has users. * this is generally only going to be used by children * whose parents already hold a lock so forward progress - * can still happen. */ + * can still happen. + */ if (lock->l_flags & LDLM_FL_CBPENDING && !(flags & LDLM_FL_CBPENDING)) continue; @@ -1100,7 +1099,8 @@ static struct ldlm_lock *search_queue(struct list_head *queue, continue; /* We match if we have existing lock with same or wider set - of bits. */ + * of bits. + */ if (lock->l_resource->lr_type == LDLM_IBITS && ((lock->l_policy_data.l_inodebits.bits & policy->l_inodebits.bits) != @@ -1192,16 +1192,18 @@ EXPORT_SYMBOL(ldlm_lock_allow_match); * keep caller code unchanged), the context failure will be discovered by * caller sometime later. */ -ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, - const struct ldlm_res_id *res_id, ldlm_type_t type, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - struct lustre_handle *lockh, int unref) +enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, + const struct ldlm_res_id *res_id, + enum ldlm_type type, + ldlm_policy_data_t *policy, + enum ldlm_mode mode, + struct lustre_handle *lockh, int unref) { struct ldlm_resource *res; struct ldlm_lock *lock, *old_lock = NULL; int rc = 0; - if (ns == NULL) { + if (!ns) { old_lock = ldlm_handle2lock(lockh); LASSERT(old_lock); @@ -1212,8 +1214,8 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } res = ldlm_resource_get(ns, NULL, res_id, type, 0); - if (res == NULL) { - LASSERT(old_lock == NULL); + if (!res) { + LASSERT(!old_lock); return 0; } @@ -1222,7 +1224,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, lock = search_queue(&res->lr_granted, &mode, policy, old_lock, flags, unref); - if (lock != NULL) { + if (lock) { rc = 1; goto out; } @@ -1232,7 +1234,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } lock = search_queue(&res->lr_waiting, &mode, policy, old_lock, flags, unref); - if (lock != NULL) { + if (lock) { rc = 1; goto out; } @@ -1317,14 +1319,14 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } EXPORT_SYMBOL(ldlm_lock_match); -ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, - __u64 *bits) +enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, + __u64 *bits) { struct ldlm_lock *lock; - ldlm_mode_t mode = 0; + enum ldlm_mode mode = 0; lock = ldlm_handle2lock(lockh); - if (lock != NULL) { + if (lock) { lock_res_and_lock(lock); if (lock->l_flags & LDLM_FL_GONE_MASK) goto out; @@ -1340,7 +1342,7 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, } out: - if (lock != NULL) { + if (lock) { unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); } @@ -1354,7 +1356,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, { void *lvb; - LASSERT(data != NULL); + LASSERT(data); LASSERT(size >= 0); switch (lock->l_lvb_type) { @@ -1368,7 +1370,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_server_swab_get(pill, &RMF_DLM_LVB, lustre_swab_ost_lvb); - if (unlikely(lvb == NULL)) { + if (unlikely(!lvb)) { LDLM_ERROR(lock, "no LVB"); return -EPROTO; } @@ -1385,7 +1387,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_server_sized_swab_get(pill, &RMF_DLM_LVB, size, lustre_swab_ost_lvb_v1); - if (unlikely(lvb == NULL)) { + if (unlikely(!lvb)) { LDLM_ERROR(lock, "no LVB"); return -EPROTO; } @@ -1410,7 +1412,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_server_swab_get(pill, &RMF_DLM_LVB, lustre_swab_lquota_lvb); - if (unlikely(lvb == NULL)) { + if (unlikely(!lvb)) { LDLM_ERROR(lock, "no LVB"); return -EPROTO; } @@ -1431,7 +1433,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_client_get(pill, &RMF_DLM_LVB); else lvb = req_capsule_server_get(pill, &RMF_DLM_LVB); - if (unlikely(lvb == NULL)) { + if (unlikely(!lvb)) { LDLM_ERROR(lock, "no LVB"); return -EPROTO; } @@ -1453,8 +1455,8 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, */ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, - ldlm_type_t type, - ldlm_mode_t mode, + enum ldlm_type type, + enum ldlm_mode mode, const struct ldlm_callback_suite *cbs, void *data, __u32 lvb_len, enum lvb_type lvb_type) @@ -1463,12 +1465,12 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, struct ldlm_resource *res; res = ldlm_resource_get(ns, NULL, res_id, type, 1); - if (res == NULL) + if (!res) return NULL; lock = ldlm_lock_new(res); - if (lock == NULL) + if (!lock) return NULL; lock->l_req_mode = mode; @@ -1483,7 +1485,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, lock->l_tree_node = NULL; /* if this is the extent lock, allocate the interval tree node */ if (type == LDLM_EXTENT) { - if (ldlm_interval_alloc(lock) == NULL) + if (!ldlm_interval_alloc(lock)) goto out; } @@ -1514,9 +1516,9 @@ out: * Does not block. As a result of enqueue the lock would be put * into granted or waiting list. */ -ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, - struct ldlm_lock **lockp, - void *cookie, __u64 *flags) +enum ldlm_error ldlm_lock_enqueue(struct ldlm_namespace *ns, + struct ldlm_lock **lockp, + void *cookie, __u64 *flags) { struct ldlm_lock *lock = *lockp; struct ldlm_resource *res = lock->l_resource; @@ -1527,7 +1529,8 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, if (lock->l_req_mode == lock->l_granted_mode) { /* The server returned a blocked lock, but it was granted * before we got a chance to actually enqueue it. We don't - * need to do anything else. */ + * need to do anything else. + */ *flags &= ~(LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_WAIT); goto out; @@ -1540,7 +1543,8 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, LBUG(); /* Some flags from the enqueue want to make it into the AST, via the - * lock's l_flags. */ + * lock's l_flags. + */ lock->l_flags |= *flags & LDLM_FL_AST_DISCARD_DATA; /* @@ -1621,19 +1625,21 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) * This can't happen with the blocking_ast, however, because we * will never call the local blocking_ast until we drop our * reader/writer reference, which we won't do until we get the - * reply and finish enqueueing. */ + * reply and finish enqueueing. + */ /* nobody should touch l_cp_ast */ lock_res_and_lock(lock); list_del_init(&lock->l_cp_ast); LASSERT(lock->l_flags & LDLM_FL_CP_REQD); /* save l_completion_ast since it can be changed by - * mds_intent_policy(), see bug 14225 */ + * mds_intent_policy(), see bug 14225 + */ completion_callback = lock->l_completion_ast; lock->l_flags &= ~LDLM_FL_CP_REQD; unlock_res_and_lock(lock); - if (completion_callback != NULL) + if (completion_callback) rc = completion_callback(lock, 0, (void *)arg); LDLM_LOCK_RELEASE(lock); @@ -1749,10 +1755,11 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, /* We create a ptlrpc request set with flow control extension. * This request set will use the work_ast_lock function to produce new * requests and will send a new request each time one completes in order - * to keep the number of requests in flight to ns_max_parallel_ast */ + * to keep the number of requests in flight to ns_max_parallel_ast + */ arg->set = ptlrpc_prep_fcset(ns->ns_max_parallel_ast ? : UINT_MAX, work_ast_lock, arg); - if (arg->set == NULL) { + if (!arg->set) { rc = -ENOMEM; goto out; } @@ -1815,7 +1822,8 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) ns = ldlm_res_to_ns(res); /* Please do not, no matter how tempting, remove this LBUG without - * talking to me first. -phik */ + * talking to me first. -phik + */ if (lock->l_readers || lock->l_writers) { LDLM_ERROR(lock, "lock still has references"); LBUG(); @@ -1831,7 +1839,8 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) ldlm_pool_del(&ns->ns_pool, lock); /* Make sure we will not be called again for same lock what is possible - * if not to zero out lock->l_granted_mode */ + * if not to zero out lock->l_granted_mode + */ lock->l_granted_mode = LCK_MINMODE; unlock_res_and_lock(lock); } @@ -1846,7 +1855,7 @@ int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) int rc = -EINVAL; if (lock) { - if (lock->l_ast_data == NULL) + if (!lock->l_ast_data) lock->l_ast_data = data; if (lock->l_ast_data == data) rc = 0; @@ -1874,7 +1883,7 @@ void ldlm_lock_dump_handle(int level, struct lustre_handle *lockh) return; lock = ldlm_handle2lock(lockh); - if (lock == NULL) + if (!lock) return; LDLM_DEBUG_LIMIT(level, lock, "###"); @@ -1900,13 +1909,13 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, if (exp && exp->exp_connection) { nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); - } else if (exp && exp->exp_obd != NULL) { + } else if (exp && exp->exp_obd) { struct obd_import *imp = exp->exp_obd->u.cli.cl_import; nid = libcfs_nid2str(imp->imp_connection->c_peer.nid); } - if (resource == NULL) { + if (!resource) { libcfs_debug_vmsg2(msgdata, fmt, args, " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", lock, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 79aeb2b..ebe9042 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -107,7 +107,7 @@ struct ldlm_bl_work_item { struct list_head blwi_head; int blwi_count; struct completion blwi_comp; - ldlm_cancel_flags_t blwi_flags; + enum ldlm_cancel_flags blwi_flags; int blwi_mem_pressure; }; @@ -136,7 +136,7 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, CDEBUG(D_DLMTRACE, "Lock %p already unused, calling callback (%p)\n", lock, lock->l_blocking_ast); - if (lock->l_blocking_ast != NULL) + if (lock->l_blocking_ast) lock->l_blocking_ast(lock, ld, lock->l_ast_data, LDLM_CB_BLOCKING); } else { @@ -185,7 +185,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, } else if (lvb_len > 0) { if (lock->l_lvb_len > 0) { /* for extent lock, lvb contains ost_lvb{}. */ - LASSERT(lock->l_lvb_data != NULL); + LASSERT(lock->l_lvb_data); if (unlikely(lock->l_lvb_len < lvb_len)) { LDLM_ERROR(lock, "Replied LVB is larger than expectation, expected = %d, replied = %d", @@ -194,7 +194,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, goto out; } } else if (ldlm_has_layout(lock)) { /* for layout lock, lvb has - * variable length */ + * variable length + */ void *lvb_data; lvb_data = kzalloc(lvb_len, GFP_NOFS); @@ -205,7 +206,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, } lock_res_and_lock(lock); - LASSERT(lock->l_lvb_data == NULL); + LASSERT(!lock->l_lvb_data); lock->l_lvb_type = LVB_T_LAYOUT; lock->l_lvb_data = lvb_data; lock->l_lvb_len = lvb_len; @@ -224,7 +225,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, } /* If we receive the completion AST before the actual enqueue returned, - * then we might need to switch lock modes, resources, or extents. */ + * then we might need to switch lock modes, resources, or extents. + */ if (dlm_req->lock_desc.l_granted_mode != lock->l_req_mode) { lock->l_req_mode = dlm_req->lock_desc.l_granted_mode; LDLM_DEBUG(lock, "completion AST, new lock mode"); @@ -256,7 +258,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, if (dlm_req->lock_flags & LDLM_FL_AST_SENT) { /* BL_AST locks are not needed in LRU. - * Let ldlm_cancel_lru() be fast. */ + * Let ldlm_cancel_lru() be fast. + */ ldlm_lock_remove_from_lru(lock); lock->l_flags |= LDLM_FL_CBPENDING | LDLM_FL_BL_AST; LDLM_DEBUG(lock, "completion AST includes blocking AST"); @@ -276,8 +279,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, LDLM_DEBUG(lock, "callback handler finished, about to run_ast_work"); - /* Let Enqueue to call osc_lock_upcall() and initialize - * l_ast_data */ + /* Let Enqueue to call osc_lock_upcall() and initialize l_ast_data */ OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_CP_ENQ_RACE, 2); ldlm_run_ast_work(ns, &ast_list, LDLM_WORK_CP_AST); @@ -312,10 +314,10 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, LDLM_DEBUG(lock, "client glimpse AST callback handler"); - if (lock->l_glimpse_ast != NULL) + if (lock->l_glimpse_ast) rc = lock->l_glimpse_ast(lock, req); - if (req->rq_repmsg != NULL) { + if (req->rq_repmsg) { ptlrpc_reply(req); } else { req->rq_status = rc; @@ -353,7 +355,7 @@ static int ldlm_callback_reply(struct ptlrpc_request *req, int rc) } static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, - ldlm_cancel_flags_t cancel_flags) + enum ldlm_cancel_flags cancel_flags) { struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool; @@ -371,7 +373,8 @@ static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, wake_up(&blp->blp_waitq); /* can not check blwi->blwi_flags as blwi could be already freed in - LCF_ASYNC mode */ + * LCF_ASYNC mode + */ if (!(cancel_flags & LCF_ASYNC)) wait_for_completion(&blwi->blwi_comp); @@ -383,7 +386,7 @@ static inline void init_blwi(struct ldlm_bl_work_item *blwi, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, struct ldlm_lock *lock, - ldlm_cancel_flags_t cancel_flags) + enum ldlm_cancel_flags cancel_flags) { init_completion(&blwi->blwi_comp); INIT_LIST_HEAD(&blwi->blwi_head); @@ -393,7 +396,7 @@ static inline void init_blwi(struct ldlm_bl_work_item *blwi, blwi->blwi_ns = ns; blwi->blwi_flags = cancel_flags; - if (ld != NULL) + if (ld) blwi->blwi_ld = *ld; if (count) { list_add(&blwi->blwi_head, cancels); @@ -417,7 +420,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock, struct list_head *cancels, int count, - ldlm_cancel_flags_t cancel_flags) + enum ldlm_cancel_flags cancel_flags) { if (cancels && count == 0) return 0; @@ -451,7 +454,7 @@ int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, - ldlm_cancel_flags_t cancel_flags) + enum ldlm_cancel_flags cancel_flags) { return ldlm_bl_to_thread(ns, ld, NULL, cancels, count, cancel_flags); } @@ -470,14 +473,14 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) req_capsule_set(&req->rq_pill, &RQF_OBD_SET_INFO); key = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); - if (key == NULL) { + if (!key) { DEBUG_REQ(D_IOCTL, req, "no set_info key"); return -EFAULT; } keylen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT); val = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL); - if (val == NULL) { + if (!val) { DEBUG_REQ(D_IOCTL, req, "no set_info val"); return -EFAULT; } @@ -519,7 +522,7 @@ static int ldlm_handle_qc_callback(struct ptlrpc_request *req) struct client_obd *cli = &req->rq_export->exp_obd->u.cli; oqctl = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); - if (oqctl == NULL) { + if (!oqctl) { CERROR("Can't unpack obd_quotactl\n"); return -EPROTO; } @@ -541,7 +544,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) /* Requests arrive in sender's byte order. The ptlrpc service * handler has already checked and, if necessary, byte-swapped the * incoming request message body, but I am responsible for the - * message buffers. */ + * message buffers. + */ /* do nothing for sec context finalize */ if (lustre_msg_get_opc(req->rq_reqmsg) == SEC_CTX_FINI) @@ -549,15 +553,14 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) req_capsule_init(&req->rq_pill, req, RCL_SERVER); - if (req->rq_export == NULL) { + if (!req->rq_export) { rc = ldlm_callback_reply(req, -ENOTCONN); ldlm_callback_errmsg(req, "Operate on unconnected server", rc, NULL); return 0; } - LASSERT(req->rq_export != NULL); - LASSERT(req->rq_export->exp_obd != NULL); + LASSERT(req->rq_export->exp_obd); switch (lustre_msg_get_opc(req->rq_reqmsg)) { case LDLM_BL_CALLBACK: @@ -591,12 +594,12 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) } ns = req->rq_export->exp_obd->obd_namespace; - LASSERT(ns != NULL); + LASSERT(ns); req_capsule_set(&req->rq_pill, &RQF_LDLM_CALLBACK); dlm_req = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); - if (dlm_req == NULL) { + if (!dlm_req) { rc = ldlm_callback_reply(req, -EPROTO); ldlm_callback_errmsg(req, "Operate without parameter", rc, NULL); @@ -604,7 +607,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) } /* Force a known safe race, send a cancel to the server for a lock - * which the server has already started a blocking callback on. */ + * which the server has already started a blocking callback on. + */ if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_BL_CB_RACE) && lustre_msg_get_opc(req->rq_reqmsg) == LDLM_BL_CALLBACK) { rc = ldlm_cli_cancel(&dlm_req->lock_handle[0], 0); @@ -634,7 +638,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) /* If somebody cancels lock and cache is already dropped, * or lock is failed before cp_ast received on client, * we can tell the server we have no lock. Otherwise, we - * should send cancel after dropping the cache. */ + * should send cancel after dropping the cache. + */ if (((lock->l_flags & LDLM_FL_CANCELING) && (lock->l_flags & LDLM_FL_BL_DONE)) || (lock->l_flags & LDLM_FL_FAILED)) { @@ -648,7 +653,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) return 0; } /* BL_AST locks are not needed in LRU. - * Let ldlm_cancel_lru() be fast. */ + * Let ldlm_cancel_lru() be fast. + */ ldlm_lock_remove_from_lru(lock); lock->l_flags |= LDLM_FL_BL_AST; } @@ -661,7 +667,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) * But we'd also like to be able to indicate in the reply that we're * cancelling right now, because it's unused, or have an intent result * in the reply, so we might have to push the responsibility for sending - * the reply down into the AST handlers, alas. */ + * the reply down into the AST handlers, alas. + */ switch (lustre_msg_get_opc(req->rq_reqmsg)) { case LDLM_BL_CALLBACK: @@ -781,17 +788,17 @@ static int ldlm_bl_thread_main(void *arg) blwi = ldlm_bl_get_work(blp); - if (blwi == NULL) { + if (!blwi) { atomic_dec(&blp->blp_busy_threads); l_wait_event_exclusive(blp->blp_waitq, - (blwi = ldlm_bl_get_work(blp)) != NULL, + (blwi = ldlm_bl_get_work(blp)), &lwi); busy = atomic_inc_return(&blp->blp_busy_threads); } else { busy = atomic_read(&blp->blp_busy_threads); } - if (blwi->blwi_ns == NULL) + if (!blwi->blwi_ns) /* added by ldlm_cleanup() */ break; @@ -810,7 +817,8 @@ static int ldlm_bl_thread_main(void *arg) /* The special case when we cancel locks in LRU * asynchronously, we pass the list of locks here. * Thus locks are marked LDLM_FL_CANCELING, but NOT - * canceled locally yet. */ + * canceled locally yet. + */ count = ldlm_cli_cancel_list_local(&blwi->blwi_head, blwi->blwi_count, LCF_BL_AST); @@ -915,7 +923,7 @@ static int ldlm_setup(void) int rc = 0; int i; - if (ldlm_state != NULL) + if (ldlm_state) return -EALREADY; ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS); @@ -1040,7 +1048,7 @@ static int ldlm_cleanup(void) ldlm_pools_fini(); - if (ldlm_state->ldlm_bl_pool != NULL) { + if (ldlm_state->ldlm_bl_pool) { struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool; while (atomic_read(&blp->blp_num_threads) > 0) { @@ -1059,7 +1067,7 @@ static int ldlm_cleanup(void) kfree(blp); } - if (ldlm_state->ldlm_cb_service != NULL) + if (ldlm_state->ldlm_cb_service) ptlrpc_unregister_service(ldlm_state->ldlm_cb_service); if (ldlm_ns_kset) @@ -1085,13 +1093,13 @@ int ldlm_init(void) ldlm_resource_slab = kmem_cache_create("ldlm_resources", sizeof(struct ldlm_resource), 0, SLAB_HWCACHE_ALIGN, NULL); - if (ldlm_resource_slab == NULL) + if (!ldlm_resource_slab) return -ENOMEM; ldlm_lock_slab = kmem_cache_create("ldlm_locks", sizeof(struct ldlm_lock), 0, SLAB_HWCACHE_ALIGN | SLAB_DESTROY_BY_RCU, NULL); - if (ldlm_lock_slab == NULL) { + if (!ldlm_lock_slab) { kmem_cache_destroy(ldlm_resource_slab); return -ENOMEM; } @@ -1099,7 +1107,7 @@ int ldlm_init(void) ldlm_interval_slab = kmem_cache_create("interval_node", sizeof(struct ldlm_interval), 0, SLAB_HWCACHE_ALIGN, NULL); - if (ldlm_interval_slab == NULL) { + if (!ldlm_interval_slab) { kmem_cache_destroy(ldlm_resource_slab); kmem_cache_destroy(ldlm_lock_slab); return -ENOMEM; @@ -1117,7 +1125,8 @@ void ldlm_exit(void) kmem_cache_destroy(ldlm_resource_slab); /* ldlm_lock_put() use RCU to call ldlm_lock_free, so need call * synchronize_rcu() to wait a grace period elapsed, so that - * ldlm_lock_free() get a chance to be called. */ + * ldlm_lock_free() get a chance to be called. + */ synchronize_rcu(); kmem_cache_destroy(ldlm_lock_slab); kmem_cache_destroy(ldlm_interval_slab); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 3d7c137..3e937b0 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -246,7 +246,6 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl) */ obd = container_of(pl, struct ldlm_namespace, ns_pool)->ns_obd; - LASSERT(obd != NULL); read_lock(&obd->obd_pool_lock); pl->pl_server_lock_volume = obd->obd_pool_slv; atomic_set(&pl->pl_limit, obd->obd_pool_limit); @@ -381,7 +380,7 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl) spin_unlock(&pl->pl_lock); recalc: - if (pl->pl_ops->po_recalc != NULL) { + if (pl->pl_ops->po_recalc) { count = pl->pl_ops->po_recalc(pl); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, count); @@ -409,7 +408,7 @@ static int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask) { int cancel = 0; - if (pl->pl_ops->po_shrink != NULL) { + if (pl->pl_ops->po_shrink) { cancel = pl->pl_ops->po_shrink(pl, nr, gfp_mask); if (nr > 0) { lprocfs_counter_add(pl->pl_stats, @@ -643,11 +642,11 @@ static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl) static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl) { - if (pl->pl_stats != NULL) { + if (pl->pl_stats) { lprocfs_free_stats(&pl->pl_stats); pl->pl_stats = NULL; } - if (pl->pl_debugfs_entry != NULL) { + if (pl->pl_debugfs_entry) { ldebugfs_remove(&pl->pl_debugfs_entry); pl->pl_debugfs_entry = NULL; } @@ -834,7 +833,7 @@ static unsigned long ldlm_pools_count(ldlm_side_t client, gfp_t gfp_mask) continue; } - if (ns_old == NULL) + if (!ns_old) ns_old = ns; ldlm_namespace_get(ns); @@ -957,7 +956,7 @@ static int ldlm_pools_recalc(ldlm_side_t client) continue; } - if (ns_old == NULL) + if (!ns_old) ns_old = ns; spin_lock(&ns->ns_lock); @@ -1040,7 +1039,7 @@ static int ldlm_pools_thread_start(void) struct l_wait_info lwi = { 0 }; struct task_struct *task; - if (ldlm_pools_thread != NULL) + if (ldlm_pools_thread) return -EALREADY; ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS); @@ -1065,7 +1064,7 @@ static int ldlm_pools_thread_start(void) static void ldlm_pools_thread_stop(void) { - if (ldlm_pools_thread == NULL) + if (!ldlm_pools_thread) return; thread_set_flags(ldlm_pools_thread, SVC_STOPPING); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index b9eb377..2d501a6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -94,7 +94,7 @@ static int ldlm_expired_completion_wait(void *data) struct obd_import *imp; struct obd_device *obd; - if (lock->l_conn_export == NULL) { + if (!lock->l_conn_export) { static unsigned long next_dump, last_dump; LCONSOLE_WARN("lock timed out (enqueued at %lld, %llds ago)\n", @@ -128,7 +128,8 @@ static int ldlm_expired_completion_wait(void *data) } /* We use the same basis for both server side and client side functions - from a single node. */ + * from a single node. + */ static int ldlm_get_enq_timeout(struct ldlm_lock *lock) { int timeout = at_get(ldlm_lock_to_ns_at(lock)); @@ -136,8 +137,9 @@ static int ldlm_get_enq_timeout(struct ldlm_lock *lock) if (AT_OFF) return obd_timeout / 2; /* Since these are non-updating timeouts, we should be conservative. - It would be nice to have some kind of "early reply" mechanism for - lock callbacks too... */ + * It would be nice to have some kind of "early reply" mechanism for + * lock callbacks too... + */ timeout = min_t(int, at_max, timeout + (timeout >> 1)); /* 150% */ return max(timeout, ldlm_enqueue_min); } @@ -239,12 +241,13 @@ noreproc: obd = class_exp2obd(lock->l_conn_export); /* if this is a local lock, then there is no import */ - if (obd != NULL) + if (obd) imp = obd->u.cli.cl_import; /* Wait a long time for enqueue - server may have to callback a - lock from another client. Server will evict the other client if it - doesn't respond reasonably, and then give us the lock. */ + * lock from another client. Server will evict the other client if it + * doesn't respond reasonably, and then give us the lock. + */ timeout = ldlm_get_enq_timeout(lock) * 2; lwd.lwd_lock = lock; @@ -258,7 +261,7 @@ noreproc: interrupted_completion_wait, &lwd); } - if (imp != NULL) { + if (imp) { spin_lock(&imp->imp_lock); lwd.lwd_conn_cnt = imp->imp_conn_cnt; spin_unlock(&imp->imp_lock); @@ -296,7 +299,8 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, !(lock->l_flags & LDLM_FL_FAILED)) { /* Make sure that this lock will not be found by raced * bl_ast and -EINVAL reply is sent to server anyways. - * bug 17645 */ + * bug 17645 + */ lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_FAILED | LDLM_FL_ATOMIC_CB | LDLM_FL_CBPENDING; need_cancel = 1; @@ -312,11 +316,13 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, ldlm_lock_decref_internal(lock, mode); /* XXX - HACK because we shouldn't call ldlm_lock_destroy() - * from llite/file.c/ll_file_flock(). */ + * from llite/file.c/ll_file_flock(). + */ /* This code makes for the fact that we do not have blocking handler on * a client for flock locks. As such this is the place where we must * completely kill failed locks. (interrupted and those that - * were waiting to be granted when server evicted us. */ + * were waiting to be granted when server evicted us. + */ if (lock->l_resource->lr_type == LDLM_FLOCK) { lock_res_and_lock(lock); ldlm_resource_unlink_lock(lock); @@ -331,7 +337,8 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, * Called after receiving reply from server. */ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, - ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode, + enum ldlm_type type, __u8 with_policy, + enum ldlm_mode mode, __u64 *flags, void *lvb, __u32 lvb_len, struct lustre_handle *lockh, int rc) { @@ -363,13 +370,13 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, /* Before we return, swab the reply */ reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - if (reply == NULL) { + if (!reply) { rc = -EPROTO; goto cleanup; } if (lvb_len != 0) { - LASSERT(lvb != NULL); + LASSERT(lvb); size = req_capsule_get_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER); @@ -401,7 +408,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, /* Key change rehash lock in per-export hash with new key */ if (exp->exp_lock_hash) { /* In the function below, .hs_keycmp resolves to - * ldlm_export_lock_keycmp() */ + * ldlm_export_lock_keycmp() + */ /* coverity[overrun-buffer-val] */ cfs_hash_rehash_key(exp->exp_lock_hash, &lock->l_remote_handle, @@ -415,7 +423,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags & LDLM_INHERIT_FLAGS); /* move NO_TIMEOUT flag to the lock to force ldlm_lock_match() - * to wait with no timeout as well */ + * to wait with no timeout as well + */ lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags & LDLM_FL_NO_TIMEOUT); unlock_res_and_lock(lock); @@ -425,7 +434,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, /* If enqueue returned a blocked lock but the completion handler has * already run, then it fixed up the resource and we don't need to do it - * again. */ + * again. + */ if ((*flags) & LDLM_FL_LOCK_CHANGED) { int newmode = reply->lock_desc.l_req_mode; @@ -445,7 +455,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc = ldlm_lock_change_resource(ns, lock, &reply->lock_desc.l_resource.lr_name); - if (rc || lock->l_resource == NULL) { + if (rc || !lock->l_resource) { rc = -ENOMEM; goto cleanup; } @@ -467,7 +477,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, if ((*flags) & LDLM_FL_AST_SENT || /* Cancel extent locks as soon as possible on a liblustre client, * because it cannot handle asynchronous ASTs robustly (see - * bug 7311). */ + * bug 7311). + */ (LIBLUSTRE_CLIENT && type == LDLM_EXTENT)) { lock_res_and_lock(lock); lock->l_flags |= LDLM_FL_CBPENDING | LDLM_FL_BL_AST; @@ -476,12 +487,14 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, } /* If the lock has already been granted by a completion AST, don't - * clobber the LVB with an older one. */ + * clobber the LVB with an older one. + */ if (lvb_len != 0) { /* We must lock or a racing completion might update lvb without * letting us know and we'll clobber the correct value. - * Cannot unlock after the check either, a that still leaves - * a tiny window for completion to get in */ + * Cannot unlock after the check either, as that still leaves + * a tiny window for completion to get in + */ lock_res_and_lock(lock); if (lock->l_req_mode != lock->l_granted_mode) rc = ldlm_fill_lvb(lock, &req->rq_pill, RCL_SERVER, @@ -495,7 +508,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, if (!is_replay) { rc = ldlm_lock_enqueue(ns, &lock, NULL, flags); - if (lock->l_completion_ast != NULL) { + if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, *flags, NULL); if (!rc) @@ -505,9 +518,10 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, } } - if (lvb_len && lvb != NULL) { + if (lvb_len && lvb) { /* Copy the LVB here, and not earlier, because the completion - * AST (if any) can override what we got in the reply */ + * AST (if any) can override what we got in the reply + */ memcpy(lvb, lock->l_lvb_data, lvb_len); } @@ -579,7 +593,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, LIST_HEAD(head); int rc; - if (cancels == NULL) + if (!cancels) cancels = &head; if (ns_connect_cancelset(ns)) { /* Estimate the amount of available space in the request. */ @@ -593,7 +607,8 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, /* Cancel LRU locks here _only_ if the server supports * EARLY_CANCEL. Otherwise we have to send extra CANCEL - * RPC, which will make us slower. */ + * RPC, which will make us slower. + */ if (avail > count) count += ldlm_cancel_lru_local(ns, cancels, to_free, avail - count, 0, flags); @@ -618,7 +633,8 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, /* Skip first lock handler in ldlm_request_pack(), * this method will increment @lock_count according * to the lock handle amount actually written to - * the buffer. */ + * the buffer. + */ dlm->lock_count = canceloff; } /* Pack into the request @pack lock handles. */ @@ -665,15 +681,14 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, int rc, err; struct ptlrpc_request *req; - LASSERT(exp != NULL); - ns = exp->exp_obd->obd_namespace; /* If we're replaying this lock, just check some invariants. - * If we're creating a new lock, get everything all setup nice. */ + * If we're creating a new lock, get everything all setup nicely. + */ if (is_replay) { lock = ldlm_handle2lock_long(lockh, 0); - LASSERT(lock != NULL); + LASSERT(lock); LDLM_DEBUG(lock, "client-side enqueue START"); LASSERT(exp == lock->l_conn_export); } else { @@ -685,13 +700,13 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, lock = ldlm_lock_create(ns, res_id, einfo->ei_type, einfo->ei_mode, &cbs, einfo->ei_cbdata, lvb_len, lvb_type); - if (lock == NULL) + if (!lock) return -ENOMEM; /* for the local lock, add the reference */ ldlm_lock_addref_internal(lock, einfo->ei_mode); ldlm_lock2handle(lock, lockh); - if (policy != NULL) - lock->l_policy_data = *policy; + if (policy) + lock->l_policy_data = *policy; if (einfo->ei_type == LDLM_EXTENT) lock->l_req_extent = policy->l_extent; @@ -706,12 +721,12 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, /* lock not sent to server yet */ - if (reqp == NULL || *reqp == NULL) { + if (!reqp || !*reqp) { req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); - if (req == NULL) { + if (!req) { failed_lock_cleanup(ns, lock, einfo->ei_mode); LDLM_LOCK_RELEASE(lock); return -ENOMEM; @@ -754,7 +769,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, policy->l_extent.end == OBD_OBJECT_EOF)); if (async) { - LASSERT(reqp != NULL); + LASSERT(reqp); return 0; } @@ -767,13 +782,14 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, lockh, rc); /* If ldlm_cli_enqueue_fini did not find the lock, we need to free - * one reference that we took */ + * one reference that we took + */ if (err == -ENOLCK) LDLM_LOCK_RELEASE(lock); else rc = err; - if (!req_passed_in && req != NULL) { + if (!req_passed_in && req) { ptlrpc_req_finished(req); if (reqp) *reqp = NULL; @@ -832,7 +848,7 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, int max, packed = 0; dlm = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); - LASSERT(dlm != NULL); + LASSERT(dlm); /* Check the room in the request buffer. */ max = req_capsule_get_size(&req->rq_pill, &RMF_DLM_REQ, RCL_CLIENT) - @@ -843,7 +859,8 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, /* XXX: it would be better to pack lock handles grouped by resource. * so that the server cancel would call filter_lvbo_update() less - * frequently. */ + * frequently. + */ list_for_each_entry(lock, head, l_bl_ast) { if (!count--) break; @@ -858,17 +875,18 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, /** * Prepare and send a batched cancel RPC. It will include \a count lock - * handles of locks given in \a cancels list. */ + * handles of locks given in \a cancels list. + */ static int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, - int count, ldlm_cancel_flags_t flags) + int count, enum ldlm_cancel_flags flags) { struct ptlrpc_request *req = NULL; struct obd_import *imp; int free, sent = 0; int rc = 0; - LASSERT(exp != NULL); + LASSERT(exp); LASSERT(count > 0); CFS_FAIL_TIMEOUT(OBD_FAIL_LDLM_PAUSE_CANCEL, cfs_fail_val); @@ -883,14 +901,14 @@ static int ldlm_cli_cancel_req(struct obd_export *exp, while (1) { imp = class_exp2cliimp(exp); - if (imp == NULL || imp->imp_invalid) { + if (!imp || imp->imp_invalid) { CDEBUG(D_DLMTRACE, "skipping cancel on invalid import %p\n", imp); return count; } req = ptlrpc_request_alloc(imp, &RQF_LDLM_CANCEL); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -946,7 +964,6 @@ out: static inline struct ldlm_pool *ldlm_imp2pl(struct obd_import *imp) { - LASSERT(imp != NULL); return &imp->imp_obd->obd_namespace->ns_pool; } @@ -971,7 +988,8 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) * is the case when server does not support LRU resize feature. * This is also possible in some recovery cases when server-side * reqs have no reference to the OBD export and thus access to - * server-side namespace is not possible. */ + * server-side namespace is not possible. + */ if (lustre_msg_get_slv(req->rq_repmsg) == 0 || lustre_msg_get_limit(req->rq_repmsg) == 0) { DEBUG_REQ(D_HA, req, @@ -989,7 +1007,8 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) * to the pool thread. We do not access obd_namespace and pool * directly here as there is no reliable way to make sure that * they are still alive at cleanup time. Evil races are possible - * which may cause Oops at that time. */ + * which may cause Oops at that time. + */ write_lock(&obd->obd_pool_lock); obd->obd_pool_slv = new_slv; obd->obd_pool_limit = new_limit; @@ -1005,7 +1024,7 @@ EXPORT_SYMBOL(ldlm_cli_update_pool); * Lock must not have any readers or writers by this time. */ int ldlm_cli_cancel(struct lustre_handle *lockh, - ldlm_cancel_flags_t cancel_flags) + enum ldlm_cancel_flags cancel_flags) { struct obd_export *exp; int avail, flags, count = 1; @@ -1016,7 +1035,7 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, /* concurrent cancels on the same handle can happen */ lock = ldlm_handle2lock_long(lockh, LDLM_FL_CANCELING); - if (lock == NULL) { + if (!lock) { LDLM_DEBUG_NOLOCK("lock is already being destroyed\n"); return 0; } @@ -1028,7 +1047,8 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, } /* Even if the lock is marked as LDLM_FL_BL_AST, this is a LDLM_CANCEL * RPC which goes to canceld portal, so we can cancel other LRU locks - * here and send them all as one LDLM_CANCEL RPC. */ + * here and send them all as one LDLM_CANCEL RPC. + */ LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, &cancels); @@ -1055,7 +1075,7 @@ EXPORT_SYMBOL(ldlm_cli_cancel); * Return the number of cancelled locks. */ int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, - ldlm_cancel_flags_t flags) + enum ldlm_cancel_flags flags) { LIST_HEAD(head); struct ldlm_lock *lock, *next; @@ -1076,7 +1096,8 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, /* Until we have compound requests and can send LDLM_CANCEL * requests batched with generic RPCs, we need to send cancels * with the LDLM_FL_BL_AST flag in a separate RPC from - * the one being generated now. */ + * the one being generated now. + */ if (!(flags & LCF_BL_AST) && (rc == LDLM_FL_BL_AST)) { LDLM_DEBUG(lock, "Cancel lock separately"); list_del_init(&lock->l_bl_ast); @@ -1116,7 +1137,8 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, lock_res_and_lock(lock); /* don't check added & count since we want to process all locks - * from unused list */ + * from unused list + */ switch (lock->l_resource->lr_type) { case LDLM_EXTENT: case LDLM_IBITS: @@ -1152,7 +1174,8 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, unsigned long la; /* Stop LRU processing when we reach past @count or have checked all - * locks in LRU. */ + * locks in LRU. + */ if (count && added >= count) return LDLM_POLICY_KEEP_LOCK; @@ -1166,7 +1189,8 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns, ldlm_pool_set_clv(pl, lv); /* Stop when SLV is not yet come from server or lv is smaller than - * it is. */ + * it is. + */ return (slv == 0 || lv < slv) ? LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK; } @@ -1186,7 +1210,8 @@ static ldlm_policy_res_t ldlm_cancel_passed_policy(struct ldlm_namespace *ns, int count) { /* Stop LRU processing when we reach past @count or have checked all - * locks in LRU. */ + * locks in LRU. + */ return (added >= count) ? LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK; } @@ -1227,7 +1252,8 @@ static ldlm_policy_res_t ldlm_cancel_default_policy(struct ldlm_namespace *ns, int count) { /* Stop LRU processing when we reach past count or have checked all - * locks in LRU. */ + * locks in LRU. + */ return (added >= count) ? LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK; } @@ -1307,7 +1333,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, count += unused - ns->ns_max_unused; pf = ldlm_cancel_lru_policy(ns, flags); - LASSERT(pf != NULL); + LASSERT(pf); while (!list_empty(&ns->ns_unused_list)) { ldlm_policy_res_t result; @@ -1331,7 +1357,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, continue; /* Somebody is already doing CANCEL. No need for this - * lock in LRU, do not traverse it again. */ + * lock in LRU, do not traverse it again. + */ if (!(lock->l_flags & LDLM_FL_CANCELING)) break; @@ -1380,7 +1407,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, /* Another thread is removing lock from LRU, or * somebody is already doing CANCEL, or there * is a blocking request which will send cancel - * by itself, or the lock is no longer unused. */ + * by itself, or the lock is no longer unused. + */ unlock_res_and_lock(lock); lu_ref_del(&lock->l_reference, __func__, current); @@ -1394,7 +1422,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, * better send cancel notification to server, so that it * frees appropriate state. This might lead to a race * where while we are doing cancel here, server is also - * silently cancelling this lock. */ + * silently cancelling this lock. + */ lock->l_flags &= ~LDLM_FL_CANCEL_ON_BLOCK; /* Setting the CBPENDING flag is a little misleading, @@ -1402,7 +1431,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, * CBPENDING is set, the lock can accumulate no more * readers/writers. Since readers and writers are * already zero here, ldlm_lock_decref() won't see - * this flag and call l_blocking_ast */ + * this flag and call l_blocking_ast + */ lock->l_flags |= LDLM_FL_CBPENDING | LDLM_FL_CANCELING; /* We can't re-add to l_lru as it confuses the @@ -1410,7 +1440,8 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, * arrives after we drop lr_lock below. We use l_bl_ast * and can't use l_pending_chain as it is used both on * server and client nevertheless bug 5666 says it is - * used only on server */ + * used only on server + */ LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, cancels); unlock_res_and_lock(lock); @@ -1425,7 +1456,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, int count, int max, - ldlm_cancel_flags_t cancel_flags, int flags) + enum ldlm_cancel_flags cancel_flags, int flags) { int added; @@ -1444,14 +1475,15 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, * callback will be performed in this function. */ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, - ldlm_cancel_flags_t cancel_flags, + enum ldlm_cancel_flags cancel_flags, int flags) { LIST_HEAD(cancels); int count, rc; /* Just prepare the list of locks, do not actually cancel them yet. - * Locks are cancelled later in a separate thread. */ + * Locks are cancelled later in a separate thread. + */ count = ldlm_prepare_lru_list(ns, &cancels, nr, 0, flags); rc = ldlm_bl_to_thread_list(ns, NULL, &cancels, count, cancel_flags); if (rc == 0) @@ -1468,15 +1500,16 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, ldlm_policy_data_t *policy, - ldlm_mode_t mode, __u64 lock_flags, - ldlm_cancel_flags_t cancel_flags, void *opaque) + enum ldlm_mode mode, __u64 lock_flags, + enum ldlm_cancel_flags cancel_flags, + void *opaque) { struct ldlm_lock *lock; int count = 0; lock_res(res); list_for_each_entry(lock, &res->lr_granted, l_res_link) { - if (opaque != NULL && lock->l_ast_data != opaque) { + if (opaque && lock->l_ast_data != opaque) { LDLM_ERROR(lock, "data %p doesn't match opaque %p", lock->l_ast_data, opaque); continue; @@ -1486,7 +1519,8 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, continue; /* If somebody is already doing CANCEL, or blocking AST came, - * skip this lock. */ + * skip this lock. + */ if (lock->l_flags & LDLM_FL_BL_AST || lock->l_flags & LDLM_FL_CANCELING) continue; @@ -1495,7 +1529,8 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, continue; /* If policy is given and this is IBITS lock, add to list only - * those locks that match by policy. */ + * those locks that match by policy. + */ if (policy && (lock->l_resource->lr_type == LDLM_IBITS) && !(lock->l_policy_data.l_inodebits.bits & policy->l_inodebits.bits)) @@ -1527,7 +1562,8 @@ EXPORT_SYMBOL(ldlm_cancel_resource_local); * Destroy \a cancels at the end. */ int ldlm_cli_cancel_list(struct list_head *cancels, int count, - struct ptlrpc_request *req, ldlm_cancel_flags_t flags) + struct ptlrpc_request *req, + enum ldlm_cancel_flags flags) { struct ldlm_lock *lock; int res = 0; @@ -1539,7 +1575,8 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, * Usually it is enough to have just 1 RPC, but it is possible that * there are too many locks to be cancelled in LRU or on a resource. * It would also speed up the case when the server does not support - * the feature. */ + * the feature. + */ while (count > 0) { LASSERT(!list_empty(cancels)); lock = list_entry(cancels->next, struct ldlm_lock, @@ -1577,12 +1614,13 @@ EXPORT_SYMBOL(ldlm_cli_cancel_list); * Cancel all locks on a resource that have 0 readers/writers. * * If flags & LDLM_FL_LOCAL_ONLY, throw the locks away without trying - * to notify the server. */ + * to notify the server. + */ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, ldlm_policy_data_t *policy, - ldlm_mode_t mode, - ldlm_cancel_flags_t flags, + enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque) { struct ldlm_resource *res; @@ -1591,7 +1629,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, int rc; res = ldlm_resource_get(ns, NULL, res_id, 0, 0); - if (res == NULL) { + if (!res) { /* This is not a problem. */ CDEBUG(D_INFO, "No resource %llu\n", res_id->name[0]); return 0; @@ -1638,17 +1676,17 @@ static int ldlm_cli_hash_cancel_unused(struct cfs_hash *hs, * to notify the server. */ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, - ldlm_cancel_flags_t flags, void *opaque) + enum ldlm_cancel_flags flags, void *opaque) { struct ldlm_cli_cancel_arg arg = { .lc_flags = flags, .lc_opaque = opaque, }; - if (ns == NULL) + if (!ns) return ELDLM_OK; - if (res_id != NULL) { + if (res_id) { return ldlm_cli_cancel_unused_resource(ns, res_id, NULL, LCK_MINMODE, flags, opaque); @@ -1743,13 +1781,13 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, struct ldlm_resource *res; int rc; - if (ns == NULL) { + if (!ns) { CERROR("must pass in namespace\n"); LBUG(); } res = ldlm_resource_get(ns, NULL, res_id, 0, 0); - if (res == NULL) + if (!res) return 0; LDLM_RESOURCE_ADDREF(res); @@ -1796,7 +1834,7 @@ static int replay_lock_interpret(const struct lu_env *env, goto out; reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - if (reply == NULL) { + if (!reply) { rc = -EPROTO; goto out; } @@ -1815,7 +1853,8 @@ static int replay_lock_interpret(const struct lu_env *env, exp = req->rq_export; if (exp && exp->exp_lock_hash) { /* In the function below, .hs_keycmp resolves to - * ldlm_export_lock_keycmp() */ + * ldlm_export_lock_keycmp() + */ /* coverity[overrun-buffer-val] */ cfs_hash_rehash_key(exp->exp_lock_hash, &lock->l_remote_handle, @@ -1850,7 +1889,8 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) /* If this is reply-less callback lock, we cannot replay it, since * server might have long dropped it, but notification of that event was - * lost by network. (and server granted conflicting lock already) */ + * lost by network. (and server granted conflicting lock already) + */ if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK) { LDLM_DEBUG(lock, "Not replaying reply-less lock:"); ldlm_lock_cancel(lock); @@ -1882,7 +1922,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) req = ptlrpc_request_alloc_pack(imp, &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); - if (req == NULL) + if (!req) return -ENOMEM; /* We're part of recovery, so don't wait for it. */ @@ -1901,7 +1941,8 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) /* notify the server we've replayed all requests. * also, we mark the request to be put on a dedicated * queue to be processed after all request replayes. - * bug 6063 */ + * bug 6063 + */ lustre_msg_set_flags(req->rq_reqmsg, MSG_REQ_REPLAY_DONE); LDLM_DEBUG(lock, "replaying lock:"); @@ -1936,7 +1977,8 @@ static void ldlm_cancel_unused_locks_for_replay(struct ldlm_namespace *ns) /* We don't need to care whether or not LRU resize is enabled * because the LDLM_CANCEL_NO_WAIT policy doesn't use the - * count parameter */ + * count parameter + */ canceled = ldlm_cancel_lru_local(ns, &cancels, ns->ns_nr_unused, 0, LCF_LOCAL, LDLM_CANCEL_NO_WAIT); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 0ae6100..03b9726 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -56,7 +56,8 @@ LIST_HEAD(ldlm_srv_namespace_list); struct mutex ldlm_cli_namespace_lock; /* Client Namespaces that have active resources in them. * Once all resources go away, ldlm_poold moves such namespaces to the - * inactive list */ + * inactive list + */ LIST_HEAD(ldlm_cli_active_namespace_list); /* Client namespaces that don't have any locks in them */ static LIST_HEAD(ldlm_cli_inactive_namespace_list); @@ -66,7 +67,8 @@ static struct dentry *ldlm_ns_debugfs_dir; struct dentry *ldlm_svc_debugfs_dir; /* during debug dump certain amount of granted locks for one resource to avoid - * DDOS. */ + * DDOS. + */ static unsigned int ldlm_dump_granted_max = 256; static ssize_t @@ -275,7 +277,8 @@ static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, ldlm_cancel_lru(ns, 0, LCF_ASYNC, LDLM_CANCEL_PASSED); /* Make sure that LRU resize was originally supported before - * turning it on here. */ + * turning it on here. + */ if (lru_resize && (ns->ns_orig_connect_flags & OBD_CONNECT_LRU_RESIZE)) { CDEBUG(D_DLMTRACE, @@ -380,7 +383,7 @@ static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) else ldebugfs_remove(&ns->ns_debugfs_entry); - if (ns->ns_stats != NULL) + if (ns->ns_stats) lprocfs_free_stats(&ns->ns_stats); } @@ -400,7 +403,7 @@ static int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) "%s", ldlm_ns_name(ns)); ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); - if (ns->ns_stats == NULL) { + if (!ns->ns_stats) { kobject_put(&ns->ns_kobj); return -ENOMEM; } @@ -420,7 +423,7 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) } else { ns_entry = debugfs_create_dir(ldlm_ns_name(ns), ldlm_ns_debugfs_dir); - if (ns_entry == NULL) + if (!ns_entry) return -ENOMEM; ns->ns_debugfs_entry = ns_entry; } @@ -554,7 +557,7 @@ static struct cfs_hash_ops ldlm_ns_fid_hash_ops = { }; struct ldlm_ns_hash_def { - ldlm_ns_type_t nsd_type; + enum ldlm_ns_type nsd_type; /** hash bucket bits */ unsigned nsd_bkt_bits; /** hash bits */ @@ -621,8 +624,8 @@ static void ldlm_namespace_register(struct ldlm_namespace *ns, */ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, ldlm_side_t client, - ldlm_appetite_t apt, - ldlm_ns_type_t ns_type) + enum ldlm_appetite apt, + enum ldlm_ns_type ns_type) { struct ldlm_namespace *ns = NULL; struct ldlm_ns_bucket *nsb; @@ -631,7 +634,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, int idx; int rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = ldlm_get_ref(); if (rc) { @@ -664,7 +667,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, CFS_HASH_BIGNAME | CFS_HASH_SPIN_BKTLOCK | CFS_HASH_NO_ITEMREF); - if (ns->ns_rs_hash == NULL) + if (!ns->ns_rs_hash) goto out_ns; cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, idx) { @@ -749,7 +752,8 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, struct lustre_handle lockh; /* First, we look for non-cleaned-yet lock - * all cleaned locks are marked by CLEANED flag. */ + * all cleaned locks are marked by CLEANED flag. + */ lock_res(res); list_for_each(tmp, q) { lock = list_entry(tmp, struct ldlm_lock, @@ -763,13 +767,14 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, break; } - if (lock == NULL) { + if (!lock) { unlock_res(res); break; } /* Set CBPENDING so nothing in the cancellation path - * can match this lock. */ + * can match this lock. + */ lock->l_flags |= LDLM_FL_CBPENDING; lock->l_flags |= LDLM_FL_FAILED; lock->l_flags |= flags; @@ -782,7 +787,8 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, /* This is a little bit gross, but much better than the * alternative: pretend that we got a blocking AST from * the server, so that when the lock is decref'd, it - * will go away ... */ + * will go away ... + */ unlock_res(res); LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY"); if (lock->l_completion_ast) @@ -837,7 +843,7 @@ static int ldlm_resource_complain(struct cfs_hash *hs, struct cfs_hash_bd *bd, */ int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags) { - if (ns == NULL) { + if (!ns) { CDEBUG(D_INFO, "NULL ns, skipping cleanup\n"); return ELDLM_OK; } @@ -873,7 +879,8 @@ force_wait: atomic_read(&ns->ns_bref) == 0, &lwi); /* Forced cleanups should be able to reclaim all references, - * so it's safe to wait forever... we can't leak locks... */ + * so it's safe to wait forever... we can't leak locks... + */ if (force && rc == -ETIMEDOUT) { LCONSOLE_ERROR("Forced cleanup waiting for %s namespace with %d resources in use, (rc=%d)\n", ldlm_ns_name(ns), @@ -943,7 +950,8 @@ static void ldlm_namespace_unregister(struct ldlm_namespace *ns, LASSERT(!list_empty(&ns->ns_list_chain)); /* Some asserts and possibly other parts of the code are still * using list_empty(&ns->ns_list_chain). This is why it is - * important to use list_del_init() here. */ + * important to use list_del_init() here. + */ list_del_init(&ns->ns_list_chain); ldlm_namespace_nr_dec(client); mutex_unlock(ldlm_namespace_lock(client)); @@ -963,7 +971,8 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) ldlm_namespace_unregister(ns, ns->ns_client); /* Fini pool _before_ parent proc dir is removed. This is important as * ldlm_pool_fini() removes own proc dir which is child to @dir. - * Removing it after @dir may cause oops. */ + * Removing it after @dir may cause oops. + */ ldlm_pool_fini(&ns->ns_pool); ldlm_namespace_debugfs_unregister(ns); @@ -971,7 +980,8 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) cfs_hash_putref(ns->ns_rs_hash); /* Namespace \a ns should be not on list at this time, otherwise * this will cause issues related to using freed \a ns in poold - * thread. */ + * thread. + */ LASSERT(list_empty(&ns->ns_list_chain)); kfree(ns); ldlm_put_ref(); @@ -1032,7 +1042,7 @@ static struct ldlm_resource *ldlm_resource_new(void) int idx; res = kmem_cache_alloc(ldlm_resource_slab, GFP_NOFS | __GFP_ZERO); - if (res == NULL) + if (!res) return NULL; INIT_LIST_HEAD(&res->lr_granted); @@ -1050,7 +1060,8 @@ static struct ldlm_resource *ldlm_resource_new(void) lu_ref_init(&res->lr_reference); /* The creator of the resource must unlock the mutex after LVB - * initialization. */ + * initialization. + */ mutex_init(&res->lr_lvb_mutex); mutex_lock(&res->lr_lvb_mutex); @@ -1065,7 +1076,8 @@ static struct ldlm_resource *ldlm_resource_new(void) */ struct ldlm_resource * ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, - const struct ldlm_res_id *name, ldlm_type_t type, int create) + const struct ldlm_res_id *name, enum ldlm_type type, + int create) { struct hlist_node *hnode; struct ldlm_resource *res; @@ -1073,14 +1085,13 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, __u64 version; int ns_refcount = 0; - LASSERT(ns != NULL); - LASSERT(parent == NULL); - LASSERT(ns->ns_rs_hash != NULL); + LASSERT(!parent); + LASSERT(ns->ns_rs_hash); LASSERT(name->name[0] != 0); cfs_hash_bd_get_and_lock(ns->ns_rs_hash, (void *)name, &bd, 0); hnode = cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name); - if (hnode != NULL) { + if (hnode) { cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 0); res = hlist_entry(hnode, struct ldlm_resource, lr_hash); /* Synchronize with regard to resource creation. */ @@ -1111,13 +1122,12 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, res->lr_ns_bucket = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd); res->lr_name = *name; res->lr_type = type; - res->lr_most_restr = LCK_NL; cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1); hnode = (version == cfs_hash_bd_version_get(&bd)) ? NULL : cfs_hash_bd_lookup_locked(ns->ns_rs_hash, &bd, (void *)name); - if (hnode != NULL) { + if (hnode) { /* Someone won the race and already added the resource. */ cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); /* Clean lu_ref for failed resource. */ @@ -1167,7 +1177,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* Let's see if we happened to be the very first resource in this * namespace. If so, and this is a client namespace, we need to move * the namespace into the active namespaces list to be patrolled by - * the ldlm_poold. */ + * the ldlm_poold. + */ if (ns_refcount == 1) { mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT); diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 6274558..c90e510 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -47,15 +47,15 @@ static char debug_file_name[1024]; unsigned int libcfs_subsystem_debug = ~0; +EXPORT_SYMBOL(libcfs_subsystem_debug); module_param(libcfs_subsystem_debug, int, 0644); MODULE_PARM_DESC(libcfs_subsystem_debug, "Lustre kernel debug subsystem mask"); -EXPORT_SYMBOL(libcfs_subsystem_debug); unsigned int libcfs_debug = (D_CANTMASK | D_NETERROR | D_HA | D_CONFIG | D_IOCTL); +EXPORT_SYMBOL(libcfs_debug); module_param(libcfs_debug, int, 0644); MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask"); -EXPORT_SYMBOL(libcfs_debug); static int libcfs_param_debug_mb_set(const char *val, const struct kernel_param *kp) @@ -82,7 +82,8 @@ static int libcfs_param_debug_mb_set(const char *val, /* While debug_mb setting look like unsigned int, in fact * it needs quite a bunch of extra processing, so we define special - * debugmb parameter type with corresponding methods to handle this case */ + * debugmb parameter type with corresponding methods to handle this case + */ static struct kernel_param_ops param_ops_debugmb = { .set = libcfs_param_debug_mb_set, .get = param_get_uint, @@ -227,8 +228,7 @@ MODULE_PARM_DESC(libcfs_debug_file_path, int libcfs_panic_in_progress; -/* libcfs_debug_token2mask() expects the returned - * string in lower-case */ +/* libcfs_debug_token2mask() expects the returned string in lower-case */ static const char * libcfs_debug_subsys2str(int subsys) { @@ -290,8 +290,7 @@ libcfs_debug_subsys2str(int subsys) } } -/* libcfs_debug_token2mask() expects the returned - * string in lower-case */ +/* libcfs_debug_token2mask() expects the returned string in lower-case */ static const char * libcfs_debug_dbg2str(int debug) { @@ -378,7 +377,7 @@ libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys) continue; token = fn(i); - if (token == NULL) /* unused bit */ + if (!token) /* unused bit */ continue; if (len > 0) { /* separator? */ @@ -418,7 +417,7 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) /* Allow a number for backwards compatibility */ for (n = strlen(str); n > 0; n--) - if (!isspace(str[n-1])) + if (!isspace(str[n - 1])) break; matched = n; t = sscanf(str, "%i%n", &m, &matched); @@ -448,8 +447,7 @@ void libcfs_debug_dumplog_internal(void *arg) snprintf(debug_file_name, sizeof(debug_file_name) - 1, "%s.%lld.%ld", libcfs_debug_file_path_arr, (s64)ktime_get_real_seconds(), (long_ptr_t)arg); - pr_alert("LustreError: dumping log to %s\n", - debug_file_name); + pr_alert("LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); libcfs_run_debug_log_upcall(debug_file_name); } @@ -471,7 +469,8 @@ void libcfs_debug_dumplog(void) /* we're being careful to ensure that the kernel thread is * able to set our state to running as it exits before we - * get to schedule() */ + * get to schedule() + */ init_waitqueue_entry(&wait, current); set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&debug_ctlwq, &wait); @@ -505,14 +504,15 @@ int libcfs_debug_init(unsigned long bufsize) libcfs_console_min_delay = CDEBUG_DEFAULT_MIN_DELAY; } - if (libcfs_debug_file_path != NULL) { + if (libcfs_debug_file_path) { strlcpy(libcfs_debug_file_path_arr, libcfs_debug_file_path, sizeof(libcfs_debug_file_path_arr)); } /* If libcfs_debug_mb is set to an invalid value or uninitialized - * then just make the total buffers smp_num_cpus * TCD_MAX_PAGES */ + * then just make the total buffers smp_num_cpus * TCD_MAX_PAGES + */ if (max > cfs_trace_max_debug_mb() || max < num_possible_cpus()) { max = TCD_MAX_PAGES; } else { @@ -542,8 +542,7 @@ int libcfs_debug_clear_buffer(void) return 0; } -/* Debug markers, although printed by S_LNET - * should not be be marked as such. */ +/* Debug markers, although printed by S_LNET should not be be marked as such. */ #undef DEBUG_SUBSYSTEM #define DEBUG_SUBSYSTEM S_UNDEFINED int libcfs_debug_mark_buffer(const char *text) diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index 2783143..dadaf76 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -97,7 +97,8 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set) /* Lost race to set CFS_FAILED_BIT. */ if (test_and_set_bit(CFS_FAILED_BIT, &cfs_fail_loc)) { /* If CFS_FAIL_ONCE is valid, only one process can fail, - * otherwise multi-process can fail at the same time. */ + * otherwise multi-process can fail at the same time. + */ if (cfs_fail_loc & CFS_FAIL_ONCE) return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 4d50510..f60feb3 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -355,7 +355,7 @@ cfs_hash_dh_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, dh = container_of(cfs_hash_dh_hhead(hs, bd), struct cfs_hash_dhead, dh_head); - if (dh->dh_tail != NULL) /* not empty */ + if (dh->dh_tail) /* not empty */ hlist_add_behind(hnode, dh->dh_tail); else /* empty list */ hlist_add_head(hnode, &dh->dh_head); @@ -371,7 +371,7 @@ cfs_hash_dh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, dh = container_of(cfs_hash_dh_hhead(hs, bd), struct cfs_hash_dhead, dh_head); - if (hnd->next == NULL) { /* it's the tail */ + if (!hnd->next) { /* it's the tail */ dh->dh_tail = (hnd->pprev == &dh->dh_head.first) ? NULL : container_of(hnd->pprev, struct hlist_node, next); } @@ -412,7 +412,7 @@ cfs_hash_dd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd, dh = container_of(cfs_hash_dd_hhead(hs, bd), struct cfs_hash_dhead_dep, dd_head); - if (dh->dd_tail != NULL) /* not empty */ + if (dh->dd_tail) /* not empty */ hlist_add_behind(hnode, dh->dd_tail); else /* empty list */ hlist_add_head(hnode, &dh->dd_head); @@ -428,7 +428,7 @@ cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd, dh = container_of(cfs_hash_dd_hhead(hs, bd), struct cfs_hash_dhead_dep, dd_head); - if (hnd->next == NULL) { /* it's the tail */ + if (!hnd->next) { /* it's the tail */ dh->dd_tail = (hnd->pprev == &dh->dd_head.first) ? NULL : container_of(hnd->pprev, struct hlist_node, next); } @@ -492,7 +492,7 @@ void cfs_hash_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bd) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ - if (likely(hs->hs_rehash_buckets == NULL)) { + if (likely(!hs->hs_rehash_buckets)) { cfs_hash_bd_from_key(hs, hs->hs_buckets, hs->hs_cur_bits, key, bd); } else { @@ -579,7 +579,8 @@ cfs_hash_bd_move_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd_old, return; /* use cfs_hash_bd_hnode_add/del, to avoid atomic & refcount ops - * in cfs_hash_bd_del/add_locked */ + * in cfs_hash_bd_del/add_locked + */ hs->hs_hops->hop_hnode_del(hs, bd_old, hnode); rc = hs->hs_hops->hop_hnode_add(hs, bd_new, hnode); cfs_hash_bd_dep_record(hs, bd_new, rc); @@ -635,13 +636,14 @@ cfs_hash_bd_lookup_intent(struct cfs_hash *hs, struct cfs_hash_bd *bd, int intent_add = (intent & CFS_HS_LOOKUP_MASK_ADD) != 0; /* with this function, we can avoid a lot of useless refcount ops, - * which are expensive atomic operations most time. */ + * which are expensive atomic operations most time. + */ match = intent_add ? NULL : hnode; hlist_for_each(ehnode, hhead) { if (!cfs_hash_keycmp(hs, key, ehnode)) continue; - if (match != NULL && match != ehnode) /* can't match */ + if (match && match != ehnode) /* can't match */ continue; /* match and ... */ @@ -659,7 +661,7 @@ cfs_hash_bd_lookup_intent(struct cfs_hash *hs, struct cfs_hash_bd *bd, if (!intent_add) return NULL; - LASSERT(hnode != NULL); + LASSERT(hnode); cfs_hash_bd_add_locked(hs, bd, hnode); return hnode; } @@ -698,8 +700,7 @@ cfs_hash_multi_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds, if (prev == bds[i].bd_bucket) continue; - LASSERT(prev == NULL || - prev->hsb_index < bds[i].bd_bucket->hsb_index); + LASSERT(!prev || prev->hsb_index < bds[i].bd_bucket->hsb_index); cfs_hash_bd_lock(hs, &bds[i], excl); prev = bds[i].bd_bucket; } @@ -730,7 +731,7 @@ cfs_hash_multi_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, cfs_hash_for_each_bd(bds, n, i) { ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key, NULL, CFS_HS_LOOKUP_IT_FIND); - if (ehnode != NULL) + if (ehnode) return ehnode; } return NULL; @@ -745,13 +746,13 @@ cfs_hash_multi_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, int intent; unsigned i; - LASSERT(hnode != NULL); + LASSERT(hnode); intent = (!noref * CFS_HS_LOOKUP_MASK_REF) | CFS_HS_LOOKUP_IT_PEEK; cfs_hash_for_each_bd(bds, n, i) { ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key, NULL, intent); - if (ehnode != NULL) + if (ehnode) return ehnode; } @@ -778,7 +779,7 @@ cfs_hash_multi_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds, cfs_hash_for_each_bd(bds, n, i) { ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key, hnode, CFS_HS_LOOKUP_IT_FINDDEL); - if (ehnode != NULL) + if (ehnode) return ehnode; } return NULL; @@ -789,26 +790,20 @@ cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2) { int rc; - if (bd2->bd_bucket == NULL) + if (!bd2->bd_bucket) return; - if (bd1->bd_bucket == NULL) { + if (!bd1->bd_bucket) { *bd1 = *bd2; bd2->bd_bucket = NULL; return; } rc = cfs_hash_bd_compare(bd1, bd2); - if (rc == 0) { + if (!rc) bd2->bd_bucket = NULL; - - } else if (rc > 0) { /* swab bd1 and bd2 */ - struct cfs_hash_bd tmp; - - tmp = *bd2; - *bd2 = *bd1; - *bd1 = tmp; - } + else if (rc > 0) + swap(*bd1, *bd2); /* swap bd1 and bd2 */ } void @@ -818,7 +813,7 @@ cfs_hash_dual_bd_get(struct cfs_hash *hs, const void *key, /* NB: caller should hold hs_lock.rw if REHASH is set */ cfs_hash_bd_from_key(hs, hs->hs_buckets, hs->hs_cur_bits, key, &bds[0]); - if (likely(hs->hs_rehash_buckets == NULL)) { + if (likely(!hs->hs_rehash_buckets)) { /* no rehash or not rehashing */ bds[1].bd_bucket = NULL; return; @@ -873,7 +868,7 @@ cfs_hash_buckets_free(struct cfs_hash_bucket **buckets, int i; for (i = prev_size; i < size; i++) { - if (buckets[i] != NULL) + if (buckets[i]) LIBCFS_FREE(buckets[i], bkt_size); } @@ -892,16 +887,16 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, struct cfs_hash_bucket **new_bkts; int i; - LASSERT(old_size == 0 || old_bkts != NULL); + LASSERT(old_size == 0 || old_bkts); - if (old_bkts != NULL && old_size == new_size) + if (old_bkts && old_size == new_size) return old_bkts; LIBCFS_ALLOC(new_bkts, sizeof(new_bkts[0]) * new_size); - if (new_bkts == NULL) + if (!new_bkts) return NULL; - if (old_bkts != NULL) { + if (old_bkts) { memcpy(new_bkts, old_bkts, min(old_size, new_size) * sizeof(*old_bkts)); } @@ -911,7 +906,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, struct cfs_hash_bd bd; LIBCFS_ALLOC(new_bkts[i], cfs_hash_bkt_size(hs)); - if (new_bkts[i] == NULL) { + if (!new_bkts[i]) { cfs_hash_buckets_free(new_bkts, cfs_hash_bkt_size(hs), old_size, new_size); return NULL; @@ -1011,14 +1006,13 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, CLASSERT(CFS_HASH_THETA_BITS < 15); - LASSERT(name != NULL); - LASSERT(ops != NULL); + LASSERT(name); LASSERT(ops->hs_key); LASSERT(ops->hs_hash); LASSERT(ops->hs_object); LASSERT(ops->hs_keycmp); - LASSERT(ops->hs_get != NULL); - LASSERT(ops->hs_put_locked != NULL); + LASSERT(ops->hs_get); + LASSERT(ops->hs_put_locked); if ((flags & CFS_HASH_REHASH) != 0) flags |= CFS_HASH_COUNTER; /* must have counter */ @@ -1029,13 +1023,12 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, LASSERT(ergo((flags & CFS_HASH_REHASH) == 0, cur_bits == max_bits)); LASSERT(ergo((flags & CFS_HASH_REHASH) != 0, (flags & CFS_HASH_NO_LOCK) == 0)); - LASSERT(ergo((flags & CFS_HASH_REHASH_KEY) != 0, - ops->hs_keycpy != NULL)); + LASSERT(ergo((flags & CFS_HASH_REHASH_KEY) != 0, ops->hs_keycpy)); len = (flags & CFS_HASH_BIGNAME) == 0 ? CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN; LIBCFS_ALLOC(hs, offsetof(struct cfs_hash, hs_name[len])); - if (hs == NULL) + if (!hs) return NULL; strlcpy(hs->hs_name, name, len); @@ -1063,7 +1056,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, hs->hs_buckets = cfs_hash_buckets_realloc(hs, NULL, 0, CFS_HASH_NBKT(hs)); - if (hs->hs_buckets != NULL) + if (hs->hs_buckets) return hs; LIBCFS_FREE(hs, offsetof(struct cfs_hash, hs_name[len])); @@ -1082,7 +1075,7 @@ cfs_hash_destroy(struct cfs_hash *hs) struct cfs_hash_bd bd; int i; - LASSERT(hs != NULL); + LASSERT(hs); LASSERT(!cfs_hash_is_exiting(hs) && !cfs_hash_is_iterating(hs)); @@ -1096,13 +1089,12 @@ cfs_hash_destroy(struct cfs_hash *hs) cfs_hash_depth_wi_cancel(hs); /* rehash should be done/canceled */ - LASSERT(hs->hs_buckets != NULL && - hs->hs_rehash_buckets == NULL); + LASSERT(hs->hs_buckets && !hs->hs_rehash_buckets); cfs_hash_for_each_bucket(hs, &bd, i) { struct hlist_head *hhead; - LASSERT(bd.bd_bucket != NULL); + LASSERT(bd.bd_bucket); /* no need to take this lock, just for consistent code */ cfs_hash_bd_lock(hs, &bd, 1); @@ -1113,7 +1105,8 @@ cfs_hash_destroy(struct cfs_hash *hs) hs->hs_name, bd.bd_bucket->hsb_index, bd.bd_offset, bd.bd_bucket->hsb_count); /* can't assert key valicate, because we - * can interrupt rehash */ + * can interrupt rehash + */ cfs_hash_bd_del_locked(hs, &bd, hnode); cfs_hash_exit(hs, hnode); } @@ -1164,7 +1157,8 @@ cfs_hash_rehash_bits(struct cfs_hash *hs) return -EAGAIN; /* XXX: need to handle case with max_theta != 2.0 - * and the case with min_theta != 0.5 */ + * and the case with min_theta != 0.5 + */ if ((hs->hs_cur_bits < hs->hs_max_bits) && (__cfs_hash_theta(hs) > hs->hs_max_theta)) return hs->hs_cur_bits + 1; @@ -1293,8 +1287,8 @@ cfs_hash_del(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) cfs_hash_dual_bd_get_and_lock(hs, key, bds, 1); /* NB: do nothing if @hnode is not in hash table */ - if (hnode == NULL || !hlist_unhashed(hnode)) { - if (bds[1].bd_bucket == NULL && hnode != NULL) { + if (!hnode || !hlist_unhashed(hnode)) { + if (!bds[1].bd_bucket && hnode) { cfs_hash_bd_del_locked(hs, &bds[0], hnode); } else { hnode = cfs_hash_dual_bd_finddel_locked(hs, bds, @@ -1302,7 +1296,7 @@ cfs_hash_del(struct cfs_hash *hs, const void *key, struct hlist_node *hnode) } } - if (hnode != NULL) { + if (hnode) { obj = cfs_hash_object(hs, hnode); bits = cfs_hash_rehash_bits(hs); } @@ -1348,7 +1342,7 @@ cfs_hash_lookup(struct cfs_hash *hs, const void *key) cfs_hash_dual_bd_get_and_lock(hs, key, bds, 0); hnode = cfs_hash_dual_bd_lookup_locked(hs, bds, key); - if (hnode != NULL) + if (hnode) obj = cfs_hash_object(hs, hnode); cfs_hash_dual_bd_unlock(hs, bds, 0); @@ -1378,7 +1372,8 @@ cfs_hash_for_each_enter(struct cfs_hash *hs) /* NB: iteration is mostly called by service thread, * we tend to cancel pending rehash-request, instead of * blocking service thread, we will relaunch rehash request - * after iteration */ + * after iteration + */ if (cfs_hash_is_rehashing(hs)) cfs_hash_rehash_cancel_locked(hs); cfs_hash_unlock(hs, 1); @@ -1436,7 +1431,7 @@ cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, struct hlist_head *hhead; cfs_hash_bd_lock(hs, &bd, excl); - if (func == NULL) { /* only glimpse size */ + if (!func) { /* only glimpse size */ count += bd.bd_bucket->hsb_count; cfs_hash_bd_unlock(hs, &bd, excl); continue; @@ -1574,7 +1569,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, stop_on_change = cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs) || - hs->hs_ops->hs_put_locked == NULL; + !hs->hs_ops->hs_put_locked; cfs_hash_lock(hs, 0); LASSERT(!cfs_hash_is_rehashing(hs)); @@ -1585,7 +1580,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, version = cfs_hash_bd_version_get(&bd); cfs_hash_bd_for_each_hlist(hs, &bd, hhead) { - for (hnode = hhead->first; hnode != NULL;) { + for (hnode = hhead->first; hnode;) { cfs_hash_bucket_validate(hs, &bd, hnode); cfs_hash_get(hs, hnode); cfs_hash_bd_unlock(hs, &bd, 0); @@ -1634,9 +1629,8 @@ cfs_hash_for_each_nolock(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, !cfs_hash_with_no_itemref(hs)) return -EOPNOTSUPP; - if (hs->hs_ops->hs_get == NULL || - (hs->hs_ops->hs_put == NULL && - hs->hs_ops->hs_put_locked == NULL)) + if (!hs->hs_ops->hs_get || + (!hs->hs_ops->hs_put && !hs->hs_ops->hs_put_locked)) return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); @@ -1667,9 +1661,8 @@ cfs_hash_for_each_empty(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, if (cfs_hash_with_no_lock(hs)) return -EOPNOTSUPP; - if (hs->hs_ops->hs_get == NULL || - (hs->hs_ops->hs_put == NULL && - hs->hs_ops->hs_put_locked == NULL)) + if (!hs->hs_ops->hs_get || + (!hs->hs_ops->hs_put && !hs->hs_ops->hs_put_locked)) return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); @@ -1708,7 +1701,6 @@ out: cfs_hash_unlock(hs, 0); cfs_hash_for_each_exit(hs); } - EXPORT_SYMBOL(cfs_hash_hlist_for_each); /* @@ -1837,7 +1829,7 @@ cfs_hash_rehash_bd(struct cfs_hash *hs, struct cfs_hash_bd *old) cfs_hash_bd_for_each_hlist(hs, old, hhead) { hlist_for_each_safe(hnode, pos, hhead) { key = cfs_hash_key(hs, hnode); - LASSERT(key != NULL); + LASSERT(key); /* Validate hnode is in the correct bucket. */ cfs_hash_bucket_validate(hs, old, hnode); /* @@ -1867,7 +1859,7 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi) int rc = 0; int i; - LASSERT(hs != NULL && cfs_hash_with_rehash(hs)); + LASSERT(hs && cfs_hash_with_rehash(hs)); cfs_hash_lock(hs, 0); LASSERT(cfs_hash_is_rehashing(hs)); @@ -1884,7 +1876,7 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi) bkts = cfs_hash_buckets_realloc(hs, hs->hs_buckets, old_size, new_size); cfs_hash_lock(hs, 1); - if (bkts == NULL) { + if (!bkts) { rc = -ENOMEM; goto out; } @@ -1903,7 +1895,7 @@ cfs_hash_rehash_worker(cfs_workitem_t *wi) goto out; } - LASSERT(hs->hs_rehash_buckets == NULL); + LASSERT(!hs->hs_rehash_buckets); hs->hs_rehash_buckets = bkts; rc = 0; @@ -1946,7 +1938,7 @@ out: bsize = cfs_hash_bkt_size(hs); cfs_hash_unlock(hs, 1); /* can't refer to @hs anymore because it could be destroyed */ - if (bkts != NULL) + if (bkts) cfs_hash_buckets_free(bkts, bsize, new_size, old_size); if (rc != 0) CDEBUG(D_INFO, "early quit of rehashing: %d\n", rc); @@ -1987,14 +1979,15 @@ void cfs_hash_rehash_key(struct cfs_hash *hs, const void *old_key, cfs_hash_bd_order(&bds[0], &bds[1]); cfs_hash_multi_bd_lock(hs, bds, 3, 1); - if (likely(old_bds[1].bd_bucket == NULL)) { + if (likely(!old_bds[1].bd_bucket)) { cfs_hash_bd_move_locked(hs, &old_bds[0], &new_bd, hnode); } else { cfs_hash_dual_bd_finddel_locked(hs, old_bds, old_key, hnode); cfs_hash_bd_add_locked(hs, &new_bd, hnode); } /* overwrite key inside locks, otherwise may screw up with - * other operations, i.e: rehash */ + * other operations, i.e: rehash + */ cfs_hash_keycpy(hs, hnode, new_key); cfs_hash_multi_bd_unlock(hs, bds, 3, 1); @@ -2013,7 +2006,7 @@ static struct cfs_hash_bucket ** cfs_hash_full_bkts(struct cfs_hash *hs) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ - if (hs->hs_rehash_buckets == NULL) + if (!hs->hs_rehash_buckets) return hs->hs_buckets; LASSERT(hs->hs_rehash_bits != 0); @@ -2025,7 +2018,7 @@ static unsigned int cfs_hash_full_nbkt(struct cfs_hash *hs) { /* NB: caller should hold hs->hs_rwlock if REHASH is set */ - if (hs->hs_rehash_buckets == NULL) + if (!hs->hs_rehash_buckets) return CFS_HASH_NBKT(hs); LASSERT(hs->hs_rehash_bits != 0); @@ -2046,15 +2039,15 @@ void cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m) theta = __cfs_hash_theta(hs); seq_printf(m, "%-*s %5d %5d %5d %d.%03d %d.%03d %d.%03d 0x%02x %6d ", - CFS_HASH_BIGNAME_LEN, hs->hs_name, - 1 << hs->hs_cur_bits, 1 << hs->hs_min_bits, - 1 << hs->hs_max_bits, - __cfs_hash_theta_int(theta), __cfs_hash_theta_frac(theta), - __cfs_hash_theta_int(hs->hs_min_theta), - __cfs_hash_theta_frac(hs->hs_min_theta), - __cfs_hash_theta_int(hs->hs_max_theta), - __cfs_hash_theta_frac(hs->hs_max_theta), - hs->hs_flags, hs->hs_rehash_count); + CFS_HASH_BIGNAME_LEN, hs->hs_name, + 1 << hs->hs_cur_bits, 1 << hs->hs_min_bits, + 1 << hs->hs_max_bits, + __cfs_hash_theta_int(theta), __cfs_hash_theta_frac(theta), + __cfs_hash_theta_int(hs->hs_min_theta), + __cfs_hash_theta_frac(hs->hs_min_theta), + __cfs_hash_theta_int(hs->hs_max_theta), + __cfs_hash_theta_frac(hs->hs_max_theta), + hs->hs_flags, hs->hs_rehash_count); /* * The distribution is a summary of the chained hash depth in diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index ba97c79..33352af 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* @@ -56,7 +51,7 @@ cfs_cpt_table_alloc(unsigned int ncpt) } LIBCFS_ALLOC(cptab, sizeof(*cptab)); - if (cptab != NULL) { + if (cptab) { cptab->ctb_version = CFS_CPU_VERSION_MAGIC; node_set(0, cptab->ctb_nodemask); cptab->ctb_nparts = ncpt; @@ -215,7 +210,7 @@ EXPORT_SYMBOL(cfs_cpt_bind); void cfs_cpu_fini(void) { - if (cfs_cpt_table != NULL) { + if (cfs_cpt_table) { cfs_cpt_table_free(cfs_cpt_table); cfs_cpt_table = NULL; } @@ -226,7 +221,7 @@ cfs_cpu_init(void) { cfs_cpt_table = cfs_cpt_table_alloc(1); - return cfs_cpt_table != NULL ? 0 : -1; + return cfs_cpt_table ? 0 : -1; } #endif /* HAVE_LIBCFS_CPT */ diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index 32db788..2de9eea 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. @@ -38,7 +33,7 @@ void cfs_percpt_lock_free(struct cfs_percpt_lock *pcl) { - LASSERT(pcl->pcl_locks != NULL); + LASSERT(pcl->pcl_locks); LASSERT(!pcl->pcl_locked); cfs_percpt_free(pcl->pcl_locks); @@ -115,7 +110,8 @@ cfs_percpt_lock(struct cfs_percpt_lock *pcl, int index) if (i == 0) { LASSERT(!pcl->pcl_locked); /* nobody should take private lock after this - * so I wouldn't starve for too long time */ + * so I wouldn't starve for too long time + */ pcl->pcl_locked = 1; } } diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index 27cf861..c5a6951 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* @@ -54,7 +49,7 @@ cfs_percpt_free(void *vars) arr = container_of(vars, struct cfs_var_array, va_ptrs[0]); for (i = 0; i < arr->va_count; i++) { - if (arr->va_ptrs[i] != NULL) + if (arr->va_ptrs[i]) LIBCFS_FREE(arr->va_ptrs[i], arr->va_size); } @@ -87,9 +82,10 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size) if (!arr) return NULL; - arr->va_size = size = L1_CACHE_ALIGN(size); - arr->va_count = count; - arr->va_cptab = cptab; + size = L1_CACHE_ALIGN(size); + arr->va_size = size; + arr->va_count = count; + arr->va_cptab = cptab; for (i = 0; i < count; i++) { LIBCFS_CPT_ALLOC(arr->va_ptrs[i], cptab, i, size); diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index 205a3ed..9dca666 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -54,7 +54,8 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), * and optionally an operator ('+' or '-'). If an operator * appears first in <str>, '*oldmask' is used as the starting point * (relative), otherwise minmask is used (absolute). An operator - * applies to all following tokens up to the next operator. */ + * applies to all following tokens up to the next operator. + */ while (*str != '\0') { while (isspace(*str)) str++; @@ -81,8 +82,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), found = 0; for (i = 0; i < 32; i++) { debugstr = bit2str(i); - if (debugstr != NULL && - strlen(debugstr) == len && + if (debugstr && strlen(debugstr) == len && strncasecmp(str, debugstr, len) == 0) { if (op == '-') newmask &= ~(1 << i); @@ -175,7 +175,7 @@ cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res) { char *end; - if (next->ls_str == NULL) + if (!next->ls_str) return 0; /* skip leading white spaces */ @@ -196,7 +196,7 @@ cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res) res->ls_str = next->ls_str; end = memchr(next->ls_str, delim, next->ls_len); - if (end == NULL) { + if (!end) { /* there is no the delimeter in the string */ end = next->ls_str + next->ls_len; next->ls_str = NULL; @@ -229,18 +229,13 @@ int cfs_str2num_check(char *str, int nob, unsigned *num, unsigned min, unsigned max) { - char *endp; + int rc; str = cfs_trimwhite(str); - *num = simple_strtoul(str, &endp, 0); - if (endp == str) + rc = kstrtouint(str, 10, num); + if (rc) return 0; - for (; endp < str + nob; endp++) { - if (!isspace(*endp)) - return 0; - } - return (*num >= min && *num <= max); } EXPORT_SYMBOL(cfs_str2num_check); @@ -266,7 +261,7 @@ cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max, struct cfs_lstr tok; LIBCFS_ALLOC(re, sizeof(*re)); - if (re == NULL) + if (!re) return -ENOMEM; if (src->ls_len == 1 && src->ls_str[0] == '*') { @@ -337,18 +332,19 @@ cfs_range_expr_print(char *buffer, int count, struct cfs_range_expr *expr, char s[] = "["; char e[] = "]"; - if (bracketed) - s[0] = e[0] = '\0'; + if (bracketed) { + s[0] = '\0'; + e[0] = '\0'; + } if (expr->re_lo == expr->re_hi) i = scnprintf(buffer, count, "%u", expr->re_lo); else if (expr->re_stride == 1) i = scnprintf(buffer, count, "%s%u-%u%s", - s, expr->re_lo, expr->re_hi, e); + s, expr->re_lo, expr->re_hi, e); else i = scnprintf(buffer, count, "%s%u-%u/%u%s", - s, expr->re_lo, expr->re_hi, - expr->re_stride, e); + s, expr->re_lo, expr->re_hi, expr->re_stride, e); return i; } @@ -442,7 +438,7 @@ cfs_expr_list_values(struct cfs_expr_list *expr_list, int max, __u32 **valpp) } LIBCFS_ALLOC(val, sizeof(val[0]) * count); - if (val == NULL) + if (!val) return -ENOMEM; count = 0; @@ -470,7 +466,7 @@ cfs_expr_list_free(struct cfs_expr_list *expr_list) struct cfs_range_expr *expr; expr = list_entry(expr_list->el_exprs.next, - struct cfs_range_expr, re_link); + struct cfs_range_expr, re_link); list_del(&expr->re_link); LIBCFS_FREE(expr, sizeof(*expr)); } @@ -495,7 +491,7 @@ cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, int rc; LIBCFS_ALLOC(expr_list, sizeof(*expr_list)); - if (expr_list == NULL) + if (!expr_list) return -ENOMEM; src.ls_str = str; @@ -509,7 +505,7 @@ cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, src.ls_len -= 2; rc = -EINVAL; - while (src.ls_str != NULL) { + while (src.ls_str) { struct cfs_lstr tok; if (!cfs_gettok(&src, ',', &tok)) { @@ -521,15 +517,12 @@ cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, if (rc != 0) break; - list_add_tail(&expr->re_link, - &expr_list->el_exprs); + list_add_tail(&expr->re_link, &expr_list->el_exprs); } } else { rc = cfs_range_expr_parse(&src, min, max, 0, &expr); - if (rc == 0) { - list_add_tail(&expr->re_link, - &expr_list->el_exprs); - } + if (rc == 0) + list_add_tail(&expr->re_link, &expr_list->el_exprs); } if (rc != 0) @@ -555,8 +548,7 @@ cfs_expr_list_free_list(struct list_head *list) struct cfs_expr_list *el; while (!list_empty(list)) { - el = list_entry(list->next, - struct cfs_expr_list, el_link); + el = list_entry(list->next, struct cfs_expr_list, el_link); list_del(&el->el_link); cfs_expr_list_free(el); } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index e52afe3..389fb9e 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* @@ -84,32 +79,32 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) { int i; - if (cptab->ctb_cpu2cpt != NULL) { + if (cptab->ctb_cpu2cpt) { LIBCFS_FREE(cptab->ctb_cpu2cpt, num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); } - for (i = 0; cptab->ctb_parts != NULL && i < cptab->ctb_nparts; i++) { + for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) { struct cfs_cpu_partition *part = &cptab->ctb_parts[i]; - if (part->cpt_nodemask != NULL) { + if (part->cpt_nodemask) { LIBCFS_FREE(part->cpt_nodemask, sizeof(*part->cpt_nodemask)); } - if (part->cpt_cpumask != NULL) + if (part->cpt_cpumask) LIBCFS_FREE(part->cpt_cpumask, cpumask_size()); } - if (cptab->ctb_parts != NULL) { + if (cptab->ctb_parts) { LIBCFS_FREE(cptab->ctb_parts, cptab->ctb_nparts * sizeof(cptab->ctb_parts[0])); } - if (cptab->ctb_nodemask != NULL) + if (cptab->ctb_nodemask) LIBCFS_FREE(cptab->ctb_nodemask, sizeof(*cptab->ctb_nodemask)); - if (cptab->ctb_cpumask != NULL) + if (cptab->ctb_cpumask) LIBCFS_FREE(cptab->ctb_cpumask, cpumask_size()); LIBCFS_FREE(cptab, sizeof(*cptab)); @@ -123,7 +118,7 @@ cfs_cpt_table_alloc(unsigned int ncpt) int i; LIBCFS_ALLOC(cptab, sizeof(*cptab)); - if (cptab == NULL) + if (!cptab) return NULL; cptab->ctb_nparts = ncpt; @@ -131,19 +126,19 @@ cfs_cpt_table_alloc(unsigned int ncpt) LIBCFS_ALLOC(cptab->ctb_cpumask, cpumask_size()); LIBCFS_ALLOC(cptab->ctb_nodemask, sizeof(*cptab->ctb_nodemask)); - if (cptab->ctb_cpumask == NULL || cptab->ctb_nodemask == NULL) + if (!cptab->ctb_cpumask || !cptab->ctb_nodemask) goto failed; LIBCFS_ALLOC(cptab->ctb_cpu2cpt, num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); - if (cptab->ctb_cpu2cpt == NULL) + if (!cptab->ctb_cpu2cpt) goto failed; memset(cptab->ctb_cpu2cpt, -1, num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); LIBCFS_ALLOC(cptab->ctb_parts, ncpt * sizeof(cptab->ctb_parts[0])); - if (cptab->ctb_parts == NULL) + if (!cptab->ctb_parts) goto failed; for (i = 0; i < ncpt; i++) { @@ -151,7 +146,7 @@ cfs_cpt_table_alloc(unsigned int ncpt) LIBCFS_ALLOC(part->cpt_cpumask, cpumask_size()); LIBCFS_ALLOC(part->cpt_nodemask, sizeof(*part->cpt_nodemask)); - if (part->cpt_cpumask == NULL || part->cpt_nodemask == NULL) + if (!part->cpt_cpumask || !part->cpt_nodemask) goto failed; } @@ -359,8 +354,6 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) if (i >= nr_cpu_ids) node_clear(node, *cptab->ctb_nodemask); - - return; } EXPORT_SYMBOL(cfs_cpt_unset_cpu); @@ -530,7 +523,8 @@ cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) return cpt; /* don't return negative value for safety of upper layer, - * instead we shadow the unknown cpu to a valid partition ID */ + * instead we shadow the unknown cpu to a valid partition ID + */ cpt = cpu % cptab->ctb_nparts; } @@ -618,7 +612,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, /* allocate scratch buffer */ LIBCFS_ALLOC(socket, cpumask_size()); LIBCFS_ALLOC(core, cpumask_size()); - if (socket == NULL || core == NULL) { + if (!socket || !core) { rc = -ENOMEM; goto out; } @@ -659,9 +653,9 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, } out: - if (socket != NULL) + if (socket) LIBCFS_FREE(socket, cpumask_size()); - if (core != NULL) + if (core) LIBCFS_FREE(core, cpumask_size()); return rc; } @@ -682,7 +676,8 @@ cfs_cpt_num_estimate(void) /* generate reasonable number of CPU partitions based on total number * of CPUs, Preferred N should be power2 and match this condition: - * 2 * (N - 1)^2 < NCPUS <= 2 * N^2 */ + * 2 * (N - 1)^2 < NCPUS <= 2 * N^2 + */ for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1) ; @@ -700,7 +695,8 @@ cfs_cpt_num_estimate(void) out: #if (BITS_PER_LONG == 32) /* config many CPU partitions on 32-bit system could consume - * too much memory */ + * too much memory + */ ncpt = min(2U, ncpt); #endif while (ncpu % ncpt != 0) @@ -735,7 +731,7 @@ cfs_cpt_table_create(int ncpt) } cptab = cfs_cpt_table_alloc(ncpt); - if (cptab == NULL) { + if (!cptab) { CERROR("Failed to allocate CPU map(%d)\n", ncpt); goto failed; } @@ -747,7 +743,7 @@ cfs_cpt_table_create(int ncpt) } LIBCFS_ALLOC(mask, cpumask_size()); - if (mask == NULL) { + if (!mask) { CERROR("Failed to allocate scratch cpumask\n"); goto failed; } @@ -793,10 +789,10 @@ cfs_cpt_table_create(int ncpt) CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n", ncpt, num_online_nodes(), num_online_cpus()); - if (mask != NULL) + if (mask) LIBCFS_FREE(mask, cpumask_size()); - if (cptab != NULL) + if (cptab) cfs_cpt_table_free(cptab); return NULL; @@ -814,7 +810,7 @@ cfs_cpt_table_create_pattern(char *pattern) for (ncpt = 0;; ncpt++) { /* quick scan bracket */ str = strchr(str, '['); - if (str == NULL) + if (!str) break; str++; } @@ -836,7 +832,7 @@ cfs_cpt_table_create_pattern(char *pattern) high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1; cptab = cfs_cpt_table_alloc(ncpt); - if (cptab == NULL) { + if (!cptab) { CERROR("Failed to allocate cpu partition table\n"); return NULL; } @@ -850,11 +846,12 @@ cfs_cpt_table_create_pattern(char *pattern) int i; int n; - if (bracket == NULL) { + if (!bracket) { if (*str != 0) { CERROR("Invalid pattern %s\n", str); goto failed; - } else if (c != ncpt) { + } + if (c != ncpt) { CERROR("expect %d partitions but found %d\n", ncpt, c); goto failed; @@ -885,7 +882,7 @@ cfs_cpt_table_create_pattern(char *pattern) } bracket = strchr(str, ']'); - if (bracket == NULL) { + if (!bracket) { CERROR("missing right bracket for cpt %d, %s\n", cpt, str); goto failed; @@ -943,6 +940,7 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) spin_lock(&cpt_data.cpt_lock); cpt_data.cpt_version++; spin_unlock(&cpt_data.cpt_lock); + /* Fall through */ default: if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", @@ -975,25 +973,25 @@ static struct notifier_block cfs_cpu_notifier = { void cfs_cpu_fini(void) { - if (cfs_cpt_table != NULL) + if (cfs_cpt_table) cfs_cpt_table_free(cfs_cpt_table); #ifdef CONFIG_HOTPLUG_CPU unregister_hotcpu_notifier(&cfs_cpu_notifier); #endif - if (cpt_data.cpt_cpumask != NULL) + if (cpt_data.cpt_cpumask) LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); } int cfs_cpu_init(void) { - LASSERT(cfs_cpt_table == NULL); + LASSERT(!cfs_cpt_table); memset(&cpt_data, 0, sizeof(cpt_data)); LIBCFS_ALLOC(cpt_data.cpt_cpumask, cpumask_size()); - if (cpt_data.cpt_cpumask == NULL) { + if (!cpt_data.cpt_cpumask) { CERROR("Failed to allocate scratch buffer\n"); return -1; } @@ -1007,7 +1005,7 @@ cfs_cpu_init(void) if (*cpu_pattern != 0) { cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); - if (cfs_cpt_table == NULL) { + if (!cfs_cpt_table) { CERROR("Failed to create cptab from pattern %s\n", cpu_pattern); goto failed; @@ -1015,7 +1013,7 @@ cfs_cpu_init(void) } else { cfs_cpt_table = cfs_cpt_table_create(cpu_npartitions); - if (cfs_cpt_table == NULL) { + if (!cfs_cpt_table) { CERROR("Failed to create ptable with npartitions %d\n", cpu_npartitions); goto failed; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index 079d50e..ec75801 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c @@ -45,14 +45,14 @@ static int cfs_crypto_hash_alloc(unsigned char alg_id, *type = cfs_crypto_hash_type(alg_id); - if (*type == NULL) { + if (!*type) { CWARN("Unsupported hash algorithm id = %d, max id is %d\n", alg_id, CFS_HASH_ALG_MAX); return -EINVAL; } desc->tfm = crypto_alloc_hash((*type)->cht_name, 0, 0); - if (desc->tfm == NULL) + if (!desc->tfm) return -EINVAL; if (IS_ERR(desc->tfm)) { @@ -69,7 +69,7 @@ static int cfs_crypto_hash_alloc(unsigned char alg_id, * Skip this function for digest, because we use shash logic at * cfs_crypto_hash_alloc. */ - if (key != NULL) + if (key) err = crypto_hash_setkey(desc->tfm, key, key_len); else if ((*type)->cht_key != 0) err = crypto_hash_setkey(desc->tfm, @@ -99,14 +99,14 @@ int cfs_crypto_hash_digest(unsigned char alg_id, int err; const struct cfs_crypto_hash_type *type; - if (buf == NULL || buf_len == 0 || hash_len == NULL) + if (!buf || buf_len == 0 || !hash_len) return -EINVAL; err = cfs_crypto_hash_alloc(alg_id, &type, &hdesc, key, key_len); if (err != 0) return err; - if (hash == NULL || *hash_len < type->cht_size) { + if (!hash || *hash_len < type->cht_size) { *hash_len = type->cht_size; crypto_free_hash(hdesc.tfm); return -ENOSPC; @@ -125,13 +125,12 @@ struct cfs_crypto_hash_desc * cfs_crypto_hash_init(unsigned char alg_id, unsigned char *key, unsigned int key_len) { - struct hash_desc *hdesc; int err; const struct cfs_crypto_hash_type *type; hdesc = kmalloc(sizeof(*hdesc), 0); - if (hdesc == NULL) + if (!hdesc) return ERR_PTR(-ENOMEM); err = cfs_crypto_hash_alloc(alg_id, &type, hdesc, key, key_len); @@ -175,16 +174,16 @@ int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *hdesc, int err; int size = crypto_hash_digestsize(((struct hash_desc *)hdesc)->tfm); - if (hash_len == NULL) { + if (!hash_len) { crypto_free_hash(((struct hash_desc *)hdesc)->tfm); kfree(hdesc); return 0; } - if (hash == NULL || *hash_len < size) { + if (!hash || *hash_len < size) { *hash_len = size; return -ENOSPC; } - err = crypto_hash_final((struct hash_desc *) hdesc, hash); + err = crypto_hash_final((struct hash_desc *)hdesc, hash); if (err < 0) { /* May be caller can fix error */ @@ -212,7 +211,6 @@ static void cfs_crypto_performance_test(unsigned char alg_id, hash, &hash_len); if (err) break; - } end = jiffies; @@ -235,8 +233,7 @@ int cfs_crypto_hash_speed(unsigned char hash_alg) { if (hash_alg < CFS_HASH_ALG_MAX) return cfs_crypto_hash_speeds[hash_alg]; - else - return -1; + return -1; } EXPORT_SYMBOL(cfs_crypto_hash_speed); @@ -249,11 +246,12 @@ static int cfs_crypto_test_hashes(void) unsigned char *data; unsigned int j; /* Data block size for testing hash. Maximum - * kmalloc size for 2.6.18 kernel is 128K */ + * kmalloc size for 2.6.18 kernel is 128K + */ unsigned int data_len = 1 * 128 * 1024; data = kmalloc(data_len, 0); - if (data == NULL) { + if (!data) { CERROR("Failed to allocate mem\n"); return -ENOMEM; } @@ -285,6 +283,4 @@ void cfs_crypto_unregister(void) { if (adler32 == 0) cfs_crypto_adler32_unregister(); - - return; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 68515d9..13d31e8 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -65,6 +65,7 @@ void cfs_cap_raise(cfs_cap_t cap) commit_creds(cred); } } +EXPORT_SYMBOL(cfs_cap_raise); void cfs_cap_lower(cfs_cap_t cap) { @@ -76,11 +77,13 @@ void cfs_cap_lower(cfs_cap_t cap) commit_creds(cred); } } +EXPORT_SYMBOL(cfs_cap_lower); int cfs_cap_raised(cfs_cap_t cap) { return cap_raised(current_cap(), cap); } +EXPORT_SYMBOL(cfs_cap_raised); static void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap) { @@ -95,10 +98,6 @@ cfs_cap_t cfs_curproc_cap_pack(void) cfs_kernel_cap_pack(current_cap(), &cap); return cap; } - -EXPORT_SYMBOL(cfs_cap_raise); -EXPORT_SYMBOL(cfs_cap_lower); -EXPORT_SYMBOL(cfs_cap_raised); EXPORT_SYMBOL(cfs_curproc_cap_pack); /* diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 59c7bf3..638e4b3 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -80,14 +80,14 @@ void libcfs_run_debug_log_upcall(char *file) argv[0] = lnet_debug_log_upcall; - LASSERTF(file != NULL, "called on a null filename\n"); + LASSERTF(file, "called on a null filename\n"); argv[1] = file; /* only need to pass the path of the file */ argv[2] = NULL; rc = call_usermodehelper(argv[0], argv, envp, 1); if (rc < 0 && rc != -ENOENT) { - CERROR("Error %d invoking LNET debug log upcall %s %s; check /proc/sys/lnet/debug_log_upcall\n", + CERROR("Error %d invoking LNET debug log upcall %s %s; check /sys/kernel/debug/lnet/debug_log_upcall\n", rc, argv[0], argv[1]); } else { CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n", @@ -106,14 +106,14 @@ void libcfs_run_upcall(char **argv) argv[0] = lnet_upcall; argc = 1; - while (argv[argc] != NULL) + while (argv[argc]) argc++; LASSERT(argc >= 2); rc = call_usermodehelper(argv[0], argv, envp, 1); if (rc < 0 && rc != -ENOENT) { - CERROR("Error %d invoking LNET upcall %s %s%s%s%s%s%s%s%s; check /proc/sys/lnet/upcall\n", + CERROR("Error %d invoking LNET upcall %s %s%s%s%s%s%s%s%s; check /sys/kernel/debug/lnet/upcall\n", rc, argv[0], argv[1], argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], @@ -142,8 +142,9 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) argv[4] = buf; argv[5] = NULL; - libcfs_run_upcall (argv); + libcfs_run_upcall(argv); } +EXPORT_SYMBOL(libcfs_run_lbug_upcall); /* coverity[+kill] */ void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata) @@ -166,9 +167,10 @@ void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata) while (1) schedule(); } +EXPORT_SYMBOL(lbug_with_loc); static int panic_notifier(struct notifier_block *self, unsigned long unused1, - void *unused2) + void *unused2) { if (libcfs_panic_in_progress) return 0; @@ -187,13 +189,12 @@ static struct notifier_block libcfs_panic_notifier = { void libcfs_register_panic_notifier(void) { - atomic_notifier_chain_register(&panic_notifier_list, &libcfs_panic_notifier); + atomic_notifier_chain_register(&panic_notifier_list, + &libcfs_panic_notifier); } void libcfs_unregister_panic_notifier(void) { - atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier); + atomic_notifier_chain_unregister(&panic_notifier_list, + &libcfs_panic_notifier); } - -EXPORT_SYMBOL(libcfs_run_lbug_upcall); -EXPORT_SYMBOL(lbug_with_loc); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c index 025e2f0..86f32ff 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c @@ -50,7 +50,7 @@ void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size, ret = kzalloc_node(size, flags | __GFP_NOWARN, cfs_cpt_spread_node(cptab, cpt)); if (!ret) { - WARN_ON(!(flags & (__GFP_FS|__GFP_HIGH))); + WARN_ON(!(flags & (__GFP_FS | __GFP_HIGH))); ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index e5bc3d3..ebc60ac 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -40,41 +40,10 @@ #define LNET_MINOR 240 -int libcfs_ioctl_getdata(char *buf, char *end, void __user *arg) +int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data) { - struct libcfs_ioctl_hdr *hdr; - struct libcfs_ioctl_data *data; - int orig_len; - - hdr = (struct libcfs_ioctl_hdr *)buf; - data = (struct libcfs_ioctl_data *)buf; - - if (copy_from_user(buf, arg, sizeof(*hdr))) - return -EFAULT; - - if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { - CERROR("PORTALS: version mismatch kernel vs application\n"); - return -EINVAL; - } - - if (hdr->ioc_len >= end - buf) { - CERROR("PORTALS: user buffer exceeds kernel buffer\n"); - return -EINVAL; - } - - if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) { - CERROR("PORTALS: user buffer too small for ioctl\n"); - return -EINVAL; - } - - orig_len = hdr->ioc_len; - if (copy_from_user(buf, arg, hdr->ioc_len)) - return -EFAULT; - if (orig_len != data->ioc_len) - return -EINVAL; - if (libcfs_ioctl_is_invalid(data)) { - CERROR("PORTALS: ioctl not correctly formatted\n"); + CERROR("LNET: ioctl not correctly formatted\n"); return -EINVAL; } @@ -88,6 +57,26 @@ int libcfs_ioctl_getdata(char *buf, char *end, void __user *arg) return 0; } +int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg, + __u32 *len) +{ + struct libcfs_ioctl_hdr hdr; + + if (copy_from_user(&hdr, arg, sizeof(hdr))) + return -EFAULT; + + if (hdr.ioc_version != LIBCFS_IOCTL_VERSION && + hdr.ioc_version != LIBCFS_IOCTL_VERSION2) { + CERROR("LNET: version mismatch expected %#x, got %#x\n", + LIBCFS_IOCTL_VERSION, hdr.ioc_version); + return -EINVAL; + } + + *len = hdr.ioc_len; + + return 0; +} + int libcfs_ioctl_popdata(void __user *arg, void *data, int size) { if (copy_to_user(arg, data, size)) @@ -102,7 +91,7 @@ libcfs_psdev_open(struct inode *inode, struct file *file) if (!inode) return -EINVAL; - if (libcfs_psdev_ops.p_open != NULL) + if (libcfs_psdev_ops.p_open) rc = libcfs_psdev_ops.p_open(0, NULL); else return -EPERM; @@ -117,7 +106,7 @@ libcfs_psdev_release(struct inode *inode, struct file *file) if (!inode) return -EINVAL; - if (libcfs_psdev_ops.p_close != NULL) + if (libcfs_psdev_ops.p_close) rc = libcfs_psdev_ops.p_close(0, NULL); else rc = -EPERM; @@ -134,8 +123,8 @@ static long libcfs_ioctl(struct file *file, return -EACCES; if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || - _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR || - _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) { + _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR || + _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) { CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n", _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); return -EINVAL; @@ -150,7 +139,7 @@ static long libcfs_ioctl(struct file *file, return 0; } - if (libcfs_psdev_ops.p_ioctl != NULL) + if (libcfs_psdev_ops.p_ioctl) rc = libcfs_psdev_ops.p_ioctl(&pfile, cmd, (void __user *)arg); else rc = -EPERM; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 64a136c..91c2ae8 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -63,9 +63,8 @@ int cfs_tracefile_init_arch(void) cfs_trace_data[i] = kmalloc(sizeof(union cfs_trace_data_union) * num_possible_cpus(), GFP_KERNEL); - if (cfs_trace_data[i] == NULL) + if (!cfs_trace_data[i]) goto out; - } /* arch related info initialized */ @@ -82,7 +81,7 @@ int cfs_tracefile_init_arch(void) kmalloc(CFS_TRACE_CONSOLE_BUFFER_SIZE, GFP_KERNEL); - if (cfs_trace_console_buffers[i][j] == NULL) + if (!cfs_trace_console_buffers[i][j]) goto out; } @@ -105,7 +104,7 @@ void cfs_tracefile_fini_arch(void) cfs_trace_console_buffers[i][j] = NULL; } - for (i = 0; cfs_trace_data[i] != NULL; i++) { + for (i = 0; cfs_trace_data[i]; i++) { kfree(cfs_trace_data[i]); cfs_trace_data[i] = NULL; } @@ -131,14 +130,13 @@ void cfs_tracefile_write_unlock(void) up_write(&cfs_tracefile_sem); } -cfs_trace_buf_type_t cfs_trace_buf_idx_get(void) +enum cfs_trace_buf_type cfs_trace_buf_idx_get(void) { if (in_irq()) return CFS_TCD_TYPE_IRQ; - else if (in_softirq()) + if (in_softirq()) return CFS_TCD_TYPE_SOFTIRQ; - else - return CFS_TCD_TYPE_PROC; + return CFS_TCD_TYPE_PROC; } /* @@ -176,16 +174,6 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) spin_unlock(&tcd->tcd_lock); } -int cfs_tcd_owns_tage(struct cfs_trace_cpu_data *tcd, - struct cfs_trace_page *tage) -{ - /* - * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - return tcd->tcd_cpu == tage->cpu; -} - void cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *msgdata, @@ -200,14 +188,14 @@ cfs_set_ptldebug_header(struct ptldebug_header *header, header->ph_cpu_id = smp_processor_id(); header->ph_type = cfs_trace_buf_idx_get(); /* y2038 safe since all user space treats this as unsigned, but - * will overflow in 2106 */ + * will overflow in 2106 + */ header->ph_sec = (u32)ts.tv_sec; header->ph_usec = ts.tv_nsec / NSEC_PER_USEC; header->ph_stack = stack; header->ph_pid = current->pid; header->ph_line_num = msgdata->msg_line; header->ph_extern_pid = 0; - return; } static char * @@ -261,12 +249,11 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, hdr->ph_pid, hdr->ph_extern_pid, file, hdr->ph_line_num, fn, len, buf); } - return; } int cfs_trace_max_debug_mb(void) { int total_mb = (totalram_pages >> (20 - PAGE_SHIFT)); - return max(512, (total_mb * 80)/100); + return max(512, (total_mb * 80) / 100); } diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 611607a..05e2c56 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -54,11 +54,15 @@ # define DEBUG_SUBSYSTEM S_LNET +#define LNET_MAX_IOCTL_BUF_LEN (sizeof(struct lnet_ioctl_net_config) + \ + sizeof(struct lnet_ioctl_config_data)) + #include "../../include/linux/libcfs/libcfs.h" #include <asm/div64.h> #include "../../include/linux/libcfs/libcfs_crypto.h" #include "../../include/linux/lnet/lib-lnet.h" +#include "../../include/linux/lnet/lib-dlc.h" #include "../../include/linux/lnet/lnet.h" #include "tracefile.h" @@ -115,11 +119,25 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand) } EXPORT_SYMBOL(libcfs_deregister_ioctl); -static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, - void __user *arg, struct libcfs_ioctl_data *data) +static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd, + void *arg, struct libcfs_ioctl_hdr *hdr) { + struct libcfs_ioctl_data *data = NULL; int err = -EINVAL; + /* + * The libcfs_ioctl_data_adjust() function performs adjustment + * operations on the libcfs_ioctl_data structure to make + * it usable by the code. This doesn't need to be called + * for new data structures added. + */ + if (hdr->ioc_version == LIBCFS_IOCTL_VERSION) { + data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); + err = libcfs_ioctl_data_adjust(data); + if (err) + return err; + } + switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); @@ -129,7 +147,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, * Handled in arch/cfs_module.c */ case IOC_LIBCFS_MARK_DEBUG: - if (data->ioc_inlbuf1 == NULL || + if (!data->ioc_inlbuf1 || data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') return -EINVAL; libcfs_debug_mark_buffer(data->ioc_inlbuf1); @@ -141,11 +159,11 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, err = -EINVAL; down_read(&ioctl_list_sem); list_for_each_entry(hand, &ioctl_list, item) { - err = hand->handle_ioctl(cmd, data); + err = hand->handle_ioctl(cmd, hdr); if (err != -EINVAL) { if (err == 0) err = libcfs_ioctl_popdata(arg, - data, sizeof(*data)); + hdr, hdr->ioc_len); break; } } @@ -160,26 +178,38 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void __user *arg) { - char *buf; - struct libcfs_ioctl_data *data; + struct libcfs_ioctl_hdr *hdr; int err = 0; + __u32 buf_len; + + err = libcfs_ioctl_getdata_len(arg, &buf_len); + if (err) + return err; - LIBCFS_ALLOC_GFP(buf, 1024, GFP_KERNEL); - if (buf == NULL) + /* + * do a check here to restrict the size of the memory + * to allocate to guard against DoS attacks. + */ + if (buf_len > LNET_MAX_IOCTL_BUF_LEN) { + CERROR("LNET: user buffer exceeds kernel buffer\n"); + return -EINVAL; + } + + LIBCFS_ALLOC_GFP(hdr, buf_len, GFP_KERNEL); + if (!hdr) return -ENOMEM; /* 'cmd' and permissions get checked in our arch-specific caller */ - if (libcfs_ioctl_getdata(buf, buf + 800, arg)) { - CERROR("PORTALS ioctl: data error\n"); - err = -EINVAL; + if (copy_from_user(hdr, arg, buf_len)) { + CERROR("LNET ioctl: data error\n"); + err = -EFAULT; goto out; } - data = (struct libcfs_ioctl_data *)buf; - err = libcfs_ioctl_int(pfile, cmd, arg, data); + err = libcfs_ioctl_handle(pfile, cmd, arg, hdr); out: - LIBCFS_FREE(buf, 1024); + LIBCFS_FREE(hdr, buf_len); return err; } @@ -192,9 +222,9 @@ struct cfs_psdev_ops libcfs_psdev_ops = { }; static int proc_call_handler(void *data, int write, loff_t *ppos, - void __user *buffer, size_t *lenp, - int (*handler)(void *data, int write, - loff_t pos, void __user *buffer, int len)) + void __user *buffer, size_t *lenp, + int (*handler)(void *data, int write, loff_t pos, + void __user *buffer, int len)) { int rc = handler(data, write, *ppos, buffer, *lenp); @@ -329,11 +359,11 @@ static int __proc_cpt_table(void *data, int write, if (write) return -EPERM; - LASSERT(cfs_cpt_table != NULL); + LASSERT(cfs_cpt_table); while (1) { LIBCFS_ALLOC(buf, len); - if (buf == NULL) + if (!buf) return -ENOMEM; rc = cfs_cpt_table_print(cfs_cpt_table, buf, len); @@ -355,23 +385,19 @@ static int __proc_cpt_table(void *data, int write, rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL); out: - if (buf != NULL) + if (buf) LIBCFS_FREE(buf, len); return rc; } static int proc_cpt_table(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) + void __user *buffer, size_t *lenp, loff_t *ppos) { return proc_call_handler(table->data, write, ppos, buffer, lenp, __proc_cpt_table); } static struct ctl_table lnet_table[] = { - /* - * NB No .strategy entries have been provided since sysctl(8) prefers - * to go via /proc for portability. - */ { .procname = "debug", .data = &libcfs_debug, @@ -535,7 +561,7 @@ static const struct file_operations *lnet_debugfs_fops_select(umode_t mode) void lustre_insert_debugfs(struct ctl_table *table, const struct lnet_debugfs_symlink_def *symlinks) { - if (lnet_debugfs_root == NULL) + if (!lnet_debugfs_root) lnet_debugfs_root = debugfs_create_dir("lnet", NULL); /* Even if we cannot create, just ignore it altogether) */ @@ -553,14 +579,12 @@ void lustre_insert_debugfs(struct ctl_table *table, for (; symlinks && symlinks->name; symlinks++) debugfs_create_symlink(symlinks->name, lnet_debugfs_root, symlinks->target); - } EXPORT_SYMBOL_GPL(lustre_insert_debugfs); static void lustre_remove_debugfs(void) { - if (lnet_debugfs_root != NULL) - debugfs_remove_recursive(lnet_debugfs_root); + debugfs_remove_recursive(lnet_debugfs_root); lnet_debugfs_root = NULL; } diff --git a/drivers/staging/lustre/lustre/libcfs/prng.c b/drivers/staging/lustre/lustre/libcfs/prng.c index 4147664..c75ae9a 100644 --- a/drivers/staging/lustre/lustre/libcfs/prng.c +++ b/drivers/staging/lustre/lustre/libcfs/prng.c @@ -42,11 +42,11 @@ #include "../../include/linux/libcfs/libcfs.h" /* -From: George Marsaglia <geo@stat.fsu.edu> -Newsgroups: sci.math -Subject: Re: A RANDOM NUMBER GENERATOR FOR C -Date: Tue, 30 Sep 1997 05:29:35 -0700 - + * From: George Marsaglia <geo@stat.fsu.edu> + * Newsgroups: sci.math + * Subject: Re: A RANDOM NUMBER GENERATOR FOR C + * Date: Tue, 30 Sep 1997 05:29:35 -0700 + * * You may replace the two constants 36969 and 18000 by any * pair of distinct constants from this list: * 18000 18030 18273 18513 18879 19074 19098 19164 19215 19584 @@ -58,7 +58,8 @@ Date: Tue, 30 Sep 1997 05:29:35 -0700 * 27960 28320 28380 28689 28710 28794 28854 28959 28980 29013 * 29379 29889 30135 30345 30459 30714 30903 30963 31059 31083 * (or any other 16-bit constants k for which both k*2^16-1 - * and k*2^15-1 are prime) */ + * and k*2^15-1 are prime) + */ #define RANDOM_CONST_A 18030 #define RANDOM_CONST_B 29013 diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 65c4f1a..ec3bc04 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -56,6 +56,51 @@ static int thread_running; static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); +struct page_collection { + struct list_head pc_pages; + /* + * if this flag is set, collect_pages() will spill both + * ->tcd_daemon_pages and ->tcd_pages to the ->pc_pages. Otherwise, + * only ->tcd_pages are spilled. + */ + int pc_want_daemon_pages; +}; + +struct tracefiled_ctl { + struct completion tctl_start; + struct completion tctl_stop; + wait_queue_head_t tctl_waitq; + pid_t tctl_pid; + atomic_t tctl_shutdown; +}; + +/* + * small data-structure for each page owned by tracefiled. + */ +struct cfs_trace_page { + /* + * page itself + */ + struct page *page; + /* + * linkage into one of the lists in trace_data_union or + * page_collection + */ + struct list_head linkage; + /* + * number of bytes used within this page + */ + unsigned int used; + /* + * cpu that owns this page + */ + unsigned short cpu; + /* + * type(context) of this page + */ + unsigned short type; +}; + static void put_pages_on_tcd_daemon_list(struct page_collection *pc, struct cfs_trace_cpu_data *tcd); @@ -80,11 +125,11 @@ static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp) */ gfp |= __GFP_NOWARN; page = alloc_page(gfp); - if (page == NULL) + if (!page) return NULL; tage = kmalloc(sizeof(*tage), gfp); - if (tage == NULL) { + if (!tage) { __free_page(page); return NULL; } @@ -96,9 +141,6 @@ static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp) static void cfs_tage_free(struct cfs_trace_page *tage) { - __LASSERT(tage != NULL); - __LASSERT(tage->page != NULL); - __free_page(tage->page); kfree(tage); atomic_dec(&cfs_tage_allocated); @@ -107,9 +149,6 @@ static void cfs_tage_free(struct cfs_trace_page *tage) static void cfs_tage_to_tail(struct cfs_trace_page *tage, struct list_head *queue) { - __LASSERT(tage != NULL); - __LASSERT(queue != NULL); - list_move_tail(&tage->linkage, queue); } @@ -127,7 +166,7 @@ int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp, struct cfs_trace_page *tage; tage = cfs_tage_alloc(gfp); - if (tage == NULL) + if (!tage) break; list_add_tail(&tage->linkage, stock); } @@ -154,7 +193,7 @@ cfs_trace_get_tage_try(struct cfs_trace_cpu_data *tcd, unsigned long len) list_del_init(&tage->linkage); } else { tage = cfs_tage_alloc(GFP_ATOMIC); - if (unlikely(tage == NULL)) { + if (unlikely(!tage)) { if ((!memory_pressure_get() || in_interrupt()) && printk_ratelimit()) printk(KERN_WARNING @@ -227,7 +266,7 @@ static struct cfs_trace_page *cfs_trace_get_tage(struct cfs_trace_cpu_data *tcd, } tage = cfs_trace_get_tage_try(tcd, len); - if (tage != NULL) + if (tage) return tage; if (thread_running) cfs_tcd_shrink(tcd); @@ -278,10 +317,11 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, /* cfs_trace_get_tcd() grabs a lock, which disables preemption and * pins us to a particular CPU. This avoids an smp_processor_id() - * warning on Linux when debugging is enabled. */ + * warning on Linux when debugging is enabled. + */ cfs_set_ptldebug_header(&header, msgdata, CDEBUG_STACK()); - if (tcd == NULL) /* arch may not log in IRQ context */ + if (!tcd) /* arch may not log in IRQ context */ goto console; if (tcd->tcd_cur_pages == 0) @@ -301,14 +341,14 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, if (libcfs_debug_binary) known_size += sizeof(header); - /*/ + /* * '2' used because vsnprintf return real size required for output * _without_ terminating NULL. * if needed is to small for this format. */ for (i = 0; i < 2; i++) { tage = cfs_trace_get_tage(tcd, needed + known_size + 1); - if (tage == NULL) { + if (!tage) { if (needed + known_size > PAGE_CACHE_SIZE) mask |= D_ERROR; @@ -352,7 +392,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, break; } - if (*(string_buf+needed-1) != '\n') + if (*(string_buf + needed - 1) != '\n') printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n", file, msgdata->msg_line, msgdata->msg_fn); @@ -384,30 +424,30 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, __LASSERT(debug_buf == string_buf); tage->used += needed; - __LASSERT (tage->used <= PAGE_CACHE_SIZE); + __LASSERT(tage->used <= PAGE_CACHE_SIZE); console: if ((mask & libcfs_printk) == 0) { /* no console output requested */ - if (tcd != NULL) + if (tcd) cfs_trace_put_tcd(tcd); return 1; } - if (cdls != NULL) { + if (cdls) { if (libcfs_console_ratelimit && cdls->cdls_next != 0 && /* not first time ever */ !cfs_time_after(cfs_time_current(), cdls->cdls_next)) { /* skipping a console message */ cdls->cdls_count++; - if (tcd != NULL) + if (tcd) cfs_trace_put_tcd(tcd); return 1; } - if (cfs_time_after(cfs_time_current(), cdls->cdls_next + - libcfs_console_max_delay - + cfs_time_seconds(10))) { + if (cfs_time_after(cfs_time_current(), + cdls->cdls_next + libcfs_console_max_delay + + cfs_time_seconds(10))) { /* last timeout was a long time ago */ cdls->cdls_delay /= libcfs_console_backoff * 4; } else { @@ -423,7 +463,7 @@ console: cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1; } - if (tcd != NULL) { + if (tcd) { cfs_print_to_console(&header, mask, string_buf, needed, file, msgdata->msg_fn); cfs_trace_put_tcd(tcd); @@ -431,18 +471,18 @@ console: string_buf = cfs_trace_get_console_buffer(); needed = 0; - if (format1 != NULL) { + if (format1) { va_copy(ap, args); needed = vsnprintf(string_buf, CFS_TRACE_CONSOLE_BUFFER_SIZE, format1, ap); va_end(ap); } - if (format2 != NULL) { + if (format2) { remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed; if (remain > 0) { va_start(ap, format2); - needed += vsnprintf(string_buf+needed, remain, + needed += vsnprintf(string_buf + needed, remain, format2, ap); va_end(ap); } @@ -453,7 +493,7 @@ console: put_cpu(); } - if (cdls != NULL && cdls->cdls_count != 0) { + if (cdls && cdls->cdls_count != 0) { string_buf = cfs_trace_get_console_buffer(); needed = snprintf(string_buf, CFS_TRACE_CONSOLE_BUFFER_SIZE, @@ -497,7 +537,8 @@ panic_collect_pages(struct page_collection *pc) { /* Do the collect_pages job on a single CPU: assumes that all other * CPUs have been stopped during a panic. If this isn't true for some - * arch, this will have to be implemented separately in each arch. */ + * arch, this will have to be implemented separately in each arch. + */ int i; int j; struct cfs_trace_cpu_data *tcd; @@ -509,8 +550,7 @@ panic_collect_pages(struct page_collection *pc) tcd->tcd_cur_pages = 0; if (pc->pc_want_daemon_pages) { - list_splice_init(&tcd->tcd_daemon_pages, - &pc->pc_pages); + list_splice_init(&tcd->tcd_daemon_pages, &pc->pc_pages); tcd->tcd_cur_daemon_pages = 0; } } @@ -527,7 +567,7 @@ static void collect_pages_on_all_cpus(struct page_collection *pc) tcd->tcd_cur_pages = 0; if (pc->pc_want_daemon_pages) { list_splice_init(&tcd->tcd_daemon_pages, - &pc->pc_pages); + &pc->pc_pages); tcd->tcd_cur_daemon_pages = 0; } } @@ -558,7 +598,6 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc) list_for_each_entry_safe(tage, tmp, &pc->pc_pages, linkage) { - __LASSERT_TAGE_INVARIANT(tage); if (tage->cpu != cpu || tage->type != i) @@ -580,7 +619,8 @@ static void put_pages_back(struct page_collection *pc) /* Add pages to a per-cpu debug daemon ringbuffer. This buffer makes sure that * we have a good amount of data at all times for dumping during an LBUG, even * if we have been steadily writing (and otherwise discarding) pages via the - * debug daemon. */ + * debug daemon. + */ static void put_pages_on_tcd_daemon_list(struct page_collection *pc, struct cfs_trace_cpu_data *tcd) { @@ -588,7 +628,6 @@ static void put_pages_on_tcd_daemon_list(struct page_collection *pc, struct cfs_trace_page *tmp; list_for_each_entry_safe(tage, tmp, &pc->pc_pages, linkage) { - __LASSERT_TAGE_INVARIANT(tage); if (tage->cpu != tcd->tcd_cpu || tage->type != tcd->tcd_type) @@ -674,12 +713,13 @@ int cfs_tracefile_dump_all_pages(char *filename) cfs_tracefile_write_lock(); - filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600); + filp = filp_open(filename, O_CREAT | O_EXCL | O_WRONLY | O_LARGEFILE, + 0600); if (IS_ERR(filp)) { rc = PTR_ERR(filp); filp = NULL; pr_err("LustreError: can't open %s for dump: rc %d\n", - filename, rc); + filename, rc); goto out; } @@ -691,10 +731,10 @@ int cfs_tracefile_dump_all_pages(char *filename) } /* ok, for now, just write the pages. in the future we'll be building - * iobufs with the pages and calling generic_direct_IO */ + * iobufs with the pages and calling generic_direct_IO + */ MMSPACE_OPEN; list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { - __LASSERT_TAGE_INVARIANT(tage); buf = kmap(tage->page); @@ -732,7 +772,6 @@ void cfs_trace_flush_pages(void) pc.pc_want_daemon_pages = 1; collect_pages(&pc); list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { - __LASSERT_TAGE_INVARIANT(tage); list_del(&tage->linkage); @@ -771,9 +810,10 @@ EXPORT_SYMBOL(cfs_trace_copyin_string); int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, const char *knl_buffer, char *append) { - /* NB if 'append' != NULL, it's a single character to append to the - * copied out string - usually "\n", for /proc entries and "" (i.e. a - * terminating zero byte) for sysctl entries */ + /* + * NB if 'append' != NULL, it's a single character to append to the + * copied out string - usually "\n" or "" (i.e. a terminating zero byte) + */ int nob = strlen(knl_buffer); if (nob > usr_buffer_nob) @@ -782,7 +822,7 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, if (copy_to_user(usr_buffer, knl_buffer, nob)) return -EFAULT; - if (append != NULL && nob < usr_buffer_nob) { + if (append && nob < usr_buffer_nob) { if (copy_to_user(usr_buffer + nob, append, 1)) return -EFAULT; @@ -799,7 +839,7 @@ int cfs_trace_allocate_string_buffer(char **str, int nob) return -EINVAL; *str = kmalloc(nob, GFP_KERNEL | __GFP_ZERO); - if (*str == NULL) + if (!*str) return -ENOMEM; return 0; @@ -842,12 +882,15 @@ int cfs_trace_daemon_command(char *str) memset(cfs_tracefile, 0, sizeof(cfs_tracefile)); } else if (strncmp(str, "size=", 5) == 0) { - cfs_tracefile_size = simple_strtoul(str + 5, NULL, 0); - if (cfs_tracefile_size < 10 || cfs_tracefile_size > 20480) - cfs_tracefile_size = CFS_TRACEFILE_SIZE; - else - cfs_tracefile_size <<= 20; - + unsigned long tmp; + + rc = kstrtoul(str + 5, 10, &tmp); + if (!rc) { + if (tmp < 10 || tmp > 20480) + cfs_tracefile_size = CFS_TRACEFILE_SIZE; + else + cfs_tracefile_size = tmp << 20; + } } else if (strlen(str) >= sizeof(cfs_tracefile)) { rc = -ENAMETOOLONG; } else if (str[0] != '/') { @@ -877,7 +920,7 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob) return rc; rc = cfs_trace_copyin_string(str, usr_str_nob + 1, - usr_str, usr_str_nob); + usr_str, usr_str_nob); if (rc == 0) rc = cfs_trace_daemon_command(str); @@ -977,7 +1020,7 @@ static int tracefiled(void *arg) } } cfs_tracefile_read_unlock(); - if (filp == NULL) { + if (!filp) { put_pages_on_daemon_list(&pc); __LASSERT(list_empty(&pc.pc_pages)); goto end_loop; @@ -985,8 +1028,7 @@ static int tracefiled(void *arg) MMSPACE_OPEN; - list_for_each_entry_safe(tage, tmp, &pc.pc_pages, - linkage) { + list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { static loff_t f_pos; __LASSERT_TAGE_INVARIANT(tage); @@ -1017,8 +1059,7 @@ static int tracefiled(void *arg) int i; printk(KERN_ALERT "Lustre: trace pages aren't empty\n"); - pr_err("total cpus(%d): ", - num_possible_cpus()); + pr_err("total cpus(%d): ", num_possible_cpus()); for (i = 0; i < num_possible_cpus(); i++) if (cpu_online(i)) pr_cont("%d(on) ", i); @@ -1028,9 +1069,9 @@ static int tracefiled(void *arg) i = 0; list_for_each_entry_safe(tage, tmp, &pc.pc_pages, - linkage) + linkage) pr_err("page %d belongs to cpu %d\n", - ++i, tage->cpu); + ++i, tage->cpu); pr_err("There are %d pages unwritten\n", i); } __LASSERT(list_empty(&pc.pc_pages)); @@ -1056,6 +1097,7 @@ end_loop: int cfs_trace_start_thread(void) { struct tracefiled_ctl *tctl = &trace_tctl; + struct task_struct *task; int rc = 0; mutex_lock(&cfs_trace_thread_mutex); @@ -1067,8 +1109,9 @@ int cfs_trace_start_thread(void) init_waitqueue_head(&tctl->tctl_waitq); atomic_set(&tctl->tctl_shutdown, 0); - if (IS_ERR(kthread_run(tracefiled, tctl, "ktracefiled"))) { - rc = -ECHILD; + task = kthread_run(tracefiled, tctl, "ktracefiled"); + if (IS_ERR(task)) { + rc = PTR_ERR(task); goto out; } @@ -1135,7 +1178,7 @@ static void trace_cleanup_on_all_cpus(void) tcd->tcd_shutting_down = 1; list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages, - linkage) { + linkage) { __LASSERT_TAGE_INVARIANT(tage); list_del(&tage->linkage); diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h index 7bf1471..4c77f90 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.h +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h @@ -39,12 +39,12 @@ #include "../../include/linux/libcfs/libcfs.h" -typedef enum { +enum cfs_trace_buf_type { CFS_TCD_TYPE_PROC = 0, CFS_TCD_TYPE_SOFTIRQ, CFS_TCD_TYPE_IRQ, CFS_TCD_TYPE_MAX -} cfs_trace_buf_type_t; +}; /* trace file lock routines */ @@ -101,8 +101,10 @@ int cfs_trace_max_debug_mb(void); #define CFS_TRACEFILE_SIZE (500 << 20) -/* Size of a buffer for sprinting console messages if we can't get a page - * from system */ +/* + * Size of a buffer for sprinting console messages if we can't get a page + * from system + */ #define CFS_TRACE_CONSOLE_BUFFER_SIZE 1024 union cfs_trace_data_union { @@ -185,66 +187,15 @@ union cfs_trace_data_union { extern union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS]; #define cfs_tcd_for_each(tcd, i, j) \ - for (i = 0; cfs_trace_data[i] != NULL; i++) \ - for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ - j < num_possible_cpus(); \ - j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) + for (i = 0; cfs_trace_data[i]; i++) \ + for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ + j < num_possible_cpus(); \ + j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) #define cfs_tcd_for_each_type_lock(tcd, i, cpu) \ - for (i = 0; cfs_trace_data[i] && \ - (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ - cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++) - -/* XXX nikita: this declaration is internal to tracefile.c and should probably - * be moved there */ -struct page_collection { - struct list_head pc_pages; - /* - * if this flag is set, collect_pages() will spill both - * ->tcd_daemon_pages and ->tcd_pages to the ->pc_pages. Otherwise, - * only ->tcd_pages are spilled. - */ - int pc_want_daemon_pages; -}; - -/* XXX nikita: this declaration is internal to tracefile.c and should probably - * be moved there */ -struct tracefiled_ctl { - struct completion tctl_start; - struct completion tctl_stop; - wait_queue_head_t tctl_waitq; - pid_t tctl_pid; - atomic_t tctl_shutdown; -}; - -/* - * small data-structure for each page owned by tracefiled. - */ -/* XXX nikita: this declaration is internal to tracefile.c and should probably - * be moved there */ -struct cfs_trace_page { - /* - * page itself - */ - struct page *page; - /* - * linkage into one of the lists in trace_data_union or - * page_collection - */ - struct list_head linkage; - /* - * number of bytes used within this page - */ - unsigned int used; - /* - * cpu that owns this page - */ - unsigned short cpu; - /* - * type(context) of this page - */ - unsigned short type; -}; + for (i = 0; cfs_trace_data[i] && \ + (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ + cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++) void cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *m, @@ -257,7 +208,7 @@ int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking); void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking); extern char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; -cfs_trace_buf_type_t cfs_trace_buf_idx_get(void); +enum cfs_trace_buf_type cfs_trace_buf_idx_get(void); static inline char * cfs_trace_get_console_buffer(void) @@ -279,8 +230,7 @@ cfs_trace_get_tcd(void) return tcd; } -static inline void -cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd) +static inline void cfs_trace_put_tcd(struct cfs_trace_cpu_data *tcd) { cfs_trace_unlock_tcd(tcd, 0); @@ -290,9 +240,6 @@ cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd) int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp, struct list_head *stock); -int cfs_tcd_owns_tage(struct cfs_trace_cpu_data *tcd, - struct cfs_trace_page *tage); - void cfs_trace_assertion_failed(const char *str, struct libcfs_debug_msg_data *m); @@ -308,8 +255,8 @@ do { \ #define __LASSERT_TAGE_INVARIANT(tage) \ do { \ - __LASSERT(tage != NULL); \ - __LASSERT(tage->page != NULL); \ + __LASSERT(tage); \ + __LASSERT(tage->page); \ __LASSERT(tage->used <= PAGE_CACHE_SIZE); \ __LASSERT(page_count(tage->page) > 0); \ } while (0) diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index 60bb88a..136bc13 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -46,18 +46,21 @@ #define CFS_WS_NAME_LEN 16 struct cfs_wi_sched { - struct list_head ws_list; /* chain on global list */ + /* chain on global list */ + struct list_head ws_list; /** serialised workitems */ spinlock_t ws_lock; /** where schedulers sleep */ wait_queue_head_t ws_waitq; /** concurrent workitems */ struct list_head ws_runq; - /** rescheduled running-workitems, a workitem can be rescheduled + /** + * rescheduled running-workitems, a workitem can be rescheduled * while running in wi_action(), but we don't to execute it again * unless it returns from wi_action(), so we put it on ws_rerunq * while rescheduling, and move it to runq after it returns - * from wi_action() */ + * from wi_action() + */ struct list_head ws_rerunq; /** CPT-table for this scheduler */ struct cfs_cpt_table *ws_cptab; @@ -128,8 +131,6 @@ cfs_wi_exit(struct cfs_wi_sched *sched, cfs_workitem_t *wi) wi->wi_scheduled = 1; /* LBUG future schedule attempts */ spin_unlock(&sched->ws_lock); - - return; } EXPORT_SYMBOL(cfs_wi_exit); @@ -163,7 +164,7 @@ cfs_wi_deschedule(struct cfs_wi_sched *sched, cfs_workitem_t *wi) wi->wi_scheduled = 0; } - LASSERT (list_empty(&wi->wi_list)); + LASSERT(list_empty(&wi->wi_list)); spin_unlock(&sched->ws_lock); return rc; @@ -186,7 +187,7 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, cfs_workitem_t *wi) spin_lock(&sched->ws_lock); if (!wi->wi_scheduled) { - LASSERT (list_empty(&wi->wi_list)); + LASSERT(list_empty(&wi->wi_list)); wi->wi_scheduled = 1; sched->ws_nscheduled++; @@ -198,21 +199,19 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, cfs_workitem_t *wi) } } - LASSERT (!list_empty(&wi->wi_list)); + LASSERT(!list_empty(&wi->wi_list)); spin_unlock(&sched->ws_lock); - return; } EXPORT_SYMBOL(cfs_wi_schedule); -static int -cfs_wi_scheduler (void *arg) +static int cfs_wi_scheduler(void *arg) { struct cfs_wi_sched *sched = (struct cfs_wi_sched *)arg; cfs_block_allsigs(); /* CPT affinity scheduler? */ - if (sched->ws_cptab != NULL) + if (sched->ws_cptab) if (cfs_cpt_bind(sched->ws_cptab, sched->ws_cpt) != 0) CWARN("Failed to bind %s on CPT %d\n", sched->ws_name, sched->ws_cpt); @@ -234,8 +233,8 @@ cfs_wi_scheduler (void *arg) while (!list_empty(&sched->ws_runq) && nloops < CFS_WI_RESCHED) { - wi = list_entry(sched->ws_runq.next, - cfs_workitem_t, wi_list); + wi = list_entry(sched->ws_runq.next, cfs_workitem_t, + wi_list); LASSERT(wi->wi_scheduled && !wi->wi_running); list_del_init(&wi->wi_list); @@ -261,14 +260,16 @@ cfs_wi_scheduler (void *arg) LASSERT(wi->wi_scheduled); /* wi is rescheduled, should be on rerunq now, we - * move it to runq so it can run action now */ + * move it to runq so it can run action now + */ list_move_tail(&wi->wi_list, &sched->ws_runq); } if (!list_empty(&sched->ws_runq)) { spin_unlock(&sched->ws_lock); /* don't sleep because some workitems still - * expect me to come back soon */ + * expect me to come back soon + */ cond_resched(); spin_lock(&sched->ws_lock); continue; @@ -343,11 +344,11 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, LASSERT(cfs_wi_data.wi_init); LASSERT(!cfs_wi_data.wi_stopping); - LASSERT(cptab == NULL || cpt == CFS_CPT_ANY || + LASSERT(!cptab || cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cfs_cpt_number(cptab))); LIBCFS_ALLOC(sched, sizeof(*sched)); - if (sched == NULL) + if (!sched) return -ENOMEM; strlcpy(sched->ws_name, name, CFS_WS_NAME_LEN); @@ -376,7 +377,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, sched->ws_starting++; spin_unlock(&cfs_wi_data.wi_glock); - if (sched->ws_cptab != NULL && sched->ws_cpt >= 0) { + if (sched->ws_cptab && sched->ws_cpt >= 0) { snprintf(name, sizeof(name), "%s_%02d_%02u", sched->ws_name, sched->ws_cpt, sched->ws_nthreads); @@ -455,7 +456,7 @@ cfs_wi_shutdown(void) } while (!list_empty(&cfs_wi_data.wi_scheds)) { sched = list_entry(cfs_wi_data.wi_scheds.next, - struct cfs_wi_sched, ws_list); + struct cfs_wi_sched, ws_list); list_del(&sched->ws_list); LIBCFS_FREE(sched, sizeof(*sched)); } diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index bc179e5..0bc0fb9f 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -60,7 +60,7 @@ static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; - LASSERT(de != NULL); + LASSERT(de); lld = ll_d2d(de); if (!lld) /* NFS copies the de->d_op methods (bug 4655) */ return; @@ -80,7 +80,8 @@ static void ll_release(struct dentry *de) * This avoids a race where ll_lookup_it() instantiates a dentry, but we get * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so - * lock_match() fails) and we spin around real_lookup(). */ + * lock_match() fails) and we spin around real_lookup(). + */ static int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) @@ -117,7 +118,8 @@ static inline int return_if_equal(struct ldlm_lock *lock, void *data) /* find any ldlm lock of the inode in mdc and lov * return 0 not find * 1 find one - * < 0 error */ + * < 0 error + */ static int find_cbdata(struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); @@ -163,10 +165,12 @@ static int ll_ddelete(const struct dentry *de) /* Disable this piece of code temporarily because this is called * inside dcache_lock so it's not appropriate to do lots of work * here. ATTENTION: Before this piece of code enabling, LU-2487 must be - * resolved. */ + * resolved. + */ #if 0 /* if not ldlm lock for this inode, set i_nlink to 0 so that - * this inode can be recycled later b=20433 */ + * this inode can be recycled later b=20433 + */ if (d_really_is_positive(de) && !find_cbdata(d_inode(de))) clear_nlink(d_inode(de)); #endif @@ -178,8 +182,6 @@ static int ll_ddelete(const struct dentry *de) int ll_d_init(struct dentry *de) { - LASSERT(de != NULL); - CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n", de, de, de->d_parent, d_inode(de), d_count(de)); @@ -218,7 +220,8 @@ void ll_intent_drop_lock(struct lookup_intent *it) ldlm_lock_decref(&handle, it->d.lustre.it_lock_mode); /* bug 494: intent_release may be called multiple times, from - * this thread and we don't want to double-decref this lock */ + * this thread and we don't want to double-decref this lock + */ it->d.lustre.it_lock_mode = 0; if (it->d.lustre.it_remote_lock_mode != 0) { handle.cookie = it->d.lustre.it_remote_lock_handle; @@ -251,8 +254,6 @@ void ll_invalidate_aliases(struct inode *inode) { struct dentry *dentry; - LASSERT(inode != NULL); - CDEBUG(D_INODE, "marking dentries for ino %lu/%u(%p) invalid\n", inode->i_ino, inode->i_generation, inode); @@ -286,9 +287,7 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode) { - LASSERT(it != NULL); - - if (it->d.lustre.it_lock_mode && inode != NULL) { + if (it->d.lustre.it_lock_mode && inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", @@ -300,7 +299,8 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode) if (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR) { /* on 2.6 there are situation when several lookups and * revalidations may be requested during single operation. - * therefore, we don't release intent here -bzzz */ + * therefore, we don't release intent here -bzzz + */ ll_intent_drop_lock(it); } } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 36b1055..bd88a3b 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -190,8 +190,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) } else if (rc == 0) { body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); /* Checked by mdc_readpage() */ - LASSERT(body != NULL); - if (body->valid & OBD_MD_FLSIZE) cl_isize_write(inode, body->size); @@ -245,7 +243,7 @@ void ll_release_page(struct page *page, int remove) kunmap(page); if (remove) { lock_page(page); - if (likely(page->mapping != NULL)) + if (likely(page->mapping)) truncate_complete_page(page->mapping, page); unlock_page(page); } @@ -334,7 +332,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, struct lustre_handle lockh; struct lu_dirpage *dp; struct page *page; - ldlm_mode_t mode; + enum ldlm_mode mode; int rc; __u64 start = 0; __u64 end = 0; @@ -381,7 +379,8 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, &it.d.lustre.it_lock_handle, dir, NULL); } else { /* for cross-ref object, l_ast_data of the lock may not be set, - * we reset it here */ + * we reset it here + */ md_set_lock_data(ll_i2sbi(dir)->ll_md_exp, &lockh.cookie, dir, NULL); } @@ -393,7 +392,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, CERROR("dir page locate: "DFID" at %llu: rc %ld\n", PFID(ll_inode2fid(dir)), lhash, PTR_ERR(page)); goto out_unlock; - } else if (page != NULL) { + } else if (page) { /* * XXX nikita: not entirely correct handling of a corner case: * suppose hash chain of entries with hash value HASH crosses @@ -499,7 +498,7 @@ int ll_dir_read(struct inode *inode, struct dir_context *ctx) __u64 next; dp = page_address(page); - for (ent = lu_dirent_start(dp); ent != NULL && !done; + for (ent = lu_dirent_start(dp); ent && !done; ent = lu_dirent_next(ent)) { __u16 type; int namelen; @@ -689,7 +688,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, struct obd_device *mgc = lsi->lsi_mgc; int lum_size; - if (lump != NULL) { + if (lump) { /* * This is coming from userspace, so should be in * local endian. But the MDS would like it in little @@ -725,7 +724,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, if (IS_ERR(op_data)) return PTR_ERR(op_data); - if (lump != NULL && lump->lmm_magic == cpu_to_le32(LMV_USER_MAGIC)) + if (lump && lump->lmm_magic == cpu_to_le32(LMV_USER_MAGIC)) op_data->op_cli_flags |= CLI_SET_MEA; /* swabbing is done in lov_setstripe() on server side */ @@ -739,8 +738,9 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, } /* In the following we use the fact that LOV_USER_MAGIC_V1 and - LOV_USER_MAGIC_V3 have the same initial fields so we do not - need to make the distinction between the 2 versions */ + * LOV_USER_MAGIC_V3 have the same initial fields so we do not + * need to make the distinction between the 2 versions + */ if (set_default && mgc->u.cli.cl_mgc_mgsexp) { char *param = NULL; char *buf; @@ -812,7 +812,6 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); lmmsize = body->eadatasize; @@ -824,7 +823,6 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, lmmsize); - LASSERT(lmm != NULL); /* * This is coming from the MDS, so is probably in @@ -933,7 +931,8 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) } /* Store it the hsm_copy for later copytool use. - * Always modified even if no lsm. */ + * Always modified even if no lsm. + */ copy->hc_data_version = data_version; } @@ -1010,11 +1009,13 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) } /* Store it the hsm_copy for later copytool use. - * Always modified even if no lsm. */ + * Always modified even if no lsm. + */ hpk.hpk_data_version = data_version; /* File could have been stripped during archiving, so we need - * to check anyway. */ + * to check anyway. + */ if ((copy->hc_hai.hai_action == HSMA_ARCHIVE) && (copy->hc_data_version != data_version)) { CDEBUG(D_HSM, "File data version mismatched. File content was changed during archiving. " @@ -1026,7 +1027,8 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) * the cdt will loop on retried archive requests. * The policy engine will ask for a new archive later * when the file will not be modified for some tunable - * time */ + * time + */ /* we do not notify caller */ hpk.hpk_flags &= ~HP_FLAG_RETRY; /* hpk_errval must be >= 0 */ @@ -1154,7 +1156,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) return rc; } /* If QIF_SPACE is not set, client should collect the - * space usage from OSSs by itself */ + * space usage from OSSs by itself + */ if (cmd == Q_GETQUOTA && !(oqctl->qc_dqblk.dqb_valid & QIF_SPACE) && !oqctl->qc_dqblk.dqb_curspace) { @@ -1205,7 +1208,8 @@ out: /* This function tries to get a single name component, * to send to the server. No actual path traversal involved, - * so we limit to NAME_MAX */ + * so we limit to NAME_MAX + */ static char *ll_getname(const char __user *filename) { int ret = 0, len; @@ -1326,7 +1330,7 @@ out_free: return rc; data = (void *)buf; - if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL || + if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) { rc = -EINVAL; goto lmv_out_free; @@ -1461,7 +1465,7 @@ free_lmv: if (request) { body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); + LASSERT(body); } else { goto out_req; } @@ -1539,7 +1543,7 @@ out_req: return rc; lmm = libcfs_kvzalloc(lmmsize, GFP_NOFS); - if (lmm == NULL) + if (!lmm) return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) { rc = -EFAULT; @@ -1688,7 +1692,6 @@ out_quotactl: if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); - LASSERT(fd != NULL); rc = rct_add(&sbi->ll_rct, current_pid(), arg); if (!rc) fd->fd_flags |= LL_FILE_RMTACL; @@ -1757,7 +1760,7 @@ out_quotactl: return -E2BIG; hur = libcfs_kvzalloc(totalsize, GFP_NOFS); - if (hur == NULL) + if (!hur) return -ENOMEM; /* Copy the whole struct */ @@ -1808,7 +1811,8 @@ out_quotactl: hpk.hpk_data_version = 0; /* File may not exist in Lustre; all progress - * reported to Lustre root */ + * reported to Lustre root + */ rc = obd_iocontrol(cmd, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); return rc; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 132d19b..4c25cf2 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -65,7 +65,7 @@ static struct ll_file_data *ll_file_data_get(void) struct ll_file_data *fd; fd = kmem_cache_alloc(ll_file_data_slab, GFP_NOFS | __GFP_ZERO); - if (fd == NULL) + if (!fd) return NULL; fd->fd_write_failed = false; return fd; @@ -73,7 +73,7 @@ static struct ll_file_data *ll_file_data_get(void) static void ll_file_data_put(struct ll_file_data *fd) { - if (fd != NULL) + if (fd) kmem_cache_free(ll_file_data_slab, fd); } @@ -134,7 +134,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, int epoch_close = 1; int rc; - if (obd == NULL) { + if (!obd) { /* * XXX: in case of LMV, is this correct to access * ->exp_handle? @@ -153,7 +153,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, } ll_prepare_close(inode, op_data, och); - if (data_version != NULL) { + if (data_version) { /* Pass in data_version implies release. */ op_data->op_bias |= MDS_HSM_RELEASE; op_data->op_data_version = *data_version; @@ -166,7 +166,8 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, /* This close must have the epoch closed. */ LASSERT(epoch_close); /* MDS has instructed us to obtain Size-on-MDS attribute from - * OSTs and send setattr to back to MDS. */ + * OSTs and send setattr to back to MDS. + */ rc = ll_som_update(inode, op_data); if (rc) { CERROR("inode %lu mdc Size-on-MDS update failed: rc = %d\n", @@ -179,7 +180,8 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, } /* DATA_MODIFIED flag was successfully sent on close, cancel data - * modification flag. */ + * modification flag. + */ if (rc == 0 && (op_data->op_bias & MDS_DATA_MODIFIED)) { struct ll_inode_info *lli = ll_i2info(inode); @@ -242,7 +244,8 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode) mutex_lock(&lli->lli_och_mutex); if (*och_usecount > 0) { /* There are still users of this handle, so skip - * freeing it. */ + * freeing it. + */ mutex_unlock(&lli->lli_och_mutex); return 0; } @@ -251,9 +254,10 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode) *och_p = NULL; mutex_unlock(&lli->lli_och_mutex); - if (och != NULL) { + if (och) { /* There might be a race and this handle may already - be closed. */ + * be closed. + */ rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, inode, och, NULL); } @@ -276,11 +280,12 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED)) ll_put_grouplock(inode, file, fd->fd_grouplock.cg_gid); - if (fd->fd_lease_och != NULL) { + if (fd->fd_lease_och) { bool lease_broken; /* Usually the lease is not released when the - * application crashed, we need to release here. */ + * application crashed, we need to release here. + */ rc = ll_lease_close(fd->fd_lease_och, inode, &lease_broken); CDEBUG(rc ? D_ERROR : D_INODE, "Clean up lease "DFID" %d/%d\n", PFID(&lli->lli_fid), rc, lease_broken); @@ -288,14 +293,15 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, fd->fd_lease_och = NULL; } - if (fd->fd_och != NULL) { + if (fd->fd_och) { rc = ll_close_inode_openhandle(md_exp, inode, fd->fd_och, NULL); fd->fd_och = NULL; goto out; } /* Let's see if we have good enough OPEN lock on the file and if - we can skip talking to MDS */ + * we can skip talking to MDS + */ mutex_lock(&lli->lli_och_mutex); if (fd->fd_omode & FMODE_WRITE) { @@ -343,7 +349,6 @@ int ll_file_release(struct inode *inode, struct file *file) if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); - LASSERT(fd != NULL); if (unlikely(fd->fd_flags & LL_FILE_RMTACL)) { fd->fd_flags &= ~LL_FILE_RMTACL; rct_del(&sbi->ll_rct, current_pid()); @@ -355,11 +360,12 @@ int ll_file_release(struct inode *inode, struct file *file) if (!is_root_inode(inode)) ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1); fd = LUSTRE_FPRIVATE(file); - LASSERT(fd != NULL); + LASSERT(fd); - /* The last ref on @file, maybe not the owner pid of statahead. + /* The last ref on @file, maybe not be the owner pid of statahead. * Different processes can open the same dir, "ll_opendir_key" means: - * it is me that should stop the statahead thread. */ + * it is me that should stop the statahead thread. + */ if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd && lli->lli_opendir_pid != 0) ll_stop_statahead(inode, lli->lli_opendir_key); @@ -396,16 +402,16 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm, __u32 opc = LUSTRE_OPC_ANY; int rc; - /* Usually we come here only for NFSD, and we want open lock. - But we can also get here with pre 2.6.15 patchless kernels, and in - that case that lock is also ok */ + /* Usually we come here only for NFSD, and we want open lock. */ /* We can also get here if there was cached open handle in revalidate_it * but it disappeared while we were getting from there to ll_file_open. * But this means this file was closed and immediately opened which - * makes a good candidate for using OPEN lock */ + * makes a good candidate for using OPEN lock + */ /* If lmmsize & lmm are not 0, we are just setting stripe info - * parameters. No need for the open lock */ - if (lmm == NULL && lmmsize == 0) { + * parameters. No need for the open lock + */ + if (!lmm && lmmsize == 0) { itp->it_flags |= MDS_OPEN_LOCK; if (itp->it_flags & FMODE_WRITE) opc = LUSTRE_OPC_CREATE; @@ -492,7 +498,7 @@ static int ll_local_open(struct file *file, struct lookup_intent *it, LASSERT(!LUSTRE_FPRIVATE(file)); - LASSERT(fd != NULL); + LASSERT(fd); if (och) { struct ptlrpc_request *req = it->d.lustre.it_data; @@ -543,7 +549,7 @@ int ll_file_open(struct inode *inode, struct file *file) file->private_data = NULL; /* prevent ll_local_open assertion */ fd = ll_file_data_get(); - if (fd == NULL) { + if (!fd) { rc = -ENOMEM; goto out_openerr; } @@ -551,7 +557,7 @@ int ll_file_open(struct inode *inode, struct file *file) fd->fd_file = file; if (S_ISDIR(inode->i_mode)) { spin_lock(&lli->lli_sa_lock); - if (lli->lli_opendir_key == NULL && lli->lli_sai == NULL && + if (!lli->lli_opendir_key && !lli->lli_sai && lli->lli_opendir_pid == 0) { lli->lli_opendir_key = fd; lli->lli_opendir_pid = current_pid(); @@ -568,7 +574,8 @@ int ll_file_open(struct inode *inode, struct file *file) if (!it || !it->d.lustre.it_disposition) { /* Convert f_flags into access mode. We cannot use file->f_mode, * because everything but O_ACCMODE mask was stripped from - * there */ + * there + */ if ((oit.it_flags + 1) & O_ACCMODE) oit.it_flags++; if (file->f_flags & O_TRUNC) @@ -577,17 +584,20 @@ int ll_file_open(struct inode *inode, struct file *file) /* kernel only call f_op->open in dentry_open. filp_open calls * dentry_open after call to open_namei that checks permissions. * Only nfsd_open call dentry_open directly without checking - * permissions and because of that this code below is safe. */ + * permissions and because of that this code below is safe. + */ if (oit.it_flags & (FMODE_WRITE | FMODE_READ)) oit.it_flags |= MDS_OPEN_OWNEROVERRIDE; /* We do not want O_EXCL here, presumably we opened the file - * already? XXX - NFS implications? */ + * already? XXX - NFS implications? + */ oit.it_flags &= ~O_EXCL; /* bug20584, if "it_flags" contains O_CREAT, the file will be * created if necessary, then "IT_CREAT" should be set to keep - * consistent with it */ + * consistent with it + */ if (oit.it_flags & O_CREAT) oit.it_op |= IT_CREAT; @@ -611,7 +621,8 @@ restart: if (*och_p) { /* Open handle is present */ if (it_disposition(it, DISP_OPEN_OPEN)) { /* Well, there's extra open request that we do not need, - let's close it somehow. This will decref request. */ + * let's close it somehow. This will decref request. + */ rc = it_open_error(DISP_OPEN_OPEN, it); if (rc) { mutex_unlock(&lli->lli_och_mutex); @@ -632,10 +643,11 @@ restart: LASSERT(*och_usecount == 0); if (!it->d.lustre.it_disposition) { /* We cannot just request lock handle now, new ELC code - means that one of other OPEN locks for this file - could be cancelled, and since blocking ast handler - would attempt to grab och_mutex as well, that would - result in a deadlock */ + * means that one of other OPEN locks for this file + * could be cancelled, and since blocking ast handler + * would attempt to grab och_mutex as well, that would + * result in a deadlock + */ mutex_unlock(&lli->lli_och_mutex); it->it_create_mode |= M_CHECK_STALE; rc = ll_intent_file_open(file->f_path.dentry, NULL, 0, it); @@ -655,9 +667,11 @@ restart: /* md_intent_lock() didn't get a request ref if there was an * open error, so don't do cleanup on the request here - * (bug 3430) */ + * (bug 3430) + */ /* XXX (green): Should not we bail out on any error here, not - * just open error? */ + * just open error? + */ rc = it_open_error(DISP_OPEN_OPEN, it); if (rc) goto out_och_free; @@ -672,8 +686,9 @@ restart: fd = NULL; /* Must do this outside lli_och_mutex lock to prevent deadlock where - different kind of OPEN lock for this same inode gets cancelled - by ldlm_cancel_lru */ + * different kind of OPEN lock for this same inode gets cancelled + * by ldlm_cancel_lru + */ if (!S_ISREG(inode->i_mode)) goto out_och_free; @@ -752,7 +767,7 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, if (fmode != FMODE_WRITE && fmode != FMODE_READ) return ERR_PTR(-EINVAL); - if (file != NULL) { + if (file) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct obd_client_handle **och_p; @@ -764,18 +779,18 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, /* Get the openhandle of the file */ rc = -EBUSY; mutex_lock(&lli->lli_och_mutex); - if (fd->fd_lease_och != NULL) { + if (fd->fd_lease_och) { mutex_unlock(&lli->lli_och_mutex); return ERR_PTR(rc); } - if (fd->fd_och == NULL) { + if (!fd->fd_och) { if (file->f_mode & FMODE_WRITE) { - LASSERT(lli->lli_mds_write_och != NULL); + LASSERT(lli->lli_mds_write_och); och_p = &lli->lli_mds_write_och; och_usecount = &lli->lli_open_fd_write_count; } else { - LASSERT(lli->lli_mds_read_och != NULL); + LASSERT(lli->lli_mds_read_och); och_p = &lli->lli_mds_read_och; och_usecount = &lli->lli_open_fd_read_count; } @@ -790,7 +805,7 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, if (rc < 0) /* more than 1 opener */ return ERR_PTR(rc); - LASSERT(fd->fd_och != NULL); + LASSERT(fd->fd_och); old_handle = fd->fd_och->och_fh; } @@ -817,7 +832,8 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, * broken; * LDLM_FL_EXCL: Set this flag so that it won't be matched by normal * open in ll_md_blocking_ast(). Otherwise as ll_md_blocking_lease_ast - * doesn't deal with openhandle, so normal openhandle will be leaked. */ + * doesn't deal with openhandle, so normal openhandle will be leaked. + */ LDLM_FL_NO_LRU | LDLM_FL_EXCL); ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); @@ -886,7 +902,7 @@ static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, int rc; lock = ldlm_handle2lock(&och->och_lease_handle); - if (lock != NULL) { + if (lock) { lock_res_and_lock(lock); cancelled = ldlm_is_cancel(lock); unlock_res_and_lock(lock); @@ -898,7 +914,7 @@ static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, if (!cancelled) ldlm_cli_cancel(&och->och_lease_handle, 0); - if (lease_broken != NULL) + if (lease_broken) *lease_broken = cancelled; rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, inode, och, @@ -914,7 +930,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, struct obd_info oinfo = { }; int rc; - LASSERT(lsm != NULL); + LASSERT(lsm); oinfo.oi_md = lsm; oinfo.oi_oa = obdo; @@ -933,7 +949,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, } set = ptlrpc_prep_set(); - if (set == NULL) { + if (!set) { CERROR("can't allocate ptlrpc set\n"); rc = -ENOMEM; } else { @@ -986,7 +1002,8 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) ll_inode_size_lock(inode); /* merge timestamps the most recently obtained from mds with - timestamps obtained from osts */ + * timestamps obtained from osts + */ LTIME_S(inode->i_atime) = lli->lli_lvb.lvb_atime; LTIME_S(inode->i_mtime) = lli->lli_lvb.lvb_mtime; LTIME_S(inode->i_ctime) = lli->lli_lvb.lvb_ctime; @@ -1155,7 +1172,8 @@ restart: out: cl_io_fini(env, io); /* If any bit been read/written (result != 0), we just return - * short read/write instead of restart io. */ + * short read/write instead of restart io. + */ if ((result == 0 || result == -ENODATA) && io->ci_need_restart) { CDEBUG(D_VFSTRACE, "Restart %s on %pD from %lld, count:%zd\n", iot == CIT_READ ? "read" : "write", @@ -1261,7 +1279,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) struct lov_stripe_md *lsm = NULL, *lsm2; oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (oa == NULL) + if (!oa) return -ENOMEM; lsm = ccc_inode_lsm_get(inode); @@ -1274,7 +1292,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) (lsm->lsm_stripe_count)); lsm2 = libcfs_kvzalloc(lsm_size, GFP_NOFS); - if (lsm2 == NULL) { + if (!lsm2) { rc = -ENOMEM; goto out; } @@ -1341,7 +1359,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry, int rc = 0; lsm = ccc_inode_lsm_get(inode); - if (lsm != NULL) { + if (lsm) { ccc_inode_lsm_put(inode, lsm); CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", inode->i_ino); @@ -1401,7 +1419,6 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); /* checked by mdc_getattr_name */ lmmsize = body->eadatasize; @@ -1412,7 +1429,6 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, } lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, lmmsize); - LASSERT(lmm != NULL); if ((lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_V1)) && (lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_V3))) { @@ -1433,7 +1449,8 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, stripe_count = 0; /* if function called for directory - we should - * avoid swab not existent lsm objects */ + * avoid swab not existent lsm objects + */ if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) { lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm); if (S_ISREG(body->mode)) @@ -1469,7 +1486,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, return -EPERM; lump = libcfs_kvzalloc(lum_size, GFP_NOFS); - if (lump == NULL) + if (!lump) return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md __user *)arg, lum_size)) { @@ -1530,7 +1547,7 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg) int rc = -ENODATA; lsm = ccc_inode_lsm_get(inode); - if (lsm != NULL) + if (lsm) rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, lsm, (void __user *)arg); ccc_inode_lsm_put(inode, lsm); @@ -1560,7 +1577,7 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) spin_unlock(&lli->lli_lock); return -EINVAL; } - LASSERT(fd->fd_grouplock.cg_lock == NULL); + LASSERT(!fd->fd_grouplock.cg_lock); spin_unlock(&lli->lli_lock); rc = cl_get_grouplock(cl_i2info(inode)->lli_clob, @@ -1597,7 +1614,7 @@ static int ll_put_grouplock(struct inode *inode, struct file *file, CWARN("no group lock held\n"); return -EINVAL; } - LASSERT(fd->fd_grouplock.cg_lock != NULL); + LASSERT(fd->fd_grouplock.cg_lock); if (fd->fd_grouplock.cg_gid != arg) { CWARN("group lock %lu doesn't match current id %lu\n", @@ -1688,7 +1705,7 @@ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, } lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) + if (!lsm) return -ENOENT; /* If the stripe_count > 1 and the application does not understand @@ -1782,7 +1799,8 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) int rc = 0; /* Get the extent count so we can calculate the size of - * required fiemap buffer */ + * required fiemap buffer + */ if (get_user(extent_count, &((struct ll_user_fiemap __user *)arg)->fm_extent_count)) return -EFAULT; @@ -1794,7 +1812,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) sizeof(struct ll_fiemap_extent)); fiemap_s = libcfs_kvzalloc(num_bytes, GFP_NOFS); - if (fiemap_s == NULL) + if (!fiemap_s) return -ENOMEM; /* get the fiemap value */ @@ -1806,7 +1824,8 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) /* If fm_extent_count is non-zero, read the first extent since * it is used to calculate end_offset and device from previous - * fiemap call. */ + * fiemap call. + */ if (extent_count) { if (copy_from_user(&fiemap_s->fm_extents[0], (char __user *)arg + sizeof(*fiemap_s), @@ -1917,13 +1936,14 @@ int ll_hsm_release(struct inode *inode) /* Release the file. * NB: lease lock handle is released in mdc_hsm_release_pack() because - * we still need it to pack l_remote_handle to MDT. */ + * we still need it to pack l_remote_handle to MDT. + */ rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, inode, och, &data_version); och = NULL; out: - if (och != NULL && !IS_ERR(och)) /* close the file */ + if (och && !IS_ERR(och)) /* close the file */ ll_lease_close(och, inode, NULL); return rc; @@ -2007,7 +2027,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, } /* to be able to restore mtime and atime after swap - * we need to first save them */ + * we need to first save them + */ if (lsl->sl_flags & (SWAP_LAYOUTS_KEEP_MTIME | SWAP_LAYOUTS_KEEP_ATIME)) { llss->ia1.ia_mtime = llss->inode1->i_mtime; @@ -2019,7 +2040,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, } /* ultimate check, before swapping the layouts we check if - * dataversion has changed (if requested) */ + * dataversion has changed (if requested) + */ if (llss->check_dv1) { rc = ll_data_version(llss->inode1, &dv, 0); if (rc) @@ -2042,9 +2064,11 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, /* struct md_op_data is used to send the swap args to the mdt * only flags is missing, so we use struct mdc_swap_layouts - * through the md_op_data->op_data */ + * through the md_op_data->op_data + */ /* flags from user space have to be converted before they are send to - * server, no flag is sent today, they are only used on the client */ + * server, no flag is sent today, they are only used on the client + */ msl.msl_flags = 0; rc = -ENOMEM; op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0, @@ -2113,7 +2137,8 @@ static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss) return -EINVAL; /* Non-root users are forbidden to set or clear flags which are - * NOT defined in HSM_USER_MASK. */ + * NOT defined in HSM_USER_MASK. + */ if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && !capable(CFS_CAP_SYS_ADMIN)) return -EPERM; @@ -2250,7 +2275,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -EPERM; file2 = fget(lsl.sl_fd); - if (file2 == NULL) + if (!file2) return -EBADF; rc = -EPERM; @@ -2413,13 +2438,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; case F_UNLCK: mutex_lock(&lli->lli_och_mutex); - if (fd->fd_lease_och != NULL) { + if (fd->fd_lease_och) { och = fd->fd_lease_och; fd->fd_lease_och = NULL; } mutex_unlock(&lli->lli_och_mutex); - if (och != NULL) { + if (och) { mode = och->och_flags & (FMODE_READ|FMODE_WRITE); rc = ll_lease_close(och, inode, &lease_broken); @@ -2444,12 +2469,12 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = 0; mutex_lock(&lli->lli_och_mutex); - if (fd->fd_lease_och == NULL) { + if (!fd->fd_lease_och) { fd->fd_lease_och = och; och = NULL; } mutex_unlock(&lli->lli_och_mutex); - if (och != NULL) { + if (och) { /* impossible now that only excl is supported for now */ ll_lease_close(och, inode, &lease_broken); rc = -EBUSY; @@ -2462,11 +2487,11 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = 0; mutex_lock(&lli->lli_och_mutex); - if (fd->fd_lease_och != NULL) { + if (fd->fd_lease_och) { struct obd_client_handle *och = fd->fd_lease_och; lock = ldlm_handle2lock(&och->och_lease_handle); - if (lock != NULL) { + if (lock) { lock_res_and_lock(lock); if (!ldlm_is_cancel(lock)) rc = och->och_flags & @@ -2537,15 +2562,17 @@ static int ll_flush(struct file *file, fl_owner_t id) LASSERT(!S_ISDIR(inode->i_mode)); /* catch async errors that were recorded back when async writeback - * failed for pages in this mapping. */ + * failed for pages in this mapping. + */ rc = lli->lli_async_rc; lli->lli_async_rc = 0; err = lov_read_and_clear_async_rc(lli->lli_clob); if (rc == 0) rc = err; - /* The application has been told write failure already. - * Do not report failure again. */ + /* The application has been told about write failure already. + * Do not report failure again. + */ if (fd->fd_write_failed) return 0; return rc ? -EIO : 0; @@ -2613,7 +2640,8 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) inode_lock(inode); /* catch async errors that were recorded back when async writeback - * failed for pages in this mapping. */ + * failed for pages in this mapping. + */ if (!S_ISDIR(inode->i_mode)) { err = lli->lli_async_rc; lli->lli_async_rc = 0; @@ -2684,7 +2712,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) * I guess between lockd processes) and then compares pid. * As such we assign pid to the owner field to make it all work, * conflict with normal locks is unlikely since pid space and - * pointer space for current->files are not intersecting */ + * pointer space for current->files are not intersecting + */ if (file_lock->fl_lmops && file_lock->fl_lmops->lm_compare_owner) flock.l_flock.owner = (unsigned long)file_lock->fl_pid; @@ -2700,7 +2729,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) * order to process an unlock request we need all of the same * information that is given with a normal read or write record * lock request. To avoid creating another ldlm unlock (cancel) - * message we'll treat a LCK_NL flock request as an unlock. */ + * message we'll treat a LCK_NL flock request as an unlock. + */ einfo.ei_mode = LCK_NL; break; case F_WRLCK: @@ -2731,7 +2761,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) #endif flags = LDLM_FL_TEST_LOCK; /* Save the old mode so that if the mode in the lock changes we - * can decrement the appropriate reader or writer refcount. */ + * can decrement the appropriate reader or writer refcount. + */ file_lock->fl_type = einfo.ei_mode; break; default: @@ -2783,11 +2814,12 @@ ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) * \param l_req_mode [IN] searched lock mode * \retval boolean, true iff all bits are found */ -int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) +int ll_have_md_lock(struct inode *inode, __u64 *bits, + enum ldlm_mode l_req_mode) { struct lustre_handle lockh; ldlm_policy_data_t policy; - ldlm_mode_t mode = (l_req_mode == LCK_MINMODE) ? + enum ldlm_mode mode = (l_req_mode == LCK_MINMODE) ? (LCK_CR|LCK_CW|LCK_PR|LCK_PW) : l_req_mode; struct lu_fid *fid; __u64 flags; @@ -2823,13 +2855,13 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) return *bits == 0; } -ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, - struct lustre_handle *lockh, __u64 flags, - ldlm_mode_t mode) +enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, + struct lustre_handle *lockh, __u64 flags, + enum ldlm_mode mode) { ldlm_policy_data_t policy = { .l_inodebits = {bits} }; struct lu_fid *fid; - ldlm_mode_t rc; + enum ldlm_mode rc; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); @@ -2867,8 +2899,6 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) struct obd_export *exp; int rc = 0; - LASSERT(inode != NULL); - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%pd\n", inode->i_ino, inode->i_generation, inode, dentry); @@ -2876,7 +2906,8 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) /* XXX: Enable OBD_CONNECT_ATTRFID to reduce unnecessary getattr RPC. * But under CMD case, it caused some lock issues, should be fixed - * with new CMD ibits lock. See bug 12718 */ + * with new CMD ibits lock. See bug 12718 + */ if (exp_connect_flags(exp) & OBD_CONNECT_ATTRFID) { struct lookup_intent oit = { .it_op = IT_GETATTR }; struct md_op_data *op_data; @@ -2894,7 +2925,8 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) oit.it_create_mode |= M_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, /* we are not interested in name - based lookup */ + * based lookup + */ &oit, 0, &req, ll_md_blocking_ast, 0); ll_finish_md_op_data(op_data); @@ -2911,9 +2943,10 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) } /* Unlinked? Unhash dentry, so it is not picked up later by - do_lookup() -> ll_revalidate_it(). We cannot use d_drop - here to preserve get_cwd functionality on 2.6. - Bug 10503 */ + * do_lookup() -> ll_revalidate_it(). We cannot use d_drop + * here to preserve get_cwd functionality on 2.6. + * Bug 10503 + */ if (!d_inode(dentry)->i_nlink) d_lustre_invalidate(dentry, 0); @@ -3027,7 +3060,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, sizeof(struct ll_fiemap_extent)); fiemap = libcfs_kvzalloc(num_bytes, GFP_NOFS); - if (fiemap == NULL) + if (!fiemap) return -ENOMEM; fiemap->fm_flags = fieinfo->fi_flags; @@ -3075,13 +3108,12 @@ int ll_inode_permission(struct inode *inode, int mask) { int rc = 0; -#ifdef MAY_NOT_BLOCK if (mask & MAY_NOT_BLOCK) return -ECHILD; -#endif /* as root inode are NOT getting validated in lookup operation, - * need to do it before permission check. */ + * need to do it before permission check. + */ if (is_root_inode(inode)) { rc = __ll_inode_revalidate(inode->i_sb->s_root, @@ -3181,8 +3213,7 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) unsigned int size; struct llioc_data *in_data = NULL; - if (cb == NULL || cmd == NULL || - count > LLIOC_MAX_CMD || count < 0) + if (!cb || !cmd || count > LLIOC_MAX_CMD || count < 0) return NULL; size = sizeof(*in_data) + count * sizeof(unsigned int); @@ -3208,7 +3239,7 @@ void ll_iocontrol_unregister(void *magic) { struct llioc_data *tmp; - if (magic == NULL) + if (!magic) return; down_write(&llioc.ioc_sem); @@ -3262,7 +3293,7 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) struct lu_env *env; int result; - if (lli->lli_clob == NULL) + if (!lli->lli_clob) return 0; env = cl_env_nested_get(&nest); @@ -3275,13 +3306,14 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) if (conf->coc_opc == OBJECT_CONF_SET) { struct ldlm_lock *lock = conf->coc_lock; - LASSERT(lock != NULL); + LASSERT(lock); LASSERT(ldlm_has_layout(lock)); if (result == 0) { /* it can only be allowed to match after layout is * applied to inode otherwise false layout would be * seen. Applying layout should happen before dropping - * the intent lock. */ + * the intent lock. + */ ldlm_lock_allow_match(lock); } } @@ -3304,14 +3336,15 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY), lock->l_lvb_data, lock->l_lvb_len); - if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY)) + if (lock->l_lvb_data && (lock->l_flags & LDLM_FL_LVB_READY)) return 0; /* if layout lock was granted right away, the layout is returned * within DLM_LVB of dlm reply; otherwise if the lock was ever * blocked and then granted via completion ast, we have to fetch * layout here. Please note that we can't use the LVB buffer in - * completion AST because it doesn't have a large enough buffer */ + * completion AST because it doesn't have a large enough buffer + */ rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc == 0) rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), @@ -3321,7 +3354,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out; } @@ -3333,20 +3366,20 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) } lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, lmmsize); - if (lmm == NULL) { + if (!lmm) { rc = -EFAULT; goto out; } lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS); - if (lvbdata == NULL) { + if (!lvbdata) { rc = -ENOMEM; goto out; } memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); - if (lock->l_lvb_data != NULL) + if (lock->l_lvb_data) kvfree(lock->l_lvb_data); lock->l_lvb_data = lvbdata; @@ -3362,8 +3395,8 @@ out: * Apply the layout to the inode. Layout lock is held and will be released * in this function. */ -static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, - struct inode *inode, __u32 *gen, bool reconf) +static int ll_layout_lock_set(struct lustre_handle *lockh, enum ldlm_mode mode, + struct inode *inode, __u32 *gen, bool reconf) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); @@ -3377,7 +3410,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, LASSERT(lustre_handle_is_used(lockh)); lock = ldlm_handle2lock(lockh); - LASSERT(lock != NULL); + LASSERT(lock); LASSERT(ldlm_has_layout(lock)); LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n", @@ -3390,12 +3423,14 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, lvb_ready = !!(lock->l_flags & LDLM_FL_LVB_READY); unlock_res_and_lock(lock); /* checking lvb_ready is racy but this is okay. The worst case is - * that multi processes may configure the file on the same time. */ + * that multi processes may configure the file on the same time. + */ if (lvb_ready || !reconf) { rc = -ENODATA; if (lvb_ready) { /* layout_gen must be valid if layout lock is not - * cancelled and stripe has already set */ + * cancelled and stripe has already set + */ *gen = ll_layout_version_get(lli); rc = 0; } @@ -3409,13 +3444,14 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, /* for layout lock, lmm is returned in lock's lvb. * lvb_data is immutable if the lock is held so it's safe to access it * without res lock. See the description in ldlm_lock_decref_internal() - * for the condition to free lvb_data of layout lock */ - if (lock->l_lvb_data != NULL) { + * for the condition to free lvb_data of layout lock + */ + if (lock->l_lvb_data) { rc = obd_unpackmd(sbi->ll_dt_exp, &md.lsm, lock->l_lvb_data, lock->l_lvb_len); if (rc >= 0) { *gen = LL_LAYOUT_GEN_EMPTY; - if (md.lsm != NULL) + if (md.lsm) *gen = md.lsm->lsm_layout_gen; rc = 0; } else { @@ -3428,7 +3464,8 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, goto out; /* set layout to file. Unlikely this will fail as old layout was - * surely eliminated */ + * surely eliminated + */ memset(&conf, 0, sizeof(conf)); conf.coc_opc = OBJECT_CONF_SET; conf.coc_inode = inode; @@ -3436,7 +3473,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, conf.u.coc_md = &md; rc = ll_layout_conf(inode, &conf); - if (md.lsm != NULL) + if (md.lsm) obd_free_memmd(sbi->ll_dt_exp, &md.lsm); /* refresh layout failed, need to wait */ @@ -3485,7 +3522,7 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) struct md_op_data *op_data; struct lookup_intent it; struct lustre_handle lockh; - ldlm_mode_t mode; + enum ldlm_mode mode; struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS, .ei_mode = LCK_CR, @@ -3507,7 +3544,8 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) again: /* mostly layout lock is caching on the local side, so try to match - * it before grabbing layout lock mutex. */ + * it before grabbing layout lock mutex. + */ mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0, LCK_CR | LCK_CW | LCK_PR | LCK_PW); if (mode != 0) { /* hit cached lock */ @@ -3537,8 +3575,7 @@ again: rc = md_enqueue(sbi->ll_md_exp, &einfo, &it, op_data, &lockh, NULL, 0, NULL, 0); - if (it.d.lustre.it_data != NULL) - ptlrpc_req_finished(it.d.lustre.it_data); + ptlrpc_req_finished(it.d.lustre.it_data); it.d.lustre.it_data = NULL; ll_finish_md_op_data(op_data); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 3f348a3..fcb6657 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -52,7 +52,7 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page) spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_SOM_DIRTY; - if (page != NULL && list_empty(&page->cpg_pending_linkage)) + if (page && list_empty(&page->cpg_pending_linkage)) list_add(&page->cpg_pending_linkage, &club->cob_pending_list); spin_unlock(&lli->lli_lock); @@ -65,7 +65,7 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) int rc = 0; spin_lock(&lli->lli_lock); - if (page != NULL && !list_empty(&page->cpg_pending_linkage)) { + if (page && !list_empty(&page->cpg_pending_linkage)) { list_del_init(&page->cpg_pending_linkage); rc = 1; } @@ -76,7 +76,8 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) /** Queues DONE_WRITING if * - done writing is allowed; - * - inode has no no dirty pages; */ + * - inode has no no dirty pages; + */ void ll_queue_done_writing(struct inode *inode, unsigned long flags) { struct ll_inode_info *lli = ll_i2info(inode); @@ -106,7 +107,8 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) * close() happen, epoch is closed as the inode is marked as * LLIF_EPOCH_PENDING. When pages are written inode should not * be inserted into the queue again, clear this flag to avoid - * it. */ + * it. + */ lli->lli_flags &= ~LLIF_DONE_WRITING; wake_up(&lcq->lcq_waitq); @@ -144,10 +146,11 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, spin_lock(&lli->lli_lock); if (!(list_empty(&club->cob_pending_list))) { if (!(lli->lli_flags & LLIF_EPOCH_PENDING)) { - LASSERT(*och != NULL); - LASSERT(lli->lli_pending_och == NULL); + LASSERT(*och); + LASSERT(!lli->lli_pending_och); /* Inode is dirty and there is no pending write done - * request yet, DONE_WRITE is to be sent later. */ + * request yet, DONE_WRITE is to be sent later. + */ lli->lli_flags |= LLIF_EPOCH_PENDING; lli->lli_pending_och = *och; spin_unlock(&lli->lli_lock); @@ -159,7 +162,8 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, if (flags & LLIF_DONE_WRITING) { /* Some pages are still dirty, it is early to send * DONE_WRITE. Wait until all pages will be flushed - * and try DONE_WRITE again later. */ + * and try DONE_WRITE again later. + */ LASSERT(!(lli->lli_flags & LLIF_DONE_WRITING)); lli->lli_flags |= LLIF_DONE_WRITING; spin_unlock(&lli->lli_lock); @@ -187,7 +191,8 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, } /* There is a pending DONE_WRITE -- close epoch with no - * attribute change. */ + * attribute change. + */ if (lli->lli_flags & LLIF_EPOCH_PENDING) { spin_unlock(&lli->lli_lock); goto out; @@ -215,7 +220,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) struct obdo *oa; int rc; - LASSERT(op_data != NULL); + LASSERT(op_data); if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) CERROR("ino %lu/%u(flags %u) som valid it just after recovery\n", inode->i_ino, inode->i_generation, @@ -266,7 +271,7 @@ static void ll_prepare_done_writing(struct inode *inode, { ll_ioepoch_close(inode, op_data, och, LLIF_DONE_WRITING); /* If there is no @och, we do not do D_W yet. */ - if (*och == NULL) + if (!*och) return; ll_pack_inode2opdata(inode, op_data, &(*och)->och_fh); @@ -289,13 +294,14 @@ static void ll_done_writing(struct inode *inode) ll_prepare_done_writing(inode, op_data, &och); /* If there is no @och, we do not do D_W yet. */ - if (och == NULL) + if (!och) goto out; rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL); if (rc == -EAGAIN) /* MDS has instructed us to obtain Size-on-MDS attribute from - * OSTs and send setattr to back to MDS. */ + * OSTs and send setattr to back to MDS. + */ rc = ll_som_update(inode, op_data); else if (rc) CERROR("inode %lu mdc done_writing failed: rc = %d\n", diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 29c325d..f6921ff 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -93,9 +93,10 @@ struct ll_remote_perm { gid_t lrp_gid; uid_t lrp_fsuid; gid_t lrp_fsgid; - int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this - is access permission with - lrp_fsuid/lrp_fsgid. */ + int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this + * is access permission with + * lrp_fsuid/lrp_fsgid. + */ }; enum lli_flags { @@ -106,7 +107,8 @@ enum lli_flags { /* DONE WRITING is allowed. */ LLIF_DONE_WRITING = (1 << 2), /* Sizeon-on-MDS attributes are changed. An attribute update needs to - * be sent to MDS. */ + * be sent to MDS. + */ LLIF_SOM_DIRTY = (1 << 3), /* File data is modified. */ LLIF_DATA_MODIFIED = (1 << 4), @@ -130,22 +132,23 @@ struct ll_inode_info { /* identifying fields for both metadata and data stacks. */ struct lu_fid lli_fid; /* Parent fid for accessing default stripe data on parent directory - * for allocating OST objects after a mknod() and later open-by-FID. */ + * for allocating OST objects after a mknod() and later open-by-FID. + */ struct lu_fid lli_pfid; - struct list_head lli_close_list; - /* open count currently used by capability only, indicate whether - * capability needs renewal */ - atomic_t lli_open_count; + struct list_head lli_close_list; + unsigned long lli_rmtperm_time; /* handle is to be sent to MDS later on done_writing and setattr. * Open handle data are needed for the recovery to reconstruct - * the inode state on the MDS. XXX: recovery is not ready yet. */ + * the inode state on the MDS. XXX: recovery is not ready yet. + */ struct obd_client_handle *lli_pending_och; /* We need all three because every inode may be opened in different - * modes */ + * modes + */ struct obd_client_handle *lli_mds_read_och; struct obd_client_handle *lli_mds_write_och; struct obd_client_handle *lli_mds_exec_och; @@ -162,7 +165,8 @@ struct ll_inode_info { spinlock_t lli_agl_lock; /* Try to make the d::member and f::member are aligned. Before using - * these members, make clear whether it is directory or not. */ + * these members, make clear whether it is directory or not. + */ union { /* for directory */ struct { @@ -173,13 +177,15 @@ struct ll_inode_info { /* since parent-child threads can share the same @file * struct, "opendir_key" is the token when dir close for * case of parent exit before child -- it is me should - * cleanup the dir readahead. */ + * cleanup the dir readahead. + */ void *d_opendir_key; struct ll_statahead_info *d_sai; /* protect statahead stuff. */ spinlock_t d_sa_lock; - /* "opendir_pid" is the token when lookup/revalid - * -- I am the owner of dir statahead. */ + /* "opendir_pid" is the token when lookup/revalidate + * -- I am the owner of dir statahead. + */ pid_t d_opendir_pid; } d; @@ -305,7 +311,8 @@ static inline struct ll_inode_info *ll_i2info(struct inode *inode) } /* default to about 40meg of readahead on a given system. That much tied - * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */ + * up in 512k readahead requests serviced at 40ms each is about 1GB/s. + */ #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_CACHE_SHIFT)) /* default to read-ahead full files smaller than 2MB on the second read */ @@ -344,11 +351,13 @@ struct ra_io_arg { unsigned long ria_end; /* end offset of read-ahead*/ /* If stride read pattern is detected, ria_stoff means where * stride read is started. Note: for normal read-ahead, the - * value here is meaningless, and also it will not be accessed*/ + * value here is meaningless, and also it will not be accessed + */ pgoff_t ria_stoff; /* ria_length and ria_pages are the length and pages length in the * stride I/O mode. And they will also be used to check whether - * it is stride I/O read-ahead in the read-ahead pages*/ + * it is stride I/O read-ahead in the read-ahead pages + */ unsigned long ria_length; unsigned long ria_pages; }; @@ -455,7 +464,8 @@ struct eacl_table { struct ll_sb_info { /* this protects pglist and ra_info. It isn't safe to - * grab from interrupt contexts */ + * grab from interrupt contexts + */ spinlock_t ll_lock; spinlock_t ll_pp_extent_lock; /* pp_extent entry*/ spinlock_t ll_process_lock; /* ll_rw_process_info */ @@ -468,10 +478,8 @@ struct ll_sb_info { int ll_flags; unsigned int ll_umounting:1, ll_xattr_cache_enabled:1; - struct list_head ll_conn_chain; /* per-conn chain of SBs */ struct lustre_client_ocd ll_lco; - struct list_head ll_orphan_dentry_list; /*please don't ask -p*/ struct ll_close_queue *ll_lcq; struct lprocfs_stats *ll_stats; /* lprocfs stats counter */ @@ -502,13 +510,16 @@ struct ll_sb_info { /* metadata stat-ahead */ unsigned int ll_sa_max; /* max statahead RPCs */ atomic_t ll_sa_total; /* statahead thread started - * count */ + * count + */ atomic_t ll_sa_wrong; /* statahead thread stopped for - * low hit ratio */ + * low hit ratio + */ atomic_t ll_agl_total; /* AGL thread started count */ - dev_t ll_sdev_orig; /* save s_dev before assign for - * clustered nfs */ + dev_t ll_sdev_orig; /* save s_dev before assign for + * clustered nfs + */ struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; __kernel_fsid_t ll_fsid; @@ -619,13 +630,15 @@ struct ll_file_data { __u32 fd_flags; fmode_t fd_omode; /* openhandle if lease exists for this file. - * Borrow lli->lli_och_mutex to protect assignment */ + * Borrow lli->lli_och_mutex to protect assignment + */ struct obd_client_handle *fd_lease_och; struct obd_client_handle *fd_och; struct file *fd_file; /* Indicate whether need to report failure when close. * true: failure is known, not report again. - * false: unknown failure, should report. */ + * false: unknown failure, should report. + */ bool fd_write_failed; }; @@ -705,10 +718,10 @@ extern struct file_operations ll_file_operations_flock; extern struct file_operations ll_file_operations_noflock; extern const struct inode_operations ll_file_inode_operations; int ll_have_md_lock(struct inode *inode, __u64 *bits, - ldlm_mode_t l_req_mode); -ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, - struct lustre_handle *lockh, __u64 flags, - ldlm_mode_t mode); + enum ldlm_mode l_req_mode); +enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, + struct lustre_handle *lockh, __u64 flags, + enum ldlm_mode mode); int ll_file_open(struct inode *inode, struct file *file); int ll_file_release(struct inode *inode, struct file *file); int ll_glimpse_ioctl(struct ll_sb_info *sbi, @@ -913,7 +926,7 @@ static inline struct vvp_thread_info *vvp_env_info(const struct lu_env *env) struct vvp_thread_info *info; info = lu_context_key_get(&env->le_ctx, &vvp_key); - LASSERT(info != NULL); + LASSERT(info); return info; } @@ -937,7 +950,7 @@ static inline struct vvp_session *vvp_env_session(const struct lu_env *env) struct vvp_session *ses; ses = lu_context_key_get(env->le_ses, &vvp_session_key); - LASSERT(ses != NULL); + LASSERT(ses); return ses; } @@ -968,7 +981,7 @@ static inline void ll_invalidate_page(struct page *vmpage) loff_t offset = vmpage->index << PAGE_CACHE_SHIFT; LASSERT(PageLocked(vmpage)); - if (mapping == NULL) + if (!mapping) return; ll_teardown_mmaps(mapping, offset, offset + PAGE_CACHE_SIZE); @@ -993,7 +1006,7 @@ static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi) { struct obd_device *obd = sbi->ll_md_exp->exp_obd; - if (obd == NULL) + if (!obd) LBUG(); return &obd->u.cli; } @@ -1018,7 +1031,7 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode) { struct lu_fid *fid; - LASSERT(inode != NULL); + LASSERT(inode); fid = &ll_i2info(inode)->lli_fid; return fid; @@ -1107,39 +1120,44 @@ static inline u64 rce_ops2valid(int ops) struct ll_statahead_info { struct inode *sai_inode; atomic_t sai_refcount; /* when access this struct, hold - * refcount */ + * refcount + */ unsigned int sai_generation; /* generation for statahead */ unsigned int sai_max; /* max ahead of lookup */ __u64 sai_sent; /* stat requests sent count */ __u64 sai_replied; /* stat requests which received - * reply */ + * reply + */ __u64 sai_index; /* index of statahead entry */ __u64 sai_index_wait; /* index of entry which is the - * caller is waiting for */ + * caller is waiting for + */ __u64 sai_hit; /* hit count */ __u64 sai_miss; /* miss count: - * for "ls -al" case, it includes - * hidden dentry miss; - * for "ls -l" case, it does not - * include hidden dentry miss. - * "sai_miss_hidden" is used for - * the later case. - */ + * for "ls -al" case, it includes + * hidden dentry miss; + * for "ls -l" case, it does not + * include hidden dentry miss. + * "sai_miss_hidden" is used for + * the later case. + */ unsigned int sai_consecutive_miss; /* consecutive miss */ unsigned int sai_miss_hidden;/* "ls -al", but first dentry - * is not a hidden one */ + * is not a hidden one + */ unsigned int sai_skip_hidden;/* skipped hidden dentry count */ unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for - * hidden entries */ + * hidden entries + */ sai_agl_valid:1;/* AGL is valid for the dir */ - wait_queue_head_t sai_waitq; /* stat-ahead wait queue */ + wait_queue_head_t sai_waitq; /* stat-ahead wait queue */ struct ptlrpc_thread sai_thread; /* stat-ahead thread */ struct ptlrpc_thread sai_agl_thread; /* AGL thread */ - struct list_head sai_entries; /* entry list */ - struct list_head sai_entries_received; /* entries returned */ - struct list_head sai_entries_stated; /* entries stated */ - struct list_head sai_entries_agl; /* AGL entries to be sent */ - struct list_head sai_cache[LL_SA_CACHE_SIZE]; + struct list_head sai_entries; /* entry list */ + struct list_head sai_entries_received; /* entries returned */ + struct list_head sai_entries_stated; /* entries stated */ + struct list_head sai_entries_agl; /* AGL entries to be sent */ + struct list_head sai_cache[LL_SA_CACHE_SIZE]; spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE]; atomic_t sai_cache_count; /* entry count in cache */ }; @@ -1171,8 +1189,8 @@ ll_statahead_mark(struct inode *dir, struct dentry *dentry) if (lli->lli_opendir_pid != current_pid()) return; - LASSERT(ldd != NULL); - if (sai != NULL) + LASSERT(ldd); + if (sai) ldd->lld_sa_generation = sai->sai_generation; } @@ -1191,7 +1209,7 @@ d_need_statahead(struct inode *dir, struct dentry *dentryp) return -EAGAIN; /* statahead has been stopped */ - if (lli->lli_opendir_key == NULL) + if (!lli->lli_opendir_key) return -EAGAIN; ldd = ll_d2d(dentryp); @@ -1313,13 +1331,15 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, /** direct write pages */ struct ll_dio_pages { /** page array to be written. we don't support - * partial pages except the last one. */ + * partial pages except the last one. + */ struct page **ldp_pages; /* offset of each page */ loff_t *ldp_offsets; /** if ldp_offsets is NULL, it means a sequential * pages to be written, then this is the file offset - * of the * first page. */ + * of the first page. + */ loff_t ldp_start_offset; /** how many bytes are to be written. */ size_t ldp_size; @@ -1345,7 +1365,6 @@ static inline int ll_file_nolock(const struct file *file) struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct inode *inode = file_inode(file); - LASSERT(fd != NULL); return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) || (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK)); } @@ -1362,7 +1381,8 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, * remote MDT, where the object is, will grant * UPDATE|PERM lock. The inode will be attached to both * LOOKUP and PERM locks, so revoking either locks will - * case the dcache being cleared */ + * case the dcache being cleared + */ if (it->d.lustre.it_remote_lock_mode) { handle.cookie = it->d.lustre.it_remote_lock_handle; CDEBUG(D_DLMTRACE, "setting l_data to inode %p(%lu/%u) for remote lock %#llx\n", @@ -1383,7 +1403,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, it->d.lustre.it_lock_set = 1; } - if (bits != NULL) + if (bits) *bits = it->d.lustre.it_lock_bits; } @@ -1401,14 +1421,14 @@ static inline int d_lustre_invalid(const struct dentry *dentry) { struct ll_dentry_data *lld = ll_d2d(dentry); - return (lld == NULL) || lld->lld_invalid; + return !lld || lld->lld_invalid; } static inline void __d_lustre_invalidate(struct dentry *dentry) { struct ll_dentry_data *lld = ll_d2d(dentry); - if (lld != NULL) + if (lld) lld->lld_invalid = 1; } @@ -1442,7 +1462,7 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested) static inline void d_lustre_revalidate(struct dentry *dentry) { spin_lock(&dentry->d_lock); - LASSERT(ll_d2d(dentry) != NULL); + LASSERT(ll_d2d(dentry)); ll_d2d(dentry)->lld_invalid = 0; spin_unlock(&dentry->d_lock); } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 446e4b8..1f3e8e8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -102,8 +102,6 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) sbi->ll_ra_info.ra_max_pages = sbi->ll_ra_info.ra_max_pages_per_file; sbi->ll_ra_info.ra_max_read_ahead_whole_pages = SBI_DEFAULT_READAHEAD_WHOLE_MAX; - INIT_LIST_HEAD(&sbi->ll_conn_chain); - INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list); ll_generate_random_uuid(uuid); class_uuid_unparse(uuid, &sbi->ll_sb_uuid); @@ -171,7 +169,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, return -ENOMEM; } - if (llite_root != NULL) { + if (llite_root) { err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); if (err < 0) CERROR("could not register mount in <debugfs>/lustre/llite\n"); @@ -204,7 +202,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT)) /* flag mdc connection as lightweight, only used for test - * purpose, use with care */ + * purpose, use with care + */ data->ocd_connect_flags |= OBD_CONNECT_LIGHTWEIGHT; data->ocd_ibits_known = MDS_INODELOCK_FULL; @@ -252,7 +251,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* For mount, we only need fs info from MDT0, and also in DNE, it * can make sure the client can be mounted as long as MDT0 is - * available */ + * available + */ err = obd_statfs(NULL, sbi->ll_md_exp, osfs, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_FOR_MDT0); @@ -265,7 +265,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, * we can access the MDC export directly and exp_connect_flags will * be non-zero, but if accessing an upgraded 2.1 server it will * have the correct flags filled in. - * XXX: fill in the LMV exp_connect_flags from MDC(s). */ + * XXX: fill in the LMV exp_connect_flags from MDC(s). + */ valid = exp_connect_flags(sbi->ll_md_exp) & CLIENT_CONNECT_MDT_REQD; if (exp_connect_flags(sbi->ll_md_exp) != 0 && valid != CLIENT_CONNECT_MDT_REQD) { @@ -382,7 +383,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* OBD_CONNECT_CKSUM should always be set, even if checksums are * disabled by default, because it can still be enabled on the * fly via /sys. As a consequence, we still need to come to an - * agreement on the supported algorithms at connect time */ + * agreement on the supported algorithms at connect time + */ data->ocd_connect_flags |= OBD_CONNECT_CKSUM; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_CKSUM_ADLER_ONLY)) @@ -453,7 +455,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, #endif /* make root inode - * XXX: move this to after cbd setup? */ + * XXX: move this to after cbd setup? + */ valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS; if (sbi->ll_flags & LL_SBI_RMT_CLIENT) valid |= OBD_MD_FLRMTPERM; @@ -493,7 +496,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, md_free_lustre_md(sbi->ll_md_exp, &lmd); ptlrpc_req_finished(request); - if (root == NULL || IS_ERR(root)) { + if (!(root)) { if (lmd.lsm) obd_free_memmd(sbi->ll_dt_exp, &lmd.lsm); #ifdef CONFIG_FS_POSIX_ACL @@ -502,8 +505,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, lmd.posix_acl = NULL; } #endif - err = IS_ERR(root) ? PTR_ERR(root) : -EBADF; - root = NULL; + err = -EBADF; CERROR("lustre_lite: bad iget4 for root\n"); goto out_root; } @@ -532,7 +534,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, &sbi->ll_cache, NULL); sb->s_root = d_make_root(root); - if (sb->s_root == NULL) { + if (!sb->s_root) { CERROR("%s: can't make root dentry\n", ll_get_fsname(sb, NULL, 0)); err = -ENOMEM; @@ -543,11 +545,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* We set sb->s_dev equal on all lustre clients in order to support * NFS export clustering. NFSD requires that the FSID be the same - * on all clients. */ + * on all clients. + */ /* s_dev is also used in lt_compare() to compare two fs, but that is - * only a node-local comparison. */ + * only a node-local comparison. + */ uuid = obd_get_uuid(sbi->ll_md_exp); - if (uuid != NULL) { + if (uuid) { sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid)); get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); } @@ -619,13 +623,12 @@ static void client_common_put_super(struct super_block *sb) cl_sb_fini(sb); - list_del(&sbi->ll_conn_chain); - obd_fid_fini(sbi->ll_dt_exp->exp_obd); obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; /* wait till all OSCs are gone, since cl_cache is accessing sbi. - * see LU-2543. */ + * see LU-2543. + */ obd_zombie_barrier(); ldebugfs_unregister_mountpoint(sbi); @@ -646,7 +649,8 @@ void ll_kill_super(struct super_block *sb) sbi = ll_s2sbi(sb); /* we need to restore s_dev from changed for clustered NFS before * put_super because new kernels have cached s_dev and change sb->s_dev - * in put_super not affected real removing devices */ + * in put_super not affected real removing devices + */ if (sbi) { sb->s_dev = sbi->ll_sdev_orig; sbi->ll_umounting = 1; @@ -777,7 +781,7 @@ static int ll_options(char *options, int *flags) next: /* Find next opt */ s2 = strchr(s1, ','); - if (s2 == NULL) + if (!s2) break; s1 = s2 + 1; } @@ -797,7 +801,6 @@ void ll_lli_init(struct ll_inode_info *lli) /* Do not set lli_fid, it has been initialized already. */ fid_zero(&lli->lli_pfid); INIT_LIST_HEAD(&lli->lli_close_list); - atomic_set(&lli->lli_open_count, 0); lli->lli_rmtperm_time = 0; lli->lli_pending_och = NULL; lli->lli_mds_read_och = NULL; @@ -890,8 +893,9 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) sb->s_d_op = &ll_d_ops; /* Generate a string unique to this super, in case some joker tries - to mount the same fs at two mount points. - Use the address of the super itself.*/ + * to mount the same fs at two mount points. + * Use the address of the super itself. + */ cfg->cfg_instance = sb; cfg->cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid; cfg->cfg_callback = class_config_llog_handler; @@ -904,7 +908,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ lprof = class_get_profile(profilenm); - if (lprof == NULL) { + if (!lprof) { LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n", profilenm); err = -EINVAL; @@ -964,7 +968,8 @@ void ll_put_super(struct super_block *sb) } /* We need to set force before the lov_disconnect in - lustre_common_put_super, since l_d cleans up osc's as well. */ + * lustre_common_put_super, since l_d cleans up osc's as well. + */ if (force) { next = 0; while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, @@ -1036,8 +1041,8 @@ void ll_clear_inode(struct inode *inode) if (S_ISDIR(inode->i_mode)) { /* these should have been cleared in ll_file_release */ - LASSERT(lli->lli_opendir_key == NULL); - LASSERT(lli->lli_sai == NULL); + LASSERT(!lli->lli_opendir_key); + LASSERT(!lli->lli_sai); LASSERT(lli->lli_opendir_pid == 0); } @@ -1065,7 +1070,7 @@ void ll_clear_inode(struct inode *inode) ll_xattr_cache_destroy(inode); if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - LASSERT(lli->lli_posix_acl == NULL); + LASSERT(!lli->lli_posix_acl); if (lli->lli_remote_perms) { free_rmtperm_hash(lli->lli_remote_perms); lli->lli_remote_perms = NULL; @@ -1074,7 +1079,7 @@ void ll_clear_inode(struct inode *inode) #ifdef CONFIG_FS_POSIX_ACL else if (lli->lli_posix_acl) { LASSERT(atomic_read(&lli->lli_posix_acl->a_refcount) == 1); - LASSERT(lli->lli_remote_perms == NULL); + LASSERT(!lli->lli_remote_perms); posix_acl_release(lli->lli_posix_acl); lli->lli_posix_acl = NULL; } @@ -1115,7 +1120,8 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, if (rc == -ENOENT) { clear_nlink(inode); /* Unlinked special device node? Or just a race? - * Pretend we done everything. */ + * Pretend we did everything. + */ if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) { ia_valid = op_data->op_attr.ia_valid; @@ -1138,7 +1144,8 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, ia_valid = op_data->op_attr.ia_valid; /* inode size will be in cl_setattr_ost, can't do it now since dirty - * cache is not cleared yet. */ + * cache is not cleared yet. + */ op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); rc = simple_setattr(dentry, &op_data->op_attr); op_data->op_attr.ia_valid = ia_valid; @@ -1161,7 +1168,6 @@ static int ll_setattr_done_writing(struct inode *inode, struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - LASSERT(op_data != NULL); if (!S_ISREG(inode->i_mode)) return 0; @@ -1175,7 +1181,8 @@ static int ll_setattr_done_writing(struct inode *inode, rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, mod); if (rc == -EAGAIN) /* MDS has instructed us to obtain Size-on-MDS attribute - * from OSTs and send setattr to back to MDS. */ + * from OSTs and send setattr to back to MDS. + */ rc = ll_som_update(inode, op_data); else if (rc) CERROR("inode %lu mdc truncate failed: rc = %d\n", @@ -1222,7 +1229,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) /* The maximum Lustre file size is variable, based on the * OST maximum object size and number of stripes. This - * needs another check in addition to the VFS check above. */ + * needs another check in addition to the VFS check above. + */ if (attr->ia_size > ll_file_maxbytes(inode)) { CDEBUG(D_INODE, "file "DFID" too large %llu > %llu\n", PFID(&lli->lli_fid), attr->ia_size, @@ -1270,7 +1278,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) } /* We always do an MDS RPC, even if we're only changing the size; - * only the MDS knows whether truncate() should fail with -ETXTBUSY */ + * only the MDS knows whether truncate() should fail with -ETXTBUSY + */ op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (!op_data) @@ -1304,7 +1313,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) /* if not in HSM import mode, clear size attr for released file * we clear the attribute send to MDT in op_data, not the original * received from caller in attr which is used later to - * decide return code */ + * decide return code + */ if (file_is_released && (attr->ia_valid & ATTR_SIZE) && !hsm_import) op_data->op_attr.ia_valid &= ~ATTR_SIZE; @@ -1342,7 +1352,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) * extent lock (new_size:EOF for truncate). It may seem * excessive to send mtime/atime updates to OSTs when not * setting times to past, but it is necessary due to possible - * time de-synchronization between MDT inode and OST objects */ + * time de-synchronization between MDT inode and OST objects + */ if (attr->ia_valid & ATTR_SIZE) down_write(&lli->lli_trunc_sem); rc = cl_setattr_ost(inode, attr); @@ -1470,7 +1481,8 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) /* We need to downshift for all 32-bit kernels, because we can't * tell if the kernel is being called via sys_statfs64() or not. * Stop before overflowing f_bsize - in which case it is better - * to just risk EOVERFLOW if caller is using old sys_statfs(). */ + * to just risk EOVERFLOW if caller is using old sys_statfs(). + */ if (sizeof(long) < 8) { while (osfs.os_blocks > ~0UL && sfs->f_bsize < 0x40000000) { sfs->f_bsize <<= 1; @@ -1514,7 +1526,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) struct ll_sb_info *sbi = ll_i2sbi(inode); LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0)); - if (lsm != NULL) { + if (lsm) { if (!lli->lli_has_smd && !(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) cl_file_inode_init(inode, md); @@ -1599,12 +1611,13 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (exp_connect_som(ll_i2mdexp(inode)) && S_ISREG(inode->i_mode)) { struct lustre_handle lockh; - ldlm_mode_t mode; + enum ldlm_mode mode; /* As it is possible a blocking ast has been processed * by this time, we need to check there is an UPDATE * lock on the client and set LLIF_MDS_SIZE_LOCK holding - * it. */ + * it. + */ mode = ll_take_md_lock(inode, MDS_INODELOCK_UPDATE, &lockh, LDLM_FL_CBPENDING, LCK_CR | LCK_CW | @@ -1617,7 +1630,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_ino, lli->lli_flags); } else { /* Use old size assignment to avoid - * deadlock bz14138 & bz14326 */ + * deadlock bz14138 & bz14326 + */ i_size_write(inode, body->size); spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_MDS_SIZE_LOCK; @@ -1627,7 +1641,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } } else { /* Use old size assignment to avoid - * deadlock bz14138 & bz14326 */ + * deadlock bz14138 & bz14326 + */ i_size_write(inode, body->size); CDEBUG(D_VFSTRACE, "inode=%lu, updating i_size %llu\n", @@ -1657,7 +1672,8 @@ void ll_read_inode2(struct inode *inode, void *opaque) /* Core attributes from the MDS first. This is a new inode, and * the VFS doesn't zero times in the core inode so we have to do * it ourselves. They will be overwritten by either MDS or OST - * attributes - we just need to make sure they aren't newer. */ + * attributes - we just need to make sure they aren't newer. + */ LTIME_S(inode->i_mtime) = 0; LTIME_S(inode->i_atime) = 0; LTIME_S(inode->i_ctime) = 0; @@ -1689,9 +1705,10 @@ void ll_delete_inode(struct inode *inode) { struct cl_inode_info *lli = cl_i2info(inode); - if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) + if (S_ISREG(inode->i_mode) && lli->lli_clob) /* discard all dirty pages before truncating them, required by - * osc_extent implementation at LU-1030. */ + * osc_extent implementation at LU-1030. + */ cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, CL_FSYNC_DISCARD, 1); @@ -1831,7 +1848,7 @@ void ll_umount_begin(struct super_block *sb) sb->s_count, atomic_read(&sb->s_active)); obd = class_exp2obd(sbi->ll_md_exp); - if (obd == NULL) { + if (!obd) { CERROR("Invalid MDC connection handle %#llx\n", sbi->ll_md_exp->exp_handle.h_cookie); return; @@ -1839,7 +1856,7 @@ void ll_umount_begin(struct super_block *sb) obd->obd_force = 1; obd = class_exp2obd(sbi->ll_dt_exp); - if (obd == NULL) { + if (!obd) { CERROR("Invalid LOV connection handle %#llx\n", sbi->ll_dt_exp->exp_handle.h_cookie); return; @@ -1941,7 +1958,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct super_block *sb, struct lookup_intent *it) { struct ll_sb_info *sbi = NULL; - struct lustre_md md; + struct lustre_md md = { NULL }; int rc; LASSERT(*inode || sb); @@ -1954,7 +1971,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, if (*inode) { ll_update_inode(*inode, &md); } else { - LASSERT(sb != NULL); + LASSERT(sb); /* * At this point server returns to client's same fid as client @@ -1965,15 +1982,14 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1, sbi->ll_flags & LL_SBI_32BIT_API), &md); - if (*inode == NULL || IS_ERR(*inode)) { + if (!inode) { #ifdef CONFIG_FS_POSIX_ACL if (md.posix_acl) { posix_acl_release(md.posix_acl); md.posix_acl = NULL; } #endif - rc = IS_ERR(*inode) ? PTR_ERR(*inode) : -ENOMEM; - *inode = NULL; + rc = -ENOMEM; CERROR("new_inode -fatal: rc %d\n", rc); goto out; } @@ -1986,14 +2002,15 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, * 1. proc1: mdt returns a lsm but not granting layout * 2. layout was changed by another client * 3. proc2: refresh layout and layout lock granted - * 4. proc1: to apply a stale layout */ - if (it != NULL && it->d.lustre.it_lock_mode != 0) { + * 4. proc1: to apply a stale layout + */ + if (it && it->d.lustre.it_lock_mode != 0) { struct lustre_handle lockh; struct ldlm_lock *lock; lockh.cookie = it->d.lustre.it_lock_handle; lock = ldlm_handle2lock(&lockh); - LASSERT(lock != NULL); + LASSERT(lock); if (ldlm_has_layout(lock)) { struct cl_object_conf conf; @@ -2008,7 +2025,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, } out: - if (md.lsm != NULL) + if (md.lsm) obd_free_memmd(sbi->ll_dt_exp, &md.lsm); md_free_lustre_md(sbi->ll_md_exp, &md); @@ -2099,7 +2116,8 @@ int ll_process_config(struct lustre_cfg *lcfg) LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == LMD_MAGIC); /* Note we have not called client_common_fill_super yet, so - proc fns must be able to handle that! */ + * proc fns must be able to handle that! + */ rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars, lcfg, sb); if (rc > 0) @@ -2113,15 +2131,13 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, const char *name, int namelen, int mode, __u32 opc, void *data) { - LASSERT(i1 != NULL); - if (namelen > ll_i2sbi(i1)->ll_namelen) return ERR_PTR(-ENAMETOOLONG); - if (op_data == NULL) + if (!op_data) op_data = kzalloc(sizeof(*op_data), GFP_NOFS); - if (op_data == NULL) + if (!op_data) return ERR_PTR(-ENOMEM); ll_i2gids(op_data->op_suppgids, i1, i2); @@ -2141,8 +2157,8 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_cap = cfs_curproc_cap_pack(); op_data->op_bias = 0; op_data->op_cli_flags = 0; - if ((opc == LUSTRE_OPC_CREATE) && (name != NULL) && - filename_is_volatile(name, namelen, NULL)) + if ((opc == LUSTRE_OPC_CREATE) && name && + filename_is_volatile(name, namelen, NULL)) op_data->op_bias |= MDS_CREATE_VOLATILE; op_data->op_opc = opc; op_data->op_mds = 0; @@ -2150,7 +2166,8 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, /* If the file is being opened after mknod() (normally due to NFS) * try to use the default stripe data from parent directory for - * allocating OST objects. Try to pass the parent FID to MDS. */ + * allocating OST objects. Try to pass the parent FID to MDS. + */ if (opc == LUSTRE_OPC_CREATE && i1 == i2 && S_ISREG(i2->i_mode) && !ll_i2info(i2)->lli_has_smd) { struct ll_inode_info *lli = ll_i2info(i2); @@ -2177,7 +2194,7 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) { struct ll_sb_info *sbi; - LASSERT((seq != NULL) && (dentry != NULL)); + LASSERT(seq && dentry); sbi = ll_s2sbi(dentry->d_sb); if (sbi->ll_flags & LL_SBI_NOLCK) @@ -2238,10 +2255,11 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen) char *ptr; int len; - if (buf == NULL) { + if (!buf) { /* this means the caller wants to use static buffer * and it doesn't care about race. Usually this is - * in error reporting path */ + * in error reporting path + */ buf = fsname_static; buflen = sizeof(fsname_static); } @@ -2267,9 +2285,9 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret) /* this can be called inside spin lock so use GFP_ATOMIC. */ buf = (char *)__get_free_page(GFP_ATOMIC); - if (buf != NULL) { + if (buf) { dentry = d_find_alias(page->mapping->host); - if (dentry != NULL) + if (dentry) path = dentry_path_raw(dentry, buf, PAGE_SIZE); } @@ -2280,9 +2298,9 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret) PFID(&obj->cob_header.coh_lu.loh_fid), (path && !IS_ERR(path)) ? path : "", ioret); - if (dentry != NULL) + if (dentry) dput(dentry); - if (buf != NULL) + if (buf) free_page((unsigned long)buf); } diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index bbae95c..31abdb7f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -72,7 +72,7 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, LASSERT(!down_write_trylock(&mm->mmap_sem)); for (vma = find_vma(mm, addr); - vma != NULL && vma->vm_start < (addr + count); vma = vma->vm_next) { + vma && vma->vm_start < (addr + count); vma = vma->vm_next) { if (vma->vm_ops && vma->vm_ops == &ll_file_vm_ops && vma->vm_flags & VM_SHARED) { ret = vma; @@ -119,13 +119,13 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret, */ env = cl_env_nested_get(nest); if (IS_ERR(env)) - return ERR_PTR(-EINVAL); + return ERR_PTR(-EINVAL); *env_ret = env; io = ccc_env_thread_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; - LASSERT(io->ci_obj != NULL); + LASSERT(io->ci_obj); fio = &io->u.ci_fault; fio->ft_index = index; @@ -136,7 +136,7 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret, * the kernel will not read other pages not covered by ldlm in * filemap_nopage. we do our readahead in ll_readpage. */ - if (ra_flags != NULL) + if (ra_flags) *ra_flags = vma->vm_flags & (VM_RAND_READ|VM_SEQ_READ); vma->vm_flags &= ~VM_SEQ_READ; vma->vm_flags |= VM_RAND_READ; @@ -151,8 +151,7 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret, LASSERT(cio->cui_cl.cis_io == io); - /* mmap lock must be MANDATORY it has to cache - * pages. */ + /* mmap lock must be MANDATORY it has to cache pages. */ io->ci_lockreq = CILR_MANDATORY; cio->cui_fd = fd; } else { @@ -178,8 +177,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, struct inode *inode; struct ll_inode_info *lli; - LASSERT(vmpage != NULL); - io = ll_fault_io_init(vma, &env, &nest, vmpage->index, NULL); if (IS_ERR(io)) { result = PTR_ERR(io); @@ -201,7 +198,8 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, /* we grab lli_trunc_sem to exclude truncate case. * Otherwise, we could add dirty pages into osc cache - * while truncate is on-going. */ + * while truncate is on-going. + */ inode = ccc_object_inode(io->ci_obj); lli = ll_i2info(inode); down_read(&lli->lli_trunc_sem); @@ -217,12 +215,13 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, struct ll_inode_info *lli = ll_i2info(inode); lock_page(vmpage); - if (vmpage->mapping == NULL) { + if (!vmpage->mapping) { unlock_page(vmpage); /* page was truncated and lock was cancelled, return * ENODATA so that VM_FAULT_NOPAGE will be returned - * to handle_mm_fault(). */ + * to handle_mm_fault(). + */ if (result == 0) result = -ENODATA; } else if (!PageDirty(vmpage)) { @@ -315,12 +314,13 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) result = cl_io_loop(env, io); /* ft_flags are only valid if we reached - * the call to filemap_fault */ + * the call to filemap_fault + */ if (vio->u.fault.fault.ft_flags_valid) fault_ret = vio->u.fault.fault.ft_flags; vmpage = vio->u.fault.ft_vmpage; - if (result != 0 && vmpage != NULL) { + if (result != 0 && vmpage) { page_cache_release(vmpage); vmf->page = NULL; } @@ -344,9 +344,10 @@ static int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) int result; sigset_t set; - /* Only SIGKILL and SIGTERM is allowed for fault/nopage/mkwrite + /* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite * so that it can be killed by admin but not cause segfault by - * other signals. */ + * other signals. + */ set = cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM)); restart: @@ -357,7 +358,7 @@ restart: /* check if this page has been truncated */ lock_page(vmpage); - if (unlikely(vmpage->mapping == NULL)) { /* unlucky */ + if (unlikely(!vmpage->mapping)) { /* unlucky */ unlock_page(vmpage); page_cache_release(vmpage); vmf->page = NULL; @@ -447,7 +448,8 @@ static void ll_vm_close(struct vm_area_struct *vma) } /* XXX put nice comment here. talk about __free_pte -> dirty pages and - * nopage's reference passing to the pte */ + * nopage's reference passing to the pte + */ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) { int rc = -ENOENT; diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 9f64dd1..74a8868 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -105,7 +105,8 @@ struct inode *search_inode_for_lustre(struct super_block *sb, return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not - * be used here. So we allocate op_data ourselves */ + * be used here. So we allocate op_data ourselves + */ op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (!op_data) return ERR_PTR(-ENOMEM); @@ -141,10 +142,11 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren struct inode *inode; struct dentry *result; - CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid)); if (!fid_is_sane(fid)) return ERR_PTR(-ESTALE); + CDEBUG(D_INFO, "Get dentry for fid: " DFID "\n", PFID(fid)); + inode = search_inode_for_lustre(sb, fid); if (IS_ERR(inode)) return ERR_CAST(inode); @@ -160,7 +162,7 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren * We have to find the parent to tell MDS how to init lov objects. */ if (S_ISREG(inode->i_mode) && !ll_i2info(inode)->lli_has_smd && - parent != NULL) { + parent && !fid_is_zero(parent)) { struct ll_inode_info *lli = ll_i2info(inode); spin_lock(&lli->lli_lock); @@ -174,8 +176,6 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren return result; } -#define LUSTRE_NFS_FID 0x97 - /** * \a connectable - is nfsd will connect himself or this should be done * at lustre @@ -188,20 +188,25 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, struct inode *parent) { + int fileid_len = sizeof(struct lustre_nfs_fid) / 4; struct lustre_nfs_fid *nfs_fid = (void *)fh; CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", - inode->i_ino, PFID(ll_inode2fid(inode)), *plen, - (int)sizeof(struct lustre_nfs_fid)); + inode->i_ino, PFID(ll_inode2fid(inode)), *plen, fileid_len); - if (*plen < sizeof(struct lustre_nfs_fid) / 4) - return 255; + if (*plen < fileid_len) { + *plen = fileid_len; + return FILEID_INVALID; + } nfs_fid->lnf_child = *ll_inode2fid(inode); - nfs_fid->lnf_parent = *ll_inode2fid(parent); - *plen = sizeof(struct lustre_nfs_fid) / 4; + if (parent) + nfs_fid->lnf_parent = *ll_inode2fid(parent); + else + fid_zero(&nfs_fid->lnf_parent); + *plen = fileid_len; - return LUSTRE_NFS_FID; + return FILEID_LUSTRE; } static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, @@ -209,7 +214,8 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, unsigned type) { /* It is hack to access lde_fid for comparison with lgd_fid. - * So the input 'name' must be part of the 'lu_dirent'. */ + * So the input 'name' must be part of the 'lu_dirent'. + */ struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name); struct ll_getname_data *lgd = container_of(ctx, struct ll_getname_data, ctx); @@ -259,7 +265,7 @@ static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, { struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; - if (fh_type != LUSTRE_NFS_FID) + if (fh_type != FILEID_LUSTRE) return ERR_PTR(-EPROTO); return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent); @@ -270,7 +276,7 @@ static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, { struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; - if (fh_type != LUSTRE_NFS_FID) + if (fh_type != FILEID_LUSTRE) return ERR_PTR(-EPROTO); return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL); diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index b27c3f2..63e4847 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -125,12 +125,12 @@ int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops) struct rmtacl_ctl_entry *rce, *e; rce = rce_alloc(key, ops); - if (rce == NULL) + if (!rce) return -ENOMEM; spin_lock(&rct->rct_lock); e = __rct_search(rct, key); - if (unlikely(e != NULL)) { + if (unlikely(e)) { CWARN("Unexpected stale rmtacl_entry found: [key: %d] [ops: %d]\n", (int)key, ops); rce_free(e); @@ -213,7 +213,7 @@ static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key, struct eacl_entry *ee; struct list_head *head = &et->et_entries[ee_hashfunc(key)]; - LASSERT(fid != NULL); + LASSERT(fid); list_for_each_entry(ee, head, ee_list) if (ee->ee_key == key) { if (lu_fid_eq(&ee->ee_fid, fid) && @@ -256,12 +256,12 @@ int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, struct eacl_entry *ee, *e; ee = ee_alloc(key, fid, type, header); - if (ee == NULL) + if (!ee) return -ENOMEM; spin_lock(&et->et_lock); e = __et_search_del(et, key, fid, type); - if (unlikely(e != NULL)) { + if (unlikely(e)) { CWARN("Unexpected stale eacl_entry found: [key: %d] [fid: " DFID "] [type: %d]\n", (int)key, PFID(fid), type); ee_free(e); diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 69c41af..3f53292 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -211,9 +211,8 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) return io->ci_result; io->ci_lockreq = CILR_NEVER; - LASSERT(head != NULL); rw = head->bi_rw; - for (bio = head; bio != NULL; bio = bio->bi_next) { + for (bio = head; bio ; bio = bio->bi_next) { LASSERT(rw == bio->bi_rw); offset = (pgoff_t)(bio->bi_iter.bi_sector << 9) + lo->lo_offset; @@ -297,7 +296,7 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req) spin_lock_irq(&lo->lo_lock); first = lo->lo_bio; - if (unlikely(first == NULL)) { + if (unlikely(!first)) { spin_unlock_irq(&lo->lo_lock); return 0; } @@ -308,7 +307,7 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req) rw = first->bi_rw; bio = &lo->lo_bio; while (*bio && (*bio)->bi_rw == rw) { - CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n", + CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u\n", (unsigned long long)(*bio)->bi_iter.bi_sector, (*bio)->bi_iter.bi_size, page_count, (*bio)->bi_vcnt); @@ -458,7 +457,7 @@ static int loop_thread(void *data) total_count, times, total_count / times); } - LASSERT(bio != NULL); + LASSERT(bio); LASSERT(count <= atomic_read(&lo->lo_pending)); loop_handle_bio(lo, bio); atomic_sub(count, &lo->lo_pending); @@ -560,7 +559,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, if (lo->lo_refcnt > count) /* we needed one fd for the ioctl */ return -EBUSY; - if (filp == NULL) + if (!filp) return -EINVAL; spin_lock_irq(&lo->lo_lock); @@ -625,11 +624,11 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LL_IOC_LLOOP_INFO: { struct lu_fid fid; - if (lo->lo_backing_file == NULL) { + if (!lo->lo_backing_file) { err = -ENOENT; break; } - if (inode == NULL) + if (!inode) inode = file_inode(lo->lo_backing_file); if (lo->lo_state == LLOOP_BOUND) fid = ll_i2info(inode)->lli_fid; @@ -676,7 +675,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, if (magic != ll_iocontrol_magic) return LLIOC_CONT; - if (disks == NULL) { + if (!disks) { err = -ENODEV; goto out1; } @@ -793,7 +792,7 @@ static int __init lloop_init(void) lloop_major, max_loop); ll_iocontrol_magic = ll_iocontrol_register(lloop_ioctl, 2, cmdlist); - if (ll_iocontrol_magic == NULL) + if (!ll_iocontrol_magic) goto out_mem1; loop_dev = kcalloc(max_loop, sizeof(*loop_dev), GFP_KERNEL); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f134ad9..f5fe928 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -43,7 +43,7 @@ #include "llite_internal.h" #include "vvp_internal.h" -/* /proc/lustre/llite mount point registration */ +/* debugfs llite mount point registration */ static struct file_operations ll_rw_extents_stats_fops; static struct file_operations ll_rw_extents_stats_pp_fops; static struct file_operations ll_rw_offset_stats_fops; @@ -345,7 +345,8 @@ static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, return rc; /* Cap this at the current max readahead window size, the readahead - * algorithm does this anyway so it's pointless to set it larger. */ + * algorithm does this anyway so it's pointless to set it larger. + */ if (pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n", sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT)); @@ -453,7 +454,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, if (diff <= 0) break; - if (sbi->ll_dt_exp == NULL) { /* being initialized */ + if (!sbi->ll_dt_exp) { /* being initialized */ rc = -ENODEV; break; } @@ -966,9 +967,9 @@ int ldebugfs_register_mountpoint(struct dentry *parent, name[MAX_STRING_SIZE] = '\0'; - LASSERT(sbi != NULL); - LASSERT(mdc != NULL); - LASSERT(osc != NULL); + LASSERT(sbi); + LASSERT(mdc); + LASSERT(osc); /* Get fsname */ len = strlen(lsi->lsi_lmd->lmd_profile); @@ -1012,7 +1013,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent, /* File operations stats */ sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES, LPROCFS_STATS_FLAG_NONE); - if (sbi->ll_stats == NULL) { + if (!sbi->ll_stats) { err = -ENOMEM; goto out; } @@ -1039,7 +1040,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent, sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string), LPROCFS_STATS_FLAG_NONE); - if (sbi->ll_ra_stats == NULL) { + if (!sbi->ll_ra_stats) { err = -ENOMEM; goto out; } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index da5f443..56d2d1d 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -118,7 +118,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, ll_read_inode2(inode, md); if (S_ISREG(inode->i_mode) && - ll_i2info(inode)->lli_clob == NULL) { + !ll_i2info(inode)->lli_clob) { CDEBUG(D_INODE, "%s: apply lsm %p to inode "DFID".\n", ll_get_fsname(sb, NULL, 0), md->lsm, @@ -127,7 +127,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, } if (rc != 0) { iget_failed(inode); - inode = ERR_PTR(rc); + inode = NULL; } else unlock_new_inode(inode); } else if (!(inode->i_state & (I_FREEING | I_CLEAR))) @@ -180,10 +180,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, __u64 bits = lock->l_policy_data.l_inodebits.bits; /* Inode is set to lock->l_resource->lr_lvb_inode - * for mdc - bug 24555 */ - LASSERT(lock->l_ast_data == NULL); + * for mdc - bug 24555 + */ + LASSERT(!lock->l_ast_data); - if (inode == NULL) + if (!inode) break; /* Invalidate all dentries associated with this inode */ @@ -202,7 +203,8 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, } /* For OPEN locks we differentiate between lock modes - * LCK_CR, LCK_CW, LCK_PR - bug 22891 */ + * LCK_CR, LCK_CW, LCK_PR - bug 22891 + */ if (bits & MDS_INODELOCK_OPEN) ll_have_md_lock(inode, &bits, lock->l_req_mode); @@ -260,7 +262,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, } if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) && - inode->i_sb->s_root != NULL && + inode->i_sb->s_root && !is_root_inode(inode)) ll_invalidate_aliases(inode); @@ -285,15 +287,11 @@ __u32 ll_i2suppgid(struct inode *i) /* Pack the required supplementary groups into the supplied groups array. * If we don't need to use the groups from the target inode(s) then we * instead pack one or more groups from the user's supplementary group - * array in case it might be useful. Not needed if doing an MDS-side upcall. */ + * array in case it might be useful. Not needed if doing an MDS-side upcall. + */ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) { -#if 0 - int i; -#endif - - LASSERT(i1 != NULL); - LASSERT(suppgids != NULL); + LASSERT(i1); suppgids[0] = ll_i2suppgid(i1); @@ -301,22 +299,6 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) suppgids[1] = ll_i2suppgid(i2); else suppgids[1] = -1; - -#if 0 - for (i = 0; i < current_ngroups; i++) { - if (suppgids[0] == -1) { - if (current_groups[i] != suppgids[1]) - suppgids[0] = current_groups[i]; - continue; - } - if (suppgids[1] == -1) { - if (current_groups[i] != suppgids[0]) - suppgids[1] = current_groups[i]; - continue; - } - break; - } -#endif } /* @@ -409,7 +391,8 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, int rc = 0; /* NB 1 request reference will be taken away by ll_intent_lock() - * when I return */ + * when I return + */ CDEBUG(D_DENTRY, "it %p it_disposition %x\n", it, it->d.lustre.it_disposition); if (!it_disposition(it, DISP_LOOKUP_NEG)) { @@ -420,13 +403,14 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, ll_set_lock_data(ll_i2sbi(parent)->ll_md_exp, inode, it, &bits); /* We used to query real size from OSTs here, but actually - this is not needed. For stat() calls size would be updated - from subsequent do_revalidate()->ll_inode_revalidate_it() in - 2.4 and - vfs_getattr_it->ll_getattr()->ll_inode_revalidate_it() in 2.6 - Everybody else who needs correct file size would call - ll_glimpse_size or some equivalent themselves anyway. - Also see bug 7198. */ + * this is not needed. For stat() calls size would be updated + * from subsequent do_revalidate()->ll_inode_revalidate_it() in + * 2.4 and + * vfs_getattr_it->ll_getattr()->ll_inode_revalidate_it() in 2.6 + * Everybody else who needs correct file size would call + * ll_glimpse_size or some equivalent themselves anyway. + * Also see bug 7198. + */ } /* Only hash *de if it is unhashed (new dentry). @@ -443,9 +427,10 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, *de = alias; } else if (!it_disposition(it, DISP_LOOKUP_NEG) && !it_disposition(it, DISP_OPEN_CREATE)) { - /* With DISP_OPEN_CREATE dentry will - instantiated in ll_create_it. */ - LASSERT(d_inode(*de) == NULL); + /* With DISP_OPEN_CREATE dentry will be + * instantiated in ll_create_it. + */ + LASSERT(!d_inode(*de)); d_instantiate(*de, inode); } @@ -498,7 +483,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, if (d_mountpoint(dentry)) CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it)); - if (it == NULL || it->it_op == IT_GETXATTR) + if (!it || it->it_op == IT_GETXATTR) it = &lookup_it; if (it->it_op == IT_GETATTR) { @@ -557,7 +542,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, out: if (req) ptlrpc_req_finished(req); - if (it->it_op == IT_GETATTR && (retval == NULL || retval == dentry)) + if (it->it_op == IT_GETATTR && (!retval || retval == dentry)) ll_statahead_mark(parent, dentry); return retval; } @@ -582,7 +567,7 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, itp = ⁢ de = ll_lookup_it(parent, dentry, itp, 0); - if (itp != NULL) + if (itp) ll_intent_release(itp); return de; @@ -622,7 +607,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, de = ll_lookup_it(dir, dentry, it, lookup_flags); if (IS_ERR(de)) rc = PTR_ERR(de); - else if (de != NULL) + else if (de) dentry = de; if (!rc) { @@ -631,7 +616,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, rc = ll_create_it(dir, dentry, mode, it); if (rc) { /* We dget in ll_splice_alias. */ - if (de != NULL) + if (de) dput(de); goto out_release; } @@ -655,7 +640,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, /* We dget in ll_splice_alias. finish_open takes * care of dget for fd open. */ - if (de != NULL) + if (de) dput(de); } } else { @@ -693,7 +678,8 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) /* We asked for a lock on the directory, but were granted a * lock on the inode. Since we finally have an inode pointer, - * stuff it in the lock. */ + * stuff it in the lock. + */ CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL); @@ -767,7 +753,7 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, int tgt_len = 0; int err; - if (unlikely(tgt != NULL)) + if (unlikely(tgt)) tgt_len = strlen(tgt) + 1; op_data = ll_prep_md_op_data(NULL, dir, NULL, @@ -888,10 +874,11 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) /* The MDS sent back the EA because we unlinked the last reference * to this file. Use this EA to unlink the objects on the OST. * It's opaque so we don't swab here; we leave it to obd_unpackmd() to - * check it is complete and sensible. */ + * check it is complete and sensible. + */ eadata = req_capsule_server_sized_get(&request->rq_pill, &RMF_MDT_MD, body->eadatasize); - LASSERT(eadata != NULL); + LASSERT(eadata); rc = obd_unpackmd(ll_i2dtexp(dir), &lsm, eadata, body->eadatasize); if (rc < 0) { @@ -901,7 +888,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) LASSERT(rc >= sizeof(*lsm)); oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (oa == NULL) { + if (!oa) { rc = -ENOMEM; goto out_free_memmd; } @@ -917,7 +904,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) &RMF_LOGCOOKIES, sizeof(struct llog_cookie) * lsm->lsm_stripe_count); - if (oti.oti_logcookies == NULL) { + if (!oti.oti_logcookies) { oa->o_valid &= ~OBD_MD_FLCOOKIE; body->valid &= ~OBD_MD_FLCOOKIE; } @@ -938,7 +925,8 @@ out: /* ll_unlink() doesn't update the inode with the new link count. * Instead, ll_ddelete() and ll_d_iput() will update it based upon if there * is any lock existing. They will recycle dentries and inodes based upon locks - * too. b=20433 */ + * too. b=20433 + */ static int ll_unlink(struct inode *dir, struct dentry *dentry) { struct ptlrpc_request *request = NULL; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 6b587d6..671039a 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -70,9 +70,9 @@ static void ll_cl_fini(struct ll_cl_context *lcc) struct cl_page *page = lcc->lcc_page; LASSERT(lcc->lcc_cookie == current); - LASSERT(env != NULL); + LASSERT(env); - if (page != NULL) { + if (page) { lu_ref_del(&page->cp_reference, "cl_io", io); cl_page_put(env, page); } @@ -97,7 +97,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, int result = 0; clob = ll_i2info(vmpage->mapping->host)->lli_clob; - LASSERT(clob != NULL); + LASSERT(clob); env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -111,7 +111,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, cio = ccc_env_io(env); io = cio->cui_cl.cis_io; - if (io == NULL && create) { + if (!io && create) { struct inode *inode = vmpage->mapping->host; loff_t pos; @@ -120,7 +120,8 @@ static struct ll_cl_context *ll_cl_init(struct file *file, /* this is too bad. Someone is trying to write the * page w/o holding inode mutex. This means we can - * add dirty pages into cache during truncate */ + * add dirty pages into cache during truncate + */ CERROR("Proc %s is dirtying page w/o inode lock, this will break truncate\n", current->comm); dump_stack(); @@ -163,12 +164,11 @@ static struct ll_cl_context *ll_cl_init(struct file *file, } lcc->lcc_io = io; - if (io == NULL) + if (!io) result = -EIO; if (result == 0) { struct cl_page *page; - LASSERT(io != NULL); LASSERT(io->ci_state == CIS_IO_GOING); LASSERT(cio->cui_fd == LUSTRE_FPRIVATE(file)); page = cl_page_find(env, clob, vmpage->index, vmpage, @@ -240,7 +240,8 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, ll_cl_fini(lcc); } /* returning 0 in prepare assumes commit must be called - * afterwards */ + * afterwards + */ } else { result = PTR_ERR(lcc); } @@ -296,8 +297,8 @@ static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which); * to get an ra budget that is larger than the remaining readahead pages * and reach here at exactly the same time. They will compute /a ret to * consume the remaining pages, but will fail at atomic_add_return() and - * get a zero ra window, although there is still ra space remaining. - Jay */ - + * get a zero ra window, although there is still ra space remaining. - Jay + */ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, struct ra_io_arg *ria, unsigned long pages) @@ -307,7 +308,8 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, /* If read-ahead pages left are less than 1M, do not do read-ahead, * otherwise it will form small read RPC(< 1M), which hurt server - * performance a lot. */ + * performance a lot. + */ ret = min(ra->ra_max_pages - atomic_read(&ra->ra_cur_pages), pages); if (ret < 0 || ret < min_t(long, PTLRPC_MAX_BRW_PAGES, pages)) { ret = 0; @@ -324,7 +326,8 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, * branch is more expensive than subtracting zero from the result. * * Strided read is left unaligned to avoid small fragments beyond - * the RPC boundary from needing an extra read RPC. */ + * the RPC boundary from needing an extra read RPC. + */ if (ria->ria_pages == 0) { long beyond_rpc = (ria->ria_start + ret) % PTLRPC_MAX_BRW_PAGES; @@ -364,7 +367,7 @@ void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which) #define RAS_CDEBUG(ras) \ CDEBUG(D_READA, \ "lrp %lu cr %lu cp %lu ws %lu wl %lu nra %lu r %lu ri %lu" \ - "csr %lu sf %lu sp %lu sl %lu \n", \ + "csr %lu sf %lu sp %lu sl %lu\n", \ ras->ras_last_readpage, ras->ras_consecutive_requests, \ ras->ras_consecutive_pages, ras->ras_window_start, \ ras->ras_window_len, ras->ras_next_readahead, \ @@ -378,9 +381,9 @@ static int index_in_window(unsigned long index, unsigned long point, unsigned long start = point - before, end = point + after; if (start > point) - start = 0; + start = 0; if (end < point) - end = ~0; + end = ~0; return start <= index && index <= end; } @@ -473,7 +476,7 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, const char *msg = NULL; vmpage = grab_cache_page_nowait(mapping, index); - if (vmpage != NULL) { + if (vmpage) { /* Check if vmpage was truncated or reclaimed */ if (vmpage->mapping == mapping) { page = cl_page_find(env, clob, vmpage->index, @@ -500,7 +503,7 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, which = RA_STAT_FAILED_GRAB_PAGE; msg = "g_c_p_n failed"; } - if (msg != NULL) { + if (msg) { ll_ra_stats_inc(mapping, which); CDEBUG(D_READA, "%s\n", msg); } @@ -515,13 +518,15 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, /* Limit this to the blocksize instead of PTLRPC_BRW_MAX_SIZE, since we don't * know what the actual RPC size is. If this needs to change, it makes more * sense to tune the i_blkbits value for the file based on the OSTs it is - * striped over, rather than having a constant value for all files here. */ + * striped over, rather than having a constant value for all files here. + */ /* RAS_INCREASE_STEP should be (1UL << (inode->i_blkbits - PAGE_CACHE_SHIFT)). * Temporarily set RAS_INCREASE_STEP to 1MB. After 4MB RPC is enabled * by default, this should be adjusted corresponding with max_read_ahead_mb * and max_read_ahead_per_file_mb otherwise the readahead budget can be used - * up quickly which will affect read performance significantly. See LU-2816 */ + * up quickly which will affect read performance significantly. See LU-2816 + */ #define RAS_INCREASE_STEP(inode) (ONE_MB_BRW_SIZE >> PAGE_CACHE_SHIFT) static inline int stride_io_mode(struct ll_readahead_state *ras) @@ -570,7 +575,7 @@ stride_pg_count(pgoff_t st_off, unsigned long st_len, unsigned long st_pgs, if (end_left > st_pgs) end_left = st_pgs; - CDEBUG(D_READA, "start %llu, end %llu start_left %lu end_left %lu \n", + CDEBUG(D_READA, "start %llu, end %llu start_left %lu end_left %lu\n", start, end, start_left, end_left); if (start == end) @@ -600,7 +605,8 @@ static int ras_inside_ra_window(unsigned long idx, struct ra_io_arg *ria) /* If ria_length == ria_pages, it means non-stride I/O mode, * idx should always inside read-ahead window in this case * For stride I/O mode, just check whether the idx is inside - * the ria_pages. */ + * the ria_pages. + */ return ria->ria_length == 0 || ria->ria_length == ria->ria_pages || (idx >= ria->ria_stoff && (idx - ria->ria_stoff) % ria->ria_length < ria->ria_pages); @@ -616,7 +622,7 @@ static int ll_read_ahead_pages(const struct lu_env *env, int rc, count = 0, stride_ria; unsigned long page_idx; - LASSERT(ria != NULL); + LASSERT(ria); RIA_DEBUG(ria); stride_ria = ria->ria_length > ria->ria_pages && ria->ria_pages > 0; @@ -634,11 +640,13 @@ static int ll_read_ahead_pages(const struct lu_env *env, } else if (stride_ria) { /* If it is not in the read-ahead window, and it is * read-ahead mode, then check whether it should skip - * the stride gap */ + * the stride gap + */ pgoff_t offset; /* FIXME: This assertion only is valid when it is for * forward read-ahead, it will be fixed when backward - * read-ahead is implemented */ + * read-ahead is implemented + */ LASSERTF(page_idx > ria->ria_stoff, "Invalid page_idx %lu rs %lu re %lu ro %lu rl %lu rp %lu\n", page_idx, ria->ria_start, ria->ria_end, ria->ria_stoff, @@ -647,7 +655,7 @@ static int ll_read_ahead_pages(const struct lu_env *env, offset = offset % (ria->ria_length); if (offset > ria->ria_pages) { page_idx += ria->ria_length - offset; - CDEBUG(D_READA, "i %lu skip %lu \n", page_idx, + CDEBUG(D_READA, "i %lu skip %lu\n", page_idx, ria->ria_length - offset); continue; } @@ -699,7 +707,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, bead = NULL; /* Enlarge the RA window to encompass the full read */ - if (bead != NULL && ras->ras_window_start + ras->ras_window_len < + if (bead && ras->ras_window_start + ras->ras_window_len < bead->lrr_start + bead->lrr_count) { ras->ras_window_len = bead->lrr_start + bead->lrr_count - ras->ras_window_start; @@ -721,7 +729,8 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, */ /* Note: we only trim the RPC, instead of extending the RPC * to the boundary, so to avoid reading too much pages during - * random reading. */ + * random reading. + */ rpc_boundary = (end + 1) & (~(PTLRPC_MAX_BRW_PAGES - 1)); if (rpc_boundary > 0) rpc_boundary--; @@ -774,8 +783,9 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, * the ras we need to go back and update the ras so that the * next read-ahead tries from where we left off. we only do so * if the region we failed to issue read-ahead on is still ahead - * of the app and behind the next index to start read-ahead from */ - CDEBUG(D_READA, "ra_end %lu end %lu stride end %lu \n", + * of the app and behind the next index to start read-ahead from + */ + CDEBUG(D_READA, "ra_end %lu end %lu stride end %lu\n", ra_end, end, ria->ria_end); if (ra_end != end + 1) { @@ -880,7 +890,8 @@ static void ras_update_stride_detector(struct ll_readahead_state *ras, } /* Stride Read-ahead window will be increased inc_len according to - * stride I/O pattern */ + * stride I/O pattern + */ static void ras_stride_increase_window(struct ll_readahead_state *ras, struct ll_ra_info *ra, unsigned long inc_len) @@ -951,7 +962,8 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, * or reads to some other part of the file. Secondly if we get a * read-ahead miss that we think we've previously issued. This can * be a symptom of there being so many read-ahead pages that the VM is - * reclaiming it before we get to it. */ + * reclaiming it before we get to it. + */ if (!index_in_window(index, ras->ras_last_readpage, 8, 8)) { zero = 1; ll_ra_stats_inc_sbi(sbi, RA_STAT_DISTANT_READPAGE); @@ -968,7 +980,8 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, * file up to ra_max_pages_per_file. This is simply a best effort * and only occurs once per open file. Normal RA behavior is reverted * to for subsequent IO. The mmap case does not increment - * ras_requests and thus can never trigger this behavior. */ + * ras_requests and thus can never trigger this behavior. + */ if (ras->ras_requests == 2 && !ras->ras_request_index) { __u64 kms_pages; @@ -1014,14 +1027,16 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, stride_io_mode(ras)) { /*If stride-RA hit cache miss, the stride dector *will not be reset to avoid the overhead of - *redetecting read-ahead mode */ + *redetecting read-ahead mode + */ if (index != ras->ras_last_readpage + 1) ras->ras_consecutive_pages = 0; ras_reset(inode, ras, index); RAS_CDEBUG(ras); } else { /* Reset both stride window and normal RA - * window */ + * window + */ ras_reset(inode, ras, index); ras->ras_consecutive_pages++; ras_stride_reset(ras); @@ -1030,7 +1045,8 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, } else if (stride_io_mode(ras)) { /* If this is contiguous read but in stride I/O mode * currently, check whether stride step still is valid, - * if invalid, it will reset the stride ra window*/ + * if invalid, it will reset the stride ra window + */ if (!index_in_stride_window(ras, index)) { /* Shrink stride read-ahead window to be zero */ ras_stride_reset(ras); @@ -1046,7 +1062,8 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, if (stride_io_mode(ras)) /* Since stride readahead is sensitive to the offset * of read-ahead, so we use original offset here, - * instead of ras_window_start, which is RPC aligned */ + * instead of ras_window_start, which is RPC aligned + */ ras->ras_next_readahead = max(index, ras->ras_next_readahead); else ras->ras_next_readahead = max(ras->ras_window_start, @@ -1054,7 +1071,8 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, RAS_CDEBUG(ras); /* Trigger RA in the mmap case where ras_consecutive_requests - * is not incremented and thus can't be used to trigger RA */ + * is not incremented and thus can't be used to trigger RA + */ if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) { ras->ras_window_len = RAS_INCREASE_STEP(inode); goto out_unlock; @@ -1100,7 +1118,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); - LASSERT(ll_i2dtexp(inode) != NULL); + LASSERT(ll_i2dtexp(inode)); env = cl_env_nested_get(&nest); if (IS_ERR(env)) { @@ -1109,7 +1127,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) } clob = ll_i2info(inode)->lli_clob; - LASSERT(clob != NULL); + LASSERT(clob); io = ccc_env_thread_io(env); io->ci_obj = clob; @@ -1152,14 +1170,16 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) /* Flush page failed because the extent is being written out. * Wait for the write of extent to be finished to avoid * breaking kernel which assumes ->writepage should mark - * PageWriteback or clean the page. */ + * PageWriteback or clean the page. + */ result = cl_sync_file_range(inode, offset, offset + PAGE_CACHE_SIZE - 1, CL_FSYNC_LOCAL, 1); if (result > 0) { /* actually we may have written more than one page. * decreasing this page because the caller will count - * it. */ + * it. + */ wbc->nr_to_write -= result - 1; result = 0; } @@ -1209,7 +1229,8 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) if (sbi->ll_umounting) /* if the mountpoint is being umounted, all pages have to be * evicted to avoid hitting LBUG when truncate_inode_pages() - * is called later on. */ + * is called later on. + */ ignore_layout = 1; result = cl_sync_file_range(inode, start, end, mode, ignore_layout); if (result > 0) { diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 711fda9..b0f7ffa 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -92,9 +92,9 @@ static void ll_invalidatepage(struct page *vmpage, unsigned int offset, if (!IS_ERR(env)) { inode = vmpage->mapping->host; obj = ll_i2info(inode)->lli_clob; - if (obj != NULL) { + if (obj) { page = cl_vmpage_page(vmpage, obj); - if (page != NULL) { + if (page) { lu_ref_add(&page->cp_reference, "delete", vmpage); cl_page_delete(env, page); @@ -128,11 +128,11 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) return 0; mapping = vmpage->mapping; - if (mapping == NULL) + if (!mapping) return 1; obj = ll_i2info(mapping->host)->lli_clob; - if (obj == NULL) + if (!obj) return 1; /* 1 for page allocator, 1 for cl_page and 1 for page cache */ @@ -145,12 +145,13 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) /* If we can't allocate an env we won't call cl_page_put() * later on which further means it's impossible to drop * page refcount by cl_page, so ask kernel to not free - * this page. */ + * this page. + */ return 0; page = cl_vmpage_page(vmpage, obj); - result = page == NULL; - if (page != NULL) { + result = !page; + if (page) { if (!cl_page_in_use(page)) { result = 1; cl_page_delete(env, page); @@ -212,7 +213,8 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr, } /* ll_free_user_pages - tear down page struct array - * @pages: array of page struct pointers underlying target buffer */ + * @pages: array of page struct pointers underlying target buffer + */ static void ll_free_user_pages(struct page **pages, int npages, int do_dirty) { int i; @@ -246,7 +248,7 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, cl_2queue_init(queue); for (i = 0; i < page_count; i++) { if (pv->ldp_offsets) - file_offset = pv->ldp_offsets[i]; + file_offset = pv->ldp_offsets[i]; LASSERT(!(file_offset & (page_size - 1))); clp = cl_page_find(env, obj, cl_index(obj, file_offset), @@ -266,7 +268,8 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, do_io = true; /* check the page type: if the page is a host page, then do - * write directly */ + * write directly + */ if (clp->cp_type == CPT_CACHEABLE) { struct page *vmpage = cl_page_vmpage(env, clp); struct page *src_page; @@ -284,14 +287,16 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, kunmap_atomic(src); /* make sure page will be added to the transfer by - * cl_io_submit()->...->vvp_page_prep_write(). */ + * cl_io_submit()->...->vvp_page_prep_write(). + */ if (rw == WRITE) set_page_dirty(vmpage); if (rw == READ) { /* do not issue the page for read, since it * may reread a ra page which has NOT uptodate - * bit set. */ + * bit set. + */ cl_page_disown(env, io, clp); do_io = false; } @@ -359,7 +364,8 @@ static ssize_t ll_direct_IO_26_seg(const struct lu_env *env, struct cl_io *io, * kmalloc limit. We need to fit all of the brw_page structs, each one * representing PAGE_SIZE worth of user data, into a single buffer, and * then truncate this to be a full-sized RPC. For 4kB PAGE_SIZE this is - * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. */ + * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. + */ #define MAX_DIO_SIZE ((MAX_MALLOC / sizeof(struct brw_page) * PAGE_CACHE_SIZE) & \ ~(DT_MAX_BRW_SIZE - 1)) static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, @@ -396,7 +402,7 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, env = cl_env_get(&refcheck); LASSERT(!IS_ERR(env)); io = ccc_env_io(env)->cui_cl.cis_io; - LASSERT(io != NULL); + LASSERT(io); /* 0. Need locking between buffered and direct access. and race with * size changing by concurrent truncates and writes. @@ -433,7 +439,8 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, * for the request, shrink it to a smaller * PAGE_SIZE multiple and try again. * We should always be able to kmalloc for a - * page worth of page pointers = 4MB on i386. */ + * page worth of page pointers = 4MB on i386. + */ if (result == -ENOMEM && size > (PAGE_CACHE_SIZE / sizeof(*pages)) * PAGE_CACHE_SIZE) { @@ -461,7 +468,7 @@ out: struct lov_stripe_md *lsm; lsm = ccc_inode_lsm_get(inode); - LASSERT(lsm != NULL); + LASSERT(lsm); lov_stripe_lock(lsm); obd_adjust_kms(ll_i2dtexp(inode), lsm, file_offset, 0); lov_stripe_unlock(lsm); diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 88ffd8e..d4a3722 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -49,13 +49,13 @@ #define SA_OMITTED_ENTRY_MAX 8ULL -typedef enum { +enum se_stat { /** negative values are for error cases */ SA_ENTRY_INIT = 0, /** init entry */ SA_ENTRY_SUCC = 1, /** stat succeed */ SA_ENTRY_INVA = 2, /** invalid entry */ SA_ENTRY_DEST = 3, /** entry to be destroyed */ -} se_stat_t; +}; struct ll_sa_entry { /* link into sai->sai_entries */ @@ -71,7 +71,7 @@ struct ll_sa_entry { /* low layer ldlm lock handle */ __u64 se_handle; /* entry status */ - se_stat_t se_stat; + enum se_stat se_stat; /* entry size, contains name */ int se_size; /* pointer to async getattr enqueue info */ @@ -130,7 +130,7 @@ ll_sa_entry_unhash(struct ll_statahead_info *sai, struct ll_sa_entry *entry) static inline int agl_should_run(struct ll_statahead_info *sai, struct inode *inode) { - return (inode != NULL && S_ISREG(inode->i_mode) && sai->sai_agl_valid); + return (inode && S_ISREG(inode->i_mode) && sai->sai_agl_valid); } static inline int sa_sent_full(struct ll_statahead_info *sai) @@ -366,7 +366,7 @@ ll_sa_entry_fini(struct ll_statahead_info *sai, struct ll_sa_entry *entry) */ static void do_sa_entry_to_stated(struct ll_statahead_info *sai, - struct ll_sa_entry *entry, se_stat_t stat) + struct ll_sa_entry *entry, enum se_stat stat) { struct ll_sa_entry *se; struct list_head *pos = &sai->sai_entries_stated; @@ -392,7 +392,7 @@ do_sa_entry_to_stated(struct ll_statahead_info *sai, */ static int ll_sa_entry_to_stated(struct ll_statahead_info *sai, - struct ll_sa_entry *entry, se_stat_t stat) + struct ll_sa_entry *entry, enum se_stat stat) { struct ll_inode_info *lli = ll_i2info(sai->sai_inode); int ret = 1; @@ -494,12 +494,13 @@ static void ll_sai_put(struct ll_statahead_info *sai) if (unlikely(atomic_read(&sai->sai_refcount) > 0)) { /* It is race case, the interpret callback just hold - * a reference count */ + * a reference count + */ spin_unlock(&lli->lli_sa_lock); return; } - LASSERT(lli->lli_opendir_key == NULL); + LASSERT(!lli->lli_opendir_key); LASSERT(thread_is_stopped(&sai->sai_thread)); LASSERT(thread_is_stopped(&sai->sai_agl_thread)); @@ -618,20 +619,21 @@ static void ll_post_statahead(struct ll_statahead_info *sai) it = &minfo->mi_it; req = entry->se_req; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { rc = -EFAULT; goto out; } child = entry->se_inode; - if (child == NULL) { + if (!child) { /* * lookup. */ LASSERT(fid_is_zero(&minfo->mi_data.op_fid2)); /* XXX: No fid in reply, this is probably cross-ref case. - * SA can't handle it yet. */ + * SA can't handle it yet. + */ if (body->valid & OBD_MD_MDS) { rc = -EAGAIN; goto out; @@ -672,7 +674,8 @@ out: /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock * reference count by calling "ll_intent_drop_lock()" in spite of the * above operations failed or not. Do not worry about calling - * "ll_intent_drop_lock()" more than once. */ + * "ll_intent_drop_lock()" more than once. + */ rc = ll_sa_entry_to_stated(sai, entry, rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC); if (rc == 0 && entry->se_index == sai->sai_index_wait) @@ -698,14 +701,15 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, /* release ibits lock ASAP to avoid deadlock when statahead * thread enqueues lock on parent in readdir and another * process enqueues lock on child with parent lock held, eg. - * unlink. */ + * unlink. + */ handle = it->d.lustre.it_lock_handle; ll_intent_drop_lock(it); } spin_lock(&lli->lli_sa_lock); /* stale entry */ - if (unlikely(lli->lli_sai == NULL || + if (unlikely(!lli->lli_sai || lli->lli_sai->sai_generation != minfo->mi_generation)) { spin_unlock(&lli->lli_sa_lock); rc = -ESTALE; @@ -720,7 +724,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, } entry = ll_sa_entry_get_byindex(sai, minfo->mi_cbdata); - if (entry == NULL) { + if (!entry) { sai->sai_replied++; spin_unlock(&lli->lli_sa_lock); rc = -EIDRM; @@ -736,7 +740,8 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, /* Release the async ibits lock ASAP to avoid deadlock * when statahead thread tries to enqueue lock on parent * for readpage and other tries to enqueue lock on child - * with parent's lock held, for example: unlink. */ + * with parent's lock held, for example: unlink. + */ entry->se_handle = handle; wakeup = list_empty(&sai->sai_entries_received); list_add_tail(&entry->se_list, @@ -756,7 +761,7 @@ out: iput(dir); kfree(minfo); } - if (sai != NULL) + if (sai) ll_sai_put(sai); return rc; } @@ -853,7 +858,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, struct ldlm_enqueue_info *einfo; int rc; - if (unlikely(inode == NULL)) + if (unlikely(!inode)) return 1; if (d_mountpoint(dentry)) @@ -908,10 +913,9 @@ static void ll_statahead_one(struct dentry *parent, const char *entry_name, rc = do_sa_revalidate(dir, entry, dentry); if (rc == 1 && agl_should_run(sai, d_inode(dentry))) ll_agl_add(sai, d_inode(dentry), entry->se_index); - } - if (dentry != NULL) dput(dentry); + } if (rc) { rc1 = ll_sa_entry_to_stated(sai, entry, @@ -948,7 +952,8 @@ static int ll_agl_thread(void *arg) if (thread_is_init(thread)) /* If someone else has changed the thread state * (e.g. already changed to SVC_STOPPING), we can't just - * blindly overwrite that setting. */ + * blindly overwrite that setting. + */ thread_set_flags(thread, SVC_RUNNING); spin_unlock(&plli->lli_agl_lock); wake_up(&thread->t_ctl_waitq); @@ -964,7 +969,8 @@ static int ll_agl_thread(void *arg) spin_lock(&plli->lli_agl_lock); /* The statahead thread maybe help to process AGL entries, - * so check whether list empty again. */ + * so check whether list empty again. + */ if (!list_empty(&sai->sai_entries_agl)) { clli = list_entry(sai->sai_entries_agl.next, struct ll_inode_info, lli_agl_list); @@ -1049,7 +1055,8 @@ static int ll_statahead_thread(void *arg) if (thread_is_init(thread)) /* If someone else has changed the thread state * (e.g. already changed to SVC_STOPPING), we can't just - * blindly overwrite that setting. */ + * blindly overwrite that setting. + */ thread_set_flags(thread, SVC_RUNNING); spin_unlock(&plli->lli_sa_lock); wake_up(&thread->t_ctl_waitq); @@ -1070,7 +1077,7 @@ static int ll_statahead_thread(void *arg) } dp = page_address(page); - for (ent = lu_dirent_start(dp); ent != NULL; + for (ent = lu_dirent_start(dp); ent; ent = lu_dirent_next(ent)) { __u64 hash; int namelen; @@ -1137,7 +1144,8 @@ interpret_it: /* If no window for metadata statahead, but there are * some AGL entries to be triggered, then try to help - * to process the AGL entries. */ + * to process the AGL entries. + */ if (sa_sent_full(sai)) { spin_lock(&plli->lli_agl_lock); while (!list_empty(&sai->sai_entries_agl)) { @@ -1274,7 +1282,7 @@ void ll_stop_statahead(struct inode *dir, void *key) { struct ll_inode_info *lli = ll_i2info(dir); - if (unlikely(key == NULL)) + if (unlikely(!key)) return; spin_lock(&lli->lli_sa_lock); @@ -1357,7 +1365,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) } dp = page_address(page); - for (ent = lu_dirent_start(dp); ent != NULL; + for (ent = lu_dirent_start(dp); ent; ent = lu_dirent_next(ent)) { __u64 hash; int namelen; @@ -1365,7 +1373,8 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) hash = le64_to_cpu(ent->lde_hash); /* The ll_get_dir_page() can return any page containing - * the given hash which may be not the start hash. */ + * the given hash which may be not the start hash. + */ if (unlikely(hash < pos)) continue; @@ -1448,7 +1457,7 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) struct ll_sb_info *sbi = ll_i2sbi(sai->sai_inode); int hit; - if (entry != NULL && entry->se_stat == SA_ENTRY_SUCC) + if (entry && entry->se_stat == SA_ENTRY_SUCC) hit = 1; else hit = 0; @@ -1498,6 +1507,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, struct ll_sa_entry *entry; struct ptlrpc_thread *thread; struct l_wait_info lwi = { 0 }; + struct task_struct *task; int rc = 0; struct ll_inode_info *plli; @@ -1540,7 +1550,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } entry = ll_sa_entry_get_byname(sai, &(*dentryp)->d_name); - if (entry == NULL || only_unplug) { + if (!entry || only_unplug) { ll_sai_unplug(sai, entry); return entry ? 1 : -EAGAIN; } @@ -1559,8 +1569,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } } - if (entry->se_stat == SA_ENTRY_SUCC && - entry->se_inode != NULL) { + if (entry->se_stat == SA_ENTRY_SUCC && entry->se_inode) { struct inode *inode = entry->se_inode; struct lookup_intent it = { .it_op = IT_GETATTR, .d.lustre.it_lock_handle = @@ -1570,7 +1579,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode), &bits); if (rc == 1) { - if (d_inode(*dentryp) == NULL) { + if (!d_inode(*dentryp)) { struct dentry *alias; alias = ll_splice_alias(inode, @@ -1616,14 +1625,14 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } sai = ll_sai_alloc(); - if (sai == NULL) { + if (!sai) { rc = -ENOMEM; goto out; } sai->sai_ls_all = (rc == LS_FIRST_DOT_DE); sai->sai_inode = igrab(dir); - if (unlikely(sai->sai_inode == NULL)) { + if (unlikely(!sai->sai_inode)) { CWARN("Do not start stat ahead on dying inode "DFID"\n", PFID(&lli->lli_fid)); rc = -ESTALE; @@ -1651,25 +1660,28 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * but as soon as we expose the sai by attaching it to the lli that * default reference can be dropped by another thread calling * ll_stop_statahead. We need to take a local reference to protect - * the sai buffer while we intend to access it. */ + * the sai buffer while we intend to access it. + */ ll_sai_get(sai); lli->lli_sai = sai; plli = ll_i2info(d_inode(parent)); - rc = PTR_ERR(kthread_run(ll_statahead_thread, parent, - "ll_sa_%u", plli->lli_opendir_pid)); + task = kthread_run(ll_statahead_thread, parent, "ll_sa_%u", + plli->lli_opendir_pid); thread = &sai->sai_thread; - if (IS_ERR_VALUE(rc)) { + if (IS_ERR(task)) { + rc = PTR_ERR(task); CERROR("can't start ll_sa thread, rc: %d\n", rc); dput(parent); lli->lli_opendir_key = NULL; thread_set_flags(thread, SVC_STOPPED); thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED); /* Drop both our own local reference and the default - * reference from allocation time. */ + * reference from allocation time. + */ ll_sai_put(sai); ll_sai_put(sai); - LASSERT(lli->lli_sai == NULL); + LASSERT(!lli->lli_sai); return -EAGAIN; } diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 86c371e..63f090a 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -54,7 +54,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb) ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); lli = kmem_cache_alloc(ll_inode_cachep, GFP_NOFS | __GFP_ZERO); - if (lli == NULL) + if (!lli) return NULL; inode_init_once(&lli->lli_vfs_inode); @@ -99,7 +99,8 @@ static int __init init_lustre_lite(void) /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data - * symbols from modules.*/ + * symbols from modules. + */ CDEBUG(D_INFO, "Lustre client module (%p).\n", &lustre_super_operations); @@ -108,26 +109,26 @@ static int __init init_lustre_lite(void) sizeof(struct ll_inode_info), 0, SLAB_HWCACHE_ALIGN|SLAB_ACCOUNT, NULL); - if (ll_inode_cachep == NULL) + if (!ll_inode_cachep) goto out_cache; ll_file_data_slab = kmem_cache_create("ll_file_data", sizeof(struct ll_file_data), 0, SLAB_HWCACHE_ALIGN, NULL); - if (ll_file_data_slab == NULL) + if (!ll_file_data_slab) goto out_cache; ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache", sizeof(struct ll_remote_perm), 0, 0, NULL); - if (ll_remote_perm_cachep == NULL) + if (!ll_remote_perm_cachep) goto out_cache; ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache", REMOTE_PERM_HASHSIZE * sizeof(struct list_head), 0, 0, NULL); - if (ll_rmtperm_hash_cachep == NULL) + if (!ll_rmtperm_hash_cachep) goto out_cache; llite_root = debugfs_create_dir("llite", debugfs_lustre_root); @@ -146,7 +147,8 @@ static int __init init_lustre_lite(void) cfs_get_random_bytes(seed, sizeof(seed)); /* Nodes with small feet have little entropy. The NID for this - * node gives the most entropy in the low bits */ + * node gives the most entropy in the low bits + */ for (i = 0;; i++) { if (LNetGetId(i, &lnet_id) == -ENOENT) break; diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 2610348..4435a63 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -59,7 +59,8 @@ static int ll_readlink_internal(struct inode *inode, *symname = lli->lli_symlink_name; /* If the total CDEBUG() size is larger than a page, it * will print a warning to the console, avoid this by - * printing just the last part of the symlink. */ + * printing just the last part of the symlink. + */ CDEBUG(D_INODE, "using cached symlink %s%.*s, len = %d\n", print_limit < symlen ? "..." : "", print_limit, (*symname) + symlen - print_limit, symlen); @@ -81,7 +82,6 @@ static int ll_readlink_internal(struct inode *inode, } body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); if ((body->valid & OBD_MD_LINKNAME) == 0) { CERROR("OBD_MD_LINKNAME not set on reply\n"); rc = -EPROTO; @@ -97,7 +97,7 @@ static int ll_readlink_internal(struct inode *inode, } *symname = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_MD); - if (*symname == NULL || + if (!*symname || strnlen(*symname, symlen) != symlen - 1) { /* not full/NULL terminated */ CERROR("inode %lu: symlink not NULL terminated string of length %d\n", diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index fdca4ec..6075ccf 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -80,7 +80,7 @@ static void *vvp_key_init(const struct lu_context *ctx, struct vvp_thread_info *info; info = kmem_cache_alloc(vvp_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -99,7 +99,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx, struct vvp_session *session; session = kmem_cache_alloc(vvp_session_kmem, GFP_NOFS | __GFP_ZERO); - if (session == NULL) + if (!session) session = ERR_PTR(-ENOMEM); return session; } @@ -228,7 +228,7 @@ int cl_sb_fini(struct super_block *sb) if (!IS_ERR(env)) { cld = sbi->ll_cl; - if (cld != NULL) { + if (cld) { cl_stack_fini(env, cld); sbi->ll_cl = NULL; sbi->ll_site = NULL; @@ -325,11 +325,11 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env, cfs_hash_hlist_for_each(dev->ld_site->ls_obj_hash, id->vpi_bucket, vvp_pgcache_obj_get, id); - if (id->vpi_obj != NULL) { + if (id->vpi_obj) { struct lu_object *lu_obj; lu_obj = lu_object_locate(id->vpi_obj, dev->ld_type); - if (lu_obj != NULL) { + if (lu_obj) { lu_object_ref_add(lu_obj, "dump", current); return lu2cl(lu_obj); } @@ -355,7 +355,7 @@ static loff_t vvp_pgcache_find(const struct lu_env *env, if (id.vpi_bucket >= CFS_HASH_NHLIST(site->ls_obj_hash)) return ~0ULL; clob = vvp_pgcache_obj(env, dev, &id); - if (clob != NULL) { + if (clob) { struct cl_object_header *hdr; int nr; struct cl_page *pg; @@ -443,7 +443,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) vvp_pgcache_id_unpack(pos, &id); sbi = f->private; clob = vvp_pgcache_obj(env, &sbi->ll_cl->cd_lu_dev, &id); - if (clob != NULL) { + if (clob) { hdr = cl_object_header(clob); spin_lock(&hdr->coh_page_guard); @@ -452,7 +452,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) seq_printf(f, "%8x@"DFID": ", id.vpi_index, PFID(&hdr->coh_lu.loh_fid)); - if (page != NULL) { + if (page) { vvp_pgcache_page_show(env, f, page); cl_page_put(env, page); } else diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 0920ac6..cca4b6c 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -78,7 +78,8 @@ static bool can_populate_pages(const struct lu_env *env, struct cl_io *io, case CIT_READ: case CIT_WRITE: /* don't need lock here to check lli_layout_gen as we have held - * extent lock and GROUP lock has to hold to swap layout */ + * extent lock and GROUP lock has to hold to swap layout + */ if (ll_layout_version_get(lli) != cio->cui_layout_gen) { io->ci_need_restart = 1; /* this will return application a short read/write */ @@ -134,7 +135,8 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) */ rc = ll_layout_restore(ccc_object_inode(obj)); /* if restore registration failed, no restart, - * we will return -ENODATA */ + * we will return -ENODATA + */ /* The layout will change after restore, so we need to * block on layout lock hold by the MDT * as MDT will not send new layout in lvb (see LU-3124) @@ -164,8 +166,7 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) DFID" layout changed from %d to %d.\n", PFID(lu_object_fid(&obj->co_lu)), cio->cui_layout_gen, gen); - /* today successful restore is the only possible - * case */ + /* today successful restore is the only possible case */ /* restore was done, clear restoring state */ ll_i2info(ccc_object_inode(obj))->lli_flags &= ~LLIF_FILE_RESTORING; @@ -181,7 +182,7 @@ static void vvp_io_fault_fini(const struct lu_env *env, CLOBINVRNT(env, io->ci_obj, ccc_object_invariant(io->ci_obj)); - if (page != NULL) { + if (page) { lu_ref_del(&page->cp_reference, "fault", io); cl_page_put(env, page); io->u.ci_fault.ft_page = NULL; @@ -220,11 +221,11 @@ static int vvp_mmap_locks(const struct lu_env *env, if (!cl_is_normalio(env, io)) return 0; - if (vio->cui_iter == NULL) /* nfs or loop back device write */ + if (!vio->cui_iter) /* nfs or loop back device write */ return 0; /* No MM (e.g. NFS)? No vmas too. */ - if (mm == NULL) + if (!mm) return 0; iov_for_each(iov, i, *(vio->cui_iter)) { @@ -456,7 +457,8 @@ static void vvp_io_setattr_end(const struct lu_env *env, if (cl_io_is_trunc(io)) /* Truncate in memory pages - they must be clean pages - * because osc has already notified to destroy osc_extents. */ + * because osc has already notified to destroy osc_extents. + */ vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size); inode_unlock(inode); @@ -529,7 +531,8 @@ static int vvp_io_read_start(const struct lu_env *env, vio->u.splice.cui_flags); /* LU-1109: do splice read stripe by stripe otherwise if it * may make nfsd stuck if this read occupied all internal pipe - * buffers. */ + * buffers. + */ io->ci_continue = 0; break; default: @@ -587,7 +590,7 @@ static int vvp_io_write_start(const struct lu_env *env, CDEBUG(D_VFSTRACE, "write: [%lli, %lli)\n", pos, pos + (long long)cnt); - if (cio->cui_iter == NULL) /* from a temp io in ll_cl_init(). */ + if (!cio->cui_iter) /* from a temp io in ll_cl_init(). */ result = 0; else result = generic_file_write_iter(cio->cui_iocb, cio->cui_iter); @@ -673,7 +676,7 @@ static int vvp_io_fault_start(const struct lu_env *env, /* must return locked page */ if (fio->ft_mkwrite) { - LASSERT(cfio->ft_vmpage != NULL); + LASSERT(cfio->ft_vmpage); lock_page(cfio->ft_vmpage); } else { result = vvp_io_kernel_fault(cfio); @@ -689,13 +692,15 @@ static int vvp_io_fault_start(const struct lu_env *env, size = i_size_read(inode); /* Though we have already held a cl_lock upon this page, but - * it still can be truncated locally. */ + * it still can be truncated locally. + */ if (unlikely((vmpage->mapping != inode->i_mapping) || (page_offset(vmpage) > size))) { CDEBUG(D_PAGE, "llite: fault and truncate race happened!\n"); /* return +1 to stop cl_io_loop() and ll_fault() will catch - * and retry. */ + * and retry. + */ result = 1; goto out; } @@ -736,7 +741,8 @@ static int vvp_io_fault_start(const struct lu_env *env, } /* if page is going to be written, we should add this page into cache - * earlier. */ + * earlier. + */ if (fio->ft_mkwrite) { wait_on_page_writeback(vmpage); if (set_page_dirty(vmpage)) { @@ -750,7 +756,8 @@ static int vvp_io_fault_start(const struct lu_env *env, /* Do not set Dirty bit here so that in case IO is * started before the page is really made dirty, we - * still have chance to detect it. */ + * still have chance to detect it. + */ result = cl_page_cache_add(env, io, page, CRT_WRITE); LASSERT(cl_page_is_owned(page, io)); @@ -792,7 +799,7 @@ static int vvp_io_fault_start(const struct lu_env *env, out: /* return unlocked vmpage to avoid deadlocking */ - if (vmpage != NULL) + if (vmpage) unlock_page(vmpage); cfio->fault.ft_flags &= ~VM_FAULT_LOCKED; return result; @@ -803,7 +810,8 @@ static int vvp_io_fsync_start(const struct lu_env *env, { /* we should mark TOWRITE bit to each dirty page in radix tree to * verify pages have been written, but this is difficult because of - * race. */ + * race. + */ return 0; } @@ -1003,7 +1011,7 @@ static int vvp_io_commit_write(const struct lu_env *env, * * (3) IO is batched up to the RPC size and is async until the * client max cache is hit - * (/proc/fs/lustre/osc/OSC.../max_dirty_mb) + * (/sys/fs/lustre/osc/OSC.../max_dirty_mb) * */ if (!PageDirty(vmpage)) { @@ -1153,7 +1161,8 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, count = io->u.ci_rw.crw_count; /* "If nbyte is 0, read() will return 0 and have no other - * results." -- Single Unix Spec */ + * results." -- Single Unix Spec + */ if (count == 0) result = 1; else @@ -1173,20 +1182,23 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, /* ignore layout change for generic CIT_MISC but not for glimpse. * io context for glimpse must set ci_verify_layout to true, - * see cl_glimpse_size0() for details. */ + * see cl_glimpse_size0() for details. + */ if (io->ci_type == CIT_MISC && !io->ci_verify_layout) io->ci_ignore_layout = 1; /* Enqueue layout lock and get layout version. We need to do this * even for operations requiring to open file, such as read and write, - * because it might not grant layout lock in IT_OPEN. */ + * because it might not grant layout lock in IT_OPEN. + */ if (result == 0 && !io->ci_ignore_layout) { result = ll_layout_refresh(inode, &cio->cui_layout_gen); if (result == -ENOENT) /* If the inode on MDS has been removed, but the objects * on OSTs haven't been destroyed (async unlink), layout * fetch will return -ENOENT, we'd ignore this error - * and continue with dirty flush. LU-3230. */ + * and continue with dirty flush. LU-3230. + */ result = 0; if (result < 0) CERROR("%s: refresh file layout " DFID " error %d.\n", diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index c82714e..03c887d 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -137,7 +137,8 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, * page may be stale due to layout change, and the process * will never be notified. * This operation is expensive but mmap processes have to pay - * a price themselves. */ + * a price themselves. + */ unmap_mapping_range(conf->coc_inode->i_mapping, 0, OBD_OBJECT_EOF, 0); @@ -147,7 +148,7 @@ static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, if (conf->coc_opc != OBJECT_CONF_SET) return 0; - if (conf->u.coc_md != NULL && conf->u.coc_md->lsm != NULL) { + if (conf->u.coc_md && conf->u.coc_md->lsm) { CDEBUG(D_VFSTRACE, DFID ": layout version change: %u -> %u\n", PFID(&lli->lli_fid), lli->lli_layout_gen, conf->u.coc_md->lsm->lsm_layout_gen); @@ -186,9 +187,8 @@ struct ccc_object *cl_inode2ccc(struct inode *inode) struct cl_object *obj = lli->lli_clob; struct lu_object *lu; - LASSERT(obj != NULL); lu = lu_object_locate(obj->co_lu.lo_header, &vvp_device_type); - LASSERT(lu != NULL); + LASSERT(lu); return lu2ccc(lu); } diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index a133475..f0b26e3 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -56,7 +56,7 @@ static void vvp_page_fini_common(struct ccc_page *cp) { struct page *vmpage = cp->cpg_page; - LASSERT(vmpage != NULL); + LASSERT(vmpage); page_cache_release(vmpage); } @@ -81,7 +81,7 @@ static int vvp_page_own(const struct lu_env *env, struct ccc_page *vpg = cl2ccc_page(slice); struct page *vmpage = vpg->cpg_page; - LASSERT(vmpage != NULL); + LASSERT(vmpage); if (nonblock) { if (!trylock_page(vmpage)) return -EAGAIN; @@ -105,7 +105,7 @@ static void vvp_page_assume(const struct lu_env *env, { struct page *vmpage = cl2vm_page(slice); - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); wait_on_page_writeback(vmpage); } @@ -116,7 +116,7 @@ static void vvp_page_unassume(const struct lu_env *env, { struct page *vmpage = cl2vm_page(slice); - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); } @@ -125,7 +125,7 @@ static void vvp_page_disown(const struct lu_env *env, { struct page *vmpage = cl2vm_page(slice); - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); unlock_page(cl2vm_page(slice)); @@ -139,7 +139,7 @@ static void vvp_page_discard(const struct lu_env *env, struct address_space *mapping; struct ccc_page *cpg = cl2ccc_page(slice); - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); mapping = vmpage->mapping; @@ -161,7 +161,7 @@ static int vvp_page_unmap(const struct lu_env *env, struct page *vmpage = cl2vm_page(slice); __u64 offset; - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); offset = vmpage->index << PAGE_CACHE_SHIFT; @@ -199,7 +199,7 @@ static void vvp_page_export(const struct lu_env *env, { struct page *vmpage = cl2vm_page(slice); - LASSERT(vmpage != NULL); + LASSERT(vmpage); LASSERT(PageLocked(vmpage)); if (uptodate) SetPageUptodate(vmpage); @@ -232,7 +232,8 @@ static int vvp_page_prep_write(const struct lu_env *env, LASSERT(!PageDirty(vmpage)); /* ll_writepage path is not a sync write, so need to set page writeback - * flag */ + * flag + */ if (!pg->cp_sync_io) set_page_writeback(vmpage); @@ -290,7 +291,7 @@ static void vvp_page_completion_read(const struct lu_env *env, } else cp->cpg_defer_uptodate = 0; - if (page->cp_sync_io == NULL) + if (!page->cp_sync_io) unlock_page(vmpage); } @@ -317,7 +318,7 @@ static void vvp_page_completion_write(const struct lu_env *env, cp->cpg_write_queued = 0; vvp_write_complete(cl2ccc(slice->cpl_obj), cp); - if (pg->cp_sync_io != NULL) { + if (pg->cp_sync_io) { LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); } else { @@ -356,15 +357,15 @@ static int vvp_page_make_ready(const struct lu_env *env, lock_page(vmpage); if (clear_page_dirty_for_io(vmpage)) { LASSERT(pg->cp_state == CPS_CACHED); - /* This actually clears the dirty bit in the radix - * tree. */ + /* This actually clears the dirty bit in the radix tree. */ set_page_writeback(vmpage); vvp_write_pending(cl2ccc(slice->cpl_obj), cl2ccc_page(slice)); CL_PAGE_HEADER(D_PAGE, env, pg, "readied\n"); } else if (pg->cp_state == CPS_PAGEOUT) { /* is it possible for osc_flush_async_page() to already - * make it ready? */ + * make it ready? + */ result = -EALREADY; } else { CL_PAGE_DEBUG(D_ERROR, env, pg, "Unexpecting page state %d.\n", @@ -385,7 +386,7 @@ static int vvp_page_print(const struct lu_env *env, (*printer)(env, cookie, LUSTRE_VVP_NAME "-page@%p(%d:%d:%d) vm@%p ", vp, vp->cpg_defer_uptodate, vp->cpg_ra_used, vp->cpg_write_queued, vmpage); - if (vmpage != NULL) { + if (vmpage) { (*printer)(env, cookie, "%lx %d:%d %lx %lu %slru", (long)vmpage->flags, page_count(vmpage), page_mapcount(vmpage), vmpage->private, diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index fa477e7..c34df37 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -148,7 +148,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, (xattr_type == XATTR_ACL_ACCESS_T || xattr_type == XATTR_ACL_DEFAULT_T)) { rce = rct_search(&sbi->ll_rct, current_pid()); - if (rce == NULL || + if (!rce || (rce->rce_ops != RMT_LSETFACL && rce->rce_ops != RMT_RSETFACL)) return -EOPNOTSUPP; @@ -158,7 +158,6 @@ int ll_setxattr_common(struct inode *inode, const char *name, ee = et_search_del(&sbi->ll_et, current_pid(), ll_inode2fid(inode), xattr_type); - LASSERT(ee != NULL); if (valid & OBD_MD_FLXATTR) { acl = lustre_acl_xattr_merge2ext( (posix_acl_xattr_header *)value, @@ -196,7 +195,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, * Release the posix ACL space. */ kfree(new_value); - if (acl != NULL) + if (acl) lustre_ext_acl_xattr_free(acl); #endif if (rc) { @@ -238,11 +237,12 @@ int ll_setxattr(struct dentry *dentry, const char *name, /* Attributes that are saved via getxattr will always have * the stripe_offset as 0. Instead, the MDS should be - * allowed to pick the starting OST index. b=17846 */ - if (lump != NULL && lump->lmm_stripe_offset == 0) + * allowed to pick the starting OST index. b=17846 + */ + if (lump && lump->lmm_stripe_offset == 0) lump->lmm_stripe_offset = -1; - if (lump != NULL && S_ISREG(inode->i_mode)) { + if (lump && S_ISREG(inode->i_mode)) { int flags = FMODE_WRITE; int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ? sizeof(*lump) : sizeof(struct lov_user_md_v3); @@ -324,7 +324,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, (xattr_type == XATTR_ACL_ACCESS_T || xattr_type == XATTR_ACL_DEFAULT_T)) { rce = rct_search(&sbi->ll_rct, current_pid()); - if (rce == NULL || + if (!rce || (rce->rce_ops != RMT_LSETFACL && rce->rce_ops != RMT_LGETFACL && rce->rce_ops != RMT_RSETFACL && @@ -365,7 +365,7 @@ do_getxattr: goto out_xattr; /* Add "system.posix_acl_access" to the list */ - if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) { + if (lli->lli_posix_acl && valid & OBD_MD_FLXATTRLS) { if (size == 0) { rc += sizeof(XATTR_NAME_ACL_ACCESS); } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) { @@ -481,13 +481,14 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, if (size == 0 && S_ISDIR(inode->i_mode)) { /* XXX directory EA is fix for now, optimize to save - * RPC transfer */ + * RPC transfer + */ rc = sizeof(struct lov_user_md); goto out; } lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) { + if (!lsm) { if (S_ISDIR(inode->i_mode)) { rc = ll_dir_getstripe(inode, &lmm, &lmmsize, &request); @@ -496,7 +497,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, } } else { /* LSM is present already after lookup/getattr call. - * we need to grab layout lock once it is implemented */ + * we need to grab layout lock once it is implemented + */ rc = obd_packmd(ll_i2dtexp(inode), &lmm, lsm); lmmsize = rc; } @@ -509,7 +511,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, /* used to call ll_get_max_mdsize() forward to get * the maximum buffer size, while some apps (such as * rsync 3.0.x) care much about the exact xattr value - * size */ + * size + */ rc = lmmsize; goto out; } @@ -525,7 +528,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, memcpy(lump, lmm, lmmsize); /* do not return layout gen for getxattr otherwise it would * confuse tar --xattr by recognizing layout gen as stripe - * offset when the file is restored. See LU-2809. */ + * offset when the file is restored. See LU-2809. + */ lump->lmm_layout_gen = 0; rc = lmmsize; @@ -559,7 +563,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) if (rc < 0) goto out; - if (buffer != NULL) { + if (buffer) { struct ll_sb_info *sbi = ll_i2sbi(inode); char *xattr_name = buffer; int xlen, rem = rc; @@ -597,12 +601,12 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) const size_t name_len = sizeof("lov") - 1; const size_t total_len = prefix_len + name_len + 1; - if (((rc + total_len) > size) && (buffer != NULL)) { + if (((rc + total_len) > size) && buffer) { ptlrpc_req_finished(request); return -ERANGE; } - if (buffer != NULL) { + if (buffer) { buffer += rc; memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len); memcpy(buffer + prefix_len, "lov", name_len); diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index d140276..460b7c5 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -23,7 +23,8 @@ */ struct ll_xattr_entry { struct list_head xe_list; /* protected with - * lli_xattrs_list_rwsem */ + * lli_xattrs_list_rwsem + */ char *xe_name; /* xattr name, \0-terminated */ char *xe_value; /* xattr value */ unsigned xe_namelen; /* strlen(xe_name) + 1 */ @@ -59,9 +60,6 @@ void ll_xattr_fini(void) */ static void ll_xattr_cache_init(struct ll_inode_info *lli) { - - LASSERT(lli != NULL); - INIT_LIST_HEAD(&lli->lli_xattrs); lli->lli_flags |= LLIF_XATTR_CACHE; } @@ -83,8 +81,7 @@ static int ll_xattr_cache_find(struct list_head *cache, list_for_each_entry(entry, cache, xe_list) { /* xattr_name == NULL means look for any entry */ - if (xattr_name == NULL || - strcmp(xattr_name, entry->xe_name) == 0) { + if (!xattr_name || strcmp(xattr_name, entry->xe_name) == 0) { *xattr = entry; CDEBUG(D_CACHE, "find: [%s]=%.*s\n", entry->xe_name, entry->xe_vallen, @@ -118,7 +115,7 @@ static int ll_xattr_cache_add(struct list_head *cache, } xattr = kmem_cache_alloc(xattr_kmem, GFP_NOFS | __GFP_ZERO); - if (xattr == NULL) { + if (!xattr) { CDEBUG(D_CACHE, "failed to allocate xattr\n"); return -ENOMEM; } @@ -270,7 +267,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, struct lookup_intent *oit, struct ptlrpc_request **req) { - ldlm_mode_t mode; + enum ldlm_mode mode; struct lustre_handle lockh = { 0 }; struct md_op_data *op_data; struct ll_inode_info *lli = ll_i2info(inode); @@ -284,7 +281,8 @@ static int ll_xattr_find_get_lock(struct inode *inode, mutex_lock(&lli->lli_xattrs_enq_lock); /* inode may have been shrunk and recreated, so data is gone, match lock - * only when data exists. */ + * only when data exists. + */ if (ll_xattr_cache_valid(lli)) { /* Try matching first. */ mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, @@ -359,7 +357,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) } /* Matched but no cache? Cancelled on error by a parallel refill. */ - if (unlikely(req == NULL)) { + if (unlikely(!req)) { CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n"); rc = -EIO; goto out_maybe_drop; @@ -376,7 +374,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { CERROR("no MDT BODY in the refill xattr reply\n"); rc = -EPROTO; goto out_destroy; @@ -388,7 +386,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) body->aclsize); xsizes = req_capsule_server_sized_get(&req->rq_pill, &RMF_EAVALS_LENS, body->max_mdsize * sizeof(__u32)); - if (xdata == NULL || xval == NULL || xsizes == NULL) { + if (!xdata || !xval || !xsizes) { CERROR("wrong setxattr reply\n"); rc = -EPROTO; goto out_destroy; @@ -404,7 +402,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) for (i = 0; i < body->max_mdsize; i++) { CDEBUG(D_CACHE, "caching [%s]=%.*s\n", xdata, *xsizes, xval); /* Perform consistency checks: attr names and vals in pill */ - if (memchr(xdata, 0, xtail - xdata) == NULL) { + if (!memchr(xdata, 0, xtail - xdata)) { CERROR("xattr protocol violation (names are broken)\n"); rc = -EPROTO; } else if (xval + *xsizes > xvtail) { diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index ee23592..378691b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -58,7 +58,8 @@ int lmv_fld_lookup(struct lmv_obd *lmv, int rc; /* FIXME: Currently ZFS still use local seq for ROOT unfortunately, and - * this fid_is_local check should be removed once LU-2240 is fixed */ + * this fid_is_local check should be removed once LU-2240 is fixed + */ LASSERTF((fid_seq_in_fldb(fid_seq(fid)) || fid_seq_is_local_file(fid_seq(fid))) && fid_is_sane(fid), DFID" is insane!\n", PFID(fid)); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 66de27f..259b211 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -69,7 +69,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, int rc = 0; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) return -EPROTO; LASSERT((body->valid & OBD_MD_MDS)); @@ -107,14 +107,16 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, op_data->op_fid1 = body->fid1; /* Sent the parent FID to the remote MDT */ - if (parent_fid != NULL) { + if (parent_fid) { /* The parent fid is only for remote open to * check whether the open is from OBF, - * see mdt_cross_open */ + * see mdt_cross_open + */ LASSERT(it->it_op & IT_OPEN); op_data->op_fid2 = *parent_fid; /* Add object FID to op_fid3, in case it needs to check stale - * (M_CHECK_STALE), see mdc_finish_intent_lock */ + * (M_CHECK_STALE), see mdc_finish_intent_lock + */ op_data->op_fid3 = body->fid1; } @@ -173,7 +175,8 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, return PTR_ERR(tgt); /* If it is ready to open the file by FID, do not need - * allocate FID at all, otherwise it will confuse MDT */ + * allocate FID at all, otherwise it will confuse MDT + */ if ((it->it_op & IT_CREAT) && !(it->it_flags & MDS_OPEN_BY_FID)) { /* @@ -204,7 +207,7 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, return rc; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) return -EPROTO; /* * Not cross-ref case, just get out of here. @@ -270,7 +273,7 @@ static int lmv_intent_lookup(struct obd_export *exp, rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it, flags, reqp, cb_blocking, extra_lock_flags); - if (rc < 0 || *reqp == NULL) + if (rc < 0 || !*reqp) return rc; /* @@ -278,7 +281,7 @@ static int lmv_intent_lookup(struct obd_export *exp, * remote inode. Let's check this. */ body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) return -EPROTO; /* Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) @@ -299,7 +302,6 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; int rc; - LASSERT(it != NULL); LASSERT(fid_is_sane(&op_data->op_fid1)); CDEBUG(D_INODE, "INTENT LOCK '%s' for '%*s' on "DFID"\n", diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index eb8e673..041d30f33 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -66,7 +66,7 @@ static inline struct lmv_stripe_md *lmv_get_mea(struct ptlrpc_request *req) struct mdt_body *body; struct lmv_stripe_md *mea; - LASSERT(req != NULL); + LASSERT(req); body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -75,8 +75,6 @@ static inline struct lmv_stripe_md *lmv_get_mea(struct ptlrpc_request *req) mea = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, body->eadatasize); - LASSERT(mea != NULL); - if (mea->mea_count == 0) return NULL; if (mea->mea_magic != MEA_MAGIC_LAST_CHAR && @@ -101,7 +99,7 @@ lmv_get_target(struct lmv_obd *lmv, u32 mds) int i; for (i = 0; i < count; i++) { - if (lmv->tgts[i] == NULL) + if (!lmv->tgts[i]) continue; if (lmv->tgts[i]->ltd_idx == mds) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 733222c..67746c9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -88,7 +88,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, spin_lock(&lmv->lmv_lock); for (i = 0; i < lmv->desc.ld_tgt_count; i++) { tgt = lmv->tgts[i]; - if (tgt == NULL || tgt->ltd_exp == NULL) + if (!tgt || !tgt->ltd_exp) continue; CDEBUG(D_INFO, "Target idx %d is %s conn %#llx\n", i, @@ -104,7 +104,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, } obd = class_exp2obd(tgt->ltd_exp); - if (obd == NULL) { + if (!obd) { rc = -ENOTCONN; goto out_lmv_lock; } @@ -262,7 +262,7 @@ static void lmv_set_timeouts(struct obd_device *obd) for (i = 0; i < lmv->desc.ld_tgt_count; i++) { tgt = lmv->tgts[i]; - if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0) + if (!tgt || !tgt->ltd_exp || tgt->ltd_active == 0) continue; obd_set_info_async(NULL, tgt->ltd_exp, sizeof(KEY_INTERMDS), @@ -302,8 +302,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, return 0; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || - lmv->tgts[i]->ltd_exp == NULL || + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp || lmv->tgts[i]->ltd_active == 0) { CWARN("%s: NULL export for %d\n", obd->obd_name, i); continue; @@ -410,7 +409,7 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) static void lmv_del_target(struct lmv_obd *lmv, int index) { - if (lmv->tgts[index] == NULL) + if (!lmv->tgts[index]) return; kfree(lmv->tgts[index]); @@ -442,7 +441,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, } } - if ((index < lmv->tgts_size) && (lmv->tgts[index] != NULL)) { + if ((index < lmv->tgts_size) && lmv->tgts[index]) { tgt = lmv->tgts[index]; CERROR("%s: UUID %s already assigned at LOV target index %d: rc = %d\n", obd->obd_name, @@ -460,7 +459,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, while (newsize < index + 1) newsize <<= 1; newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); - if (newtgts == NULL) { + if (!newtgts) { lmv_init_unlock(lmv); return -ENOMEM; } @@ -539,11 +538,9 @@ int lmv_check_connect(struct obd_device *obd) CDEBUG(D_CONFIG, "Time to connect %s to %s\n", lmv->cluuid.uuid, obd->obd_name); - LASSERT(lmv->tgts != NULL); - for (i = 0; i < lmv->desc.ld_tgt_count; i++) { tgt = lmv->tgts[i]; - if (tgt == NULL) + if (!tgt) continue; rc = lmv_connect_mdc(obd, tgt); if (rc) @@ -563,7 +560,7 @@ int lmv_check_connect(struct obd_device *obd) int rc2; tgt = lmv->tgts[i]; - if (tgt == NULL) + if (!tgt) continue; tgt->ltd_active = 0; if (tgt->ltd_exp) { @@ -586,9 +583,6 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct obd_device *mdc_obd; int rc; - LASSERT(tgt != NULL); - LASSERT(obd != NULL); - mdc_obd = class_exp2obd(tgt->ltd_exp); if (mdc_obd) { @@ -641,7 +635,7 @@ static int lmv_disconnect(struct obd_export *exp) goto out_local; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp) continue; lmv_disconnect_mdc(obd, lmv->tgts[i]); @@ -685,8 +679,9 @@ repeat_fid2path: goto out_fid2path; /* If remote_gf != NULL, it means just building the - * path on the remote MDT, copy this path segment to gf */ - if (remote_gf != NULL) { + * path on the remote MDT, copy this path segment to gf + */ + if (remote_gf) { struct getinfo_fid2path *ori_gf; char *ptr; @@ -716,7 +711,7 @@ repeat_fid2path: goto out_fid2path; /* sigh, has to go to another MDT to do path building further */ - if (remote_gf == NULL) { + if (!remote_gf) { remote_gf_size = sizeof(*remote_gf) + PATH_MAX; remote_gf = kzalloc(remote_gf_size, GFP_NOFS); if (!remote_gf) { @@ -803,7 +798,8 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, /* unregister request (call from llapi_hsm_copytool_fini) */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { /* best effort: try to clean as much as possible - * (continue on error) */ + * (continue on error) + */ obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, lk, uarg); } @@ -827,7 +823,8 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, /* All or nothing: try to register to all MDS. * In case of failure, unregister from previous MDS, - * except if it because of inactive target. */ + * except if it because of inactive target. + */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, lk, uarg); @@ -847,8 +844,8 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, return rc; } /* else: transient error. - * kuc will register to the missing MDT - * when it is back */ + * kuc will register to the missing MDT when it is back + */ } else { any_set = true; } @@ -901,8 +898,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (index >= count) return -ENODEV; - if (lmv->tgts[index] == NULL || - lmv->tgts[index]->ltd_active == 0) + if (!lmv->tgts[index] || lmv->tgts[index]->ltd_active == 0) return -ENODATA; mdc_obd = class_exp2obd(lmv->tgts[index]->ltd_exp); @@ -936,18 +932,18 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, return -EINVAL; tgt = lmv->tgts[qctl->qc_idx]; - if (tgt == NULL || tgt->ltd_exp == NULL) + if (!tgt || !tgt->ltd_exp) return -EINVAL; } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lmv->tgts[i]; - if (tgt == NULL) + if (!tgt) continue; if (!obd_uuid_equals(&tgt->ltd_uuid, &qctl->obd_uuid)) continue; - if (tgt->ltd_exp == NULL) + if (!tgt->ltd_exp) return -EINVAL; break; @@ -981,8 +977,8 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (icc->icc_mdtindex >= count) return -ENODEV; - if (lmv->tgts[icc->icc_mdtindex] == NULL || - lmv->tgts[icc->icc_mdtindex]->ltd_exp == NULL || + if (!lmv->tgts[icc->icc_mdtindex] || + !lmv->tgts[icc->icc_mdtindex]->ltd_exp || lmv->tgts[icc->icc_mdtindex]->ltd_active == 0) return -ENODEV; rc = obd_iocontrol(cmd, lmv->tgts[icc->icc_mdtindex]->ltd_exp, @@ -990,7 +986,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, break; } case LL_IOC_GET_CONNECT_FLAGS: { - if (lmv->tgts[0] == NULL) + if (!lmv->tgts[0]) return -ENODATA; rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg); break; @@ -1007,10 +1003,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - return PTR_ERR(tgt); + return PTR_ERR(tgt); - if (tgt->ltd_exp == NULL) - return -EINVAL; + if (!tgt->ltd_exp) + return -EINVAL; rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); break; @@ -1035,7 +1031,8 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, /* if the request is about a single fid * or if there is a single MDS, no need to split - * the request. */ + * the request. + */ if (reqcount == 1 || count == 1) { tgt = lmv_find_target(lmv, &hur->hur_user_item[0].hui_fid); @@ -1058,7 +1055,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, hur_user_item[nr]) + hur->hur_request.hr_data_len; req = libcfs_kvzalloc(reqlen, GFP_NOFS); - if (req == NULL) + if (!req) return -ENOMEM; lmv_hsm_req_build(lmv, hur, lmv->tgts[i], req); @@ -1084,7 +1081,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (IS_ERR(tgt2)) return PTR_ERR(tgt2); - if ((tgt1->ltd_exp == NULL) || (tgt2->ltd_exp == NULL)) + if (!tgt1->ltd_exp || !tgt2->ltd_exp) return -EINVAL; /* only files on same MDT can have their layouts swapped */ @@ -1108,11 +1105,11 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, struct obd_device *mdc_obd; int err; - if (lmv->tgts[i] == NULL || - lmv->tgts[i]->ltd_exp == NULL) + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp) continue; /* ll_umount_begin() sets force flag but for lmv, not - * mdc. Let's pass it through */ + * mdc. Let's pass it through + */ mdc_obd = class_exp2obd(lmv->tgts[i]->ltd_exp); mdc_obd->obd_force = obddev->obd_force; err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, @@ -1189,7 +1186,7 @@ static int lmv_placement_policy(struct obd_device *obd, { struct lmv_obd *lmv = &obd->u.lmv; - LASSERT(mds != NULL); + LASSERT(mds); if (lmv->desc.ld_tgt_count == 1) { *mds = 0; @@ -1219,7 +1216,8 @@ static int lmv_placement_policy(struct obd_device *obd, } /* Allocate new fid on target according to operation type and parent - * home mds. */ + * home mds. + */ *mds = op_data->op_mds; return 0; } @@ -1239,7 +1237,7 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, u32 mds) */ mutex_lock(&tgt->ltd_fid_mutex); - if (tgt->ltd_active == 0 || tgt->ltd_exp == NULL) { + if (tgt->ltd_active == 0 || !tgt->ltd_exp) { rc = -ENODEV; goto out; } @@ -1266,8 +1264,8 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, u32 mds = 0; int rc; - LASSERT(op_data != NULL); - LASSERT(fid != NULL); + LASSERT(op_data); + LASSERT(fid); rc = lmv_placement_policy(obd, op_data, &mds); if (rc) { @@ -1305,7 +1303,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS); - if (lmv->tgts == NULL) + if (!lmv->tgts) return -ENOMEM; lmv->tgts_size = 32; @@ -1346,11 +1344,11 @@ static int lmv_cleanup(struct obd_device *obd) struct lmv_obd *lmv = &obd->u.lmv; fld_client_fini(&lmv->lmv_fld); - if (lmv->tgts != NULL) { + if (lmv->tgts) { int i; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL) + if (!lmv->tgts[i]) continue; lmv_del_target(lmv, i); } @@ -1371,7 +1369,8 @@ static int lmv_process_config(struct obd_device *obd, u32 len, void *buf) switch (lcfg->lcfg_command) { case LCFG_ADD_MDC: /* modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDT0000_UUID - * 2:0 3:1 4:lustre-MDT0000-mdc_UUID */ + * 2:0 3:1 4:lustre-MDT0000-mdc_UUID + */ if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid)) { rc = -EINVAL; goto out; @@ -1416,7 +1415,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, return -ENOMEM; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp) continue; rc = obd_statfs(env, lmv->tgts[i]->ltd_exp, temp, @@ -1435,7 +1434,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, * i.e. mount does not need the merged osfs * from all of MDT. * And also clients can be mounted as long as - * MDT0 is in service*/ + * MDT0 is in service + */ if (flags & OBD_STATFS_FOR_MDT0) goto out_free_temp; } else { @@ -1561,7 +1561,7 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) * space of MDT storing inode. */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp) continue; md_null_inode(lmv->tgts[i]->ltd_exp, fid); } @@ -1589,7 +1589,7 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, * space of MDT storing inode. */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp) continue; rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data); if (rc) @@ -1669,7 +1669,7 @@ static int lmv_create(struct obd_export *exp, struct md_op_data *op_data, cap_effective, rdev, request); if (rc == 0) { - if (*request == NULL) + if (!*request) return rc; CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2)); } @@ -1715,7 +1715,6 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, int pmode; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); if (!(body->valid & OBD_MD_MDS)) return 0; @@ -1822,7 +1821,6 @@ lmv_getattr_name(struct obd_export *exp, struct md_op_data *op_data, body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); if (body->valid & OBD_MD_MDS) { struct lu_fid rid = body->fid1; @@ -1856,7 +1854,8 @@ lmv_getattr_name(struct obd_export *exp, struct md_op_data *op_data, NULL) static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, - int op_tgt, ldlm_mode_t mode, int bits, int flag) + int op_tgt, enum ldlm_mode mode, int bits, + int flag) { struct lu_fid *fid = md_op_data_fid(op_data, flag); struct obd_device *obd = exp->exp_obd; @@ -2111,7 +2110,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) while (--nlupgs > 0) { ent = lu_dirent_start(dp); - for (end_dirent = ent; ent != NULL; + for (end_dirent = ent; ent; end_dirent = ent, ent = lu_dirent_next(ent)) ; @@ -2131,7 +2130,8 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) break; /* Enlarge the end entry lde_reclen from 0 to - * first entry of next lu_dirpage. */ + * first entry of next lu_dirpage. + */ LASSERT(le16_to_cpu(end_dirent->lde_reclen) == 0); end_dirent->lde_reclen = cpu_to_le16((char *)(dp->ldp_entries) - @@ -2241,7 +2241,7 @@ retry: return rc; body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) return -EPROTO; /* Not cross-ref case, just get out of here. */ @@ -2269,7 +2269,8 @@ retry: * 4. Then A will resend unlink RPC to MDT0. (retry 2nd times). * * In theory, it might try unlimited time here, but it should - * be very rare case. */ + * be very rare case. + */ op_data->op_fid2 = body->fid1; ptlrpc_req_finished(*request); *request = NULL; @@ -2284,7 +2285,8 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) switch (stage) { case OBD_CLEANUP_EARLY: /* XXX: here should be calling obd_precleanup() down to - * stack. */ + * stack. + */ break; case OBD_CLEANUP_EXPORTS: fld_client_debugfs_fini(&lmv->lmv_fld); @@ -2305,7 +2307,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, int rc = 0; obd = class_exp2obd(exp); - if (obd == NULL) { + if (!obd) { CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; @@ -2326,7 +2328,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, /* * All tgts should be connected when this gets called. */ - if (tgt == NULL || tgt->ltd_exp == NULL) + if (!tgt || !tgt->ltd_exp) continue; if (!obd_get_info(env, tgt->ltd_exp, keylen, key, @@ -2369,7 +2371,7 @@ static int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, int rc = 0; obd = class_exp2obd(exp); - if (obd == NULL) { + if (!obd) { CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n", exp->exp_handle.h_cookie); return -EINVAL; @@ -2382,7 +2384,7 @@ static int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, for (i = 0; i < lmv->desc.ld_tgt_count; i++) { tgt = lmv->tgts[i]; - if (tgt == NULL || tgt->ltd_exp == NULL) + if (!tgt || !tgt->ltd_exp) continue; err = obd_set_info_async(env, tgt->ltd_exp, @@ -2417,9 +2419,9 @@ static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return 0; } - if (*lmmp == NULL) { + if (!*lmmp) { *lmmp = libcfs_kvzalloc(mea_size, GFP_NOFS); - if (*lmmp == NULL) + if (!*lmmp) return -ENOMEM; } @@ -2457,10 +2459,10 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, __u32 magic; mea_size = lmv_get_easize(lmv); - if (lsmp == NULL) + if (!lsmp) return mea_size; - if (*lsmp != NULL && lmm == NULL) { + if (*lsmp && !lmm) { kvfree(*tmea); *lsmp = NULL; return 0; @@ -2469,7 +2471,7 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, LASSERT(mea_size == lmm_size); *tmea = libcfs_kvzalloc(mea_size, GFP_NOFS); - if (*tmea == NULL) + if (!*tmea) return -ENOMEM; if (!lmm) @@ -2499,8 +2501,8 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, } static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - ldlm_cancel_flags_t flags, void *opaque) + ldlm_policy_data_t *policy, enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -2508,10 +2510,10 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, int err; int i; - LASSERT(fid != NULL); + LASSERT(fid); for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL || + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp || lmv->tgts[i]->ltd_active == 0) continue; @@ -2533,14 +2535,16 @@ static int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, return rc; } -static ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, - const struct lu_fid *fid, ldlm_type_t type, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - struct lustre_handle *lockh) +static enum ldlm_mode lmv_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, + enum ldlm_type type, + ldlm_policy_data_t *policy, + enum ldlm_mode mode, + struct lustre_handle *lockh) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - ldlm_mode_t rc; + enum ldlm_mode rc; int i; CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid)); @@ -2552,8 +2556,7 @@ static ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, * one fid was created in. */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - if (lmv->tgts[i] == NULL || - lmv->tgts[i]->ltd_exp == NULL || + if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp || lmv->tgts[i]->ltd_active == 0) continue; @@ -2709,7 +2712,7 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, tgt = lmv->tgts[i]; - if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0) + if (!tgt || !tgt->ltd_exp || tgt->ltd_active == 0) continue; if (!tgt->ltd_active) { CDEBUG(D_HA, "mdt %d is inactive.\n", i); @@ -2744,7 +2747,7 @@ static int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, int err; tgt = lmv->tgts[i]; - if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) { + if (!tgt || !tgt->ltd_exp || !tgt->ltd_active) { CERROR("lmv idx %d inactive\n", i); return -EIO; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 40cf4d9..b39e364 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -138,7 +138,7 @@ static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lmv_obd *lmv; - LASSERT(dev != NULL); + LASSERT(dev); lmv = &dev->u.lmv; seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid); return 0; @@ -171,7 +171,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) { struct lmv_tgt_desc *tgt = v; - if (tgt == NULL) + if (!tgt) return 0; seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_idx, tgt->ltd_uuid.uuid, diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 66a2492..b5fc159 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -651,7 +651,7 @@ static inline struct lov_session *lov_env_session(const struct lu_env *env) struct lov_session *ses; ses = lu_context_key_get(env->le_ses, &lov_session_key); - LASSERT(ses != NULL); + LASSERT(ses); return ses; } @@ -759,7 +759,7 @@ static inline struct lovsub_lock *cl2sub_lock(const struct cl_lock *lock) const struct cl_lock_slice *slice; slice = cl_lock_at(lock, &lovsub_device_type); - LASSERT(slice != NULL); + LASSERT(slice); return cl2lovsub_lock(slice); } @@ -817,7 +817,7 @@ static inline struct lov_thread_info *lov_env_info(const struct lu_env *env) struct lov_thread_info *info; info = lu_context_key_get(&env->le_ctx, &lov_key); - LASSERT(info != NULL); + LASSERT(info); return info; } diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 2c33cbc..ee093e0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -143,7 +143,7 @@ static void *lov_key_init(const struct lu_context *ctx, struct lov_thread_info *info; info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info != NULL) + if (info) INIT_LIST_HEAD(&info->lti_closure.clc_list); else info = ERR_PTR(-ENOMEM); @@ -171,7 +171,7 @@ static void *lov_session_key_init(const struct lu_context *ctx, struct lov_session *info; info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -199,15 +199,15 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, int i; struct lov_device *ld = lu2lov_dev(d); - LASSERT(ld->ld_lov != NULL); - if (ld->ld_target == NULL) + LASSERT(ld->ld_lov); + if (!ld->ld_target) return NULL; lov_foreach_target(ld, i) { struct lovsub_device *lsd; lsd = ld->ld_target[i]; - if (lsd != NULL) { + if (lsd) { cl_stack_fini(env, lovsub2cl_dev(lsd)); ld->ld_target[i] = NULL; } @@ -222,8 +222,8 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, int i; int rc = 0; - LASSERT(d->ld_site != NULL); - if (ld->ld_target == NULL) + LASSERT(d->ld_site); + if (!ld->ld_target) return rc; lov_foreach_target(ld, i) { @@ -232,7 +232,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, struct lov_tgt_desc *desc; desc = ld->ld_lov->lov_tgts[i]; - if (desc == NULL) + if (!desc) continue; cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, @@ -262,7 +262,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, int result; lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO); - if (lr != NULL) { + if (lr) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); result = 0; } else @@ -282,9 +282,9 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) struct lov_device_emerg *em; em = emrg[i]; - if (em != NULL) { + if (em) { LASSERT(em->emrg_page_list.pl_nr == 0); - if (em->emrg_env != NULL) + if (em->emrg_env) cl_env_put(em->emrg_env, &em->emrg_refcheck); kfree(em); } @@ -300,7 +300,7 @@ static struct lu_device *lov_device_free(const struct lu_env *env, cl_device_fini(lu2cl_dev(d)); kfree(ld->ld_target); - if (ld->ld_emrg != NULL) + if (ld->ld_emrg) lov_emerg_free(ld->ld_emrg, nr); kfree(ld); return NULL; @@ -311,7 +311,7 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, { struct lov_device *ld = lu2lov_dev(dev); - if (ld->ld_target[index] != NULL) { + if (ld->ld_target[index]) { cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index])); ld->ld_target[index] = NULL; } @@ -324,13 +324,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) int result; emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS); - if (emerg == NULL) + if (!emerg) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { struct lov_device_emerg *em; em = kzalloc(sizeof(*em), GFP_NOFS); - if (em != NULL) { + if (em) { emerg[i] = em; cl_page_list_init(&em->emrg_page_list); em->emrg_env = cl_env_alloc(&em->emrg_refcheck, @@ -370,7 +370,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) return PTR_ERR(emerg); newd = kcalloc(tgt_size, sz, GFP_NOFS); - if (newd != NULL) { + if (newd) { mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); @@ -379,7 +379,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) dev->ld_target = newd; dev->ld_target_nr = tgt_size; - if (dev->ld_emrg != NULL) + if (dev->ld_emrg) lov_emerg_free(dev->ld_emrg, sub_size); dev->ld_emrg = emerg; mutex_unlock(&dev->ld_mutex); @@ -404,8 +404,6 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, obd_getref(obd); tgt = obd->u.lov.lov_tgts[index]; - LASSERT(tgt != NULL); - LASSERT(tgt->ltd_obd != NULL); if (!tgt->ltd_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); @@ -414,7 +412,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, rc = lov_expand_targets(env, ld); if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) { - LASSERT(dev->ld_site != NULL); + LASSERT(dev->ld_site); cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type, tgt->ltd_obd->obd_lu_dev); @@ -492,7 +490,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, /* setup the LOV OBD */ obd = class_name2obd(lustre_cfg_string(cfg, 0)); - LASSERT(obd != NULL); + LASSERT(obd); rc = lov_setup(obd, cfg); if (rc) { lov_device_free(env, d); diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index b3c9c85..c27b884 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -101,7 +101,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) for (i = 0; i < stripe_count; i++) { loi = kmem_cache_alloc(lov_oinfo_slab, GFP_NOFS | __GFP_ZERO); - if (loi == NULL) + if (!loi) goto err; lsm->lsm_oinfo[i] = loi; } @@ -162,12 +162,13 @@ static int lsm_destroy_plain(struct lov_stripe_md *lsm, struct obdo *oa, } /* Find minimum stripe maxbytes value. For inactive or - * reconnecting targets use LUSTRE_STRIPE_MAXBYTES. */ + * reconnecting targets use LUSTRE_STRIPE_MAXBYTES. + */ static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes) { struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import; - if (imp == NULL || !tgt->ltd_active) { + if (!imp || !tgt->ltd_active) { *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES; return; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index f8e92fe..725ebf9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -43,7 +43,8 @@ /* lov_do_div64(a, b) returns a % b, and a = a / b. * The 32-bit code is LOV-specific due to knowing about stripe limits in * order to reduce the divisor to a 32-bit number. If the divisor is - * already a 32-bit value the compiler handles this directly. */ + * already a 32-bit value the compiler handles this directly. + */ #if BITS_PER_LONG == 64 # define lov_do_div64(n, base) ({ \ uint64_t __base = (base); \ @@ -92,7 +93,8 @@ struct lov_request_set { atomic_t set_refcount; struct obd_export *set_exp; /* XXX: There is @set_exp already, however obd_statfs gets obd_device - only. */ + * only. + */ struct obd_device *set_obd; int set_count; atomic_t set_completes; @@ -114,7 +116,6 @@ void lov_finish_set(struct lov_request_set *set); static inline void lov_get_reqset(struct lov_request_set *set) { - LASSERT(set != NULL); LASSERT(atomic_read(&set->set_refcount) > 0); atomic_inc(&set->set_refcount); } diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 93fe69e..50954ce 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -60,7 +60,7 @@ static inline void lov_sub_exit(struct lov_io_sub *sub) static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub) { - if (sub->sub_io != NULL) { + if (sub->sub_io) { if (sub->sub_io_initialized) { lov_sub_enter(sub); cl_io_fini(sub->sub_env, sub->sub_io); @@ -74,7 +74,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, kfree(sub->sub_io); sub->sub_io = NULL; } - if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) { + if (!IS_ERR_OR_NULL(sub->sub_env)) { if (!sub->sub_borrowed) cl_env_put(sub->sub_env, &sub->sub_refcheck); sub->sub_env = NULL; @@ -143,11 +143,11 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, int stripe = sub->sub_stripe; int result; - LASSERT(sub->sub_io == NULL); - LASSERT(sub->sub_env == NULL); + LASSERT(!sub->sub_io); + LASSERT(!sub->sub_env); LASSERT(sub->sub_stripe < lio->lis_stripe_count); - if (unlikely(lov_r0(lov)->lo_sub[stripe] == NULL)) + if (unlikely(!lov_r0(lov)->lo_sub[stripe])) return -EIO; result = 0; @@ -252,7 +252,6 @@ static int lov_page_stripe(const struct cl_page *page) subobj = lu2lovsub( lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header, &lovsub_device_type)); - LASSERT(subobj != NULL); return subobj->lso_index; } @@ -263,9 +262,9 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, struct cl_page *page = slice->cpl_page; int stripe; - LASSERT(lio->lis_cl.cis_io != NULL); + LASSERT(lio->lis_cl.cis_io); LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object); - LASSERT(lsm != NULL); + LASSERT(lsm); LASSERT(lio->lis_nr_subios > 0); stripe = lov_page_stripe(page); @@ -278,7 +277,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; int result; - LASSERT(lio->lis_object != NULL); + LASSERT(lio->lis_object); /* * Need to be optimized, we can't afford to allocate a piece of memory @@ -288,7 +287,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, libcfs_kvzalloc(lsm->lsm_stripe_count * sizeof(lio->lis_subs[0]), GFP_NOFS); - if (lio->lis_subs != NULL) { + if (lio->lis_subs) { lio->lis_nr_subios = lio->lis_stripe_count; lio->lis_single_subio_index = -1; lio->lis_active_subios = 0; @@ -304,7 +303,6 @@ static void lov_io_slice_init(struct lov_io *lio, io->ci_result = 0; lio->lis_object = obj; - LASSERT(obj->lo_lsm != NULL); lio->lis_stripe_count = obj->lo_lsm->lsm_stripe_count; switch (io->ci_type) { @@ -358,7 +356,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) struct lov_object *lov = cl2lov(ios->cis_obj); int i; - if (lio->lis_subs != NULL) { + if (lio->lis_subs) { for (i = 0; i < lio->lis_nr_subios; i++) lov_io_sub_fini(env, lio, &lio->lis_subs[i]); kvfree(lio->lis_subs); @@ -395,7 +393,7 @@ static int lov_io_iter_init(const struct lu_env *env, endpos, &start, &end)) continue; - if (unlikely(lov_r0(lio->lis_object)->lo_sub[stripe] == NULL)) { + if (unlikely(!lov_r0(lio->lis_object)->lo_sub[stripe])) { if (ios->cis_io->ci_type == CIT_READ || ios->cis_io->ci_type == CIT_WRITE || ios->cis_io->ci_type == CIT_FAULT) @@ -601,13 +599,13 @@ static int lov_io_submit(const struct lu_env *env, return rc; } - LASSERT(lio->lis_subs != NULL); + LASSERT(lio->lis_subs); if (alloc) { stripes_qin = libcfs_kvzalloc(sizeof(*stripes_qin) * lio->lis_nr_subios, GFP_NOFS); - if (stripes_qin == NULL) + if (!stripes_qin) return -ENOMEM; for (stripe = 0; stripe < lio->lis_nr_subios; stripe++) @@ -955,7 +953,7 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, struct lov_io *lio = lov_env_io(env); int result; - LASSERT(lov->lo_lsm != NULL); + LASSERT(lov->lo_lsm); lio->lis_object = lov; switch (io->ci_type) { diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index d866791..e0a6438 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -115,7 +115,7 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck, /* * check that sub-lock doesn't have lock link to this top-lock. */ - LASSERT(lov_lock_link_find(env, lck, lsl) == NULL); + LASSERT(!lov_lock_link_find(env, lck, lsl)); LASSERT(idx < lck->lls_nr); lck->lls_sub[idx].sub_lock = lsl; @@ -145,7 +145,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, LASSERT(idx < lck->lls_nr); link = kmem_cache_alloc(lov_lock_link_kmem, GFP_NOFS | __GFP_ZERO); - if (link != NULL) { + if (link) { struct lov_sublock_env *subenv; struct lov_lock_sub *lls; struct cl_lock_descr *descr; @@ -160,7 +160,8 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, * to remember the subio. This is because lock is able * to be cached, but this is not true for IO. This * further means a sublock might be referenced in - * different io context. -jay */ + * different io context. -jay + */ sublock = cl_lock_hold(subenv->lse_env, subenv->lse_io, descr, "lov-parent", parent); @@ -220,7 +221,7 @@ static int lov_sublock_lock(const struct lu_env *env, LASSERT(!(lls->sub_flags & LSF_HELD)); link = lov_lock_link_find(env, lck, sublock); - LASSERT(link != NULL); + LASSERT(link); lov_lock_unlink(env, link, sublock); lov_sublock_unlock(env, sublock, closure, NULL); lck->lls_cancel_race = 1; @@ -309,14 +310,14 @@ static int lov_lock_sub_init(const struct lu_env *env, * XXX for wide striping smarter algorithm is desirable, * breaking out of the loop, early. */ - if (likely(r0->lo_sub[i] != NULL) && + if (likely(r0->lo_sub[i]) && lov_stripe_intersects(loo->lo_lsm, i, file_start, file_end, &start, &end)) nr++; } LASSERT(nr > 0); lck->lls_sub = libcfs_kvzalloc(nr * sizeof(lck->lls_sub[0]), GFP_NOFS); - if (lck->lls_sub == NULL) + if (!lck->lls_sub) return -ENOMEM; lck->lls_nr = nr; @@ -328,14 +329,14 @@ static int lov_lock_sub_init(const struct lu_env *env, * top-lock. */ for (i = 0, nr = 0; i < r0->lo_nr; ++i) { - if (likely(r0->lo_sub[i] != NULL) && + if (likely(r0->lo_sub[i]) && lov_stripe_intersects(loo->lo_lsm, i, file_start, file_end, &start, &end)) { struct cl_lock_descr *descr; descr = &lck->lls_sub[nr].sub_descr; - LASSERT(descr->cld_obj == NULL); + LASSERT(!descr->cld_obj); descr->cld_obj = lovsub2cl(r0->lo_sub[i]); descr->cld_start = cl_index(descr->cld_obj, start); descr->cld_end = cl_index(descr->cld_obj, end); @@ -369,7 +370,6 @@ static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, struct cl_lock *sublock; int dying; - LASSERT(lck->lls_sub[i].sub_lock != NULL); sublock = lck->lls_sub[i].sub_lock->lss_cl.cls_lock; LASSERT(cl_lock_is_mutexed(sublock)); @@ -413,7 +413,6 @@ static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, if (!(lck->lls_sub[i].sub_flags & LSF_HELD)) { struct cl_lock *sublock; - LASSERT(lck->lls_sub[i].sub_lock != NULL); sublock = lck->lls_sub[i].sub_lock->lss_cl.cls_lock; LASSERT(cl_lock_is_mutexed(sublock)); LASSERT(sublock->cll_state != CLS_FREEING); @@ -435,13 +434,13 @@ static void lov_lock_fini(const struct lu_env *env, lck = cl2lov_lock(slice); LASSERT(lck->lls_nr_filled == 0); - if (lck->lls_sub != NULL) { + if (lck->lls_sub) { for (i = 0; i < lck->lls_nr; ++i) /* * No sub-locks exists at this point, as sub-lock has * a reference on its parent. */ - LASSERT(lck->lls_sub[i].sub_lock == NULL); + LASSERT(!lck->lls_sub[i].sub_lock); kvfree(lck->lls_sub); } kmem_cache_free(lov_lock_kmem, lck); @@ -479,7 +478,8 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, result = cl_enqueue_try(env, sublock, io, enqflags); if ((sublock->cll_state == CLS_ENQUEUED) && !(enqflags & CEF_AGL)) { /* if it is enqueued, try to `wait' on it---maybe it's already - * granted */ + * granted + */ result = cl_wait_try(env, sublock); if (result == CLO_REENQUEUED) result = CLO_WAIT; @@ -515,12 +515,13 @@ static int lov_sublock_fill(const struct lu_env *env, struct cl_lock *parent, if (!IS_ERR(sublock)) { cl_lock_get_trust(sublock); if (parent->cll_state == CLS_QUEUING && - lck->lls_sub[idx].sub_lock == NULL) { + !lck->lls_sub[idx].sub_lock) { lov_sublock_adopt(env, lck, sublock, idx, link); } else { kmem_cache_free(lov_lock_link_kmem, link); /* other thread allocated sub-lock, or enqueue is no - * longer going on */ + * longer going on + */ cl_lock_mutex_put(env, parent); cl_lock_unhold(env, sublock, "lov-parent", parent); cl_lock_mutex_get(env, parent); @@ -574,10 +575,11 @@ static int lov_lock_enqueue(const struct lu_env *env, * Sub-lock might have been canceled, while top-lock was * cached. */ - if (sub == NULL) { + if (!sub) { result = lov_sublock_fill(env, lock, io, lck, i); /* lov_sublock_fill() released @lock mutex, - * restart. */ + * restart. + */ break; } sublock = sub->lss_cl.cls_lock; @@ -605,7 +607,8 @@ static int lov_lock_enqueue(const struct lu_env *env, /* take recursive mutex of sublock */ cl_lock_mutex_get(env, sublock); /* need to release all locks in closure - * otherwise it may deadlock. LU-2683.*/ + * otherwise it may deadlock. LU-2683. + */ lov_sublock_unlock(env, sub, closure, subenv); /* sublock and parent are held. */ @@ -620,7 +623,7 @@ static int lov_lock_enqueue(const struct lu_env *env, break; } } else { - LASSERT(sublock->cll_conflict == NULL); + LASSERT(!sublock->cll_conflict); lov_sublock_unlock(env, sub, closure, subenv); } } @@ -649,11 +652,12 @@ static int lov_lock_unuse(const struct lu_env *env, /* top-lock state cannot change concurrently, because single * thread (one that released the last hold) carries unlocking - * to the completion. */ + * to the completion. + */ LASSERT(slice->cls_lock->cll_state == CLS_INTRANSIT); lls = &lck->lls_sub[i]; sub = lls->sub_lock; - if (sub == NULL) + if (!sub) continue; sublock = sub->lss_cl.cls_lock; @@ -695,10 +699,11 @@ static void lov_lock_cancel(const struct lu_env *env, /* top-lock state cannot change concurrently, because single * thread (one that released the last hold) carries unlocking - * to the completion. */ + * to the completion. + */ lls = &lck->lls_sub[i]; sub = lls->sub_lock; - if (sub == NULL) + if (!sub) continue; sublock = sub->lss_cl.cls_lock; @@ -757,7 +762,6 @@ again: lls = &lck->lls_sub[i]; sub = lls->sub_lock; - LASSERT(sub != NULL); sublock = sub->lss_cl.cls_lock; rc = lov_sublock_lock(env, lck, lls, closure, &subenv); if (rc == 0) { @@ -776,8 +780,9 @@ again: if (result != 0) break; } - /* Each sublock only can be reenqueued once, so will not loop for - * ever. */ + /* Each sublock only can be reenqueued once, so will not loop + * forever. + */ if (result == 0 && reenqueued != 0) goto again; cl_lock_closure_fini(closure); @@ -805,7 +810,7 @@ static int lov_lock_use(const struct lu_env *env, lls = &lck->lls_sub[i]; sub = lls->sub_lock; - if (sub == NULL) { + if (!sub) { /* * Sub-lock might have been canceled, while top-lock was * cached. @@ -826,7 +831,8 @@ static int lov_lock_use(const struct lu_env *env, i, 1, rc); } else if (sublock->cll_state == CLS_NEW) { /* Sub-lock might have been canceled, while - * top-lock was cached. */ + * top-lock was cached. + */ result = -ESTALE; lov_sublock_release(env, lck, i, 1, result); } @@ -852,45 +858,6 @@ static int lov_lock_use(const struct lu_env *env, return result; } -#if 0 -static int lock_lock_multi_match() -{ - struct cl_lock *lock = slice->cls_lock; - struct cl_lock_descr *subneed = &lov_env_info(env)->lti_ldescr; - struct lov_object *loo = cl2lov(lov->lls_cl.cls_obj); - struct lov_layout_raid0 *r0 = lov_r0(loo); - struct lov_lock_sub *sub; - struct cl_object *subobj; - u64 fstart; - u64 fend; - u64 start; - u64 end; - int i; - - fstart = cl_offset(need->cld_obj, need->cld_start); - fend = cl_offset(need->cld_obj, need->cld_end + 1) - 1; - subneed->cld_mode = need->cld_mode; - cl_lock_mutex_get(env, lock); - for (i = 0; i < lov->lls_nr; ++i) { - sub = &lov->lls_sub[i]; - if (sub->sub_lock == NULL) - continue; - subobj = sub->sub_descr.cld_obj; - if (!lov_stripe_intersects(loo->lo_lsm, sub->sub_stripe, - fstart, fend, &start, &end)) - continue; - subneed->cld_start = cl_index(subobj, start); - subneed->cld_end = cl_index(subobj, end); - subneed->cld_obj = subobj; - if (!cl_lock_ext_match(&sub->sub_got, subneed)) { - result = 0; - break; - } - } - cl_lock_mutex_put(env, lock); -} -#endif - /** * Check if the extent region \a descr is covered by \a child against the * specific \a stripe. @@ -922,10 +889,10 @@ static int lov_lock_stripe_is_matching(const struct lu_env *env, idx = lov_stripe_number(lsm, start); if (idx == stripe || - unlikely(lov_r0(lov)->lo_sub[idx] == NULL)) { + unlikely(!lov_r0(lov)->lo_sub[idx])) { idx = lov_stripe_number(lsm, end); if (idx == stripe || - unlikely(lov_r0(lov)->lo_sub[idx] == NULL)) + unlikely(!lov_r0(lov)->lo_sub[idx])) result = 1; } } @@ -970,7 +937,8 @@ static int lov_lock_fits_into(const struct lu_env *env, LASSERT(lov->lls_nr > 0); /* for top lock, it's necessary to match enq flags otherwise it will - * run into problem if a sublock is missing and reenqueue. */ + * run into problem if a sublock is missing and reenqueue. + */ if (need->cld_enq_flags != lov->lls_orig.cld_enq_flags) return 0; @@ -1074,7 +1042,7 @@ static void lov_lock_delete(const struct lu_env *env, struct lov_lock_sub *lls = &lck->lls_sub[i]; struct lovsub_lock *lsl = lls->sub_lock; - if (lsl == NULL) /* already removed */ + if (!lsl) /* already removed */ continue; rc = lov_sublock_lock(env, lck, lls, closure, NULL); @@ -1090,9 +1058,9 @@ static void lov_lock_delete(const struct lu_env *env, lov_sublock_release(env, lck, i, 1, 0); link = lov_lock_link_find(env, lck, lsl); - LASSERT(link != NULL); + LASSERT(link); lov_lock_unlink(env, link, lsl); - LASSERT(lck->lls_sub[i].sub_lock == NULL); + LASSERT(!lck->lls_sub[i].sub_lock); lov_sublock_unlock(env, lsl, closure, NULL); } @@ -1112,7 +1080,7 @@ static int lov_lock_print(const struct lu_env *env, void *cookie, sub = &lck->lls_sub[i]; (*p)(env, cookie, " %d %x: ", i, sub->sub_flags); - if (sub->sub_lock != NULL) + if (sub->sub_lock) cl_lock_print(env, cookie, p, sub->sub_lock->lss_cl.cls_lock); else @@ -1140,7 +1108,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, int result; lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (lck != NULL) { + if (lck) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); result = lov_lock_sub_init(env, lck, io); } else @@ -1176,7 +1144,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, int result = -ENOMEM; lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (lck != NULL) { + if (lck) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); lck->lls_orig = lock->cll_descr; result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index 97115be..029cd4d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -129,7 +129,8 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, "stripe %d KMS %sing %llu->%llu\n", stripe, kms > loi->loi_kms ? "increase":"shrink", loi->loi_kms, kms); - loi_kms_set(loi, loi->loi_lvb.lvb_size = kms); + loi->loi_lvb.lvb_size = kms; + loi_kms_set(loi, loi->loi_lvb.lvb_size); } return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 65077b7..7ba670a 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -61,7 +61,8 @@ #include "lov_internal.h" /* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion. - Any function that expects lov_tgts to remain stationary must take a ref. */ + * Any function that expects lov_tgts to remain stationary must take a ref. + */ static void lov_getref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -96,7 +97,8 @@ static void lov_putref(struct obd_device *obd) list_add(&tgt->ltd_kill, &kill); /* XXX - right now there is a dependency on ld_tgt_count * being the maximum tgt index for computing the - * mds_max_easize. So we can't shrink it. */ + * mds_max_easize. So we can't shrink it. + */ lov_ost_pool_remove(&lov->lov_packed, i); lov->lov_tgts[i] = NULL; lov->lov_death_row--; @@ -158,7 +160,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (activate) { tgt_obd->obd_no_recov = 0; /* FIXME this is probably supposed to be - ptlrpc_set_import_active. Horrible naming. */ + * ptlrpc_set_import_active. Horrible naming. + */ ptlrpc_activate_import(imp); } @@ -315,7 +318,8 @@ static int lov_disconnect(struct obd_export *exp) } /* Let's hold another reference so lov_del_obd doesn't spin through - putref every time */ + * putref every time + */ obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { @@ -358,7 +362,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, * LU-642, initially inactive OSC could miss the obd_connect, * we make up for it here. */ - if (ev == OBD_NOTIFY_ACTIVATE && tgt->ltd_exp == NULL && + if (ev == OBD_NOTIFY_ACTIVATE && !tgt->ltd_exp && obd_uuid_equals(uuid, &tgt->ltd_uuid)) { struct obd_uuid lov_osc_uuid = {"LOV_OSC_UUID"}; @@ -399,10 +403,9 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, CDEBUG(D_INFO, "OSC %s already %sactive!\n", uuid->uuid, active ? "" : "in"); goto out; - } else { - CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n", - obd_uuid2str(uuid), active ? "" : "in"); } + CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n", + obd_uuid2str(uuid), active ? "" : "in"); lov->lov_tgts[index]->ltd_active = active; if (active) { @@ -481,7 +484,8 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, continue; /* don't send sync event if target not - * connected/activated */ + * connected/activated + */ if (is_sync && !lov->lov_tgts[i]->ltd_active) continue; @@ -521,12 +525,12 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, tgt_obd = class_find_client_obd(uuidp, LUSTRE_OSC_NAME, &obd->obd_uuid); - if (tgt_obd == NULL) + if (!tgt_obd) return -EINVAL; mutex_lock(&lov->lov_lock); - if ((index < lov->lov_tgt_size) && (lov->lov_tgts[index] != NULL)) { + if ((index < lov->lov_tgt_size) && lov->lov_tgts[index]) { tgt = lov->lov_tgts[index]; CERROR("UUID %s already assigned at LOV target index %d\n", obd_uuid2str(&tgt->ltd_uuid), index); @@ -543,7 +547,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, while (newsize < index + 1) newsize <<= 1; newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS); - if (newtgts == NULL) { + if (!newtgts) { mutex_unlock(&lov->lov_lock); return -ENOMEM; } @@ -596,8 +600,9 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, if (lov->lov_connects == 0) { /* lov_connect hasn't been called yet. We'll do the - lov_connect_obd on this target when that fn first runs, - because we don't know the connect flags yet. */ + * lov_connect_obd on this target when that fn first runs, + * because we don't know the connect flags yet. + */ return 0; } @@ -613,7 +618,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, goto out; } - if (lov->lov_cache != NULL) { + if (lov->lov_cache) { rc = obd_set_info_async(NULL, tgt->ltd_exp, sizeof(KEY_CACHE_SET), KEY_CACHE_SET, sizeof(struct cl_client_cache), lov->lov_cache, @@ -702,8 +707,9 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) kfree(tgt); /* Manual cleanup - no cleanup logs to clean up the osc's. We must - do it ourselves. And we can't do it from lov_cleanup, - because we just lost our only reference to it. */ + * do it ourselves. And we can't do it from lov_cleanup, + * because we just lost our only reference to it. + */ if (osc_obd) class_manual_cleanup(osc_obd); } @@ -773,9 +779,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (desc->ld_magic != LOV_DESC_MAGIC) { if (desc->ld_magic == __swab32(LOV_DESC_MAGIC)) { - CDEBUG(D_OTHER, "%s: Swabbing lov desc %p\n", - obd->obd_name, desc); - lustre_swab_lov_desc(desc); + CDEBUG(D_OTHER, "%s: Swabbing lov desc %p\n", + obd->obd_name, desc); + lustre_swab_lov_desc(desc); } else { CERROR("%s: Bad lov desc magic: %#x\n", obd->obd_name, desc->ld_magic); @@ -859,7 +865,8 @@ static int lov_cleanup(struct obd_device *obd) /* free pool structs */ CDEBUG(D_INFO, "delete pool %p\n", pool); /* In the function below, .hs_keycmp resolves to - * pool_hashkey_keycmp() */ + * pool_hashkey_keycmp() + */ /* coverity[overrun-buffer-val] */ lov_pool_del(obd, pool->pool_name); } @@ -879,8 +886,9 @@ static int lov_cleanup(struct obd_device *obd) if (lov->lov_tgts[i]->ltd_active || atomic_read(&lov->lov_refcount)) /* We should never get here - these - should have been removed in the - disconnect. */ + * should have been removed in the + * disconnect. + */ CERROR("lov tgt %d not cleaned! deathrow=%d, lovrc=%d\n", i, lov->lov_death_row, atomic_read(&lov->lov_refcount)); @@ -981,7 +989,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, ost_idx = src_oa->o_nlink; lsm = *ea; - if (lsm == NULL) { + if (!lsm) { rc = -EINVAL; goto out; } @@ -1025,8 +1033,8 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, struct lov_obd *lov; int rc = 0; - LASSERT(ea != NULL); - if (exp == NULL) + LASSERT(ea); + if (!exp) return -EINVAL; if ((src_oa->o_valid & OBD_MD_FLFLAGS) && @@ -1043,7 +1051,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, /* Recreate a specific object id at the given OST index */ if ((src_oa->o_valid & OBD_MD_FLFLAGS) && (src_oa->o_flags & OBD_FL_RECREATE_OBJS)) { - rc = lov_recreate(exp, src_oa, ea, oti); + rc = lov_recreate(exp, src_oa, ea, oti); } obd_putref(exp->exp_obd); @@ -1052,7 +1060,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, #define ASSERT_LSM_MAGIC(lsmp) \ do { \ - LASSERT((lsmp) != NULL); \ + LASSERT((lsmp)); \ LASSERTF(((lsmp)->lsm_magic == LOV_MAGIC_V1 || \ (lsmp)->lsm_magic == LOV_MAGIC_V3), \ "%p->lsm_magic=%x\n", (lsmp), (lsmp)->lsm_magic); \ @@ -1065,7 +1073,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, struct lov_request_set *set; struct obd_info oinfo; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0, err = 0; @@ -1085,9 +1092,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, if (rc) goto out; - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1105,10 +1110,9 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, } } - if (rc == 0) { - LASSERT(lsm_op_find(lsm->lsm_magic) != NULL); + if (rc == 0) rc = lsm_op_find(lsm->lsm_magic)->lsm_destroy(lsm, oa, md_exp); - } + err = lov_fini_destroy_set(set); out: obd_putref(exp->exp_obd); @@ -1133,7 +1137,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *lovset; struct lov_obd *lov; - struct list_head *pos; struct lov_request *req; int rc = 0, err; @@ -1153,9 +1156,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each(pos, &lovset->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &lovset->set_list, rq_link) { CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n", POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx); @@ -1174,7 +1175,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, if (!list_empty(&rqset->set_requests)) { LASSERT(rc == 0); - LASSERT(rqset->set_interpret == NULL); + LASSERT(!rqset->set_interpret); rqset->set_interpret = lov_getattr_interpret; rqset->set_arg = (void *)lovset; return rc; @@ -1199,14 +1200,14 @@ static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, } /* If @oti is given, the request goes from MDS and responses from OSTs are not - needed. Otherwise, a client is waiting for responses. */ + * needed. Otherwise, a client is waiting for responses. + */ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, struct obd_trans_info *oti, struct ptlrpc_request_set *rqset) { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0; @@ -1230,9 +1231,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1262,7 +1261,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, return rc ? rc : err; } - LASSERT(rqset->set_interpret == NULL); + LASSERT(!rqset->set_interpret); rqset->set_interpret = lov_setattr_interpret; rqset->set_arg = (void *)set; @@ -1272,7 +1271,8 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, /* find any ldlm lock of the inode in lov * return 0 not find * 1 find one - * < 0 error */ + * < 0 error + */ static int lov_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, ldlm_iterator_t it, void *data) @@ -1326,20 +1326,17 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, struct obd_device *obd = class_exp2obd(exp); struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0; - LASSERT(oinfo != NULL); - LASSERT(oinfo->oi_osfs != NULL); + LASSERT(oinfo->oi_osfs); lov = &obd->u.lov; rc = lov_prep_statfs_set(obd, oinfo, &set); if (rc) return rc; - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + list_for_each_entry(req, &set->set_list, rq_link) { rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, max_age, rqset); if (rc) @@ -1355,7 +1352,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, return rc ? rc : err; } - LASSERT(rqset->set_interpret == NULL); + LASSERT(!rqset->set_interpret); rqset->set_interpret = lov_statfs_interpret; rqset->set_arg = (void *)set; return 0; @@ -1369,9 +1366,10 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, int rc = 0; /* for obdclass we forbid using obd_statfs_rqset, but prefer using async - * statfs requests */ + * statfs requests + */ set = ptlrpc_prep_set(); - if (set == NULL) + if (!set) return -ENOMEM; oinfo.oi_osfs = osfs; @@ -1503,7 +1501,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, &qctl->obd_uuid)) continue; - if (tgt->ltd_exp == NULL) + if (!tgt->ltd_exp) return -EINVAL; break; @@ -1545,14 +1543,15 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, continue; /* ll_umount_begin() sets force flag but for lov, not - * osc. Let's pass it through */ + * osc. Let's pass it through + */ osc_obd = class_exp2obd(lov->lov_tgts[i]->ltd_exp); osc_obd->obd_force = obddev->obd_force; err = obd_iocontrol(cmd, lov->lov_tgts[i]->ltd_exp, len, karg, uarg); - if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) { + if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) return err; - } else if (err) { + if (err) { if (lov->lov_tgts[i]->ltd_active) { CDEBUG(err == -ENOTTY ? D_IOCTL : D_WARNING, @@ -1622,7 +1621,8 @@ static u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, return -EINVAL; /* If we have finished mapping on previous device, shift logical - * offset to start of next device */ + * offset to start of next device + */ if ((lov_stripe_intersects(lsm, stripe_no, fm_start, fm_end, &lun_start, &lun_end)) != 0 && local_end < lun_end) { @@ -1630,7 +1630,8 @@ static u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, *start_stripe = stripe_no; } else { /* This is a special value to indicate that caller should - * calculate offset in next stripe. */ + * calculate offset in next stripe. + */ fm_end_offset = 0; *start_stripe = (stripe_no + 1) % lsm->lsm_stripe_count; } @@ -1741,7 +1742,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, buffer_size = fiemap_count_to_size(fm_key->fiemap.fm_extent_count); fm_local = libcfs_kvzalloc(buffer_size, GFP_NOFS); - if (fm_local == NULL) { + if (!fm_local) { rc = -ENOMEM; goto out; } @@ -1798,7 +1799,8 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, /* If this is a continuation FIEMAP call and we are on * starting stripe then lun_start needs to be set to - * fm_end_offset */ + * fm_end_offset + */ if (fm_end_offset != 0 && cur_stripe == start_stripe) lun_start = fm_end_offset; @@ -1820,7 +1822,8 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, len_mapped_single_call = 0; /* If the output buffer is very large and the objects have many - * extents we may need to loop on a single OST repeatedly */ + * extents we may need to loop on a single OST repeatedly + */ ost_eof = 0; ost_done = 0; do { @@ -1876,7 +1879,8 @@ inactive_tgt: if (ext_count == 0) { ost_done = 1; /* If last stripe has hole at the end, - * then we need to return */ + * then we need to return + */ if (cur_stripe_wrap == last_stripe) { fiemap->fm_mapped_extents = 0; goto finish; @@ -1898,7 +1902,8 @@ inactive_tgt: ost_done = 1; /* Clear the EXTENT_LAST flag which can be present on - * last extent */ + * last extent + */ if (lcl_fm_ext[ext_count-1].fe_flags & FIEMAP_EXTENT_LAST) lcl_fm_ext[ext_count - 1].fe_flags &= ~FIEMAP_EXTENT_LAST; @@ -1927,7 +1932,8 @@ inactive_tgt: finish: /* Indicate that we are returning device offsets unless file just has - * single stripe */ + * single stripe + */ if (lsm->lsm_stripe_count > 1) fiemap->fm_flags |= FIEMAP_FLAG_DEVICE_ORDER; @@ -1935,7 +1941,8 @@ finish: goto skip_last_device_calc; /* Check if we have reached the last stripe and whether mapping for that - * stripe is done. */ + * stripe is done. + */ if (cur_stripe_wrap == last_stripe) { if (ost_done || ost_eof) fiemap->fm_extents[current_extent - 1].fe_flags |= @@ -1980,10 +1987,12 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, /* XXX This is another one of those bits that will need to * change if we ever actually support nested LOVs. It uses - * the lock's export to find out which stripe it is. */ + * the lock's export to find out which stripe it is. + */ /* XXX - it's assumed all the locks for deleted OSTs have * been cancelled. Also, the export for deleted OSTs will - * be NULL and won't match the lock's export. */ + * be NULL and won't match the lock's export. + */ for (i = 0; i < lsm->lsm_stripe_count; i++) { loi = lsm->lsm_oinfo[i]; if (lov_oinfo_is_dummy(loi)) @@ -2072,7 +2081,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, unsigned next_id = 0, mds_con = 0; incr = check_uuid = do_inactive = no_set = 0; - if (set == NULL) { + if (!set) { no_set = 1; set = ptlrpc_prep_set(); if (!set) @@ -2095,7 +2104,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, } else if (KEY_IS(KEY_MDS_CONN)) { mds_con = 1; } else if (KEY_IS(KEY_CACHE_SET)) { - LASSERT(lov->lov_cache == NULL); + LASSERT(!lov->lov_cache); lov->lov_cache = val; do_inactive = 1; } @@ -2319,7 +2328,8 @@ static int __init lov_init(void) /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data - * symbols from modules.*/ + * symbols from modules. + */ CDEBUG(D_INFO, "Lustre LOV module (%p).\n", &lov_caches); rc = lu_kmem_init(lov_caches); @@ -2329,7 +2339,7 @@ static int __init lov_init(void) lov_oinfo_slab = kmem_cache_create("lov_oinfo", sizeof(struct lov_oinfo), 0, SLAB_HWCACHE_ALIGN, NULL); - if (lov_oinfo_slab == NULL) { + if (!lov_oinfo_slab) { lu_kmem_fini(lov_caches); return -ENOMEM; } diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 3b79ebc..4101696 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -135,7 +135,8 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, * Do not leave the object in cache to avoid accessing * freed memory. This is because osc_object is referring to * lov_oinfo of lsm_stripe_data which will be freed due to - * this failure. */ + * this failure. + */ cl_object_kill(env, stripe); cl_object_put(env, stripe); return -EIO; @@ -154,7 +155,7 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, /* reuse ->coh_attr_guard to protect coh_parent change */ spin_lock(&subhdr->coh_attr_guard); parent = subhdr->coh_parent; - if (parent == NULL) { + if (!parent) { subhdr->coh_parent = hdr; spin_unlock(&subhdr->coh_attr_guard); subhdr->coh_nesting = hdr->coh_nesting + 1; @@ -170,11 +171,12 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, spin_unlock(&subhdr->coh_attr_guard); old_obj = lu_object_locate(&parent->coh_lu, &lov_device_type); - LASSERT(old_obj != NULL); + LASSERT(old_obj); old_lov = cl2lov(lu2cl(old_obj)); if (old_lov->lo_layout_invalid) { /* the object's layout has already changed but isn't - * refreshed */ + * refreshed + */ lu_object_unhash(env, &stripe->co_lu); result = -EAGAIN; } else { @@ -212,14 +214,14 @@ static int lov_init_raid0(const struct lu_env *env, LOV_MAGIC_V1, LOV_MAGIC_V3, lsm->lsm_magic); } - LASSERT(lov->lo_lsm == NULL); + LASSERT(!lov->lo_lsm); lov->lo_lsm = lsm_addref(lsm); r0->lo_nr = lsm->lsm_stripe_count; LASSERT(r0->lo_nr <= lov_targets_nr(dev)); r0->lo_sub = libcfs_kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]), GFP_NOFS); - if (r0->lo_sub != NULL) { + if (r0->lo_sub) { result = 0; subconf->coc_inode = conf->coc_inode; spin_lock_init(&r0->lo_sub_lock); @@ -241,9 +243,10 @@ static int lov_init_raid0(const struct lu_env *env, subdev = lovsub2cl_dev(dev->ld_target[ost_idx]); subconf->u.coc_oinfo = oinfo; - LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx); + LASSERTF(subdev, "not init ost %d\n", ost_idx); /* In the function below, .hs_keycmp resolves to - * lu_obj_hop_keycmp() */ + * lu_obj_hop_keycmp() + */ /* coverity[overrun-buffer-val] */ stripe = lov_sub_find(env, subdev, ofid, subconf); if (!IS_ERR(stripe)) { @@ -269,9 +272,9 @@ static int lov_init_released(const struct lu_env *env, { struct lov_stripe_md *lsm = conf->u.coc_md->lsm; - LASSERT(lsm != NULL); + LASSERT(lsm); LASSERT(lsm_is_released(lsm)); - LASSERT(lov->lo_lsm == NULL); + LASSERT(!lov->lo_lsm); lov->lo_lsm = lsm_addref(lsm); return 0; @@ -310,7 +313,8 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, cl_object_put(env, sub); /* ... wait until it is actually destroyed---sub-object clears its - * ->lo_sub[] slot in lovsub_object_fini() */ + * ->lo_sub[] slot in lovsub_object_fini() + */ if (r0->lo_sub[idx] == los) { waiter = &lov_env_info(env)->lti_waiter; init_waitqueue_entry(waiter, current); @@ -318,7 +322,8 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, set_current_state(TASK_UNINTERRUPTIBLE); while (1) { /* this wait-queue is signaled at the end of - * lu_object_free(). */ + * lu_object_free(). + */ set_current_state(TASK_UNINTERRUPTIBLE); spin_lock(&r0->lo_sub_lock); if (r0->lo_sub[idx] == los) { @@ -332,7 +337,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, } remove_wait_queue(&bkt->lsb_marche_funebre, waiter); } - LASSERT(r0->lo_sub[idx] == NULL); + LASSERT(!r0->lo_sub[idx]); } static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, @@ -345,11 +350,11 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, dump_lsm(D_INODE, lsm); lov_layout_wait(env, lov); - if (r0->lo_sub != NULL) { + if (r0->lo_sub) { for (i = 0; i < r0->lo_nr; ++i) { struct lovsub_object *los = r0->lo_sub[i]; - if (los != NULL) { + if (los) { cl_locks_prune(env, &los->lso_cl, 1); /* * If top-level object is to be evicted from @@ -374,7 +379,7 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, { struct lov_layout_raid0 *r0 = &state->raid0; - if (r0->lo_sub != NULL) { + if (r0->lo_sub) { kvfree(r0->lo_sub); r0->lo_sub = NULL; } @@ -412,7 +417,7 @@ static int lov_print_raid0(const struct lu_env *env, void *cookie, for (i = 0; i < r0->lo_nr; ++i) { struct lu_object *sub; - if (r0->lo_sub[i] != NULL) { + if (r0->lo_sub[i]) { sub = lovsub2lu(r0->lo_sub[i]); lu_object_print(env, cookie, p, sub); } else { @@ -465,7 +470,8 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, * context, and this function is called in ccc_lock_state(), it will * hit this assertion. * Anyway, it's still okay to call attr_get w/o type guard as layout - * can't go if locks exist. */ + * can't go if locks exist. + */ /* LASSERT(atomic_read(&lsm->lsm_refc) > 1); */ if (!r0->lo_attr_valid) { @@ -475,7 +481,8 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, memset(lvb, 0, sizeof(*lvb)); /* XXX: timestamps can be negative by sanity:test_39m, - * how can it be? */ + * how can it be? + */ lvb->lvb_atime = LLONG_MIN; lvb->lvb_ctime = LLONG_MIN; lvb->lvb_mtime = LLONG_MIN; @@ -569,7 +576,7 @@ static const struct lov_layout_operations lov_dispatch[] = { */ static enum lov_layout_type lov_type(struct lov_stripe_md *lsm) { - if (lsm == NULL) + if (!lsm) return LLT_EMPTY; if (lsm_is_released(lsm)) return LLT_RELEASED; @@ -624,7 +631,7 @@ static void lov_conf_lock(struct lov_object *lov) { LASSERT(lov->lo_owner != current); down_write(&lov->lo_type_guard); - LASSERT(lov->lo_owner == NULL); + LASSERT(!lov->lo_owner); lov->lo_owner = current; } @@ -666,7 +673,7 @@ static int lov_layout_change(const struct lu_env *unused, LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); - if (conf->u.coc_md != NULL) + if (conf->u.coc_md) llt = lov_type(conf->u.coc_md->lsm); LASSERT(0 <= llt && llt < ARRAY_SIZE(lov_dispatch)); @@ -689,7 +696,7 @@ static int lov_layout_change(const struct lu_env *unused, old_ops->llo_fini(env, lov, &lov->u); LASSERT(atomic_read(&lov->lo_active_ios) == 0); - LASSERT(hdr->coh_tree.rnode == NULL); + LASSERT(!hdr->coh_tree.rnode); LASSERT(hdr->coh_pages == 0); lov->lo_type = LLT_EMPTY; @@ -767,10 +774,10 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, LASSERT(conf->coc_opc == OBJECT_CONF_SET); - if (conf->u.coc_md != NULL) + if (conf->u.coc_md) lsm = conf->u.coc_md->lsm; - if ((lsm == NULL && lov->lo_lsm == NULL) || - ((lsm != NULL && lov->lo_lsm != NULL) && + if ((!lsm && !lov->lo_lsm) || + ((lsm && lov->lo_lsm) && (lov->lo_lsm->lsm_layout_gen == lsm->lsm_layout_gen) && (lov->lo_lsm->lsm_pattern == lsm->lsm_pattern))) { /* same version of layout */ @@ -845,7 +852,8 @@ static int lov_attr_get(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr) { /* do not take lock, as this function is called under a - * spin-lock. Layout is protected from changing by ongoing IO. */ + * spin-lock. Layout is protected from changing by ongoing IO. + */ return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_getattr, env, obj, attr); } @@ -892,7 +900,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, struct lu_object *obj; lov = kmem_cache_alloc(lov_object_kmem, GFP_NOFS | __GFP_ZERO); - if (lov != NULL) { + if (lov) { obj = lov2lu(lov); lu_object_init(obj, NULL, dev); lov->lo_cl.co_ops = &lov_ops; @@ -913,7 +921,7 @@ static struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov) struct lov_stripe_md *lsm = NULL; lov_conf_freeze(lov); - if (lov->lo_lsm != NULL) { + if (lov->lo_lsm) { lsm = lsm_addref(lov->lo_lsm); CDEBUG(D_INODE, "lsm %p addref %d/%d by %p.\n", lsm, atomic_read(&lsm->lsm_refc), @@ -928,12 +936,12 @@ struct lov_stripe_md *lov_lsm_get(struct cl_object *clobj) struct lu_object *luobj; struct lov_stripe_md *lsm = NULL; - if (clobj == NULL) + if (!clobj) return NULL; luobj = lu_object_locate(&cl_object_header(clobj)->coh_lu, &lov_device_type); - if (luobj != NULL) + if (luobj) lsm = lov_lsm_addref(lu2lov(luobj)); return lsm; } @@ -941,7 +949,7 @@ EXPORT_SYMBOL(lov_lsm_get); void lov_lsm_put(struct cl_object *unused, struct lov_stripe_md *lsm) { - if (lsm != NULL) + if (lsm) lov_free_memmd(&lsm); } EXPORT_SYMBOL(lov_lsm_put); @@ -953,7 +961,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) luobj = lu_object_locate(&cl_object_header(clob)->coh_lu, &lov_device_type); - if (luobj != NULL) { + if (luobj) { struct lov_object *lov = lu2lov(luobj); lov_conf_freeze(lov); @@ -963,7 +971,6 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) int i; lsm = lov->lo_lsm; - LASSERT(lsm != NULL); for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_oinfo *loi = lsm->lsm_oinfo[i]; diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index aa520aa..1ceea3d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -55,7 +55,6 @@ u64 lov_stripe_size(struct lov_stripe_md *lsm, u64 ost_size, if (ost_size == 0) return 0; - LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, NULL, &swidth); /* lov_do_div64(a, b) returns a % b, and a = a / b */ @@ -115,7 +114,8 @@ u64 lov_stripe_size(struct lov_stripe_md *lsm, u64 ost_size, * this function returns < 0 when the offset was "before" the stripe and * was moved forward to the start of the stripe in question; 0 when it * falls in the stripe and no shifting was done; > 0 when the offset - * was outside the stripe and was pulled back to its final byte. */ + * was outside the stripe and was pulled back to its final byte. + */ int lov_stripe_offset(struct lov_stripe_md *lsm, u64 lov_off, int stripeno, u64 *obdoff) { @@ -129,8 +129,6 @@ int lov_stripe_offset(struct lov_stripe_md *lsm, u64 lov_off, return 0; } - LASSERT(lsm_op_find(magic) != NULL); - lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, &lov_off, &swidth); @@ -183,7 +181,6 @@ u64 lov_size_to_stripe(struct lov_stripe_md *lsm, u64 file_size, if (file_size == OBD_OBJECT_EOF) return OBD_OBJECT_EOF; - LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, &file_size, &swidth); @@ -213,7 +210,8 @@ u64 lov_size_to_stripe(struct lov_stripe_md *lsm, u64 file_size, /* given an extent in an lov and a stripe, calculate the extent of the stripe * that is contained within the lov extent. this returns true if the given - * stripe does intersect with the lov extent. */ + * stripe does intersect with the lov extent. + */ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, u64 start, u64 end, u64 *obd_start, u64 *obd_end) { @@ -227,7 +225,8 @@ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, /* this stripe doesn't intersect the file extent when neither * start or the end intersected the stripe and obd_start and - * obd_end got rounded up to the save value. */ + * obd_end got rounded up to the save value. + */ if (start_side != 0 && end_side != 0 && *obd_start == *obd_end) return 0; @@ -238,7 +237,8 @@ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, * in the wrong direction and touch it up. * interestingly, this can't underflow since end must be > start * if we passed through the previous check. - * (should we assert for that somewhere?) */ + * (should we assert for that somewhere?) + */ if (end_side != 0) (*obd_end)--; @@ -252,7 +252,6 @@ int lov_stripe_number(struct lov_stripe_md *lsm, u64 lov_off) u64 stripe_off, swidth; int magic = lsm->lsm_magic; - LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_offset(lsm, NULL, &lov_off, &swidth); stripe_off = lov_do_div64(lov_off, swidth); diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index a78211f..9235d7d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -141,7 +141,8 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, if (lsm) { /* If we are just sizing the EA, limit the stripe count - * to the actual number of OSTs in this filesystem. */ + * to the actual number of OSTs in this filesystem. + */ if (!lmmp) { stripe_count = lov_get_stripecnt(lov, lmm_magic, lsm->lsm_stripe_count); @@ -155,7 +156,8 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, /* No need to allocate more than maximum supported stripes. * Anyway, this is pretty inaccurate since ld_tgt_count now * represents max index and we should rely on the actual number - * of OSTs instead */ + * of OSTs instead + */ stripe_count = lov_mds_md_max_stripe_count( lov->lov_ocd.ocd_max_easize, lmm_magic); @@ -183,7 +185,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return -ENOMEM; } - CDEBUG(D_INFO, "lov_packmd: LOV_MAGIC 0x%08X, lmm_size = %d \n", + CDEBUG(D_INFO, "lov_packmd: LOV_MAGIC 0x%08X, lmm_size = %d\n", lmm_magic, lmm_size); lmmv1 = *lmmp; @@ -241,7 +243,8 @@ __u16 lov_get_stripecnt(struct lov_obd *lov, __u32 magic, __u16 stripe_count) stripe_count = 1; /* stripe count is based on whether ldiskfs can handle - * larger EA sizes */ + * larger EA sizes + */ if (lov->lov_ocd.ocd_connect_flags & OBD_CONNECT_MAX_EASIZE && lov->lov_ocd.ocd_max_easize) max_stripes = lov_mds_md_max_stripe_count( @@ -257,7 +260,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) { int rc; - if (lsm_op_find(le32_to_cpu(*(__u32 *)lmm)) == NULL) { + if (!lsm_op_find(le32_to_cpu(*(__u32 *)lmm))) { CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n", le32_to_cpu(*(__u32 *)lmm), lmm_bytes); CERROR("%*phN\n", lmm_bytes, lmm); @@ -306,10 +309,9 @@ int lov_free_memmd(struct lov_stripe_md **lsmp) *lsmp = NULL; LASSERT(atomic_read(&lsm->lsm_refc) > 0); refc = atomic_dec_return(&lsm->lsm_refc); - if (refc == 0) { - LASSERT(lsm_op_find(lsm->lsm_magic) != NULL); + if (refc == 0) lsm_op_find(lsm->lsm_magic)->lsm_free(lsm); - } + return refc; } @@ -359,7 +361,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (!lmm) return lsm_size; - LASSERT(lsm_op_find(magic) != NULL); rc = lsm_op_find(magic)->lsm_unpackmd(lov, *lsmp, lmm); if (rc) { lov_free_memmd(lsmp); @@ -399,13 +400,15 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, set_fs(KERNEL_DS); /* we only need the header part from user space to get lmm_magic and - * lmm_stripe_count, (the header part is common to v1 and v3) */ + * lmm_stripe_count, (the header part is common to v1 and v3) + */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(&lum, lump, lum_size)) { rc = -EFAULT; goto out_set; - } else if ((lum.lmm_magic != LOV_USER_MAGIC) && - (lum.lmm_magic != LOV_USER_MAGIC_V3)) { + } + if ((lum.lmm_magic != LOV_USER_MAGIC) && + (lum.lmm_magic != LOV_USER_MAGIC_V3)) { rc = -EINVAL; goto out_set; } diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 037ae91..17ae450 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -57,7 +57,7 @@ static int lov_page_invariant(const struct cl_page_slice *slice) const struct cl_page *page = slice->cpl_page; const struct cl_page *sub = lov_sub_page(slice); - return ergo(sub != NULL, + return ergo(sub, page->cp_child == sub && sub->cp_parent == page && page->cp_state == sub->cp_state); @@ -70,7 +70,7 @@ static void lov_page_fini(const struct lu_env *env, LINVRNT(lov_page_invariant(slice)); - if (sub != NULL) { + if (sub) { LASSERT(sub->cp_state == CPS_FREEING); lu_ref_del(&sub->cp_reference, "lov", sub->cp_parent); sub->cp_parent = NULL; @@ -151,7 +151,7 @@ static const struct cl_page_operations lov_page_ops = { static void lov_empty_page_fini(const struct lu_env *env, struct cl_page_slice *slice) { - LASSERT(slice->cpl_page->cp_child == NULL); + LASSERT(!slice->cpl_page->cp_child); } int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 3ee1d40..210304f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -64,7 +64,7 @@ void lov_pool_putref(struct pool_desc *pool) if (atomic_dec_and_test(&pool->pool_refcount)) { LASSERT(hlist_unhashed(&pool->pool_hash)); LASSERT(list_empty(&pool->pool_list)); - LASSERT(pool->pool_debugfs_entry == NULL); + LASSERT(!pool->pool_debugfs_entry); lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); kfree(pool); @@ -154,7 +154,7 @@ struct cfs_hash_ops pool_hash_operations = { /* ifdef needed for liblustre support */ /* - * pool /proc seq_file methods + * pool debugfs seq_file methods */ /* * iterator is used to go through the target pool entries @@ -204,7 +204,8 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos) if ((pool_tgt_count(pool) == 0) || (*pos >= pool_tgt_count(pool))) { /* iter is not created, so stop() has no way to - * find pool to dec ref */ + * find pool to dec ref + */ lov_pool_putref(pool); return NULL; } @@ -217,7 +218,8 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos) iter->idx = 0; /* we use seq_file private field to memorized iterator so - * we can free it at stop() */ + * we can free it at stop() + */ /* /!\ do not forget to restore it to pool before freeing it */ s->private = iter; if (*pos > 0) { @@ -226,8 +228,8 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos) i = 0; do { - ptr = pool_proc_next(s, &iter, &i); - } while ((i < *pos) && (ptr != NULL)); + ptr = pool_proc_next(s, &iter, &i); + } while ((i < *pos) && ptr); return ptr; } return iter; @@ -239,10 +241,12 @@ static void pool_proc_stop(struct seq_file *s, void *v) /* in some cases stop() method is called 2 times, without * calling start() method (see seq_read() from fs/seq_file.c) - * we have to free only if s->private is an iterator */ + * we have to free only if s->private is an iterator + */ if ((iter) && (iter->magic == POOL_IT_MAGIC)) { /* we restore s->private so next call to pool_proc_start() - * will work */ + * will work + */ s->private = iter->pool; lov_pool_putref(iter->pool); kfree(iter); @@ -255,7 +259,7 @@ static int pool_proc_show(struct seq_file *s, void *v) struct lov_tgt_desc *tgt; LASSERTF(iter->magic == POOL_IT_MAGIC, "%08X", iter->magic); - LASSERT(iter->pool != NULL); + LASSERT(iter->pool); LASSERT(iter->idx <= pool_tgt_count(iter->pool)); down_read(&pool_tgt_rw_sem(iter->pool)); @@ -304,7 +308,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) init_rwsem(&op->op_rw_sem); op->op_size = count; op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS); - if (op->op_array == NULL) { + if (!op->op_array) { op->op_size = 0; return -ENOMEM; } @@ -324,7 +328,7 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count) new_size = max(min_count, 2 * op->op_size); new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS); - if (new == NULL) + if (!new) return -ENOMEM; /* copy old array to new one */ @@ -429,7 +433,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) INIT_HLIST_NODE(&new_pool->pool_hash); /* we need this assert seq_file is not implemented for liblustre */ - /* get ref for /proc file */ + /* get ref for debugfs file */ lov_pool_getref(new_pool); new_pool->pool_debugfs_entry = ldebugfs_add_simple( lov->lov_pool_debugfs_entry, @@ -486,7 +490,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname) /* lookup and kill hash reference */ pool = cfs_hash_del_key(lov->lov_pools_hash_body, poolname); - if (pool == NULL) + if (!pool) return -ENOENT; if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) { @@ -517,7 +521,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) lov = &(obd->u.lov); pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); - if (pool == NULL) + if (!pool) return -ENOENT; obd_str2uuid(&ost_uuid, ostname); @@ -563,7 +567,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) lov = &(obd->u.lov); pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); - if (pool == NULL) + if (!pool) return -ENOENT; obd_str2uuid(&ost_uuid, ostname); @@ -631,10 +635,10 @@ struct pool_desc *lov_find_pool(struct lov_obd *lov, char *poolname) pool = NULL; if (poolname[0] != '\0') { pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); - if (pool == NULL) + if (!pool) CWARN("Request for an unknown pool ("LOV_POOLNAMEF")\n", poolname); - if ((pool != NULL) && (pool_tgt_count(pool) == 0)) { + if (pool && (pool_tgt_count(pool) == 0)) { CWARN("Request for an empty pool ("LOV_POOLNAMEF")\n", poolname); /* pool is ignored, so we remove ref on it */ diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 42deda7..42660f2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -156,7 +156,7 @@ static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) tgt = lov->lov_tgts[ost_idx]; - if (unlikely(tgt == NULL)) { + if (unlikely(!tgt)) { rc = 0; goto out; } @@ -178,7 +178,7 @@ static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) cfs_time_seconds(1), NULL, NULL); rc = l_wait_event(waitq, lov_check_set(lov, ost_idx), &lwi); - if (tgt != NULL && tgt->ltd_active) + if (tgt && tgt->ltd_active) return 1; return 0; @@ -190,28 +190,23 @@ out: static int common_attr_done(struct lov_request_set *set) { - struct list_head *pos; struct lov_request *req; struct obdo *tmp_oa; int rc = 0, attrset = 0; - LASSERT(set->set_oi != NULL); - - if (set->set_oi->oi_oa == NULL) + if (!set->set_oi->oi_oa) return 0; if (!atomic_read(&set->set_success)) return -EIO; tmp_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (tmp_oa == NULL) { + if (!tmp_oa) { rc = -ENOMEM; goto out; } - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (!req->rq_complete || req->rq_rc) continue; if (req->rq_oi.oi_oa->o_valid == 0) /* inactive stripe */ @@ -227,7 +222,8 @@ static int common_attr_done(struct lov_request_set *set) if ((set->set_oi->oi_oa->o_valid & OBD_MD_FLEPOCH) && (set->set_oi->oi_md->lsm_stripe_count != attrset)) { /* When we take attributes of some epoch, we require all the - * ost to be active. */ + * ost to be active. + */ CERROR("Not all the stripes had valid attrs\n"); rc = -EIO; goto out; @@ -246,7 +242,7 @@ int lov_fini_getattr_set(struct lov_request_set *set) { int rc = 0; - if (set == NULL) + if (!set) return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) @@ -258,7 +254,8 @@ int lov_fini_getattr_set(struct lov_request_set *set) } /* The callback for osc_getattr_async that finalizes a request info when a - * response is received. */ + * response is received. + */ static int cb_getattr_update(void *cookie, int rc) { struct obd_info *oinfo = cookie; @@ -312,7 +309,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (req->rq_oi.oi_oa == NULL) { + if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; goto out_set; @@ -337,7 +334,7 @@ out_set: int lov_fini_destroy_set(struct lov_request_set *set) { - if (set == NULL) + if (!set) return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { @@ -368,7 +365,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, set->set_oi->oi_md = lsm; set->set_oi->oi_oa = src_oa; set->set_oti = oti; - if (oti != NULL && src_oa->o_valid & OBD_MD_FLCOOKIE) + if (oti && src_oa->o_valid & OBD_MD_FLCOOKIE) set->set_cookies = oti->oti_logcookies; for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -395,7 +392,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (req->rq_oi.oi_oa == NULL) { + if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; goto out_set; @@ -419,7 +416,7 @@ int lov_fini_setattr_set(struct lov_request_set *set) { int rc = 0; - if (set == NULL) + if (!set) return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { @@ -460,7 +457,8 @@ int lov_update_setattr_set(struct lov_request_set *set, } /* The callback for osc_setattr_async that finalizes a request info when a - * response is received. */ + * response is received. + */ static int cb_setattr_update(void *cookie, int rc) { struct obd_info *oinfo = cookie; @@ -486,7 +484,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, set->set_exp = exp; set->set_oti = oti; set->set_oi = oinfo; - if (oti != NULL && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) + if (oti && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) set->set_cookies = oti->oti_logcookies; for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) { @@ -511,7 +509,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (req->rq_oi.oi_oa == NULL) { + if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; goto out_set; @@ -581,7 +579,7 @@ int lov_fini_statfs_set(struct lov_request_set *set) { int rc = 0; - if (set == NULL) + if (!set) return 0; if (atomic_read(&set->set_completes)) { @@ -648,7 +646,8 @@ static void lov_update_statfs(struct obd_statfs *osfs, } /* The callback for osc_statfs_async that finalizes a request info when a - * response is received. */ + * response is received. + */ static int cb_statfs_update(void *cookie, int rc) { struct obd_info *oinfo = cookie; @@ -668,7 +667,8 @@ static int cb_statfs_update(void *cookie, int rc) lov_sfs = oinfo->oi_osfs; success = atomic_read(&set->set_success); /* XXX: the same is done in lov_update_common_set, however - lovset->set_exp is not initialized. */ + * lovset->set_exp is not initialized. + */ lov_update_set(set, lovreq, rc); if (rc) goto out; @@ -718,7 +718,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, for (i = 0; i < lov->desc.ld_tgt_count; i++) { struct lov_request *req; - if (lov->lov_tgts[i] == NULL || + if (!lov->lov_tgts[i] || (!lov_check_and_wait_active(lov, i) && (oinfo->oi_flags & OBD_STATFS_NODELAY))) { CDEBUG(D_HA, "lov idx %d inactive\n", i); @@ -726,7 +726,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, } /* skip targets that have been explicitly disabled by the - * administrator */ + * administrator + */ if (!lov->lov_tgts[i]->ltd_exp) { CDEBUG(D_HA, "lov idx %d administratively disabled\n", i); continue; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index f1795c3..233740c 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -101,7 +101,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, next->ld_site = d->ld_site; ldt = next->ld_type; - LASSERT(ldt != NULL); rc = ldt->ldt_ops->ldto_device_init(env, next, ldt->ldt_name, NULL); if (rc) { next->ld_site = NULL; @@ -149,7 +148,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev, int result; lsr = kmem_cache_alloc(lovsub_req_kmem, GFP_NOFS | __GFP_ZERO); - if (lsr != NULL) { + if (lsr) { cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops); result = 0; } else @@ -175,7 +174,7 @@ static struct lu_device *lovsub_device_alloc(const struct lu_env *env, struct lovsub_device *lsd; lsd = kzalloc(sizeof(*lsd), GFP_NOFS); - if (lsd != NULL) { + if (lsd) { int result; result = cl_device_init(&lsd->acid_cl, t); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 1a3e30a..0046812 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -148,7 +148,8 @@ static void lovsub_lock_descr_map(const struct cl_lock_descr *in, { pgoff_t size; /* stripe size in pages */ pgoff_t skip; /* how many pages in every stripe are occupied by - * "other" stripes */ + * "other" stripes + */ pgoff_t start; pgoff_t end; @@ -284,7 +285,8 @@ static int lovsub_lock_delete_one(const struct lu_env *env, switch (parent->cll_state) { case CLS_ENQUEUED: /* See LU-1355 for the case that a glimpse lock is - * interrupted by signal */ + * interrupted by signal + */ LASSERT(parent->cll_flags & CLF_CANCELLED); break; case CLS_QUEUING: @@ -429,7 +431,7 @@ static int lovsub_lock_print(const struct lu_env *env, void *cookie, list_for_each_entry(scan, &sub->lss_parents, lll_list) { lov = scan->lll_super; (*p)(env, cookie, "[%d %p ", scan->lll_idx, lov); - if (lov != NULL) + if (lov) cl_lock_descr_print(env, cookie, p, &lov->lls_cl.cls_lock->cll_descr); (*p)(env, cookie, "] "); @@ -454,7 +456,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, int result; lsk = kmem_cache_alloc(lovsub_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (lsk != NULL) { + if (lsk) { INIT_LIST_HEAD(&lsk->lss_parents); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 5ba5ee1..0a9bf51 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -63,7 +63,7 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, under = &dev->acid_next->cd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); - if (below != NULL) { + if (below) { lu_object_add(obj, below); cl_object_page_init(lu2cl(obj), sizeof(struct lovsub_page)); result = 0; @@ -144,7 +144,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lu_object *obj; los = kmem_cache_alloc(lovsub_object_kmem, GFP_NOFS | __GFP_ZERO); - if (los != NULL) { + if (los) { struct cl_object_header *hdr; obj = lovsub2lu(los); diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 337241d..bb81d04 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -46,7 +46,7 @@ static int lov_stripesize_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lov_desc *desc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; seq_printf(m, "%llu\n", desc->ld_default_stripe_size); return 0; @@ -61,7 +61,7 @@ static ssize_t lov_stripesize_seq_write(struct file *file, __u64 val; int rc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; rc = lprocfs_write_u64_helper(buffer, count, &val); if (rc) @@ -79,7 +79,7 @@ static int lov_stripeoffset_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lov_desc *desc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; seq_printf(m, "%llu\n", desc->ld_default_stripe_offset); return 0; @@ -94,7 +94,7 @@ static ssize_t lov_stripeoffset_seq_write(struct file *file, __u64 val; int rc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; rc = lprocfs_write_u64_helper(buffer, count, &val); if (rc) @@ -111,7 +111,7 @@ static int lov_stripetype_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lov_desc *desc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; seq_printf(m, "%u\n", desc->ld_pattern); return 0; @@ -125,7 +125,7 @@ static ssize_t lov_stripetype_seq_write(struct file *file, struct lov_desc *desc; int val, rc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; rc = lprocfs_write_helper(buffer, count, &val); if (rc) @@ -143,7 +143,7 @@ static int lov_stripecount_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lov_desc *desc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; seq_printf(m, "%d\n", (__s16)(desc->ld_default_stripe_count + 1) - 1); return 0; @@ -157,7 +157,7 @@ static ssize_t lov_stripecount_seq_write(struct file *file, struct lov_desc *desc; int val, rc; - LASSERT(dev != NULL); + LASSERT(dev); desc = &dev->u.lov.desc; rc = lprocfs_write_helper(buffer, count, &val); if (rc) @@ -199,7 +199,7 @@ static int lov_desc_uuid_seq_show(struct seq_file *m, void *v) struct obd_device *dev = (struct obd_device *)m->private; struct lov_obd *lov; - LASSERT(dev != NULL); + LASSERT(dev); lov = &dev->u.lov; seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid); return 0; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 3d2997a..54f4ca6 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -90,7 +90,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct ptlrpc_request **req, __u64 extra_lock_flags); int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, - struct list_head *cancels, ldlm_mode_t mode, + struct list_head *cancels, enum ldlm_mode mode, __u64 bits); /* mdc/mdc_request.c */ int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, @@ -119,8 +119,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request); int mdc_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - ldlm_cancel_flags_t flags, void *opaque); + ldlm_policy_data_t *policy, enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque); int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lu_fid *fid, __u64 *bits); @@ -129,10 +129,10 @@ int mdc_intent_getattr_async(struct obd_export *exp, struct md_enqueue_info *minfo, struct ldlm_enqueue_info *einfo); -ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, - const struct lu_fid *fid, ldlm_type_t type, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - struct lustre_handle *lockh); +enum ldlm_mode mdc_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, enum ldlm_type type, + ldlm_policy_data_t *policy, enum ldlm_mode mode, + struct lustre_handle *lockh); static inline int mdc_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, int opc, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 7218532..b3bfdcb 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -41,8 +41,6 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) { - LASSERT(b != NULL); - b->suppgid = suppgid; b->uid = from_kuid(&init_user_ns, current_uid()); b->gid = from_kgid(&init_user_ns, current_gid()); @@ -83,7 +81,6 @@ void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, { struct mdt_body *b = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(b != NULL); b->valid = valid; b->eadatasize = ea_size; b->flags = flags; @@ -323,7 +320,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, return; lum = req_capsule_client_get(&req->rq_pill, &RMF_EADATA); - if (ea == NULL) { /* Remove LOV EA */ + if (!ea) { /* Remove LOV EA */ lum->lmm_magic = LOV_USER_MAGIC_V1; lum->lmm_stripe_size = 0; lum->lmm_stripe_count = 0; @@ -346,7 +343,6 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_unlink)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); - LASSERT(rec != NULL); rec->ul_opcode = op_data->op_cli_flags & CLI_RM_ENTRY ? REINT_RMENTRY : REINT_UNLINK; @@ -362,7 +358,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) rec->ul_bias = op_data->op_bias; tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); - LASSERT(tmp != NULL); + LASSERT(tmp); LOGL0(op_data->op_name, op_data->op_namelen, tmp); } @@ -373,7 +369,6 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_link)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); - LASSERT(rec != NULL); rec->lk_opcode = REINT_LINK; rec->lk_fsuid = op_data->op_fsuid; /* current->fsuid; */ @@ -456,10 +451,9 @@ static void mdc_hsm_release_pack(struct ptlrpc_request *req, struct ldlm_lock *lock; data = req_capsule_client_get(&req->rq_pill, &RMF_CLOSE_DATA); - LASSERT(data != NULL); lock = ldlm_handle2lock(&op_data->op_lease_handle); - if (lock != NULL) { + if (lock) { data->cd_handle = lock->l_remote_handle; ldlm_lock_put(lock); } @@ -495,7 +489,8 @@ static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) /* We record requests in flight in cli->cl_r_in_flight here. * There is only one write rpc possible in mdc anyway. If this to change - * in the future - the code may need to be revisited. */ + * in the future - the code may need to be revisited. + */ int mdc_enter_request(struct client_obd *cli) { int rc = 0; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index ef9a1e1..6dae574 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -129,7 +129,7 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, lock = ldlm_handle2lock((struct lustre_handle *)lockh); - LASSERT(lock != NULL); + LASSERT(lock); lock_res_and_lock(lock); if (lock->l_resource->lr_lvb_inode && lock->l_resource->lr_lvb_inode != data) { @@ -151,13 +151,13 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, return 0; } -ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, - const struct lu_fid *fid, ldlm_type_t type, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - struct lustre_handle *lockh) +enum ldlm_mode mdc_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, enum ldlm_type type, + ldlm_policy_data_t *policy, enum ldlm_mode mode, + struct lustre_handle *lockh) { struct ldlm_res_id res_id; - ldlm_mode_t rc; + enum ldlm_mode rc; fid_build_reg_res_name(fid, &res_id); /* LU-4405: Clear bits not supported by server */ @@ -170,8 +170,8 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, int mdc_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, ldlm_policy_data_t *policy, - ldlm_mode_t mode, - ldlm_cancel_flags_t flags, + enum ldlm_mode mode, + enum ldlm_cancel_flags flags, void *opaque) { struct ldlm_res_id res_id; @@ -191,12 +191,12 @@ int mdc_null_inode(struct obd_export *exp, struct ldlm_resource *res; struct ldlm_namespace *ns = class_exp2obd(exp)->obd_namespace; - LASSERTF(ns != NULL, "no namespace passed\n"); + LASSERTF(ns, "no namespace passed\n"); fid_build_reg_res_name(fid, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); - if (res == NULL) + if (!res) return 0; lock_res(res); @@ -210,7 +210,8 @@ int mdc_null_inode(struct obd_export *exp, /* find any ldlm lock of the inode in mdc * return 0 not find * 1 find one - * < 0 error */ + * < 0 error + */ int mdc_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, ldlm_iterator_t it, void *data) @@ -252,7 +253,8 @@ static inline void mdc_clear_replay_flag(struct ptlrpc_request *req, int rc) * OOM here may cause recovery failure if lmm is needed (only for the * original open if the MDS crashed just when this client also OOM'd) * but this is incredibly unlikely, and questionable whether the client - * could do MDS recovery under OOM anyways... */ + * could do MDS recovery under OOM anyways... + */ static void mdc_realloc_openmsg(struct ptlrpc_request *req, struct mdt_body *body) { @@ -317,7 +319,7 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_OPEN); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return ERR_PTR(-ENOMEM); } @@ -365,7 +367,7 @@ mdc_intent_getxattr_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETXATTR); - if (req == NULL) + if (!req) return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, &cancels, count); @@ -409,7 +411,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_UNLINK); - if (req == NULL) + if (!req) return ERR_PTR(-ENOMEM); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -453,7 +455,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETATTR); - if (req == NULL) + if (!req) return ERR_PTR(-ENOMEM); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -497,7 +499,7 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_LAYOUT); - if (req == NULL) + if (!req) return ERR_PTR(-ENOMEM); req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); @@ -514,7 +516,8 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, /* pack the layout intent request */ layout = req_capsule_client_get(&req->rq_pill, &RMF_LAYOUT_INTENT); /* LAYOUT_INTENT_ACCESS is generic, specific operation will be - * set for replication */ + * set for replication + */ layout->li_opc = LAYOUT_INTENT_ACCESS; req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, @@ -530,7 +533,7 @@ mdc_enqueue_pack(struct obd_export *exp, int lvb_len) int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); - if (req == NULL) + if (!req) return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); @@ -561,7 +564,8 @@ static int mdc_finish_enqueue(struct obd_export *exp, LASSERT(rc >= 0); /* Similarly, if we're going to replay this request, we don't want to - * actually get a lock, just perform the intent. */ + * actually get a lock, just perform the intent. + */ if (req->rq_transno || req->rq_replay) { lockreq = req_capsule_client_get(pill, &RMF_DLM_REQ); lockreq->lock_flags |= ldlm_flags_to_wire(LDLM_FL_INTENT_ONLY); @@ -573,10 +577,10 @@ static int mdc_finish_enqueue(struct obd_export *exp, rc = 0; } else { /* rc = 0 */ lock = ldlm_handle2lock(lockh); - LASSERT(lock != NULL); /* If the server gave us back a different lock mode, we should - * fix up our variables. */ + * fix up our variables. + */ if (lock->l_req_mode != einfo->ei_mode) { ldlm_lock_addref(lockh, lock->l_req_mode); ldlm_lock_decref(lockh, einfo->ei_mode); @@ -586,7 +590,6 @@ static int mdc_finish_enqueue(struct obd_export *exp, } lockrep = req_capsule_server_get(pill, &RMF_DLM_REP); - LASSERT(lockrep != NULL); /* checked by ldlm_cli_enqueue() */ intent->it_disposition = (int)lockrep->lock_policy_res1; intent->it_status = (int)lockrep->lock_policy_res2; @@ -595,7 +598,8 @@ static int mdc_finish_enqueue(struct obd_export *exp, intent->it_data = req; /* Technically speaking rq_transno must already be zero if - * it_status is in error, so the check is a bit redundant */ + * it_status is in error, so the check is a bit redundant + */ if ((!req->rq_transno || intent->it_status < 0) && req->rq_replay) mdc_clear_replay_flag(req, intent->it_status); @@ -605,7 +609,8 @@ static int mdc_finish_enqueue(struct obd_export *exp, * * It's important that we do this first! Otherwise we might exit the * function without doing so, and try to replay a failed create - * (bug 3440) */ + * (bug 3440) + */ if (it->it_op & IT_OPEN && req->rq_replay && (!it_disposition(it, DISP_OPEN_OPEN) || intent->it_status != 0)) mdc_clear_replay_flag(req, intent->it_status); @@ -618,7 +623,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, struct mdt_body *body; body = req_capsule_server_get(pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { CERROR("Can't swab mdt_body\n"); return -EPROTO; } @@ -645,11 +650,12 @@ static int mdc_finish_enqueue(struct obd_export *exp, */ eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); - if (eadata == NULL) + if (!eadata) return -EPROTO; /* save lvb data and length in case this is for layout - * lock */ + * lock + */ lvb_data = eadata; lvb_len = body->eadatasize; @@ -690,31 +696,32 @@ static int mdc_finish_enqueue(struct obd_export *exp, LASSERT(client_is_remote(exp)); perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); - if (perm == NULL) + if (!perm) return -EPROTO; } } else if (it->it_op & IT_LAYOUT) { /* maybe the lock was granted right away and layout - * is packed into RMF_DLM_LVB of req */ + * is packed into RMF_DLM_LVB of req + */ lvb_len = req_capsule_get_size(pill, &RMF_DLM_LVB, RCL_SERVER); if (lvb_len > 0) { lvb_data = req_capsule_server_sized_get(pill, &RMF_DLM_LVB, lvb_len); - if (lvb_data == NULL) + if (!lvb_data) return -EPROTO; } } /* fill in stripe data for layout lock */ lock = ldlm_handle2lock(lockh); - if (lock != NULL && ldlm_has_layout(lock) && lvb_data != NULL) { + if (lock && ldlm_has_layout(lock) && lvb_data) { void *lmm; LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d\n", ldlm_it2str(it->it_op), lvb_len); lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS); - if (lmm == NULL) { + if (!lmm) { LDLM_LOCK_PUT(lock); return -ENOMEM; } @@ -722,24 +729,25 @@ static int mdc_finish_enqueue(struct obd_export *exp, /* install lvb_data */ lock_res_and_lock(lock); - if (lock->l_lvb_data == NULL) { + if (!lock->l_lvb_data) { lock->l_lvb_type = LVB_T_LAYOUT; lock->l_lvb_data = lmm; lock->l_lvb_len = lvb_len; lmm = NULL; } unlock_res_and_lock(lock); - if (lmm != NULL) + if (lmm) kvfree(lmm); } - if (lock != NULL) + if (lock) LDLM_LOCK_PUT(lock); return rc; } /* We always reserve enough space in the reply packet for a stripe MD, because - * we don't know in advance the file type. */ + * we don't know in advance the file type. + */ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lookup_intent *it, struct md_op_data *op_data, struct lustre_handle *lockh, void *lmm, int lmmsize, @@ -782,14 +790,15 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, policy = &getxattr_policy; } - LASSERT(reqp == NULL); + LASSERT(!reqp); generation = obddev->u.cli.cl_import->imp_generation; resend: flags = saved_flags; if (!it) { /* The only way right now is FLOCK, in this case we hide flock - policy as lmm, but lmmsize is 0 */ + * policy as lmm, but lmmsize is 0 + */ LASSERT(lmm && lmmsize == 0); LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n", einfo->ei_type); @@ -823,9 +832,10 @@ resend: if (IS_ERR(req)) return PTR_ERR(req); - if (req != NULL && it && it->it_op & IT_CREAT) + if (req && it && it->it_op & IT_CREAT) /* ask ptlrpc not to resend on EINPROGRESS since we have our own - * retry logic */ + * retry logic + */ req->rq_no_retry_einprogress = 1; if (resends) { @@ -836,7 +846,8 @@ resend: /* It is important to obtain rpc_lock first (if applicable), so that * threads that are serialised with rpc_lock are not polluting our - * rpcs in flight counter. We do not do flock request limiting, though*/ + * rpcs in flight counter. We do not do flock request limiting, though + */ if (it) { mdc_get_rpc_lock(obddev->u.cli.cl_rpc_lock, it); rc = mdc_enter_request(&obddev->u.cli); @@ -852,13 +863,14 @@ resend: 0, lvb_type, lockh, 0); if (!it) { /* For flock requests we immediately return without further - delay and let caller deal with the rest, since rest of - this function metadata processing makes no sense for flock - requests anyway. But in case of problem during comms with - Server (ETIMEDOUT) or any signal/kill attempt (EINTR), we - can not rely on caller and this mainly for F_UNLCKs - (explicits or automatically generated by Kernel to clean - current FLocks upon exit) that can't be trashed */ + * delay and let caller deal with the rest, since rest of + * this function metadata processing makes no sense for flock + * requests anyway. But in case of problem during comms with + * Server (ETIMEDOUT) or any signal/kill attempt (EINTR), we + * can not rely on caller and this mainly for F_UNLCKs + * (explicits or automatically generated by Kernel to clean + * current FLocks upon exit) that can't be trashed + */ if ((rc == -EINTR) || (rc == -ETIMEDOUT)) goto resend; return rc; @@ -878,13 +890,13 @@ resend: } lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - LASSERT(lockrep != NULL); lockrep->lock_policy_res2 = ptlrpc_status_ntoh(lockrep->lock_policy_res2); /* Retry the create infinitely when we get -EINPROGRESS from - * server. This is required by the new quota design. */ + * server. This is required by the new quota design. + */ if (it->it_op & IT_CREAT && (int)lockrep->lock_policy_res2 == -EINPROGRESS) { mdc_clear_replay_flag(req, rc); @@ -930,13 +942,13 @@ static int mdc_finish_intent_lock(struct obd_export *exp, struct ldlm_lock *lock; int rc; - LASSERT(request != NULL); LASSERT(request != LP_POISON); LASSERT(request->rq_repmsg != LP_POISON); if (!it_disposition(it, DISP_IT_EXECD)) { /* The server failed before it even started executing the - * intent, i.e. because it couldn't unpack the request. */ + * intent, i.e. because it couldn't unpack the request. + */ LASSERT(it->d.lustre.it_status != 0); return it->d.lustre.it_status; } @@ -945,10 +957,11 @@ static int mdc_finish_intent_lock(struct obd_export *exp, return rc; mdt_body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - LASSERT(mdt_body != NULL); /* mdc_enqueue checked */ + LASSERT(mdt_body); /* mdc_enqueue checked */ /* If we were revalidating a fid/name pair, mark the intent in - * case we fail and get called again from lookup */ + * case we fail and get called again from lookup + */ if (fid_is_sane(&op_data->op_fid2) && it->it_create_mode & M_CHECK_STALE && it->it_op != IT_GETATTR) { @@ -957,7 +970,8 @@ static int mdc_finish_intent_lock(struct obd_export *exp, /* sever can return one of two fids: * op_fid2 - new allocated fid - if file is created. * op_fid3 - existent fid - if file only open. - * op_fid3 is saved in lmv_intent_open */ + * op_fid3 is saved in lmv_intent_open + */ if ((!lu_fid_eq(&op_data->op_fid2, &mdt_body->fid1)) && (!lu_fid_eq(&op_data->op_fid3, &mdt_body->fid1))) { CDEBUG(D_DENTRY, "Found stale data "DFID"("DFID")/"DFID @@ -1001,7 +1015,8 @@ static int mdc_finish_intent_lock(struct obd_export *exp, * one. We have to set the data here instead of in * mdc_enqueue, because we need to use the child's inode as * the l_ast_data to match, and that's not available until - * intent_finish has performed the iget().) */ + * intent_finish has performed the iget().) + */ lock = ldlm_handle2lock(lockh); if (lock) { ldlm_policy_data_t policy = lock->l_policy_data; @@ -1036,11 +1051,12 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, { /* We could just return 1 immediately, but since we should only * be called in revalidate_it if we already have a lock, let's - * verify that. */ + * verify that. + */ struct ldlm_res_id res_id; struct lustre_handle lockh; ldlm_policy_data_t policy; - ldlm_mode_t mode; + enum ldlm_mode mode; if (it->d.lustre.it_lock_handle) { lockh.cookie = it->d.lustre.it_lock_handle; @@ -1059,10 +1075,12 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, * Unfortunately, if the bits are split across multiple * locks, there's no easy way to match all of them here, * so an extra RPC would be performed to fetch all - * of those bits at once for now. */ + * of those bits at once for now. + */ /* For new MDTs(> 2.4), UPDATE|PERM should be enough, * but for old MDTs (< 2.4), permission is covered - * by LOOKUP lock, so it needs to match all bits here.*/ + * by LOOKUP lock, so it needs to match all bits here. + */ policy.l_inodebits.bits = MDS_INODELOCK_UPDATE | MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM; @@ -1147,11 +1165,13 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, (it->it_op & (IT_LOOKUP | IT_GETATTR))) { /* We could just return 1 immediately, but since we should only * be called in revalidate_it if we already have a lock, let's - * verify that. */ + * verify that. + */ it->d.lustre.it_lock_handle = 0; rc = mdc_revalidate_lock(exp, it, &op_data->op_fid2, NULL); /* Only return failure if it was not GETATTR by cfid - (from inode_revalidate) */ + * (from inode_revalidate) + */ if (rc || op_data->op_namelen != 0) return rc; } @@ -1206,7 +1226,6 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, } lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - LASSERT(lockrep != NULL); lockrep->lock_policy_res2 = ptlrpc_status_ntoh(lockrep->lock_policy_res2); @@ -1235,7 +1254,8 @@ int mdc_intent_getattr_async(struct obd_export *exp, struct ldlm_res_id res_id; /*XXX: Both MDS_INODELOCK_LOOKUP and MDS_INODELOCK_UPDATE are needed * for statahead currently. Consider CMD in future, such two bits - * maybe managed by different MDS, should be adjusted then. */ + * maybe managed by different MDS, should be adjusted then. + */ ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index ac7695a..019b237 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -65,9 +65,10 @@ static int mdc_reint(struct ptlrpc_request *request, /* Find and cancel locally locks matched by inode @bits & @mode in the resource * found by @fid. Found locks are added into @cancel list. Returns the amount of - * locks added to @cancels list. */ + * locks added to @cancels list. + */ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, - struct list_head *cancels, ldlm_mode_t mode, + struct list_head *cancels, enum ldlm_mode mode, __u64 bits) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; @@ -81,14 +82,15 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, * * This distinguishes from a case when ELC is not supported originally, * when we still want to cancel locks in advance and just cancel them - * locally, without sending any RPC. */ + * locally, without sending any RPC. + */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) return 0; fid_build_reg_res_name(fid, &res_id); res = ldlm_resource_get(exp->exp_obd->obd_namespace, NULL, &res_id, 0, 0); - if (res == NULL) + if (!res) return 0; LDLM_RESOURCE_ADDREF(res); /* Initialize ibits lock policy. */ @@ -111,8 +113,6 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, int count = 0, rc; __u64 bits; - LASSERT(op_data != NULL); - bits = MDS_INODELOCK_UPDATE; if (op_data->op_attr.ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) bits |= MDS_INODELOCK_LOOKUP; @@ -123,7 +123,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, &cancels, LCK_EX, bits); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_SETATTR); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -151,10 +151,10 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_request_set_replen(req); if (mod && (op_data->op_flags & MF_EPOCH_OPEN) && req->rq_import->imp_replayable) { - LASSERT(*mod == NULL); + LASSERT(!*mod); *mod = obd_mod_alloc(); - if (*mod == NULL) { + if (!*mod) { DEBUG_REQ(D_ERROR, req, "Can't allocate md_open_data"); } else { req->rq_replay = 1; @@ -181,8 +181,6 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH); body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(epoch != NULL); - LASSERT(body != NULL); epoch->handle = body->handle; epoch->ioepoch = body->ioepoch; req->rq_replay_cb = mdc_replay_open; @@ -195,7 +193,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, *request = req; if (rc && req->rq_commit_cb) { /* Put an extra reference on \var mod on error case. */ - if (mod != NULL && *mod != NULL) + if (mod && *mod) obd_mod_put(*mod); req->rq_commit_cb(req); } @@ -237,7 +235,7 @@ rebuild: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_CREATE_RMT_ACL); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -262,7 +260,8 @@ rebuild: ptlrpc_request_set_replen(req); /* ask ptlrpc not to resend on EINPROGRESS since we have our own retry - * logic here */ + * logic here + */ req->rq_no_retry_einprogress = 1; if (resends) { @@ -280,7 +279,8 @@ rebuild: goto resend; } else if (rc == -EINPROGRESS) { /* Retry create infinitely until succeed or get other - * error code. */ + * error code. + */ ptlrpc_req_finished(req); resends++; @@ -308,7 +308,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request *req = *request; int count = 0, rc; - LASSERT(req == NULL); + LASSERT(!req); if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1)) && @@ -324,7 +324,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, MDS_INODELOCK_FULL); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_UNLINK); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -373,7 +373,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_LINK); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -429,7 +429,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_RENAME); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 4348127..c7a0fa1 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -63,7 +63,8 @@ static inline int mdc_queue_wait(struct ptlrpc_request *req) /* mdc_enter_request() ensures that this client has no more * than cl_max_rpcs_in_flight RPCs simultaneously inf light - * against an MDT. */ + * against an MDT. + */ rc = mdc_enter_request(cli); if (rc != 0) return rc; @@ -83,7 +84,7 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid) req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETSTATUS, LUSTRE_MDS_VERSION, MDS_GETSTATUS); - if (req == NULL) + if (!req) return -ENOMEM; mdc_pack_body(req, NULL, 0, 0, -1, 0); @@ -96,7 +97,7 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid) goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out; } @@ -136,7 +137,7 @@ static int mdc_getattr_common(struct obd_export *exp, /* sanity check for the reply */ body = req_capsule_server_get(pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) return -EPROTO; CDEBUG(D_NET, "mode: %o\n", body->mode); @@ -146,7 +147,7 @@ static int mdc_getattr_common(struct obd_export *exp, eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); - if (eadata == NULL) + if (!eadata) return -EPROTO; } @@ -156,7 +157,7 @@ static int mdc_getattr_common(struct obd_export *exp, LASSERT(client_is_remote(exp)); perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); - if (perm == NULL) + if (!perm) return -EPROTO; } @@ -176,7 +177,7 @@ static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, } *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); @@ -214,7 +215,7 @@ static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR_NAME); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -261,7 +262,7 @@ static int mdc_is_subdir(struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION, MDS_IS_SUBDIR); - if (req == NULL) + if (!req) return -ENOMEM; mdc_is_subdir_pack(req, pfid, cfid, 0); @@ -290,7 +291,7 @@ static int mdc_xattr_common(struct obd_export *exp, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt); - if (req == NULL) + if (!req) return -ENOMEM; if (xattr_name) { @@ -425,7 +426,7 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) return -EPROTO; acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize); - if (acl == NULL) + if (!acl) return 0; if (IS_ERR(acl)) { @@ -461,7 +462,6 @@ static int mdc_get_lustre_md(struct obd_export *exp, memset(md, 0, sizeof(*md)); md->body = req_capsule_server_get(pill, &RMF_MDT_BODY); - LASSERT(md->body != NULL); if (md->body->valid & OBD_MD_FLEASIZE) { int lmmsize; @@ -593,17 +593,16 @@ void mdc_replay_open(struct ptlrpc_request *req) struct lustre_handle old; struct mdt_body *body; - if (mod == NULL) { + if (!mod) { DEBUG_REQ(D_ERROR, req, "Can't properly replay without open data."); return; } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body != NULL); och = mod->mod_och; - if (och != NULL) { + if (och) { struct lustre_handle *file_fh; LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC); @@ -615,7 +614,7 @@ void mdc_replay_open(struct ptlrpc_request *req) *file_fh = body->handle; } close_req = mod->mod_close_req; - if (close_req != NULL) { + if (close_req) { __u32 opc = lustre_msg_get_opc(close_req->rq_reqmsg); struct mdt_ioepoch *epoch; @@ -624,7 +623,7 @@ void mdc_replay_open(struct ptlrpc_request *req) &RMF_MDT_EPOCH); LASSERT(epoch); - if (och != NULL) + if (och) LASSERT(!memcmp(&old, &epoch->handle, sizeof(old))); DEBUG_REQ(D_HA, close_req, "updating close body with new fh"); epoch->handle = body->handle; @@ -635,7 +634,7 @@ void mdc_commit_open(struct ptlrpc_request *req) { struct md_open_data *mod = req->rq_cb_data; - if (mod == NULL) + if (!mod) return; /** @@ -675,15 +674,15 @@ int mdc_set_open_replay_data(struct obd_export *exp, rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT); body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY); - LASSERT(rec != NULL); + LASSERT(rec); /* Incoming message in my byte order (it's been swabbed). */ /* Outgoing messages always in my byte order. */ - LASSERT(body != NULL); + LASSERT(body); /* Only if the import is replayable, we set replay_open data */ if (och && imp->imp_replayable) { mod = obd_mod_alloc(); - if (mod == NULL) { + if (!mod) { DEBUG_REQ(D_ERROR, open_req, "Can't allocate md_open_data"); return 0; @@ -749,11 +748,11 @@ static int mdc_clear_open_replay_data(struct obd_export *exp, * It is possible to not have \var mod in a case of eviction between * lookup and ll_file_open(). **/ - if (mod == NULL) + if (!mod) return 0; LASSERT(mod != LP_POISON); - LASSERT(mod->mod_open_req != NULL); + LASSERT(mod->mod_open_req); mdc_free_open(mod); mod->mod_och = NULL; @@ -804,7 +803,7 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), req_fmt); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE); @@ -815,13 +814,14 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a * portal whose threads are not taking any DLM locks and are therefore - * always progressing */ + * always progressing + */ req->rq_request_portal = MDS_READPAGE_PORTAL; ptlrpc_at_set_req_timeout(req); /* Ensure that this close's handle is fixed up during replay. */ - if (likely(mod != NULL)) { - LASSERTF(mod->mod_open_req != NULL && + if (likely(mod)) { + LASSERTF(mod->mod_open_req && mod->mod_open_req->rq_type != LI_POISON, "POISONED open %p!\n", mod->mod_open_req); @@ -829,7 +829,8 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, DEBUG_REQ(D_HA, mod->mod_open_req, "matched open"); /* We no longer want to preserve this open for replay even - * though the open was committed. b=3632, b=3633 */ + * though the open was committed. b=3632, b=3633 + */ spin_lock(&mod->mod_open_req->rq_lock); mod->mod_open_req->rq_replay = 0; spin_unlock(&mod->mod_open_req->rq_lock); @@ -851,7 +852,7 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, rc = ptlrpc_queue_wait(req); mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL); - if (req->rq_repmsg == NULL) { + if (!req->rq_repmsg) { CDEBUG(D_RPCTRACE, "request failed to send: %p, %d\n", req, req->rq_status); if (rc == 0) @@ -867,7 +868,7 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, rc = -rc; } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) + if (!body) rc = -EPROTO; } else if (rc == -ESTALE) { /** @@ -877,7 +878,6 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, */ if (mod) { DEBUG_REQ(D_HA, req, "Reset ESTALE = %d", rc); - LASSERT(mod->mod_open_req != NULL); if (mod->mod_open_req->rq_committed) rc = 0; } @@ -887,7 +887,8 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, if (rc != 0) mod->mod_close_req = NULL; /* Since now, mod is accessed through open_req only, - * thus close req does not keep a reference on mod anymore. */ + * thus close req does not keep a reference on mod anymore. + */ obd_mod_put(mod); } *request = req; @@ -904,7 +905,7 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_DONE_WRITING); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING); @@ -913,15 +914,16 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, return rc; } - if (mod != NULL) { - LASSERTF(mod->mod_open_req != NULL && + if (mod) { + LASSERTF(mod->mod_open_req && mod->mod_open_req->rq_type != LI_POISON, "POISONED setattr %p!\n", mod->mod_open_req); mod->mod_close_req = req; DEBUG_REQ(D_HA, mod->mod_open_req, "matched setattr"); /* We no longer want to preserve this setattr for replay even - * though the open was committed. b=3632, b=3633 */ + * though the open was committed. b=3632, b=3633 + */ spin_lock(&mod->mod_open_req->rq_lock); mod->mod_open_req->rq_replay = 0; spin_unlock(&mod->mod_open_req->rq_lock); @@ -941,7 +943,6 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, * Let's check if mod exists and return no error in that case */ if (mod) { - LASSERT(mod->mod_open_req != NULL); if (mod->mod_open_req->rq_committed) rc = 0; } @@ -950,11 +951,12 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, if (mod) { if (rc != 0) mod->mod_close_req = NULL; - LASSERT(mod->mod_open_req != NULL); + LASSERT(mod->mod_open_req); mdc_free_open(mod); /* Since now, mod is accessed through setattr req only, - * thus DW req does not keep a reference on mod anymore. */ + * thus DW req does not keep a reference on mod anymore. + */ obd_mod_put(mod); } @@ -979,7 +981,7 @@ static int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, restart_bulk: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE); @@ -993,7 +995,7 @@ restart_bulk: desc = ptlrpc_prep_bulk_imp(req, op_data->op_npages, 1, BULK_PUT_SINK, MDS_BULK_PORTAL); - if (desc == NULL) { + if (!desc) { ptlrpc_request_free(req); return -ENOMEM; } @@ -1067,7 +1069,7 @@ static int mdc_statfs(const struct lu_env *env, req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS, LUSTRE_MDS_VERSION, MDS_STATFS); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto output; } @@ -1089,7 +1091,7 @@ static int mdc_statfs(const struct lu_env *env, } msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); - if (msfs == NULL) { + if (!msfs) { rc = -EPROTO; goto out; } @@ -1162,7 +1164,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_PROGRESS, LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -1171,7 +1173,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, /* Copy hsm_progress struct */ req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS); - if (req_hpk == NULL) { + if (!req_hpk) { rc = -EPROTO; goto out; } @@ -1196,7 +1198,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_REGISTER, LUSTRE_MDS_VERSION, MDS_HSM_CT_REGISTER); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -1206,7 +1208,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) /* Copy hsm_progress struct */ archive_mask = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_ARCHIVE); - if (archive_mask == NULL) { + if (!archive_mask) { rc = -EPROTO; goto out; } @@ -1231,7 +1233,7 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_ACTION); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_ACTION); @@ -1251,7 +1253,7 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, req_hca = req_capsule_server_get(&req->rq_pill, &RMF_MDS_HSM_CURRENT_ACTION); - if (req_hca == NULL) { + if (!req_hca) { rc = -EPROTO; goto out; } @@ -1271,7 +1273,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_UNREGISTER, LUSTRE_MDS_VERSION, MDS_HSM_CT_UNREGISTER); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -1296,7 +1298,7 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_GET); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_GET); @@ -1315,7 +1317,7 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, goto out; req_hus = req_capsule_server_get(&req->rq_pill, &RMF_HSM_USER_STATE); - if (req_hus == NULL) { + if (!req_hus) { rc = -EPROTO; goto out; } @@ -1337,7 +1339,7 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_SET); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_SET); @@ -1351,7 +1353,7 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, /* Copy states */ req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET); - if (req_hss == NULL) { + if (!req_hss) { rc = -EPROTO; goto out; } @@ -1376,7 +1378,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, int rc; req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -1397,7 +1399,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, /* Copy hsm_request struct */ req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST); - if (req_hr == NULL) { + if (!req_hr) { rc = -EPROTO; goto out; } @@ -1405,7 +1407,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, /* Copy hsm_user_item structs */ req_hui = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM); - if (req_hui == NULL) { + if (!req_hui) { rc = -EPROTO; goto out; } @@ -1414,7 +1416,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, /* Copy opaque field */ req_opaque = req_capsule_client_get(&req->rq_pill, &RMF_GENERIC_DATA); - if (req_opaque == NULL) { + if (!req_opaque) { rc = -EPROTO; goto out; } @@ -1513,7 +1515,7 @@ static int mdc_changelog_send_thread(void *csdata) /* Set up the remote catalog handle */ ctxt = llog_get_context(cs->cs_obd, LLOG_CHANGELOG_REPL_CTXT); - if (ctxt == NULL) { + if (!ctxt) { rc = -ENOENT; goto out; } @@ -1554,6 +1556,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, struct ioc_changelog *icc) { struct changelog_show *cs; + struct task_struct *task; int rc; /* Freed in mdc_changelog_send_thread */ @@ -1571,15 +1574,20 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, * New thread because we should return to user app before * writing into our pipe */ - rc = PTR_ERR(kthread_run(mdc_changelog_send_thread, cs, - "mdc_clg_send_thread")); - if (!IS_ERR_VALUE(rc)) { - CDEBUG(D_CHANGELOG, "start changelog thread\n"); - return 0; + task = kthread_run(mdc_changelog_send_thread, cs, + "mdc_clg_send_thread"); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("%s: can't start changelog thread: rc = %d\n", + obd->obd_name, rc); + kfree(cs); + } else { + rc = 0; + CDEBUG(D_CHANGELOG, "%s: started changelog thread\n", + obd->obd_name); } CERROR("Failed to start changelog thread: %d\n", rc); - kfree(cs); return rc; } @@ -1597,7 +1605,7 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION, MDS_QUOTACHECK); - if (req == NULL) + if (!req) return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); @@ -1606,7 +1614,8 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, ptlrpc_request_set_replen(req); /* the next poll will find -ENODATA, that means quotacheck is - * going on */ + * going on + */ cli->cl_qchk_stat = -ENODATA; rc = ptlrpc_queue_wait(req); if (rc) @@ -1641,7 +1650,7 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION, MDS_QUOTACTL); - if (req == NULL) + if (!req) return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); @@ -1695,7 +1704,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SWAP_LAYOUTS); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -1881,7 +1890,7 @@ static int mdc_get_info_rpc(struct obd_export *exp, int rc = -EINVAL; req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY, @@ -1906,7 +1915,8 @@ static int mdc_get_info_rpc(struct obd_export *exp, rc = ptlrpc_queue_wait(req); /* -EREMOTE means the get_info result is partial, and it needs to - * continue on another MDT, see fid2path part in lmv_iocontrol */ + * continue on another MDT, see fid2path part in lmv_iocontrol + */ if (rc == 0 || rc == -EREMOTE) { tmp = req_capsule_server_get(&req->rq_pill, &RMF_GETINFO_VAL); memcpy(val, tmp, vallen); @@ -2140,7 +2150,7 @@ static int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC); @@ -2182,7 +2192,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, * Flush current sequence to make client obtain new one * from server in case of disconnect/reconnect. */ - if (cli->cl_seq != NULL) + if (cli->cl_seq) seq_client_flush(cli->cl_seq); rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL); @@ -2245,7 +2255,8 @@ static int mdc_cancel_for_recovery(struct ldlm_lock *lock) /* FIXME: if we ever get into a situation where there are too many * opened files with open locks on a single node, then we really - * should replay these open locks to reget it */ + * should replay these open locks to reget it + */ if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN) return 0; @@ -2429,7 +2440,7 @@ static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index ab4800c..6fc8225 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -90,7 +90,8 @@ static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id, int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type) { /* fsname is at most 8 chars long, maybe contain "-". - * e.g. "lustre", "SUN-000" */ + * e.g. "lustre", "SUN-000" + */ return mgc_name2resid(fsname, strlen(fsname), res_id, type); } EXPORT_SYMBOL(mgc_fsname2resid); @@ -102,7 +103,8 @@ static int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type /* logname consists of "fsname-nodetype". * e.g. "lustre-MDT0001", "SUN-000-client" - * there is an exception: llog "params" */ + * there is an exception: llog "params" + */ name_end = strrchr(logname, '-'); if (!name_end) len = strlen(logname); @@ -125,7 +127,8 @@ static int config_log_get(struct config_llog_data *cld) } /* Drop a reference to a config log. When no longer referenced, - we can free the config log data */ + * we can free the config log data + */ static void config_log_put(struct config_llog_data *cld) { CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, @@ -162,7 +165,7 @@ struct config_llog_data *config_log_find(char *logname, struct config_llog_data *found = NULL; void *instance; - LASSERT(logname != NULL); + LASSERT(logname); instance = cfg ? cfg->cfg_instance : NULL; spin_lock(&config_list_lock); @@ -252,7 +255,8 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd, char logname[32]; /* we have to use different llog for clients and mdts for cmd - * where only clients are notified if one of cmd server restarts */ + * where only clients are notified if one of cmd server restarts + */ LASSERT(strlen(fsname) < sizeof(logname) / 2); strcpy(logname, fsname); LASSERT(lcfg.cfg_instance); @@ -300,7 +304,7 @@ static int config_log_add(struct obd_device *obd, char *logname, * <fsname>-sptlrpc. multiple regular logs may share one sptlrpc log. */ ptr = strrchr(logname, '-'); - if (ptr == NULL || ptr - logname > 8) { + if (!ptr || ptr - logname > 8) { CERROR("logname %s is too long\n", logname); return -EINVAL; } @@ -309,7 +313,7 @@ static int config_log_add(struct obd_device *obd, char *logname, strcpy(seclogname + (ptr - logname), "-sptlrpc"); sptlrpc_cld = config_log_find(seclogname, NULL); - if (sptlrpc_cld == NULL) { + if (!sptlrpc_cld) { sptlrpc_cld = do_config_log_add(obd, seclogname, CONFIG_T_SPTLRPC, NULL, NULL); if (IS_ERR(sptlrpc_cld)) { @@ -376,7 +380,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) int rc = 0; cld = config_log_find(logname, cfg); - if (cld == NULL) + if (!cld) return -ENOENT; mutex_lock(&cld->cld_lock); @@ -455,7 +459,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) spin_lock(&config_list_lock); list_for_each_entry(cld, &config_llog_list, cld_list_chain) { - if (cld->cld_recover == NULL) + if (!cld->cld_recover) continue; seq_printf(m, " - { client: %s, nidtbl_version: %u }\n", cld->cld_logname, @@ -483,8 +487,9 @@ static void do_requeue(struct config_llog_data *cld) LASSERT(atomic_read(&cld->cld_refcount) > 0); /* Do not run mgc_process_log on a disconnected export or an - export which is being disconnected. Take the client - semaphore to make the check non-racy. */ + * export which is being disconnected. Take the client + * semaphore to make the check non-racy. + */ down_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem); if (cld->cld_mgcexp->exp_obd->u.cli.cl_conn_count != 0) { CDEBUG(D_MGC, "updating log %s\n", cld->cld_logname); @@ -529,8 +534,9 @@ static int mgc_requeue_thread(void *data) } /* Always wait a few seconds to allow the server who - caused the lock revocation to finish its setup, plus some - random so everyone doesn't try to reconnect at once. */ + * caused the lock revocation to finish its setup, plus some + * random so everyone doesn't try to reconnect at once. + */ to = MGC_TIMEOUT_MIN_SECONDS * HZ; to += rand * HZ / 100; /* rand is centi-seconds */ lwi = LWI_TIMEOUT(to, NULL, NULL); @@ -559,7 +565,8 @@ static int mgc_requeue_thread(void *data) LASSERT(atomic_read(&cld->cld_refcount) > 0); /* Whether we enqueued again or not in mgc_process_log, - * we're done with the ref from the old enqueue */ + * we're done with the ref from the old enqueue + */ if (cld_prev) config_log_put(cld_prev); cld_prev = cld; @@ -575,7 +582,8 @@ static int mgc_requeue_thread(void *data) config_log_put(cld_prev); /* break after scanning the list so that we can drop - * refcount to losing lock clds */ + * refcount to losing lock clds + */ if (unlikely(stopped)) { spin_lock(&config_list_lock); break; @@ -598,7 +606,8 @@ static int mgc_requeue_thread(void *data) } /* Add a cld to the list to requeue. Start the requeue thread if needed. - We are responsible for dropping the config log reference from here on out. */ + * We are responsible for dropping the config log reference from here on out. + */ static void mgc_requeue_add(struct config_llog_data *cld) { CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n", @@ -635,7 +644,8 @@ static int mgc_llog_init(const struct lu_env *env, struct obd_device *obd) int rc; /* setup only remote ctxt, the local disk context is switched per each - * filesystem during mgc_fs_setup() */ + * filesystem during mgc_fs_setup() + */ rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CONFIG_REPL_CTXT, obd, &llog_client_ops); if (rc) @@ -697,7 +707,8 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) static int mgc_cleanup(struct obd_device *obd) { /* COMPAT_146 - old config logs may have added profiles we don't - know about */ + * know about + */ if (obd->obd_type->typ_refcnt <= 1) /* Only for the last mgc */ class_del_profiles(); @@ -711,6 +722,7 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars = { NULL }; + struct task_struct *task; int rc; ptlrpcd_addref(); @@ -734,10 +746,10 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) init_waitqueue_head(&rq_waitq); /* start requeue thread */ - rc = PTR_ERR(kthread_run(mgc_requeue_thread, NULL, - "ll_cfg_requeue")); - if (IS_ERR_VALUE(rc)) { - CERROR("%s: Cannot start requeue thread (%d),no more log updates!\n", + task = kthread_run(mgc_requeue_thread, NULL, "ll_cfg_requeue"); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("%s: cannot start requeue thread: rc = %d; no more log updates\n", obd->obd_name, rc); goto err_cleanup; } @@ -793,7 +805,8 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, break; } /* Make sure not to re-enqueue when the mgc is stopping - (we get called from client_disconnect_export) */ + * (we get called from client_disconnect_export) + */ if (!lock->l_conn_export || !lock->l_conn_export->exp_obd->u.cli.cl_conn_count) { CDEBUG(D_MGC, "log %.8s: disconnecting, won't requeue\n", @@ -815,7 +828,8 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, /* Not sure where this should go... */ /* This is the timeout value for MGS_CONNECT request plus a ping interval, such - * that we can have a chance to try the secondary MGS if any. */ + * that we can have a chance to try the secondary MGS if any. + */ #define MGC_ENQUEUE_LIMIT (INITIAL_CONNECT_TIMEOUT + (AT_OFF ? 0 : at_min) \ + PING_INTERVAL) #define MGC_TARGET_REG_LIMIT 10 @@ -879,11 +893,12 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, cld->cld_resid.name[0]); /* We need a callback for every lockholder, so don't try to - ldlm_lock_match (see rev 1.1.2.11.2.47) */ + * ldlm_lock_match (see rev 1.1.2.11.2.47) + */ req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0); @@ -894,7 +909,8 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, rc = ldlm_cli_enqueue(exp, &req, &einfo, &cld->cld_resid, NULL, flags, NULL, 0, LVB_T_NONE, lockh, 0); /* A failed enqueue should still call the mgc_blocking_ast, - where it will be requeued if needed ("grant failed"). */ + * where it will be requeued if needed ("grant failed"). + */ ptlrpc_req_finished(req); return rc; } @@ -921,7 +937,7 @@ static int mgc_target_register(struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, MGS_TARGET_REG); - if (req == NULL) + if (!req) return -ENOMEM; req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); @@ -1109,7 +1125,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, int rc = 0; int off = 0; - LASSERT(cfg->cfg_instance != NULL); + LASSERT(cfg->cfg_instance); LASSERT(cfg->cfg_sb == cfg->cfg_instance); inst = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); @@ -1195,7 +1211,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, /* lustre-OST0001-osc-<instance #> */ strcpy(obdname, cld->cld_logname); cname = strrchr(obdname, '-'); - if (cname == NULL) { + if (!cname) { CERROR("mgc %s: invalid logname %s\n", mgc->obd_name, obdname); break; @@ -1212,7 +1228,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, /* find the obd by obdname */ obd = class_name2obd(obdname); - if (obd == NULL) { + if (!obd) { CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n", mgc->obd_name, obdname); rc = 0; @@ -1227,7 +1243,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, uuid = buf + pos; down_read(&obd->u.cli.cl_sem); - if (obd->u.cli.cl_import == NULL) { + if (!obd->u.cli.cl_import) { /* client does not connect to the OST yet */ up_read(&obd->u.cli.cl_sem); rc = 0; @@ -1257,7 +1273,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, rc = -ENOMEM; lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); - if (lcfg == NULL) { + if (!lcfg) { CERROR("mgc: cannot allocate memory\n"); break; } @@ -1309,14 +1325,14 @@ static int mgc_process_recover_log(struct obd_device *obd, nrpages = CONFIG_READ_NRPAGES_INIT; pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL); - if (pages == NULL) { + if (!pages) { rc = -ENOMEM; goto out; } for (i = 0; i < nrpages; i++) { pages[i] = alloc_page(GFP_KERNEL); - if (pages[i] == NULL) { + if (!pages[i]) { rc = -ENOMEM; goto out; } @@ -1327,7 +1343,7 @@ again: LASSERT(mutex_is_locked(&cld->cld_lock)); req = ptlrpc_request_alloc(class_exp2cliimp(cld->cld_mgcexp), &RQF_MGS_CONFIG_READ); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -1338,7 +1354,6 @@ again: /* pack request */ body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY); - LASSERT(body != NULL); LASSERT(sizeof(body->mcb_name) > strlen(cld->cld_logname)); if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name)) >= sizeof(body->mcb_name)) { @@ -1353,7 +1368,7 @@ again: /* allocate bulk transfer descriptor */ desc = ptlrpc_prep_bulk_imp(req, nrpages, 1, BULK_PUT_SINK, MGS_BULK_PORTAL); - if (desc == NULL) { + if (!desc) { rc = -ENOMEM; goto out; } @@ -1373,7 +1388,8 @@ again: } /* always update the index even though it might have errors with - * handling the recover logs */ + * handling the recover logs + */ cfg->cfg_last_idx = res->mcr_offset; eof = res->mcr_offset == res->mcr_size; @@ -1400,7 +1416,8 @@ again: mne_swab = !!ptlrpc_rep_need_swab(req); #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 50, 0) /* This import flag means the server did an extra swab of IR MNE - * records (fixed in LU-1252), reverse it here if needed. LU-1644 */ + * records (fixed in LU-1252), reverse it here if needed. LU-1644 + */ if (unlikely(req->rq_import->imp_need_mne_swab)) mne_swab = !mne_swab; #else @@ -1434,7 +1451,7 @@ out: if (pages) { for (i = 0; i < nrpages; i++) { - if (pages[i] == NULL) + if (!pages[i]) break; __free_page(pages[i]); } @@ -1489,7 +1506,8 @@ static int mgc_process_cfg_log(struct obd_device *mgc, /* logname and instance info should be the same, so use our * copy of the instance for the update. The cfg_last_idx will - * be updated here. */ + * be updated here. + */ rc = class_config_parse_llog(env, ctxt, cld->cld_logname, &cld->cld_cfg); @@ -1529,9 +1547,10 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) LASSERT(cld); /* I don't want multiple processes running process_log at once -- - sounds like badness. It actually might be fine, as long as - we're not trying to update from the same log - simultaneously (in which case we should use a per-log sem.) */ + * sounds like badness. It actually might be fine, as long as + * we're not trying to update from the same log + * simultaneously (in which case we should use a per-log sem.) + */ mutex_lock(&cld->cld_lock); if (cld->cld_stopping) { mutex_unlock(&cld->cld_lock); @@ -1556,7 +1575,8 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) CDEBUG(D_MGC, "Can't get cfg lock: %d\n", rcl); /* mark cld_lostlock so that it will requeue - * after MGC becomes available. */ + * after MGC becomes available. + */ cld->cld_lostlock = 1; /* Get extra reference, it will be put in requeue thread */ config_log_get(cld); @@ -1635,18 +1655,19 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) if (rc) break; cld = config_log_find(logname, cfg); - if (cld == NULL) { + if (!cld) { rc = -ENOENT; break; } /* COMPAT_146 */ /* FIXME only set this for old logs! Right now this forces - us to always skip the "inside markers" check */ + * us to always skip the "inside markers" check + */ cld->cld_cfg.cfg_flags |= CFG_F_COMPAT146; rc = mgc_process_log(obd, cld); - if (rc == 0 && cld->cld_recover != NULL) { + if (rc == 0 && cld->cld_recover) { if (OCD_HAS_FLAG(&obd->u.cli.cl_import-> imp_connect_data, IMP_RECOV)) { rc = mgc_process_log(obd, cld->cld_recover); @@ -1660,7 +1681,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) CERROR("Cannot process recover llog %d\n", rc); } - if (rc == 0 && cld->cld_params != NULL) { + if (rc == 0 && cld->cld_params) { rc = mgc_process_log(obd, cld->cld_params); if (rc == -ENOENT) { CDEBUG(D_MGC, diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 49ba885..0e02ae9 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -104,7 +104,7 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header, return old_size; new = kmemdup(*header, new_size, GFP_NOFS); - if (unlikely(new == NULL)) + if (unlikely(!new)) return -ENOMEM; kfree(*header); @@ -124,7 +124,7 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, return 0; new = kmemdup(*header, ext_size, GFP_NOFS); - if (unlikely(new == NULL)) + if (unlikely(!new)) return -ENOMEM; kfree(*header); @@ -149,7 +149,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); new = kzalloc(esize, GFP_NOFS); - if (unlikely(new == NULL)) + if (unlikely(!new)) return ERR_PTR(-ENOMEM); new->a_count = cpu_to_le32(count); @@ -180,7 +180,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, return -EINVAL; new = kzalloc(size, GFP_NOFS); - if (unlikely(new == NULL)) + if (unlikely(!new)) return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); @@ -300,7 +300,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); new = kzalloc(ext_size, GFP_NOFS); - if (unlikely(new == NULL)) + if (unlikely(!new)) return ERR_PTR(-ENOMEM); for (i = 0, j = 0; i < posix_count; i++) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 63246ba..191ec43 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -44,6 +44,7 @@ #include "../include/obd_support.h" #include "../include/lustre_fid.h" #include <linux/list.h> +#include <linux/sched.h> #include "../include/cl_object.h" #include "cl_internal.h" @@ -93,7 +94,7 @@ static int cl_io_invariant(const struct cl_io *io) * CIS_IO_GOING. */ ergo(io->ci_owned_nr > 0, io->ci_state == CIS_IO_GOING || - (io->ci_state == CIS_LOCKED && up != NULL)); + (io->ci_state == CIS_LOCKED && up)); } /** @@ -111,7 +112,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) slice = container_of(io->ci_layers.prev, struct cl_io_slice, cis_linkage); list_del_init(&slice->cis_linkage); - if (slice->cis_iop->op[io->ci_type].cio_fini != NULL) + if (slice->cis_iop->op[io->ci_type].cio_fini) slice->cis_iop->op[io->ci_type].cio_fini(env, slice); /* * Invalidate slice to catch use after free. This assumes that @@ -164,7 +165,7 @@ static int cl_io_init0(const struct lu_env *env, struct cl_io *io, result = 0; cl_object_for_each(scan, obj) { - if (scan->co_ops->coo_io_init != NULL) { + if (scan->co_ops->coo_io_init) { result = scan->co_ops->coo_io_init(env, scan, io); if (result != 0) break; @@ -186,7 +187,7 @@ int cl_io_sub_init(const struct lu_env *env, struct cl_io *io, struct cl_thread_info *info = cl_env_info(env); LASSERT(obj != cl_object_top(obj)); - if (info->clt_current_io == NULL) + if (!info->clt_current_io) info->clt_current_io = io; return cl_io_init0(env, io, iot, obj); } @@ -208,7 +209,7 @@ int cl_io_init(const struct lu_env *env, struct cl_io *io, struct cl_thread_info *info = cl_env_info(env); LASSERT(obj == cl_object_top(obj)); - LASSERT(info->clt_current_io == NULL); + LASSERT(!info->clt_current_io); info->clt_current_io = io; return cl_io_init0(env, io, iot, obj); @@ -224,7 +225,7 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, enum cl_io_type iot, loff_t pos, size_t count) { LINVRNT(iot == CIT_READ || iot == CIT_WRITE); - LINVRNT(io->ci_obj != NULL); + LINVRNT(io->ci_obj); LU_OBJECT_HEADER(D_VFSTRACE, env, &io->ci_obj->co_lu, "io range: %u [%llu, %llu) %u %u\n", @@ -292,7 +293,7 @@ static void cl_io_locks_sort(struct cl_io *io) list_for_each_entry_safe(curr, temp, &io->ci_lockset.cls_todo, cill_linkage) { - if (prev != NULL) { + if (prev) { switch (cl_lock_descr_sort(&prev->cill_descr, &curr->cill_descr)) { case 0: @@ -308,7 +309,8 @@ static void cl_io_locks_sort(struct cl_io *io) &prev->cill_linkage); done = 0; continue; /* don't change prev: it's - * still "previous" */ + * still "previous" + */ case -1: /* already in order */ break; } @@ -327,32 +329,31 @@ static void cl_io_locks_sort(struct cl_io *io) int cl_queue_match(const struct list_head *queue, const struct cl_lock_descr *need) { - struct cl_io_lock_link *scan; + struct cl_io_lock_link *scan; - list_for_each_entry(scan, queue, cill_linkage) { - if (cl_lock_descr_match(&scan->cill_descr, need)) - return 1; - } - return 0; + list_for_each_entry(scan, queue, cill_linkage) { + if (cl_lock_descr_match(&scan->cill_descr, need)) + return 1; + } + return 0; } EXPORT_SYMBOL(cl_queue_match); static int cl_queue_merge(const struct list_head *queue, const struct cl_lock_descr *need) { - struct cl_io_lock_link *scan; - - list_for_each_entry(scan, queue, cill_linkage) { - if (cl_lock_descr_cmp(&scan->cill_descr, need)) - continue; - cl_lock_descr_merge(&scan->cill_descr, need); - CDEBUG(D_VFSTRACE, "lock: %d: [%lu, %lu]\n", - scan->cill_descr.cld_mode, scan->cill_descr.cld_start, - scan->cill_descr.cld_end); - return 1; - } - return 0; + struct cl_io_lock_link *scan; + list_for_each_entry(scan, queue, cill_linkage) { + if (cl_lock_descr_cmp(&scan->cill_descr, need)) + continue; + cl_lock_descr_merge(&scan->cill_descr, need); + CDEBUG(D_VFSTRACE, "lock: %d: [%lu, %lu]\n", + scan->cill_descr.cld_mode, scan->cill_descr.cld_start, + scan->cill_descr.cld_end); + return 1; + } + return 0; } static int cl_lockset_match(const struct cl_lockset *set, @@ -399,11 +400,11 @@ static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock = link->cill_lock; list_del_init(&link->cill_linkage); - if (lock != NULL) { + if (lock) { cl_lock_release(env, lock, "io", io); link->cill_lock = NULL; } - if (link->cill_fini != NULL) + if (link->cill_fini) link->cill_fini(env, link); } @@ -419,7 +420,8 @@ static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, list_for_each_entry_safe(link, temp, &set->cls_todo, cill_linkage) { if (!cl_lockset_match(set, &link->cill_descr)) { /* XXX some locking to guarantee that locks aren't - * expanded in between. */ + * expanded in between. + */ result = cl_lockset_lock_one(env, io, set, link); if (result != 0) break; @@ -458,7 +460,7 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_invariant(io)); cl_io_for_each(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_lock == NULL) + if (!scan->cis_iop->op[io->ci_type].cio_lock) continue; result = scan->cis_iop->op[io->ci_type].cio_lock(env, scan); if (result != 0) @@ -503,7 +505,7 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) cl_lock_link_fini(env, io, link); } cl_io_for_each_reverse(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_unlock != NULL) + if (scan->cis_iop->op[io->ci_type].cio_unlock) scan->cis_iop->op[io->ci_type].cio_unlock(env, scan); } io->ci_state = CIS_UNLOCKED; @@ -529,7 +531,7 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io) result = 0; cl_io_for_each(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_iter_init == NULL) + if (!scan->cis_iop->op[io->ci_type].cio_iter_init) continue; result = scan->cis_iop->op[io->ci_type].cio_iter_init(env, scan); @@ -556,7 +558,7 @@ void cl_io_iter_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_invariant(io)); cl_io_for_each_reverse(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_iter_fini != NULL) + if (scan->cis_iop->op[io->ci_type].cio_iter_fini) scan->cis_iop->op[io->ci_type].cio_iter_fini(env, scan); } io->ci_state = CIS_IT_ENDED; @@ -581,7 +583,7 @@ static void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, /* layers have to be notified. */ cl_io_for_each_reverse(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_advance != NULL) + if (scan->cis_iop->op[io->ci_type].cio_advance) scan->cis_iop->op[io->ci_type].cio_advance(env, scan, nob); } @@ -621,7 +623,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, int result; link = kzalloc(sizeof(*link), GFP_NOFS); - if (link != NULL) { + if (link) { link->cill_descr = *descr; link->cill_fini = cl_free_io_lock_link; result = cl_io_lock_add(env, io, link); @@ -648,7 +650,7 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io) io->ci_state = CIS_IO_GOING; cl_io_for_each(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_start == NULL) + if (!scan->cis_iop->op[io->ci_type].cio_start) continue; result = scan->cis_iop->op[io->ci_type].cio_start(env, scan); if (result != 0) @@ -673,7 +675,7 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_invariant(io)); cl_io_for_each_reverse(scan, io) { - if (scan->cis_iop->op[io->ci_type].cio_end != NULL) + if (scan->cis_iop->op[io->ci_type].cio_end) scan->cis_iop->op[io->ci_type].cio_end(env, scan); /* TODO: error handling. */ } @@ -687,7 +689,7 @@ cl_io_slice_page(const struct cl_io_slice *ios, struct cl_page *page) const struct cl_page_slice *slice; slice = cl_page_at(page, ios->cis_obj->co_lu.lo_dev->ld_type); - LINVRNT(slice != NULL); + LINVRNT(slice); return slice; } @@ -759,11 +761,11 @@ int cl_io_read_page(const struct lu_env *env, struct cl_io *io, * "parallel io" (see CLO_REPEAT loops in cl_lock.c). */ cl_io_for_each(scan, io) { - if (scan->cis_iop->cio_read_page != NULL) { + if (scan->cis_iop->cio_read_page) { const struct cl_page_slice *slice; slice = cl_io_slice_page(scan, page); - LINVRNT(slice != NULL); + LINVRNT(slice); result = scan->cis_iop->cio_read_page(env, scan, slice); if (result != 0) break; @@ -798,7 +800,7 @@ int cl_io_prepare_write(const struct lu_env *env, struct cl_io *io, LASSERT(cl_page_in_io(page, io)); cl_io_for_each_reverse(scan, io) { - if (scan->cis_iop->cio_prepare_write != NULL) { + if (scan->cis_iop->cio_prepare_write) { const struct cl_page_slice *slice; slice = cl_io_slice_page(scan, page); @@ -833,11 +835,11 @@ int cl_io_commit_write(const struct lu_env *env, struct cl_io *io, * state. Better (and more general) way of dealing with such situation * is needed. */ - LASSERT(cl_page_is_owned(page, io) || page->cp_parent != NULL); + LASSERT(cl_page_is_owned(page, io) || page->cp_parent); LASSERT(cl_page_in_io(page, io)); cl_io_for_each(scan, io) { - if (scan->cis_iop->cio_commit_write != NULL) { + if (scan->cis_iop->cio_commit_write) { const struct cl_page_slice *slice; slice = cl_io_slice_page(scan, page); @@ -872,7 +874,7 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io, LINVRNT(crt < ARRAY_SIZE(scan->cis_iop->req_op)); cl_io_for_each(scan, io) { - if (scan->cis_iop->req_op[crt].cio_submit == NULL) + if (!scan->cis_iop->req_op[crt].cio_submit) continue; result = scan->cis_iop->req_op[crt].cio_submit(env, scan, crt, queue); @@ -900,7 +902,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, int rc; cl_page_list_for_each(pg, &queue->c2_qin) { - LASSERT(pg->cp_sync_io == NULL); + LASSERT(!pg->cp_sync_io); pg->cp_sync_io = anchor; } @@ -913,14 +915,14 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, * clean pages), count them as completed to avoid infinite * wait. */ - cl_page_list_for_each(pg, &queue->c2_qin) { + cl_page_list_for_each(pg, &queue->c2_qin) { pg->cp_sync_io = NULL; cl_sync_io_note(anchor, 1); - } + } - /* wait for the IO to be finished. */ - rc = cl_sync_io_wait(env, io, &queue->c2_qout, - anchor, timeout); + /* wait for the IO to be finished. */ + rc = cl_sync_io_wait(env, io, &queue->c2_qout, + anchor, timeout); } else { LASSERT(list_empty(&queue->c2_qout.pl_pages)); cl_page_list_for_each(pg, &queue->c2_qin) @@ -1026,7 +1028,7 @@ void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice, { struct list_head *linkage = &slice->cis_linkage; - LASSERT((linkage->prev == NULL && linkage->next == NULL) || + LASSERT((!linkage->prev && !linkage->next) || list_empty(linkage)); list_add_tail(linkage, &io->ci_layers); @@ -1053,8 +1055,9 @@ EXPORT_SYMBOL(cl_page_list_init); void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) { /* it would be better to check that page is owned by "current" io, but - * it is not passed here. */ - LASSERT(page->cp_owner != NULL); + * it is not passed here. + */ + LASSERT(page->cp_owner); LINVRNT(plist->pl_owner == current); lockdep_off(); @@ -1263,7 +1266,7 @@ EXPORT_SYMBOL(cl_2queue_init_page); */ struct cl_io *cl_io_top(struct cl_io *io) { - while (io->ci_parent != NULL) + while (io->ci_parent) io = io->ci_parent; return io; } @@ -1296,13 +1299,13 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) LASSERT(list_empty(&req->crq_pages)); LASSERT(req->crq_nrpages == 0); LINVRNT(list_empty(&req->crq_layers)); - LINVRNT(equi(req->crq_nrobjs > 0, req->crq_o != NULL)); + LINVRNT(equi(req->crq_nrobjs > 0, req->crq_o)); - if (req->crq_o != NULL) { + if (req->crq_o) { for (i = 0; i < req->crq_nrobjs; ++i) { struct cl_object *obj = req->crq_o[i].ro_obj; - if (obj != NULL) { + if (obj) { lu_object_ref_del_at(&obj->co_lu, &req->crq_o[i].ro_obj_ref, "cl_req", req); @@ -1326,7 +1329,7 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { dev = lu2cl_dev(slice->cpl_obj->co_lu.lo_dev); - if (dev->cd_ops->cdo_req_init != NULL) { + if (dev->cd_ops->cdo_req_init) { result = dev->cd_ops->cdo_req_init(env, dev, req); if (result != 0) @@ -1334,7 +1337,7 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, } } page = page->cp_child; - } while (page != NULL && result == 0); + } while (page && result == 0); return result; } @@ -1353,7 +1356,7 @@ void cl_req_completion(const struct lu_env *env, struct cl_req *req, int rc) slice = list_entry(req->crq_layers.prev, struct cl_req_slice, crs_linkage); list_del_init(&slice->crs_linkage); - if (slice->crs_ops->cro_completion != NULL) + if (slice->crs_ops->cro_completion) slice->crs_ops->cro_completion(env, slice, rc); } cl_req_free(env, req); @@ -1371,7 +1374,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, LINVRNT(nr_objects > 0); req = kzalloc(sizeof(*req), GFP_NOFS); - if (req != NULL) { + if (req) { int result; req->crq_type = crt; @@ -1380,7 +1383,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]), GFP_NOFS); - if (req->crq_o != NULL) { + if (req->crq_o) { req->crq_nrobjs = nr_objects; result = cl_req_init(env, req, page); } else @@ -1408,7 +1411,7 @@ void cl_req_page_add(const struct lu_env *env, page = cl_page_top(page); LASSERT(list_empty(&page->cp_flight)); - LASSERT(page->cp_req == NULL); + LASSERT(!page->cp_req); CL_PAGE_DEBUG(D_PAGE, env, page, "req %p, %d, %u\n", req, req->crq_type, req->crq_nrpages); @@ -1418,7 +1421,7 @@ void cl_req_page_add(const struct lu_env *env, page->cp_req = req; obj = cl_object_top(page->cp_obj); for (i = 0, rqo = req->crq_o; obj != rqo->ro_obj; ++i, ++rqo) { - if (rqo->ro_obj == NULL) { + if (!rqo->ro_obj) { rqo->ro_obj = obj; cl_object_get(obj); lu_object_ref_add_at(&obj->co_lu, &rqo->ro_obj_ref, @@ -1463,11 +1466,11 @@ int cl_req_prep(const struct lu_env *env, struct cl_req *req) * of objects. */ for (i = 0; i < req->crq_nrobjs; ++i) - LASSERT(req->crq_o[i].ro_obj != NULL); + LASSERT(req->crq_o[i].ro_obj); result = 0; list_for_each_entry(slice, &req->crq_layers, crs_linkage) { - if (slice->crs_ops->cro_prep != NULL) { + if (slice->crs_ops->cro_prep) { result = slice->crs_ops->cro_prep(env, slice); if (result != 0) break; @@ -1501,9 +1504,8 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, scan = cl_page_at(page, slice->crs_dev->cd_lu_dev.ld_type); - LASSERT(scan != NULL); obj = scan->cpl_obj; - if (slice->crs_ops->cro_attr_set != NULL) + if (slice->crs_ops->cro_attr_set) slice->crs_ops->cro_attr_set(env, slice, obj, attr + i, flags); } @@ -1511,9 +1513,6 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, } EXPORT_SYMBOL(cl_req_attr_set); -/* XXX complete(), init_completion(), and wait_for_completion(), until they are - * implemented in libcfs. */ -# include <linux/sched.h> /** * Initialize synchronous io wait anchor, for transfer of \a nrpages pages. diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 1836dc0..7b7f344 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -96,7 +96,7 @@ static int cl_lock_invariant(const struct lu_env *env, result = atomic_read(&lock->cll_ref) > 0 && cl_lock_invariant_trusted(env, lock); - if (!result && env != NULL) + if (!result && env) CL_LOCK_DEBUG(D_ERROR, env, lock, "invariant broken"); return result; } @@ -288,7 +288,7 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); obj = lock->cll_descr.cld_obj; - LINVRNT(obj != NULL); + LINVRNT(obj); CDEBUG(D_TRACE, "releasing reference: %d %p %lu\n", atomic_read(&lock->cll_ref), lock, RETIP); @@ -362,7 +362,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, struct lu_object_header *head; lock = kmem_cache_alloc(cl_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (lock != NULL) { + if (lock) { atomic_set(&lock->cll_ref, 1); lock->cll_descr = *descr; lock->cll_state = CLS_NEW; @@ -461,7 +461,7 @@ static int cl_lock_fits_into(const struct lu_env *env, LINVRNT(cl_lock_invariant_trusted(env, lock)); list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_fits_into != NULL && + if (slice->cls_ops->clo_fits_into && !slice->cls_ops->clo_fits_into(env, slice, need, io)) return 0; } @@ -524,14 +524,14 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, lock = cl_lock_lookup(env, obj, io, need); spin_unlock(&head->coh_lock_guard); - if (lock == NULL) { + if (!lock) { lock = cl_lock_alloc(env, obj, io, need); if (!IS_ERR(lock)) { struct cl_lock *ghost; spin_lock(&head->coh_lock_guard); ghost = cl_lock_lookup(env, obj, io, need); - if (ghost == NULL) { + if (!ghost) { cl_lock_get_trust(lock); list_add_tail(&lock->cll_linkage, &head->coh_locks); @@ -572,7 +572,7 @@ struct cl_lock *cl_lock_peek(const struct lu_env *env, const struct cl_io *io, spin_lock(&head->coh_lock_guard); lock = cl_lock_lookup(env, obj, io, need); spin_unlock(&head->coh_lock_guard); - if (lock == NULL) + if (!lock) return NULL; cl_lock_mutex_get(env, lock); @@ -584,7 +584,7 @@ struct cl_lock *cl_lock_peek(const struct lu_env *env, const struct cl_io *io, cl_lock_put(env, lock); lock = NULL; } - } while (lock == NULL); + } while (!lock); cl_lock_hold_add(env, lock, scope, source); cl_lock_user_add(env, lock); @@ -775,7 +775,7 @@ static void cl_lock_cancel0(const struct lu_env *env, struct cl_lock *lock) lock->cll_flags |= CLF_CANCELLED; list_for_each_entry_reverse(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_cancel != NULL) + if (slice->cls_ops->clo_cancel) slice->cls_ops->clo_cancel(env, slice); } } @@ -812,7 +812,7 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) */ list_for_each_entry_reverse(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_delete != NULL) + if (slice->cls_ops->clo_delete) slice->cls_ops->clo_delete(env, slice); } /* @@ -935,7 +935,8 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) if (result == 0) { /* To avoid being interrupted by the 'non-fatal' signals * (SIGCHLD, for instance), we'd block them temporarily. - * LU-305 */ + * LU-305 + */ blocked = cfs_block_sigsinv(LUSTRE_FATAL_SIGS); init_waitqueue_entry(&waiter, current); @@ -946,7 +947,8 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) LASSERT(cl_lock_nr_mutexed(env) == 0); /* Returning ERESTARTSYS instead of EINTR so syscalls - * can be restarted if signals are pending here */ + * can be restarted if signals are pending here + */ result = -ERESTARTSYS; if (likely(!OBD_FAIL_CHECK(OBD_FAIL_LOCK_STATE_WAIT_INTR))) { schedule(); @@ -974,7 +976,7 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); list_for_each_entry(slice, &lock->cll_layers, cls_linkage) - if (slice->cls_ops->clo_state != NULL) + if (slice->cls_ops->clo_state) slice->cls_ops->clo_state(env, slice, state); wake_up_all(&lock->cll_wq); } @@ -1039,7 +1041,7 @@ static int cl_unuse_try_internal(const struct lu_env *env, struct cl_lock *lock) result = -ENOSYS; list_for_each_entry_reverse(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_unuse != NULL) { + if (slice->cls_ops->clo_unuse) { result = slice->cls_ops->clo_unuse(env, slice); if (result != 0) break; @@ -1072,7 +1074,7 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) result = -ENOSYS; state = cl_lock_intransit(env, lock); list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_use != NULL) { + if (slice->cls_ops->clo_use) { result = slice->cls_ops->clo_use(env, slice); if (result != 0) break; @@ -1125,7 +1127,7 @@ static int cl_enqueue_kick(const struct lu_env *env, result = -ENOSYS; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_enqueue != NULL) { + if (slice->cls_ops->clo_enqueue) { result = slice->cls_ops->clo_enqueue(env, slice, io, flags); if (result != 0) @@ -1170,7 +1172,8 @@ int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock, /* kick layers. */ result = cl_enqueue_kick(env, lock, io, flags); /* For AGL case, the cl_lock::cll_state may - * become CLS_HELD already. */ + * become CLS_HELD already. + */ if (result == 0 && lock->cll_state == CLS_QUEUING) cl_lock_state_set(env, lock, CLS_ENQUEUED); break; @@ -1215,7 +1218,7 @@ int cl_lock_enqueue_wait(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(lock)); LASSERT(lock->cll_state == CLS_QUEUING); - LASSERT(lock->cll_conflict != NULL); + LASSERT(lock->cll_conflict); conflict = lock->cll_conflict; lock->cll_conflict = NULL; @@ -1258,7 +1261,7 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, do { result = cl_enqueue_try(env, lock, io, enqflags); if (result == CLO_WAIT) { - if (lock->cll_conflict != NULL) + if (lock->cll_conflict) result = cl_lock_enqueue_wait(env, lock, 1); else result = cl_lock_state_wait(env, lock); @@ -1300,7 +1303,8 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) } /* Only if the lock is in CLS_HELD or CLS_ENQUEUED state, it can hold - * underlying resources. */ + * underlying resources. + */ if (!(lock->cll_state == CLS_HELD || lock->cll_state == CLS_ENQUEUED)) { cl_lock_user_del(env, lock); return 0; @@ -1416,7 +1420,7 @@ int cl_wait_try(const struct lu_env *env, struct cl_lock *lock) result = -ENOSYS; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_wait != NULL) { + if (slice->cls_ops->clo_wait) { result = slice->cls_ops->clo_wait(env, slice); if (result != 0) break; @@ -1449,7 +1453,7 @@ int cl_wait(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); LASSERTF(lock->cll_state == CLS_ENQUEUED || lock->cll_state == CLS_HELD, - "Wrong state %d \n", lock->cll_state); + "Wrong state %d\n", lock->cll_state); LASSERT(lock->cll_holds > 0); do { @@ -1487,7 +1491,7 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock) pound = 0; list_for_each_entry_reverse(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_weigh != NULL) { + if (slice->cls_ops->clo_weigh) { ounce = slice->cls_ops->clo_weigh(env, slice); pound += ounce; if (pound < ounce) /* over-weight^Wflow */ @@ -1523,7 +1527,7 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); list_for_each_entry_reverse(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_modify != NULL) { + if (slice->cls_ops->clo_modify) { result = slice->cls_ops->clo_modify(env, slice, desc); if (result != 0) return result; @@ -1584,7 +1588,7 @@ int cl_lock_closure_build(const struct lu_env *env, struct cl_lock *lock, result = cl_lock_enclosure(env, lock, closure); if (result == 0) { list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { - if (slice->cls_ops->clo_closure != NULL) { + if (slice->cls_ops->clo_closure) { result = slice->cls_ops->clo_closure(env, slice, closure); if (result != 0) @@ -1777,13 +1781,15 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, lock = NULL; need->cld_mode = CLM_READ; /* CLM_READ matches both READ & WRITE, but - * not PHANTOM */ + * not PHANTOM + */ need->cld_start = need->cld_end = index; need->cld_enq_flags = 0; spin_lock(&head->coh_lock_guard); /* It is fine to match any group lock since there could be only one - * with a uniq gid and it conflicts with all other lock modes too */ + * with a uniq gid and it conflicts with all other lock modes too + */ list_for_each_entry(scan, &head->coh_locks, cll_linkage) { if (scan != except && (scan->cll_descr.cld_mode == CLM_GROUP || @@ -1798,7 +1804,8 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, (canceld || !(scan->cll_flags & CLF_CANCELLED)) && (pending || !(scan->cll_flags & CLF_CANCELPEND))) { /* Don't increase cs_hit here since this - * is just a helper function. */ + * is just a helper function. + */ cl_lock_get_trust(scan); lock = scan; break; @@ -1820,7 +1827,6 @@ static pgoff_t pgoff_at_lock(struct cl_page *page, struct cl_lock *lock) dtype = lock->cll_descr.cld_obj->co_lu.lo_dev->ld_type; slice = cl_page_at(page, dtype); - LASSERT(slice != NULL); return slice->cpl_page->cp_index; } @@ -1840,11 +1846,12 @@ static int check_and_discard_cb(const struct lu_env *env, struct cl_io *io, /* refresh non-overlapped index */ tmp = cl_lock_at_pgoff(env, lock->cll_descr.cld_obj, index, lock, 1, 0); - if (tmp != NULL) { + if (tmp) { /* Cache the first-non-overlapped index so as to skip * all pages within [index, clt_fn_index). This * is safe because if tmp lock is canceled, it will - * discard these pages. */ + * discard these pages. + */ info->clt_fn_index = tmp->cll_descr.cld_end + 1; if (tmp->cll_descr.cld_end == CL_PAGE_EOF) info->clt_fn_index = CL_PAGE_EOF; @@ -1950,7 +1957,7 @@ void cl_locks_prune(const struct lu_env *env, struct cl_object *obj, int cancel) * already destroyed (as otherwise they will be left unprotected). */ LASSERT(ergo(!cancel, - head->coh_tree.rnode == NULL && head->coh_pages == 0)); + !head->coh_tree.rnode && head->coh_pages == 0)); spin_lock(&head->coh_lock_guard); while (!list_empty(&head->coh_locks)) { @@ -2194,7 +2201,7 @@ void cl_lock_print(const struct lu_env *env, void *cookie, (*printer)(env, cookie, " %s@%p: ", slice->cls_obj->co_lu.lo_dev->ld_type->ldt_name, slice); - if (slice->cls_ops->clo_print != NULL) + if (slice->cls_ops->clo_print) slice->cls_ops->clo_print(env, cookie, printer, slice); (*printer)(env, cookie, "\n"); } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f118983..39b4fd0 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -152,7 +152,7 @@ struct cl_object *cl_object_top(struct cl_object *o) struct cl_object_header *hdr = cl_object_header(o); struct cl_object *top; - while (hdr->coh_parent != NULL) + while (hdr->coh_parent) hdr = hdr->coh_parent; top = lu2cl(lu_object_top(&hdr->coh_lu)); @@ -217,7 +217,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, top = obj->co_lu.lo_header; result = 0; list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_get != NULL) { + if (obj->co_ops->coo_attr_get) { result = obj->co_ops->coo_attr_get(env, obj, attr); if (result != 0) { if (result > 0) @@ -249,7 +249,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, result = 0; list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_set != NULL) { + if (obj->co_ops->coo_attr_set) { result = obj->co_ops->coo_attr_set(env, obj, attr, v); if (result != 0) { if (result > 0) @@ -280,7 +280,7 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, result = 0; list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_glimpse != NULL) { + if (obj->co_ops->coo_glimpse) { result = obj->co_ops->coo_glimpse(env, obj, lvb); if (result != 0) break; @@ -306,7 +306,7 @@ int cl_conf_set(const struct lu_env *env, struct cl_object *obj, top = obj->co_lu.lo_header; result = 0; list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_conf_set != NULL) { + if (obj->co_ops->coo_conf_set) { result = obj->co_ops->coo_conf_set(env, obj, conf); if (result != 0) break; @@ -328,7 +328,7 @@ void cl_object_kill(const struct lu_env *env, struct cl_object *obj) struct cl_object_header *hdr; hdr = cl_object_header(obj); - LASSERT(hdr->coh_tree.rnode == NULL); + LASSERT(!hdr->coh_tree.rnode); LASSERT(hdr->coh_pages == 0); set_bit(LU_OBJECT_HEARD_BANSHEE, &hdr->coh_lu.loh_flags); @@ -541,7 +541,7 @@ static void cl_env_init0(struct cl_env *cle, void *debug) { LASSERT(cle->ce_ref == 0); LASSERT(cle->ce_magic == &cl_env_init0); - LASSERT(cle->ce_debug == NULL && cle->ce_owner == NULL); + LASSERT(!cle->ce_debug && !cle->ce_owner); cle->ce_ref = 1; cle->ce_debug = debug; @@ -576,7 +576,7 @@ static int cl_env_hops_keycmp(const void *key, struct hlist_node *hn) { struct cl_env *cle = cl_env_hops_obj(hn); - LASSERT(cle->ce_owner != NULL); + LASSERT(cle->ce_owner); return (key == cle->ce_owner); } @@ -610,7 +610,7 @@ static inline void cl_env_attach(struct cl_env *cle) if (cle) { int rc; - LASSERT(cle->ce_owner == NULL); + LASSERT(!cle->ce_owner); cle->ce_owner = (void *) (long) current->pid; rc = cfs_hash_add_unique(cl_env_hash, cle->ce_owner, &cle->ce_node); @@ -638,7 +638,7 @@ static int cl_env_store_init(void) CFS_HASH_MAX_THETA, &cl_env_hops, CFS_HASH_RW_BKTLOCK); - return cl_env_hash != NULL ? 0 : -ENOMEM; + return cl_env_hash ? 0 : -ENOMEM; } static void cl_env_store_fini(void) @@ -648,7 +648,7 @@ static void cl_env_store_fini(void) static inline struct cl_env *cl_env_detach(struct cl_env *cle) { - if (cle == NULL) + if (!cle) cle = cl_env_fetch(); if (cle && cle->ce_owner) @@ -663,7 +663,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug) struct cl_env *cle; cle = kmem_cache_alloc(cl_env_kmem, GFP_NOFS | __GFP_ZERO); - if (cle != NULL) { + if (cle) { int rc; INIT_LIST_HEAD(&cle->ce_linkage); @@ -717,7 +717,7 @@ static struct lu_env *cl_env_peek(int *refcheck) env = NULL; cle = cl_env_fetch(); - if (cle != NULL) { + if (cle) { CL_ENV_INC(hit); env = &cle->ce_lu; *refcheck = ++cle->ce_ref; @@ -742,7 +742,7 @@ struct lu_env *cl_env_get(int *refcheck) struct lu_env *env; env = cl_env_peek(refcheck); - if (env == NULL) { + if (!env) { env = cl_env_new(lu_context_tags_default, lu_session_tags_default, __builtin_return_address(0)); @@ -769,7 +769,7 @@ struct lu_env *cl_env_alloc(int *refcheck, __u32 tags) { struct lu_env *env; - LASSERT(cl_env_peek(refcheck) == NULL); + LASSERT(!cl_env_peek(refcheck)); env = cl_env_new(tags, tags, __builtin_return_address(0)); if (!IS_ERR(env)) { struct cl_env *cle; @@ -784,7 +784,7 @@ EXPORT_SYMBOL(cl_env_alloc); static void cl_env_exit(struct cl_env *cle) { - LASSERT(cle->ce_owner == NULL); + LASSERT(!cle->ce_owner); lu_context_exit(&cle->ce_lu.le_ctx); lu_context_exit(&cle->ce_ses); } @@ -803,7 +803,7 @@ void cl_env_put(struct lu_env *env, int *refcheck) cle = cl_env_container(env); LASSERT(cle->ce_ref > 0); - LASSERT(ergo(refcheck != NULL, cle->ce_ref == *refcheck)); + LASSERT(ergo(refcheck, cle->ce_ref == *refcheck)); CDEBUG(D_OTHER, "%d@%p\n", cle->ce_ref, cle); if (--cle->ce_ref == 0) { @@ -878,7 +878,7 @@ struct lu_env *cl_env_nested_get(struct cl_env_nest *nest) nest->cen_cookie = NULL; env = cl_env_peek(&nest->cen_refcheck); - if (env != NULL) { + if (env) { if (!cl_io_is_going(env)) return env; cl_env_put(env, &nest->cen_refcheck); @@ -930,14 +930,12 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site, const char *typename; struct lu_device *d; - LASSERT(ldt != NULL); - typename = ldt->ldt_name; d = ldt->ldt_ops->ldto_device_alloc(env, ldt, NULL); if (!IS_ERR(d)) { int rc; - if (site != NULL) + if (site) d->ld_site = site; rc = ldt->ldt_ops->ldto_device_init(env, d, typename, next); if (rc == 0) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 61f28eb..72f9924 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -69,7 +69,7 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, */ static struct cl_page *cl_page_top_trusted(struct cl_page *page) { - while (page->cp_parent != NULL) + while (page->cp_parent) page = page->cp_parent; return page; } @@ -110,7 +110,7 @@ cl_page_at_trusted(const struct cl_page *page, return slice; } page = page->cp_child; - } while (page != NULL); + } while (page); return NULL; } @@ -127,7 +127,7 @@ struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index) assert_spin_locked(&hdr->coh_page_guard); page = radix_tree_lookup(&hdr->coh_tree, index); - if (page != NULL) + if (page) cl_page_get_trust(page); return page; } @@ -188,7 +188,7 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj, * Pages for lsm-less file has no underneath sub-page * for osc, in case of ... */ - PASSERT(env, page, slice != NULL); + PASSERT(env, page, slice); page = slice->cpl_page; /* @@ -245,9 +245,9 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) struct cl_object *obj = page->cp_obj; PASSERT(env, page, list_empty(&page->cp_batch)); - PASSERT(env, page, page->cp_owner == NULL); - PASSERT(env, page, page->cp_req == NULL); - PASSERT(env, page, page->cp_parent == NULL); + PASSERT(env, page, !page->cp_owner); + PASSERT(env, page, !page->cp_req); + PASSERT(env, page, !page->cp_parent); PASSERT(env, page, page->cp_state == CPS_FREEING); might_sleep(); @@ -284,7 +284,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, struct lu_object_header *head; page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); - if (page != NULL) { + if (page) { int result = 0; atomic_set(&page->cp_ref, 1); @@ -305,7 +305,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, head = o->co_lu.lo_header; list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { - if (o->co_ops->coo_page_init != NULL) { + if (o->co_ops->coo_page_init) { result = o->co_ops->coo_page_init(env, o, page, vmpage); if (result != 0) { @@ -369,13 +369,13 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, */ page = cl_vmpage_page(vmpage, o); PINVRNT(env, page, - ergo(page != NULL, + ergo(page, cl_page_vmpage(env, page) == vmpage && (void *)radix_tree_lookup(&hdr->coh_tree, idx) == page)); } - if (page != NULL) + if (page) return page; /* allocate and initialize cl_page */ @@ -385,7 +385,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, if (type == CPT_TRANSIENT) { if (parent) { - LASSERT(page->cp_parent == NULL); + LASSERT(!page->cp_parent); page->cp_parent = parent; parent->cp_child = page; } @@ -418,7 +418,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, "fail to insert into radix tree: %d\n", err); } else { if (parent) { - LASSERT(page->cp_parent == NULL); + LASSERT(!page->cp_parent); page->cp_parent = parent; parent->cp_child = page; } @@ -426,7 +426,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, } spin_unlock(&hdr->coh_page_guard); - if (unlikely(ghost != NULL)) { + if (unlikely(ghost)) { cl_page_delete0(env, ghost, 0); cl_page_free(env, ghost); } @@ -467,14 +467,13 @@ static inline int cl_page_invariant(const struct cl_page *pg) owner = pg->cp_owner; return cl_page_in_use(pg) && - ergo(parent != NULL, parent->cp_child == pg) && - ergo(child != NULL, child->cp_parent == pg) && - ergo(child != NULL, pg->cp_obj != child->cp_obj) && - ergo(parent != NULL, pg->cp_obj != parent->cp_obj) && - ergo(owner != NULL && parent != NULL, + ergo(parent, parent->cp_child == pg) && + ergo(child, child->cp_parent == pg) && + ergo(child, pg->cp_obj != child->cp_obj) && + ergo(parent, pg->cp_obj != parent->cp_obj) && + ergo(owner && parent, parent->cp_owner == pg->cp_owner->ci_parent) && - ergo(owner != NULL && child != NULL, - child->cp_owner->ci_parent == owner) && + ergo(owner && child, child->cp_owner->ci_parent == owner) && /* * Either page is early in initialization (has neither child * nor parent yet), or it is in the object radix tree. @@ -482,7 +481,7 @@ static inline int cl_page_invariant(const struct cl_page *pg) ergo(pg->cp_state < CPS_FREEING && pg->cp_type == CPT_CACHEABLE, (void *)radix_tree_lookup(&header->coh_tree, pg->cp_index) == pg || - (child == NULL && parent == NULL)); + (!child && !parent)); } static void cl_page_state_set0(const struct lu_env *env, @@ -535,10 +534,10 @@ static void cl_page_state_set0(const struct lu_env *env, old = page->cp_state; PASSERT(env, page, allowed_transitions[old][state]); CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state); - for (; page != NULL; page = page->cp_child) { + for (; page; page = page->cp_child) { PASSERT(env, page, page->cp_state == old); PASSERT(env, page, - equi(state == CPS_OWNED, page->cp_owner != NULL)); + equi(state == CPS_OWNED, page->cp_owner)); cl_page_state_set_trust(page, state); } @@ -584,7 +583,7 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) LASSERT(page->cp_state == CPS_FREEING); LASSERT(atomic_read(&page->cp_ref) == 0); - PASSERT(env, page, page->cp_owner == NULL); + PASSERT(env, page, !page->cp_owner); PASSERT(env, page, list_empty(&page->cp_batch)); /* * Page is no longer reachable by other threads. Tear @@ -609,11 +608,11 @@ struct page *cl_page_vmpage(const struct lu_env *env, struct cl_page *page) page = cl_page_top(page); do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { - if (slice->cpl_ops->cpo_vmpage != NULL) + if (slice->cpl_ops->cpo_vmpage) return slice->cpl_ops->cpo_vmpage(env, slice); } page = page->cp_child; - } while (page != NULL); + } while (page); LBUG(); /* ->cpo_vmpage() has to be defined somewhere in the stack */ } EXPORT_SYMBOL(cl_page_vmpage); @@ -639,10 +638,10 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) * can be rectified easily. */ top = (struct cl_page *)vmpage->private; - if (top == NULL) + if (!top) return NULL; - for (page = top; page != NULL; page = page->cp_child) { + for (page = top; page; page = page->cp_child) { if (cl_object_same(page->cp_obj, obj)) { cl_page_get_trust(page); break; @@ -689,7 +688,7 @@ EXPORT_SYMBOL(cl_page_at); cpl_linkage) { \ __method = *(void **)((char *)__scan->cpl_ops + \ __op); \ - if (__method != NULL) { \ + if (__method) { \ __result = (*__method)(__env, __scan, \ ## __VA_ARGS__); \ if (__result != 0) \ @@ -697,7 +696,7 @@ EXPORT_SYMBOL(cl_page_at); } \ } \ __page = __page->cp_child; \ - } while (__page != NULL && __result == 0); \ + } while (__page && __result == 0); \ if (__result > 0) \ __result = 0; \ __result; \ @@ -717,12 +716,12 @@ do { \ cpl_linkage) { \ __method = *(void **)((char *)__scan->cpl_ops + \ __op); \ - if (__method != NULL) \ + if (__method) \ (*__method)(__env, __scan, \ ## __VA_ARGS__); \ } \ __page = __page->cp_child; \ - } while (__page != NULL); \ + } while (__page); \ } while (0) #define CL_PAGE_INVOID_REVERSE(_env, _page, _op, _proto, ...) \ @@ -734,19 +733,19 @@ do { \ void (*__method)_proto; \ \ /* get to the bottom page. */ \ - while (__page->cp_child != NULL) \ + while (__page->cp_child) \ __page = __page->cp_child; \ do { \ list_for_each_entry_reverse(__scan, &__page->cp_layers, \ cpl_linkage) { \ __method = *(void **)((char *)__scan->cpl_ops + \ __op); \ - if (__method != NULL) \ + if (__method) \ (*__method)(__env, __scan, \ ## __VA_ARGS__); \ } \ __page = __page->cp_parent; \ - } while (__page != NULL); \ + } while (__page); \ } while (0) static int cl_page_invoke(const struct lu_env *env, @@ -772,8 +771,8 @@ static void cl_page_invoid(const struct lu_env *env, static void cl_page_owner_clear(struct cl_page *page) { - for (page = cl_page_top(page); page != NULL; page = page->cp_child) { - if (page->cp_owner != NULL) { + for (page = cl_page_top(page); page; page = page->cp_child) { + if (page->cp_owner) { LASSERT(page->cp_owner->ci_owned_nr > 0); page->cp_owner->ci_owned_nr--; page->cp_owner = NULL; @@ -784,10 +783,8 @@ static void cl_page_owner_clear(struct cl_page *page) static void cl_page_owner_set(struct cl_page *page) { - for (page = cl_page_top(page); page != NULL; page = page->cp_child) { - LASSERT(page->cp_owner != NULL); + for (page = cl_page_top(page); page; page = page->cp_child) page->cp_owner->ci_owned_nr++; - } } void cl_page_disown0(const struct lu_env *env, @@ -862,8 +859,8 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io, struct cl_io *, int), io, nonblock); if (result == 0) { - PASSERT(env, pg, pg->cp_owner == NULL); - PASSERT(env, pg, pg->cp_req == NULL); + PASSERT(env, pg, !pg->cp_owner); + PASSERT(env, pg, !pg->cp_req); pg->cp_owner = io; pg->cp_task = current; cl_page_owner_set(pg); @@ -921,7 +918,7 @@ void cl_page_assume(const struct lu_env *env, io = cl_io_top(io); cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_assume)); - PASSERT(env, pg, pg->cp_owner == NULL); + PASSERT(env, pg, !pg->cp_owner); pg->cp_owner = io; pg->cp_task = current; cl_page_owner_set(pg); @@ -1037,7 +1034,7 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, * skip removing it. */ tmp = pg->cp_child; - for (; tmp != NULL; tmp = tmp->cp_child) { + for (; tmp; tmp = tmp->cp_child) { void *value; struct cl_object_header *hdr; @@ -1135,7 +1132,7 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) pg = cl_page_top_trusted((struct cl_page *)pg); slice = container_of(pg->cp_layers.next, const struct cl_page_slice, cpl_linkage); - PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked != NULL); + PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked); /* * Call ->cpo_is_vmlocked() directly instead of going through * CL_PAGE_INVOKE(), because cl_page_is_vmlocked() is used by @@ -1216,7 +1213,7 @@ void cl_page_completion(const struct lu_env *env, PASSERT(env, pg, crt < CRT_NR); /* cl_page::cp_req already cleared by the caller (osc_completion()) */ - PASSERT(env, pg, pg->cp_req == NULL); + PASSERT(env, pg, !pg->cp_req); PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt)); CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret); @@ -1304,7 +1301,7 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, return -EINVAL; list_for_each_entry(scan, &pg->cp_layers, cpl_linkage) { - if (scan->cpl_ops->io[crt].cpo_cache_add == NULL) + if (!scan->cpl_ops->io[crt].cpo_cache_add) continue; result = scan->cpl_ops->io[crt].cpo_cache_add(env, scan, io); @@ -1450,8 +1447,8 @@ void cl_page_print(const struct lu_env *env, void *cookie, { struct cl_page *scan; - for (scan = cl_page_top((struct cl_page *)pg); - scan != NULL; scan = scan->cp_child) + for (scan = cl_page_top((struct cl_page *)pg); scan; + scan = scan->cp_child) cl_page_header_print(env, cookie, printer, scan); CL_PAGE_INVOKE(env, (struct cl_page *)pg, CL_PAGE_OP(cpo_print), (const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 65cf46c..c1310c2 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -42,7 +42,6 @@ #include "../../include/linux/lnet/lnetctl.h" #include "../include/lustre_debug.h" #include "../include/lprocfs_status.h" -#include "../include/lustre/lustre_build_version.h" #include <linux/list.h> #include "../include/cl_object.h" #include "llog_internal.h" @@ -52,7 +51,7 @@ EXPORT_SYMBOL(obd_devs); struct list_head obd_types; DEFINE_RWLOCK(obd_dev_lock); -/* The following are visible and mutable through /proc/sys/lustre/. */ +/* The following are visible and mutable through /sys/fs/lustre. */ unsigned int obd_debug_peer_on_timeout; EXPORT_SYMBOL(obd_debug_peer_on_timeout); unsigned int obd_dump_on_timeout; @@ -67,7 +66,7 @@ unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT; /* seconds */ EXPORT_SYMBOL(obd_timeout); unsigned int obd_timeout_set; EXPORT_SYMBOL(obd_timeout_set); -/* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */ +/* Adaptive timeout defs here instead of ptlrpc module for /sys/fs/ access */ unsigned int at_min; EXPORT_SYMBOL(at_min); unsigned int at_max = 600; @@ -218,14 +217,14 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) goto out; } - if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) { + if (strlen(LUSTRE_VERSION_STRING) + 1 > data->ioc_inllen1) { CERROR("ioctl buffer too small to hold version\n"); err = -EINVAL; goto out; } - memcpy(data->ioc_bulk, BUILD_VERSION, - strlen(BUILD_VERSION) + 1); + memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING, + strlen(LUSTRE_VERSION_STRING) + 1); err = obd_ioctl_popdata((void __user *)arg, data, len); if (err) @@ -341,7 +340,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } if (data->ioc_dev == OBD_DEV_BY_DEVNAME) { - if (data->ioc_inllen4 <= 0 || data->ioc_inlbuf4 == NULL) { + if (data->ioc_inllen4 <= 0 || !data->ioc_inlbuf4) { err = -EINVAL; goto out; } @@ -358,7 +357,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) goto out; } - if (obd == NULL) { + if (!obd) { CERROR("OBD ioctl : No Device %d\n", data->ioc_dev); err = -EINVAL; goto out; @@ -481,7 +480,7 @@ static int __init init_obdclass(void) int lustre_register_fs(void); - LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n"); + LCONSOLE_INFO("Lustre: Build Version: " LUSTRE_VERSION_STRING "\n"); spin_lock_init(&obd_types_lock); obd_zombie_impexp_init(); @@ -509,7 +508,8 @@ static int __init init_obdclass(void) /* Default the dirty page cache cap to 1/2 of system memory. * For clients with less memory, a larger fraction is needed - * for other purposes (mostly for BGL). */ + * for other purposes (mostly for BGL). + */ if (totalram_pages <= 512 << (20 - PAGE_CACHE_SHIFT)) obd_max_dirty_pages = totalram_pages / 4; else @@ -544,8 +544,6 @@ static int __init init_obdclass(void) return err; } -/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this - * ifdef to the end of the file to cover module and versioning goo.*/ static void cleanup_obdclass(void) { int i; @@ -579,7 +577,7 @@ static void cleanup_obdclass(void) } MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>"); -MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION); +MODULE_DESCRIPTION("Lustre Class Driver Build Version: " LUSTRE_VERSION_STRING); MODULE_LICENSE("GPL"); MODULE_VERSION(LUSTRE_VERSION_STRING); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 5665655..9042632 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -70,17 +70,16 @@ static struct obd_device *obd_device_alloc(void) struct obd_device *obd; obd = kmem_cache_alloc(obd_device_cachep, GFP_NOFS | __GFP_ZERO); - if (obd != NULL) + if (obd) obd->obd_magic = OBD_DEVICE_MAGIC; return obd; } static void obd_device_free(struct obd_device *obd) { - LASSERT(obd != NULL); LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC, "obd %p obd_magic %08x != %08x\n", obd, obd->obd_magic, OBD_DEVICE_MAGIC); - if (obd->obd_namespace != NULL) { + if (obd->obd_namespace) { CERROR("obd %p: namespace %p was not properly cleaned up (obd_force=%d)!\n", obd, obd->obd_namespace, obd->obd_force); LBUG(); @@ -113,15 +112,6 @@ static struct obd_type *class_get_type(const char *name) if (!type) { const char *modname = name; - if (strcmp(modname, "obdfilter") == 0) - modname = "ofd"; - - if (strcmp(modname, LUSTRE_LWP_NAME) == 0) - modname = LUSTRE_OSP_NAME; - - if (!strncmp(modname, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME))) - modname = LUSTRE_MDT_NAME; - if (!request_module("%s", modname)) { CDEBUG(D_INFO, "Loaded module '%s'\n", modname); type = class_search_type(name); @@ -203,7 +193,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, goto failed; } - if (ldt != NULL) { + if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); if (rc != 0) @@ -365,7 +355,7 @@ void class_release_dev(struct obd_device *obd) obd, obd->obd_magic, OBD_DEVICE_MAGIC); LASSERTF(obd == obd_devs[obd->obd_minor], "obd %p != obd_devs[%d] %p\n", obd, obd->obd_minor, obd_devs[obd->obd_minor]); - LASSERT(obd_type != NULL); + LASSERT(obd_type); CDEBUG(D_INFO, "Release obd device %s at %d obd_type name =%s\n", obd->obd_name, obd->obd_minor, obd->obd_type->typ_name); @@ -391,7 +381,8 @@ int class_name2dev(const char *name) if (obd && strcmp(name, obd->obd_name) == 0) { /* Make sure we finished attaching before we give - out any references */ + * out any references + */ LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); if (obd->obd_attached) { read_unlock(&obd_dev_lock); @@ -466,8 +457,9 @@ struct obd_device *class_num2obd(int num) EXPORT_SYMBOL(class_num2obd); /* Search for a client OBD connected to tgt_uuid. If grp_uuid is - specified, then only the client with that uuid is returned, - otherwise any client connected to the tgt is returned. */ + * specified, then only the client with that uuid is returned, + * otherwise any client connected to the tgt is returned. + */ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, const char *typ_name, struct obd_uuid *grp_uuid) @@ -498,9 +490,10 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, EXPORT_SYMBOL(class_find_client_obd); /* Iterate the obd_device list looking devices have grp_uuid. Start - searching at *next, and if a device is found, the next index to look - at is saved in *next. If next is NULL, then the first matching device - will always be returned. */ + * searching at *next, and if a device is found, the next index to look + * at is saved in *next. If next is NULL, then the first matching device + * will always be returned. + */ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next) { int i; @@ -659,7 +652,7 @@ static void class_export_destroy(struct obd_export *exp) struct obd_device *obd = exp->exp_obd; LASSERT_ATOMIC_ZERO(&exp->exp_refcount); - LASSERT(obd != NULL); + LASSERT(obd); CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, exp->exp_client_uuid.uuid, obd->obd_name); @@ -699,7 +692,6 @@ EXPORT_SYMBOL(class_export_get); void class_export_put(struct obd_export *exp) { - LASSERT(exp != NULL); LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, atomic_read(&exp->exp_refcount) - 1); @@ -719,7 +711,8 @@ EXPORT_SYMBOL(class_export_put); /* Creates a new export, adds it to the hash table, and returns a * pointer to it. The refcount is 2: one for the hash reference, and - * one for the pointer returned by this function. */ + * one for the pointer returned by this function. + */ struct obd_export *class_new_export(struct obd_device *obd, struct obd_uuid *cluuid) { @@ -902,8 +895,9 @@ static void init_imp_at(struct imp_at *at) at_init(&at->iat_net_latency, 0, 0); for (i = 0; i < IMP_AT_MAX_PORTALS; i++) { /* max service estimates are tracked on the server side, so - don't use the AT history here, just use the last reported - val. (But keep hist for proc histogram, worst_ever) */ + * don't use the AT history here, just use the last reported + * val. (But keep hist for proc histogram, worst_ever) + */ at_init(&at->iat_service_estimate[i], INITIAL_CONNECT_TIMEOUT, AT_FLG_NOHIST); } @@ -942,7 +936,8 @@ struct obd_import *class_new_import(struct obd_device *obd) init_imp_at(&imp->imp_at); /* the default magic is V2, will be used in connect RPC, and - * then adjusted according to the flags in request/reply. */ + * then adjusted according to the flags in request/reply. + */ imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2; return imp; @@ -951,7 +946,7 @@ EXPORT_SYMBOL(class_new_import); void class_destroy_import(struct obd_import *import) { - LASSERT(import != NULL); + LASSERT(import); LASSERT(import != LP_POISON); class_handle_unhash(&import->imp_handle); @@ -971,8 +966,7 @@ void __class_export_add_lock_ref(struct obd_export *exp, struct ldlm_lock *lock) LASSERT(lock->l_exp_refs_nr >= 0); - if (lock->l_exp_refs_target != NULL && - lock->l_exp_refs_target != exp) { + if (lock->l_exp_refs_target && lock->l_exp_refs_target != exp) { LCONSOLE_WARN("setting export %p for lock %p which already has export %p\n", exp, lock, lock->l_exp_refs_target); } @@ -1006,17 +1000,18 @@ EXPORT_SYMBOL(__class_export_del_lock_ref); #endif /* A connection defines an export context in which preallocation can - be managed. This releases the export pointer reference, and returns - the export handle, so the export refcount is 1 when this function - returns. */ + * be managed. This releases the export pointer reference, and returns + * the export handle, so the export refcount is 1 when this function + * returns. + */ int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid) { struct obd_export *export; - LASSERT(conn != NULL); - LASSERT(obd != NULL); - LASSERT(cluuid != NULL); + LASSERT(conn); + LASSERT(obd); + LASSERT(cluuid); export = class_new_export(obd, cluuid); if (IS_ERR(export)) @@ -1036,7 +1031,8 @@ EXPORT_SYMBOL(class_connect); * and if disconnect really need * 2 - removing from hash * 3 - in client_unlink_export - * The export pointer passed to this function can destroyed */ + * The export pointer passed to this function can destroyed + */ int class_disconnect(struct obd_export *export) { int already_disconnected; @@ -1053,7 +1049,8 @@ int class_disconnect(struct obd_export *export) /* class_cleanup(), abort_recovery(), and class_fail_export() * all end up in here, and if any of them race we shouldn't - * call extra class_export_puts(). */ + * call extra class_export_puts(). + */ if (already_disconnected) goto no_disconn; @@ -1093,7 +1090,8 @@ void class_fail_export(struct obd_export *exp) /* Most callers into obd_disconnect are removing their own reference * (request, for example) in addition to the one from the hash table. - * We don't have such a reference here, so make one. */ + * We don't have such a reference here, so make one. + */ class_export_get(exp); rc = obd_disconnect(exp); if (rc) @@ -1142,14 +1140,14 @@ static void obd_zombie_impexp_cull(void) spin_unlock(&obd_zombie_impexp_lock); - if (import != NULL) { + if (import) { class_import_destroy(import); spin_lock(&obd_zombie_impexp_lock); zombies_count--; spin_unlock(&obd_zombie_impexp_lock); } - if (export != NULL) { + if (export) { class_export_destroy(export); spin_lock(&obd_zombie_impexp_lock); zombies_count--; @@ -1157,7 +1155,7 @@ static void obd_zombie_impexp_cull(void) } cond_resched(); - } while (import != NULL || export != NULL); + } while (import || export); } static struct completion obd_zombie_start; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 1913f3e..8eddf20 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -59,7 +59,6 @@ #include <linux/highmem.h> #include <linux/io.h> #include <asm/ioctls.h> -#include <linux/poll.h> #include <linux/uaccess.h> #include <linux/miscdevice.h> #include <linux/seq_file.h> @@ -71,7 +70,6 @@ #include "../../include/obd_class.h" #include "../../include/lprocfs_status.h" #include "../../include/lustre_ver.h" -#include "../../include/lustre/lustre_build_version.h" /* buffer MUST be at least the size of obd_ioctl_hdr */ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) @@ -104,9 +102,10 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) /* When there are lots of processes calling vmalloc on multi-core * system, the high lock contention will hurt performance badly, * obdfilter-survey is an example, which relies on ioctl. So we'd - * better avoid vmalloc on ioctl path. LU-66 */ + * better avoid vmalloc on ioctl path. LU-66 + */ *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_NOFS); - if (*buf == NULL) { + if (!*buf) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); return -EINVAL; @@ -454,8 +453,7 @@ out: int class_procfs_clean(void) { - if (debugfs_lustre_root != NULL) - debugfs_remove_recursive(debugfs_lustre_root); + debugfs_remove_recursive(debugfs_lustre_root); debugfs_lustre_root = NULL; diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index f956d7e..f7ee605 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -76,8 +76,6 @@ static struct llog_handle *llog_alloc_handle(void) */ static void llog_free_handle(struct llog_handle *loghandle) { - LASSERT(loghandle != NULL); - /* failed llog_init_handle */ if (!loghandle->lgh_hdr) goto out; @@ -115,7 +113,7 @@ static int llog_read_header(const struct lu_env *env, if (rc) return rc; - if (lop->lop_read_header == NULL) + if (!lop->lop_read_header) return -EOPNOTSUPP; rc = lop->lop_read_header(env, handle); @@ -144,7 +142,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, struct llog_log_hdr *llh; int rc; - LASSERT(handle->lgh_hdr == NULL); + LASSERT(!handle->lgh_hdr); llh = kzalloc(sizeof(*llh), GFP_NOFS); if (!llh) @@ -228,11 +226,11 @@ static int llog_process_thread(void *arg) return 0; } - if (cd != NULL) { + if (cd) { last_called_index = cd->lpcd_first_idx; index = cd->lpcd_first_idx + 1; } - if (cd != NULL && cd->lpcd_last_idx) + if (cd && cd->lpcd_last_idx) last_index = cd->lpcd_last_idx; else last_index = LLOG_BITMAP_BYTES * 8 - 1; @@ -262,7 +260,8 @@ repeat: /* NB: when rec->lrh_len is accessed it is already swabbed * since it is used at the "end" of the loop and the rec - * swabbing is done at the beginning of the loop. */ + * swabbing is done at the beginning of the loop. + */ for (rec = (struct llog_rec_hdr *)buf; (char *)rec < buf + LLOG_CHUNK_SIZE; rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)) { @@ -328,7 +327,7 @@ repeat: } out: - if (cd != NULL) + if (cd) cd->lpcd_last_idx = last_called_index; kfree(buf); @@ -376,17 +375,20 @@ int llog_process_or_fork(const struct lu_env *env, lpi->lpi_catdata = catdata; if (fork) { + struct task_struct *task; + /* The new thread can't use parent env, - * init the new one in llog_process_thread_daemonize. */ + * init the new one in llog_process_thread_daemonize. + */ lpi->lpi_env = NULL; init_completion(&lpi->lpi_completion); - rc = PTR_ERR(kthread_run(llog_process_thread_daemonize, lpi, - "llog_process_thread")); - if (IS_ERR_VALUE(rc)) { + task = kthread_run(llog_process_thread_daemonize, lpi, + "llog_process_thread"); + if (IS_ERR(task)) { + rc = PTR_ERR(task); CERROR("%s: cannot start thread: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); - kfree(lpi); - return rc; + goto out_lpi; } wait_for_completion(&lpi->lpi_completion); } else { @@ -394,6 +396,7 @@ int llog_process_or_fork(const struct lu_env *env, llog_process_thread(lpi); } rc = lpi->lpi_rc; +out_lpi: kfree(lpi); return rc; } @@ -416,13 +419,13 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, LASSERT(ctxt); LASSERT(ctxt->loc_logops); - if (ctxt->loc_logops->lop_open == NULL) { + if (!ctxt->loc_logops->lop_open) { *lgh = NULL; return -EOPNOTSUPP; } *lgh = llog_alloc_handle(); - if (*lgh == NULL) + if (!*lgh) return -ENOMEM; (*lgh)->lgh_ctxt = ctxt; (*lgh)->lgh_logops = ctxt->loc_logops; @@ -449,7 +452,7 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle) rc = llog_handle2ops(loghandle, &lop); if (rc) goto out; - if (lop->lop_close == NULL) { + if (!lop->lop_close) { rc = -EOPNOTSUPP; goto out; } diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 0f05e9c..b88ccba 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -69,7 +69,7 @@ static int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *loghandle; int rc = 0; - if (cathandle == NULL) + if (!cathandle) return -EBADF; down_write(&cathandle->lgh_lock); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 9bc5199..826623f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -88,7 +88,8 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) spin_unlock(&obd->obd_dev_lock); /* obd->obd_starting is needed for the case of cleanup - * in error case while obd is starting up. */ + * in error case while obd is starting up. + */ LASSERTF(obd->obd_starting == 1 || obd->obd_stopping == 1 || obd->obd_set_up == 0, "wrong obd state: %d/%d/%d\n", !!obd->obd_starting, @@ -110,11 +111,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) struct obd_llog_group *olg; int rc, idx; - LASSERT(ctxt != NULL); - LASSERT(ctxt != LP_POISON); - olg = ctxt->loc_olg; - LASSERT(olg != NULL); + LASSERT(olg); LASSERT(olg != LP_POISON); idx = ctxt->loc_idx; @@ -151,7 +149,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, if (index < 0 || index >= LLOG_MAX_CTXTS) return -EINVAL; - LASSERT(olg != NULL); + LASSERT(olg); ctxt = llog_new_ctxt(obd); if (!ctxt) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index 7b8379a..967ba2e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -386,7 +386,8 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) * * Overwrite fields from the end first, so they are not * clobbered, and use memmove() instead of memcpy() because - * the source and target buffers overlap. bug 16771 */ + * the source and target buffers overlap. bug 16771 + */ createtime = cm32->cm_createtime; canceltime = cm32->cm_canceltime; memmove(marker->cm_comment, cm32->cm_comment, MTI_NAMELEN32); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c index 6acc4a1..13aca5b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c @@ -48,14 +48,15 @@ void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount) int smp_id; unsigned long flags = 0; - if (stats == NULL) + if (!stats) return; LASSERTF(0 <= idx && idx < stats->ls_num, "idx %d, ls_num %hu\n", idx, stats->ls_num); /* With per-client stats, statistics are allocated only for - * single CPU area, so the smp_id should be 0 always. */ + * single CPU area, so the smp_id should be 0 always. + */ smp_id = lprocfs_stats_lock(stats, LPROCFS_GET_SMP_ID, &flags); if (smp_id < 0) return; @@ -96,14 +97,15 @@ void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, long amount) int smp_id; unsigned long flags = 0; - if (stats == NULL) + if (!stats) return; LASSERTF(0 <= idx && idx < stats->ls_num, "idx %d, ls_num %hu\n", idx, stats->ls_num); /* With per-client stats, statistics are allocated only for - * single CPU area, so the smp_id should be 0 always. */ + * single CPU area, so the smp_id should be 0 always. + */ smp_id = lprocfs_stats_lock(stats, LPROCFS_GET_SMP_ID, &flags); if (smp_id < 0) return; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index eda44d8..28bb4e5 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -109,7 +109,7 @@ int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep) __u64 mask = 1; int i, ret = 0; - for (i = 0; obd_connect_names[i] != NULL; i++, mask <<= 1) { + for (i = 0; obd_connect_names[i]; i++, mask <<= 1) { if (flags & mask) ret += snprintf(page + ret, count - ret, "%s%s", ret ? sep : "", obd_connect_names[i]); @@ -149,10 +149,10 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, } /* * Need to think these cases : - * 1. #echo x.00 > /proc/xxx output result : x - * 2. #echo x.0x > /proc/xxx output result : x.0x - * 3. #echo x.x0 > /proc/xxx output result : x.x - * 4. #echo x.xx > /proc/xxx output result : x.xx + * 1. #echo x.00 > /sys/xxx output result : x + * 2. #echo x.0x > /sys/xxx output result : x.0x + * 3. #echo x.x0 > /sys/xxx output result : x.x + * 4. #echo x.xx > /sys/xxx output result : x.xx * Only reserved 2 bits fraction. */ for (i = 0; i < (5 - prtn); i++) @@ -199,7 +199,7 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, if (pbuf == end) return -EINVAL; - if (end != NULL && *end == '.') { + if (end && *end == '.') { int temp_val, pow = 1; int i; @@ -247,7 +247,7 @@ struct dentry *ldebugfs_add_simple(struct dentry *root, struct dentry *entry; umode_t mode = 0; - if (root == NULL || name == NULL || fops == NULL) + if (!root || !name || !fops) return ERR_PTR(-EINVAL); if (fops->read) @@ -272,7 +272,7 @@ int ldebugfs_add_vars(struct dentry *parent, if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list)) return -EINVAL; - while (list->name != NULL) { + while (list->name) { struct dentry *entry; umode_t mode = 0; @@ -491,7 +491,7 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data) char *imp_state_name = NULL; int rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = lprocfs_climp_check(obd); if (rc) return rc; @@ -514,7 +514,7 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) struct ptlrpc_connection *conn; int rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = lprocfs_climp_check(obd); if (rc) @@ -543,7 +543,7 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, memset(cnt, 0, sizeof(*cnt)); - if (stats == NULL) { + if (!stats) { /* set count to 1 to avoid divide-by-zero errs in callers */ cnt->lc_count = 1; return; @@ -554,7 +554,7 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); for (i = 0; i < num_entry; i++) { - if (stats->ls_percpu[i] == NULL) + if (!stats->ls_percpu[i]) continue; percpu_cntr = lprocfs_stats_counter_get(stats, i, idx); @@ -577,7 +577,7 @@ EXPORT_SYMBOL(lprocfs_stats_collect); #define flag2str(flag, first) \ do { \ if (imp->imp_##flag) \ - seq_printf(m, "%s" #flag, first ? "" : ", "); \ + seq_printf(m, "%s" #flag, first ? "" : ", "); \ } while (0) static int obd_import_flags2str(struct obd_import *imp, struct seq_file *m) { @@ -604,7 +604,7 @@ static void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, char *sep int i; bool first = true; - for (i = 0; obd_connect_names[i] != NULL; i++, mask <<= 1) { + for (i = 0; obd_connect_names[i]; i++, mask <<= 1) { if (flags & mask) { seq_printf(m, "%s%s", first ? sep : "", obd_connect_names[i]); @@ -629,7 +629,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) int rw = 0; int rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = lprocfs_climp_check(obd); if (rc) return rc; @@ -665,7 +665,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) seq_printf(m, "%s%s", j ? ", " : "", nidstr); j++; } - if (imp->imp_connection != NULL) + if (imp->imp_connection) libcfs_nid2str_r(imp->imp_connection->c_peer.nid, nidstr, sizeof(nidstr)); else @@ -682,7 +682,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data) atomic_read(&imp->imp_inval_count)); spin_unlock(&imp->imp_lock); - if (obd->obd_svc_stats == NULL) + if (!obd->obd_svc_stats) goto out_climp; header = &obd->obd_svc_stats->ls_cnt_header[PTLRPC_REQWAIT_CNTR]; @@ -779,7 +779,7 @@ int lprocfs_rd_state(struct seq_file *m, void *data) struct obd_import *imp; int j, k, rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = lprocfs_climp_check(obd); if (rc) return rc; @@ -825,7 +825,7 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) struct dhms ts; int i, rc; - LASSERT(obd != NULL); + LASSERT(obd); rc = lprocfs_climp_check(obd); if (rc) return rc; @@ -967,12 +967,12 @@ int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) unsigned long flags = 0; int i; - LASSERT(stats->ls_percpu[cpuid] == NULL); + LASSERT(!stats->ls_percpu[cpuid]); LASSERT((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0); percpusize = lprocfs_stats_counter_size(stats); LIBCFS_ALLOC_ATOMIC(stats->ls_percpu[cpuid], percpusize); - if (stats->ls_percpu[cpuid] != NULL) { + if (stats->ls_percpu[cpuid]) { rc = 0; if (unlikely(stats->ls_biggest_alloc_num <= cpuid)) { if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) @@ -1017,7 +1017,7 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, /* alloc percpu pointers for all possible cpu slots */ LIBCFS_ALLOC(stats, offsetof(typeof(*stats), ls_percpu[num_entry])); - if (stats == NULL) + if (!stats) return NULL; stats->ls_num = num; @@ -1027,14 +1027,14 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, /* alloc num of counter headers */ LIBCFS_ALLOC(stats->ls_cnt_header, stats->ls_num * sizeof(struct lprocfs_counter_header)); - if (stats->ls_cnt_header == NULL) + if (!stats->ls_cnt_header) goto fail; if ((flags & LPROCFS_STATS_FLAG_NOPERCPU) != 0) { /* contains only one set counters */ percpusize = lprocfs_stats_counter_size(stats); LIBCFS_ALLOC_ATOMIC(stats->ls_percpu[0], percpusize); - if (stats->ls_percpu[0] == NULL) + if (!stats->ls_percpu[0]) goto fail; stats->ls_biggest_alloc_num = 1; } else if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) { @@ -1059,7 +1059,7 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh) unsigned int percpusize; unsigned int i; - if (stats == NULL || stats->ls_num == 0) + if (!stats || stats->ls_num == 0) return; *statsh = NULL; @@ -1070,9 +1070,9 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh) percpusize = lprocfs_stats_counter_size(stats); for (i = 0; i < num_entry; i++) - if (stats->ls_percpu[i] != NULL) + if (stats->ls_percpu[i]) LIBCFS_FREE(stats->ls_percpu[i], percpusize); - if (stats->ls_cnt_header != NULL) + if (stats->ls_cnt_header) LIBCFS_FREE(stats->ls_cnt_header, stats->ls_num * sizeof(struct lprocfs_counter_header)); LIBCFS_FREE(stats, offsetof(typeof(*stats), ls_percpu[num_entry])); @@ -1090,7 +1090,7 @@ void lprocfs_clear_stats(struct lprocfs_stats *stats) num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); for (i = 0; i < num_entry; i++) { - if (stats->ls_percpu[i] == NULL) + if (!stats->ls_percpu[i]) continue; for (j = 0; j < stats->ls_num; j++) { percpu_cntr = lprocfs_stats_counter_get(stats, i, j); @@ -1230,10 +1230,8 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned int i; unsigned int num_cpu; - LASSERT(stats != NULL); - header = &stats->ls_cnt_header[index]; - LASSERTF(header != NULL, "Failed to allocate stats header:[%d]%s/%s\n", + LASSERTF(header, "Failed to allocate stats header:[%d]%s/%s\n", index, name, units); header->lc_config = conf; @@ -1242,7 +1240,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); for (i = 0; i < num_cpu; ++i) { - if (stats->ls_percpu[i] == NULL) + if (!stats->ls_percpu[i]) continue; percpu_cntr = lprocfs_stats_counter_get(stats, i, index); percpu_cntr->lc_count = 0; @@ -1270,7 +1268,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, { __s64 ret = 0; - if (lc == NULL || header == NULL) + if (!lc || !header) return 0; switch (field) { @@ -1412,7 +1410,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, /* there is no strnstr() in rhel5 and ubuntu kernels */ val = lprocfs_strnstr(buffer, name, buflen); - if (val == NULL) + if (!val) return (char *)buffer; val += strlen(name); /* skip prefix */ diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index ce248f4..0fa4bac 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -86,13 +86,12 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) */ fid = lu_object_fid(o); if (fid_is_zero(fid)) { - LASSERT(top->loh_hash.next == NULL - && top->loh_hash.pprev == NULL); + LASSERT(!top->loh_hash.next && !top->loh_hash.pprev); LASSERT(list_empty(&top->loh_lru)); if (!atomic_dec_and_test(&top->loh_ref)) return; list_for_each_entry_reverse(o, &top->loh_layers, lo_linkage) { - if (o->lo_ops->loo_object_release != NULL) + if (o->lo_ops->loo_object_release) o->lo_ops->loo_object_release(env, o); } lu_object_free(env, orig); @@ -119,7 +118,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) * layers, and notify them that object is no longer busy. */ list_for_each_entry_reverse(o, &top->loh_layers, lo_linkage) { - if (o->lo_ops->loo_object_release != NULL) + if (o->lo_ops->loo_object_release) o->lo_ops->loo_object_release(env, o); } @@ -210,7 +209,7 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, * lu_object_header. */ top = dev->ld_ops->ldo_object_alloc(env, NULL, dev); - if (top == NULL) + if (!top) return ERR_PTR(-ENOMEM); if (IS_ERR(top)) return top; @@ -245,7 +244,7 @@ next: } while (!clean); list_for_each_entry_reverse(scan, layers, lo_linkage) { - if (scan->lo_ops->loo_object_start != NULL) { + if (scan->lo_ops->loo_object_start) { result = scan->lo_ops->loo_object_start(env, scan); if (result != 0) { lu_object_free(env, top); @@ -276,7 +275,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) * First call ->loo_object_delete() method to release all resources. */ list_for_each_entry_reverse(scan, layers, lo_linkage) { - if (scan->lo_ops->loo_object_delete != NULL) + if (scan->lo_ops->loo_object_delete) scan->lo_ops->loo_object_delete(env, scan); } @@ -296,7 +295,6 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) */ o = container_of0(splice.prev, struct lu_object, lo_linkage); list_del_init(&o->lo_linkage); - LASSERT(o->lo_ops->loo_object_free != NULL); o->lo_ops->loo_object_free(env, o); } @@ -451,7 +449,6 @@ int lu_cdebug_printer(const struct lu_env *env, va_start(args, format); key = lu_context_key_get(&env->le_ctx, &lu_global_key); - LASSERT(key != NULL); used = strlen(key->lck_area); complete = format[strlen(format) - 1] == '\n'; @@ -508,7 +505,7 @@ void lu_object_print(const struct lu_env *env, void *cookie, (*printer)(env, cookie, "%*.*s%s@%p", depth, depth, ruler, o->lo_dev->ld_type->ldt_name, o); - if (o->lo_ops->loo_object_print != NULL) + if (o->lo_ops->loo_object_print) (*o->lo_ops->loo_object_print)(env, cookie, printer, o); (*printer)(env, cookie, "\n"); @@ -535,9 +532,10 @@ static struct lu_object *htable_lookup(struct lu_site *s, *version = ver; bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd); /* cfs_hash_bd_peek_locked is a somehow "internal" function - * of cfs_hash, it doesn't add refcount on object. */ + * of cfs_hash, it doesn't add refcount on object. + */ hnode = cfs_hash_bd_peek_locked(s->ls_obj_hash, bd, (void *)f); - if (hnode == NULL) { + if (!hnode) { lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_MISS); return ERR_PTR(-ENOENT); } @@ -636,7 +634,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, * If dying object is found during index search, add @waiter to the * site wait-queue and return ERR_PTR(-EAGAIN). */ - if (conf != NULL && conf->loc_flags & LOC_F_NEW) + if (conf && conf->loc_flags & LOC_F_NEW) return lu_object_new(env, dev, f, conf); s = dev->ld_site; @@ -715,7 +713,7 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env, top = lu_object_find(env, dev, f, conf); if (!IS_ERR(top)) { obj = lu_object_locate(top->lo_header, dev->ld_type); - if (obj == NULL) + if (!obj) lu_object_put(env, top); } else obj = top; @@ -966,11 +964,11 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) CFS_HASH_NO_ITEMREF | CFS_HASH_DEPTH | CFS_HASH_ASSERT_EMPTY); - if (s->ls_obj_hash != NULL) + if (s->ls_obj_hash) break; } - if (s->ls_obj_hash == NULL) { + if (!s->ls_obj_hash) { CERROR("failed to create lu_site hash with bits: %d\n", bits); return -ENOMEM; } @@ -982,7 +980,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) } s->ls_stats = lprocfs_alloc_stats(LU_SS_LAST_STAT, 0); - if (s->ls_stats == NULL) { + if (!s->ls_stats) { cfs_hash_putref(s->ls_obj_hash); s->ls_obj_hash = NULL; return -ENOMEM; @@ -1031,19 +1029,19 @@ void lu_site_fini(struct lu_site *s) list_del_init(&s->ls_linkage); mutex_unlock(&lu_sites_guard); - if (s->ls_obj_hash != NULL) { + if (s->ls_obj_hash) { cfs_hash_putref(s->ls_obj_hash); s->ls_obj_hash = NULL; } - if (s->ls_top_dev != NULL) { + if (s->ls_top_dev) { s->ls_top_dev->ld_site = NULL; lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s); lu_device_put(s->ls_top_dev); s->ls_top_dev = NULL; } - if (s->ls_stats != NULL) + if (s->ls_stats) lprocfs_free_stats(&s->ls_stats); } EXPORT_SYMBOL(lu_site_fini); @@ -1088,7 +1086,7 @@ EXPORT_SYMBOL(lu_device_put); */ int lu_device_init(struct lu_device *d, struct lu_device_type *t) { - if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start != NULL) + if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start) t->ldt_ops->ldto_start(t); memset(d, 0, sizeof(*d)); atomic_set(&d->ld_ref, 0); @@ -1107,7 +1105,7 @@ void lu_device_fini(struct lu_device *d) struct lu_device_type *t; t = d->ld_type; - if (d->ld_obd != NULL) { + if (d->ld_obd) { d->ld_obd->obd_lu_dev = NULL; d->ld_obd = NULL; } @@ -1116,7 +1114,7 @@ void lu_device_fini(struct lu_device *d) LASSERTF(atomic_read(&d->ld_ref) == 0, "Refcount is %u\n", atomic_read(&d->ld_ref)); LASSERT(t->ldt_device_nr > 0); - if (--t->ldt_device_nr == 0 && t->ldt_ops->ldto_stop != NULL) + if (--t->ldt_device_nr == 0 && t->ldt_ops->ldto_stop) t->ldt_ops->ldto_stop(t); } EXPORT_SYMBOL(lu_device_fini); @@ -1148,7 +1146,7 @@ void lu_object_fini(struct lu_object *o) LASSERT(list_empty(&o->lo_linkage)); - if (dev != NULL) { + if (dev) { lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, "lu_object", o); lu_device_put(dev); @@ -1239,7 +1237,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) struct lu_device *next; lu_site_purge(env, site, ~0); - for (scan = top; scan != NULL; scan = next) { + for (scan = top; scan; scan = next) { next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan); lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init); lu_device_put(scan); @@ -1248,13 +1246,13 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) /* purge again. */ lu_site_purge(env, site, ~0); - for (scan = top; scan != NULL; scan = next) { + for (scan = top; scan; scan = next) { const struct lu_device_type *ldt = scan->ld_type; struct obd_type *type; next = ldt->ldt_ops->ldto_device_free(env, scan); type = ldt->ldt_obd_type; - if (type != NULL) { + if (type) { type->typ_refcnt--; class_put_type(type); } @@ -1289,14 +1287,14 @@ int lu_context_key_register(struct lu_context_key *key) int result; int i; - LASSERT(key->lct_init != NULL); - LASSERT(key->lct_fini != NULL); + LASSERT(key->lct_init); + LASSERT(key->lct_fini); LASSERT(key->lct_tags != 0); result = -ENFILE; spin_lock(&lu_keys_guard); for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { - if (lu_keys[i] == NULL) { + if (!lu_keys[i]) { key->lct_index = i; atomic_set(&key->lct_used, 1); lu_keys[i] = key; @@ -1313,12 +1311,10 @@ EXPORT_SYMBOL(lu_context_key_register); static void key_fini(struct lu_context *ctx, int index) { - if (ctx->lc_value != NULL && ctx->lc_value[index] != NULL) { + if (ctx->lc_value && ctx->lc_value[index]) { struct lu_context_key *key; key = lu_keys[index]; - LASSERT(key != NULL); - LASSERT(key->lct_fini != NULL); LASSERT(atomic_read(&key->lct_used) > 1); key->lct_fini(ctx, key, ctx->lc_value[index]); @@ -1376,7 +1372,7 @@ int lu_context_key_register_many(struct lu_context_key *k, ...) if (result) break; key = va_arg(args, struct lu_context_key *); - } while (key != NULL); + } while (key); va_end(args); if (result != 0) { @@ -1404,7 +1400,7 @@ void lu_context_key_degister_many(struct lu_context_key *k, ...) do { lu_context_key_degister(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_degister_many); @@ -1420,7 +1416,7 @@ void lu_context_key_revive_many(struct lu_context_key *k, ...) do { lu_context_key_revive(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_revive_many); @@ -1436,7 +1432,7 @@ void lu_context_key_quiesce_many(struct lu_context_key *k, ...) do { lu_context_key_quiesce(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_quiesce_many); @@ -1497,7 +1493,7 @@ static void keys_fini(struct lu_context *ctx) { int i; - if (ctx->lc_value == NULL) + if (!ctx->lc_value) return; for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) @@ -1511,12 +1507,12 @@ static int keys_fill(struct lu_context *ctx) { int i; - LINVRNT(ctx->lc_value != NULL); + LINVRNT(ctx->lc_value); for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { struct lu_context_key *key; key = lu_keys[i]; - if (ctx->lc_value[i] == NULL && key != NULL && + if (!ctx->lc_value[i] && key && (key->lct_tags & ctx->lc_tags) && /* * Don't create values for a LCT_QUIESCENT key, as this @@ -1525,7 +1521,7 @@ static int keys_fill(struct lu_context *ctx) !(key->lct_tags & LCT_QUIESCENT)) { void *value; - LINVRNT(key->lct_init != NULL); + LINVRNT(key->lct_init); LINVRNT(key->lct_index == i); value = key->lct_init(ctx, key); @@ -1542,7 +1538,7 @@ static int keys_fill(struct lu_context *ctx) * value. */ ctx->lc_value[i] = value; - if (key->lct_exit != NULL) + if (key->lct_exit) ctx->lc_tags |= LCT_HAS_EXIT; } ctx->lc_version = key_set_version; @@ -1554,7 +1550,7 @@ static int keys_init(struct lu_context *ctx) { ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]), GFP_NOFS); - if (likely(ctx->lc_value != NULL)) + if (likely(ctx->lc_value)) return keys_fill(ctx); return -ENOMEM; @@ -1626,14 +1622,13 @@ void lu_context_exit(struct lu_context *ctx) LINVRNT(ctx->lc_state == LCS_ENTERED); ctx->lc_state = LCS_LEFT; - if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value != NULL) { + if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value) { for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { - if (ctx->lc_value[i] != NULL) { + if (ctx->lc_value[i]) { struct lu_context_key *key; key = lu_keys[i]; - LASSERT(key != NULL); - if (key->lct_exit != NULL) + if (key->lct_exit) key->lct_exit(ctx, key, ctx->lc_value[i]); } @@ -1688,7 +1683,7 @@ int lu_env_refill(struct lu_env *env) int result; result = lu_context_refill(&env->le_ctx); - if (result == 0 && env->le_ses != NULL) + if (result == 0 && env->le_ses) result = lu_context_refill(env->le_ses); return result; } @@ -1922,11 +1917,11 @@ int lu_kmem_init(struct lu_kmem_descr *caches) int result; struct lu_kmem_descr *iter = caches; - for (result = 0; iter->ckd_cache != NULL; ++iter) { + for (result = 0; iter->ckd_cache; ++iter) { *iter->ckd_cache = kmem_cache_create(iter->ckd_name, iter->ckd_size, 0, 0, NULL); - if (*iter->ckd_cache == NULL) { + if (!*iter->ckd_cache) { result = -ENOMEM; /* free all previously allocated caches */ lu_kmem_fini(caches); @@ -1943,7 +1938,7 @@ EXPORT_SYMBOL(lu_kmem_init); */ void lu_kmem_fini(struct lu_kmem_descr *caches) { - for (; caches->ckd_cache != NULL; ++caches) { + for (; caches->ckd_cache; ++caches) { kmem_cache_destroy(*caches->ckd_cache); *caches->ckd_cache = NULL; } diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index fb9147c..403ceea 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -65,7 +65,7 @@ void class_handle_hash(struct portals_handle *h, { struct handle_bucket *bucket; - LASSERT(h != NULL); + LASSERT(h); LASSERT(list_empty(&h->h_link)); /* @@ -140,10 +140,11 @@ void *class_handle2object(__u64 cookie) struct portals_handle *h; void *retval = NULL; - LASSERT(handle_hash != NULL); + LASSERT(handle_hash); /* Be careful when you want to change this code. See the - * rcu_read_lock() definition on top this file. - jxiong */ + * rcu_read_lock() definition on top this file. - jxiong + */ bucket = handle_hash + (cookie & HANDLE_HASH_MASK); rcu_read_lock(); @@ -170,7 +171,7 @@ void class_handle_free_cb(struct rcu_head *rcu) struct portals_handle *h = RCU2HANDLE(rcu); void *ptr = (void *)(unsigned long)h->h_cookie; - if (h->h_ops->hop_free != NULL) + if (h->h_ops->hop_free) h->h_ops->hop_free(ptr, h->h_size); else kfree(ptr); @@ -183,11 +184,11 @@ int class_handle_init(void) struct timespec64 ts; int seed[2]; - LASSERT(handle_hash == NULL); + LASSERT(!handle_hash); handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, GFP_NOFS); - if (handle_hash == NULL) + if (!handle_hash) return -ENOMEM; spin_lock_init(&handle_base_lock); @@ -234,7 +235,7 @@ void class_handle_cleanup(void) { int count; - LASSERT(handle_hash != NULL); + LASSERT(handle_hash); count = cleanup_all_handles(); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index d6184f8..b10ea31 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -93,7 +93,8 @@ int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index) EXPORT_SYMBOL(lustre_uuid_to_peer); /* Add a nid to a niduuid. Multiple nids can be added to a single uuid; - LNET will choose the best one. */ + * LNET will choose the best one. + */ int class_add_uuid(const char *uuid, __u64 nid) { struct uuid_nid_data *data, *entry; @@ -151,7 +152,7 @@ int class_del_uuid(const char *uuid) struct uuid_nid_data *data; spin_lock(&g_uuid_lock); - if (uuid != NULL) { + if (uuid) { struct obd_uuid tmp; obd_str2uuid(&tmp, uuid); @@ -165,7 +166,7 @@ int class_del_uuid(const char *uuid) list_splice_init(&g_uuid_list, &deathrow); spin_unlock(&g_uuid_lock); - if (uuid != NULL && list_empty(&deathrow)) { + if (uuid && list_empty(&deathrow)) { CDEBUG(D_INFO, "Try to delete a non-existent uuid %s\n", uuid); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 49cdc64..2134b60 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -71,8 +71,9 @@ int class_find_param(char *buf, char *key, char **valp) EXPORT_SYMBOL(class_find_param); /* returns 0 if this is the first key in the buffer, else 1. - valp points to first char after key. */ -static int class_match_param(char *buf, char *key, char **valp) + * valp points to first char after key. + */ +static int class_match_param(char *buf, const char *key, char **valp) { if (!buf) return 1; @@ -114,9 +115,10 @@ enum { }; /* 0 is good nid, - 1 not found - < 0 error - endh is set to next separator */ + * 1 not found + * < 0 error + * endh is set to next separator + */ static int class_parse_value(char *buf, int opc, void *value, char **endh, int quiet) { @@ -210,7 +212,7 @@ static int class_attach(struct lustre_cfg *lcfg) name, typename, rc); goto out; } - LASSERTF(obd != NULL, "Cannot get obd device %s of type %s\n", + LASSERTF(obd, "Cannot get obd device %s of type %s\n", name, typename); LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC, "obd %p obd_magic %08X != %08X\n", @@ -230,7 +232,8 @@ static int class_attach(struct lustre_cfg *lcfg) mutex_init(&obd->obd_dev_mutex); spin_lock_init(&obd->obd_osfs_lock); /* obd->obd_osfs_age must be set to a value in the distant - * past to guarantee a fresh statfs is fetched on mount. */ + * past to guarantee a fresh statfs is fetched on mount. + */ obd->obd_osfs_age = cfs_time_shift_64(-1000); /* XXX belongs in setup not attach */ @@ -272,9 +275,9 @@ static int class_attach(struct lustre_cfg *lcfg) obd->obd_minor, typename, atomic_read(&obd->obd_refcount)); return 0; out: - if (obd != NULL) { + if (obd) class_release_dev(obd); - } + return rc; } @@ -286,7 +289,7 @@ static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) int err = 0; struct obd_export *exp; - LASSERT(obd != NULL); + LASSERT(obd); LASSERTF(obd == class_num2obd(obd->obd_minor), "obd %p != obd_devs[%d] %p\n", obd, obd->obd_minor, class_num2obd(obd->obd_minor)); @@ -315,7 +318,8 @@ static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return -EEXIST; } /* just leave this on forever. I can't use obd_set_up here because - other fns check that status, and we're not actually set up yet. */ + * other fns check that status, and we're not actually set up yet. + */ obd->obd_starting = 1; obd->obd_uuid_hash = NULL; spin_unlock(&obd->obd_dev_lock); @@ -503,7 +507,8 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source) if ((refs == 1) && obd->obd_stopping) { /* All exports have been destroyed; there should - be no more in-progress ops by this point.*/ + * be no more in-progress ops by this point. + */ spin_lock(&obd->obd_self_export->exp_lock); obd->obd_self_export->exp_flags |= exp_flags_from_obd(obd); @@ -723,7 +728,8 @@ static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) } /* We can't call ll_process_config or lquota_process_config directly because - * it lives in a module that must be loaded after this one. */ + * it lives in a module that must be loaded after this one. + */ static int (*client_process_config)(struct lustre_cfg *lcfg); static int (*quota_process_config)(struct lustre_cfg *lcfg); @@ -812,7 +818,8 @@ int class_process_config(struct lustre_cfg *lcfg) lustre_cfg_string(lcfg, 2), lustre_cfg_string(lcfg, 3)); /* set these mount options somewhere, so ll_fill_super - * can find them. */ + * can find them. + */ err = class_add_profile(LUSTRE_CFG_BUFLEN(lcfg, 1), lustre_cfg_string(lcfg, 1), LUSTRE_CFG_BUFLEN(lcfg, 2), @@ -988,8 +995,9 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, fakefile.private_data = &fake_seqfile; fake_seqfile.private = data; /* e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt - or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar - or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 */ + * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar + * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 + */ for (i = 1; i < lcfg->lcfg_bufcount; i++) { key = lustre_cfg_buf(lcfg, i); /* Strip off prefix */ @@ -1008,7 +1016,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, /* Search proc entries */ while (lvars[j].name) { var = &lvars[j]; - if (class_match_param(key, (char *)var->name, NULL) == 0 + if (!class_match_param(key, var->name, NULL) && keylen == strlen(var->name)) { matched++; rc = -EROFS; @@ -1027,9 +1035,10 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, } if (!matched) { /* If the prefix doesn't match, return error so we - can pass it down the stack */ + * can pass it down the stack + */ if (strnchr(key, keylen, '.')) - return -ENOSYS; + return -ENOSYS; CERROR("%s: unknown param %s\n", (char *)lustre_cfg_string(lcfg, 0), key); /* rc = -EINVAL; continue parsing other params */ @@ -1116,7 +1125,8 @@ int class_config_llog_handler(const struct lu_env *env, } } /* A config command without a start marker before it is - illegal (post 146) */ + * illegal (post 146) + */ if (!(clli->cfg_flags & CFG_F_COMPAT146) && !(clli->cfg_flags & CFG_F_MARKER) && (lcfg->lcfg_command != LCFG_MARKER)) { @@ -1182,8 +1192,9 @@ int class_config_llog_handler(const struct lu_env *env, } /* we override the llog's uuid for clients, to insure they - are unique */ - if (clli && clli->cfg_instance != NULL && + * are unique + */ + if (clli && clli->cfg_instance && lcfg->lcfg_command == LCFG_ATTACH) { lustre_cfg_bufs_set_string(&bufs, 2, clli->cfg_uuid.uuid); @@ -1211,7 +1222,8 @@ int class_config_llog_handler(const struct lu_env *env, lcfg_new->lcfg_flags = lcfg->lcfg_flags; /* XXX Hack to try to remain binary compatible with - * pre-newconfig logs */ + * pre-newconfig logs + */ if (lcfg->lcfg_nal != 0 && /* pre-newconfig log? */ (lcfg->lcfg_nid >> 32) == 0) { __u32 addr = (__u32)(lcfg->lcfg_nid & 0xffffffff); @@ -1270,7 +1282,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, if (cfg) { cd.lpcd_first_idx = cfg->cfg_last_idx; callback = cfg->cfg_callback; - LASSERT(callback != NULL); + LASSERT(callback); } else { callback = class_config_llog_handler; } diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index b5aa816..d138e05 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -283,9 +283,10 @@ int lustre_start_mgc(struct super_block *sb) recov_bk = 0; /* Try all connections, but only once (again). - We don't want to block another target from starting - (using its local copy of the log), but we do want to connect - if at all possible. */ + * We don't want to block another target from starting + * (using its local copy of the log), but we do want to connect + * if at all possible. + */ recov_bk++; CDEBUG(D_MOUNT, "%s: Set MGC reconnect %d\n", mgcname, recov_bk); @@ -375,7 +376,8 @@ int lustre_start_mgc(struct super_block *sb) goto out_free; /* Keep a refcount of servers/clients who started with "mount", - so we know when we can get rid of the mgc. */ + * so we know when we can get rid of the mgc. + */ atomic_set(&obd->u.cli.cl_mgc_refcount, 1); /* We connect to the MGS at setup, and don't disconnect until cleanup */ @@ -403,7 +405,8 @@ int lustre_start_mgc(struct super_block *sb) out: /* Keep the mgc info in the sb. Note that many lsi's can point - to the same mgc.*/ + * to the same mgc. + */ lsi->lsi_mgc = obd; out_free: mutex_unlock(&mgc_start_lock); @@ -432,7 +435,8 @@ static int lustre_stop_mgc(struct super_block *sb) LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0); if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) { /* This is not fatal, every client that stops - will call in here. */ + * will call in here. + */ CDEBUG(D_MOUNT, "mgc still has %d references.\n", atomic_read(&obd->u.cli.cl_mgc_refcount)); rc = -EBUSY; @@ -440,19 +444,20 @@ static int lustre_stop_mgc(struct super_block *sb) } /* The MGC has no recoverable data in any case. - * force shutdown set in umount_begin */ + * force shutdown set in umount_begin + */ obd->obd_no_recov = 1; if (obd->u.cli.cl_mgc_mgsexp) { /* An error is not fatal, if we are unable to send the - disconnect mgs ping evictor cleans up the export */ + * disconnect mgs ping evictor cleans up the export + */ rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp); if (rc) CDEBUG(D_MOUNT, "disconnect failed %d\n", rc); } - /* Save the obdname for cleaning the nid uuids, which are - obdname_XX */ + /* Save the obdname for cleaning the nid uuids, which are obdname_XX */ len = strlen(obd->obd_name) + 6; niduuid = kzalloc(len, GFP_NOFS); if (niduuid) { @@ -518,13 +523,12 @@ static int lustre_free_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - LASSERT(lsi != NULL); CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi); /* someone didn't call server_put_mount. */ LASSERT(atomic_read(&lsi->lsi_mounts) == 0); - if (lsi->lsi_lmd != NULL) { + if (lsi->lsi_lmd) { kfree(lsi->lsi_lmd->lmd_dev); kfree(lsi->lsi_lmd->lmd_profile); kfree(lsi->lsi_lmd->lmd_mgssec); @@ -538,7 +542,7 @@ static int lustre_free_lsi(struct super_block *sb) kfree(lsi->lsi_lmd); } - LASSERT(lsi->lsi_llsbi == NULL); + LASSERT(!lsi->lsi_llsbi); kfree(lsi); s2lsi_nocast(sb) = NULL; @@ -546,13 +550,12 @@ static int lustre_free_lsi(struct super_block *sb) } /* The lsi has one reference for every server that is using the disk - - e.g. MDT, MGS, and potentially MGC */ + * e.g. MDT, MGS, and potentially MGC + */ static int lustre_put_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - LASSERT(lsi != NULL); - CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts)); if (atomic_dec_and_test(&lsi->lsi_mounts)) { lustre_free_lsi(sb); @@ -588,21 +591,22 @@ static int server_name2fsname(const char *svname, char *fsname, if (dash == svname) return -EINVAL; - if (fsname != NULL) { + if (fsname) { strncpy(fsname, svname, dash - svname); fsname[dash - svname] = '\0'; } - if (endptr != NULL) + if (endptr) *endptr = dash; return 0; } /* Get the index from the obd name. - rc = server type, or - rc < 0 on error - if endptr isn't NULL it is set to end of name */ + * rc = server type, or + * rc < 0 on error + * if endptr isn't NULL it is set to end of name + */ static int server_name2index(const char *svname, __u32 *idx, const char **endptr) { @@ -627,18 +631,18 @@ static int server_name2index(const char *svname, __u32 *idx, dash += 3; if (strncmp(dash, "all", 3) == 0) { - if (endptr != NULL) + if (endptr) *endptr = dash + 3; return rc | LDD_F_SV_ALL; } index = simple_strtoul(dash, (char **)endptr, 16); - if (idx != NULL) + if (idx) *idx = index; /* Account for -mdc after index that is possible when specifying mdt */ - if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1, - sizeof(LUSTRE_MDC_NAME)-1) == 0) + if (endptr && strncmp(LUSTRE_MDC_NAME, *endptr + 1, + sizeof(LUSTRE_MDC_NAME) - 1) == 0) *endptr += sizeof(LUSTRE_MDC_NAME); return rc; @@ -661,7 +665,8 @@ int lustre_common_put_super(struct super_block *sb) return rc; } /* BUSY just means that there's some other obd that - needs the mgc. Let him clean it up. */ + * needs the mgc. Let him clean it up. + */ CDEBUG(D_MOUNT, "MGC still in use\n"); } /* Drop a ref to the mounted disk */ @@ -731,8 +736,9 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) int rc = 0, devmax; /* The shortest an ost name can be is 8 chars: -OST0000. - We don't actually know the fsname at this time, so in fact - a user could specify any fsname. */ + * We don't actually know the fsname at this time, so in fact + * a user could specify any fsname. + */ devmax = strlen(ptr) / 8 + 1; /* temp storage until we figure out how many we have */ @@ -756,7 +762,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) (uint)(s2-s1), s1, rc); s1 = s2; /* now we are pointing at ':' (next exclude) - or ',' (end of excludes) */ + * or ',' (end of excludes) + */ if (lmd->lmd_exclude_count >= devmax) break; } @@ -788,7 +795,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) lmd->lmd_mgssec = NULL; tail = strchr(ptr, ','); - if (tail == NULL) + if (!tail) length = strlen(ptr); else length = tail - ptr; @@ -807,14 +814,14 @@ static int lmd_parse_string(char **handle, char *ptr) char *tail; int length; - if ((handle == NULL) || (ptr == NULL)) + if (!handle || !ptr) return -EINVAL; kfree(*handle); *handle = NULL; tail = strchr(ptr, ','); - if (tail == NULL) + if (!tail) length = strlen(ptr); else length = tail - ptr; @@ -847,14 +854,14 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) return -EINVAL; } - if (lmd->lmd_mgs != NULL) + if (lmd->lmd_mgs) oldlen = strlen(lmd->lmd_mgs) + 1; mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS); if (!mgsnid) return -ENOMEM; - if (lmd->lmd_mgs != NULL) { + if (lmd->lmd_mgs) { /* Multiple mgsnid= are taken to mean failover locations */ memcpy(mgsnid, lmd->lmd_mgs, oldlen); mgsnid[oldlen - 1] = ':'; @@ -909,10 +916,12 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) s1++; /* Client options are parsed in ll_options: eg. flock, - user_xattr, acl */ + * user_xattr, acl + */ /* Parse non-ldiskfs options here. Rather than modifying - ldiskfs, we just zero these out here */ + * ldiskfs, we just zero these out here + */ if (strncmp(s1, "abort_recov", 11) == 0) { lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; clear++; @@ -940,7 +949,8 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) sizeof(PARAM_MGSNODE) - 1) == 0) { s2 = s1 + sizeof(PARAM_MGSNODE) - 1; /* Assume the next mount opt is the first - invalid nid we get to. */ + * invalid nid we get to. + */ rc = lmd_parse_mgs(lmd, &s2); if (rc) goto invalid; @@ -981,7 +991,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) size_t length, params_length; char *tail = strchr(s1 + 6, ','); - if (tail == NULL) + if (!tail) length = strlen(s1); else length = tail - s1; @@ -1000,18 +1010,20 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) clear++; } /* Linux 2.4 doesn't pass the device, so we stuck it at the - end of the options. */ + * end of the options. + */ else if (strncmp(s1, "device=", 7) == 0) { devname = s1 + 7; /* terminate options right before device. device - must be the last one. */ + * must be the last one. + */ *s1 = '\0'; break; } /* Find next opt */ s2 = strchr(s1, ','); - if (s2 == NULL) { + if (!s2) { if (clear) *s1 = '\0'; break; @@ -1113,9 +1125,9 @@ static int lustre_fill_super(struct super_block *sb, void *data, int silent) if (lmd_is_client(lmd)) { CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile); - if (client_fill_super == NULL) + if (!client_fill_super) request_module("lustre"); - if (client_fill_super == NULL) { + if (!client_fill_super) { LCONSOLE_ERROR_MSG(0x165, "Nothing registered for client mount! Is the 'lustre' module loaded?\n"); lustre_put_lsi(sb); rc = -ENODEV; @@ -1136,7 +1148,8 @@ static int lustre_fill_super(struct super_block *sb, void *data, int silent) } /* If error happens in fill_super() call, @lsi will be killed there. - * This is why we do not put it here. */ + * This is why we do not put it here. + */ goto out; out: if (rc) { @@ -1151,7 +1164,8 @@ out: } /* We can't call ll_fill_super by name because it lives in a module that - must be loaded after this one. */ + * must be loaded after this one. + */ void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb, struct vfsmount *mnt)) { @@ -1166,7 +1180,7 @@ void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb)) EXPORT_SYMBOL(lustre_register_kill_super_cb); /***************** FS registration ******************/ -struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, +static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, const char *devname, void *data) { struct lustre_mount_data2 lmd2 = { diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 75e1dea..e6436cb 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -55,7 +55,8 @@ void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent) EXPORT_SYMBOL(obdo_set_parent_fid); /* WARNING: the file systems must take care not to tinker with - attributes they don't manage (such as blocks). */ + * attributes they don't manage (such as blocks). + */ void obdo_from_inode(struct obdo *dst, struct inode *src, u32 valid) { u32 newvalid = 0; @@ -122,7 +123,8 @@ void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj) ostid_set_seq_mdt0(&ioobj->ioo_oid); /* Since 2.4 this does not contain o_mode in the low 16 bits. - * Instead, it holds (bd_md_max_brw - 1) for multi-bulk BRW RPCs */ + * Instead, it holds (bd_md_max_brw - 1) for multi-bulk BRW RPCs + */ ioobj->ioo_max_brw = 0; } EXPORT_SYMBOL(obdo_to_ioobj); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 4ca82af..3be28c5 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -146,7 +146,7 @@ static inline struct echo_thread_info *echo_env_info(const struct lu_env *env) struct echo_thread_info *info; info = lu_context_key_get(&env->le_ctx, &echo_thread_key); - LASSERT(info != NULL); + LASSERT(info); return info; } @@ -267,7 +267,7 @@ static void echo_page_completion(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - LASSERT(slice->cpl_page->cp_sync_io != NULL); + LASSERT(slice->cpl_page->cp_sync_io); } static void echo_page_fini(const struct lu_env *env, @@ -393,13 +393,13 @@ static int echo_lock_init(const struct lu_env *env, struct echo_lock *el; el = kmem_cache_alloc(echo_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (el != NULL) { + if (el) { cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops); el->el_object = cl2echo_obj(obj); INIT_LIST_HEAD(&el->el_chain); atomic_set(&el->el_refcount, 0); } - return el == NULL ? -ENOMEM : 0; + return !el ? -ENOMEM : 0; } static int echo_conf_set(const struct lu_env *env, struct cl_object *obj, @@ -439,7 +439,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, under = ed->ed_next; below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); - if (below == NULL) + if (!below) return -ENOMEM; lu_object_add(obj, below); } @@ -470,12 +470,12 @@ static int echo_alloc_memmd(struct echo_device *ed, int lsm_size; /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) + if (ed->ed_next) return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); /* OFD has no unpackmd method, do everything here */ lsm_size = lov_stripe_md_size(1); - LASSERT(*lsmp == NULL); + LASSERT(!*lsmp); *lsmp = kzalloc(lsm_size, GFP_NOFS); if (!*lsmp) return -ENOMEM; @@ -498,12 +498,11 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) int lsm_size; /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) + if (ed->ed_next) return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); /* OFD has no unpackmd method, do everything here */ lsm_size = lov_stripe_md_size(1); - LASSERT(*lsmp != NULL); kfree((*lsmp)->lsm_oinfo[0]); kfree(*lsmp); *lsmp = NULL; @@ -562,9 +561,9 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, struct lu_object *obj = NULL; /* we're the top dev. */ - LASSERT(hdr == NULL); + LASSERT(!hdr); eco = kmem_cache_alloc(echo_object_kmem, GFP_NOFS | __GFP_ZERO); - if (eco != NULL) { + if (eco) { struct cl_object_header *hdr = &eco->eo_hdr; obj = &echo_obj2cl(eco)->co_lu; @@ -627,7 +626,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx, struct echo_thread_info *info; info = kmem_cache_alloc(echo_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -658,7 +657,7 @@ static void *echo_session_key_init(const struct lu_context *ctx, struct echo_session_info *session; session = kmem_cache_alloc(echo_session_kmem, GFP_NOFS | __GFP_ZERO); - if (session == NULL) + if (!session) session = ERR_PTR(-ENOMEM); return session; } @@ -715,11 +714,11 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, cleanup = 2; obd = class_name2obd(lustre_cfg_string(cfg, 0)); - LASSERT(obd != NULL); - LASSERT(env != NULL); + LASSERT(obd); + LASSERT(env); tgt = class_name2obd(lustre_cfg_string(cfg, 1)); - if (tgt == NULL) { + if (!tgt) { CERROR("Can not find tgt device %s\n", lustre_cfg_string(cfg, 1)); rc = -ENODEV; @@ -747,14 +746,14 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, cleanup = 4; /* if echo client is to be stacked upon ost device, the next is - * NULL since ost is not a clio device so far */ - if (next != NULL && !lu_device_is_cl(next)) + * NULL since ost is not a clio device so far + */ + if (next && !lu_device_is_cl(next)) next = NULL; tgt_type_name = tgt->obd_type->typ_name; - if (next != NULL) { - LASSERT(next != NULL); - if (next->ld_site != NULL) { + if (next) { + if (next->ld_site) { rc = -EBUSY; goto out; } @@ -967,7 +966,8 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, } /* In the function below, .hs_keycmp resolves to - * lu_obj_hop_keycmp() */ + * lu_obj_hop_keycmp() + */ /* coverity[overrun-buffer-val] */ obj = cl_object_find(env, echo_dev2cl(d), fid, &conf->eoc_cl); if (IS_ERR(obj)) { @@ -1063,7 +1063,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, struct list_head *el; int found = 0, still_used = 0; - LASSERT(ec != NULL); spin_lock(&ec->ec_lock); list_for_each(el, &ec->ec_locks) { ecl = list_entry(el, struct echo_lock, el_chain); @@ -1121,7 +1120,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, int i; LASSERT((offset & ~CFS_PAGE_MASK) == 0); - LASSERT(ed->ed_next != NULL); + LASSERT(ed->ed_next); env = cl_env_get(&refcheck); if (IS_ERR(env)) return PTR_ERR(env); @@ -1167,7 +1166,8 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, cl_page_list_add(&queue->c2_qin, clp); /* drop the reference count for cl_page_find, so that the page - * will be freed in cl_2queue_fini. */ + * will be freed in cl_2queue_fini. + */ cl_page_put(env, clp); cl_page_clip(env, clp, 0, page_size); @@ -1393,11 +1393,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, brw_flags = OBD_BRW_ASYNC; pga = kcalloc(npages, sizeof(*pga), GFP_NOFS); - if (pga == NULL) + if (!pga) return -ENOMEM; pages = kcalloc(npages, sizeof(*pages), GFP_NOFS); - if (pages == NULL) { + if (!pages) { kfree(pga); return -ENOMEM; } @@ -1406,11 +1406,11 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, i < npages; i++, pgp++, off += PAGE_CACHE_SIZE) { - LASSERT(pgp->pg == NULL); /* for cleanup */ + LASSERT(!pgp->pg); /* for cleanup */ rc = -ENOMEM; pgp->pg = alloc_page(gfp_mask); - if (pgp->pg == NULL) + if (!pgp->pg) goto out; pages[i] = pgp->pg; @@ -1425,7 +1425,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } /* brw mode can only be used at client */ - LASSERT(ed->ed_next != NULL); + LASSERT(ed->ed_next); rc = cl_echo_object_brw(eco, rw, offset, pages, npages, async); out: @@ -1433,7 +1433,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, verify = 0; for (i = 0, pgp = pga; i < npages; i++, pgp++) { - if (pgp->pg == NULL) + if (!pgp->pg) continue; if (verify) { @@ -1475,7 +1475,7 @@ static int echo_client_prep_commit(const struct lu_env *env, lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS); rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS); - if (lnb == NULL || rnb == NULL) { + if (!lnb || !rnb) { ret = -ENOMEM; goto out; } @@ -1513,7 +1513,7 @@ static int echo_client_prep_commit(const struct lu_env *env, struct page *page = lnb[i].page; /* read past eof? */ - if (page == NULL && lnb[i].rc == 0) + if (!page && lnb[i].rc == 0) continue; if (async) @@ -1582,7 +1582,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, if (test_mode == 1) async = 0; - if (ed->ed_next == NULL && test_mode != 3) { + if (!ed->ed_next && test_mode != 3) { test_mode = 3; data->ioc_plen1 = data->ioc_count; } @@ -1834,7 +1834,7 @@ static int echo_client_disconnect(struct obd_export *exp) { int rc; - if (exp == NULL) { + if (!exp) { rc = -EINVAL; goto out; } diff --git a/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/drivers/staging/lustre/lustre/obdecho/echo_internal.h index 69063fa..f5034a2 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_internal.h +++ b/drivers/staging/lustre/lustre/obdecho/echo_internal.h @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index b69ec0f..b5df5e6 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -381,7 +381,7 @@ static int osc_checksum_type_seq_show(struct seq_file *m, void *v) DECLARE_CKSUM_NAME; - if (obd == NULL) + if (!obd) return 0; for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { @@ -406,7 +406,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, DECLARE_CKSUM_NAME; char kernbuf[10]; - if (obd == NULL) + if (!obd) return 0; if (count > sizeof(kernbuf) - 1) @@ -422,8 +422,8 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0) continue; if (!strcmp(kernbuf, cksum_name[i])) { - obd->u.cli.cl_cksum_type = 1 << i; - return count; + obd->u.cli.cl_cksum_type = 1 << i; + return count; } } return -EINVAL; diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 6b5f8d0..c6623c1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -140,7 +140,7 @@ static const char *oes_strings[] = { static inline struct osc_extent *rb_extent(struct rb_node *n) { - if (n == NULL) + if (!n) return NULL; return container_of(n, struct osc_extent, oe_node); @@ -148,7 +148,7 @@ static inline struct osc_extent *rb_extent(struct rb_node *n) static inline struct osc_extent *next_extent(struct osc_extent *ext) { - if (ext == NULL) + if (!ext) return NULL; LASSERT(ext->oe_intree); @@ -157,7 +157,7 @@ static inline struct osc_extent *next_extent(struct osc_extent *ext) static inline struct osc_extent *prev_extent(struct osc_extent *ext) { - if (ext == NULL) + if (!ext) return NULL; LASSERT(ext->oe_intree); @@ -240,7 +240,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, goto out; } - if (ext->oe_osclock == NULL && ext->oe_grants > 0) { + if (!ext->oe_osclock && ext->oe_grants > 0) { rc = 90; goto out; } @@ -262,7 +262,8 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, } /* Do not verify page list if extent is in RPC. This is because an - * in-RPC extent is supposed to be exclusively accessible w/o lock. */ + * in-RPC extent is supposed to be exclusively accessible w/o lock. + */ if (ext->oe_state > OES_CACHE) { rc = 0; goto out; @@ -319,7 +320,7 @@ static int osc_extent_is_overlapped(struct osc_object *obj, if (!extent_debug) return 0; - for (tmp = first_extent(obj); tmp != NULL; tmp = next_extent(tmp)) { + for (tmp = first_extent(obj); tmp; tmp = next_extent(tmp)) { if (tmp == ext) continue; if (tmp->oe_end >= ext->oe_start && @@ -347,7 +348,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj) struct osc_extent *ext; ext = kmem_cache_alloc(osc_extent_kmem, GFP_NOFS | __GFP_ZERO); - if (ext == NULL) + if (!ext) return NULL; RB_CLEAR_NODE(&ext->oe_node); @@ -415,7 +416,7 @@ static struct osc_extent *osc_extent_search(struct osc_object *obj, struct osc_extent *tmp, *p = NULL; LASSERT(osc_object_is_locked(obj)); - while (n != NULL) { + while (n) { tmp = rb_extent(n); if (index < tmp->oe_start) { n = n->rb_left; @@ -439,7 +440,7 @@ static struct osc_extent *osc_extent_lookup(struct osc_object *obj, struct osc_extent *ext; ext = osc_extent_search(obj, index); - if (ext != NULL && ext->oe_start <= index && index <= ext->oe_end) + if (ext && ext->oe_start <= index && index <= ext->oe_end) return osc_extent_get(ext); return NULL; } @@ -454,7 +455,7 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) LASSERT(ext->oe_intree == 0); LASSERT(ext->oe_obj == obj); LASSERT(osc_object_is_locked(obj)); - while (*n != NULL) { + while (*n) { tmp = rb_extent(*n); parent = *n; @@ -533,7 +534,7 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, LASSERT(cur->oe_state == OES_CACHE); LASSERT(osc_object_is_locked(obj)); - if (victim == NULL) + if (!victim) return -EINVAL; if (victim->oe_state != OES_CACHE || victim->oe_fsync_wait) @@ -587,7 +588,8 @@ void osc_extent_release(const struct lu_env *env, struct osc_extent *ext) if (ext->oe_trunc_pending) { /* a truncate process is waiting for this extent. * This may happen due to a race, check - * osc_cache_truncate_start(). */ + * osc_cache_truncate_start(). + */ osc_extent_state_set(ext, OES_TRUNC); ext->oe_trunc_pending = 0; } else { @@ -639,11 +641,10 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, int rc; cur = osc_extent_alloc(obj); - if (cur == NULL) + if (!cur) return ERR_PTR(-ENOMEM); lock = cl_lock_at_pgoff(env, osc2cl(obj), index, NULL, 1, 0); - LASSERT(lock != NULL); LASSERT(lock->cll_descr.cld_mode >= CLM_WRITE); LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT); @@ -678,9 +679,9 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, restart: osc_object_lock(obj); ext = osc_extent_search(obj, cur->oe_start); - if (ext == NULL) + if (!ext) ext = first_extent(obj); - while (ext != NULL) { + while (ext) { loff_t ext_chk_start = ext->oe_start >> ppc_bits; loff_t ext_chk_end = ext->oe_end >> ppc_bits; @@ -705,18 +706,21 @@ restart: /* ok, from now on, ext and cur have these attrs: * 1. covered by the same lock - * 2. contiguous at chunk level or overlapping. */ + * 2. contiguous at chunk level or overlapping. + */ if (overlapped(ext, cur)) { /* cur is the minimum unit, so overlapping means - * full contain. */ + * full contain. + */ EASSERTF((ext->oe_start <= cur->oe_start && ext->oe_end >= cur->oe_end), ext, EXTSTR, EXTPARA(cur)); if (ext->oe_state > OES_CACHE || ext->oe_fsync_wait) { /* for simplicity, we wait for this extent to - * finish before going forward. */ + * finish before going forward. + */ conflict = osc_extent_get(ext); break; } @@ -729,17 +733,20 @@ restart: if (ext->oe_state != OES_CACHE || ext->oe_fsync_wait) { /* we can't do anything for a non OES_CACHE extent, or * if there is someone waiting for this extent to be - * flushed, try next one. */ + * flushed, try next one. + */ ext = next_extent(ext); continue; } /* check if they belong to the same rpc slot before trying to * merge. the extents are not overlapped and contiguous at - * chunk level to get here. */ + * chunk level to get here. + */ if (ext->oe_max_end != max_end) { /* if they don't belong to the same RPC slot or - * max_pages_per_rpc has ever changed, do not merge. */ + * max_pages_per_rpc has ever changed, do not merge. + */ ext = next_extent(ext); continue; } @@ -748,7 +755,8 @@ restart: * level so that we know the whole extent is covered by grant * (the pages in the extent are NOT required to be contiguous). * Otherwise, it will be too much difficult to know which - * chunks have grants allocated. */ + * chunks have grants allocated. + */ /* try to do front merge - extend ext's start */ if (chunk + 1 == ext_chk_start) { @@ -768,28 +776,29 @@ restart: *grants -= chunksize; /* try to merge with the next one because we just fill - * in a gap */ + * in a gap + */ if (osc_extent_merge(env, ext, next_extent(ext)) == 0) /* we can save extent tax from next extent */ *grants += cli->cl_extent_tax; found = osc_extent_hold(ext); } - if (found != NULL) + if (found) break; ext = next_extent(ext); } osc_extent_tree_dump(D_CACHE, obj); - if (found != NULL) { - LASSERT(conflict == NULL); + if (found) { + LASSERT(!conflict); if (!IS_ERR(found)) { LASSERT(found->oe_osclock == cur->oe_osclock); OSC_EXTENT_DUMP(D_CACHE, found, "found caching ext for %lu.\n", index); } - } else if (conflict == NULL) { + } else if (!conflict) { /* create a new extent */ EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur); cur->oe_grants = chunksize + cli->cl_extent_tax; @@ -804,11 +813,12 @@ restart: } osc_object_unlock(obj); - if (conflict != NULL) { - LASSERT(found == NULL); + if (conflict) { + LASSERT(!found); /* waiting for IO to finish. Please notice that it's impossible - * to be an OES_TRUNC extent. */ + * to be an OES_TRUNC extent. + */ rc = osc_extent_wait(env, conflict, OES_INV); osc_extent_put(env, conflict); conflict = NULL; @@ -865,7 +875,8 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, last_count != PAGE_CACHE_SIZE) { /* For short writes we shouldn't count parts of pages that * span a whole chunk on the OST side, or our accounting goes - * wrong. Should match the code in filter_grant_check. */ + * wrong. Should match the code in filter_grant_check. + */ int offset = oap->oap_page_off & ~CFS_PAGE_MASK; int count = oap->oap_count + (offset & (blocksize - 1)); int end = (offset + oap->oap_count) & (blocksize - 1); @@ -909,7 +920,8 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, osc_object_lock(obj); LASSERT(sanity_check_nolock(ext) == 0); /* `Kick' this extent only if the caller is waiting for it to be - * written out. */ + * written out. + */ if (state == OES_INV && !ext->oe_urgent && !ext->oe_hp && !ext->oe_trunc_pending) { if (ext->oe_state == OES_ACTIVE) { @@ -967,7 +979,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, /* Request new lu_env. * We can't use that env from osc_cache_truncate_start() because - * it's from lov_io_sub and not fully initialized. */ + * it's from lov_io_sub and not fully initialized. + */ env = cl_env_nested_get(&nest); io = &osc_env_info(env)->oti_io; io->ci_obj = cl_object_top(osc2cl(obj)); @@ -984,7 +997,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, LASSERT(list_empty(&oap->oap_rpc_item)); /* only discard the pages with their index greater than - * trunc_index, and ... */ + * trunc_index, and ... + */ if (sub->cp_index < trunc_index || (sub->cp_index == trunc_index && partial)) { /* accounting how many pages remaining in the chunk @@ -1028,11 +1042,13 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, pgoff_t last_index; /* if there is no pages in this chunk, we can also free grants - * for the last chunk */ + * for the last chunk + */ if (pages_in_chunk == 0) { /* if this is the 1st chunk and no pages in this chunk, * ext->oe_nr_pages must be zero, so we should be in - * the other if-clause. */ + * the other if-clause. + */ LASSERT(trunc_chunk > 0); --trunc_chunk; ++chunks; @@ -1074,13 +1090,13 @@ static int osc_extent_make_ready(const struct lu_env *env, LASSERT(sanity_check(ext) == 0); /* in locking state, any process should not touch this extent. */ EASSERT(ext->oe_state == OES_LOCKING, ext); - EASSERT(ext->oe_owner != NULL, ext); + EASSERT(ext->oe_owner, ext); OSC_EXTENT_DUMP(D_CACHE, ext, "make ready\n"); list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) { ++page_count; - if (last == NULL || last->oap_obj_off < oap->oap_obj_off) + if (!last || last->oap_obj_off < oap->oap_obj_off) last = oap; /* checking ASYNC_READY is race safe */ @@ -1103,9 +1119,10 @@ static int osc_extent_make_ready(const struct lu_env *env, } LASSERT(page_count == ext->oe_nr_pages); - LASSERT(last != NULL); + LASSERT(last); /* the last page is the only one we need to refresh its count by - * the size of file. */ + * the size of file. + */ if (!(last->oap_async_flags & ASYNC_COUNT_STABLE)) { last->oap_count = osc_refresh_count(env, last, OBD_BRW_WRITE); LASSERT(last->oap_count > 0); @@ -1114,7 +1131,8 @@ static int osc_extent_make_ready(const struct lu_env *env, } /* for the rest of pages, we don't need to call osf_refresh_count() - * because it's known they are not the last page */ + * because it's known they are not the last page + */ list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) { if (!(oap->oap_async_flags & ASYNC_COUNT_STABLE)) { oap->oap_count = PAGE_CACHE_SIZE - oap->oap_page_off; @@ -1167,9 +1185,10 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) end_index = min(ext->oe_max_end, ((chunk + 1) << ppc_bits) - 1); next = next_extent(ext); - if (next != NULL && next->oe_start <= end_index) { + if (next && next->oe_start <= end_index) { /* complex mode - overlapped with the next extent, - * this case will be handled by osc_extent_find() */ + * this case will be handled by osc_extent_find() + */ rc = -EAGAIN; goto out; } @@ -1197,7 +1216,7 @@ static void osc_extent_tree_dump0(int level, struct osc_object *obj, /* osc_object_lock(obj); */ cnt = 1; - for (ext = first_extent(obj); ext != NULL; ext = next_extent(ext)) + for (ext = first_extent(obj); ext; ext = next_extent(ext)) OSC_EXTENT_DUMP(level, ext, "in tree %d.\n", cnt++); cnt = 1; @@ -1262,7 +1281,6 @@ static int osc_refresh_count(const struct lu_env *env, /* readpage queues with _COUNT_STABLE, shouldn't get here. */ LASSERT(!(cmd & OBD_BRW_READ)); - LASSERT(opg != NULL); obj = opg->ops_cl.cpl_obj; cl_object_attr_lock(obj); @@ -1299,16 +1317,16 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, * page->cp_req can be NULL if io submission failed before * cl_req was allocated. */ - if (page->cp_req != NULL) + if (page->cp_req) cl_req_page_done(env, page); - LASSERT(page->cp_req == NULL); + LASSERT(!page->cp_req); crt = cmd == OBD_BRW_READ ? CRT_READ : CRT_WRITE; /* Clear opg->ops_transfer_pinned before VM lock is released. */ opg->ops_transfer_pinned = 0; spin_lock(&obj->oo_seatbelt); - LASSERT(opg->ops_submitter != NULL); + LASSERT(opg->ops_submitter); LASSERT(!list_empty(&opg->ops_inflight)); list_del_init(&opg->ops_inflight); opg->ops_submitter = NULL; @@ -1367,7 +1385,8 @@ static void osc_consume_write_grant(struct client_obd *cli, } /* the companion to osc_consume_write_grant, called when a brw has completed. - * must be called with the loi lock held. */ + * must be called with the loi lock held. + */ static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { @@ -1410,7 +1429,8 @@ static void __osc_unreserve_grant(struct client_obd *cli, /* it's quite normal for us to get more grant than reserved. * Thinking about a case that two extents merged by adding a new * chunk, we can save one extent tax. If extent tax is greater than - * one chunk, we can save more grant by adding a new chunk */ + * one chunk, we can save more grant by adding a new chunk + */ cli->cl_reserved_grant -= reserved; if (unused > reserved) { cli->cl_avail_grant += reserved; @@ -1454,7 +1474,8 @@ static void osc_free_grant(struct client_obd *cli, unsigned int nr_pages, cli->cl_lost_grant += lost_grant; if (cli->cl_avail_grant < grant && cli->cl_lost_grant >= grant) { /* borrow some grant from truncate to avoid the case that - * truncate uses up all avail grant */ + * truncate uses up all avail grant + */ cli->cl_lost_grant -= grant; cli->cl_avail_grant += grant; } @@ -1539,7 +1560,8 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, client_obd_list_lock(&cli->cl_loi_list_lock); /* force the caller to try sync io. this can jump the list - * of queued writes and create a discontiguous rpc stream */ + * of queued writes and create a discontiguous rpc stream + */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_NO_GRANT) || cli->cl_dirty_max < PAGE_CACHE_SIZE || cli->cl_ar.ar_force_sync || loi->loi_ar.ar_force_sync) { @@ -1558,7 +1580,8 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, * Adding a cache waiter will trigger urgent write-out no matter what * RPC size will be. * The exiting condition is no avail grants and no dirty pages caching, - * that really means there is no space on the OST. */ + * that really means there is no space on the OST. + */ init_waitqueue_head(&ocw.ocw_waitq); ocw.ocw_oap = oap; ocw.ocw_grant = bytes; @@ -1640,7 +1663,8 @@ static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) /* This maintains the lists of pending pages to read/write for a given object * (lop). This is used by osc_check_rpcs->osc_next_obj() and osc_list_maint() - * to quickly find objects that are ready to send an RPC. */ + * to quickly find objects that are ready to send an RPC. + */ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, int cmd) { @@ -1649,8 +1673,9 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, /* if we have an invalid import we want to drain the queued pages * by forcing them through rpcs that immediately fail and complete * the pages. recovery relies on this to empty the queued pages - * before canceling the locks and evicting down the llite pages */ - if ((cli->cl_import == NULL || cli->cl_import->imp_invalid)) + * before canceling the locks and evicting down the llite pages + */ + if (!cli->cl_import || cli->cl_import->imp_invalid) invalid_import = 1; if (cmd & OBD_BRW_WRITE) { @@ -1670,7 +1695,8 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, } /* trigger a write rpc stream as long as there are dirtiers * waiting for space. as they're waiting, they're not going to - * create more pages to coalesce with what's waiting.. */ + * create more pages to coalesce with what's waiting.. + */ if (!list_empty(&cli->cl_cache_waiters)) { CDEBUG(D_CACHE, "cache waiters forcing RPC\n"); return 1; @@ -1723,7 +1749,8 @@ static void on_list(struct list_head *item, struct list_head *list, int should_b } /* maintain the osc's cli list membership invariants so that osc_send_oap_rpc - * can find pages to build into rpcs quickly */ + * can find pages to build into rpcs quickly + */ static int __osc_list_maint(struct client_obd *cli, struct osc_object *osc) { if (osc_makes_hprpc(osc)) { @@ -1761,7 +1788,8 @@ static int osc_list_maint(struct client_obd *cli, struct osc_object *osc) * application. As an async write fails we record the error code for later if * the app does an fsync. As long as errors persist we force future rpcs to be * sync so that the app can get a sync error and break the cycle of queueing - * pages for which writeback will fail. */ + * pages for which writeback will fail. + */ static void osc_process_ar(struct osc_async_rc *ar, __u64 xid, int rc) { @@ -1780,7 +1808,8 @@ static void osc_process_ar(struct osc_async_rc *ar, __u64 xid, } /* this must be called holding the loi list lock to give coverage to exit_cache, - * async_flag maintenance, and oap_request */ + * async_flag maintenance, and oap_request + */ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int sent, int rc) { @@ -1788,7 +1817,7 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; - if (oap->oap_request != NULL) { + if (oap->oap_request) { xid = ptlrpc_req_xid(oap->oap_request); ptlrpc_req_finished(oap->oap_request); oap->oap_request = NULL; @@ -1906,7 +1935,7 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist) while ((ext = next_extent(ext)) != NULL) { if ((ext->oe_state != OES_CACHE) || (!list_empty(&ext->oe_link) && - ext->oe_owner != NULL)) + ext->oe_owner)) continue; if (!try_to_add_extent_for_io(cli, ext, rpclist, @@ -1918,10 +1947,10 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist) return page_count; ext = first_extent(obj); - while (ext != NULL) { + while (ext) { if ((ext->oe_state != OES_CACHE) || /* this extent may be already in current rpclist */ - (!list_empty(&ext->oe_link) && ext->oe_owner != NULL)) { + (!list_empty(&ext->oe_link) && ext->oe_owner)) { ext = next_extent(ext); continue; } @@ -1968,7 +1997,8 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, } /* we're going to grab page lock, so release object lock because - * lock order is page lock -> object lock. */ + * lock order is page lock -> object lock. + */ osc_object_unlock(osc); list_for_each_entry_safe(ext, tmp, &rpclist, oe_link) { @@ -1980,7 +2010,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, continue; } } - if (first == NULL) { + if (!first) { first = ext; srvlock = ext->oe_srvlock; } else { @@ -2053,12 +2083,14 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, }) /* This is called by osc_check_rpcs() to find which objects have pages that - * we could be sending. These lists are maintained by osc_makes_rpc(). */ + * we could be sending. These lists are maintained by osc_makes_rpc(). + */ static struct osc_object *osc_next_obj(struct client_obd *cli) { /* First return objects that have blocked locks so that they * will be flushed quickly and other clients can get the lock, - * then objects which have pages ready to be stuffed into RPCs */ + * then objects which have pages ready to be stuffed into RPCs + */ if (!list_empty(&cli->cl_loi_hp_ready_list)) return list_to_obj(&cli->cl_loi_hp_ready_list, hp_ready_item); if (!list_empty(&cli->cl_loi_ready_list)) @@ -2067,14 +2099,16 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) /* then if we have cache waiters, return all objects with queued * writes. This is especially important when many small files * have filled up the cache and not been fired into rpcs because - * they don't pass the nr_pending/object threshold */ + * they don't pass the nr_pending/object threshold + */ if (!list_empty(&cli->cl_cache_waiters) && !list_empty(&cli->cl_loi_write_list)) return list_to_obj(&cli->cl_loi_write_list, write_item); /* then return all queued objects when we have an invalid import - * so that they get flushed */ - if (cli->cl_import == NULL || cli->cl_import->imp_invalid) { + * so that they get flushed + */ + if (!cli->cl_import || cli->cl_import->imp_invalid) { if (!list_empty(&cli->cl_loi_write_list)) return list_to_obj(&cli->cl_loi_write_list, write_item); if (!list_empty(&cli->cl_loi_read_list)) @@ -2111,7 +2145,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) * would be redundant if we were getting read/write work items * instead of objects. we don't want send_oap_rpc to drain a * partial read pending queue when we're given this object to - * do io on writes while there are cache waiters */ + * do io on writes while there are cache waiters + */ osc_object_lock(osc); if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) { rc = osc_send_write_rpc(env, cli, osc); @@ -2133,7 +2168,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) * because it might be blocked at grabbing * the page lock as we mentioned. * - * Anyway, continue to drain pages. */ + * Anyway, continue to drain pages. + */ /* break; */ } } @@ -2158,12 +2194,13 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, { int rc = 0; - if (osc != NULL && osc_list_maint(cli, osc) == 0) + if (osc && osc_list_maint(cli, osc) == 0) return 0; if (!async) { /* disable osc_lru_shrink() temporarily to avoid - * potential stack overrun problem. LU-2859 */ + * potential stack overrun problem. LU-2859 + */ atomic_inc(&cli->cl_lru_shrinkers); client_obd_list_lock(&cli->cl_loi_list_lock); osc_check_rpcs(env, cli); @@ -2171,7 +2208,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, atomic_dec(&cli->cl_lru_shrinkers); } else { CDEBUG(D_CACHE, "Queue writeback work for client %p.\n", cli); - LASSERT(cli->cl_writeback_work != NULL); + LASSERT(cli->cl_writeback_work); rc = ptlrpcd_queue_work(cli->cl_writeback_work); } return rc; @@ -2236,7 +2273,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, if (oap->oap_magic != OAP_MAGIC) return -EINVAL; - if (cli->cl_import == NULL || cli->cl_import->imp_invalid) + if (!cli->cl_import || cli->cl_import->imp_invalid) return -EIO; if (!list_empty(&oap->oap_pending_item) || @@ -2287,12 +2324,14 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, * 1. if there exists an active extent for this IO, mostly this page * can be added to the active extent and sometimes we need to * expand extent to accommodate this page; - * 2. otherwise, a new extent will be allocated. */ + * 2. otherwise, a new extent will be allocated. + */ ext = oio->oi_active; - if (ext != NULL && ext->oe_start <= index && ext->oe_max_end >= index) { + if (ext && ext->oe_start <= index && ext->oe_max_end >= index) { /* one chunk plus extent overhead must be enough to write this - * page */ + * page + */ grants = (1 << cli->cl_chunkbits) + cli->cl_extent_tax; if (ext->oe_end >= index) grants = 0; @@ -2319,7 +2358,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, } } rc = 0; - } else if (ext != NULL) { + } else if (ext) { /* index is located outside of active extent */ need_release = 1; } @@ -2329,13 +2368,14 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, ext = NULL; } - if (ext == NULL) { + if (!ext) { int tmp = (1 << cli->cl_chunkbits) + cli->cl_extent_tax; /* try to find new extent to cover this page */ - LASSERT(oio->oi_active == NULL); + LASSERT(!oio->oi_active); /* we may have allocated grant for this page if we failed - * to expand the previous active extent. */ + * to expand the previous active extent. + */ LASSERT(ergo(grants > 0, grants >= tmp)); rc = 0; @@ -2362,8 +2402,8 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, osc_unreserve_grant(cli, grants, tmp); } - LASSERT(ergo(rc == 0, ext != NULL)); - if (ext != NULL) { + LASSERT(ergo(rc == 0, ext)); + if (ext) { EASSERTF(ext->oe_end >= index && ext->oe_start <= index, ext, "index = %lu.\n", index); LASSERT((oap->oap_brw_flags & OBD_BRW_FROM_GRANT) != 0); @@ -2400,15 +2440,16 @@ int osc_teardown_async_page(const struct lu_env *env, ext = osc_extent_lookup(obj, oap2cl_page(oap)->cp_index); /* only truncated pages are allowed to be taken out. * See osc_extent_truncate() and osc_cache_truncate_start() - * for details. */ - if (ext != NULL && ext->oe_state != OES_TRUNC) { + * for details. + */ + if (ext && ext->oe_state != OES_TRUNC) { OSC_EXTENT_DUMP(D_ERROR, ext, "trunc at %lu.\n", oap2cl_page(oap)->cp_index); rc = -EBUSY; } } osc_object_unlock(obj); - if (ext != NULL) + if (ext) osc_extent_put(env, ext); return rc; } @@ -2433,7 +2474,7 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, osc_object_lock(obj); ext = osc_extent_lookup(obj, index); - if (ext == NULL) { + if (!ext) { osc_extent_tree_dump(D_ERROR, obj); LASSERTF(0, "page index %lu is NOT covered.\n", index); } @@ -2451,7 +2492,8 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, * exists a deadlock problem because other process can wait for * page writeback bit holding page lock; and meanwhile in * vvp_page_make_ready(), we need to grab page lock before - * really sending the RPC. */ + * really sending the RPC. + */ case OES_TRUNC: /* race with truncate, page will be redirtied */ case OES_ACTIVE: @@ -2459,7 +2501,8 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, * re-dirty the page. If we continued on here, and we were the * one making the extent active, we could deadlock waiting for * the page writeback to clear but it won't because the extent - * is active and won't be written out. */ + * is active and won't be written out. + */ rc = -EAGAIN; goto out; default: @@ -2530,12 +2573,13 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) if (ext->oe_start <= index && ext->oe_end >= index) { LASSERT(ext->oe_state == OES_LOCK_DONE); /* For OES_LOCK_DONE state extent, it has already held - * a refcount for RPC. */ + * a refcount for RPC. + */ found = osc_extent_get(ext); break; } } - if (found != NULL) { + if (found) { list_del_init(&found->oe_link); osc_update_pending(obj, cmd, -found->oe_nr_pages); osc_object_unlock(obj); @@ -2546,8 +2590,9 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) } else { osc_object_unlock(obj); /* ok, it's been put in an rpc. only one oap gets a request - * reference */ - if (oap->oap_request != NULL) { + * reference + */ + if (oap->oap_request) { ptlrpc_mark_interrupted(oap->oap_request); ptlrpcd_wake(oap->oap_request); ptlrpc_req_finished(oap->oap_request); @@ -2582,7 +2627,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, } ext = osc_extent_alloc(obj); - if (ext == NULL) { + if (!ext) { list_for_each_entry_safe(oap, tmp, list, oap_pending_item) { list_del_init(&oap->oap_pending_item); osc_ap_completion(env, cli, oap, 0, -ENOMEM); @@ -2637,18 +2682,19 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, again: osc_object_lock(obj); ext = osc_extent_search(obj, index); - if (ext == NULL) + if (!ext) ext = first_extent(obj); else if (ext->oe_end < index) ext = next_extent(ext); - while (ext != NULL) { + while (ext) { EASSERT(ext->oe_state != OES_TRUNC, ext); if (ext->oe_state > OES_CACHE || ext->oe_urgent) { /* if ext is in urgent state, it means there must exist * a page already having been flushed by write_page(). * We have to wait for this extent because we can't - * truncate that page. */ + * truncate that page. + */ LASSERT(!ext->oe_hp); OSC_EXTENT_DUMP(D_CACHE, ext, "waiting for busy extent\n"); @@ -2663,7 +2709,8 @@ again: /* though we grab inode mutex for write path, but we * release it before releasing extent(in osc_io_end()), * so there is a race window that an extent is still - * in OES_ACTIVE when truncate starts. */ + * in OES_ACTIVE when truncate starts. + */ LASSERT(!ext->oe_trunc_pending); ext->oe_trunc_pending = 1; } else { @@ -2688,7 +2735,8 @@ again: list_del_init(&ext->oe_link); /* extent may be in OES_ACTIVE state because inode mutex - * is released before osc_io_end() in file write case */ + * is released before osc_io_end() in file write case + */ if (ext->oe_state != OES_TRUNC) osc_extent_wait(env, ext, OES_TRUNC); @@ -2713,19 +2761,21 @@ again: /* we need to hold this extent in OES_TRUNC state so * that no writeback will happen. This is to avoid - * BUG 17397. */ - LASSERT(oio->oi_trunc == NULL); + * BUG 17397. + */ + LASSERT(!oio->oi_trunc); oio->oi_trunc = osc_extent_get(ext); OSC_EXTENT_DUMP(D_CACHE, ext, "trunc at %llu\n", size); } osc_extent_put(env, ext); } - if (waiting != NULL) { + if (waiting) { int rc; /* ignore the result of osc_extent_wait the write initiator - * should take care of it. */ + * should take care of it. + */ rc = osc_extent_wait(env, waiting, OES_INV); if (rc < 0) OSC_EXTENT_DUMP(D_CACHE, waiting, "error: %d.\n", rc); @@ -2746,7 +2796,7 @@ void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, struct osc_extent *ext = oio->oi_trunc; oio->oi_trunc = NULL; - if (ext != NULL) { + if (ext) { bool unplug = false; EASSERT(ext->oe_nr_pages > 0, ext); @@ -2789,11 +2839,11 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, again: osc_object_lock(obj); ext = osc_extent_search(obj, index); - if (ext == NULL) + if (!ext) ext = first_extent(obj); else if (ext->oe_end < index) ext = next_extent(ext); - while (ext != NULL) { + while (ext) { int rc; if (ext->oe_start > end) @@ -2844,11 +2894,11 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, osc_object_lock(obj); ext = osc_extent_search(obj, start); - if (ext == NULL) + if (!ext) ext = first_extent(obj); else if (ext->oe_end < start) ext = next_extent(ext); - while (ext != NULL) { + while (ext) { if (ext->oe_start > end) break; @@ -2867,12 +2917,13 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, ext->oe_urgent = 1; list = &obj->oo_urgent_exts; } - if (list != NULL) + if (list) list_move_tail(&ext->oe_link, list); unplug = true; } else { /* the only discarder is lock cancelling, so - * [start, end] must contain this extent */ + * [start, end] must contain this extent + */ EASSERT(ext->oe_start >= start && ext->oe_max_end <= end, ext); osc_extent_state_set(ext, OES_LOCKING); @@ -2887,14 +2938,16 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, /* It's pretty bad to wait for ACTIVE extents, because * we don't know how long we will wait for it to be * flushed since it may be blocked at awaiting more - * grants. We do this for the correctness of fsync. */ + * grants. We do this for the correctness of fsync. + */ LASSERT(hp == 0 && discard == 0); ext->oe_urgent = 1; break; case OES_TRUNC: /* this extent is being truncated, can't do anything * for it now. it will be set to urgent after truncate - * is finished in osc_cache_truncate_end(). */ + * is finished in osc_cache_truncate_end(). + */ default: break; } @@ -2913,7 +2966,8 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, EASSERT(ext->oe_state == OES_LOCKING, ext); /* Discard caching pages. We don't actually write this - * extent out but we complete it as if we did. */ + * extent out but we complete it as if we did. + */ rc = osc_extent_make_ready(env, ext); if (unlikely(rc < 0)) { OSC_EXTENT_DUMP(D_ERROR, ext, diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 415c27e..d55d04d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -69,10 +69,12 @@ struct osc_io { /** true if this io is lockless. */ int oi_lockless; /** active extents, we know how many bytes is going to be written, - * so having an active extent will prevent it from being fragmented */ + * so having an active extent will prevent it from being fragmented + */ struct osc_extent *oi_active; /** partially truncated extent, we need to hold this extent to prevent - * page writeback from happening. */ + * page writeback from happening. + */ struct osc_extent *oi_trunc; struct obd_info oi_info; @@ -154,7 +156,8 @@ struct osc_object { atomic_t oo_nr_writes; /** Protect extent tree. Will be used to protect - * oo_{read|write}_pages soon. */ + * oo_{read|write}_pages soon. + */ spinlock_t oo_lock; }; @@ -472,7 +475,7 @@ static inline struct osc_thread_info *osc_env_info(const struct lu_env *env) struct osc_thread_info *info; info = lu_context_key_get(&env->le_ctx, &osc_key); - LASSERT(info != NULL); + LASSERT(info); return info; } @@ -481,7 +484,7 @@ static inline struct osc_session *osc_env_session(const struct lu_env *env) struct osc_session *ses; ses = lu_context_key_get(env->le_ses, &osc_session_key); - LASSERT(ses != NULL); + LASSERT(ses); return ses; } @@ -522,7 +525,7 @@ static inline struct cl_object *osc2cl(const struct osc_object *obj) return (struct cl_object *)&obj->oo_cl; } -static inline ldlm_mode_t osc_cl_lock2ldlm(enum cl_lock_mode mode) +static inline enum ldlm_mode osc_cl_lock2ldlm(enum cl_lock_mode mode) { LASSERT(mode == CLM_READ || mode == CLM_WRITE || mode == CLM_GROUP); if (mode == CLM_READ) @@ -533,7 +536,7 @@ static inline ldlm_mode_t osc_cl_lock2ldlm(enum cl_lock_mode mode) return LCK_GROUP; } -static inline enum cl_lock_mode osc_ldlm2cl_lock(ldlm_mode_t mode) +static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode) { LASSERT(mode == LCK_PR || mode == LCK_PW || mode == LCK_GROUP); if (mode == LCK_PR) @@ -627,22 +630,26 @@ struct osc_extent { oe_srvlock:1, oe_memalloc:1, /** an ACTIVE extent is going to be truncated, so when this extent - * is released, it will turn into TRUNC state instead of CACHE. */ + * is released, it will turn into TRUNC state instead of CACHE. + */ oe_trunc_pending:1, /** this extent should be written asap and someone may wait for the * write to finish. This bit is usually set along with urgent if * the extent was CACHE state. * fsync_wait extent can't be merged because new extent region may - * exceed fsync range. */ + * exceed fsync range. + */ oe_fsync_wait:1, /** covering lock is being canceled */ oe_hp:1, /** this extent should be written back asap. set if one of pages is - * called by page WB daemon, or sync write or reading requests. */ + * called by page WB daemon, or sync write or reading requests. + */ oe_urgent:1; /** how many grants allocated for this extent. * Grant allocated for this extent. There is no grant allocated - * for reading extents and sync write extents. */ + * for reading extents and sync write extents. + */ unsigned int oe_grants; /** # of dirty pages in this extent */ unsigned int oe_nr_pages; @@ -655,21 +662,25 @@ struct osc_extent { struct osc_page *oe_next_page; /** start and end index of this extent, include start and end * themselves. Page offset here is the page index of osc_pages. - * oe_start is used as keyword for red-black tree. */ + * oe_start is used as keyword for red-black tree. + */ pgoff_t oe_start; pgoff_t oe_end; /** maximum ending index of this extent, this is limited by - * max_pages_per_rpc, lock extent and chunk size. */ + * max_pages_per_rpc, lock extent and chunk size. + */ pgoff_t oe_max_end; /** waitqueue - for those who want to be notified if this extent's - * state has changed. */ + * state has changed. + */ wait_queue_head_t oe_waitq; /** lock covering this extent */ struct cl_lock *oe_osclock; /** terminator of this extent. Must be true if this extent is in IO. */ struct task_struct *oe_owner; /** return value of writeback. If somebody is waiting for this extent, - * this value can be known by outside world. */ + * this value can be known by outside world. + */ int oe_rc; /** max pages per rpc when this extent was created */ unsigned int oe_mppr; diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 7078cc5..67cb6e4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -123,7 +123,7 @@ static void *osc_key_init(const struct lu_context *ctx, struct osc_thread_info *info; info = kmem_cache_alloc(osc_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -148,7 +148,7 @@ static void *osc_session_init(const struct lu_context *ctx, struct osc_session *info; info = kmem_cache_alloc(osc_session_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -228,7 +228,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, /* Setup OSC OBD */ obd = class_name2obd(lustre_cfg_string(cfg, 0)); - LASSERT(obd != NULL); + LASSERT(obd); rc = osc_setup(obd, cfg); if (rc) { osc_device_free(env, d); diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index a4c6146..ea695c2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -47,11 +47,13 @@ struct lu_env; enum async_flags { ASYNC_READY = 0x1, /* ap_make_ready will not be called before this - page is added to an rpc */ + * page is added to an rpc + */ ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */ ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called - to give the caller a chance to update - or cancel the size of the io */ + * to give the caller a chance to update + * or cancel the size of the io + */ ASYNC_HP = 0x10, }; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index abd0beb..2d8d93c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -73,7 +73,7 @@ static struct osc_page *osc_cl_page_osc(struct cl_page *page) const struct cl_page_slice *slice; slice = cl_page_at(page, &osc_device_type); - LASSERT(slice != NULL); + LASSERT(slice); return cl2osc_page(slice); } @@ -135,7 +135,7 @@ static int osc_io_submit(const struct lu_env *env, /* Top level IO. */ io = page->cp_owner; - LASSERT(io != NULL); + LASSERT(io); opg = osc_cl_page_osc(page); oap = &opg->ops_oap; @@ -266,13 +266,14 @@ static int osc_io_prepare_write(const struct lu_env *env, * This implements OBD_BRW_CHECK logic from old client. */ - if (imp == NULL || imp->imp_invalid) + if (!imp || imp->imp_invalid) result = -EIO; if (result == 0 && oio->oi_lockless) /* this page contains `invalid' data, but who cares? * nobody can access the invalid data. * in osc_io_commit_write(), we're going to write exact - * [from, to) bytes of this page to OST. -jay */ + * [from, to) bytes of this page to OST. -jay + */ cl_page_export(env, slice->cpl_page, 1); return result; @@ -349,7 +350,7 @@ static int trunc_check_cb(const struct lu_env *env, struct cl_io *io, __u64 start = *(__u64 *)cbdata; slice = cl_page_at(page, &osc_device_type); - LASSERT(slice != NULL); + LASSERT(slice); ops = cl2osc_page(slice); oap = &ops->ops_oap; @@ -500,7 +501,7 @@ static void osc_io_setattr_end(const struct lu_env *env, __u64 size = io->u.ci_setattr.sa_attr.lvb_size; osc_trunc_check(env, io, oio, size); - if (oio->oi_trunc != NULL) { + if (oio->oi_trunc) { osc_cache_truncate_end(env, oio, cl2osc(obj)); oio->oi_trunc = NULL; } @@ -596,7 +597,8 @@ static int osc_io_fsync_start(const struct lu_env *env, * send OST_SYNC RPC. This is bad because it causes extents * to be written osc by osc. However, we usually start * writeback before CL_FSYNC_ALL so this won't have any real - * problem. */ + * problem. + */ rc = osc_cache_wait_range(env, osc, start, end); if (result == 0) result = rc; @@ -754,7 +756,7 @@ static void osc_req_attr_set(const struct lu_env *env, opg = osc_cl_page_osc(apage); apage = opg->ops_cl.cpl_page; /* now apage is a sub-page */ lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1); - if (lock == NULL) { + if (!lock) { struct cl_object_header *head; struct cl_lock *scan; @@ -770,10 +772,9 @@ static void osc_req_attr_set(const struct lu_env *env, } olck = osc_lock_at(lock); - LASSERT(olck != NULL); - LASSERT(ergo(opg->ops_srvlock, olck->ols_lock == NULL)); + LASSERT(ergo(opg->ops_srvlock, !olck->ols_lock)); /* check for lockless io. */ - if (olck->ols_lock != NULL) { + if (olck->ols_lock) { oa->o_handle = olck->ols_lock->l_remote_handle; oa->o_valid |= OBD_MD_FLHANDLE; } @@ -804,7 +805,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev, int result; or = kmem_cache_alloc(osc_req_kmem, GFP_NOFS | __GFP_ZERO); - if (or != NULL) { + if (or) { cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops); result = 0; } else diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 71f2810..87f3522 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -79,7 +79,7 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) struct ldlm_lock *lock; lock = ldlm_handle2lock(handle); - if (lock != NULL) + if (lock) LDLM_LOCK_PUT(lock); return lock; } @@ -94,42 +94,40 @@ static int osc_lock_invariant(struct osc_lock *ols) int handle_used = lustre_handle_is_used(&ols->ols_handle); if (ergo(osc_lock_is_lockless(ols), - ols->ols_locklessable && ols->ols_lock == NULL)) + ols->ols_locklessable && !ols->ols_lock)) return 1; /* * If all the following "ergo"s are true, return 1, otherwise 0 */ - if (!ergo(olock != NULL, handle_used)) + if (!ergo(olock, handle_used)) return 0; - if (!ergo(olock != NULL, - olock->l_handle.h_cookie == ols->ols_handle.cookie)) + if (!ergo(olock, olock->l_handle.h_cookie == ols->ols_handle.cookie)) return 0; if (!ergo(handle_used, - ergo(lock != NULL && olock != NULL, lock == olock) && - ergo(lock == NULL, olock == NULL))) + ergo(lock && olock, lock == olock) && + ergo(!lock, !olock))) return 0; /* * Check that ->ols_handle and ->ols_lock are consistent, but * take into account that they are set at the different time. */ if (!ergo(ols->ols_state == OLS_CANCELLED, - olock == NULL && !handle_used)) + !olock && !handle_used)) return 0; /* * DLM lock is destroyed only after we have seen cancellation * ast. */ - if (!ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, - ((olock->l_flags & LDLM_FL_DESTROYED) == 0))) + if (!ergo(olock && ols->ols_state < OLS_CANCELLED, + ((olock->l_flags & LDLM_FL_DESTROYED) == 0))) return 0; if (!ergo(ols->ols_state == OLS_GRANTED, - olock != NULL && - olock->l_req_mode == olock->l_granted_mode && - ols->ols_hold)) + olock && olock->l_req_mode == olock->l_granted_mode && + ols->ols_hold)) return 0; return 1; } @@ -149,14 +147,15 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) spin_lock(&osc_ast_guard); dlmlock = olck->ols_lock; - if (dlmlock == NULL) { + if (!dlmlock) { spin_unlock(&osc_ast_guard); return; } olck->ols_lock = NULL; /* wb(); --- for all who checks (ols->ols_lock != NULL) before - * call to osc_lock_detach() */ + * call to osc_lock_detach() + */ dlmlock->l_ast_data = NULL; olck->ols_handle.cookie = 0ULL; spin_unlock(&osc_ast_guard); @@ -171,7 +170,8 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) /* Must get the value under the lock to avoid possible races. */ old_kms = cl2osc(obj)->oo_oinfo->loi_kms; /* Update the kms. Need to loop all granted locks. - * Not a problem for the client */ + * Not a problem for the client + */ attr->cat_kms = ldlm_extent_shift_kms(dlmlock, old_kms); cl_object_attr_set(env, obj, attr, CAT_KMS); @@ -247,7 +247,7 @@ static void osc_lock_fini(const struct lu_env *env, * lock is destroyed immediately after upcall. */ osc_lock_unhold(ols); - LASSERT(ols->ols_lock == NULL); + LASSERT(!ols->ols_lock); LASSERT(atomic_read(&ols->ols_pageref) == 0 || atomic_read(&ols->ols_pageref) == _PAGEREF_MAGIC); @@ -292,7 +292,7 @@ static struct osc_lock *osc_ast_data_get(struct ldlm_lock *dlm_lock) lock_res_and_lock(dlm_lock); spin_lock(&osc_ast_guard); olck = dlm_lock->l_ast_data; - if (olck != NULL) { + if (olck) { struct cl_lock *lock = olck->ols_cl.cls_lock; /* * If osc_lock holds a reference on ldlm lock, return it even @@ -359,13 +359,13 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, __u64 size; dlmlock = olck->ols_lock; - LASSERT(dlmlock != NULL); /* re-grab LVB from a dlm lock under DLM spin-locks. */ *lvb = *(struct ost_lvb *)dlmlock->l_lvb_data; size = lvb->lvb_size; /* Extend KMS up to the end of this lock and no further - * A lock on [x,y] means a KMS of up to y + 1 bytes! */ + * A lock on [x,y] means a KMS of up to y + 1 bytes! + */ if (size > dlmlock->l_policy_data.l_extent.end) size = dlmlock->l_policy_data.l_extent.end + 1; if (size >= oinfo->loi_kms) { @@ -429,7 +429,8 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, * to take a semaphore on a parent lock. This is safe, because * spin-locks are needed to protect consistency of * dlmlock->l_*_mode and LVB, and we have finished processing - * them. */ + * them. + */ unlock_res_and_lock(dlmlock); cl_lock_modify(env, lock, descr); cl_lock_signal(env, lock); @@ -444,12 +445,12 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) struct ldlm_lock *dlmlock; dlmlock = ldlm_handle2lock_long(&olck->ols_handle, 0); - LASSERT(dlmlock != NULL); + LASSERT(dlmlock); lock_res_and_lock(dlmlock); spin_lock(&osc_ast_guard); LASSERT(dlmlock->l_ast_data == olck); - LASSERT(olck->ols_lock == NULL); + LASSERT(!olck->ols_lock); olck->ols_lock = dlmlock; spin_unlock(&osc_ast_guard); @@ -470,7 +471,8 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) olck->ols_hold = 1; /* lock reference taken by ldlm_handle2lock_long() is owned by - * osc_lock and released in osc_lock_detach() */ + * osc_lock and released in osc_lock_detach() + */ lu_ref_add(&dlmlock->l_reference, "osc_lock", olck); olck->ols_has_ref = 1; } @@ -508,10 +510,10 @@ static int osc_lock_upcall(void *cookie, int errcode) struct ldlm_lock *dlmlock; dlmlock = ldlm_handle2lock(&olck->ols_handle); - if (dlmlock != NULL) { + if (dlmlock) { lock_res_and_lock(dlmlock); spin_lock(&osc_ast_guard); - LASSERT(olck->ols_lock == NULL); + LASSERT(!olck->ols_lock); dlmlock->l_ast_data = NULL; olck->ols_handle.cookie = 0ULL; spin_unlock(&osc_ast_guard); @@ -548,7 +550,8 @@ static int osc_lock_upcall(void *cookie, int errcode) /* For AGL case, the RPC sponsor may exits the cl_lock * processing without wait() called before related OSC * lock upcall(). So update the lock status according - * to the enqueue result inside AGL upcall(). */ + * to the enqueue result inside AGL upcall(). + */ if (olck->ols_agl) { lock->cll_flags |= CLF_FROM_UPCALL; cl_wait_try(env, lock); @@ -571,7 +574,8 @@ static int osc_lock_upcall(void *cookie, int errcode) lu_ref_del(&lock->cll_reference, "upcall", lock); /* This maybe the last reference, so must be called after - * cl_lock_mutex_put(). */ + * cl_lock_mutex_put(). + */ cl_lock_put(env, lock); cl_env_nested_put(&nest, env); @@ -634,7 +638,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env, cancel = 0; olck = osc_ast_data_get(dlmlock); - if (olck != NULL) { + if (olck) { lock = olck->ols_cl.cls_lock; cl_lock_mutex_get(env, lock); LINVRNT(osc_lock_invariant(olck)); @@ -786,17 +790,17 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { olck = osc_ast_data_get(dlmlock); - if (olck != NULL) { + if (olck) { lock = olck->ols_cl.cls_lock; cl_lock_mutex_get(env, lock); /* * ldlm_handle_cp_callback() copied LVB from request * to lock->l_lvb_data, store it in osc_lock. */ - LASSERT(dlmlock->l_lvb_data != NULL); + LASSERT(dlmlock->l_lvb_data); lock_res_and_lock(dlmlock); olck->ols_lvb = *(struct ost_lvb *)dlmlock->l_lvb_data; - if (olck->ols_lock == NULL) { + if (!olck->ols_lock) { /* * upcall (osc_lock_upcall()) hasn't yet been * called. Do nothing now, upcall will bind @@ -850,14 +854,15 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) * environment. */ olck = osc_ast_data_get(dlmlock); - if (olck != NULL) { + if (olck) { lock = olck->ols_cl.cls_lock; /* Do not grab the mutex of cl_lock for glimpse. * See LU-1274 for details. * BTW, it's okay for cl_lock to be cancelled during * this period because server can handle this race. * See ldlm_server_glimpse_ast() for details. - * cl_lock_mutex_get(env, lock); */ + * cl_lock_mutex_get(env, lock); + */ cap = &req->rq_pill; req_capsule_extend(cap, &RQF_LDLM_GL_CALLBACK); req_capsule_set_size(cap, &RMF_DLM_LVB, RCL_SERVER, @@ -1017,7 +1022,8 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(lock)); /* make it enqueue anyway for glimpse lock, because we actually - * don't need to cancel any conflicting locks. */ + * don't need to cancel any conflicting locks. + */ if (olck->ols_glimpse) return 0; @@ -1051,7 +1057,8 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, * imagine that client has PR lock on [0, 1000], and thread T0 * is doing lockless IO in [500, 1500] region. Concurrent * thread T1 can see lockless data in [500, 1000], which is - * wrong, because these data are possibly stale. */ + * wrong, because these data are possibly stale. + */ if (!lockless && osc_lock_compatible(olck, scan_ols)) continue; @@ -1074,7 +1081,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, } else { CDEBUG(D_DLMTRACE, "lock %p is conflicted with %p, will wait\n", lock, conflict); - LASSERT(lock->cll_conflict == NULL); + LASSERT(!lock->cll_conflict); lu_ref_add(&conflict->cll_reference, "cancel-wait", lock); lock->cll_conflict = conflict; @@ -1123,7 +1130,8 @@ static int osc_lock_enqueue(const struct lu_env *env, struct ldlm_enqueue_info *einfo = &ols->ols_einfo; /* lock will be passed as upcall cookie, - * hold ref to prevent to be released. */ + * hold ref to prevent to be released. + */ cl_lock_hold_add(env, lock, "upcall", lock); /* a user for lock also */ cl_lock_user_add(env, lock); @@ -1174,7 +1182,8 @@ static int osc_lock_wait(const struct lu_env *env, } else if (olck->ols_agl) { if (lock->cll_flags & CLF_FROM_UPCALL) /* It is from enqueue RPC reply upcall for - * updating state. Do not re-enqueue. */ + * updating state. Do not re-enqueue. + */ return -ENAVAIL; olck->ols_state = OLS_NEW; } else { @@ -1197,7 +1206,7 @@ static int osc_lock_wait(const struct lu_env *env, } LASSERT(equi(olck->ols_state >= OLS_UPCALL_RECEIVED && - lock->cll_error == 0, olck->ols_lock != NULL)); + lock->cll_error == 0, olck->ols_lock)); return lock->cll_error ?: olck->ols_state >= OLS_GRANTED ? 0 : CLO_WAIT; } @@ -1235,7 +1244,8 @@ static int osc_lock_use(const struct lu_env *env, LASSERT(lock->cll_state == CLS_INTRANSIT); LASSERT(lock->cll_users > 0); /* set a flag for osc_dlm_blocking_ast0() to signal the - * lock.*/ + * lock. + */ olck->ols_ast_wait = 1; rc = CLO_WAIT; } @@ -1306,7 +1316,7 @@ static void osc_lock_cancel(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(lock)); LINVRNT(osc_lock_invariant(olck)); - if (dlmlock != NULL) { + if (dlmlock) { int do_cancel; discard = !!(dlmlock->l_flags & LDLM_FL_DISCARD_DATA); @@ -1318,7 +1328,8 @@ static void osc_lock_cancel(const struct lu_env *env, /* Now that we're the only user of dlm read/write reference, * mostly the ->l_readers + ->l_writers should be zero. * However, there is a corner case. - * See bug 18829 for details.*/ + * See bug 18829 for details. + */ do_cancel = (dlmlock->l_readers == 0 && dlmlock->l_writers == 0); dlmlock->l_flags |= LDLM_FL_CBPENDING; @@ -1382,7 +1393,7 @@ static void osc_lock_state(const struct lu_env *env, if (state == CLS_HELD && slice->cls_lock->cll_state != CLS_HELD) { struct osc_io *oio = osc_env_io(env); - LASSERT(lock->ols_owner == NULL); + LASSERT(!lock->ols_owner); lock->ols_owner = oio; } else if (state != CLS_HELD) lock->ols_owner = NULL; @@ -1517,7 +1528,8 @@ static void osc_lock_lockless_state(const struct lu_env *env, lock->ols_owner = oio; /* set the io to be lockless if this lock is for io's - * host object */ + * host object + */ if (cl_object_same(oio->oi_cl.cis_obj, slice->cls_obj)) oio->oi_lockless = 1; } @@ -1556,7 +1568,7 @@ int osc_lock_init(const struct lu_env *env, int result; clk = kmem_cache_alloc(osc_lock_kmem, GFP_NOFS | __GFP_ZERO); - if (clk != NULL) { + if (clk) { __u32 enqflags = lock->cll_descr.cld_enq_flags; osc_lock_build_einfo(env, lock, clk, &clk->ols_einfo); @@ -1599,7 +1611,7 @@ int osc_dlm_lock_pageref(struct ldlm_lock *dlm) * doesn't matter because in the worst case we don't cancel a lock * which we actually can, that's no harm. */ - if (olock != NULL && + if (olock && atomic_add_return(_PAGEREF_MAGIC, &olock->ols_pageref) != _PAGEREF_MAGIC) { atomic_sub(_PAGEREF_MAGIC, &olock->ols_pageref); diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index fdd6219..60d8230 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -113,7 +113,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) LASSERT(list_empty(&osc->oo_write_item)); LASSERT(list_empty(&osc->oo_read_item)); - LASSERT(osc->oo_root.rb_node == NULL); + LASSERT(!osc->oo_root.rb_node); LASSERT(list_empty(&osc->oo_hp_exts)); LASSERT(list_empty(&osc->oo_urgent_exts)); LASSERT(list_empty(&osc->oo_rpc_exts)); @@ -256,7 +256,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct lu_object *obj; osc = kmem_cache_alloc(osc_object_kmem, GFP_NOFS | __GFP_ZERO); - if (osc != NULL) { + if (osc) { obj = osc2lu(osc); lu_object_init(obj, NULL, dev); osc->oo_cl.co_ops = &osc_ops; diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 8943f0a..d11582a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -51,111 +51,12 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, * @{ */ -/* - * Comment out osc_page_protected because it may sleep inside the - * the client_obd_list_lock. - * client_obd_list_lock -> osc_ap_completion -> osc_completion -> - * -> osc_page_protected -> osc_page_is_dlocked -> osc_match_base - * -> ldlm_lock_match -> sptlrpc_import_check_ctx -> sleep. - */ -#if 0 -static int osc_page_is_dlocked(const struct lu_env *env, - const struct osc_page *opg, - enum cl_lock_mode mode, int pending, int unref) -{ - struct cl_page *page; - struct osc_object *obj; - struct osc_thread_info *info; - struct ldlm_res_id *resname; - struct lustre_handle *lockh; - ldlm_policy_data_t *policy; - ldlm_mode_t dlmmode; - __u64 flags; - - might_sleep(); - - info = osc_env_info(env); - resname = &info->oti_resname; - policy = &info->oti_policy; - lockh = &info->oti_handle; - page = opg->ops_cl.cpl_page; - obj = cl2osc(opg->ops_cl.cpl_obj); - - flags = LDLM_FL_TEST_LOCK | LDLM_FL_BLOCK_GRANTED; - if (pending) - flags |= LDLM_FL_CBPENDING; - - dlmmode = osc_cl_lock2ldlm(mode) | LCK_PW; - osc_lock_build_res(env, obj, resname); - osc_index2policy(policy, page->cp_obj, page->cp_index, page->cp_index); - return osc_match_base(osc_export(obj), resname, LDLM_EXTENT, policy, - dlmmode, &flags, NULL, lockh, unref); -} - -/** - * Checks an invariant that a page in the cache is covered by a lock, as - * needed. - */ -static int osc_page_protected(const struct lu_env *env, - const struct osc_page *opg, - enum cl_lock_mode mode, int unref) -{ - struct cl_object_header *hdr; - struct cl_lock *scan; - struct cl_page *page; - struct cl_lock_descr *descr; - int result; - - LINVRNT(!opg->ops_temp); - - page = opg->ops_cl.cpl_page; - if (page->cp_owner != NULL && - cl_io_top(page->cp_owner)->ci_lockreq == CILR_NEVER) - /* - * If IO is done without locks (liblustre, or lloop), lock is - * not required. - */ - result = 1; - else - /* otherwise check for a DLM lock */ - result = osc_page_is_dlocked(env, opg, mode, 1, unref); - if (result == 0) { - /* maybe this page is a part of a lockless io? */ - hdr = cl_object_header(opg->ops_cl.cpl_obj); - descr = &osc_env_info(env)->oti_descr; - descr->cld_mode = mode; - descr->cld_start = page->cp_index; - descr->cld_end = page->cp_index; - spin_lock(&hdr->coh_lock_guard); - list_for_each_entry(scan, &hdr->coh_locks, cll_linkage) { - /* - * Lock-less sub-lock has to be either in HELD state - * (when io is actively going on), or in CACHED state, - * when top-lock is being unlocked: - * cl_io_unlock()->cl_unuse()->...->lov_lock_unuse(). - */ - if ((scan->cll_state == CLS_HELD || - scan->cll_state == CLS_CACHED) && - cl_lock_ext_match(&scan->cll_descr, descr)) { - struct osc_lock *olck; - - olck = osc_lock_at(scan); - result = osc_lock_is_lockless(olck); - break; - } - } - spin_unlock(&hdr->coh_lock_guard); - } - return result; -} -#else static int osc_page_protected(const struct lu_env *env, const struct osc_page *opg, enum cl_lock_mode mode, int unref) { return 1; } -#endif /***************************************************************************** * @@ -168,7 +69,7 @@ static void osc_page_fini(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); CDEBUG(D_TRACE, "%p\n", opg); - LASSERT(opg->ops_lock == NULL); + LASSERT(!opg->ops_lock); } static void osc_page_transfer_get(struct osc_page *opg, const char *label) @@ -204,7 +105,8 @@ static void osc_page_transfer_add(const struct lu_env *env, struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); /* ops_lru and ops_inflight share the same field, so take it from LRU - * first and then use it as inflight. */ + * first and then use it as inflight. + */ osc_lru_del(osc_cli(obj), opg, false); spin_lock(&obj->oo_seatbelt); @@ -232,9 +134,10 @@ static int osc_page_cache_add(const struct lu_env *env, /* for sync write, kernel will wait for this page to be flushed before * osc_io_end() is called, so release it earlier. - * for mkwrite(), it's known there is no further pages. */ + * for mkwrite(), it's known there is no further pages. + */ if (cl_io_is_sync_write(io) || cl_io_is_mkwrite(io)) { - if (oio->oi_active != NULL) { + if (oio->oi_active) { osc_extent_release(env, oio->oi_active); oio->oi_active = NULL; } @@ -258,7 +161,7 @@ static int osc_page_addref_lock(const struct lu_env *env, struct osc_lock *olock; int rc; - LASSERT(opg->ops_lock == NULL); + LASSERT(!opg->ops_lock); olock = osc_lock_at(lock); if (atomic_inc_return(&olock->ols_pageref) <= 0) { @@ -278,7 +181,7 @@ static void osc_page_putref_lock(const struct lu_env *env, struct cl_lock *lock = opg->ops_lock; struct osc_lock *olock; - LASSERT(lock != NULL); + LASSERT(lock); olock = osc_lock_at(lock); atomic_dec(&olock->ols_pageref); @@ -296,7 +199,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); - if (lock != NULL) { + if (lock) { if (osc_page_addref_lock(env, cl2osc_page(slice), lock) == 0) result = -EBUSY; cl_lock_put(env, lock); @@ -424,7 +327,7 @@ static void osc_page_delete(const struct lu_env *env, } spin_lock(&obj->oo_seatbelt); - if (opg->ops_submitter != NULL) { + if (opg->ops_submitter) { LASSERT(!list_empty(&opg->ops_inflight)); list_del_init(&opg->ops_inflight); opg->ops_submitter = NULL; @@ -458,7 +361,8 @@ static int osc_page_cancel(const struct lu_env *env, LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); /* Check if the transferring against this page - * is completed, or not even queued. */ + * is completed, or not even queued. + */ if (opg->ops_transfer_pinned) /* FIXME: may not be interrupted.. */ rc = osc_cancel_async_page(env, opg); @@ -522,7 +426,8 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, * creates temporary pages outside of a lock. */ /* ops_inflight and ops_lru are the same field, but it doesn't - * hurt to initialize it twice :-) */ + * hurt to initialize it twice :-) + */ INIT_LIST_HEAD(&opg->ops_inflight); INIT_LIST_HEAD(&opg->ops_lru); @@ -581,7 +486,8 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq); static atomic_t osc_lru_waiters = ATOMIC_INIT(0); /* LRU pages are freed in batch mode. OSC should at least free this - * number of pages to avoid running out of LRU budget, and.. */ + * number of pages to avoid running out of LRU budget, and.. + */ static const int lru_shrink_min = 2 << (20 - PAGE_CACHE_SHIFT); /* 2M */ /* free this number at most otherwise it will take too long time to finish. */ static const int lru_shrink_max = 32 << (20 - PAGE_CACHE_SHIFT); /* 32M */ @@ -590,7 +496,8 @@ static const int lru_shrink_max = 32 << (20 - PAGE_CACHE_SHIFT); /* 32M */ * we should free slots aggressively. In this way, slots are freed in a steady * step to maintain fairness among OSCs. * - * Return how many LRU pages should be freed. */ + * Return how many LRU pages should be freed. + */ static int osc_cache_too_much(struct client_obd *cli) { struct cl_client_cache *cache = cli->cl_cache; @@ -602,7 +509,8 @@ static int osc_cache_too_much(struct client_obd *cli) return min(pages, lru_shrink_max); /* if it's going to run out LRU slots, we should free some, but not - * too much to maintain fairness among OSCs. */ + * too much to maintain fairness among OSCs. + */ if (atomic_read(cli->cl_lru_left) < cache->ccc_lru_max >> 4) { unsigned long tmp; @@ -630,7 +538,8 @@ static int discard_pagevec(const struct lu_env *env, struct cl_io *io, /* free LRU page only if nobody is using it. * This check is necessary to avoid freeing the pages * having already been removed from LRU and pinned - * for IO. */ + * for IO. + */ if (!cl_page_in_use(page)) { cl_page_unmap(env, io, page); cl_page_discard(env, io, page); @@ -688,14 +597,14 @@ int osc_lru_shrink(struct client_obd *cli, int target) continue; } - LASSERT(page->cp_obj != NULL); + LASSERT(page->cp_obj); if (clobj != page->cp_obj) { struct cl_object *tmp = page->cp_obj; cl_object_get(tmp); client_obd_list_unlock(&cli->cl_lru_list_lock); - if (clobj != NULL) { + if (clobj) { count -= discard_pagevec(env, io, pvec, index); index = 0; @@ -720,11 +629,13 @@ int osc_lru_shrink(struct client_obd *cli, int target) /* move this page to the end of list as it will be discarded * soon. The page will be finally removed from LRU list in - * osc_page_delete(). */ + * osc_page_delete(). + */ list_move_tail(&opg->ops_lru, &cli->cl_lru_list); /* it's okay to grab a refcount here w/o holding lock because - * it has to grab cl_lru_list_lock to delete the page. */ + * it has to grab cl_lru_list_lock to delete the page. + */ cl_page_get(page); pvec[index++] = page; if (++count >= target) @@ -740,7 +651,7 @@ int osc_lru_shrink(struct client_obd *cli, int target) } client_obd_list_unlock(&cli->cl_lru_list_lock); - if (clobj != NULL) { + if (clobj) { count -= discard_pagevec(env, io, pvec, index); cl_io_fini(env, io); @@ -775,7 +686,8 @@ static void osc_lru_add(struct client_obd *cli, struct osc_page *opg) } /* delete page from LRUlist. The page can be deleted from LRUlist for two - * reasons: redirtied or deleted from page cache. */ + * reasons: redirtied or deleted from page cache. + */ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg, bool del) { if (opg->ops_in_lru) { @@ -797,7 +709,8 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg, bool del) * this osc occupies too many LRU pages and kernel is * stealing one of them. * cl_lru_shrinkers is to avoid recursive call in case - * we're already in the context of osc_lru_shrink(). */ + * we're already in the context of osc_lru_shrink(). + */ if (atomic_read(&cli->cl_lru_shrinkers) == 0 && !memory_pressure_get()) osc_lru_shrink(cli, osc_cache_too_much(cli)); @@ -819,7 +732,7 @@ static int osc_lru_reclaim(struct client_obd *cli) int max_scans; int rc; - LASSERT(cache != NULL); + LASSERT(cache); rc = osc_lru_shrink(cli, lru_shrink_min); if (rc != 0) { @@ -834,7 +747,8 @@ static int osc_lru_reclaim(struct client_obd *cli) atomic_read(&cli->cl_lru_busy)); /* Reclaim LRU slots from other client_obd as it can't free enough - * from its own. This should rarely happen. */ + * from its own. This should rarely happen. + */ spin_lock(&cache->ccc_lru_lock); LASSERT(!list_empty(&cache->ccc_lru)); @@ -875,7 +789,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, struct client_obd *cli = osc_cli(obj); int rc = 0; - if (cli->cl_cache == NULL) /* shall not be in LRU */ + if (!cli->cl_cache) /* shall not be in LRU */ return 0; LASSERT(atomic_read(cli->cl_lru_left) >= 0); @@ -892,7 +806,8 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, cond_resched(); /* slowest case, all of caching pages are busy, notifying - * other OSCs that we're lack of LRU slots. */ + * other OSCs that we're lack of LRU slots. + */ atomic_inc(&osc_lru_waiters); gen = atomic_read(&cli->cl_lru_in_list); diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index e70e796..208f72b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -13,11 +13,6 @@ * General Public License version 2 for more details (a copy is included * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA - * * GPL HEADER END */ /* @@ -36,7 +31,7 @@ static inline struct osc_quota_info *osc_oqi_alloc(u32 id) struct osc_quota_info *oqi; oqi = kmem_cache_alloc(osc_quota_kmem, GFP_NOFS | __GFP_ZERO); - if (oqi != NULL) + if (oqi) oqi->oqi_id = id; return oqi; @@ -52,10 +47,12 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) oqi = cfs_hash_lookup(cli->cl_quota_hash[type], &qid[type]); if (oqi) { /* do not try to access oqi here, it could have been - * freed by osc_quota_setdq() */ + * freed by osc_quota_setdq() + */ /* the slot is busy, the user is about to run out of - * quota space on this OST */ + * quota space on this OST + */ CDEBUG(D_QUOTA, "chkdq found noquota for %s %d\n", type == USRQUOTA ? "user" : "grout", qid[type]); return NO_QUOTA; @@ -89,12 +86,13 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], oqi = cfs_hash_lookup(cli->cl_quota_hash[type], &qid[type]); if ((flags & FL_QUOTA_FLAG(type)) != 0) { /* This ID is getting close to its quota limit, let's - * switch to sync I/O */ - if (oqi != NULL) + * switch to sync I/O + */ + if (oqi) continue; oqi = osc_oqi_alloc(qid[type]); - if (oqi == NULL) { + if (!oqi) { rc = -ENOMEM; break; } @@ -113,8 +111,9 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], qid[type], rc); } else { /* This ID is now off the hook, let's remove it from - * the hash table */ - if (oqi == NULL) + * the hash table + */ + if (!oqi) continue; oqi = cfs_hash_del_key(cli->cl_quota_hash[type], @@ -147,7 +146,7 @@ oqi_keycmp(const void *key, struct hlist_node *hnode) struct osc_quota_info *oqi; u32 uid; - LASSERT(key != NULL); + LASSERT(key); uid = *((u32 *)key); oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash); @@ -218,7 +217,7 @@ int osc_quota_setup(struct obd_device *obd) CFS_HASH_MAX_THETA, "a_hash_ops, CFS_HASH_DEFAULT); - if (cli->cl_quota_hash[type] == NULL) + if (!cli->cl_quota_hash[type]) break; } @@ -252,7 +251,7 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, OST_QUOTACTL); - if (req == NULL) + if (!req) return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); @@ -294,7 +293,7 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, OST_QUOTACHECK); - if (req == NULL) + if (!req) return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); @@ -302,8 +301,8 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, ptlrpc_request_set_replen(req); - /* the next poll will find -ENODATA, that means quotacheck is - * going on */ + /* the next poll will find -ENODATA, that means quotacheck is going on + */ cli->cl_qchk_stat = -ENODATA; rc = ptlrpc_queue_wait(req); if (rc) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 3ae00fc..10f262f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -104,7 +104,6 @@ struct osc_enqueue_args { static void osc_release_ppga(struct brw_page **ppga, u32 count); static int brw_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *data, int rc); -static int osc_cleanup(struct obd_device *obd); /* Pack OSC object metadata for disk storage (LE byte order). */ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, @@ -113,18 +112,18 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, int lmm_size; lmm_size = sizeof(**lmmp); - if (lmmp == NULL) + if (!lmmp) return lmm_size; - if (*lmmp != NULL && lsm == NULL) { + if (*lmmp && !lsm) { kfree(*lmmp); *lmmp = NULL; return 0; - } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { + } else if (unlikely(lsm && ostid_id(&lsm->lsm_oi) == 0)) { return -EBADF; } - if (*lmmp == NULL) { + if (!*lmmp) { *lmmp = kzalloc(lmm_size, GFP_NOFS); if (!*lmmp) return -ENOMEM; @@ -143,7 +142,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, int lsm_size; struct obd_import *imp = class_exp2cliimp(exp); - if (lmm != NULL) { + if (lmm) { if (lmm_bytes < sizeof(*lmm)) { CERROR("%s: lov_mds_md too small: %d, need %d\n", exp->exp_obd->obd_name, lmm_bytes, @@ -160,23 +159,23 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, } lsm_size = lov_stripe_md_size(1); - if (lsmp == NULL) + if (!lsmp) return lsm_size; - if (*lsmp != NULL && lmm == NULL) { + if (*lsmp && !lmm) { kfree((*lsmp)->lsm_oinfo[0]); kfree(*lsmp); *lsmp = NULL; return 0; } - if (*lsmp == NULL) { + if (!*lsmp) { *lsmp = kzalloc(lsm_size, GFP_NOFS); - if (unlikely(*lsmp == NULL)) + if (unlikely(!*lsmp)) return -ENOMEM; (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS); - if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { + if (unlikely(!(*lsmp)->lsm_oinfo[0])) { kfree(*lsmp); return -ENOMEM; } @@ -185,11 +184,11 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return -EBADF; } - if (lmm != NULL) + if (lmm) /* XXX zero *lsmp? */ ostid_le_to_cpu(&lmm->lmm_oi, &(*lsmp)->lsm_oi); - if (imp != NULL && + if (imp && (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES)) (*lsmp)->lsm_maxbytes = imp->imp_connect_data.ocd_maxbytes; else @@ -246,7 +245,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); @@ -276,7 +275,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); @@ -294,7 +293,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out; } @@ -321,7 +320,7 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); @@ -339,7 +338,7 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out; } @@ -362,7 +361,7 @@ static int osc_setattr_interpret(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out; } @@ -384,7 +383,7 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); @@ -451,7 +450,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa, } req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -482,7 +481,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa, goto out_req; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { rc = -EPROTO; goto out_req; } @@ -500,7 +499,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa, lsm->lsm_oi = oa->o_oi; *ea = lsm; - if (oti != NULL) { + if (oti) { oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg); if (oa->o_valid & OBD_MD_FLCOOKIE) { @@ -530,7 +529,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH); @@ -573,7 +572,7 @@ static int osc_sync_interpret(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { CERROR("can't unpack ost_body\n"); rc = -EPROTO; goto out; @@ -595,7 +594,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC); @@ -629,10 +628,11 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, /* Find and cancel locally locks matched by @mode in the resource found by * @objid. Found locks are added into @cancel list. Returns the amount of - * locks added to @cancels list. */ + * locks added to @cancels list. + */ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, struct list_head *cancels, - ldlm_mode_t mode, __u64 lock_flags) + enum ldlm_mode mode, __u64 lock_flags) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; struct ldlm_res_id res_id; @@ -644,13 +644,14 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, * * This distinguishes from a case when ELC is not supported originally, * when we still want to cancel locks in advance and just cancel them - * locally, without sending any RPC. */ + * locally, without sending any RPC. + */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) return 0; ostid_build_res_name(&oa->o_oi, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); - if (res == NULL) + if (!res) return 0; LDLM_RESOURCE_ADDREF(res); @@ -723,7 +724,8 @@ static int osc_create(const struct lu_env *env, struct obd_export *exp, * If the client dies, or the OST is down when the object should be destroyed, * the records are not cancelled, and when the OST reconnects to the MDS next, * it will retrieve the llog unlink logs and then sends the log cancellation - * cookies to the MDS after committing destroy transactions. */ + * cookies to the MDS after committing destroy transactions. + */ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, struct obd_trans_info *oti, struct obd_export *md_export) @@ -743,7 +745,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, LDLM_FL_DISCARD_DATA); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_DESTROY); - if (req == NULL) { + if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; } @@ -758,7 +760,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); - if (oti != NULL && oa->o_valid & OBD_MD_FLCOOKIE) + if (oti && oa->o_valid & OBD_MD_FLCOOKIE) oa->o_lcookie = *oti->oti_logcookies; body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); @@ -769,7 +771,8 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, /* If osc_destroy is for destroying the unlink orphan, * sent from MDT to OST, which should not be blocked here, * because the process might be triggered by ptlrpcd, and - * it is not good to block ptlrpcd thread (b=16006)*/ + * it is not good to block ptlrpcd thread (b=16006 + **/ if (!(oa->o_flags & OBD_FL_DELORPHAN)) { req->rq_interpret_reply = osc_destroy_interpret; if (!osc_can_send_destroy(cli)) { @@ -810,7 +813,8 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, (long)(obd_max_dirty_pages + 1))) { /* The atomic_read() allowing the atomic_inc() are * not covered by a lock thus they may safely race and trip - * this CERROR() unless we add in a small fudge factor (+1). */ + * this CERROR() unless we add in a small fudge factor (+1). + */ CERROR("dirty %d - %d > system dirty_max %d\n", atomic_read(&obd_dirty_pages), atomic_read(&obd_dirty_transit_pages), @@ -839,7 +843,7 @@ void osc_update_next_shrink(struct client_obd *cli) { cli->cl_next_shrink_grant = cfs_time_shift(cli->cl_grant_shrink_interval); - CDEBUG(D_CACHE, "next time %ld to shrink grant \n", + CDEBUG(D_CACHE, "next time %ld to shrink grant\n", cli->cl_next_shrink_grant); } @@ -900,7 +904,8 @@ static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa) /* Shrink the current grant, either from some large amount to enough for a * full set of in-flight RPCs, or if we have already shrunk to that limit * then to enough for a single RPC. This avoids keeping more grant than - * needed, and avoids shrinking the grant piecemeal. */ + * needed, and avoids shrinking the grant piecemeal. + */ static int osc_shrink_grant(struct client_obd *cli) { __u64 target_bytes = (cli->cl_max_rpcs_in_flight + 1) * @@ -922,7 +927,8 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) client_obd_list_lock(&cli->cl_loi_list_lock); /* Don't shrink if we are already above or below the desired limit * We don't want to shrink below a single RPC, as that will negatively - * impact block allocation and long-term performance. */ + * impact block allocation and long-term performance. + */ if (target_bytes < cli->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT) target_bytes = cli->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; @@ -970,7 +976,8 @@ static int osc_should_shrink_grant(struct client_obd *client) if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) { /* Get the current RPC size directly, instead of going via: * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export) - * Keep comment here so that it can be found by searching. */ + * Keep comment here so that it can be found by searching. + */ int brw_size = client->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; if (client->cl_import->imp_state == LUSTRE_IMP_FULL && @@ -1007,7 +1014,7 @@ static int osc_add_shrink_grant(struct client_obd *client) client->cl_import->imp_obd->obd_name, rc); return rc; } - CDEBUG(D_CACHE, "add grant client %s \n", + CDEBUG(D_CACHE, "add grant client %s\n", client->cl_import->imp_obd->obd_name); osc_update_next_shrink(client); return 0; @@ -1040,7 +1047,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant, ocd->ocd_grant, cli->cl_dirty); /* workaround for servers which do not have the patch from - * LU-2679 */ + * LU-2679 + */ cli->cl_avail_grant = ocd->ocd_grant; } @@ -1060,7 +1068,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) /* We assume that the reason this OSC got a short read is because it read * beyond the end of a stripe file; i.e. lustre is reading a sparse file * via the LOV, and it _knows_ it's reading inside the file, it's just that - * this stripe never got written at or beyond this stripe offset yet. */ + * this stripe never got written at or beyond this stripe offset yet. + */ static void handle_short_read(int nob_read, u32 page_count, struct brw_page **pga) { @@ -1106,7 +1115,7 @@ static int check_write_rcs(struct ptlrpc_request *req, remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS, sizeof(*remote_rcs) * niocount); - if (remote_rcs == NULL) { + if (!remote_rcs) { CDEBUG(D_INFO, "Missing/short RC vector on BRW_WRITE reply\n"); return -EPROTO; } @@ -1139,7 +1148,8 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) OBD_BRW_SYNC | OBD_BRW_ASYNC|OBD_BRW_NOQUOTA); /* warn if we try to combine flags that we don't know to be - * safe to combine */ + * safe to combine + */ if (unlikely((p1->flag & mask) != (p2->flag & mask))) { CWARN("Saw flags 0x%x and 0x%x in the same brw, please report this at http://bugs.whamcloud.com/\n", p1->flag, p2->flag); @@ -1152,7 +1162,7 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) static u32 osc_checksum_bulk(int nob, u32 pg_count, struct brw_page **pga, int opc, - cksum_type_t cksum_type) + enum cksum_type cksum_type) { __u32 cksum; int i = 0; @@ -1174,7 +1184,8 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, int count = pga[i]->count > nob ? nob : pga[i]->count; /* corrupt the data before we compute the checksum, to - * simulate an OST->client data error */ + * simulate an OST->client data error + */ if (i == 0 && opc == OST_READ && OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE)) { unsigned char *ptr = kmap(pga[i]->pg); @@ -1205,7 +1216,8 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, cfs_crypto_hash_final(hdesc, NULL, NULL); /* For sending we only compute the wrong checksum instead - * of corrupting the data so it is still correct on a redo */ + * of corrupting the data so it is still correct on a redo + */ if (opc == OST_WRITE && OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_SEND)) cksum++; @@ -1244,7 +1256,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, opc = OST_READ; req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_BRW_READ); } - if (req == NULL) + if (!req) return -ENOMEM; for (niocount = i = 1; i < page_count; i++) { @@ -1266,7 +1278,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); /* ask ptlrpc not to resend on EINPROGRESS since BRWs have their own - * retry logic */ + * retry logic + */ req->rq_no_retry_einprogress = 1; desc = ptlrpc_prep_bulk_imp(req, page_count, @@ -1274,7 +1287,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, opc == OST_WRITE ? BULK_GET_SOURCE : BULK_PUT_SINK, OST_BULK_PORTAL); - if (desc == NULL) { + if (!desc) { rc = -ENOMEM; goto out; } @@ -1283,7 +1296,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, body = req_capsule_client_get(pill, &RMF_OST_BODY); ioobj = req_capsule_client_get(pill, &RMF_OBD_IOOBJ); niobuf = req_capsule_client_get(pill, &RMF_NIOBUF_REMOTE); - LASSERT(body != NULL && ioobj != NULL && niobuf != NULL); + LASSERT(body && ioobj && niobuf); lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa); @@ -1293,7 +1306,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, * that might be send for this request. The actual number is decided * when the RPC is finally sent in ptlrpc_register_bulk(). It sends * "max - 1" for old client compatibility sending "0", and also so the - * the actual maximum is a power-of-two number, not one less. LU-1431 */ + * the actual maximum is a power-of-two number, not one less. LU-1431 + */ ioobj_max_brw_set(ioobj, desc->bd_md_max_brw); LASSERT(page_count > 0); pg_prev = pga[0]; @@ -1355,8 +1369,9 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, if (cli->cl_checksum && !sptlrpc_flavor_has_bulk(&req->rq_flvr)) { /* store cl_cksum_type in a local variable since - * it can be changed via lprocfs */ - cksum_type_t cksum_type = cli->cl_cksum_type; + * it can be changed via lprocfs + */ + enum cksum_type cksum_type = cli->cl_cksum_type; if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) { oa->o_flags &= OBD_FL_LOCAL_MASK; @@ -1375,7 +1390,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, oa->o_flags |= cksum_type_pack(cksum_type); } else { /* clear out the checksum flag, in case this is a - * resend but cl_checksum is no longer set. b=11238 */ + * resend but cl_checksum is no longer set. b=11238 + */ oa->o_valid &= ~OBD_MD_FLCKSUM; } oa->o_cksum = body->oa.o_cksum; @@ -1415,11 +1431,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, __u32 client_cksum, __u32 server_cksum, int nob, u32 page_count, struct brw_page **pga, - cksum_type_t client_cksum_type) + enum cksum_type client_cksum_type) { __u32 new_cksum; char *msg; - cksum_type_t cksum_type; + enum cksum_type cksum_type; if (server_cksum == client_cksum) { CDEBUG(D_PAGE, "checksum %x confirmed\n", client_cksum); @@ -1472,9 +1488,9 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) return rc; } - LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc); + LASSERTF(req->rq_repmsg, "rc = %d\n", rc); body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - if (body == NULL) { + if (!body) { DEBUG_REQ(D_INFO, req, "Can't unpack body\n"); return -EPROTO; } @@ -1550,7 +1566,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) __u32 server_cksum = body->oa.o_cksum; char *via = ""; char *router = ""; - cksum_type_t cksum_type; + enum cksum_type cksum_type; cksum_type = cksum_type_unpack(body->oa.o_valid&OBD_MD_FLFLAGS ? body->oa.o_flags : 0); @@ -1627,7 +1643,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, return rc; list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) { - if (oap->oap_request != NULL) { + if (oap->oap_request) { LASSERTF(request == oap->oap_request, "request %p != oap_request %p\n", request, oap->oap_request); @@ -1638,12 +1654,14 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, } } /* New request takes over pga and oaps from old request. - * Note that copying a list_head doesn't work, need to move it... */ + * Note that copying a list_head doesn't work, need to move it... + */ aa->aa_resends++; new_req->rq_interpret_reply = request->rq_interpret_reply; new_req->rq_async_args = request->rq_async_args; /* cap resend delay to the current request timeout, this is similar to - * what ptlrpc does (see after_reply()) */ + * what ptlrpc does (see after_reply()) + */ if (aa->aa_resends > new_req->rq_timeout) new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout; else @@ -1669,7 +1687,8 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, /* XXX: This code will run into problem if we're going to support * to add a series of BRW RPCs into a self-defined ptlrpc_request_set * and wait for all of them to be finished. We should inherit request - * set from old request. */ + * set from old request. + */ ptlrpcd_add_req(new_req); DEBUG_REQ(D_INFO, new_req, "new request"); @@ -1709,7 +1728,7 @@ static void sort_brw_pages(struct brw_page **array, int num) static void osc_release_ppga(struct brw_page **ppga, u32 count) { - LASSERT(ppga != NULL); + LASSERT(ppga); kfree(ppga); } @@ -1725,7 +1744,8 @@ static int brw_interpret(const struct lu_env *env, rc = osc_brw_fini_request(req, rc); CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc); /* When server return -EINPROGRESS, client should always retry - * regardless of the number of times the bulk was resent already. */ + * regardless of the number of times the bulk was resent already. + */ if (osc_recoverable_error(rc)) { if (req->rq_import_generation != req->rq_import->imp_generation) { @@ -1748,7 +1768,7 @@ static int brw_interpret(const struct lu_env *env, } list_for_each_entry_safe(ext, tmp, &aa->aa_exts, oe_link) { - if (obj == NULL && rc == 0) { + if (!obj && rc == 0) { obj = osc2cl(ext->oe_obj); cl_object_get(obj); } @@ -1759,7 +1779,7 @@ static int brw_interpret(const struct lu_env *env, LASSERT(list_empty(&aa->aa_exts)); LASSERT(list_empty(&aa->aa_oaps)); - if (obj != NULL) { + if (obj) { struct obdo *oa = aa->aa_oa; struct cl_attr *attr = &osc_env_info(env)->oti_attr; unsigned long valid = 0; @@ -1798,7 +1818,8 @@ static int brw_interpret(const struct lu_env *env, client_obd_list_lock(&cli->cl_loi_list_lock); /* We need to decrement before osc_ap_completion->osc_wake_cache_waiters * is called so we know whether to go to sync BRWs or wait for more - * RPCs to complete */ + * RPCs to complete + */ if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE) cli->cl_w_in_flight--; else @@ -1871,13 +1892,13 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, } pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS); - if (pga == NULL) { + if (!pga) { rc = -ENOMEM; goto out; } oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); - if (oa == NULL) { + if (!oa) { rc = -ENOMEM; goto out; } @@ -1886,7 +1907,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, list_for_each_entry(oap, &rpc_list, oap_rpc_item) { struct cl_page *page = oap2cl_page(oap); - if (clerq == NULL) { + if (!clerq) { clerq = cl_req_alloc(env, page, crt, 1 /* only 1-object rpcs for now */); if (IS_ERR(clerq)) { @@ -1907,7 +1928,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, } /* always get the data for the obdo for the rpc */ - LASSERT(clerq != NULL); + LASSERT(clerq); crattr->cra_oa = oa; cl_req_attr_set(env, clerq, crattr, ~0ULL); if (lock) { @@ -1938,7 +1959,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, * we race with setattr (locally or in queue at OST). If OST gets * later setattr before earlier BRW (as determined by the request xid), * the OST will not use BRW timestamps. Sadly, there is no obvious - * way to do this in a single call. bug 10150 */ + * way to do this in a single call. bug 10150 + */ body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); crattr->cra_oa = &body->oa; cl_req_attr_set(env, clerq, crattr, @@ -1955,11 +1977,12 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, aa->aa_clerq = clerq; /* queued sync pages can be torn down while the pages - * were between the pending list and the rpc */ + * were between the pending list and the rpc + */ tmp = NULL; list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) { /* only one oap gets a request reference */ - if (tmp == NULL) + if (!tmp) tmp = oap; if (oap->oap_interrupted && !req->rq_intr) { CDEBUG(D_INODE, "oap %p in req %p interrupted\n", @@ -1967,7 +1990,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, ptlrpc_mark_interrupted(req); } } - if (tmp != NULL) + if (tmp) tmp->oap_request = ptlrpc_request_addref(req); client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2001,13 +2024,14 @@ out: kfree(crattr); if (rc != 0) { - LASSERT(req == NULL); + LASSERT(!req); if (oa) kmem_cache_free(obdo_cachep, oa); kfree(pga); /* this should happen rarely and is pretty bad, it makes the - * pending list not follow the dirty order */ + * pending list not follow the dirty order + */ while (!list_empty(ext_list)) { ext = list_entry(ext_list->next, struct osc_extent, oe_link); @@ -2026,7 +2050,6 @@ static int osc_set_lock_data_with_check(struct ldlm_lock *lock, void *data = einfo->ei_cbdata; int set = 0; - LASSERT(lock != NULL); LASSERT(lock->l_blocking_ast == einfo->ei_cb_bl); LASSERT(lock->l_resource->lr_type == einfo->ei_type); LASSERT(lock->l_completion_ast == einfo->ei_cb_cp); @@ -2035,7 +2058,7 @@ static int osc_set_lock_data_with_check(struct ldlm_lock *lock, lock_res_and_lock(lock); spin_lock(&osc_ast_guard); - if (lock->l_ast_data == NULL) + if (!lock->l_ast_data) lock->l_ast_data = data; if (lock->l_ast_data == data) set = 1; @@ -2052,7 +2075,7 @@ static int osc_set_data_with_check(struct lustre_handle *lockh, struct ldlm_lock *lock = ldlm_handle2lock(lockh); int set = 0; - if (lock != NULL) { + if (lock) { set = osc_set_lock_data_with_check(lock, einfo); LDLM_LOCK_PUT(lock); } else @@ -2064,7 +2087,8 @@ static int osc_set_data_with_check(struct lustre_handle *lockh, /* find any ldlm lock of the inode in osc * return 0 not find * 1 find one - * < 0 error */ + * < 0 error + */ static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, ldlm_iterator_t replace, void *data) { @@ -2095,7 +2119,6 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, rep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - LASSERT(rep != NULL); rep->lock_policy_res1 = ptlrpc_status_ntoh(rep->lock_policy_res1); if (rep->lock_policy_res1) @@ -2127,18 +2150,21 @@ static int osc_enqueue_interpret(const struct lu_env *env, __u64 *flags = aa->oa_flags; /* Make a local copy of a lock handle and a mode, because aa->oa_* - * might be freed anytime after lock upcall has been called. */ + * might be freed anytime after lock upcall has been called. + */ lustre_handle_copy(&handle, aa->oa_lockh); mode = aa->oa_ei->ei_mode; /* ldlm_cli_enqueue is holding a reference on the lock, so it must - * be valid. */ + * be valid. + */ lock = ldlm_handle2lock(&handle); /* Take an additional reference so that a blocking AST that * ldlm_cli_enqueue_fini() might post for a failed lock, is guaranteed * to arrive after an upcall has been executed by - * osc_enqueue_fini(). */ + * osc_enqueue_fini(). + */ ldlm_lock_addref(&handle, mode); /* Let CP AST to grant the lock first. */ @@ -2170,7 +2196,7 @@ static int osc_enqueue_interpret(const struct lu_env *env, */ ldlm_lock_decref(&handle, mode); - LASSERTF(lock != NULL, "lockh %p, req %p, aa %p - client evicted?\n", + LASSERTF(lock, "lockh %p, req %p, aa %p - client evicted?\n", aa->oa_lockh, req, aa); ldlm_lock_decref(&handle, mode); LDLM_LOCK_PUT(lock); @@ -2185,7 +2211,8 @@ struct ptlrpc_request_set *PTLRPCD_SET = (void *)1; * others may take a considerable amount of time in a case of ost failure; and * when other sync requests do not get released lock from a client, the client * is excluded from the cluster -- such scenarious make the life difficult, so - * release locks just after they are obtained. */ + * release locks just after they are obtained. + */ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, __u64 *flags, ldlm_policy_data_t *policy, struct ost_lvb *lvb, int kms_valid, @@ -2198,11 +2225,12 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct ptlrpc_request *req = NULL; int intent = *flags & LDLM_FL_HAS_INTENT; __u64 match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); - ldlm_mode_t mode; + enum ldlm_mode mode; int rc; /* Filesystem lock extents are extended to page boundaries so that - * dealing with the page cache is a little smoother. */ + * dealing with the page cache is a little smoother. + */ policy->l_extent.start -= policy->l_extent.start & ~CFS_PAGE_MASK; policy->l_extent.end |= ~CFS_PAGE_MASK; @@ -2226,7 +2254,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, * * At some point we should cancel the read lock instead of making them * send us a blocking callback, but there are problems with canceling - * locks out from other users right now, too. */ + * locks out from other users right now, too. + */ mode = einfo->ei_mode; if (einfo->ei_mode == LCK_PR) mode |= LCK_PW; @@ -2238,7 +2267,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, if ((agl != 0) && !(matched->l_flags & LDLM_FL_LVB_READY)) { /* For AGL, if enqueue RPC is sent but the lock is not * granted, then skip to process this strpe. - * Return -ECANCELED to tell the caller. */ + * Return -ECANCELED to tell the caller. + */ ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); return -ECANCELED; @@ -2247,19 +2277,22 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW - * lock is matched whereas we asked for PR. */ + * lock is matched whereas we asked for PR. + */ if (!rqset && einfo->ei_mode != mode) ldlm_lock_addref(lockh, LCK_PR); if (intent) { /* I would like to be able to ASSERT here that * rss <= kms, but I can't, for reasons which - * are explained in lov_enqueue() */ + * are explained in lov_enqueue() + */ } /* We already have a lock, and it's referenced. * * At this point, the cl_lock::cll_state is CLS_QUEUING, - * AGL upcall may change it to CLS_HELD directly. */ + * AGL upcall may change it to CLS_HELD directly. + */ (*upcall)(cookie, ELDLM_OK); if (einfo->ei_mode != mode) @@ -2281,7 +2314,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); - if (req == NULL) + if (!req) return -ENOMEM; rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0); @@ -2341,27 +2374,29 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, { struct obd_device *obd = exp->exp_obd; __u64 lflags = *flags; - ldlm_mode_t rc; + enum ldlm_mode rc; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) return -EIO; /* Filesystem lock extents are extended to page boundaries so that - * dealing with the page cache is a little smoother */ + * dealing with the page cache is a little smoother + */ policy->l_extent.start -= policy->l_extent.start & ~CFS_PAGE_MASK; policy->l_extent.end |= ~CFS_PAGE_MASK; /* Next, search for already existing extent locks that will cover us */ /* If we're trying to read, we also search for an existing PW lock. The * VFS and page cache already protect us locally, so lots of readers/ - * writers can share a single PW lock. */ + * writers can share a single PW lock. + */ rc = mode; if (mode == LCK_PR) rc |= LCK_PW; rc = ldlm_lock_match(obd->obd_namespace, lflags, res_id, type, policy, rc, lockh, unref); if (rc) { - if (data != NULL) { + if (data) { if (!osc_set_data_with_check(lockh, data)) { if (!(lflags & LDLM_FL_TEST_LOCK)) ldlm_lock_decref(lockh, rc); @@ -2398,8 +2433,9 @@ static int osc_statfs_interpret(const struct lu_env *env, * due to issues at a higher level (LOV). * Exit immediately since the caller is * aware of the problem and takes care - * of the clean up */ - return rc; + * of the clean up + */ + return rc; if ((rc == -ENOTCONN || rc == -EAGAIN) && (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) { @@ -2411,7 +2447,7 @@ static int osc_statfs_interpret(const struct lu_env *env, goto out; msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); - if (msfs == NULL) { + if (!msfs) { rc = -EPROTO; goto out; } @@ -2436,9 +2472,10 @@ static int osc_statfs_async(struct obd_export *exp, * extra calls into the filesystem if that isn't necessary (e.g. * during mount that would help a bit). Having relative timestamps * is not so great if request processing is slow, while absolute - * timestamps are not ideal because they need time synchronization. */ + * timestamps are not ideal because they need time synchronization. + */ req = ptlrpc_request_alloc(obd->u.cli.cl_import, &RQF_OST_STATFS); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); @@ -2474,8 +2511,9 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_import *imp = NULL; int rc; - /*Since the request might also come from lprocfs, so we need - *sync this with client_disconnect_export Bug15684*/ + /* Since the request might also come from lprocfs, so we need + * sync this with client_disconnect_export Bug15684 + */ down_read(&obd->u.cli.cl_sem); if (obd->u.cli.cl_import) imp = class_import_get(obd->u.cli.cl_import); @@ -2488,12 +2526,13 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, * extra calls into the filesystem if that isn't necessary (e.g. * during mount that would help a bit). Having relative timestamps * is not so great if request processing is slow, while absolute - * timestamps are not ideal because they need time synchronization. */ + * timestamps are not ideal because they need time synchronization. + */ req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS); class_import_put(imp); - if (req == NULL) + if (!req) return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); @@ -2516,7 +2555,7 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, goto out; msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); - if (msfs == NULL) { + if (!msfs) { rc = -EPROTO; goto out; } @@ -2546,7 +2585,8 @@ static int osc_getstripe(struct lov_stripe_md *lsm, return -ENODATA; /* we only need the header part from user space to get lmm_magic and - * lmm_stripe_count, (the header part is common to v1 and v3) */ + * lmm_stripe_count, (the header part is common to v1 and v3) + */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(&lum, lump, lum_size)) return -EFAULT; @@ -2561,7 +2601,8 @@ static int osc_getstripe(struct lov_stripe_md *lsm, LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lumk->lmm_objects[0])); /* we can use lov_mds_md_size() to compute lum_size - * because lov_user_md_vX and lov_mds_md_vX have the same size */ + * because lov_user_md_vX and lov_mds_md_vX have the same size + */ if (lum.lmm_stripe_count > 0) { lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); lumk = kzalloc(lum_size, GFP_NOFS); @@ -2701,7 +2742,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, @@ -2722,7 +2763,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, goto out; reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID); - if (reply == NULL) { + if (!reply) { rc = -EPROTO; goto out; } @@ -2736,7 +2777,7 @@ out: struct ldlm_res_id res_id; ldlm_policy_data_t policy; struct lustre_handle lockh; - ldlm_mode_t mode = 0; + enum ldlm_mode mode = 0; struct ptlrpc_request *req; struct ll_user_fiemap *reply; char *tmp; @@ -2775,7 +2816,7 @@ out: skip_locking: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_FIEMAP); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto drop_lock; } @@ -2804,7 +2845,7 @@ skip_locking: goto fini_req; reply = req_capsule_server_get(&req->rq_pill, &RMF_FIEMAP_VAL); - if (reply == NULL) { + if (!reply) { rc = -EPROTO; goto fini_req; } @@ -2853,7 +2894,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, if (KEY_IS(KEY_CACHE_SET)) { struct client_obd *cli = &obd->u.cli; - LASSERT(cli->cl_cache == NULL); /* only once */ + LASSERT(!cli->cl_cache); /* only once */ cli->cl_cache = val; atomic_inc(&cli->cl_cache->ccc_users); cli->cl_lru_left = &cli->cl_cache->ccc_lru_left; @@ -2881,16 +2922,17 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, return -EINVAL; /* We pass all other commands directly to OST. Since nobody calls osc - methods directly and everybody is supposed to go through LOV, we - assume lov checked invalid values for us. - The only recognised values so far are evict_by_nid and mds_conn. - Even if something bad goes through, we'd get a -EINVAL from OST - anyway. */ + * methods directly and everybody is supposed to go through LOV, we + * assume lov checked invalid values for us. + * The only recognised values so far are evict_by_nid and mds_conn. + * Even if something bad goes through, we'd get a -EINVAL from OST + * anyway. + */ req = ptlrpc_request_alloc(imp, KEY_IS(KEY_GRANT_SHRINK) ? &RQF_OST_SET_GRANT_INFO : &RQF_OBD_SET_INFO); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, @@ -2929,7 +2971,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, ptlrpc_request_set_replen(req); if (!KEY_IS(KEY_GRANT_SHRINK)) { - LASSERT(set != NULL); + LASSERT(set); ptlrpc_set_add_req(set, req); ptlrpc_check_set(NULL, set); } else { @@ -2947,7 +2989,7 @@ static int osc_reconnect(const struct lu_env *env, { struct client_obd *cli = &obd->u.cli; - if (data != NULL && (data->ocd_connect_flags & OBD_CONNECT_GRANT)) { + if (data && (data->ocd_connect_flags & OBD_CONNECT_GRANT)) { long lost_grant; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -2988,7 +3030,7 @@ static int osc_disconnect(struct obd_export *exp) * So the osc should be disconnected from the shrink list, after we * are sure the import has been destroyed. BUG18662 */ - if (obd->u.cli.cl_import == NULL) + if (!obd->u.cli.cl_import) osc_del_shrink_grant(&obd->u.cli); return rc; } @@ -3025,7 +3067,8 @@ static int osc_import_event(struct obd_device *obd, /* Reset grants */ cli = &obd->u.cli; /* all pages go to failing rpcs due to the invalid - * import */ + * import + */ osc_io_unplug(env, cli, NULL); ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); @@ -3207,13 +3250,13 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) return 0; } -int osc_cleanup(struct obd_device *obd) +static int osc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc; /* lru cleanup */ - if (cli->cl_cache != NULL) { + if (cli->cl_cache) { LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); spin_lock(&cli->cl_cache->ccc_lru_lock); list_del_init(&cli->cl_lru_osc); @@ -3256,7 +3299,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) return osc_process_config_base(obd, buf); } -struct obd_ops osc_obd_ops = { +static struct obd_ops osc_obd_ops = { .owner = THIS_MODULE, .setup = osc_setup, .precleanup = osc_precleanup, @@ -3299,7 +3342,8 @@ static int __init osc_init(void) /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data - * symbols from modules.*/ + * symbols from modules. + */ CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches); rc = lu_kmem_init(osc_caches); diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 1cc3c69..9b89068 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -145,7 +145,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE); desc = ptlrpc_new_bulk(npages, max_brw, type, portal); - if (desc == NULL) + if (!desc) return NULL; desc->bd_import_generation = req->rq_import_generation; @@ -171,7 +171,7 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page, int pageoffset, int len, int pin) { LASSERT(desc->bd_iov_count < desc->bd_max_iov); - LASSERT(page != NULL); + LASSERT(page); LASSERT(pageoffset >= 0); LASSERT(len > 0); LASSERT(pageoffset + len <= PAGE_CACHE_SIZE); @@ -193,7 +193,6 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) { int i; - LASSERT(desc != NULL); LASSERT(desc->bd_iov_count != LI_POISON); /* not freed already */ LASSERT(desc->bd_md_count == 0); /* network hands off */ LASSERT((desc->bd_export != NULL) ^ (desc->bd_import != NULL)); @@ -412,7 +411,7 @@ int ptlrpc_request_cache_init(void) request_cache = kmem_cache_create("ptlrpc_cache", sizeof(struct ptlrpc_request), 0, SLAB_HWCACHE_ALIGN, NULL); - return request_cache == NULL ? -ENOMEM : 0; + return !request_cache ? -ENOMEM : 0; } void ptlrpc_request_cache_fini(void) @@ -442,8 +441,6 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) struct list_head *l, *tmp; struct ptlrpc_request *req; - LASSERT(pool != NULL); - spin_lock(&pool->prp_lock); list_for_each_safe(l, tmp, &pool->prp_req_list) { req = list_entry(l, struct ptlrpc_request, rq_list); @@ -753,7 +750,7 @@ ptlrpc_request_alloc_internal(struct obd_import *imp, struct ptlrpc_request *request; request = __ptlrpc_request_alloc(imp, pool); - if (request == NULL) + if (!request) return NULL; req_capsule_init(&request->rq_pill, request, RCL_CLIENT); @@ -952,10 +949,10 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set, atomic_inc(&set->set_remaining); req->rq_queued_time = cfs_time_current(); - if (req->rq_reqmsg != NULL) + if (req->rq_reqmsg) lustre_msg_set_jobid(req->rq_reqmsg, NULL); - if (set->set_producer != NULL) + if (set->set_producer) /* * If the request set has a producer callback, the RPC must be * sent straight away @@ -975,7 +972,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc, struct ptlrpc_request_set *set = pc->pc_set; int count, i; - LASSERT(req->rq_set == NULL); + LASSERT(!req->rq_set); LASSERT(test_bit(LIOD_STOP, &pc->pc_flags) == 0); spin_lock(&set->set_new_req_lock); @@ -1016,7 +1013,6 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, { int delay = 0; - LASSERT(status != NULL); *status = 0; if (req->rq_ctx_init || req->rq_ctx_fini) { @@ -1079,7 +1075,7 @@ static int ptlrpc_console_allow(struct ptlrpc_request *req) __u32 opc; int err; - LASSERT(req->rq_reqmsg != NULL); + LASSERT(req->rq_reqmsg); opc = lustre_msg_get_opc(req->rq_reqmsg); /* @@ -1168,7 +1164,7 @@ static int after_reply(struct ptlrpc_request *req) struct timespec64 work_start; long timediff; - LASSERT(obd != NULL); + LASSERT(obd); /* repbuf must be unlinked */ LASSERT(!req->rq_receiving_reply && !req->rq_reply_unlink); @@ -1248,7 +1244,7 @@ static int after_reply(struct ptlrpc_request *req) ktime_get_real_ts64(&work_start); timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC + (work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC; - if (obd->obd_svc_stats != NULL) { + if (obd->obd_svc_stats) { lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, timediff); ptlrpc_lprocfs_rpc_sent(req, timediff); @@ -1311,7 +1307,7 @@ static int after_reply(struct ptlrpc_request *req) /* version recovery */ ptlrpc_save_versions(req); ptlrpc_retain_replayable_request(req, imp); - } else if (req->rq_commit_cb != NULL && + } else if (req->rq_commit_cb && list_empty(&req->rq_replay_list)) { /* * NB: don't call rq_commit_cb if it's already on @@ -1438,7 +1434,7 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) { int remaining, rc; - LASSERT(set->set_producer != NULL); + LASSERT(set->set_producer); remaining = atomic_read(&set->set_remaining); @@ -1751,7 +1747,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) * process the reply. Similarly if the RPC returned * an error, and therefore the bulk will never arrive. */ - if (req->rq_bulk == NULL || req->rq_status < 0) { + if (!req->rq_bulk || req->rq_status < 0) { ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); goto interpret; } @@ -1803,7 +1799,7 @@ interpret: } ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE); - CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0, + CDEBUG(req->rq_reqmsg ? D_RPCTRACE : 0, "Completed RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n", current_comm(), imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, @@ -1883,7 +1879,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) "timed out for sent delay" : "timed out for slow reply"), (s64)req->rq_sent, (s64)req->rq_real_sent); - if (imp != NULL && obd_debug_peer_on_timeout) + if (imp && obd_debug_peer_on_timeout) LNetDebugPeer(imp->imp_connection->c_peer); ptlrpc_unregister_reply(req, async_unlink); @@ -1892,7 +1888,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) if (obd_dump_on_timeout) libcfs_debug_dumplog(); - if (imp == NULL) { + if (!imp) { DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?"); return 1; } @@ -1945,8 +1941,6 @@ int ptlrpc_expired_set(void *data) struct list_head *tmp; time64_t now = ktime_get_real_seconds(); - LASSERT(set != NULL); - /* A timeout expired. See which reqs it applies to... */ list_for_each(tmp, &set->set_requests) { struct ptlrpc_request *req = @@ -2003,7 +1997,6 @@ void ptlrpc_interrupted_set(void *data) struct ptlrpc_request_set *set = data; struct list_head *tmp; - LASSERT(set != NULL); CDEBUG(D_RPCTRACE, "INTERRUPTED SET %p\n", set); list_for_each(tmp, &set->set_requests) { @@ -2175,7 +2168,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) rc = req->rq_status; } - if (set->set_interpret != NULL) { + if (set->set_interpret) { int (*interpreter)(struct ptlrpc_request_set *set, void *, int) = set->set_interpret; rc = interpreter(set, set->set_arg, rc); @@ -2207,10 +2200,10 @@ EXPORT_SYMBOL(ptlrpc_set_wait); */ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { - if (request == NULL) + if (!request) return; LASSERTF(!request->rq_receiving_reply, "req %p\n", request); - LASSERTF(request->rq_rqbd == NULL, "req %p\n", request);/* client-side */ + LASSERTF(!request->rq_rqbd, "req %p\n", request);/* client-side */ LASSERTF(list_empty(&request->rq_list), "req %p\n", request); LASSERTF(list_empty(&request->rq_set_chain), "req %p\n", request); LASSERTF(list_empty(&request->rq_exp_list), "req %p\n", request); @@ -2222,7 +2215,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) * We must take it off the imp_replay_list first. Otherwise, we'll set * request->rq_reqmsg to NULL while osc_close is dereferencing it. */ - if (request->rq_import != NULL) { + if (request->rq_import) { if (!locked) spin_lock(&request->rq_import->imp_lock); list_del_init(&request->rq_replay_list); @@ -2237,20 +2230,20 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) LBUG(); } - if (request->rq_repbuf != NULL) + if (request->rq_repbuf) sptlrpc_cli_free_repbuf(request); - if (request->rq_export != NULL) { + if (request->rq_export) { class_export_put(request->rq_export); request->rq_export = NULL; } - if (request->rq_import != NULL) { + if (request->rq_import) { class_import_put(request->rq_import); request->rq_import = NULL; } - if (request->rq_bulk != NULL) + if (request->rq_bulk) ptlrpc_free_bulk_pin(request->rq_bulk); - if (request->rq_reqbuf != NULL || request->rq_clrbuf != NULL) + if (request->rq_reqbuf || request->rq_clrbuf) sptlrpc_cli_free_reqbuf(request); if (request->rq_cli_ctx) @@ -2270,7 +2263,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) */ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) { - if (request == NULL) + if (!request) return 1; if (request == LP_POISON || @@ -2352,7 +2345,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * a chance to run reply_in_callback(), and to make sure we've * unlinked before returning a req to the pool. */ - if (request->rq_set != NULL) + if (request->rq_set) wq = &request->rq_set->set_waitq; else wq = &request->rq_reply_waitq; @@ -2387,7 +2380,7 @@ static void ptlrpc_free_request(struct ptlrpc_request *req) req->rq_replay = 0; spin_unlock(&req->rq_lock); - if (req->rq_commit_cb != NULL) + if (req->rq_commit_cb) req->rq_commit_cb(req); list_del_init(&req->rq_replay_list); @@ -2428,7 +2421,6 @@ void ptlrpc_free_committed(struct obd_import *imp) struct ptlrpc_request *last_req = NULL; /* temporary fire escape */ bool skip_committed_list = true; - LASSERT(imp != NULL); assert_spin_locked(&imp->imp_lock); if (imp->imp_peer_committed_transno == imp->imp_last_transno_checked && @@ -2612,11 +2604,11 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) struct ptlrpc_request_set *set; int rc; - LASSERT(req->rq_set == NULL); + LASSERT(!req->rq_set); LASSERT(!req->rq_receiving_reply); set = ptlrpc_prep_set(); - if (set == NULL) { + if (!set) { CERROR("Unable to allocate ptlrpc set."); return -ENOMEM; } @@ -2848,8 +2840,6 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set) { struct list_head *tmp, *pos; - LASSERT(set != NULL); - list_for_each_safe(pos, tmp, &set->set_requests) { struct ptlrpc_request *req = list_entry(pos, struct ptlrpc_request, @@ -2995,7 +2985,6 @@ static int work_interpreter(const struct lu_env *env, struct ptlrpc_work_async_args *arg = data; LASSERT(ptlrpcd_check_work(req)); - LASSERT(arg->cb != NULL); rc = arg->cb(env, arg->cbdata); @@ -3027,12 +3016,12 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, might_sleep(); - if (cb == NULL) + if (!cb) return ERR_PTR(-EINVAL); /* copy some code from deprecated fakereq. */ req = ptlrpc_request_cache_alloc(GFP_NOFS); - if (req == NULL) { + if (!req) { CERROR("ptlrpc: run out of memory!\n"); return ERR_PTR(-ENOMEM); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index da1f0b1..a14daff 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -72,7 +72,8 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, * returned and may be compared against out object. */ /* In the function below, .hs_keycmp resolves to - * conn_keycmp() */ + * conn_keycmp() + */ /* coverity[overrun-buffer-val] */ conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash); if (conn != conn2) { @@ -172,7 +173,7 @@ conn_keycmp(const void *key, struct hlist_node *hnode) struct ptlrpc_connection *conn; const lnet_process_id_t *conn_key; - LASSERT(key != NULL); + LASSERT(key); conn_key = key; conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash); diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 07e76a2..47be21a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -71,7 +71,8 @@ void request_out_callback(lnet_event_t *ev) if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) { /* Failed send: make it seem like the reply timed out, just - * like failing sends in client.c does currently... */ + * like failing sends in client.c does currently... + */ req->rq_net_err = 1; ptlrpc_client_wake_req(req); @@ -95,7 +96,8 @@ void reply_in_callback(lnet_event_t *ev) LASSERT(ev->md.start == req->rq_repbuf); LASSERT(ev->offset + ev->mlength <= req->rq_repbuf_len); /* We've set LNET_MD_MANAGE_REMOTE for all outgoing requests - for adaptive timeouts' early reply. */ + * for adaptive timeouts' early reply. + */ LASSERT((ev->md.options & LNET_MD_MANAGE_REMOTE) != 0); spin_lock(&req->rq_lock); @@ -151,7 +153,8 @@ void reply_in_callback(lnet_event_t *ev) req->rq_reply_off = ev->offset; req->rq_nob_received = ev->mlength; /* LNetMDUnlink can't be called under the LNET_LOCK, - so we must unlink in ptlrpc_unregister_reply */ + * so we must unlink in ptlrpc_unregister_reply + */ DEBUG_REQ(D_INFO, req, "reply in flags=%x mlen=%u offset=%d replen=%d", lustre_msg_get_flags(req->rq_reqmsg), @@ -162,7 +165,8 @@ void reply_in_callback(lnet_event_t *ev) out_wake: /* NB don't unlock till after wakeup; req can disappear under us - * since we don't have our own ref */ + * since we don't have our own ref + */ ptlrpc_client_wake_req(req); spin_unlock(&req->rq_lock); } @@ -213,7 +217,8 @@ void client_bulk_callback(lnet_event_t *ev) desc->bd_failure = 1; /* NB don't unlock till after wakeup; desc can disappear under us - * otherwise */ + * otherwise + */ if (desc->bd_md_count == 0) ptlrpc_client_wake_req(desc->bd_req); @@ -250,7 +255,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, __u64 new_seq; /* set sequence ID for request and add it to history list, - * it must be called with hold svcpt::scp_lock */ + * it must be called with hold svcpt::scp_lock + */ new_seq = (sec << REQS_SEC_SHIFT) | (usec << REQS_USEC_SHIFT) | @@ -258,7 +264,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, if (new_seq > svcpt->scp_hist_seq) { /* This handles the initial case of scp_hist_seq == 0 or - * we just jumped into a new time window */ + * we just jumped into a new time window + */ svcpt->scp_hist_seq = new_seq; } else { LASSERT(REQS_SEQ_SHIFT(svcpt) < REQS_USEC_SHIFT); @@ -266,7 +273,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, * however, it's possible that we used up all bits for * sequence and jumped into the next usec bucket (future time), * then we hope there will be less RPCs per bucket at some - * point, and sequence will catch up again */ + * point, and sequence will catch up again + */ svcpt->scp_hist_seq += (1U << REQS_SEQ_SHIFT(svcpt)); new_seq = svcpt->scp_hist_seq; } @@ -302,7 +310,8 @@ void request_in_callback(lnet_event_t *ev) * request buffer we can use the request object embedded in * rqbd. Note that if we failed to allocate a request, * we'd have to re-post the rqbd, which we can't do in this - * context. */ + * context. + */ req = &rqbd->rqbd_req; memset(req, 0, sizeof(*req)); } else { @@ -312,7 +321,7 @@ void request_in_callback(lnet_event_t *ev) return; } req = ptlrpc_request_cache_alloc(GFP_ATOMIC); - if (req == NULL) { + if (!req) { CERROR("Can't allocate incoming request descriptor: Dropping %s RPC from %s\n", service->srv_name, libcfs_id2str(ev->initiator)); @@ -322,7 +331,8 @@ void request_in_callback(lnet_event_t *ev) /* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL, * flags are reset and scalars are zero. We only set the message - * size to non-zero if this was a successful receive. */ + * size to non-zero if this was a successful receive. + */ req->rq_xid = ev->match_bits; req->rq_reqbuf = ev->md.start + ev->offset; if (ev->type == LNET_EVENT_PUT && ev->status == 0) @@ -352,7 +362,8 @@ void request_in_callback(lnet_event_t *ev) svcpt->scp_nrqbds_posted); /* Normally, don't complain about 0 buffers posted; LNET won't - * drop incoming reqs since we set the portal lazy */ + * drop incoming reqs since we set the portal lazy + */ if (test_req_buffer_pressure && ev->type != LNET_EVENT_UNLINK && svcpt->scp_nrqbds_posted == 0) @@ -369,7 +380,8 @@ void request_in_callback(lnet_event_t *ev) svcpt->scp_nreqs_incoming++; /* NB everything can disappear under us once the request - * has been queued and we unlock, so do the wake now... */ + * has been queued and we unlock, so do the wake now... + */ wake_up(&svcpt->scp_waitq); spin_unlock(&svcpt->scp_lock); @@ -390,7 +402,8 @@ void reply_out_callback(lnet_event_t *ev) if (!rs->rs_difficult) { /* 'Easy' replies have no further processing so I drop the - * net's ref on 'rs' */ + * net's ref on 'rs' + */ LASSERT(ev->unlinked); ptlrpc_rs_decref(rs); return; @@ -400,7 +413,8 @@ void reply_out_callback(lnet_event_t *ev) if (ev->unlinked) { /* Last network callback. The net's ref on 'rs' stays put - * until ptlrpc_handle_rs() is done with it */ + * until ptlrpc_handle_rs() is done with it + */ spin_lock(&svcpt->scp_rep_lock); spin_lock(&rs->rs_lock); @@ -443,7 +457,7 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, lnet_nid_t dst_nid; lnet_nid_t src_nid; - peer->pid = LUSTRE_SRV_LNET_PID; + peer->pid = LNET_PID_LUSTRE; /* Choose the matching UUID that's closest */ while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) { @@ -483,7 +497,8 @@ static void ptlrpc_ni_fini(void) /* Wait for the event queue to become idle since there may still be * messages in flight with pending events (i.e. the fire-and-forget * messages == client requests and "non-difficult" server - * replies */ + * replies + */ for (retries = 0;; retries++) { rc = LNetEQFree(ptlrpc_eq_h); @@ -513,7 +528,7 @@ static lnet_pid_t ptl_get_pid(void) { lnet_pid_t pid; - pid = LUSTRE_SRV_LNET_PID; + pid = LNET_PID_LUSTRE; return pid; } @@ -533,11 +548,13 @@ static int ptlrpc_ni_init(void) } /* CAVEAT EMPTOR: how we process portals events is _radically_ - * different depending on... */ + * different depending on... + */ /* kernel LNet calls our master callback when there are new event, * because we are guaranteed to get every event via callback, * so we just set EQ size to 0 to avoid overhead of serializing - * enqueue/dequeue operations in LNet. */ + * enqueue/dequeue operations in LNet. + */ rc = LNetEQAlloc(0, ptlrpc_master_callback, &ptlrpc_eq_h); if (rc == 0) return 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index f752c78..70fcac1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -112,7 +112,8 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp); * CLOSED. I would rather refcount the import and free it after * disconnection like we do with exports. To do that, the client_obd * will need to save the peer info somewhere other than in the import, - * though. */ + * though. + */ int ptlrpc_init_import(struct obd_import *imp) { spin_lock(&imp->imp_lock); @@ -282,11 +283,13 @@ void ptlrpc_invalidate_import(struct obd_import *imp) /* Wait forever until inflight == 0. We really can't do it another * way because in some cases we need to wait for very long reply * unlink. We can't do anything before that because there is really - * no guarantee that some rdma transfer is not in progress right now. */ + * no guarantee that some rdma transfer is not in progress right now. + */ do { /* Calculate max timeout for waiting on rpcs to error * out. Use obd_timeout if calculated value is smaller - * than it. */ + * than it. + */ if (!OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) { timeout = ptlrpc_inflight_timeout(imp); timeout += timeout / 3; @@ -304,7 +307,8 @@ void ptlrpc_invalidate_import(struct obd_import *imp) /* Wait for all requests to error out and call completion * callbacks. Cap it at obd_timeout -- these should all - * have been locally cancelled by ptlrpc_abort_inflight. */ + * have been locally cancelled by ptlrpc_abort_inflight. + */ lwi = LWI_TIMEOUT_INTERVAL( cfs_timeout_cap(cfs_time_seconds(timeout)), (timeout > 1)?cfs_time_seconds(1):cfs_time_seconds(1)/2, @@ -328,13 +332,15 @@ void ptlrpc_invalidate_import(struct obd_import *imp) * maybe waiting for long reply unlink in * sluggish nets). Let's check this. If there * is no inflight and unregistering != 0, this - * is bug. */ + * is bug. + */ LASSERTF(count == 0, "Some RPCs are still unregistering: %d\n", count); /* Let's save one loop as soon as inflight have * dropped to zero. No new inflights possible at - * this point. */ + * this point. + */ rc = 0; } else { list_for_each_safe(tmp, n, @@ -501,7 +507,8 @@ static int import_select_connection(struct obd_import *imp) conn->oic_last_attempt); /* If we have not tried this connection since - the last successful attempt, go with this one */ + * the last successful attempt, go with this one + */ if ((conn->oic_last_attempt == 0) || cfs_time_beforeq_64(conn->oic_last_attempt, imp->imp_last_success_conn)) { @@ -511,8 +518,9 @@ static int import_select_connection(struct obd_import *imp) } /* If all of the connections have already been tried - since the last successful connection; just choose the - least recently used */ + * since the last successful connection; just choose the + * least recently used + */ if (!imp_conn) imp_conn = conn; else if (cfs_time_before_64(conn->oic_last_attempt, @@ -529,10 +537,11 @@ static int import_select_connection(struct obd_import *imp) LASSERT(imp_conn->oic_conn); /* If we've tried everything, and we're back to the beginning of the - list, increase our timeout and try again. It will be reset when - we do finally connect. (FIXME: really we should wait for all network - state associated with the last connection attempt to drain before - trying to reconnect on it.) */ + * list, increase our timeout and try again. It will be reset when + * we do finally connect. (FIXME: really we should wait for all network + * state associated with the last connection attempt to drain before + * trying to reconnect on it.) + */ if (tried_all && (imp->imp_conn_list.next == &imp_conn->oic_item)) { struct adaptive_timeout *at = &imp->imp_at.iat_net_latency; @@ -553,7 +562,6 @@ static int import_select_connection(struct obd_import *imp) imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); dlmexp = class_conn2export(&imp->imp_dlm_handle); - LASSERT(dlmexp != NULL); ptlrpc_connection_put(dlmexp->exp_connection); dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn); class_export_put(dlmexp); @@ -590,7 +598,8 @@ static int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno) struct list_head *tmp; /* The requests in committed_list always have smaller transnos than - * the requests in replay_list */ + * the requests in replay_list + */ if (!list_empty(&imp->imp_committed_list)) { tmp = imp->imp_committed_list.next; req = list_entry(tmp, struct ptlrpc_request, rq_replay_list); @@ -674,7 +683,8 @@ int ptlrpc_connect_import(struct obd_import *imp) goto out; /* Reset connect flags to the originally requested flags, in case - * the server is updated on-the-fly we will get the new features. */ + * the server is updated on-the-fly we will get the new features. + */ imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig; /* Reset ocd_version each time so the server knows the exact versions */ imp->imp_connect_data.ocd_version = LUSTRE_VERSION_CODE; @@ -687,7 +697,7 @@ int ptlrpc_connect_import(struct obd_import *imp) goto out; request = ptlrpc_request_alloc(imp, &RQF_MDS_CONNECT); - if (request == NULL) { + if (!request) { rc = -ENOMEM; goto out; } @@ -700,7 +710,8 @@ int ptlrpc_connect_import(struct obd_import *imp) } /* Report the rpc service time to the server so that it knows how long - * to wait for clients to join recovery */ + * to wait for clients to join recovery + */ lustre_msg_set_service_time(request->rq_reqmsg, at_timeout2est(request->rq_timeout)); @@ -708,7 +719,8 @@ int ptlrpc_connect_import(struct obd_import *imp) * import_select_connection will increase the net latency on * repeated reconnect attempts to cover slow networks. * We override/ignore the server rpc completion estimate here, - * which may be large if this is a reconnect attempt */ + * which may be large if this is a reconnect attempt + */ request->rq_timeout = INITIAL_CONNECT_TIMEOUT; lustre_msg_set_timeout(request->rq_reqmsg, request->rq_timeout); @@ -799,7 +811,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (rc) { /* if this reconnect to busy export - not need select new target - * for connecting*/ + * for connecting + */ imp->imp_force_reconnect = ptlrpc_busy_reconnect(rc); spin_unlock(&imp->imp_lock); ptlrpc_maybe_ping_import_soon(imp); @@ -817,7 +830,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, ocd = req_capsule_server_sized_get(&request->rq_pill, &RMF_CONNECT_DATA, ret); - if (ocd == NULL) { + if (!ocd) { CERROR("%s: no connect data from server\n", imp->imp_obd->obd_name); rc = -EPROTO; @@ -851,7 +864,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (!exp) { /* This could happen if export is cleaned during the - connect attempt */ + * connect attempt + */ CERROR("%s: missing export after connect\n", imp->imp_obd->obd_name); rc = -ENODEV; @@ -877,14 +891,16 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } /* if applies, adjust the imp->imp_msg_magic here - * according to reply flags */ + * according to reply flags + */ imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); /* Initial connects are allowed for clients with non-random * uuids when servers are in recovery. Simply signal the - * servers replay is complete and wait in REPLAY_WAIT. */ + * servers replay is complete and wait in REPLAY_WAIT. + */ if (msg_flags & MSG_CONNECT_RECOVERING) { CDEBUG(D_HA, "connect to %s during recovery\n", obd2cli_tgt(imp->imp_obd)); @@ -923,7 +939,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, * already erased all of our state because of previous * eviction. If it is in recovery - we are safe to * participate since we can reestablish all of our state - * with server again */ + * with server again + */ if ((msg_flags & MSG_CONNECT_RECOVERING)) { CDEBUG(level, "%s@%s changed server handle from %#llx to %#llx but is still in recovery\n", obd2cli_tgt(imp->imp_obd), @@ -1039,7 +1056,8 @@ finish: ocd->ocd_version < LUSTRE_VERSION_CODE - LUSTRE_VERSION_OFFSET_WARN)) { /* Sigh, some compilers do not like #ifdef in the middle - of macro arguments */ + * of macro arguments + */ const char *older = "older. Consider upgrading server or downgrading client" ; const char *newer = "newer than client version. Consider upgrading client" @@ -1061,7 +1079,8 @@ finish: * fixup is version-limited, because we don't want to carry the * OBD_CONNECT_MNE_SWAB flag around forever, just so long as we * need interop with unpatched 2.2 servers. For newer servers, - * the client will do MNE swabbing only as needed. LU-1644 */ + * the client will do MNE swabbing only as needed. LU-1644 + */ if (unlikely((ocd->ocd_connect_flags & OBD_CONNECT_VERSION) && !(ocd->ocd_connect_flags & OBD_CONNECT_MNE_SWAB) && OBD_OCD_VERSION_MAJOR(ocd->ocd_version) == 2 && @@ -1079,7 +1098,8 @@ finish: if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) { /* We sent to the server ocd_cksum_types with bits set * for algorithms we understand. The server masked off - * the checksum types it doesn't support */ + * the checksum types it doesn't support + */ if ((ocd->ocd_cksum_types & cksum_types_supported_client()) == 0) { LCONSOLE_WARN("The negotiation of the checksum algorithm to use with server %s failed (%x/%x), disabling checksums\n", @@ -1093,7 +1113,8 @@ finish: } } else { /* The server does not support OBD_CONNECT_CKSUM. - * Enforce ADLER for backward compatibility*/ + * Enforce ADLER for backward compatibility + */ cli->cl_supp_cksum_types = OBD_CKSUM_ADLER; } cli->cl_cksum_type = cksum_type_select(cli->cl_supp_cksum_types); @@ -1109,7 +1130,8 @@ finish: /* Reset ns_connect_flags only for initial connect. It might be * changed in while using FS and if we reset it in reconnect * this leads to losing user settings done before such as - * disable lru_resize, etc. */ + * disable lru_resize, etc. + */ if (old_connect_flags != exp_connect_flags(exp) || aa->pcaa_initial_connect) { CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server flags: %#llx\n", @@ -1123,13 +1145,14 @@ finish: if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) && (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2)) /* We need a per-message support flag, because - a. we don't know if the incoming connect reply - supports AT or not (in reply_in_callback) - until we unpack it. - b. failovered server means export and flags are gone - (in ptlrpc_send_reply). - Can only be set when we know AT is supported at - both ends */ + * a. we don't know if the incoming connect reply + * supports AT or not (in reply_in_callback) + * until we unpack it. + * b. failovered server means export and flags are gone + * (in ptlrpc_send_reply). + * Can only be set when we know AT is supported at + * both ends + */ imp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; else imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; @@ -1162,7 +1185,7 @@ out: struct obd_connect_data *ocd; /* reply message might not be ready */ - if (request->rq_repmsg == NULL) + if (!request->rq_repmsg) return -EPROTO; ocd = req_capsule_server_get(&request->rq_pill, @@ -1243,7 +1266,7 @@ static int signal_completed_replay(struct obd_import *imp) req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING, LUSTRE_OBD_VERSION, OBD_PING); - if (req == NULL) { + if (!req) { atomic_dec(&imp->imp_replay_inflight); return -ENOMEM; } @@ -1339,7 +1362,8 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) /* bug 17802: XXX client_disconnect_export vs connect request * race. if client will evicted at this time, we start * invalidate thread without reference to import and import can - * be freed at same time. */ + * be freed at same time. + */ class_import_get(imp); task = kthread_run(ptlrpc_invalidate_import_thread, imp, "ll_imp_inval"); @@ -1471,11 +1495,13 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) if (req) { /* We are disconnecting, do not retry a failed DISCONNECT rpc if * it fails. We can get through the above with a down server - * if the client doesn't know the server is gone yet. */ + * if the client doesn't know the server is gone yet. + */ req->rq_no_resend = 1; /* We want client umounts to happen quickly, no matter the - server state... */ + * server state... + */ req->rq_timeout = min_t(int, req->rq_timeout, INITIAL_CONNECT_TIMEOUT); @@ -1507,9 +1533,10 @@ EXPORT_SYMBOL(ptlrpc_disconnect_import); extern unsigned int at_min, at_max, at_history; /* Bin into timeslices using AT_BINS bins. - This gives us a max of the last binlimit*AT_BINS secs without the storage, - but still smoothing out a return to normalcy from a slow response. - (E.g. remember the maximum latency in each minute of the last 4 minutes.) */ + * This gives us a max of the last binlimit*AT_BINS secs without the storage, + * but still smoothing out a return to normalcy from a slow response. + * (E.g. remember the maximum latency in each minute of the last 4 minutes.) + */ int at_measured(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; @@ -1523,7 +1550,8 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) if (val == 0) /* 0's don't count, because we never want our timeout to - drop to 0, and because 0 could mean an error */ + * drop to 0, and because 0 could mean an error + */ return 0; spin_lock(&at->at_lock); @@ -1565,7 +1593,8 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) if (at->at_flags & AT_FLG_NOHIST) /* Only keep last reported val; keeping the rest of the history - for proc only */ + * for debugfs only + */ at->at_current = val; if (at_max > 0) diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index c0e613c..0e60264 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -118,25 +118,6 @@ static const struct req_msg_field *quotactl_only[] = { &RMF_OBD_QUOTACTL }; -static const struct req_msg_field *quota_body_only[] = { - &RMF_PTLRPC_BODY, - &RMF_QUOTA_BODY -}; - -static const struct req_msg_field *ldlm_intent_quota_client[] = { - &RMF_PTLRPC_BODY, - &RMF_DLM_REQ, - &RMF_LDLM_INTENT, - &RMF_QUOTA_BODY -}; - -static const struct req_msg_field *ldlm_intent_quota_server[] = { - &RMF_PTLRPC_BODY, - &RMF_DLM_REP, - &RMF_DLM_LVB, - &RMF_QUOTA_BODY -}; - static const struct req_msg_field *mdt_close_client[] = { &RMF_PTLRPC_BODY, &RMF_MDT_EPOCH, @@ -514,16 +495,6 @@ static const struct req_msg_field *mds_setattr_server[] = { &RMF_CAPA2 }; -static const struct req_msg_field *mds_update_client[] = { - &RMF_PTLRPC_BODY, - &RMF_UPDATE, -}; - -static const struct req_msg_field *mds_update_server[] = { - &RMF_PTLRPC_BODY, - &RMF_UPDATE_REPLY, -}; - static const struct req_msg_field *llog_origin_handle_create_client[] = { &RMF_PTLRPC_BODY, &RMF_LLOGD_BODY, @@ -551,16 +522,6 @@ static const struct req_msg_field *llog_origin_handle_next_block_server[] = { &RMF_EADATA }; -static const struct req_msg_field *obd_idx_read_client[] = { - &RMF_PTLRPC_BODY, - &RMF_IDX_INFO -}; - -static const struct req_msg_field *obd_idx_read_server[] = { - &RMF_PTLRPC_BODY, - &RMF_IDX_INFO -}; - static const struct req_msg_field *ost_body_only[] = { &RMF_PTLRPC_BODY, &RMF_OST_BODY @@ -676,7 +637,6 @@ static const struct req_msg_field *mdt_hsm_request[] = { static struct req_format *req_formats[] = { &RQF_OBD_PING, &RQF_OBD_SET_INFO, - &RQF_OBD_IDX_READ, &RQF_SEC_CTX, &RQF_MGS_TARGET_REG, &RQF_MGS_SET_INFO, @@ -721,7 +681,6 @@ static struct req_format *req_formats[] = { &RQF_MDS_HSM_ACTION, &RQF_MDS_HSM_REQUEST, &RQF_MDS_SWAP_LAYOUTS, - &RQF_UPDATE_OBJ, &RQF_QC_CALLBACK, &RQF_OST_CONNECT, &RQF_OST_DISCONNECT, @@ -759,8 +718,6 @@ static struct req_format *req_formats[] = { &RQF_LDLM_INTENT_CREATE, &RQF_LDLM_INTENT_UNLINK, &RQF_LDLM_INTENT_GETXATTR, - &RQF_LDLM_INTENT_QUOTA, - &RQF_QUOTA_DQACQ, &RQF_LOG_CANCEL, &RQF_LLOG_ORIGIN_HANDLE_CREATE, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -899,11 +856,6 @@ struct req_msg_field RMF_OBD_QUOTACTL = lustre_swab_obd_quotactl, NULL); EXPORT_SYMBOL(RMF_OBD_QUOTACTL); -struct req_msg_field RMF_QUOTA_BODY = - DEFINE_MSGF("quota_body", 0, - sizeof(struct quota_body), lustre_swab_quota_body, NULL); -EXPORT_SYMBOL(RMF_QUOTA_BODY); - struct req_msg_field RMF_MDT_EPOCH = DEFINE_MSGF("mdt_ioepoch", 0, sizeof(struct mdt_ioepoch), lustre_swab_mdt_ioepoch, NULL); @@ -1105,10 +1057,6 @@ struct req_msg_field RMF_FIEMAP_VAL = DEFINE_MSGF("fiemap", 0, -1, lustre_swab_fiemap, NULL); EXPORT_SYMBOL(RMF_FIEMAP_VAL); -struct req_msg_field RMF_IDX_INFO = - DEFINE_MSGF("idx_info", 0, sizeof(struct idx_info), - lustre_swab_idx_info, NULL); -EXPORT_SYMBOL(RMF_IDX_INFO); struct req_msg_field RMF_HSM_USER_STATE = DEFINE_MSGF("hsm_user_state", 0, sizeof(struct hsm_user_state), lustre_swab_hsm_user_state, NULL); @@ -1145,15 +1093,6 @@ struct req_msg_field RMF_MDS_HSM_REQUEST = lustre_swab_hsm_request, NULL); EXPORT_SYMBOL(RMF_MDS_HSM_REQUEST); -struct req_msg_field RMF_UPDATE = DEFINE_MSGF("update", 0, -1, - lustre_swab_update_buf, NULL); -EXPORT_SYMBOL(RMF_UPDATE); - -struct req_msg_field RMF_UPDATE_REPLY = DEFINE_MSGF("update_reply", 0, -1, - lustre_swab_update_reply_buf, - NULL); -EXPORT_SYMBOL(RMF_UPDATE_REPLY); - struct req_msg_field RMF_SWAP_LAYOUTS = DEFINE_MSGF("swap_layouts", 0, sizeof(struct mdc_swap_layouts), lustre_swab_swap_layouts, NULL); @@ -1196,12 +1135,6 @@ struct req_format RQF_OBD_SET_INFO = DEFINE_REQ_FMT0("OBD_SET_INFO", obd_set_info_client, empty); EXPORT_SYMBOL(RQF_OBD_SET_INFO); -/* Read index file through the network */ -struct req_format RQF_OBD_IDX_READ = - DEFINE_REQ_FMT0("OBD_IDX_READ", - obd_idx_read_client, obd_idx_read_server); -EXPORT_SYMBOL(RQF_OBD_IDX_READ); - struct req_format RQF_SEC_CTX = DEFINE_REQ_FMT0("SEC_CTX", empty, empty); EXPORT_SYMBOL(RQF_SEC_CTX); @@ -1253,16 +1186,6 @@ struct req_format RQF_QC_CALLBACK = DEFINE_REQ_FMT0("QC_CALLBACK", quotactl_only, empty); EXPORT_SYMBOL(RQF_QC_CALLBACK); -struct req_format RQF_QUOTA_DQACQ = - DEFINE_REQ_FMT0("QUOTA_DQACQ", quota_body_only, quota_body_only); -EXPORT_SYMBOL(RQF_QUOTA_DQACQ); - -struct req_format RQF_LDLM_INTENT_QUOTA = - DEFINE_REQ_FMT0("LDLM_INTENT_QUOTA", - ldlm_intent_quota_client, - ldlm_intent_quota_server); -EXPORT_SYMBOL(RQF_LDLM_INTENT_QUOTA); - struct req_format RQF_MDS_GETSTATUS = DEFINE_REQ_FMT0("MDS_GETSTATUS", mdt_body_only, mdt_body_capa); EXPORT_SYMBOL(RQF_MDS_GETSTATUS); @@ -1357,11 +1280,6 @@ struct req_format RQF_MDS_GET_INFO = mds_getinfo_server); EXPORT_SYMBOL(RQF_MDS_GET_INFO); -struct req_format RQF_UPDATE_OBJ = - DEFINE_REQ_FMT0("OBJECT_UPDATE_OBJ", mds_update_client, - mds_update_server); -EXPORT_SYMBOL(RQF_UPDATE_OBJ); - struct req_format RQF_LDLM_ENQUEUE = DEFINE_REQ_FMT0("LDLM_ENQUEUE", ldlm_enqueue_client, ldlm_enqueue_lvb_server); @@ -1712,7 +1630,7 @@ void req_capsule_init(struct req_capsule *pill, * high-priority RPC queue getting peeked at before ost_handle() * handles an OST RPC. */ - if (req != NULL && pill == &req->rq_pill && req->rq_pill_init) + if (req && pill == &req->rq_pill && req->rq_pill_init) return; memset(pill, 0, sizeof(*pill)); @@ -1720,7 +1638,7 @@ void req_capsule_init(struct req_capsule *pill, pill->rc_loc = location; req_capsule_init_area(pill); - if (req != NULL && pill == &req->rq_pill) + if (req && pill == &req->rq_pill) req->rq_pill_init = 1; } EXPORT_SYMBOL(req_capsule_init); @@ -1752,7 +1670,7 @@ static struct lustre_msg *__req_msg(const struct req_capsule *pill, */ void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt) { - LASSERT(pill->rc_fmt == NULL || pill->rc_fmt == fmt); + LASSERT(!pill->rc_fmt || pill->rc_fmt == fmt); LASSERT(__req_format_is_sane(fmt)); pill->rc_fmt = fmt; @@ -1773,8 +1691,6 @@ int req_capsule_filled_sizes(struct req_capsule *pill, const struct req_format *fmt = pill->rc_fmt; int i; - LASSERT(fmt != NULL); - for (i = 0; i < fmt->rf_fields[loc].nr; ++i) { if (pill->rc_area[loc][i] == -1) { pill->rc_area[loc][i] = @@ -1810,7 +1726,7 @@ int req_capsule_server_pack(struct req_capsule *pill) LASSERT(pill->rc_loc == RCL_SERVER); fmt = pill->rc_fmt; - LASSERT(fmt != NULL); + LASSERT(fmt); count = req_capsule_filled_sizes(pill, RCL_SERVER); rc = lustre_pack_reply(pill->rc_req, count, @@ -1865,7 +1781,7 @@ swabber_dumper_helper(struct req_capsule *pill, swabber = swabber ?: field->rmf_swabber; if (ptlrpc_buf_need_swab(pill->rc_req, inout, offset) && - swabber != NULL && value != NULL) + swabber && value) do_swab = 1; else do_swab = 0; @@ -1947,17 +1863,15 @@ static void *__req_capsule_get(struct req_capsule *pill, [RCL_SERVER] = "server" }; - LASSERT(pill != NULL); - LASSERT(pill != LP_POISON); fmt = pill->rc_fmt; - LASSERT(fmt != NULL); + LASSERT(fmt); LASSERT(fmt != LP_POISON); LASSERT(__req_format_is_sane(fmt)); offset = __req_capsule_offset(pill, field, loc); msg = __req_msg(pill, loc); - LASSERT(msg != NULL); + LASSERT(msg); getter = (field->rmf_flags & RMF_F_STRING) ? (typeof(getter))lustre_msg_string : lustre_msg_buf; @@ -1980,7 +1894,7 @@ static void *__req_capsule_get(struct req_capsule *pill, } value = getter(msg, offset, len); - if (value == NULL) { + if (!value) { DEBUG_REQ(D_ERROR, pill->rc_req, "Wrong buffer for field `%s' (%d of %d) in format `%s': %d vs. %d (%s)\n", field->rmf_name, offset, lustre_msg_bufcount(msg), @@ -2209,7 +2123,7 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt) const struct req_format *old; - LASSERT(pill->rc_fmt != NULL); + LASSERT(pill->rc_fmt); LASSERT(__req_format_is_sane(fmt)); old = pill->rc_fmt; @@ -2222,7 +2136,7 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt) const struct req_msg_field *ofield = FMT_FIELD(old, i, j); /* "opaque" fields can be transmogrified */ - if (ofield->rmf_swabber == NULL && + if (!ofield->rmf_swabber && (ofield->rmf_flags & ~RMF_F_NO_SIZE_CHECK) == 0 && (ofield->rmf_size == -1 || ofield->rmf_flags == RMF_F_NO_SIZE_CHECK)) @@ -2289,7 +2203,7 @@ void req_capsule_shrink(struct req_capsule *pill, int offset; fmt = pill->rc_fmt; - LASSERT(fmt != NULL); + LASSERT(fmt); LASSERT(__req_format_is_sane(fmt)); LASSERT(req_capsule_has_field(pill, field, loc)); LASSERT(req_capsule_field_present(pill, field, loc)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index e877020..a23ac5f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -75,7 +75,8 @@ } while (0) /* This is a callback from the llog_* functions. - * Assumes caller has already pushed us into the kernel context. */ + * Assumes caller has already pushed us into the kernel context. + */ static int llog_client_open(const struct lu_env *env, struct llog_handle *lgh, struct llog_logid *logid, char *name, enum llog_open_param open_param) @@ -93,7 +94,7 @@ static int llog_client_open(const struct lu_env *env, LASSERT(lgh); req = ptlrpc_request_alloc(imp, &RQF_LLOG_ORIGIN_HANDLE_CREATE); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -130,7 +131,7 @@ static int llog_client_open(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); - if (body == NULL) { + if (!body) { rc = -EFAULT; goto out; } @@ -158,7 +159,7 @@ static int llog_client_next_block(const struct lu_env *env, req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, LUSTRE_LOG_VERSION, LLOG_ORIGIN_HANDLE_NEXT_BLOCK); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto err_exit; } @@ -179,14 +180,14 @@ static int llog_client_next_block(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); - if (body == NULL) { + if (!body) { rc = -EFAULT; goto out; } /* The log records are swabbed as they are processed */ ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA); - if (ptr == NULL) { + if (!ptr) { rc = -EFAULT; goto out; } @@ -216,7 +217,7 @@ static int llog_client_prev_block(const struct lu_env *env, req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK, LUSTRE_LOG_VERSION, LLOG_ORIGIN_HANDLE_PREV_BLOCK); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto err_exit; } @@ -236,13 +237,13 @@ static int llog_client_prev_block(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); - if (body == NULL) { + if (!body) { rc = -EFAULT; goto out; } ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA); - if (ptr == NULL) { + if (!ptr) { rc = -EFAULT; goto out; } @@ -269,7 +270,7 @@ static int llog_client_read_header(const struct lu_env *env, req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER, LUSTRE_LOG_VERSION, LLOG_ORIGIN_HANDLE_READ_HEADER); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto err_exit; } @@ -285,7 +286,7 @@ static int llog_client_read_header(const struct lu_env *env, goto out; hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR); - if (hdr == NULL) { + if (!hdr) { rc = -EFAULT; goto out; } @@ -316,8 +317,9 @@ static int llog_client_close(const struct lu_env *env, struct llog_handle *handle) { /* this doesn't call LLOG_ORIGIN_HANDLE_CLOSE because - the servers all close the file at the end of every - other LLOG_ RPC. */ + * the servers all close the file at the end of every + * other LLOG_ RPC. + */ return 0; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index dac66f5..fbccb62 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -58,7 +58,7 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) LASSERT(ctxt); new_imp = ctxt->loc_obd->u.cli.cl_import; - LASSERTF(ctxt->loc_imp == NULL || ctxt->loc_imp == new_imp, + LASSERTF(!ctxt->loc_imp || ctxt->loc_imp == new_imp, "%p - %p\n", ctxt->loc_imp, new_imp); mutex_lock(&ctxt->loc_mutex); if (ctxt->loc_imp != new_imp) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index cc55b79..fcaa289 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -131,7 +131,6 @@ static struct ll_rpc_opcode { { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" }, { SEC_CTX_FINI, "sec_ctx_fini" }, { FLD_QUERY, "fld_query" }, - { UPDATE_OBJ, "update_obj" }, }; static struct ll_eopcode { @@ -192,15 +191,15 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV; - LASSERT(*debugfs_root_ret == NULL); - LASSERT(*stats_ret == NULL); + LASSERT(!*debugfs_root_ret); + LASSERT(!*stats_ret); svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES, 0); - if (svc_stats == NULL) + if (!svc_stats) return; - if (dir != NULL) { + if (dir) { svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL); if (IS_ERR(svc_debugfs_entry)) { lprocfs_free_stats(&svc_stats); @@ -246,11 +245,11 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); if (rc < 0) { - if (dir != NULL) + if (dir) ldebugfs_remove(&svc_debugfs_entry); lprocfs_free_stats(&svc_stats); } else { - if (dir != NULL) + if (dir) *debugfs_root_ret = svc_debugfs_entry; *stats_ret = svc_stats; } @@ -307,7 +306,8 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, /* This sanity check is more of an insanity check; we can still * hose a kernel by allowing the request history to grow too - * far. */ + * far. + */ bufpages = (svc->srv_buf_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; if (val > totalram_pages / (2 * bufpages)) return -ERANGE; @@ -456,8 +456,6 @@ static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state) static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, struct ptlrpc_nrs_pol_info *info) { - LASSERT(policy != NULL); - LASSERT(info != NULL); assert_spin_locked(&policy->pol_nrs->nrs_lock); memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX); @@ -508,7 +506,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) spin_unlock(&nrs->nrs_lock); infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS); - if (infos == NULL) { + if (!infos) { rc = -ENOMEM; goto unlock; } @@ -676,7 +674,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, /** * No [reg|hp] token has been specified */ - if (cmd == NULL) + if (!cmd) goto default_queue; /** @@ -733,15 +731,15 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, struct list_head *e; struct ptlrpc_request *req; - if (srhi->srhi_req != NULL && - srhi->srhi_seq > svcpt->scp_hist_seq_culled && + if (srhi->srhi_req && srhi->srhi_seq > svcpt->scp_hist_seq_culled && srhi->srhi_seq <= seq) { /* If srhi_req was set previously, hasn't been culled and * we're searching for a seq on or after it (i.e. more * recent), search from it onwards. * Since the service history is LRU (i.e. culled reqs will * be near the head), we shouldn't have to do long - * re-scans */ + * re-scans + */ LASSERTF(srhi->srhi_seq == srhi->srhi_req->rq_history_seq, "%s:%d: seek seq %llu, request seq %llu\n", svcpt->scp_service->srv_name, svcpt->scp_cpt, @@ -919,7 +917,8 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) * here. The request could contain any old crap, so you * must be just as careful as the service's request * parser. Currently I only print stuff here I know is OK - * to look at coz it was set up in request_in_callback()!!! */ + * to look at coz it was set up in request_in_callback()!!! + */ seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld:%lds(%+lds) ", req->rq_history_seq, nidstr, libcfs_id2str(req->rq_peer), req->rq_xid, @@ -927,7 +926,7 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) (s64)req->rq_arrival_time.tv_sec, (long)(req->rq_sent - req->rq_arrival_time.tv_sec), (long)(req->rq_sent - req->rq_deadline)); - if (svc->srv_ops.so_req_printer == NULL) + if (!svc->srv_ops.so_req_printer) seq_putc(s, '\n'); else svc->srv_ops.so_req_printer(s, srhi->srhi_req); @@ -1103,7 +1102,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, "stats", &svc->srv_debugfs_entry, &svc->srv_stats); - if (svc->srv_debugfs_entry == NULL) + if (IS_ERR_OR_NULL(svc->srv_debugfs_entry)) return; ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL); @@ -1129,7 +1128,7 @@ void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount) int opc = opcode_offset(op); svc_stats = req->rq_import->imp_obd->obd_svc_stats; - if (svc_stats == NULL || opc <= 0) + if (!svc_stats || opc <= 0) return; LASSERT(opc < LUSTRE_MAX_OPCODES); if (!(op == LDLM_ENQUEUE || op == MDS_REINT)) @@ -1166,7 +1165,7 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) { - if (svc->srv_debugfs_entry != NULL) + if (!IS_ERR_OR_NULL(svc->srv_debugfs_entry)) ldebugfs_remove(&svc->srv_debugfs_entry); if (svc->srv_stats) @@ -1198,7 +1197,7 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, req = ptlrpc_prep_ping(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); - if (req == NULL) + if (!req) return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index c5d7ff5..c5bbf7b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -56,7 +56,6 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, lnet_md_t md; LASSERT(portal != 0); - LASSERT(conn != NULL); CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer)); md.start = base; md.length = len; @@ -88,7 +87,8 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, int rc2; /* We're going to get an UNLINK event when I unlink below, * which will complete just like any other failed send, so - * I fall through and return success here! */ + * I fall through and return success here! + */ CERROR("LNetPut(%s, %d, %lld) failed: %d\n", libcfs_id2str(conn->c_peer), portal, xid, rc); rc2 = LNetMDUnlink(*mdh); @@ -130,7 +130,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) LASSERT(desc->bd_md_count == 0); LASSERT(desc->bd_md_max_brw <= PTLRPC_BULK_OPS_COUNT); LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES); - LASSERT(desc->bd_req != NULL); + LASSERT(desc->bd_req); LASSERT(desc->bd_type == BULK_PUT_SINK || desc->bd_type == BULK_GET_SOURCE); @@ -153,7 +153,8 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) * using the same RDMA match bits after an error. * * For multi-bulk RPCs, rq_xid is the last XID needed for bulks. The - * first bulk XID is power-of-two aligned before rq_xid. LU-1431 */ + * first bulk XID is power-of-two aligned before rq_xid. LU-1431 + */ xid = req->rq_xid & ~((__u64)desc->bd_md_max_brw - 1); LASSERTF(!(desc->bd_registered && req->rq_send_state != LUSTRE_IMP_REPLAY) || @@ -209,7 +210,8 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) } /* Set rq_xid to matchbits of the final bulk so that server can - * infer the number of bulks that were prepared */ + * infer the number of bulks that were prepared + */ req->rq_xid = --xid; LASSERTF(desc->bd_last_xid == (req->rq_xid & PTLRPC_BULK_OPS_MASK), "bd_last_xid = x%llu, rq_xid = x%llu\n", @@ -260,7 +262,8 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* the unlink ensures the callback happens ASAP and is the last * one. If it fails, it must be because completion just happened, * but we must still l_wait_event() in this case to give liblustre - * a chance to run client_bulk_callback() */ + * a chance to run client_bulk_callback() + */ mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ @@ -273,14 +276,15 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) if (async) return 0; - if (req->rq_set != NULL) + if (req->rq_set) wq = &req->rq_set->set_waitq; else wq = &req->rq_reply_waitq; for (;;) { /* Network access will complete in finite time but the HUGE - * timeout lets us CWARN for visibility of sluggish NALs */ + * timeout lets us CWARN for visibility of sluggish LNDs + */ lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK), cfs_time_seconds(1), NULL, NULL); rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi); @@ -305,13 +309,13 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) req->rq_arrival_time.tv_sec, 1); if (!(flags & PTLRPC_REPLY_EARLY) && - (req->rq_type != PTL_RPC_MSG_ERR) && - (req->rq_reqmsg != NULL) && + (req->rq_type != PTL_RPC_MSG_ERR) && req->rq_reqmsg && !(lustre_msg_get_flags(req->rq_reqmsg) & (MSG_RESENT | MSG_REPLAY | MSG_REQ_REPLAY_DONE | MSG_LOCK_REPLAY_DONE))) { /* early replies, errors and recovery requests don't count - * toward our service time estimate */ + * toward our service time estimate + */ int oldse = at_measured(&svcpt->scp_at_estimate, service_time); if (oldse != 0) { @@ -325,7 +329,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) lustre_msg_set_service_time(req->rq_repmsg, service_time); /* Report service time estimate for future client reqs, but report 0 * (to be ignored by client) if it's a error reply during recovery. - * (bz15815) */ + * (bz15815) + */ if (req->rq_type == PTL_RPC_MSG_ERR && !req->rq_export) lustre_msg_set_timeout(req->rq_repmsg, 0); else @@ -360,10 +365,10 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) * target_queue_final_reply(). */ LASSERT(req->rq_no_reply == 0); - LASSERT(req->rq_reqbuf != NULL); - LASSERT(rs != NULL); + LASSERT(req->rq_reqbuf); + LASSERT(rs); LASSERT((flags & PTLRPC_REPLY_MAYBE_DIFFICULT) || !rs->rs_difficult); - LASSERT(req->rq_repmsg != NULL); + LASSERT(req->rq_repmsg); LASSERT(req->rq_repmsg == rs->rs_msg); LASSERT(rs->rs_cb_id.cbid_fn == reply_out_callback); LASSERT(rs->rs_cb_id.cbid_arg == rs); @@ -403,12 +408,12 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) ptlrpc_at_set_reply(req, flags); - if (req->rq_export == NULL || req->rq_export->exp_connection == NULL) + if (!req->rq_export || !req->rq_export->exp_connection) conn = ptlrpc_connection_get(req->rq_peer, req->rq_self, NULL); else conn = ptlrpc_connection_addref(req->rq_export->exp_connection); - if (unlikely(conn == NULL)) { + if (unlikely(!conn)) { CERROR("not replying on NULL connection\n"); /* bug 9635 */ return -ENOTCONN; } @@ -498,12 +503,13 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) LASSERT(request->rq_wait_ctx == 0); /* If this is a re-transmit, we're required to have disengaged - * cleanly from the previous attempt */ + * cleanly from the previous attempt + */ LASSERT(!request->rq_receiving_reply); LASSERT(!((lustre_msg_get_flags(request->rq_reqmsg) & MSG_REPLAY) && (request->rq_import->imp_state == LUSTRE_IMP_FULL))); - if (unlikely(obd != NULL && obd->obd_fail)) { + if (unlikely(obd && obd->obd_fail)) { CDEBUG(D_HA, "muting rpc for failed imp obd %s\n", obd->obd_name); /* this prevents us from waiting in ptlrpc_queue_wait */ @@ -535,7 +541,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) goto out; /* bulk register should be done after wrap_request() */ - if (request->rq_bulk != NULL) { + if (request->rq_bulk) { rc = ptlrpc_register_bulk(request); if (rc != 0) goto out; @@ -543,14 +549,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) if (!noreply) { LASSERT(request->rq_replen != 0); - if (request->rq_repbuf == NULL) { - LASSERT(request->rq_repdata == NULL); - LASSERT(request->rq_repmsg == NULL); + if (!request->rq_repbuf) { + LASSERT(!request->rq_repdata); + LASSERT(!request->rq_repmsg); rc = sptlrpc_cli_alloc_repbuf(request, request->rq_replen); if (rc) { /* this prevents us from looping in - * ptlrpc_queue_wait */ + * ptlrpc_queue_wait + */ spin_lock(&request->rq_lock); request->rq_err = 1; spin_unlock(&request->rq_lock); @@ -602,7 +609,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) reply_md.eq_handle = ptlrpc_eq_h; /* We must see the unlink callback to unset rq_reply_unlink, - so we can't auto-unlink */ + * so we can't auto-unlink + */ rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN, &request->rq_reply_md_h); if (rc != 0) { @@ -623,7 +631,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* add references on request for request_out_callback */ ptlrpc_request_addref(request); - if (obd != NULL && obd->obd_svc_stats != NULL) + if (obd && obd->obd_svc_stats) lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQACTIVE_CNTR, atomic_read(&request->rq_import->imp_inflight)); @@ -632,7 +640,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) ktime_get_real_ts64(&request->rq_arrival_time); request->rq_sent = ktime_get_real_seconds(); /* We give the server rq_timeout secs to process the req, and - add the network latency for our local timeout. */ + * add the network latency for our local timeout. + */ request->rq_deadline = request->rq_sent + request->rq_timeout + ptlrpc_at_get_net_latency(request); @@ -656,7 +665,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) cleanup_me: /* MEUnlink is safe; the PUT didn't even get off the ground, and * nobody apart from the PUT's target has the right nid+XID to - * access the reply buffer. */ + * access the reply buffer. + */ rc2 = LNetMEUnlink(reply_me_h); LASSERT(rc2 == 0); /* UNLINKED callback called synchronously */ @@ -664,7 +674,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) cleanup_bulk: /* We do sync unlink here as there was no real transfer here so - * the chance to have long unlink to sluggish net is smaller here. */ + * the chance to have long unlink to sluggish net is smaller here. + */ ptlrpc_unregister_bulk(request, 0); out: if (request->rq_memalloc) @@ -692,7 +703,8 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) /* NB: CPT affinity service should use new LNet flag LNET_INS_LOCAL, * which means buffer can only be attached on local CPT, and LND - * threads can find it by grabbing a local lock */ + * threads can find it by grabbing a local lock + */ rc = LNetMEAttach(service->srv_req_portal, match_id, 0, ~0, LNET_UNLINK, rqbd->rqbd_svcpt->scp_cpt >= 0 ? diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 57acf8c..58e5d86 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -47,9 +43,6 @@ #include "../../include/linux/libcfs/libcfs.h" #include "ptlrpc_internal.h" -/* XXX: This is just for liblustre. Remove the #if defined directive when the - * "cfs_" prefix is dropped from cfs_list_head. */ - /** * NRS core object. */ @@ -57,7 +50,7 @@ struct nrs_core nrs_core; static int nrs_policy_init(struct ptlrpc_nrs_policy *policy) { - return policy->pol_desc->pd_ops->op_policy_init != NULL ? + return policy->pol_desc->pd_ops->op_policy_init ? policy->pol_desc->pd_ops->op_policy_init(policy) : 0; } @@ -66,7 +59,7 @@ static void nrs_policy_fini(struct ptlrpc_nrs_policy *policy) LASSERT(policy->pol_ref == 0); LASSERT(policy->pol_req_queued == 0); - if (policy->pol_desc->pd_ops->op_policy_fini != NULL) + if (policy->pol_desc->pd_ops->op_policy_fini) policy->pol_desc->pd_ops->op_policy_fini(policy); } @@ -82,7 +75,7 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *policy, if (policy->pol_state == NRS_POL_STATE_STOPPED) return -ENODEV; - return policy->pol_desc->pd_ops->op_policy_ctl != NULL ? + return policy->pol_desc->pd_ops->op_policy_ctl ? policy->pol_desc->pd_ops->op_policy_ctl(policy, opc, arg) : -ENOSYS; } @@ -91,7 +84,7 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; - if (policy->pol_desc->pd_ops->op_policy_stop != NULL) { + if (policy->pol_desc->pd_ops->op_policy_stop) { spin_unlock(&nrs->nrs_lock); policy->pol_desc->pd_ops->op_policy_stop(policy); @@ -154,7 +147,7 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; - if (tmp == NULL) + if (!tmp) return; nrs->nrs_policy_primary = NULL; @@ -220,12 +213,12 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) * nrs_policy_flags::PTLRPC_NRS_FL_FALLBACK flag set can * register with NRS core. */ - LASSERT(nrs->nrs_policy_fallback == NULL); + LASSERT(!nrs->nrs_policy_fallback); } else { /** * Shouldn't start primary policy if w/o fallback policy. */ - if (nrs->nrs_policy_fallback == NULL) + if (!nrs->nrs_policy_fallback) return -EPERM; if (policy->pol_state == NRS_POL_STATE_STARTED) @@ -348,10 +341,10 @@ static void nrs_resource_put(struct ptlrpc_nrs_resource *res) { struct ptlrpc_nrs_policy *policy = res->res_policy; - if (policy->pol_desc->pd_ops->op_res_put != NULL) { + if (policy->pol_desc->pd_ops->op_res_put) { struct ptlrpc_nrs_resource *parent; - for (; res != NULL; res = parent) { + for (; res; res = parent) { parent = res->res_parent; policy->pol_desc->pd_ops->op_res_put(policy, res); } @@ -390,12 +383,11 @@ struct ptlrpc_nrs_resource *nrs_resource_get(struct ptlrpc_nrs_policy *policy, rc = policy->pol_desc->pd_ops->op_res_get(policy, nrq, res, &tmp, moving_req); if (rc < 0) { - if (res != NULL) + if (res) nrs_resource_put(res); return NULL; } - LASSERT(tmp != NULL); tmp->res_parent = res; tmp->res_policy = policy; res = tmp; @@ -445,7 +437,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, nrs_policy_get_locked(fallback); primary = nrs->nrs_policy_primary; - if (primary != NULL) + if (primary) nrs_policy_get_locked(primary); spin_unlock(&nrs->nrs_lock); @@ -454,9 +446,9 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * Obtain resource hierarchy references. */ resp[NRS_RES_FALLBACK] = nrs_resource_get(fallback, nrq, moving_req); - LASSERT(resp[NRS_RES_FALLBACK] != NULL); + LASSERT(resp[NRS_RES_FALLBACK]); - if (primary != NULL) { + if (primary) { resp[NRS_RES_PRIMARY] = nrs_resource_get(primary, nrq, moving_req); /** @@ -465,7 +457,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * reference on the policy as it will not be used for this * request. */ - if (resp[NRS_RES_PRIMARY] == NULL) + if (!resp[NRS_RES_PRIMARY]) nrs_policy_put(primary); } } @@ -485,7 +477,7 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) int i; for (i = 0; i < NRS_RES_MAX; i++) { - if (resp[i] != NULL) { + if (resp[i]) { pols[i] = resp[i]->res_policy; nrs_resource_put(resp[i]); resp[i] = NULL; @@ -526,7 +518,7 @@ struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, nrq = policy->pol_desc->pd_ops->op_req_get(policy, peek, force); - LASSERT(ergo(nrq != NULL, nrs_request_policy(nrq) == policy)); + LASSERT(ergo(nrq, nrs_request_policy(nrq) == policy)); return nrq; } @@ -552,7 +544,7 @@ static inline void nrs_request_enqueue(struct ptlrpc_nrs_request *nrq) * the preferred choice. */ for (i = NRS_RES_MAX - 1; i >= 0; i--) { - if (nrq->nr_res_ptrs[i] == NULL) + if (!nrq->nr_res_ptrs[i]) continue; nrq->nr_res_idx = i; @@ -622,7 +614,7 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, spin_lock(&nrs->nrs_lock); policy = nrs_policy_find_locked(nrs, name); - if (policy == NULL) { + if (!policy) { rc = -ENOENT; goto out; } @@ -644,7 +636,7 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, break; } out: - if (policy != NULL) + if (policy) nrs_policy_put_locked(policy); spin_unlock(&nrs->nrs_lock); @@ -669,7 +661,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) spin_lock(&nrs->nrs_lock); policy = nrs_policy_find_locked(nrs, name); - if (policy == NULL) { + if (!policy) { spin_unlock(&nrs->nrs_lock); CERROR("Can't find NRS policy %s\n", name); @@ -702,7 +694,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_fini(policy); - LASSERT(policy->pol_private == NULL); + LASSERT(!policy->pol_private); kfree(policy); return 0; @@ -726,18 +718,16 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; int rc; - LASSERT(svcpt != NULL); - LASSERT(desc->pd_ops != NULL); - LASSERT(desc->pd_ops->op_res_get != NULL); - LASSERT(desc->pd_ops->op_req_get != NULL); - LASSERT(desc->pd_ops->op_req_enqueue != NULL); - LASSERT(desc->pd_ops->op_req_dequeue != NULL); - LASSERT(desc->pd_compat != NULL); + LASSERT(desc->pd_ops->op_res_get); + LASSERT(desc->pd_ops->op_req_get); + LASSERT(desc->pd_ops->op_req_enqueue); + LASSERT(desc->pd_ops->op_req_dequeue); + LASSERT(desc->pd_compat); policy = kzalloc_node(sizeof(*policy), GFP_NOFS, cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, svcpt->scp_cpt)); - if (policy == NULL) + if (!policy) return -ENOMEM; policy->pol_nrs = nrs; @@ -757,7 +747,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, spin_lock(&nrs->nrs_lock); tmp = nrs_policy_find_locked(nrs, policy->pol_desc->pd_name); - if (tmp != NULL) { + if (tmp) { CERROR("NRS policy %s has been registered, can't register it for %s\n", policy->pol_desc->pd_name, svcpt->scp_service->srv_name); @@ -947,14 +937,14 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) /** * Optionally allocate a high-priority NRS head. */ - if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL) + if (!svcpt->scp_service->srv_ops.so_hpreq_handler) goto out; svcpt->scp_nrs_hp = kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS, cfs_cpt_spread_node(svcpt->scp_service->srv_cptable, svcpt->scp_cpt)); - if (svcpt->scp_nrs_hp == NULL) { + if (!svcpt->scp_nrs_hp) { rc = -ENOMEM; goto out; } @@ -1079,7 +1069,7 @@ again: } } - if (desc->pd_ops->op_lprocfs_fini != NULL) + if (desc->pd_ops->op_lprocfs_fini) desc->pd_ops->op_lprocfs_fini(svc); } @@ -1107,13 +1097,12 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) struct ptlrpc_nrs_pol_desc *desc; int rc = 0; - LASSERT(conf != NULL); - LASSERT(conf->nc_ops != NULL); - LASSERT(conf->nc_compat != NULL); + LASSERT(conf->nc_ops); + LASSERT(conf->nc_compat); LASSERT(ergo(conf->nc_compat == nrs_policy_compat_one, - conf->nc_compat_svc_name != NULL)); + conf->nc_compat_svc_name)); LASSERT(ergo((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0, - conf->nc_owner != NULL)); + conf->nc_owner)); conf->nc_name[NRS_POL_NAME_MAX - 1] = '\0'; @@ -1136,7 +1125,7 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) mutex_lock(&nrs_core.nrs_mutex); - if (nrs_policy_find_desc_locked(conf->nc_name) != NULL) { + if (nrs_policy_find_desc_locked(conf->nc_name)) { CERROR("NRS: failing to register policy %s which has already been registered with NRS core!\n", conf->nc_name); rc = -EEXIST; @@ -1214,7 +1203,7 @@ again: * No need to take a reference to other modules here, as we * will be calling from the module's init() function. */ - if (desc->pd_ops->op_lprocfs_init != NULL) { + if (desc->pd_ops->op_lprocfs_init) { rc = desc->pd_ops->op_lprocfs_init(svc); if (rc != 0) { rc2 = nrs_policy_unregister_locked(desc); @@ -1278,7 +1267,7 @@ int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc) if (!nrs_policy_compatible(svc, desc)) continue; - if (desc->pd_ops->op_lprocfs_init != NULL) { + if (desc->pd_ops->op_lprocfs_init) { rc = desc->pd_ops->op_lprocfs_init(svc); if (rc != 0) goto failed; @@ -1319,7 +1308,7 @@ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) if (!nrs_policy_compatible(svc, desc)) continue; - if (desc->pd_ops->op_lprocfs_fini != NULL) + if (desc->pd_ops->op_lprocfs_fini) desc->pd_ops->op_lprocfs_fini(svc); } @@ -1366,7 +1355,8 @@ void ptlrpc_nrs_req_finalize(struct ptlrpc_request *req) if (req->rq_nrq.nr_initialized) { nrs_resource_put_safe(req->rq_nrq.nr_res_ptrs); /* no protection on bit nr_initialized because no - * contention at this late stage */ + * contention at this late stage + */ req->rq_nrq.nr_finalized = 1; } } @@ -1459,7 +1449,7 @@ ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp, list_for_each_entry(policy, &nrs->nrs_policy_queued, pol_list_queued) { nrq = nrs_request_get(policy, peek, force); - if (nrq != NULL) { + if (nrq) { if (likely(!peek)) { nrq->nr_started = 1; diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 8e21f0c..0d8da35 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -83,7 +79,7 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy) head = kzalloc_node(sizeof(*head), GFP_NOFS, cfs_cpt_spread_node(nrs_pol2cptab(policy), nrs_pol2cptid(policy))); - if (head == NULL) + if (!head) return -ENOMEM; INIT_LIST_HEAD(&head->fh_list); @@ -104,7 +100,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy) { struct nrs_fifo_head *head = policy->pol_private; - LASSERT(head != NULL); + LASSERT(head); LASSERT(list_empty(&head->fh_list)); kfree(head); @@ -169,7 +165,7 @@ struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, list_entry(head->fh_list.next, struct ptlrpc_nrs_request, nr_u.fifo.fr_list); - if (likely(!peek && nrq != NULL)) { + if (likely(!peek && nrq)) { struct ptlrpc_request *req = container_of(nrq, struct ptlrpc_request, rq_nrq); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index f3cb518..f3ac810 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -133,7 +133,8 @@ EXPORT_SYMBOL(lustre_msg_size_v2); * NOTE: this should only be used for NEW requests, and should always be * in the form of a v2 request. If this is a connection to a v1 * target then the first buffer will be stripped because the ptlrpc - * data is part of the lustre_msg_v1 header. b=14043 */ + * data is part of the lustre_msg_v1 header. b=14043 + */ int lustre_msg_size(__u32 magic, int count, __u32 *lens) { __u32 size[] = { sizeof(struct ptlrpc_body) }; @@ -157,7 +158,8 @@ int lustre_msg_size(__u32 magic, int count, __u32 *lens) EXPORT_SYMBOL(lustre_msg_size); /* This is used to determine the size of a buffer that was already packed - * and will correctly handle the different message formats. */ + * and will correctly handle the different message formats. + */ int lustre_packed_msg_size(struct lustre_msg *msg) { switch (msg->lm_magic) { @@ -183,7 +185,7 @@ void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens, for (i = 0; i < count; i++) msg->lm_buflens[i] = lens[i]; - if (bufs == NULL) + if (!bufs) return; ptr = (char *)msg + lustre_msg_hdr_size_v2(count); @@ -267,7 +269,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_rep_lock); /* If we cannot get anything for some long time, we better - * bail out instead of waiting infinitely */ + * bail out instead of waiting infinitely + */ lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL); rc = l_wait_event(svcpt->scp_rep_waitq, !list_empty(&svcpt->scp_rep_idle), &lwi); @@ -306,7 +309,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, struct ptlrpc_reply_state *rs; int msg_len, rc; - LASSERT(req->rq_reply_state == NULL); + LASSERT(!req->rq_reply_state); if ((flags & LPRFL_EARLY_REPLY) == 0) { spin_lock(&req->rq_lock); @@ -383,7 +386,6 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size) { int i, offset, buflen, bufcount; - LASSERT(m != NULL); LASSERT(n >= 0); bufcount = m->lm_bufcount; @@ -488,7 +490,7 @@ void lustre_free_reply_state(struct ptlrpc_reply_state *rs) LASSERT(!rs->rs_difficult || rs->rs_handled); LASSERT(!rs->rs_on_net); LASSERT(!rs->rs_scheduled); - LASSERT(rs->rs_export == NULL); + LASSERT(!rs->rs_export); LASSERT(rs->rs_nlocks == 0); LASSERT(list_empty(&rs->rs_exp_list)); LASSERT(list_empty(&rs->rs_obd_list)); @@ -677,7 +679,8 @@ int lustre_msg_buflen(struct lustre_msg *m, int n) EXPORT_SYMBOL(lustre_msg_buflen); /* NB return the bufcount for lustre_msg_v2 format, so if message is packed - * in V1 format, the result is one bigger. (add struct ptlrpc_body). */ + * in V1 format, the result is one bigger. (add struct ptlrpc_body). + */ int lustre_msg_bufcount(struct lustre_msg *m) { switch (m->lm_magic) { @@ -705,7 +708,7 @@ char *lustre_msg_string(struct lustre_msg *m, int index, int max_len) LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic); } - if (str == NULL) { + if (!str) { CERROR("can't unpack string in msg %p buffer[%d]\n", m, index); return NULL; } @@ -740,7 +743,6 @@ static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index, { void *ptr = NULL; - LASSERT(msg != NULL); switch (msg->lm_magic) { case LUSTRE_MSG_MAGIC_V2: ptr = lustre_msg_buf_v2(msg, index, min_size); @@ -799,7 +801,8 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg) /* no break */ default: /* flags might be printed in debug code while message - * uninitialized */ + * uninitialized + */ return 0; } } @@ -1032,7 +1035,8 @@ int lustre_msg_get_status(struct lustre_msg *msg) /* no break */ default: /* status might be printed in debug code while message - * uninitialized */ + * uninitialized + */ return -EINVAL; } } @@ -1368,7 +1372,8 @@ void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) struct ptlrpc_body *pb; /* Don't set jobid for ldlm ast RPCs, they've been shrunk. - * See the comment in ptlrpc_request_pack(). */ + * See the comment in ptlrpc_request_pack(). + */ if (!opc || opc == LDLM_BL_CALLBACK || opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK) return; @@ -1377,7 +1382,7 @@ void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) sizeof(struct ptlrpc_body)); LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); - if (jobid != NULL) + if (jobid) memcpy(pb->pb_jobid, jobid, JOBSTATS_JOBID_SIZE); else if (pb->pb_jobid[0] == '\0') lustre_get_jobid(pb->pb_jobid); @@ -1427,7 +1432,7 @@ int do_set_info_async(struct obd_import *imp, int rc; req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); - if (req == NULL) + if (!req) return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, @@ -1488,7 +1493,8 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) * clients and servers without ptlrpc_body_v2 (< 2.3) * do not swab any fields beyond pb_jobid, as we are * using this swab function for both ptlrpc_body - * and ptlrpc_body_v2. */ + * and ptlrpc_body_v2. + */ CLASSERT(offsetof(typeof(*b), pb_jobid) != 0); } EXPORT_SYMBOL(lustre_swab_ptlrpc_body); @@ -1502,7 +1508,8 @@ void lustre_swab_connect(struct obd_connect_data *ocd) __swab32s(&ocd->ocd_index); __swab32s(&ocd->ocd_brw_size); /* ocd_blocksize and ocd_inodespace don't need to be swabbed because - * they are 8-byte values */ + * they are 8-byte values + */ __swab16s(&ocd->ocd_grant_extent); __swab32s(&ocd->ocd_unused); __swab64s(&ocd->ocd_transno); @@ -1512,7 +1519,8 @@ void lustre_swab_connect(struct obd_connect_data *ocd) /* Fields after ocd_cksum_types are only accessible by the receiver * if the corresponding flag in ocd_connect_flags is set. Accessing * any field after ocd_maxbytes on the receiver without a valid flag - * may result in out-of-bound memory access and kernel oops. */ + * may result in out-of-bound memory access and kernel oops. + */ if (ocd->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE) __swab32s(&ocd->ocd_max_easize); if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES) @@ -1848,20 +1856,6 @@ void lustre_swab_fiemap(struct ll_user_fiemap *fiemap) } EXPORT_SYMBOL(lustre_swab_fiemap); -void lustre_swab_idx_info(struct idx_info *ii) -{ - __swab32s(&ii->ii_magic); - __swab32s(&ii->ii_flags); - __swab16s(&ii->ii_count); - __swab32s(&ii->ii_attrs); - lustre_swab_lu_fid(&ii->ii_fid); - __swab64s(&ii->ii_version); - __swab64s(&ii->ii_hash_start); - __swab64s(&ii->ii_hash_end); - __swab16s(&ii->ii_keysize); - __swab16s(&ii->ii_recsize); -} - void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) { __swab32s(&rr->rr_opcode); @@ -1986,7 +1980,8 @@ static void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d) { /* the lock data is a union and the first two fields are always an * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock - * data the same way. */ + * data the same way. + */ __swab64s(&d->l_extent.start); __swab64s(&d->l_extent.end); __swab64s(&d->l_extent.gid); @@ -2035,16 +2030,6 @@ void lustre_swab_ldlm_reply(struct ldlm_reply *r) } EXPORT_SYMBOL(lustre_swab_ldlm_reply); -void lustre_swab_quota_body(struct quota_body *b) -{ - lustre_swab_lu_fid(&b->qb_fid); - lustre_swab_lu_fid((struct lu_fid *)&b->qb_id); - __swab32s(&b->qb_flags); - __swab64s(&b->qb_count); - __swab64s(&b->qb_usage); - __swab64s(&b->qb_slv_ver); -} - /* Dump functions */ void dump_ioo(struct obd_ioobj *ioo) { @@ -2288,24 +2273,6 @@ void lustre_swab_hsm_request(struct hsm_request *hr) } EXPORT_SYMBOL(lustre_swab_hsm_request); -void lustre_swab_update_buf(struct update_buf *ub) -{ - __swab32s(&ub->ub_magic); - __swab32s(&ub->ub_count); -} -EXPORT_SYMBOL(lustre_swab_update_buf); - -void lustre_swab_update_reply_buf(struct update_reply *ur) -{ - int i; - - __swab32s(&ur->ur_version); - __swab32s(&ur->ur_count); - for (i = 0; i < ur->ur_count; i++) - __swab32s(&ur->ur_lens[i]); -} -EXPORT_SYMBOL(lustre_swab_update_reply_buf); - void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl) { __swab64s(&msl->msl_flags); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index fb2d523..44bf026 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -68,7 +68,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) struct ptlrpc_request *req; req = ptlrpc_prep_ping(obd->u.cli.cl_import); - if (req == NULL) + if (!req) return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; @@ -86,7 +86,7 @@ static int ptlrpc_ping(struct obd_import *imp) struct ptlrpc_request *req; req = ptlrpc_prep_ping(imp); - if (req == NULL) { + if (!req) { CERROR("OOM trying to ping %s->%s\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd)); @@ -257,11 +257,12 @@ static int ptlrpc_pinger_main(void *arg) /* Wait until the next ping time, or until we're stopped. */ time_to_next_wake = pinger_check_timeout(this_ping); /* The ping sent by ptlrpc_send_rpc may get sent out - say .01 second after this. - ptlrpc_pinger_sending_on_import will then set the - next ping time to next_ping + .01 sec, which means - we will SKIP the next ping at next_ping, and the - ping will get sent 2 timeouts from now! Beware. */ + * say .01 second after this. + * ptlrpc_pinger_sending_on_import will then set the + * next ping time to next_ping + .01 sec, which means + * we will SKIP the next ping at next_ping, and the + * ping will get sent 2 timeouts from now! Beware. + */ CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n", time_to_next_wake, cfs_time_add(this_ping, @@ -293,6 +294,7 @@ static struct ptlrpc_thread pinger_thread; int ptlrpc_start_pinger(void) { struct l_wait_info lwi = { 0 }; + struct task_struct *task; int rc; if (!thread_is_init(&pinger_thread) && @@ -303,10 +305,11 @@ int ptlrpc_start_pinger(void) strcpy(pinger_thread.t_name, "ll_ping"); - rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread, - "%s", pinger_thread.t_name)); - if (IS_ERR_VALUE(rc)) { - CERROR("cannot start thread: %d\n", rc); + task = kthread_run(ptlrpc_pinger_main, &pinger_thread, + pinger_thread.t_name); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("cannot start pinger thread: rc = %d\n", rc); return rc; } l_wait_event(pinger_thread.t_ctl_waitq, @@ -489,7 +492,6 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, break; } } - LASSERTF(ti != NULL, "ti is NULL !\n"); if (list_empty(&ti->ti_obd_list)) { list_del(&ti->ti_chain); kfree(ti); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 8f67e05..6ca26c9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -101,8 +101,6 @@ struct nrs_core { * registration/unregistration, and NRS core lprocfs operations. */ struct mutex nrs_mutex; - /* XXX: This is just for liblustre. Remove the #if defined directive - * when the * "cfs_" prefix is dropped from cfs_list_head. */ /** * List of all policy descriptors registered with NRS core; protected * by nrs_core::nrs_mutex. diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 60fb0ce..0c36663 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -163,8 +163,6 @@ void ptlrpcd_wake(struct ptlrpc_request *req) { struct ptlrpc_request_set *rq_set = req->rq_set; - LASSERT(rq_set != NULL); - wake_up(&rq_set->set_waitq); } EXPORT_SYMBOL(ptlrpcd_wake); @@ -176,7 +174,7 @@ ptlrpcd_select_pc(struct ptlrpc_request *req) int cpt; int idx; - if (req != NULL && req->rq_send_state != LUSTRE_IMP_FULL) + if (req && req->rq_send_state != LUSTRE_IMP_FULL) return &ptlrpcd_rcv; cpt = cfs_cpt_current(cfs_cpt_table, 1); @@ -240,10 +238,11 @@ void ptlrpcd_add_req(struct ptlrpc_request *req) req->rq_invalid_rqset = 0; spin_unlock(&req->rq_lock); - l_wait_event(req->rq_set_waitq, (req->rq_set == NULL), &lwi); + l_wait_event(req->rq_set_waitq, !req->rq_set, &lwi); } else if (req->rq_set) { /* If we have a valid "rq_set", just reuse it to avoid double - * linked. */ + * linked. + */ LASSERT(req->rq_phase == RQ_PHASE_NEW); LASSERT(req->rq_send_state == LUSTRE_IMP_REPLAY); @@ -321,7 +320,8 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) rc |= ptlrpc_check_set(env, set); /* NB: ptlrpc_check_set has already moved completed request at the - * head of seq::set_requests */ + * head of seq::set_requests + */ list_for_each_safe(pos, tmp, &set->set_requests) { req = list_entry(pos, struct ptlrpc_request, rq_set_chain); if (req->rq_phase != RQ_PHASE_COMPLETE) @@ -339,7 +339,8 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) rc = atomic_read(&set->set_new_count); /* If we have nothing to do, check whether we can take some - * work from our partner threads. */ + * work from our partner threads. + */ if (rc == 0 && pc->pc_npartners > 0) { struct ptlrpcd_ctl *partner; struct ptlrpc_request_set *ps; @@ -349,12 +350,12 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) partner = pc->pc_partners[pc->pc_cursor++]; if (pc->pc_cursor >= pc->pc_npartners) pc->pc_cursor = 0; - if (partner == NULL) + if (!partner) continue; spin_lock(&partner->pc_lock); ps = partner->pc_set; - if (ps == NULL) { + if (!ps) { spin_unlock(&partner->pc_lock); continue; } @@ -580,7 +581,7 @@ int ptlrpcd_start(struct ptlrpcd_ctl *pc) return 0; out_set: - if (pc->pc_set != NULL) { + if (pc->pc_set) { struct ptlrpc_request_set *set = pc->pc_set; spin_lock(&pc->pc_lock); @@ -631,7 +632,7 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) out: if (pc->pc_npartners > 0) { - LASSERT(pc->pc_partners != NULL); + LASSERT(pc->pc_partners); kfree(pc->pc_partners); pc->pc_partners = NULL; @@ -645,7 +646,7 @@ static void ptlrpcd_fini(void) int i; int j; - if (ptlrpcds != NULL) { + if (ptlrpcds) { for (i = 0; i < ptlrpcds_num; i++) { if (!ptlrpcds[i]) break; diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index db6626c..e5d344d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -114,7 +114,8 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) if (req->rq_transno > last_transno) { /* Since the imp_committed_list is immutable before * all of it's requests being replayed, it's safe to - * use a cursor to accelerate the search */ + * use a cursor to accelerate the search + */ imp->imp_replay_cursor = imp->imp_replay_cursor->next; while (imp->imp_replay_cursor != @@ -137,8 +138,9 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) } /* All the requests in committed list have been replayed, let's replay - * the imp_replay_list */ - if (req == NULL) { + * the imp_replay_list + */ + if (!req) { list_for_each_safe(tmp, pos, &imp->imp_replay_list) { req = list_entry(tmp, struct ptlrpc_request, rq_replay_list); @@ -152,15 +154,16 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) /* If need to resend the last sent transno (because a reconnect * has occurred), then stop on the matching req and send it again. * If, however, the last sent transno has been committed then we - * continue replay from the next request. */ - if (req != NULL && imp->imp_resend_replay) + * continue replay from the next request. + */ + if (req && imp->imp_resend_replay) lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT); spin_lock(&imp->imp_lock); imp->imp_resend_replay = 0; spin_unlock(&imp->imp_lock); - if (req != NULL) { + if (req) { rc = ptlrpc_replay_req(req); if (rc) { CERROR("recovery replay error %d for req %llu\n", @@ -249,7 +252,8 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) } /* Wait for recovery to complete and resend. If evicted, then - this request will be errored out later.*/ + * this request will be errored out later. + */ spin_lock(&failed_req->rq_lock); if (!failed_req->rq_no_resend) failed_req->rq_resend = 1; @@ -260,7 +264,7 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) * Administratively active/deactive a client. * This should only be called by the ioctl interface, currently * - the lctl deactivate and activate commands - * - echo 0/1 >> /proc/osc/XXX/active + * - echo 0/1 >> /sys/fs/lustre/osc/XXX/active * - client umount -f (ll_umount_begin) */ int ptlrpc_set_import_active(struct obd_import *imp, int active) @@ -271,13 +275,15 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) LASSERT(obd); /* When deactivating, mark import invalid, and abort in-flight - * requests. */ + * requests. + */ if (!active) { LCONSOLE_WARN("setting import %s INACTIVE by administrator request\n", obd2cli_tgt(imp->imp_obd)); /* set before invalidate to avoid messages about imp_inval - * set without imp_deactive in ptlrpc_import_delay_req */ + * set without imp_deactive in ptlrpc_import_delay_req + */ spin_lock(&imp->imp_lock); imp->imp_deactive = 1; spin_unlock(&imp->imp_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 39f5261..85f8f7c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -94,7 +94,7 @@ int sptlrpc_unregister_policy(struct ptlrpc_sec_policy *policy) LASSERT(number < SPTLRPC_POLICY_MAX); write_lock(&policy_lock); - if (unlikely(policies[number] == NULL)) { + if (unlikely(!policies[number])) { write_unlock(&policy_lock); CERROR("%s: already unregistered\n", policy->sp_name); return -EINVAL; @@ -126,11 +126,11 @@ struct ptlrpc_sec_policy *sptlrpc_wireflavor2policy(__u32 flavor) policy = policies[number]; if (policy && !try_module_get(policy->sp_owner)) policy = NULL; - if (policy == NULL) + if (!policy) flag = atomic_read(&loaded); read_unlock(&policy_lock); - if (policy != NULL || flag != 0 || + if (policy || flag != 0 || number != SPTLRPC_POLICY_GSS) break; @@ -327,7 +327,7 @@ static int import_sec_validate_get(struct obd_import *imp, } *sec = sptlrpc_import_sec_ref(imp); - if (*sec == NULL) { + if (!*sec) { CERROR("import %p (%s) with no sec\n", imp, ptlrpc_import_state_name(imp->imp_state)); return -EACCES; @@ -429,7 +429,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, reqmsg_size = req->rq_reqlen; if (reqmsg_size != 0) { reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS); - if (reqmsg == NULL) + if (!reqmsg) return -ENOMEM; memcpy(reqmsg, req->rq_reqmsg, reqmsg_size); } @@ -445,7 +445,8 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, /* alloc new request buffer * we don't need to alloc reply buffer here, leave it to the - * rest procedure of ptlrpc */ + * rest procedure of ptlrpc + */ if (reqmsg_size != 0) { rc = sptlrpc_cli_alloc_reqbuf(req, reqmsg_size); if (!rc) { @@ -798,7 +799,8 @@ void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode) spin_unlock(&sec->ps_lock); /* force SVC_NULL for context initiation rpc, SVC_INTG for context - * destruction rpc */ + * destruction rpc + */ if (unlikely(req->rq_ctx_init)) flvr_set_svc(&req->rq_flvr.sf_rpc, SPTLRPC_SVC_NULL); else if (unlikely(req->rq_ctx_fini)) @@ -938,7 +940,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) LASSERT(ctx->cc_sec); LASSERT(req->rq_repbuf); LASSERT(req->rq_repdata); - LASSERT(req->rq_repmsg == NULL); + LASSERT(!req->rq_repmsg); req->rq_rep_swab_mask = 0; @@ -1000,8 +1002,8 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req) { LASSERT(req->rq_repbuf); - LASSERT(req->rq_repdata == NULL); - LASSERT(req->rq_repmsg == NULL); + LASSERT(!req->rq_repdata); + LASSERT(!req->rq_repmsg); LASSERT(req->rq_reply_off + req->rq_nob_received <= req->rq_repbuf_len); if (req->rq_reply_off == 0 && @@ -1046,13 +1048,13 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, int rc; early_req = ptlrpc_request_cache_alloc(GFP_NOFS); - if (early_req == NULL) + if (!early_req) return -ENOMEM; early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS); - if (early_buf == NULL) { + if (!early_buf) { rc = -ENOMEM; goto err_req; } @@ -1067,8 +1069,8 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, } LASSERT(req->rq_repbuf); - LASSERT(req->rq_repdata == NULL); - LASSERT(req->rq_repmsg == NULL); + LASSERT(!req->rq_repdata); + LASSERT(!req->rq_repmsg); if (req->rq_reply_off != 0) { CERROR("early reply with offset %u\n", req->rq_reply_off); @@ -1354,12 +1356,12 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, might_sleep(); - if (imp == NULL) + if (!imp) return 0; conn = imp->imp_connection; - if (svc_ctx == NULL) { + if (!svc_ctx) { struct client_obd *cliobd = &imp->imp_obd->u.cli; /* * normal import, determine flavor from rule set, except @@ -1447,11 +1449,11 @@ static void import_flush_ctx_common(struct obd_import *imp, { struct ptlrpc_sec *sec; - if (imp == NULL) + if (!imp) return; sec = sptlrpc_import_sec_ref(imp); - if (sec == NULL) + if (!sec) return; sec_cop_flush_ctx_cache(sec, uid, grace, force); @@ -1484,7 +1486,7 @@ int sptlrpc_cli_alloc_reqbuf(struct ptlrpc_request *req, int msgsize) LASSERT(ctx); LASSERT(ctx->cc_sec); LASSERT(ctx->cc_sec->ps_policy); - LASSERT(req->rq_reqmsg == NULL); + LASSERT(!req->rq_reqmsg); LASSERT_ATOMIC_POS(&ctx->cc_refcount); policy = ctx->cc_sec->ps_policy; @@ -1515,7 +1517,7 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req) LASSERT(ctx->cc_sec->ps_policy); LASSERT_ATOMIC_POS(&ctx->cc_refcount); - if (req->rq_reqbuf == NULL && req->rq_clrbuf == NULL) + if (!req->rq_reqbuf && !req->rq_clrbuf) return; policy = ctx->cc_sec->ps_policy; @@ -1632,7 +1634,7 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) LASSERT(ctx->cc_sec->ps_policy); LASSERT_ATOMIC_POS(&ctx->cc_refcount); - if (req->rq_repbuf == NULL) + if (!req->rq_repbuf) return; LASSERT(req->rq_repbuf_len); @@ -1684,12 +1686,13 @@ int sptlrpc_target_export_check(struct obd_export *exp, { struct sptlrpc_flavor flavor; - if (exp == NULL) + if (!exp) return 0; /* client side export has no imp_reverse, skip - * FIXME maybe we should check flavor this as well??? */ - if (exp->exp_imp_reverse == NULL) + * FIXME maybe we should check flavor this as well??? + */ + if (!exp->exp_imp_reverse) return 0; /* don't care about ctx fini rpc */ @@ -1702,11 +1705,13 @@ int sptlrpc_target_export_check(struct obd_export *exp, * the first req with the new flavor, then treat it as current flavor, * adapt reverse sec according to it. * note the first rpc with new flavor might not be with root ctx, in - * which case delay the sec_adapt by leaving exp_flvr_adapt == 1. */ + * which case delay the sec_adapt by leaving exp_flvr_adapt == 1. + */ if (unlikely(exp->exp_flvr_changed) && flavor_allowed(&exp->exp_flvr_old[1], req)) { /* make the new flavor as "current", and old ones as - * about-to-expire */ + * about-to-expire + */ CDEBUG(D_SEC, "exp %p: just changed: %x->%x\n", exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[1].sf_rpc); flavor = exp->exp_flvr_old[1]; @@ -1742,10 +1747,12 @@ int sptlrpc_target_export_check(struct obd_export *exp, } /* if it equals to the current flavor, we accept it, but need to - * dealing with reverse sec/ctx */ + * dealing with reverse sec/ctx + */ if (likely(flavor_allowed(&exp->exp_flvr, req))) { /* most cases should return here, we only interested in - * gss root ctx init */ + * gss root ctx init + */ if (!req->rq_auth_gss || !req->rq_ctx_init || (!req->rq_auth_usr_root && !req->rq_auth_usr_mdt && !req->rq_auth_usr_ost)) { @@ -1755,7 +1762,8 @@ int sptlrpc_target_export_check(struct obd_export *exp, /* if flavor just changed, we should not proceed, just leave * it and current flavor will be discovered and replaced - * shortly, and let _this_ rpc pass through */ + * shortly, and let _this_ rpc pass through + */ if (exp->exp_flvr_changed) { LASSERT(exp->exp_flvr_adapt); spin_unlock(&exp->exp_lock); @@ -1809,7 +1817,8 @@ int sptlrpc_target_export_check(struct obd_export *exp, } /* now it doesn't match the current flavor, the only chance we can - * accept it is match the old flavors which is not expired. */ + * accept it is match the old flavors which is not expired. + */ if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) { if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[1], req)) { @@ -1915,9 +1924,9 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) int rc; LASSERT(msg); - LASSERT(req->rq_reqmsg == NULL); - LASSERT(req->rq_repmsg == NULL); - LASSERT(req->rq_svc_ctx == NULL); + LASSERT(!req->rq_reqmsg); + LASSERT(!req->rq_repmsg); + LASSERT(!req->rq_svc_ctx); req->rq_req_swab_mask = 0; @@ -1994,7 +2003,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) /* failed alloc, try emergency pool */ rs = lustre_get_emerg_rs(svcpt); - if (rs == NULL) + if (!rs) return -ENOMEM; req->rq_reply_state = rs; @@ -2059,7 +2068,7 @@ void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req) { struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx; - if (ctx != NULL) + if (ctx) atomic_inc(&ctx->sc_refcount); } @@ -2067,7 +2076,7 @@ void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req) { struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx; - if (ctx == NULL) + if (!ctx) return; LASSERT_ATOMIC_POS(&ctx->sc_refcount); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 22621c7..72d5b9b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -120,7 +120,7 @@ static struct ptlrpc_enc_page_pool { } page_pools; /* - * /proc/fs/lustre/sptlrpc/encrypt_page_pools + * /sys/kernel/debug/lustre/sptlrpc/encrypt_page_pools */ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) { @@ -195,7 +195,7 @@ static void enc_pools_release_free_pages(long npages) while (npages--) { LASSERT(page_pools.epp_pools[p_idx]); - LASSERT(page_pools.epp_pools[p_idx][g_idx] != NULL); + LASSERT(page_pools.epp_pools[p_idx][g_idx]); __free_page(page_pools.epp_pools[p_idx][g_idx]); page_pools.epp_pools[p_idx][g_idx] = NULL; @@ -316,7 +316,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) int p_idx, g_idx; int i; - if (desc->bd_enc_iov == NULL) + if (!desc->bd_enc_iov) return; LASSERT(desc->bd_iov_count > 0); @@ -331,9 +331,9 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) LASSERT(page_pools.epp_pools[p_idx]); for (i = 0; i < desc->bd_iov_count; i++) { - LASSERT(desc->bd_enc_iov[i].kiov_page != NULL); + LASSERT(desc->bd_enc_iov[i].kiov_page); LASSERT(g_idx != 0 || page_pools.epp_pools[p_idx]); - LASSERT(page_pools.epp_pools[p_idx][g_idx] == NULL); + LASSERT(!page_pools.epp_pools[p_idx][g_idx]); page_pools.epp_pools[p_idx][g_idx] = desc->bd_enc_iov[i].kiov_page; @@ -412,7 +412,7 @@ int sptlrpc_enc_pool_init(void) page_pools.epp_st_max_wait = 0; enc_pools_alloc(); - if (page_pools.epp_pools == NULL) + if (!page_pools.epp_pools) return -ENOMEM; register_shrinker(&pools_shrinker); @@ -475,7 +475,7 @@ int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed) int size = msg->lm_buflens[offset]; bsd = lustre_msg_buf(msg, offset, sizeof(*bsd)); - if (bsd == NULL) { + if (!bsd) { CERROR("Invalid bulk sec desc: size %d\n", size); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 4b0b81c..93b91bf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -78,7 +78,7 @@ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) memset(flvr, 0, sizeof(*flvr)); - if (str == NULL || str[0] == '\0') { + if (!str || str[0] == '\0') { flvr->sf_rpc = SPTLRPC_FLVR_INVALID; return 0; } @@ -103,7 +103,7 @@ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) * format: plain-hash:<hash_alg> */ alg = strchr(bulk, ':'); - if (alg == NULL) + if (!alg) goto err_out; *alg++ = '\0'; @@ -166,7 +166,7 @@ static int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) sptlrpc_rule_init(rule); flavor = strchr(param, '='); - if (flavor == NULL) { + if (!flavor) { CERROR("invalid param, no '='\n"); return -EINVAL; } @@ -216,7 +216,7 @@ static int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) static void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) { LASSERT(rset->srs_nslot || - (rset->srs_nrule == 0 && rset->srs_rules == NULL)); + (rset->srs_nrule == 0 && !rset->srs_rules)); if (rset->srs_nslot) { kfree(rset->srs_rules); @@ -241,7 +241,7 @@ static int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) /* better use realloc() if available */ rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS); - if (rules == NULL) + if (!rules) return -ENOMEM; if (rset->srs_nrule) { @@ -450,7 +450,7 @@ static void target2fsname(const char *tgt, char *fsname, int buflen) } /* if we didn't find the pattern, treat the whole string as fsname */ - if (ptr == NULL) + if (!ptr) len = strlen(tgt); else len = ptr - tgt; @@ -579,13 +579,13 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, int rc; target = lustre_cfg_string(lcfg, 1); - if (target == NULL) { + if (!target) { CERROR("missing target name\n"); return -EINVAL; } param = lustre_cfg_string(lcfg, 2); - if (param == NULL) { + if (!param) { CERROR("missing parameter\n"); return -EINVAL; } @@ -603,12 +603,12 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, if (rc) return -EINVAL; - if (conf == NULL) { + if (!conf) { target2fsname(target, fsname, sizeof(fsname)); mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); - if (conf == NULL) { + if (!conf) { CERROR("can't find conf\n"); rc = -ENOMEM; } else { @@ -638,7 +638,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen) int len; ptr = strrchr(logname, '-'); - if (ptr == NULL || strcmp(ptr, "-sptlrpc")) { + if (!ptr || strcmp(ptr, "-sptlrpc")) { CERROR("%s is not a sptlrpc config log\n", logname); return -EINVAL; } @@ -772,7 +772,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(name, 0); - if (conf == NULL) + if (!conf) goto out; /* convert uuid name (supposed end with _UUID) to target name */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 6e58d5f..d5afc4f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -166,11 +166,13 @@ again: * is not optimal. we perhaps want to use balanced binary tree * to trace each sec as order of expiry time. * another issue here is we wakeup as fixed interval instead of - * according to each sec's expiry time */ + * according to each sec's expiry time + */ mutex_lock(&sec_gc_mutex); list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { /* if someone is waiting to be deleted, let it - * proceed as soon as possible. */ + * proceed as soon as possible. + */ if (atomic_read(&sec_gc_wait_del)) { CDEBUG(D_SEC, "deletion pending, start over\n"); mutex_unlock(&sec_gc_mutex); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index bda9a77..e610a8d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -82,7 +82,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) if (cli->cl_import) sec = sptlrpc_import_sec_ref(cli->cl_import); - if (sec == NULL) + if (!sec) goto out; sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str)); @@ -121,7 +121,7 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v) if (cli->cl_import) sec = sptlrpc_import_sec_ref(cli->cl_import); - if (sec == NULL) + if (!sec) goto out; if (sec->ps_policy->sp_cops->display) @@ -178,7 +178,7 @@ int sptlrpc_lproc_init(void) { int rc; - LASSERT(sptlrpc_debugfs_dir == NULL); + LASSERT(!sptlrpc_debugfs_dir); sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root, sptlrpc_lprocfs_vars, NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index ebfa609..40e5349 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -250,7 +250,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, alloc_size = size_roundup_power2(newmsg_size); newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); - if (newbuf == NULL) + if (!newbuf) return -ENOMEM; /* Must lock this, so that otherwise unprotected change of @@ -258,7 +258,8 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, * imp_replay_list traversing threads. See LU-3333 * This is a bandaid at best, we really need to deal with this * in request enlarging code before unpacking that's already - * there */ + * there + */ if (req->rq_import) spin_lock(&req->rq_import->imp_lock); memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); @@ -319,7 +320,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) LASSERT(rs->rs_size >= rs_size); } else { rs = libcfs_kvzalloc(rs_size, GFP_NOFS); - if (rs == NULL) + if (!rs) return -ENOMEM; rs->rs_size = rs_size; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 905a414..6276bf5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -104,7 +104,7 @@ static int plain_unpack_bsd(struct lustre_msg *msg, int swabbed) return -EPROTO; bsd = lustre_msg_buf(msg, PLAIN_PACK_BULK_OFF, PLAIN_BSD_SIZE); - if (bsd == NULL) { + if (!bsd) { CERROR("bulk sec desc has short size %d\n", lustre_msg_buflen(msg, PLAIN_PACK_BULK_OFF)); return -EPROTO; @@ -227,7 +227,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) swabbed = ptlrpc_rep_need_swab(req); phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); - if (phdr == NULL) { + if (!phdr) { CERROR("missing plain header\n"); return -EPROTO; } @@ -264,7 +264,8 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) } } else { /* whether we sent with bulk or not, we expect the same - * in reply, except for early reply */ + * in reply, except for early reply + */ if (!req->rq_early && !equi(req->rq_pack_bulk == 1, phdr->ph_flags & PLAIN_FL_BULK)) { @@ -419,7 +420,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) LASSERT(sec->ps_import); LASSERT(atomic_read(&sec->ps_refcount) == 0); LASSERT(atomic_read(&sec->ps_nctx) == 0); - LASSERT(plsec->pls_ctx == NULL); + LASSERT(!plsec->pls_ctx); class_import_put(sec->ps_import); @@ -468,7 +469,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, /* install ctx immediately if this is a reverse sec */ if (svc_ctx) { ctx = plain_sec_install_ctx(plsec); - if (ctx == NULL) { + if (!ctx) { plain_destroy_sec(sec); return NULL; } @@ -492,7 +493,7 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, atomic_inc(&ctx->cc_refcount); read_unlock(&plsec->pls_lock); - if (unlikely(ctx == NULL)) + if (unlikely(!ctx)) ctx = plain_sec_install_ctx(plsec); return ctx; @@ -665,7 +666,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, newbuf_size = size_roundup_power2(newbuf_size); newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS); - if (newbuf == NULL) + if (!newbuf) return -ENOMEM; /* Must lock this, so that otherwise unprotected change of @@ -673,7 +674,8 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, * imp_replay_list traversing threads. See LU-3333 * This is a bandaid at best, we really need to deal with this * in request enlarging code before unpacking that's already - * there */ + * there + */ if (req->rq_import) spin_lock(&req->rq_import->imp_lock); @@ -732,7 +734,7 @@ int plain_accept(struct ptlrpc_request *req) swabbed = ptlrpc_req_need_swab(req); phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); - if (phdr == NULL) { + if (!phdr) { CERROR("missing plain header\n"); return -EPROTO; } @@ -801,7 +803,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) LASSERT(rs->rs_size >= rs_size); } else { rs = libcfs_kvzalloc(rs_size, GFP_NOFS); - if (rs == NULL) + if (!rs) return -ENOMEM; rs->rs_size = rs_size; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 8598300..6f71ecc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -77,7 +77,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS, cfs_cpt_spread_node(svc->srv_cptable, svcpt->scp_cpt)); - if (rqbd == NULL) + if (!rqbd) return NULL; rqbd->rqbd_svcpt = svcpt; @@ -89,7 +89,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) svcpt->scp_cpt, svc->srv_buf_size, GFP_KERNEL); - if (rqbd->rqbd_buffer == NULL) { + if (!rqbd->rqbd_buffer) { kfree(rqbd); return NULL; } @@ -144,13 +144,14 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) for (i = 0; i < svc->srv_nbuf_per_group; i++) { /* NB: another thread might have recycled enough rqbds, we - * need to make sure it wouldn't over-allocate, see LU-1212. */ + * need to make sure it wouldn't over-allocate, see LU-1212. + */ if (svcpt->scp_nrqbds_posted >= svc->srv_nbuf_per_group) break; rqbd = ptlrpc_alloc_rqbd(svcpt); - if (rqbd == NULL) { + if (!rqbd) { CERROR("%s: Can't allocate request buffer\n", svc->srv_name); rc = -ENOMEM; @@ -322,7 +323,8 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) list_add_tail(&rqbd->rqbd_list, &svcpt->scp_rqbd_idle); /* Don't complain if no request buffers are posted right now; LNET - * won't drop requests because we set the portal lazy! */ + * won't drop requests because we set the portal lazy! + */ spin_unlock(&svcpt->scp_lock); @@ -363,13 +365,15 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, init = max_t(int, init, tc->tc_nthrs_init); /* NB: please see comments in lustre_lnet.h for definition - * details of these members */ + * details of these members + */ LASSERT(tc->tc_nthrs_max != 0); if (tc->tc_nthrs_user != 0) { /* In case there is a reason to test a service with many * threads, we give a less strict check here, it can - * be up to 8 * nthrs_max */ + * be up to 8 * nthrs_max + */ total = min(tc->tc_nthrs_max * 8, tc->tc_nthrs_user); nthrs = total / svc->srv_ncpts; init = max(init, nthrs); @@ -379,7 +383,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, total = tc->tc_nthrs_max; if (tc->tc_nthrs_base == 0) { /* don't care about base threads number per partition, - * this is most for non-affinity service */ + * this is most for non-affinity service + */ nthrs = total / svc->srv_ncpts; goto out; } @@ -390,7 +395,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, /* NB: Increase the base number if it's single partition * and total number of cores/HTs is larger or equal to 4. - * result will always < 2 * nthrs_base */ + * result will always < 2 * nthrs_base + */ weight = cfs_cpt_weight(svc->srv_cptable, CFS_CPT_ANY); for (i = 1; (weight >> (i + 1)) != 0 && /* >= 4 cores/HTs */ (tc->tc_nthrs_base >> i) != 0; i++) @@ -490,7 +496,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, array->paa_reqs_array = kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS, cfs_cpt_spread_node(svc->srv_cptable, cpt)); - if (array->paa_reqs_array == NULL) + if (!array->paa_reqs_array) return -ENOMEM; for (index = 0; index < size; index++) @@ -499,14 +505,15 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, array->paa_reqs_count = kzalloc_node(sizeof(__u32) * size, GFP_NOFS, cfs_cpt_spread_node(svc->srv_cptable, cpt)); - if (array->paa_reqs_count == NULL) + if (!array->paa_reqs_count) goto free_reqs_array; setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer, (unsigned long)svcpt); /* At SOW, service time should be quick; 10s seems generous. If client - * timeout is less than this, we'll be sending an early reply. */ + * timeout is less than this, we'll be sending an early reply. + */ at_init(&svcpt->scp_at_estimate, 10, 0); /* assign this before call ptlrpc_grow_req_bufs */ @@ -514,7 +521,8 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, /* Now allocate the request buffers, but don't post them now */ rc = ptlrpc_grow_req_bufs(svcpt, 0); /* We shouldn't be under memory pressure at startup, so - * fail if we can't allocate all our buffers at this time. */ + * fail if we can't allocate all our buffers at this time. + */ if (rc != 0) goto free_reqs_count; @@ -556,14 +564,14 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, LASSERT(conf->psc_thr.tc_ctx_tags != 0); cptable = cconf->cc_cptable; - if (cptable == NULL) + if (!cptable) cptable = cfs_cpt_table; if (!conf->psc_thr.tc_cpu_affinity) { ncpts = 1; } else { ncpts = cfs_cpt_number(cptable); - if (cconf->cc_pattern != NULL) { + if (cconf->cc_pattern) { struct cfs_expr_list *el; rc = cfs_expr_list_parse(cconf->cc_pattern, @@ -632,11 +640,11 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (!conf->psc_thr.tc_cpu_affinity) cpt = CFS_CPT_ANY; else - cpt = cpts != NULL ? cpts[i] : i; + cpt = cpts ? cpts[i] : i; svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS, cfs_cpt_spread_node(cptable, cpt)); - if (svcpt == NULL) { + if (!svcpt) { rc = -ENOMEM; goto failed; } @@ -696,7 +704,8 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) LASSERT(list_empty(&req->rq_timed_list)); /* DEBUG_REQ() assumes the reply state of a request with a valid - * ref will not be destroyed until that reference is dropped. */ + * ref will not be destroyed until that reference is dropped. + */ ptlrpc_req_drop_rs(req); sptlrpc_svc_ctx_decref(req); @@ -704,7 +713,8 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) if (req != &req->rq_rqbd->rqbd_req) { /* NB request buffers use an embedded * req if the incoming req unlinked the - * MD; this isn't one of them! */ + * MD; this isn't one of them! + */ ptlrpc_request_cache_free(req); } } @@ -728,7 +738,8 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) if (req->rq_at_linked) { spin_lock(&svcpt->scp_at_lock); /* recheck with lock, in case it's unlinked by - * ptlrpc_at_check_timed() */ + * ptlrpc_at_check_timed() + */ if (likely(req->rq_at_linked)) ptlrpc_at_remove_timed(req); spin_unlock(&svcpt->scp_at_lock); @@ -755,7 +766,8 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) svcpt->scp_hist_nrqbds++; /* cull some history? - * I expect only about 1 or 2 rqbds need to be recycled here */ + * I expect only about 1 or 2 rqbds need to be recycled here + */ while (svcpt->scp_hist_nrqbds > svc->srv_hist_nrqbds_cpt_max) { rqbd = list_entry(svcpt->scp_hist_rqbds.next, struct ptlrpc_request_buffer_desc, @@ -765,7 +777,8 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) svcpt->scp_hist_nrqbds--; /* remove rqbd's reqs from svc's req history while - * I've got the service lock */ + * I've got the service lock + */ list_for_each(tmp, &rqbd->rqbd_reqs) { req = list_entry(tmp, struct ptlrpc_request, rq_list); @@ -846,7 +859,7 @@ static void ptlrpc_server_finish_active_request( ptlrpc_nrs_req_finalize(req); - if (req->rq_export != NULL) + if (req->rq_export) class_export_rpc_dec(req->rq_export); ptlrpc_server_finish_request(svcpt, req); @@ -869,13 +882,13 @@ static int ptlrpc_check_req(struct ptlrpc_request *req) req->rq_export->exp_conn_cnt); return -EEXIST; } - if (unlikely(obd == NULL || obd->obd_fail)) { + if (unlikely(!obd || obd->obd_fail)) { /* * Failing over, don't handle any more reqs, send * error response instead. */ CDEBUG(D_RPCTRACE, "Dropping req %p for failed obd %s\n", - req, (obd != NULL) ? obd->obd_name : "unknown"); + req, obd ? obd->obd_name : "unknown"); rc = -ENODEV; } else if (lustre_msg_get_flags(req->rq_reqmsg) & (MSG_REPLAY | MSG_REQ_REPLAY_DONE)) { @@ -942,7 +955,8 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req) div_u64_rem(req->rq_deadline, array->paa_size, &index); if (array->paa_reqs_count[index] > 0) { /* latest rpcs will have the latest deadlines in the list, - * so search backward. */ + * so search backward. + */ list_for_each_entry_reverse(rq, &array->paa_reqs_array[index], rq_timed_list) { @@ -1003,7 +1017,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) int rc; /* deadline is when the client expects us to reply, margin is the - difference between clients' and servers' expectations */ + * difference between clients' and servers' expectations + */ DEBUG_REQ(D_ADAPTTO, req, "%ssending early reply (deadline %+lds, margin %+lds) for %d+%d", AT_OFF ? "AT off - not " : "", @@ -1027,12 +1042,14 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } /* Fake our processing time into the future to ask the clients - * for some extra amount of time */ + * for some extra amount of time + */ at_measured(&svcpt->scp_at_estimate, at_extra + ktime_get_real_seconds() - req->rq_arrival_time.tv_sec); /* Check to see if we've actually increased the deadline - - * we may be past adaptive_max */ + * we may be past adaptive_max + */ if (req->rq_deadline >= req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate)) { DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%lld), not sending early reply\n", @@ -1044,7 +1061,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) newdl = ktime_get_real_seconds() + at_get(&svcpt->scp_at_estimate); reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); - if (reqcopy == NULL) + if (!reqcopy) return -ENOMEM; reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS); if (!reqmsg) { @@ -1074,7 +1091,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) /* Connection ref */ reqcopy->rq_export = class_conn2export( lustre_msg_get_handle(reqcopy->rq_reqmsg)); - if (reqcopy->rq_export == NULL) { + if (!reqcopy->rq_export) { rc = -ENODEV; goto out; } @@ -1102,7 +1119,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } /* Free the (early) reply state from lustre_pack_reply. - (ptlrpc_send_reply takes it's own rs ref, so this is safe here) */ + * (ptlrpc_send_reply takes it's own rs ref, so this is safe here) + */ ptlrpc_req_drop_rs(reqcopy); out_put: @@ -1117,7 +1135,8 @@ out_free: } /* Send early replies to everybody expiring within at_early_margin - asking for at_extra time */ + * asking for at_extra time + */ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) { struct ptlrpc_at_array *array = &svcpt->scp_at_array; @@ -1152,7 +1171,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) } /* We're close to a timeout, and we don't know how much longer the - server will take. Send early replies to everyone expiring soon. */ + * server will take. Send early replies to everyone expiring soon. + */ INIT_LIST_HEAD(&work_list); deadline = -1; div_u64_rem(array->paa_deadline, array->paa_size, &index); @@ -1194,7 +1214,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) first, at_extra, counter); if (first < 0) { /* We're already past request deadlines before we even get a - chance to send early replies */ + * chance to send early replies + */ LCONSOLE_WARN("%s: This server is not able to keep up with request traffic (cpu-bound).\n", svcpt->scp_service->srv_name); CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n", @@ -1204,7 +1225,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) } /* we took additional refcount so entries can't be deleted from list, no - * locking is needed */ + * locking is needed + */ while (!list_empty(&work_list)) { rq = list_entry(work_list.next, struct ptlrpc_request, rq_timed_list); @@ -1237,7 +1259,8 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, if (req->rq_export && req->rq_ops) { /* Perform request specific check. We should do this check * before the request is added into exp_hp_rpcs list otherwise - * it may hit swab race at LU-1044. */ + * it may hit swab race at LU-1044. + */ if (req->rq_ops->hpreq_check) { rc = req->rq_ops->hpreq_check(req); /** @@ -1272,7 +1295,8 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) { if (req->rq_export && req->rq_ops) { /* refresh lock timeout again so that client has more - * room to send lock cancel RPC. */ + * room to send lock cancel RPC. + */ if (req->rq_ops->hpreq_fini) req->rq_ops->hpreq_fini(req); @@ -1316,7 +1340,7 @@ static bool ptlrpc_server_allow_high(struct ptlrpc_service_part *svcpt, CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) { /* leave just 1 thread for normal RPCs */ running = PTLRPC_NTHRS_INIT; - if (svcpt->scp_service->srv_ops.so_hpreq_handler != NULL) + if (svcpt->scp_service->srv_ops.so_hpreq_handler) running += 1; } @@ -1355,7 +1379,7 @@ static bool ptlrpc_server_allow_normal(struct ptlrpc_service_part *svcpt, CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) { /* leave just 1 thread for normal RPCs */ running = PTLRPC_NTHRS_INIT; - if (svcpt->scp_service->srv_ops.so_hpreq_handler != NULL) + if (svcpt->scp_service->srv_ops.so_hpreq_handler) running += 1; } @@ -1405,7 +1429,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) if (ptlrpc_server_high_pending(svcpt, force)) { req = ptlrpc_nrs_req_get_nolock(svcpt, true, force); - if (req != NULL) { + if (req) { svcpt->scp_hreq_count++; goto got_request; } @@ -1413,7 +1437,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) if (ptlrpc_server_normal_pending(svcpt, force)) { req = ptlrpc_nrs_req_get_nolock(svcpt, false, force); - if (req != NULL) { + if (req) { svcpt->scp_hreq_count = 0; goto got_request; } @@ -1461,7 +1485,8 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, list_del_init(&req->rq_list); svcpt->scp_nreqs_incoming--; /* Consider this still a "queued" request as far as stats are - * concerned */ + * concerned + */ spin_unlock(&svcpt->scp_lock); /* go through security check/transform */ @@ -1598,7 +1623,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, int fail_opc = 0; request = ptlrpc_server_request_get(svcpt, false); - if (request == NULL) + if (!request) return 0; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT)) @@ -1620,7 +1645,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, timediff = timespec64_sub(work_start, request->rq_arrival_time); timediff_usecs = timediff.tv_sec * USEC_PER_SEC + timediff.tv_nsec / NSEC_PER_USEC; - if (likely(svc->srv_stats != NULL)) { + if (likely(svc->srv_stats)) { lprocfs_counter_add(svc->srv_stats, PTLRPC_REQWAIT_CNTR, timediff_usecs); lprocfs_counter_add(svc->srv_stats, PTLRPC_REQQDEPTH_CNTR, @@ -1652,7 +1677,8 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, } /* Discard requests queued for longer than the deadline. - The deadline is increased if we send an early reply. */ + * The deadline is increased if we send an early reply. + */ if (ktime_get_real_seconds() > request->rq_deadline) { DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s: deadline " CFS_DURATION_T ":" CFS_DURATION_T "s ago\n", libcfs_id2str(request->rq_peer), @@ -1718,7 +1744,7 @@ put_conn: request->rq_status, (request->rq_repmsg ? lustre_msg_get_status(request->rq_repmsg) : -999)); - if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) { + if (likely(svc->srv_stats && request->rq_reqmsg)) { __u32 op = lustre_msg_get_opc(request->rq_reqmsg); int opc = opcode_offset(op); @@ -1804,7 +1830,8 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) if (nlocks == 0 && !been_handled) { /* If we see this, we should already have seen the warning - * in mds_steal_ack_locks() */ + * in mds_steal_ack_locks() + */ CDEBUG(D_HA, "All locks stolen from rs %p x%lld.t%lld o%d NID %s\n", rs, rs->rs_xid, rs->rs_transno, rs->rs_opc, @@ -1858,7 +1885,8 @@ ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt) /* CAVEAT EMPTOR: We might be allocating buffers here because we've * allowed the request history to grow out of control. We could put a * sanity check on that here and cull some history if we need the - * space. */ + * space. + */ if (avail <= low_water) ptlrpc_grow_req_bufs(svcpt, 1); @@ -1992,7 +2020,8 @@ static int ptlrpc_main(void *arg) /* NB: we will call cfs_cpt_bind() for all threads, because we * might want to run lustre server only on a subset of system CPUs, - * in that case ->scp_cpt is CFS_CPT_ANY */ + * in that case ->scp_cpt is CFS_CPT_ANY + */ rc = cfs_cpt_bind(svc->srv_cptable, svcpt->scp_cpt); if (rc != 0) { CWARN("%s: failed to bind %s on CPT %d\n", @@ -2008,7 +2037,7 @@ static int ptlrpc_main(void *arg) set_current_groups(ginfo); put_group_info(ginfo); - if (svc->srv_ops.so_thr_init != NULL) { + if (svc->srv_ops.so_thr_init) { rc = svc->srv_ops.so_thr_init(thread); if (rc) goto out; @@ -2057,7 +2086,8 @@ static int ptlrpc_main(void *arg) /* SVC_STOPPING may already be set here if someone else is trying * to stop the service while this new thread has been dynamically * forked. We still set SVC_RUNNING to let our creator know that - * we are now running, however we will exit as soon as possible */ + * we are now running, however we will exit as soon as possible + */ thread_add_flags(thread, SVC_RUNNING); svcpt->scp_nthrs_running++; spin_unlock(&svcpt->scp_lock); @@ -2116,7 +2146,8 @@ static int ptlrpc_main(void *arg) ptlrpc_server_post_idle_rqbds(svcpt) < 0) { /* I just failed to repost request buffers. * Wait for a timeout (unless something else - * happens) before I try again */ + * happens) before I try again + */ svcpt->scp_rqbd_timeout = cfs_time_seconds(1) / 10; CDEBUG(D_RPCTRACE, "Posted buffers: %d\n", svcpt->scp_nrqbds_posted); @@ -2132,10 +2163,10 @@ out_srv_fini: /* * deconstruct service specific state created by ptlrpc_start_thread() */ - if (svc->srv_ops.so_thr_done != NULL) + if (svc->srv_ops.so_thr_done) svc->srv_ops.so_thr_done(thread); - if (env != NULL) { + if (env) { lu_context_fini(&env->le_ctx); kfree(env); } @@ -2229,14 +2260,14 @@ static void ptlrpc_stop_hr_threads(void) ptlrpc_hr.hr_stopping = 1; cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { - if (hrp->hrp_thrs == NULL) + if (!hrp->hrp_thrs) continue; /* uninitialized */ for (j = 0; j < hrp->hrp_nthrs; j++) wake_up_all(&hrp->hrp_thrs[j].hrt_waitq); } cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { - if (hrp->hrp_thrs == NULL) + if (!hrp->hrp_thrs) continue; /* uninitialized */ wait_event(ptlrpc_hr.hr_waitq, atomic_read(&hrp->hrp_nstopped) == @@ -2255,24 +2286,27 @@ static int ptlrpc_start_hr_threads(void) for (j = 0; j < hrp->hrp_nthrs; j++) { struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j]; + struct task_struct *task; - rc = PTR_ERR(kthread_run(ptlrpc_hr_main, + task = kthread_run(ptlrpc_hr_main, &hrp->hrp_thrs[j], "ptlrpc_hr%02d_%03d", hrp->hrp_cpt, - hrt->hrt_id)); - if (IS_ERR_VALUE(rc)) + hrt->hrt_id); + if (IS_ERR(task)) { + rc = PTR_ERR(task); break; + } } wait_event(ptlrpc_hr.hr_waitq, atomic_read(&hrp->hrp_nstarted) == j); - if (!IS_ERR_VALUE(rc)) - continue; - CERROR("Reply handling thread %d:%d Failed on starting: rc = %d\n", - i, j, rc); - ptlrpc_stop_hr_threads(); - return rc; + if (rc < 0) { + CERROR("cannot start reply handler thread %d:%d: rc = %d\n", + i, j, rc); + ptlrpc_stop_hr_threads(); + return rc; + } } return 0; } @@ -2333,7 +2367,7 @@ static void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) int i; ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service != NULL) + if (svcpt->scp_service) ptlrpc_svcpt_stop_threads(svcpt); } } @@ -2374,10 +2408,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) struct l_wait_info lwi = { 0 }; struct ptlrpc_thread *thread; struct ptlrpc_service *svc; + struct task_struct *task; int rc; - LASSERT(svcpt != NULL); - svc = svcpt->scp_service; CDEBUG(D_RPCTRACE, "%s[%d] started %d min %d max %d\n", @@ -2396,7 +2429,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) thread = kzalloc_node(sizeof(*thread), GFP_NOFS, cfs_cpt_spread_node(svc->srv_cptable, svcpt->scp_cpt)); - if (thread == NULL) + if (!thread) return -ENOMEM; init_waitqueue_head(&thread->t_ctl_waitq); @@ -2409,7 +2442,8 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) if (svcpt->scp_nthrs_starting != 0) { /* serialize starting because some modules (obdfilter) - * might require unique and contiguous t_id */ + * might require unique and contiguous t_id + */ LASSERT(svcpt->scp_nthrs_starting == 1); spin_unlock(&svcpt->scp_lock); kfree(thread); @@ -2442,9 +2476,10 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) } CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); - rc = PTR_ERR(kthread_run(ptlrpc_main, thread, "%s", thread->t_name)); - if (IS_ERR_VALUE(rc)) { - CERROR("cannot start thread '%s': rc %d\n", + task = kthread_run(ptlrpc_main, thread, "%s", thread->t_name); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("cannot start thread '%s': rc = %d\n", thread->t_name, rc); spin_lock(&svcpt->scp_lock); --svcpt->scp_nthrs_starting; @@ -2488,7 +2523,7 @@ int ptlrpc_hr_init(void) ptlrpc_hr.hr_partitions = cfs_percpt_alloc(ptlrpc_hr.hr_cpt_table, sizeof(*hrp)); - if (ptlrpc_hr.hr_partitions == NULL) + if (!ptlrpc_hr.hr_partitions) return -ENOMEM; init_waitqueue_head(&ptlrpc_hr.hr_waitq); @@ -2509,7 +2544,7 @@ int ptlrpc_hr_init(void) kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS, cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table, i)); - if (hrp->hrp_thrs == NULL) { + if (!hrp->hrp_thrs) { rc = -ENOMEM; goto out; } @@ -2537,7 +2572,7 @@ void ptlrpc_hr_fini(void) struct ptlrpc_hr_partition *hrp; int i; - if (ptlrpc_hr.hr_partitions == NULL) + if (!ptlrpc_hr.hr_partitions) return; ptlrpc_stop_hr_threads(); @@ -2577,7 +2612,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) /* early disarm AT timer... */ ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service != NULL) + if (svcpt->scp_service) del_timer(&svcpt->scp_at_timer); } } @@ -2592,18 +2627,20 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) int i; /* All history will be culled when the next request buffer is - * freed in ptlrpc_service_purge_all() */ + * freed in ptlrpc_service_purge_all() + */ svc->srv_hist_nrqbds_cpt_max = 0; rc = LNetClearLazyPortal(svc->srv_req_portal); LASSERT(rc == 0); ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service == NULL) + if (!svcpt->scp_service) break; /* Unlink all the request buffers. This forces a 'final' - * event with its 'unlink' flag set for each posted rqbd */ + * event with its 'unlink' flag set for each posted rqbd + */ list_for_each_entry(rqbd, &svcpt->scp_rqbd_posted, rqbd_list) { rc = LNetMDUnlink(rqbd->rqbd_md_h); @@ -2612,17 +2649,19 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) } ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service == NULL) + if (!svcpt->scp_service) break; /* Wait for the network to release any buffers - * it's currently filling */ + * it's currently filling + */ spin_lock(&svcpt->scp_lock); while (svcpt->scp_nrqbds_posted != 0) { spin_unlock(&svcpt->scp_lock); /* Network access will complete in finite time but * the HUGE timeout lets us CWARN for visibility - * of sluggish NALs */ + * of sluggish LNDs + */ lwi = LWI_TIMEOUT_INTERVAL( cfs_time_seconds(LONG_UNLINK), cfs_time_seconds(1), NULL, NULL); @@ -2648,7 +2687,7 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) int i; ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service == NULL) + if (!svcpt->scp_service) break; spin_lock(&svcpt->scp_rep_lock); @@ -2663,7 +2702,8 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) /* purge the request queue. NB No new replies (rqbds * all unlinked) and no service threads, so I'm the only - * thread noodling the request queue now */ + * thread noodling the request queue now + */ while (!list_empty(&svcpt->scp_req_incoming)) { req = list_entry(svcpt->scp_req_incoming.next, struct ptlrpc_request, rq_list); @@ -2682,11 +2722,13 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) LASSERT(svcpt->scp_nreqs_incoming == 0); LASSERT(svcpt->scp_nreqs_active == 0); /* history should have been culled by - * ptlrpc_server_finish_request */ + * ptlrpc_server_finish_request + */ LASSERT(svcpt->scp_hist_nrqbds == 0); /* Now free all the request buffers since nothing - * references them any more... */ + * references them any more... + */ while (!list_empty(&svcpt->scp_rqbd_idle)) { rqbd = list_entry(svcpt->scp_rqbd_idle.next, @@ -2714,7 +2756,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) int i; ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service == NULL) + if (!svcpt->scp_service) break; /* In case somebody rearmed this in the meantime */ @@ -2730,7 +2772,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) ptlrpc_service_for_each_part(svcpt, i, svc) kfree(svcpt); - if (svc->srv_cpts != NULL) + if (svc->srv_cpts) cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts); kfree(svc); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 61d9ca9..3ffd2d9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -333,17 +333,9 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_MAX_TYPE == 14); CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - LASSERTF(UPDATE_OBJ == 1000, "found %lld\n", - (long long)UPDATE_OBJ); - LASSERTF(UPDATE_LAST_OPC == 1001, "found %lld\n", - (long long)UPDATE_LAST_OPC); CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); - CLASSERT(LQUOTA_TYPE_USR == 0); - CLASSERT(LQUOTA_TYPE_GRP == 1); - CLASSERT(LQUOTA_RES_MD == 1); - CLASSERT(LQUOTA_RES_DT == 2); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", @@ -437,30 +429,6 @@ void lustre_assert_wire_constants(void) (unsigned)LMAC_NOT_IN_OI); LASSERTF(LMAC_FID_ON_OST == 0x00000008UL, "found 0x%.8xUL\n", (unsigned)LMAC_FID_ON_OST); - LASSERTF(OBJ_CREATE == 1, "found %lld\n", - (long long)OBJ_CREATE); - LASSERTF(OBJ_DESTROY == 2, "found %lld\n", - (long long)OBJ_DESTROY); - LASSERTF(OBJ_REF_ADD == 3, "found %lld\n", - (long long)OBJ_REF_ADD); - LASSERTF(OBJ_REF_DEL == 4, "found %lld\n", - (long long)OBJ_REF_DEL); - LASSERTF(OBJ_ATTR_SET == 5, "found %lld\n", - (long long)OBJ_ATTR_SET); - LASSERTF(OBJ_ATTR_GET == 6, "found %lld\n", - (long long)OBJ_ATTR_GET); - LASSERTF(OBJ_XATTR_SET == 7, "found %lld\n", - (long long)OBJ_XATTR_SET); - LASSERTF(OBJ_XATTR_GET == 8, "found %lld\n", - (long long)OBJ_XATTR_GET); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_INSERT == 10, "found %lld\n", - (long long)OBJ_INDEX_INSERT); - LASSERTF(OBJ_INDEX_DELETE == 11, "found %lld\n", - (long long)OBJ_INDEX_DELETE); /* Checks for struct ost_id */ LASSERTF((int)sizeof(struct ost_id) == 16, "found %lld\n", @@ -587,9 +555,6 @@ void lustre_assert_wire_constants(void) (long long)LDF_COLLIDE); LASSERTF(LU_PAGE_SIZE == 4096, "found %lld\n", (long long)LU_PAGE_SIZE); - /* Checks for union lu_page */ - LASSERTF((int)sizeof(union lu_page) == 4096, "found %lld\n", - (long long)(int)sizeof(union lu_page)); /* Checks for struct lustre_handle */ LASSERTF((int)sizeof(struct lustre_handle) == 8, "found %lld\n", @@ -1535,11 +1500,6 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n", (long long)(int)sizeof(union lquota_id)); - LASSERTF(QUOTABLOCK_BITS == 10, "found %lld\n", - (long long)QUOTABLOCK_BITS); - LASSERTF(QUOTABLOCK_SIZE == 1024, "found %lld\n", - (long long)QUOTABLOCK_SIZE); - /* Checks for struct obd_quotactl */ LASSERTF((int)sizeof(struct obd_quotactl) == 112, "found %lld\n", (long long)(int)sizeof(struct obd_quotactl)); @@ -1642,138 +1602,6 @@ void lustre_assert_wire_constants(void) LASSERTF(Q_FINVALIDATE == 0x800104, "found 0x%.8x\n", Q_FINVALIDATE); - /* Checks for struct lquota_acct_rec */ - LASSERTF((int)sizeof(struct lquota_acct_rec) == 16, "found %lld\n", - (long long)(int)sizeof(struct lquota_acct_rec)); - LASSERTF((int)offsetof(struct lquota_acct_rec, bspace) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_acct_rec, bspace)); - LASSERTF((int)sizeof(((struct lquota_acct_rec *)0)->bspace) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_acct_rec *)0)->bspace)); - LASSERTF((int)offsetof(struct lquota_acct_rec, ispace) == 8, "found %lld\n", - (long long)(int)offsetof(struct lquota_acct_rec, ispace)); - LASSERTF((int)sizeof(((struct lquota_acct_rec *)0)->ispace) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_acct_rec *)0)->ispace)); - - /* Checks for struct lquota_glb_rec */ - LASSERTF((int)sizeof(struct lquota_glb_rec) == 32, "found %lld\n", - (long long)(int)sizeof(struct lquota_glb_rec)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_hardlimit) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_hardlimit)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_hardlimit) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_hardlimit)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_softlimit) == 8, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_softlimit)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_softlimit) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_softlimit)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_time) == 16, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_time)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_time) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_time)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_granted) == 24, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_granted)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_granted) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_granted)); - - /* Checks for struct lquota_slv_rec */ - LASSERTF((int)sizeof(struct lquota_slv_rec) == 8, "found %lld\n", - (long long)(int)sizeof(struct lquota_slv_rec)); - LASSERTF((int)offsetof(struct lquota_slv_rec, qsr_granted) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_slv_rec, qsr_granted)); - LASSERTF((int)sizeof(((struct lquota_slv_rec *)0)->qsr_granted) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_slv_rec *)0)->qsr_granted)); - - /* Checks for struct idx_info */ - LASSERTF((int)sizeof(struct idx_info) == 80, "found %lld\n", - (long long)(int)sizeof(struct idx_info)); - LASSERTF((int)offsetof(struct idx_info, ii_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_magic)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_magic)); - LASSERTF((int)offsetof(struct idx_info, ii_flags) == 4, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_flags)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_flags) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_flags)); - LASSERTF((int)offsetof(struct idx_info, ii_count) == 8, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_count)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_count) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_count)); - LASSERTF((int)offsetof(struct idx_info, ii_pad0) == 10, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad0)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad0) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad0)); - LASSERTF((int)offsetof(struct idx_info, ii_attrs) == 12, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_attrs)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_attrs) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_attrs)); - LASSERTF((int)offsetof(struct idx_info, ii_fid) == 16, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_fid)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_fid)); - LASSERTF((int)offsetof(struct idx_info, ii_version) == 32, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_version)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_version) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_version)); - LASSERTF((int)offsetof(struct idx_info, ii_hash_start) == 40, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_hash_start)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_hash_start) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_hash_start)); - LASSERTF((int)offsetof(struct idx_info, ii_hash_end) == 48, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_hash_end)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_hash_end) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_hash_end)); - LASSERTF((int)offsetof(struct idx_info, ii_keysize) == 56, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_keysize)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_keysize) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_keysize)); - LASSERTF((int)offsetof(struct idx_info, ii_recsize) == 58, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_recsize)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_recsize) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_recsize)); - LASSERTF((int)offsetof(struct idx_info, ii_pad1) == 60, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad1)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad1) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad1)); - LASSERTF((int)offsetof(struct idx_info, ii_pad2) == 64, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad2)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad2) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad2)); - LASSERTF((int)offsetof(struct idx_info, ii_pad3) == 72, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad3)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad3) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad3)); - CLASSERT(IDX_INFO_MAGIC == 0x3D37CC37); - - /* Checks for struct lu_idxpage */ - LASSERTF((int)sizeof(struct lu_idxpage) == 16, "found %lld\n", - (long long)(int)sizeof(struct lu_idxpage)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_magic)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_magic)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_flags) == 4, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_flags)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_flags) == 2, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_flags)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_nr) == 6, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_nr)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_nr) == 2, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_nr)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_pad0) == 8, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_pad0)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_pad0) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_pad0)); - CLASSERT(LIP_MAGIC == 0x8A6D6B6C); - LASSERTF(LIP_HDR_SIZE == 16, "found %lld\n", - (long long)LIP_HDR_SIZE); - LASSERTF(II_FL_NOHASH == 1, "found %lld\n", - (long long)II_FL_NOHASH); - LASSERTF(II_FL_VARKEY == 2, "found %lld\n", - (long long)II_FL_VARKEY); - LASSERTF(II_FL_VARREC == 4, "found %lld\n", - (long long)II_FL_VARREC); - LASSERTF(II_FL_NONUNQ == 8, "found %lld\n", - (long long)II_FL_NONUNQ); - /* Checks for struct niobuf_remote */ LASSERTF((int)sizeof(struct niobuf_remote) == 16, "found %lld\n", (long long)(int)sizeof(struct niobuf_remote)); @@ -3753,50 +3581,6 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct ll_fiemap_info_key *)0)->fiemap) == 32, "found %lld\n", (long long)(int)sizeof(((struct ll_fiemap_info_key *)0)->fiemap)); - /* Checks for struct quota_body */ - LASSERTF((int)sizeof(struct quota_body) == 112, "found %lld\n", - (long long)(int)sizeof(struct quota_body)); - LASSERTF((int)offsetof(struct quota_body, qb_fid) == 0, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_fid)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_fid)); - LASSERTF((int)offsetof(struct quota_body, qb_id) == 16, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_id)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_id) == 16, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_id)); - LASSERTF((int)offsetof(struct quota_body, qb_flags) == 32, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_flags)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_flags) == 4, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_flags)); - LASSERTF((int)offsetof(struct quota_body, qb_padding) == 36, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_padding)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding) == 4, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_padding)); - LASSERTF((int)offsetof(struct quota_body, qb_count) == 40, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_count)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_count) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_count)); - LASSERTF((int)offsetof(struct quota_body, qb_usage) == 48, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_usage)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_usage) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_usage)); - LASSERTF((int)offsetof(struct quota_body, qb_slv_ver) == 56, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_slv_ver)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_slv_ver) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_slv_ver)); - LASSERTF((int)offsetof(struct quota_body, qb_lockh) == 64, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_lockh)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_lockh) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_lockh)); - LASSERTF((int)offsetof(struct quota_body, qb_glb_lockh) == 72, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_glb_lockh)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_glb_lockh) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_glb_lockh)); - LASSERTF((int)offsetof(struct quota_body, qb_padding1[4]) == 112, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_padding1[4])); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding1[4]) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_padding1[4])); - /* Checks for struct mgs_target_info */ LASSERTF((int)sizeof(struct mgs_target_info) == 4544, "found %lld\n", (long long)(int)sizeof(struct mgs_target_info)); @@ -4431,60 +4215,4 @@ void lustre_assert_wire_constants(void) LASSERTF(sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n", (long long)sizeof(((struct hsm_user_import *)0)->hui_archive_id)); - - /* Checks for struct update_buf */ - LASSERTF((int)sizeof(struct update_buf) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_buf)); - LASSERTF((int)offsetof(struct update_buf, ub_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_magic)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_magic)); - LASSERTF((int)offsetof(struct update_buf, ub_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_count)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_count)); - LASSERTF((int)offsetof(struct update_buf, ub_bufs) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_bufs)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_bufs)); - - /* Checks for struct update_reply */ - LASSERTF((int)sizeof(struct update_reply) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_reply)); - LASSERTF((int)offsetof(struct update_reply, ur_version) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_version)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_version) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_version)); - LASSERTF((int)offsetof(struct update_reply, ur_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_count)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_count)); - LASSERTF((int)offsetof(struct update_reply, ur_lens) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_lens)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_lens) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_lens)); - - /* Checks for struct update */ - LASSERTF((int)sizeof(struct update) == 56, "found %lld\n", - (long long)(int)sizeof(struct update)); - LASSERTF((int)offsetof(struct update, u_type) == 0, "found %lld\n", - (long long)(int)offsetof(struct update, u_type)); - LASSERTF((int)sizeof(((struct update *)0)->u_type) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_type)); - LASSERTF((int)offsetof(struct update, u_batchid) == 4, "found %lld\n", - (long long)(int)offsetof(struct update, u_batchid)); - LASSERTF((int)sizeof(((struct update *)0)->u_batchid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_batchid)); - LASSERTF((int)offsetof(struct update, u_fid) == 8, "found %lld\n", - (long long)(int)offsetof(struct update, u_fid)); - LASSERTF((int)sizeof(((struct update *)0)->u_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_fid)); - LASSERTF((int)offsetof(struct update, u_lens) == 24, "found %lld\n", - (long long)(int)offsetof(struct update, u_lens)); - LASSERTF((int)sizeof(((struct update *)0)->u_lens) == 32, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_lens)); - LASSERTF((int)offsetof(struct update, u_bufs) == 56, "found %lld\n", - (long long)(int)offsetof(struct update, u_bufs)); - LASSERTF((int)sizeof(((struct update *)0)->u_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_bufs)); } diff --git a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h index 7b7e7b2..f4f35c9 100644 --- a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h +++ b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h @@ -538,8 +538,8 @@ struct vpfe_isif_raw_config { }; /********************************************************************** - IPIPE API Structures -**********************************************************************/ + * IPIPE API Structures + **********************************************************************/ /* IPIPE module configurations */ diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index ac78ed2..ff47a8f3 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1350,21 +1350,16 @@ error: */ static long ipipe_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) { - int ret = 0; - switch (cmd) { case VIDIOC_VPFE_IPIPE_S_CONFIG: - ret = ipipe_s_config(sd, arg); - break; + return ipipe_s_config(sd, arg); case VIDIOC_VPFE_IPIPE_G_CONFIG: - ret = ipipe_g_config(sd, arg); - break; + return ipipe_g_config(sd, arg); default: - ret = -ENOIOCTLCMD; + return -ENOIOCTLCMD; } - return ret; } void vpfe_ipipe_enable(struct vpfe_device *vpfe_dev, int en) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c index b1d5e23..0792fbd 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c @@ -682,8 +682,10 @@ ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id, ipipe_clock_enable(base_addr); if (id == IPIPE_RGB2RGB_2) { - /* For second RGB module, gain integer is 3 bits instead - of 4, offset has 11 bits insread of 13 */ + /* + * For second RGB module, gain integer is 3 bits instead + * of 4, offset has 11 bits insread of 13 + */ offset = RGB2_MUL_BASE; integ_mask = 0x7; offset_mask = RGB2RGB_2_OFST_MASK; @@ -792,8 +794,10 @@ ipipe_set_3d_lut_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, /* valied table */ tbl = lut_3d->table; for (i = 0; i < VPFE_IPIPE_MAX_SIZE_3D_LUT; i++) { - /* Each entry has 0-9 (B), 10-19 (G) and - 20-29 R values */ + /* + * Each entry has 0-9 (B), 10-19 (G) and + * 20-29 R values + */ val = tbl[i].b & D3_LUT_ENTRY_MASK; val |= (tbl[i].g & D3_LUT_ENTRY_MASK) << D3_LUT_ENTRY_G_SHIFT; diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h index 2bf2f7a..7ee1572 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h @@ -278,9 +278,10 @@ /* Resizer Rescale Parameters */ #define RSZ_EN_A 0x58 #define RSZ_EN_B 0xe8 -/* offset of the registers to be added with base register of - either RSZ0 or RSZ1 -*/ +/* + * offset of the registers to be added with base register of + * either RSZ0 or RSZ1 + */ #define RSZ_MODE 0x4 #define RSZ_420 0x8 #define RSZ_I_VPS 0xc diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 633d645..6e4c87f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -641,8 +641,9 @@ ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif, } static int -ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) +ipipeif_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index cfad426..ae9202d 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -282,7 +282,8 @@ isif_config_format(struct vpfe_device *vpfe_dev, unsigned int pad) * @fmt: pointer to v4l2 subdev format structure */ static void -isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg, +isif_try_format(struct vpfe_isif_device *isif, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { unsigned int width = fmt->format.width; @@ -625,21 +626,16 @@ static int isif_set_params(struct v4l2_subdev *sd, void *params) */ static long isif_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) { - int ret; - switch (cmd) { case VIDIOC_VPFE_ISIF_S_RAW_PARAMS: - ret = isif_set_params(sd, arg); - break; + return isif_set_params(sd, arg); case VIDIOC_VPFE_ISIF_G_RAW_PARAMS: - ret = isif_get_params(sd, arg); - break; + return isif_get_params(sd, arg); default: - ret = -ENOIOCTLCMD; + return -ENOIOCTLCMD; } - return ret; } static void isif_config_gain_offset(struct vpfe_isif_device *isif) @@ -1399,8 +1395,9 @@ static int isif_set_stream(struct v4l2_subdev *sd, int enable) * @which: wanted subdev format. */ static struct v4l2_mbus_framefmt * -__isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, enum v4l2_subdev_format_whence which) +__isif_get_format(struct vpfe_isif_device *isif, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, + enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) { struct v4l2_subdev_format fmt; diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 42de95e..3cd56cc 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1387,8 +1387,9 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int resizer_set_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; @@ -1447,8 +1448,9 @@ static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_con * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int resizer_get_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct v4l2_mbus_framefmt *format; @@ -1670,7 +1672,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->crop_resizer.input = RESIZER_CROP_INPUT_IPIPEIF; else if (ipipe_source == IPIPE_OUTPUT_RESIZER) - resizer->crop_resizer.input = + resizer->crop_resizer.input = RESIZER_CROP_INPUT_IPIPE; else return -EINVAL; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index ec46f36..bf077f8 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -442,8 +442,10 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev) /* create links now, starting with external(i2c) entities */ for (i = 0; i < vpfe_dev->num_ext_subdevs; i++) - /* if entity has no pads (ex: amplifier), - cant establish link */ + /* + * if entity has no pads (ex: amplifier), + * cant establish link + */ if (vpfe_dev->sd[i]->entity.num_pads) { ret = media_create_pad_link(&vpfe_dev->sd[i]->entity, 0, &vpfe_dev->vpfe_isif.subdev.entity, diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 3ec7e65..0a65405 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -172,21 +172,19 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video) static int vpfe_update_pipe_state(struct vpfe_video_device *video) { struct vpfe_pipeline *pipe = &video->pipe; - int ret; - ret = vpfe_prepare_pipeline(video); - if (ret) - return ret; + if (vpfe_prepare_pipeline(video)) + return vpfe_prepare_pipeline(video); - /* Find out if there is any input video - if yes, it is single shot. - */ + /* + * Find out if there is any input video + * if yes, it is single shot. + */ if (pipe->input_num == 0) { pipe->state = VPFE_PIPELINE_STREAM_CONTINUOUS; - ret = vpfe_update_current_ext_subdev(video); - if (ret) { + if (vpfe_update_current_ext_subdev(video)) { pr_err("Invalid external subdev\n"); - return ret; + return vpfe_update_current_ext_subdev(video); } } else { pipe->state = VPFE_PIPELINE_STREAM_SINGLESHOT; @@ -460,7 +458,7 @@ void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video) video->next_frm = list_entry(video->dma_queue.next, struct vpfe_cap_buffer, list); - if (VPFE_PIPELINE_STREAM_SINGLESHOT == video->pipe.state) + if (video->pipe.state == VPFE_PIPELINE_STREAM_SINGLESHOT) video->cur_frm = video->next_frm; list_del(&video->next_frm->list); @@ -529,10 +527,11 @@ static int vpfe_release(struct file *file) if (fh->io_allowed) { if (video->started) { vpfe_stop_capture(video); - /* mark pipe state as stopped in vpfe_release(), - as app might call streamon() after streamoff() - in which case driver has to start streaming. - */ + /* + * mark pipe state as stopped in vpfe_release(), + * as app might call streamon() after streamoff() + * in which case driver has to start streaming. + */ video->pipe.state = VPFE_PIPELINE_STREAM_STOPPED; vb2_streamoff(&video->buffer_queue, video->buffer_queue.type); @@ -668,12 +667,13 @@ static int vpfe_enum_fmt(struct file *file, void *priv, struct v4l2_subdev *subdev; struct v4l2_format format; struct media_pad *remote; - int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt\n"); - /* since already subdev pad format is set, - only one pixel format is available */ + /* + * since already subdev pad format is set, + * only one pixel format is available + */ if (fmt->index > 0) { v4l2_err(&vpfe_dev->v4l2_dev, "Invalid index\n"); return -EINVAL; @@ -695,11 +695,10 @@ static int vpfe_enum_fmt(struct file *file, void *priv, sd_fmt.pad = remote->index; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; /* get output format of remote subdev */ - ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt); - if (ret) { + if (v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt)) { v4l2_err(&vpfe_dev->v4l2_dev, "invalid remote subdev for video node\n"); - return ret; + return v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt); } /* convert to pix format */ mbus.code = sd_fmt.format.code; @@ -726,7 +725,6 @@ static int vpfe_s_fmt(struct file *file, void *priv, struct vpfe_video_device *video = video_drvdata(file); struct vpfe_device *vpfe_dev = video->vpfe_dev; struct v4l2_format format; - int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt\n"); /* If streaming is started, return error */ @@ -735,9 +733,8 @@ static int vpfe_s_fmt(struct file *file, void *priv, return -EBUSY; } /* get adjacent subdev's output pad format */ - ret = __vpfe_video_get_format(video, &format); - if (ret) - return ret; + if (__vpfe_video_get_format(video, &format)) + return __vpfe_video_get_format(video, &format); *fmt = format; video->fmt = *fmt; return 0; @@ -760,13 +757,11 @@ static int vpfe_try_fmt(struct file *file, void *priv, struct vpfe_video_device *video = video_drvdata(file); struct vpfe_device *vpfe_dev = video->vpfe_dev; struct v4l2_format format; - int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt\n"); /* get adjacent subdev's output pad format */ - ret = __vpfe_video_get_format(video, &format); - if (ret) - return ret; + if (__vpfe_video_get_format(video, &format)) + return __vpfe_video_get_format(video, &format); *fmt = format; return 0; @@ -843,9 +838,8 @@ static int vpfe_s_input(struct file *file, void *priv, unsigned int index) v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n"); - ret = mutex_lock_interruptible(&video->lock); - if (ret) - return ret; + if (mutex_lock_interruptible(&video->lock)) + return mutex_lock_interruptible(&video->lock); /* * If streaming is started return device busy * error @@ -946,9 +940,8 @@ static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id) v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n"); /* Call decoder driver function to set the standard */ - ret = mutex_lock_interruptible(&video->lock); - if (ret) - return ret; + if (mutex_lock_interruptible(&video->lock)) + return mutex_lock_interruptible(&video->lock); sdinfo = video->current_ext_subdev; /* If streaming is started, return device busy error */ if (video->started) { @@ -1328,15 +1321,14 @@ static int vpfe_reqbufs(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n"); - if (V4L2_BUF_TYPE_VIDEO_CAPTURE != req_buf->type && - V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) { + if (req_buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + req_buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT){ v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buffer type\n"); return -EINVAL; } - ret = mutex_lock_interruptible(&video->lock); - if (ret) - return ret; + if (mutex_lock_interruptible(&video->lock)) + return mutex_lock_interruptible(&video->lock); if (video->io_usrs != 0) { v4l2_err(&vpfe_dev->v4l2_dev, "Only one IO user allowed\n"); @@ -1362,11 +1354,10 @@ static int vpfe_reqbufs(struct file *file, void *priv, q->buf_struct_size = sizeof(struct vpfe_cap_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - ret = vb2_queue_init(q); - if (ret) { + if (vb2_queue_init(q)) { v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n"); vb2_dma_contig_cleanup_ctx(vpfe_dev->pdev); - return ret; + return vb2_queue_init(q); } fh->io_allowed = 1; @@ -1390,8 +1381,8 @@ static int vpfe_querybuf(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querybuf\n"); - if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type && - V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { + if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n"); return -EINVAL; } @@ -1417,8 +1408,8 @@ static int vpfe_qbuf(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_qbuf\n"); - if (V4L2_BUF_TYPE_VIDEO_CAPTURE != p->type && - V4L2_BUF_TYPE_VIDEO_OUTPUT != p->type) { + if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + p->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n"); return -EINVAL; } @@ -1445,8 +1436,8 @@ static int vpfe_dqbuf(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_dqbuf\n"); - if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type && - V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { + if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n"); return -EINVAL; } @@ -1478,8 +1469,8 @@ static int vpfe_streamon(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n"); - if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf_type && - V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { + if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + buf_type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n"); return ret; } @@ -1495,7 +1486,7 @@ static int vpfe_streamon(struct file *file, void *priv, return -EIO; } /* Validate the pipeline */ - if (V4L2_BUF_TYPE_VIDEO_CAPTURE == buf_type) { + if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { ret = vpfe_video_validate_pipeline(pipe); if (ret < 0) return ret; @@ -1542,9 +1533,8 @@ static int vpfe_streamoff(struct file *file, void *priv, return -EINVAL; } - ret = mutex_lock_interruptible(&video->lock); - if (ret) - return ret; + if (mutex_lock_interruptible(&video->lock)) + return mutex_lock_interruptible(&video->lock); vpfe_stop_capture(video); ret = vb2_streamoff(&video->buffer_queue, buf_type); diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c b/drivers/staging/most/hdm-dim2/dim2_hdm.c index 6296aa5..c736310 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hdm.c +++ b/drivers/staging/most/hdm-dim2/dim2_hdm.c @@ -736,7 +736,7 @@ static int dim2_probe(struct platform_device *pdev) int ret, i; struct kobject *kobj; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; @@ -747,47 +747,31 @@ static int dim2_probe(struct platform_device *pdev) test_dev = dev; #else res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - pr_err("no memory region defined\n"); - ret = -ENOENT; - goto err_free_dev; - } - - if (!request_mem_region(res->start, resource_size(res), pdev->name)) { - pr_err("failed to request mem region\n"); - ret = -EBUSY; - goto err_free_dev; - } - - dev->io_base = ioremap(res->start, resource_size(res)); - if (!dev->io_base) { - pr_err("failed to ioremap\n"); - ret = -ENOMEM; - goto err_release_mem; - } + dev->io_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(dev->io_base)) + return PTR_ERR(dev->io_base); ret = platform_get_irq(pdev, 0); if (ret < 0) { - pr_err("failed to get irq\n"); - goto err_unmap_io; + dev_err(&pdev->dev, "failed to get irq\n"); + return -ENODEV; } dev->irq_ahb0 = ret; - ret = request_irq(dev->irq_ahb0, dim2_ahb_isr, 0, "mlb_ahb0", dev); + ret = devm_request_irq(&pdev->dev, dev->irq_ahb0, dim2_ahb_isr, 0, + "mlb_ahb0", dev); if (ret) { - pr_err("failed to request IRQ: %d, err: %d\n", - dev->irq_ahb0, ret); - goto err_unmap_io; + dev_err(&pdev->dev, "failed to request IRQ: %d, err: %d\n", + dev->irq_ahb0, ret); + return ret; } #endif init_waitqueue_head(&dev->netinfo_waitq); dev->deliver_netinfo = 0; dev->netinfo_task = kthread_run(&deliver_netinfo_thread, (void *)dev, "dim2_netinfo"); - if (IS_ERR(dev->netinfo_task)) { + if (IS_ERR(dev->netinfo_task)) ret = PTR_ERR(dev->netinfo_task); - goto err_free_irq; - } for (i = 0; i < DMA_CHANNELS; i++) { struct most_channel_capability *cap = dev->capabilities + i; @@ -855,16 +839,6 @@ err_unreg_iface: most_deregister_interface(&dev->most_iface); err_stop_thread: kthread_stop(dev->netinfo_task); -err_free_irq: -#if !defined(ENABLE_HDM_TEST) - free_irq(dev->irq_ahb0, dev); -err_unmap_io: - iounmap(dev->io_base); -err_release_mem: - release_mem_region(res->start, resource_size(res)); -err_free_dev: -#endif - kfree(dev); return ret; } @@ -878,7 +852,6 @@ err_free_dev: static int dim2_remove(struct platform_device *pdev) { struct dim2_hdm *dev = platform_get_drvdata(pdev); - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct dim2_platform_data *pdata = pdev->dev.platform_data; unsigned long flags; @@ -892,13 +865,6 @@ static int dim2_remove(struct platform_device *pdev) dim2_sysfs_destroy(&dev->bus); most_deregister_interface(&dev->most_iface); kthread_stop(dev->netinfo_task); -#if !defined(ENABLE_HDM_TEST) - free_irq(dev->irq_ahb0, dev); - iounmap(dev->io_base); - release_mem_region(res->start, resource_size(res)); -#endif - kfree(dev); - platform_set_drvdata(pdev, NULL); /* * break link to local platform_device_id struct diff --git a/drivers/staging/most/hdm-dim2/dim2_sysfs.c b/drivers/staging/most/hdm-dim2/dim2_sysfs.c index c5b10c7..2b28e4a 100644 --- a/drivers/staging/most/hdm-dim2/dim2_sysfs.c +++ b/drivers/staging/most/hdm-dim2/dim2_sysfs.c @@ -63,7 +63,6 @@ static ssize_t bus_kobj_attr_show(struct kobject *kobj, struct attribute *attr, static ssize_t bus_kobj_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) { - ssize_t ret; struct medialb_bus *bus = container_of(kobj, struct medialb_bus, kobj_group); struct bus_attr *xattr = container_of(attr, struct bus_attr, attr); @@ -71,8 +70,7 @@ static ssize_t bus_kobj_attr_store(struct kobject *kobj, struct attribute *attr, if (!xattr->store) return -EIO; - ret = xattr->store(bus, buf, count); - return ret; + return xattr->store(bus, buf, count); } static struct sysfs_ops const bus_kobj_sysfs_ops = { diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c b/drivers/staging/most/hdm-usb/hdm_usb.c index 41690f8..9d5555d 100644 --- a/drivers/staging/most/hdm-usb/hdm_usb.c +++ b/drivers/staging/most/hdm-usb/hdm_usb.c @@ -40,7 +40,6 @@ #define MAX_SUFFIX_LEN 10 #define MAX_STRING_LEN 80 #define MAX_BUF_SIZE 0xFFFF -#define CEILING(x, y) (((x) + (y) - 1) / (y)) #define USB_VENDOR_ID_SMSC 0x0424 /* VID: SMSC */ #define USB_DEV_ID_BRDG 0xC001 /* PID: USB Bridge */ @@ -137,7 +136,6 @@ struct most_dev { #define to_mdev(d) container_of(d, struct most_dev, iface) #define to_mdev_from_work(w) container_of(w, struct most_dev, poll_work_obj) -static struct workqueue_struct *schedule_usb_work; static void wq_clear_halt(struct work_struct *wq_obj); static void wq_netinfo(struct work_struct *wq_obj); @@ -226,6 +224,8 @@ static void free_anchored_buffers(struct most_dev *mdev, unsigned int channel) kfree(anchor); } spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + + cancel_work_sync(&anchor->clear_work_obj); } /** @@ -411,7 +411,7 @@ static void hdm_write_completion(struct urb *urb) mbo->status = MBO_E_INVAL; usb_unlink_urb(urb); INIT_WORK(&anchor->clear_work_obj, wq_clear_halt); - queue_work(schedule_usb_work, &anchor->clear_work_obj); + schedule_work(&anchor->clear_work_obj); return; case -ENODEV: case -EPROTO: @@ -575,7 +575,7 @@ static void hdm_read_completion(struct urb *urb) mbo->status = MBO_E_INVAL; usb_unlink_urb(urb); INIT_WORK(&anchor->clear_work_obj, wq_clear_halt); - queue_work(schedule_usb_work, &anchor->clear_work_obj); + schedule_work(&anchor->clear_work_obj); return; case -ENODEV: case -EPROTO: @@ -785,7 +785,7 @@ static int hdm_configure_channel(struct most_interface *iface, int channel, temp_size += tail_space; /* calculate extra length to comply w/ HW padding */ - conf->extra_len = (CEILING(temp_size, USB_MTU) * USB_MTU) + conf->extra_len = (DIV_ROUND_UP(temp_size, USB_MTU) * USB_MTU) - conf->buffer_size; exit: mdev->conf[channel] = *conf; @@ -872,7 +872,7 @@ static void link_stat_timer_handler(unsigned long data) { struct most_dev *mdev = (struct most_dev *)data; - queue_work(schedule_usb_work, &mdev->poll_work_obj); + schedule_work(&mdev->poll_work_obj); mdev->link_stat_timer.expires = jiffies + (2 * HZ); add_timer(&mdev->link_stat_timer); } @@ -1415,19 +1415,13 @@ static int __init hdm_usb_init(void) pr_err("could not register hdm_usb driver\n"); return -EIO; } - schedule_usb_work = create_workqueue("hdmu_work"); - if (!schedule_usb_work) { - pr_err("could not create workqueue\n"); - usb_deregister(&hdm_usb); - return -ENOMEM; - } + return 0; } static void __exit hdm_usb_exit(void) { pr_info("hdm_usb_exit()\n"); - destroy_workqueue(schedule_usb_work); usb_deregister(&hdm_usb); } diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 322ee01..7c619fe 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1259,7 +1259,6 @@ static int arm_mbo_chain(struct most_c_obj *c, int dir, for (i = 0; i < c->cfg.num_buffers; i++) { mbo = kzalloc(sizeof(*mbo), GFP_KERNEL); if (!mbo) { - pr_info("WARN: Allocation of MBO failed.\n"); retval = i; goto _exit; } diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 3d9a426..75fe61c 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -175,7 +175,7 @@ static int wait_till_ready(struct spi_device *spi_nand) retval = spinand_read_status(spi_nand, &stat); if (retval < 0) return -1; - else if (!(stat & 0x1)) + if (!(stat & 0x1)) break; cond_resched(); diff --git a/drivers/staging/netlogic/platform_net.c b/drivers/staging/netlogic/platform_net.c index 9b52154..abf4c71 100644 --- a/drivers/staging/netlogic/platform_net.c +++ b/drivers/staging/netlogic/platform_net.c @@ -170,7 +170,7 @@ static void xls_gmac_init(void) xlr_net_dev0.num_resources = 2; xlr_resource_init(&xlr_net0_res[0], xlr_gmac_offsets[0], - xlr_gmac_irqs[0]); + xlr_gmac_irqs[0]); platform_device_register(&xlr_net_dev0); /* second block is XAUI, not supported yet */ @@ -183,7 +183,7 @@ static void xls_gmac_init(void) ndata0.phy_addr[mac] = mac + 0x10; xlr_resource_init(&xlr_net0_res[mac * 2], - xlr_gmac_offsets[mac], + xlr_gmac_offsets[mac], xlr_gmac_irqs[mac]); } xlr_net_dev0.num_resources = 8; @@ -223,7 +223,7 @@ static void xlr_gmac_init(void) ndata0.tx_stnid[mac] = FMN_STNID_GMAC0_TX0 + mac; ndata0.phy_addr[mac] = mac; xlr_resource_init(&xlr_net0_res[mac * 2], xlr_gmac_offsets[mac], - xlr_gmac_irqs[mac]); + xlr_gmac_irqs[mac]); } xlr_net_dev0.num_resources = 8; xlr_net_dev0.resource = xlr_net0_res; diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c index 0b4e819..0015847 100644 --- a/drivers/staging/netlogic/xlr_net.c +++ b/drivers/staging/netlogic/xlr_net.c @@ -69,8 +69,7 @@ static inline u32 xlr_nae_rdreg(u32 __iomem *base, unsigned int reg) return __raw_readl(base + reg); } -static inline void xlr_reg_update(u32 *base_addr, - u32 off, u32 val, u32 mask) +static inline void xlr_reg_update(u32 *base_addr, u32 off, u32 val, u32 mask) { u32 tmp; @@ -122,8 +121,8 @@ static inline unsigned char *xlr_alloc_skb(void) return skb->data; } -static void xlr_net_fmn_handler(int bkt, int src_stnid, int size, - int code, struct nlm_fmn_msg *msg, void *arg) +static void xlr_net_fmn_handler(int bkt, int src_stnid, int size, int code, + struct nlm_fmn_msg *msg, void *arg) { struct sk_buff *skb; void *skb_data = NULL; @@ -131,13 +130,13 @@ static void xlr_net_fmn_handler(int bkt, int src_stnid, int size, struct xlr_net_priv *priv; u32 port, length; unsigned char *addr; - struct xlr_adapter *adapter = (struct xlr_adapter *) arg; + struct xlr_adapter *adapter = (struct xlr_adapter *)arg; length = (msg->msg0 >> 40) & 0x3fff; if (length == 0) { addr = bus_to_virt(msg->msg0 & 0xffffffffffULL); addr = addr - MAC_SKB_BACK_PTR_SIZE; - skb = (struct sk_buff *) *(unsigned long *)addr; + skb = (struct sk_buff *)(*(unsigned long *)addr); dev_kfree_skb_any((struct sk_buff *)addr); } else { addr = (unsigned char *) @@ -145,9 +144,9 @@ static void xlr_net_fmn_handler(int bkt, int src_stnid, int size, length = length - BYTE_OFFSET - MAC_CRC_LEN; port = ((int)msg->msg0) & 0x0f; addr = addr - MAC_SKB_BACK_PTR_SIZE; - skb = (struct sk_buff *) *(unsigned long *)addr; + skb = (struct sk_buff *)(*(unsigned long *)addr); skb->dev = adapter->netdev[port]; - if (skb->dev == NULL) + if (!skb->dev) return; ndev = skb->dev; priv = netdev_priv(ndev); @@ -207,7 +206,7 @@ static int xlr_net_fill_rx_ring(struct net_device *ndev) struct xlr_net_priv *priv = netdev_priv(ndev); int i; - for (i = 0; i < MAX_FRIN_SPILL/4; i++) { + for (i = 0; i < MAX_FRIN_SPILL / 4; i++) { skb_data = xlr_alloc_skb(); if (!skb_data) { pr_err("SKB allocation failed\n"); @@ -252,7 +251,7 @@ static int xlr_net_stop(struct net_device *ndev) } static void xlr_make_tx_desc(struct nlm_fmn_msg *msg, unsigned long addr, - struct sk_buff *skb) + struct sk_buff *skb) { unsigned long physkb = virt_to_phys(skb); int cpu_core = nlm_core_id(); @@ -266,12 +265,13 @@ static void xlr_make_tx_desc(struct nlm_fmn_msg *msg, unsigned long addr, ((u64)fr_stn_id << 54) | /* Free back id */ (u64)0 << 40 | /* Set len to 0 */ ((u64)physkb & 0xffffffff)); /* 32bit address */ - msg->msg2 = msg->msg3 = 0; + msg->msg2 = 0; + msg->msg3 = 0; } static void __maybe_unused xlr_wakeup_queue(unsigned long dev) { - struct net_device *ndev = (struct net_device *) dev; + struct net_device *ndev = (struct net_device *)dev; struct xlr_net_priv *priv = netdev_priv(ndev); struct phy_device *phydev = xlr_get_phydev(priv); @@ -280,7 +280,7 @@ static void __maybe_unused xlr_wakeup_queue(unsigned long dev) } static netdev_tx_t xlr_net_start_xmit(struct sk_buff *skb, - struct net_device *ndev) + struct net_device *ndev) { struct nlm_fmn_msg msg; struct xlr_net_priv *priv = netdev_priv(ndev); @@ -309,10 +309,10 @@ static void xlr_hw_set_mac_addr(struct net_device *ndev) /* set mac station address */ xlr_nae_wreg(priv->base_addr, R_MAC_ADDR0, - ((ndev->dev_addr[5] << 24) | (ndev->dev_addr[4] << 16) | - (ndev->dev_addr[3] << 8) | (ndev->dev_addr[2]))); + ((ndev->dev_addr[5] << 24) | (ndev->dev_addr[4] << 16) | + (ndev->dev_addr[3] << 8) | (ndev->dev_addr[2]))); xlr_nae_wreg(priv->base_addr, R_MAC_ADDR0 + 1, - ((ndev->dev_addr[1] << 24) | (ndev->dev_addr[0] << 16))); + ((ndev->dev_addr[1] << 24) | (ndev->dev_addr[0] << 16))); xlr_nae_wreg(priv->base_addr, R_MAC_ADDR_MASK2, 0xffffffff); xlr_nae_wreg(priv->base_addr, R_MAC_ADDR_MASK2 + 1, 0xffffffff); @@ -320,12 +320,12 @@ static void xlr_hw_set_mac_addr(struct net_device *ndev) xlr_nae_wreg(priv->base_addr, R_MAC_ADDR_MASK3 + 1, 0xffffffff); xlr_nae_wreg(priv->base_addr, R_MAC_FILTER_CONFIG, - (1 << O_MAC_FILTER_CONFIG__BROADCAST_EN) | - (1 << O_MAC_FILTER_CONFIG__ALL_MCAST_EN) | - (1 << O_MAC_FILTER_CONFIG__MAC_ADDR0_VALID)); + (1 << O_MAC_FILTER_CONFIG__BROADCAST_EN) | + (1 << O_MAC_FILTER_CONFIG__ALL_MCAST_EN) | + (1 << O_MAC_FILTER_CONFIG__MAC_ADDR0_VALID)); if (priv->nd->phy_interface == PHY_INTERFACE_MODE_RGMII || - priv->nd->phy_interface == PHY_INTERFACE_MODE_SGMII) + priv->nd->phy_interface == PHY_INTERFACE_MODE_SGMII) xlr_reg_update(priv->base_addr, R_IPG_IFG, MAC_B2B_IPG, 0x7f); } @@ -406,7 +406,8 @@ static void xlr_stats(struct net_device *ndev, struct rtnl_link_stats64 *stats) } static struct rtnl_link_stats64 *xlr_get_stats64(struct net_device *ndev, - struct rtnl_link_stats64 *stats) + struct rtnl_link_stats64 *stats + ) { xlr_stats(ndev, stats); return stats; @@ -426,7 +427,7 @@ static struct net_device_ops xlr_netdev_ops = { * Gmac init */ static void *xlr_config_spill(struct xlr_net_priv *priv, int reg_start_0, - int reg_start_1, int reg_size, int size) + int reg_start_1, int reg_size, int size) { void *spill; u32 *base; @@ -436,13 +437,15 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, int reg_start_0, base = priv->base_addr; spill_size = size; spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_ATOMIC); - if (!spill) + if (!spill) { pr_err("Unable to allocate memory for spill area!\n"); + return ZERO_SIZE_PTR; + } spill = PTR_ALIGN(spill, SMP_CACHE_BYTES); phys_addr = virt_to_phys(spill); dev_dbg(&priv->ndev->dev, "Allocated spill %d bytes at %lx\n", - size, phys_addr); + size, phys_addr); xlr_nae_wreg(base, reg_start_0, (phys_addr >> 5) & 0xffffffff); xlr_nae_wreg(base, reg_start_1, ((u64)phys_addr >> 37) & 0x07); xlr_nae_wreg(base, reg_size, spill_size); @@ -511,19 +514,19 @@ static void xlr_config_pde(struct xlr_net_priv *priv) xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_0, (bkt_map & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_0 + 1, - ((bkt_map >> 32) & 0xffffffff)); + ((bkt_map >> 32) & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_1, (bkt_map & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_1 + 1, - ((bkt_map >> 32) & 0xffffffff)); + ((bkt_map >> 32) & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_2, (bkt_map & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_2 + 1, - ((bkt_map >> 32) & 0xffffffff)); + ((bkt_map >> 32) & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_3, (bkt_map & 0xffffffff)); xlr_nae_wreg(priv->base_addr, R_PDE_CLASS_3 + 1, - ((bkt_map >> 32) & 0xffffffff)); + ((bkt_map >> 32) & 0xffffffff)); } /* @@ -541,8 +544,8 @@ static int xlr_config_common(struct xlr_net_priv *priv) /* Setting non-core MsgBktSize(0x321 - 0x325) */ for (i = start_stn_id; i <= end_stn_id; i++) { xlr_nae_wreg(priv->base_addr, - R_GMAC_RFR0_BUCKET_SIZE + i - start_stn_id, - bucket_size[i]); + R_GMAC_RFR0_BUCKET_SIZE + i - start_stn_id, + bucket_size[i]); } /* @@ -552,8 +555,8 @@ static int xlr_config_common(struct xlr_net_priv *priv) for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) xlr_nae_wreg(priv->base_addr, - (R_CC_CPU0_0 + (i * 8)) + j, - gmac->credit_config[(i * 8) + j]); + (R_CC_CPU0_0 + (i * 8)) + j, + gmac->credit_config[(i * 8) + j]); } xlr_nae_wreg(priv->base_addr, R_MSG_TX_THRESHOLD, 3); @@ -567,7 +570,7 @@ static int xlr_config_common(struct xlr_net_priv *priv) if (err) return err; nlm_register_fmn_handler(start_stn_id, end_stn_id, xlr_net_fmn_handler, - priv->adapter); + priv->adapter); return 0; } @@ -583,7 +586,7 @@ static void xlr_config_translate_table(struct xlr_net_priv *priv) cpu_mask = priv->nd->cpu_mask; pr_info("Using %s-based distribution\n", - (use_bkt) ? "bucket" : "class"); + (use_bkt) ? "bucket" : "class"); j = 0; for (i = 0; i < 32; i++) { if ((1 << i) & cpu_mask) { @@ -614,7 +617,7 @@ static void xlr_config_translate_table(struct xlr_net_priv *priv) val = ((c1 << 23) | (b1 << 17) | (use_bkt << 16) | (c2 << 7) | (b2 << 1) | (use_bkt << 0)); dev_dbg(&priv->ndev->dev, "Table[%d] b1=%d b2=%d c1=%d c2=%d\n", - i, b1, b2, c1, c2); + i, b1, b2, c1, c2); xlr_nae_wreg(priv->base_addr, R_TRANSLATETABLE + i, val); c1 = c2; } @@ -629,16 +632,16 @@ static void xlr_config_parser(struct xlr_net_priv *priv) /* Use 7bit CRChash for flow classification with 127 as CRC polynomial*/ xlr_nae_wreg(priv->base_addr, R_PARSERCONFIGREG, - ((0x7f << 8) | (1 << 1))); + ((0x7f << 8) | (1 << 1))); /* configure the parser : L2 Type is configured in the bootloader */ /* extract IP: src, dest protocol */ xlr_nae_wreg(priv->base_addr, R_L3CTABLE, - (9 << 20) | (1 << 19) | (1 << 18) | (0x01 << 16) | - (0x0800 << 0)); + (9 << 20) | (1 << 19) | (1 << 18) | (0x01 << 16) | + (0x0800 << 0)); xlr_nae_wreg(priv->base_addr, R_L3CTABLE + 1, - (9 << 25) | (1 << 21) | (12 << 14) | (4 << 10) | - (16 << 4) | 4); + (9 << 25) | (1 << 21) | (12 << 14) | (4 << 10) | + (16 << 4) | 4); /* Configure to extract SRC port and Dest port for TCP and UDP pkts */ xlr_nae_wreg(priv->base_addr, R_L4CTABLE, 6); @@ -663,7 +666,7 @@ static int xlr_phy_write(u32 *base_addr, int phy_addr, int regnum, u16 val) xlr_nae_wreg(base_addr, R_MII_MGMT_ADDRESS, (phy_addr << 8) | regnum); /* Write the data which starts the write cycle */ - xlr_nae_wreg(base_addr, R_MII_MGMT_WRITE_DATA, (u32) val); + xlr_nae_wreg(base_addr, R_MII_MGMT_WRITE_DATA, (u32)val); /* poll for the read cycle to complete */ while (!timedout) { @@ -692,11 +695,11 @@ static int xlr_phy_read(u32 *base_addr, int phy_addr, int regnum) /* setup the phy reg to be used */ xlr_nae_wreg(base_addr, R_MII_MGMT_ADDRESS, - (phy_addr << 8) | (regnum << 0)); + (phy_addr << 8) | (regnum << 0)); /* Issue the read command */ xlr_nae_wreg(base_addr, R_MII_MGMT_COMMAND, - (1 << O_MII_MGMT_COMMAND__rstat)); + (1 << O_MII_MGMT_COMMAND__rstat)); /* poll for the read cycle to complete */ while (!timedout) { @@ -724,7 +727,7 @@ static int xlr_mii_write(struct mii_bus *bus, int phy_addr, int regnum, u16 val) ret = xlr_phy_write(priv->mii_addr, phy_addr, regnum, val); dev_dbg(&priv->ndev->dev, "mii_write phy %d : %d <- %x [%x]\n", - phy_addr, regnum, val, ret); + phy_addr, regnum, val, ret); return ret; } @@ -735,7 +738,7 @@ static int xlr_mii_read(struct mii_bus *bus, int phy_addr, int regnum) ret = xlr_phy_read(priv->mii_addr, phy_addr, regnum); dev_dbg(&priv->ndev->dev, "mii_read phy %d : %d [%x]\n", - phy_addr, regnum, ret); + phy_addr, regnum, ret); return ret; } @@ -797,13 +800,16 @@ void xlr_set_gmac_speed(struct xlr_net_priv *priv) if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { if (speed == SPEED_10) xlr_nae_wreg(priv->base_addr, - R_INTERFACE_CONTROL, SGMII_SPEED_10); + R_INTERFACE_CONTROL, + SGMII_SPEED_10); if (speed == SPEED_100) xlr_nae_wreg(priv->base_addr, - R_INTERFACE_CONTROL, SGMII_SPEED_100); + R_INTERFACE_CONTROL, + SGMII_SPEED_100); if (speed == SPEED_1000) xlr_nae_wreg(priv->base_addr, - R_INTERFACE_CONTROL, SGMII_SPEED_1000); + R_INTERFACE_CONTROL, + SGMII_SPEED_1000); } if (speed == SPEED_10) xlr_nae_wreg(priv->base_addr, R_CORECONTROL, 0x2); @@ -864,7 +870,7 @@ static int xlr_mii_probe(struct xlr_net_priv *priv) } static int xlr_setup_mdio(struct xlr_net_priv *priv, - struct platform_device *pdev) + struct platform_device *pdev) { int err; @@ -877,7 +883,7 @@ static int xlr_setup_mdio(struct xlr_net_priv *priv, priv->mii_bus->priv = priv; priv->mii_bus->name = "xlr-mdio"; snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d", - priv->mii_bus->name, priv->port_id); + priv->mii_bus->name, priv->port_id); priv->mii_bus->read = xlr_mii_read; priv->mii_bus->write = xlr_mii_write; priv->mii_bus->parent = &pdev->dev; @@ -910,25 +916,31 @@ static void xlr_port_enable(struct xlr_net_priv *priv) /* Setup MAC_CONFIG reg if (xls & rgmii) */ if ((prid == 0x8000 || prid == 0x4000 || prid == 0xc000) && - priv->nd->phy_interface == PHY_INTERFACE_MODE_RGMII) + priv->nd->phy_interface == PHY_INTERFACE_MODE_RGMII) xlr_reg_update(priv->base_addr, R_RX_CONTROL, - (1 << O_RX_CONTROL__RGMII), (1 << O_RX_CONTROL__RGMII)); + (1 << O_RX_CONTROL__RGMII), + (1 << O_RX_CONTROL__RGMII)); /* Rx Tx enable */ xlr_reg_update(priv->base_addr, R_MAC_CONFIG_1, - ((1 << O_MAC_CONFIG_1__rxen) | (1 << O_MAC_CONFIG_1__txen) | - (1 << O_MAC_CONFIG_1__rxfc) | (1 << O_MAC_CONFIG_1__txfc)), - ((1 << O_MAC_CONFIG_1__rxen) | (1 << O_MAC_CONFIG_1__txen) | - (1 << O_MAC_CONFIG_1__rxfc) | (1 << O_MAC_CONFIG_1__txfc))); + ((1 << O_MAC_CONFIG_1__rxen) | + (1 << O_MAC_CONFIG_1__txen) | + (1 << O_MAC_CONFIG_1__rxfc) | + (1 << O_MAC_CONFIG_1__txfc)), + ((1 << O_MAC_CONFIG_1__rxen) | + (1 << O_MAC_CONFIG_1__txen) | + (1 << O_MAC_CONFIG_1__rxfc) | + (1 << O_MAC_CONFIG_1__txfc))); /* Setup tx control reg */ xlr_reg_update(priv->base_addr, R_TX_CONTROL, - ((1 << O_TX_CONTROL__TxEnable) | - (512 << O_TX_CONTROL__TxThreshold)), 0x3fff); + ((1 << O_TX_CONTROL__TXENABLE) | + (512 << O_TX_CONTROL__TXTHRESHOLD)), 0x3fff); /* Setup rx control reg */ xlr_reg_update(priv->base_addr, R_RX_CONTROL, - 1 << O_RX_CONTROL__RxEnable, 1 << O_RX_CONTROL__RxEnable); + 1 << O_RX_CONTROL__RXENABLE, + 1 << O_RX_CONTROL__RXENABLE); } static void xlr_port_disable(struct xlr_net_priv *priv) @@ -936,25 +948,26 @@ static void xlr_port_disable(struct xlr_net_priv *priv) /* Setup MAC_CONFIG reg */ /* Rx Tx disable*/ xlr_reg_update(priv->base_addr, R_MAC_CONFIG_1, - ((1 << O_MAC_CONFIG_1__rxen) | (1 << O_MAC_CONFIG_1__txen) | - (1 << O_MAC_CONFIG_1__rxfc) | (1 << O_MAC_CONFIG_1__txfc)), - 0x0); + ((1 << O_MAC_CONFIG_1__rxen) | + (1 << O_MAC_CONFIG_1__txen) | + (1 << O_MAC_CONFIG_1__rxfc) | + (1 << O_MAC_CONFIG_1__txfc)), 0x0); /* Setup tx control reg */ xlr_reg_update(priv->base_addr, R_TX_CONTROL, - ((1 << O_TX_CONTROL__TxEnable) | - (512 << O_TX_CONTROL__TxThreshold)), 0); + ((1 << O_TX_CONTROL__TXENABLE) | + (512 << O_TX_CONTROL__TXTHRESHOLD)), 0); /* Setup rx control reg */ xlr_reg_update(priv->base_addr, R_RX_CONTROL, - 1 << O_RX_CONTROL__RxEnable, 0); + 1 << O_RX_CONTROL__RXENABLE, 0); } /* * Initialization of gmac */ static int xlr_gmac_init(struct xlr_net_priv *priv, - struct platform_device *pdev) + struct platform_device *pdev) { int ret; @@ -963,9 +976,9 @@ static int xlr_gmac_init(struct xlr_net_priv *priv, xlr_port_disable(priv); xlr_nae_wreg(priv->base_addr, R_DESC_PACK_CTRL, - (1 << O_DESC_PACK_CTRL__MaxEntry) - | (BYTE_OFFSET << O_DESC_PACK_CTRL__ByteOffset) - | (1600 << O_DESC_PACK_CTRL__RegularSize)); + (1 << O_DESC_PACK_CTRL__MAXENTRY) | + (BYTE_OFFSET << O_DESC_PACK_CTRL__BYTEOFFSET) | + (1600 << O_DESC_PACK_CTRL__REGULARSIZE)); ret = xlr_setup_mdio(priv, pdev); if (ret) @@ -977,21 +990,14 @@ static int xlr_gmac_init(struct xlr_net_priv *priv, /* speed 2.5Mhz */ xlr_nae_wreg(priv->base_addr, R_CORECONTROL, 0x02); /* Setup Interrupt mask reg */ - xlr_nae_wreg(priv->base_addr, R_INTMASK, - (1 << O_INTMASK__TxIllegal) | - (1 << O_INTMASK__MDInt) | - (1 << O_INTMASK__TxFetchError) | - (1 << O_INTMASK__P2PSpillEcc) | - (1 << O_INTMASK__TagFull) | - (1 << O_INTMASK__Underrun) | - (1 << O_INTMASK__Abort) - ); + xlr_nae_wreg(priv->base_addr, R_INTMASK, (1 << O_INTMASK__TXILLEGAL) | + (1 << O_INTMASK__MDINT) | (1 << O_INTMASK__TXFETCHERROR) | + (1 << O_INTMASK__P2PSPILLECC) | (1 << O_INTMASK__TAGFULL) | + (1 << O_INTMASK__UNDERRUN) | (1 << O_INTMASK__ABORT)); /* Clear all stats */ - xlr_reg_update(priv->base_addr, R_STATCTRL, - 0, 1 << O_STATCTRL__ClrCnt); - xlr_reg_update(priv->base_addr, R_STATCTRL, 1 << 2, - 1 << 2); + xlr_reg_update(priv->base_addr, R_STATCTRL, 0, 1 << O_STATCTRL__CLRCNT); + xlr_reg_update(priv->base_addr, R_STATCTRL, 1 << 2, 1 << 2); return 0; } @@ -1019,7 +1025,7 @@ static int xlr_net_probe(struct platform_device *pdev) * Each controller has 4 gmac ports, mapping each controller * under one parent device, 4 gmac ports under one device. */ - for (port = 0; port < pdev->num_resources/2; port++) { + for (port = 0; port < pdev->num_resources / 2; port++) { ndev = alloc_etherdev_mq(sizeof(struct xlr_net_priv), 32); if (!ndev) { pr_err("Allocation of Ethernet device failed\n"); @@ -1035,7 +1041,7 @@ static int xlr_net_probe(struct platform_device *pdev) if (res == NULL) { pr_err("No memory resource for MAC %d\n", - priv->port_id); + priv->port_id); err = -ENODEV; goto err_gmac; } @@ -1048,7 +1054,7 @@ static int xlr_net_probe(struct platform_device *pdev) adapter->netdev[port] = ndev; res = platform_get_resource(pdev, IORESOURCE_IRQ, port); - if (res == NULL) { + if (!res) { pr_err("No irq resource for MAC %d\n", priv->port_id); err = -ENODEV; goto err_gmac; @@ -1098,7 +1104,7 @@ static int xlr_net_probe(struct platform_device *pdev) err = register_netdev(ndev); if (err) { pr_err("Registering netdev failed for gmac%d\n", - priv->port_id); + priv->port_id); goto err_netdev; } platform_set_drvdata(pdev, priv); diff --git a/drivers/staging/netlogic/xlr_net.h b/drivers/staging/netlogic/xlr_net.h index 7ae8874..f76e16c 100644 --- a/drivers/staging/netlogic/xlr_net.h +++ b/drivers/staging/netlogic/xlr_net.h @@ -277,332 +277,332 @@ #define O_MAC_FILTER_CONFIG__MAC_ADDR0_VALID 0 #define R_HASH_TABLE_VECTOR 0x30 #define R_TX_CONTROL 0x0A0 -#define O_TX_CONTROL__Tx15Halt 31 -#define O_TX_CONTROL__Tx14Halt 30 -#define O_TX_CONTROL__Tx13Halt 29 -#define O_TX_CONTROL__Tx12Halt 28 -#define O_TX_CONTROL__Tx11Halt 27 -#define O_TX_CONTROL__Tx10Halt 26 -#define O_TX_CONTROL__Tx9Halt 25 -#define O_TX_CONTROL__Tx8Halt 24 -#define O_TX_CONTROL__Tx7Halt 23 -#define O_TX_CONTROL__Tx6Halt 22 -#define O_TX_CONTROL__Tx5Halt 21 -#define O_TX_CONTROL__Tx4Halt 20 -#define O_TX_CONTROL__Tx3Halt 19 -#define O_TX_CONTROL__Tx2Halt 18 -#define O_TX_CONTROL__Tx1Halt 17 -#define O_TX_CONTROL__Tx0Halt 16 -#define O_TX_CONTROL__TxIdle 15 -#define O_TX_CONTROL__TxEnable 14 -#define O_TX_CONTROL__TxThreshold 0 -#define W_TX_CONTROL__TxThreshold 14 +#define O_TX_CONTROL__TX15HALT 31 +#define O_TX_CONTROL__TX14HALT 30 +#define O_TX_CONTROL__TX13HALT 29 +#define O_TX_CONTROL__TX12HALT 28 +#define O_TX_CONTROL__TX11HALT 27 +#define O_TX_CONTROL__TX10HALT 26 +#define O_TX_CONTROL__TX9HALT 25 +#define O_TX_CONTROL__TX8HALT 24 +#define O_TX_CONTROL__TX7HALT 23 +#define O_TX_CONTROL__TX6HALT 22 +#define O_TX_CONTROL__TX5HALT 21 +#define O_TX_CONTROL__TX4HALT 20 +#define O_TX_CONTROL__TX3HALT 19 +#define O_TX_CONTROL__TX2HALT 18 +#define O_TX_CONTROL__TX1HALT 17 +#define O_TX_CONTROL__TX0HALT 16 +#define O_TX_CONTROL__TXIDLE 15 +#define O_TX_CONTROL__TXENABLE 14 +#define O_TX_CONTROL__TXTHRESHOLD 0 +#define W_TX_CONTROL__TXTHRESHOLD 14 #define R_RX_CONTROL 0x0A1 #define O_RX_CONTROL__RGMII 10 -#define O_RX_CONTROL__SoftReset 2 -#define O_RX_CONTROL__RxHalt 1 -#define O_RX_CONTROL__RxEnable 0 +#define O_RX_CONTROL__SOFTRESET 2 +#define O_RX_CONTROL__RXHALT 1 +#define O_RX_CONTROL__RXENABLE 0 #define R_DESC_PACK_CTRL 0x0A2 -#define O_DESC_PACK_CTRL__ByteOffset 17 -#define W_DESC_PACK_CTRL__ByteOffset 3 -#define O_DESC_PACK_CTRL__PrePadEnable 16 -#define O_DESC_PACK_CTRL__MaxEntry 14 -#define W_DESC_PACK_CTRL__MaxEntry 2 -#define O_DESC_PACK_CTRL__RegularSize 0 -#define W_DESC_PACK_CTRL__RegularSize 14 +#define O_DESC_PACK_CTRL__BYTEOFFSET 17 +#define W_DESC_PACK_CTRL__BYTEOFFSET 3 +#define O_DESC_PACK_CTRL__PREPADENABLE 16 +#define O_DESC_PACK_CTRL__MAXENTRY 14 +#define W_DESC_PACK_CTRL__MAXENTRY 2 +#define O_DESC_PACK_CTRL__REGULARSIZE 0 +#define W_DESC_PACK_CTRL__REGULARSIZE 14 #define R_STATCTRL 0x0A3 -#define O_STATCTRL__OverFlowEn 4 +#define O_STATCTRL__OVERFLOWEN 4 #define O_STATCTRL__GIG 3 -#define O_STATCTRL__Sten 2 -#define O_STATCTRL__ClrCnt 1 -#define O_STATCTRL__AutoZ 0 +#define O_STATCTRL__STEN 2 +#define O_STATCTRL__CLRCNT 1 +#define O_STATCTRL__AUTOZ 0 #define R_L2ALLOCCTRL 0x0A4 -#define O_L2ALLOCCTRL__TxL2Allocate 9 -#define W_L2ALLOCCTRL__TxL2Allocate 9 -#define O_L2ALLOCCTRL__RxL2Allocate 0 -#define W_L2ALLOCCTRL__RxL2Allocate 9 +#define O_L2ALLOCCTRL__TXL2ALLOCATE 9 +#define W_L2ALLOCCTRL__TXL2ALLOCATE 9 +#define O_L2ALLOCCTRL__RXL2ALLOCATE 0 +#define W_L2ALLOCCTRL__RXL2ALLOCATE 9 #define R_INTMASK 0x0A5 -#define O_INTMASK__Spi4TxError 28 -#define O_INTMASK__Spi4RxError 27 -#define O_INTMASK__RGMIIHalfDupCollision 27 -#define O_INTMASK__Abort 26 -#define O_INTMASK__Underrun 25 -#define O_INTMASK__DiscardPacket 24 -#define O_INTMASK__AsyncFifoFull 23 -#define O_INTMASK__TagFull 22 -#define O_INTMASK__Class3Full 21 -#define O_INTMASK__C3EarlyFull 20 -#define O_INTMASK__Class2Full 19 -#define O_INTMASK__C2EarlyFull 18 -#define O_INTMASK__Class1Full 17 -#define O_INTMASK__C1EarlyFull 16 -#define O_INTMASK__Class0Full 15 -#define O_INTMASK__C0EarlyFull 14 -#define O_INTMASK__RxDataFull 13 -#define O_INTMASK__RxEarlyFull 12 -#define O_INTMASK__RFreeEmpty 9 -#define O_INTMASK__RFEarlyEmpty 8 -#define O_INTMASK__P2PSpillEcc 7 -#define O_INTMASK__FreeDescFull 5 -#define O_INTMASK__FreeEarlyFull 4 -#define O_INTMASK__TxFetchError 3 -#define O_INTMASK__StatCarry 2 -#define O_INTMASK__MDInt 1 -#define O_INTMASK__TxIllegal 0 +#define O_INTMASK__SPI4TXERROR 28 +#define O_INTMASK__SPI4RXERROR 27 +#define O_INTMASK__RGMIIHALFDUPCOLLISION 27 +#define O_INTMASK__ABORT 26 +#define O_INTMASK__UNDERRUN 25 +#define O_INTMASK__DISCARDPACKET 24 +#define O_INTMASK__ASYNCFIFOFULL 23 +#define O_INTMASK__TAGFULL 22 +#define O_INTMASK__CLASS3FULL 21 +#define O_INTMASK__C3EARLYFULL 20 +#define O_INTMASK__CLASS2FULL 19 +#define O_INTMASK__C2EARLYFULL 18 +#define O_INTMASK__CLASS1FULL 17 +#define O_INTMASK__C1EARLYFULL 16 +#define O_INTMASK__CLASS0FULL 15 +#define O_INTMASK__C0EARLYFULL 14 +#define O_INTMASK__RXDATAFULL 13 +#define O_INTMASK__RXEARLYFULL 12 +#define O_INTMASK__RFREEEMPTY 9 +#define O_INTMASK__RFEARLYEMPTY 8 +#define O_INTMASK__P2PSPILLECC 7 +#define O_INTMASK__FREEDESCFULL 5 +#define O_INTMASK__FREEEARLYFULL 4 +#define O_INTMASK__TXFETCHERROR 3 +#define O_INTMASK__STATCARRY 2 +#define O_INTMASK__MDINT 1 +#define O_INTMASK__TXILLEGAL 0 #define R_INTREG 0x0A6 -#define O_INTREG__Spi4TxError 28 -#define O_INTREG__Spi4RxError 27 -#define O_INTREG__RGMIIHalfDupCollision 27 -#define O_INTREG__Abort 26 -#define O_INTREG__Underrun 25 -#define O_INTREG__DiscardPacket 24 -#define O_INTREG__AsyncFifoFull 23 -#define O_INTREG__TagFull 22 -#define O_INTREG__Class3Full 21 -#define O_INTREG__C3EarlyFull 20 -#define O_INTREG__Class2Full 19 -#define O_INTREG__C2EarlyFull 18 -#define O_INTREG__Class1Full 17 -#define O_INTREG__C1EarlyFull 16 -#define O_INTREG__Class0Full 15 -#define O_INTREG__C0EarlyFull 14 -#define O_INTREG__RxDataFull 13 -#define O_INTREG__RxEarlyFull 12 -#define O_INTREG__RFreeEmpty 9 -#define O_INTREG__RFEarlyEmpty 8 -#define O_INTREG__P2PSpillEcc 7 -#define O_INTREG__FreeDescFull 5 -#define O_INTREG__FreeEarlyFull 4 -#define O_INTREG__TxFetchError 3 -#define O_INTREG__StatCarry 2 -#define O_INTREG__MDInt 1 -#define O_INTREG__TxIllegal 0 +#define O_INTREG__SPI4TXERROR 28 +#define O_INTREG__SPI4RXERROR 27 +#define O_INTREG__RGMIIHALFDUPCOLLISION 27 +#define O_INTREG__ABORT 26 +#define O_INTREG__UNDERRUN 25 +#define O_INTREG__DISCARDPACKET 24 +#define O_INTREG__ASYNCFIFOFULL 23 +#define O_INTREG__TAGFULL 22 +#define O_INTREG__CLASS3FULL 21 +#define O_INTREG__C3EARLYFULL 20 +#define O_INTREG__CLASS2FULL 19 +#define O_INTREG__C2EARLYFULL 18 +#define O_INTREG__CLASS1FULL 17 +#define O_INTREG__C1EARLYFULL 16 +#define O_INTREG__CLASS0FULL 15 +#define O_INTREG__C0EARLYFULL 14 +#define O_INTREG__RXDATAFULL 13 +#define O_INTREG__RXEARLYFULL 12 +#define O_INTREG__RFREEEMPTY 9 +#define O_INTREG__RFEARLYEMPTY 8 +#define O_INTREG__P2PSPILLECC 7 +#define O_INTREG__FREEDESCFULL 5 +#define O_INTREG__FREEEARLYFULL 4 +#define O_INTREG__TXFETCHERROR 3 +#define O_INTREG__STATCARRY 2 +#define O_INTREG__MDINT 1 +#define O_INTREG__TXILLEGAL 0 #define R_TXRETRY 0x0A7 -#define O_TXRETRY__CollisionRetry 6 -#define O_TXRETRY__BusErrorRetry 5 -#define O_TXRETRY__UnderRunRetry 4 -#define O_TXRETRY__Retries 0 -#define W_TXRETRY__Retries 4 +#define O_TXRETRY__COLLISIONRETRY 6 +#define O_TXRETRY__BUSERRORRETRY 5 +#define O_TXRETRY__UNDERRUNRETRY 4 +#define O_TXRETRY__RETRIES 0 +#define W_TXRETRY__RETRIES 4 #define R_CORECONTROL 0x0A8 -#define O_CORECONTROL__ErrorThread 4 -#define W_CORECONTROL__ErrorThread 7 -#define O_CORECONTROL__Shutdown 2 -#define O_CORECONTROL__Speed 0 -#define W_CORECONTROL__Speed 2 +#define O_CORECONTROL__ERRORTHREAD 4 +#define W_CORECONTROL__ERRORTHREAD 7 +#define O_CORECONTROL__SHUTDOWN 2 +#define O_CORECONTROL__SPEED 0 +#define W_CORECONTROL__SPEED 2 #define R_BYTEOFFSET0 0x0A9 #define R_BYTEOFFSET1 0x0AA #define R_L2TYPE_0 0x0F0 -#define O_L2TYPE__ExtraHdrProtoSize 26 -#define W_L2TYPE__ExtraHdrProtoSize 5 -#define O_L2TYPE__ExtraHdrProtoOffset 20 -#define W_L2TYPE__ExtraHdrProtoOffset 6 -#define O_L2TYPE__ExtraHeaderSize 14 -#define W_L2TYPE__ExtraHeaderSize 6 -#define O_L2TYPE__ProtoOffset 8 -#define W_L2TYPE__ProtoOffset 6 -#define O_L2TYPE__L2HdrOffset 2 -#define W_L2TYPE__L2HdrOffset 6 -#define O_L2TYPE__L2Proto 0 -#define W_L2TYPE__L2Proto 2 +#define O_L2TYPE__EXTRAHDRPROTOSIZE 26 +#define W_L2TYPE__EXTRAHDRPROTOSIZE 5 +#define O_L2TYPE__EXTRAHDRPROTOOFFSET 20 +#define W_L2TYPE__EXTRAHDRPROTOOFFSET 6 +#define O_L2TYPE__EXTRAHEADERSIZE 14 +#define W_L2TYPE__EXTRAHEADERSIZE 6 +#define O_L2TYPE__PROTOOFFSET 8 +#define W_L2TYPE__PROTOOFFSET 6 +#define O_L2TYPE__L2HDROFFSET 2 +#define W_L2TYPE__L2HDROFFSET 6 +#define O_L2TYPE__L2PROTO 0 +#define W_L2TYPE__L2PROTO 2 #define R_L2TYPE_1 0xF0 #define R_L2TYPE_2 0xF0 #define R_L2TYPE_3 0xF0 #define R_PARSERCONFIGREG 0x100 -#define O_PARSERCONFIGREG__CRCHashPoly 8 -#define W_PARSERCONFIGREG__CRCHashPoly 7 -#define O_PARSERCONFIGREG__PrePadOffset 4 -#define W_PARSERCONFIGREG__PrePadOffset 4 -#define O_PARSERCONFIGREG__UseCAM 2 -#define O_PARSERCONFIGREG__UseHASH 1 -#define O_PARSERCONFIGREG__UseProto 0 +#define O_PARSERCONFIGREG__CRCHASHPOLY 8 +#define W_PARSERCONFIGREG__CRCHASHPOLY 7 +#define O_PARSERCONFIGREG__PREPADOFFSET 4 +#define W_PARSERCONFIGREG__PREPADOFFSET 4 +#define O_PARSERCONFIGREG__USECAM 2 +#define O_PARSERCONFIGREG__USEHASH 1 +#define O_PARSERCONFIGREG__USEPROTO 0 #define R_L3CTABLE 0x140 -#define O_L3CTABLE__Offset0 25 -#define W_L3CTABLE__Offset0 7 -#define O_L3CTABLE__Len0 21 -#define W_L3CTABLE__Len0 4 -#define O_L3CTABLE__Offset1 14 -#define W_L3CTABLE__Offset1 7 -#define O_L3CTABLE__Len1 10 -#define W_L3CTABLE__Len1 4 -#define O_L3CTABLE__Offset2 4 -#define W_L3CTABLE__Offset2 6 -#define O_L3CTABLE__Len2 0 -#define W_L3CTABLE__Len2 4 -#define O_L3CTABLE__L3HdrOffset 26 -#define W_L3CTABLE__L3HdrOffset 6 -#define O_L3CTABLE__L4ProtoOffset 20 -#define W_L3CTABLE__L4ProtoOffset 6 -#define O_L3CTABLE__IPChksumCompute 19 -#define O_L3CTABLE__L4Classify 18 -#define O_L3CTABLE__L2Proto 16 -#define W_L3CTABLE__L2Proto 2 -#define O_L3CTABLE__L3ProtoKey 0 -#define W_L3CTABLE__L3ProtoKey 16 +#define O_L3CTABLE__OFFSET0 25 +#define W_L3CTABLE__OFFSET0 7 +#define O_L3CTABLE__LEN0 21 +#define W_L3CTABLE__LEN0 4 +#define O_L3CTABLE__OFFSET1 14 +#define W_L3CTABLE__OFFSET1 7 +#define O_L3CTABLE__LEN1 10 +#define W_L3CTABLE__LEN1 4 +#define O_L3CTABLE__OFFSET2 4 +#define W_L3CTABLE__OFFSET2 6 +#define O_L3CTABLE__LEN2 0 +#define W_L3CTABLE__LEN2 4 +#define O_L3CTABLE__L3HDROFFSET 26 +#define W_L3CTABLE__L3HDROFFSET 6 +#define O_L3CTABLE__L4PROTOOFFSET 20 +#define W_L3CTABLE__L4PROTOOFFSET 6 +#define O_L3CTABLE__IPCHKSUMCOMPUTE 19 +#define O_L3CTABLE__L4CLASSIFY 18 +#define O_L3CTABLE__L2PROTO 16 +#define W_L3CTABLE__L2PROTO 2 +#define O_L3CTABLE__L3PROTOKEY 0 +#define W_L3CTABLE__L3PROTOKEY 16 #define R_L4CTABLE 0x160 -#define O_L4CTABLE__Offset0 21 -#define W_L4CTABLE__Offset0 6 -#define O_L4CTABLE__Len0 17 -#define W_L4CTABLE__Len0 4 -#define O_L4CTABLE__Offset1 11 -#define W_L4CTABLE__Offset1 6 -#define O_L4CTABLE__Len1 7 -#define W_L4CTABLE__Len1 4 -#define O_L4CTABLE__TCPChksumEnable 0 +#define O_L4CTABLE__OFFSET0 21 +#define W_L4CTABLE__OFFSET0 6 +#define O_L4CTABLE__LEN0 17 +#define W_L4CTABLE__LEN0 4 +#define O_L4CTABLE__OFFSET1 11 +#define W_L4CTABLE__OFFSET1 6 +#define O_L4CTABLE__LEN1 7 +#define W_L4CTABLE__LEN1 4 +#define O_L4CTABLE__TCPCHKSUMENABLE 0 #define R_CAM4X128TABLE 0x172 -#define O_CAM4X128TABLE__ClassId 7 -#define W_CAM4X128TABLE__ClassId 2 -#define O_CAM4X128TABLE__BucketId 1 -#define W_CAM4X128TABLE__BucketId 6 -#define O_CAM4X128TABLE__UseBucket 0 +#define O_CAM4X128TABLE__CLASSID 7 +#define W_CAM4X128TABLE__CLASSID 2 +#define O_CAM4X128TABLE__BUCKETID 1 +#define W_CAM4X128TABLE__BUCKETID 6 +#define O_CAM4X128TABLE__USEBUCKET 0 #define R_CAM4X128KEY 0x180 #define R_TRANSLATETABLE 0x1A0 #define R_DMACR0 0x200 -#define O_DMACR0__Data0WrMaxCr 27 -#define W_DMACR0__Data0WrMaxCr 3 -#define O_DMACR0__Data0RdMaxCr 24 -#define W_DMACR0__Data0RdMaxCr 3 -#define O_DMACR0__Data1WrMaxCr 21 -#define W_DMACR0__Data1WrMaxCr 3 -#define O_DMACR0__Data1RdMaxCr 18 -#define W_DMACR0__Data1RdMaxCr 3 -#define O_DMACR0__Data2WrMaxCr 15 -#define W_DMACR0__Data2WrMaxCr 3 -#define O_DMACR0__Data2RdMaxCr 12 -#define W_DMACR0__Data2RdMaxCr 3 -#define O_DMACR0__Data3WrMaxCr 9 -#define W_DMACR0__Data3WrMaxCr 3 -#define O_DMACR0__Data3RdMaxCr 6 -#define W_DMACR0__Data3RdMaxCr 3 -#define O_DMACR0__Data4WrMaxCr 3 -#define W_DMACR0__Data4WrMaxCr 3 -#define O_DMACR0__Data4RdMaxCr 0 -#define W_DMACR0__Data4RdMaxCr 3 +#define O_DMACR0__DATA0WRMAXCR 27 +#define W_DMACR0__DATA0WRMAXCR 3 +#define O_DMACR0__DATA0RDMAXCR 24 +#define W_DMACR0__DATA0RDMAXCR 3 +#define O_DMACR0__DATA1WRMAXCR 21 +#define W_DMACR0__DATA1WRMAXCR 3 +#define O_DMACR0__DATA1RDMAXCR 18 +#define W_DMACR0__DATA1RDMAXCR 3 +#define O_DMACR0__DATA2WRMAXCR 15 +#define W_DMACR0__DATA2WRMAXCR 3 +#define O_DMACR0__DATA2RDMAXCR 12 +#define W_DMACR0__DATA2RDMAXCR 3 +#define O_DMACR0__DATA3WRMAXCR 9 +#define W_DMACR0__DATA3WRMAXCR 3 +#define O_DMACR0__DATA3RDMAXCR 6 +#define W_DMACR0__DATA3RDMAXCR 3 +#define O_DMACR0__DATA4WRMAXCR 3 +#define W_DMACR0__DATA4WRMAXCR 3 +#define O_DMACR0__DATA4RDMAXCR 0 +#define W_DMACR0__DATA4RDMAXCR 3 #define R_DMACR1 0x201 -#define O_DMACR1__Data5WrMaxCr 27 -#define W_DMACR1__Data5WrMaxCr 3 -#define O_DMACR1__Data5RdMaxCr 24 -#define W_DMACR1__Data5RdMaxCr 3 -#define O_DMACR1__Data6WrMaxCr 21 -#define W_DMACR1__Data6WrMaxCr 3 -#define O_DMACR1__Data6RdMaxCr 18 -#define W_DMACR1__Data6RdMaxCr 3 -#define O_DMACR1__Data7WrMaxCr 15 -#define W_DMACR1__Data7WrMaxCr 3 -#define O_DMACR1__Data7RdMaxCr 12 -#define W_DMACR1__Data7RdMaxCr 3 -#define O_DMACR1__Data8WrMaxCr 9 -#define W_DMACR1__Data8WrMaxCr 3 -#define O_DMACR1__Data8RdMaxCr 6 -#define W_DMACR1__Data8RdMaxCr 3 -#define O_DMACR1__Data9WrMaxCr 3 -#define W_DMACR1__Data9WrMaxCr 3 -#define O_DMACR1__Data9RdMaxCr 0 -#define W_DMACR1__Data9RdMaxCr 3 +#define O_DMACR1__DATA5WRMAXCR 27 +#define W_DMACR1__DATA5WRMAXCR 3 +#define O_DMACR1__DATA5RDMAXCR 24 +#define W_DMACR1__DATA5RDMAXCR 3 +#define O_DMACR1__DATA6WRMAXCR 21 +#define W_DMACR1__DATA6WRMAXCR 3 +#define O_DMACR1__DATA6RDMAXCR 18 +#define W_DMACR1__DATA6RDMAXCR 3 +#define O_DMACR1__DATA7WRMAXCR 15 +#define W_DMACR1__DATA7WRMAXCR 3 +#define O_DMACR1__DATA7RDMAXCR 12 +#define W_DMACR1__DATA7RDMAXCR 3 +#define O_DMACR1__DATA8WRMAXCR 9 +#define W_DMACR1__DATA8WRMAXCR 3 +#define O_DMACR1__DATA8RDMAXCR 6 +#define W_DMACR1__DATA8RDMAXCR 3 +#define O_DMACR1__DATA9WRMAXCR 3 +#define W_DMACR1__DATA9WRMAXCR 3 +#define O_DMACR1__DATA9RDMAXCR 0 +#define W_DMACR1__DATA9RDMAXCR 3 #define R_DMACR2 0x202 -#define O_DMACR2__Data10WrMaxCr 27 -#define W_DMACR2__Data10WrMaxCr 3 -#define O_DMACR2__Data10RdMaxCr 24 -#define W_DMACR2__Data10RdMaxCr 3 -#define O_DMACR2__Data11WrMaxCr 21 -#define W_DMACR2__Data11WrMaxCr 3 -#define O_DMACR2__Data11RdMaxCr 18 -#define W_DMACR2__Data11RdMaxCr 3 -#define O_DMACR2__Data12WrMaxCr 15 -#define W_DMACR2__Data12WrMaxCr 3 -#define O_DMACR2__Data12RdMaxCr 12 -#define W_DMACR2__Data12RdMaxCr 3 -#define O_DMACR2__Data13WrMaxCr 9 -#define W_DMACR2__Data13WrMaxCr 3 -#define O_DMACR2__Data13RdMaxCr 6 -#define W_DMACR2__Data13RdMaxCr 3 -#define O_DMACR2__Data14WrMaxCr 3 -#define W_DMACR2__Data14WrMaxCr 3 -#define O_DMACR2__Data14RdMaxCr 0 -#define W_DMACR2__Data14RdMaxCr 3 +#define O_DMACR2__DATA10WRMAXCR 27 +#define W_DMACR2__DATA10WRMAXCR 3 +#define O_DMACR2__DATA10RDMAXCR 24 +#define W_DMACR2__DATA10RDMAXCR 3 +#define O_DMACR2__DATA11WRMAXCR 21 +#define W_DMACR2__DATA11WRMAXCR 3 +#define O_DMACR2__DATA11RDMAXCR 18 +#define W_DMACR2__DATA11RDMAXCR 3 +#define O_DMACR2__DATA12WRMAXCR 15 +#define W_DMACR2__DATA12WRMAXCR 3 +#define O_DMACR2__DATA12RDMAXCR 12 +#define W_DMACR2__DATA12RDMAXCR 3 +#define O_DMACR2__DATA13WRMAXCR 9 +#define W_DMACR2__DATA13WRMAXCR 3 +#define O_DMACR2__DATA13RDMAXCR 6 +#define W_DMACR2__DATA13RDMAXCR 3 +#define O_DMACR2__DATA14WRMAXCR 3 +#define W_DMACR2__DATA14WRMAXCR 3 +#define O_DMACR2__DATA14RDMAXCR 0 +#define W_DMACR2__DATA14RDMAXCR 3 #define R_DMACR3 0x203 -#define O_DMACR3__Data15WrMaxCr 27 -#define W_DMACR3__Data15WrMaxCr 3 -#define O_DMACR3__Data15RdMaxCr 24 -#define W_DMACR3__Data15RdMaxCr 3 -#define O_DMACR3__SpClassWrMaxCr 21 -#define W_DMACR3__SpClassWrMaxCr 3 -#define O_DMACR3__SpClassRdMaxCr 18 -#define W_DMACR3__SpClassRdMaxCr 3 -#define O_DMACR3__JumFrInWrMaxCr 15 -#define W_DMACR3__JumFrInWrMaxCr 3 -#define O_DMACR3__JumFrInRdMaxCr 12 -#define W_DMACR3__JumFrInRdMaxCr 3 -#define O_DMACR3__RegFrInWrMaxCr 9 -#define W_DMACR3__RegFrInWrMaxCr 3 -#define O_DMACR3__RegFrInRdMaxCr 6 -#define W_DMACR3__RegFrInRdMaxCr 3 -#define O_DMACR3__FrOutWrMaxCr 3 -#define W_DMACR3__FrOutWrMaxCr 3 -#define O_DMACR3__FrOutRdMaxCr 0 -#define W_DMACR3__FrOutRdMaxCr 3 +#define O_DMACR3__DATA15WRMAXCR 27 +#define W_DMACR3__DATA15WRMAXCR 3 +#define O_DMACR3__DATA15RDMAXCR 24 +#define W_DMACR3__DATA15RDMAXCR 3 +#define O_DMACR3__SPCLASSWRMAXCR 21 +#define W_DMACR3__SPCLASSWRMAXCR 3 +#define O_DMACR3__SPCLASSRDMAXCR 18 +#define W_DMACR3__SPCLASSRDMAXCR 3 +#define O_DMACR3__JUMFRINWRMAXCR 15 +#define W_DMACR3__JUMFRINWRMAXCR 3 +#define O_DMACR3__JUMFRINRDMAXCR 12 +#define W_DMACR3__JUMFRINRDMAXCR 3 +#define O_DMACR3__REGFRINWRMAXCR 9 +#define W_DMACR3__REGFRINWRMAXCR 3 +#define O_DMACR3__REGFRINRDMAXCR 6 +#define W_DMACR3__REGFRINRDMAXCR 3 +#define O_DMACR3__FROUTWRMAXCR 3 +#define W_DMACR3__FROUTWRMAXCR 3 +#define O_DMACR3__FROUTRDMAXCR 0 +#define W_DMACR3__FROUTRDMAXCR 3 #define R_REG_FRIN_SPILL_MEM_START_0 0x204 -#define O_REG_FRIN_SPILL_MEM_START_0__RegFrInSpillMemStart0 0 -#define W_REG_FRIN_SPILL_MEM_START_0__RegFrInSpillMemStart0 32 +#define O_REG_FRIN_SPILL_MEM_START_0__REGFRINSPILLMEMSTART0 0 +#define W_REG_FRIN_SPILL_MEM_START_0__REGFRINSPILLMEMSTART0 32 #define R_REG_FRIN_SPILL_MEM_START_1 0x205 -#define O_REG_FRIN_SPILL_MEM_START_1__RegFrInSpillMemStart1 0 -#define W_REG_FRIN_SPILL_MEM_START_1__RegFrInSpillMemStart1 3 +#define O_REG_FRIN_SPILL_MEM_START_1__REGFRINSPILLMEMSTART1 0 +#define W_REG_FRIN_SPILL_MEM_START_1__REGFRINSPILLMEMSTART1 3 #define R_REG_FRIN_SPILL_MEM_SIZE 0x206 -#define O_REG_FRIN_SPILL_MEM_SIZE__RegFrInSpillMemSize 0 -#define W_REG_FRIN_SPILL_MEM_SIZE__RegFrInSpillMemSize 32 +#define O_REG_FRIN_SPILL_MEM_SIZE__REGFRINSPILLMEMSIZE 0 +#define W_REG_FRIN_SPILL_MEM_SIZE__REGFRINSPILLMEMSIZE 32 #define R_FROUT_SPILL_MEM_START_0 0x207 -#define O_FROUT_SPILL_MEM_START_0__FrOutSpillMemStart0 0 -#define W_FROUT_SPILL_MEM_START_0__FrOutSpillMemStart0 32 +#define O_FROUT_SPILL_MEM_START_0__FROUTSPILLMEMSTART0 0 +#define W_FROUT_SPILL_MEM_START_0__FROUTSPILLMEMSTART0 32 #define R_FROUT_SPILL_MEM_START_1 0x208 -#define O_FROUT_SPILL_MEM_START_1__FrOutSpillMemStart1 0 -#define W_FROUT_SPILL_MEM_START_1__FrOutSpillMemStart1 3 +#define O_FROUT_SPILL_MEM_START_1__FROUTSPILLMEMSTART1 0 +#define W_FROUT_SPILL_MEM_START_1__FROUTSPILLMEMSTART1 3 #define R_FROUT_SPILL_MEM_SIZE 0x209 -#define O_FROUT_SPILL_MEM_SIZE__FrOutSpillMemSize 0 -#define W_FROUT_SPILL_MEM_SIZE__FrOutSpillMemSize 32 +#define O_FROUT_SPILL_MEM_SIZE__FROUTSPILLMEMSIZE 0 +#define W_FROUT_SPILL_MEM_SIZE__FROUTSPILLMEMSIZE 32 #define R_CLASS0_SPILL_MEM_START_0 0x20A -#define O_CLASS0_SPILL_MEM_START_0__Class0SpillMemStart0 0 -#define W_CLASS0_SPILL_MEM_START_0__Class0SpillMemStart0 32 +#define O_CLASS0_SPILL_MEM_START_0__CLASS0SPILLMEMSTART0 0 +#define W_CLASS0_SPILL_MEM_START_0__CLASS0SPILLMEMSTART0 32 #define R_CLASS0_SPILL_MEM_START_1 0x20B -#define O_CLASS0_SPILL_MEM_START_1__Class0SpillMemStart1 0 -#define W_CLASS0_SPILL_MEM_START_1__Class0SpillMemStart1 3 +#define O_CLASS0_SPILL_MEM_START_1__CLASS0SPILLMEMSTART1 0 +#define W_CLASS0_SPILL_MEM_START_1__CLASS0SPILLMEMSTART1 3 #define R_CLASS0_SPILL_MEM_SIZE 0x20C -#define O_CLASS0_SPILL_MEM_SIZE__Class0SpillMemSize 0 -#define W_CLASS0_SPILL_MEM_SIZE__Class0SpillMemSize 32 +#define O_CLASS0_SPILL_MEM_SIZE__CLASS0SPILLMEMSIZE 0 +#define W_CLASS0_SPILL_MEM_SIZE__CLASS0SPILLMEMSIZE 32 #define R_JUMFRIN_SPILL_MEM_START_0 0x20D -#define O_JUMFRIN_SPILL_MEM_START_0__JumFrInSpillMemStar0 0 -#define W_JUMFRIN_SPILL_MEM_START_0__JumFrInSpillMemStar0 32 +#define O_JUMFRIN_SPILL_MEM_START_0__JUMFRINSPILLMEMSTART0 0 +#define W_JUMFRIN_SPILL_MEM_START_0__JUMFRINSPILLMEMSTART0 32 #define R_JUMFRIN_SPILL_MEM_START_1 0x20E -#define O_JUMFRIN_SPILL_MEM_START_1__JumFrInSpillMemStart1 0 -#define W_JUMFRIN_SPILL_MEM_START_1__JumFrInSpillMemStart1 3 +#define O_JUMFRIN_SPILL_MEM_START_1__JUMFRINSPILLMEMSTART1 0 +#define W_JUMFRIN_SPILL_MEM_START_1__JUMFRINSPILLMEMSTART1 3 #define R_JUMFRIN_SPILL_MEM_SIZE 0x20F -#define O_JUMFRIN_SPILL_MEM_SIZE__JumFrInSpillMemSize 0 -#define W_JUMFRIN_SPILL_MEM_SIZE__JumFrInSpillMemSize 32 +#define O_JUMFRIN_SPILL_MEM_SIZE__JUMFRINSPILLMEMSIZE 0 +#define W_JUMFRIN_SPILL_MEM_SIZE__JUMFRINSPILLMEMSIZE 32 #define R_CLASS1_SPILL_MEM_START_0 0x210 -#define O_CLASS1_SPILL_MEM_START_0__Class1SpillMemStart0 0 -#define W_CLASS1_SPILL_MEM_START_0__Class1SpillMemStart0 32 +#define O_CLASS1_SPILL_MEM_START_0__CLASS1SPILLMEMSTART0 0 +#define W_CLASS1_SPILL_MEM_START_0__CLASS1SPILLMEMSTART0 32 #define R_CLASS1_SPILL_MEM_START_1 0x211 -#define O_CLASS1_SPILL_MEM_START_1__Class1SpillMemStart1 0 -#define W_CLASS1_SPILL_MEM_START_1__Class1SpillMemStart1 3 +#define O_CLASS1_SPILL_MEM_START_1__CLASS1SPILLMEMSTART1 0 +#define W_CLASS1_SPILL_MEM_START_1__CLASS1SPILLMEMSTART1 3 #define R_CLASS1_SPILL_MEM_SIZE 0x212 -#define O_CLASS1_SPILL_MEM_SIZE__Class1SpillMemSize 0 -#define W_CLASS1_SPILL_MEM_SIZE__Class1SpillMemSize 32 +#define O_CLASS1_SPILL_MEM_SIZE__CLASS1SPILLMEMSIZE 0 +#define W_CLASS1_SPILL_MEM_SIZE__CLASS1SPILLMEMSIZE 32 #define R_CLASS2_SPILL_MEM_START_0 0x213 -#define O_CLASS2_SPILL_MEM_START_0__Class2SpillMemStart0 0 -#define W_CLASS2_SPILL_MEM_START_0__Class2SpillMemStart0 32 +#define O_CLASS2_SPILL_MEM_START_0__CLASS2SPILLMEMSTART0 0 +#define W_CLASS2_SPILL_MEM_START_0__CLASS2SPILLMEMSTART0 32 #define R_CLASS2_SPILL_MEM_START_1 0x214 -#define O_CLASS2_SPILL_MEM_START_1__Class2SpillMemStart1 0 -#define W_CLASS2_SPILL_MEM_START_1__Class2SpillMemStart1 3 +#define O_CLASS2_SPILL_MEM_START_1__CLASS2SPILLMEMSTART1 0 +#define W_CLASS2_SPILL_MEM_START_1__CLASS2SPILLMEMSTART1 3 #define R_CLASS2_SPILL_MEM_SIZE 0x215 -#define O_CLASS2_SPILL_MEM_SIZE__Class2SpillMemSize 0 -#define W_CLASS2_SPILL_MEM_SIZE__Class2SpillMemSize 32 +#define O_CLASS2_SPILL_MEM_SIZE__CLASS2SPILLMEMSIZE 0 +#define W_CLASS2_SPILL_MEM_SIZE__CLASS2SPILLMEMSIZE 32 #define R_CLASS3_SPILL_MEM_START_0 0x216 -#define O_CLASS3_SPILL_MEM_START_0__Class3SpillMemStart0 0 -#define W_CLASS3_SPILL_MEM_START_0__Class3SpillMemStart0 32 +#define O_CLASS3_SPILL_MEM_START_0__CLASS3SPILLMEMSTART0 0 +#define W_CLASS3_SPILL_MEM_START_0__CLASS3SPILLMEMSTART0 32 #define R_CLASS3_SPILL_MEM_START_1 0x217 -#define O_CLASS3_SPILL_MEM_START_1__Class3SpillMemStart1 0 -#define W_CLASS3_SPILL_MEM_START_1__Class3SpillMemStart1 3 +#define O_CLASS3_SPILL_MEM_START_1__CLASS3SPILLMEMSTART1 0 +#define W_CLASS3_SPILL_MEM_START_1__CLASS3SPILLMEMSTART1 3 #define R_CLASS3_SPILL_MEM_SIZE 0x218 -#define O_CLASS3_SPILL_MEM_SIZE__Class3SpillMemSize 0 -#define W_CLASS3_SPILL_MEM_SIZE__Class3SpillMemSize 32 +#define O_CLASS3_SPILL_MEM_SIZE__CLASS3SPILLMEMSIZE 0 +#define W_CLASS3_SPILL_MEM_SIZE__CLASS3SPILLMEMSIZE 32 #define R_REG_FRIN1_SPILL_MEM_START_0 0x219 #define R_REG_FRIN1_SPILL_MEM_START_1 0x21a #define R_REG_FRIN1_SPILL_MEM_SIZE 0x21b @@ -679,244 +679,244 @@ #define O_SPISTRV3__EG_STRV_THRESH_15 0 #define W_SPISTRV3__EG_STRV_THRESH_15 7 #define R_TXDATAFIFO0 0x221 -#define O_TXDATAFIFO0__Tx0DataFifoStart 24 -#define W_TXDATAFIFO0__Tx0DataFifoStart 7 -#define O_TXDATAFIFO0__Tx0DataFifoSize 16 -#define W_TXDATAFIFO0__Tx0DataFifoSize 7 -#define O_TXDATAFIFO0__Tx1DataFifoStart 8 -#define W_TXDATAFIFO0__Tx1DataFifoStart 7 -#define O_TXDATAFIFO0__Tx1DataFifoSize 0 -#define W_TXDATAFIFO0__Tx1DataFifoSize 7 +#define O_TXDATAFIFO0__TX0DATAFIFOSTART 24 +#define W_TXDATAFIFO0__TX0DATAFIFOSTART 7 +#define O_TXDATAFIFO0__TX0DATAFIFOSIZE 16 +#define W_TXDATAFIFO0__TX0DATAFIFOSIZE 7 +#define O_TXDATAFIFO0__TX1DATAFIFOSTART 8 +#define W_TXDATAFIFO0__TX1DATAFIFOSTART 7 +#define O_TXDATAFIFO0__TX1DATAFIFOSIZE 0 +#define W_TXDATAFIFO0__TX1DATAFIFOSIZE 7 #define R_TXDATAFIFO1 0x222 -#define O_TXDATAFIFO1__Tx2DataFifoStart 24 -#define W_TXDATAFIFO1__Tx2DataFifoStart 7 -#define O_TXDATAFIFO1__Tx2DataFifoSize 16 -#define W_TXDATAFIFO1__Tx2DataFifoSize 7 -#define O_TXDATAFIFO1__Tx3DataFifoStart 8 -#define W_TXDATAFIFO1__Tx3DataFifoStart 7 -#define O_TXDATAFIFO1__Tx3DataFifoSize 0 -#define W_TXDATAFIFO1__Tx3DataFifoSize 7 +#define O_TXDATAFIFO1__TX2DATAFIFOSTART 24 +#define W_TXDATAFIFO1__TX2DATAFIFOSTART 7 +#define O_TXDATAFIFO1__TX2DATAFIFOSIZE 16 +#define W_TXDATAFIFO1__TX2DATAFIFOSIZE 7 +#define O_TXDATAFIFO1__TX3DATAFIFOSTART 8 +#define W_TXDATAFIFO1__TX3DATAFIFOSTART 7 +#define O_TXDATAFIFO1__TX3DATAFIFOSIZE 0 +#define W_TXDATAFIFO1__TX3DATAFIFOSIZE 7 #define R_TXDATAFIFO2 0x223 -#define O_TXDATAFIFO2__Tx4DataFifoStart 24 -#define W_TXDATAFIFO2__Tx4DataFifoStart 7 -#define O_TXDATAFIFO2__Tx4DataFifoSize 16 -#define W_TXDATAFIFO2__Tx4DataFifoSize 7 -#define O_TXDATAFIFO2__Tx5DataFifoStart 8 -#define W_TXDATAFIFO2__Tx5DataFifoStart 7 -#define O_TXDATAFIFO2__Tx5DataFifoSize 0 -#define W_TXDATAFIFO2__Tx5DataFifoSize 7 +#define O_TXDATAFIFO2__TX4DATAFIFOSTART 24 +#define W_TXDATAFIFO2__TX4DATAFIFOSTART 7 +#define O_TXDATAFIFO2__TX4DATAFIFOSIZE 16 +#define W_TXDATAFIFO2__TX4DATAFIFOSIZE 7 +#define O_TXDATAFIFO2__TX5DATAFIFOSTART 8 +#define W_TXDATAFIFO2__TX5DATAFIFOSTART 7 +#define O_TXDATAFIFO2__TX5DATAFIFOSIZE 0 +#define W_TXDATAFIFO2__TX5DATAFIFOSIZE 7 #define R_TXDATAFIFO3 0x224 -#define O_TXDATAFIFO3__Tx6DataFifoStart 24 -#define W_TXDATAFIFO3__Tx6DataFifoStart 7 -#define O_TXDATAFIFO3__Tx6DataFifoSize 16 -#define W_TXDATAFIFO3__Tx6DataFifoSize 7 -#define O_TXDATAFIFO3__Tx7DataFifoStart 8 -#define W_TXDATAFIFO3__Tx7DataFifoStart 7 -#define O_TXDATAFIFO3__Tx7DataFifoSize 0 -#define W_TXDATAFIFO3__Tx7DataFifoSize 7 +#define O_TXDATAFIFO3__TX6DATAFIFOSTART 24 +#define W_TXDATAFIFO3__TX6DATAFIFOSTART 7 +#define O_TXDATAFIFO3__TX6DATAFIFOSIZE 16 +#define W_TXDATAFIFO3__TX6DATAFIFOSIZE 7 +#define O_TXDATAFIFO3__TX7DATAFIFOSTART 8 +#define W_TXDATAFIFO3__TX7DATAFIFOSTART 7 +#define O_TXDATAFIFO3__TX7DATAFIFOSIZE 0 +#define W_TXDATAFIFO3__TX7DATAFIFOSIZE 7 #define R_TXDATAFIFO4 0x225 -#define O_TXDATAFIFO4__Tx8DataFifoStart 24 -#define W_TXDATAFIFO4__Tx8DataFifoStart 7 -#define O_TXDATAFIFO4__Tx8DataFifoSize 16 -#define W_TXDATAFIFO4__Tx8DataFifoSize 7 -#define O_TXDATAFIFO4__Tx9DataFifoStart 8 -#define W_TXDATAFIFO4__Tx9DataFifoStart 7 -#define O_TXDATAFIFO4__Tx9DataFifoSize 0 -#define W_TXDATAFIFO4__Tx9DataFifoSize 7 +#define O_TXDATAFIFO4__TX8DATAFIFOSTART 24 +#define W_TXDATAFIFO4__TX8DATAFIFOSTART 7 +#define O_TXDATAFIFO4__TX8DATAFIFOSIZE 16 +#define W_TXDATAFIFO4__TX8DATAFIFOSIZE 7 +#define O_TXDATAFIFO4__TX9DATAFIFOSTART 8 +#define W_TXDATAFIFO4__TX9DATAFIFOSTART 7 +#define O_TXDATAFIFO4__TX9DATAFIFOSIZE 0 +#define W_TXDATAFIFO4__TX9DATAFIFOSIZE 7 #define R_TXDATAFIFO5 0x226 -#define O_TXDATAFIFO5__Tx10DataFifoStart 24 -#define W_TXDATAFIFO5__Tx10DataFifoStart 7 -#define O_TXDATAFIFO5__Tx10DataFifoSize 16 -#define W_TXDATAFIFO5__Tx10DataFifoSize 7 -#define O_TXDATAFIFO5__Tx11DataFifoStart 8 -#define W_TXDATAFIFO5__Tx11DataFifoStart 7 -#define O_TXDATAFIFO5__Tx11DataFifoSize 0 -#define W_TXDATAFIFO5__Tx11DataFifoSize 7 +#define O_TXDATAFIFO5__TX10DATAFIFOSTART 24 +#define W_TXDATAFIFO5__TX10DATAFIFOSTART 7 +#define O_TXDATAFIFO5__TX10DATAFIFOSIZE 16 +#define W_TXDATAFIFO5__TX10DATAFIFOSIZE 7 +#define O_TXDATAFIFO5__TX11DATAFIFOSTART 8 +#define W_TXDATAFIFO5__TX11DATAFIFOSTART 7 +#define O_TXDATAFIFO5__TX11DATAFIFOSIZE 0 +#define W_TXDATAFIFO5__TX11DATAFIFOSIZE 7 #define R_TXDATAFIFO6 0x227 -#define O_TXDATAFIFO6__Tx12DataFifoStart 24 -#define W_TXDATAFIFO6__Tx12DataFifoStart 7 -#define O_TXDATAFIFO6__Tx12DataFifoSize 16 -#define W_TXDATAFIFO6__Tx12DataFifoSize 7 -#define O_TXDATAFIFO6__Tx13DataFifoStart 8 -#define W_TXDATAFIFO6__Tx13DataFifoStart 7 -#define O_TXDATAFIFO6__Tx13DataFifoSize 0 -#define W_TXDATAFIFO6__Tx13DataFifoSize 7 +#define O_TXDATAFIFO6__TX12DATAFIFOSTART 24 +#define W_TXDATAFIFO6__TX12DATAFIFOSTART 7 +#define O_TXDATAFIFO6__TX12DATAFIFOSIZE 16 +#define W_TXDATAFIFO6__TX12DATAFIFOSIZE 7 +#define O_TXDATAFIFO6__TX13DATAFIFOSTART 8 +#define W_TXDATAFIFO6__TX13DATAFIFOSTART 7 +#define O_TXDATAFIFO6__TX13DATAFIFOSIZE 0 +#define W_TXDATAFIFO6__TX13DATAFIFOSIZE 7 #define R_TXDATAFIFO7 0x228 -#define O_TXDATAFIFO7__Tx14DataFifoStart 24 -#define W_TXDATAFIFO7__Tx14DataFifoStart 7 -#define O_TXDATAFIFO7__Tx14DataFifoSize 16 -#define W_TXDATAFIFO7__Tx14DataFifoSize 7 -#define O_TXDATAFIFO7__Tx15DataFifoStart 8 -#define W_TXDATAFIFO7__Tx15DataFifoStart 7 -#define O_TXDATAFIFO7__Tx15DataFifoSize 0 -#define W_TXDATAFIFO7__Tx15DataFifoSize 7 +#define O_TXDATAFIFO7__TX14DATAFIFOSTART 24 +#define W_TXDATAFIFO7__TX14DATAFIFOSTART 7 +#define O_TXDATAFIFO7__TX14DATAFIFOSIZE 16 +#define W_TXDATAFIFO7__TX14DATAFIFOSIZE 7 +#define O_TXDATAFIFO7__TX15DATAFIFOSTART 8 +#define W_TXDATAFIFO7__TX15DATAFIFOSTART 7 +#define O_TXDATAFIFO7__TX15DATAFIFOSIZE 0 +#define W_TXDATAFIFO7__TX15DATAFIFOSIZE 7 #define R_RXDATAFIFO0 0x229 -#define O_RXDATAFIFO0__Rx0DataFifoStart 24 -#define W_RXDATAFIFO0__Rx0DataFifoStart 7 -#define O_RXDATAFIFO0__Rx0DataFifoSize 16 -#define W_RXDATAFIFO0__Rx0DataFifoSize 7 -#define O_RXDATAFIFO0__Rx1DataFifoStart 8 -#define W_RXDATAFIFO0__Rx1DataFifoStart 7 -#define O_RXDATAFIFO0__Rx1DataFifoSize 0 -#define W_RXDATAFIFO0__Rx1DataFifoSize 7 +#define O_RXDATAFIFO0__RX0DATAFIFOSTART 24 +#define W_RXDATAFIFO0__RX0DATAFIFOSTART 7 +#define O_RXDATAFIFO0__RX0DATAFIFOSIZE 16 +#define W_RXDATAFIFO0__RX0DATAFIFOSIZE 7 +#define O_RXDATAFIFO0__RX1DATAFIFOSTART 8 +#define W_RXDATAFIFO0__RX1DATAFIFOSTART 7 +#define O_RXDATAFIFO0__RX1DATAFIFOSIZE 0 +#define W_RXDATAFIFO0__RX1DATAFIFOSIZE 7 #define R_RXDATAFIFO1 0x22A -#define O_RXDATAFIFO1__Rx2DataFifoStart 24 -#define W_RXDATAFIFO1__Rx2DataFifoStart 7 -#define O_RXDATAFIFO1__Rx2DataFifoSize 16 -#define W_RXDATAFIFO1__Rx2DataFifoSize 7 -#define O_RXDATAFIFO1__Rx3DataFifoStart 8 -#define W_RXDATAFIFO1__Rx3DataFifoStart 7 -#define O_RXDATAFIFO1__Rx3DataFifoSize 0 -#define W_RXDATAFIFO1__Rx3DataFifoSize 7 +#define O_RXDATAFIFO1__RX2DATAFIFOSTART 24 +#define W_RXDATAFIFO1__RX2DATAFIFOSTART 7 +#define O_RXDATAFIFO1__RX2DATAFIFOSIZE 16 +#define W_RXDATAFIFO1__RX2DATAFIFOSIZE 7 +#define O_RXDATAFIFO1__RX3DATAFIFOSTART 8 +#define W_RXDATAFIFO1__RX3DATAFIFOSTART 7 +#define O_RXDATAFIFO1__RX3DATAFIFOSIZE 0 +#define W_RXDATAFIFO1__RX3DATAFIFOSIZE 7 #define R_RXDATAFIFO2 0x22B -#define O_RXDATAFIFO2__Rx4DataFifoStart 24 -#define W_RXDATAFIFO2__Rx4DataFifoStart 7 -#define O_RXDATAFIFO2__Rx4DataFifoSize 16 -#define W_RXDATAFIFO2__Rx4DataFifoSize 7 -#define O_RXDATAFIFO2__Rx5DataFifoStart 8 -#define W_RXDATAFIFO2__Rx5DataFifoStart 7 -#define O_RXDATAFIFO2__Rx5DataFifoSize 0 -#define W_RXDATAFIFO2__Rx5DataFifoSize 7 +#define O_RXDATAFIFO2__RX4DATAFIFOSTART 24 +#define W_RXDATAFIFO2__RX4DATAFIFOSTART 7 +#define O_RXDATAFIFO2__RX4DATAFIFOSIZE 16 +#define W_RXDATAFIFO2__RX4DATAFIFOSIZE 7 +#define O_RXDATAFIFO2__RX5DATAFIFOSTART 8 +#define W_RXDATAFIFO2__RX5DATAFIFOSTART 7 +#define O_RXDATAFIFO2__RX5DATAFIFOSIZE 0 +#define W_RXDATAFIFO2__RX5DATAFIFOSIZE 7 #define R_RXDATAFIFO3 0x22C -#define O_RXDATAFIFO3__Rx6DataFifoStart 24 -#define W_RXDATAFIFO3__Rx6DataFifoStart 7 -#define O_RXDATAFIFO3__Rx6DataFifoSize 16 -#define W_RXDATAFIFO3__Rx6DataFifoSize 7 -#define O_RXDATAFIFO3__Rx7DataFifoStart 8 -#define W_RXDATAFIFO3__Rx7DataFifoStart 7 -#define O_RXDATAFIFO3__Rx7DataFifoSize 0 -#define W_RXDATAFIFO3__Rx7DataFifoSize 7 +#define O_RXDATAFIFO3__RX6DATAFIFOSTART 24 +#define W_RXDATAFIFO3__RX6DATAFIFOSTART 7 +#define O_RXDATAFIFO3__RX6DATAFIFOSIZE 16 +#define W_RXDATAFIFO3__RX6DATAFIFOSIZE 7 +#define O_RXDATAFIFO3__RX7DATAFIFOSTART 8 +#define W_RXDATAFIFO3__RX7DATAFIFOSTART 7 +#define O_RXDATAFIFO3__RX7DATAFIFOSIZE 0 +#define W_RXDATAFIFO3__RX7DATAFIFOSIZE 7 #define R_RXDATAFIFO4 0x22D -#define O_RXDATAFIFO4__Rx8DataFifoStart 24 -#define W_RXDATAFIFO4__Rx8DataFifoStart 7 -#define O_RXDATAFIFO4__Rx8DataFifoSize 16 -#define W_RXDATAFIFO4__Rx8DataFifoSize 7 -#define O_RXDATAFIFO4__Rx9DataFifoStart 8 -#define W_RXDATAFIFO4__Rx9DataFifoStart 7 -#define O_RXDATAFIFO4__Rx9DataFifoSize 0 -#define W_RXDATAFIFO4__Rx9DataFifoSize 7 +#define O_RXDATAFIFO4__RX8DATAFIFOSTART 24 +#define W_RXDATAFIFO4__RX8DATAFIFOSTART 7 +#define O_RXDATAFIFO4__RX8DATAFIFOSIZE 16 +#define W_RXDATAFIFO4__RX8DATAFIFOSIZE 7 +#define O_RXDATAFIFO4__RX9DATAFIFOSTART 8 +#define W_RXDATAFIFO4__RX9DATAFIFOSTART 7 +#define O_RXDATAFIFO4__RX9DATAFIFOSIZE 0 +#define W_RXDATAFIFO4__RX9DATAFIFOSIZE 7 #define R_RXDATAFIFO5 0x22E -#define O_RXDATAFIFO5__Rx10DataFifoStart 24 -#define W_RXDATAFIFO5__Rx10DataFifoStart 7 -#define O_RXDATAFIFO5__Rx10DataFifoSize 16 -#define W_RXDATAFIFO5__Rx10DataFifoSize 7 -#define O_RXDATAFIFO5__Rx11DataFifoStart 8 -#define W_RXDATAFIFO5__Rx11DataFifoStart 7 -#define O_RXDATAFIFO5__Rx11DataFifoSize 0 -#define W_RXDATAFIFO5__Rx11DataFifoSize 7 +#define O_RXDATAFIFO5__RX10DATAFIFOSTART 24 +#define W_RXDATAFIFO5__RX10DATAFIFOSTART 7 +#define O_RXDATAFIFO5__RX10DATAFIFOSIZE 16 +#define W_RXDATAFIFO5__RX10DATAFIFOSIZE 7 +#define O_RXDATAFIFO5__RX11DATAFIFOSTART 8 +#define W_RXDATAFIFO5__RX11DATAFIFOSTART 7 +#define O_RXDATAFIFO5__RX11DATAFIFOSIZE 0 +#define W_RXDATAFIFO5__RX11DATAFIFOSIZE 7 #define R_RXDATAFIFO6 0x22F -#define O_RXDATAFIFO6__Rx12DataFifoStart 24 -#define W_RXDATAFIFO6__Rx12DataFifoStart 7 -#define O_RXDATAFIFO6__Rx12DataFifoSize 16 -#define W_RXDATAFIFO6__Rx12DataFifoSize 7 -#define O_RXDATAFIFO6__Rx13DataFifoStart 8 -#define W_RXDATAFIFO6__Rx13DataFifoStart 7 -#define O_RXDATAFIFO6__Rx13DataFifoSize 0 -#define W_RXDATAFIFO6__Rx13DataFifoSize 7 +#define O_RXDATAFIFO6__RX12DATAFIFOSTART 24 +#define W_RXDATAFIFO6__RX12DATAFIFOSTART 7 +#define O_RXDATAFIFO6__RX12DATAFIFOSIZE 16 +#define W_RXDATAFIFO6__RX12DATAFIFOSIZE 7 +#define O_RXDATAFIFO6__RX13DATAFIFOSTART 8 +#define W_RXDATAFIFO6__RX13DATAFIFOSTART 7 +#define O_RXDATAFIFO6__RX13DATAFIFOSIZE 0 +#define W_RXDATAFIFO6__RX13DATAFIFOSIZE 7 #define R_RXDATAFIFO7 0x230 -#define O_RXDATAFIFO7__Rx14DataFifoStart 24 -#define W_RXDATAFIFO7__Rx14DataFifoStart 7 -#define O_RXDATAFIFO7__Rx14DataFifoSize 16 -#define W_RXDATAFIFO7__Rx14DataFifoSize 7 -#define O_RXDATAFIFO7__Rx15DataFifoStart 8 -#define W_RXDATAFIFO7__Rx15DataFifoStart 7 -#define O_RXDATAFIFO7__Rx15DataFifoSize 0 -#define W_RXDATAFIFO7__Rx15DataFifoSize 7 +#define O_RXDATAFIFO7__RX14DATAFIFOSTART 24 +#define W_RXDATAFIFO7__RX14DATAFIFOSTART 7 +#define O_RXDATAFIFO7__RX14DATAFIFOSIZE 16 +#define W_RXDATAFIFO7__RX14DATAFIFOSIZE 7 +#define O_RXDATAFIFO7__RX15DATAFIFOSTART 8 +#define W_RXDATAFIFO7__RX15DATAFIFOSTART 7 +#define O_RXDATAFIFO7__RX15DATAFIFOSIZE 0 +#define W_RXDATAFIFO7__RX15DATAFIFOSIZE 7 #define R_XGMACPADCALIBRATION 0x231 #define R_FREEQCARVE 0x233 #define R_SPI4STATICDELAY0 0x240 -#define O_SPI4STATICDELAY0__DataLine7 28 -#define W_SPI4STATICDELAY0__DataLine7 4 -#define O_SPI4STATICDELAY0__DataLine6 24 -#define W_SPI4STATICDELAY0__DataLine6 4 -#define O_SPI4STATICDELAY0__DataLine5 20 -#define W_SPI4STATICDELAY0__DataLine5 4 -#define O_SPI4STATICDELAY0__DataLine4 16 -#define W_SPI4STATICDELAY0__DataLine4 4 -#define O_SPI4STATICDELAY0__DataLine3 12 -#define W_SPI4STATICDELAY0__DataLine3 4 -#define O_SPI4STATICDELAY0__DataLine2 8 -#define W_SPI4STATICDELAY0__DataLine2 4 -#define O_SPI4STATICDELAY0__DataLine1 4 -#define W_SPI4STATICDELAY0__DataLine1 4 -#define O_SPI4STATICDELAY0__DataLine0 0 -#define W_SPI4STATICDELAY0__DataLine0 4 +#define O_SPI4STATICDELAY0__DATALINE7 28 +#define W_SPI4STATICDELAY0__DATALINE7 4 +#define O_SPI4STATICDELAY0__DATALINE6 24 +#define W_SPI4STATICDELAY0__DATALINE6 4 +#define O_SPI4STATICDELAY0__DATALINE5 20 +#define W_SPI4STATICDELAY0__DATALINE5 4 +#define O_SPI4STATICDELAY0__DATALINE4 16 +#define W_SPI4STATICDELAY0__DATALINE4 4 +#define O_SPI4STATICDELAY0__DATALINE3 12 +#define W_SPI4STATICDELAY0__DATALINE3 4 +#define O_SPI4STATICDELAY0__DATALINE2 8 +#define W_SPI4STATICDELAY0__DATALINE2 4 +#define O_SPI4STATICDELAY0__DATALINE1 4 +#define W_SPI4STATICDELAY0__DATALINE1 4 +#define O_SPI4STATICDELAY0__DATALINE0 0 +#define W_SPI4STATICDELAY0__DATALINE0 4 #define R_SPI4STATICDELAY1 0x241 -#define O_SPI4STATICDELAY1__DataLine15 28 -#define W_SPI4STATICDELAY1__DataLine15 4 -#define O_SPI4STATICDELAY1__DataLine14 24 -#define W_SPI4STATICDELAY1__DataLine14 4 -#define O_SPI4STATICDELAY1__DataLine13 20 -#define W_SPI4STATICDELAY1__DataLine13 4 -#define O_SPI4STATICDELAY1__DataLine12 16 -#define W_SPI4STATICDELAY1__DataLine12 4 -#define O_SPI4STATICDELAY1__DataLine11 12 -#define W_SPI4STATICDELAY1__DataLine11 4 -#define O_SPI4STATICDELAY1__DataLine10 8 -#define W_SPI4STATICDELAY1__DataLine10 4 -#define O_SPI4STATICDELAY1__DataLine9 4 -#define W_SPI4STATICDELAY1__DataLine9 4 -#define O_SPI4STATICDELAY1__DataLine8 0 -#define W_SPI4STATICDELAY1__DataLine8 4 +#define O_SPI4STATICDELAY1__DATALINE15 28 +#define W_SPI4STATICDELAY1__DATALINE15 4 +#define O_SPI4STATICDELAY1__DATALINE14 24 +#define W_SPI4STATICDELAY1__DATALINE14 4 +#define O_SPI4STATICDELAY1__DATALINE13 20 +#define W_SPI4STATICDELAY1__DATALINE13 4 +#define O_SPI4STATICDELAY1__DATALINE12 16 +#define W_SPI4STATICDELAY1__DATALINE12 4 +#define O_SPI4STATICDELAY1__DATALINE11 12 +#define W_SPI4STATICDELAY1__DATALINE11 4 +#define O_SPI4STATICDELAY1__DATALINE10 8 +#define W_SPI4STATICDELAY1__DATALINE10 4 +#define O_SPI4STATICDELAY1__DATALINE9 4 +#define W_SPI4STATICDELAY1__DATALINE9 4 +#define O_SPI4STATICDELAY1__DATALINE8 0 +#define W_SPI4STATICDELAY1__DATALINE8 4 #define R_SPI4STATICDELAY2 0x242 -#define O_SPI4STATICDELAY0__TxStat1 8 -#define W_SPI4STATICDELAY0__TxStat1 4 -#define O_SPI4STATICDELAY0__TxStat0 4 -#define W_SPI4STATICDELAY0__TxStat0 4 -#define O_SPI4STATICDELAY0__RxControl 0 -#define W_SPI4STATICDELAY0__RxControl 4 +#define O_SPI4STATICDELAY0__TXSTAT1 8 +#define W_SPI4STATICDELAY0__TXSTAT1 4 +#define O_SPI4STATICDELAY0__TXSTAT0 4 +#define W_SPI4STATICDELAY0__TXSTAT0 4 +#define O_SPI4STATICDELAY0__RXCONTROL 0 +#define W_SPI4STATICDELAY0__RXCONTROL 4 #define R_SPI4CONTROL 0x243 -#define O_SPI4CONTROL__StaticDelay 2 +#define O_SPI4CONTROL__STATICDELAY 2 #define O_SPI4CONTROL__LVDS_LVTTL 1 -#define O_SPI4CONTROL__SPI4Enable 0 +#define O_SPI4CONTROL__SPI4ENABLE 0 #define R_CLASSWATERMARKS 0x244 -#define O_CLASSWATERMARKS__Class0Watermark 24 -#define W_CLASSWATERMARKS__Class0Watermark 5 -#define O_CLASSWATERMARKS__Class1Watermark 16 -#define W_CLASSWATERMARKS__Class1Watermark 5 -#define O_CLASSWATERMARKS__Class3Watermark 0 -#define W_CLASSWATERMARKS__Class3Watermark 5 +#define O_CLASSWATERMARKS__CLASS0WATERMARK 24 +#define W_CLASSWATERMARKS__CLASS0WATERMARK 5 +#define O_CLASSWATERMARKS__CLASS1WATERMARK 16 +#define W_CLASSWATERMARKS__CLASS1WATERMARK 5 +#define O_CLASSWATERMARKS__CLASS3WATERMARK 0 +#define W_CLASSWATERMARKS__CLASS3WATERMARK 5 #define R_RXWATERMARKS1 0x245 -#define O_RXWATERMARKS__Rx0DataWatermark 24 -#define W_RXWATERMARKS__Rx0DataWatermark 7 -#define O_RXWATERMARKS__Rx1DataWatermark 16 -#define W_RXWATERMARKS__Rx1DataWatermark 7 -#define O_RXWATERMARKS__Rx3DataWatermark 0 -#define W_RXWATERMARKS__Rx3DataWatermark 7 +#define O_RXWATERMARKS__RX0DATAWATERMARK 24 +#define W_RXWATERMARKS__RX0DATAWATERMARK 7 +#define O_RXWATERMARKS__RX1DATAWATERMARK 16 +#define W_RXWATERMARKS__RX1DATAWATERMARK 7 +#define O_RXWATERMARKS__RX3DATAWATERMARK 0 +#define W_RXWATERMARKS__RX3DATAWATERMARK 7 #define R_RXWATERMARKS2 0x246 -#define O_RXWATERMARKS__Rx4DataWatermark 24 -#define W_RXWATERMARKS__Rx4DataWatermark 7 -#define O_RXWATERMARKS__Rx5DataWatermark 16 -#define W_RXWATERMARKS__Rx5DataWatermark 7 -#define O_RXWATERMARKS__Rx6DataWatermark 8 -#define W_RXWATERMARKS__Rx6DataWatermark 7 -#define O_RXWATERMARKS__Rx7DataWatermark 0 -#define W_RXWATERMARKS__Rx7DataWatermark 7 +#define O_RXWATERMARKS__RX4DATAWATERMARK 24 +#define W_RXWATERMARKS__RX4DATAWATERMARK 7 +#define O_RXWATERMARKS__RX5DATAWATERMARK 16 +#define W_RXWATERMARKS__RX5DATAWATERMARK 7 +#define O_RXWATERMARKS__RX6DATAWATERMARK 8 +#define W_RXWATERMARKS__RX6DATAWATERMARK 7 +#define O_RXWATERMARKS__RX7DATAWATERMARK 0 +#define W_RXWATERMARKS__RX7DATAWATERMARK 7 #define R_RXWATERMARKS3 0x247 -#define O_RXWATERMARKS__Rx8DataWatermark 24 -#define W_RXWATERMARKS__Rx8DataWatermark 7 -#define O_RXWATERMARKS__Rx9DataWatermark 16 -#define W_RXWATERMARKS__Rx9DataWatermark 7 -#define O_RXWATERMARKS__Rx10DataWatermark 8 -#define W_RXWATERMARKS__Rx10DataWatermark 7 -#define O_RXWATERMARKS__Rx11DataWatermark 0 -#define W_RXWATERMARKS__Rx11DataWatermark 7 +#define O_RXWATERMARKS__RX8DATAWATERMARK 24 +#define W_RXWATERMARKS__RX8DATAWATERMARK 7 +#define O_RXWATERMARKS__RX9DATAWATERMARK 16 +#define W_RXWATERMARKS__RX9DATAWATERMARK 7 +#define O_RXWATERMARKS__RX10DATAWATERMARK 8 +#define W_RXWATERMARKS__RX10DATAWATERMARK 7 +#define O_RXWATERMARKS__RX11DATAWATERMARK 0 +#define W_RXWATERMARKS__RX11DATAWATERMARK 7 #define R_RXWATERMARKS4 0x248 -#define O_RXWATERMARKS__Rx12DataWatermark 24 -#define W_RXWATERMARKS__Rx12DataWatermark 7 -#define O_RXWATERMARKS__Rx13DataWatermark 16 -#define W_RXWATERMARKS__Rx13DataWatermark 7 -#define O_RXWATERMARKS__Rx14DataWatermark 8 -#define W_RXWATERMARKS__Rx14DataWatermark 7 -#define O_RXWATERMARKS__Rx15DataWatermark 0 -#define W_RXWATERMARKS__Rx15DataWatermark 7 +#define O_RXWATERMARKS__RX12DATAWATERMARK 24 +#define W_RXWATERMARKS__RX12DATAWATERMARK 7 +#define O_RXWATERMARKS__RX13DATAWATERMARK 16 +#define W_RXWATERMARKS__RX13DATAWATERMARK 7 +#define O_RXWATERMARKS__RX14DATAWATERMARK 8 +#define W_RXWATERMARKS__RX14DATAWATERMARK 7 +#define O_RXWATERMARKS__RX15DATAWATERMARK 0 +#define W_RXWATERMARKS__RX15DATAWATERMARK 7 #define R_FREEWATERMARKS 0x249 -#define O_FREEWATERMARKS__FreeOutWatermark 16 -#define W_FREEWATERMARKS__FreeOutWatermark 16 -#define O_FREEWATERMARKS__JumFrWatermark 8 -#define W_FREEWATERMARKS__JumFrWatermark 7 -#define O_FREEWATERMARKS__RegFrWatermark 0 -#define W_FREEWATERMARKS__RegFrWatermark 7 +#define O_FREEWATERMARKS__FREEOUTWATERMARK 16 +#define W_FREEWATERMARKS__FREEOUTWATERMARK 16 +#define O_FREEWATERMARKS__JUMFRWATERMARK 8 +#define W_FREEWATERMARKS__JUMFRWATERMARK 7 +#define O_FREEWATERMARKS__REGFRWATERMARK 0 +#define W_FREEWATERMARKS__REGFRWATERMARK 7 #define R_EGRESSFIFOCARVINGSLOTS 0x24a #define CTRL_RES0 0 diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 1503ad7..c335ae2 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -38,18 +38,18 @@ #include "nvec.h" #define I2C_CNFG 0x00 -#define I2C_CNFG_PACKET_MODE_EN (1 << 10) -#define I2C_CNFG_NEW_MASTER_SFM (1 << 11) +#define I2C_CNFG_PACKET_MODE_EN BIT(10) +#define I2C_CNFG_NEW_MASTER_SFM BIT(11) #define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12 #define I2C_SL_CNFG 0x20 -#define I2C_SL_NEWSL (1 << 2) -#define I2C_SL_NACK (1 << 1) -#define I2C_SL_RESP (1 << 0) -#define I2C_SL_IRQ (1 << 3) -#define END_TRANS (1 << 4) -#define RCVD (1 << 2) -#define RNW (1 << 1) +#define I2C_SL_NEWSL BIT(2) +#define I2C_SL_NACK BIT(1) +#define I2C_SL_RESP BIT(0) +#define I2C_SL_IRQ BIT(3) +#define END_TRANS BIT(4) +#define RCVD BIT(2) +#define RNW BIT(1) #define I2C_SL_RCVD 0x24 #define I2C_SL_STATUS 0x28 @@ -148,7 +148,7 @@ static int nvec_status_notifier(struct notifier_block *nb, dev_warn(nvec->dev, "unhandled msg type %ld\n", event_type); print_hex_dump(KERN_WARNING, "payload: ", DUMP_PREFIX_NONE, 16, 1, - msg, msg[1] + 2, true); + msg, msg[1] + 2, true); return NOTIFY_OK; } @@ -257,7 +257,7 @@ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value) * occurred, the nvec driver may print an error. */ int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data, - short size) + short size) { struct nvec_msg *msg; unsigned long flags; @@ -313,10 +313,11 @@ int nvec_write_sync(struct nvec_chip *nvec, } dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", - nvec->sync_write_pending); + nvec->sync_write_pending); if (!(wait_for_completion_timeout(&nvec->sync_write, - msecs_to_jiffies(2000)))) { - dev_warn(nvec->dev, "timeout waiting for sync write to complete\n"); + msecs_to_jiffies(2000)))) { + dev_warn(nvec->dev, + "timeout waiting for sync write to complete\n"); mutex_unlock(&nvec->sync_write_mutex); return -ETIMEDOUT; } @@ -422,8 +423,8 @@ static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg) if ((msg->data[0] >> 7) == 1 && (msg->data[0] & 0x0f) == 5) print_hex_dump(KERN_WARNING, "ec system event ", - DUMP_PREFIX_NONE, 16, 1, msg->data, - msg->data[1] + 2, true); + DUMP_PREFIX_NONE, 16, 1, msg->data, + msg->data[1] + 2, true); atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data); @@ -493,8 +494,8 @@ static void nvec_rx_completed(struct nvec_chip *nvec) { if (nvec->rx->pos != nvec_msg_size(nvec->rx)) { dev_err(nvec->dev, "RX incomplete: Expected %u bytes, got %u\n", - (uint) nvec_msg_size(nvec->rx), - (uint) nvec->rx->pos); + (uint)nvec_msg_size(nvec->rx), + (uint)nvec->rx->pos); nvec_msg_free(nvec, nvec->rx); nvec->state = 0; @@ -688,8 +689,8 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) if ((status & (RCVD | RNW)) == RCVD) { if (received != nvec->i2c_addr) dev_err(nvec->dev, - "received address 0x%02x, expected 0x%02x\n", - received, nvec->i2c_addr); + "received address 0x%02x, expected 0x%02x\n", + received, nvec->i2c_addr); nvec->state = 1; } @@ -778,7 +779,7 @@ static int nvec_i2c_parse_dt_pdata(struct nvec_chip *nvec) } if (of_property_read_u32(nvec->dev->of_node, "slave-addr", - &nvec->i2c_addr)) { + &nvec->i2c_addr)) { dev_err(nvec->dev, "no i2c address specified"); return -ENODEV; } @@ -854,14 +855,14 @@ static int tegra_nvec_probe(struct platform_device *pdev) INIT_WORK(&nvec->tx_work, nvec_request_master); err = devm_gpio_request_one(&pdev->dev, nvec->gpio, GPIOF_OUT_INIT_HIGH, - "nvec gpio"); + "nvec gpio"); if (err < 0) { dev_err(nvec->dev, "couldn't request gpio\n"); return -ENODEV; } err = devm_request_irq(&pdev->dev, nvec->irq, nvec_interrupt, 0, - "nvec", nvec); + "nvec", nvec); if (err) { dev_err(nvec->dev, "couldn't request irq\n"); return -ENODEV; @@ -883,8 +884,10 @@ static int tegra_nvec_probe(struct platform_device *pdev) err = nvec_write_sync(nvec, get_firmware_version, 2, &msg); if (!err) { - dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n", - msg->data[4], msg->data[5], msg->data[6], msg->data[7]); + dev_warn(nvec->dev, + "ec firmware version %02x.%02x.%02x / %02x\n", + msg->data[4], msg->data[5], + msg->data[6], msg->data[7]); nvec_msg_free(nvec, msg); } diff --git a/drivers/staging/octeon-usb/TODO b/drivers/staging/octeon-usb/TODO index cc58a7e..2b29acc 100644 --- a/drivers/staging/octeon-usb/TODO +++ b/drivers/staging/octeon-usb/TODO @@ -1,11 +1,8 @@ -This driver is functional and has been tested on EdgeRouter Lite with -USB mass storage. +This driver is functional and has been tested on EdgeRouter Lite, +D-Link DSR-1000N and EBH5600 evaluation board with USB mass storage. TODO: - kernel coding style - checkpatch warnings - - dead code elimination - - device tree bindings - - possibly eliminate the extra "hardware abstraction layer" Contact: Aaro Koskinen <aaro.koskinen@iki.fi> diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index eaf6ded..17442b3 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -43,29 +43,15 @@ * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. */ -#include <linux/kernel.h> + +#include <linux/usb.h> +#include <linux/slab.h> #include <linux/module.h> -#include <linux/init.h> -#include <linux/pci.h> +#include <linux/usb/hcd.h> #include <linux/prefetch.h> -#include <linux/interrupt.h> #include <linux/platform_device.h> -#include <linux/usb.h> - -#include <linux/time.h> -#include <linux/delay.h> - -#include <asm/octeon/cvmx.h> -#include <asm/octeon/cvmx-iob-defs.h> - -#include <linux/usb/hcd.h> - -#include <linux/err.h> #include <asm/octeon/octeon.h> -#include <asm/octeon/cvmx-helper.h> -#include <asm/octeon/cvmx-sysinfo.h> -#include <asm/octeon/cvmx-helper-board.h> #include "octeon-hcd.h" @@ -113,35 +99,35 @@ enum cvmx_usb_direction { }; /** - * enum cvmx_usb_complete - possible callback function status codes + * enum cvmx_usb_status - possible callback function status codes * - * @CVMX_USB_COMPLETE_SUCCESS: The transaction / operation finished without + * @CVMX_USB_STATUS_OK: The transaction / operation finished without * any errors - * @CVMX_USB_COMPLETE_SHORT: FIXME: This is currently not implemented - * @CVMX_USB_COMPLETE_CANCEL: The transaction was canceled while in flight + * @CVMX_USB_STATUS_SHORT: FIXME: This is currently not implemented + * @CVMX_USB_STATUS_CANCEL: The transaction was canceled while in flight * by a user call to cvmx_usb_cancel - * @CVMX_USB_COMPLETE_ERROR: The transaction aborted with an unexpected + * @CVMX_USB_STATUS_ERROR: The transaction aborted with an unexpected * error status - * @CVMX_USB_COMPLETE_STALL: The transaction received a USB STALL response + * @CVMX_USB_STATUS_STALL: The transaction received a USB STALL response * from the device - * @CVMX_USB_COMPLETE_XACTERR: The transaction failed with an error from the + * @CVMX_USB_STATUS_XACTERR: The transaction failed with an error from the * device even after a number of retries - * @CVMX_USB_COMPLETE_DATATGLERR: The transaction failed with a data toggle + * @CVMX_USB_STATUS_DATATGLERR: The transaction failed with a data toggle * error even after a number of retries - * @CVMX_USB_COMPLETE_BABBLEERR: The transaction failed with a babble error - * @CVMX_USB_COMPLETE_FRAMEERR: The transaction failed with a frame error + * @CVMX_USB_STATUS_BABBLEERR: The transaction failed with a babble error + * @CVMX_USB_STATUS_FRAMEERR: The transaction failed with a frame error * even after a number of retries */ -enum cvmx_usb_complete { - CVMX_USB_COMPLETE_SUCCESS, - CVMX_USB_COMPLETE_SHORT, - CVMX_USB_COMPLETE_CANCEL, - CVMX_USB_COMPLETE_ERROR, - CVMX_USB_COMPLETE_STALL, - CVMX_USB_COMPLETE_XACTERR, - CVMX_USB_COMPLETE_DATATGLERR, - CVMX_USB_COMPLETE_BABBLEERR, - CVMX_USB_COMPLETE_FRAMEERR, +enum cvmx_usb_status { + CVMX_USB_STATUS_OK, + CVMX_USB_STATUS_SHORT, + CVMX_USB_STATUS_CANCEL, + CVMX_USB_STATUS_ERROR, + CVMX_USB_STATUS_STALL, + CVMX_USB_STATUS_XACTERR, + CVMX_USB_STATUS_DATATGLERR, + CVMX_USB_STATUS_BABBLEERR, + CVMX_USB_STATUS_FRAMEERR, }; /** @@ -160,13 +146,13 @@ enum cvmx_usb_complete { * status call. */ struct cvmx_usb_port_status { - uint32_t reserved : 25; - uint32_t port_enabled : 1; - uint32_t port_over_current : 1; - uint32_t port_powered : 1; + u32 reserved : 25; + u32 port_enabled : 1; + u32 port_over_current : 1; + u32 port_powered : 1; enum cvmx_usb_speed port_speed : 2; - uint32_t connected : 1; - uint32_t connect_change : 1; + u32 connected : 1; + u32 connect_change : 1; }; /** @@ -180,7 +166,7 @@ struct cvmx_usb_port_status { struct cvmx_usb_iso_packet { int offset; int length; - enum cvmx_usb_complete status; + enum cvmx_usb_status status; }; /** @@ -234,13 +220,13 @@ enum cvmx_usb_pipe_flags { * The low level hardware can transfer a maximum of this number of bytes in each * transfer. The field is 19 bits wide */ -#define MAX_TRANSFER_BYTES ((1<<19)-1) +#define MAX_TRANSFER_BYTES ((1 << 19) - 1) /* * The low level hardware can transfer a maximum of this number of packets in * each transfer. The field is 10 bits wide */ -#define MAX_TRANSFER_PACKETS ((1<<10)-1) +#define MAX_TRANSFER_PACKETS ((1 << 10) - 1) /** * Logical transactions may take numerous low level @@ -284,9 +270,9 @@ enum cvmx_usb_stage { struct cvmx_usb_transaction { struct list_head node; enum cvmx_usb_transfer type; - uint64_t buffer; + u64 buffer; int buffer_length; - uint64_t control_header; + u64 control_header; int iso_start_frame; int iso_number_packets; struct cvmx_usb_iso_packet *iso_packets; @@ -328,36 +314,37 @@ struct cvmx_usb_transaction { struct cvmx_usb_pipe { struct list_head node; struct list_head transactions; - uint64_t interval; - uint64_t next_tx_frame; + u64 interval; + u64 next_tx_frame; enum cvmx_usb_pipe_flags flags; enum cvmx_usb_speed device_speed; enum cvmx_usb_transfer transfer_type; enum cvmx_usb_direction transfer_dir; int multi_count; - uint16_t max_packet; - uint8_t device_addr; - uint8_t endpoint_num; - uint8_t hub_device_addr; - uint8_t hub_port; - uint8_t pid_toggle; - uint8_t channel; - int8_t split_sc_frame; + u16 max_packet; + u8 device_addr; + u8 endpoint_num; + u8 hub_device_addr; + u8 hub_port; + u8 pid_toggle; + u8 channel; + s8 split_sc_frame; }; struct cvmx_usb_tx_fifo { struct { int channel; int size; - uint64_t address; - } entry[MAX_CHANNELS+1]; + u64 address; + } entry[MAX_CHANNELS + 1]; int head; int tail; }; /** - * struct cvmx_usb_state - the state of the USB block + * struct octeon_hcd - the state of the USB block * + * lock: Serialization lock. * init_flags: Flags passed to initialize. * index: Which USB block this is for. * idle_hardware_channels: Bit set for every idle hardware channel. @@ -372,7 +359,8 @@ struct cvmx_usb_tx_fifo { * frame_number: Increments every SOF interrupt for time keeping. * active_split: Points to the current active split, or NULL. */ -struct cvmx_usb_state { +struct octeon_hcd { + spinlock_t lock; /* serialization lock */ int init_flags; int index; int idle_hardware_channels; @@ -382,23 +370,18 @@ struct cvmx_usb_state { struct cvmx_usb_port_status port_status; struct list_head idle_pipes; struct list_head active_pipes[4]; - uint64_t frame_number; + u64 frame_number; struct cvmx_usb_transaction *active_split; struct cvmx_usb_tx_fifo periodic; struct cvmx_usb_tx_fifo nonperiodic; }; -struct octeon_hcd { - spinlock_t lock; - struct cvmx_usb_state usb; -}; - /* This macro spins on a register waiting for it to reach a condition. */ #define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ ({int result; \ do { \ - uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \ - octeon_get_clock_rate() / 1000000; \ + u64 done = cvmx_get_cycle() + (u64)timeout_usec * \ + octeon_get_clock_rate() / 1000000; \ union _union c; \ \ while (1) { \ @@ -431,7 +414,7 @@ struct octeon_hcd { /* Returns the IO address to push/pop stuff data from the FIFOs */ #define USB_FIFO_ADDRESS(channel, usb_index) \ - (CVMX_USBCX_GOTGCTL(usb_index) + ((channel)+1)*0x1000) + (CVMX_USBCX_GOTGCTL(usb_index) + ((channel) + 1) * 0x1000) /** * struct octeon_temp_buffer - a bounce buffer for USB transfers @@ -447,11 +430,6 @@ struct octeon_temp_buffer { u8 data[0]; }; -static inline struct octeon_hcd *cvmx_usb_to_octeon(struct cvmx_usb_state *p) -{ - return container_of(p, struct octeon_hcd, usb); -} - static inline struct usb_hcd *octeon_to_hcd(struct octeon_hcd *p) { return container_of((void *)p, struct usb_hcd, hcd_priv); @@ -562,14 +540,12 @@ static void octeon_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) * * Returns: Result of the read */ -static inline uint32_t cvmx_usb_read_csr32(struct cvmx_usb_state *usb, - uint64_t address) +static inline u32 cvmx_usb_read_csr32(struct octeon_hcd *usb, u64 address) { - uint32_t result = cvmx_read64_uint32(address ^ 4); + u32 result = cvmx_read64_uint32(address ^ 4); return result; } - /** * Write a USB 32bit CSR. It performs the necessary address * swizzle for 32bit CSRs and logs the value in a readable format @@ -579,8 +555,8 @@ static inline uint32_t cvmx_usb_read_csr32(struct cvmx_usb_state *usb, * @address: 64bit address to write * @value: Value to write */ -static inline void cvmx_usb_write_csr32(struct cvmx_usb_state *usb, - uint64_t address, uint32_t value) +static inline void cvmx_usb_write_csr32(struct octeon_hcd *usb, + u64 address, u32 value) { cvmx_write64_uint32(address ^ 4, value); cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); @@ -595,14 +571,13 @@ static inline void cvmx_usb_write_csr32(struct cvmx_usb_state *usb, * * Returns: Non zero if we need to do split transactions */ -static inline int cvmx_usb_pipe_needs_split(struct cvmx_usb_state *usb, +static inline int cvmx_usb_pipe_needs_split(struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe) { return pipe->device_speed != CVMX_USB_SPEED_HIGH && usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH; } - /** * Trivial utility function to return the correct PID for a pipe * @@ -617,7 +592,7 @@ static inline int cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe) return 0; /* Data0 */ } -static void cvmx_fifo_setup(struct cvmx_usb_state *usb) +static void cvmx_fifo_setup(struct octeon_hcd *usb) { union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3; union cvmx_usbcx_gnptxfsiz npsiz; @@ -675,7 +650,7 @@ static void cvmx_fifo_setup(struct cvmx_usb_state *usb) * * Returns: 0 or a negative error code. */ -static int cvmx_usb_shutdown(struct cvmx_usb_state *usb) +static int cvmx_usb_shutdown(struct octeon_hcd *usb) { union cvmx_usbnx_clk_ctl usbn_clk_ctl; @@ -704,12 +679,12 @@ static int cvmx_usb_shutdown(struct cvmx_usb_state *usb) * off in the disabled state. * * @dev: Pointer to struct device for logging purposes. - * @usb: Pointer to struct cvmx_usb_state. + * @usb: Pointer to struct octeon_hcd. * * Returns: 0 or a negative error code. */ static int cvmx_usb_initialize(struct device *dev, - struct cvmx_usb_state *usb) + struct octeon_hcd *usb) { int channel; int divisor; @@ -975,7 +950,7 @@ retry: * * @usb: USB device state populated by cvmx_usb_initialize(). */ -static void cvmx_usb_reset_port(struct cvmx_usb_state *usb) +static void cvmx_usb_reset_port(struct octeon_hcd *usb) { usb->usbcx_hprt.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); @@ -1002,7 +977,6 @@ static void cvmx_usb_reset_port(struct cvmx_usb_state *usb) CVMX_USBCX_HPRT(usb->index)); } - /** * Disable a USB port. After this call the USB port will not * generate data transfers and will not generate events. @@ -1013,7 +987,7 @@ static void cvmx_usb_reset_port(struct cvmx_usb_state *usb) * * Returns: 0 or a negative error code. */ -static int cvmx_usb_disable(struct cvmx_usb_state *usb) +static int cvmx_usb_disable(struct octeon_hcd *usb) { /* Disable the port */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt, @@ -1021,7 +995,6 @@ static int cvmx_usb_disable(struct cvmx_usb_state *usb) return 0; } - /** * Get the current state of the USB port. Use this call to * determine if the usb port has anything connected, is enabled, @@ -1033,8 +1006,7 @@ static int cvmx_usb_disable(struct cvmx_usb_state *usb) * * Returns: Port status information */ -static struct cvmx_usb_port_status cvmx_usb_get_status( - struct cvmx_usb_state *usb) +static struct cvmx_usb_port_status cvmx_usb_get_status(struct octeon_hcd *usb) { union cvmx_usbcx_hprt usbc_hprt; struct cvmx_usb_port_status result; @@ -1105,7 +1077,7 @@ static struct cvmx_usb_port_status cvmx_usb_get_status( * * Returns: A non-NULL value is a pipe. NULL means an error. */ -static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, +static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct octeon_hcd *usb, int device_addr, int endpoint_num, enum cvmx_usb_speed @@ -1125,8 +1097,8 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, if (!pipe) return NULL; if ((device_speed == CVMX_USB_SPEED_HIGH) && - (transfer_dir == CVMX_USB_DIRECTION_OUT) && - (transfer_type == CVMX_USB_TRANSFER_BULK)) + (transfer_dir == CVMX_USB_DIRECTION_OUT) && + (transfer_type == CVMX_USB_TRANSFER_BULK)) pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING; pipe->device_addr = device_addr; pipe->endpoint_num = endpoint_num; @@ -1143,9 +1115,9 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, if (!interval) interval = 1; if (cvmx_usb_pipe_needs_split(usb, pipe)) { - pipe->interval = interval*8; + pipe->interval = interval * 8; /* Force start splits to be schedule on uFrame 0 */ - pipe->next_tx_frame = ((usb->frame_number+7)&~7) + + pipe->next_tx_frame = ((usb->frame_number + 7) & ~7) + pipe->interval; } else { pipe->interval = interval; @@ -1166,7 +1138,6 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, return pipe; } - /** * Poll the RX FIFOs and remove data as needed. This function is only used * in non DMA mode. It is very important that this function be called quickly @@ -1174,13 +1145,13 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, * * @usb: USB device state populated by cvmx_usb_initialize(). */ -static void cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) +static void cvmx_usb_poll_rx_fifo(struct octeon_hcd *usb) { union cvmx_usbcx_grxstsph rx_status; int channel; int bytes; - uint64_t address; - uint32_t *ptr; + u64 address; + u32 *ptr; rx_status.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index)); @@ -1213,7 +1184,6 @@ static void cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) CVMX_SYNCW; } - /** * Fill the TX hardware fifo with data out of the software * fifos @@ -1225,7 +1195,7 @@ static void cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) * Returns: Non zero if the hardware fifo was too small and needs * to be serviced again. */ -static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, +static int cvmx_usb_fill_tx_hw(struct octeon_hcd *usb, struct cvmx_usb_tx_fifo *fifo, int available) { /* @@ -1234,9 +1204,9 @@ static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, */ while (available && (fifo->head != fifo->tail)) { int i = fifo->tail; - const uint32_t *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); - uint64_t csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, - usb->index) ^ 4; + const u32 *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); + u64 csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, + usb->index) ^ 4; int words = available; /* Limit the amount of data to what the SW fifo has */ @@ -1275,13 +1245,12 @@ static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, return fifo->head != fifo->tail; } - /** * Check the hardware FIFOs and fill them as needed * * @usb: USB device state populated by cvmx_usb_initialize(). */ -static void cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb) +static void cvmx_usb_poll_tx_fifo(struct octeon_hcd *usb) { if (usb->periodic.head != usb->periodic.tail) { union cvmx_usbcx_hptxsts tx_status; @@ -1312,14 +1281,13 @@ static void cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb) } } - /** * Fill the TX FIFO with an outgoing packet * * @usb: USB device state populated by cvmx_usb_initialize(). * @channel: Channel number to get packet from */ -static void cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) +static void cvmx_usb_fill_tx_fifo(struct octeon_hcd *usb, int channel) { union cvmx_usbcx_hccharx hcchar; union cvmx_usbcx_hcspltx usbc_hcsplt; @@ -1348,7 +1316,7 @@ static void cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) return; if ((hcchar.s.eptype == CVMX_USB_TRANSFER_INTERRUPT) || - (hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS)) + (hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS)) fifo = &usb->periodic; else fifo = &usb->nonperiodic; @@ -1357,7 +1325,7 @@ static void cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) fifo->entry[fifo->head].address = cvmx_read64_uint64(CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel * 8); - fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2; + fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize + 3) >> 2; fifo->head++; if (fifo->head > MAX_CHANNELS) fifo->head = 0; @@ -1373,12 +1341,11 @@ static void cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) * @channel: Channel to setup * @pipe: Pipe for control transaction */ -static void cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, +static void cvmx_usb_start_channel_control(struct octeon_hcd *usb, int channel, struct cvmx_usb_pipe *pipe) { - struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); - struct usb_hcd *hcd = octeon_to_hcd(priv); + struct usb_hcd *hcd = octeon_to_hcd(usb); struct device *dev = hcd->self.controller; struct cvmx_usb_transaction *transaction = list_first_entry(&pipe->transactions, typeof(*transaction), @@ -1488,9 +1455,9 @@ static void cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, */ packets_to_transfer = DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet); - if (packets_to_transfer == 0) + if (packets_to_transfer == 0) { packets_to_transfer = 1; - else if ((packets_to_transfer > 1) && + } else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { /* * Limit to one packet when not using DMA. Channels must be @@ -1515,7 +1482,6 @@ static void cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, usbc_hctsiz.u32); } - /** * Start a channel to perform the pipe's head transaction * @@ -1523,7 +1489,7 @@ static void cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, * @channel: Channel to setup * @pipe: Pipe to start */ -static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, +static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel, struct cvmx_usb_pipe *pipe) { struct cvmx_usb_transaction *transaction = @@ -1539,7 +1505,7 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, pipe->flags |= CVMX_USB_PIPE_FLAGS_SCHEDULED; /* Mark this channel as in use */ - usb->idle_hardware_channels &= ~(1<<channel); + usb->idle_hardware_channels &= ~(1 << channel); /* Enable the channel interrupt bits */ { @@ -1579,22 +1545,22 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, usbc_hcintmsk.s.xfercomplmsk = 1; } cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCINTMSKX(channel, usb->index), - usbc_hcintmsk.u32); + CVMX_USBCX_HCINTMSKX(channel, usb->index), + usbc_hcintmsk.u32); /* Enable the channel interrupt to propagate */ usbc_haintmsk.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index)); - usbc_haintmsk.s.haintmsk |= 1<<channel; + usbc_haintmsk.s.haintmsk |= 1 << channel; cvmx_usb_write_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index), usbc_haintmsk.u32); } /* Setup the location the DMA engine uses. */ { - uint64_t reg; - uint64_t dma_address = transaction->buffer + - transaction->actual_bytes; + u64 reg; + u64 dma_address = transaction->buffer + + transaction->actual_bytes; if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) dma_address = transaction->buffer + @@ -1636,15 +1602,16 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, * We only store the lower two bits since the time ahead * can only be two frames */ - if ((transaction->stage&1) == 0) { + if ((transaction->stage & 1) == 0) { if (transaction->type == CVMX_USB_TRANSFER_BULK) pipe->split_sc_frame = (usb->frame_number + 1) & 0x7f; else pipe->split_sc_frame = (usb->frame_number + 2) & 0x7f; - } else + } else { pipe->split_sc_frame = -1; + } usbc_hcsplt.s.spltena = 1; usbc_hcsplt.s.hubaddr = pipe->hub_device_addr; @@ -1666,10 +1633,9 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, * begin/middle/end of the data or all */ if (!usbc_hcsplt.s.compsplt && - (pipe->transfer_dir == - CVMX_USB_DIRECTION_OUT) && - (pipe->transfer_type == - CVMX_USB_TRANSFER_ISOCHRONOUS)) { + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && + (pipe->transfer_type == + CVMX_USB_TRANSFER_ISOCHRONOUS)) { /* * Clear the split complete frame number as * there isn't going to be a split complete @@ -1732,11 +1698,11 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, */ packets_to_transfer = DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet); - if (packets_to_transfer == 0) + if (packets_to_transfer == 0) { packets_to_transfer = 1; - else if ((packets_to_transfer > 1) && - (usb->init_flags & - CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { + } else if ((packets_to_transfer > 1) && + (usb->init_flags & + CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { /* * Limit to one packet when not using DMA. Channels must * be restarted between every packet for IN @@ -1783,7 +1749,7 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, * Set the startframe odd/even properly. This is only used for * periodic */ - usbc_hcchar.s.oddfrm = usb->frame_number&1; + usbc_hcchar.s.oddfrm = usb->frame_number & 1; /* * Set the number of back to back packets allowed by this @@ -1843,9 +1809,11 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, break; } { - union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = + union cvmx_usbcx_hctsizx usbc_hctsiz = { .u32 = cvmx_usb_read_csr32(usb, - CVMX_USBCX_HCTSIZX(channel, usb->index))}; + CVMX_USBCX_HCTSIZX(channel, + usb->index)) + }; transaction->xfersize = usbc_hctsiz.s.xfersize; transaction->pktcnt = usbc_hctsiz.s.pktcnt; } @@ -1858,21 +1826,19 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel, cvmx_usb_fill_tx_fifo(usb, channel); } - /** * Find a pipe that is ready to be scheduled to hardware. * @usb: USB device state populated by cvmx_usb_initialize(). - * @list: Pipe list to search - * @current_frame: - * Frame counter to use as a time reference. + * @xfer_type: Transfer type * * Returns: Pipe or NULL if none are ready */ static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe( - struct cvmx_usb_state *usb, - struct list_head *list, - uint64_t current_frame) + struct octeon_hcd *usb, + enum cvmx_usb_transfer xfer_type) { + struct list_head *list = usb->active_pipes + xfer_type; + u64 current_frame = usb->frame_number; struct cvmx_usb_pipe *pipe; list_for_each_entry(pipe, list, node) { @@ -1880,11 +1846,11 @@ static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe( list_first_entry(&pipe->transactions, typeof(*t), node); if (!(pipe->flags & CVMX_USB_PIPE_FLAGS_SCHEDULED) && t && - (pipe->next_tx_frame <= current_frame) && - ((pipe->split_sc_frame == -1) || - ((((int)current_frame - (int)pipe->split_sc_frame) - & 0x7f) < 0x40)) && - (!usb->active_split || (usb->active_split == t))) { + (pipe->next_tx_frame <= current_frame) && + ((pipe->split_sc_frame == -1) || + ((((int)current_frame - pipe->split_sc_frame) & 0x7f) < + 0x40)) && + (!usb->active_split || (usb->active_split == t))) { prefetch(t); return pipe; } @@ -1892,6 +1858,32 @@ static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe( return NULL; } +static struct cvmx_usb_pipe *cvmx_usb_next_pipe(struct octeon_hcd *usb, + int is_sof) +{ + struct cvmx_usb_pipe *pipe; + + /* Find a pipe needing service. */ + if (is_sof) { + /* + * Only process periodic pipes on SOF interrupts. This way we + * are sure that the periodic data is sent in the beginning of + * the frame. + */ + pipe = cvmx_usb_find_ready_pipe(usb, + CVMX_USB_TRANSFER_ISOCHRONOUS); + if (pipe) + return pipe; + pipe = cvmx_usb_find_ready_pipe(usb, + CVMX_USB_TRANSFER_INTERRUPT); + if (pipe) + return pipe; + } + pipe = cvmx_usb_find_ready_pipe(usb, CVMX_USB_TRANSFER_CONTROL); + if (pipe) + return pipe; + return cvmx_usb_find_ready_pipe(usb, CVMX_USB_TRANSFER_BULK); +} /** * Called whenever a pipe might need to be scheduled to the @@ -1900,7 +1892,7 @@ static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe( * @usb: USB device state populated by cvmx_usb_initialize(). * @is_sof: True if this schedule was called on a SOF interrupt. */ -static void cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) +static void cvmx_usb_schedule(struct octeon_hcd *usb, int is_sof) { int channel; struct cvmx_usb_pipe *pipe; @@ -1922,7 +1914,7 @@ static void cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) CVMX_USBCX_HFIR(usb->index)) }; - if (hfnum.s.frrem < hfir.s.frint/4) + if (hfnum.s.frrem < hfir.s.frint / 4) goto done; } @@ -1932,35 +1924,7 @@ static void cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) if (unlikely(channel > 7)) break; - /* Find a pipe needing service */ - pipe = NULL; - if (is_sof) { - /* - * Only process periodic pipes on SOF interrupts. This - * way we are sure that the periodic data is sent in the - * beginning of the frame - */ - pipe = cvmx_usb_find_ready_pipe(usb, - usb->active_pipes + - CVMX_USB_TRANSFER_ISOCHRONOUS, - usb->frame_number); - if (likely(!pipe)) - pipe = cvmx_usb_find_ready_pipe(usb, - usb->active_pipes + - CVMX_USB_TRANSFER_INTERRUPT, - usb->frame_number); - } - if (likely(!pipe)) { - pipe = cvmx_usb_find_ready_pipe(usb, - usb->active_pipes + - CVMX_USB_TRANSFER_CONTROL, - usb->frame_number); - if (likely(!pipe)) - pipe = cvmx_usb_find_ready_pipe(usb, - usb->active_pipes + - CVMX_USB_TRANSFER_BULK, - usb->frame_number); - } + pipe = cvmx_usb_next_pipe(usb, is_sof); if (!pipe) break; @@ -1974,7 +1938,7 @@ done: */ need_sof = 0; for (ttype = CVMX_USB_TRANSFER_CONTROL; - ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { + ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { list_for_each_entry(pipe, &usb->active_pipes[ttype], node) { if (pipe->next_tx_frame > usb->frame_number) { need_sof = 1; @@ -1986,19 +1950,18 @@ done: cvmx_usbcx_gintmsk, sofmsk, need_sof); } -static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, - enum cvmx_usb_complete status, +static void octeon_usb_urb_complete_callback(struct octeon_hcd *usb, + enum cvmx_usb_status status, struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction, int bytes_transferred, struct urb *urb) { - struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); - struct usb_hcd *hcd = octeon_to_hcd(priv); + struct usb_hcd *hcd = octeon_to_hcd(usb); struct device *dev = hcd->self.controller; - if (likely(status == CVMX_USB_COMPLETE_SUCCESS)) + if (likely(status == CVMX_USB_STATUS_OK)) urb->actual_length = bytes_transferred; else urb->actual_length = 0; @@ -2015,12 +1978,11 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, * field. */ struct cvmx_usb_iso_packet *iso_packet = - (struct cvmx_usb_iso_packet *) urb->setup_packet; + (struct cvmx_usb_iso_packet *)urb->setup_packet; /* Recalculate the transfer size by adding up each packet */ urb->actual_length = 0; for (i = 0; i < urb->number_of_packets; i++) { - if (iso_packet[i].status == - CVMX_USB_COMPLETE_SUCCESS) { + if (iso_packet[i].status == CVMX_USB_STATUS_OK) { urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = iso_packet[i].length; @@ -2040,41 +2002,41 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, } switch (status) { - case CVMX_USB_COMPLETE_SUCCESS: + case CVMX_USB_STATUS_OK: urb->status = 0; break; - case CVMX_USB_COMPLETE_CANCEL: + case CVMX_USB_STATUS_CANCEL: if (urb->status == 0) urb->status = -ENOENT; break; - case CVMX_USB_COMPLETE_STALL: + case CVMX_USB_STATUS_STALL: dev_dbg(dev, "status=stall pipe=%p transaction=%p size=%d\n", pipe, transaction, bytes_transferred); urb->status = -EPIPE; break; - case CVMX_USB_COMPLETE_BABBLEERR: + case CVMX_USB_STATUS_BABBLEERR: dev_dbg(dev, "status=babble pipe=%p transaction=%p size=%d\n", pipe, transaction, bytes_transferred); urb->status = -EPIPE; break; - case CVMX_USB_COMPLETE_SHORT: + case CVMX_USB_STATUS_SHORT: dev_dbg(dev, "status=short pipe=%p transaction=%p size=%d\n", pipe, transaction, bytes_transferred); urb->status = -EREMOTEIO; break; - case CVMX_USB_COMPLETE_ERROR: - case CVMX_USB_COMPLETE_XACTERR: - case CVMX_USB_COMPLETE_DATATGLERR: - case CVMX_USB_COMPLETE_FRAMEERR: + case CVMX_USB_STATUS_ERROR: + case CVMX_USB_STATUS_XACTERR: + case CVMX_USB_STATUS_DATATGLERR: + case CVMX_USB_STATUS_FRAMEERR: dev_dbg(dev, "status=%d pipe=%p transaction=%p size=%d\n", status, pipe, transaction, bytes_transferred); urb->status = -EPROTO; break; } - usb_hcd_unlink_urb_from_ep(octeon_to_hcd(priv), urb); - spin_unlock(&priv->lock); - usb_hcd_giveback_urb(octeon_to_hcd(priv), urb, urb->status); - spin_lock(&priv->lock); + usb_hcd_unlink_urb_from_ep(octeon_to_hcd(usb), urb); + spin_unlock(&usb->lock); + usb_hcd_giveback_urb(octeon_to_hcd(usb), urb, urb->status); + spin_lock(&usb->lock); } /** @@ -2088,10 +2050,10 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, * @complete_code: * Completion code */ -static void cvmx_usb_perform_complete(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct cvmx_usb_transaction *transaction, - enum cvmx_usb_complete complete_code) +static void cvmx_usb_complete(struct octeon_hcd *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + enum cvmx_usb_status complete_code) { /* If this was a split then clear our split in progress marker */ if (usb->active_split == transaction) @@ -2111,7 +2073,7 @@ static void cvmx_usb_perform_complete(struct cvmx_usb_state *usb, * next one */ if ((transaction->iso_number_packets > 1) && - (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { + (complete_code == CVMX_USB_STATUS_OK)) { /* No bytes transferred for this packet as of yet */ transaction->actual_bytes = 0; /* One less ISO waiting to transfer */ @@ -2134,7 +2096,6 @@ static void cvmx_usb_perform_complete(struct cvmx_usb_state *usb, kfree(transaction); } - /** * Submit a usb transaction to a pipe. Called for all types * of transactions. @@ -2158,12 +2119,12 @@ static void cvmx_usb_perform_complete(struct cvmx_usb_state *usb, * Returns: Transaction or NULL on failure. */ static struct cvmx_usb_transaction *cvmx_usb_submit_transaction( - struct cvmx_usb_state *usb, + struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, enum cvmx_usb_transfer type, - uint64_t buffer, + u64 buffer, int buffer_length, - uint64_t control_header, + u64 control_header, int iso_start_frame, int iso_number_packets, struct cvmx_usb_iso_packet *iso_packets, @@ -2209,7 +2170,6 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_transaction( return transaction; } - /** * Call to submit a USB Bulk transfer to a pipe. * @@ -2220,7 +2180,7 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_transaction( * Returns: A submitted transaction or NULL on failure. */ static struct cvmx_usb_transaction *cvmx_usb_submit_bulk( - struct cvmx_usb_state *usb, + struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, struct urb *urb) { @@ -2234,7 +2194,6 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_bulk( urb); } - /** * Call to submit a USB Interrupt transfer to a pipe. * @@ -2245,7 +2204,7 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_bulk( * Returns: A submitted transaction or NULL on failure. */ static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt( - struct cvmx_usb_state *usb, + struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, struct urb *urb) { @@ -2260,7 +2219,6 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt( urb); } - /** * Call to submit a USB Control transfer to a pipe. * @@ -2271,12 +2229,12 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt( * Returns: A submitted transaction or NULL on failure. */ static struct cvmx_usb_transaction *cvmx_usb_submit_control( - struct cvmx_usb_state *usb, + struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, struct urb *urb) { int buffer_length = urb->transfer_buffer_length; - uint64_t control_header = urb->setup_dma; + u64 control_header = urb->setup_dma; struct usb_ctrlrequest *header = cvmx_phys_to_ptr(control_header); if ((header->bRequestType & USB_DIR_IN) == 0) @@ -2292,7 +2250,6 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_control( urb); } - /** * Call to submit a USB Isochronous transfer to a pipe. * @@ -2303,13 +2260,13 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_control( * Returns: A submitted transaction or NULL on failure. */ static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous( - struct cvmx_usb_state *usb, + struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, struct urb *urb) { struct cvmx_usb_iso_packet *packets; - packets = (struct cvmx_usb_iso_packet *) urb->setup_packet; + packets = (struct cvmx_usb_iso_packet *)urb->setup_packet; return cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_ISOCHRONOUS, urb->transfer_dma, @@ -2320,7 +2277,6 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous( packets, urb); } - /** * Cancel one outstanding request in a pipe. Canceling a request * can fail if the transaction has already completed before cancel @@ -2334,7 +2290,7 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous( * * Returns: 0 or a negative error code. */ -static int cvmx_usb_cancel(struct cvmx_usb_state *usb, +static int cvmx_usb_cancel(struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction) { @@ -2360,17 +2316,15 @@ static int cvmx_usb_cancel(struct cvmx_usb_state *usb, if (usbc_hcchar.s.chena) { usbc_hcchar.s.chdis = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCCHARX(pipe->channel, - usb->index), - usbc_hcchar.u32); + CVMX_USBCX_HCCHARX(pipe->channel, + usb->index), + usbc_hcchar.u32); } } - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_CANCEL); + cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_CANCEL); return 0; } - /** * Cancel all outstanding requests in a pipe. Logically all this * does is call cvmx_usb_cancel() in a loop. @@ -2380,7 +2334,7 @@ static int cvmx_usb_cancel(struct cvmx_usb_state *usb, * * Returns: 0 or a negative error code. */ -static int cvmx_usb_cancel_all(struct cvmx_usb_state *usb, +static int cvmx_usb_cancel_all(struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe) { struct cvmx_usb_transaction *transaction, *next; @@ -2395,7 +2349,6 @@ static int cvmx_usb_cancel_all(struct cvmx_usb_state *usb, return 0; } - /** * Close a pipe created with cvmx_usb_open_pipe(). * @@ -2405,7 +2358,7 @@ static int cvmx_usb_cancel_all(struct cvmx_usb_state *usb, * Returns: 0 or a negative error code. EBUSY is returned if the pipe has * outstanding transfers. */ -static int cvmx_usb_close_pipe(struct cvmx_usb_state *usb, +static int cvmx_usb_close_pipe(struct octeon_hcd *usb, struct cvmx_usb_pipe *pipe) { /* Fail if the pipe has pending transactions */ @@ -2426,7 +2379,7 @@ static int cvmx_usb_close_pipe(struct cvmx_usb_state *usb, * * Returns: USB frame number */ -static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb) +static int cvmx_usb_get_frame_number(struct octeon_hcd *usb) { int frame_number; union cvmx_usbcx_hfnum usbc_hfnum; @@ -2437,6 +2390,197 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb) return frame_number; } +static void cvmx_usb_transfer_control(struct octeon_hcd *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + union cvmx_usbcx_hccharx usbc_hcchar, + int buffer_space_left, + int bytes_in_last_packet) +{ + switch (transaction->stage) { + case CVMX_USB_STAGE_NON_CONTROL: + case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: + /* This should be impossible */ + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_ERROR); + break; + case CVMX_USB_STAGE_SETUP: + pipe->pid_toggle = 1; + if (cvmx_usb_pipe_needs_split(usb, pipe)) { + transaction->stage = + CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; + } else { + struct usb_ctrlrequest *header = + cvmx_phys_to_ptr(transaction->control_header); + if (header->wLength) + transaction->stage = CVMX_USB_STAGE_DATA; + else + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: + { + struct usb_ctrlrequest *header = + cvmx_phys_to_ptr(transaction->control_header); + if (header->wLength) + transaction->stage = CVMX_USB_STAGE_DATA; + else + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_DATA: + if (cvmx_usb_pipe_needs_split(usb, pipe)) { + transaction->stage = CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; + /* + * For setup OUT data that are splits, + * the hardware doesn't appear to count + * transferred data. Here we manually + * update the data transferred + */ + if (!usbc_hcchar.s.epdir) { + if (buffer_space_left < pipe->max_packet) + transaction->actual_bytes += + buffer_space_left; + else + transaction->actual_bytes += + pipe->max_packet; + } + } else if ((buffer_space_left == 0) || + (bytes_in_last_packet < pipe->max_packet)) { + pipe->pid_toggle = 1; + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: + if ((buffer_space_left == 0) || + (bytes_in_last_packet < pipe->max_packet)) { + pipe->pid_toggle = 1; + transaction->stage = CVMX_USB_STAGE_STATUS; + } else { + transaction->stage = CVMX_USB_STAGE_DATA; + } + break; + case CVMX_USB_STAGE_STATUS: + if (cvmx_usb_pipe_needs_split(usb, pipe)) + transaction->stage = + CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; + else + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + break; + case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: + cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK); + break; + } +} + +static void cvmx_usb_transfer_bulk(struct octeon_hcd *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + union cvmx_usbcx_hcintx usbc_hcint, + int buffer_space_left, + int bytes_in_last_packet) +{ + /* + * The only time a bulk transfer isn't complete when it finishes with + * an ACK is during a split transaction. For splits we need to continue + * the transfer if more data is needed. + */ + if (cvmx_usb_pipe_needs_split(usb, pipe)) { + if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + else if (buffer_space_left && + (bytes_in_last_packet == pipe->max_packet)) + transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + else + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + } else { + if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && + (usbc_hcint.s.nak)) + pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING; + if (!buffer_space_left || + (bytes_in_last_packet < pipe->max_packet)) + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + } +} + +static void cvmx_usb_transfer_intr(struct octeon_hcd *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + int buffer_space_left, + int bytes_in_last_packet) +{ + if (cvmx_usb_pipe_needs_split(usb, pipe)) { + if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) { + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + } else if (buffer_space_left && + (bytes_in_last_packet == pipe->max_packet)) { + transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + } else { + pipe->next_tx_frame += pipe->interval; + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + } + } else if (!buffer_space_left || + (bytes_in_last_packet < pipe->max_packet)) { + pipe->next_tx_frame += pipe->interval; + cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK); + } +} + +static void cvmx_usb_transfer_isoc(struct octeon_hcd *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + int buffer_space_left, + int bytes_in_last_packet, + int bytes_this_transfer) +{ + if (cvmx_usb_pipe_needs_split(usb, pipe)) { + /* + * ISOCHRONOUS OUT splits don't require a complete split stage. + * Instead they use a sequence of begin OUT splits to transfer + * the data 188 bytes at a time. Once the transfer is complete, + * the pipe sleeps until the next schedule interval. + */ + if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { + /* + * If no space left or this wasn't a max size packet + * then this transfer is complete. Otherwise start it + * again to send the next 188 bytes + */ + if (!buffer_space_left || (bytes_this_transfer < 188)) { + pipe->next_tx_frame += pipe->interval; + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + } + return; + } + if (transaction->stage == + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { + /* + * We are in the incoming data phase. Keep getting data + * until we run out of space or get a small packet + */ + if ((buffer_space_left == 0) || + (bytes_in_last_packet < pipe->max_packet)) { + pipe->next_tx_frame += pipe->interval; + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_OK); + } + } else { + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + } + } else { + pipe->next_tx_frame += pipe->interval; + cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK); + } +} /** * Poll a channel for status @@ -2446,10 +2590,9 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb) * * Returns: Zero on success */ -static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) +static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel) { - struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); - struct usb_hcd *hcd = octeon_to_hcd(priv); + struct usb_hcd *hcd = octeon_to_hcd(usb); struct device *dev = hcd->self.controller; union cvmx_usbcx_hcintx usbc_hcint; union cvmx_usbcx_hctsizx usbc_hctsiz; @@ -2476,9 +2619,9 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * write of HCCHARX without changing things */ cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCCHARX(channel, - usb->index), - usbc_hcchar.u32); + CVMX_USBCX_HCCHARX(channel, + usb->index), + usbc_hcchar.u32); return 0; } @@ -2493,14 +2636,12 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) hcintmsk.u32 = 0; hcintmsk.s.chhltdmsk = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCINTMSKX(channel, - usb->index), - hcintmsk.u32); + CVMX_USBCX_HCINTMSKX(channel, usb->index), + hcintmsk.u32); usbc_hcchar.s.chdis = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCCHARX(channel, - usb->index), - usbc_hcchar.u32); + CVMX_USBCX_HCCHARX(channel, usb->index), + usbc_hcchar.u32); return 0; } else if (usbc_hcint.s.xfercompl) { /* @@ -2524,7 +2665,7 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) /* Disable the channel interrupts now that it is done */ cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); - usb->idle_hardware_channels |= (1<<channel); + usb->idle_hardware_channels |= (1 << channel); /* Make sure this channel is tied to a valid pipe */ pipe = usb->pipe_for_channel[channel]; @@ -2594,7 +2735,7 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * transferred */ if ((transaction->stage == CVMX_USB_STAGE_SETUP) || - (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) + (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) bytes_this_transfer = 0; /* @@ -2622,8 +2763,8 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * will clear this flag */ if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && - (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) + (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING; if (unlikely(WARN_ON_ONCE(bytes_this_transfer < 0))) { @@ -2632,8 +2773,8 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * keeps substracting same byte count over and over again. In * such case we just need to fail every transaction. */ - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_ERROR); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_ERROR); return 0; } @@ -2645,24 +2786,24 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * the actual bytes transferred */ pipe->pid_toggle = 0; - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_STALL); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_STALL); } else if (usbc_hcint.s.xacterr) { /* * XactErr as a response means the device signaled * something wrong with the transfer. For example, PID * toggle errors cause these. */ - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_XACTERR); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_XACTERR); } else if (usbc_hcint.s.bblerr) { /* Babble Error (BblErr) */ - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_BABBLEERR); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_BABBLEERR); } else if (usbc_hcint.s.datatglerr) { /* Data toggle error */ - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_DATATGLERR); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_DATATGLERR); } else if (usbc_hcint.s.nyet) { /* * NYET as a response is only allowed in three cases: as a @@ -2677,10 +2818,10 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * again. Otherwise this transaction is complete */ if ((buffer_space_left == 0) || - (bytes_in_last_packet < pipe->max_packet)) - cvmx_usb_perform_complete(usb, pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); + (bytes_in_last_packet < pipe->max_packet)) + cvmx_usb_complete(usb, pipe, + transaction, + CVMX_USB_STATUS_OK); } else { /* * Split transactions retry the split complete 4 times @@ -2714,205 +2855,26 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) switch (transaction->type) { case CVMX_USB_TRANSFER_CONTROL: - switch (transaction->stage) { - case CVMX_USB_STAGE_NON_CONTROL: - case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: - /* This should be impossible */ - cvmx_usb_perform_complete(usb, pipe, - transaction, CVMX_USB_COMPLETE_ERROR); - break; - case CVMX_USB_STAGE_SETUP: - pipe->pid_toggle = 1; - if (cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = - CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; - else { - struct usb_ctrlrequest *header = - cvmx_phys_to_ptr(transaction->control_header); - if (header->wLength) - transaction->stage = - CVMX_USB_STAGE_DATA; - else - transaction->stage = - CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: - { - struct usb_ctrlrequest *header = - cvmx_phys_to_ptr(transaction->control_header); - if (header->wLength) - transaction->stage = - CVMX_USB_STAGE_DATA; - else - transaction->stage = - CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_DATA: - if (cvmx_usb_pipe_needs_split(usb, pipe)) { - transaction->stage = - CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; - /* - * For setup OUT data that are splits, - * the hardware doesn't appear to count - * transferred data. Here we manually - * update the data transferred - */ - if (!usbc_hcchar.s.epdir) { - if (buffer_space_left < pipe->max_packet) - transaction->actual_bytes += - buffer_space_left; - else - transaction->actual_bytes += - pipe->max_packet; - } - } else if ((buffer_space_left == 0) || - (bytes_in_last_packet < - pipe->max_packet)) { - pipe->pid_toggle = 1; - transaction->stage = - CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: - if ((buffer_space_left == 0) || - (bytes_in_last_packet < - pipe->max_packet)) { - pipe->pid_toggle = 1; - transaction->stage = - CVMX_USB_STAGE_STATUS; - } else { - transaction->stage = - CVMX_USB_STAGE_DATA; - } - break; - case CVMX_USB_STAGE_STATUS: - if (cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = - CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; - else - cvmx_usb_perform_complete(usb, pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - break; - case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: - cvmx_usb_perform_complete(usb, pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - break; - } + cvmx_usb_transfer_control(usb, pipe, transaction, + usbc_hcchar, + buffer_space_left, + bytes_in_last_packet); break; case CVMX_USB_TRANSFER_BULK: + cvmx_usb_transfer_bulk(usb, pipe, transaction, + usbc_hcint, buffer_space_left, + bytes_in_last_packet); + break; case CVMX_USB_TRANSFER_INTERRUPT: - /* - * The only time a bulk transfer isn't complete when it - * finishes with an ACK is during a split transaction. - * For splits we need to continue the transfer if more - * data is needed - */ - if (cvmx_usb_pipe_needs_split(usb, pipe)) { - if (transaction->stage == - CVMX_USB_STAGE_NON_CONTROL) - transaction->stage = - CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; - else { - if (buffer_space_left && - (bytes_in_last_packet == - pipe->max_packet)) - transaction->stage = - CVMX_USB_STAGE_NON_CONTROL; - else { - if (transaction->type == - CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += - pipe->interval; - cvmx_usb_perform_complete( - usb, - pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - } - } - } else { - if ((pipe->device_speed == - CVMX_USB_SPEED_HIGH) && - (pipe->transfer_type == - CVMX_USB_TRANSFER_BULK) && - (pipe->transfer_dir == - CVMX_USB_DIRECTION_OUT) && - (usbc_hcint.s.nak)) - pipe->flags |= - CVMX_USB_PIPE_FLAGS_NEED_PING; - if (!buffer_space_left || - (bytes_in_last_packet < - pipe->max_packet)) { - if (transaction->type == - CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += - pipe->interval; - cvmx_usb_perform_complete(usb, pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - } - } + cvmx_usb_transfer_intr(usb, pipe, transaction, + buffer_space_left, + bytes_in_last_packet); break; case CVMX_USB_TRANSFER_ISOCHRONOUS: - if (cvmx_usb_pipe_needs_split(usb, pipe)) { - /* - * ISOCHRONOUS OUT splits don't require a - * complete split stage. Instead they use a - * sequence of begin OUT splits to transfer the - * data 188 bytes at a time. Once the transfer - * is complete, the pipe sleeps until the next - * schedule interval - */ - if (pipe->transfer_dir == - CVMX_USB_DIRECTION_OUT) { - /* - * If no space left or this wasn't a max - * size packet then this transfer is - * complete. Otherwise start it again to - * send the next 188 bytes - */ - if (!buffer_space_left || - (bytes_this_transfer < 188)) { - pipe->next_tx_frame += - pipe->interval; - cvmx_usb_perform_complete(usb, - pipe, transaction, - CVMX_USB_COMPLETE_SUCCESS); - } - } else { - if (transaction->stage == - CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { - /* - * We are in the incoming data - * phase. Keep getting data - * until we run out of space or - * get a small packet - */ - if ((buffer_space_left == 0) || - (bytes_in_last_packet < - pipe->max_packet)) { - pipe->next_tx_frame += - pipe->interval; - cvmx_usb_perform_complete( - usb, - pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - } - } else - transaction->stage = - CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; - } - } else { - pipe->next_tx_frame += pipe->interval; - cvmx_usb_perform_complete(usb, pipe, - transaction, - CVMX_USB_COMPLETE_SUCCESS); - } + cvmx_usb_transfer_isoc(usb, pipe, transaction, + buffer_space_left, + bytes_in_last_packet, + bytes_this_transfer); break; } } else if (usbc_hcint.s.nak) { @@ -2947,20 +2909,18 @@ static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * We get channel halted interrupts with no result bits * sets when the cable is unplugged */ - cvmx_usb_perform_complete(usb, pipe, transaction, - CVMX_USB_COMPLETE_ERROR); + cvmx_usb_complete(usb, pipe, transaction, + CVMX_USB_STATUS_ERROR); } } return 0; } -static void octeon_usb_port_callback(struct cvmx_usb_state *usb) +static void octeon_usb_port_callback(struct octeon_hcd *usb) { - struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); - - spin_unlock(&priv->lock); - usb_hcd_poll_rh_status(octeon_to_hcd(priv)); - spin_lock(&priv->lock); + spin_unlock(&usb->lock); + usb_hcd_poll_rh_status(octeon_to_hcd(usb)); + spin_lock(&usb->lock); } /** @@ -2973,7 +2933,7 @@ static void octeon_usb_port_callback(struct cvmx_usb_state *usb) * * Returns: 0 or a negative error code. */ -static int cvmx_usb_poll(struct cvmx_usb_state *usb) +static int cvmx_usb_poll(struct octeon_hcd *usb) { union cvmx_usbcx_hfnum usbc_hfnum; union cvmx_usbcx_gintsts usbc_gintsts; @@ -2982,7 +2942,7 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) /* Update the frame counter */ usbc_hfnum.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); - if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum) + if ((usb->frame_number & 0x3fff) > usbc_hfnum.s.frnum) usb->frame_number += 0x4000; usb->frame_number &= ~0x3fffull; usb->frame_number |= usbc_hfnum.s.frnum; @@ -3029,8 +2989,8 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) */ octeon_usb_port_callback(usb); /* Clear the port change bits */ - usbc_hprt.u32 = cvmx_usb_read_csr32(usb, - CVMX_USBCX_HPRT(usb->index)); + usbc_hprt.u32 = + cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); usbc_hprt.s.prtena = 0; cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), usbc_hprt.u32); @@ -3057,7 +3017,7 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) channel = __fls(usbc_haint.u32); cvmx_usb_poll_channel(usb, channel); - usbc_haint.u32 ^= 1<<channel; + usbc_haint.u32 ^= 1 << channel; } } @@ -3074,12 +3034,12 @@ static inline struct octeon_hcd *hcd_to_octeon(struct usb_hcd *hcd) static irqreturn_t octeon_usb_irq(struct usb_hcd *hcd) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - cvmx_usb_poll(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + cvmx_usb_poll(usb); + spin_unlock_irqrestore(&usb->lock, flags); return IRQ_HANDLED; } @@ -3096,16 +3056,16 @@ static void octeon_usb_stop(struct usb_hcd *hcd) static int octeon_usb_get_frame_number(struct usb_hcd *hcd) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); - return cvmx_usb_get_frame_number(&priv->usb); + return cvmx_usb_get_frame_number(usb); } static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); struct device *dev = hcd->self.controller; struct cvmx_usb_transaction *transaction = NULL; struct cvmx_usb_pipe *pipe; @@ -3115,11 +3075,11 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, int rc; urb->status = 0; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); rc = usb_hcd_link_urb_to_ep(hcd, urb); if (rc) { - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); return rc; } @@ -3185,7 +3145,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, dev = dev->parent; } } - pipe = cvmx_usb_open_pipe(&priv->usb, usb_pipedevice(urb->pipe), + pipe = cvmx_usb_open_pipe(usb, usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe), speed, le16_to_cpu(ep->desc.wMaxPacketSize) & 0x7ff, @@ -3199,7 +3159,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, split_device, split_port); if (!pipe) { usb_hcd_unlink_urb_from_ep(hcd, urb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); dev_dbg(dev, "Failed to create pipe\n"); return -ENOMEM; } @@ -3228,8 +3188,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, urb->iso_frame_desc[i].offset; iso_packet[i].length = urb->iso_frame_desc[i].length; - iso_packet[i].status = - CVMX_USB_COMPLETE_ERROR; + iso_packet[i].status = CVMX_USB_STATUS_ERROR; } /* * Store a pointer to the list in the URB setup_packet @@ -3237,7 +3196,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, * this saves us a bunch of logic. */ urb->setup_packet = (char *)iso_packet; - transaction = cvmx_usb_submit_isochronous(&priv->usb, + transaction = cvmx_usb_submit_isochronous(usb, pipe, urb); /* * If submit failed we need to free our private packet @@ -3253,29 +3212,29 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, dev_dbg(dev, "Submit interrupt to %d.%d\n", usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); - transaction = cvmx_usb_submit_interrupt(&priv->usb, pipe, urb); + transaction = cvmx_usb_submit_interrupt(usb, pipe, urb); break; case PIPE_CONTROL: dev_dbg(dev, "Submit control to %d.%d\n", usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); - transaction = cvmx_usb_submit_control(&priv->usb, pipe, urb); + transaction = cvmx_usb_submit_control(usb, pipe, urb); break; case PIPE_BULK: dev_dbg(dev, "Submit bulk to %d.%d\n", usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); - transaction = cvmx_usb_submit_bulk(&priv->usb, pipe, urb); + transaction = cvmx_usb_submit_bulk(usb, pipe, urb); break; } if (!transaction) { usb_hcd_unlink_urb_from_ep(hcd, urb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); dev_dbg(dev, "Failed to submit\n"); return -ENOMEM; } urb->hcpriv = transaction; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); return 0; } @@ -3283,24 +3242,24 @@ static int octeon_usb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); unsigned long flags; int rc; if (!urb->dev) return -EINVAL; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); rc = usb_hcd_check_unlink_urb(hcd, urb, status); if (rc) goto out; urb->status = status; - cvmx_usb_cancel(&priv->usb, urb->ep->hcpriv, urb->hcpriv); + cvmx_usb_cancel(usb, urb->ep->hcpriv, urb->hcpriv); out: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); return rc; } @@ -3311,28 +3270,28 @@ static void octeon_usb_endpoint_disable(struct usb_hcd *hcd, struct device *dev = hcd->self.controller; if (ep->hcpriv) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); struct cvmx_usb_pipe *pipe = ep->hcpriv; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - cvmx_usb_cancel_all(&priv->usb, pipe); - if (cvmx_usb_close_pipe(&priv->usb, pipe)) + spin_lock_irqsave(&usb->lock, flags); + cvmx_usb_cancel_all(usb, pipe); + if (cvmx_usb_close_pipe(usb, pipe)) dev_dbg(dev, "Closing pipe %p failed\n", pipe); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); ep->hcpriv = NULL; } } static int octeon_usb_hub_status_data(struct usb_hcd *hcd, char *buf) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); struct cvmx_usb_port_status port_status; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - port_status = cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); buf[0] = 0; buf[0] = port_status.connect_change << 1; @@ -3340,12 +3299,11 @@ static int octeon_usb_hub_status_data(struct usb_hcd *hcd, char *buf) } static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, - u16 wIndex, char *buf, u16 wLength) + u16 wIndex, char *buf, u16 wLength) { - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); struct device *dev = hcd->self.controller; struct cvmx_usb_port_status usb_port_status; - struct cvmx_usb_state *usb = &priv->usb; int port_status; struct usb_hub_descriptor *desc; unsigned long flags; @@ -3372,9 +3330,9 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, switch (wValue) { case USB_PORT_FEAT_ENABLE: dev_dbg(dev, " ENABLE\n"); - spin_lock_irqsave(&priv->lock, flags); - cvmx_usb_disable(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + cvmx_usb_disable(usb); + spin_unlock_irqrestore(&usb->lock, flags); break; case USB_PORT_FEAT_SUSPEND: dev_dbg(dev, " SUSPEND\n"); @@ -3391,20 +3349,18 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_C_CONNECTION: dev_dbg(dev, " C_CONNECTION\n"); /* Clears drivers internal connect status change flag */ - spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = - cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + usb->port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); break; case USB_PORT_FEAT_C_RESET: dev_dbg(dev, " C_RESET\n"); /* * Clears the driver's internal Port Reset Change flag. */ - spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = - cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + usb->port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); break; case USB_PORT_FEAT_C_ENABLE: dev_dbg(dev, " C_ENABLE\n"); @@ -3412,10 +3368,9 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * Clears the driver's internal Port Enable/Disable * Change flag. */ - spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = - cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + usb->port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); break; case USB_PORT_FEAT_C_SUSPEND: dev_dbg(dev, " C_SUSPEND\n"); @@ -3428,10 +3383,9 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_C_OVER_CURRENT: dev_dbg(dev, " C_OVER_CURRENT\n"); /* Clears the driver's overcurrent Change flag */ - spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = - cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + usb->port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); break; default: dev_dbg(dev, " UNKNOWN\n"); @@ -3452,7 +3406,7 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, break; case GetHubStatus: dev_dbg(dev, "GetHubStatus\n"); - *(__le32 *) buf = 0; + *(__le32 *)buf = 0; break; case GetPortStatus: dev_dbg(dev, "GetPortStatus\n"); @@ -3461,9 +3415,9 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, return -EINVAL; } - spin_lock_irqsave(&priv->lock, flags); - usb_port_status = cvmx_usb_get_status(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + usb_port_status = cvmx_usb_get_status(usb); + spin_unlock_irqrestore(&usb->lock, flags); port_status = 0; if (usb_port_status.connect_change) { @@ -3504,7 +3458,7 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, dev_dbg(dev, " LOWSPEED\n"); } - *((__le32 *) buf) = cpu_to_le32(port_status); + *((__le32 *)buf) = cpu_to_le32(port_status); break; case SetHubFeature: dev_dbg(dev, "SetHubFeature\n"); @@ -3526,16 +3480,16 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* * Program the port power bit to drive VBUS on the USB. */ - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt, prtpwr, 1); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&usb->lock, flags); return 0; case USB_PORT_FEAT_RESET: dev_dbg(dev, " RESET\n"); - spin_lock_irqsave(&priv->lock, flags); - cvmx_usb_reset_port(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + cvmx_usb_reset_port(usb); + spin_unlock_irqrestore(&usb->lock, flags); return 0; case USB_PORT_FEAT_INDICATOR: dev_dbg(dev, " INDICATOR\n"); @@ -3580,14 +3534,14 @@ static int octeon_usb_probe(struct platform_device *pdev) struct device_node *usbn_node; int irq = platform_get_irq(pdev, 0); struct device *dev = &pdev->dev; - struct octeon_hcd *priv; + struct octeon_hcd *usb; struct usb_hcd *hcd; u32 clock_rate = 48000000; bool is_crystal_clock = false; const char *clock_type; int i; - if (dev->of_node == NULL) { + if (!dev->of_node) { dev_err(dev, "Error: empty of_node\n"); return -ENXIO; } @@ -3614,9 +3568,8 @@ static int octeon_usb_probe(struct platform_device *pdev) break; default: dev_err(dev, "Illegal USBN \"clock-frequency\" %u\n", - clock_rate); + clock_rate); return -ENXIO; - } i = of_property_read_string(usbn_node, @@ -3634,7 +3587,7 @@ static int octeon_usb_probe(struct platform_device *pdev) initialize_flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND; res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res_mem == NULL) { + if (!res_mem) { dev_err(dev, "found no memory resource\n"); return -ENXIO; } @@ -3680,31 +3633,31 @@ static int octeon_usb_probe(struct platform_device *pdev) return -1; } hcd->uses_new_polling = 1; - priv = (struct octeon_hcd *)hcd->hcd_priv; + usb = (struct octeon_hcd *)hcd->hcd_priv; - spin_lock_init(&priv->lock); + spin_lock_init(&usb->lock); - priv->usb.init_flags = initialize_flags; + usb->init_flags = initialize_flags; /* Initialize the USB state structure */ - priv->usb.index = usb_num; - INIT_LIST_HEAD(&priv->usb.idle_pipes); - for (i = 0; i < ARRAY_SIZE(priv->usb.active_pipes); i++) - INIT_LIST_HEAD(&priv->usb.active_pipes[i]); + usb->index = usb_num; + INIT_LIST_HEAD(&usb->idle_pipes); + for (i = 0; i < ARRAY_SIZE(usb->active_pipes); i++) + INIT_LIST_HEAD(&usb->active_pipes[i]); /* Due to an errata, CN31XX doesn't support DMA */ if (OCTEON_IS_MODEL(OCTEON_CN31XX)) { - priv->usb.init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; + usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; /* Only use one channel with non DMA */ - priv->usb.idle_hardware_channels = 0x1; + usb->idle_hardware_channels = 0x1; } else if (OCTEON_IS_MODEL(OCTEON_CN5XXX)) { /* CN5XXX have an errata with channel 3 */ - priv->usb.idle_hardware_channels = 0xf7; + usb->idle_hardware_channels = 0xf7; } else { - priv->usb.idle_hardware_channels = 0xff; + usb->idle_hardware_channels = 0xff; } - status = cvmx_usb_initialize(dev, &priv->usb); + status = cvmx_usb_initialize(dev, usb); if (status) { dev_dbg(dev, "USB initialization failed with %d\n", status); kfree(hcd); @@ -3729,13 +3682,13 @@ static int octeon_usb_remove(struct platform_device *pdev) int status; struct device *dev = &pdev->dev; struct usb_hcd *hcd = dev_get_drvdata(dev); - struct octeon_hcd *priv = hcd_to_octeon(hcd); + struct octeon_hcd *usb = hcd_to_octeon(hcd); unsigned long flags; usb_remove_hcd(hcd); - spin_lock_irqsave(&priv->lock, flags); - status = cvmx_usb_shutdown(&priv->usb); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&usb->lock, flags); + status = cvmx_usb_shutdown(usb); + spin_unlock_irqrestore(&usb->lock, flags); if (status) dev_dbg(dev, "USB shutdown failed with %d\n", status); @@ -3754,7 +3707,7 @@ MODULE_DEVICE_TABLE(of, octeon_usb_match); static struct platform_driver octeon_usb_driver = { .driver = { - .name = "OcteonUSB", + .name = "octeon-hcd", .of_match_table = octeon_usb_match, }, .probe = octeon_usb_probe, diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 70e7fa5..3353aefe 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -110,7 +110,7 @@ * initialization. Do not change this register after the initial programming. */ union cvmx_usbcx_gahbcfg { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gahbcfg_s * @ptxfemplvl: Periodic TxFIFO Empty Level (PTxFEmpLvl) @@ -145,13 +145,13 @@ union cvmx_usbcx_gahbcfg { * * 1'b1: Unmask the interrupt assertion to the application. */ struct cvmx_usbcx_gahbcfg_s { - __BITFIELD_FIELD(uint32_t reserved_9_31 : 23, - __BITFIELD_FIELD(uint32_t ptxfemplvl : 1, - __BITFIELD_FIELD(uint32_t nptxfemplvl : 1, - __BITFIELD_FIELD(uint32_t reserved_6_6 : 1, - __BITFIELD_FIELD(uint32_t dmaen : 1, - __BITFIELD_FIELD(uint32_t hbstlen : 4, - __BITFIELD_FIELD(uint32_t glblintrmsk : 1, + __BITFIELD_FIELD(u32 reserved_9_31 : 23, + __BITFIELD_FIELD(u32 ptxfemplvl : 1, + __BITFIELD_FIELD(u32 nptxfemplvl : 1, + __BITFIELD_FIELD(u32 reserved_6_6 : 1, + __BITFIELD_FIELD(u32 dmaen : 1, + __BITFIELD_FIELD(u32 hbstlen : 4, + __BITFIELD_FIELD(u32 glblintrmsk : 1, ;))))))) } s; }; @@ -164,7 +164,7 @@ union cvmx_usbcx_gahbcfg { * This register contains the configuration options of the O2P USB core. */ union cvmx_usbcx_ghwcfg3 { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_ghwcfg3_s * @dfifodepth: DFIFO Depth (DfifoDepth) @@ -212,16 +212,16 @@ union cvmx_usbcx_ghwcfg3 { * * Others: Reserved */ struct cvmx_usbcx_ghwcfg3_s { - __BITFIELD_FIELD(uint32_t dfifodepth : 16, - __BITFIELD_FIELD(uint32_t reserved_13_15 : 3, - __BITFIELD_FIELD(uint32_t ahbphysync : 1, - __BITFIELD_FIELD(uint32_t rsttype : 1, - __BITFIELD_FIELD(uint32_t optfeature : 1, - __BITFIELD_FIELD(uint32_t vendor_control_interface_support : 1, - __BITFIELD_FIELD(uint32_t i2c_selection : 1, - __BITFIELD_FIELD(uint32_t otgen : 1, - __BITFIELD_FIELD(uint32_t pktsizewidth : 3, - __BITFIELD_FIELD(uint32_t xfersizewidth : 4, + __BITFIELD_FIELD(u32 dfifodepth : 16, + __BITFIELD_FIELD(u32 reserved_13_15 : 3, + __BITFIELD_FIELD(u32 ahbphysync : 1, + __BITFIELD_FIELD(u32 rsttype : 1, + __BITFIELD_FIELD(u32 optfeature : 1, + __BITFIELD_FIELD(u32 vendor_control_interface_support : 1, + __BITFIELD_FIELD(u32 i2c_selection : 1, + __BITFIELD_FIELD(u32 otgen : 1, + __BITFIELD_FIELD(u32 pktsizewidth : 3, + __BITFIELD_FIELD(u32 xfersizewidth : 4, ;)))))))))) } s; }; @@ -238,7 +238,7 @@ union cvmx_usbcx_ghwcfg3 { * Mask interrupt: 1'b0, Unmask interrupt: 1'b1 */ union cvmx_usbcx_gintmsk { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gintmsk_s * @wkupintmsk: Resume/Remote Wakeup Detected Interrupt Mask @@ -279,38 +279,38 @@ union cvmx_usbcx_gintmsk { * @modemismsk: Mode Mismatch Interrupt Mask (ModeMisMsk) */ struct cvmx_usbcx_gintmsk_s { - __BITFIELD_FIELD(uint32_t wkupintmsk : 1, - __BITFIELD_FIELD(uint32_t sessreqintmsk : 1, - __BITFIELD_FIELD(uint32_t disconnintmsk : 1, - __BITFIELD_FIELD(uint32_t conidstschngmsk : 1, - __BITFIELD_FIELD(uint32_t reserved_27_27 : 1, - __BITFIELD_FIELD(uint32_t ptxfempmsk : 1, - __BITFIELD_FIELD(uint32_t hchintmsk : 1, - __BITFIELD_FIELD(uint32_t prtintmsk : 1, - __BITFIELD_FIELD(uint32_t reserved_23_23 : 1, - __BITFIELD_FIELD(uint32_t fetsuspmsk : 1, - __BITFIELD_FIELD(uint32_t incomplpmsk : 1, - __BITFIELD_FIELD(uint32_t incompisoinmsk : 1, - __BITFIELD_FIELD(uint32_t oepintmsk : 1, - __BITFIELD_FIELD(uint32_t inepintmsk : 1, - __BITFIELD_FIELD(uint32_t epmismsk : 1, - __BITFIELD_FIELD(uint32_t reserved_16_16 : 1, - __BITFIELD_FIELD(uint32_t eopfmsk : 1, - __BITFIELD_FIELD(uint32_t isooutdropmsk : 1, - __BITFIELD_FIELD(uint32_t enumdonemsk : 1, - __BITFIELD_FIELD(uint32_t usbrstmsk : 1, - __BITFIELD_FIELD(uint32_t usbsuspmsk : 1, - __BITFIELD_FIELD(uint32_t erlysuspmsk : 1, - __BITFIELD_FIELD(uint32_t i2cint : 1, - __BITFIELD_FIELD(uint32_t ulpickintmsk : 1, - __BITFIELD_FIELD(uint32_t goutnakeffmsk : 1, - __BITFIELD_FIELD(uint32_t ginnakeffmsk : 1, - __BITFIELD_FIELD(uint32_t nptxfempmsk : 1, - __BITFIELD_FIELD(uint32_t rxflvlmsk : 1, - __BITFIELD_FIELD(uint32_t sofmsk : 1, - __BITFIELD_FIELD(uint32_t otgintmsk : 1, - __BITFIELD_FIELD(uint32_t modemismsk : 1, - __BITFIELD_FIELD(uint32_t reserved_0_0 : 1, + __BITFIELD_FIELD(u32 wkupintmsk : 1, + __BITFIELD_FIELD(u32 sessreqintmsk : 1, + __BITFIELD_FIELD(u32 disconnintmsk : 1, + __BITFIELD_FIELD(u32 conidstschngmsk : 1, + __BITFIELD_FIELD(u32 reserved_27_27 : 1, + __BITFIELD_FIELD(u32 ptxfempmsk : 1, + __BITFIELD_FIELD(u32 hchintmsk : 1, + __BITFIELD_FIELD(u32 prtintmsk : 1, + __BITFIELD_FIELD(u32 reserved_23_23 : 1, + __BITFIELD_FIELD(u32 fetsuspmsk : 1, + __BITFIELD_FIELD(u32 incomplpmsk : 1, + __BITFIELD_FIELD(u32 incompisoinmsk : 1, + __BITFIELD_FIELD(u32 oepintmsk : 1, + __BITFIELD_FIELD(u32 inepintmsk : 1, + __BITFIELD_FIELD(u32 epmismsk : 1, + __BITFIELD_FIELD(u32 reserved_16_16 : 1, + __BITFIELD_FIELD(u32 eopfmsk : 1, + __BITFIELD_FIELD(u32 isooutdropmsk : 1, + __BITFIELD_FIELD(u32 enumdonemsk : 1, + __BITFIELD_FIELD(u32 usbrstmsk : 1, + __BITFIELD_FIELD(u32 usbsuspmsk : 1, + __BITFIELD_FIELD(u32 erlysuspmsk : 1, + __BITFIELD_FIELD(u32 i2cint : 1, + __BITFIELD_FIELD(u32 ulpickintmsk : 1, + __BITFIELD_FIELD(u32 goutnakeffmsk : 1, + __BITFIELD_FIELD(u32 ginnakeffmsk : 1, + __BITFIELD_FIELD(u32 nptxfempmsk : 1, + __BITFIELD_FIELD(u32 rxflvlmsk : 1, + __BITFIELD_FIELD(u32 sofmsk : 1, + __BITFIELD_FIELD(u32 otgintmsk : 1, + __BITFIELD_FIELD(u32 modemismsk : 1, + __BITFIELD_FIELD(u32 reserved_0_0 : 1, ;)))))))))))))))))))))))))))))))) } s; }; @@ -331,7 +331,7 @@ union cvmx_usbcx_gintmsk { * automatically. */ union cvmx_usbcx_gintsts { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gintsts_s * @wkupint: Resume/Remote Wakeup Detected Interrupt (WkUpInt) @@ -509,38 +509,38 @@ union cvmx_usbcx_gintsts { * * 1'b1: Host mode */ struct cvmx_usbcx_gintsts_s { - __BITFIELD_FIELD(uint32_t wkupint : 1, - __BITFIELD_FIELD(uint32_t sessreqint : 1, - __BITFIELD_FIELD(uint32_t disconnint : 1, - __BITFIELD_FIELD(uint32_t conidstschng : 1, - __BITFIELD_FIELD(uint32_t reserved_27_27 : 1, - __BITFIELD_FIELD(uint32_t ptxfemp : 1, - __BITFIELD_FIELD(uint32_t hchint : 1, - __BITFIELD_FIELD(uint32_t prtint : 1, - __BITFIELD_FIELD(uint32_t reserved_23_23 : 1, - __BITFIELD_FIELD(uint32_t fetsusp : 1, - __BITFIELD_FIELD(uint32_t incomplp : 1, - __BITFIELD_FIELD(uint32_t incompisoin : 1, - __BITFIELD_FIELD(uint32_t oepint : 1, - __BITFIELD_FIELD(uint32_t iepint : 1, - __BITFIELD_FIELD(uint32_t epmis : 1, - __BITFIELD_FIELD(uint32_t reserved_16_16 : 1, - __BITFIELD_FIELD(uint32_t eopf : 1, - __BITFIELD_FIELD(uint32_t isooutdrop : 1, - __BITFIELD_FIELD(uint32_t enumdone : 1, - __BITFIELD_FIELD(uint32_t usbrst : 1, - __BITFIELD_FIELD(uint32_t usbsusp : 1, - __BITFIELD_FIELD(uint32_t erlysusp : 1, - __BITFIELD_FIELD(uint32_t i2cint : 1, - __BITFIELD_FIELD(uint32_t ulpickint : 1, - __BITFIELD_FIELD(uint32_t goutnakeff : 1, - __BITFIELD_FIELD(uint32_t ginnakeff : 1, - __BITFIELD_FIELD(uint32_t nptxfemp : 1, - __BITFIELD_FIELD(uint32_t rxflvl : 1, - __BITFIELD_FIELD(uint32_t sof : 1, - __BITFIELD_FIELD(uint32_t otgint : 1, - __BITFIELD_FIELD(uint32_t modemis : 1, - __BITFIELD_FIELD(uint32_t curmod : 1, + __BITFIELD_FIELD(u32 wkupint : 1, + __BITFIELD_FIELD(u32 sessreqint : 1, + __BITFIELD_FIELD(u32 disconnint : 1, + __BITFIELD_FIELD(u32 conidstschng : 1, + __BITFIELD_FIELD(u32 reserved_27_27 : 1, + __BITFIELD_FIELD(u32 ptxfemp : 1, + __BITFIELD_FIELD(u32 hchint : 1, + __BITFIELD_FIELD(u32 prtint : 1, + __BITFIELD_FIELD(u32 reserved_23_23 : 1, + __BITFIELD_FIELD(u32 fetsusp : 1, + __BITFIELD_FIELD(u32 incomplp : 1, + __BITFIELD_FIELD(u32 incompisoin : 1, + __BITFIELD_FIELD(u32 oepint : 1, + __BITFIELD_FIELD(u32 iepint : 1, + __BITFIELD_FIELD(u32 epmis : 1, + __BITFIELD_FIELD(u32 reserved_16_16 : 1, + __BITFIELD_FIELD(u32 eopf : 1, + __BITFIELD_FIELD(u32 isooutdrop : 1, + __BITFIELD_FIELD(u32 enumdone : 1, + __BITFIELD_FIELD(u32 usbrst : 1, + __BITFIELD_FIELD(u32 usbsusp : 1, + __BITFIELD_FIELD(u32 erlysusp : 1, + __BITFIELD_FIELD(u32 i2cint : 1, + __BITFIELD_FIELD(u32 ulpickint : 1, + __BITFIELD_FIELD(u32 goutnakeff : 1, + __BITFIELD_FIELD(u32 ginnakeff : 1, + __BITFIELD_FIELD(u32 nptxfemp : 1, + __BITFIELD_FIELD(u32 rxflvl : 1, + __BITFIELD_FIELD(u32 sof : 1, + __BITFIELD_FIELD(u32 otgint : 1, + __BITFIELD_FIELD(u32 modemis : 1, + __BITFIELD_FIELD(u32 curmod : 1, ;)))))))))))))))))))))))))))))))) } s; }; @@ -554,7 +554,7 @@ union cvmx_usbcx_gintsts { * Non-Periodic TxFIFO. */ union cvmx_usbcx_gnptxfsiz { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gnptxfsiz_s * @nptxfdep: Non-Periodic TxFIFO Depth (NPTxFDep) @@ -566,8 +566,8 @@ union cvmx_usbcx_gnptxfsiz { * Transmit FIFO RAM. */ struct cvmx_usbcx_gnptxfsiz_s { - __BITFIELD_FIELD(uint32_t nptxfdep : 16, - __BITFIELD_FIELD(uint32_t nptxfstaddr : 16, + __BITFIELD_FIELD(u32 nptxfdep : 16, + __BITFIELD_FIELD(u32 nptxfstaddr : 16, ;)) } s; }; @@ -581,7 +581,7 @@ union cvmx_usbcx_gnptxfsiz { * Non-Periodic TxFIFO and the Non-Periodic Transmit Request Queue. */ union cvmx_usbcx_gnptxsts { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gnptxsts_s * @nptxqtop: Top of the Non-Periodic Transmit Request Queue (NPTxQTop) @@ -617,10 +617,10 @@ union cvmx_usbcx_gnptxsts { * * Others: Reserved */ struct cvmx_usbcx_gnptxsts_s { - __BITFIELD_FIELD(uint32_t reserved_31_31 : 1, - __BITFIELD_FIELD(uint32_t nptxqtop : 7, - __BITFIELD_FIELD(uint32_t nptxqspcavail : 8, - __BITFIELD_FIELD(uint32_t nptxfspcavail : 16, + __BITFIELD_FIELD(u32 reserved_31_31 : 1, + __BITFIELD_FIELD(u32 nptxqtop : 7, + __BITFIELD_FIELD(u32 nptxqspcavail : 8, + __BITFIELD_FIELD(u32 nptxfspcavail : 16, ;)))) } s; }; @@ -634,7 +634,7 @@ union cvmx_usbcx_gnptxsts { * the core. */ union cvmx_usbcx_grstctl { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_grstctl_s * @ahbidle: AHB Master Idle (AHBIdle) @@ -739,16 +739,16 @@ union cvmx_usbcx_grstctl { * selected, the PHY domain has to be reset for proper operation. */ struct cvmx_usbcx_grstctl_s { - __BITFIELD_FIELD(uint32_t ahbidle : 1, - __BITFIELD_FIELD(uint32_t dmareq : 1, - __BITFIELD_FIELD(uint32_t reserved_11_29 : 19, - __BITFIELD_FIELD(uint32_t txfnum : 5, - __BITFIELD_FIELD(uint32_t txfflsh : 1, - __BITFIELD_FIELD(uint32_t rxfflsh : 1, - __BITFIELD_FIELD(uint32_t intknqflsh : 1, - __BITFIELD_FIELD(uint32_t frmcntrrst : 1, - __BITFIELD_FIELD(uint32_t hsftrst : 1, - __BITFIELD_FIELD(uint32_t csftrst : 1, + __BITFIELD_FIELD(u32 ahbidle : 1, + __BITFIELD_FIELD(u32 dmareq : 1, + __BITFIELD_FIELD(u32 reserved_11_29 : 19, + __BITFIELD_FIELD(u32 txfnum : 5, + __BITFIELD_FIELD(u32 txfflsh : 1, + __BITFIELD_FIELD(u32 rxfflsh : 1, + __BITFIELD_FIELD(u32 intknqflsh : 1, + __BITFIELD_FIELD(u32 frmcntrrst : 1, + __BITFIELD_FIELD(u32 hsftrst : 1, + __BITFIELD_FIELD(u32 csftrst : 1, ;)))))))))) } s; }; @@ -762,7 +762,7 @@ union cvmx_usbcx_grstctl { * RxFIFO. */ union cvmx_usbcx_grxfsiz { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_grxfsiz_s * @rxfdep: RxFIFO Depth (RxFDep) @@ -771,8 +771,8 @@ union cvmx_usbcx_grxfsiz { * * Maximum value is 32768 */ struct cvmx_usbcx_grxfsiz_s { - __BITFIELD_FIELD(uint32_t reserved_16_31 : 16, - __BITFIELD_FIELD(uint32_t rxfdep : 16, + __BITFIELD_FIELD(u32 reserved_16_31 : 16, + __BITFIELD_FIELD(u32 rxfdep : 16, ;)) } s; }; @@ -792,7 +792,7 @@ union cvmx_usbcx_grxfsiz { * hardware. */ union cvmx_usbcx_grxstsph { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_grxstsph_s * @pktsts: Packet Status (PktSts) @@ -814,11 +814,11 @@ union cvmx_usbcx_grxstsph { * packet belongs. */ struct cvmx_usbcx_grxstsph_s { - __BITFIELD_FIELD(uint32_t reserved_21_31 : 11, - __BITFIELD_FIELD(uint32_t pktsts : 4, - __BITFIELD_FIELD(uint32_t dpid : 2, - __BITFIELD_FIELD(uint32_t bcnt : 11, - __BITFIELD_FIELD(uint32_t chnum : 4, + __BITFIELD_FIELD(u32 reserved_21_31 : 11, + __BITFIELD_FIELD(u32 pktsts : 4, + __BITFIELD_FIELD(u32 dpid : 2, + __BITFIELD_FIELD(u32 bcnt : 11, + __BITFIELD_FIELD(u32 chnum : 4, ;))))) } s; }; @@ -835,7 +835,7 @@ union cvmx_usbcx_grxstsph { * to this register after the initial programming. */ union cvmx_usbcx_gusbcfg { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_gusbcfg_s * @otgi2csel: UTMIFS or I2C Interface Select (OtgI2CSel) @@ -895,19 +895,19 @@ union cvmx_usbcx_gusbcfg { * * One 48-MHz PHY clock = 0.25 bit times */ struct cvmx_usbcx_gusbcfg_s { - __BITFIELD_FIELD(uint32_t reserved_17_31 : 15, - __BITFIELD_FIELD(uint32_t otgi2csel : 1, - __BITFIELD_FIELD(uint32_t phylpwrclksel : 1, - __BITFIELD_FIELD(uint32_t reserved_14_14 : 1, - __BITFIELD_FIELD(uint32_t usbtrdtim : 4, - __BITFIELD_FIELD(uint32_t hnpcap : 1, - __BITFIELD_FIELD(uint32_t srpcap : 1, - __BITFIELD_FIELD(uint32_t ddrsel : 1, - __BITFIELD_FIELD(uint32_t physel : 1, - __BITFIELD_FIELD(uint32_t fsintf : 1, - __BITFIELD_FIELD(uint32_t ulpi_utmi_sel : 1, - __BITFIELD_FIELD(uint32_t phyif : 1, - __BITFIELD_FIELD(uint32_t toutcal : 3, + __BITFIELD_FIELD(u32 reserved_17_31 : 15, + __BITFIELD_FIELD(u32 otgi2csel : 1, + __BITFIELD_FIELD(u32 phylpwrclksel : 1, + __BITFIELD_FIELD(u32 reserved_14_14 : 1, + __BITFIELD_FIELD(u32 usbtrdtim : 4, + __BITFIELD_FIELD(u32 hnpcap : 1, + __BITFIELD_FIELD(u32 srpcap : 1, + __BITFIELD_FIELD(u32 ddrsel : 1, + __BITFIELD_FIELD(u32 physel : 1, + __BITFIELD_FIELD(u32 fsintf : 1, + __BITFIELD_FIELD(u32 ulpi_utmi_sel : 1, + __BITFIELD_FIELD(u32 phyif : 1, + __BITFIELD_FIELD(u32 toutcal : 3, ;))))))))))))) } s; }; @@ -925,15 +925,15 @@ union cvmx_usbcx_gusbcfg { * in the corresponding Host Channel-n Interrupt register. */ union cvmx_usbcx_haint { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_haint_s * @haint: Channel Interrupts (HAINT) * One bit per channel: Bit 0 for Channel 0, bit 15 for Channel 15 */ struct cvmx_usbcx_haint_s { - __BITFIELD_FIELD(uint32_t reserved_16_31 : 16, - __BITFIELD_FIELD(uint32_t haint : 16, + __BITFIELD_FIELD(u32 reserved_16_31 : 16, + __BITFIELD_FIELD(u32 haint : 16, ;)) } s; }; @@ -950,15 +950,15 @@ union cvmx_usbcx_haint { * Mask interrupt: 1'b0 Unmask interrupt: 1'b1 */ union cvmx_usbcx_haintmsk { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_haintmsk_s * @haintmsk: Channel Interrupt Mask (HAINTMsk) * One bit per channel: Bit 0 for channel 0, bit 15 for channel 15 */ struct cvmx_usbcx_haintmsk_s { - __BITFIELD_FIELD(uint32_t reserved_16_31 : 16, - __BITFIELD_FIELD(uint32_t haintmsk : 16, + __BITFIELD_FIELD(u32 reserved_16_31 : 16, + __BITFIELD_FIELD(u32 haintmsk : 16, ;)) } s; }; @@ -970,7 +970,7 @@ union cvmx_usbcx_haintmsk { * */ union cvmx_usbcx_hccharx { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hccharx_s * @chena: Channel Enable (ChEna) @@ -1028,17 +1028,17 @@ union cvmx_usbcx_hccharx { * Indicates the maximum packet size of the associated endpoint. */ struct cvmx_usbcx_hccharx_s { - __BITFIELD_FIELD(uint32_t chena : 1, - __BITFIELD_FIELD(uint32_t chdis : 1, - __BITFIELD_FIELD(uint32_t oddfrm : 1, - __BITFIELD_FIELD(uint32_t devaddr : 7, - __BITFIELD_FIELD(uint32_t ec : 2, - __BITFIELD_FIELD(uint32_t eptype : 2, - __BITFIELD_FIELD(uint32_t lspddev : 1, - __BITFIELD_FIELD(uint32_t reserved_16_16 : 1, - __BITFIELD_FIELD(uint32_t epdir : 1, - __BITFIELD_FIELD(uint32_t epnum : 4, - __BITFIELD_FIELD(uint32_t mps : 11, + __BITFIELD_FIELD(u32 chena : 1, + __BITFIELD_FIELD(u32 chdis : 1, + __BITFIELD_FIELD(u32 oddfrm : 1, + __BITFIELD_FIELD(u32 devaddr : 7, + __BITFIELD_FIELD(u32 ec : 2, + __BITFIELD_FIELD(u32 eptype : 2, + __BITFIELD_FIELD(u32 lspddev : 1, + __BITFIELD_FIELD(u32 reserved_16_16 : 1, + __BITFIELD_FIELD(u32 epdir : 1, + __BITFIELD_FIELD(u32 epnum : 4, + __BITFIELD_FIELD(u32 mps : 11, ;))))))))))) } s; }; @@ -1052,7 +1052,7 @@ union cvmx_usbcx_hccharx { * register after initializing the host. */ union cvmx_usbcx_hcfg { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hcfg_s * @fslssupp: FS- and LS-Only Support (FSLSSupp) @@ -1084,9 +1084,9 @@ union cvmx_usbcx_hcfg { * * 2'b11: Reserved */ struct cvmx_usbcx_hcfg_s { - __BITFIELD_FIELD(uint32_t reserved_3_31 : 29, - __BITFIELD_FIELD(uint32_t fslssupp : 1, - __BITFIELD_FIELD(uint32_t fslspclksel : 2, + __BITFIELD_FIELD(u32 reserved_3_31 : 29, + __BITFIELD_FIELD(u32 fslssupp : 1, + __BITFIELD_FIELD(u32 fslspclksel : 2, ;))) } s; }; @@ -1106,7 +1106,7 @@ union cvmx_usbcx_hcfg { * HAINT and GINTSTS registers. */ union cvmx_usbcx_hcintx { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hcintx_s * @datatglerr: Data Toggle Error (DataTglErr) @@ -1126,18 +1126,18 @@ union cvmx_usbcx_hcintx { * Transfer completed normally without any errors. */ struct cvmx_usbcx_hcintx_s { - __BITFIELD_FIELD(uint32_t reserved_11_31 : 21, - __BITFIELD_FIELD(uint32_t datatglerr : 1, - __BITFIELD_FIELD(uint32_t frmovrun : 1, - __BITFIELD_FIELD(uint32_t bblerr : 1, - __BITFIELD_FIELD(uint32_t xacterr : 1, - __BITFIELD_FIELD(uint32_t nyet : 1, - __BITFIELD_FIELD(uint32_t ack : 1, - __BITFIELD_FIELD(uint32_t nak : 1, - __BITFIELD_FIELD(uint32_t stall : 1, - __BITFIELD_FIELD(uint32_t ahberr : 1, - __BITFIELD_FIELD(uint32_t chhltd : 1, - __BITFIELD_FIELD(uint32_t xfercompl : 1, + __BITFIELD_FIELD(u32 reserved_11_31 : 21, + __BITFIELD_FIELD(u32 datatglerr : 1, + __BITFIELD_FIELD(u32 frmovrun : 1, + __BITFIELD_FIELD(u32 bblerr : 1, + __BITFIELD_FIELD(u32 xacterr : 1, + __BITFIELD_FIELD(u32 nyet : 1, + __BITFIELD_FIELD(u32 ack : 1, + __BITFIELD_FIELD(u32 nak : 1, + __BITFIELD_FIELD(u32 stall : 1, + __BITFIELD_FIELD(u32 ahberr : 1, + __BITFIELD_FIELD(u32 chhltd : 1, + __BITFIELD_FIELD(u32 xfercompl : 1, ;)))))))))))) } s; }; @@ -1152,7 +1152,7 @@ union cvmx_usbcx_hcintx { * Mask interrupt: 1'b0 Unmask interrupt: 1'b1 */ union cvmx_usbcx_hcintmskx { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hcintmskx_s * @datatglerrmsk: Data Toggle Error Mask (DataTglErrMsk) @@ -1168,18 +1168,18 @@ union cvmx_usbcx_hcintmskx { * @xfercomplmsk: Transfer Completed Mask (XferComplMsk) */ struct cvmx_usbcx_hcintmskx_s { - __BITFIELD_FIELD(uint32_t reserved_11_31 : 21, - __BITFIELD_FIELD(uint32_t datatglerrmsk : 1, - __BITFIELD_FIELD(uint32_t frmovrunmsk : 1, - __BITFIELD_FIELD(uint32_t bblerrmsk : 1, - __BITFIELD_FIELD(uint32_t xacterrmsk : 1, - __BITFIELD_FIELD(uint32_t nyetmsk : 1, - __BITFIELD_FIELD(uint32_t ackmsk : 1, - __BITFIELD_FIELD(uint32_t nakmsk : 1, - __BITFIELD_FIELD(uint32_t stallmsk : 1, - __BITFIELD_FIELD(uint32_t ahberrmsk : 1, - __BITFIELD_FIELD(uint32_t chhltdmsk : 1, - __BITFIELD_FIELD(uint32_t xfercomplmsk : 1, + __BITFIELD_FIELD(u32 reserved_11_31 : 21, + __BITFIELD_FIELD(u32 datatglerrmsk : 1, + __BITFIELD_FIELD(u32 frmovrunmsk : 1, + __BITFIELD_FIELD(u32 bblerrmsk : 1, + __BITFIELD_FIELD(u32 xacterrmsk : 1, + __BITFIELD_FIELD(u32 nyetmsk : 1, + __BITFIELD_FIELD(u32 ackmsk : 1, + __BITFIELD_FIELD(u32 nakmsk : 1, + __BITFIELD_FIELD(u32 stallmsk : 1, + __BITFIELD_FIELD(u32 ahberrmsk : 1, + __BITFIELD_FIELD(u32 chhltdmsk : 1, + __BITFIELD_FIELD(u32 xfercomplmsk : 1, ;)))))))))))) } s; }; @@ -1191,7 +1191,7 @@ union cvmx_usbcx_hcintmskx { * */ union cvmx_usbcx_hcspltx { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hcspltx_s * @spltena: Split Enable (SpltEna) @@ -1219,12 +1219,12 @@ union cvmx_usbcx_hcspltx { * translator. */ struct cvmx_usbcx_hcspltx_s { - __BITFIELD_FIELD(uint32_t spltena : 1, - __BITFIELD_FIELD(uint32_t reserved_17_30 : 14, - __BITFIELD_FIELD(uint32_t compsplt : 1, - __BITFIELD_FIELD(uint32_t xactpos : 2, - __BITFIELD_FIELD(uint32_t hubaddr : 7, - __BITFIELD_FIELD(uint32_t prtaddr : 7, + __BITFIELD_FIELD(u32 spltena : 1, + __BITFIELD_FIELD(u32 reserved_17_30 : 14, + __BITFIELD_FIELD(u32 compsplt : 1, + __BITFIELD_FIELD(u32 xactpos : 2, + __BITFIELD_FIELD(u32 hubaddr : 7, + __BITFIELD_FIELD(u32 prtaddr : 7, ;)))))) } s; }; @@ -1236,7 +1236,7 @@ union cvmx_usbcx_hcspltx { * */ union cvmx_usbcx_hctsizx { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hctsizx_s * @dopng: Do Ping (DoPng) @@ -1265,10 +1265,10 @@ union cvmx_usbcx_hctsizx { * size for IN transactions (periodic and non-periodic). */ struct cvmx_usbcx_hctsizx_s { - __BITFIELD_FIELD(uint32_t dopng : 1, - __BITFIELD_FIELD(uint32_t pid : 2, - __BITFIELD_FIELD(uint32_t pktcnt : 10, - __BITFIELD_FIELD(uint32_t xfersize : 19, + __BITFIELD_FIELD(u32 dopng : 1, + __BITFIELD_FIELD(u32 pid : 2, + __BITFIELD_FIELD(u32 pktcnt : 10, + __BITFIELD_FIELD(u32 xfersize : 19, ;)))) } s; }; @@ -1282,7 +1282,7 @@ union cvmx_usbcx_hctsizx { * which the O2P USB core has enumerated. */ union cvmx_usbcx_hfir { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hfir_s * @frint: Frame Interval (FrInt) @@ -1303,8 +1303,8 @@ union cvmx_usbcx_hfir { * * 1 ms (PHY clock frequency for FS/LS) */ struct cvmx_usbcx_hfir_s { - __BITFIELD_FIELD(uint32_t reserved_16_31 : 16, - __BITFIELD_FIELD(uint32_t frint : 16, + __BITFIELD_FIELD(u32 reserved_16_31 : 16, + __BITFIELD_FIELD(u32 frint : 16, ;)) } s; }; @@ -1319,7 +1319,7 @@ union cvmx_usbcx_hfir { * in the current (micro)frame. */ union cvmx_usbcx_hfnum { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hfnum_s * @frrem: Frame Time Remaining (FrRem) @@ -1333,8 +1333,8 @@ union cvmx_usbcx_hfnum { * USB, and is reset to 0 when it reaches 16'h3FFF. */ struct cvmx_usbcx_hfnum_s { - __BITFIELD_FIELD(uint32_t frrem : 16, - __BITFIELD_FIELD(uint32_t frnum : 16, + __BITFIELD_FIELD(u32 frrem : 16, + __BITFIELD_FIELD(u32 frnum : 16, ;)) } s; }; @@ -1355,7 +1355,7 @@ union cvmx_usbcx_hfnum { * the application must write a 1 to the bit to clear the interrupt. */ union cvmx_usbcx_hprt { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hprt_s * @prtspd: Port Speed (PrtSpd) @@ -1461,21 +1461,21 @@ union cvmx_usbcx_hprt { * * 1: A device is attached to the port. */ struct cvmx_usbcx_hprt_s { - __BITFIELD_FIELD(uint32_t reserved_19_31 : 13, - __BITFIELD_FIELD(uint32_t prtspd : 2, - __BITFIELD_FIELD(uint32_t prttstctl : 4, - __BITFIELD_FIELD(uint32_t prtpwr : 1, - __BITFIELD_FIELD(uint32_t prtlnsts : 2, - __BITFIELD_FIELD(uint32_t reserved_9_9 : 1, - __BITFIELD_FIELD(uint32_t prtrst : 1, - __BITFIELD_FIELD(uint32_t prtsusp : 1, - __BITFIELD_FIELD(uint32_t prtres : 1, - __BITFIELD_FIELD(uint32_t prtovrcurrchng : 1, - __BITFIELD_FIELD(uint32_t prtovrcurract : 1, - __BITFIELD_FIELD(uint32_t prtenchng : 1, - __BITFIELD_FIELD(uint32_t prtena : 1, - __BITFIELD_FIELD(uint32_t prtconndet : 1, - __BITFIELD_FIELD(uint32_t prtconnsts : 1, + __BITFIELD_FIELD(u32 reserved_19_31 : 13, + __BITFIELD_FIELD(u32 prtspd : 2, + __BITFIELD_FIELD(u32 prttstctl : 4, + __BITFIELD_FIELD(u32 prtpwr : 1, + __BITFIELD_FIELD(u32 prtlnsts : 2, + __BITFIELD_FIELD(u32 reserved_9_9 : 1, + __BITFIELD_FIELD(u32 prtrst : 1, + __BITFIELD_FIELD(u32 prtsusp : 1, + __BITFIELD_FIELD(u32 prtres : 1, + __BITFIELD_FIELD(u32 prtovrcurrchng : 1, + __BITFIELD_FIELD(u32 prtovrcurract : 1, + __BITFIELD_FIELD(u32 prtenchng : 1, + __BITFIELD_FIELD(u32 prtena : 1, + __BITFIELD_FIELD(u32 prtconndet : 1, + __BITFIELD_FIELD(u32 prtconnsts : 1, ;))))))))))))))) } s; }; @@ -1489,7 +1489,7 @@ union cvmx_usbcx_hprt { * TxFIFO, as shown in Figures 310 and 311. */ union cvmx_usbcx_hptxfsiz { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hptxfsiz_s * @ptxfsize: Host Periodic TxFIFO Depth (PTxFSize) @@ -1499,8 +1499,8 @@ union cvmx_usbcx_hptxfsiz { * @ptxfstaddr: Host Periodic TxFIFO Start Address (PTxFStAddr) */ struct cvmx_usbcx_hptxfsiz_s { - __BITFIELD_FIELD(uint32_t ptxfsize : 16, - __BITFIELD_FIELD(uint32_t ptxfstaddr : 16, + __BITFIELD_FIELD(u32 ptxfsize : 16, + __BITFIELD_FIELD(u32 ptxfstaddr : 16, ;)) } s; }; @@ -1514,7 +1514,7 @@ union cvmx_usbcx_hptxfsiz { * TxFIFO and the Periodic Transmit Request Queue */ union cvmx_usbcx_hptxsts { - uint32_t u32; + u32 u32; /** * struct cvmx_usbcx_hptxsts_s * @ptxqtop: Top of the Periodic Transmit Request Queue (PTxQTop) @@ -1555,9 +1555,9 @@ union cvmx_usbcx_hptxsts { * * Others: Reserved */ struct cvmx_usbcx_hptxsts_s { - __BITFIELD_FIELD(uint32_t ptxqtop : 8, - __BITFIELD_FIELD(uint32_t ptxqspcavail : 8, - __BITFIELD_FIELD(uint32_t ptxfspcavail : 16, + __BITFIELD_FIELD(u32 ptxqtop : 8, + __BITFIELD_FIELD(u32 ptxqspcavail : 8, + __BITFIELD_FIELD(u32 ptxfspcavail : 16, ;))) } s; }; @@ -1571,7 +1571,7 @@ union cvmx_usbcx_hptxsts { * hreset and phy_rst signals. */ union cvmx_usbnx_clk_ctl { - uint64_t u64; + u64 u64; /** * struct cvmx_usbnx_clk_ctl_s * @divide2: The 'hclk' used by the USB subsystem is derived @@ -1661,21 +1661,21 @@ union cvmx_usbnx_clk_ctl { * until AFTER this field is set and then read. */ struct cvmx_usbnx_clk_ctl_s { - __BITFIELD_FIELD(uint64_t reserved_20_63 : 44, - __BITFIELD_FIELD(uint64_t divide2 : 2, - __BITFIELD_FIELD(uint64_t hclk_rst : 1, - __BITFIELD_FIELD(uint64_t p_x_on : 1, - __BITFIELD_FIELD(uint64_t p_rtype : 2, - __BITFIELD_FIELD(uint64_t p_com_on : 1, - __BITFIELD_FIELD(uint64_t p_c_sel : 2, - __BITFIELD_FIELD(uint64_t cdiv_byp : 1, - __BITFIELD_FIELD(uint64_t sd_mode : 2, - __BITFIELD_FIELD(uint64_t s_bist : 1, - __BITFIELD_FIELD(uint64_t por : 1, - __BITFIELD_FIELD(uint64_t enable : 1, - __BITFIELD_FIELD(uint64_t prst : 1, - __BITFIELD_FIELD(uint64_t hrst : 1, - __BITFIELD_FIELD(uint64_t divide : 3, + __BITFIELD_FIELD(u64 reserved_20_63 : 44, + __BITFIELD_FIELD(u64 divide2 : 2, + __BITFIELD_FIELD(u64 hclk_rst : 1, + __BITFIELD_FIELD(u64 p_x_on : 1, + __BITFIELD_FIELD(u64 p_rtype : 2, + __BITFIELD_FIELD(u64 p_com_on : 1, + __BITFIELD_FIELD(u64 p_c_sel : 2, + __BITFIELD_FIELD(u64 cdiv_byp : 1, + __BITFIELD_FIELD(u64 sd_mode : 2, + __BITFIELD_FIELD(u64 s_bist : 1, + __BITFIELD_FIELD(u64 por : 1, + __BITFIELD_FIELD(u64 enable : 1, + __BITFIELD_FIELD(u64 prst : 1, + __BITFIELD_FIELD(u64 hrst : 1, + __BITFIELD_FIELD(u64 divide : 3, ;))))))))))))))) } s; }; @@ -1688,7 +1688,7 @@ union cvmx_usbnx_clk_ctl { * Contains general control and status information for the USBN block. */ union cvmx_usbnx_usbp_ctl_status { - uint64_t u64; + u64 u64; /** * struct cvmx_usbnx_usbp_ctl_status_s * @txrisetune: HS Transmitter Rise/Fall Time Adjustment @@ -1804,41 +1804,41 @@ union cvmx_usbnx_usbp_ctl_status { * de-assertion. */ struct cvmx_usbnx_usbp_ctl_status_s { - __BITFIELD_FIELD(uint64_t txrisetune : 1, - __BITFIELD_FIELD(uint64_t txvreftune : 4, - __BITFIELD_FIELD(uint64_t txfslstune : 4, - __BITFIELD_FIELD(uint64_t txhsxvtune : 2, - __BITFIELD_FIELD(uint64_t sqrxtune : 3, - __BITFIELD_FIELD(uint64_t compdistune : 3, - __BITFIELD_FIELD(uint64_t otgtune : 3, - __BITFIELD_FIELD(uint64_t otgdisable : 1, - __BITFIELD_FIELD(uint64_t portreset : 1, - __BITFIELD_FIELD(uint64_t drvvbus : 1, - __BITFIELD_FIELD(uint64_t lsbist : 1, - __BITFIELD_FIELD(uint64_t fsbist : 1, - __BITFIELD_FIELD(uint64_t hsbist : 1, - __BITFIELD_FIELD(uint64_t bist_done : 1, - __BITFIELD_FIELD(uint64_t bist_err : 1, - __BITFIELD_FIELD(uint64_t tdata_out : 4, - __BITFIELD_FIELD(uint64_t siddq : 1, - __BITFIELD_FIELD(uint64_t txpreemphasistune : 1, - __BITFIELD_FIELD(uint64_t dma_bmode : 1, - __BITFIELD_FIELD(uint64_t usbc_end : 1, - __BITFIELD_FIELD(uint64_t usbp_bist : 1, - __BITFIELD_FIELD(uint64_t tclk : 1, - __BITFIELD_FIELD(uint64_t dp_pulld : 1, - __BITFIELD_FIELD(uint64_t dm_pulld : 1, - __BITFIELD_FIELD(uint64_t hst_mode : 1, - __BITFIELD_FIELD(uint64_t tuning : 4, - __BITFIELD_FIELD(uint64_t tx_bs_enh : 1, - __BITFIELD_FIELD(uint64_t tx_bs_en : 1, - __BITFIELD_FIELD(uint64_t loop_enb : 1, - __BITFIELD_FIELD(uint64_t vtest_enb : 1, - __BITFIELD_FIELD(uint64_t bist_enb : 1, - __BITFIELD_FIELD(uint64_t tdata_sel : 1, - __BITFIELD_FIELD(uint64_t taddr_in : 4, - __BITFIELD_FIELD(uint64_t tdata_in : 8, - __BITFIELD_FIELD(uint64_t ate_reset : 1, + __BITFIELD_FIELD(u64 txrisetune : 1, + __BITFIELD_FIELD(u64 txvreftune : 4, + __BITFIELD_FIELD(u64 txfslstune : 4, + __BITFIELD_FIELD(u64 txhsxvtune : 2, + __BITFIELD_FIELD(u64 sqrxtune : 3, + __BITFIELD_FIELD(u64 compdistune : 3, + __BITFIELD_FIELD(u64 otgtune : 3, + __BITFIELD_FIELD(u64 otgdisable : 1, + __BITFIELD_FIELD(u64 portreset : 1, + __BITFIELD_FIELD(u64 drvvbus : 1, + __BITFIELD_FIELD(u64 lsbist : 1, + __BITFIELD_FIELD(u64 fsbist : 1, + __BITFIELD_FIELD(u64 hsbist : 1, + __BITFIELD_FIELD(u64 bist_done : 1, + __BITFIELD_FIELD(u64 bist_err : 1, + __BITFIELD_FIELD(u64 tdata_out : 4, + __BITFIELD_FIELD(u64 siddq : 1, + __BITFIELD_FIELD(u64 txpreemphasistune : 1, + __BITFIELD_FIELD(u64 dma_bmode : 1, + __BITFIELD_FIELD(u64 usbc_end : 1, + __BITFIELD_FIELD(u64 usbp_bist : 1, + __BITFIELD_FIELD(u64 tclk : 1, + __BITFIELD_FIELD(u64 dp_pulld : 1, + __BITFIELD_FIELD(u64 dm_pulld : 1, + __BITFIELD_FIELD(u64 hst_mode : 1, + __BITFIELD_FIELD(u64 tuning : 4, + __BITFIELD_FIELD(u64 tx_bs_enh : 1, + __BITFIELD_FIELD(u64 tx_bs_en : 1, + __BITFIELD_FIELD(u64 loop_enb : 1, + __BITFIELD_FIELD(u64 vtest_enb : 1, + __BITFIELD_FIELD(u64 bist_enb : 1, + __BITFIELD_FIELD(u64 tdata_sel : 1, + __BITFIELD_FIELD(u64 taddr_in : 4, + __BITFIELD_FIELD(u64 tdata_in : 8, + __BITFIELD_FIELD(u64 ate_reset : 1, ;))))))))))))))))))))))))))))))))))) } s; }; diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 6aed3cf..ed55304 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -26,8 +26,6 @@ #include <net/xfrm.h> #endif /* CONFIG_XFRM */ -#include <linux/atomic.h> - #include <asm/octeon/octeon.h> #include "ethernet-defines.h" @@ -364,17 +362,8 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) /* Increment RX stats for virtual ports */ if (port >= CVMX_PIP_NUM_INPUT_PORTS) { -#ifdef CONFIG_64BIT - atomic64_add(1, - (atomic64_t *)&priv->stats.rx_packets); - atomic64_add(skb->len, - (atomic64_t *)&priv->stats.rx_bytes); -#else - atomic_add(1, - (atomic_t *)&priv->stats.rx_packets); - atomic_add(skb->len, - (atomic_t *)&priv->stats.rx_bytes); -#endif + priv->stats.rx_packets++; + priv->stats.rx_bytes += skb->len; } netif_receive_skb(skb); } else { @@ -383,13 +372,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) printk_ratelimited("%s: Device not up, packet dropped\n", dev->name); */ -#ifdef CONFIG_64BIT - atomic64_add(1, - (atomic64_t *)&priv->stats.rx_dropped); -#else - atomic_add(1, - (atomic_t *)&priv->stats.rx_dropped); -#endif + priv->stats.rx_dropped++; dev_kfree_skb_irq(skb); } } else { diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 8d239e2..00adc52 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -226,18 +226,7 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev) priv->stats.multicast += rx_status.multicast_packets; priv->stats.rx_crc_errors += rx_status.inb_errors; priv->stats.rx_frame_errors += rx_status.fcs_align_err_packets; - - /* - * The drop counter must be incremented atomically - * since the RX tasklet also increments it. - */ -#ifdef CONFIG_64BIT - atomic64_add(rx_status.dropped_packets, - (atomic64_t *)&priv->stats.rx_dropped); -#else - atomic_add(rx_status.dropped_packets, - (atomic_t *)&priv->stats.rx_dropped); -#endif + priv->stats.rx_dropped += rx_status.dropped_packets; } return &priv->stats; @@ -790,7 +779,6 @@ static int cvm_oct_probe(struct platform_device *pdev) cvmx_fau_atomic_write32(priv->fau + qos * 4, 0); switch (priv->imode) { - /* These types don't support ports to IPD/PKO */ case CVMX_HELPER_INTERFACE_MODE_DISABLED: case CVMX_HELPER_INTERFACE_MODE_PCIE: diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c index e569f9f..47dfe25 100644 --- a/drivers/staging/rdma/hfi1/efivar.c +++ b/drivers/staging/rdma/hfi1/efivar.c @@ -127,13 +127,12 @@ static int read_efi_var(const char *name, unsigned long *size, * temporary buffer. Now allocate a correctly sized * buffer. */ - data = kmalloc(temp_size, GFP_KERNEL); + data = kmemdup(temp_buffer, temp_size, GFP_KERNEL); if (!data) { ret = -ENOMEM; goto fail; } - memcpy(data, temp_buffer, temp_size); *size = temp_size; *return_data = data; diff --git a/drivers/staging/rdma/hfi1/mr.c b/drivers/staging/rdma/hfi1/mr.c index a3f8b88..3825321 100644 --- a/drivers/staging/rdma/hfi1/mr.c +++ b/drivers/staging/rdma/hfi1/mr.c @@ -70,7 +70,7 @@ static int init_mregion(struct hfi1_mregion *mr, struct ib_pd *pd, int m, i = 0; int rval = 0; - m = (count + HFI1_SEGSZ - 1) / HFI1_SEGSZ; + m = DIV_ROUND_UP(count, HFI1_SEGSZ); for (; i < m; i++) { mr->map[i] = kzalloc(sizeof(*mr->map[0]), GFP_KERNEL); if (!mr->map[i]) @@ -159,7 +159,7 @@ static struct hfi1_mr *alloc_mr(int count, struct ib_pd *pd) int m; /* Allocate struct plus pointers to first level page tables. */ - m = (count + HFI1_SEGSZ - 1) / HFI1_SEGSZ; + m = DIV_ROUND_UP(count, HFI1_SEGSZ); mr = kzalloc(sizeof(*mr) + m * sizeof(mr->mr.map[0]), GFP_KERNEL); if (!mr) goto bail; @@ -333,7 +333,7 @@ struct ib_fmr *hfi1_alloc_fmr(struct ib_pd *pd, int mr_access_flags, int rval = -ENOMEM; /* Allocate struct plus pointers to first level page tables. */ - m = (fmr_attr->max_pages + HFI1_SEGSZ - 1) / HFI1_SEGSZ; + m = DIV_ROUND_UP(fmr_attr->max_pages, HFI1_SEGSZ); fmr = kzalloc(sizeof(*fmr) + m * sizeof(fmr->mr.map[0]), GFP_KERNEL); if (!fmr) goto bail; diff --git a/drivers/staging/rdma/hfi1/user_sdma.c b/drivers/staging/rdma/hfi1/user_sdma.c index 4f55950..2f48419 100644 --- a/drivers/staging/rdma/hfi1/user_sdma.c +++ b/drivers/staging/rdma/hfi1/user_sdma.c @@ -67,7 +67,6 @@ #include "hfi.h" #include "sdma.h" #include "user_sdma.h" -#include "sdma.h" #include "verbs.h" /* for the headers */ #include "common.h" /* for struct hfi1_tid_info */ #include "trace.h" @@ -925,8 +924,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) unsigned pageidx, len; base = (unsigned long)iovec->iov.iov_base; - offset = ((base + iovec->offset + iov_offset) & - ~PAGE_MASK); + offset = offset_in_page(base + iovec->offset + + iov_offset); pageidx = (((iovec->offset + iov_offset + base) - (base & PAGE_MASK)) >> PAGE_SHIFT); len = offset + req->info.fragsize > PAGE_SIZE ? diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c index cdcf0ea..2e2145c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_iol.c +++ b/drivers/staging/rtl8188eu/core/rtw_iol.c @@ -11,21 +11,18 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * * ******************************************************************************/ -#include<rtw_iol.h> +#include <rtw_iol.h> -bool rtw_IOL_applied(struct adapter *adapter) +bool rtw_IOL_applied(struct adapter *adapter) { - if (1 == adapter->registrypriv.fw_iol) + if (adapter->registrypriv.fw_iol == 1) return true; - if ((2 == adapter->registrypriv.fw_iol) && (!adapter_to_dvobj(adapter)->ishighspeed)) + if ((adapter->registrypriv.fw_iol == 2) && + (!adapter_to_dvobj(adapter)->ishighspeed)) return true; return false; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 9c2e659..a645a62 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -122,10 +122,8 @@ void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { rtw_free_mlme_priv_ie_data(pmlmepriv); - if (pmlmepriv) { - if (pmlmepriv->free_bss_buf) - vfree(pmlmepriv->free_bss_buf); - } + if (pmlmepriv) + vfree(pmlmepriv->free_bss_buf); } struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 96e5c6d..e3add48 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -20,6 +20,7 @@ #define _RTW_MLME_EXT_C_ #include <linux/ieee80211.h> +#include <asm/unaligned.h> #include <osdep_service.h> #include <drv_types.h> @@ -1027,7 +1028,6 @@ static void issue_assocreq(struct adapter *padapter) unsigned char *pframe, *p; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - __le16 le_tmp; unsigned int i, j, ie_len, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ie *pIE; @@ -1073,8 +1073,7 @@ static void issue_assocreq(struct adapter *padapter) /* listen interval */ /* todo: listen interval for power saving */ - le_tmp = cpu_to_le16(3); - memcpy(pframe , (unsigned char *)&le_tmp, 2); + put_unaligned_le16(3, pframe); pframe += 2; pattrib->pktlen += 2; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index c81639c..40b7a30 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -116,9 +116,8 @@ void _rtw_free_recv_priv(struct recv_priv *precvpriv) rtw_free_uc_swdec_pending_queue(padapter); - if (precvpriv->pallocated_frame_buf) { + if (precvpriv->pallocated_frame_buf) vfree(precvpriv->pallocated_frame_buf); - } rtw_hal_free_recv_priv(padapter); @@ -910,9 +909,8 @@ static int sta2ap_data_frame(struct adapter *adapter, process_pwrbit_data(adapter, precv_frame); - if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { + if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) process_wmmps_data(adapter, precv_frame); - } if (GetFrameSubType(ptr) & BIT(6)) { /* No data, will not indicate to upper layer, temporily count it here */ @@ -1527,10 +1525,9 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, if (pdefrag_q != NULL) { if (fragnum == 0) { /* the first fragment */ - if (!list_empty(&pdefrag_q->queue)) { + if (!list_empty(&pdefrag_q->queue)) /* free current defrag_q */ rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); - } } /* Then enqueue the 0~(n-1) fragment into the defrag_q */ @@ -1646,9 +1643,8 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) a_len -= nSubframe_Length; if (a_len != 0) { padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); - if (padding_len == 4) { + if (padding_len == 4) padding_len = 0; - } if (a_len < padding_len) { goto exit; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index d5ce1e2..f2dd7a6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -247,11 +247,8 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_frame_buf) - vfree(pxmitpriv->pallocated_frame_buf); - - if (pxmitpriv->pallocated_xmitbuf) - vfree(pxmitpriv->pallocated_xmitbuf); + vfree(pxmitpriv->pallocated_frame_buf); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xmit extension buff */ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c b/drivers/staging/rtl8188eu/hal/bb_cfg.c index f58a822..c2ad6a3 100644 --- a/drivers/staging/rtl8188eu/hal/bb_cfg.c +++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c @@ -598,18 +598,12 @@ static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *adapter) reg[RF_PATH_A] = &hal_data->PHYRegDef[RF_PATH_A]; reg[RF_PATH_B] = &hal_data->PHYRegDef[RF_PATH_B]; - reg[RF_PATH_C] = &hal_data->PHYRegDef[RF_PATH_C]; - reg[RF_PATH_D] = &hal_data->PHYRegDef[RF_PATH_D]; reg[RF_PATH_A]->rfintfs = rFPGA0_XAB_RFInterfaceSW; reg[RF_PATH_B]->rfintfs = rFPGA0_XAB_RFInterfaceSW; - reg[RF_PATH_C]->rfintfs = rFPGA0_XCD_RFInterfaceSW; - reg[RF_PATH_D]->rfintfs = rFPGA0_XCD_RFInterfaceSW; reg[RF_PATH_A]->rfintfi = rFPGA0_XAB_RFInterfaceRB; reg[RF_PATH_B]->rfintfi = rFPGA0_XAB_RFInterfaceRB; - reg[RF_PATH_C]->rfintfi = rFPGA0_XCD_RFInterfaceRB; - reg[RF_PATH_D]->rfintfi = rFPGA0_XCD_RFInterfaceRB; reg[RF_PATH_A]->rfintfo = rFPGA0_XA_RFInterfaceOE; reg[RF_PATH_B]->rfintfo = rFPGA0_XB_RFInterfaceOE; @@ -622,13 +616,9 @@ static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *adapter) reg[RF_PATH_A]->rfLSSI_Select = rFPGA0_XAB_RFParameter; reg[RF_PATH_B]->rfLSSI_Select = rFPGA0_XAB_RFParameter; - reg[RF_PATH_C]->rfLSSI_Select = rFPGA0_XCD_RFParameter; - reg[RF_PATH_D]->rfLSSI_Select = rFPGA0_XCD_RFParameter; reg[RF_PATH_A]->rfTxGainStage = rFPGA0_TxGainStage; reg[RF_PATH_B]->rfTxGainStage = rFPGA0_TxGainStage; - reg[RF_PATH_C]->rfTxGainStage = rFPGA0_TxGainStage; - reg[RF_PATH_D]->rfTxGainStage = rFPGA0_TxGainStage; reg[RF_PATH_A]->rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; reg[RF_PATH_B]->rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; @@ -638,43 +628,27 @@ static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *adapter) reg[RF_PATH_A]->rfSwitchControl = rFPGA0_XAB_SwitchControl; reg[RF_PATH_B]->rfSwitchControl = rFPGA0_XAB_SwitchControl; - reg[RF_PATH_C]->rfSwitchControl = rFPGA0_XCD_SwitchControl; - reg[RF_PATH_D]->rfSwitchControl = rFPGA0_XCD_SwitchControl; reg[RF_PATH_A]->rfAGCControl1 = rOFDM0_XAAGCCore1; reg[RF_PATH_B]->rfAGCControl1 = rOFDM0_XBAGCCore1; - reg[RF_PATH_C]->rfAGCControl1 = rOFDM0_XCAGCCore1; - reg[RF_PATH_D]->rfAGCControl1 = rOFDM0_XDAGCCore1; reg[RF_PATH_A]->rfAGCControl2 = rOFDM0_XAAGCCore2; reg[RF_PATH_B]->rfAGCControl2 = rOFDM0_XBAGCCore2; - reg[RF_PATH_C]->rfAGCControl2 = rOFDM0_XCAGCCore2; - reg[RF_PATH_D]->rfAGCControl2 = rOFDM0_XDAGCCore2; reg[RF_PATH_A]->rfRxIQImbalance = rOFDM0_XARxIQImbalance; reg[RF_PATH_B]->rfRxIQImbalance = rOFDM0_XBRxIQImbalance; - reg[RF_PATH_C]->rfRxIQImbalance = rOFDM0_XCRxIQImbalance; - reg[RF_PATH_D]->rfRxIQImbalance = rOFDM0_XDRxIQImbalance; reg[RF_PATH_A]->rfRxAFE = rOFDM0_XARxAFE; reg[RF_PATH_B]->rfRxAFE = rOFDM0_XBRxAFE; - reg[RF_PATH_C]->rfRxAFE = rOFDM0_XCRxAFE; - reg[RF_PATH_D]->rfRxAFE = rOFDM0_XDRxAFE; reg[RF_PATH_A]->rfTxIQImbalance = rOFDM0_XATxIQImbalance; reg[RF_PATH_B]->rfTxIQImbalance = rOFDM0_XBTxIQImbalance; - reg[RF_PATH_C]->rfTxIQImbalance = rOFDM0_XCTxIQImbalance; - reg[RF_PATH_D]->rfTxIQImbalance = rOFDM0_XDTxIQImbalance; reg[RF_PATH_A]->rfTxAFE = rOFDM0_XATxAFE; reg[RF_PATH_B]->rfTxAFE = rOFDM0_XBTxAFE; - reg[RF_PATH_C]->rfTxAFE = rOFDM0_XCTxAFE; - reg[RF_PATH_D]->rfTxAFE = rOFDM0_XDTxAFE; reg[RF_PATH_A]->rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; reg[RF_PATH_B]->rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - reg[RF_PATH_C]->rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; - reg[RF_PATH_D]->rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; reg[RF_PATH_A]->rfLSSIReadBackPi = TransceiverA_HSPI_Readback; reg[RF_PATH_B]->rfLSSIReadBackPi = TransceiverB_HSPI_Readback; diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index d3e8a8e..ae42b44 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -180,32 +180,6 @@ static void get_tx_power_index(struct adapter *adapt, u8 channel, u8 *cck_pwr, hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]+ hal_data->BW20_24G_Diff[TxCount][index]; bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_C) { - cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_B][index]+ - hal_data->BW20_24G_Diff[TxCount][index]; - - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_B][index]+ - hal_data->BW20_24G_Diff[TxCount][index]; - bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_D) { - cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_B][index]+ - hal_data->BW20_24G_Diff[RF_PATH_C][index]+ - hal_data->BW20_24G_Diff[TxCount][index]; - - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_B][index]+ - hal_data->BW20_24G_Diff[RF_PATH_C][index]+ - hal_data->BW20_24G_Diff[TxCount][index]; - bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; } } } diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h index b8833fa..2670d6b 100644 --- a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h @@ -69,8 +69,6 @@ enum hw90_block { enum rf_radio_path { RF_PATH_A = 0, /* Radio Path A */ RF_PATH_B = 1, /* Radio Path B */ - RF_PATH_C = 2, /* Radio Path C */ - RF_PATH_D = 3, /* Radio Path D */ }; #define MAX_PG_GROUP 13 diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index aec20bb..5d6a1c9 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -3095,7 +3095,6 @@ struct iw_handler_def rtw_handlers_def = { .get_wireless_stats = rtw_get_wireless_stats, }; -#include <rtw_android.h> int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct iwreq *wrq = (struct iwreq *)rq; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index e9c4f97..ba64a4f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -680,7 +680,7 @@ static void _rtl92e_hwconfig(struct net_device *dev) rtl92e_writeb(dev, BW_OPMODE, regBwOpMode); { - u32 ratr_value = 0; + u32 ratr_value; ratr_value = regRATR; if (priv->rf_type == RF_1T2R) @@ -1000,7 +1000,7 @@ void rtl92e_link_change(struct net_device *dev) _rtl92e_update_msr(dev); if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { - u32 reg = 0; + u32 reg; reg = rtl92e_readl(dev, RCR); if (priv->rtllib->state == RTLLIB_LINKED) { @@ -1186,7 +1186,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - struct tx_fwinfo_8190pci *pTxFwInfo = NULL; + struct tx_fwinfo_8190pci *pTxFwInfo; pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); @@ -2235,7 +2235,7 @@ void rtl92e_disable_irq(struct net_device *dev) void rtl92e_clear_irq(struct net_device *dev) { - u32 tmp = 0; + u32 tmp; tmp = rtl92e_readl(dev, ISR); rtl92e_writel(dev, ISR, tmp); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 8f989a9..0b06482 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -288,7 +288,7 @@ static void _rtl92e_tx_timeout(struct net_device *dev) void rtl92e_irq_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); priv->irq_enabled = 1; @@ -297,7 +297,7 @@ void rtl92e_irq_enable(struct net_device *dev) void rtl92e_irq_disable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); priv->ops->irq_disable(dev); @@ -306,7 +306,7 @@ void rtl92e_irq_disable(struct net_device *dev) static void _rtl92e_set_chan(struct net_device *dev, short ch) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); if (priv->chan_forced) @@ -1546,14 +1546,14 @@ static void _rtl92e_watchdog_timer_cb(unsigned long data) *****************************************************************************/ void rtl92e_rx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); priv->ops->rx_enable(dev); } void rtl92e_tx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); priv->ops->tx_enable(dev); @@ -1612,7 +1612,7 @@ static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio) static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); int ret; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); @@ -1643,7 +1643,7 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); int ret; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); @@ -1676,7 +1676,7 @@ static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) static void _rtl92e_tx_isr(struct net_device *dev, int prio) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -1850,7 +1850,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev) static int _rtl92e_alloc_tx_ring(struct net_device *dev, unsigned int prio, unsigned int entries) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct tx_desc *ring; dma_addr_t dma; int i; @@ -1944,7 +1944,7 @@ void rtl92e_reset_desc_ring(struct net_device *dev) void rtl92e_update_rx_pkt_timestamp(struct net_device *dev, struct rtllib_rx_stats *stats) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); if (stats->bIsAMPDU && !stats->bFirstMPDU) stats->mac_time = priv->LastRxDescTSF; @@ -2022,7 +2022,7 @@ void rtl92e_copy_mpdu_stats(struct rtllib_rx_stats *psrc_stats, static void _rtl92e_rx_normal(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; bool unicast_packet = false; bool bLedBlinking = true; @@ -2128,7 +2128,7 @@ done: static void _rtl92e_tx_resume(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; struct sk_buff *skb; int queue_index; @@ -2279,7 +2279,7 @@ static int _rtl92e_set_mac_adr(struct net_device *dev, void *mac) /* based on ipw2200 driver */ static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; int ret = -1; struct rtllib_device *ieee = priv->rtllib; @@ -2403,7 +2403,7 @@ out: static irqreturn_t _rtl92e_irq(int irq, void *netdev) { struct net_device *dev = (struct net_device *) netdev; - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags; u32 inta; u32 intb; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index ef03242..b6b714d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -1875,7 +1875,7 @@ void rtl92e_dm_rf_pathcheck_wq(void *data) struct r8192_priv, rfpath_check_wq); struct net_device *dev = priv->rtllib->dev; - u8 rfpath = 0, i; + u8 rfpath, i; rfpath = rtl92e_readb(dev, 0xc04); diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index c04a020..c7fd1b1 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -189,7 +189,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, struct ba_record *pBA) { - struct sk_buff *skb = NULL; + struct sk_buff *skb; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -204,7 +204,7 @@ static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, struct ba_record *pBA, u16 StatusCode) { - struct sk_buff *skb = NULL; + struct sk_buff *skb; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); if (skb) @@ -217,7 +217,7 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, struct ba_record *pBA, enum tr_select TxRxSelect, u16 ReasonCode) { - struct sk_buff *skb = NULL; + struct sk_buff *skb; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); if (skb) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 37343ec..af64bd3 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -905,7 +905,7 @@ static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - size_t hdrlen = 0; + size_t hdrlen; hdrlen = rtllib_get_hdrlen(fc); if (HTCCheck(ieee, skb->data)) { diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 19c3bff..25b5b5e 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -776,7 +776,7 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, { struct sk_buff *skb; struct rtllib_authentication *auth; - int len = 0; + int len; len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 86f52ac..01a75bd 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -243,7 +243,7 @@ int rtllib_wx_get_rate(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - u32 tmp_rate = 0; + u32 tmp_rate; tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 9bc5aac..f8041f9d6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -515,7 +515,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) ieee80211_send_probe_requests(ieee); - queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); + schedule_delayed_work(&ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); up(&ieee->scan_sem); return; @@ -614,7 +614,7 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ if (ieee->scanning == 0) { ieee->scanning = 1; - queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); + schedule_delayed_work(&ieee->softmac_scan_wq, 0); } }else ieee->start_scan(ieee->dev); @@ -1241,7 +1241,7 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee) ieee->state = IEEE80211_ASSOCIATING_RETRY; - queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, \ + schedule_delayed_work(&ieee->associate_retry_wq, \ IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); @@ -1382,7 +1382,7 @@ static void ieee80211_associate_complete(struct ieee80211_device *ieee) ieee->state = IEEE80211_LINKED; //ieee->UpdateHalRATRTableHandler(dev, ieee->dot11HTOperationalRateSet); - queue_work(ieee->wq, &ieee->associate_complete_wq); + schedule_work(&ieee->associate_complete_wq); } static void ieee80211_associate_procedure_wq(struct work_struct *work) @@ -1483,7 +1483,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee } ieee->state = IEEE80211_ASSOCIATING; - queue_work(ieee->wq, &ieee->associate_procedure_wq); + schedule_work(&ieee->associate_procedure_wq); }else{ if(ieee80211_is_54g(&ieee->current_network) && (ieee->modulation & IEEE80211_OFDM_MODULATION)){ @@ -2044,7 +2044,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, "Association response status code 0x%x\n", errcode); if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_work(ieee->wq, &ieee->associate_procedure_wq); + schedule_work(&ieee->associate_procedure_wq); } else { ieee80211_associate_abort(ieee); } @@ -2100,7 +2100,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, notify_wx_assoc_event(ieee); //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); RemovePeerTS(ieee, header->addr2); - queue_work(ieee->wq, &ieee->associate_procedure_wq); + schedule_work(&ieee->associate_procedure_wq); } break; case IEEE80211_STYPE_MANAGE_ACT: @@ -2442,7 +2442,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) inline void ieee80211_start_ibss(struct ieee80211_device *ieee) { - queue_delayed_work(ieee->wq, &ieee->start_ibss_wq, 150); + schedule_delayed_work(&ieee->start_ibss_wq, 150); } /* this is called only in user context, with wx_sem held */ @@ -2725,7 +2725,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) setup_timer(&ieee->beacon_timer, ieee80211_send_beacon_cb, (unsigned long)ieee); - ieee->wq = create_workqueue(DRV_NAME); INIT_DELAYED_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq); INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq); @@ -2755,7 +2754,6 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee) del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - destroy_workqueue(ieee->wq); up(&ieee->wx_sem); } diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 3c58963..3a93218 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1962,7 +1962,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, network->qos_data.param_count)) { network->qos_data.old_param_count = network->qos_data.param_count; - queue_work(priv->priv_wq, &priv->qos_activate); + schedule_work(&priv->qos_activate); RT_TRACE(COMP_QOS, "QoS parameters change call qos_activate\n"); } @@ -1971,7 +1971,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, &def_qos_parameters, size); if ((network->qos_data.active == 1) && (active_network == 1)) { - queue_work(priv->priv_wq, &priv->qos_activate); + schedule_work(&priv->qos_activate); RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n"); } @@ -1990,7 +1990,7 @@ static int rtl8192_handle_beacon(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); rtl8192_qos_handle_probe_response(priv, 1, network); - queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0); + schedule_delayed_work(&priv->update_beacon_wq, 0); return 0; } @@ -2042,7 +2042,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, network->flags, priv->ieee80211->current_network.qos_data.active); if (set_qos_param == 1) - queue_work(priv->priv_wq, &priv->qos_activate); + schedule_work(&priv->qos_activate); return 0; @@ -2387,7 +2387,6 @@ static void rtl8192_init_priv_task(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - priv->priv_wq = create_workqueue(DRV_NAME); INIT_WORK(&priv->reset_wq, rtl8192_restart); @@ -3518,7 +3517,7 @@ static void watch_dog_timer_callback(unsigned long data) { struct r8192_priv *priv = ieee80211_priv((struct net_device *)data); - queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0); + schedule_delayed_work(&priv->watch_dog_wq, 0); mod_timer(&priv->watch_dog_timer, jiffies + msecs_to_jiffies(IEEE80211_WATCH_DOG_TIME)); } @@ -5022,7 +5021,6 @@ fail2: kfree(priv->pFirmware); priv->pFirmware = NULL; rtl8192_usb_deleteendpoints(dev); - destroy_workqueue(priv->priv_wq); mdelay(10); fail: free_ieee80211(dev); @@ -5060,7 +5058,6 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) kfree(priv->pFirmware); priv->pFirmware = NULL; rtl8192_usb_deleteendpoints(dev); - destroy_workqueue(priv->priv_wq); mdelay(10); } free_ieee80211(dev); diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index d2e86b9..1e0e53c 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1628,47 +1628,75 @@ static void dm_bb_initialgain_backup(struct net_device *dev) void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, u32 dm_value) { - if (dm_type == DIG_TYPE_THRESH_HIGH) { + switch (dm_type) { + case DIG_TYPE_THRESH_HIGH: dm_digtable.rssi_high_thresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_LOW) { + break; + + case DIG_TYPE_THRESH_LOW: dm_digtable.rssi_low_thresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { + break; + + case DIG_TYPE_THRESH_HIGHPWR_HIGH: dm_digtable.rssi_high_power_highthresh = dm_value; - } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW) { + break; + + case DIG_TYPE_THRESH_HIGHPWR_LOW: dm_digtable.rssi_high_power_lowthresh = dm_value; - } else if (dm_type == DIG_TYPE_ENABLE) { + break; + + case DIG_TYPE_ENABLE: dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = true; - } else if (dm_type == DIG_TYPE_DISABLE) { + break; + + case DIG_TYPE_DISABLE: dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = false; - } else if (dm_type == DIG_TYPE_DBG_MODE) { + break; + + case DIG_TYPE_DBG_MODE: if (dm_value >= DM_DBG_MAX) dm_value = DM_DBG_OFF; dm_digtable.dbg_mode = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RSSI) { + break; + + case DIG_TYPE_RSSI: if (dm_value > 100) dm_value = 30; dm_digtable.rssi_val = (long)dm_value; - } else if (dm_type == DIG_TYPE_ALGORITHM) { + break; + + case DIG_TYPE_ALGORITHM: if (dm_value >= DIG_ALGO_MAX) dm_value = DIG_ALGO_BY_FALSE_ALARM; if (dm_digtable.dig_algorithm != (u8)dm_value) dm_digtable.dig_algorithm_switch = 1; dm_digtable.dig_algorithm = (u8)dm_value; - } else if (dm_type == DIG_TYPE_BACKOFF) { + break; + + case DIG_TYPE_BACKOFF: if (dm_value > 30) dm_value = 30; dm_digtable.backoff_val = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RX_GAIN_MIN) { + break; + + case DIG_TYPE_RX_GAIN_MIN: if (dm_value == 0) dm_value = 0x1; dm_digtable.rx_gain_range_min = (u8)dm_value; - } else if (dm_type == DIG_TYPE_RX_GAIN_MAX) { + break; + + case DIG_TYPE_RX_GAIN_MAX: if (dm_value > 0x50) dm_value = 0x50; dm_digtable.rx_gain_range_max = (u8)dm_value; + break; + + default: + break; } + } /* DM_ChangeDynamicInitGainThresh */ /*----------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index db2e31bc..a15f3ce 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -137,7 +137,7 @@ static inline void handle_group_key(struct ieee_param *param, } } -static inline char *translate_scan(struct _adapter *padapter, +static noinline_for_stack char *translate_scan(struct _adapter *padapter, struct iw_request_info *info, struct wlan_network *pnetwork, char *start, char *stop) diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index b64f10b..f1d3d70 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -221,7 +221,7 @@ static int r871x_suspend(struct usb_interface *pusb_intf, pm_message_t state) return 0; } -void rtl871x_intf_resume(struct _adapter *padapter) +static void rtl871x_intf_resume(struct _adapter *padapter) { if (padapter->dvobjpriv.inirp_init) padapter->dvobjpriv.inirp_init(padapter); diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index e77be2a..c2ac581 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -228,16 +228,18 @@ static void r8712_usb_read_port_complete(struct urb *purb) } } else { switch (purb->status) { - case -ENOENT: - if (padapter->bSuspended) - break; - /* Fall through. */ case -EINVAL: case -EPIPE: case -ENODEV: case -ESHUTDOWN: padapter->bDriverStopped = true; break; + case -ENOENT: + if (!padapter->bSuspended) { + padapter->bDriverStopped = true; + break; + } + /* Fall through. */ case -EPROTO: precvbuf->reuse = true; r8712_read_port(padapter, precvpriv->ff_hwaddr, 0, diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index d398183..f8866d7 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -131,7 +131,7 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter, for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); - if (pxmitbuf->pxmit_urb[i] == NULL) { + if (!pxmitbuf->pxmit_urb[i]) { netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n"); return _FAIL; } @@ -171,7 +171,7 @@ int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev) goto _xmit_entry_drop; } pxmitframe = r8712_alloc_xmitframe(pxmitpriv); - if (pxmitframe == NULL) { + if (!pxmitframe) { ret = 0; goto _xmit_entry_drop; } diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 1aa9b26..ce4b589 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -171,24 +171,20 @@ static u8 chk_sta_is_alive(struct sta_info *psta) return ret; } -void expire_timeout_chk23a(struct rtw_adapter *padapter) +void expire_timeout_chk23a(struct rtw_adapter *padapter) { - struct list_head *phead, *plist, *ptmp; + struct list_head *phead; u8 updated = 0; - struct sta_info *psta; + struct sta_info *psta, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; u8 chk_alive_num = 0; struct sta_info *chk_alive_list[NUM_STA]; int i; spin_lock_bh(&pstapriv->auth_list_lock); - phead = &pstapriv->auth_list; - /* check auth_queue */ - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, auth_list); - + list_for_each_entry_safe(psta, ptmp, phead, auth_list) { if (psta->expire_to > 0) { psta->expire_to--; if (psta->expire_to == 0) { @@ -206,19 +202,13 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) spin_lock_bh(&pstapriv->auth_list_lock); } } - } - spin_unlock_bh(&pstapriv->auth_list_lock); spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - /* check asoc_queue */ - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) { if (chk_sta_is_alive(psta) || !psta->expire_to) { psta->expire_to = pstapriv->expire_to; psta->keep_alive_trycnt = 0; @@ -283,7 +273,6 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) } } } - spin_unlock_bh(&pstapriv->asoc_list_lock); if (chk_alive_num) { @@ -1059,7 +1048,7 @@ void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode) int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) { - struct list_head *plist, *phead; + struct list_head *phead; u8 added = false; int i, ret = 0; struct rtw_wlan_acl_node *paclnode; @@ -1073,12 +1062,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) return -1; spin_lock_bh(&pacl_node_q->lock); - phead = get_list_head(pacl_node_q); - - list_for_each(plist, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry(paclnode, phead, list) { if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid == true) { added = true; @@ -1087,7 +1072,6 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) } } } - spin_unlock_bh(&pacl_node_q->lock); if (added) @@ -1121,8 +1105,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) { - struct list_head *plist, *phead, *ptmp; - struct rtw_wlan_acl_node *paclnode; + struct list_head *phead; + struct rtw_wlan_acl_node *paclnode, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; @@ -1130,12 +1114,8 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr); spin_lock_bh(&pacl_node_q->lock); - phead = get_list_head(pacl_node_q); - - list_for_each_safe(plist, ptmp, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry_safe(paclnode, ptmp, phead, list) { if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { paclnode->valid = false; @@ -1146,7 +1126,6 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) } } } - spin_unlock_bh(&pacl_node_q->lock); DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num); @@ -1354,20 +1333,14 @@ void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated) { /* update associated stations cap. */ if (updated == true) { - struct list_head *phead, *plist, *ptmp; - struct sta_info *psta; + struct list_head *phead; + struct sta_info *psta, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) VCS_update23a(padapter, psta); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); } } @@ -1627,7 +1600,7 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti int rtw_ap_inform_ch_switch23a(struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset) { - struct list_head *phead, *plist; + struct list_head *phead; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1642,10 +1615,7 @@ int rtw_ap_inform_ch_switch23a(struct rtw_adapter *padapter, u8 new_ch, u8 ch_of spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - - list_for_each(plist, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry(psta, phead, asoc_list) { issue_action_spct_ch_switch23a(padapter, psta->hwaddr, new_ch, ch_offset); psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); } @@ -1658,8 +1628,8 @@ int rtw_ap_inform_ch_switch23a(struct rtw_adapter *padapter, u8 new_ch, u8 ch_of int rtw_sta_flush23a(struct rtw_adapter *padapter) { - struct list_head *phead, *plist, *ptmp; - struct sta_info *psta; + struct list_head *phead; + struct sta_info *psta, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -1675,10 +1645,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) { /* Remove sta from asoc_list */ list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; @@ -1744,9 +1711,9 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) struct mlme_priv *mlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct sta_priv *pstapriv = &padapter->stapriv; - struct sta_info *psta; + struct sta_info *psta, *ptmp; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct list_head *phead, *plist, *ptmp; + struct list_head *phead; u8 chk_alive_num = 0; struct sta_info *chk_alive_list[NUM_STA]; int i; @@ -1775,15 +1742,9 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) } spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) chk_alive_list[chk_alive_num++] = psta; - } - spin_unlock_bh(&pstapriv->asoc_list_lock); for (i = 0; i < chk_alive_num; i++) { @@ -1841,8 +1802,8 @@ void start_ap_mode23a(struct rtw_adapter *padapter) void stop_ap_mode23a(struct rtw_adapter *padapter) { - struct list_head *phead, *plist, *ptmp; - struct rtw_wlan_acl_node *paclnode; + struct list_head *phead; + struct rtw_wlan_acl_node *paclnode, *ptmp; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1864,15 +1825,10 @@ void stop_ap_mode23a(struct rtw_adapter *padapter) /* for ACL */ spin_lock_bh(&pacl_node_q->lock); phead = get_list_head(pacl_node_q); - - list_for_each_safe(plist, ptmp, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry_safe(paclnode, ptmp, phead, list) { if (paclnode->valid == true) { paclnode->valid = false; - list_del_init(&paclnode->list); - pacl_list->num--; } } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 3c09ea9..3adda55 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -171,21 +171,15 @@ exit: void rtw_free_network_queue23a(struct rtw_adapter *padapter) { - struct list_head *phead, *plist, *ptmp; - struct wlan_network *pnetwork; + struct list_head *phead; + struct wlan_network *pnetwork, *ptmp; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; spin_lock_bh(&scanned_queue->lock); - phead = get_list_head(scanned_queue); - - list_for_each_safe(plist, ptmp, phead) { - pnetwork = container_of(plist, struct wlan_network, list); - + list_for_each_entry_safe(pnetwork, ptmp, phead, list) _rtw_free_network23a(pmlmepriv, pnetwork); - } - spin_unlock_bh(&scanned_queue->lock); } @@ -329,15 +323,12 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) struct wlan_network * rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) { - struct list_head *plist, *phead; + struct list_head *phead; struct wlan_network *pwlan; struct wlan_network *oldest = NULL; phead = get_list_head(scanned_queue); - - list_for_each(plist, phead) { - pwlan = container_of(plist, struct wlan_network, list); - + list_for_each_entry(pwlan, phead, list) { if (pwlan->fixed != true) { if (!oldest || time_after(oldest->last_scanned, pwlan->last_scanned)) @@ -445,7 +436,6 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter, spin_lock_bh(&queue->lock); phead = get_list_head(queue); - list_for_each(plist, phead) { pnetwork = container_of(plist, struct wlan_network, list); @@ -710,21 +700,17 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) static void free_scanqueue(struct mlme_priv *pmlmepriv) { - struct wlan_network *pnetwork; + struct wlan_network *pnetwork, *ptemp; struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue; - struct list_head *plist, *phead, *ptemp; + struct list_head *phead; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, "+free_scanqueue\n"); spin_lock_bh(&scan_queue->lock); - phead = get_list_head(scan_queue); - - list_for_each_safe(plist, ptemp, phead) { - pnetwork = container_of(plist, struct wlan_network, list); + list_for_each_entry_safe(pnetwork, ptemp, phead, list) { pnetwork->fixed = false; _rtw_free_network23a(pmlmepriv, pnetwork); } - spin_unlock_bh(&scan_queue->lock); } @@ -1625,15 +1611,13 @@ exit: static struct wlan_network * rtw_select_candidate_from_queue(struct mlme_priv *pmlmepriv) { - struct wlan_network *pnetwork, *candidate = NULL; + struct wlan_network *pnetwork, *ptmp, *candidate = NULL; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - struct list_head *phead, *plist, *ptmp; + struct list_head *phead; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); - - list_for_each_safe(plist, ptmp, phead) { - pnetwork = container_of(plist, struct wlan_network, list); + list_for_each_entry_safe(pnetwork, ptmp, phead, list) { if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, "%s: return _FAIL:(pnetwork == NULL)\n", diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a39e441..f4fff38 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6061,10 +6061,10 @@ int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) #ifdef CONFIG_8723AU_AP_MODE else { /* tx bc/mc frames after update TIM */ struct sta_info *psta_bmc; - struct list_head *plist, *phead, *ptmp; - struct xmit_frame *pxmitframe; + struct list_head *phead; + struct xmit_frame *pxmitframe, *ptmp; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; /* for BC/MC Frames */ psta_bmc = rtw_get_bcmc_stainfo23a(padapter); @@ -6078,10 +6078,8 @@ int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) phead = get_list_head(&psta_bmc->sleep_q); - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, - struct xmit_frame, - list); + list_for_each_entry_safe(pxmitframe, ptmp, + phead, list) { list_del_init(&pxmitframe->list); @@ -6098,7 +6096,6 @@ int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) rtl8723au_hal_xmitframe_enqueue(padapter, pxmitframe); } - /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); } diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 81abe50..0a7741c 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -85,16 +85,15 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, return res; } -void _rtw_free_recv_priv23a (struct recv_priv *precvpriv) +void _rtw_free_recv_priv23a(struct recv_priv *precvpriv) { struct rtw_adapter *padapter = precvpriv->adapter; - struct recv_frame *precvframe; - struct list_head *plist, *ptmp; + struct recv_frame *precvframe, *ptmp; rtw_free_uc_swdec_pending_queue23a(padapter); - list_for_each_safe(plist, ptmp, &precvpriv->free_recv_queue.queue) { - precvframe = container_of(plist, struct recv_frame, list); + list_for_each_entry_safe(precvframe, ptmp, + &precvpriv->free_recv_queue.queue, list) { list_del_init(&precvframe->list); kfree(precvframe); } @@ -195,19 +194,13 @@ using spinlock to protect static void rtw_free_recvframe23a_queue(struct rtw_queue *pframequeue) { - struct recv_frame *hdr; - struct list_head *plist, *phead, *ptmp; + struct recv_frame *hdr, *ptmp; + struct list_head *phead; spin_lock(&pframequeue->lock); - phead = get_list_head(pframequeue); - plist = phead->next; - - list_for_each_safe(plist, ptmp, phead) { - hdr = container_of(plist, struct recv_frame, list); + list_for_each_entry_safe(hdr, ptmp, phead, list) rtw_free_recvframe23a(hdr); - } - spin_unlock(&pframequeue->lock); } @@ -1549,16 +1542,14 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, struct rtw_queue *defrag_q) { - struct list_head *plist, *phead, *ptmp; - u8 *data, wlanhdr_offset; - u8 curfragnum; - struct recv_frame *pnfhdr; + struct list_head *plist, *phead; + u8 wlanhdr_offset; + u8 curfragnum; + struct recv_frame *pnfhdr, *ptmp; struct recv_frame *prframe, *pnextrframe; - struct rtw_queue *pfree_recv_queue; + struct rtw_queue *pfree_recv_queue; struct sk_buff *skb; - - curfragnum = 0; pfree_recv_queue = &adapter->recvpriv.free_recv_queue; @@ -1579,12 +1570,7 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, curfragnum++; - phead = get_list_head(defrag_q); - - data = prframe->pkt->data; - - list_for_each_safe(plist, ptmp, phead) { - pnfhdr = container_of(plist, struct recv_frame, list); + list_for_each_entry_safe(pnfhdr, ptmp, phead, list) { pnextrframe = (struct recv_frame *)pnfhdr; /* check the fragment sequence (2nd ~n fragment frame) */ @@ -1626,8 +1612,6 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, "Performance defrag!!!!!\n"); - - return prframe; } diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index b06bff7..22d857b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -83,8 +83,8 @@ int _rtw_init_sta_priv23a(struct sta_priv *pstapriv) int _rtw_free_sta_priv23a(struct sta_priv *pstapriv) { - struct list_head *phead, *plist, *ptmp; - struct sta_info *psta; + struct list_head *phead; + struct sta_info *psta, *ptmp; struct recv_reorder_ctrl *preorder_ctrl; int index; @@ -93,12 +93,9 @@ int _rtw_free_sta_priv23a(struct sta_priv *pstapriv) spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { phead = &pstapriv->sta_hash[index]; - - list_for_each_safe(plist, ptmp, phead) { + list_for_each_entry_safe(psta, ptmp, phead, hash_list) { int i; - psta = container_of(plist, struct sta_info, - hash_list); for (i = 0; i < 16 ; i++) { preorder_ctrl = &psta->recvreorder_ctrl[i]; del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); @@ -325,8 +322,8 @@ exit: /* free all stainfo which in sta_hash[all] */ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) { - struct list_head *plist, *phead, *ptmp; - struct sta_info *psta; + struct list_head *phead; + struct sta_info *psta, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo23a(padapter); s32 index; @@ -335,13 +332,9 @@ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) return; spin_lock_bh(&pstapriv->sta_hash_lock); - for (index = 0; index < NUM_STA; index++) { phead = &pstapriv->sta_hash[index]; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, hash_list); - + list_for_each_entry_safe(psta, ptmp, phead, hash_list) { if (pbcmc_stainfo != psta) rtw_free_stainfo23a(padapter, psta); } @@ -352,9 +345,9 @@ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) /* any station allocated can be searched by hash list */ struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr) { - struct list_head *plist, *phead; + struct list_head *phead; struct sta_info *psta = NULL; - u32 index; + u32 index; const u8 *addr; if (hwaddr == NULL) @@ -368,12 +361,8 @@ struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr) index = wifi_mac_hash(addr); spin_lock_bh(&pstapriv->sta_hash_lock); - phead = &pstapriv->sta_hash[index]; - - list_for_each(plist, phead) { - psta = container_of(plist, struct sta_info, hash_list); - + list_for_each_entry(psta, phead, hash_list) { /* if found the matched address */ if (ether_addr_equal(psta->hwaddr, addr)) break; @@ -418,7 +407,7 @@ bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr) { bool res = true; #ifdef CONFIG_8723AU_AP_MODE - struct list_head *plist, *phead; + struct list_head *phead; struct rtw_wlan_acl_node *paclnode; bool match = false; struct sta_priv *pstapriv = &padapter->stapriv; @@ -427,10 +416,7 @@ bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr) spin_lock_bh(&pacl_node_q->lock); phead = get_list_head(pacl_node_q); - - list_for_each(plist, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry(paclnode, phead, list) { if (ether_addr_equal(paclnode->addr, mac_addr)) { if (paclnode->valid) { match = true; diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index a4b6bb6..b82b182 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -193,39 +193,38 @@ fail: goto exit; } -void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) +void _rtw_free_xmit_priv23a(struct xmit_priv *pxmitpriv) { struct rtw_adapter *padapter = pxmitpriv->adapter; - struct xmit_frame *pxframe; - struct xmit_buf *pxmitbuf; - struct list_head *plist, *ptmp; + struct xmit_frame *pxframe, *ptmp; + struct xmit_buf *pxmitbuf, *ptmp2; - list_for_each_safe(plist, ptmp, &pxmitpriv->free_xmit_queue.queue) { - pxframe = container_of(plist, struct xmit_frame, list); + list_for_each_entry_safe(pxframe, ptmp, + &pxmitpriv->free_xmit_queue.queue, list) { list_del_init(&pxframe->list); rtw_os_xmit_complete23a(padapter, pxframe); kfree(pxframe); } - list_for_each_safe(plist, ptmp, &pxmitpriv->xmitbuf_list) { - pxmitbuf = container_of(plist, struct xmit_buf, list2); + list_for_each_entry_safe(pxmitbuf, ptmp2, + &pxmitpriv->xmitbuf_list, list2) { list_del_init(&pxmitbuf->list2); rtw_os_xmit_resource_free23a(padapter, pxmitbuf); kfree(pxmitbuf); } /* free xframe_ext queue, the same count as extbuf */ - list_for_each_safe(plist, ptmp, - &pxmitpriv->free_xframe_ext_queue.queue) { - pxframe = container_of(plist, struct xmit_frame, list); + list_for_each_entry_safe(pxframe, ptmp, + &pxmitpriv->free_xframe_ext_queue.queue, + list) { list_del_init(&pxframe->list); rtw_os_xmit_complete23a(padapter, pxframe); kfree(pxframe); } /* free xmit extension buff */ - list_for_each_safe(plist, ptmp, &pxmitpriv->xmitextbuf_list) { - pxmitbuf = container_of(plist, struct xmit_buf, list2); + list_for_each_entry_safe(pxmitbuf, ptmp2, + &pxmitpriv->xmitextbuf_list, list2) { list_del_init(&pxmitbuf->list2); rtw_os_xmit_resource_free23a(padapter, pxmitbuf); kfree(pxmitbuf); @@ -1563,18 +1562,13 @@ exit: void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv, struct rtw_queue *pframequeue) { - struct list_head *plist, *phead, *ptmp; - struct xmit_frame *pxmitframe; + struct list_head *phead; + struct xmit_frame *pxmitframe, *ptmp; spin_lock_bh(&pframequeue->lock); - phead = get_list_head(pframequeue); - - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, struct xmit_frame, list); - + list_for_each_entry_safe(pxmitframe, ptmp, phead, list) rtw_free_xmitframe23a(pxmitpriv, pxmitframe); - } spin_unlock_bh(&pframequeue->lock); } @@ -1612,9 +1606,9 @@ struct xmit_frame * rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) { - struct list_head *sta_plist, *sta_phead, *ptmp; + struct list_head *sta_phead; struct hw_xmit *phwxmit; - struct tx_servq *ptxservq = NULL; + struct tx_servq *ptxservq = NULL, *ptmp; struct rtw_queue *pframe_queue = NULL; struct xmit_frame *pxmitframe = NULL; struct rtw_adapter *padapter = pxmitpriv->adapter; @@ -1638,11 +1632,8 @@ rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, phwxmit = phwxmit_i + inx[i]; sta_phead = get_list_head(phwxmit->sta_queue); - - list_for_each_safe(sta_plist, ptmp, sta_phead) { - ptxservq = container_of(sta_plist, struct tx_servq, - tx_pending); - + list_for_each_entry_safe(ptxservq, ptmp, sta_phead, + tx_pending) { pframe_queue = &ptxservq->sta_pending; pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue); @@ -2052,18 +2043,15 @@ dequeue_xmitframes_to_sleeping_queue(struct rtw_adapter *padapter, struct rtw_queue *pframequeue) { int ret; - struct list_head *plist, *phead, *ptmp; - u8 ac_index; + struct list_head *phead; + u8 ac_index; struct tx_servq *ptxservq; - struct pkt_attrib *pattrib; - struct xmit_frame *pxmitframe; - struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + struct pkt_attrib *pattrib; + struct xmit_frame *pxmitframe, *ptmp; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; phead = get_list_head(pframequeue); - - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, struct xmit_frame, list); - + list_for_each_entry_safe(pxmitframe, ptmp, phead, list) { ret = xmitframe_enqueue_for_sleeping_sta23a(padapter, pxmitframe); if (ret == true) { @@ -2124,17 +2112,14 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) { u8 update_mask = 0, wmmps_ac = 0; struct sta_info *psta_bmc; - struct list_head *plist, *phead, *ptmp; - struct xmit_frame *pxmitframe = NULL; + struct list_head *phead; + struct xmit_frame *pxmitframe = NULL, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; spin_lock_bh(&pxmitpriv->lock); - phead = get_list_head(&psta->sleep_q); - - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, struct xmit_frame, list); + list_for_each_entry_safe(pxmitframe, ptmp, phead, list) { list_del_init(&pxmitframe->list); switch (pxmitframe->attrib.priority) { @@ -2194,7 +2179,6 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) pstapriv->sta_dz_bitmap &= ~CHKBIT(psta->aid); } - /* spin_unlock_bh(&psta->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); @@ -2206,13 +2190,8 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ spin_lock_bh(&pxmitpriv->lock); - phead = get_list_head(&psta_bmc->sleep_q); - - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, struct xmit_frame, - list); - + list_for_each_entry_safe(pxmitframe, ptmp, phead, list) { list_del_init(&pxmitframe->list); psta_bmc->sleepq_len--; @@ -2232,7 +2211,6 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) /* update_BCNTIM(padapter); */ update_mask |= BIT(1); } - /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); } @@ -2245,19 +2223,15 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, struct sta_info *psta) { u8 wmmps_ac = 0; - struct list_head *plist, *phead, *ptmp; - struct xmit_frame *pxmitframe; + struct list_head *phead; + struct xmit_frame *pxmitframe, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; /* spin_lock_bh(&psta->sleep_q.lock); */ spin_lock_bh(&pxmitpriv->lock); - phead = get_list_head(&psta->sleep_q); - - list_for_each_safe(plist, ptmp, phead) { - pxmitframe = container_of(plist, struct xmit_frame, list); - + list_for_each_entry_safe(pxmitframe, ptmp, phead, list) { switch (pxmitframe->attrib.priority) { case 1: case 2: diff --git a/drivers/staging/rtl8723au/hal/HalHWImg8723A_RF.c b/drivers/staging/rtl8723au/hal/HalHWImg8723A_RF.c index dbf571e..286f3ea 100644 --- a/drivers/staging/rtl8723au/hal/HalHWImg8723A_RF.c +++ b/drivers/staging/rtl8723au/hal/HalHWImg8723A_RF.c @@ -215,7 +215,7 @@ void ODM_ReadAndConfig_RadioA_1T_8723A(struct dm_odm_t *pDM_Odm) u32 i = 0; u8 platform = 0x04; u8 board = pDM_Odm->BoardType; - u32 ArrayLen = sizeof(Array_RadioA_1T_8723A)/sizeof(u32); + u32 ArrayLen = ARRAY_SIZE(Array_RadioA_1T_8723A); u32 *Array = Array_RadioA_1T_8723A; hex += board; diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 530db57..9d7b11b 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -328,7 +328,7 @@ int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) if (trigger == C2H_EVT_HOST_CLOSE) goto exit; /* Not ready */ - else if (trigger != C2H_EVT_FW_CLOSE) + if (trigger != C2H_EVT_FW_CLOSE) goto clear_evt; /* Not a valid value */ c2h_evt = (struct c2h_evt_hdr *)buf; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 33eabf4..1688f66 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -77,8 +77,6 @@ if ((BTCoexDbgLevel == _bt_dbg_on_)) {\ #define PlatformZeroMemory(ptr, sz) memset(ptr, 0, sz) -#define PlatformProcessHCICommands(...) -#define PlatformTxBTQueuedPackets(...) #define PlatformIndicateBTACLData(...) (RT_STATUS_SUCCESS) #define GET_UNDECORATED_AVERAGE_RSSI(padapter) \ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 0ae2180..908b84c 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1270,18 +1270,14 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter) { - struct list_head *plist, *phead, *ptmp; + struct list_head *phead; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork; + struct wlan_network *pnetwork, *ptmp; spin_lock_bh(&pmlmepriv->scanned_queue.lock); - phead = get_list_head(queue); - - list_for_each_safe(plist, ptmp, phead) { - pnetwork = container_of(plist, struct wlan_network, list); - + list_for_each_entry_safe(pnetwork, ptmp, phead, list) { /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch23a @@ -1289,7 +1285,6 @@ void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter) pnetwork->network.DSConfig) >= 0) rtw_cfg80211_inform_bss(padapter, pnetwork); } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* call this after other things have been done */ @@ -2850,9 +2845,9 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, { const u8 *mac = params->mac; int ret = 0; - struct list_head *phead, *plist, *ptmp; + struct list_head *phead; u8 updated = 0; - struct sta_info *psta; + struct sta_info *psta, *ptmp; struct rtw_adapter *padapter = netdev_priv(ndev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; @@ -2881,13 +2876,9 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, return -EINVAL; spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - /* check asoc_queue */ - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) { if (ether_addr_equal(mac, psta->hwaddr)) { if (psta->dot8021xalg == 1 && psta->bpairwise_key_installed == false) { @@ -2912,7 +2903,6 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, } } } - spin_unlock_bh(&pstapriv->asoc_list_lock); associated_clients_update23a(padapter, updated); diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index 0cdaef0..cf4a506 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -210,22 +210,21 @@ exit: void rtl8723au_write_port_cancel(struct rtw_adapter *padapter) { struct xmit_buf *pxmitbuf; - struct list_head *plist; int j; DBG_8723A("%s\n", __func__); padapter->bWritePortCancel = true; - list_for_each(plist, &padapter->xmitpriv.xmitbuf_list) { - pxmitbuf = container_of(plist, struct xmit_buf, list2); + list_for_each_entry(pxmitbuf, &padapter->xmitpriv.xmitbuf_list, + list2) { for (j = 0; j < 8; j++) { if (pxmitbuf->pxmit_urb[j]) usb_kill_urb(pxmitbuf->pxmit_urb[j]); } } - list_for_each(plist, &padapter->xmitpriv.xmitextbuf_list) { - pxmitbuf = container_of(plist, struct xmit_buf, list2); + list_for_each_entry(pxmitbuf, &padapter->xmitpriv.xmitextbuf_list, + list2) { for (j = 0; j < 8; j++) { if (pxmitbuf->pxmit_urb[j]) usb_kill_urb(pxmitbuf->pxmit_urb[j]); diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index f2eb18e..f564a74 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * @@ -30,74 +31,76 @@ * Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* + * Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will - * pick up from where this one left off. */ + * pick up from where this one left off. + */ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, - unsigned int *offset, enum xfer_buf_dir dir) + unsigned int buflen, + struct scsi_cmnd *srb, + unsigned int *index, + unsigned int *offset, + enum xfer_buf_dir dir) { unsigned int cnt; - /* If not using scatter-gather, just transfer the data directly. - * Make certain it will fit in the available buffer space. */ + /* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count(srb) == 0) { + unsigned char *sgbuffer; + if (*offset >= scsi_bufflen(srb)) return 0; cnt = min(buflen, scsi_bufflen(srb) - *offset); + + sgbuffer = (unsigned char *)scsi_sglist(srb) + *offset; + if (dir == TO_XFER_BUF) - memcpy((unsigned char *) scsi_sglist(srb) + *offset, - buffer, cnt); + memcpy(sgbuffer, buffer, cnt); else - memcpy(buffer, (unsigned char *) scsi_sglist(srb) + - *offset, cnt); + memcpy(buffer, sgbuffer, cnt); *offset += cnt; - /* Using scatter-gather. We have to go through the list one entry + /* + * Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and - * each page has to be kmap()'ed separately. If the page is already - * in kernel-addressable memory then kmap() will return its address. - * If the page is not directly accessible -- such as a user buffer - * located in high memory -- then kmap() will map it to a temporary - * position in the kernel's virtual address space. */ + * each page has to be kmap()'ed separately. + */ } else { struct scatterlist *sg = - (struct scatterlist *) scsi_sglist(srb) + (struct scatterlist *)scsi_sglist(srb) + *index; - /* This loop handles a single s-g list entry, which may + /* + * This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update - * the *offset and *index values for the next loop. */ + * the *offset and *index values for the next loop. + */ cnt = 0; while (cnt < buflen && *index < scsi_sg_count(srb)) { struct page *page = sg_page(sg) + ((sg->offset + *offset) >> PAGE_SHIFT); - unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE-1); + unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE - 1); unsigned int sglen = sg->length - *offset; if (sglen > buflen - cnt) { - /* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; } else { - /* Transfer continues to next s-g entry */ *offset = 0; ++*index; ++sg; } - /* Transfer the data for all the pages in this - * s-g entry. For each page: call kmap(), do the - * transfer, and call kunmap() immediately after. */ while (sglen > 0) { unsigned int plen = min(sglen, (unsigned int) PAGE_SIZE - poff); @@ -122,10 +125,12 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* + * Store the contents of buffer into srb's transfer buffer and set the + * SCSI residue. + */ void rtsx_stor_set_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) + unsigned int buflen, struct scsi_cmnd *srb) { unsigned int index = 0, offset = 0; @@ -136,7 +141,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, } void rtsx_stor_get_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) + unsigned int buflen, struct scsi_cmnd *srb) { unsigned int index = 0, offset = 0; @@ -146,12 +151,12 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer, scsi_set_resid(srb, scsi_bufflen(srb) - buflen); } - /*********************************************************************** * Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* + * Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */ @@ -161,20 +166,21 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result = rtsx_scsi_handler(srb, chip); - /* if the command gets aborted by the higher layers, we need to - * short-circuit all other processing + /* + * if the command gets aborted by the higher layers, we need to + * short-circuit all other processing. */ if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) { dev_dbg(rtsx_dev(chip), "-- command was aborted\n"); srb->result = DID_ABORT << 16; - goto Handle_Errors; + goto handle_errors; } /* if there is a transport error, reset and don't auto-sense */ if (result == TRANSPORT_ERROR) { dev_dbg(rtsx_dev(chip), "-- transport indicates error, resetting\n"); srb->result = DID_ERROR << 16; - goto Handle_Errors; + goto handle_errors; } srb->result = SAM_STAT_GOOD; @@ -188,21 +194,18 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) /* set the result so the higher layers expect this data */ srb->result = SAM_STAT_CHECK_CONDITION; memcpy(srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN(srb)]), - sizeof(struct sense_data_t)); + (unsigned char *)&chip->sense_buffer[SCSI_LUN(srb)], + sizeof(struct sense_data_t)); } return; - /* Error and abort processing: try to resynchronize with the device - * by issuing a port reset. If that fails, try a class-specific - * device reset. */ -Handle_Errors: +handle_errors: return; } void rtsx_add_cmd(struct rtsx_chip *chip, - u8 cmd_type, u16 reg_addr, u8 mask, u8 data) + u8 cmd_type, u16 reg_addr, u8 mask, u8 data) { u32 *cb = (u32 *)(chip->host_cmds_ptr); u32 val = 0; @@ -321,9 +324,11 @@ static inline void rtsx_add_sg_tbl( } static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, - struct scatterlist *sg, int num_sg, unsigned int *index, - unsigned int *offset, int size, - enum dma_data_direction dma_dir, int timeout) + struct scatterlist *sg, int num_sg, + unsigned int *index, + unsigned int *offset, int size, + enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; @@ -334,7 +339,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, struct scatterlist *sg_ptr; u32 val = TRIG_DMA; - if ((sg == NULL) || (num_sg <= 0) || !offset || !index) + if (!sg || (num_sg <= 0) || !offset || !index) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -363,15 +368,16 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, spin_unlock_irq(&rtsx->reg_lock); - sg_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt = dma_map_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg; chip->sgi = 0; - /* Usually the next entry will be @sg@ + 1, but if this sg element + /* + * Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to - * the proper sg + * the proper sg. */ for (i = 0; i < *index; i++) sg_ptr = sg_next(sg_ptr); @@ -476,7 +482,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + dma_unmap_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -485,8 +491,9 @@ out: } static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, - struct scatterlist *sg, int num_sg, - enum dma_data_direction dma_dir, int timeout) + struct scatterlist *sg, int num_sg, + enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; @@ -496,7 +503,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, long timeleft; struct scatterlist *sg_ptr; - if ((sg == NULL) || (num_sg <= 0)) + if (!sg || (num_sg <= 0)) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -525,7 +532,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, spin_unlock_irq(&rtsx->reg_lock); - buf_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt = dma_map_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg; @@ -623,7 +630,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + dma_unmap_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -632,7 +639,8 @@ out: } static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, - size_t len, enum dma_data_direction dma_dir, int timeout) + size_t len, enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; @@ -642,7 +650,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, u32 val = 1 << 31; long timeleft; - if ((buf == NULL) || (len <= 0)) + if (!buf || (len <= 0)) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -706,7 +714,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_single(&(rtsx->pci->dev), addr, len, dma_dir); + dma_unmap_single(&rtsx->pci->dev, addr, len, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -715,9 +723,9 @@ out: } int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, - void *buf, size_t len, int use_sg, unsigned int *index, - unsigned int *offset, enum dma_data_direction dma_dir, - int timeout) + void *buf, size_t len, int use_sg, + unsigned int *index, unsigned int *offset, + enum dma_data_direction dma_dir, int timeout) { int err = 0; @@ -725,13 +733,16 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) return -EIO; - if (use_sg) - err = rtsx_transfer_sglist_adma_partial(chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int)len, dma_dir, timeout); - else + if (use_sg) { + struct scatterlist *sg = (struct scatterlist *)buf; + + err = rtsx_transfer_sglist_adma_partial(chip, card, sg, use_sg, + index, offset, (int)len, + dma_dir, timeout); + } else { err = rtsx_transfer_buf(chip, card, buf, len, dma_dir, timeout); + } if (err < 0) { if (RTSX_TST_DELINK(chip)) { RTSX_CLR_DELINK(chip); @@ -744,7 +755,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, } int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len, - int use_sg, enum dma_data_direction dma_dir, int timeout) + int use_sg, enum dma_data_direction dma_dir, int timeout) { int err = 0; @@ -756,8 +767,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len, if (use_sg) { err = rtsx_transfer_sglist_adma(chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); } else { err = rtsx_transfer_buf(chip, card, buf, len, dma_dir, timeout); } diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index e53a3d1..95f7cae 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -1,3 +1,4 @@ +#include <linux/kernel.h> #include <linux/sizes.h> #include "ddk750_help.h" @@ -5,6 +6,10 @@ #include "ddk750_chip.h" #include "ddk750_power.h" +/* n / d + 1 / 2 = (2n + d) / 2d */ +#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom))) +#define MHz(x) ((x) * 1000000) + logical_chip_type_t getChipType(void) { unsigned short physicalID; @@ -335,7 +340,7 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll) unsigned int diff; tmpClock = pll->inputFreq * M / N / X; - diff = absDiff(tmpClock, request_orig); + diff = abs(tmpClock - request_orig); if (diff < mini_diff) { pll->M = M; pll->N = N; diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h index 5be814e..009db92 100644 --- a/drivers/staging/sm750fb/ddk750_help.h +++ b/drivers/staging/sm750fb/ddk750_help.h @@ -6,7 +6,6 @@ #include <linux/ioport.h> #include <linux/io.h> #include <linux/uaccess.h> -#include "sm750_help.h" /* software control endianness */ #define PEEK32(addr) readl(addr + mmio750) diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 7e57b57..ccb4e06 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -25,13 +25,12 @@ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, Note that normal SM750/SM718 only use those two register for auto-centering mode. */ - POKE32(CRT_AUTO_CENTERING_TL, - FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, TOP, 0) - | FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, LEFT, 0)); + POKE32(CRT_AUTO_CENTERING_TL, 0); POKE32(CRT_AUTO_CENTERING_BR, - FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y - 1) - | FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x - 1)); + (((y - 1) << CRT_AUTO_CENTERING_BR_BOTTOM_SHIFT) & + CRT_AUTO_CENTERING_BR_BOTTOM_MASK) | + ((x - 1) & CRT_AUTO_CENTERING_BR_RIGHT_MASK)); /* Assume common fields in dispControl have been properly set before calling this function. @@ -84,20 +83,32 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll) /* programe secondary pixel clock */ POKE32(CRT_PLL_CTRL, formatPllReg(pll)); POKE32(CRT_HORIZONTAL_TOTAL, - FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1) - | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1)); + (((pModeParam->horizontal_total - 1) << + CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) & + CRT_HORIZONTAL_TOTAL_TOTAL_MASK) | + ((pModeParam->horizontal_display_end - 1) & + CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK)); POKE32(CRT_HORIZONTAL_SYNC, - FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width) - | FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1)); + ((pModeParam->horizontal_sync_width << + CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) & + CRT_HORIZONTAL_SYNC_WIDTH_MASK) | + ((pModeParam->horizontal_sync_start - 1) & + CRT_HORIZONTAL_SYNC_START_MASK)); POKE32(CRT_VERTICAL_TOTAL, - FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1) - | FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1)); + (((pModeParam->vertical_total - 1) << + CRT_VERTICAL_TOTAL_TOTAL_SHIFT) & + CRT_VERTICAL_TOTAL_TOTAL_MASK) | + ((pModeParam->vertical_display_end - 1) & + CRT_VERTICAL_TOTAL_DISPLAY_END_MASK)); POKE32(CRT_VERTICAL_SYNC, - FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height) - | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); + ((pModeParam->vertical_sync_height << + CRT_VERTICAL_SYNC_HEIGHT_SHIFT) & + CRT_VERTICAL_SYNC_HEIGHT_MASK) | + ((pModeParam->vertical_sync_start - 1) & + CRT_VERTICAL_SYNC_START_MASK)); tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE; @@ -130,16 +141,25 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll) POKE32(PANEL_HORIZONTAL_TOTAL, reg); POKE32(PANEL_HORIZONTAL_SYNC, - FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width) - | FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1)); + ((pModeParam->horizontal_sync_width << + PANEL_HORIZONTAL_SYNC_WIDTH_SHIFT) & + PANEL_HORIZONTAL_SYNC_WIDTH_MASK) | + ((pModeParam->horizontal_sync_start - 1) & + PANEL_HORIZONTAL_SYNC_START_MASK)); POKE32(PANEL_VERTICAL_TOTAL, - FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1) - | FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1)); + (((pModeParam->vertical_total - 1) << + PANEL_VERTICAL_TOTAL_TOTAL_SHIFT) & + PANEL_VERTICAL_TOTAL_TOTAL_MASK) | + ((pModeParam->vertical_display_end - 1) & + PANEL_VERTICAL_TOTAL_DISPLAY_END_MASK)); POKE32(PANEL_VERTICAL_SYNC, - FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height) - | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1)); + ((pModeParam->vertical_sync_height << + PANEL_VERTICAL_SYNC_HEIGHT_SHIFT) & + PANEL_VERTICAL_SYNC_HEIGHT_MASK) | + ((pModeParam->vertical_sync_start - 1) & + PANEL_VERTICAL_SYNC_START_MASK)); tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE; if (pModeParam->vertical_sync_polarity) diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h index 4702897..9552479 100644 --- a/drivers/staging/sm750fb/ddk750_reg.h +++ b/drivers/staging/sm750fb/ddk750_reg.h @@ -109,286 +109,187 @@ #define GPIO_MUX_0 BIT(0) #define LOCALMEM_ARBITRATION 0x00000C -#define LOCALMEM_ARBITRATION_ROTATE 28:28 -#define LOCALMEM_ARBITRATION_ROTATE_OFF 0 -#define LOCALMEM_ARBITRATION_ROTATE_ON 1 -#define LOCALMEM_ARBITRATION_VGA 26:24 -#define LOCALMEM_ARBITRATION_VGA_OFF 0 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_VGA_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_DMA 22:20 -#define LOCALMEM_ARBITRATION_DMA_OFF 0 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_DMA_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_ZVPORT1 18:16 -#define LOCALMEM_ARBITRATION_ZVPORT1_OFF 0 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_ZVPORT0 14:12 -#define LOCALMEM_ARBITRATION_ZVPORT0_OFF 0 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_VIDEO 10:8 -#define LOCALMEM_ARBITRATION_VIDEO_OFF 0 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_PANEL 6:4 -#define LOCALMEM_ARBITRATION_PANEL_OFF 0 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_7 7 -#define LOCALMEM_ARBITRATION_CRT 2:0 -#define LOCALMEM_ARBITRATION_CRT_OFF 0 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_1 1 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_2 2 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_3 3 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_4 4 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_5 5 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_6 6 -#define LOCALMEM_ARBITRATION_CRT_PRIORITY_7 7 +#define LOCALMEM_ARBITRATION_ROTATE BIT(28) +#define LOCALMEM_ARBITRATION_VGA_MASK (0x7 << 24) +#define LOCALMEM_ARBITRATION_VGA_OFF (0x0 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_1 (0x1 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_2 (0x2 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_3 (0x3 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_4 (0x4 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_5 (0x5 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_6 (0x6 << 24) +#define LOCALMEM_ARBITRATION_VGA_PRIORITY_7 (0x7 << 24) +#define LOCALMEM_ARBITRATION_DMA_MASK (0x7 << 20) +#define LOCALMEM_ARBITRATION_DMA_OFF (0x0 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_1 (0x1 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_2 (0x2 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_3 (0x3 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_4 (0x4 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_5 (0x5 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_6 (0x6 << 20) +#define LOCALMEM_ARBITRATION_DMA_PRIORITY_7 (0x7 << 20) +#define LOCALMEM_ARBITRATION_ZVPORT1_MASK (0x7 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_OFF (0x0 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_1 (0x1 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_2 (0x2 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_3 (0x3 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_4 (0x4 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_5 (0x5 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_6 (0x6 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_7 (0x7 << 16) +#define LOCALMEM_ARBITRATION_ZVPORT0_MASK (0x7 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_OFF (0x0 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_1 (0x1 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_2 (0x2 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_3 (0x3 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_4 (0x4 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_5 (0x5 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_6 (0x6 << 12) +#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_7 (0x7 << 12) +#define LOCALMEM_ARBITRATION_VIDEO_MASK (0x7 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_OFF (0x0 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_1 (0x1 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_2 (0x2 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_3 (0x3 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_4 (0x4 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_5 (0x5 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_6 (0x6 << 8) +#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_7 (0x7 << 8) +#define LOCALMEM_ARBITRATION_PANEL_MASK (0x7 << 4) +#define LOCALMEM_ARBITRATION_PANEL_OFF (0x0 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_1 (0x1 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_2 (0x2 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_3 (0x3 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_4 (0x4 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_5 (0x5 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_6 (0x6 << 4) +#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_7 (0x7 << 4) +#define LOCALMEM_ARBITRATION_CRT_MASK 0x7 +#define LOCALMEM_ARBITRATION_CRT_OFF 0x0 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_1 0x1 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_2 0x2 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_3 0x3 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_4 0x4 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_5 0x5 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_6 0x6 +#define LOCALMEM_ARBITRATION_CRT_PRIORITY_7 0x7 #define PCIMEM_ARBITRATION 0x000010 -#define PCIMEM_ARBITRATION_ROTATE 28:28 -#define PCIMEM_ARBITRATION_ROTATE_OFF 0 -#define PCIMEM_ARBITRATION_ROTATE_ON 1 -#define PCIMEM_ARBITRATION_VGA 26:24 -#define PCIMEM_ARBITRATION_VGA_OFF 0 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_VGA_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_DMA 22:20 -#define PCIMEM_ARBITRATION_DMA_OFF 0 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_DMA_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_ZVPORT1 18:16 -#define PCIMEM_ARBITRATION_ZVPORT1_OFF 0 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_ZVPORT0 14:12 -#define PCIMEM_ARBITRATION_ZVPORT0_OFF 0 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_VIDEO 10:8 -#define PCIMEM_ARBITRATION_VIDEO_OFF 0 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_PANEL 6:4 -#define PCIMEM_ARBITRATION_PANEL_OFF 0 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_PANEL_PRIORITY_7 7 -#define PCIMEM_ARBITRATION_CRT 2:0 -#define PCIMEM_ARBITRATION_CRT_OFF 0 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_1 1 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_2 2 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_3 3 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_4 4 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_5 5 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_6 6 -#define PCIMEM_ARBITRATION_CRT_PRIORITY_7 7 +#define PCIMEM_ARBITRATION_ROTATE BIT(28) +#define PCIMEM_ARBITRATION_VGA_MASK (0x7 << 24) +#define PCIMEM_ARBITRATION_VGA_OFF (0x0 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_1 (0x1 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_2 (0x2 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_3 (0x3 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_4 (0x4 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_5 (0x5 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_6 (0x6 << 24) +#define PCIMEM_ARBITRATION_VGA_PRIORITY_7 (0x7 << 24) +#define PCIMEM_ARBITRATION_DMA_MASK (0x7 << 20) +#define PCIMEM_ARBITRATION_DMA_OFF (0x0 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_1 (0x1 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_2 (0x2 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_3 (0x3 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_4 (0x4 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_5 (0x5 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_6 (0x6 << 20) +#define PCIMEM_ARBITRATION_DMA_PRIORITY_7 (0x7 << 20) +#define PCIMEM_ARBITRATION_ZVPORT1_MASK (0x7 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_OFF (0x0 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_1 (0x1 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_2 (0x2 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_3 (0x3 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_4 (0x4 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_5 (0x5 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_6 (0x6 << 16) +#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_7 (0x7 << 16) +#define PCIMEM_ARBITRATION_ZVPORT0_MASK (0x7 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_OFF (0x0 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_1 (0x1 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_2 (0x2 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_3 (0x3 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_4 (0x4 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_5 (0x5 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_6 (0x6 << 12) +#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_7 (0x7 << 12) +#define PCIMEM_ARBITRATION_VIDEO_MASK (0x7 << 8) +#define PCIMEM_ARBITRATION_VIDEO_OFF (0x0 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_1 (0x1 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_2 (0x2 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_3 (0x3 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_4 (0x4 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_5 (0x5 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_6 (0x6 << 8) +#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_7 (0x7 << 8) +#define PCIMEM_ARBITRATION_PANEL_MASK (0x7 << 4) +#define PCIMEM_ARBITRATION_PANEL_OFF (0x0 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_1 (0x1 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_2 (0x2 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_3 (0x3 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_4 (0x4 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_5 (0x5 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_6 (0x6 << 4) +#define PCIMEM_ARBITRATION_PANEL_PRIORITY_7 (0x7 << 4) +#define PCIMEM_ARBITRATION_CRT_MASK 0x7 +#define PCIMEM_ARBITRATION_CRT_OFF 0x0 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_1 0x1 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_2 0x2 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_3 0x3 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_4 0x4 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_5 0x5 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_6 0x6 +#define PCIMEM_ARBITRATION_CRT_PRIORITY_7 0x7 #define RAW_INT 0x000020 -#define RAW_INT_ZVPORT1_VSYNC 4:4 -#define RAW_INT_ZVPORT1_VSYNC_INACTIVE 0 -#define RAW_INT_ZVPORT1_VSYNC_ACTIVE 1 -#define RAW_INT_ZVPORT1_VSYNC_CLEAR 1 -#define RAW_INT_ZVPORT0_VSYNC 3:3 -#define RAW_INT_ZVPORT0_VSYNC_INACTIVE 0 -#define RAW_INT_ZVPORT0_VSYNC_ACTIVE 1 -#define RAW_INT_ZVPORT0_VSYNC_CLEAR 1 -#define RAW_INT_CRT_VSYNC 2:2 -#define RAW_INT_CRT_VSYNC_INACTIVE 0 -#define RAW_INT_CRT_VSYNC_ACTIVE 1 -#define RAW_INT_CRT_VSYNC_CLEAR 1 -#define RAW_INT_PANEL_VSYNC 1:1 -#define RAW_INT_PANEL_VSYNC_INACTIVE 0 -#define RAW_INT_PANEL_VSYNC_ACTIVE 1 -#define RAW_INT_PANEL_VSYNC_CLEAR 1 -#define RAW_INT_VGA_VSYNC 0:0 -#define RAW_INT_VGA_VSYNC_INACTIVE 0 -#define RAW_INT_VGA_VSYNC_ACTIVE 1 -#define RAW_INT_VGA_VSYNC_CLEAR 1 +#define RAW_INT_ZVPORT1_VSYNC BIT(4) +#define RAW_INT_ZVPORT0_VSYNC BIT(3) +#define RAW_INT_CRT_VSYNC BIT(2) +#define RAW_INT_PANEL_VSYNC BIT(1) +#define RAW_INT_VGA_VSYNC BIT(0) #define INT_STATUS 0x000024 -#define INT_STATUS_GPIO31 31:31 -#define INT_STATUS_GPIO31_INACTIVE 0 -#define INT_STATUS_GPIO31_ACTIVE 1 -#define INT_STATUS_GPIO30 30:30 -#define INT_STATUS_GPIO30_INACTIVE 0 -#define INT_STATUS_GPIO30_ACTIVE 1 -#define INT_STATUS_GPIO29 29:29 -#define INT_STATUS_GPIO29_INACTIVE 0 -#define INT_STATUS_GPIO29_ACTIVE 1 -#define INT_STATUS_GPIO28 28:28 -#define INT_STATUS_GPIO28_INACTIVE 0 -#define INT_STATUS_GPIO28_ACTIVE 1 -#define INT_STATUS_GPIO27 27:27 -#define INT_STATUS_GPIO27_INACTIVE 0 -#define INT_STATUS_GPIO27_ACTIVE 1 -#define INT_STATUS_GPIO26 26:26 -#define INT_STATUS_GPIO26_INACTIVE 0 -#define INT_STATUS_GPIO26_ACTIVE 1 -#define INT_STATUS_GPIO25 25:25 -#define INT_STATUS_GPIO25_INACTIVE 0 -#define INT_STATUS_GPIO25_ACTIVE 1 -#define INT_STATUS_I2C 12:12 -#define INT_STATUS_I2C_INACTIVE 0 -#define INT_STATUS_I2C_ACTIVE 1 -#define INT_STATUS_PWM 11:11 -#define INT_STATUS_PWM_INACTIVE 0 -#define INT_STATUS_PWM_ACTIVE 1 -#define INT_STATUS_DMA1 10:10 -#define INT_STATUS_DMA1_INACTIVE 0 -#define INT_STATUS_DMA1_ACTIVE 1 -#define INT_STATUS_DMA0 9:9 -#define INT_STATUS_DMA0_INACTIVE 0 -#define INT_STATUS_DMA0_ACTIVE 1 -#define INT_STATUS_PCI 8:8 -#define INT_STATUS_PCI_INACTIVE 0 -#define INT_STATUS_PCI_ACTIVE 1 -#define INT_STATUS_SSP1 7:7 -#define INT_STATUS_SSP1_INACTIVE 0 -#define INT_STATUS_SSP1_ACTIVE 1 -#define INT_STATUS_SSP0 6:6 -#define INT_STATUS_SSP0_INACTIVE 0 -#define INT_STATUS_SSP0_ACTIVE 1 -#define INT_STATUS_DE 5:5 -#define INT_STATUS_DE_INACTIVE 0 -#define INT_STATUS_DE_ACTIVE 1 -#define INT_STATUS_ZVPORT1_VSYNC 4:4 -#define INT_STATUS_ZVPORT1_VSYNC_INACTIVE 0 -#define INT_STATUS_ZVPORT1_VSYNC_ACTIVE 1 -#define INT_STATUS_ZVPORT0_VSYNC 3:3 -#define INT_STATUS_ZVPORT0_VSYNC_INACTIVE 0 -#define INT_STATUS_ZVPORT0_VSYNC_ACTIVE 1 -#define INT_STATUS_CRT_VSYNC 2:2 -#define INT_STATUS_CRT_VSYNC_INACTIVE 0 -#define INT_STATUS_CRT_VSYNC_ACTIVE 1 -#define INT_STATUS_PANEL_VSYNC 1:1 -#define INT_STATUS_PANEL_VSYNC_INACTIVE 0 -#define INT_STATUS_PANEL_VSYNC_ACTIVE 1 -#define INT_STATUS_VGA_VSYNC 0:0 -#define INT_STATUS_VGA_VSYNC_INACTIVE 0 -#define INT_STATUS_VGA_VSYNC_ACTIVE 1 +#define INT_STATUS_GPIO31 BIT(31) +#define INT_STATUS_GPIO30 BIT(30) +#define INT_STATUS_GPIO29 BIT(29) +#define INT_STATUS_GPIO28 BIT(28) +#define INT_STATUS_GPIO27 BIT(27) +#define INT_STATUS_GPIO26 BIT(26) +#define INT_STATUS_GPIO25 BIT(25) +#define INT_STATUS_I2C BIT(12) +#define INT_STATUS_PWM BIT(11) +#define INT_STATUS_DMA1 BIT(10) +#define INT_STATUS_DMA0 BIT(9) +#define INT_STATUS_PCI BIT(8) +#define INT_STATUS_SSP1 BIT(7) +#define INT_STATUS_SSP0 BIT(6) +#define INT_STATUS_DE BIT(5) +#define INT_STATUS_ZVPORT1_VSYNC BIT(4) +#define INT_STATUS_ZVPORT0_VSYNC BIT(3) +#define INT_STATUS_CRT_VSYNC BIT(2) +#define INT_STATUS_PANEL_VSYNC BIT(1) +#define INT_STATUS_VGA_VSYNC BIT(0) #define INT_MASK 0x000028 -#define INT_MASK_GPIO31 31:31 -#define INT_MASK_GPIO31_DISABLE 0 -#define INT_MASK_GPIO31_ENABLE 1 -#define INT_MASK_GPIO30 30:30 -#define INT_MASK_GPIO30_DISABLE 0 -#define INT_MASK_GPIO30_ENABLE 1 -#define INT_MASK_GPIO29 29:29 -#define INT_MASK_GPIO29_DISABLE 0 -#define INT_MASK_GPIO29_ENABLE 1 -#define INT_MASK_GPIO28 28:28 -#define INT_MASK_GPIO28_DISABLE 0 -#define INT_MASK_GPIO28_ENABLE 1 -#define INT_MASK_GPIO27 27:27 -#define INT_MASK_GPIO27_DISABLE 0 -#define INT_MASK_GPIO27_ENABLE 1 -#define INT_MASK_GPIO26 26:26 -#define INT_MASK_GPIO26_DISABLE 0 -#define INT_MASK_GPIO26_ENABLE 1 -#define INT_MASK_GPIO25 25:25 -#define INT_MASK_GPIO25_DISABLE 0 -#define INT_MASK_GPIO25_ENABLE 1 -#define INT_MASK_I2C 12:12 -#define INT_MASK_I2C_DISABLE 0 -#define INT_MASK_I2C_ENABLE 1 -#define INT_MASK_PWM 11:11 -#define INT_MASK_PWM_DISABLE 0 -#define INT_MASK_PWM_ENABLE 1 -#define INT_MASK_DMA1 10:10 -#define INT_MASK_DMA1_DISABLE 0 -#define INT_MASK_DMA1_ENABLE 1 -#define INT_MASK_DMA 9:9 -#define INT_MASK_DMA_DISABLE 0 -#define INT_MASK_DMA_ENABLE 1 -#define INT_MASK_PCI 8:8 -#define INT_MASK_PCI_DISABLE 0 -#define INT_MASK_PCI_ENABLE 1 -#define INT_MASK_SSP1 7:7 -#define INT_MASK_SSP1_DISABLE 0 -#define INT_MASK_SSP1_ENABLE 1 -#define INT_MASK_SSP0 6:6 -#define INT_MASK_SSP0_DISABLE 0 -#define INT_MASK_SSP0_ENABLE 1 -#define INT_MASK_DE 5:5 -#define INT_MASK_DE_DISABLE 0 -#define INT_MASK_DE_ENABLE 1 -#define INT_MASK_ZVPORT1_VSYNC 4:4 -#define INT_MASK_ZVPORT1_VSYNC_DISABLE 0 -#define INT_MASK_ZVPORT1_VSYNC_ENABLE 1 -#define INT_MASK_ZVPORT0_VSYNC 3:3 -#define INT_MASK_ZVPORT0_VSYNC_DISABLE 0 -#define INT_MASK_ZVPORT0_VSYNC_ENABLE 1 -#define INT_MASK_CRT_VSYNC 2:2 -#define INT_MASK_CRT_VSYNC_DISABLE 0 -#define INT_MASK_CRT_VSYNC_ENABLE 1 -#define INT_MASK_PANEL_VSYNC 1:1 -#define INT_MASK_PANEL_VSYNC_DISABLE 0 -#define INT_MASK_PANEL_VSYNC_ENABLE 1 -#define INT_MASK_VGA_VSYNC 0:0 -#define INT_MASK_VGA_VSYNC_DISABLE 0 -#define INT_MASK_VGA_VSYNC_ENABLE 1 +#define INT_MASK_GPIO31 BIT(31) +#define INT_MASK_GPIO30 BIT(30) +#define INT_MASK_GPIO29 BIT(29) +#define INT_MASK_GPIO28 BIT(28) +#define INT_MASK_GPIO27 BIT(27) +#define INT_MASK_GPIO26 BIT(26) +#define INT_MASK_GPIO25 BIT(25) +#define INT_MASK_I2C BIT(12) +#define INT_MASK_PWM BIT(11) +#define INT_MASK_DMA1 BIT(10) +#define INT_MASK_DMA BIT(9) +#define INT_MASK_PCI BIT(8) +#define INT_MASK_SSP1 BIT(7) +#define INT_MASK_SSP0 BIT(6) +#define INT_MASK_DE BIT(5) +#define INT_MASK_ZVPORT1_VSYNC BIT(4) +#define INT_MASK_ZVPORT0_VSYNC BIT(3) +#define INT_MASK_CRT_VSYNC BIT(2) +#define INT_MASK_PANEL_VSYNC BIT(1) +#define INT_MASK_VGA_VSYNC BIT(0) #define CURRENT_GATE 0x000040 #define CURRENT_GATE_MCLK_MASK (0x3 << 14) @@ -451,49 +352,27 @@ #define MODE0_GATE_DMA BIT(0) #define MODE1_GATE 0x000048 -#define MODE1_GATE_MCLK 15:14 -#define MODE1_GATE_MCLK_112MHZ 0 -#define MODE1_GATE_MCLK_84MHZ 1 -#define MODE1_GATE_MCLK_56MHZ 2 -#define MODE1_GATE_MCLK_42MHZ 3 -#define MODE1_GATE_M2XCLK 13:12 -#define MODE1_GATE_M2XCLK_336MHZ 0 -#define MODE1_GATE_M2XCLK_168MHZ 1 -#define MODE1_GATE_M2XCLK_112MHZ 2 -#define MODE1_GATE_M2XCLK_84MHZ 3 -#define MODE1_GATE_VGA 10:10 -#define MODE1_GATE_VGA_OFF 0 -#define MODE1_GATE_VGA_ON 1 -#define MODE1_GATE_PWM 9:9 -#define MODE1_GATE_PWM_OFF 0 -#define MODE1_GATE_PWM_ON 1 -#define MODE1_GATE_I2C 8:8 -#define MODE1_GATE_I2C_OFF 0 -#define MODE1_GATE_I2C_ON 1 -#define MODE1_GATE_SSP 7:7 -#define MODE1_GATE_SSP_OFF 0 -#define MODE1_GATE_SSP_ON 1 -#define MODE1_GATE_GPIO 6:6 -#define MODE1_GATE_GPIO_OFF 0 -#define MODE1_GATE_GPIO_ON 1 -#define MODE1_GATE_ZVPORT 5:5 -#define MODE1_GATE_ZVPORT_OFF 0 -#define MODE1_GATE_ZVPORT_ON 1 -#define MODE1_GATE_CSC 4:4 -#define MODE1_GATE_CSC_OFF 0 -#define MODE1_GATE_CSC_ON 1 -#define MODE1_GATE_DE 3:3 -#define MODE1_GATE_DE_OFF 0 -#define MODE1_GATE_DE_ON 1 -#define MODE1_GATE_DISPLAY 2:2 -#define MODE1_GATE_DISPLAY_OFF 0 -#define MODE1_GATE_DISPLAY_ON 1 -#define MODE1_GATE_LOCALMEM 1:1 -#define MODE1_GATE_LOCALMEM_OFF 0 -#define MODE1_GATE_LOCALMEM_ON 1 -#define MODE1_GATE_DMA 0:0 -#define MODE1_GATE_DMA_OFF 0 -#define MODE1_GATE_DMA_ON 1 +#define MODE1_GATE_MCLK_MASK (0x3 << 14) +#define MODE1_GATE_MCLK_112MHZ (0x0 << 14) +#define MODE1_GATE_MCLK_84MHZ (0x1 << 14) +#define MODE1_GATE_MCLK_56MHZ (0x2 << 14) +#define MODE1_GATE_MCLK_42MHZ (0x3 << 14) +#define MODE1_GATE_M2XCLK_MASK (0x3 << 12) +#define MODE1_GATE_M2XCLK_336MHZ (0x0 << 12) +#define MODE1_GATE_M2XCLK_168MHZ (0x1 << 12) +#define MODE1_GATE_M2XCLK_112MHZ (0x2 << 12) +#define MODE1_GATE_M2XCLK_84MHZ (0x3 << 12) +#define MODE1_GATE_VGA BIT(10) +#define MODE1_GATE_PWM BIT(9) +#define MODE1_GATE_I2C BIT(8) +#define MODE1_GATE_SSP BIT(7) +#define MODE1_GATE_GPIO BIT(6) +#define MODE1_GATE_ZVPORT BIT(5) +#define MODE1_GATE_CSC BIT(4) +#define MODE1_GATE_DE BIT(3) +#define MODE1_GATE_DISPLAY BIT(2) +#define MODE1_GATE_LOCALMEM BIT(1) +#define MODE1_GATE_DMA BIT(0) #define POWER_MODE_CTRL 0x00004C #ifdef VALIDATION_CHIP @@ -507,14 +386,14 @@ #define POWER_MODE_CTRL_MODE_SLEEP (0x2 << 0) #define PCI_MASTER_BASE 0x000050 -#define PCI_MASTER_BASE_ADDRESS 7:0 +#define PCI_MASTER_BASE_ADDRESS_MASK 0xff #define DEVICE_ID 0x000054 -#define DEVICE_ID_DEVICE_ID 31:16 -#define DEVICE_ID_REVISION_ID 7:0 +#define DEVICE_ID_DEVICE_ID_MASK (0xffff << 16) +#define DEVICE_ID_REVISION_ID_MASK 0xff #define PLL_CLK_COUNT 0x000058 -#define PLL_CLK_COUNT_COUNTER 15:0 +#define PLL_CLK_COUNT_COUNTER_MASK 0xffff #define PANEL_PLL_CTRL 0x00005C #define PLL_CTRL_BYPASS BIT(18) @@ -554,231 +433,104 @@ #endif #define GPIO_DATA 0x010000 -#define GPIO_DATA_31 31:31 -#define GPIO_DATA_30 30:30 -#define GPIO_DATA_29 29:29 -#define GPIO_DATA_28 28:28 -#define GPIO_DATA_27 27:27 -#define GPIO_DATA_26 26:26 -#define GPIO_DATA_25 25:25 -#define GPIO_DATA_24 24:24 -#define GPIO_DATA_23 23:23 -#define GPIO_DATA_22 22:22 -#define GPIO_DATA_21 21:21 -#define GPIO_DATA_20 20:20 -#define GPIO_DATA_19 19:19 -#define GPIO_DATA_18 18:18 -#define GPIO_DATA_17 17:17 -#define GPIO_DATA_16 16:16 -#define GPIO_DATA_15 15:15 -#define GPIO_DATA_14 14:14 -#define GPIO_DATA_13 13:13 -#define GPIO_DATA_12 12:12 -#define GPIO_DATA_11 11:11 -#define GPIO_DATA_10 10:10 -#define GPIO_DATA_9 9:9 -#define GPIO_DATA_8 8:8 -#define GPIO_DATA_7 7:7 -#define GPIO_DATA_6 6:6 -#define GPIO_DATA_5 5:5 -#define GPIO_DATA_4 4:4 -#define GPIO_DATA_3 3:3 -#define GPIO_DATA_2 2:2 -#define GPIO_DATA_1 1:1 -#define GPIO_DATA_0 0:0 +#define GPIO_DATA_31 BIT(31) +#define GPIO_DATA_30 BIT(30) +#define GPIO_DATA_29 BIT(29) +#define GPIO_DATA_28 BIT(28) +#define GPIO_DATA_27 BIT(27) +#define GPIO_DATA_26 BIT(26) +#define GPIO_DATA_25 BIT(25) +#define GPIO_DATA_24 BIT(24) +#define GPIO_DATA_23 BIT(23) +#define GPIO_DATA_22 BIT(22) +#define GPIO_DATA_21 BIT(21) +#define GPIO_DATA_20 BIT(20) +#define GPIO_DATA_19 BIT(19) +#define GPIO_DATA_18 BIT(18) +#define GPIO_DATA_17 BIT(17) +#define GPIO_DATA_16 BIT(16) +#define GPIO_DATA_15 BIT(15) +#define GPIO_DATA_14 BIT(14) +#define GPIO_DATA_13 BIT(13) +#define GPIO_DATA_12 BIT(12) +#define GPIO_DATA_11 BIT(11) +#define GPIO_DATA_10 BIT(10) +#define GPIO_DATA_9 BIT(9) +#define GPIO_DATA_8 BIT(8) +#define GPIO_DATA_7 BIT(7) +#define GPIO_DATA_6 BIT(6) +#define GPIO_DATA_5 BIT(5) +#define GPIO_DATA_4 BIT(4) +#define GPIO_DATA_3 BIT(3) +#define GPIO_DATA_2 BIT(2) +#define GPIO_DATA_1 BIT(1) +#define GPIO_DATA_0 BIT(0) #define GPIO_DATA_DIRECTION 0x010004 -#define GPIO_DATA_DIRECTION_31 31:31 -#define GPIO_DATA_DIRECTION_31_INPUT 0 -#define GPIO_DATA_DIRECTION_31_OUTPUT 1 -#define GPIO_DATA_DIRECTION_30 30:30 -#define GPIO_DATA_DIRECTION_30_INPUT 0 -#define GPIO_DATA_DIRECTION_30_OUTPUT 1 -#define GPIO_DATA_DIRECTION_29 29:29 -#define GPIO_DATA_DIRECTION_29_INPUT 0 -#define GPIO_DATA_DIRECTION_29_OUTPUT 1 -#define GPIO_DATA_DIRECTION_28 28:28 -#define GPIO_DATA_DIRECTION_28_INPUT 0 -#define GPIO_DATA_DIRECTION_28_OUTPUT 1 -#define GPIO_DATA_DIRECTION_27 27:27 -#define GPIO_DATA_DIRECTION_27_INPUT 0 -#define GPIO_DATA_DIRECTION_27_OUTPUT 1 -#define GPIO_DATA_DIRECTION_26 26:26 -#define GPIO_DATA_DIRECTION_26_INPUT 0 -#define GPIO_DATA_DIRECTION_26_OUTPUT 1 -#define GPIO_DATA_DIRECTION_25 25:25 -#define GPIO_DATA_DIRECTION_25_INPUT 0 -#define GPIO_DATA_DIRECTION_25_OUTPUT 1 -#define GPIO_DATA_DIRECTION_24 24:24 -#define GPIO_DATA_DIRECTION_24_INPUT 0 -#define GPIO_DATA_DIRECTION_24_OUTPUT 1 -#define GPIO_DATA_DIRECTION_23 23:23 -#define GPIO_DATA_DIRECTION_23_INPUT 0 -#define GPIO_DATA_DIRECTION_23_OUTPUT 1 -#define GPIO_DATA_DIRECTION_22 22:22 -#define GPIO_DATA_DIRECTION_22_INPUT 0 -#define GPIO_DATA_DIRECTION_22_OUTPUT 1 -#define GPIO_DATA_DIRECTION_21 21:21 -#define GPIO_DATA_DIRECTION_21_INPUT 0 -#define GPIO_DATA_DIRECTION_21_OUTPUT 1 -#define GPIO_DATA_DIRECTION_20 20:20 -#define GPIO_DATA_DIRECTION_20_INPUT 0 -#define GPIO_DATA_DIRECTION_20_OUTPUT 1 -#define GPIO_DATA_DIRECTION_19 19:19 -#define GPIO_DATA_DIRECTION_19_INPUT 0 -#define GPIO_DATA_DIRECTION_19_OUTPUT 1 -#define GPIO_DATA_DIRECTION_18 18:18 -#define GPIO_DATA_DIRECTION_18_INPUT 0 -#define GPIO_DATA_DIRECTION_18_OUTPUT 1 -#define GPIO_DATA_DIRECTION_17 17:17 -#define GPIO_DATA_DIRECTION_17_INPUT 0 -#define GPIO_DATA_DIRECTION_17_OUTPUT 1 -#define GPIO_DATA_DIRECTION_16 16:16 -#define GPIO_DATA_DIRECTION_16_INPUT 0 -#define GPIO_DATA_DIRECTION_16_OUTPUT 1 -#define GPIO_DATA_DIRECTION_15 15:15 -#define GPIO_DATA_DIRECTION_15_INPUT 0 -#define GPIO_DATA_DIRECTION_15_OUTPUT 1 -#define GPIO_DATA_DIRECTION_14 14:14 -#define GPIO_DATA_DIRECTION_14_INPUT 0 -#define GPIO_DATA_DIRECTION_14_OUTPUT 1 -#define GPIO_DATA_DIRECTION_13 13:13 -#define GPIO_DATA_DIRECTION_13_INPUT 0 -#define GPIO_DATA_DIRECTION_13_OUTPUT 1 -#define GPIO_DATA_DIRECTION_12 12:12 -#define GPIO_DATA_DIRECTION_12_INPUT 0 -#define GPIO_DATA_DIRECTION_12_OUTPUT 1 -#define GPIO_DATA_DIRECTION_11 11:11 -#define GPIO_DATA_DIRECTION_11_INPUT 0 -#define GPIO_DATA_DIRECTION_11_OUTPUT 1 -#define GPIO_DATA_DIRECTION_10 10:10 -#define GPIO_DATA_DIRECTION_10_INPUT 0 -#define GPIO_DATA_DIRECTION_10_OUTPUT 1 -#define GPIO_DATA_DIRECTION_9 9:9 -#define GPIO_DATA_DIRECTION_9_INPUT 0 -#define GPIO_DATA_DIRECTION_9_OUTPUT 1 -#define GPIO_DATA_DIRECTION_8 8:8 -#define GPIO_DATA_DIRECTION_8_INPUT 0 -#define GPIO_DATA_DIRECTION_8_OUTPUT 1 -#define GPIO_DATA_DIRECTION_7 7:7 -#define GPIO_DATA_DIRECTION_7_INPUT 0 -#define GPIO_DATA_DIRECTION_7_OUTPUT 1 -#define GPIO_DATA_DIRECTION_6 6:6 -#define GPIO_DATA_DIRECTION_6_INPUT 0 -#define GPIO_DATA_DIRECTION_6_OUTPUT 1 -#define GPIO_DATA_DIRECTION_5 5:5 -#define GPIO_DATA_DIRECTION_5_INPUT 0 -#define GPIO_DATA_DIRECTION_5_OUTPUT 1 -#define GPIO_DATA_DIRECTION_4 4:4 -#define GPIO_DATA_DIRECTION_4_INPUT 0 -#define GPIO_DATA_DIRECTION_4_OUTPUT 1 -#define GPIO_DATA_DIRECTION_3 3:3 -#define GPIO_DATA_DIRECTION_3_INPUT 0 -#define GPIO_DATA_DIRECTION_3_OUTPUT 1 -#define GPIO_DATA_DIRECTION_2 2:2 -#define GPIO_DATA_DIRECTION_2_INPUT 0 -#define GPIO_DATA_DIRECTION_2_OUTPUT 1 -#define GPIO_DATA_DIRECTION_1 131 -#define GPIO_DATA_DIRECTION_1_INPUT 0 -#define GPIO_DATA_DIRECTION_1_OUTPUT 1 -#define GPIO_DATA_DIRECTION_0 0:0 -#define GPIO_DATA_DIRECTION_0_INPUT 0 -#define GPIO_DATA_DIRECTION_0_OUTPUT 1 +#define GPIO_DATA_DIRECTION_31 BIT(31) +#define GPIO_DATA_DIRECTION_30 BIT(30) +#define GPIO_DATA_DIRECTION_29 BIT(29) +#define GPIO_DATA_DIRECTION_28 BIT(28) +#define GPIO_DATA_DIRECTION_27 BIT(27) +#define GPIO_DATA_DIRECTION_26 BIT(26) +#define GPIO_DATA_DIRECTION_25 BIT(25) +#define GPIO_DATA_DIRECTION_24 BIT(24) +#define GPIO_DATA_DIRECTION_23 BIT(23) +#define GPIO_DATA_DIRECTION_22 BIT(22) +#define GPIO_DATA_DIRECTION_21 BIT(21) +#define GPIO_DATA_DIRECTION_20 BIT(20) +#define GPIO_DATA_DIRECTION_19 BIT(19) +#define GPIO_DATA_DIRECTION_18 BIT(18) +#define GPIO_DATA_DIRECTION_17 BIT(17) +#define GPIO_DATA_DIRECTION_16 BIT(16) +#define GPIO_DATA_DIRECTION_15 BIT(15) +#define GPIO_DATA_DIRECTION_14 BIT(14) +#define GPIO_DATA_DIRECTION_13 BIT(13) +#define GPIO_DATA_DIRECTION_12 BIT(12) +#define GPIO_DATA_DIRECTION_11 BIT(11) +#define GPIO_DATA_DIRECTION_10 BIT(10) +#define GPIO_DATA_DIRECTION_9 BIT(9) +#define GPIO_DATA_DIRECTION_8 BIT(8) +#define GPIO_DATA_DIRECTION_7 BIT(7) +#define GPIO_DATA_DIRECTION_6 BIT(6) +#define GPIO_DATA_DIRECTION_5 BIT(5) +#define GPIO_DATA_DIRECTION_4 BIT(4) +#define GPIO_DATA_DIRECTION_3 BIT(3) +#define GPIO_DATA_DIRECTION_2 BIT(2) +#define GPIO_DATA_DIRECTION_1 BIT(1) +#define GPIO_DATA_DIRECTION_0 BIT(0) #define GPIO_INTERRUPT_SETUP 0x010008 -#define GPIO_INTERRUPT_SETUP_TRIGGER_31 22:22 -#define GPIO_INTERRUPT_SETUP_TRIGGER_31_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_31_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_30 21:21 -#define GPIO_INTERRUPT_SETUP_TRIGGER_30_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_30_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_29 20:20 -#define GPIO_INTERRUPT_SETUP_TRIGGER_29_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_29_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_28 19:19 -#define GPIO_INTERRUPT_SETUP_TRIGGER_28_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_28_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_27 18:18 -#define GPIO_INTERRUPT_SETUP_TRIGGER_27_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_27_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_26 17:17 -#define GPIO_INTERRUPT_SETUP_TRIGGER_26_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_26_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_TRIGGER_25 16:16 -#define GPIO_INTERRUPT_SETUP_TRIGGER_25_EDGE 0 -#define GPIO_INTERRUPT_SETUP_TRIGGER_25_LEVEL 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_31 14:14 -#define GPIO_INTERRUPT_SETUP_ACTIVE_31_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_31_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_30 13:13 -#define GPIO_INTERRUPT_SETUP_ACTIVE_30_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_30_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_29 12:12 -#define GPIO_INTERRUPT_SETUP_ACTIVE_29_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_29_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_28 11:11 -#define GPIO_INTERRUPT_SETUP_ACTIVE_28_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_28_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_27 10:10 -#define GPIO_INTERRUPT_SETUP_ACTIVE_27_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_27_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_26 9:9 -#define GPIO_INTERRUPT_SETUP_ACTIVE_26_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_26_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ACTIVE_25 8:8 -#define GPIO_INTERRUPT_SETUP_ACTIVE_25_LOW 0 -#define GPIO_INTERRUPT_SETUP_ACTIVE_25_HIGH 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_31 6:6 -#define GPIO_INTERRUPT_SETUP_ENABLE_31_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_31_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_30 5:5 -#define GPIO_INTERRUPT_SETUP_ENABLE_30_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_30_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_29 4:4 -#define GPIO_INTERRUPT_SETUP_ENABLE_29_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_29_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_28 3:3 -#define GPIO_INTERRUPT_SETUP_ENABLE_28_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_28_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_27 2:2 -#define GPIO_INTERRUPT_SETUP_ENABLE_27_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_27_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_26 1:1 -#define GPIO_INTERRUPT_SETUP_ENABLE_26_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_26_INTERRUPT 1 -#define GPIO_INTERRUPT_SETUP_ENABLE_25 0:0 -#define GPIO_INTERRUPT_SETUP_ENABLE_25_GPIO 0 -#define GPIO_INTERRUPT_SETUP_ENABLE_25_INTERRUPT 1 +#define GPIO_INTERRUPT_SETUP_TRIGGER_31 BIT(22) +#define GPIO_INTERRUPT_SETUP_TRIGGER_30 BIT(21) +#define GPIO_INTERRUPT_SETUP_TRIGGER_29 BIT(20) +#define GPIO_INTERRUPT_SETUP_TRIGGER_28 BIT(19) +#define GPIO_INTERRUPT_SETUP_TRIGGER_27 BIT(18) +#define GPIO_INTERRUPT_SETUP_TRIGGER_26 BIT(17) +#define GPIO_INTERRUPT_SETUP_TRIGGER_25 BIT(16) +#define GPIO_INTERRUPT_SETUP_ACTIVE_31 BIT(14) +#define GPIO_INTERRUPT_SETUP_ACTIVE_30 BIT(13) +#define GPIO_INTERRUPT_SETUP_ACTIVE_29 BIT(12) +#define GPIO_INTERRUPT_SETUP_ACTIVE_28 BIT(11) +#define GPIO_INTERRUPT_SETUP_ACTIVE_27 BIT(10) +#define GPIO_INTERRUPT_SETUP_ACTIVE_26 BIT(9) +#define GPIO_INTERRUPT_SETUP_ACTIVE_25 BIT(8) +#define GPIO_INTERRUPT_SETUP_ENABLE_31 BIT(6) +#define GPIO_INTERRUPT_SETUP_ENABLE_30 BIT(5) +#define GPIO_INTERRUPT_SETUP_ENABLE_29 BIT(4) +#define GPIO_INTERRUPT_SETUP_ENABLE_28 BIT(3) +#define GPIO_INTERRUPT_SETUP_ENABLE_27 BIT(2) +#define GPIO_INTERRUPT_SETUP_ENABLE_26 BIT(1) +#define GPIO_INTERRUPT_SETUP_ENABLE_25 BIT(0) #define GPIO_INTERRUPT_STATUS 0x01000C -#define GPIO_INTERRUPT_STATUS_31 22:22 -#define GPIO_INTERRUPT_STATUS_31_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_31_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_31_RESET 1 -#define GPIO_INTERRUPT_STATUS_30 21:21 -#define GPIO_INTERRUPT_STATUS_30_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_30_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_30_RESET 1 -#define GPIO_INTERRUPT_STATUS_29 20:20 -#define GPIO_INTERRUPT_STATUS_29_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_29_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_29_RESET 1 -#define GPIO_INTERRUPT_STATUS_28 19:19 -#define GPIO_INTERRUPT_STATUS_28_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_28_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_28_RESET 1 -#define GPIO_INTERRUPT_STATUS_27 18:18 -#define GPIO_INTERRUPT_STATUS_27_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_27_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_27_RESET 1 -#define GPIO_INTERRUPT_STATUS_26 17:17 -#define GPIO_INTERRUPT_STATUS_26_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_26_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_26_RESET 1 -#define GPIO_INTERRUPT_STATUS_25 16:16 -#define GPIO_INTERRUPT_STATUS_25_INACTIVE 0 -#define GPIO_INTERRUPT_STATUS_25_ACTIVE 1 -#define GPIO_INTERRUPT_STATUS_25_RESET 1 +#define GPIO_INTERRUPT_STATUS_31 BIT(22) +#define GPIO_INTERRUPT_STATUS_30 BIT(21) +#define GPIO_INTERRUPT_STATUS_29 BIT(20) +#define GPIO_INTERRUPT_STATUS_28 BIT(19) +#define GPIO_INTERRUPT_STATUS_27 BIT(18) +#define GPIO_INTERRUPT_STATUS_26 BIT(17) +#define GPIO_INTERRUPT_STATUS_25 BIT(16) #define PANEL_DISPLAY_CTRL 0x080000 @@ -818,14 +570,14 @@ #define PANEL_DISPLAY_CTRL_FORMAT_32 (0x2 << 0) #define PANEL_PAN_CTRL 0x080004 -#define PANEL_PAN_CTRL_VERTICAL_PAN 31:24 -#define PANEL_PAN_CTRL_VERTICAL_VSYNC 21:16 -#define PANEL_PAN_CTRL_HORIZONTAL_PAN 15:8 -#define PANEL_PAN_CTRL_HORIZONTAL_VSYNC 5:0 +#define PANEL_PAN_CTRL_VERTICAL_PAN_MASK (0xff << 24) +#define PANEL_PAN_CTRL_VERTICAL_VSYNC_MASK (0x3f << 16) +#define PANEL_PAN_CTRL_HORIZONTAL_PAN_MASK (0xff << 8) +#define PANEL_PAN_CTRL_HORIZONTAL_VSYNC_MASK 0x3f #define PANEL_COLOR_KEY 0x080008 -#define PANEL_COLOR_KEY_MASK 31:16 -#define PANEL_COLOR_KEY_VALUE 15:0 +#define PANEL_COLOR_KEY_MASK_MASK (0xffff << 16) +#define PANEL_COLOR_KEY_VALUE_MASK 0xffff #define PANEL_FB_ADDRESS 0x08000C #define PANEL_FB_ADDRESS_STATUS BIT(31) @@ -863,454 +615,383 @@ #define PANEL_HORIZONTAL_TOTAL_DISPLAY_END_MASK 0xfff #define PANEL_HORIZONTAL_SYNC 0x080028 -#define PANEL_HORIZONTAL_SYNC_WIDTH 23:16 -#define PANEL_HORIZONTAL_SYNC_START 11:0 +#define PANEL_HORIZONTAL_SYNC_WIDTH_SHIFT 16 +#define PANEL_HORIZONTAL_SYNC_WIDTH_MASK (0xff << 16) +#define PANEL_HORIZONTAL_SYNC_START_MASK 0xfff #define PANEL_VERTICAL_TOTAL 0x08002C -#define PANEL_VERTICAL_TOTAL_TOTAL 26:16 -#define PANEL_VERTICAL_TOTAL_DISPLAY_END 10:0 +#define PANEL_VERTICAL_TOTAL_TOTAL_SHIFT 16 +#define PANEL_VERTICAL_TOTAL_TOTAL_MASK (0x7ff << 16) +#define PANEL_VERTICAL_TOTAL_DISPLAY_END_MASK 0x7ff #define PANEL_VERTICAL_SYNC 0x080030 -#define PANEL_VERTICAL_SYNC_HEIGHT 21:16 -#define PANEL_VERTICAL_SYNC_START 10:0 +#define PANEL_VERTICAL_SYNC_HEIGHT_SHIFT 16 +#define PANEL_VERTICAL_SYNC_HEIGHT_MASK (0x3f << 16) +#define PANEL_VERTICAL_SYNC_START_MASK 0x7ff #define PANEL_CURRENT_LINE 0x080034 -#define PANEL_CURRENT_LINE_LINE 10:0 +#define PANEL_CURRENT_LINE_LINE_MASK 0x7ff /* Video Control */ #define VIDEO_DISPLAY_CTRL 0x080040 -#define VIDEO_DISPLAY_CTRL_LINE_BUFFER 18:18 -#define VIDEO_DISPLAY_CTRL_LINE_BUFFER_DISABLE 0 -#define VIDEO_DISPLAY_CTRL_LINE_BUFFER_ENABLE 1 -#define VIDEO_DISPLAY_CTRL_FIFO 17:16 -#define VIDEO_DISPLAY_CTRL_FIFO_1 0 -#define VIDEO_DISPLAY_CTRL_FIFO_3 1 -#define VIDEO_DISPLAY_CTRL_FIFO_7 2 -#define VIDEO_DISPLAY_CTRL_FIFO_11 3 -#define VIDEO_DISPLAY_CTRL_BUFFER 15:15 -#define VIDEO_DISPLAY_CTRL_BUFFER_0 0 -#define VIDEO_DISPLAY_CTRL_BUFFER_1 1 -#define VIDEO_DISPLAY_CTRL_CAPTURE 14:14 -#define VIDEO_DISPLAY_CTRL_CAPTURE_DISABLE 0 -#define VIDEO_DISPLAY_CTRL_CAPTURE_ENABLE 1 -#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER 13:13 -#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER_DISABLE 0 -#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER_ENABLE 1 -#define VIDEO_DISPLAY_CTRL_BYTE_SWAP 12:12 -#define VIDEO_DISPLAY_CTRL_BYTE_SWAP_DISABLE 0 -#define VIDEO_DISPLAY_CTRL_BYTE_SWAP_ENABLE 1 -#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE 11:11 -#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE_NORMAL 0 -#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE_HALF 1 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE 10:10 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE_NORMAL 0 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE_HALF 1 -#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE 9:9 -#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE_REPLICATE 0 -#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE_INTERPOLATE 1 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE 8:8 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE_REPLICATE 0 -#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE_INTERPOLATE 1 -#define VIDEO_DISPLAY_CTRL_PIXEL 7:4 -#define VIDEO_DISPLAY_CTRL_GAMMA 3:3 -#define VIDEO_DISPLAY_CTRL_GAMMA_DISABLE 0 -#define VIDEO_DISPLAY_CTRL_GAMMA_ENABLE 1 -#define VIDEO_DISPLAY_CTRL_FORMAT 1:0 -#define VIDEO_DISPLAY_CTRL_FORMAT_8 0 -#define VIDEO_DISPLAY_CTRL_FORMAT_16 1 -#define VIDEO_DISPLAY_CTRL_FORMAT_32 2 -#define VIDEO_DISPLAY_CTRL_FORMAT_YUV 3 +#define VIDEO_DISPLAY_CTRL_LINE_BUFFER BIT(18) +#define VIDEO_DISPLAY_CTRL_FIFO_MASK (0x3 << 16) +#define VIDEO_DISPLAY_CTRL_FIFO_1 (0x0 << 16) +#define VIDEO_DISPLAY_CTRL_FIFO_3 (0x1 << 16) +#define VIDEO_DISPLAY_CTRL_FIFO_7 (0x2 << 16) +#define VIDEO_DISPLAY_CTRL_FIFO_11 (0x3 << 16) +#define VIDEO_DISPLAY_CTRL_BUFFER BIT(15) +#define VIDEO_DISPLAY_CTRL_CAPTURE BIT(14) +#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER BIT(13) +#define VIDEO_DISPLAY_CTRL_BYTE_SWAP BIT(12) +#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE BIT(11) +#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE BIT(10) +#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE BIT(9) +#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE BIT(8) +#define VIDEO_DISPLAY_CTRL_PIXEL_MASK (0xf << 4) +#define VIDEO_DISPLAY_CTRL_GAMMA BIT(3) +#define VIDEO_DISPLAY_CTRL_FORMAT_MASK 0x3 +#define VIDEO_DISPLAY_CTRL_FORMAT_8 0x0 +#define VIDEO_DISPLAY_CTRL_FORMAT_16 0x1 +#define VIDEO_DISPLAY_CTRL_FORMAT_32 0x2 +#define VIDEO_DISPLAY_CTRL_FORMAT_YUV 0x3 #define VIDEO_FB_0_ADDRESS 0x080044 -#define VIDEO_FB_0_ADDRESS_STATUS 31:31 -#define VIDEO_FB_0_ADDRESS_STATUS_CURRENT 0 -#define VIDEO_FB_0_ADDRESS_STATUS_PENDING 1 -#define VIDEO_FB_0_ADDRESS_EXT 27:27 -#define VIDEO_FB_0_ADDRESS_EXT_LOCAL 0 -#define VIDEO_FB_0_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_FB_0_ADDRESS_ADDRESS 25:0 +#define VIDEO_FB_0_ADDRESS_STATUS BIT(31) +#define VIDEO_FB_0_ADDRESS_EXT BIT(27) +#define VIDEO_FB_0_ADDRESS_ADDRESS_MASK 0x3ffffff #define VIDEO_FB_WIDTH 0x080048 -#define VIDEO_FB_WIDTH_WIDTH 29:16 -#define VIDEO_FB_WIDTH_OFFSET 13:0 +#define VIDEO_FB_WIDTH_WIDTH_MASK (0x3fff << 16) +#define VIDEO_FB_WIDTH_OFFSET_MASK 0x3fff #define VIDEO_FB_0_LAST_ADDRESS 0x08004C -#define VIDEO_FB_0_LAST_ADDRESS_EXT 27:27 -#define VIDEO_FB_0_LAST_ADDRESS_EXT_LOCAL 0 -#define VIDEO_FB_0_LAST_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_FB_0_LAST_ADDRESS_ADDRESS 25:0 +#define VIDEO_FB_0_LAST_ADDRESS_EXT BIT(27) +#define VIDEO_FB_0_LAST_ADDRESS_ADDRESS_MASK 0x3ffffff #define VIDEO_PLANE_TL 0x080050 -#define VIDEO_PLANE_TL_TOP 26:16 -#define VIDEO_PLANE_TL_LEFT 10:0 +#define VIDEO_PLANE_TL_TOP_MASK (0x7ff << 16) +#define VIDEO_PLANE_TL_LEFT_MASK 0x7ff #define VIDEO_PLANE_BR 0x080054 -#define VIDEO_PLANE_BR_BOTTOM 26:16 -#define VIDEO_PLANE_BR_RIGHT 10:0 +#define VIDEO_PLANE_BR_BOTTOM_MASK (0x7ff << 16) +#define VIDEO_PLANE_BR_RIGHT_MASK 0x7ff #define VIDEO_SCALE 0x080058 -#define VIDEO_SCALE_VERTICAL_MODE 31:31 -#define VIDEO_SCALE_VERTICAL_MODE_EXPAND 0 -#define VIDEO_SCALE_VERTICAL_MODE_SHRINK 1 -#define VIDEO_SCALE_VERTICAL_SCALE 27:16 -#define VIDEO_SCALE_HORIZONTAL_MODE 15:15 -#define VIDEO_SCALE_HORIZONTAL_MODE_EXPAND 0 -#define VIDEO_SCALE_HORIZONTAL_MODE_SHRINK 1 -#define VIDEO_SCALE_HORIZONTAL_SCALE 11:0 +#define VIDEO_SCALE_VERTICAL_MODE BIT(31) +#define VIDEO_SCALE_VERTICAL_SCALE_MASK (0xfff << 16) +#define VIDEO_SCALE_HORIZONTAL_MODE BIT(15) +#define VIDEO_SCALE_HORIZONTAL_SCALE_MASK 0xfff #define VIDEO_INITIAL_SCALE 0x08005C -#define VIDEO_INITIAL_SCALE_FB_1 27:16 -#define VIDEO_INITIAL_SCALE_FB_0 11:0 +#define VIDEO_INITIAL_SCALE_FB_1_MASK (0xfff << 16) +#define VIDEO_INITIAL_SCALE_FB_0_MASK 0xfff #define VIDEO_YUV_CONSTANTS 0x080060 -#define VIDEO_YUV_CONSTANTS_Y 31:24 -#define VIDEO_YUV_CONSTANTS_R 23:16 -#define VIDEO_YUV_CONSTANTS_G 15:8 -#define VIDEO_YUV_CONSTANTS_B 7:0 +#define VIDEO_YUV_CONSTANTS_Y_MASK (0xff << 24) +#define VIDEO_YUV_CONSTANTS_R_MASK (0xff << 16) +#define VIDEO_YUV_CONSTANTS_G_MASK (0xff << 8) +#define VIDEO_YUV_CONSTANTS_B_MASK 0xff #define VIDEO_FB_1_ADDRESS 0x080064 -#define VIDEO_FB_1_ADDRESS_STATUS 31:31 -#define VIDEO_FB_1_ADDRESS_STATUS_CURRENT 0 -#define VIDEO_FB_1_ADDRESS_STATUS_PENDING 1 -#define VIDEO_FB_1_ADDRESS_EXT 27:27 -#define VIDEO_FB_1_ADDRESS_EXT_LOCAL 0 -#define VIDEO_FB_1_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_FB_1_ADDRESS_ADDRESS 25:0 +#define VIDEO_FB_1_ADDRESS_STATUS BIT(31) +#define VIDEO_FB_1_ADDRESS_EXT BIT(27) +#define VIDEO_FB_1_ADDRESS_ADDRESS_MASK 0x3ffffff #define VIDEO_FB_1_LAST_ADDRESS 0x080068 -#define VIDEO_FB_1_LAST_ADDRESS_EXT 27:27 -#define VIDEO_FB_1_LAST_ADDRESS_EXT_LOCAL 0 -#define VIDEO_FB_1_LAST_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_FB_1_LAST_ADDRESS_ADDRESS 25:0 +#define VIDEO_FB_1_LAST_ADDRESS_EXT BIT(27) +#define VIDEO_FB_1_LAST_ADDRESS_ADDRESS_MASK 0x3ffffff /* Video Alpha Control */ #define VIDEO_ALPHA_DISPLAY_CTRL 0x080080 -#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT 28:28 -#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT_PER_PIXEL 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT_ALPHA 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_ALPHA 27:24 -#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO 17:16 -#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_1 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_3 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_7 2 -#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_11 3 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE 11:11 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE_NORMAL 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE_HALF 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE 10:10 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE_NORMAL 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE_HALF 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE 9:9 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE_REPLICATE 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE_INTERPOLATE 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE 8:8 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE_REPLICATE 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE_INTERPOLATE 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_PIXEL 7:4 -#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY 3:3 -#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY_DISABLE 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY_ENABLE 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT 1:0 -#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_8 0 -#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_16 1 -#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4 2 -#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4 3 +#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT BIT(28) +#define VIDEO_ALPHA_DISPLAY_CTRL_ALPHA_MASK (0xf << 24) +#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_MASK (0x3 << 16) +#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_1 (0x0 << 16) +#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_3 (0x1 << 16) +#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_7 (0x2 << 16) +#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_11 (0x3 << 16) +#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE BIT(11) +#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE BIT(10) +#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE BIT(9) +#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE BIT(8) +#define VIDEO_ALPHA_DISPLAY_CTRL_PIXEL_MASK (0xf << 4) +#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY BIT(3) +#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_MASK 0x3 +#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_8 0x0 +#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_16 0x1 +#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4 0x2 +#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4 0x3 #define VIDEO_ALPHA_FB_ADDRESS 0x080084 -#define VIDEO_ALPHA_FB_ADDRESS_STATUS 31:31 -#define VIDEO_ALPHA_FB_ADDRESS_STATUS_CURRENT 0 -#define VIDEO_ALPHA_FB_ADDRESS_STATUS_PENDING 1 -#define VIDEO_ALPHA_FB_ADDRESS_EXT 27:27 -#define VIDEO_ALPHA_FB_ADDRESS_EXT_LOCAL 0 -#define VIDEO_ALPHA_FB_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_ALPHA_FB_ADDRESS_ADDRESS 25:0 +#define VIDEO_ALPHA_FB_ADDRESS_STATUS BIT(31) +#define VIDEO_ALPHA_FB_ADDRESS_EXT BIT(27) +#define VIDEO_ALPHA_FB_ADDRESS_ADDRESS_MASK 0x3ffffff #define VIDEO_ALPHA_FB_WIDTH 0x080088 -#define VIDEO_ALPHA_FB_WIDTH_WIDTH 29:16 -#define VIDEO_ALPHA_FB_WIDTH_OFFSET 13:0 +#define VIDEO_ALPHA_FB_WIDTH_WIDTH_MASK (0x3fff << 16) +#define VIDEO_ALPHA_FB_WIDTH_OFFSET_MASK 0x3fff #define VIDEO_ALPHA_FB_LAST_ADDRESS 0x08008C -#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT 27:27 -#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT_LOCAL 0 -#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT_EXTERNAL 1 -#define VIDEO_ALPHA_FB_LAST_ADDRESS_ADDRESS 25:0 +#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT BIT(27) +#define VIDEO_ALPHA_FB_LAST_ADDRESS_ADDRESS_MASK 0x3ffffff #define VIDEO_ALPHA_PLANE_TL 0x080090 -#define VIDEO_ALPHA_PLANE_TL_TOP 26:16 -#define VIDEO_ALPHA_PLANE_TL_LEFT 10:0 +#define VIDEO_ALPHA_PLANE_TL_TOP_MASK (0x7ff << 16) +#define VIDEO_ALPHA_PLANE_TL_LEFT_MASK 0x7ff #define VIDEO_ALPHA_PLANE_BR 0x080094 -#define VIDEO_ALPHA_PLANE_BR_BOTTOM 26:16 -#define VIDEO_ALPHA_PLANE_BR_RIGHT 10:0 +#define VIDEO_ALPHA_PLANE_BR_BOTTOM_MASK (0x7ff << 16) +#define VIDEO_ALPHA_PLANE_BR_RIGHT_MASK 0x7ff #define VIDEO_ALPHA_SCALE 0x080098 -#define VIDEO_ALPHA_SCALE_VERTICAL_MODE 31:31 -#define VIDEO_ALPHA_SCALE_VERTICAL_MODE_EXPAND 0 -#define VIDEO_ALPHA_SCALE_VERTICAL_MODE_SHRINK 1 -#define VIDEO_ALPHA_SCALE_VERTICAL_SCALE 27:16 -#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE 15:15 -#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE_EXPAND 0 -#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE_SHRINK 1 -#define VIDEO_ALPHA_SCALE_HORIZONTAL_SCALE 11:0 +#define VIDEO_ALPHA_SCALE_VERTICAL_MODE BIT(31) +#define VIDEO_ALPHA_SCALE_VERTICAL_SCALE_MASK (0xfff << 16) +#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE BIT(15) +#define VIDEO_ALPHA_SCALE_HORIZONTAL_SCALE_MASK 0xfff #define VIDEO_ALPHA_INITIAL_SCALE 0x08009C -#define VIDEO_ALPHA_INITIAL_SCALE_VERTICAL 27:16 -#define VIDEO_ALPHA_INITIAL_SCALE_HORIZONTAL 11:0 +#define VIDEO_ALPHA_INITIAL_SCALE_VERTICAL_MASK (0xfff << 16) +#define VIDEO_ALPHA_INITIAL_SCALE_HORIZONTAL_MASK 0xfff #define VIDEO_ALPHA_CHROMA_KEY 0x0800A0 -#define VIDEO_ALPHA_CHROMA_KEY_MASK 31:16 -#define VIDEO_ALPHA_CHROMA_KEY_VALUE 15:0 +#define VIDEO_ALPHA_CHROMA_KEY_MASK_MASK (0xffff << 16) +#define VIDEO_ALPHA_CHROMA_KEY_VALUE_MASK 0xffff #define VIDEO_ALPHA_COLOR_LOOKUP_01 0x0800A4 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_1 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_0 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_23 0x0800A8 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_3 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_2 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_45 0x0800AC -#define VIDEO_ALPHA_COLOR_LOOKUP_45_5 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_4 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_67 0x0800B0 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_7 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_6 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_89 0x0800B4 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_9 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_8 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_AB 0x0800B8 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_CD 0x0800BC -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_BLUE_MASK 0x1f #define VIDEO_ALPHA_COLOR_LOOKUP_EF 0x0800C0 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F 31:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_RED 31:27 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_GREEN 26:21 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_BLUE 20:16 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E 15:0 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_RED 15:11 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_GREEN 10:5 -#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_BLUE 4:0 +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_MASK (0xffff << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_RED_MASK (0x1f << 27) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_GREEN_MASK (0x3f << 21) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_BLUE_MASK (0x1f << 16) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_MASK 0xffff +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_RED_MASK (0x1f << 11) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_GREEN_MASK (0x3f << 5) +#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_BLUE_MASK 0x1f /* Panel Cursor Control */ #define PANEL_HWC_ADDRESS 0x0800F0 -#define PANEL_HWC_ADDRESS_ENABLE 31:31 -#define PANEL_HWC_ADDRESS_ENABLE_DISABLE 0 -#define PANEL_HWC_ADDRESS_ENABLE_ENABLE 1 -#define PANEL_HWC_ADDRESS_EXT 27:27 -#define PANEL_HWC_ADDRESS_EXT_LOCAL 0 -#define PANEL_HWC_ADDRESS_EXT_EXTERNAL 1 -#define PANEL_HWC_ADDRESS_ADDRESS 25:0 +#define PANEL_HWC_ADDRESS_ENABLE BIT(31) +#define PANEL_HWC_ADDRESS_EXT BIT(27) +#define PANEL_HWC_ADDRESS_ADDRESS_MASK 0x3ffffff #define PANEL_HWC_LOCATION 0x0800F4 -#define PANEL_HWC_LOCATION_TOP 27:27 -#define PANEL_HWC_LOCATION_TOP_INSIDE 0 -#define PANEL_HWC_LOCATION_TOP_OUTSIDE 1 -#define PANEL_HWC_LOCATION_Y 26:16 -#define PANEL_HWC_LOCATION_LEFT 11:11 -#define PANEL_HWC_LOCATION_LEFT_INSIDE 0 -#define PANEL_HWC_LOCATION_LEFT_OUTSIDE 1 -#define PANEL_HWC_LOCATION_X 10:0 +#define PANEL_HWC_LOCATION_TOP BIT(27) +#define PANEL_HWC_LOCATION_Y_MASK (0x7ff << 16) +#define PANEL_HWC_LOCATION_LEFT BIT(11) +#define PANEL_HWC_LOCATION_X_MASK 0x7ff #define PANEL_HWC_COLOR_12 0x0800F8 -#define PANEL_HWC_COLOR_12_2_RGB565 31:16 -#define PANEL_HWC_COLOR_12_1_RGB565 15:0 +#define PANEL_HWC_COLOR_12_2_RGB565_MASK (0xffff << 16) +#define PANEL_HWC_COLOR_12_1_RGB565_MASK 0xffff #define PANEL_HWC_COLOR_3 0x0800FC -#define PANEL_HWC_COLOR_3_RGB565 15:0 +#define PANEL_HWC_COLOR_3_RGB565_MASK 0xffff /* Old Definitions +++ */ #define PANEL_HWC_COLOR_01 0x0800F8 -#define PANEL_HWC_COLOR_01_1_RED 31:27 -#define PANEL_HWC_COLOR_01_1_GREEN 26:21 -#define PANEL_HWC_COLOR_01_1_BLUE 20:16 -#define PANEL_HWC_COLOR_01_0_RED 15:11 -#define PANEL_HWC_COLOR_01_0_GREEN 10:5 -#define PANEL_HWC_COLOR_01_0_BLUE 4:0 +#define PANEL_HWC_COLOR_01_1_RED_MASK (0x1f << 27) +#define PANEL_HWC_COLOR_01_1_GREEN_MASK (0x3f << 21) +#define PANEL_HWC_COLOR_01_1_BLUE_MASK (0x1f << 16) +#define PANEL_HWC_COLOR_01_0_RED_MASK (0x1f << 11) +#define PANEL_HWC_COLOR_01_0_GREEN_MASK (0x3f << 5) +#define PANEL_HWC_COLOR_01_0_BLUE_MASK 0x1f #define PANEL_HWC_COLOR_2 0x0800FC -#define PANEL_HWC_COLOR_2_RED 15:11 -#define PANEL_HWC_COLOR_2_GREEN 10:5 -#define PANEL_HWC_COLOR_2_BLUE 4:0 +#define PANEL_HWC_COLOR_2_RED_MASK (0x1f << 11) +#define PANEL_HWC_COLOR_2_GREEN_MASK (0x3f << 5) +#define PANEL_HWC_COLOR_2_BLUE_MASK 0x1f /* Old Definitions --- */ /* Alpha Control */ #define ALPHA_DISPLAY_CTRL 0x080100 -#define ALPHA_DISPLAY_CTRL_SELECT 28:28 -#define ALPHA_DISPLAY_CTRL_SELECT_PER_PIXEL 0 -#define ALPHA_DISPLAY_CTRL_SELECT_ALPHA 1 -#define ALPHA_DISPLAY_CTRL_ALPHA 27:24 -#define ALPHA_DISPLAY_CTRL_FIFO 17:16 -#define ALPHA_DISPLAY_CTRL_FIFO_1 0 -#define ALPHA_DISPLAY_CTRL_FIFO_3 1 -#define ALPHA_DISPLAY_CTRL_FIFO_7 2 -#define ALPHA_DISPLAY_CTRL_FIFO_11 3 -#define ALPHA_DISPLAY_CTRL_PIXEL 7:4 -#define ALPHA_DISPLAY_CTRL_CHROMA_KEY 3:3 -#define ALPHA_DISPLAY_CTRL_CHROMA_KEY_DISABLE 0 -#define ALPHA_DISPLAY_CTRL_CHROMA_KEY_ENABLE 1 -#define ALPHA_DISPLAY_CTRL_FORMAT 1:0 -#define ALPHA_DISPLAY_CTRL_FORMAT_16 1 -#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4 2 -#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4 3 +#define ALPHA_DISPLAY_CTRL_SELECT BIT(28) +#define ALPHA_DISPLAY_CTRL_ALPHA_MASK (0xf << 24) +#define ALPHA_DISPLAY_CTRL_FIFO_MASK (0x3 << 16) +#define ALPHA_DISPLAY_CTRL_FIFO_1 (0x0 << 16) +#define ALPHA_DISPLAY_CTRL_FIFO_3 (0x1 << 16) +#define ALPHA_DISPLAY_CTRL_FIFO_7 (0x2 << 16) +#define ALPHA_DISPLAY_CTRL_FIFO_11 (0x3 << 16) +#define ALPHA_DISPLAY_CTRL_PIXEL_MASK (0xf << 4) +#define ALPHA_DISPLAY_CTRL_CHROMA_KEY BIT(3) +#define ALPHA_DISPLAY_CTRL_FORMAT_MASK 0x3 +#define ALPHA_DISPLAY_CTRL_FORMAT_16 0x1 +#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4 0x2 +#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4 0x3 #define ALPHA_FB_ADDRESS 0x080104 -#define ALPHA_FB_ADDRESS_STATUS 31:31 -#define ALPHA_FB_ADDRESS_STATUS_CURRENT 0 -#define ALPHA_FB_ADDRESS_STATUS_PENDING 1 -#define ALPHA_FB_ADDRESS_EXT 27:27 -#define ALPHA_FB_ADDRESS_EXT_LOCAL 0 -#define ALPHA_FB_ADDRESS_EXT_EXTERNAL 1 -#define ALPHA_FB_ADDRESS_ADDRESS 25:0 +#define ALPHA_FB_ADDRESS_STATUS BIT(31) +#define ALPHA_FB_ADDRESS_EXT BIT(27) +#define ALPHA_FB_ADDRESS_ADDRESS_MASK 0x3ffffff #define ALPHA_FB_WIDTH 0x080108 -#define ALPHA_FB_WIDTH_WIDTH 29:16 -#define ALPHA_FB_WIDTH_OFFSET 13:0 +#define ALPHA_FB_WIDTH_WIDTH_MASK (0x3fff << 16) +#define ALPHA_FB_WIDTH_OFFSET_MASK 0x3fff #define ALPHA_PLANE_TL 0x08010C -#define ALPHA_PLANE_TL_TOP 26:16 -#define ALPHA_PLANE_TL_LEFT 10:0 +#define ALPHA_PLANE_TL_TOP_MASK (0x7ff << 16) +#define ALPHA_PLANE_TL_LEFT_MASK 0x7ff #define ALPHA_PLANE_BR 0x080110 -#define ALPHA_PLANE_BR_BOTTOM 26:16 -#define ALPHA_PLANE_BR_RIGHT 10:0 +#define ALPHA_PLANE_BR_BOTTOM_MASK (0x7ff << 16) +#define ALPHA_PLANE_BR_RIGHT_MASK 0x7ff #define ALPHA_CHROMA_KEY 0x080114 -#define ALPHA_CHROMA_KEY_MASK 31:16 -#define ALPHA_CHROMA_KEY_VALUE 15:0 +#define ALPHA_CHROMA_KEY_MASK_MASK (0xffff << 16) +#define ALPHA_CHROMA_KEY_VALUE_MASK 0xffff #define ALPHA_COLOR_LOOKUP_01 0x080118 -#define ALPHA_COLOR_LOOKUP_01_1 31:16 -#define ALPHA_COLOR_LOOKUP_01_1_RED 31:27 -#define ALPHA_COLOR_LOOKUP_01_1_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_01_1_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_01_0 15:0 -#define ALPHA_COLOR_LOOKUP_01_0_RED 15:11 -#define ALPHA_COLOR_LOOKUP_01_0_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_01_0_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_01_1_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_01_1_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_01_1_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_01_1_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_01_0_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_01_0_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_01_0_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_01_0_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_23 0x08011C -#define ALPHA_COLOR_LOOKUP_23_3 31:16 -#define ALPHA_COLOR_LOOKUP_23_3_RED 31:27 -#define ALPHA_COLOR_LOOKUP_23_3_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_23_3_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_23_2 15:0 -#define ALPHA_COLOR_LOOKUP_23_2_RED 15:11 -#define ALPHA_COLOR_LOOKUP_23_2_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_23_2_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_23_3_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_23_3_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_23_3_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_23_3_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_23_2_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_23_2_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_23_2_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_23_2_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_45 0x080120 -#define ALPHA_COLOR_LOOKUP_45_5 31:16 -#define ALPHA_COLOR_LOOKUP_45_5_RED 31:27 -#define ALPHA_COLOR_LOOKUP_45_5_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_45_5_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_45_4 15:0 -#define ALPHA_COLOR_LOOKUP_45_4_RED 15:11 -#define ALPHA_COLOR_LOOKUP_45_4_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_45_4_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_45_5_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_45_5_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_45_5_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_45_5_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_45_4_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_45_4_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_45_4_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_45_4_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_67 0x080124 -#define ALPHA_COLOR_LOOKUP_67_7 31:16 -#define ALPHA_COLOR_LOOKUP_67_7_RED 31:27 -#define ALPHA_COLOR_LOOKUP_67_7_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_67_7_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_67_6 15:0 -#define ALPHA_COLOR_LOOKUP_67_6_RED 15:11 -#define ALPHA_COLOR_LOOKUP_67_6_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_67_6_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_67_7_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_67_7_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_67_7_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_67_7_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_67_6_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_67_6_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_67_6_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_67_6_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_89 0x080128 -#define ALPHA_COLOR_LOOKUP_89_9 31:16 -#define ALPHA_COLOR_LOOKUP_89_9_RED 31:27 -#define ALPHA_COLOR_LOOKUP_89_9_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_89_9_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_89_8 15:0 -#define ALPHA_COLOR_LOOKUP_89_8_RED 15:11 -#define ALPHA_COLOR_LOOKUP_89_8_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_89_8_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_89_9_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_89_9_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_89_9_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_89_9_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_89_8_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_89_8_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_89_8_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_89_8_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_AB 0x08012C -#define ALPHA_COLOR_LOOKUP_AB_B 31:16 -#define ALPHA_COLOR_LOOKUP_AB_B_RED 31:27 -#define ALPHA_COLOR_LOOKUP_AB_B_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_AB_B_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_AB_A 15:0 -#define ALPHA_COLOR_LOOKUP_AB_A_RED 15:11 -#define ALPHA_COLOR_LOOKUP_AB_A_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_AB_A_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_AB_B_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_AB_B_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_AB_B_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_AB_B_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_AB_A_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_AB_A_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_AB_A_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_AB_A_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_CD 0x080130 -#define ALPHA_COLOR_LOOKUP_CD_D 31:16 -#define ALPHA_COLOR_LOOKUP_CD_D_RED 31:27 -#define ALPHA_COLOR_LOOKUP_CD_D_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_CD_D_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_CD_C 15:0 -#define ALPHA_COLOR_LOOKUP_CD_C_RED 15:11 -#define ALPHA_COLOR_LOOKUP_CD_C_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_CD_C_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_CD_D_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_CD_D_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_CD_D_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_CD_D_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_CD_C_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_CD_C_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_CD_C_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_CD_C_BLUE_MASK 0x1f #define ALPHA_COLOR_LOOKUP_EF 0x080134 -#define ALPHA_COLOR_LOOKUP_EF_F 31:16 -#define ALPHA_COLOR_LOOKUP_EF_F_RED 31:27 -#define ALPHA_COLOR_LOOKUP_EF_F_GREEN 26:21 -#define ALPHA_COLOR_LOOKUP_EF_F_BLUE 20:16 -#define ALPHA_COLOR_LOOKUP_EF_E 15:0 -#define ALPHA_COLOR_LOOKUP_EF_E_RED 15:11 -#define ALPHA_COLOR_LOOKUP_EF_E_GREEN 10:5 -#define ALPHA_COLOR_LOOKUP_EF_E_BLUE 4:0 +#define ALPHA_COLOR_LOOKUP_EF_F_MASK (0xffff << 16) +#define ALPHA_COLOR_LOOKUP_EF_F_RED_MASK (0x1f << 27) +#define ALPHA_COLOR_LOOKUP_EF_F_GREEN_MASK (0x3f << 21) +#define ALPHA_COLOR_LOOKUP_EF_F_BLUE_MASK (0x1f << 16) +#define ALPHA_COLOR_LOOKUP_EF_E_MASK 0xffff +#define ALPHA_COLOR_LOOKUP_EF_E_RED_MASK (0x1f << 11) +#define ALPHA_COLOR_LOOKUP_EF_E_GREEN_MASK (0x3f << 5) +#define ALPHA_COLOR_LOOKUP_EF_E_BLUE_MASK 0x1f /* CRT Graphics Control */ @@ -1364,125 +1045,107 @@ #define CRT_DISPLAY_CTRL_FORMAT_32 (0x2 << 0) #define CRT_FB_ADDRESS 0x080204 -#define CRT_FB_ADDRESS_STATUS 31:31 -#define CRT_FB_ADDRESS_STATUS_CURRENT 0 -#define CRT_FB_ADDRESS_STATUS_PENDING 1 -#define CRT_FB_ADDRESS_EXT 27:27 -#define CRT_FB_ADDRESS_EXT_LOCAL 0 -#define CRT_FB_ADDRESS_EXT_EXTERNAL 1 -#define CRT_FB_ADDRESS_ADDRESS 25:0 +#define CRT_FB_ADDRESS_STATUS BIT(31) +#define CRT_FB_ADDRESS_EXT BIT(27) +#define CRT_FB_ADDRESS_ADDRESS_MASK 0x3ffffff #define CRT_FB_WIDTH 0x080208 -#define CRT_FB_WIDTH_WIDTH 29:16 -#define CRT_FB_WIDTH_OFFSET 13:0 +#define CRT_FB_WIDTH_WIDTH_SHIFT 16 +#define CRT_FB_WIDTH_WIDTH_MASK (0x3fff << 16) +#define CRT_FB_WIDTH_OFFSET_MASK 0x3fff #define CRT_HORIZONTAL_TOTAL 0x08020C -#define CRT_HORIZONTAL_TOTAL_TOTAL 27:16 -#define CRT_HORIZONTAL_TOTAL_DISPLAY_END 11:0 +#define CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT 16 +#define CRT_HORIZONTAL_TOTAL_TOTAL_MASK (0xfff << 16) +#define CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK 0xfff #define CRT_HORIZONTAL_SYNC 0x080210 -#define CRT_HORIZONTAL_SYNC_WIDTH 23:16 -#define CRT_HORIZONTAL_SYNC_START 11:0 +#define CRT_HORIZONTAL_SYNC_WIDTH_SHIFT 16 +#define CRT_HORIZONTAL_SYNC_WIDTH_MASK (0xff << 16) +#define CRT_HORIZONTAL_SYNC_START_MASK 0xfff #define CRT_VERTICAL_TOTAL 0x080214 -#define CRT_VERTICAL_TOTAL_TOTAL 26:16 -#define CRT_VERTICAL_TOTAL_DISPLAY_END 10:0 +#define CRT_VERTICAL_TOTAL_TOTAL_SHIFT 16 +#define CRT_VERTICAL_TOTAL_TOTAL_MASK (0x7ff << 16) +#define CRT_VERTICAL_TOTAL_DISPLAY_END_MASK (0x7ff) #define CRT_VERTICAL_SYNC 0x080218 -#define CRT_VERTICAL_SYNC_HEIGHT 21:16 -#define CRT_VERTICAL_SYNC_START 10:0 +#define CRT_VERTICAL_SYNC_HEIGHT_SHIFT 16 +#define CRT_VERTICAL_SYNC_HEIGHT_MASK (0x3f << 16) +#define CRT_VERTICAL_SYNC_START_MASK 0x7ff #define CRT_SIGNATURE_ANALYZER 0x08021C -#define CRT_SIGNATURE_ANALYZER_STATUS 31:16 -#define CRT_SIGNATURE_ANALYZER_ENABLE 3:3 -#define CRT_SIGNATURE_ANALYZER_ENABLE_DISABLE 0 -#define CRT_SIGNATURE_ANALYZER_ENABLE_ENABLE 1 -#define CRT_SIGNATURE_ANALYZER_RESET 2:2 -#define CRT_SIGNATURE_ANALYZER_RESET_NORMAL 0 -#define CRT_SIGNATURE_ANALYZER_RESET_RESET 1 -#define CRT_SIGNATURE_ANALYZER_SOURCE 1:0 +#define CRT_SIGNATURE_ANALYZER_STATUS_MASK (0xffff << 16) +#define CRT_SIGNATURE_ANALYZER_ENABLE BIT(3) +#define CRT_SIGNATURE_ANALYZER_RESET BIT(2) +#define CRT_SIGNATURE_ANALYZER_SOURCE_MASK 0x3 #define CRT_SIGNATURE_ANALYZER_SOURCE_RED 0 #define CRT_SIGNATURE_ANALYZER_SOURCE_GREEN 1 #define CRT_SIGNATURE_ANALYZER_SOURCE_BLUE 2 #define CRT_CURRENT_LINE 0x080220 -#define CRT_CURRENT_LINE_LINE 10:0 +#define CRT_CURRENT_LINE_LINE_MASK 0x7ff #define CRT_MONITOR_DETECT 0x080224 -#define CRT_MONITOR_DETECT_VALUE 25:25 -#define CRT_MONITOR_DETECT_VALUE_DISABLE 0 -#define CRT_MONITOR_DETECT_VALUE_ENABLE 1 -#define CRT_MONITOR_DETECT_ENABLE 24:24 -#define CRT_MONITOR_DETECT_ENABLE_DISABLE 0 -#define CRT_MONITOR_DETECT_ENABLE_ENABLE 1 -#define CRT_MONITOR_DETECT_RED 23:16 -#define CRT_MONITOR_DETECT_GREEN 15:8 -#define CRT_MONITOR_DETECT_BLUE 7:0 +#define CRT_MONITOR_DETECT_VALUE BIT(25) +#define CRT_MONITOR_DETECT_ENABLE BIT(24) +#define CRT_MONITOR_DETECT_RED_MASK (0xff << 16) +#define CRT_MONITOR_DETECT_GREEN_MASK (0xff << 8) +#define CRT_MONITOR_DETECT_BLUE_MASK 0xff #define CRT_SCALE 0x080228 -#define CRT_SCALE_VERTICAL_MODE 31:31 -#define CRT_SCALE_VERTICAL_MODE_EXPAND 0 -#define CRT_SCALE_VERTICAL_MODE_SHRINK 1 -#define CRT_SCALE_VERTICAL_SCALE 27:16 -#define CRT_SCALE_HORIZONTAL_MODE 15:15 -#define CRT_SCALE_HORIZONTAL_MODE_EXPAND 0 -#define CRT_SCALE_HORIZONTAL_MODE_SHRINK 1 -#define CRT_SCALE_HORIZONTAL_SCALE 11:0 +#define CRT_SCALE_VERTICAL_MODE BIT(31) +#define CRT_SCALE_VERTICAL_SCALE_MASK (0xfff << 16) +#define CRT_SCALE_HORIZONTAL_MODE BIT(15) +#define CRT_SCALE_HORIZONTAL_SCALE_MASK 0xfff /* CRT Cursor Control */ #define CRT_HWC_ADDRESS 0x080230 -#define CRT_HWC_ADDRESS_ENABLE 31:31 -#define CRT_HWC_ADDRESS_ENABLE_DISABLE 0 -#define CRT_HWC_ADDRESS_ENABLE_ENABLE 1 -#define CRT_HWC_ADDRESS_EXT 27:27 -#define CRT_HWC_ADDRESS_EXT_LOCAL 0 -#define CRT_HWC_ADDRESS_EXT_EXTERNAL 1 -#define CRT_HWC_ADDRESS_ADDRESS 25:0 +#define CRT_HWC_ADDRESS_ENABLE BIT(31) +#define CRT_HWC_ADDRESS_EXT BIT(27) +#define CRT_HWC_ADDRESS_ADDRESS_MASK 0x3ffffff #define CRT_HWC_LOCATION 0x080234 -#define CRT_HWC_LOCATION_TOP 27:27 -#define CRT_HWC_LOCATION_TOP_INSIDE 0 -#define CRT_HWC_LOCATION_TOP_OUTSIDE 1 -#define CRT_HWC_LOCATION_Y 26:16 -#define CRT_HWC_LOCATION_LEFT 11:11 -#define CRT_HWC_LOCATION_LEFT_INSIDE 0 -#define CRT_HWC_LOCATION_LEFT_OUTSIDE 1 -#define CRT_HWC_LOCATION_X 10:0 +#define CRT_HWC_LOCATION_TOP BIT(27) +#define CRT_HWC_LOCATION_Y_MASK (0x7ff << 16) +#define CRT_HWC_LOCATION_LEFT BIT(11) +#define CRT_HWC_LOCATION_X_MASK 0x7ff #define CRT_HWC_COLOR_12 0x080238 -#define CRT_HWC_COLOR_12_2_RGB565 31:16 -#define CRT_HWC_COLOR_12_1_RGB565 15:0 +#define CRT_HWC_COLOR_12_2_RGB565_MASK (0xffff << 16) +#define CRT_HWC_COLOR_12_1_RGB565_MASK 0xffff #define CRT_HWC_COLOR_3 0x08023C -#define CRT_HWC_COLOR_3_RGB565 15:0 +#define CRT_HWC_COLOR_3_RGB565_MASK 0xffff /* This vertical expansion below start at 0x080240 ~ 0x080264 */ #define CRT_VERTICAL_EXPANSION 0x080240 #ifndef VALIDATION_CHIP - #define CRT_VERTICAL_CENTERING_VALUE 31:24 + #define CRT_VERTICAL_CENTERING_VALUE_MASK (0xff << 24) #endif -#define CRT_VERTICAL_EXPANSION_COMPARE_VALUE 23:16 -#define CRT_VERTICAL_EXPANSION_LINE_BUFFER 15:12 -#define CRT_VERTICAL_EXPANSION_SCALE_FACTOR 11:0 +#define CRT_VERTICAL_EXPANSION_COMPARE_VALUE_MASK (0xff << 16) +#define CRT_VERTICAL_EXPANSION_LINE_BUFFER_MASK (0xf << 12) +#define CRT_VERTICAL_EXPANSION_SCALE_FACTOR_MASK 0xfff /* This horizontal expansion below start at 0x080268 ~ 0x08027C */ #define CRT_HORIZONTAL_EXPANSION 0x080268 #ifndef VALIDATION_CHIP - #define CRT_HORIZONTAL_CENTERING_VALUE 31:24 + #define CRT_HORIZONTAL_CENTERING_VALUE_MASK (0xff << 24) #endif -#define CRT_HORIZONTAL_EXPANSION_COMPARE_VALUE 23:16 -#define CRT_HORIZONTAL_EXPANSION_SCALE_FACTOR 11:0 +#define CRT_HORIZONTAL_EXPANSION_COMPARE_VALUE_MASK (0xff << 16) +#define CRT_HORIZONTAL_EXPANSION_SCALE_FACTOR_MASK 0xfff #ifndef VALIDATION_CHIP /* Auto Centering */ #define CRT_AUTO_CENTERING_TL 0x080280 - #define CRT_AUTO_CENTERING_TL_TOP 26:16 - #define CRT_AUTO_CENTERING_TL_LEFT 10:0 + #define CRT_AUTO_CENTERING_TL_TOP_MASK (0x7ff << 16) + #define CRT_AUTO_CENTERING_TL_LEFT_MASK 0x7ff #define CRT_AUTO_CENTERING_BR 0x080284 - #define CRT_AUTO_CENTERING_BR_BOTTOM 26:16 - #define CRT_AUTO_CENTERING_BR_RIGHT 10:0 + #define CRT_AUTO_CENTERING_BR_BOTTOM_MASK (0x7ff << 16) + #define CRT_AUTO_CENTERING_BR_BOTTOM_SHIFT 16 + #define CRT_AUTO_CENTERING_BR_RIGHT_MASK 0x7ff #endif /* sm750le new register to control panel output */ @@ -1498,112 +1161,86 @@ /* Color Space Conversion registers. */ #define CSC_Y_SOURCE_BASE 0x1000C8 -#define CSC_Y_SOURCE_BASE_EXT 27:27 -#define CSC_Y_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_Y_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_Y_SOURCE_BASE_CS 26:26 -#define CSC_Y_SOURCE_BASE_CS_0 0 -#define CSC_Y_SOURCE_BASE_CS_1 1 -#define CSC_Y_SOURCE_BASE_ADDRESS 25:0 +#define CSC_Y_SOURCE_BASE_EXT BIT(27) +#define CSC_Y_SOURCE_BASE_CS BIT(26) +#define CSC_Y_SOURCE_BASE_ADDRESS_MASK 0x3ffffff #define CSC_CONSTANTS 0x1000CC -#define CSC_CONSTANTS_Y 31:24 -#define CSC_CONSTANTS_R 23:16 -#define CSC_CONSTANTS_G 15:8 -#define CSC_CONSTANTS_B 7:0 +#define CSC_CONSTANTS_Y_MASK (0xff << 24) +#define CSC_CONSTANTS_R_MASK (0xff << 16) +#define CSC_CONSTANTS_G_MASK (0xff << 8) +#define CSC_CONSTANTS_B_MASK 0xff #define CSC_Y_SOURCE_X 0x1000D0 -#define CSC_Y_SOURCE_X_INTEGER 26:16 -#define CSC_Y_SOURCE_X_FRACTION 15:3 +#define CSC_Y_SOURCE_X_INTEGER_MASK (0x7ff << 16) +#define CSC_Y_SOURCE_X_FRACTION_MASK (0x1fff << 3) #define CSC_Y_SOURCE_Y 0x1000D4 -#define CSC_Y_SOURCE_Y_INTEGER 27:16 -#define CSC_Y_SOURCE_Y_FRACTION 15:3 +#define CSC_Y_SOURCE_Y_INTEGER_MASK (0xfff << 16) +#define CSC_Y_SOURCE_Y_FRACTION_MASK (0x1fff << 3) #define CSC_U_SOURCE_BASE 0x1000D8 -#define CSC_U_SOURCE_BASE_EXT 27:27 -#define CSC_U_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_U_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_U_SOURCE_BASE_CS 26:26 -#define CSC_U_SOURCE_BASE_CS_0 0 -#define CSC_U_SOURCE_BASE_CS_1 1 -#define CSC_U_SOURCE_BASE_ADDRESS 25:0 +#define CSC_U_SOURCE_BASE_EXT BIT(27) +#define CSC_U_SOURCE_BASE_CS BIT(26) +#define CSC_U_SOURCE_BASE_ADDRESS_MASK 0x3ffffff #define CSC_V_SOURCE_BASE 0x1000DC -#define CSC_V_SOURCE_BASE_EXT 27:27 -#define CSC_V_SOURCE_BASE_EXT_LOCAL 0 -#define CSC_V_SOURCE_BASE_EXT_EXTERNAL 1 -#define CSC_V_SOURCE_BASE_CS 26:26 -#define CSC_V_SOURCE_BASE_CS_0 0 -#define CSC_V_SOURCE_BASE_CS_1 1 -#define CSC_V_SOURCE_BASE_ADDRESS 25:0 +#define CSC_V_SOURCE_BASE_EXT BIT(27) +#define CSC_V_SOURCE_BASE_CS BIT(26) +#define CSC_V_SOURCE_BASE_ADDRESS_MASK 0x3ffffff #define CSC_SOURCE_DIMENSION 0x1000E0 -#define CSC_SOURCE_DIMENSION_X 31:16 -#define CSC_SOURCE_DIMENSION_Y 15:0 +#define CSC_SOURCE_DIMENSION_X_MASK (0xffff << 16) +#define CSC_SOURCE_DIMENSION_Y_MASK 0xffff #define CSC_SOURCE_PITCH 0x1000E4 -#define CSC_SOURCE_PITCH_Y 31:16 -#define CSC_SOURCE_PITCH_UV 15:0 +#define CSC_SOURCE_PITCH_Y_MASK (0xffff << 16) +#define CSC_SOURCE_PITCH_UV_MASK 0xffff #define CSC_DESTINATION 0x1000E8 -#define CSC_DESTINATION_WRAP 31:31 -#define CSC_DESTINATION_WRAP_DISABLE 0 -#define CSC_DESTINATION_WRAP_ENABLE 1 -#define CSC_DESTINATION_X 27:16 -#define CSC_DESTINATION_Y 11:0 +#define CSC_DESTINATION_WRAP BIT(31) +#define CSC_DESTINATION_X_MASK (0xfff << 16) +#define CSC_DESTINATION_Y_MASK 0xfff #define CSC_DESTINATION_DIMENSION 0x1000EC -#define CSC_DESTINATION_DIMENSION_X 31:16 -#define CSC_DESTINATION_DIMENSION_Y 15:0 +#define CSC_DESTINATION_DIMENSION_X_MASK (0xffff << 16) +#define CSC_DESTINATION_DIMENSION_Y_MASK 0xffff #define CSC_DESTINATION_PITCH 0x1000F0 -#define CSC_DESTINATION_PITCH_X 31:16 -#define CSC_DESTINATION_PITCH_Y 15:0 +#define CSC_DESTINATION_PITCH_X_MASK (0xffff << 16) +#define CSC_DESTINATION_PITCH_Y_MASK 0xffff #define CSC_SCALE_FACTOR 0x1000F4 -#define CSC_SCALE_FACTOR_HORIZONTAL 31:16 -#define CSC_SCALE_FACTOR_VERTICAL 15:0 +#define CSC_SCALE_FACTOR_HORIZONTAL_MASK (0xffff << 16) +#define CSC_SCALE_FACTOR_VERTICAL_MASK 0xffff #define CSC_DESTINATION_BASE 0x1000F8 -#define CSC_DESTINATION_BASE_EXT 27:27 -#define CSC_DESTINATION_BASE_EXT_LOCAL 0 -#define CSC_DESTINATION_BASE_EXT_EXTERNAL 1 -#define CSC_DESTINATION_BASE_CS 26:26 -#define CSC_DESTINATION_BASE_CS_0 0 -#define CSC_DESTINATION_BASE_CS_1 1 -#define CSC_DESTINATION_BASE_ADDRESS 25:0 +#define CSC_DESTINATION_BASE_EXT BIT(27) +#define CSC_DESTINATION_BASE_CS BIT(26) +#define CSC_DESTINATION_BASE_ADDRESS_MASK 0x3ffffff #define CSC_CONTROL 0x1000FC -#define CSC_CONTROL_STATUS 31:31 -#define CSC_CONTROL_STATUS_STOP 0 -#define CSC_CONTROL_STATUS_START 1 -#define CSC_CONTROL_SOURCE_FORMAT 30:28 -#define CSC_CONTROL_SOURCE_FORMAT_YUV422 0 -#define CSC_CONTROL_SOURCE_FORMAT_YUV420I 1 -#define CSC_CONTROL_SOURCE_FORMAT_YUV420 2 -#define CSC_CONTROL_SOURCE_FORMAT_YVU9 3 -#define CSC_CONTROL_SOURCE_FORMAT_IYU1 4 -#define CSC_CONTROL_SOURCE_FORMAT_IYU2 5 -#define CSC_CONTROL_SOURCE_FORMAT_RGB565 6 -#define CSC_CONTROL_SOURCE_FORMAT_RGB8888 7 -#define CSC_CONTROL_DESTINATION_FORMAT 27:26 -#define CSC_CONTROL_DESTINATION_FORMAT_RGB565 0 -#define CSC_CONTROL_DESTINATION_FORMAT_RGB8888 1 -#define CSC_CONTROL_HORIZONTAL_FILTER 25:25 -#define CSC_CONTROL_HORIZONTAL_FILTER_DISABLE 0 -#define CSC_CONTROL_HORIZONTAL_FILTER_ENABLE 1 -#define CSC_CONTROL_VERTICAL_FILTER 24:24 -#define CSC_CONTROL_VERTICAL_FILTER_DISABLE 0 -#define CSC_CONTROL_VERTICAL_FILTER_ENABLE 1 -#define CSC_CONTROL_BYTE_ORDER 23:23 -#define CSC_CONTROL_BYTE_ORDER_YUYV 0 -#define CSC_CONTROL_BYTE_ORDER_UYVY 1 +#define CSC_CONTROL_STATUS BIT(31) +#define CSC_CONTROL_SOURCE_FORMAT_MASK (0x7 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_YUV422 (0x0 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_YUV420I (0x1 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_YUV420 (0x2 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_YVU9 (0x3 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_IYU1 (0x4 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_IYU2 (0x5 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_RGB565 (0x6 << 28) +#define CSC_CONTROL_SOURCE_FORMAT_RGB8888 (0x7 << 28) +#define CSC_CONTROL_DESTINATION_FORMAT_MASK (0x3 << 26) +#define CSC_CONTROL_DESTINATION_FORMAT_RGB565 (0x0 << 26) +#define CSC_CONTROL_DESTINATION_FORMAT_RGB8888 (0x1 << 26) +#define CSC_CONTROL_HORIZONTAL_FILTER BIT(25) +#define CSC_CONTROL_VERTICAL_FILTER BIT(24) +#define CSC_CONTROL_BYTE_ORDER BIT(23) #define DE_DATA_PORT 0x110000 #define I2C_BYTE_COUNT 0x010040 -#define I2C_BYTE_COUNT_COUNT 3:0 +#define I2C_BYTE_COUNT_COUNT_MASK 0xf #define I2C_CTRL 0x010041 #define I2C_CTRL_INT BIT(4) @@ -1619,14 +1256,11 @@ #define I2C_STATUS_BSY BIT(0) #define I2C_RESET 0x010042 -#define I2C_RESET_BUS_ERROR 2:2 -#define I2C_RESET_BUS_ERROR_CLEAR 0 +#define I2C_RESET_BUS_ERROR BIT(2) #define I2C_SLAVE_ADDRESS 0x010043 -#define I2C_SLAVE_ADDRESS_ADDRESS 7:1 -#define I2C_SLAVE_ADDRESS_RW 0:0 -#define I2C_SLAVE_ADDRESS_RW_W 0 -#define I2C_SLAVE_ADDRESS_RW_R 1 +#define I2C_SLAVE_ADDRESS_ADDRESS_MASK (0x7f << 1) +#define I2C_SLAVE_ADDRESS_RW BIT(0) #define I2C_DATA0 0x010044 #define I2C_DATA1 0x010045 @@ -1647,120 +1281,59 @@ #define ZV0_CAPTURE_CTRL 0x090000 -#define ZV0_CAPTURE_CTRL_FIELD_INPUT 27:27 -#define ZV0_CAPTURE_CTRL_FIELD_INPUT_EVEN_FIELD 0 -#define ZV0_CAPTURE_CTRL_FIELD_INPUT_ODD_FIELD 1 -#define ZV0_CAPTURE_CTRL_SCAN 26:26 -#define ZV0_CAPTURE_CTRL_SCAN_PROGRESSIVE 0 -#define ZV0_CAPTURE_CTRL_SCAN_INTERLACE 1 -#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER 25:25 -#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER_0 0 -#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER_1 1 -#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC 24:24 -#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC_INACTIVE 0 -#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC_ACTIVE 1 -#define ZV0_CAPTURE_CTRL_ADJ 19:19 -#define ZV0_CAPTURE_CTRL_ADJ_NORMAL 0 -#define ZV0_CAPTURE_CTRL_ADJ_DELAY 1 -#define ZV0_CAPTURE_CTRL_HA 18:18 -#define ZV0_CAPTURE_CTRL_HA_DISABLE 0 -#define ZV0_CAPTURE_CTRL_HA_ENABLE 1 -#define ZV0_CAPTURE_CTRL_VSK 17:17 -#define ZV0_CAPTURE_CTRL_VSK_DISABLE 0 -#define ZV0_CAPTURE_CTRL_VSK_ENABLE 1 -#define ZV0_CAPTURE_CTRL_HSK 16:16 -#define ZV0_CAPTURE_CTRL_HSK_DISABLE 0 -#define ZV0_CAPTURE_CTRL_HSK_ENABLE 1 -#define ZV0_CAPTURE_CTRL_FD 15:15 -#define ZV0_CAPTURE_CTRL_FD_RISING 0 -#define ZV0_CAPTURE_CTRL_FD_FALLING 1 -#define ZV0_CAPTURE_CTRL_VP 14:14 -#define ZV0_CAPTURE_CTRL_VP_HIGH 0 -#define ZV0_CAPTURE_CTRL_VP_LOW 1 -#define ZV0_CAPTURE_CTRL_HP 13:13 -#define ZV0_CAPTURE_CTRL_HP_HIGH 0 -#define ZV0_CAPTURE_CTRL_HP_LOW 1 -#define ZV0_CAPTURE_CTRL_CP 12:12 -#define ZV0_CAPTURE_CTRL_CP_HIGH 0 -#define ZV0_CAPTURE_CTRL_CP_LOW 1 -#define ZV0_CAPTURE_CTRL_UVS 11:11 -#define ZV0_CAPTURE_CTRL_UVS_DISABLE 0 -#define ZV0_CAPTURE_CTRL_UVS_ENABLE 1 -#define ZV0_CAPTURE_CTRL_BS 10:10 -#define ZV0_CAPTURE_CTRL_BS_DISABLE 0 -#define ZV0_CAPTURE_CTRL_BS_ENABLE 1 -#define ZV0_CAPTURE_CTRL_CS 9:9 -#define ZV0_CAPTURE_CTRL_CS_16 0 -#define ZV0_CAPTURE_CTRL_CS_8 1 -#define ZV0_CAPTURE_CTRL_CF 8:8 -#define ZV0_CAPTURE_CTRL_CF_YUV 0 -#define ZV0_CAPTURE_CTRL_CF_RGB 1 -#define ZV0_CAPTURE_CTRL_FS 7:7 -#define ZV0_CAPTURE_CTRL_FS_DISABLE 0 -#define ZV0_CAPTURE_CTRL_FS_ENABLE 1 -#define ZV0_CAPTURE_CTRL_WEAVE 6:6 -#define ZV0_CAPTURE_CTRL_WEAVE_DISABLE 0 -#define ZV0_CAPTURE_CTRL_WEAVE_ENABLE 1 -#define ZV0_CAPTURE_CTRL_BOB 5:5 -#define ZV0_CAPTURE_CTRL_BOB_DISABLE 0 -#define ZV0_CAPTURE_CTRL_BOB_ENABLE 1 -#define ZV0_CAPTURE_CTRL_DB 4:4 -#define ZV0_CAPTURE_CTRL_DB_DISABLE 0 -#define ZV0_CAPTURE_CTRL_DB_ENABLE 1 -#define ZV0_CAPTURE_CTRL_CC 3:3 -#define ZV0_CAPTURE_CTRL_CC_CONTINUE 0 -#define ZV0_CAPTURE_CTRL_CC_CONDITION 1 -#define ZV0_CAPTURE_CTRL_RGB 2:2 -#define ZV0_CAPTURE_CTRL_RGB_DISABLE 0 -#define ZV0_CAPTURE_CTRL_RGB_ENABLE 1 -#define ZV0_CAPTURE_CTRL_656 1:1 -#define ZV0_CAPTURE_CTRL_656_DISABLE 0 -#define ZV0_CAPTURE_CTRL_656_ENABLE 1 -#define ZV0_CAPTURE_CTRL_CAP 0:0 -#define ZV0_CAPTURE_CTRL_CAP_DISABLE 0 -#define ZV0_CAPTURE_CTRL_CAP_ENABLE 1 +#define ZV0_CAPTURE_CTRL_FIELD_INPUT BIT(27) +#define ZV0_CAPTURE_CTRL_SCAN BIT(26) +#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER BIT(25) +#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC BIT(24) +#define ZV0_CAPTURE_CTRL_ADJ BIT(19) +#define ZV0_CAPTURE_CTRL_HA BIT(18) +#define ZV0_CAPTURE_CTRL_VSK BIT(17) +#define ZV0_CAPTURE_CTRL_HSK BIT(16) +#define ZV0_CAPTURE_CTRL_FD BIT(15) +#define ZV0_CAPTURE_CTRL_VP BIT(14) +#define ZV0_CAPTURE_CTRL_HP BIT(13) +#define ZV0_CAPTURE_CTRL_CP BIT(12) +#define ZV0_CAPTURE_CTRL_UVS BIT(11) +#define ZV0_CAPTURE_CTRL_BS BIT(10) +#define ZV0_CAPTURE_CTRL_CS BIT(9) +#define ZV0_CAPTURE_CTRL_CF BIT(8) +#define ZV0_CAPTURE_CTRL_FS BIT(7) +#define ZV0_CAPTURE_CTRL_WEAVE BIT(6) +#define ZV0_CAPTURE_CTRL_BOB BIT(5) +#define ZV0_CAPTURE_CTRL_DB BIT(4) +#define ZV0_CAPTURE_CTRL_CC BIT(3) +#define ZV0_CAPTURE_CTRL_RGB BIT(2) +#define ZV0_CAPTURE_CTRL_656 BIT(1) +#define ZV0_CAPTURE_CTRL_CAP BIT(0) #define ZV0_CAPTURE_CLIP 0x090004 -#define ZV0_CAPTURE_CLIP_YCLIP_EVEN_FIELD 25:16 -#define ZV0_CAPTURE_CLIP_YCLIP 25:16 -#define ZV0_CAPTURE_CLIP_XCLIP 9:0 +#define ZV0_CAPTURE_CLIP_EYCLIP_MASK (0x3ff << 16) +#define ZV0_CAPTURE_CLIP_XCLIP_MASK 0x3ff #define ZV0_CAPTURE_SIZE 0x090008 -#define ZV0_CAPTURE_SIZE_HEIGHT 26:16 -#define ZV0_CAPTURE_SIZE_WIDTH 10:0 +#define ZV0_CAPTURE_SIZE_HEIGHT_MASK (0x7ff << 16) +#define ZV0_CAPTURE_SIZE_WIDTH_MASK 0x7ff #define ZV0_CAPTURE_BUF0_ADDRESS 0x09000C -#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS 31:31 -#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS_CURRENT 0 -#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS_PENDING 1 -#define ZV0_CAPTURE_BUF0_ADDRESS_EXT 27:27 -#define ZV0_CAPTURE_BUF0_ADDRESS_EXT_LOCAL 0 -#define ZV0_CAPTURE_BUF0_ADDRESS_EXT_EXTERNAL 1 -#define ZV0_CAPTURE_BUF0_ADDRESS_CS 26:26 -#define ZV0_CAPTURE_BUF0_ADDRESS_CS_0 0 -#define ZV0_CAPTURE_BUF0_ADDRESS_CS_1 1 -#define ZV0_CAPTURE_BUF0_ADDRESS_ADDRESS 25:0 +#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS BIT(31) +#define ZV0_CAPTURE_BUF0_ADDRESS_EXT BIT(27) +#define ZV0_CAPTURE_BUF0_ADDRESS_CS BIT(26) +#define ZV0_CAPTURE_BUF0_ADDRESS_ADDRESS_MASK 0x3ffffff #define ZV0_CAPTURE_BUF1_ADDRESS 0x090010 -#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS 31:31 -#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS_CURRENT 0 -#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS_PENDING 1 -#define ZV0_CAPTURE_BUF1_ADDRESS_EXT 27:27 -#define ZV0_CAPTURE_BUF1_ADDRESS_EXT_LOCAL 0 -#define ZV0_CAPTURE_BUF1_ADDRESS_EXT_EXTERNAL 1 -#define ZV0_CAPTURE_BUF1_ADDRESS_CS 26:26 -#define ZV0_CAPTURE_BUF1_ADDRESS_CS_0 0 -#define ZV0_CAPTURE_BUF1_ADDRESS_CS_1 1 -#define ZV0_CAPTURE_BUF1_ADDRESS_ADDRESS 25:0 +#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS BIT(31) +#define ZV0_CAPTURE_BUF1_ADDRESS_EXT BIT(27) +#define ZV0_CAPTURE_BUF1_ADDRESS_CS BIT(26) +#define ZV0_CAPTURE_BUF1_ADDRESS_ADDRESS_MASK 0x3ffffff #define ZV0_CAPTURE_BUF_OFFSET 0x090014 #ifndef VALIDATION_CHIP - #define ZV0_CAPTURE_BUF_OFFSET_YCLIP_ODD_FIELD 25:16 + #define ZV0_CAPTURE_BUF_OFFSET_YCLIP_ODD_FIELD (0x3ff << 16) #endif -#define ZV0_CAPTURE_BUF_OFFSET_OFFSET 15:0 +#define ZV0_CAPTURE_BUF_OFFSET_OFFSET_MASK 0xffff #define ZV0_CAPTURE_FIFO_CTRL 0x090018 -#define ZV0_CAPTURE_FIFO_CTRL_FIFO 2:0 +#define ZV0_CAPTURE_FIFO_CTRL_FIFO_MASK 0x7 #define ZV0_CAPTURE_FIFO_CTRL_FIFO_0 0 #define ZV0_CAPTURE_FIFO_CTRL_FIFO_1 1 #define ZV0_CAPTURE_FIFO_CTRL_FIFO_2 2 @@ -1771,130 +1344,68 @@ #define ZV0_CAPTURE_FIFO_CTRL_FIFO_7 7 #define ZV0_CAPTURE_YRGB_CONST 0x09001C -#define ZV0_CAPTURE_YRGB_CONST_Y 31:24 -#define ZV0_CAPTURE_YRGB_CONST_R 23:16 -#define ZV0_CAPTURE_YRGB_CONST_G 15:8 -#define ZV0_CAPTURE_YRGB_CONST_B 7:0 +#define ZV0_CAPTURE_YRGB_CONST_Y_MASK (0xff << 24) +#define ZV0_CAPTURE_YRGB_CONST_R_MASK (0xff << 16) +#define ZV0_CAPTURE_YRGB_CONST_G_MASK (0xff << 8) +#define ZV0_CAPTURE_YRGB_CONST_B_MASK 0xff #define ZV0_CAPTURE_LINE_COMP 0x090020 -#define ZV0_CAPTURE_LINE_COMP_LC 10:0 +#define ZV0_CAPTURE_LINE_COMP_LC_MASK 0x7ff /* ZV1 */ #define ZV1_CAPTURE_CTRL 0x098000 -#define ZV1_CAPTURE_CTRL_FIELD_INPUT 27:27 -#define ZV1_CAPTURE_CTRL_FIELD_INPUT_EVEN_FIELD 0 -#define ZV1_CAPTURE_CTRL_FIELD_INPUT_ODD_FIELD 0 -#define ZV1_CAPTURE_CTRL_SCAN 26:26 -#define ZV1_CAPTURE_CTRL_SCAN_PROGRESSIVE 0 -#define ZV1_CAPTURE_CTRL_SCAN_INTERLACE 1 -#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER 25:25 -#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER_0 0 -#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER_1 1 -#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC 24:24 -#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC_INACTIVE 0 -#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC_ACTIVE 1 -#define ZV1_CAPTURE_CTRL_PANEL 20:20 -#define ZV1_CAPTURE_CTRL_PANEL_DISABLE 0 -#define ZV1_CAPTURE_CTRL_PANEL_ENABLE 1 -#define ZV1_CAPTURE_CTRL_ADJ 19:19 -#define ZV1_CAPTURE_CTRL_ADJ_NORMAL 0 -#define ZV1_CAPTURE_CTRL_ADJ_DELAY 1 -#define ZV1_CAPTURE_CTRL_HA 18:18 -#define ZV1_CAPTURE_CTRL_HA_DISABLE 0 -#define ZV1_CAPTURE_CTRL_HA_ENABLE 1 -#define ZV1_CAPTURE_CTRL_VSK 17:17 -#define ZV1_CAPTURE_CTRL_VSK_DISABLE 0 -#define ZV1_CAPTURE_CTRL_VSK_ENABLE 1 -#define ZV1_CAPTURE_CTRL_HSK 16:16 -#define ZV1_CAPTURE_CTRL_HSK_DISABLE 0 -#define ZV1_CAPTURE_CTRL_HSK_ENABLE 1 -#define ZV1_CAPTURE_CTRL_FD 15:15 -#define ZV1_CAPTURE_CTRL_FD_RISING 0 -#define ZV1_CAPTURE_CTRL_FD_FALLING 1 -#define ZV1_CAPTURE_CTRL_VP 14:14 -#define ZV1_CAPTURE_CTRL_VP_HIGH 0 -#define ZV1_CAPTURE_CTRL_VP_LOW 1 -#define ZV1_CAPTURE_CTRL_HP 13:13 -#define ZV1_CAPTURE_CTRL_HP_HIGH 0 -#define ZV1_CAPTURE_CTRL_HP_LOW 1 -#define ZV1_CAPTURE_CTRL_CP 12:12 -#define ZV1_CAPTURE_CTRL_CP_HIGH 0 -#define ZV1_CAPTURE_CTRL_CP_LOW 1 -#define ZV1_CAPTURE_CTRL_UVS 11:11 -#define ZV1_CAPTURE_CTRL_UVS_DISABLE 0 -#define ZV1_CAPTURE_CTRL_UVS_ENABLE 1 -#define ZV1_CAPTURE_CTRL_BS 10:10 -#define ZV1_CAPTURE_CTRL_BS_DISABLE 0 -#define ZV1_CAPTURE_CTRL_BS_ENABLE 1 -#define ZV1_CAPTURE_CTRL_CS 9:9 -#define ZV1_CAPTURE_CTRL_CS_16 0 -#define ZV1_CAPTURE_CTRL_CS_8 1 -#define ZV1_CAPTURE_CTRL_CF 8:8 -#define ZV1_CAPTURE_CTRL_CF_YUV 0 -#define ZV1_CAPTURE_CTRL_CF_RGB 1 -#define ZV1_CAPTURE_CTRL_FS 7:7 -#define ZV1_CAPTURE_CTRL_FS_DISABLE 0 -#define ZV1_CAPTURE_CTRL_FS_ENABLE 1 -#define ZV1_CAPTURE_CTRL_WEAVE 6:6 -#define ZV1_CAPTURE_CTRL_WEAVE_DISABLE 0 -#define ZV1_CAPTURE_CTRL_WEAVE_ENABLE 1 -#define ZV1_CAPTURE_CTRL_BOB 5:5 -#define ZV1_CAPTURE_CTRL_BOB_DISABLE 0 -#define ZV1_CAPTURE_CTRL_BOB_ENABLE 1 -#define ZV1_CAPTURE_CTRL_DB 4:4 -#define ZV1_CAPTURE_CTRL_DB_DISABLE 0 -#define ZV1_CAPTURE_CTRL_DB_ENABLE 1 -#define ZV1_CAPTURE_CTRL_CC 3:3 -#define ZV1_CAPTURE_CTRL_CC_CONTINUE 0 -#define ZV1_CAPTURE_CTRL_CC_CONDITION 1 -#define ZV1_CAPTURE_CTRL_RGB 2:2 -#define ZV1_CAPTURE_CTRL_RGB_DISABLE 0 -#define ZV1_CAPTURE_CTRL_RGB_ENABLE 1 -#define ZV1_CAPTURE_CTRL_656 1:1 -#define ZV1_CAPTURE_CTRL_656_DISABLE 0 -#define ZV1_CAPTURE_CTRL_656_ENABLE 1 -#define ZV1_CAPTURE_CTRL_CAP 0:0 -#define ZV1_CAPTURE_CTRL_CAP_DISABLE 0 -#define ZV1_CAPTURE_CTRL_CAP_ENABLE 1 +#define ZV1_CAPTURE_CTRL_FIELD_INPUT BIT(27) +#define ZV1_CAPTURE_CTRL_SCAN BIT(26) +#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER BIT(25) +#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC BIT(24) +#define ZV1_CAPTURE_CTRL_PANEL BIT(20) +#define ZV1_CAPTURE_CTRL_ADJ BIT(19) +#define ZV1_CAPTURE_CTRL_HA BIT(18) +#define ZV1_CAPTURE_CTRL_VSK BIT(17) +#define ZV1_CAPTURE_CTRL_HSK BIT(16) +#define ZV1_CAPTURE_CTRL_FD BIT(15) +#define ZV1_CAPTURE_CTRL_VP BIT(14) +#define ZV1_CAPTURE_CTRL_HP BIT(13) +#define ZV1_CAPTURE_CTRL_CP BIT(12) +#define ZV1_CAPTURE_CTRL_UVS BIT(11) +#define ZV1_CAPTURE_CTRL_BS BIT(10) +#define ZV1_CAPTURE_CTRL_CS BIT(9) +#define ZV1_CAPTURE_CTRL_CF BIT(8) +#define ZV1_CAPTURE_CTRL_FS BIT(7) +#define ZV1_CAPTURE_CTRL_WEAVE BIT(6) +#define ZV1_CAPTURE_CTRL_BOB BIT(5) +#define ZV1_CAPTURE_CTRL_DB BIT(4) +#define ZV1_CAPTURE_CTRL_CC BIT(3) +#define ZV1_CAPTURE_CTRL_RGB BIT(2) +#define ZV1_CAPTURE_CTRL_656 BIT(1) +#define ZV1_CAPTURE_CTRL_CAP BIT(0) #define ZV1_CAPTURE_CLIP 0x098004 -#define ZV1_CAPTURE_CLIP_YCLIP 25:16 -#define ZV1_CAPTURE_CLIP_XCLIP 9:0 +#define ZV1_CAPTURE_CLIP_YCLIP_MASK (0x3ff << 16) +#define ZV1_CAPTURE_CLIP_XCLIP_MASK 0x3ff #define ZV1_CAPTURE_SIZE 0x098008 -#define ZV1_CAPTURE_SIZE_HEIGHT 26:16 -#define ZV1_CAPTURE_SIZE_WIDTH 10:0 +#define ZV1_CAPTURE_SIZE_HEIGHT_MASK (0x7ff << 16) +#define ZV1_CAPTURE_SIZE_WIDTH_MASK 0x7ff #define ZV1_CAPTURE_BUF0_ADDRESS 0x09800C -#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS 31:31 -#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS_CURRENT 0 -#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS_PENDING 1 -#define ZV1_CAPTURE_BUF0_ADDRESS_EXT 27:27 -#define ZV1_CAPTURE_BUF0_ADDRESS_EXT_LOCAL 0 -#define ZV1_CAPTURE_BUF0_ADDRESS_EXT_EXTERNAL 1 -#define ZV1_CAPTURE_BUF0_ADDRESS_CS 26:26 -#define ZV1_CAPTURE_BUF0_ADDRESS_CS_0 0 -#define ZV1_CAPTURE_BUF0_ADDRESS_CS_1 1 -#define ZV1_CAPTURE_BUF0_ADDRESS_ADDRESS 25:0 +#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS BIT(31) +#define ZV1_CAPTURE_BUF0_ADDRESS_EXT BIT(27) +#define ZV1_CAPTURE_BUF0_ADDRESS_CS BIT(26) +#define ZV1_CAPTURE_BUF0_ADDRESS_ADDRESS_MASK 0x3ffffff #define ZV1_CAPTURE_BUF1_ADDRESS 0x098010 -#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS 31:31 -#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS_CURRENT 0 -#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS_PENDING 1 -#define ZV1_CAPTURE_BUF1_ADDRESS_EXT 27:27 -#define ZV1_CAPTURE_BUF1_ADDRESS_EXT_LOCAL 0 -#define ZV1_CAPTURE_BUF1_ADDRESS_EXT_EXTERNAL 1 -#define ZV1_CAPTURE_BUF1_ADDRESS_CS 26:26 -#define ZV1_CAPTURE_BUF1_ADDRESS_CS_0 0 -#define ZV1_CAPTURE_BUF1_ADDRESS_CS_1 1 -#define ZV1_CAPTURE_BUF1_ADDRESS_ADDRESS 25:0 +#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS BIT(31) +#define ZV1_CAPTURE_BUF1_ADDRESS_EXT BIT(27) +#define ZV1_CAPTURE_BUF1_ADDRESS_CS BIT(26) +#define ZV1_CAPTURE_BUF1_ADDRESS_ADDRESS_MASK 0x3ffffff #define ZV1_CAPTURE_BUF_OFFSET 0x098014 -#define ZV1_CAPTURE_BUF_OFFSET_OFFSET 15:0 +#define ZV1_CAPTURE_BUF_OFFSET_OFFSET_MASK 0xffff #define ZV1_CAPTURE_FIFO_CTRL 0x098018 -#define ZV1_CAPTURE_FIFO_CTRL_FIFO 2:0 +#define ZV1_CAPTURE_FIFO_CTRL_FIFO_MASK 0x7 #define ZV1_CAPTURE_FIFO_CTRL_FIFO_0 0 #define ZV1_CAPTURE_FIFO_CTRL_FIFO_1 1 #define ZV1_CAPTURE_FIFO_CTRL_FIFO_2 2 @@ -1905,34 +1416,24 @@ #define ZV1_CAPTURE_FIFO_CTRL_FIFO_7 7 #define ZV1_CAPTURE_YRGB_CONST 0x09801C -#define ZV1_CAPTURE_YRGB_CONST_Y 31:24 -#define ZV1_CAPTURE_YRGB_CONST_R 23:16 -#define ZV1_CAPTURE_YRGB_CONST_G 15:8 -#define ZV1_CAPTURE_YRGB_CONST_B 7:0 +#define ZV1_CAPTURE_YRGB_CONST_Y_MASK (0xff << 24) +#define ZV1_CAPTURE_YRGB_CONST_R_MASK (0xff << 16) +#define ZV1_CAPTURE_YRGB_CONST_G_MASK (0xff << 8) +#define ZV1_CAPTURE_YRGB_CONST_B_MASK 0xff #define DMA_1_SOURCE 0x0D0010 -#define DMA_1_SOURCE_ADDRESS_EXT 27:27 -#define DMA_1_SOURCE_ADDRESS_EXT_LOCAL 0 -#define DMA_1_SOURCE_ADDRESS_EXT_EXTERNAL 1 -#define DMA_1_SOURCE_ADDRESS_CS 26:26 -#define DMA_1_SOURCE_ADDRESS_CS_0 0 -#define DMA_1_SOURCE_ADDRESS_CS_1 1 -#define DMA_1_SOURCE_ADDRESS 25:0 +#define DMA_1_SOURCE_ADDRESS_EXT BIT(27) +#define DMA_1_SOURCE_ADDRESS_CS BIT(26) +#define DMA_1_SOURCE_ADDRESS_MASK 0x3ffffff #define DMA_1_DESTINATION 0x0D0014 -#define DMA_1_DESTINATION_ADDRESS_EXT 27:27 -#define DMA_1_DESTINATION_ADDRESS_EXT_LOCAL 0 -#define DMA_1_DESTINATION_ADDRESS_EXT_EXTERNAL 1 -#define DMA_1_DESTINATION_ADDRESS_CS 26:26 -#define DMA_1_DESTINATION_ADDRESS_CS_0 0 -#define DMA_1_DESTINATION_ADDRESS_CS_1 1 -#define DMA_1_DESTINATION_ADDRESS 25:0 +#define DMA_1_DESTINATION_ADDRESS_EXT BIT(27) +#define DMA_1_DESTINATION_ADDRESS_CS BIT(26) +#define DMA_1_DESTINATION_ADDRESS_MASK 0x3ffffff #define DMA_1_SIZE_CONTROL 0x0D0018 -#define DMA_1_SIZE_CONTROL_STATUS 31:31 -#define DMA_1_SIZE_CONTROL_STATUS_IDLE 0 -#define DMA_1_SIZE_CONTROL_STATUS_ACTIVE 1 -#define DMA_1_SIZE_CONTROL_SIZE 23:0 +#define DMA_1_SIZE_CONTROL_STATUS BIT(31) +#define DMA_1_SIZE_CONTROL_SIZE_MASK 0xffffff #define DMA_ABORT_INTERRUPT 0x0D0020 #define DMA_ABORT_INTERRUPT_ABORT_1 BIT(5) @@ -1946,16 +1447,12 @@ #define GPIO_DATA_SM750LE 0x020018 -#define GPIO_DATA_SM750LE_1 1:1 -#define GPIO_DATA_SM750LE_0 0:0 +#define GPIO_DATA_SM750LE_1 BIT(1) +#define GPIO_DATA_SM750LE_0 BIT(0) #define GPIO_DATA_DIRECTION_SM750LE 0x02001C -#define GPIO_DATA_DIRECTION_SM750LE_1 1:1 -#define GPIO_DATA_DIRECTION_SM750LE_1_INPUT 0 -#define GPIO_DATA_DIRECTION_SM750LE_1_OUTPUT 1 -#define GPIO_DATA_DIRECTION_SM750LE_0 0:0 -#define GPIO_DATA_DIRECTION_SM750LE_0_INPUT 0 -#define GPIO_DATA_DIRECTION_SM750LE_0_OUTPUT 1 +#define GPIO_DATA_DIRECTION_SM750LE_1 BIT(1) +#define GPIO_DATA_DIRECTION_SM750LE_0 BIT(0) #endif diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index c9d4871..59c7455 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -13,8 +13,6 @@ #include <linux/vmalloc.h> #include <linux/pagemap.h> #include <linux/screen_info.h> -#include <linux/vmalloc.h> -#include <linux/pagemap.h> #include <linux/console.h> #include <asm/fb.h> #include "sm750.h" diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index e150680..9aa4066 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -17,7 +17,6 @@ #include "sm750.h" #include "sm750_accel.h" -#include "sm750_help.h" static inline void write_dpr(struct lynx_accel *accel, int offset, u32 regValue) { writel(regValue, accel->dprBase + offset); @@ -41,20 +40,16 @@ void hw_de_init(struct lynx_accel *accel) write_dpr(accel, DE_MASKS, 0xFFFFFFFF); /* dpr1c */ - reg = FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, NORMAL)| - FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_Y, 0)| - FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, 0)| - FIELD_SET(0, DE_STRETCH_FORMAT, ADDRESSING, XY)| - FIELD_VALUE(0, DE_STRETCH_FORMAT, SOURCE_HEIGHT, 3); - - clr = FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_XY)& - FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_Y)& - FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_X)& - FIELD_CLEAR(DE_STRETCH_FORMAT, ADDRESSING)& - FIELD_CLEAR(DE_STRETCH_FORMAT, SOURCE_HEIGHT); + reg = 0x3; + + clr = DE_STRETCH_FORMAT_PATTERN_XY | DE_STRETCH_FORMAT_PATTERN_Y_MASK | + DE_STRETCH_FORMAT_PATTERN_X_MASK | + DE_STRETCH_FORMAT_ADDRESSING_MASK | + DE_STRETCH_FORMAT_SOURCE_HEIGHT_MASK; /* DE_STRETCH bpp format need be initialized in setMode routine */ - write_dpr(accel, DE_STRETCH_FORMAT, (read_dpr(accel, DE_STRETCH_FORMAT) & clr) | reg); + write_dpr(accel, DE_STRETCH_FORMAT, + (read_dpr(accel, DE_STRETCH_FORMAT) & ~clr) | reg); /* disable clipping and transparent */ write_dpr(accel, DE_CLIP_TL, 0); /* dpr2c */ @@ -63,16 +58,11 @@ void hw_de_init(struct lynx_accel *accel) write_dpr(accel, DE_COLOR_COMPARE_MASK, 0); /* dpr24 */ write_dpr(accel, DE_COLOR_COMPARE, 0); - reg = FIELD_SET(0, DE_CONTROL, TRANSPARENCY, DISABLE)| - FIELD_SET(0, DE_CONTROL, TRANSPARENCY_MATCH, OPAQUE)| - FIELD_SET(0, DE_CONTROL, TRANSPARENCY_SELECT, SOURCE); - - clr = FIELD_CLEAR(DE_CONTROL, TRANSPARENCY)& - FIELD_CLEAR(DE_CONTROL, TRANSPARENCY_MATCH)& - FIELD_CLEAR(DE_CONTROL, TRANSPARENCY_SELECT); + clr = DE_CONTROL_TRANSPARENCY | DE_CONTROL_TRANSPARENCY_MATCH | + DE_CONTROL_TRANSPARENCY_SELECT; /* dpr0c */ - write_dpr(accel, DE_CONTROL, (read_dpr(accel, DE_CONTROL)&clr)|reg); + write_dpr(accel, DE_CONTROL, read_dpr(accel, DE_CONTROL) & ~clr); } /* set2dformat only be called from setmode functions @@ -85,7 +75,9 @@ void hw_set2dformat(struct lynx_accel *accel, int fmt) /* fmt=0,1,2 for 8,16,32,bpp on sm718/750/502 */ reg = read_dpr(accel, DE_STRETCH_FORMAT); - reg = FIELD_VALUE(reg, DE_STRETCH_FORMAT, PIXEL_FORMAT, fmt); + reg &= ~DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK; + reg |= ((fmt << DE_STRETCH_FORMAT_PIXEL_FORMAT_SHIFT) & + DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK); write_dpr(accel, DE_STRETCH_FORMAT, reg); } @@ -105,31 +97,28 @@ int hw_fillrect(struct lynx_accel *accel, write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */ write_dpr(accel, DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, pitch/Bpp)| - FIELD_VALUE(0, DE_PITCH, SOURCE, pitch/Bpp)); /* dpr10 */ + ((pitch / Bpp << DE_PITCH_DESTINATION_SHIFT) & + DE_PITCH_DESTINATION_MASK) | + (pitch / Bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */ write_dpr(accel, DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, pitch/Bpp)| - FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, pitch/Bpp)); /* dpr44 */ + ((pitch / Bpp << DE_WINDOW_WIDTH_DST_SHIFT) & + DE_WINDOW_WIDTH_DST_MASK) | + (pitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr44 */ write_dpr(accel, DE_FOREGROUND, color); /* DPR14 */ write_dpr(accel, DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE)| - FIELD_VALUE(0, DE_DESTINATION, X, x)| - FIELD_VALUE(0, DE_DESTINATION, Y, y)); /* dpr4 */ + ((x << DE_DESTINATION_X_SHIFT) & DE_DESTINATION_X_MASK) | + (y & DE_DESTINATION_Y_MASK)); /* dpr4 */ write_dpr(accel, DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, width)| - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr8 */ + ((width << DE_DIMENSION_X_SHIFT) & DE_DIMENSION_X_MASK) | + (height & DE_DIMENSION_Y_ET_MASK)); /* dpr8 */ - deCtrl = - FIELD_SET(0, DE_CONTROL, STATUS, START)| - FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)| - FIELD_SET(0, DE_CONTROL, LAST_PIXEL, ON)| - FIELD_SET(0, DE_CONTROL, COMMAND, RECTANGLE_FILL)| - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2)| - FIELD_VALUE(0, DE_CONTROL, ROP, rop); /* dpr0xc */ + deCtrl = DE_CONTROL_STATUS | DE_CONTROL_LAST_PIXEL | + DE_CONTROL_COMMAND_RECTANGLE_FILL | DE_CONTROL_ROP_SELECT | + (rop & DE_CONTROL_ROP_MASK); /* dpr0xc */ write_dpr(accel, DE_CONTROL, deCtrl); return 0; @@ -237,18 +226,18 @@ unsigned int rop2) /* ROP value */ Note that input pitch is BYTE value, but the 2D Pitch register uses pixel values. Need Byte to pixel conversion. */ - { - write_dpr(accel, DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, (dPitch/Bpp)) | - FIELD_VALUE(0, DE_PITCH, SOURCE, (sPitch/Bpp))); /* dpr10 */ - } + write_dpr(accel, DE_PITCH, + ((dPitch / Bpp << DE_PITCH_DESTINATION_SHIFT) & + DE_PITCH_DESTINATION_MASK) | + (sPitch / Bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */ /* Screen Window width in Pixels. 2D engine uses this value to calculate the linear address in frame buffer for a given point. */ write_dpr(accel, DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) | - FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (sPitch/Bpp))); /* dpr3c */ + ((dPitch / Bpp << DE_WINDOW_WIDTH_DST_SHIFT) & + DE_WINDOW_WIDTH_DST_MASK) | + (sPitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */ if (accel->de_wait() != 0) return -1; @@ -256,24 +245,18 @@ unsigned int rop2) /* ROP value */ { write_dpr(accel, DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1, sx) | - FIELD_VALUE(0, DE_SOURCE, Y_K2, sy)); /* dpr0 */ + ((sx << DE_SOURCE_X_K1_SHIFT) & DE_SOURCE_X_K1_MASK) | + (sy & DE_SOURCE_Y_K2_MASK)); /* dpr0 */ write_dpr(accel, DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, dx) | - FIELD_VALUE(0, DE_DESTINATION, Y, dy)); /* dpr04 */ + ((dx << DE_DESTINATION_X_SHIFT) & DE_DESTINATION_X_MASK) | + (dy & DE_DESTINATION_Y_MASK)); /* dpr04 */ write_dpr(accel, DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */ - - de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) | - ((nDirection == RIGHT_TO_LEFT) ? - FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT) - : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) | - FIELD_SET(0, DE_CONTROL, STATUS, START); + ((width << DE_DIMENSION_X_SHIFT) & DE_DIMENSION_X_MASK) | + (height & DE_DIMENSION_Y_ET_MASK)); /* dpr08 */ + + de_ctrl = (rop2 & DE_CONTROL_ROP_MASK) | DE_CONTROL_ROP_SELECT | + ((nDirection == RIGHT_TO_LEFT) ? DE_CONTROL_DIRECTION : 0) | + DE_CONTROL_COMMAND_BITBLT | DE_CONTROL_STATUS; write_dpr(accel, DE_CONTROL, de_ctrl); /* dpr0c */ } @@ -287,10 +270,8 @@ static unsigned int deGetTransparency(struct lynx_accel *accel) de_ctrl = read_dpr(accel, DE_CONTROL); - de_ctrl &= - FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) | - FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT)| - FIELD_MASK(DE_CONTROL_TRANSPARENCY); + de_ctrl &= (DE_CONTROL_TRANSPARENCY_MATCH | + DE_CONTROL_TRANSPARENCY_SELECT | DE_CONTROL_TRANSPARENCY); return de_ctrl; } @@ -338,42 +319,39 @@ int hw_imageblit(struct lynx_accel *accel, Note that input pitch is BYTE value, but the 2D Pitch register uses pixel values. Need Byte to pixel conversion. */ - { - write_dpr(accel, DE_PITCH, - FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch/bytePerPixel) | - FIELD_VALUE(0, DE_PITCH, SOURCE, dPitch/bytePerPixel)); /* dpr10 */ - } + write_dpr(accel, DE_PITCH, + ((dPitch / bytePerPixel << DE_PITCH_DESTINATION_SHIFT) & + DE_PITCH_DESTINATION_MASK) | + (dPitch / bytePerPixel & DE_PITCH_SOURCE_MASK)); /* dpr10 */ /* Screen Window width in Pixels. 2D engine uses this value to calculate the linear address in frame buffer for a given point. */ write_dpr(accel, DE_WINDOW_WIDTH, - FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/bytePerPixel)) | - FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE, (dPitch/bytePerPixel))); + ((dPitch / bytePerPixel << DE_WINDOW_WIDTH_DST_SHIFT) & + DE_WINDOW_WIDTH_DST_MASK) | + (dPitch / bytePerPixel & DE_WINDOW_WIDTH_SRC_MASK)); /* Note: For 2D Source in Host Write, only X_K1_MONO field is needed, and Y_K2 field is not used. For mono bitmap, use startBit for X_K1. */ write_dpr(accel, DE_SOURCE, - FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) | - FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit)); /* dpr00 */ + (startBit << DE_SOURCE_X_K1_SHIFT) & + DE_SOURCE_X_K1_MONO_MASK); /* dpr00 */ write_dpr(accel, DE_DESTINATION, - FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) | - FIELD_VALUE(0, DE_DESTINATION, X, dx) | - FIELD_VALUE(0, DE_DESTINATION, Y, dy)); /* dpr04 */ + ((dx << DE_DESTINATION_X_SHIFT) & DE_DESTINATION_X_MASK) | + (dy & DE_DESTINATION_Y_MASK)); /* dpr04 */ write_dpr(accel, DE_DIMENSION, - FIELD_VALUE(0, DE_DIMENSION, X, width) | - FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */ + ((width << DE_DIMENSION_X_SHIFT) & DE_DIMENSION_X_MASK) | + (height & DE_DIMENSION_Y_ET_MASK)); /* dpr08 */ write_dpr(accel, DE_FOREGROUND, fColor); write_dpr(accel, DE_BACKGROUND, bColor); - de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) | - FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) | - FIELD_SET(0, DE_CONTROL, COMMAND, HOST_WRITE) | - FIELD_SET(0, DE_CONTROL, HOST, MONO) | - FIELD_SET(0, DE_CONTROL, STATUS, START); + de_ctrl = (rop2 & DE_CONTROL_ROP_MASK) | + DE_CONTROL_ROP_SELECT | DE_CONTROL_COMMAND_HOST_WRITE | + DE_CONTROL_HOST | DE_CONTROL_STATUS; write_dpr(accel, DE_CONTROL, de_ctrl | deGetTransparency(accel)); diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h index 1ec66d2..d59d005 100644 --- a/drivers/staging/sm750fb/sm750_accel.h +++ b/drivers/staging/sm750fb/sm750_accel.h @@ -21,212 +21,162 @@ #define DE_PORT_ADDR_TYPE3 0x100000 #define DE_SOURCE 0x0 -#define DE_SOURCE_WRAP 31:31 -#define DE_SOURCE_WRAP_DISABLE 0 -#define DE_SOURCE_WRAP_ENABLE 1 -#define DE_SOURCE_X_K1 29:16 -#define DE_SOURCE_Y_K2 15:0 -#define DE_SOURCE_X_K1_MONO 20:16 +#define DE_SOURCE_WRAP BIT(31) +#define DE_SOURCE_X_K1_SHIFT 16 +#define DE_SOURCE_X_K1_MASK (0x3fff << 16) +#define DE_SOURCE_X_K1_MONO_MASK (0x1f << 16) +#define DE_SOURCE_Y_K2_MASK 0xffff #define DE_DESTINATION 0x4 -#define DE_DESTINATION_WRAP 31:31 -#define DE_DESTINATION_WRAP_DISABLE 0 -#define DE_DESTINATION_WRAP_ENABLE 1 -#define DE_DESTINATION_X 28:16 -#define DE_DESTINATION_Y 15:0 +#define DE_DESTINATION_WRAP BIT(31) +#define DE_DESTINATION_X_SHIFT 16 +#define DE_DESTINATION_X_MASK (0x1fff << 16) +#define DE_DESTINATION_Y_MASK 0xffff #define DE_DIMENSION 0x8 -#define DE_DIMENSION_X 28:16 -#define DE_DIMENSION_Y_ET 15:0 +#define DE_DIMENSION_X_SHIFT 16 +#define DE_DIMENSION_X_MASK (0x1fff << 16) +#define DE_DIMENSION_Y_ET_MASK 0x1fff #define DE_CONTROL 0xC -#define DE_CONTROL_STATUS 31:31 -#define DE_CONTROL_STATUS_STOP 0 -#define DE_CONTROL_STATUS_START 1 -#define DE_CONTROL_PATTERN 30:30 -#define DE_CONTROL_PATTERN_MONO 0 -#define DE_CONTROL_PATTERN_COLOR 1 -#define DE_CONTROL_UPDATE_DESTINATION_X 29:29 -#define DE_CONTROL_UPDATE_DESTINATION_X_DISABLE 0 -#define DE_CONTROL_UPDATE_DESTINATION_X_ENABLE 1 -#define DE_CONTROL_QUICK_START 28:28 -#define DE_CONTROL_QUICK_START_DISABLE 0 -#define DE_CONTROL_QUICK_START_ENABLE 1 -#define DE_CONTROL_DIRECTION 27:27 -#define DE_CONTROL_DIRECTION_LEFT_TO_RIGHT 0 -#define DE_CONTROL_DIRECTION_RIGHT_TO_LEFT 1 -#define DE_CONTROL_MAJOR 26:26 -#define DE_CONTROL_MAJOR_X 0 -#define DE_CONTROL_MAJOR_Y 1 -#define DE_CONTROL_STEP_X 25:25 -#define DE_CONTROL_STEP_X_POSITIVE 1 -#define DE_CONTROL_STEP_X_NEGATIVE 0 -#define DE_CONTROL_STEP_Y 24:24 -#define DE_CONTROL_STEP_Y_POSITIVE 1 -#define DE_CONTROL_STEP_Y_NEGATIVE 0 -#define DE_CONTROL_STRETCH 23:23 -#define DE_CONTROL_STRETCH_DISABLE 0 -#define DE_CONTROL_STRETCH_ENABLE 1 -#define DE_CONTROL_HOST 22:22 -#define DE_CONTROL_HOST_COLOR 0 -#define DE_CONTROL_HOST_MONO 1 -#define DE_CONTROL_LAST_PIXEL 21:21 -#define DE_CONTROL_LAST_PIXEL_OFF 0 -#define DE_CONTROL_LAST_PIXEL_ON 1 -#define DE_CONTROL_COMMAND 20:16 -#define DE_CONTROL_COMMAND_BITBLT 0 -#define DE_CONTROL_COMMAND_RECTANGLE_FILL 1 -#define DE_CONTROL_COMMAND_DE_TILE 2 -#define DE_CONTROL_COMMAND_TRAPEZOID_FILL 3 -#define DE_CONTROL_COMMAND_ALPHA_BLEND 4 -#define DE_CONTROL_COMMAND_RLE_STRIP 5 -#define DE_CONTROL_COMMAND_SHORT_STROKE 6 -#define DE_CONTROL_COMMAND_LINE_DRAW 7 -#define DE_CONTROL_COMMAND_HOST_WRITE 8 -#define DE_CONTROL_COMMAND_HOST_READ 9 -#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP 10 -#define DE_CONTROL_COMMAND_ROTATE 11 -#define DE_CONTROL_COMMAND_FONT 12 -#define DE_CONTROL_COMMAND_TEXTURE_LOAD 15 -#define DE_CONTROL_ROP_SELECT 15:15 -#define DE_CONTROL_ROP_SELECT_ROP3 0 -#define DE_CONTROL_ROP_SELECT_ROP2 1 -#define DE_CONTROL_ROP2_SOURCE 14:14 -#define DE_CONTROL_ROP2_SOURCE_BITMAP 0 -#define DE_CONTROL_ROP2_SOURCE_PATTERN 1 -#define DE_CONTROL_MONO_DATA 13:12 -#define DE_CONTROL_MONO_DATA_NOT_PACKED 0 -#define DE_CONTROL_MONO_DATA_8_PACKED 1 -#define DE_CONTROL_MONO_DATA_16_PACKED 2 -#define DE_CONTROL_MONO_DATA_32_PACKED 3 -#define DE_CONTROL_REPEAT_ROTATE 11:11 -#define DE_CONTROL_REPEAT_ROTATE_DISABLE 0 -#define DE_CONTROL_REPEAT_ROTATE_ENABLE 1 -#define DE_CONTROL_TRANSPARENCY_MATCH 10:10 -#define DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE 0 -#define DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT 1 -#define DE_CONTROL_TRANSPARENCY_SELECT 9:9 -#define DE_CONTROL_TRANSPARENCY_SELECT_SOURCE 0 -#define DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION 1 -#define DE_CONTROL_TRANSPARENCY 8:8 -#define DE_CONTROL_TRANSPARENCY_DISABLE 0 -#define DE_CONTROL_TRANSPARENCY_ENABLE 1 -#define DE_CONTROL_ROP 7:0 +#define DE_CONTROL_STATUS BIT(31) +#define DE_CONTROL_PATTERN BIT(30) +#define DE_CONTROL_UPDATE_DESTINATION_X BIT(29) +#define DE_CONTROL_QUICK_START BIT(28) +#define DE_CONTROL_DIRECTION BIT(27) +#define DE_CONTROL_MAJOR BIT(26) +#define DE_CONTROL_STEP_X BIT(25) +#define DE_CONTROL_STEP_Y BIT(24) +#define DE_CONTROL_STRETCH BIT(23) +#define DE_CONTROL_HOST BIT(22) +#define DE_CONTROL_LAST_PIXEL BIT(21) +#define DE_CONTROL_COMMAND_SHIFT 16 +#define DE_CONTROL_COMMAND_MASK (0x1f << 16) +#define DE_CONTROL_COMMAND_BITBLT (0x0 << 16) +#define DE_CONTROL_COMMAND_RECTANGLE_FILL (0x1 << 16) +#define DE_CONTROL_COMMAND_DE_TILE (0x2 << 16) +#define DE_CONTROL_COMMAND_TRAPEZOID_FILL (0x3 << 16) +#define DE_CONTROL_COMMAND_ALPHA_BLEND (0x4 << 16) +#define DE_CONTROL_COMMAND_RLE_STRIP (0x5 << 16) +#define DE_CONTROL_COMMAND_SHORT_STROKE (0x6 << 16) +#define DE_CONTROL_COMMAND_LINE_DRAW (0x7 << 16) +#define DE_CONTROL_COMMAND_HOST_WRITE (0x8 << 16) +#define DE_CONTROL_COMMAND_HOST_READ (0x9 << 16) +#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP (0xa << 16) +#define DE_CONTROL_COMMAND_ROTATE (0xb << 16) +#define DE_CONTROL_COMMAND_FONT (0xc << 16) +#define DE_CONTROL_COMMAND_TEXTURE_LOAD (0xe << 16) +#define DE_CONTROL_ROP_SELECT BIT(15) +#define DE_CONTROL_ROP2_SOURCE BIT(14) +#define DE_CONTROL_MONO_DATA_SHIFT 12 +#define DE_CONTROL_MONO_DATA_MASK (0x3 << 12) +#define DE_CONTROL_MONO_DATA_NOT_PACKED (0x0 << 12) +#define DE_CONTROL_MONO_DATA_8_PACKED (0x1 << 12) +#define DE_CONTROL_MONO_DATA_16_PACKED (0x2 << 12) +#define DE_CONTROL_MONO_DATA_32_PACKED (0x3 << 12) +#define DE_CONTROL_REPEAT_ROTATE BIT(11) +#define DE_CONTROL_TRANSPARENCY_MATCH BIT(10) +#define DE_CONTROL_TRANSPARENCY_SELECT BIT(9) +#define DE_CONTROL_TRANSPARENCY BIT(8) +#define DE_CONTROL_ROP_MASK 0xff /* Pseudo fields. */ -#define DE_CONTROL_SHORT_STROKE_DIR 27:24 -#define DE_CONTROL_SHORT_STROKE_DIR_225 0 -#define DE_CONTROL_SHORT_STROKE_DIR_135 1 -#define DE_CONTROL_SHORT_STROKE_DIR_315 2 -#define DE_CONTROL_SHORT_STROKE_DIR_45 3 -#define DE_CONTROL_SHORT_STROKE_DIR_270 4 -#define DE_CONTROL_SHORT_STROKE_DIR_90 5 -#define DE_CONTROL_SHORT_STROKE_DIR_180 8 -#define DE_CONTROL_SHORT_STROKE_DIR_0 10 -#define DE_CONTROL_ROTATION 25:24 -#define DE_CONTROL_ROTATION_0 0 -#define DE_CONTROL_ROTATION_270 1 -#define DE_CONTROL_ROTATION_90 2 -#define DE_CONTROL_ROTATION_180 3 +#define DE_CONTROL_SHORT_STROKE_DIR_MASK (0xf << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_225 (0x0 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_135 (0x1 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_315 (0x2 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_45 (0x3 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_270 (0x4 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_90 (0x5 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_180 (0x8 << 24) +#define DE_CONTROL_SHORT_STROKE_DIR_0 (0xa << 24) +#define DE_CONTROL_ROTATION_MASK (0x3 << 24) +#define DE_CONTROL_ROTATION_0 (0x0 << 24) +#define DE_CONTROL_ROTATION_270 (0x1 << 24) +#define DE_CONTROL_ROTATION_90 (0x2 << 24) +#define DE_CONTROL_ROTATION_180 (0x3 << 24) #define DE_PITCH 0x000010 -#define DE_PITCH_DESTINATION 28:16 -#define DE_PITCH_SOURCE 12:0 +#define DE_PITCH_DESTINATION_SHIFT 16 +#define DE_PITCH_DESTINATION_MASK (0x1fff << 16) +#define DE_PITCH_SOURCE_MASK 0x1fff #define DE_FOREGROUND 0x000014 -#define DE_FOREGROUND_COLOR 31:0 +#define DE_FOREGROUND_COLOR_MASK 0xffffffff #define DE_BACKGROUND 0x000018 -#define DE_BACKGROUND_COLOR 31:0 +#define DE_BACKGROUND_COLOR_MASK 0xffffffff #define DE_STRETCH_FORMAT 0x00001C -#define DE_STRETCH_FORMAT_PATTERN_XY 30:30 -#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL 0 -#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE 1 -#define DE_STRETCH_FORMAT_PATTERN_Y 29:27 -#define DE_STRETCH_FORMAT_PATTERN_X 25:23 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT 21:20 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8 0 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16 1 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32 2 -#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24 3 - -#define DE_STRETCH_FORMAT_ADDRESSING 19:16 -#define DE_STRETCH_FORMAT_ADDRESSING_XY 0 -#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR 15 -#define DE_STRETCH_FORMAT_SOURCE_HEIGHT 11:0 +#define DE_STRETCH_FORMAT_PATTERN_XY BIT(30) +#define DE_STRETCH_FORMAT_PATTERN_Y_SHIFT 27 +#define DE_STRETCH_FORMAT_PATTERN_Y_MASK (0x7 << 27) +#define DE_STRETCH_FORMAT_PATTERN_X_SHIFT 23 +#define DE_STRETCH_FORMAT_PATTERN_X_MASK (0x7 << 23) +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_SHIFT 20 +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK (0x3 << 20) +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8 (0x0 << 20) +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16 (0x1 << 20) +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32 (0x2 << 20) +#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24 (0x3 << 20) +#define DE_STRETCH_FORMAT_ADDRESSING_SHIFT 16 +#define DE_STRETCH_FORMAT_ADDRESSING_MASK (0xf << 16) +#define DE_STRETCH_FORMAT_ADDRESSING_XY (0x0 << 16) +#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR (0xf << 16) +#define DE_STRETCH_FORMAT_SOURCE_HEIGHT_MASK 0xfff #define DE_COLOR_COMPARE 0x000020 -#define DE_COLOR_COMPARE_COLOR 23:0 +#define DE_COLOR_COMPARE_COLOR_MASK 0xffffff #define DE_COLOR_COMPARE_MASK 0x000024 -#define DE_COLOR_COMPARE_MASK_MASKS 23:0 +#define DE_COLOR_COMPARE_MASK_MASK 0xffffff #define DE_MASKS 0x000028 -#define DE_MASKS_BYTE_MASK 31:16 -#define DE_MASKS_BIT_MASK 15:0 +#define DE_MASKS_BYTE_MASK (0xffff << 16) +#define DE_MASKS_BIT_MASK 0xffff #define DE_CLIP_TL 0x00002C -#define DE_CLIP_TL_TOP 31:16 -#define DE_CLIP_TL_STATUS 13:13 -#define DE_CLIP_TL_STATUS_DISABLE 0 -#define DE_CLIP_TL_STATUS_ENABLE 1 -#define DE_CLIP_TL_INHIBIT 12:12 -#define DE_CLIP_TL_INHIBIT_OUTSIDE 0 -#define DE_CLIP_TL_INHIBIT_INSIDE 1 -#define DE_CLIP_TL_LEFT 11:0 +#define DE_CLIP_TL_TOP_MASK (0xffff << 16) +#define DE_CLIP_TL_STATUS BIT(13) +#define DE_CLIP_TL_INHIBIT BIT(12) +#define DE_CLIP_TL_LEFT_MASK 0xfff #define DE_CLIP_BR 0x000030 -#define DE_CLIP_BR_BOTTOM 31:16 -#define DE_CLIP_BR_RIGHT 12:0 +#define DE_CLIP_BR_BOTTOM_MASK (0xffff << 16) +#define DE_CLIP_BR_RIGHT_MASK 0x1fff #define DE_MONO_PATTERN_LOW 0x000034 -#define DE_MONO_PATTERN_LOW_PATTERN 31:0 +#define DE_MONO_PATTERN_LOW_PATTERN_MASK 0xffffffff #define DE_MONO_PATTERN_HIGH 0x000038 -#define DE_MONO_PATTERN_HIGH_PATTERN 31:0 +#define DE_MONO_PATTERN_HIGH_PATTERN_MASK 0xffffffff #define DE_WINDOW_WIDTH 0x00003C -#define DE_WINDOW_WIDTH_DESTINATION 28:16 -#define DE_WINDOW_WIDTH_SOURCE 12:0 +#define DE_WINDOW_WIDTH_DST_SHIFT 16 +#define DE_WINDOW_WIDTH_DST_MASK (0x1fff << 16) +#define DE_WINDOW_WIDTH_SRC_MASK 0x1fff #define DE_WINDOW_SOURCE_BASE 0x000040 -#define DE_WINDOW_SOURCE_BASE_EXT 27:27 -#define DE_WINDOW_SOURCE_BASE_EXT_LOCAL 0 -#define DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL 1 -#define DE_WINDOW_SOURCE_BASE_CS 26:26 -#define DE_WINDOW_SOURCE_BASE_CS_0 0 -#define DE_WINDOW_SOURCE_BASE_CS_1 1 -#define DE_WINDOW_SOURCE_BASE_ADDRESS 25:0 +#define DE_WINDOW_SOURCE_BASE_EXT BIT(27) +#define DE_WINDOW_SOURCE_BASE_CS BIT(26) +#define DE_WINDOW_SOURCE_BASE_ADDRESS_MASK 0x3ffffff #define DE_WINDOW_DESTINATION_BASE 0x000044 -#define DE_WINDOW_DESTINATION_BASE_EXT 27:27 -#define DE_WINDOW_DESTINATION_BASE_EXT_LOCAL 0 -#define DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL 1 -#define DE_WINDOW_DESTINATION_BASE_CS 26:26 -#define DE_WINDOW_DESTINATION_BASE_CS_0 0 -#define DE_WINDOW_DESTINATION_BASE_CS_1 1 -#define DE_WINDOW_DESTINATION_BASE_ADDRESS 25:0 +#define DE_WINDOW_DESTINATION_BASE_EXT BIT(27) +#define DE_WINDOW_DESTINATION_BASE_CS BIT(26) +#define DE_WINDOW_DESTINATION_BASE_ADDRESS_MASK 0x3ffffff #define DE_ALPHA 0x000048 -#define DE_ALPHA_VALUE 7:0 +#define DE_ALPHA_VALUE_MASK 0xff #define DE_WRAP 0x00004C -#define DE_WRAP_X 31:16 -#define DE_WRAP_Y 15:0 +#define DE_WRAP_X_MASK (0xffff << 16) +#define DE_WRAP_Y_MASK 0xffff #define DE_STATUS 0x000050 -#define DE_STATUS_CSC 1:1 -#define DE_STATUS_CSC_CLEAR 0 -#define DE_STATUS_CSC_NOT_ACTIVE 0 -#define DE_STATUS_CSC_ACTIVE 1 -#define DE_STATUS_2D 0:0 -#define DE_STATUS_2D_CLEAR 0 -#define DE_STATUS_2D_NOT_ACTIVE 0 -#define DE_STATUS_2D_ACTIVE 1 - - +#define DE_STATUS_CSC BIT(1) +#define DE_STATUS_2D BIT(0) /* blt direction */ #define TOP_TO_BOTTOM 0 diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c index e887101..2d348c6 100644 --- a/drivers/staging/sm750fb/sm750_cursor.c +++ b/drivers/staging/sm750fb/sm750_cursor.c @@ -16,7 +16,6 @@ #include <linux/screen_info.h> #include "sm750.h" -#include "sm750_help.h" #include "sm750_cursor.h" @@ -28,33 +27,25 @@ writel((data), cursor->mmio + (addr)) /* cursor control for voyager and 718/750*/ #define HWC_ADDRESS 0x0 -#define HWC_ADDRESS_ENABLE 31:31 -#define HWC_ADDRESS_ENABLE_DISABLE 0 -#define HWC_ADDRESS_ENABLE_ENABLE 1 -#define HWC_ADDRESS_EXT 27:27 -#define HWC_ADDRESS_EXT_LOCAL 0 -#define HWC_ADDRESS_EXT_EXTERNAL 1 -#define HWC_ADDRESS_CS 26:26 -#define HWC_ADDRESS_CS_0 0 -#define HWC_ADDRESS_CS_1 1 -#define HWC_ADDRESS_ADDRESS 25:0 +#define HWC_ADDRESS_ENABLE BIT(31) +#define HWC_ADDRESS_EXT BIT(27) +#define HWC_ADDRESS_CS BIT(26) +#define HWC_ADDRESS_ADDRESS_MASK 0x3ffffff #define HWC_LOCATION 0x4 -#define HWC_LOCATION_TOP 27:27 -#define HWC_LOCATION_TOP_INSIDE 0 -#define HWC_LOCATION_TOP_OUTSIDE 1 -#define HWC_LOCATION_Y 26:16 -#define HWC_LOCATION_LEFT 11:11 -#define HWC_LOCATION_LEFT_INSIDE 0 -#define HWC_LOCATION_LEFT_OUTSIDE 1 -#define HWC_LOCATION_X 10:0 +#define HWC_LOCATION_TOP BIT(27) +#define HWC_LOCATION_Y_SHIFT 16 +#define HWC_LOCATION_Y_MASK (0x7ff << 16) +#define HWC_LOCATION_LEFT BIT(11) +#define HWC_LOCATION_X_MASK 0x7ff #define HWC_COLOR_12 0x8 -#define HWC_COLOR_12_2_RGB565 31:16 -#define HWC_COLOR_12_1_RGB565 15:0 +#define HWC_COLOR_12_2_RGB565_SHIFT 16 +#define HWC_COLOR_12_2_RGB565_MASK (0xffff << 16) +#define HWC_COLOR_12_1_RGB565_MASK 0xffff #define HWC_COLOR_3 0xC -#define HWC_COLOR_3_RGB565 15:0 +#define HWC_COLOR_3_RGB565_MASK 0xffff /* hw_cursor_xxx works for voyager,718 and 750 */ @@ -62,9 +53,7 @@ void hw_cursor_enable(struct lynx_cursor *cursor) { u32 reg; - reg = FIELD_VALUE(0, HWC_ADDRESS, ADDRESS, cursor->offset)| - FIELD_SET(0, HWC_ADDRESS, EXT, LOCAL)| - FIELD_SET(0, HWC_ADDRESS, ENABLE, ENABLE); + reg = (cursor->offset & HWC_ADDRESS_ADDRESS_MASK) | HWC_ADDRESS_ENABLE; POKE32(HWC_ADDRESS, reg); } void hw_cursor_disable(struct lynx_cursor *cursor) @@ -83,14 +72,17 @@ void hw_cursor_setPos(struct lynx_cursor *cursor, { u32 reg; - reg = FIELD_VALUE(0, HWC_LOCATION, Y, y)| - FIELD_VALUE(0, HWC_LOCATION, X, x); + reg = (((y << HWC_LOCATION_Y_SHIFT) & HWC_LOCATION_Y_MASK) | + (x & HWC_LOCATION_X_MASK)); POKE32(HWC_LOCATION, reg); } void hw_cursor_setColor(struct lynx_cursor *cursor, u32 fg, u32 bg) { - POKE32(HWC_COLOR_12, (fg<<16)|(bg&0xffff)); + u32 reg = (fg << HWC_COLOR_12_2_RGB565_SHIFT) & + HWC_COLOR_12_2_RGB565_MASK; + + POKE32(HWC_COLOR_12, reg | (bg & HWC_COLOR_12_1_RGB565_MASK)); POKE32(HWC_COLOR_3, 0xffe0); } diff --git a/drivers/staging/sm750fb/sm750_help.h b/drivers/staging/sm750fb/sm750_help.h deleted file mode 100644 index c070cf2..0000000 --- a/drivers/staging/sm750fb/sm750_help.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef LYNX_HELP_H__ -#define LYNX_HELP_H__ - -/* Internal macros */ -#define _F_START(f) (0 ? f) -#define _F_END(f) (1 ? f) -#define _F_SIZE(f) (1 + _F_END(f) - _F_START(f)) -#define _F_MASK(f) (((1 << _F_SIZE(f)) - 1) << _F_START(f)) -#define _F_NORMALIZE(v, f) (((v) & _F_MASK(f)) >> _F_START(f)) -#define _F_DENORMALIZE(v, f) (((v) << _F_START(f)) & _F_MASK(f)) - -/* Global macros */ -#define FIELD_GET(x, reg, field) \ -( \ - _F_NORMALIZE((x), reg ## _ ## field) \ -) - -#define FIELD_SET(x, reg, field, value) \ -( \ - (x & ~_F_MASK(reg ## _ ## field)) \ - | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \ -) - -#define FIELD_VALUE(x, reg, field, value) \ -( \ - (x & ~_F_MASK(reg ## _ ## field)) \ - | _F_DENORMALIZE(value, reg ## _ ## field) \ -) - -#define FIELD_CLEAR(reg, field) \ -( \ - ~_F_MASK(reg ## _ ## field) \ -) - -/* Field Macros */ -#define FIELD_START(field) (0 ? field) -#define FIELD_END(field) (1 ? field) -#define FIELD_SIZE(field) (1 + FIELD_END(field) - FIELD_START(field)) -#define FIELD_MASK(field) (((1 << (FIELD_SIZE(field)-1)) | ((1 << (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field)) - -static inline unsigned int absDiff(unsigned int a, unsigned int b) -{ - if (a < b) - return b-a; - else - return a-b; -} - -/* n / d + 1 / 2 = (2n + d) / 2d */ -#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom))) -#define MHz(x) ((x) * 1000000) - - - - -#endif diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index 01850bf..2daeedd 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -1,4 +1,3 @@ -#include <linux/version.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> @@ -343,11 +342,10 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, POKE32(CRT_FB_ADDRESS, crtc->oScreen); reg = var->xres * (var->bits_per_pixel >> 3); /* crtc->channel is not equal to par->index on numeric,be aware of that */ - reg = ALIGN(reg, crtc->line_pad); - - POKE32(CRT_FB_WIDTH, - FIELD_VALUE(0, CRT_FB_WIDTH, WIDTH, reg)| - FIELD_VALUE(0, CRT_FB_WIDTH, OFFSET, fix->line_length)); + reg = ALIGN(reg, crtc->line_pad) << CRT_FB_WIDTH_WIDTH_SHIFT; + reg &= CRT_FB_WIDTH_WIDTH_MASK; + reg |= (fix->line_length & CRT_FB_WIDTH_OFFSET_MASK); + POKE32(CRT_FB_WIDTH, reg); /* SET PIXEL FORMAT */ reg = PEEK32(CRT_DISPLAY_CTRL); @@ -550,8 +548,8 @@ int hw_sm750_pan_display(struct lynxfb_crtc *crtc, (total & PANEL_FB_ADDRESS_ADDRESS_MASK)); } else { POKE32(CRT_FB_ADDRESS, - FIELD_VALUE(PEEK32(CRT_FB_ADDRESS), - CRT_FB_ADDRESS, ADDRESS, total)); + PEEK32(CRT_FB_ADDRESS) | + (total & CRT_FB_ADDRESS_ADDRESS_MASK)); } return 0; } diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index 162ca18..880d9f0 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -575,7 +575,7 @@ struct spar_io_channel_protocol { * room) */ static inline u16 -add_physinfo_entries(u32 inp_pfn, u16 inp_off, u32 inp_len, u16 index, +add_physinfo_entries(u64 inp_pfn, u16 inp_off, u32 inp_len, u16 index, u16 max_pi_arr_entries, struct phys_info pi_arr[]) { u32 len; @@ -589,21 +589,19 @@ add_physinfo_entries(u32 inp_pfn, u16 inp_off, u32 inp_len, u16 index, pi_arr[index].pi_pfn = inp_pfn; pi_arr[index].pi_off = (u16)inp_off; pi_arr[index].pi_len = (u16)inp_len; - return index + 1; + return index + 1; } - /* this entry spans multiple pages */ - for (len = inp_len, i = 0; len; - len -= pi_arr[index + i].pi_len, i++) { + /* this entry spans multiple pages */ + for (len = inp_len, i = 0; len; + len -= pi_arr[index + i].pi_len, i++) { if (index + i >= max_pi_arr_entries) return 0; pi_arr[index + i].pi_pfn = inp_pfn + i; if (i == 0) { pi_arr[index].pi_off = inp_off; pi_arr[index].pi_len = firstlen; - } - - else { + } else { pi_arr[index + i].pi_off = 0; pi_arr[index + i].pi_len = (u16)MINNUM(len, (u32)PI_PAGE_SIZE); diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index a301385..533bb5b 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -221,7 +221,6 @@ visorbus_release_busdevice(struct device *xdev) { struct visor_device *dev = dev_get_drvdata(xdev); - dev_set_drvdata(xdev, NULL); kfree(dev); } @@ -701,12 +700,10 @@ DRIVER_ATTR_version(struct device_driver *xdrv, char *buf) static int register_driver_attributes(struct visor_driver *drv) { - int rc; struct driver_attribute version = __ATTR(version, S_IRUGO, DRIVER_ATTR_version, NULL); drv->version_attr = version; - rc = driver_create_file(&drv->driver, &drv->version_attr); - return rc; + return driver_create_file(&drv->driver, &drv->version_attr); } static void @@ -771,7 +768,7 @@ visordriver_probe_device(struct device *xdev) get_device(&dev->device); if (!drv->probe) { up(&dev->visordriver_callback_lock); - rc = -1; + rc = -ENODEV; goto away; } rc = drv->probe(dev); @@ -973,7 +970,7 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); static int create_visor_device(struct visor_device *dev) { - int rc = -1; + int rc; u32 chipset_bus_no = dev->chipset_bus_no; u32 chipset_dev_no = dev->chipset_dev_no; @@ -995,6 +992,7 @@ create_visor_device(struct visor_device *dev) if (!dev->periodic_work) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no, DIAG_SEVERITY_ERR); + rc = -EINVAL; goto away; } @@ -1032,14 +1030,15 @@ create_visor_device(struct visor_device *dev) if (rc < 0) { POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no, DIAG_SEVERITY_ERR); - goto away_register; + goto away_unregister; } list_add_tail(&dev->list_all, &list_all_device_instances); return 0; -away_register: +away_unregister: device_unregister(&dev->device); + away: put_device(&dev->device); return rc; @@ -1058,23 +1057,21 @@ static int get_vbus_header_info(struct visorchannel *chan, struct spar_vbus_headerinfo *hdr_info) { - int rc = -1; - if (!SPAR_VBUS_CHANNEL_OK_CLIENT(visorchannel_get_header(chan))) - goto away; + return -EINVAL; + if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info, sizeof(*hdr_info)) < 0) { - goto away; + return -EIO; } if (hdr_info->struct_bytes < sizeof(struct spar_vbus_headerinfo)) - goto away; + return -EINVAL; + if (hdr_info->device_info_struct_bytes < sizeof(struct ultra_vbus_deviceinfo)) { - goto away; + return -EINVAL; } - rc = 0; -away: - return rc; + return 0; } /* Write the contents of <info> to the struct @@ -1197,17 +1194,14 @@ fix_vbus_dev_info(struct visor_device *visordev) static int create_bus_instance(struct visor_device *dev) { - int rc; int id = dev->chipset_bus_no; struct spar_vbus_headerinfo *hdr_info; POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); - if (!hdr_info) { - rc = -1; - goto away; - } + if (!hdr_info) + return -ENOMEM; dev_set_name(&dev->device, "visorbus%d", id); dev->device.bus = &visorbus_type; @@ -1217,8 +1211,8 @@ create_bus_instance(struct visor_device *dev) if (device_register(&dev->device) < 0) { POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id, POSTCODE_SEVERITY_ERR); - rc = -1; - goto away_mem; + kfree(hdr_info); + return -ENODEV; } if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) { @@ -1234,11 +1228,6 @@ create_bus_instance(struct visor_device *dev) list_add_tail(&dev->list_all, &list_all_bus_instances); dev_set_drvdata(&dev->device, dev); return 0; - -away_mem: - kfree(hdr_info); -away: - return rc; } /** Remove a device instance for the visor bus itself. @@ -1328,7 +1317,7 @@ chipset_bus_destroy(struct visor_device *dev) static void chipset_device_create(struct visor_device *dev_info) { - int rc = -1; + int rc; u32 bus_no = dev_info->chipset_bus_no; u32 dev_no = dev_info->chipset_dev_no; @@ -1405,7 +1394,7 @@ resume_state_change_complete(struct visor_device *dev, int status) static void initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) { - int rc = -1, x; + int rc; struct visor_driver *drv = NULL; void (*notify_func)(struct visor_device *dev, int response) = NULL; @@ -1414,14 +1403,18 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) else notify_func = chipset_responders.device_resume; if (!notify_func) - goto away; + return; drv = to_visor_driver(dev->device.driver); - if (!drv) - goto away; + if (!drv) { + (*notify_func)(dev, -ENODEV); + return; + } - if (dev->pausing || dev->resuming) - goto away; + if (dev->pausing || dev->resuming) { + (*notify_func)(dev, -EBUSY); + return; + } /* Note that even though both drv->pause() and drv->resume * specify a callback function, it is NOT necessary for us to @@ -1431,11 +1424,13 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) * visorbus while child function drivers are still running. */ if (is_pause) { - if (!drv->pause) - goto away; + if (!drv->pause) { + (*notify_func)(dev, -EINVAL); + return; + } dev->pausing = true; - x = drv->pause(dev, pause_state_change_complete); + rc = drv->pause(dev, pause_state_change_complete); } else { /* This should be done at BUS resume time, but an * existing problem prevents us from ever getting a bus @@ -1444,24 +1439,20 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) * would never even get here in that case. */ fix_vbus_dev_info(dev); - if (!drv->resume) - goto away; + if (!drv->resume) { + (*notify_func)(dev, -EINVAL); + return; + } dev->resuming = true; - x = drv->resume(dev, resume_state_change_complete); + rc = drv->resume(dev, resume_state_change_complete); } - if (x < 0) { + if (rc < 0) { if (is_pause) dev->pausing = false; else dev->resuming = false; - goto away; - } - rc = 0; -away: - if (rc < 0) { - if (notify_func) - (*notify_func)(dev, rc); + (*notify_func)(dev, -EINVAL); } } diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index a79aa2d..b75b063 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -2316,7 +2316,7 @@ visorchipset_init(struct acpi_device *acpi_device) visorchipset_platform_device.dev.devt = major_dev; if (platform_device_register(&visorchipset_platform_device) < 0) { POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR); - rc = -1; + rc = -ENODEV; goto cleanup; } POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index f27eb9a..f546553 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -116,7 +116,7 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb) break; } - if (status != STATUS_SUCCESS) { + if (status) { priv->int_buf.in_use = false; dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status); @@ -221,7 +221,7 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb) rcb); status = usb_submit_urb(urb, GFP_ATOMIC); - if (status != 0) { + if (status) { dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status); return STATUS_FAILURE; } @@ -282,7 +282,7 @@ int vnt_tx_context(struct vnt_private *priv, context); status = usb_submit_urb(urb, GFP_ATOMIC); - if (status != 0) { + if (status) { dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status); context->in_use = false; diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 3a76586..25dc108 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -284,10 +284,8 @@ s32 wilc_parse_network_info(u8 *msg_buffer, msg_type = msg_buffer[0]; - if ('N' != msg_type) { - PRINT_ER("Received Message format incorrect.\n"); + if ('N' != msg_type) return -EFAULT; - } msg_id = msg_buffer[1]; msg_len = MAKE_WORD16(msg_buffer[2], msg_buffer[3]); diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 748199d..63eca24 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -105,20 +105,20 @@ struct connect_resp_info { u16 ies_len; }; -typedef struct { - u8 au8bssid[6]; - u8 *pu8ReqIEs; - size_t ReqIEsLen; - u8 *pu8RespIEs; - u16 u16RespIEsLen; - u16 u16ConnectStatus; -} tstrConnectInfo; +struct connect_info { + u8 bssid[6]; + u8 *req_ies; + size_t req_ies_len; + u8 *resp_ies; + u16 resp_ies_len; + u16 status; +}; -typedef struct { - u16 u16reason; +struct disconnect_info { + u16 reason; u8 *ie; size_t ie_len; -} tstrDisconnectNotifInfo; +}; s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index d1eedfb..b2fdc93 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -46,7 +46,6 @@ #define HOST_IF_MSG_DEL_BA_SESSION 34 #define HOST_IF_MSG_Q_IDLE 35 #define HOST_IF_MSG_DEL_ALL_STA 36 -#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 37 #define HOST_IF_MSG_SET_TX_POWER 38 #define HOST_IF_MSG_GET_TX_POWER 39 #define HOST_IF_MSG_EXIT 100 @@ -62,10 +61,6 @@ #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 -struct cfg_param_attr { - struct cfg_param_val cfg_attr_info; -}; - struct host_if_wpa_attr { u8 *key; const u8 *mac_addr; @@ -335,7 +330,7 @@ static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif, up(&hif_sema_driver); if (result) { - PRINT_ER("Failed to set driver handler\n"); + netdev_err(vif->ndev, "Failed to set driver handler\n"); return -EINVAL; } @@ -360,7 +355,7 @@ static s32 handle_set_operation_mode(struct wilc_vif *vif, up(&hif_sema_driver); if (result) { - PRINT_ER("Failed to set driver handler\n"); + netdev_err(vif->ndev, "Failed to set driver handler\n"); return -EINVAL; } @@ -389,7 +384,7 @@ static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) host_int_get_ipaddress(vif, firmware_ip_addr, idx); if (result) { - PRINT_ER("Failed to set IP address\n"); + netdev_err(vif->ndev, "Failed to set IP address\n"); return -EINVAL; } @@ -417,40 +412,35 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx) wilc_setup_ipaddress(vif, set_ip[idx], idx); if (result != 0) { - PRINT_ER("Failed to get IP address\n"); + netdev_err(vif->ndev, "Failed to get IP address\n"); return -EINVAL; } return result; } -static s32 handle_set_mac_address(struct wilc_vif *vif, - struct set_mac_addr *set_mac_addr) +static void handle_set_mac_address(struct wilc_vif *vif, + struct set_mac_addr *set_mac_addr) { - s32 result = 0; + int ret = 0; struct wid wid; - u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL); + u8 *mac_buf; - if (!mac_buf) { - PRINT_ER("No buffer to send mac address\n"); - return -EFAULT; - } - memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN); + mac_buf = kmemdup(set_mac_addr->mac_addr, ETH_ALEN, GFP_KERNEL); + if (!mac_buf) + return; wid.id = (u16)WID_MAC_ADDR; wid.type = WID_STR; wid.val = mac_buf; wid.size = ETH_ALEN; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) { - PRINT_ER("Failed to set mac address\n"); - result = -EFAULT; - } + ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (ret) + netdev_err(vif->ndev, "Failed to set mac address\n"); kfree(mac_buf); - return result; } static s32 handle_get_mac_address(struct wilc_vif *vif, @@ -468,7 +458,7 @@ static s32 handle_get_mac_address(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to get mac address\n"); + netdev_err(vif->ndev, "Failed to get mac address\n"); result = -EFAULT; } up(&hif_sema_wait_response); @@ -482,287 +472,288 @@ static s32 handle_cfg_param(struct wilc_vif *vif, s32 result = 0; struct wid wid_list[32]; struct host_if_drv *hif_drv = vif->hif_drv; - u8 wid_cnt = 0; + int i = 0; down(&hif_drv->sem_cfg_values); - if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) { - if (cfg_param_attr->cfg_attr_info.bss_type < 6) { - wid_list[wid_cnt].id = WID_BSS_TYPE; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type; + if (cfg_param_attr->flag & BSS_TYPE) { + if (cfg_param_attr->bss_type < 6) { + wid_list[i].id = WID_BSS_TYPE; + wid_list[i].val = (s8 *)&cfg_param_attr->bss_type; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->bss_type; } else { - PRINT_ER("check value 6 over\n"); + netdev_err(vif->ndev, "check value 6 over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) { - if (cfg_param_attr->cfg_attr_info.auth_type == 1 || - cfg_param_attr->cfg_attr_info.auth_type == 2 || - cfg_param_attr->cfg_attr_info.auth_type == 5) { - wid_list[wid_cnt].id = WID_AUTH_TYPE; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type; + i++; + } + if (cfg_param_attr->flag & AUTH_TYPE) { + if (cfg_param_attr->auth_type == 1 || + cfg_param_attr->auth_type == 2 || + cfg_param_attr->auth_type == 5) { + wid_list[i].id = WID_AUTH_TYPE; + wid_list[i].val = (s8 *)&cfg_param_attr->auth_type; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->auth_type; } else { - PRINT_ER("Impossible value \n"); + netdev_err(vif->ndev, "Impossible value\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) { - if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 && - cfg_param_attr->cfg_attr_info.auth_timeout < 65536) { - wid_list[wid_cnt].id = WID_AUTH_TIMEOUT; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout; + i++; + } + if (cfg_param_attr->flag & AUTHEN_TIMEOUT) { + if (cfg_param_attr->auth_timeout > 0 && + cfg_param_attr->auth_timeout < 65536) { + wid_list[i].id = WID_AUTH_TIMEOUT; + wid_list[i].val = (s8 *)&cfg_param_attr->auth_timeout; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.auth_timeout = cfg_param_attr->auth_timeout; } else { - PRINT_ER("Range(1 ~ 65535) over\n"); + netdev_err(vif->ndev, "Range(1 ~ 65535) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) { - if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) { - wid_list[wid_cnt].id = WID_POWER_MANAGEMENT; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode; + i++; + } + if (cfg_param_attr->flag & POWER_MANAGEMENT) { + if (cfg_param_attr->power_mgmt_mode < 5) { + wid_list[i].id = WID_POWER_MANAGEMENT; + wid_list[i].val = (s8 *)&cfg_param_attr->power_mgmt_mode; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->power_mgmt_mode; } else { - PRINT_ER("Invalid power mode\n"); + netdev_err(vif->ndev, "Invalid power mode\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) { - if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 && - cfg_param_attr->cfg_attr_info.short_retry_limit < 256) { - wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit; + i++; + } + if (cfg_param_attr->flag & RETRY_SHORT) { + if (cfg_param_attr->short_retry_limit > 0 && + cfg_param_attr->short_retry_limit < 256) { + wid_list[i].id = WID_SHORT_RETRY_LIMIT; + wid_list[i].val = (s8 *)&cfg_param_attr->short_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.short_retry_limit = cfg_param_attr->short_retry_limit; } else { - PRINT_ER("Range(1~256) over\n"); + netdev_err(vif->ndev, "Range(1~256) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) { - if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 && - cfg_param_attr->cfg_attr_info.long_retry_limit < 256) { - wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit; + i++; + } + if (cfg_param_attr->flag & RETRY_LONG) { + if (cfg_param_attr->long_retry_limit > 0 && + cfg_param_attr->long_retry_limit < 256) { + wid_list[i].id = WID_LONG_RETRY_LIMIT; + wid_list[i].val = (s8 *)&cfg_param_attr->long_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.long_retry_limit = cfg_param_attr->long_retry_limit; } else { - PRINT_ER("Range(1~256) over\n"); + netdev_err(vif->ndev, "Range(1~256) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) { - if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 && - cfg_param_attr->cfg_attr_info.frag_threshold < 7937) { - wid_list[wid_cnt].id = WID_FRAG_THRESHOLD; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold; + i++; + } + if (cfg_param_attr->flag & FRAG_THRESHOLD) { + if (cfg_param_attr->frag_threshold > 255 && + cfg_param_attr->frag_threshold < 7937) { + wid_list[i].id = WID_FRAG_THRESHOLD; + wid_list[i].val = (s8 *)&cfg_param_attr->frag_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.frag_threshold = cfg_param_attr->frag_threshold; } else { - PRINT_ER("Threshold Range fail\n"); + netdev_err(vif->ndev, "Threshold Range fail\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) { - if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 && - cfg_param_attr->cfg_attr_info.rts_threshold < 65536) { - wid_list[wid_cnt].id = WID_RTS_THRESHOLD; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold; + i++; + } + if (cfg_param_attr->flag & RTS_THRESHOLD) { + if (cfg_param_attr->rts_threshold > 255 && + cfg_param_attr->rts_threshold < 65536) { + wid_list[i].id = WID_RTS_THRESHOLD; + wid_list[i].val = (s8 *)&cfg_param_attr->rts_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.rts_threshold = cfg_param_attr->rts_threshold; } else { - PRINT_ER("Threshold Range fail\n"); + netdev_err(vif->ndev, "Threshold Range fail\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) { - if (cfg_param_attr->cfg_attr_info.preamble_type < 3) { - wid_list[wid_cnt].id = WID_PREAMBLE; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type; + i++; + } + if (cfg_param_attr->flag & PREAMBLE) { + if (cfg_param_attr->preamble_type < 3) { + wid_list[i].id = WID_PREAMBLE; + wid_list[i].val = (s8 *)&cfg_param_attr->preamble_type; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.preamble_type = cfg_param_attr->preamble_type; } else { - PRINT_ER("Preamle Range(0~2) over\n"); + netdev_err(vif->ndev, "Preamle Range(0~2) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) { - if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) { - wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed; + i++; + } + if (cfg_param_attr->flag & SHORT_SLOT_ALLOWED) { + if (cfg_param_attr->short_slot_allowed < 2) { + wid_list[i].id = WID_SHORT_SLOT_ALLOWED; + wid_list[i].val = (s8 *)&cfg_param_attr->short_slot_allowed; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->short_slot_allowed; } else { - PRINT_ER("Short slot(2) over\n"); + netdev_err(vif->ndev, "Short slot(2) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) { - if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) { - wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled; + i++; + } + if (cfg_param_attr->flag & TXOP_PROT_DISABLE) { + if (cfg_param_attr->txop_prot_disabled < 2) { + wid_list[i].id = WID_11N_TXOP_PROT_DISABLE; + wid_list[i].val = (s8 *)&cfg_param_attr->txop_prot_disabled; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->txop_prot_disabled; } else { - PRINT_ER("TXOP prot disable\n"); + netdev_err(vif->ndev, "TXOP prot disable\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) { - if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 && - cfg_param_attr->cfg_attr_info.beacon_interval < 65536) { - wid_list[wid_cnt].id = WID_BEACON_INTERVAL; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval; + i++; + } + if (cfg_param_attr->flag & BEACON_INTERVAL) { + if (cfg_param_attr->beacon_interval > 0 && + cfg_param_attr->beacon_interval < 65536) { + wid_list[i].id = WID_BEACON_INTERVAL; + wid_list[i].val = (s8 *)&cfg_param_attr->beacon_interval; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.beacon_interval = cfg_param_attr->beacon_interval; } else { - PRINT_ER("Beacon interval(1~65535) fail\n"); + netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) { - if (cfg_param_attr->cfg_attr_info.dtim_period > 0 && - cfg_param_attr->cfg_attr_info.dtim_period < 256) { - wid_list[wid_cnt].id = WID_DTIM_PERIOD; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period; + i++; + } + if (cfg_param_attr->flag & DTIM_PERIOD) { + if (cfg_param_attr->dtim_period > 0 && + cfg_param_attr->dtim_period < 256) { + wid_list[i].id = WID_DTIM_PERIOD; + wid_list[i].val = (s8 *)&cfg_param_attr->dtim_period; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.dtim_period = cfg_param_attr->dtim_period; } else { - PRINT_ER("DTIM range(1~255) fail\n"); + netdev_err(vif->ndev, "DTIM range(1~255) fail\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) { - if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) { - wid_list[wid_cnt].id = WID_SITE_SURVEY; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled; + i++; + } + if (cfg_param_attr->flag & SITE_SURVEY) { + if (cfg_param_attr->site_survey_enabled < 3) { + wid_list[i].id = WID_SITE_SURVEY; + wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_enabled; + wid_list[i].type = WID_CHAR; + wid_list[i].size = sizeof(char); + hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->site_survey_enabled; } else { - PRINT_ER("Site survey disable\n"); + netdev_err(vif->ndev, "Site survey disable\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) { - if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 && - cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) { - wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time; + i++; + } + if (cfg_param_attr->flag & SITE_SURVEY_SCAN_TIME) { + if (cfg_param_attr->site_survey_scan_time > 0 && + cfg_param_attr->site_survey_scan_time < 65536) { + wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME; + wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_scan_time; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->site_survey_scan_time; } else { - PRINT_ER("Site survey scan time(1~65535) over\n"); + netdev_err(vif->ndev, "Site scan time(1~65535) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) { - if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 && - cfg_param_attr->cfg_attr_info.active_scan_time < 65536) { - wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time; + i++; + } + if (cfg_param_attr->flag & ACTIVE_SCANTIME) { + if (cfg_param_attr->active_scan_time > 0 && + cfg_param_attr->active_scan_time < 65536) { + wid_list[i].id = WID_ACTIVE_SCAN_TIME; + wid_list[i].val = (s8 *)&cfg_param_attr->active_scan_time; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.active_scan_time = cfg_param_attr->active_scan_time; } else { - PRINT_ER("Active scan time(1~65535) over\n"); + netdev_err(vif->ndev, "Active time(1~65535) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) { - if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 && - cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) { - wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME; - wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); - hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time; + i++; + } + if (cfg_param_attr->flag & PASSIVE_SCANTIME) { + if (cfg_param_attr->passive_scan_time > 0 && + cfg_param_attr->passive_scan_time < 65536) { + wid_list[i].id = WID_PASSIVE_SCAN_TIME; + wid_list[i].val = (s8 *)&cfg_param_attr->passive_scan_time; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.passive_scan_time = cfg_param_attr->passive_scan_time; } else { - PRINT_ER("Passive scan time(1~65535) over\n"); + netdev_err(vif->ndev, "Passive time(1~65535) over\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; - } - if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) { - enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate; - - if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 - || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 - || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 - || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 - || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 - || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) { - wid_list[wid_cnt].id = WID_CURRENT_TX_RATE; - wid_list[wid_cnt].val = (s8 *)&curr_tx_rate; - wid_list[wid_cnt].type = WID_SHORT; - wid_list[wid_cnt].size = sizeof(u16); + i++; + } + if (cfg_param_attr->flag & CURRENT_TX_RATE) { + enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->curr_tx_rate; + + if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 || + curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 || + curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 || + curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 || + curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 || + curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || + curr_tx_rate == MBPS_54) { + wid_list[i].id = WID_CURRENT_TX_RATE; + wid_list[i].val = (s8 *)&curr_tx_rate; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate; } else { - PRINT_ER("out of TX rate\n"); + netdev_err(vif->ndev, "out of TX rate\n"); result = -EINVAL; goto ERRORHANDLER; } - wid_cnt++; + i++; } result = wilc_send_config_pkt(vif, SET_CFG, wid_list, - wid_cnt, wilc_get_vif_idx(vif)); + i, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Error in setting CFG params\n"); + netdev_err(vif->ndev, "Error in setting CFG params\n"); ERRORHANDLER: up(&hif_drv->sem_cfg_values); @@ -795,13 +786,13 @@ static s32 Handle_Scan(struct wilc_vif *vif, if ((hif_drv->hif_state >= HOST_IF_SCANNING) && (hif_drv->hif_state < HOST_IF_CONNECTED)) { - PRINT_ER("Already scan\n"); + netdev_err(vif->ndev, "Already scan\n"); result = -EBUSY; goto ERRORHANDLER; } if (wilc_optaining_ip || wilc_connecting) { - PRINT_ER("Don't do obss scan\n"); + netdev_err(vif->ndev, "Don't do obss scan\n"); result = -EBUSY; goto ERRORHANDLER; } @@ -877,7 +868,7 @@ static s32 Handle_Scan(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send scan parameters config packet\n"); + netdev_err(vif->ndev, "Failed to send scan parameters\n"); ERRORHANDLER: if (result) { @@ -917,13 +908,13 @@ static s32 Handle_ScanDone(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to set abort running scan\n"); + netdev_err(vif->ndev, "Failed to set abort running\n"); result = -EFAULT; } } if (!hif_drv) { - PRINT_ER("Driver handler is NULL\n"); + netdev_err(vif->ndev, "Driver handler is NULL\n"); return result; } @@ -949,13 +940,13 @@ static s32 Handle_Connect(struct wilc_vif *vif, if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) { result = 0; - PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n"); + netdev_err(vif->ndev, "Discard connect request\n"); return result; } ptstrJoinBssParam = pstrHostIFconnectAttr->params; if (!ptstrJoinBssParam) { - PRINT_ER("Required BSSID not found\n"); + netdev_err(vif->ndev, "Required BSSID not found\n"); result = -ENOENT; goto ERRORHANDLER; } @@ -1063,7 +1054,7 @@ static s32 Handle_Connect(struct wilc_vif *vif, if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) { *(pu8CurrByte++) = pstrHostIFconnectAttr->ch; } else { - PRINT_ER("Channel out of range\n"); + netdev_err(vif->ndev, "Channel out of range\n"); *(pu8CurrByte++) = 0xFF; } *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF; @@ -1146,7 +1137,7 @@ static s32 Handle_Connect(struct wilc_vif *vif, u32WidsCount, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("failed to send config packet\n"); + netdev_err(vif->ndev, "failed to send config packet\n"); result = -EFAULT; goto ERRORHANDLER; } else { @@ -1155,20 +1146,20 @@ static s32 Handle_Connect(struct wilc_vif *vif, ERRORHANDLER: if (result) { - tstrConnectInfo strConnectInfo; + struct connect_info strConnectInfo; del_timer(&hif_drv->connect_timer); - memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + memset(&strConnectInfo, 0, sizeof(struct connect_info)); if (pstrHostIFconnectAttr->result) { if (pstrHostIFconnectAttr->bssid) - memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6); + memcpy(strConnectInfo.bssid, pstrHostIFconnectAttr->bssid, 6); if (pstrHostIFconnectAttr->ies) { - strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len; - strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL); - memcpy(strConnectInfo.pu8ReqIEs, + strConnectInfo.req_ies_len = pstrHostIFconnectAttr->ies_len; + strConnectInfo.req_ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL); + memcpy(strConnectInfo.req_ies, pstrHostIFconnectAttr->ies, pstrHostIFconnectAttr->ies_len); } @@ -1179,11 +1170,11 @@ ERRORHANDLER: NULL, pstrHostIFconnectAttr->arg); hif_drv->hif_state = HOST_IF_IDLE; - kfree(strConnectInfo.pu8ReqIEs); - strConnectInfo.pu8ReqIEs = NULL; + kfree(strConnectInfo.req_ies); + strConnectInfo.req_ies = NULL; } else { - PRINT_ER("Connect callback function pointer is NULL\n"); + netdev_err(vif->ndev, "Connect callback is NULL\n"); } } @@ -1240,7 +1231,7 @@ static s32 Handle_FlushConnect(struct wilc_vif *vif) u32WidsCount, wilc_get_vif_idx(join_req_vif)); if (result) { - PRINT_ER("failed to send config packet\n"); + netdev_err(vif->ndev, "failed to send config packet\n"); result = -EINVAL; } @@ -1250,13 +1241,13 @@ static s32 Handle_FlushConnect(struct wilc_vif *vif) static s32 Handle_ConnectTimeout(struct wilc_vif *vif) { s32 result = 0; - tstrConnectInfo strConnectInfo; + struct connect_info strConnectInfo; struct wid wid; u16 u16DummyReasonCode = 0; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("Driver handler is NULL\n"); + netdev_err(vif->ndev, "Driver handler is NULL\n"); return result; } @@ -1264,18 +1255,18 @@ static s32 Handle_ConnectTimeout(struct wilc_vif *vif) scan_while_connected = false; - memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + memset(&strConnectInfo, 0, sizeof(struct connect_info)); if (hif_drv->usr_conn_req.conn_result) { if (hif_drv->usr_conn_req.bssid) { - memcpy(strConnectInfo.au8bssid, + memcpy(strConnectInfo.bssid, hif_drv->usr_conn_req.bssid, 6); } if (hif_drv->usr_conn_req.ies) { - strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len; - strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); - memcpy(strConnectInfo.pu8ReqIEs, + strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len; + strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); + memcpy(strConnectInfo.req_ies, hif_drv->usr_conn_req.ies, hif_drv->usr_conn_req.ies_len); } @@ -1286,10 +1277,10 @@ static s32 Handle_ConnectTimeout(struct wilc_vif *vif) NULL, hif_drv->usr_conn_req.arg); - kfree(strConnectInfo.pu8ReqIEs); - strConnectInfo.pu8ReqIEs = NULL; + kfree(strConnectInfo.req_ies); + strConnectInfo.req_ies = NULL; } else { - PRINT_ER("Connect callback function pointer is NULL\n"); + netdev_err(vif->ndev, "Connect callback is NULL\n"); } wid.id = (u16)WID_DISCONNECT; @@ -1300,7 +1291,7 @@ static s32 Handle_ConnectTimeout(struct wilc_vif *vif) result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send dissconect config packet\n"); + netdev_err(vif->ndev, "Failed to send dissconect\n"); hif_drv->usr_conn_req.ssid_len = 0; kfree(hif_drv->usr_conn_req.ssid); @@ -1342,7 +1333,7 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo); if ((!pstrNetworkInfo) || (!hif_drv->usr_scan_req.scan_result)) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); result = -EINVAL; goto done; } @@ -1418,13 +1409,13 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, u8 u8MacStatus; u8 u8MacStatusReasonCode; u8 u8MacStatusAdditionalInfo; - tstrConnectInfo strConnectInfo; - tstrDisconnectNotifInfo strDisconnectNotifInfo; + struct connect_info strConnectInfo; + struct disconnect_info strDisconnectNotifInfo; s32 s32Err = 0; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("Driver handler is NULL\n"); + netdev_err(vif->ndev, "Driver handler is NULL\n"); return -ENODEV; } @@ -1433,14 +1424,14 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, hif_drv->usr_scan_req.scan_result) { if (!pstrRcvdGnrlAsyncInfo->buffer || !hif_drv->usr_conn_req.conn_result) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EINVAL; } u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0]; if ('I' != u8MsgType) { - PRINT_ER("Received Message format incorrect.\n"); + netdev_err(vif->ndev, "Received Message incorrect.\n"); return -EFAULT; } @@ -1455,7 +1446,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, u32 u32RcvdAssocRespInfoLen = 0; struct connect_resp_info *pstrConnectRespInfo = NULL; - memset(&strConnectInfo, 0, sizeof(tstrConnectInfo)); + memset(&strConnectInfo, 0, sizeof(struct connect_info)); if (u8MacStatus == MAC_CONNECTED) { memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE); @@ -1469,15 +1460,15 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen, &pstrConnectRespInfo); if (s32Err) { - PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err); + netdev_err(vif->ndev, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err); } else { - strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->status; + strConnectInfo.status = pstrConnectRespInfo->status; - if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) { + if (strConnectInfo.status == SUCCESSFUL_STATUSCODE) { if (pstrConnectRespInfo->ies) { - strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->ies_len; - strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL); - memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->ies, + strConnectInfo.resp_ies_len = pstrConnectRespInfo->ies_len; + strConnectInfo.resp_ies = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL); + memcpy(strConnectInfo.resp_ies, pstrConnectRespInfo->ies, pstrConnectRespInfo->ies_len); } } @@ -1491,28 +1482,28 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, } if ((u8MacStatus == MAC_CONNECTED) && - (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) { - PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); + (strConnectInfo.status != SUCCESSFUL_STATUSCODE)) { + netdev_err(vif->ndev, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); eth_zero_addr(wilc_connected_ssid); } else if (u8MacStatus == MAC_DISCONNECTED) { - PRINT_ER("Received MAC status is MAC_DISCONNECTED\n"); + netdev_err(vif->ndev, "Received MAC status is MAC_DISCONNECTED\n"); eth_zero_addr(wilc_connected_ssid); } if (hif_drv->usr_conn_req.bssid) { - memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.bssid, 6); + memcpy(strConnectInfo.bssid, hif_drv->usr_conn_req.bssid, 6); if ((u8MacStatus == MAC_CONNECTED) && - (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) { memcpy(hif_drv->assoc_bssid, hif_drv->usr_conn_req.bssid, ETH_ALEN); } } if (hif_drv->usr_conn_req.ies) { - strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len; - strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); - memcpy(strConnectInfo.pu8ReqIEs, + strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len; + strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); + memcpy(strConnectInfo.req_ies, hif_drv->usr_conn_req.ies, hif_drv->usr_conn_req.ies_len); } @@ -1525,7 +1516,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, hif_drv->usr_conn_req.arg); if ((u8MacStatus == MAC_CONNECTED) && - (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) { wilc_set_power_mgmt(vif, 0, 0); hif_drv->hif_state = HOST_IF_CONNECTED; @@ -1538,11 +1529,11 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, scan_while_connected = false; } - kfree(strConnectInfo.pu8RespIEs); - strConnectInfo.pu8RespIEs = NULL; + kfree(strConnectInfo.resp_ies); + strConnectInfo.resp_ies = NULL; - kfree(strConnectInfo.pu8ReqIEs); - strConnectInfo.pu8ReqIEs = NULL; + kfree(strConnectInfo.req_ies); + strConnectInfo.req_ies = NULL; hif_drv->usr_conn_req.ssid_len = 0; kfree(hif_drv->usr_conn_req.ssid); hif_drv->usr_conn_req.ssid = NULL; @@ -1553,14 +1544,14 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, hif_drv->usr_conn_req.ies = NULL; } else if ((u8MacStatus == MAC_DISCONNECTED) && (hif_drv->hif_state == HOST_IF_CONNECTED)) { - memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); + memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info)); if (hif_drv->usr_scan_req.scan_result) { del_timer(&hif_drv->scan_timer); Handle_ScanDone(vif, SCAN_EVENT_ABORTED); } - strDisconnectNotifInfo.u16reason = 0; + strDisconnectNotifInfo.reason = 0; strDisconnectNotifInfo.ie = NULL; strDisconnectNotifInfo.ie_len = 0; @@ -1574,7 +1565,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, &strDisconnectNotifInfo, hif_drv->usr_conn_req.arg); } else { - PRINT_ER("Connect result callback function is NULL\n"); + netdev_err(vif->ndev, "Connect result NULL\n"); } eth_zero_addr(hif_drv->assoc_bssid); @@ -1643,11 +1634,8 @@ static int Handle_Key(struct wilc_vif *vif, pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL); - - if (pu8keybuf == NULL) { - PRINT_ER("No buffer to send Key\n"); + if (!pu8keybuf) return -ENOMEM; - } pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index; pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len; @@ -1668,10 +1656,8 @@ static int Handle_Key(struct wilc_vif *vif, kfree(pu8keybuf); } else if (pstrHostIFkeyAttr->action & ADDKEY) { pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL); - if (!pu8keybuf) { - PRINT_ER("No buffer to send Key\n"); + if (!pu8keybuf) return -ENOMEM; - } pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index; memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1); memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key, @@ -1715,7 +1701,6 @@ static int Handle_Key(struct wilc_vif *vif, if (pstrHostIFkeyAttr->action & ADDKEY_AP) { pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (!pu8keybuf) { - PRINT_ER("No buffer to send RxGTK Key\n"); ret = -ENOMEM; goto _WPARxGtk_end_case_; } @@ -1747,7 +1732,6 @@ static int Handle_Key(struct wilc_vif *vif, } else if (pstrHostIFkeyAttr->action & ADDKEY) { pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (pu8keybuf == NULL) { - PRINT_ER("No buffer to send RxGTK Key\n"); ret = -ENOMEM; goto _WPARxGtk_end_case_; } @@ -1755,7 +1739,7 @@ static int Handle_Key(struct wilc_vif *vif, if (hif_drv->hif_state == HOST_IF_CONNECTED) memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN); else - PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n"); + netdev_err(vif->ndev, "Couldn't handle\n"); memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8); memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1); @@ -1787,7 +1771,6 @@ _WPARxGtk_end_case_: if (pstrHostIFkeyAttr->action & ADDKEY_AP) { pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL); if (!pu8keybuf) { - PRINT_ER("No buffer to send PTK Key\n"); ret = -ENOMEM; goto _WPAPtk_end_case_; } @@ -1816,7 +1799,7 @@ _WPARxGtk_end_case_: } else if (pstrHostIFkeyAttr->action & ADDKEY) { pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); if (!pu8keybuf) { - PRINT_ER("No buffer to send PTK Key\n"); + netdev_err(vif->ndev, "No buffer send PTK\n"); ret = -ENOMEM; goto _WPAPtk_end_case_; } @@ -1848,7 +1831,7 @@ _WPAPtk_end_case_: case PMKSA: pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL); if (!pu8keybuf) { - PRINT_ER("No buffer to send PMKSA Key\n"); + netdev_err(vif->ndev, "No buffer to send PMKSA Key\n"); return -ENOMEM; } @@ -1872,7 +1855,7 @@ _WPAPtk_end_case_: } if (result) - PRINT_ER("Failed to send key config packet\n"); + netdev_err(vif->ndev, "Failed to send key config packet\n"); return result; } @@ -1899,13 +1882,13 @@ static void Handle_Disconnect(struct wilc_vif *vif) wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to send dissconect config packet\n"); + netdev_err(vif->ndev, "Failed to send dissconect\n"); } else { - tstrDisconnectNotifInfo strDisconnectNotifInfo; + struct disconnect_info strDisconnectNotifInfo; - memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo)); + memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info)); - strDisconnectNotifInfo.u16reason = 0; + strDisconnectNotifInfo.reason = 0; strDisconnectNotifInfo.ie = NULL; strDisconnectNotifInfo.ie_len = 0; @@ -1928,7 +1911,7 @@ static void Handle_Disconnect(struct wilc_vif *vif) &strDisconnectNotifInfo, hif_drv->usr_conn_req.arg); } else { - PRINT_ER("usr_conn_req.conn_result = NULL\n"); + netdev_err(vif->ndev, "conn_result = NULL\n"); } scan_while_connected = false; @@ -1973,7 +1956,6 @@ static s32 Handle_GetChnl(struct wilc_vif *vif) { s32 result = 0; struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; wid.id = (u16)WID_CURRENT_CHANNEL; wid.type = WID_CHAR; @@ -1984,12 +1966,10 @@ static s32 Handle_GetChnl(struct wilc_vif *vif) wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to get channel number\n"); + netdev_err(vif->ndev, "Failed to get channel number\n"); result = -EFAULT; } - up(&hif_drv->sem_get_chnl); - return result; } @@ -2006,7 +1986,7 @@ static void Handle_GetRssi(struct wilc_vif *vif) result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to get RSSI value\n"); + netdev_err(vif->ndev, "Failed to get RSSI value\n"); result = -EFAULT; } @@ -2017,7 +1997,6 @@ static void Handle_GetLinkspeed(struct wilc_vif *vif) { s32 result = 0; struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; link_speed = 0; @@ -2029,11 +2008,10 @@ static void Handle_GetLinkspeed(struct wilc_vif *vif) result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to get LINKSPEED value\n"); + netdev_err(vif->ndev, "Failed to get LINKSPEED value\n"); result = -EFAULT; } - up(&hif_drv->sem_get_link_speed); } static s32 Handle_GetStatistics(struct wilc_vif *vif, @@ -2077,7 +2055,7 @@ static s32 Handle_GetStatistics(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send scan parameters config packet\n"); + netdev_err(vif->ndev, "Failed to send scan parameters\n"); if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && pstrStatistics->link_speed != DEFAULT_LINK_SPEED) @@ -2106,13 +2084,11 @@ static s32 Handle_Get_InActiveTime(struct wilc_vif *vif, stamac = wid.val; memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN); - PRINT_D(CFG80211_DBG, "SETING STA inactive time\n"); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to SET incative time\n"); + netdev_err(vif->ndev, "Failed to SET incative time\n"); return -EFAULT; } @@ -2125,12 +2101,10 @@ static s32 Handle_Get_InActiveTime(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to get incative time\n"); + netdev_err(vif->ndev, "Failed to get incative time\n"); return -EFAULT; } - PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time); - up(&hif_drv->sem_inactive_time); return result; @@ -2181,7 +2155,7 @@ static void Handle_AddBeacon(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send add beacon config packet\n"); + netdev_err(vif->ndev, "Failed to send add beacon\n"); ERRORHANDLER: kfree(wid.val); @@ -2208,7 +2182,7 @@ static void Handle_DelBeacon(struct wilc_vif *vif) result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send delete beacon config packet\n"); + netdev_err(vif->ndev, "Failed to send delete beacon\n"); } static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, @@ -2279,7 +2253,7 @@ static void Handle_AddStation(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result != 0) - PRINT_ER("Failed to send add station config packet\n"); + netdev_err(vif->ndev, "Failed to send add station\n"); ERRORHANDLER: kfree(pstrStationParam->rates); @@ -2319,7 +2293,7 @@ static void Handle_DelAllSta(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send add station config packet\n"); + netdev_err(vif->ndev, "Failed to send add station\n"); ERRORHANDLER: kfree(wid.val); @@ -2349,7 +2323,7 @@ static void Handle_DelStation(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send add station config packet\n"); + netdev_err(vif->ndev, "Failed to send add station\n"); ERRORHANDLER: kfree(wid.val); @@ -2376,7 +2350,7 @@ static void Handle_EditStation(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send edit station config packet\n"); + netdev_err(vif->ndev, "Failed to send edit station\n"); ERRORHANDLER: kfree(pstrStationParam->rates); @@ -2432,7 +2406,7 @@ static int Handle_RemainOnChan(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result != 0) - PRINT_ER("Failed to set remain on channel\n"); + netdev_err(vif->ndev, "Failed to set remain on channel\n"); ERRORHANDLER: { @@ -2476,7 +2450,7 @@ static int Handle_RegisterFrame(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { - PRINT_ER("Failed to frame register config packet\n"); + netdev_err(vif->ndev, "Failed to frame register\n"); result = -EINVAL; } @@ -2499,7 +2473,7 @@ static u32 Handle_ListenStateExpired(struct wilc_vif *vif, wid.val = kmalloc(wid.size, GFP_KERNEL); if (!wid.val) { - PRINT_ER("Failed to allocate memory\n"); + netdev_err(vif->ndev, "Failed to allocate memory\n"); return -ENOMEM; } @@ -2509,7 +2483,7 @@ static u32 Handle_ListenStateExpired(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result != 0) { - PRINT_ER("Failed to set remain on channel\n"); + netdev_err(vif->ndev, "Failed to set remain channel\n"); goto _done_; } @@ -2542,7 +2516,7 @@ static void ListenTimerCB(unsigned long arg) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); } static void Handle_PowerManagement(struct wilc_vif *vif, @@ -2565,7 +2539,7 @@ static void Handle_PowerManagement(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send power management config packet\n"); + netdev_err(vif->ndev, "Failed to send power management\n"); } static void Handle_SetMulticastFilter(struct wilc_vif *vif, @@ -2600,43 +2574,12 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif, result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) - PRINT_ER("Failed to send setup multicast config packet\n"); + netdev_err(vif->ndev, "Failed to send setup multicast\n"); ERRORHANDLER: kfree(wid.val); } -static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif, - struct ba_session_info *strHostIfBASessionInfo) -{ - s32 result = 0; - struct wid wid; - char *ptr = NULL; - - wid.id = (u16)WID_DEL_ALL_RX_BA; - wid.type = WID_STR; - wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL); - wid.size = BLOCK_ACK_REQ_SIZE; - ptr = wid.val; - *ptr++ = 0x14; - *ptr++ = 0x3; - *ptr++ = 0x2; - memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN); - ptr += ETH_ALEN; - *ptr++ = strHostIfBASessionInfo->tid; - *ptr++ = 0; - *ptr++ = 32; - - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - kfree(wid.val); - - up(&hif_sema_wait_response); - - return result; -} - static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr) { int ret; @@ -2854,10 +2797,6 @@ static int hostIFthread(void *pvArg) Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info); break; - case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS: - Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info); - break; - case HOST_IF_MSG_DEL_ALL_STA: Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info); break; @@ -2870,7 +2809,7 @@ static int hostIFthread(void *pvArg) handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr); break; default: - PRINT_ER("[Host Interface] undefined Received Msg ID\n"); + netdev_err(vif->ndev, "[Host Interface] undefined\n"); break; } } @@ -2923,7 +2862,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) if (!hif_drv) { result = -EFAULT; - PRINT_ER("Failed to send setup multicast config packet\n"); + netdev_err(vif->ndev, "Failed to send setup multicast\n"); return result; } @@ -2937,7 +2876,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue : Request to remove WEP key\n"); + netdev_err(vif->ndev, "Request to remove WEP key\n"); down(&hif_drv->sem_test_key_block); return result; @@ -2951,7 +2890,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) if (!hif_drv) { result = -EFAULT; - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return result; } @@ -2965,7 +2904,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue : Default key index\n"); + netdev_err(vif->ndev, "Default key index\n"); down(&hif_drv->sem_test_key_block); return result; @@ -2979,7 +2918,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -2998,7 +2937,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue :WEP Key\n"); + netdev_err(vif->ndev, "STA - WEP Key\n"); down(&hif_drv->sem_test_key_block); return result; @@ -3010,19 +2949,14 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, int result = 0; struct host_if_msg msg; struct host_if_drv *hif_drv = vif->hif_drv; - int i; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } memset(&msg, 0, sizeof(struct host_if_msg)); - if (INFO) { - for (i = 0; i < len; i++) - PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]); - } msg.id = HOST_IF_MSG_KEY; msg.body.key_info.type = WEP; msg.body.key_info.action = ADDKEY_AP; @@ -3039,7 +2973,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue :WEP Key\n"); + netdev_err(vif->ndev, "AP - WEP Key\n"); down(&hif_drv->sem_test_key_block); return result; @@ -3053,10 +2987,9 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, struct host_if_msg msg; struct host_if_drv *hif_drv = vif->hif_drv; u8 key_len = ptk_key_len; - int i; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3081,20 +3014,11 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, if (!msg.body.key_info.attr.wpa.key) return -ENOMEM; - if (rx_mic) { + if (rx_mic) memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN); - if (INFO) { - for (i = 0; i < RX_MIC_KEY_LEN; i++) - PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]); - } - } - if (tx_mic) { + + if (tx_mic) memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN); - if (INFO) { - for (i = 0; i < TX_MIC_KEY_LEN; i++) - PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]); - } - } msg.body.key_info.attr.wpa.key_len = key_len; msg.body.key_info.attr.wpa.mac_addr = mac_addr; @@ -3104,7 +3028,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue: PTK Key\n"); + netdev_err(vif->ndev, "PTK Key\n"); down(&hif_drv->sem_test_key_block); @@ -3122,7 +3046,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, u8 key_len = gtk_key_len; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } memset(&msg, 0, sizeof(struct host_if_msg)); @@ -3172,7 +3096,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue: RX GTK\n"); + netdev_err(vif->ndev, "RX GTK\n"); down(&hif_drv->sem_test_key_block); @@ -3188,7 +3112,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, int i; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3208,7 +3132,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER(" Error in sending messagequeue: PMKID Info\n"); + netdev_err(vif->ndev, "PMKID Info\n"); return result; } @@ -3226,7 +3150,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("Failed to send get mac address\n"); + netdev_err(vif->ndev, "Failed to send get mac address\n"); return -EFAULT; } @@ -3245,12 +3169,12 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv || !connect_result) { - PRINT_ER("Driver is null\n"); + netdev_err(vif->ndev, "Driver is null\n"); return -EFAULT; } if (!join_params) { - PRINT_ER("Unable to Join - JoinParams is NULL\n"); + netdev_err(vif->ndev, "Unable to Join - JoinParams is NULL\n"); return -EFAULT; } @@ -3290,7 +3214,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("Failed to send message queue: Set join request\n"); + netdev_err(vif->ndev, "send message: Set join request\n"); return -EFAULT; } @@ -3308,7 +3232,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("Driver is null\n"); + netdev_err(vif->ndev, "Driver is null\n"); return -EFAULT; } @@ -3319,7 +3243,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Failed to send message queue: disconnect\n"); + netdev_err(vif->ndev, "Failed to send message: disconnect\n"); down(&hif_drv->sem_test_disconn_block); @@ -3336,7 +3260,7 @@ static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("Driver is null\n"); + netdev_err(vif->ndev, "Driver is null\n"); return -EFAULT; } @@ -3349,10 +3273,10 @@ static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) { *pu32RcvdAssocRespInfoLen = 0; - PRINT_ER("Failed to send association response config packet\n"); + netdev_err(vif->ndev, "Failed to send association response\n"); return -EINVAL; } - + *pu32RcvdAssocRespInfoLen = wid.size; return result; } @@ -3364,7 +3288,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3375,7 +3299,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); return -EINVAL; } @@ -3395,7 +3319,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); result = -EINVAL; } @@ -3414,7 +3338,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); result = -EINVAL; } @@ -3429,7 +3353,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3441,7 +3365,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Failed to send get host channel param's message queue "); + netdev_err(vif->ndev, "Failed to send get host ch param\n"); down(&hif_drv->sem_inactive_time); @@ -3462,14 +3386,14 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("Failed to send get host channel param's message queue "); + netdev_err(vif->ndev, "Failed to send get host ch param\n"); return -EFAULT; } down(&hif_drv->sem_get_rssi); if (!rssi_level) { - PRINT_ER("RSS pointer value is null"); + netdev_err(vif->ndev, "RSS pointer value is null\n"); return -EFAULT; } @@ -3490,7 +3414,7 @@ int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("Failed to send get host channel param's message queue "); + netdev_err(vif->ndev, "Failed to send get host channel\n"); return -EFAULT; } @@ -3510,7 +3434,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv || !scan_result) { - PRINT_ER("hif_drv or scan_result = NULL\n"); + netdev_err(vif->ndev, "hif_drv or scan_result = NULL\n"); return -EFAULT; } @@ -3543,7 +3467,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) { - PRINT_ER("Error in sending message queue\n"); + netdev_err(vif->ndev, "Error in sending message queue\n"); return -EINVAL; } @@ -3555,20 +3479,20 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, } int wilc_hif_set_cfg(struct wilc_vif *vif, - struct cfg_param_val *cfg_param) + struct cfg_param_attr *cfg_param) { int result = 0; struct host_if_msg msg; struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("hif_drv NULL\n"); + netdev_err(vif->ndev, "hif_drv NULL\n"); return -EFAULT; } memset(&msg, 0, sizeof(struct host_if_msg)); msg.id = HOST_IF_MSG_CFG_PARAMS; - msg.body.cfg_info.cfg_attr_info = *cfg_param; + msg.body.cfg_info = *cfg_param; msg.vif = vif; result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); @@ -3581,7 +3505,7 @@ static void GetPeriodicRSSI(unsigned long arg) struct wilc_vif *vif = (struct wilc_vif *)arg; if (!vif->hif_drv) { - PRINT_ER("Driver handler is NULL\n"); + netdev_err(vif->ndev, "Driver handler is NULL\n"); return; } @@ -3630,15 +3554,13 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) sema_init(&hif_drv->sem_test_key_block, 0); sema_init(&hif_drv->sem_test_disconn_block, 0); sema_init(&hif_drv->sem_get_rssi, 0); - sema_init(&hif_drv->sem_get_link_speed, 0); - sema_init(&hif_drv->sem_get_chnl, 0); sema_init(&hif_drv->sem_inactive_time, 0); if (clients_count == 0) { result = wilc_mq_create(&hif_msg_q); if (result < 0) { - PRINT_ER("Failed to creat MQ\n"); + netdev_err(vif->ndev, "Failed to creat MQ\n"); goto _fail_; } @@ -3646,7 +3568,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) "WILC_kthread"); if (IS_ERR(hif_thread_handler)) { - PRINT_ER("Failed to creat Thread\n"); + netdev_err(vif->ndev, "Failed to creat Thread\n"); result = -EFAULT; goto _fail_mq_; } @@ -3690,7 +3612,7 @@ int wilc_deinit(struct wilc_vif *vif) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("hif_drv = NULL\n"); + netdev_err(vif->ndev, "hif_drv = NULL\n"); return -EFAULT; } @@ -3725,7 +3647,7 @@ int wilc_deinit(struct wilc_vif *vif) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result != 0) - PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result); + netdev_err(vif->ndev, "deinit : Error(%d)\n", result); down(&hif_sema_thread); @@ -3756,7 +3678,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer, hif_drv = vif->hif_drv; if (!hif_drv || hif_drv == terminated_handle) { - PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv); + netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); return; } @@ -3771,7 +3693,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result); + netdev_err(vif->ndev, "message parameters (%d)\n", result); } void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, @@ -3800,7 +3722,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, } if (!hif_drv->usr_conn_req.conn_result) { - PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n"); + netdev_err(vif->ndev, "there is no current Connect Request\n"); up(&hif_sema_deinit); return; } @@ -3816,7 +3738,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result); + netdev_err(vif->ndev, "synchronous info (%d)\n", result); up(&hif_sema_deinit); } @@ -3847,7 +3769,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result); + netdev_err(vif->ndev, "complete param (%d)\n", result); } } @@ -3862,7 +3784,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3879,7 +3801,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); return result; } @@ -3891,7 +3813,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3904,7 +3826,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); return result; } @@ -3916,7 +3838,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3941,7 +3863,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); return result; } @@ -3955,7 +3877,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -3985,7 +3907,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc mq send fail\n"); + netdev_err(vif->ndev, "wilc mq send fail\n"); ERRORHANDLER: if (result) { @@ -4004,7 +3926,7 @@ int wilc_del_beacon(struct wilc_vif *vif) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4013,7 +3935,7 @@ int wilc_del_beacon(struct wilc_vif *vif) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4026,7 +3948,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4046,7 +3968,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4058,7 +3980,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4074,7 +3996,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4089,7 +4011,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) u8 assoc_sta = 0; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4101,26 +4023,17 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) for (i = 0; i < MAX_NUM_STA; i++) { if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN); - PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", - del_all_sta_info->del_all_sta[i][0], - del_all_sta_info->del_all_sta[i][1], - del_all_sta_info->del_all_sta[i][2], - del_all_sta_info->del_all_sta[i][3], - del_all_sta_info->del_all_sta[i][4], - del_all_sta_info->del_all_sta[i][5]); assoc_sta++; } } - if (!assoc_sta) { - PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n"); + if (!assoc_sta) return result; - } del_all_sta_info->assoc_sta = assoc_sta; result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); down(&hif_sema_wait_response); @@ -4136,7 +4049,7 @@ int wilc_edit_station(struct wilc_vif *vif, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4156,7 +4069,7 @@ int wilc_edit_station(struct wilc_vif *vif, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4169,7 +4082,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4186,7 +4099,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4199,7 +4112,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4213,7 +4126,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4378,7 +4291,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4392,7 +4305,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } @@ -4404,7 +4317,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) struct host_if_drv *hif_drv = vif->hif_drv; if (!hif_drv) { - PRINT_ER("driver is null\n"); + netdev_err(vif->ndev, "driver is null\n"); return -EFAULT; } @@ -4418,7 +4331,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) - PRINT_ER("wilc_mq_send fail\n"); + netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 5e65f2c..795c18c 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -96,7 +96,7 @@ enum CURRENT_TXRATE { MBPS_54 = 54 }; -struct cfg_param_val { +struct cfg_param_attr { u32 flag; u8 ht_enable; u8 bss_type; @@ -172,9 +172,9 @@ typedef void (*wilc_scan_result)(enum scan_event, struct network_info *, void *, void *); typedef void (*wilc_connect_result)(enum conn_event, - tstrConnectInfo *, + struct connect_info *, u8, - tstrDisconnectNotifInfo *, + struct disconnect_info *, void *); typedef void (*wilc_remain_on_chan_expired)(void *, u32); @@ -272,14 +272,12 @@ struct host_if_drv { enum host_if_state hif_state; u8 assoc_bssid[ETH_ALEN]; - struct cfg_param_val cfg_values; + struct cfg_param_attr cfg_values; struct semaphore sem_cfg_values; struct semaphore sem_test_key_block; struct semaphore sem_test_disconn_block; struct semaphore sem_get_rssi; - struct semaphore sem_get_link_speed; - struct semaphore sem_get_chnl; struct semaphore sem_inactive_time; struct timer_list scan_timer; @@ -338,7 +336,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, size_t ies_len, wilc_scan_result scan_result, void *user_arg, struct hidden_network *hidden_network); int wilc_hif_set_cfg(struct wilc_vif *vif, - struct cfg_param_val *cfg_param); + struct cfg_param_attr *cfg_param); int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); int wilc_deinit(struct wilc_vif *vif); int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index 21f35d7..7d9e5de 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -7,7 +7,6 @@ * @version 1.0 */ #include "wilc_wfi_cfgoperations.h" -#include "linux_wlan_common.h" #include "wilc_wlan_if.h" #include "wilc_wlan.h" @@ -52,15 +51,11 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size) struct wilc_wfi_radiotap_hdr *hdr; struct wilc_wfi_radiotap_cb_hdr *cb_hdr; - PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n"); - if (!wilc_wfi_mon) return; - if (!netif_running(wilc_wfi_mon)) { - PRINT_INFO(HOSTAPD_DBG, "Monitor interface already RUNNING\n"); + if (!netif_running(wilc_wfi_mon)) return; - } /* Get WILC header */ memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); @@ -73,10 +68,8 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size) /* hostapd callback mgmt frame */ skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr)); - if (!skb) { - PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); + if (!skb) return; - } memcpy(skb_put(skb, size), buff, size); @@ -103,20 +96,16 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size) } else { skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr)); - if (!skb) { - PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb"); + if (!skb) return; - } memcpy(skb_put(skb, size), buff, size); hdr = (struct wilc_wfi_radiotap_hdr *)skb_push(skb, sizeof(*hdr)); memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr)); - PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len); hdr->hdr.it_present = cpu_to_le32 (1 << IEEE80211_RADIOTAP_RATE); /* | */ - PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present); hdr->rate = 5; /* txrate->bitrate / 5; */ } @@ -138,14 +127,6 @@ struct tx_complete_mon_data { static void mgmt_tx_complete(void *priv, int status) { struct tx_complete_mon_data *pv_data = priv; - u8 *buf = pv_data->buff; - - if (status == 1) { - if (INFO || buf[0] == 0x10 || buf[0] == 0xb0) - PRINT_INFO(HOSTAPD_DBG, "Packet sent successfully - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); - } else { - PRINT_INFO(HOSTAPD_DBG, "Couldn't send packet - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff); - } /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */ kfree(pv_data->buff); @@ -157,10 +138,8 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) { struct tx_complete_mon_data *mgmt_tx = NULL; - if (!dev) { - PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n"); + if (!dev) return -EFAULT; - } netif_stop_queue(dev); mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); @@ -195,7 +174,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, struct net_device *dev) { - u32 rtap_len, i, ret = 0; + u32 rtap_len, ret = 0; struct WILC_WFI_mon_priv *mon_priv; struct sk_buff *skb2; @@ -205,30 +184,14 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, return -EFAULT; mon_priv = netdev_priv(wilc_wfi_mon); - - if (!mon_priv) { - PRINT_ER("Monitor interface private structure is NULL\n"); + if (!mon_priv) return -EFAULT; - } - rtap_len = ieee80211_get_radiotap_len(skb->data); - if (skb->len < rtap_len) { - PRINT_ER("Error in radiotap header\n"); + if (skb->len < rtap_len) return -1; - } - /* skip the radiotap header */ - PRINT_INFO(HOSTAPD_DBG, "Radiotap len: %d\n", rtap_len); - if (INFO) { - for (i = 0; i < rtap_len; i++) - PRINT_INFO(HOSTAPD_DBG, "Radiotap_hdr[%d] %02x\n", i, skb->data[i]); - } - /* Skip the ratio tap header */ skb_pull(skb, rtap_len); - if (skb->data[0] == 0xc0) - PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n", skb->data[4], skb->data[5], skb->data[6], skb->data[7], skb->data[8], skb->data[9]); - if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) { skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); @@ -261,19 +224,15 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, } skb->dev = mon_priv->real_ndev; - PRINT_INFO(HOSTAPD_DBG, "Skipping the radiotap header\n"); - - /* actual deliver of data is device-specific, and not shown here */ - PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name); - PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name); - /* Identify if Ethernet or MAC header (data or mgmt) */ memcpy(srcAdd, &skb->data[10], 6); memcpy(bssid, &skb->data[16], 6); /* if source address and bssid fields are equal>>Mac header */ /*send it to mgmt frames handler */ if (!(memcmp(srcAdd, bssid, 6))) { - mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); + ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); + if (ret) + netdev_err(dev, "fail to mgmt tx\n"); dev_kfree_skb(skb); } else { ret = wilc_mac_xmit(skb, mon_priv->real_ndev); @@ -302,15 +261,12 @@ struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_devi struct WILC_WFI_mon_priv *priv; /*If monitor interface is already initialized, return it*/ - if (wilc_wfi_mon) + if (wilc_wfi_mon) return wilc_wfi_mon; wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv)); - if (!wilc_wfi_mon) { - PRINT_ER("failed to allocate memory\n"); + if (!wilc_wfi_mon) return NULL; - } - wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP; strncpy(wilc_wfi_mon->name, name, IFNAMSIZ); wilc_wfi_mon->name[IFNAMSIZ - 1] = 0; @@ -318,14 +274,12 @@ struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_devi ret = register_netdevice(wilc_wfi_mon); if (ret) { - PRINT_ER(" register_netdevice failed (%d)\n", ret); + netdev_err(real_dev, "register_netdevice failed\n"); return NULL; } priv = netdev_priv(wilc_wfi_mon); - if (!priv) { - PRINT_ER("private structure is NULL\n"); + if (!priv) return NULL; - } priv->real_ndev = real_dev; @@ -346,13 +300,10 @@ int WILC_WFI_deinit_mon_interface(void) bool rollback_lock = false; if (wilc_wfi_mon) { - PRINT_D(HOSTAPD_DBG, "In Deinit monitor interface\n"); - PRINT_D(HOSTAPD_DBG, "RTNL is being locked\n"); if (rtnl_is_locked()) { rtnl_unlock(); rollback_lock = true; } - PRINT_D(HOSTAPD_DBG, "Unregister netdev\n"); unregister_netdev(wilc_wfi_mon); if (rollback_lock) { diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index a731b46..bfa754b 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1,5 +1,4 @@ #include "wilc_wfi_cfgoperations.h" -#include "linux_wlan_common.h" #include "wilc_wlan_if.h" #include "wilc_wlan.h" @@ -13,7 +12,6 @@ #include <linux/kthread.h> #include <linux/firmware.h> -#include <linux/delay.h> #include <linux/init.h> #include <linux/netdevice.h> @@ -224,11 +222,6 @@ static void deinit_irq(struct net_device *dev) } } -void wilc_dbg(u8 *buff) -{ - PRINT_D(INIT_DBG, "%d\n", *buff); -} - int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout) { /* FIXME: replace with mutex_lock or wait_for_completion */ @@ -1312,7 +1305,7 @@ EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, int gpio, const struct wilc_hif_func *ops) { - int i; + int i, ret; struct wilc_vif *vif; struct net_device *ndev; struct wilc *wl; @@ -1333,7 +1326,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, for (i = 0; i < NUM_CONCURRENT_IFC; i++) { ndev = alloc_etherdev(sizeof(struct wilc_vif)); if (!ndev) - return -1; + return -ENOMEM; vif = netdev_priv(ndev); memset(vif, 0, sizeof(struct wilc_vif)); @@ -1372,8 +1365,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, vif->netstats.tx_bytes = 0; } - if (register_netdev(ndev)) - return -1; + ret = register_netdev(ndev); + if (ret) + return ret; vif->iftype = STATION_MODE; vif->mac_opened = 0; diff --git a/drivers/staging/wilc1000/linux_wlan_common.h b/drivers/staging/wilc1000/linux_wlan_common.h deleted file mode 100644 index 0d9a71f..0000000 --- a/drivers/staging/wilc1000/linux_wlan_common.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef LINUX_WLAN_COMMON_H -#define LINUX_WLAN_COMMON_H - -enum debug_region { - Hostapd_debug = 0, - CFG80211_debug, - Init_debug, - COMP = 0xFFFFFFFF, -}; - -#define HOSTAPD_DBG (1 << Hostapd_debug) -#define CFG80211_DBG (1 << CFG80211_debug) -#define INIT_DBG (1 << Init_debug) - -#if defined(WILC_DEBUGFS) -extern atomic_t WILC_REGION; -extern atomic_t WILC_DEBUG_LEVEL; - -#define DEBUG BIT(0) -#define INFO BIT(1) -#define WRN BIT(2) -#define ERR BIT(3) - -#define PRINT_D(region, ...) \ - do { \ - if ((atomic_read(&WILC_DEBUG_LEVEL) & DEBUG) && \ - ((atomic_read(&WILC_REGION)) & (region))) { \ - printk("DBG [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_INFO(region, ...) \ - do { \ - if ((atomic_read(&WILC_DEBUG_LEVEL) & INFO) && \ - ((atomic_read(&WILC_REGION)) & (region))) { \ - printk("INFO [%s]", __func__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_WRN(region, ...) \ - do { \ - if ((atomic_read(&WILC_DEBUG_LEVEL) & WRN) && \ - ((atomic_read(&WILC_REGION)) & (region))) { \ - printk("WRN [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_ER(...) \ - do { \ - if ((atomic_read(&WILC_DEBUG_LEVEL) & ERR)) { \ - printk("ERR [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#else - -#define REGION (INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG) - -#define DEBUG 1 -#define INFO 0 -#define WRN 0 - -#define PRINT_D(region, ...) \ - do { \ - if (DEBUG == 1 && ((REGION)&(region))) { \ - printk("DBG [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_INFO(region, ...) \ - do { \ - if (INFO == 1 && ((REGION)&(region))) { \ - printk("INFO [%s]", __func__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_WRN(region, ...) \ - do { \ - if (WRN == 1 && ((REGION)&(region))) { \ - printk("WRN [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } \ - } while (0) - -#define PRINT_ER(...) \ - do { \ - printk("ERR [%s: %d]", __func__, __LINE__); \ - printk(__VA_ARGS__); \ - } while (0) - -#endif - -#define LINUX_RX_SIZE (96 * 1024) -#define LINUX_TX_SIZE (64 * 1024) - - -#define WILC_MULTICAST_TABLE_SIZE 8 - -#if defined(BEAGLE_BOARD) - #define SPI_CHANNEL 4 - - #if SPI_CHANNEL == 4 - #define MODALIAS "wilc_spi4" - #define GPIO_NUM 162 - #else - #define MODALIAS "wilc_spi3" - #define GPIO_NUM 133 - #endif -#elif defined(PLAT_WMS8304) /* rachel */ - #define MODALIAS "wilc_spi" - #define GPIO_NUM 139 -#elif defined(PLAT_RKXXXX) - #define MODALIAS "WILC_IRQ" - #define GPIO_NUM RK30_PIN3_PD2 /* RK30_PIN3_PA1 */ -/* RK30_PIN3_PD2 */ -/* RK2928_PIN1_PA7 */ - -#elif defined(CUSTOMER_PLATFORM) -/* - TODO : specify MODALIAS name and GPIO number. This is certainly necessary for SPI interface. - * - * ex) - * #define MODALIAS "WILC_SPI" - * #define GPIO_NUM 139 - */ - -#else -/* base on SAMA5D3_Xplained Board */ - #define MODALIAS "WILC_SPI" - #define GPIO_NUM 0x44 -#endif -#endif diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index da7ec8b..fcbc95d 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c @@ -23,12 +23,12 @@ static struct dentry *wilc_dir; /* * -------------------------------------------------------------------------------- */ +#define DEBUG BIT(0) +#define INFO BIT(1) +#define WRN BIT(2) +#define ERR BIT(3) -#define DBG_REGION_ALL (HOSTAPD_DBG | CFG80211_DBG | INIT_DBG) #define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) -atomic_t WILC_REGION = ATOMIC_INIT(INIT_DBG | CFG80211_DBG | - HOSTAPD_DBG); -EXPORT_SYMBOL_GPL(WILC_REGION); atomic_t WILC_DEBUG_LEVEL = ATOMIC_INIT(ERR); EXPORT_SYMBOL_GPL(WILC_DEBUG_LEVEL); @@ -76,44 +76,6 @@ static ssize_t wilc_debug_level_write(struct file *filp, const char __user *buf, return count; } -static ssize_t wilc_debug_region_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) -{ - char buf[128]; - int res = 0; - - /* only allow read from start */ - if (*ppos > 0) - return 0; - - res = scnprintf(buf, sizeof(buf), "Debug region: %x\n", atomic_read(&WILC_REGION)); - - return simple_read_from_buffer(userbuf, count, ppos, buf, res); -} - -static ssize_t wilc_debug_region_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos) -{ - char buffer[128] = {}; - int flag; - - if (count > sizeof(buffer)) - return -EINVAL; - - if (copy_from_user(buffer, buf, count)) - return -EFAULT; - - flag = buffer[0] - '0'; - - if (flag > DBG_REGION_ALL) { - printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&WILC_REGION)); - return -EFAULT; - } - - atomic_set(&WILC_REGION, (int)flag); - printk("new debug-region is %x\n", atomic_read(&WILC_REGION)); - - return count; -} - /* * -------------------------------------------------------------------------------- */ @@ -130,12 +92,11 @@ struct wilc_debugfs_info_t { const char *name; int perm; unsigned int data; - struct file_operations fops; + const struct file_operations fops; }; static struct wilc_debugfs_info_t debugfs_info[] = { { "wilc_debug_level", 0666, (DEBUG | ERR), FOPS(NULL, wilc_debug_level_read, wilc_debug_level_write, NULL), }, - { "wilc_debug_region", 0666, (INIT_DBG | CFG80211_DBG), FOPS(NULL, wilc_debug_region_read, wilc_debug_region_write, NULL), }, }; static int __init wilc_debugfs_init(void) diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c index 780ddd3..6cb894e 100644 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ b/drivers/staging/wilc1000/wilc_msgqueue.c @@ -1,7 +1,6 @@ #include "wilc_msgqueue.h" #include <linux/spinlock.h> -#include "linux_wlan_common.h" #include <linux/errno.h> #include <linux/slab.h> diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 963875af..029bd09 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -30,15 +30,15 @@ static const struct sdio_device_id wilc_sdio_ids[] = { #define WILC_SDIO_BLOCK_SIZE 512 -typedef struct { +struct wilc_sdio { bool irq_gpio; u32 block_size; int nint; #define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in registers 0xf7, 0xf8 */ int has_thrpt_enh3; -} wilc_sdio_t; +}; -static wilc_sdio_t g_sdio; +static struct wilc_sdio g_sdio; static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data); static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data); @@ -675,7 +675,7 @@ static int sdio_init(struct wilc *wilc, bool resume) u32 chipid; if (!resume) { - memset(&g_sdio, 0, sizeof(wilc_sdio_t)); + memset(&g_sdio, 0, sizeof(struct wilc_sdio)); g_sdio.irq_gpio = wilc->dev_irq_num; } diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 2928712..d41b8b6 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -18,19 +18,18 @@ #include <linux/spi/spi.h> #include <linux/of_gpio.h> -#include "linux_wlan_common.h" #include <linux/string.h> #include "wilc_wlan_if.h" #include "wilc_wlan.h" #include "wilc_wfi_netdevice.h" -typedef struct { +struct wilc_spi { int crc_off; int nint; int has_thrpt_enh; -} wilc_spi_t; +}; -static wilc_spi_t g_spi; +static struct wilc_spi g_spi; static int wilc_spi_read(struct wilc *wilc, u32, u8 *, u32); static int wilc_spi_write(struct wilc *wilc, u32, u8 *, u32); @@ -380,9 +379,8 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, break; } - if (result != N_OK) { + if (result != N_OK) return result; - } if (!g_spi.crc_off) wb[len - 1] = (crc7(0x7f, (const u8 *)&wb[0], len - 1)) << 1; @@ -419,9 +417,8 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, return result; } /* zero spi write buffers. */ - for (wix = len; wix < len2; wix++) { + for (wix = len; wix < len2; wix++) wb[wix] = 0; - } rix = len; if (wilc_spi_tx_rx(wilc, wb, rb, len2)) { @@ -445,8 +442,9 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, /* } while(&rptr[1] <= &rb[len2]); */ if (rsp != cmd) { - dev_err(&spi->dev, "Failed cmd response, cmd (%02x)" - ", resp (%02x)\n", cmd, rsp); + dev_err(&spi->dev, + "Failed cmd response, cmd (%02x), resp (%02x)\n", + cmd, rsp); result = N_FAIL; return result; } @@ -514,7 +512,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, crc[0] = rb[rix++]; crc[1] = rb[rix++]; } else { - dev_err(&spi->dev,"buffer overrun when reading crc.\n"); + dev_err(&spi->dev, "buffer overrun when reading crc.\n"); result = N_FAIL; return result; } @@ -523,9 +521,8 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, int ix; /* some data may be read in response to dummy bytes. */ - for (ix = 0; (rix < len2) && (ix < sz); ) { + for (ix = 0; (rix < len2) && (ix < sz); ) b[ix++] = rb[rix++]; - } sz -= ix; @@ -680,7 +677,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz) **/ if (!g_spi.crc_off) { if (wilc_spi_tx(wilc, crc, 2)) { - dev_err(&spi->dev,"Failed data block crc write, bus error...\n"); + dev_err(&spi->dev, "Failed data block crc write, bus error...\n"); result = N_FAIL; break; } @@ -711,9 +708,8 @@ static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) dat = cpu_to_le32(dat); result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, 0); - if (result != N_OK) { + if (result != N_OK) dev_err(&spi->dev, "Failed internal write cmd...\n"); - } return result; } @@ -756,9 +752,8 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) } result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless); - if (result != N_OK) { + if (result != N_OK) dev_err(&spi->dev, "Failed cmd, write reg (%08x)...\n", addr); - } return result; } @@ -786,9 +781,8 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) * Data **/ result = spi_data_write(wilc, buf, size); - if (result != N_OK) { + if (result != N_OK) dev_err(&spi->dev, "Failed block data write...\n"); - } return 1; } @@ -867,7 +861,7 @@ static int wilc_spi_init(struct wilc *wilc, bool resume) return 1; } - memset(&g_spi, 0, sizeof(wilc_spi_t)); + memset(&g_spi, 0, sizeof(struct wilc_spi)); /** * configure protocol @@ -1074,7 +1068,7 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1); if (!ret) { - dev_err(&spi->dev,"fail write reg vmm_core_ctl...\n"); + dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n"); goto _fail_; } } @@ -1124,9 +1118,9 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int nint) return 0; } - for (i = 0; (i < 5) && (nint > 0); i++, nint--) { + for (i = 0; (i < 5) && (nint > 0); i++, nint--) reg |= (BIT((27 + i))); - } + ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg); if (!ret) { dev_err(&spi->dev, "Failed write reg (%08x)...\n", @@ -1141,9 +1135,8 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int nint) return 0; } - for (i = 0; (i < 3) && (nint > 0); i++, nint--) { + for (i = 0; (i < 3) && (nint > 0); i++, nint--) reg |= BIT(i); - } ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®); if (!ret) { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 81a2ee9..378c350 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -157,7 +157,7 @@ static u8 wlan_channel = INVALID_CHANNEL; static u8 curr_channel; static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; static u8 p2p_local_random = 0x01; -static u8 p2p_recv_random = 0x00; +static u8 p2p_recv_random; static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; static bool wilc_ie; @@ -290,9 +290,6 @@ static void remove_network_from_shadow(unsigned long arg) for (i = 0; i < last_scanned_cnt; i++) { if (time_after(now, last_scanned_shadow[i].time_scan + (unsigned long)(SCAN_RESULT_EXPIRE))) { - PRINT_D(CFG80211_DBG, "Network expired ScanShadow:%s\n", - last_scanned_shadow[i].ssid); - kfree(last_scanned_shadow[i].ies); last_scanned_shadow[i].ies = NULL; @@ -305,13 +302,9 @@ static void remove_network_from_shadow(unsigned long arg) } } - PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", - last_scanned_cnt); if (last_scanned_cnt != 0) { hAgingTimer.data = arg; mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); - } else { - PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); } } @@ -327,7 +320,6 @@ static int is_network_in_shadow(struct network_info *pstrNetworkInfo, int i; if (last_scanned_cnt == 0) { - PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); hAgingTimer.data = (unsigned long)user_void; mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); state = -1; @@ -350,10 +342,9 @@ static void add_network_to_shadow(struct network_info *pstrNetworkInfo, u32 ap_index = 0; u8 rssi_index = 0; - if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) { - PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n"); + if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) return; - } + if (ap_found == -1) { ap_index = last_scanned_cnt; last_scanned_cnt++; @@ -424,21 +415,8 @@ static void CfgScanResult(enum scan_event scan_event, if (!channel) return; - PRINT_INFO(CFG80211_DBG, "Network Info::" - "CHANNEL Frequency: %d," - "RSSI: %d," - "Capability Info: %d," - "Beacon Period: %d\n", - channel->center_freq, - (s32)network_info->rssi * 100, - network_info->cap_info, - network_info->beacon_period); - if (network_info->new_network) { if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { - PRINT_D(CFG80211_DBG, - "Network %s found\n", - network_info->ssid); priv->u32RcvdChCount++; add_network_to_shadow(network_info, priv, join_params); @@ -463,8 +441,6 @@ static void CfgScanResult(enum scan_event scan_event, for (i = 0; i < priv->u32RcvdChCount; i++) { if (memcmp(last_scanned_shadow[i].bssid, network_info->bssid, 6) == 0) { - PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", last_scanned_shadow[i].ssid); - last_scanned_shadow[i].rssi = network_info->rssi; last_scanned_shadow[i].time_scan = jiffies; break; @@ -473,15 +449,8 @@ static void CfgScanResult(enum scan_event scan_event, } } } else if (scan_event == SCAN_EVENT_DONE) { - PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev); - PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n"); refresh_scan(priv, 1, false); - if (priv->u32RcvdChCount > 0) - PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount); - else - PRINT_D(CFG80211_DBG, "No networks found\n"); - down(&(priv->hSemScanReq)); if (priv->pstrScanReq) { @@ -494,7 +463,6 @@ static void CfgScanResult(enum scan_event scan_event, } else if (scan_event == SCAN_EVENT_ABORTED) { down(&(priv->hSemScanReq)); - PRINT_D(CFG80211_DBG, "Scan Aborted\n"); if (priv->pstrScanReq) { update_scan_time(); refresh_scan(priv, 1, false); @@ -511,9 +479,9 @@ static void CfgScanResult(enum scan_event scan_event, int wilc_connecting; static void CfgConnectResult(enum conn_event enuConnDisconnEvent, - tstrConnectInfo *pstrConnectInfo, + struct connect_info *pstrConnectInfo, u8 u8MacStatus, - tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, + struct disconnect_info *pstrDisconnectNotifInfo, void *pUserVoid) { struct wilc_priv *priv; @@ -534,12 +502,10 @@ static void CfgConnectResult(enum conn_event enuConnDisconnEvent, if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { u16 u16ConnectStatus; - u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; - - PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus); + u16ConnectStatus = pstrConnectInfo->status; if ((u8MacStatus == MAC_DISCONNECTED) && - (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { + (pstrConnectInfo->status == SUCCESSFUL_STATUSCODE)) { u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE); @@ -555,14 +521,12 @@ static void CfgConnectResult(enum conn_event enuConnDisconnEvent, bool bNeedScanRefresh = false; u32 i; - PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], - pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); - memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); + memcpy(priv->au8AssociatedBss, pstrConnectInfo->bssid, ETH_ALEN); for (i = 0; i < last_scanned_cnt; i++) { if (memcmp(last_scanned_shadow[i].bssid, - pstrConnectInfo->au8bssid, + pstrConnectInfo->bssid, ETH_ALEN) == 0) { unsigned long now = jiffies; @@ -579,14 +543,9 @@ static void CfgConnectResult(enum conn_event enuConnDisconnEvent, refresh_scan(priv, 1, true); } - - PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen); - - PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); - - cfg80211_connect_result(dev, pstrConnectInfo->au8bssid, - pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen, - pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen, + cfg80211_connect_result(dev, pstrConnectInfo->bssid, + pstrConnectInfo->req_ies, pstrConnectInfo->req_ies_len, + pstrConnectInfo->resp_ies, pstrConnectInfo->resp_ies_len, u16ConnectStatus, GFP_KERNEL); } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { wilc_optaining_ip = false; @@ -600,11 +559,11 @@ static void CfgConnectResult(enum conn_event enuConnDisconnEvent, if (!pstrWFIDrv->p2p_connect) wlan_channel = INVALID_CHANNEL; if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) { - pstrDisconnectNotifInfo->u16reason = 3; + pstrDisconnectNotifInfo->reason = 3; } else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) { - pstrDisconnectNotifInfo->u16reason = 1; + pstrDisconnectNotifInfo->reason = 1; } - cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie, + cfg80211_disconnected(dev, pstrDisconnectNotifInfo->reason, pstrDisconnectNotifInfo->ie, pstrDisconnectNotifInfo->ie_len, false, GFP_KERNEL); } @@ -622,7 +581,6 @@ static int set_channel(struct wiphy *wiphy, vif = netdev_priv(priv->dev); channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); - PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq); curr_channel = channelnum; result = wilc_set_mac_chnl_num(vif, channelnum); @@ -653,18 +611,16 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) priv->bCfgScanning = true; if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { - for (i = 0; i < request->n_channels; i++) { + for (i = 0; i < request->n_channels; i++) au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); - PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); - } - - PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels); - PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len); - - PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); if (request->n_ssids >= 1) { - strHiddenNetwork.net_info = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL); + strHiddenNetwork.net_info = + kmalloc_array(request->n_ssids, + sizeof(struct hidden_network), + GFP_KERNEL); + if (!strHiddenNetwork.net_info) + return -ENOMEM; strHiddenNetwork.n_ssids = request->n_ssids; @@ -675,11 +631,9 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) memcpy(strHiddenNetwork.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len; } else { - PRINT_D(CFG80211_DBG, "Received one NULL SSID\n"); strHiddenNetwork.n_ssids -= 1; } } - PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, au8ScanChanList, request->n_channels, @@ -687,7 +641,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) request->ie_len, CfgScanResult, (void *)priv, &strHiddenNetwork); } else { - PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, au8ScanChanList, request->n_channels, @@ -699,10 +652,8 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) netdev_err(priv->dev, "Requested scanned channels over\n"); } - if (s32Error != 0) { + if (s32Error != 0) s32Error = -EBUSY; - PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error); - } return s32Error; } @@ -728,53 +679,30 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, vif = netdev_priv(priv->dev); pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; - PRINT_D(CFG80211_DBG, - "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", - sme->ssid, dev, priv->hif_drv); - if (!(strncmp(sme->ssid, "DIRECT-", 7))) { - PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); + if (!(strncmp(sme->ssid, "DIRECT-", 7))) pstrWFIDrv->p2p_connect = 1; - } else { + else pstrWFIDrv->p2p_connect = 0; - } - PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type); for (i = 0; i < last_scanned_cnt; i++) { if ((sme->ssid_len == last_scanned_shadow[i].ssid_len) && memcmp(last_scanned_shadow[i].ssid, sme->ssid, sme->ssid_len) == 0) { - PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid); - if (!sme->bssid) { - PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n"); + if (!sme->bssid) break; - } else { + else if (memcmp(last_scanned_shadow[i].bssid, sme->bssid, - ETH_ALEN) == 0) { - PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n"); + ETH_ALEN) == 0) break; - } - } } } if (i < last_scanned_cnt) { - PRINT_D(CFG80211_DBG, "Required bss is in scan results\n"); - pstrNetworkInfo = &last_scanned_shadow[i]; - - PRINT_INFO(CFG80211_DBG, "network BSSID to be associated:" - "%x%x%x%x%x%x\n", - pstrNetworkInfo->bssid[0], pstrNetworkInfo->bssid[1], - pstrNetworkInfo->bssid[2], pstrNetworkInfo->bssid[3], - pstrNetworkInfo->bssid[4], pstrNetworkInfo->bssid[5]); } else { s32Error = -ENOENT; - if (last_scanned_cnt == 0) - PRINT_D(CFG80211_DBG, "No Scan results yet\n"); - else - PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error); wilc_connecting = 0; return s32Error; } @@ -782,18 +710,12 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len)); - PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions); - PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group); - - PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise); - if (sme->crypto.cipher_group != NO_ENCRYPT) { pcwpa_version = "Default"; if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { u8security = ENCRYPT_ENABLED | WEP; pcgroup_encrypt_val = "WEP40"; pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; - PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx); priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); @@ -866,22 +788,17 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, } } - PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group); - - PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type); switch (sme->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: - PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n"); tenuAuth_type = OPEN_SYSTEM; break; case NL80211_AUTHTYPE_SHARED_KEY: tenuAuth_type = SHARED_KEY; - PRINT_D(CFG80211_DBG, "In SHARED KEY\n"); break; default: - PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type); + break; } if (sme->crypto.n_akm_suites) { @@ -895,12 +812,6 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, } } - - PRINT_INFO(CFG80211_DBG, "Required Ch = %d\n", pstrNetworkInfo->ch); - - PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n", - pcgroup_encrypt_val, pccipher_group, pcwpa_version); - curr_channel = pstrNetworkInfo->ch; if (!pstrWFIDrv->p2p_connect) @@ -941,8 +852,6 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_co wlan_channel = INVALID_CHANNEL; wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE); - PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code); - p2p_local_random = 0x01; p2p_recv_random = 0x00; wilc_ie = false; @@ -963,7 +872,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, { s32 s32Error = 0, KeyLen = params->key_len; - u32 i; struct wilc_priv *priv; const u8 *pu8RxMic = NULL; const u8 *pu8TxMic = NULL; @@ -978,15 +886,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, vif = netdev_priv(netdev); wl = vif->wilc; - PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); - - PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index); - - PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], - params->key[1], - params->key[2]); - - switch (params->cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: @@ -994,12 +893,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, priv->WILC_WFI_wep_key_len[key_index] = params->key_len; memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); - PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index); - PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len); - - for (i = 0; i < params->key_len; i++) - PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]); - tenuAuth_type = OPEN_SYSTEM; if (params->cipher == WLAN_CIPHER_SUITE_WEP40) @@ -1016,12 +909,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, priv->WILC_WFI_wep_key_len[key_index] = params->key_len; memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); - PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index); - PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len); - if (INFO) { - for (i = 0; i < params->key_len; i++) - PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]); - } wilc_add_wep_key_bss_sta(vif, params->key, params->key_len, key_index); } @@ -1072,22 +959,12 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, priv->wilc_gtk[key_index]->key_len = params->key_len; priv->wilc_gtk[key_index]->seq_len = params->seq_len; - if (INFO) { - for (i = 0; i < params->key_len; i++) - PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]); - for (i = 0; i < params->seq_len; i++) - PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); - } - - wilc_add_rx_gtk(vif, params->key, KeyLen, key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode); } else { - PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]); - if (params->cipher == WLAN_CIPHER_SUITE_TKIP) u8pmode = ENCRYPT_ENABLED | WPA | TKIP; else @@ -1109,14 +986,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, if ((params->seq_len) > 0) priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); - if (INFO) { - for (i = 0; i < params->key_len; i++) - PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]); - - for (i = 0; i < params->seq_len; i++) - PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); - } - memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); if ((params->seq_len) > 0) @@ -1160,10 +1029,6 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); } g_key_gtk_params.cipher = params->cipher; - - PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], - g_key_gtk_params.key[1], - g_key_gtk_params.key[2]); g_gtk_keys_saved = true; } @@ -1197,21 +1062,12 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); } g_key_ptk_params.cipher = params->cipher; - - PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], - g_key_ptk_params.key[1], - g_key_ptk_params.key[2]); g_ptk_keys_saved = true; } wilc_add_ptk(vif, params->key, KeyLen, mac_addr, pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index); - PRINT_D(CFG80211_DBG, "Adding pairwise key\n"); - if (INFO) { - for (i = 0; i < params->key_len; i++) - PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]); - } } } break; @@ -1279,11 +1135,8 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev, if (key_index >= 0 && key_index <= 3) { memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]); priv->WILC_WFI_wep_key_len[key_index] = 0; - - PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index); wilc_remove_wep_key(vif, key_index); } else { - PRINT_D(CFG80211_DBG, "Removing all installed keys\n"); wilc_remove_key(priv->hif_drv, mac_addr); } @@ -1296,26 +1149,17 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, { struct wilc_priv *priv; struct key_params key_params; - u32 i; priv = wiphy_priv(wiphy); if (!pairwise) { - PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); - key_params.key = priv->wilc_gtk[key_index]->key; key_params.cipher = priv->wilc_gtk[key_index]->cipher; key_params.key_len = priv->wilc_gtk[key_index]->key_len; key_params.seq = priv->wilc_gtk[key_index]->seq; key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; - if (INFO) { - for (i = 0; i < key_params.key_len; i++) - PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]); - } } else { - PRINT_D(CFG80211_DBG, "Getting pairwise key\n"); - key_params.key = priv->wilc_ptk[key_index]->key; key_params.cipher = priv->wilc_ptk[key_index]->cipher; key_params.key_len = priv->wilc_ptk[key_index]->key_len; @@ -1337,8 +1181,6 @@ static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 ke priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index); - wilc_set_wep_default_keyid(vif, key_index); return 0; @@ -1356,10 +1198,6 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, vif = netdev_priv(dev); if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { - PRINT_D(HOSTAPD_DBG, "Getting station parameters\n"); - - PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]); - for (i = 0; i < NUM_STA_ASSOCIATED; i++) { if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { associatedsta = i; @@ -1376,7 +1214,6 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, wilc_get_inactive_time(vif, mac, &inactive_time); sinfo->inactive_time = 1000 * inactive_time; - PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time); } if (vif->iftype == STATION_MODE) { @@ -1408,14 +1245,13 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, static int change_bss(struct wiphy *wiphy, struct net_device *dev, struct bss_parameters *params) { - PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n"); return 0; } static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { s32 s32Error = 0; - struct cfg_param_val pstrCfgParamVal; + struct cfg_param_attr pstrCfgParamVal; struct wilc_priv *priv; struct wilc_vif *vif; @@ -1423,33 +1259,25 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) vif = netdev_priv(priv->dev); pstrCfgParamVal.flag = 0; - PRINT_D(CFG80211_DBG, "Setting Wiphy params\n"); if (changed & WIPHY_PARAM_RETRY_SHORT) { - PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", - priv->dev->ieee80211_ptr->wiphy->retry_short); pstrCfgParamVal.flag |= RETRY_SHORT; pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; } if (changed & WIPHY_PARAM_RETRY_LONG) { - PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long); pstrCfgParamVal.flag |= RETRY_LONG; pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; } if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { - PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold); pstrCfgParamVal.flag |= FRAG_THRESHOLD; pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; } if (changed & WIPHY_PARAM_RTS_THRESHOLD) { - PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold); - pstrCfgParamVal.flag |= RTS_THRESHOLD; pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; } - PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n"); s32Error = wilc_hif_set_cfg(vif, &pstrCfgParamVal); if (s32Error) netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); @@ -1467,19 +1295,16 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct wilc_priv *priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - PRINT_D(CFG80211_DBG, "Setting PMKSA\n"); for (i = 0; i < priv->pmkid_list.numpmkid; i++) { if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, ETH_ALEN)) { flag = PMKID_FOUND; - PRINT_D(CFG80211_DBG, "PMKID already exists\n"); break; } } if (i < WILC_MAX_NUM_PMKIDS) { - PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n"); memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, ETH_ALEN); memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, @@ -1491,10 +1316,9 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, s32Error = -EINVAL; } - if (!s32Error) { - PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n"); + if (!s32Error) s32Error = wilc_set_pmkid_info(vif, &priv->pmkid_list); - } + return s32Error; } @@ -1506,12 +1330,9 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct wilc_priv *priv = wiphy_priv(wiphy); - PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); - for (i = 0; i < priv->pmkid_list.numpmkid; i++) { if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, ETH_ALEN)) { - PRINT_D(CFG80211_DBG, "Reseting PMKID values\n"); memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid)); break; } @@ -1538,8 +1359,6 @@ static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) { struct wilc_priv *priv = wiphy_priv(wiphy); - PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); - memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr)); return 0; @@ -1795,8 +1614,6 @@ static int cancel_remain_on_channel(struct wiphy *wiphy, priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - PRINT_D(CFG80211_DBG, "Cancel remain on channel\n"); - s32Error = wilc_listen_state_expired(vif, priv->strRemainOnChanParams.u32ListenSessionID); return s32Error; } @@ -1979,7 +1796,6 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, s32 rssi_thold, u32 rssi_hyst) { - PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n"); return 0; } @@ -1989,8 +1805,6 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev, struct wilc_priv *priv; struct wilc_vif *vif; - PRINT_D(CFG80211_DBG, "Dumping station information\n"); - if (idx != 0) return -ENOENT; @@ -2010,8 +1824,6 @@ static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, struct wilc_priv *priv; struct wilc_vif *vif; - PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); - if (!wiphy) return -ENOENT; @@ -2037,9 +1849,6 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, vif = netdev_priv(dev); priv = wiphy_priv(wiphy); wl = vif->wilc; - - PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); - PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); p2p_local_random = 0x01; p2p_recv_random = 0x00; wilc_ie = false; @@ -2049,8 +1858,6 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, switch (type) { case NL80211_IFTYPE_STATION: wilc_connecting = 0; - PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); - dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; vif->monitor_flag = 0; @@ -2065,8 +1872,6 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, case NL80211_IFTYPE_P2P_CLIENT: wilc_connecting = 0; - PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); - dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; vif->monitor_flag = 0; @@ -2079,7 +1884,6 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, case NL80211_IFTYPE_AP: wilc_enable_ps = false; - PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; vif->iftype = AP_MODE; @@ -2096,8 +1900,6 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, wilc_optaining_ip = true; mod_timer(&wilc_during_ip_timer, jiffies + msecs_to_jiffies(during_ip_time)); - PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); - wilc_set_operation_mode(vif, AP_MODE); dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; @@ -2126,11 +1928,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); vif = netdev_priv(dev); - wl = vif ->wilc; - PRINT_D(HOSTAPD_DBG, "Starting ap\n"); - - PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n", - settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); + wl = vif->wilc; s32Error = set_channel(wiphy, &settings->chandef); @@ -2157,8 +1955,6 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); - s32Error = wilc_add_beacon(vif, 0, 0, beacon->head_len, (u8 *)beacon->head, beacon->tail_len, @@ -2180,8 +1976,6 @@ static int stop_ap(struct wiphy *wiphy, struct net_device *dev) priv = wiphy_priv(wiphy); vif = netdev_priv(priv->dev); - PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); - wilc_wlan_set_bssid(dev, NullBssid, AP_MODE); s32Error = wilc_del_beacon(vif); @@ -2213,14 +2007,6 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, strStaParams.rates_len = params->supported_rates_len; strStaParams.rates = params->supported_rates; - PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); - - PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4], - priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); - PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); - PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", - strStaParams.rates_len); - if (!params->ht_capa) { strStaParams.ht_supported = false; } else { @@ -2238,23 +2024,6 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, strStaParams.flags_mask = params->sta_flags_mask; strStaParams.flags_set = params->sta_flags_set; - PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", - strStaParams.ht_supported); - PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", - strStaParams.ht_capa_info); - PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", - strStaParams.ht_ampdu_params); - PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", - strStaParams.ht_ext_params); - PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", - strStaParams.ht_tx_bf_cap); - PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", - strStaParams.ht_ante_sel); - PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", - strStaParams.flags_mask); - PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", - strStaParams.flags_set); - s32Error = wilc_add_station(vif, &strStaParams); if (s32Error) netdev_err(dev, "Host add station fail\n"); @@ -2278,16 +2047,9 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, vif = netdev_priv(dev); if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { - PRINT_D(HOSTAPD_DBG, "Deleting station\n"); - - - if (!mac) { - PRINT_D(HOSTAPD_DBG, "All associated stations\n"); + if (!mac) s32Error = wilc_del_allstation(vif, priv->assoc_stainfo.au8Sta_AssociatedBss); - } else { - PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - } s32Error = wilc_del_station(vif, mac); @@ -2305,9 +2067,6 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, struct add_sta_param strStaParams = { {0} }; struct wilc_vif *vif; - - PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); - if (!wiphy) return -EFAULT; @@ -2320,14 +2079,6 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, strStaParams.rates_len = params->supported_rates_len; strStaParams.rates = params->supported_rates; - PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", - strStaParams.bssid[0], strStaParams.bssid[1], - strStaParams.bssid[2], strStaParams.bssid[3], - strStaParams.bssid[4], strStaParams.bssid[5]); - PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); - PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", - strStaParams.rates_len); - if (!params->ht_capa) { strStaParams.ht_supported = false; } else { @@ -2345,23 +2096,6 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, strStaParams.flags_mask = params->sta_flags_mask; strStaParams.flags_set = params->sta_flags_set; - PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", - strStaParams.ht_supported); - PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", - strStaParams.ht_capa_info); - PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", - strStaParams.ht_ampdu_params); - PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", - strStaParams.ht_ext_params); - PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", - strStaParams.ht_tx_bf_cap); - PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", - strStaParams.ht_ante_sel); - PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", - strStaParams.flags_mask); - PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", - strStaParams.flags_set); - s32Error = wilc_edit_station(vif, &strStaParams); if (s32Error) netdev_err(dev, "Host edit station fail\n"); @@ -2381,20 +2115,12 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, struct net_device *new_ifc = NULL; priv = wiphy_priv(wiphy); - - - - PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); - vif = netdev_priv(priv->wdev->netdev); if (type == NL80211_IFTYPE_MONITOR) { - PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); - PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", vif->ndev); new_ifc = WILC_WFI_init_mon_interface(name, vif->ndev); if (new_ifc) { - PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); vif = netdev_priv(priv->wdev->netdev); vif->monitor_flag = 1; } @@ -2404,7 +2130,6 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) { - PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); return 0; } @@ -2514,42 +2239,10 @@ static struct cfg80211_ops wilc_cfg80211_ops = { }; -int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) -{ - struct wilc_priv *priv; - - priv = wiphy_priv(wiphy); - switch (changed) { - case WILC_WFI_RX_PKT: - { - priv->netstats.rx_packets++; - priv->netstats.rx_bytes += pktlen; - priv->netstats.rx_time = get_jiffies_64(); - } - break; - - case WILC_WFI_TX_PKT: - { - priv->netstats.tx_packets++; - priv->netstats.tx_bytes += pktlen; - priv->netstats.tx_time = get_jiffies_64(); - - } - break; - - default: - break; - } - return 0; -} - static struct wireless_dev *WILC_WFI_CfgAlloc(void) { struct wireless_dev *wdev; - - PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); - wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (!wdev) goto _fail_; @@ -2580,8 +2273,6 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *de struct wireless_dev *wdev; s32 s32Error = 0; - PRINT_D(CFG80211_DBG, "Registering wifi device\n"); - wdev = WILC_WFI_CfgAlloc(); if (!wdev) { netdev_err(net, "wiphy new allocate failed\n"); @@ -2596,8 +2287,6 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *de wdev->wiphy->wowlan = &wowlan_support; #endif wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; - PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids); - wdev->wiphy->max_scan_ie_len = 1000; wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; wdev->wiphy->cipher_suites = cipher_suites; @@ -2610,19 +2299,11 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *de wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; wdev->iftype = NL80211_IFTYPE_STATION; - - - PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", - wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, - wdev->wiphy->interface_modes, wdev->iftype); - set_wiphy_dev(wdev->wiphy, dev); s32Error = wiphy_register(wdev->wiphy); if (s32Error) netdev_err(net, "Cannot register wiphy device\n"); - else - PRINT_D(CFG80211_DBG, "Successful Registering\n"); priv->dev = net; return wdev; @@ -2634,7 +2315,6 @@ int wilc_init_host_int(struct net_device *net) struct wilc_priv *priv; - PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); priv = wdev_priv(net->ieee80211_ptr); if (op_ifcs == 0) { setup_timer(&hAgingTimer, remove_network_from_shadow, 0); @@ -2683,26 +2363,17 @@ int wilc_deinit_host_int(struct net_device *net) void wilc_free_wiphy(struct net_device *net) { - PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); - - if (!net) { - PRINT_D(INIT_DBG, "net_device is NULL\n"); + if (!net) return; - } - if (!net->ieee80211_ptr) { - PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); + if (!net->ieee80211_ptr) return; - } - if (!net->ieee80211_ptr->wiphy) { - PRINT_D(INIT_DBG, "wiphy is NULL\n"); + if (!net->ieee80211_ptr->wiphy) return; - } wiphy_unregister(net->ieee80211_ptr->wiphy); - PRINT_D(INIT_DBG, "Freeing wiphy\n"); wiphy_free(net->ieee80211_ptr->wiphy); kfree(net->ieee80211_ptr); } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index ab53d9d..85a3810 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -12,7 +12,6 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *dev); void wilc_free_wiphy(struct net_device *net); -int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed); int wilc_deinit_host_int(struct net_device *net); int wilc_init_host_int(struct net_device *net); void WILC_WFI_monitor_rx(u8 *buff, u32 size); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 3077f5d4..4123cff 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -35,8 +35,6 @@ #include <linux/skbuff.h> #include <linux/ieee80211.h> #include <net/cfg80211.h> -#include <linux/ieee80211.h> -#include <net/cfg80211.h> #include <net/ieee80211_radiotap.h> #include <linux/if_arp.h> #include <linux/in6.h> @@ -228,8 +226,6 @@ int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif); void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_mac_indicate(struct wilc *wilc, int flag); -void wilc_dbg(u8 *buff); - int wilc_lock_timeout(struct wilc *wilc, void *, u32 timeout); void wilc_netdev_cleanup(struct wilc *wilc); int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int gpio, diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index a396ac9..0020620 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -3,23 +3,6 @@ #include "wilc_wfi_netdevice.h" #include "wilc_wlan_cfg.h" -static u32 dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ; - -/* FIXME: replace with dev_debug() */ -static void wilc_debug(u32 flag, char *fmt, ...) -{ - char buf[256]; - va_list args; - - if (flag & dbgflag) { - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); - - wilc_dbg(buf); - } -} - static CHIP_PS_STATE_T chip_ps_state = CHIP_WAKEDUP; static inline void acquire_bus(struct wilc *wilc, BUS_ACQUIRE_T acquire) @@ -38,7 +21,6 @@ static inline void release_bus(struct wilc *wilc, BUS_RELEASE_T release) static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) { - if (tqe == wilc->txq_head) { wilc->txq_head = tqe->next; if (wilc->txq_head) @@ -157,7 +139,6 @@ struct pending_acks_info { struct txq_entry_t *txqe; }; - #define NOT_TCP_ACK (-1) #define MAX_TCP_SESSION 25 @@ -207,9 +188,8 @@ static inline int add_tcp_pending_ack(u32 ack, u32 session_index, return 0; } -static inline int tcp_process(struct net_device *dev, struct txq_entry_t *tqe) +static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) { - int ret; u8 *eth_hdr_ptr; u8 *buffer = tqe->buffer; unsigned short h_proto; @@ -266,15 +246,9 @@ static inline int tcp_process(struct net_device *dev, struct txq_entry_t *tqe) add_tcp_pending_ack(ack_no, i, tqe); } - - } else { - ret = 0; } - } else { - ret = 0; } spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - return ret; } static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) @@ -325,7 +299,7 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) return 1; } -static bool enabled = false; +static bool enabled; void wilc_enable_tcp_ack_filter(bool value) { @@ -452,7 +426,6 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) { - if (wilc->quit) return 0; @@ -473,7 +446,6 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) { - if (wilc->rxq_head) { struct rxq_entry_t *rqe; @@ -500,7 +472,7 @@ EXPORT_SYMBOL_GPL(chip_allow_sleep); void chip_wakeup(struct wilc *wilc) { - u32 reg, clk_status_reg, trials = 0; + u32 reg, clk_status_reg; if ((wilc->io_type & 0x1) == HIF_SPI) { do { @@ -510,11 +482,8 @@ void chip_wakeup(struct wilc *wilc) do { usleep_range(2 * 1000, 2 * 1000); - if ((wilc_get_chipid(wilc, true) == 0)) - wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n"); - - } while ((wilc_get_chipid(wilc, true) == 0) && ((++trials % 3) == 0)); - + wilc_get_chipid(wilc, true); + } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); } else if ((wilc->io_type & 0x1) == HIF_SDIO) { wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); @@ -526,14 +495,11 @@ void chip_wakeup(struct wilc *wilc) wilc->hif_func->hif_read_reg(wilc, 0xf1, &clk_status_reg); - while (((clk_status_reg & 0x1) == 0) && (((++trials) % 3) == 0)) { + while ((clk_status_reg & 0x1) == 0) { usleep_range(2 * 1000, 2 * 1000); wilc->hif_func->hif_read_reg(wilc, 0xf1, &clk_status_reg); - - if ((clk_status_reg & 0x1) == 0) - wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n"); } if ((clk_status_reg & 0x1) == 0) { wilc->hif_func->hif_write_reg(wilc, 0xf0, @@ -1028,7 +994,6 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, ret = -EIO; goto _fail_; } - PRINT_D(INIT_DBG, "Offset = %d\n", offset); } while (offset < buffer_size); _fail_: @@ -1117,12 +1082,6 @@ int wilc_wlan_start(struct wilc *wilc) return (ret < 0) ? ret : 0; } -void wilc_wlan_global_reset(struct wilc *wilc) -{ - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); - wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, 0x0); - release_bus(wilc, RELEASE_ONLY); -} int wilc_wlan_stop(struct wilc *wilc) { u32 reg = 0; @@ -1342,11 +1301,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u32 wid, int commit, int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size) { - int ret; - - ret = wilc_wlan_cfg_get_wid_value((u16)wid, buffer, buffer_size); - - return ret; + return wilc_wlan_cfg_get_wid_value((u16)wid, buffer, buffer_size); } int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, @@ -1404,18 +1359,18 @@ static u32 init_chip(struct net_device *dev) if ((chipid & 0xfff) != 0xa0) { ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®); if (!ret) { - wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n"); + netdev_err(dev, "fail read reg 0x1118\n"); return ret; } reg |= BIT(0); ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); if (!ret) { - wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n"); + netdev_err(dev, "fail write reg 0x1118\n"); return ret; } ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); if (!ret) { - wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc0000 ...\n"); + netdev_err(dev, "fail write reg 0xc0000\n"); return ret; } } @@ -1461,8 +1416,6 @@ int wilc_wlan_init(struct net_device *dev) wilc = vif->wilc; - PRINT_D(INIT_DBG, "Initializing WILC_Wlan ...\n"); - wilc->quit = 0; if (!wilc->hif_func->hif_init(wilc, false)) { @@ -1470,7 +1423,7 @@ int wilc_wlan_init(struct net_device *dev) goto _fail_; } - if (!wilc_wlan_cfg_init(wilc_debug)) { + if (!wilc_wlan_cfg_init()) { ret = -ENOBUFS; goto _fail_; } @@ -1480,7 +1433,6 @@ int wilc_wlan_init(struct net_device *dev) if (!wilc->tx_buffer) { ret = -ENOBUFS; - PRINT_ER("Can't allocate Tx Buffer"); goto _fail_; } @@ -1489,7 +1441,6 @@ int wilc_wlan_init(struct net_device *dev) if (!wilc->rx_buffer) { ret = -ENOBUFS; - PRINT_ER("Can't allocate Rx Buffer"); goto _fail_; } diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index 06d02ab..bcd4bfa 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -128,6 +128,11 @@ #define WILC_PLL_TO_SPI 2 #define ABORT_INT BIT(31) +#define LINUX_RX_SIZE (96 * 1024) +#define LINUX_TX_SIZE (64 * 1024) + +#define MODALIAS "WILC_SPI" +#define GPIO_NUM 0x44 /*******************************************/ /* E0 and later Interrupt flags. */ /*******************************************/ diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index 2bb684a..b992243 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -19,9 +19,7 @@ * ********************************************/ -typedef struct { - wilc_debug_func dPrint; - +struct wilc_mac_cfg { int mac_status; u8 mac_address[7]; u8 ip_address[5]; @@ -40,11 +38,11 @@ typedef struct { u8 firmware_info[8]; u8 scan_result[256]; u8 scan_result1[256]; -} wilc_mac_cfg_t; +}; -static wilc_mac_cfg_t g_mac; +static struct wilc_mac_cfg g_mac; -static wilc_cfg_byte_t g_cfg_byte[] = { +static struct wilc_cfg_byte g_cfg_byte[] = { {WID_BSS_TYPE, 0}, {WID_CURRENT_TX_RATE, 0}, {WID_CURRENT_CHANNEL, 0}, @@ -87,7 +85,7 @@ static wilc_cfg_byte_t g_cfg_byte[] = { {WID_NIL, 0} }; -static wilc_cfg_hword_t g_cfg_hword[] = { +static struct wilc_cfg_hword g_cfg_hword[] = { {WID_LINK_LOSS_THRESHOLD, 0}, {WID_RTS_THRESHOLD, 0}, {WID_FRAG_THRESHOLD, 0}, @@ -108,7 +106,7 @@ static wilc_cfg_hword_t g_cfg_hword[] = { {WID_NIL, 0} }; -static wilc_cfg_word_t g_cfg_word[] = { +static struct wilc_cfg_word g_cfg_word[] = { {WID_FAILED_COUNT, 0}, {WID_RETRY_COUNT, 0}, {WID_MULTIPLE_RETRY_COUNT, 0}, @@ -131,7 +129,7 @@ static wilc_cfg_word_t g_cfg_word[] = { }; -static wilc_cfg_str_t g_cfg_str[] = { +static struct wilc_cfg_str g_cfg_str[] = { {WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */ {WID_FIRMWARE_VERSION, g_mac.firmware_version}, {WID_OPERATIONAL_RATE_SET, g_mac.supp_rate}, @@ -349,7 +347,7 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size) static int wilc_wlan_parse_info_frame(u8 *info, int size) { - wilc_mac_cfg_t *pd = &g_mac; + struct wilc_mac_cfg *pd = &g_mac; u32 wid, len; int type = WILC_CFG_RSP_STATUS; @@ -389,8 +387,6 @@ int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size) ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); } else if (type == 4) { /* binary command */ ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); - } else { - g_mac.dPrint(N_ERR, "illegal id\n"); } return ret; @@ -481,8 +477,6 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i++; } while (1); - } else { - g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid); } return ret; @@ -537,9 +531,8 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, return ret; } -int wilc_wlan_cfg_init(wilc_debug_func func) +int wilc_wlan_cfg_init(void) { - memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t)); - g_mac.dPrint = func; + memset((void *)&g_mac, 0, sizeof(struct wilc_mac_cfg)); return 1; } diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h index 5f74eb8..b8641a2 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.h +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h @@ -10,25 +10,25 @@ #ifndef WILC_WLAN_CFG_H #define WILC_WLAN_CFG_H -typedef struct { +struct wilc_cfg_byte { u16 id; u16 val; -} wilc_cfg_byte_t; +}; -typedef struct { +struct wilc_cfg_hword { u16 id; u16 val; -} wilc_cfg_hword_t; +}; -typedef struct { +struct wilc_cfg_word { u32 id; u32 val; -} wilc_cfg_word_t; +}; -typedef struct { +struct wilc_cfg_str { u32 id; u8 *str; -} wilc_cfg_str_t; +}; struct wilc; int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size); @@ -36,6 +36,6 @@ int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id); int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size); int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, struct wilc_cfg_rsp *rsp); -int wilc_wlan_cfg_init(wilc_debug_func func); +int wilc_wlan_cfg_init(void); #endif diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 269c56e..fbe34eb 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -11,7 +11,6 @@ #define WILC_WLAN_IF_H #include <linux/semaphore.h> -#include "linux_wlan_common.h" #include <linux/netdevice.h> /******************************************** @@ -95,7 +94,7 @@ typedef void (*wilc_tx_complete_func_t)(void *, int); * Wlan Configuration ID * ********************************************/ - +#define WILC_MULTICAST_TABLE_SIZE 8 #define MAX_SSID_LEN 33 #define MAX_RATES_SUPPORTED 12 diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 8dfe438..cec6d0b 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1360,7 +1360,6 @@ void hfa384x_destroy(hfa384x_t *hw); int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis); -int hfa384x_drvr_commtallies(hfa384x_t *hw); int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport); int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport); int hfa384x_drvr_flashdl_enable(hfa384x_t *hw); @@ -1391,10 +1390,6 @@ static inline int hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val) } int -hfa384x_drvr_getconfig_async(hfa384x_t *hw, - u16 rid, ctlx_usercb_t usercb, void *usercb_data); - -int hfa384x_drvr_setconfig_async(hfa384x_t *hw, u16 rid, void *buf, diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index fda8a95..09b4b2c 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -213,8 +213,6 @@ unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); static void hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx); -static void hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx); - static int usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp, hfa384x_cmdresult_t *result); @@ -816,43 +814,6 @@ static void hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx) } } -/*---------------------------------------------------------------- -* hfa384x_cb_rrid -* -* CTLX completion handler for async RRID type control exchanges. -* -* Note: If the handling is changed here, it should probably be -* changed in dorrid as well. -* -* Arguments: -* hw hw struct -* ctlx completed CTLX -* -* Returns: -* nothing -* -* Side effects: -* -* Call context: -* interrupt -----------------------------------------------------------------*/ -static void hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx) -{ - if (ctlx->usercb != NULL) { - hfa384x_rridresult_t rridresult; - - if (ctlx->state != CTLX_COMPLETE) { - memset(&rridresult, 0, sizeof(rridresult)); - rridresult.rid = le16_to_cpu(ctlx->outbuf.rridreq.rid); - } else { - usbctlx_get_rridresult(&ctlx->inbuf.rridresp, - &rridresult); - } - - ctlx->usercb(hw, &rridresult, ctlx->usercb_data); - } -} - static inline int hfa384x_docmd_wait(hfa384x_t *hw, hfa384x_metacmd_t *cmd) { return hfa384x_docmd(hw, DOWAIT, cmd, NULL, NULL, NULL); @@ -1735,37 +1696,6 @@ done: } /*---------------------------------------------------------------- -* hfa384x_drvr_commtallies -* -* Send a commtallies inquiry to the MAC. Note that this is an async -* call that will result in an info frame arriving sometime later. -* -* Arguments: -* hw device structure -* -* Returns: -* zero success. -* -* Side effects: -* -* Call context: -* process -----------------------------------------------------------------*/ -int hfa384x_drvr_commtallies(hfa384x_t *hw) -{ - hfa384x_metacmd_t cmd; - - cmd.cmd = HFA384x_CMDCODE_INQ; - cmd.parm0 = HFA384x_IT_COMMTALLIES; - cmd.parm1 = 0; - cmd.parm2 = 0; - - hfa384x_docmd_async(hw, &cmd, NULL, NULL, NULL); - - return 0; -} - -/*---------------------------------------------------------------- * hfa384x_drvr_disable * * Issues the disable command to stop communications on one of @@ -2110,41 +2040,6 @@ int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len) } /*---------------------------------------------------------------- - * hfa384x_drvr_getconfig_async - * - * Performs the sequence necessary to perform an async read of - * of a config/info item. - * - * Arguments: - * hw device structure - * rid config/info record id (host order) - * buf host side record buffer. Upon return it will - * contain the body portion of the record (minus the - * RID and len). - * len buffer length (in bytes, should match record length) - * cbfn caller supplied callback, called when the command - * is done (successful or not). - * cbfndata pointer to some caller supplied data that will be - * passed in as an argument to the cbfn. - * - * Returns: - * nothing the cbfn gets a status argument identifying if - * any errors occur. - * Side effects: - * Queues an hfa384x_usbcmd_t for subsequent execution. - * - * Call context: - * Any - ----------------------------------------------------------------*/ -int -hfa384x_drvr_getconfig_async(hfa384x_t *hw, - u16 rid, ctlx_usercb_t usercb, void *usercb_data) -{ - return hfa384x_dorrid_async(hw, rid, NULL, 0, - hfa384x_cb_rrid, usercb, usercb_data); -} - -/*---------------------------------------------------------------- * hfa384x_drvr_setconfig_async * * Performs the sequence necessary to write a config/info item. diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index a9c1e0b..88255ce 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -328,7 +328,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, p80211_wep.data = NULL; - if (skb == NULL) + if (!skb) return NETDEV_TX_OK; if (wlandev->state != WLAN_DEVICE_OPEN) { @@ -388,7 +388,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, goto failed; } } - if (wlandev->txframe == NULL) { + if (!wlandev->txframe) { result = 1; goto failed; } @@ -736,7 +736,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev) /* Allocate and initialize the wiphy struct */ wiphy = wlan_create_wiphy(physdev, wlandev); - if (wiphy == NULL) { + if (!wiphy) { dev_err(physdev, "Failed to alloc wiphy.\n"); return 1; } @@ -744,7 +744,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev) /* Allocate and initialize the struct device */ netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", NET_NAME_UNKNOWN, ether_setup); - if (netdev == NULL) { + if (!netdev) { dev_err(physdev, "Failed to alloc netdev.\n"); wlan_free_wiphy(wiphy); result = 1; diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 194f67e..ae6a53c 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -177,7 +177,8 @@ static void prism2sta_disconnect_usb(struct usb_interface *interface) tasklet_kill(&hw->completion_bh); tasklet_kill(&hw->reaper_bh); - flush_scheduled_work(); + cancel_work_sync(&hw->link_bh); + cancel_work_sync(&hw->commsqual_bh); /* Now we complete any outstanding commands * and tell everyone who is waiting for their |