From: Keir Fraser Date: Wed, 24 Feb 2010 11:05:02 +0000 (+0000) Subject: Provide a variant of __RING_SIZE() that is an integer constant X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5f6e276a574cfbcb9ae6b7f0a2a26448651930da;p=legacy%2Flinux-2.6.18-xen.git Provide a variant of __RING_SIZE() that is an integer constant expression Without that, gcc 4.5 won't compile (at least) netfront, where this is being used to specify array sizes. Signed-off-by: Jan Beulich --- diff --git a/drivers/xen/blkfront/block.h b/drivers/xen/blkfront/block.h index a50be77e..df5a43cd 100644 --- a/drivers/xen/blkfront/block.h +++ b/drivers/xen/blkfront/block.h @@ -87,7 +87,7 @@ struct blk_shadow { unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; }; -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE) +#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) /* * We have one of these per vbd, whether ide, scsi or 'other'. They diff --git a/drivers/xen/blktap/blktap.c b/drivers/xen/blktap/blktap.c index eec9f6eb..ab857435 100644 --- a/drivers/xen/blktap/blktap.c +++ b/drivers/xen/blktap/blktap.c @@ -70,7 +70,7 @@ * mmap_alloc is initialised to 2 and should be adjustable on the fly via * sysfs. */ -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE) +#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) #define MAX_DYNAMIC_MEM BLK_RING_SIZE #define MAX_PENDING_REQS BLK_RING_SIZE #define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST) diff --git a/drivers/xen/blktap2/blktap.h b/drivers/xen/blktap2/blktap.h index 5e616f4e..d691bdf4 100644 --- a/drivers/xen/blktap2/blktap.h +++ b/drivers/xen/blktap2/blktap.h @@ -69,7 +69,7 @@ extern int blktap_debug_level; * mmap_alloc is initialised to 2 and should be adjustable on the fly via * sysfs. */ -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE) +#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) #define MAX_DYNAMIC_MEM BLK_RING_SIZE #define MAX_PENDING_REQS BLK_RING_SIZE #define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST) diff --git a/drivers/xen/netback/common.h b/drivers/xen/netback/common.h index a93e6f77..57056938 100644 --- a/drivers/xen/netback/common.h +++ b/drivers/xen/netback/common.h @@ -177,8 +177,8 @@ extern void netif_accel_init(void); -#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) -#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) +#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE) +#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE) void netif_disconnect(netif_t *netif); diff --git a/drivers/xen/netfront/netfront.h b/drivers/xen/netfront/netfront.h index 72d0183e..1279365b 100644 --- a/drivers/xen/netfront/netfront.h +++ b/drivers/xen/netfront/netfront.h @@ -38,8 +38,8 @@ #include #include -#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE) -#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE) +#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE) +#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE) #include diff --git a/drivers/xen/scsifront/common.h b/drivers/xen/scsifront/common.h index 3b5ce144..5fd050ce 100644 --- a/drivers/xen/scsifront/common.h +++ b/drivers/xen/scsifront/common.h @@ -70,8 +70,7 @@ #define VSCSIIF_MAX_TARGET 64 #define VSCSIIF_MAX_LUN 255 -#define VSCSIIF_RING_SIZE \ - __RING_SIZE((struct vscsiif_sring *)0, PAGE_SIZE) +#define VSCSIIF_RING_SIZE __CONST_RING_SIZE(vscsiif, PAGE_SIZE) #define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE struct vscsifrnt_shadow { diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h index 3c56bc2d..0880b1c5 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h @@ -50,6 +50,12 @@ typedef unsigned int RING_IDX; * A ring contains as many entries as will fit, rounded down to the nearest * power of two (so we can mask with (size-1) to loop around). */ +#define __CONST_RING_SIZE(_s, _sz) \ + (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ + sizeof(((struct _s##_sring *)0)->ring[0]))) +/* + * The same for passing in an actual pointer instead of a name tag. + */ #define __RING_SIZE(_s, _sz) \ (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) diff --git a/include/xen/interface/io/usbif.h b/include/xen/interface/io/usbif.h index 91e82b88..6099c29b 100644 --- a/include/xen/interface/io/usbif.h +++ b/include/xen/interface/io/usbif.h @@ -128,7 +128,7 @@ struct usbif_urb_response { typedef struct usbif_urb_response usbif_urb_response_t; DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request, struct usbif_urb_response); -#define USB_URB_RING_SIZE __RING_SIZE((struct usbif_urb_sring *)0, PAGE_SIZE) +#define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE) /* * RING for notifying connect/disconnect events to frontend @@ -146,6 +146,6 @@ struct usbif_conn_response { typedef struct usbif_conn_response usbif_conn_response_t; DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request, struct usbif_conn_response); -#define USB_CONN_RING_SIZE __RING_SIZE((struct usbif_conn_sring *)0, PAGE_SIZE) +#define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE) #endif /* __XEN_PUBLIC_IO_USBIF_H__ */