Skip to content

Commit

Permalink
[PATCH] gfp flags annotations - part 1
Browse files Browse the repository at this point in the history
 - added typedef unsigned int __nocast gfp_t;

 - replaced __nocast uses for gfp flags with gfp_t - it gives exactly
   the same warnings as far as sparse is concerned, doesn't change
   generated code (from gcc point of view we replaced unsigned int with
   typedef) and documents what's going on far better.

Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Al Viro authored and Linus Torvalds committed Oct 8, 2005
1 parent 3b0e77b commit dd0fc66
Show file tree
Hide file tree
Showing 145 changed files with 340 additions and 360 deletions.
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/pci/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct dma_coherent_mem {
};

void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast gfp)
dma_addr_t *dma_handle, gfp_t gfp)
{
void *ret;
struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct dma_coherent_mem {
};

void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast gfp)
dma_addr_t *dma_handle, gfp_t gfp)
{
void *ret;
struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/bpa_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void bpa_map_iommu(void)


static void *bpa_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
void *ret;

Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
EXPORT_SYMBOL(dma_set_mask);

void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
struct dma_mapping_ops *dma_ops = get_dma_ops(dev);

Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
* to the dma address (mapping) of the first page.
*/
void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
void *ret = NULL;
dma_addr_t mapping;
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/pci_direct_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "pci.h"

static void *pci_direct_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
void *ret;

Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/pci_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static inline struct iommu_table *devnode_table(struct device *dev)
* to the dma address (mapping) of the first page.
*/
static void *pci_iommu_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
return iommu_alloc_coherent(devnode_table(hwdev), size, dma_handle,
flag);
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc64/kernel/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
}

static void *vio_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, unsigned int __nocast flag)
dma_addr_t *dma_handle, gfp_t flag)
{
return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
dma_handle, flag);
Expand Down
2 changes: 1 addition & 1 deletion drivers/atm/ambassador.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ static void drain_rx_pools (amb_dev * dev) {
}

static inline void fill_rx_pool (amb_dev * dev, unsigned char pool,
unsigned int __nocast priority)
gfp_t priority)
{
rx_in rx;
amb_rxq * rxq;
Expand Down
5 changes: 2 additions & 3 deletions drivers/atm/firestream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,7 @@ static void reset_chip (struct fs_dev *dev)
}
}

static void __devinit *aligned_kmalloc (int size, unsigned int __nocast flags,
int alignment)
static void __devinit *aligned_kmalloc (int size, gfp_t flags, int alignment)
{
void *t;

Expand Down Expand Up @@ -1466,7 +1465,7 @@ static inline int nr_buffers_in_freepool (struct fs_dev *dev, struct freepool *f
working again after that... -- REW */

static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
unsigned int __nocast gfp_flags)
gfp_t gfp_flags)
{
struct FS_BPENTRY *qe, *ne;
struct sk_buff *skb;
Expand Down
2 changes: 1 addition & 1 deletion drivers/atm/fore200e.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fore200e_irq_itoa(int irq)


static void*
fore200e_kmalloc(int size, unsigned int __nocast flags)
fore200e_kmalloc(int size, gfp_t flags)
{
void *chunk = kzalloc(size, flags);

Expand Down
5 changes: 2 additions & 3 deletions drivers/base/dmapool.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ dma_pool_create (const char *name, struct device *dev,


static struct dma_page *
pool_alloc_page (struct dma_pool *pool, unsigned int __nocast mem_flags)
pool_alloc_page (struct dma_pool *pool, gfp_t mem_flags)
{
struct dma_page *page;
int mapsize;
Expand Down Expand Up @@ -262,8 +262,7 @@ dma_pool_destroy (struct dma_pool *pool)
* If such a memory block can't be allocated, null is returned.
*/
void *
dma_pool_alloc (struct dma_pool *pool, unsigned int __nocast mem_flags,
dma_addr_t *handle)
dma_pool_alloc (struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle)
{
unsigned long flags;
struct dma_page *page;
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets)
return 1;
}

static void *pkt_rb_alloc(unsigned int __nocast gfp_mask, void *data)
static void *pkt_rb_alloc(gfp_t gfp_mask, void *data)
{
return kmalloc(sizeof(struct pkt_rb_node), gfp_mask);
}
Expand Down Expand Up @@ -2082,7 +2082,7 @@ static int pkt_close(struct inode *inode, struct file *file)
}


static void *psd_pool_alloc(unsigned int __nocast gfp_mask, void *data)
static void *psd_pool_alloc(gfp_t gfp_mask, void *data)
{
return kmalloc(sizeof(struct packet_stacked_data), gfp_mask);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/bpa10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void bpa10x_complete(struct urb *urb, struct pt_regs *regs)
}

static inline struct urb *bpa10x_alloc_urb(struct usb_device *udev, unsigned int pipe,
size_t size, unsigned int __nocast flags, void *data)
size_t size, gfp_t flags, void *data)
{
struct urb *urb;
struct usb_ctrlrequest *cr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static struct usb_device_id blacklist_ids[] = {
{ } /* Terminating entry */
};

static struct _urb *_urb_alloc(int isoc, unsigned int __nocast gfp)
static struct _urb *_urb_alloc(int isoc, gfp_t gfp)
{
struct _urb *_urb = kmalloc(sizeof(struct _urb) +
sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
Expand Down
3 changes: 1 addition & 2 deletions drivers/connector/connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ int cn_already_initialized = 0;
* a new message.
*
*/
int cn_netlink_send(struct cn_msg *msg, u32 __group,
unsigned int __nocast gfp_mask)
int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
{
struct cn_callback_entry *__cbq;
unsigned int size;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ieee1394/raw1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static struct hpsb_address_ops arm_ops = {

static void queue_complete_cb(struct pending_request *req);

static struct pending_request *__alloc_pending_request(unsigned int __nocast flags)
static struct pending_request *__alloc_pending_request(gfp_t flags)
{
struct pending_request *req;

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
u32 remote_qpn, u16 pkey_index,
struct ib_ah *ah, int rmpp_active,
int hdr_len, int data_len,
unsigned int __nocast gfp_mask)
gfp_t gfp_mask)
{
struct ib_mad_agent_private *mad_agent_priv;
struct ib_mad_send_buf *send_buf;
Expand Down
6 changes: 3 additions & 3 deletions drivers/infiniband/core/sa_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ static void ib_sa_path_rec_release(struct ib_sa_query *sa_query)
int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
struct ib_sa_path_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, unsigned int __nocast gfp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_path_rec *resp,
void *context),
Expand Down Expand Up @@ -676,7 +676,7 @@ static void ib_sa_service_rec_release(struct ib_sa_query *sa_query)
int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
struct ib_sa_service_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, unsigned int __nocast gfp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_service_rec *resp,
void *context),
Expand Down Expand Up @@ -759,7 +759,7 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
u8 method,
struct ib_sa_mcmember_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, unsigned int __nocast gfp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_mcmember_rec *resp,
void *context),
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static kmem_cache_t *_crypt_io_pool;
/*
* Mempool alloc and free functions for the page
*/
static void *mempool_alloc_page(unsigned int __nocast gfp_mask, void *data)
static void *mempool_alloc_page(gfp_t gfp_mask, void *data)
{
return alloc_page(gfp_mask);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct io {
static unsigned _num_ios;
static mempool_t *_io_pool;

static void *alloc_io(unsigned int __nocast gfp_mask, void *pool_data)
static void *alloc_io(gfp_t gfp_mask, void *pool_data)
{
return kmalloc(sizeof(struct io), gfp_mask);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static inline sector_t region_to_sector(struct region_hash *rh, region_t region)
/* FIXME move this */
static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw);

static void *region_alloc(unsigned int __nocast gfp_mask, void *pool_data)
static void *region_alloc(gfp_t gfp_mask, void *pool_data)
{
return kmalloc(sizeof(struct region), gfp_mask);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static mdk_personality_t multipath_personality;


static void *mp_pool_alloc(unsigned int __nocast gfp_flags, void *data)
static void *mp_pool_alloc(gfp_t gfp_flags, void *data)
{
struct multipath_bh *mpb;
mpb = kmalloc(sizeof(*mpb), gfp_flags);
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static mdk_personality_t raid1_personality;
static void unplug_slaves(mddev_t *mddev);


static void * r1bio_pool_alloc(unsigned int __nocast gfp_flags, void *data)
static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
{
struct pool_info *pi = data;
r1bio_t *r1_bio;
Expand All @@ -79,7 +79,7 @@ static void r1bio_pool_free(void *r1_bio, void *data)
#define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
#define RESYNC_WINDOW (2048*1024)

static void * r1buf_pool_alloc(unsigned int __nocast gfp_flags, void *data)
static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
{
struct pool_info *pi = data;
struct page *page;
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

static void unplug_slaves(mddev_t *mddev);

static void * r10bio_pool_alloc(unsigned int __nocast gfp_flags, void *data)
static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
{
conf_t *conf = data;
r10bio_t *r10_bio;
Expand Down Expand Up @@ -81,7 +81,7 @@ static void r10bio_pool_free(void *r10_bio, void *data)
* one for write (we recover only one drive per r10buf)
*
*/
static void * r10buf_pool_alloc(unsigned int __nocast gfp_flags, void *data)
static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
{
conf_t *conf = data;
struct page *page;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ static void bond_mc_list_destroy(struct bonding *bond)
* Copy all the Multicast addresses from src to the bonding device dst
*/
static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
unsigned int __nocast gfp_flag)
gfp_t gfp_flag)
{
struct dev_mc_list *dmi, *new_dmi;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ns83820.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
return 0;
}

static inline int rx_refill(struct net_device *ndev, unsigned int __nocast gfp)
static inline int rx_refill(struct net_device *ndev, gfp_t gfp)
{
struct ns83820 *dev = PRIV(ndev);
unsigned i;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/sungem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ struct gem {
#define ALIGNED_RX_SKB_ADDR(addr) \
((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr))
static __inline__ struct sk_buff *gem_alloc_skb(int size,
unsigned int __nocast gfp_flags)
gfp_t gfp_flags)
{
struct sk_buff *skb = alloc_skb(size + 64, gfp_flags);

Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/scsi/zfcp_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ zfcp_unit_dequeue(struct zfcp_unit *unit)
}

static void *
zfcp_mempool_alloc(unsigned int __nocast gfp_mask, void *size)
zfcp_mempool_alloc(gfp_t gfp_mask, void *size)
{
return kmalloc((size_t) size, gfp_mask);
}
Expand Down
10 changes: 5 additions & 5 deletions fs/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct bio_set {
*/
static struct bio_set *fs_bio_set;

static inline struct bio_vec *bvec_alloc_bs(unsigned int __nocast gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
{
struct bio_vec *bvl;
struct biovec_slab *bp;
Expand Down Expand Up @@ -155,7 +155,7 @@ inline void bio_init(struct bio *bio)
* allocate bio and iovecs from the memory pools specified by the
* bio_set structure.
**/
struct bio *bio_alloc_bioset(unsigned int __nocast gfp_mask, int nr_iovecs, struct bio_set *bs)
struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
{
struct bio *bio = mempool_alloc(bs->bio_pool, gfp_mask);

Expand All @@ -181,7 +181,7 @@ struct bio *bio_alloc_bioset(unsigned int __nocast gfp_mask, int nr_iovecs, stru
return bio;
}

struct bio *bio_alloc(unsigned int __nocast gfp_mask, int nr_iovecs)
struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)
{
struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);

Expand Down Expand Up @@ -277,7 +277,7 @@ inline void __bio_clone(struct bio *bio, struct bio *bio_src)
*
* Like __bio_clone, only also allocates the returned bio
*/
struct bio *bio_clone(struct bio *bio, unsigned int __nocast gfp_mask)
struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
{
struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set);

Expand Down Expand Up @@ -1078,7 +1078,7 @@ struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, int first_sectors)
return bp;
}

static void *bio_pair_alloc(unsigned int __nocast gfp_flags, void *data)
static void *bio_pair_alloc(gfp_t gfp_flags, void *data)
{
return kmalloc(sizeof(struct bio_pair), gfp_flags);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,7 @@ static void recalc_bh_state(void)
buffer_heads_over_limit = (tot > max_buffer_heads);
}

struct buffer_head *alloc_buffer_head(unsigned int __nocast gfp_flags)
struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
{
struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
if (ret) {
Expand Down
2 changes: 1 addition & 1 deletion fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static struct bio *mpage_bio_submit(int rw, struct bio *bio)
static struct bio *
mpage_alloc(struct block_device *bdev,
sector_t first_sector, int nr_vecs,
unsigned int __nocast gfp_flags)
gfp_t gfp_flags)
{
struct bio *bio;

Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* Depending on @gfp_mask the allocation may be guaranteed to succeed.
*/
static inline void *__ntfs_malloc(unsigned long size,
unsigned int __nocast gfp_mask)
gfp_t gfp_mask)
{
if (likely(size <= PAGE_SIZE)) {
BUG_ON(!size);
Expand Down
Loading

0 comments on commit dd0fc66

Please sign in to comment.